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: object

Model class of the application.

Parameters

loglogging.Logger

A logger.

hoststr, optional

Host address. (the default is “localhost”)

port_commandint, optional

Command port to connect. (the default is 50010)

port_telemetryint, optional

Telemetry port to connect. (the default is 50011)

timeout_connectionfloat, 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

loglogging.Logger

A logger.

is_csc_commanderbool

Commandable SAL component (CSC) is the commander or not.

local_modeenum LocalMode

Local model.

is_closed_loopbool

Closed-loop control is on or not.

inclination_sourceenum MTM2.InclinationTelemetrySource

Inclination telemetry source.

signal_controlSignalControl

Signal to report the control status.

signal_power_systemSignalPowerSystem

Signal to report the power system status.

signal_statusSignalStatus

Signal to report the updated status of system.

signal_configSignalConfig

Signal to send the configuration.

signal_scriptSignalScript

Signal to send the script progress.

signal_ilc_statusSignalIlcStatus

Signal to send the inner-loop controller (ILC) status.

signal_closed_loop_control_modeSignalClosedLoopControlMode

Signal to send the update status of closed-loop control mode.

system_statusdict

System status.

fault_managerFaultManager

Fault manager to record the system error.

utility_monitorUtilityMonitor

Utility monitor to monitor the utility status.

controllerlsst.ts.m2com.ControllerCell

Controller to do the TCP/IP communication with the servers of M2 cell.

duration_refreshint

Duration to refresh the data in milliseconds.

ilc_retry_timesint

Retry times to transition the inner-loop controller (ILC) state.

ilc_timeoutfloat

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()

Disconnect from the M2 controller.

enter_diagnostic()

Transition from the Standby mode to the Diagnostic mode.

enter_enable()

Transition from the Diagnostic mode to the Enable mode.

exit_diagnostic()

Transition from the Diagnostic mode to the Standby mode.

exit_enable()

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_current_force_limits()

Get the current force limits.

go_to_position(x, y, z, rx, ry, rz)

Go to the position.

is_enabled_and_closed_loop_control()

The system is in the Enabled state and closed-loop control or not.

is_enabled_and_open_loop_control()

The system is in the Enabled state and open-loop control or not.

reboot_controller()

Reboot the cell controller.

report_config(**kwargs)

Report the configuration defined in Config class.

report_control_status()

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()

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

actuatorslist

Selected actuators to do the movement. If the empty list [] is passed, the function will raise the RuntimeError.

forcefloat

Force to apply in Newton.

Raises

RuntimeError

No actuator is selected.

RuntimeError

Not in the enabled state with closed-loop control.

clear_error(error: int) None

Clear the error.

Parameters

errorint

Error code.

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.

actuatorslist [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_displacementfloat or int, optional

Target displacement of the actuators. (the default is 0)

unitenum lsst.ts.m2com.ActuatorDisplacementUnit, optional

Displacement unit. (the default is ActuatorDisplacementUnit.Millimeter)

Raises

RuntimeError

Not in the enabled state with open-loop control.

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_namestr or None, optional

Name of the script. (the default is None)

bypass_state_checkingbool, optional

Bypass the state checking or not. (the default is False)

Raises

RuntimeError

Not in the enabled state.

async connect(time_process: float = 3.0) None

Connect to the M2 controller.

Parameters

time_processfloat, optional

Waiting time to let the application processes the received welcome messages. (the default is 3.0)

Raises

RuntimeError

There is the connection with the M2 controller already.

async disconnect() None

Disconnect from the M2 controller.

async enter_diagnostic() bool

Transition from the Standby mode to the Diagnostic mode.

Returns

bool

True if the communication power is on already, which implies the commandable SAL component (CSC) is using the M2 now. Otherwise, False.

Raises

RuntimeError

When the system is not in the Standby mode.

async enter_enable() bool

Transition from the Diagnostic mode to the Enable mode.

Returns

bool

True if the motor power is on already, which implies the commandable SAL component (CSC) is using the M2 now. Otherwise, False.

Raises

RuntimeError

When the system is not in the Diagnostic mode.

async exit_diagnostic() None

Transition from the Diagnostic mode to the Standby mode.

Raises

RuntimeError

When the system is not in the Diagnostic mode.

async exit_enable() None

Transition from the Enable mode to the Diagnostic mode.

Raises

RuntimeError

When 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

statusany

Default status.

Returns

collectiondict

Collection of default actuator status.

get_current_force_limits() tuple[float, float]

Get the current force limits.

Returns

float

Maximum axial force in Newton.

float

Maximum 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

xfloat

Position x in um.

yfloat

Position y in um.

zfloat

Position z in um.

rxfloat

Rotation x in arcsec.

ryfloat

Rotation y in arcsec.

rzfloat

Rotation z in arcsec.

Raises

RuntimeError

Not in the closed-loop control.

is_enabled_and_closed_loop_control() bool

The system is in the Enabled state and closed-loop control or not.

Returns

bool

True 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

bool

True if the system is in the Enabled state and open-loop control. Otherwise, False.

async reboot_controller() None

Reboot the cell controller.

Raises

RuntimeError

Not in the standby state with local control.

report_config(**kwargs: dict[str, Any]) Config

Report the configuration defined in Config class.

Parameters

**kwargsdict

Configuration key-value pairs. The available keys are defined in Config class.

Returns

configConfig

Configuration.

Raises

KeyError

Key name does not exist in the Config class.

report_control_status() None

Report the control status.

report_error(error: int) None

Report the error.

Parameters

errorint

Error code.

report_script_progress(progress: int) None

Report the script progress.

Parameters

progressint

Progress of the script execution (0-100%).

async reset_breakers(power_type: PowerType) None

Reset the breakers.

Parameters

power_typeenum MTM2.PowerType

Power type.

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

hoststr

Host address.

port_commandint

Command port to connect.

port_telemetryint

Telemetry port to connect.

timeout_connectionfloat

Connection timeout in second.

Raises

RuntimeError

There is the connection with the M2 controller already.

ValueError

When the command port equals to the telemetry port.

update_system_status(status_name: str, new_status: bool) None

Update the system status.

Parameters

status_namestr

Status name. It must be in the keys of self.system_status.

new_statusbool

New status.

Raises

ValueError

Status name is not in the list.