AtTcpipCsc#

class lsst.ts.attcpip.AtTcpipCsc(name, index, config_schema, config_dir=None, check_if_duplicate=False, initial_state=State.STANDBY, override='', simulation_mode=0)#

Bases: ConfigurableCsc

Base Configurable CSC with common code.

The base Configurable CSC is intended to be used by systems that connect to the AuxTel LabVIEW servers via TCP/IP, like ATMCS and ATPneumatics.

Parameters:
  • name (str) – Name of SAL component.

  • index (int or None) – SAL component index, or 0 or None if the component is not indexed.

  • check_if_duplicate (bool, optional) – Check for heartbeat events from the same SAL name and index at startup (before starting the heartbeat loop)? Defaults to False in order to speed up unit tests, but amain sets it true.

  • initial_state (State, int or None, optional) – Initial state for this CSC. If None use the class attribute default_initial_state. Typically, State.STANDBY (or State.OFFLINE for an externally commandable CSC) but can also be State.DISABLED, or State.ENABLED, in which case you may also want to specify override for a configurable CSC.

  • override (str, optional) – Configuration override file to apply if initial_state is State.DISABLED or State.ENABLED. Ignored if the CSC is not configurable.

  • simulation_mode (int, optional) – Simulation mode. The default is 0: do not simulate.

  • allow_missing_callbacks (bool, optional) – Allow missing do_<name> callback methods? Missing method will be replaced with one that raises salobj.ExpectedError. This is intended for mock controllers, which may only support a subset of commands.

  • config_schema (dict[str, Any])

  • config_dir (str | Path | None, default: None)

Attributes Summary

Methods Summary

begin_disable(data)

Begin do_disable; called before state changes.

begin_enable(data)

Begin do_enable; called before state changes.

begin_standby(data)

Begin do_standby; called before the state changes.

call_set_write(data)

Call await set_write for an event or telemetry.

close_tasks()

Shut down pending tasks.

cmd_evt_loop()

Execute the command and event loop.

configure(config)

Configure the CSC.

end_disable(data)

End do_disable; called after state changes but before command acknowledged.

end_enable(data)

End do_enable; called after state changes but before command acknowledged.

end_standby(data)

End do_standby; called after state changes but before command acknowledged.

end_start(data)

End do_start; called after state changes but before command acknowledged.

fault(code, report[, traceback])

Enter the fault state and output the errorCode event.

get_config_pkg()

Get the name of the configuration package, e.g. "ts_config_ocs".

perform_common_part_of_state_transition(...)

Utility method to perform the common part of any state transition.

start_clients()

Start the clients for the TCP/IPconnections as well as background tasks.

stop_clients()

Stop all clients and background tasks.

telemetry_loop()

Execute the telemetry loop.

wait_cmd_done(command)

Write a command and wait for it to be reported as Done or Fail by AT.

wait_fail_reason_event(sequence_id)

Wait for the fail reason event to arrive.

wait_fututre_done_or_fault(future)

Wait for either the future to be done or for the CSC to go to FAULT, whichever comes first.

write_command(command, **params)

Write the command JSON string to the TCP/IP command/event server.

Attributes Documentation

connected#
valid_simulation_modes: Sequence[int] = [0, 1]#

Methods Documentation

async begin_disable(data)#

Begin do_disable; called before state changes.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async begin_enable(data)#

Begin do_enable; called before state changes.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async begin_standby(data)#

Begin do_standby; called before the state changes.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async call_set_write(data)#

Call await set_write for an event or telemetry.

data contains both the event or telemetry name and the attribute values. The method will first extract the name and the values and then write.

Parameters:

data (dict`[`str, Any]) – Data.

Return type:

None

async close_tasks()#

Shut down pending tasks. Called by close.

Perform all cleanup other than disabling logging to SAL and closing the dds domain.

Return type:

None

async cmd_evt_loop()#

Execute the command and event loop.

This loop waits for incoming command and event messages and processes them when they arrive.

Return type:

None

async configure(config)#

Configure the CSC.

Parameters:

config (object) – The configuration, as described by the config schema, as a struct-like object.

Return type:

None

Notes

Called when running the start command, just before changing summary state from State.STANDBY to State.DISABLED.

async end_disable(data)#

End do_disable; called after state changes but before command acknowledged.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async end_enable(data)#

End do_enable; called after state changes but before command acknowledged.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async end_standby(data)#

End do_standby; called after state changes but before command acknowledged.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async end_start(data)#

End do_start; called after state changes but before command acknowledged.

Parameters:

data (salobj.BaseMsgType) – Command data

Return type:

None

async fault(code, report, traceback='')#

Enter the fault state and output the errorCode event.

Parameters:
  • code (int) – Error code for the errorCode event. If None then errorCode is not output, and you should output it yourself. Specifying None is deprecated; please always specify an integer error code.

  • report (str) – Description of the error.

  • traceback (str, optional) – Description of the traceback, if any.

Return type:

None

static get_config_pkg()#

Get the name of the configuration package, e.g. “ts_config_ocs”.

Return type:

str

async perform_common_part_of_state_transition(command, expected_states)#

Utility method to perform the common part of any state transition.

State-specific code is executed in the specific being_xxx and end_xxx methods.

Parameters:
  • command (CommonCommand) – The command to be executed.

  • expected_states (list`[`sal_enums.State]) – List of states AT is expected to be in.

Return type:

None

async start_clients()#

Start the clients for the TCP/IPconnections as well as background tasks.

If simulator_mode == 1 then the simulator gets initialized and started as well.

Return type:

None

async stop_clients()#

Stop all clients and background tasks.

If simulator_mode == 1 then the simulator gets stopped as well.

Return type:

None

async telemetry_loop()#

Execute the telemetry loop.

This loop waits for incoming telemetry messages and processes them when they arrive.

Return type:

None

async wait_cmd_done(command)#

Write a command and wait for it to be reported as Done or Fail by AT.

Parameters:

command (CommonCommand) – The command to wait for.

Return type:

None

async wait_fail_reason_event(sequence_id)#

Wait for the fail reason event to arrive.

If the fail reason event doesn’t arrive after FAIL_REASON_TIMEOUT the issued command is set to FAIL without a reason.

Parameters:

sequence_id (int) – The ID of the issued command.

Return type:

None

async wait_fututre_done_or_fault(future)#

Wait for either the future to be done or for the CSC to go to FAULT, whichever comes first.

Parameters:

future (Future)

Return type:

None

async write_command(command, **params)#

Write the command JSON string to the TCP/IP command/event server.

Parameters:
  • command (str) – The command to write.

  • **params (typing.Any) – The parameters for the command. This may be empty.

Returns:

command_issued – An instance of CommandIssued to monitor the future state of the command.

Return type:

CommandIssued

Notes

If no command parameters are passed on then a default parameter named value is added since the real ATMCS expects this. This will be removed in DM-39629.