MTDomeCsc

class lsst.ts.MTDome.MTDomeCsc(config_dir=None, initial_state=<State.STANDBY: 5>, simulation_mode=0, mock_port=None)

Bases: lsst.ts.salobj.configurable_csc.ConfigurableCsc

Upper level Commandable SAL Component to interface with the Simonyi Survey Telescope Dome lower level components.

Parameters:
config_dir : string

The configuration directory

initial_state : salobj.State

The initial state of the CSC

simulation_mode : int

Simulation mode. Allowed values:

  • 0: regular operation.
  • 1: simulation: use a mock low level HVAC controller.
mock_port : int

The port that the mock controller will listen on

Notes

Simulation Modes

Supported simulation modes:

  • 0: regular operation
  • 1: simulation mode: start a mock TCP/IP Dome controller and talk to it

Attributes Summary

config_dir Get or set the configuration directory.
connected
default_initial_state
disabled_or_enabled Return True if the summary state is State.DISABLED or State.ENABLED.
domain
enable_cmdline_state
require_settings
simulation_mode Get the current simulation mode.
summary_state Get the summary state as a State enum.
valid_simulation_modes

Methods Summary

add_arguments(parser) Add arguments to the parser created by make_from_cmd_line.
add_kwargs_from_args(args, kwargs) Add constructor keyword arguments based on parsed arguments.
amain(index, **kwargs) Make a CSC from command-line arguments and run it.
assert_enabled([action]) Assert that an action that requires ENABLED state can be run.
begin_disable(data) Begin do_disable; called before state changes.
begin_enable(data) Begin do_enable; called before state changes.
begin_exitControl(data) Begin do_exitControl; called before state changes.
begin_standby(data) Begin do_standby; called before the state changes.
begin_start(data) Begin do_start; configure the CSC before changing state.
cancel_status_tasks() Cancel all status tasks.
close([exception, cancel_start]) Shut down, clean up resources and set done_task done.
close_tasks() Disconnect from the TCP/IP controller, if connected, and stop the mock controller, if running.
config_llcs(system, settings) Config command not to be executed by SAL.
configure(config) Configure the CSC.
connect() Connect to the dome controller’s TCP/IP port.
disconnect() Disconnect from the TCP/IP controller, if connected, and stop the mock controller, if running.
do_closeLouvers(data) Close Louvers.
do_closeShutter(data) Close Shutter.
do_crawlAz(data) Crawl AZ.
do_crawlEl(data) Crawl El.
do_disable(data) Transition from State.ENABLED to State.DISABLED.
do_enable(data) Transition from State.DISABLED to State.ENABLED.
do_exitControl(data) Transition from State.STANDBY to State.OFFLINE and quit.
do_moveAz(data) Move AZ.
do_moveEl(data) Move El.
do_openShutter(data) Open Shutter.
do_park(data) Park.
do_setAuthList(data) Update the authorization list.
do_setLogLevel(data) Set logging level.
do_setLouvers(data) Set Louver.
do_setTemperature(data) Set Temperature.
do_standby(data) Transition from State.DISABLED or State.FAULT to State.STANDBY.
do_start(data) Transition from State.STANDBY to State.DISABLED.
do_stop(data) Stop.
do_stopAz(data) Stop AZ.
do_stopEl(data) Stop El.
do_stopLouvers(data) Stop Louvers.
do_stopShutter(data) Stop Shutter.
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_exitControl(data) End do_exitControl; 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.
fans(data) Fans command not to be executed by SAL.
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.
handle_summary_state() Override of the handle_summary_state function to connect or disconnect to the lower level components (or the mock_controller) when needed.
implement_simulation_mode(simulation_mode) Implement going into or out of simulation mode.
inflate(data) Inflate command not to be executed by SAL.
make_from_cmd_line(index, **kwargs) Construct a CSC from command line arguments.
one_status_loop(method, interval) Run one status method forever at the specified interval.
put_log_level() Output the logLevel event.
read_config_dir() Set self.config_label_dict and output evt_settingVersions.
remove_keys_from_dict(dict_with_too_many_keys) Return a copy of a dict with specified items removed.
report_summary_state() Report a new value for summary_state, including current state.
request_and_send_llc_status(llc_name, topic) Generic method for retrieving the status of a lower level component and publish that on the corresponding telemetry topic.
send_telemetry(telemetry, topic) Prepares the telemetry for sending using the provided status and sends it.
set_simulation_mode(simulation_mode) Set the simulation mode.
start() Finish constructing the CSC.
start_mock_ctrl() Start the mock controller.
start_status_tasks() Start all status tasks.
statusAMCS() AMCS status command not to be executed by SAL.
statusApSCS() ApSCS status command not to be executed by SAL.
statusLCS() LCS status command not to be executed by SAL.
statusLWSCS() LWSCS status command not to be executed by SAL.
statusMonCS() MonCS status command not to be executed by SAL.
statusThCS() ThCS status command not to be executed by SAL.
stop_mock_ctrl() Stop the mock controller, if running.
write_then_read_reply(command, **params) Write the cmd string and then read the reply to the command.

