Controller

class lsst.ts.m2com.Controller(log=None, timeout_in_second=0.05, maxsize_queue=1000, is_csc=True)

Bases: object

Controller class.

Parameters:
loglogging.Logger or None, optional

A logger. If None, a logger will be instantiated. (the default is None)

timeout_in_secondfloat, optional

Time limit for reading data from the TCP/IP interface (sec). (the default is 0.05)

maxsize_queueint, optional

Maximum size of queue. (the default is 1000)

is_cscbool, optional

Is called by the commandable SAL component (CSC) or not. This is a temporary option to separate the CSC and engineering user interface (EUI). This will be removed in the future after the state machines in the cell controller are unified to a single one. (the default is True)

Attributes:
loglogging.Logger

A logger.

client_commandTcpClient or None

Command client.

client_telemetryTcpClient or None

Telemetry client.

queue_eventasyncio.Queue

Queue of the event.

last_command_statusCommandStatus

Last command status.

timeoutfloat

Time limit for reading data from the TCP/IP interface (sec).

is_cscbool

Is CSC or not. Remove this after the state machines in cell controller are unified.

controller_state: enum `lsst.ts.salobj.State`

Controller’s state.

Methods Summary

are_clients_connected()

The command and telemetry sockets are connected or not.

assert_controller_state(command_name, ...)

Assert the current controller's state is allowed to do the command or not.

clear_errors()

Clear the errors.

close()

Cancel the task and close the connection.

start(host, port_command, port_telemetry[, ...])

Start the task and connection.

write_command_to_server(message_name[, ...])

Write the command (message_name) to server.

Methods Documentation

are_clients_connected()

The command and telemetry sockets are connected or not.

Returns:
bool

True if clients are connected. Else, False.

assert_controller_state(command_name, allowed_curr_states)

Assert the current controller’s state is allowed to do the command or not.

Parameters:
command_namestr

Command name.

allowed_curr_stateslist [lsst.ts.salobj.State]

Allowed current states.

Raises:
ValueError

When the command is not allowed in current controller’s state.

async clear_errors()

Clear the errors.

async close()

Cancel the task and close the connection.

Note: this function is safe to call even though there is no connection.

start(host, port_command, port_telemetry, sequence_generator=None, timeout=10.0)

Start the task and connection.

Parameters:
hoststr

Host address.

port_commandint

IP port for the command server.

port_telemetryint

IP port for the telemetry server.

sequence_generatorgenerator or None, optional

Sequence generator. (the default is None)

timeoutfloat, optional

Connection timeout in second. (default is 10.0)

async write_command_to_server(message_name, message_details=None, timeout=10.0, controller_state_expected=None)

Write the command (message_name) to server.

Parameters:
message_namestr

Message name to server.

message_detailsdict or None, optional

Message details. (the default is None)

timeoutfloat, optional

Timeout of command in second. (the default is 10.0)

controller_state_expectedenum lsst.ts.salobj.State or None,

optional

Expected controller’s state. This is only used for the commands related to the state transition. (the default is None)

Raises:
OSError

When no TCP/IP connection.

RuntimeError

When the command failed.