CommandTelemetryServer

class lsst.ts.hexrotcomm.CommandTelemetryServer(host, log, port, ConfigClass, TelemetryClass, connect_callback, config_callback, telemetry_callback)

Bases: object

Serve command and telemetry ports for a low level controller to connect to.

Parameters:
host : str or None

IP address for this server. If None then bind to all network interfaces.

port : int

Port for telemetry and configuration; if nonzero then the command port will be one larger. Specify 0 to choose random values for both ports; this is recommended for unit tests, to avoid collision with a running CSC.

log : logging.Logger

Logger.

ConfigClass : ctypes.Structure

Class for configuration.

TelemetryClass : ctypes.Structure

Class for telemetry

connect_callback : callable

Function to call when a connection is made or dropped. The function receives one argument: this server.

config_callback : callable

Function to call when configuration is read. The function receives one argument: this server.

telemetry_callback : callable

Function to call when telemetry is read. The function receives one argument: this server.

Attributes Summary

command_connected Return True if the command socket is connected.
command_port Return the command port; may be 0 if not started.
connect_timeout Time limit for Moog controller to connect to this server (sec).
connected Return True if command and telemetry sockets are connected.
disconnect_timeout Time limit to close the server and telemetry sockets (sec).
telemetry_connected Return True if the telemetry socket is connected.
telemetry_port Return the telemetry port; may be 0 if not started.

Methods Summary

async_call_connect_callback()
call_connect_callback() Call the connect_callback if connection state has changed.
close() Close everything.
command_connect_callback(command_server) Called when the command server connection state changes.
monitor_command_reader() Monitor the command reader; if it closes then close the writer.
next_telemetry([skip]) Wait for next telemetry.
put_command(command) Write a command to the controller.
read_telemetry_and_config() Read telemetry and configuration from the Moog controller.
start() Start command and telemetry TCP/IP servers.
telemetry_connect_callback(telemetry_server) Called when the telemetry server connection state changes.
wait_connected() Wait for command and telemetry sockets to be connected.

Attributes Documentation

command_connected

Return True if the command socket is connected.

command_port

Return the command port; may be 0 if not started.

connect_timeout = 10

Time limit for Moog controller to connect to this server (sec).

connected

Return True if command and telemetry sockets are connected.

disconnect_timeout = 5

Time limit to close the server and telemetry sockets (sec).

telemetry_connected

Return True if the telemetry socket is connected.

telemetry_port

Return the telemetry port; may be 0 if not started.

Methods Documentation

async_call_connect_callback()
call_connect_callback()

Call the connect_callback if connection state has changed.

close()

Close everything.

command_connect_callback(command_server)

Called when the command server connection state changes.

monitor_command_reader()

Monitor the command reader; if it closes then close the writer.

next_telemetry(skip=2)

Wait for next telemetry.

Parameters:
skip : int (optional)

Number of telemetry items to skip. 1 is ideal to wait for the result of a command, because it avoids a race condition between sending the command and seeing the result.

put_command(command)

Write a command to the controller.

Parameters:
command : Command

Command to write. Its counter field will be set.

read_telemetry_and_config()

Read telemetry and configuration from the Moog controller.

start()

Start command and telemetry TCP/IP servers.

telemetry_connect_callback(telemetry_server)

Called when the telemetry server connection state changes.

wait_connected()

Wait for command and telemetry sockets to be connected.