Attributes Documentation

config_dir

Get or set the configuration directory.

Parameters:
config_dir : str, bytes, or pathlib.Path

New configuration directory.

Returns:
config_dir : pathlib.Path

Absolute path to the configuration directory.

Raises:
ValueError

If the new configuration dir is not a directory.

connected
default_initial_state = 5
disabled_or_enabled

Return True if the summary state is State.DISABLED or State.ENABLED.

This is useful in handle_summary_state to determine if you should start or stop a telemetry loop, and connect to or disconnect from an external controller

domain
enable_cmdline_state = False
require_settings = False
simulation_mode

Get the current simulation mode.

0 means normal operation (no simulation).

Raises:
ExpectedError

If the new simulation mode is not a supported value.

summary_state

Get the summary state as a State enum.

valid_simulation_modes = (0, 1)

Methods Documentation

classmethod add_arguments(parser)

Add arguments to the parser created by make_from_cmd_line.

Parameters:
parser : argparse.ArgumentParser

The argument parser.

Notes

If you override this method then you should almost certainly override add_kwargs_from_args as well.

classmethod add_kwargs_from_args(args, kwargs)

Add constructor keyword arguments based on parsed arguments.

Parameters:
args : argparse.namespace

Parsed command.

kwargs : dict

Keyword argument dict for the constructor. Update this based on args. The index argument will already be present if relevant.

Notes

If you override this method then you should almost certainly override add_arguments as well.

classmethod amain(index, **kwargs)

Make a CSC from command-line arguments and run it.

Parameters:
index : int, enum.IntEnum, True, False or None

If the CSC is indexed: specify True make index a required command-line argument that accepts any index, or an enum.IntEnum class to make index a required command-line argument that only accepts the enum values. If the CSC is not indexed specify None or 0.

**kwargs : dict, optional

Additional keyword arguments for your CSC’s constructor.

assert_enabled(action='')

Assert that an action that requires ENABLED state can be run.

Parameters:
action : str, optional

Action attempted. Not needed if this is called at the beginning of a do_... method, since the user will know what command was called.

begin_disable(data)

Begin do_disable; called before state changes.

Parameters:
data : DataType

Command data

begin_enable(data)

Begin do_enable; called before state changes.

Parameters:
data : DataType

Command data

begin_exitControl(data)

Begin do_exitControl; called before state changes.

Parameters:
data : DataType

Command data

begin_standby(data)

Begin do_standby; called before the state changes.

Parameters:
data : DataType

Command data

begin_start(data)

Begin do_start; configure the CSC before changing state.

Parameters:
data : cmd_start.DataType

Command data

Notes

The settingsToApply field must be one of:

  • The name of a config label or config file
  • The name and version of a config file, formatted as <file_name>:<version>, where the version is a git reference, such as a git tag or commit hash. This form does not support labels.
cancel_status_tasks()

Cancel all status tasks.

close(exception=None, cancel_start=True)

Shut down, clean up resources and set done_task done.

May be called multiple times. The first call closes the Controller; subsequent calls wait until the Controller is closed.

