psi_coldbox

PSIColdbox Class for the CMS Pixel 8-channel Coldbox developed at PSI

Classes

PSIColdbox(*args, **kwargs)

PSIColdbox

class icicle.psi_coldbox.PSIColdbox(*args, **kwargs)

Bases: MQTTInstrument

__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.

ENV_MAP = {0: 'TEMPERATURE_AIR', 1: 'TEMPERATURE_WATER', 2: 'RELATIVE_HUMIDITY', 3: 'DEW_POINT', 4: 'EMPTY', 5: 'EMPTY', 6: 'RUNTIME', 7: 'FLUSH', 8: 'RINSE'}

Mapping for information from the ENV statement into storage.

MEASUREMENTS = {'CONTROL_VOLTAGE': [0, 0, 0, 0, 0, 0, 0, 0], 'DEW_POINT': 0.0, 'DISKSPACE': 0, 'EMPTY': 0, 'ERROR': 0, 'FLOW': 0, 'FLUSH': 0, 'GREEN': 0, 'INTERLOCK': 0, 'LID': 0, 'MODE': [0, 0, 0, 0, 0, 0, 0, 0], 'N2_THROTTLE': 0, 'PELTIER_CURRENT': [0, 0, 0, 0, 0, 0, 0, 0], 'PELTIER_POWER': [0, 0, 0, 0, 0, 0, 0, 0], 'PELTIER_RESISTANCE': [0, 0, 0, 0, 0, 0, 0, 0], 'PELTIER_VOLTAGE': [0, 0, 0, 0, 0, 0, 0, 0], 'PID_KD': [0, 0, 0, 0, 0, 0, 0, 0], 'PID_KI': [0, 0, 0, 0, 0, 0, 0, 0], 'PID_KP': [0, 0, 0, 0, 0, 0, 0, 0], 'PID_MAX': [0, 0, 0, 0, 0, 0, 0, 0], 'PID_MIN': [0, 0, 0, 0, 0, 0, 0, 0], 'POWER': [0, 0, 0, 0, 0, 0, 0, 0], 'RED': 0, 'REFERENCE_VOLTAGE': [0, 0, 0, 0, 0, 0, 0, 0], 'RELATIVE_HUMIDITY': 0.0, 'RINSE': 0, 'RUNTIME': 0.0, 'SOFTWARE_VERSION': [0, 0, 0, 0, 0, 0, 0, 0], 'SUPPLY_CURRENT': [0, 0, 0, 0, 0, 0, 0, 0], 'SUPPLY_POWER': [0, 0, 0, 0, 0, 0, 0, 0], 'SUPPLY_VOLTAGE': [0, 0, 0, 0, 0, 0, 0, 0], 'TEMPERATURE_AIR': 0.0, 'TEMPERATURE_DIFF': [0, 0, 0, 0, 0, 0, 0, 0], 'TEMPERATURE_MEASURED': [0, 0, 0, 0, 0, 0, 0, 0], 'TEMPERATURE_SET': [0, 0, 0, 0, 0, 0, 0, 0], 'TEMPERATURE_W': [0, 0, 0, 0, 0, 0, 0, 0], 'TEMPERATURE_WATER': 0.0, 'YELLOW': 0}

Storage for information read from the MQTT monitor.

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

READ_MAP = {'CONTROLVOLTAGE_SET': 'CONTROL_VOLTAGE', 'GETSWVERSION': 'SOFTWARE_VERSION', 'PELTIER_I': 'PELTIER_CURRENT', 'PELTIER_P': 'PELTIER_POWER', 'PELTIER_R': 'PELTIER_RESISTANCE', 'PELTIER_U': 'PELTIER_VOLTAGE', 'POWERSTATE': 'POWER', 'REF_U': 'REFERENCE_VOLTAGE', 'SUPPLY_I': 'SUPPLY_CURRENT', 'SUPPLY_P': 'SUPPLY_POWER', 'SUPPLY_U': 'SUPPLY_VOLTAGE', 'TEMP_DIFF': 'TEMPERATURE_DIFF', 'TEMP_M': 'TEMPERATURE_MEASURED', 'TEMP_SET': 'TEMPERATURE_SET', 'TEMP_W': 'TEMPERATURE_W'}

Mapping for information from the monitor into storage.

