CommandHandler#

class lsst.ts.ess.controller.CommandHandler(callback, simulation_mode, devices_in_error_state=False)#

Bases: AbstractCommandHandler

Handle incoming commands and send replies. Apply configuration and read sensor data.

Parameters:
  • callback (Callable) – The callback coroutine handling the sensor telemetry. This can be a coroutine that sends the data via a socket connection or a coroutine in a test class to verify that the command has been handled correctly.

  • simulation_mode (int) – Indicating if a simulation mode (> 0) or not (0) is active. Simulation mode 0 means “connect to the real sensors.” Set simulation_mode to 1 to enable simulation mode and connect to a mock sensor.

  • are (The commands that can be handled) – configure: Load the configuration that is passed on with the command and connect to the devices specified in that configuration. This command can be sent multiple times before a start is received and only the last configuration is kept. start: Start reading the sensor data of the connected devices and send it as plain text via the socket. If no configuration was sent then the start command is ignored. Once started no configuration changes can be done anymore. stop: Stop sending sensor data and disconnect from all devices. Once stopped, configuration changes can be done again and/or reading of sensor data can be started again.

  • devices_in_error_state (bool, default: False)

Attributes Summary

Methods Summary

create_device(device_configuration[, ...])

Get the device to connect to by using the specified configuration.

Attributes Documentation

valid_simulation_modes = (0, 1)#

Methods Documentation

create_device(device_configuration, devices_in_error_state=False)#

Get the device to connect to by using the specified configuration.

Parameters:
  • device_configuration (dict) – A dict representing the device to connect to. The format of the dict follows the configuration of the ts_ess_csc project.

  • devices_in_error_state (bool) – Whether the devices are in error state (True) or not (False, default). To be used by unit tests.

Returns:

device – The device to connect to.

Return type:

common.device.BaseDevice

Raises:

RuntimeError – In case an incorrect configuration has been loaded.

Notes

In case simulation_mode is set to 1, only the sensor type is used and a mock device is instantiated. In case a serial device is specified, the device will only be instantiated if the code is running on a Raspberry Pi. In all other cases, the architecture of the platform is irrelevant.