psi_coldbox
PSIColdbox Class for the CMS Pixel 8-channel Coldbox developed at PSI
Classes
|
MQTTInstrument implementation for PSIColdbox. |
PSIColdbox
- class icicle.psi_coldbox.PSIColdbox(*args, **kwargs)
Bases:
MQTTInstrument
MQTTInstrument implementation for PSIColdbox.
- __init__(resource, **kwargs)
- Parameters:
resource – TCPIP::<host>::<port>::SOCKET
**username – username for the mqtt server (default=””)
**password – password for the mqtt server (default=””)
**init – whether to initialize the coldbox (default=False)
**sim – whether to simulate the instrument (default=False)
**ssl – whether to use ssl (default=False)
**publish_on_query – publish to mqtt on query (default=False)
**publish_on_set – publish to mqtt on every set (default=False)
**publish_on_update – publish to mqtt on every update (default=False)
**publish_on_time – publish to mqtt after time (default=False)
**publish_sleep – define time (default=`PSIColdbox.PUBLISH_SLEEP`)
**publish_topic – topic to publish to (default=”psi_coldbox”)
- DEFAULT = {'CONTROL_VOLTAGE': 0.0, 'MODE': 0, 'PID_KD': 3.0, 'PID_KI': 0.03, 'PID_KP': 0.4, 'PID_MAX': 12, 'PID_MIN': -4, 'TEMPERATURE_SET': 15.0}
Dictionary with the default values for operation.
- MEASURE_TYPES = {'PELTIER_I': 'Current of the peltier (I)', 'PELTIER_P': 'Power of the peltier (W)', 'PELTIER_R': 'Resistance of the peltier (Ohm)', 'PELTIER_U': 'Voltage of the peltier (V)', 'SPEED': 'Can not be measured, this is required by TemperatureChannel', 'SUPPLY_I': 'Supply Current of the TEC Controller (I)', 'SUPPLY_P': 'Supply Power of the TEC Controller (W)', 'SUPPLY_U': 'Supply Voltage of the TEC Controller (V)', 'TEMPERATURE': 'Temperature of the peltier (degC)'}
Dictionary with the possible measurechannels.
- MONITOR_SLEEP = 5
Frequency of monitor
- class MeasureChannel(instrument, channel, measure_type, unit='')
Bases:
MeasureChannel
MeasureChannel implementation for PSIColdbox.
- property status: bool
- Returns:
status, True for operational; False for interlocked
- Return type:
bool
- property value: float
- Returns:
pin value at measurement
- Return type:
float
- PUBLISH_SLEEP = 5
Time between two publishes if option is on time
- QUERY_LATENCY = 1
MQTT maximum query latency
- READ_LATENCY = 10
MQTT maximum read latency
- class TemperatureChannel(instrument, channel, measure_temperature, measure_speed)
Bases:
TemperatureChannel
TemperatureChannel implementation for TEC controller.
- property measure_temperature: float
- Returns:
temperature measured
- Return type:
float
- property speed: float
“Fake” entry point to keep common interface. This device does not have a speed setting.
- property state: bool
- Returns:
power state of the channel
- Return type:
bool
- property status: bool
- Returns:
status, True for operational; False for interlocked
- Return type:
bool
- property temperature: float
- Returns:
temperature set
- Return type:
float
- VALIDATION_DELAY = 1
Time between two queries for value validation
- VALIDATION_TIME = 10
Time for set_temperature_and_validate to validate temperature.
- VALIDATION_TIMEOUT = 60
Time for set_temperature_and_validate to timeout during validation.
- add_publish_client(client: MQTTClient) None
Append a client to a publishing list.
- Parameters:
client – MQTT Client to add
- clear_error(channel=0) None
Clear errors on one or all TEC controller
- Parameters:
channel – Select the TEC controller (default=0, which is all).
- clear_publish_clients() None
Remove all clients from a publishing list.
- ensure_maximum_humidity(value, **kwargs) float
turn on flush and wait for humidity to go below threshold value
- Parameters:
value – target value for the humidity.
**validation_mode – “RH” (default) or “DP”.
**validation_time – (default=`PSIColdbox.VALIDATION_TIME`).
**validation_timeout – (default=`PSIColdbox.VALIDATION_TIMEOUT`).
**no_lock – override acquire_lock (default=False).
- Returns:
read-back value after validation
- Return type:
float
- execute(command) None
Execute a command by publishing it to the MQTT client. Only for internal use or debugging. Normally to be called directly
- Parameters:
command – The command to be executed.
- get_alarms() int
- Returns:
number of alarms received from coldbox
- Return type:
int
- static get_measurements() dict
- Returns:
MEASUREMENTS dictionary
- Return type:
dict
- static get_settings() dict
- Returns:
SETTINGS dictionary
- Return type:
dict
- get_warnings() int
- Returns:
number of warnings received from coldbox
- Return type:
int
- identify() str
- Returns:
identification of instrument
- Return type:
str
- interlocked() bool
- Returns:
whether interlock is triggered
- Return type:
bool
- load_variables_from_icicle(channel=0) None
Load defaults from icicle to TEC controller
- Parameters:
channel – Select the TEC controller (default=0, which is all).
- load_variables_from_tec(channel=0) None
Load settings from the memory of a TEC controller
- Parameters:
channel – Select the TEC controller (default=0, which is all).
- monitor(**kwargs) None
monitoring the coldbox.
- Parameters:
**repetition – number of repetitions. runs forever if not provided or 0.
**monitor_sleep – time between queries. if not provided, default is used.
**monitor_style – display long or short monitor (default=’short’)
**monitor_compression – override the last message (default=True)
- Print:
current measurement block.
- off(channel=0, **kwargs) int
turn off peltier element.
- Parameters:
channel – output to be turned off (default=0, which is all).
**no_lock – override acquire_lock (default=False).
**attempts – how many retries to give set command (default=3).
- Returns:
read-back value.
- Return type:
int
- on(channel=0, **kwargs) int
turn on peltier element.
- Parameters:
channel – output to be turned on (default=0, which is all).
**no_lock – override acquire_lock (default=False).
**attempts – how many retries to give set command (default=3).
- Returns:
read-back value.
- Return type:
int
- publish_on_query(setting, value) None
call to publish at query-call.
- Parameters:
setting – setting to publish
value – value to publish, either value or list.
- publish_on_set(setting, value, channel=0) None
call to publish at set-call.
- Parameters:
setting – setting to publish
value – value to publish, either value or list.
channel – select the TEC controller (default=0, which is all).
- publish_on_time() None
call to publish on time. checks, if new publish is allowed.
- publish_on_update() None
Call to publish on update. Will publish cache.
- push_simulation() None
Simulate the receival of updates from the simulated MQTTServer
- query(setting, **kwargs)
- Parameters:
setting – setting to query.
**channel – provide the channel, DEPRECATED (default=0).
**force_query – require query or read from cache (default=False).
- Returns:
value at measurement
- Return type:
according to PSIColdbox.SETTINGS
- query_channel(setting, channel, **kwargs)
returns the value for the setting.
- Parameters:
setting – setting to query.
channel – channel number to query.
**force_query – require query or read from cache (default=False).
- Returns:
value at measurement
- Return type:
according to PSIColdbox.SETTINGS
- read(setting, **kwargs)
- Parameters:
setting – setting to read.
**channel – provide channel, DEPRECATED (default=0).
- Returns:
value from cache
- Return type:
according to PSIColdbox.SETTINGS
- read_channel(setting, channel)
returns the value for the setting from cache.
- Parameters:
setting – setting to query.
channel – channel number to query.
- Returns:
value at measurement
- Return type:
according to PSIColdbox.SETTINGS
- reboot(channel=0) None
Reboot one or all TEC controller.
- Parameters:
channel – Select the TEC controller (default=0, which is all).
- remove_publish_client(client: MQTTClient) None
Append the client from a publishing list.
- Parameters:
client – MQTT Client to add
- reset() None
Resets counter for alarms and warnings
- reset_alarms() None
Reset the number of alarms read by the MQTT client.
- reset_warnings() None
Reset the number of alarms read by the MQTT client.
- save_variables_on_tec(channel=0) None
Save current settings to the memory of a TEC controller
- Parameters:
channel – Select the TEC controller (default=0, which is all).
- set(setting, value=None, **kwargs)
set setting on the instrument to value for output channel, and query the setting back. to set one channel, use set_channel instead.
- Parameters:
setting – key in class dictionary SETTINGS.
value – target value can be left for commands.
**channel – provide a channel, DEPRECATED (default=0).
**no_lock – override acquire_lock (default=False).
**attempts – how many retries to give set command (default=3).
- Returns:
read-back value if query available, else if command was sent.
- Return type:
according to PSIColdbox.SETTINGS
- set_channel(setting, channel, value=None)
set setting on the instrument to value for output channel, and query the setting back. to set all, use set instead.
- Parameters:
setting – key in class dictionary SETTINGS.
channel – channel in {1, …, 8}
value – target value, can be left for commands.
**no_lock – override acquire_lock (default=False).
**attempts – how many retries to give set command (default=3).
- Returns:
read-back value if query available, else if command was
sent successfully. :rtype: according to PSIColdbox.SETTINGS
- set_publish_on_query(setting) None
activate publishing on query-call
- Parameters:
setting – allow publishing
- set_publish_on_set(setting) None
activate publishing on set
- Parameters:
setting – allow publishing
- set_publish_on_time(setting, **kwargs) None
activate publishing on time
- Parameters:
setting – allow publishing
**publish_sleep – set time (default=`PSIColdbox.PUBLISH_SLEEP`)
- set_publish_on_update(setting) None
activate publishing on updates (excluding queries).
- Parameters:
setting – turn on or off
- set_temperature_and_validate(value, **kwargs) list
set temperature on instrument to value on the provided channels. specify an acceptable range and wait for the validation_time the temperature to be inside the range and stay inside the range. if the requirement is not met during validation_timeout, there will be a timeout. the function allows for humidity control, ensuring the set temperature is above the dew point. it will activate flush to lower the dew point and allows to set minimal steps for the temperature movement and a minimal distance to the dew point. power needs to be on and mode needs to be set to temperature
- Parameters:
value – target value for temperature.
**channel_list – list of channels to validate (default=None, means all)
**tolerance – tolerance, preferred to range (default=1.0 if neither)
**min_value – minimum value for validation range.
**max_value – maximum value for validation range.
**validation_time – (default=`PSIColdbox.VALIDATION_TIME`).
**validation_timeout – (default=`PSIColdbox.VALIDATION_TIMEOUT`).
**humidity_control – keep temperature above dew-point (default=False)
**distance_to_dew_point – distance to the dew point (default=1.0)
**distance_to_change_temperature – distance for step (default=1.0).
**pid_control – check if PID values are all positive (default=True)
**no_lock – override acquire_lock (default=False).
**attempts – how many retries to give set command (default=3).
- Returns:
read-back value after validation
- Return type:
float
- set_temperature_channel_and_validate(channel, value, **kwargs) float
set the temperature on one channel according to set_temperature_and_validate. please see the documentation there.
- Parameters:
channel – channel in {1, …, 8}
value – target temperature.
**kwargs – see set_temperature_and_validate.
- Returns:
temperature, once the temperature is close to setting.
- Return type:
float
- status(channel=0, **kwargs) int
get power status of the peltier element.
- Parameters:
channel – output to be queried (default=0, which is all).
**no_lock – override acquire_lock (default=False).
**attempts – how many retries to give set command (default=3).
- Returns:
read-back value.
- Return type:
int
- update(msg) None
Handling function to update the storage. Called from MQTT client to store received data.
- Parameters:
msg – The message received.
- validate_channel(channel, **kwargs) bool
check if an output exists on this device.
- Parameters:
channel – channel number to validate as an output.
**raise_exception – raise exception or return bool (default=True).
- Returns:
whether channel exists or not
- Return type:
bool