HexapodCommander¶
-
class
lsst.ts.hexapod.
HexapodCommander
(index, enable)¶ Bases:
lsst.ts.salobj.csc_commander.CscCommander
Command the Hexapod CSC from the command line.
Parameters: - index :
int
SAL index of Hexapod CSC.
- Read commands from stdin and write updated events and telemetry to stdout.
- The telemetry is filtered so that tiny changes due to encoder jitter
- are ignored.
- See bin/command_hexapod.py for an example of how to use this class.
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)Construct the commander and run it. check_arguments
(args, *names)Check that the required arguments are provided, and return them as a keyword argument dict with cast values. close
()Close the commander, prior to quitting. do_start
(args)Allow the start command to have no arguments. event_callback
(data, name)Generic callback for events. evt_summaryState_callback
(data)field_is_public
(name)Return True if the specified field name is public, False otherwise. format_data
(data)Format an event or telemetry sample for printing. format_item
(key, value)Format one event or telemetry field for printing. get_commands_help
()Get help for each command, as a list of strings. get_public_data
(data)Return a dict of field_name: value for public fields. get_rounded_public_fields
(data[, digits])Get the public fields for a sample, with float values rounded. make_from_cmd_line
(index, **kwargs)Construct a SAL-related class from command line arguments. output
(str)Print a string to output, appending a final newline. positions_close
(position1, position2)Return True if two positions are nearly equal. print_help
()Print help. run_command
(cmd)Run the specified command string and wait for it to finish. run_command_topic
(command_name, args)Run a command that has an associated salobj RemoteCommand topic. start
()Start asynchonous processes. tel_actuators_callback
(data)Callback for actuators telemetry. tel_application_callback
(data)Callback for the application telemetry. telemetry_callback
(data, name)Generic callback for telemetry. 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.- parser :
-
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.- args :
-
classmethod
amain
(*, index, **kwargs)¶ Construct the commander and run it.
Parse the command line to construct the commander, then parse and execute commands until the
exit
is seen.Parameters:
-
check_arguments
(args, *names)¶ Check that the required arguments are provided, and return them as a keyword argument dict with cast values.
Parameters: - args :
List
[str
] Command arguments, as strings.
- *names :
List
[str
ortuple
] Argument name and optional cast function. Each element is either:
- An argument name, in which case the argument is cast to a float
- A tuple of (name, cast function), in which case the argument
- is cast using the cast function.
- args :
-
close
()¶ Close the commander, prior to quitting.
-
do_start
(args)¶ Allow the start command to have no arguments.
-
event_callback
(data, name)¶ Generic callback for events.
You may provide evt_<event_name> methods to override printing of specific events.
-
evt_summaryState_callback
(data)¶
-
field_is_public
(name)¶ Return True if the specified field name is public, False otherwise.
-
format_data
(data)¶ Format an event or telemetry sample for printing.
-
format_item
(key, value)¶ Format one event or telemetry field for printing.
-
get_commands_help
()¶ Get help for each command, as a list of strings.
End with “Other Commands:” and any commands in help_dict that are not in command_dict.
-
get_public_data
(data)¶ Return a dict of field_name: value for public fields.
Parameters: - data :
dds_sample
DDS sample.
- data :
-
get_rounded_public_fields
(data, digits=4)¶ Get the public fields for a sample, with float values rounded.
-
classmethod
make_from_cmd_line
(index, **kwargs)¶ Construct a SAL-related class from command line arguments.
Parameters: - index :
int
,True
,False
orNone
If the SAL component is indexed: specify
True
to make index a required command line argument, or specify a non-zeroint
to use that index. If the SAL component is not indexed: specifyNone
or 0.- **kwargs :
dict
, optional Additional keyword arguments for your class’s constructor.
Returns: - instance :
cls
The constructed instance.
Notes
To add additional command-line arguments, override
add_arguments
andadd_kwargs_from_args
.- index :
-
output
(str)¶ Print a string to output, appending a final newline.
Please call this instead of print to support unit tests.
If
self.testing
is True then appendstr
toself.output_queue
instead of printing it. Use this mode for unit testing a CSC commander.
-
positions_close
(position1, position2)¶ Return True if two positions are nearly equal.
Parameters:
-
print_help
()¶ Print help.
-
run_command
(cmd)¶ Run the specified command string and wait for it to finish.
Parameters: - cmd :
str
Command string (command name and arguments). Note: does not handle the “exit” command.
- cmd :
-
run_command_topic
(command_name, args)¶ Run a command that has an associated salobj RemoteCommand topic.
Parameters: Notes
This method works for command topics that take scalar arguments. To support command topics with more exotic arguments you must provide a do_<command> method that parses the arguments and add an entry to self.help_dict.
-
start
()¶ Start asynchonous processes.
-
tel_actuators_callback
(data)¶ Callback for actuators telemetry.
Output actuators telemetry data if the values have changed enough to be interesting.
Parameters: - data : self.controller.tel_actuators.DataType.
Actuators data.
-
tel_application_callback
(data)¶ Callback for the application telemetry.
Output application telemetry if the values have changed enough to be interesting.
Parameters: - data : self.controller.tel_application.DataType.
Actuators data.
-
telemetry_callback
(data, name)¶ Generic callback for telemetry.
You may provide tel_<telemetry_name> methods to override printing of specific telemetry topics.
- index :