SETTINGS = {'CLEAR_ERROR': {'SET': 'cmd ClearError', 'channel': True}, 'CONTROL_VOLTAGE': {'FIND': 'ControlVoltage_Set', 'QUERY': 'get ControlVoltage_Set', 'SET': 'set ControlVoltage_Set {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'DEW_POINT': {'FIND': 'DP', 'QUERY': 'get DP', 'type': <class 'float'>}, 'DP': {'FIND': 'DP', 'QUERY': 'get DP', 'type': <class 'float'>}, 'ERROR': {'FIND': 'Error', 'QUERY': 'get Error', 'channel': True, 'type': <class 'int'>}, 'FLUSH': {'FIND': 'valve0', 'QUERY': 'get valve0', 'SET': 'set valve0 {}', 'default': 'off', 'type': <class 'int'>, 'verifier': <function is_in.<locals>._is_in>}, 'FLUSH_TOGGLE': {'FIND': 'valve0', 'QUERY': 'get valve0', 'SET': 'cmd valve0', 'type': <class 'int'>}, 'LOAD_VARIABLES': {'SET': 'cmd LoadVariables', 'channel': True}, 'MODE': {'FIND': 'Mode', 'QUERY': 'get Mode', 'SET': 'set Mode {}', 'channel': True, 'type': <class 'int'>, 'verifier': <function is_in.<locals>._is_in>}, 'N2_THROTTLE': {'FIND': 'throttle', 'QUERY': 'get throttleN2', 'SET': 'cmd throttleN2{}', 'default': 'Off', 'type': <class 'int'>, 'verifier': <function is_in.<locals>._is_in>}, 'PELTIER_CURRENT': {'FIND': 'Peltier_I', 'QUERY': 'get Peltier_I', 'channel': True, 'type': <class 'float'>}, 'PELTIER_POWER': {'FIND': 'Peltier_P', 'QUERY': 'get Peltier_P', 'channel': True, 'type': <class 'float'>}, 'PELTIER_RESISTANCE': {'FIND': 'Peltier_R', 'QUERY': 'get Peltier_R', 'channel': True, 'type': <class 'float'>}, 'PELTIER_VOLTAGE': {'FIND': 'Peltier_U', 'QUERY': 'get Peltier_U', 'channel': True, 'type': <class 'float'>}, 'PID_KD': {'FIND': 'PID_kd', 'QUERY': 'get PID_kd', 'SET': 'set PID_kd {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'PID_KI': {'FIND': 'PID_ki', 'QUERY': 'get PID_ki', 'SET': 'set PID_ki {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'PID_KP': {'FIND': 'PID_kp', 'QUERY': 'get PID_kp', 'SET': 'set PID_kp {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'PID_MAX': {'FIND': 'PID_Max', 'QUERY': 'get PID_Max', 'SET': 'set PID_Max {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'PID_MIN': {'FIND': 'PID_Min', 'QUERY': 'get PID_Min', 'SET': 'set PID_Min {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'POWER': {'FIND': 'PowerState', 'QUERY': 'get PowerState', 'SET': 'cmd Power_{}', 'channel': True, 'type': <class 'int'>, 'verifier': <function is_in.<locals>._is_in>}, 'REBOOT': {'SET': 'cmd Reboot', 'channel': True}, 'REFERENCE_VOLTAGE': {'FIND': 'Ref_U', 'QUERY': 'get Ref_U', 'channel': True, 'type': <class 'float'>}, 'RELATIVE_HUMIDITY': {'FIND': 'RH', 'QUERY': 'get RH', 'type': <class 'float'>}, 'REL_HUMIDITY': {'FIND': 'RH', 'QUERY': 'get RH', 'type': <class 'float'>}, 'RH': {'FIND': 'RH', 'QUERY': 'get RH', 'type': <class 'float'>}, 'RINSE': {'FIND': 'valve1', 'QUERY': 'get valve1', 'SET': 'set valve1 {}', 'default': 'off', 'type': <class 'int'>, 'verifier': <function is_in.<locals>._is_in>}, 'RINSE_TOGGLE': {'FIND': 'valve1', 'QUERY': 'get valve1', 'SET': 'cmd valve1', 'type': <class 'int'>}, 'SAVE_VARIABLES': {'SET': 'cmd SaveVariables', 'channel': True}, 'SOFTWARE_VERSION': {'FIND': 'GetSWVersion', 'QUERY': 'cmd GetSWVersion', 'channel': True, 'type': <class 'str'>}, 'SUPPLY_CURRENT': {'FIND': 'Supply_I', 'QUERY': 'get Supply_I', 'channel': True, 'type': <class 'float'>}, 'SUPPLY_POWER': {'FIND': 'Supply_P', 'QUERY': 'get Supply_P', 'channel': True, 'type': <class 'float'>}, 'SUPPLY_VOLTAGE': {'FIND': 'Supply_U', 'QUERY': 'get Supply_U', 'channel': True, 'type': <class 'float'>}, 'TEMPERATURE_AIR': {'FIND': 'Temp', 'QUERY': 'get Temp', 'type': <class 'float'>}, 'TEMPERATURE_BOX': {'FIND': 'Temp', 'QUERY': 'get Temp', 'type': <class 'float'>}, 'TEMPERATURE_DIFF': {'FIND': 'Temp_Diff', 'QUERY': 'get Temp_Diff', 'channel': True, 'type': <class 'float'>}, 'TEMPERATURE_MEASURED': {'FIND': 'Temp_M', 'QUERY': 'get Temp_M', 'channel': True, 'type': <class 'float'>}, 'TEMPERATURE_SET': {'FIND': 'Temp_Set', 'QUERY': 'get Temp_Set', 'SET': 'set Temp_Set {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}, 'TEMPERATURE_W': {'FIND': 'Temp_W', 'QUERY': 'get Temp_W', 'channel': True, 'type': <class 'float'>}, 'THROTTLE_N2': {'FIND': 'throttle', 'QUERY': 'get throttleN2', 'SET': 'cmd throttleN2{}', 'default': 'Off', 'type': <class 'int'>, 'verifier': <function is_in.<locals>._is_in>}, 'VOLTAGE': {'FIND': 'ControlVoltage', 'QUERY': 'get ControlVoltage_Set', 'SET': 'set ControlVoltage_Set {}', 'channel': True, 'type': <class 'float'>, 'verifier': <function is_numeric.<locals>._is_numeric>}}

Possible settings and commands to use.

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.

VAR_MAP = {0: 'GREEN', 1: 'YELLOW', 2: 'RED', 3: 'LID', 4: 'INTERLOCK', 5: 'DISKSPACE', 6: 'FLOW', 7: 'N2_THROTTLE'}

Mapping for information from the VAR statement into storage.

add_publish_client(client: MQTTClient) None

Append a client to a publishing list. :param client: MQTT Client to add

clear_error(channel=0) None

Clear errors on one or all TEC controller :param channel: Select the TEC controller (default=0, which is all).

clear_publish_clients() None

Remove all clients from a publishing list.

execute(command) None

Execute a command by publishing it to the MQTT client. For development. :param command: The command to be executed.

get_alarms() int
Returns:

number of alarms received from coldbox

Return type:

int

get_warnings() int
Returns:

number of warnings received from coldbox

Return type:

int

identify() str
Returns:

identification of instrument

Return type:

str

interlocked() bool

Check, if interlock has been triggered by tessie :return: boolean if interlock is triggered :rtype: bool

load_variables_from_icicle(channel=0) None

Load defaults from icicle to TEC controller :param 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 :param channel: Select the TEC controller (default=0, which is all).

monitor(**kwargs) None

monitoring the coldbox. :param **repetition: number of repetitions. runs forever if not provided or 0. :param **monitor_sleep: time between queries. if not provided, default is used. :param ** monitor_style: display long or short monitor (default=’short’) :param ** monitor_compression: override the last message (default=True) :print: current measurement block.

off(channel=0, **kwargs) int

turn off peltier element. :param channel: output to be turned off (default=0, which is all). :param **no_lock: override acquire_lock (default=False). :param **attempts: how many retries to give set command (default=3). :return: read-back value. :rtype: int

on(channel=0, **kwargs) int

turn on peltier element. :param channel: output to be turned on (default=0, which is all). :param **no_lock: override acquire_lock (default=False). :param **attempts: how many retries to give set command (default=3). :return: read-back value. :rtype: int

publish_on_query(setting, value) None

call to publish at query-call. :param setting: setting to publish :param value: value to publish, either value or list.

publish_on_set(setting, value, channel=0) None

call to publish at set-call. :param setting: setting to publish :param value: value to publish, either value or list. :param 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. :param channel: Select the TEC controller (default=0, which is all).

remove_publish_client(client: MQTTClient) None

Append the client from a publishing list. :param 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 :param 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 successfully. :rtype: 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_humidity_and_validate(value, **kwargs) float

turn on flush and wait for humidity to go below threshold value :param value: target value for the humidity. :param **validation_mode: “RH” (default) or “DP”. :param **validation_time: (default=`PSIColdbox.VALIDATION_TIME`). :param **validation_timeout: (default=`PSIColdbox.VALIDATION_TIMEOUT`). :param **no_lock: override acquire_lock (default=False). :return: read-back value after validation :rtype: float

set_publish_on_query(setting) None

activate publishing on query-call :param setting: allow publishing

set_publish_on_set(setting) None

activate publishing on set :param setting: allow publishing

set_publish_on_time(setting, **kwargs) None

activate publishing on time :param setting: allow publishing :param **publish_sleep: set time (default=`PSIColdbox.PUBLISH_SLEEP`)

set_publish_on_update(setting) None

activate publishing on updates (excluding queries). :param setting: turn on or off

set_temperature_and_validate(value, **kwargs) list

set temperature on instrument to value, validate that the value is within the allowed range. requires mode=0 and power=1. allows customization with keyword arguments.

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. :param channel: output to be queried (default=0, which is all). :param **no_lock: override acquire_lock (default=False). :param **attempts: how many retries to give set command (default=3). :return: read-back value. :rtype: 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. :param channel: channel number to validate as an output. :param **raise_exception: raise exception or return bool (default=True). :return: whether channel exists or not :rtype: bool