Subclasses should override close_tasks instead of close, unless you have a good reason to do otherwise.

Parameters:
exception : Exception, optional

The exception that caused stopping, if any, in which case the self.done_task exception is set to this value. Specify None for a normal exit, in which case the self.done_task result is set to None.

cancel_start : bool, optional

Cancel the start task? Leave this true unless calling this from the start task.

Notes

Removes the SAL log handler, calls close_tasks to stop all background tasks, pauses briefly to allow final SAL messages to be sent, then closes the dds domain.

close_tasks()

Disconnect from the TCP/IP controller, if connected, and stop the mock controller, if running.

config_llcs(system, settings)

Config command not to be executed by SAL.

This command will be used to send the values of one or more parameters to configure the lower level components.

Parameters:
system: `str`

The name of the lower level component to configure.

settings : dict

A dict containing key,value for all the parameters that need to be configured. The structure is:

"jmax"
"amax"
"vmax"
configure(config)

Configure the CSC.

Parameters:
config : object

The configuration as described by the schema at schema_path, as a struct-like object.

Notes

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

connect()

Connect to the dome controller’s TCP/IP port.

Start the mock controller, if simulating.

disconnect()

Disconnect from the TCP/IP controller, if connected, and stop the mock controller, if running.

do_closeLouvers(data)

Close Louvers.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_closeShutter(data)

Close Shutter.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_crawlAz(data)

Crawl AZ.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_crawlEl(data)

Crawl El.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_disable(data)

Transition from State.ENABLED to State.DISABLED.

Parameters:
data : cmd_disable.DataType

Command data

do_enable(data)

Transition from State.DISABLED to State.ENABLED.

Parameters:
data : cmd_enable.DataType

Command data

do_exitControl(data)

Transition from State.STANDBY to State.OFFLINE and quit.

Parameters:
data : cmd_exitControl.DataType

Command data

do_moveAz(data)

Move AZ.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_moveEl(data)

Move El.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_openShutter(data)

Open Shutter.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_park(data)

Park.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_setAuthList(data)

Update the authorization list.

Parameters:
data : cmd_setAuthList.DataType

Authorization lists.

Notes

Add items if the data string starts with “+”, ignoring duplicates (both with respect to the existing items and within the data string). Remove items if the data string starts with “-“, ignoring missing items (items specified for removal that do not exist). Ignore whitespace after each comma and after the +/- prefix.

do_setLogLevel(data)

Set logging level.

Parameters:
data : cmd_setLogLevel.DataType

Logging level.

do_setLouvers(data)

Set Louver.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_setTemperature(data)

Set Temperature.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_standby(data)

Transition from State.DISABLED or State.FAULT to State.STANDBY.

Parameters:
data : cmd_standby.DataType

Command data

do_start(data)

Transition from State.STANDBY to State.DISABLED.

Parameters:
data : cmd_start.DataType

Command data

do_stop(data)

Stop.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_stopAz(data)

Stop AZ.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_stopEl(data)

Stop El.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_stopLouvers(data)

Stop Louvers.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

do_stopShutter(data)

Stop Shutter.

Parameters:
data : A SALOBJ data object

Contains the data as defined in the SAL XML file.

end_disable(data)

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

Parameters:
data : DataType

Command data

end_enable(data)

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

Parameters:
data : DataType

Command data

end_exitControl(data)

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

Parameters:
data : DataType

Command data

end_standby(data)

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

Parameters:
data : DataType

Command data

end_start(data)

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

Parameters:
data : DataType

Command data

fans(data)

Fans command not to be executed by SAL.

This command will be used to switch on or off the fans in the dome.

Parameters:
data : dict

A dictionary with arguments to the function call. It should contain the key “action” with a string value (ON or OFF).

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.

static get_config_pkg()

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

handle_summary_state()

Override of the handle_summary_state function to connect or disconnect to the lower level components (or the mock_controller) when needed.

implement_simulation_mode(simulation_mode)

Implement going into or out of simulation mode.

Deprecated. See simulation mode for details.

Parameters:
simulation_mode : int

Requested simulation mode; 0 for normal operation.

