Main Interface¶
CTSChamber¶
- class CTSChamber(serial_device: str | None = None, ascii_protocol_address: int | None = None, resource_path: str | None = None, resource_manager: ResourceManager | None = None, communication_timeout: int | None = None, communication_retries: int | None = 3, chamber_model: CTSChamberModel | None = None)[source]¶
Bases:
objectImplements the control of a CTS environmental chamber.
- Parameters:
serial_device (Optional[str]) – The serial device to use for communication, in case RS-232 or USB (via an adapter) is used. Cannot be used together with resource_path. Default is
None.resource_path (Optional[str]) – The resource path to use for communication. Cannot be used together with serial_device. Default is
None.resource_manager (Optional[pyvisa.ResourceManager]) – The resource manager to use for communication. If
None, a new resource manager will be created. Default isNone.ascii_protocol_address (Optional[int]) – The ASCII protocol address to use for communication. Default is 0x81. Must be between 0x81 and 0xA0.
communication_timeout (Optional[int]) – The communication timeout in milliseconds. Default is 1000.
communication_retries (Optional[int]) – The number of retries for communication. Default is 3.
chamber_model (Optional[cts_chamber.CTSChamberModel]) – The model of the CTS environmental chamber. If
None, the cts_chamber.CTSChamberModel.C_40 model will be used. Default isNone.
- Raises:
CTSChamberCommunicationError – If the connection to the device cannot be established.
The main class for controlling CTS environmental chambers. This class provides methods for setting temperature and humidity, reading chamber state, and managing ramp operations.
Key Features:
Temperature and humidity control
State monitoring and error detection
Ramp parameter management
Communication via RS-232
Support for multiple CTS chamber models
Example Usage:
from cts_chamber import CTSChamber, CTSChamberModel # Connect to chamber via serial port chamber = CTSChamber( serial_device="/dev/ttyUSB0", ) # Set temperature and humidity chamber.set_temperature(25.0) chamber.set_humidity(50.0) # Read current temperature and temperature setpoint current, set_point = chamber.get_temperature() print(f"Current temperture is {current} °C") print(f"Setpoint is {set_point} °C")
- DEFAULT_ASCII_PROTOCOL_ADDRESS = 129¶
Default ASCII protocol address for the device.
- DEFAULT_CHAMBER_MODEL = 'C-40'¶
Default model of the CTS environmental chamber.
- DEFAULT_COMMUNICATION_TIMEOUT = 1000¶
Default communication timeout in milliseconds.
- collect_errors() None[source]¶
Collects errors from the CTS chamber. Errors are available in the state after calling this method.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- get_humidity() Tuple[float, float][source]¶
Gets the current humidity and set humidity from the CTS chamber.
- Returns:
A tuple containing the current humidity and the set humidity.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
- get_humidity_ramp_information() CTSChamberRampParameters[source]¶
Gets information about the ongoing humidity ramp operation.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
- get_state() CTSState[source]¶
Gets the current state of the CTS chamber.
- Returns:
An instance of CTSState containing the current state of the chamber.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
- get_temperature() Tuple[float, float][source]¶
Gets the current temperature and set temperature from the CTS chamber.
- Returns:
A tuple containing the current temperature and the set temperature.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
- get_temperature_ramp_information() CTSChamberRampParameters[source]¶
Gets information about the ongoing temperature ramp operation.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
- pause() None[source]¶
Pauses the CTS chamber.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- ramp_to_humidity(target: float, ramp_up_rate: float | None = None, ramp_down_rate: float | None = None) None[source]¶
- ramp_to_temperature(target: float, ramp_up_rate: float | None = None, ramp_down_rate: float | None = None) None[source]¶
Ramps up or down to a target temperature on the CTS chamber using the specified ramp rates If a rate is None, the chamber will use the maximum ramp rate.
- Parameters:
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- resume() None[source]¶
Resumes the CTS chamber from a paused state.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- send_command(command: str) str[source]¶
Sends a command to the CTS chamber and returns the response. The command should be an ASCII string, which will be encoded to bytes before sending.
- Parameters:
command (str) – The command to send to the chamber.
- Returns:
The response from the chamber.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
- set_humidity(value: float) None[source]¶
Sets the humidity on the CTS chamber.
- Parameters:
value (float) – The humidity value to set.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- set_temperature(value: float) None[source]¶
Sets the temperature on the CTS chamber.
- Parameters:
value (float) – The temperature value to set.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- start() None[source]¶
Starts the CTS chamber.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None
- stop() None[source]¶
Stops the CTS chamber.
- Raises:
CTSChamberCommandError – If the command fails or the response is invalid.
CTSChamberCommunicationError – If there is an error in communication with the device.
- Return type:
None