Model¶
- class lsst.ts.m2gui.Model(log: Logger, host: str = 'localhost', port_command: int = 50010, port_telemetry: int = 50011, timeout_connection: float = 10.0, is_simulation_mode: bool = False)¶
Bases:
objectModel class of the application.
Parameters¶
- log
logging.Logger A logger.
- host
str, optional Host address. (the default is “localhost”)
- port_command
int, optional Command port to connect. (the default is 50010)
- port_telemetry
int, optional Telemetry port to connect. (the default is 50011)
- timeout_connection
float, optional Connection timeout in second. (the default is 10.0)
- is_simulation_mode:
bool, optional True if running in simulation mode. (the default is False)
Attributes¶
- log
logging.Logger A logger.
- is_csc_commander
bool Commandable SAL component (CSC) is the commander or not.
- local_modeenum
LocalMode Local model.
- is_closed_loop
bool Closed-loop control is on or not.
- inclination_sourceenum
MTM2.InclinationTelemetrySource Inclination telemetry source.
- signal_control
SignalControl Signal to report the control status.
- signal_power_system
SignalPowerSystem Signal to report the power system status.
- signal_status
SignalStatus Signal to report the updated status of system.
- signal_config
SignalConfig Signal to send the configuration.
- signal_script
SignalScript Signal to send the script progress.
- signal_ilc_status
SignalIlcStatus Signal to send the inner-loop controller (ILC) status.
- signal_closed_loop_control_mode
SignalClosedLoopControlMode Signal to send the update status of closed-loop control mode.
- system_status
dict System status.
- fault_manager
FaultManager Fault manager to record the system error.
- utility_monitor
UtilityMonitor Utility monitor to monitor the utility status.
- controller
lsst.ts.m2com.ControllerCell Controller to do the TCP/IP communication with the servers of M2 cell.
- duration_refresh
int Duration to refresh the data in milliseconds.
- ilc_retry_times
int Retry times to transition the inner-loop controller (ILC) state.
- ilc_timeout
float Timeout in second for the transition of ILC state.
Methods Summary
apply_actuator_force(actuators, force)Apply the actuator force.
clear_error(error)Clear the error.
command_actuator(command[, actuators, ...])Run the actuator command.
command_script(command[, script_name, ...])Run the script command.
connect([time_process])Connect to the M2 controller.
Disconnect from the M2 controller.
Transition from the Standby mode to the Diagnostic mode.
Transition from the Diagnostic mode to the Enable mode.
Transition from the Diagnostic mode to the Standby mode.
Transition from the Enable mode to the Diagnostic mode.
fault()Fault the system and transition to the Diagnostic mode if the system is in the Enable mode originally.
get_actuator_default_status(status)Get the default actuator status.
Get the current force limits.
go_to_position(x, y, z, rx, ry, rz)Go to the position.
The system is in the Enabled state and closed-loop control or not.
The system is in the Enabled state and open-loop control or not.
Reboot the cell controller.
report_config(**kwargs)Report the configuration defined in Config class.
Report the control status.
report_error(error)Report the error.
report_script_progress(progress)Report the script progress.
reset_breakers(power_type)Reset the breakers.
Reset errors.
update_connection_information(host, ...)Update the connection information.
update_system_status(status_name, new_status)Update the system status.
Methods Documentation
- async apply_actuator_force(actuators: list[int], force: float) None¶
Apply the actuator force.
Parameters¶
- actuators
list Selected actuators to do the movement. If the empty list [] is passed, the function will raise the RuntimeError.
- force
float Force to apply in Newton.
Raises¶
RuntimeErrorNo actuator is selected.
RuntimeErrorNot in the enabled state with closed-loop control.
- actuators
- async command_actuator(command: CommandActuator, actuators: list[int] | None = None, target_displacement: float | int = 0, unit: ActuatorDisplacementUnit = ActuatorDisplacementUnit.Millimeter) None¶
Run the actuator command.
Parameters¶
- commandenum
lsst.ts.m2com.CommandActuator Actuator command.
- actuators
list[int]or None, optional Selected actuators to do the movement. If the empty list [] is passed, the function will raise the RuntimeError. (the default is None)
- target_displacement
floatorint, optional Target displacement of the actuators. (the default is 0)
- unitenum
lsst.ts.m2com.ActuatorDisplacementUnit, optional Displacement unit. (the default is ActuatorDisplacementUnit.Millimeter)
Raises¶
RuntimeErrorNot in the enabled state with open-loop control.
- commandenum
- async command_script(command: CommandScript, script_name: str | None = None, bypass_state_checking: bool = False) None¶
Run the script command.
Parameters¶
- commandenum
lsst.ts.m2com.CommandScript Script command.
- script_name
stror None, optional Name of the script. (the default is None)
- bypass_state_checking
bool, optional Bypass the state checking or not. (the default is False)
Raises¶
RuntimeErrorNot in the enabled state.
- commandenum
- async connect(time_process: float = 3.0) None¶
Connect to the M2 controller.
Parameters¶
- time_process
float, optional Waiting time to let the application processes the received welcome messages. (the default is 3.0)
Raises¶
RuntimeErrorThere is the connection with the M2 controller already.
- time_process
- async disconnect() None¶
Disconnect from the M2 controller.
- async enter_diagnostic() bool¶
Transition from the Standby mode to the Diagnostic mode.
Returns¶
boolTrue if the communication power is on already, which implies the commandable SAL component (CSC) is using the M2 now. Otherwise, False.
Raises¶
RuntimeErrorWhen the system is not in the Standby mode.
- async enter_enable() bool¶
Transition from the Diagnostic mode to the Enable mode.
Returns¶
boolTrue if the motor power is on already, which implies the commandable SAL component (CSC) is using the M2 now. Otherwise, False.
Raises¶
RuntimeErrorWhen the system is not in the Diagnostic mode.
- async exit_diagnostic() None¶
Transition from the Diagnostic mode to the Standby mode.
Raises¶
RuntimeErrorWhen the system is not in the Diagnostic mode.
- async exit_enable() None¶
Transition from the Enable mode to the Diagnostic mode.
Raises¶
RuntimeErrorWhen the system is not in the Enable mode.
- async fault() None¶
Fault the system and transition to the Diagnostic mode if the system is in the Enable mode originally.
- get_actuator_default_status(status: Any) dict¶
Get the default actuator status.
Parameters¶
- status
any Default status.
Returns¶
- collection
dict Collection of default actuator status.
- status
- get_current_force_limits() tuple[float, float]¶
Get the current force limits.
Returns¶
floatMaximum axial force in Newton.
floatMaximum tangent force in Newton.
- async go_to_position(x: float, y: float, z: float, rx: float, ry: float, rz: float) None¶
Go to the position.
Parameters¶
- x
float Position x in um.
- y
float Position y in um.
- z
float Position z in um.
- rx
float Rotation x in arcsec.
- ry
float Rotation y in arcsec.
- rz
float Rotation z in arcsec.
Raises¶
RuntimeErrorNot in the closed-loop control.
- x
- is_enabled_and_closed_loop_control() bool¶
The system is in the Enabled state and closed-loop control or not.
Returns¶
boolTrue if the system is in the Enabled state and closed-loop control. Otherwise, False.
- is_enabled_and_open_loop_control() bool¶
The system is in the Enabled state and open-loop control or not.
Returns¶
boolTrue if the system is in the Enabled state and open-loop control. Otherwise, False.
- async reboot_controller() None¶
Reboot the cell controller.
Raises¶
RuntimeErrorNot in the standby state with local control.
- report_config(**kwargs: dict[str, Any]) Config¶
Report the configuration defined in Config class.
Parameters¶
- **kwargs
dict Configuration key-value pairs. The available keys are defined in Config class.
Returns¶
- config
Config Configuration.
Raises¶
KeyErrorKey name does not exist in the Config class.
- **kwargs
- report_control_status() None¶
Report the control status.
- report_script_progress(progress: int) None¶
Report the script progress.
Parameters¶
- progress
int Progress of the script execution (0-100%).
- progress
- async reset_breakers(power_type: PowerType) None¶
Reset the breakers.
Parameters¶
- power_typeenum
MTM2.PowerType Power type.
- power_typeenum
- async reset_errors() None¶
Reset errors.
- update_connection_information(host: str, port_command: int, port_telemetry: int, timeout_connection: float) None¶
Update the connection information.
Parameters¶
- host
str Host address.
- port_command
int Command port to connect.
- port_telemetry
int Telemetry port to connect.
- timeout_connection
float Connection timeout in second.
Raises¶
RuntimeErrorThere is the connection with the M2 controller already.
ValueErrorWhen the command port equals to the telemetry port.
- host
- log