Raises:
ExpectedError

If simulation_mode is not a supported value.

inflate(data)

Inflate command not to be executed by SAL.

This command will be used to inflate or deflate the inflatable seal.

Parameters:
data : dict

A dictionary with arguments to the function call. It should contain the key “action” with a string value (ON or OFF).

classmethod make_from_cmd_line(index, **kwargs)

Construct a CSC from command line arguments.

Parameters:
index : int, enum.IntEnum, True, False or None

If the CSC is indexed: specify True make index a required command-line argument that accepts any index, or an enum.IntEnum class to make index a required command-line argument that only accepts the enum values. If the CSC is not indexed specify None or 0.

**kwargs : dict, optional

Additional keyword arguments for your CSC’s constructor.

Returns:
csc : cls

The CSC.

Notes

To add additional command-line arguments, override add_arguments and add_kwargs_from_args.

one_status_loop(method, interval)

Run one status method forever at the specified interval.

Parameters:
method: coro

The status method to run

interval: `float`

The interval (sec) at which to run the status method.

put_log_level()

Output the logLevel event.

read_config_dir()

Set self.config_label_dict and output evt_settingVersions.

Set self.config_label_dict from self.config_dir/_labels.yaml. Output the settingVersions event (if changed) as follows:

  • recommendedSettingsLabels is a comma-separated list of labels in self.config_label_dict, truncated by omitting labels if necessary.
  • recommendedSettingsVersion is derived from git information for self.config_dir, if it is a git repository, else “”.
remove_keys_from_dict(dict_with_too_many_keys)

Return a copy of a dict with specified items removed.

Parameters:
dict_with_too_many_keys : dict

The dict where to remove the keys from.

Returns:
dict_with_keys_removed : dict

A dict with the same keys as the given dict but with the given keys removed.

report_summary_state()

Report a new value for summary_state, including current state.

Subclasses may wish to override for code that depends on the current state (rather than the state transition command that got it into that state).

request_and_send_llc_status(llc_name, topic)

Generic method for retrieving the status of a lower level component and publish that on the corresponding telemetry topic.

Parameters:
llc_name: `LlcName`

The name of the lower level component.

topic: SAL topic

The SAL topic to publish the telemetry to.

send_telemetry(telemetry, topic)

Prepares the telemetry for sending using the provided status and sends it.

Parameters:
telemetry: `dict`

The lower level telemetry to extract the telemetry from.

topic: SAL topic

The SAL topic to publish the telemetry to.

set_simulation_mode(simulation_mode)

Set the simulation mode.

Await implement_simulation_mode, update the simulation mode property and report the new value.

Parameters:
simulation_mode : int

Requested simulation mode; 0 for normal operation.

start()

Finish constructing the CSC.

  • If initial_summary_state is State.DISABLED or State.ENABLED then call configure.
  • Run BaseCsc.start
start_mock_ctrl()

Start the mock controller.

The simulation mode must be 1.

start_status_tasks()

Start all status tasks.

statusAMCS()

AMCS status command not to be executed by SAL.

This command will be used to request the full status of the AMCS lower level component.

statusApSCS()

ApSCS status command not to be executed by SAL.

This command will be used to request the full status of the ApSCS lower level component.

statusLCS()

LCS status command not to be executed by SAL.

This command will be used to request the full status of the LCS lower level component.

statusLWSCS()

LWSCS status command not to be executed by SAL.

This command will be used to request the full status of the LWSCS lower level component.

statusMonCS()

MonCS status command not to be executed by SAL.

This command will be used to request the full status of the MonCS lower level component.

statusThCS()

ThCS status command not to be executed by SAL.

This command will be used to request the full status of the ThCS lower level component.

stop_mock_ctrl()

Stop the mock controller, if running.

write_then_read_reply(command, **params)

Write the cmd string and then read the reply to the command.

Parameters:
command: `str`

The command to write.

**params:

The parameters for the command. This may be empty.

Returns:
data : dict

A dict of the form {“response”: ResponseCode, “timeout”: TimeoutValue} where “response” can be zero for “OK” or non-zero for “ERROR”.