Controller¶
-
class
lsst.ts.salobj.
Controller
(name, index=None, *, do_callbacks=False)¶ Bases:
object
A class that receives commands for a SAL component and sends telemetry and events from that component.
This class provides much of the behavior for
BaseCsc
, basically everything except the standard summary states and associated transition commands.Parameters: - name :
str
Name of SAL component.
- index :
int
orNone
(optional) SAL component index, or 0 or None if the component is not indexed. A value is required if the component is indexed.
- do_callbacks :
bool
(optional) Set
do_<name>
methods as callbacks for commands? If True then there must be exactly onedo_<name>
method for each command.
Notes
Writing a Controller
(To write a CSC see Writing a CSC, instead)
To write a controller that is not a CSC (one that does not provide the standard summary states and associated state transition commands):
- Inherit from this class.
- Provide all Required Logging Attributes; these are automatically provided to CSCs, but not other controllers.
- Implement
close_tasks
.
Here is an example that makes a Test controller and displays the topic-related attributes, but has no code to do anything useful with those topics (see
TestCsc
for that):include salobj # the index is arbitrary, but a remote must use the same index # to talk to this controller test_controller = salobj.Controller("Test", index=5) print(dir(test_controller))
You should see the following topic-related attributes:
Commands, each an instance of
topics.ControllerCommand
:cmd_standby
cmd_start
- … and so on for all other standard CSC commands
cmd_setArrays
cmd_setScalars
Events, each an instance of
topics.ControllerEvent
:evt_appliedSettingsMatchStart
evt_errorCode
- … and so on for all other standard CSC events
evt_arrays
evt_scalars
Telemetry, each an instance of
topics.ControllerTelemetry
(note that there are no standard CSC telemetry topics):tel_arrays
tel_scalars
Required Logging Attributes
Each
Controller
must support the following topics, as specified in ts_xml inSALGenerics.xml
:- setLogLevel command
- logLevel event
- logMessage event
Attributes: - log :
logging.Logger
A logger.
- salinfo :
SalInfo
SAL info.
- cmd_<command_name> :
topics.ControllerCommand
Controller command topic. There is one for each command supported by the SAL component.
- evt_<event_name> :
topics.ControllerEvent
Controller event topic. There is one for each event topic supported by the SAL component.
- tel_<telemetry_name> :
topics.ControllerTelemetry
Controller telemetry topic. There is one for each telemetry topic supported by the SAL component.
Attributes Summary
domain
Methods Summary
close
([exception])Shut down, clean up resources and set done_task done. close_tasks
()Shut down pending tasks. do_setLogLevel
(data)Set logging level. put_log_level
()Output the logLevel event. start
()Finish construction. Attributes Documentation
-
domain
¶
Methods Documentation
-
close
(exception=None)¶ 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 ofclose
, unless you have a good reason to do otherwise.Parameters: 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
()¶ Shut down pending tasks. Called by
close
.Perform all cleanup other than disabling logging to SAL and closing the dds domain.
-
do_setLogLevel
(data)¶ Set logging level.
Parameters: - data :
cmd_setLogLevel.DataType
Logging level.
- data :
-
put_log_level
()¶ Output the logLevel event.
-
start
()¶ Finish construction.
- name :