AtSimulator#

class lsst.ts.attcpip.AtSimulator(host, cmd_evt_port, telemetry_port, simulator_state=State.STANDBY, send_fail_reason=True)#

Bases: object

Common code for simulating an AT system.

host#

The simulator host.

Type:

str

cmd_evt_port#

The command and events port.

Type:

int

telemetry_port#

The telemetry port.

Type:

int

simulator_state#

The summary state to start with.

Type:

sal_enums.State

send_fail_reason#

Send a fail reason for failed commands or not. Defaults to True. Unit tests may set this to False.

Type:

bool

Parameters:
  • host (str)

  • cmd_evt_port (int)

  • telemetry_port (int)

  • simulator_state (State, default: <State.STANDBY: 5>)

  • send_fail_reason (bool, default: True)

Methods Summary

base_cmd_evt_connect_callback(server)

Callback to call when a command/event client connects or disconnects.

cmd_evt_connect_callback(server)

Callback to call when a command/event client connects or disconnects.

cmd_evt_dispatch_callback(data)

Asynchronous function to call when data is read and dispatched.

disable(*, sequence_id)

Switch to sal_enums.State.DISABLED.

enable(*, sequence_id)

Switch to sal_enums.State.ENABLED.

fault()

Switch to sal_enums.State.FAULT.

load_schemas()

Load the JSON schemas needed to validate the incoming and outgoing JSON messages.

send_detailed_state_events()

Send detailed state events.

standby(*, sequence_id)

Switch to sal_enums.State.STANDBY.

start(*, sequence_id)

Start and switch to sal_enums.State.DISABLED.

telemetry_connect_callback(server)

Callback function for when a telemetry client connects or disconnects.

telemetry_dispatch_callback(data)

Asynchronous function to call when data are read and dispatched.

verify_data(data)

Verify the format and values of the data.

write_ack_response(sequence_id)

Write an ACK response.

write_fail_response(sequence_id, reason, ...)

Write a FAIL response.

write_noack_response(sequence_id)

Write a NOACK response.

write_success_response(sequence_id)

Write a SUCCESS response.

Methods Documentation

async base_cmd_evt_connect_callback(server)#

Callback to call when a command/event client connects or disconnects.

This method will call cmd_evt_connect_callback which needs to be implemented by subclasses.

Parameters:

server (tcpip.OneClientServer) – The server to which the client connected.

Return type:

None

async cmd_evt_connect_callback(server)#

Callback to call when a command/event client connects or disconnects.

Parameters:

server (tcpip.OneClientServer) – The server to which the client connected.

Return type:

None

async cmd_evt_dispatch_callback(data)#

Asynchronous function to call when data is read and dispatched.

The received data is validated and then dispatched to the corresponding function as listed in self.dispatch_dict. If the data is invalid then a noack response is sent back to the client and the data is not dispatched.

Parameters:

data (dict`[`str, typing.Any]) – The data sent to the server.

Return type:

None

async disable(*, sequence_id)#

Switch to sal_enums.State.DISABLED.

Parameters:

sequence_id (int)

Return type:

None

async enable(*, sequence_id)#

Switch to sal_enums.State.ENABLED.

Parameters:

sequence_id (int)

Return type:

None

async fault()#

Switch to sal_enums.State.FAULT.

Return type:

None

load_schemas()#

Load the JSON schemas needed to validate the incoming and outgoing JSON messages.

Return type:

None

async send_detailed_state_events()#

Send detailed state events.

This method is called when going to FAULT state. Subclasses may implement this such that the device specific behavior is mimicked.

Return type:

None

async standby(*, sequence_id)#

Switch to sal_enums.State.STANDBY.

Parameters:

sequence_id (int)

Return type:

None

async start(*, sequence_id)#

Start and switch to sal_enums.State.DISABLED.

Parameters:

sequence_id (int)

Return type:

None

async telemetry_connect_callback(server)#

Callback function for when a telemetry client connects or disconnects.

Parameters:

server (tcpip.OneClientServer) – The server to which the client connected.

Return type:

None

async telemetry_dispatch_callback(data)#

Asynchronous function to call when data are read and dispatched.

The received data is ignored since the telemetry server is only supposed to send data and not to receive any.

Parameters:

data (dict`[`str, typing.Any]) – The data sent to the server.

Return type:

None

async verify_data(data)#

Verify the format and values of the data.

The format of the data is described at lsst-ts/ts_labview_tcp_json as well as in the JSON schemas in the schemas directory.

Parameters:

data (dict of any) – The dict to be verified.

Returns:

Whether the data follows the correct format and has the correct contents or not.

Return type:

bool

async write_ack_response(sequence_id)#

Write an ACK response.

Parameters:

sequence_id (int) – The command sequence id.

Return type:

None

async write_fail_response(sequence_id, reason, error_details)#

Write a FAIL response.

Parameters:
  • sequence_id (int) – The command sequence id.

  • reason (str) – The reason why the command failed.

  • error_details (str) – Details of the error.

Return type:

None

async write_noack_response(sequence_id)#

Write a NOACK response.

Parameters:

sequence_id (int) – The command sequence id.

Return type:

None

async write_success_response(sequence_id)#

Write a SUCCESS response.

Parameters:

sequence_id (int) – The command sequence id.

Return type:

None