MockMTRotatorController¶
-
class
lsst.ts.rotator.
MockMTRotatorController
(log, host='127.0.0.1', command_port=5571, telemetry_port=5570, initial_state=<ControllerState.OFFLINE: 3>)¶ Bases:
lsst.ts.hexrotcomm.base_mock_controller.BaseMockController
Mock MT rotator controller that talks over TCP/IP.
Parameters: - log :
logging.Logger
Logger.
- host :
str
(optional) IP address of CSC server.
- command_port :
int
(optional) Command socket port. This argument is intended for unit tests; use the default value for normal operation.
- telemetry_port :
int
(optional) Telemetry socket port. This argument is intended for unit tests; use the default value for normal operation.
- initial_state :
lsst.ts.idl.enums.Rotator.ControllerState
(optional) Initial state of mock controller.
Notes
To start the mock controller:
ctrl = MockRotatorController(…) await ctrl.connect_taskTo stop the server:
await ctrl.stop()Known Limitations
- Constant-velocity motion is not supported.
- The path generator is very primitive; acceleration is presently instantaneous. This could be improved by using code from the ATMCS simulator.
- I am not sure what the real controller does if a track command is late; for now the simulator goes into FAULT.
Attributes Summary
command_connected
Return True if the command socket is connected. connect_retry_interval
connected
Return True if command and telemetry sockets are connected. enabled_substate
offline_substate
state
telemetry_connected
Return True if the telemetry socket is connected. telemetry_interval
Methods Summary
assert_state
(state[, offline_substate, …])assert_stationary
()close
()Kill command and telemetry tasks and close the connections. command_loop
()Read and execute commands. connect
()Connect the sockets. connect_command
()Connect or reconnect to the command socket. connect_telemetry
()Connect or reconnect to the telemetry/configuration socket. do_clearError
(data)do_clear_error
(command)do_config_accel
(command)do_config_vel
(command)do_constant_velocity
(command)do_disable
(command)do_enable
(command)do_enter_control
(command)do_exit
(command)do_move_point_to_point
(command)do_position_set
(command)do_set_constant_vel
(command)do_standby
(command)do_start
(command)do_stop
(command)do_track
(command)do_track_vel_cmd
(command)end_run_command
(command, cmd_method)Called when run_command is done. get_command_key
(command)Return the key to command_table. run_command
(command)Run a command. set_state
(state)Set the current state and substates. telemetry_loop
()Write configuration once, then telemetry at regular intervals. tracking_timer
()If this times out then go into a FAULT state. update_and_get_header
(frame_id)Update the config or telemetry header and return it. update_telemetry
()Update self.client.telemetry. write_config
()Write the current configuration. Attributes Documentation
-
command_connected
¶ Return True if the command socket is connected.
-
connect_retry_interval
= 0.1¶
-
connected
¶ Return True if command and telemetry sockets are connected.
-
enabled_substate
¶
-
offline_substate
¶
-
state
¶
-
telemetry_connected
¶ Return True if the telemetry socket is connected.
-
telemetry_interval
= 0.1¶
Methods Documentation
-
assert_state
(state, offline_substate=None, enabled_substate=None)¶
-
assert_stationary
()¶
-
close
()¶ Kill command and telemetry tasks and close the connections.
Always safe to call.
-
command_loop
()¶ Read and execute commands.
-
connect
()¶ Connect the sockets.
Notes
This will wait forever for a connection.
-
connect_command
()¶ Connect or reconnect to the command socket.
Notes
This will wait forever for a connection.
-
connect_telemetry
()¶ Connect or reconnect to the telemetry/configuration socket.
Notes
This will wait forever for a connection.
-
do_clearError
(data)¶
-
do_clear_error
(command)¶
-
do_config_accel
(command)¶
-
do_config_vel
(command)¶
-
do_constant_velocity
(command)¶
-
do_disable
(command)¶
-
do_enable
(command)¶
-
do_enter_control
(command)¶
-
do_exit
(command)¶
-
do_move_point_to_point
(command)¶
-
do_position_set
(command)¶
-
do_set_constant_vel
(command)¶
-
do_standby
(command)¶
-
do_start
(command)¶
-
do_stop
(command)¶
-
do_track
(command)¶
-
do_track_vel_cmd
(command)¶
-
end_run_command
(command, cmd_method)¶ Called when run_command is done.
Can be used to clear the set position.
-
get_command_key
(command)¶ Return the key to command_table.
-
run_command
(command)¶ Run a command.
Parameters: - command :
Command
Command to run.
- command :
-
set_state
(state)¶ Set the current state and substates.
Parameters: - state :
lsst.ts.idl.enums.Rotator.ControllerState
orint
New state.
Notes
Sets the substates as follows:
lsst.ts.idl.enums.Rotator.OfflineSubstate.AVAILABLE
if state ==lsst.ts.idl.enums.Rotator.ControllerState.OFFLINE
lsst.ts.idl.enums.Rotator.EnabledSubstate.STATIONARY
if state ==lsst.ts.idl.enums.Rotator.ControllerState.ENABLED
The real controller goes to substate
lsst.ts.idl.enums.Rotator.OfflineSubstate.PUBLISH_ONLY
when going offline, but requires the engineering user interface (EUI) to get out of that state, and we don’t have an EUI for the mock controller!- state :
-
telemetry_loop
()¶ Write configuration once, then telemetry at regular intervals.
-
tracking_timer
()¶ If this times out then go into a FAULT state.
Used to make sure TRACK commands arrive often enough.
-
update_and_get_header
(frame_id)¶ Update the config or telemetry header and return it.
Call this prior to writing telemetry or configuration.
Parameters: - frame_id :
int
Frame ID of header to write.
- frame_id :
-
update_telemetry
()¶ Update self.client.telemetry.
-
write_config
()¶ Write the current configuration.
- log :