MockModel¶
- class lsst.ts.m2com.MockModel(log: Logger | None = None, inclinometer_angle: float = 90.0, telemetry_interval: float = 0.05, communication_voltage: float = 23.0, communication_current: float = 6.5, motor_voltage: float = 23.0, motor_current: float = 8.5)¶
Bases:
object
Mock Model class.
Parameters¶
- log
logging.Logger
or None, optional A logger. If None, a logger will be instantiated. (the default is None)
- inclinometer_angle
float
, optional Inclinometer angle in degree. (the default is 90.0)
- telemetry_interval
float
, optional Telemetry interval in second. (the default is 0.05, which means 20 Hz)
- communication_voltage
float
, optional Communication voltage in volt if the power is on. (the default is 23.0)
- communication_current
float
, optional Communication current in ampere if the power is on. (the default is 6.5)
- motor_voltage
float
, optional Motor voltage in volt if the power is on. (the default is 23.0)
- motor_current
float
, optional Motor current in ampere if the power is on. (the default is 8.5)
Attributes¶
- log
logging.Logger
A logger.
- control_open_loop
MockControlOpenLoop
Open-loop control.
- control_closed_loop
MockControlClosedLoop
Closed-loop control.
- telemetry_interval
float
Telemetry interval in second.
- inclinometer_angle
float
Inclinometer angle in degree.
- inclinometer_angle_external
float
External inclinometer angle in degree. This has the same coordinate system of look-up table angle.
- control_parameters
dict
Control parameters in the closed-loop controller (CLC).
- mirror_position
dict
Mirror’s position. The key is the axis (x, y, z, xRot, yRot, zRot) of mirror. The units are the micron and arcsec.
- steps_hardpoints_offset
numpy.ndarray
[int
] Offset of the hardpoint steps. This is used in the rigid body movement.
- power_communication
MockPowerSystem
Power system of communication.
- power_motor
MockPowerSystem
Power system of motor.
- in_position
bool
M2 assembly is in position or not.
- list_ilc
list [MockInnerLoopController]
List of the inner-loop controllers (ILC).
- mtmount_in_position
bool
MTMount in position or not.
- script_engine
MockScriptEngine
Script engine to run the binary script.
- error_handler
MockErrorHandler
Error handler to manage the error codes.
- plant
MockPlant
Plant model.
Attributes Summary
Updated digital input when the communication power is on.
Default digital input defined with the enum 'DigitalInput'.
Updated digital input when the motor power is on.
Default digital output defined with the enum 'DigitalOutput'.
Mirror radial motion limit (in mm).
Mirror motion limit in the optical direction (in mm).
Methods Summary
balance_forces_and_steps
([do_update, ...])Balance the forces and steps.
Check the set point of mirror's position.
Clear the errors.
configure
(config_dir, lut_path)Do the configuration.
enable_open_loop_max_limit
(status)Enable the maximum limit of open-loop control.
fault
(error_code)Fault the model.
Get the current hardpoint displacements in meter.
Get the default mirror position.
Get the value of digital input that represents the current state of the system.
Get the value of digital output.
get_mode_ilc
(addresses)Get the mode of inner-loop controller (ILC).
Get the telemetry data.
handle_position_mirror
(mirror_position_set_point)Handle positioning the mirror.
The actuator force is out of limit or not.
The force error of tangent link is out of limit or not.
reset_breakers
(power_type)Reset the breakers.
set_inclinometer_angle
(angle[, is_external])Set the angle of inclinometer.
set_mode_ilc
(addresses, mode)Set the mode of inner-loop controller (ILC).
switch_digital_output
(digital_output, bit, ...)Switch the digital output with the specific bit.
switch_force_balance_system
(status)Switch the force balance system.
Attributes Documentation
- digital_input_communication¶
Updated digital input when the communication power is on.
- digital_input_default¶
Default digital input defined with the enum ‘DigitalInput’.
- digital_input_motor¶
Updated digital input when the motor power is on.
- digital_output_default¶
Default digital output defined with the enum ‘DigitalOutput’.
- position_limit_radial¶
Mirror radial motion limit (in mm).
- position_limit_z¶
Mirror motion limit in the optical direction (in mm).
Methods Documentation
- balance_forces_and_steps(do_update: bool = True, steps_rigid_body: int = 100) bool ¶
Balance the forces and steps.
Notes¶
This function will check the actuators are in position or not and udpate the self.in_position after doing the force dynamics.
Parameters¶
- do_update
bool
, optional If True, update the internal data. Otherwise, no update. (the default is True)
- steps_rigid_body
int
, optional Steps to run for the rigid body movement. (the default is 100)
Raises¶
RuntimeError
When the open-loop and closed-loop controls are running at the same time.
- do_update
- check_set_point_position_mirror(mirror_position_set_point: dict) bool ¶
Check the set point of mirror’s position.
Parameters¶
- mirror_position_set_point
dict
Dictionary with the same format as
self.mirror_position
.
Returns¶
bool
True if all check pass. Otherwise, False.
- mirror_position_set_point
- clear_errors() None ¶
Clear the errors.
- configure(config_dir: Path, lut_path: str) None ¶
Do the configuration.
Parameters¶
- config_dir
pathlib.PosixPath
Configuration directory.
- lut_path
str
Look-up table (LUT) path.
- config_dir
- enable_open_loop_max_limit(status: bool) bool ¶
Enable the maximum limit of open-loop control.
Parameters¶
- status
bool
True if allow the maximum limit of open-loop control. Otherwise, False.
Returns¶
- result
bool
True if succeeds. Otherwise, False.
- status
- fault(error_code: MockErrorCode) None ¶
Fault the model.
Parameters¶
- error_codeenum
MockErrorCode
Error code.
- error_codeenum
- get_current_hardpoint_displacement() ndarray[Any, dtype[float64]] ¶
Get the current hardpoint displacements in meter.
Returns¶
numpy.ndarray
Current hardpoint displacements in meter.
- get_default_mirror_position() dict ¶
Get the default mirror position.
Returns¶
dict
Default mirror position. The key is axis.
- get_digital_input() int ¶
Get the value of digital input that represents the current state of the system.
Returns¶
- digital_input
int
Value of the digital input.
- digital_input
- get_digital_output() int ¶
Get the value of digital output.
Returns¶
- digital_output
int
Value of the digital output.
- digital_output
- get_mode_ilc(addresses: list[int]) list[lsst.ts.xml.enums.MTM2.InnerLoopControlMode] ¶
Get the mode of inner-loop controller (ILC).
Parameters¶
- addresses
list [int]
0-based addresses.
Returns¶
- list_mode
list [MTM2.InnerLoopControlMode]
List of the ILC mode.
- addresses
- handle_position_mirror(mirror_position_set_point: dict) None ¶
Handle positioning the mirror.
Notes¶
This translates the “Context.move.vi” in ts_mtm2_cell.
Parameters¶
- mirror_position_set_point
dict
Dictionary with the same format as
self.mirror_position
.
- mirror_position_set_point
- is_actuator_force_out_limit() tuple[bool, lsst.ts.m2com.enum.MockErrorCode, list, list] ¶
The actuator force is out of limit or not.
By default, return the judgement based on the open-loop control. If the closed-loop control is running, return the result based on it.
Returns¶
- is_out_limit
bool
True if the actuator force is out of limit. Otherwise, False.
- error_codeenum
MockErrorCode
Error code.
- limit_switches_retract
list
Triggered retracted limit switches.
- limit_switches_extend
list
Triggered extended limit switches.
- is_out_limit
- is_force_error_tangent_out_limit() tuple[bool, lsst.ts.m2com.enum.MockErrorCode] ¶
The force error of tangent link is out of limit or not.
This function is translated from TangentLoadCellFaultDetection.vi in ts_mtm2 LabVIEW project.
Returns¶
- is_out_limit
bool
True if the force error is out of limit. Otherwise, False.
- error_codeenum
MockErrorCode
Error code.
- is_out_limit
- reset_breakers(power_type: PowerType) bool ¶
Reset the breakers.
Parameters¶
- power_type
MTM2.PowerType
Power type.
Returns¶
- result
bool
True if succeeds. Otherwise, False.
- power_type
- set_inclinometer_angle(angle: float, is_external: bool = False) None ¶
Set the angle of inclinometer.
Parameters¶
- angle
float
Inclinometer angle in degree.
- is_external
bool
, optional Is the external inclinometer angle or not. (the default is False)
- angle
- set_mode_ilc(addresses: list[int], mode: InnerLoopControlMode) None ¶
Set the mode of inner-loop controller (ILC).
Parameters¶
- addresses
list [int]
0-based addresses.
- modeenum
MTM2.InnerLoopControlMode
ILC mode.
- addresses
- switch_digital_output(digital_output: int, bit: DigitalOutput, status: DigitalOutputStatus) int ¶
Switch the digital output with the specific bit.
Parameters¶
- digital_output
int
Digital output.
- bitenum
DigitalOutput
Bit to switch.
- statusenum
DigitalOutputStatus
Digital output status.
Returns¶
int
Updated value of the digital output.
Raises¶
RuntimeError
If the status is not supported.
- digital_output
- log