ChillerModel¶
- class lsst.ts.atwhitelight.ChillerModel(config, csc, log, status_callback, simulate, make_connect_time_out=False)¶
Bases:
object
Interface to the ThermoTek chiller.
Connect, disconnect, send commands, and monitor state.
- Parameters:
- config
types.SimpleNamespace
Chiller-specific configuration.
- csc
lsst.ts.salobj.BaseCsc
The CSC. This class writes to chiller-specific event topics.
- log
logging.Logger
Logger.
- status_callback
awaitable
orNone
Coroutine to call when evt_chillerWatchdog or evt_chillerConnected changes. It receives one argument: this model.
- simulate
bool
Run in simulation mode? If true then run a mock chiller.
- make_connect_time_out
bool
, optional Make the connect method timeout? Only useful for unit tests. Ignored if simulate false.
- config
- Raises:
- TypeError
If
status_callback
is not None and not a coroutine.
Notes
The ThermoTek T257P can only servo to the supply temperature, despite the command manual offering a command to set it to other sensors. In addition, the value read by the return sensor is not believable.
Attributes Summary
Return True if connected to the server and the configuration commands have run.
Return True if connected to the server and the configuration commands have run.
Methods Summary
Call the status callback, if there is one.
check_set_temperature
(temperature)Check a demand temperature to see if it is range.
close
()Run commands to set control sensor and alarm and warning levels.
connect
()Connect to the chiller and configure it.
Disconnect from the chiller and cancel tasks.
Request ambient temperature, in C
Request coolant flow rate, in liters/minute
do_read_fan_speed
(fan_num)Read the speed of one fan, in revolutions per second.
Read the level 1 alarm state
do_read_l2_alarms
(sublevel)Read the level 2 alarm state
Request await self.run_command(temperature, in C
Request set temperature, in C
Request supply temperature, in C
Request TEC Bank1 current, in DC Amps
Request TEC Bank2 current, in DC Amps
Request the TEC drive level and mode.
Read the uptime.
Read the warning state
do_set_alarm_threshold
(threshold_type, value)Set an alarm threshold for coolant flow rate or one of several temperatures.
do_set_chiller_status
(status)Set the chiller status.
do_set_control_sensor
(sensor)Set the sensor to match for temperature control.
do_set_control_temperature
(temperature)Set the desired temperature.
do_set_warning_threshold
(threshold_type, value)Set a warning threshold for coolant flow rate, or one of several temperatures.
Request a watchdog packet
Get the current evt_chillerWatchdog data.
handle_read_fan_speed
(data, fan_num)handle_read_l1_alarms
(data)handle_read_l2_alarms
(data)handle_read_tec_bank_currents
(data, field_name)handle_read_temperature
(data, field_name)handle_read_warnings
(data)handle_reply
(reply)Handle a reply.
handle_watchdog
(data)parse_current
(data)Parses current as a float in Amps.
parse_flow
(data)Parse flow rate as a float in ?
parse_temperature
(data)Parse temperature as a float in deg C.
Reset the seen_x attributes.
run_command
(cmd)Run a chiller command and handle the reply.
Start cooling and wait for the watchdog to report it.
Stop cooling and wait for the watchdog to report it.
Run telemetry commands at regular intervals.
Run a watchdog command at regular intervals.
Attributes Documentation
- configured¶
Return True if connected to the server and the configuration commands have run.
- connected¶
Return True if connected to the server and the configuration commands have run.
Methods Documentation
- async call_status_callback()¶
Call the status callback, if there is one.
- check_set_temperature(temperature)¶
Check a demand temperature to see if it is range.
- Parameters:
- temperature
float
The temperature to check (C)
- temperature
- Raises:
- lsst.ts.salobj.ExpectedError
If temperature < config.low_supply_temperature_warning or temperature > config.high_supply_temperature_warning
- async close()¶
- async configure_chiller()¶
Run commands to set control sensor and alarm and warning levels.
- async connect()¶
Connect to the chiller and configure it.
Start background tasks that keep the model up-to-date.
- async disconnect()¶
Disconnect from the chiller and cancel tasks.
- async do_read_ambient_temperature()¶
Request ambient temperature, in C
- async do_read_coolant_flow_rate()¶
Request coolant flow rate, in liters/minute
- async do_read_fan_speed(fan_num)¶
Read the speed of one fan, in revolutions per second.
- Parameters:
- fan_numint in range [1, 4]
- async do_read_l1_alarms()¶
Read the level 1 alarm state
- async do_read_l2_alarms(sublevel)¶
Read the level 2 alarm state
- Parameters:
- sublevelint
which set of L2 alarms to query should be 1 or 2
- async do_read_return_temperature()¶
Request await self.run_command(temperature, in C
- async do_read_set_temperature()¶
Request set temperature, in C
- async do_read_supply_temperature()¶
Request supply temperature, in C
- async do_read_tec_bank1()¶
Request TEC Bank1 current, in DC Amps
- async do_read_tec_bank2()¶
Request TEC Bank2 current, in DC Amps
- async do_read_tec_drive_level()¶
Request the TEC drive level and mode.
The returned value is a percentage and a C or H for cool/heat mode.
- async do_read_uptime()¶
Read the uptime.
- async do_read_warnings()¶
Read the warning state
- async do_set_alarm_threshold(threshold_type, value)¶
Set an alarm threshold for coolant flow rate or one of several temperatures.
- Parameters:
- threshold_typeChillerThresholdType
Threshold type.
- valuefloat in range -999.9 to 999.9
Threshold value:
Temperature is in C and may be negative or positive.
Flow is in liters/minute and must be positive.
- async do_set_chiller_status(status)¶
Set the chiller status.
- Parameters:
- statusint
desired state: 0 = standby, 1 = run
- async do_set_control_sensor(sensor)¶
Set the sensor to match for temperature control.
- Parameters:
- sensor
ChillerControlSensor
Sensor to match for temperature control.
- sensor
- async do_set_control_temperature(temperature)¶
Set the desired temperature.
- Parameters:
- temperaturefloat
Temperature (C)
- async do_set_warning_threshold(threshold_type, value)¶
Set a warning threshold for coolant flow rate, or one of several temperatures.
- Parameters:
- threshold_typeChillerThresholdType
Threshold type.
- valuefloat in range -999.9 to 999.9
Threshold value:
Temperature is in C and may be negative or positive.
Flow is in liters/minute and must be positive.
- async do_watchdog()¶
Request a watchdog packet
- get_watchdog()¶
Get the current evt_chillerWatchdog data.
Raise RuntimeError if not connected or if watchdog data has not been seen since the connection was made (which would be a bug, since the model should not report being connected until watchdog data is seen).
- async handle_read_coolant_flow_rate(data)¶
- async handle_read_fan_speed(data, fan_num)¶
- async handle_read_l1_alarms(data)¶
- async handle_read_l2_alarms(data)¶
- async handle_read_tec_bank_currents(data, field_name)¶
- async handle_read_tec_drive_level(data)¶
- async handle_read_temperature(data, field_name)¶
- async handle_read_warnings(data)¶
- async handle_reply(reply)¶
Handle a reply.
Parse it and send it to the appropriate handle_x method.
- Parameters:
- reply
str
Reply from the chiller, without the final checksum and
- .
- reply
- async handle_set_alarm_threshold(data)¶
- async handle_set_chiller_status(data)¶
- async handle_set_control_sensor(data)¶
- async handle_set_control_temperature(data)¶
- async handle_set_warning_threshold(data)¶
- async handle_watchdog(data)¶
- parse_current(data)¶
Parses current as a float in Amps.
- parse_flow(data)¶
Parse flow rate as a float in ?
- parse_temperature(data)¶
Parse temperature as a float in deg C.
- reset_seen()¶
Reset the seen_x attributes.
The seen_x attributes are used topics which have multiple fields whose values are filled by separate commands. Each value is a set of topic field names. As each field is seen, add its name to the appropriate set, and if all fields have been seen, write the topic and reset the seen_x to an empty set.
Call this method:
When you construct the model (to create the attributes)
When you disconnect
When you connect (to be paranoid)
- async run_command(cmd)¶
Run a chiller command and handle the reply.
If the command or reply handler fails, log an error and raise an exception.
- Parameters:
- cmd
str
Command, with no device ID or checksum.
- cmd
- Returns:
- reply
str
The reply, without the trailing checksum and “
- “.
You should not need this, since this method handles the reply before returning it.
- reply
- Raises:
- ConnectedError
If the chiller is not connected.
- RuntimeError
If the chiller rejects the command, or a reply is not seen in time.
- Exception
If the reply handler raises an exception.
- async start_cooling()¶
Start cooling and wait for the watchdog to report it.
- async stop_cooling()¶
Stop cooling and wait for the watchdog to report it.
- async telemetry_loop()¶
Run telemetry commands at regular intervals.