ControllerCell¶
- class lsst.ts.m2com.ControllerCell(log=None, timeout_in_second=0.05, maxsize_queue=1000, is_csc=True, host=None, port_command=None, port_telemetry=None, timeout_connection=10)¶
Bases:
Controller
Cell controller class.
- Parameters:
- log
logging.Logger
or None, optional A logger. If None, a logger will be instantiated. (the default is None)
- timeout_in_second
float
, optional Time limit for reading data from the TCP/IP interface (sec). (the default is 0.05)
- maxsize_queue
int
, optional Maximum size of queue. (the default is 1000)
- is_csc
bool
, 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)
- host
str
or None, optional Host address. (the default is None)
- port_command
int
or None, optional Command port to connect. (the default is None)
- port_telemetry
int
or None, optional Telemetry port to connect. (the default is None)
- timeout_connection
int
orfloat
, optional Connection timeout in second. (the default is 10)
- log
- Attributes:
- host
str
or None Host address.
- port_command
int
or None Command port to connect.
- port_telemetry
int
or None Telemetry port to connect.
- timeout_connection
int
orfloat
Connection timeout in second.
- mock_server
MockServer
or None Mock server to support the simulation.
- run_loops
bool
The event and telemetry loops are running or not.
- stop_loop_timeout
float
Timeout of stoping loop in second.
- host
Attributes Summary
Methods Summary
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 the errors.
close
()Cancel the task and close the connection.
Close the asynchronous tasks.
Connect the TCP/IP server.
run_mock_server
(config_dir, lut_path)Run the mock server to support the simulation mode.
run_task_connection_monitor_loop
(...[, period])Run the task of connection monitor loop.
run_task_event_loop
(process_event, *args, ...)Run the task of event loop.
run_task_telemetry_loop
(process_telemetry, *args)Run the task of telemetry loop.
start
(host, port_command, port_telemetry[, ...])Start the task and connection.
Stop the loops.
write_command_to_server
(message_name[, ...])Write the command (message_name) to server.
Attributes Documentation
- TELEMETRY_WAIT_TIMEOUT = 900¶
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_name
str
Command name.
- allowed_curr_states
list [lsst.ts.salobj.State]
Allowed current states.
- command_name
- 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.
- async close_tasks()¶
Close the asynchronous tasks.
- async connect_server()¶
Connect the TCP/IP server.
- Raises:
- RuntimeError
If timeout in connection.
- async run_mock_server(config_dir, lut_path)¶
Run the mock server to support the simulation mode.
- Parameters:
- config_dir
pathlib.PosixPath
Configuration directory.
- lut_path
str
Look-up table (LUT) path.
- config_dir
- run_task_connection_monitor_loop(process_lost_connection, *args, period=1, **kwargs)¶
Run the task of connection monitor loop.
- Parameters:
- process_lost_connection
func
orcoroutine
Function to process the lost of connection.
- *args
args
Arguments needed in “process_lost_connection” function call.
- period
float
orint
, optional Period to check the connection status in second. (the default is 1)
- **kwargs
dict
, optional Additional keyword arguments in “process_lost_connection” function call.
- process_lost_connection
- run_task_event_loop(process_event, *args, **kwargs)¶
Run the task of event loop.
- Parameters:
- process_event
func
orcoroutine
Function to process the event. It must have a keyward argument of “message” to receive the message as a dictionary.
- *args
args
Arguments needed in “process_event” function call.
- **kwargs
dict
, optional Additional keyword arguments in “process_event” function call.
- process_event
- run_task_telemetry_loop(process_telemetry, *args, period=2, **kwargs)¶
Run the task of telemetry loop.
- Parameters:
- process_telemetry
func
orcoroutine
Function to process the telemetry. It must have a keyward argument of “message” to receive the message as a dictionary.
- *args
args
Arguments needed in “process_telemetry” function call.
- period
float
orint
, optional Period to check the telemetry rate in second. (the default is 2)
- **kwargs
dict
, optional Additional keyword arguments in “process_telemetry” function call.
- process_telemetry
- start(host, port_command, port_telemetry, sequence_generator=None, timeout=10.0)¶
Start the task and connection.
- async stop_loops()¶
Stop the loops.
- 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_name
str
Message name to server.
- message_details
dict
or None, optional Message details. (the default is None)
- timeout
float
, 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)
- message_name
- Raises:
OSError
When no TCP/IP connection.
RuntimeError
When the command failed.