MockModel

class lsst.ts.m2com.MockModel(log: Optional[Logger] = 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:
loglogging.Logger or None, optional

A logger. If None, a logger will be instantiated. (the default is None)

inclinometer_anglefloat, optional

Inclinometer angle in degree. (the default is 90.0)

telemetry_intervalfloat, optional

Telemetry interval in second. (the default is 0.05, which means 20 Hz)

communication_voltagefloat, optional

Communication voltage in volt if the power is on. (the default is 23.0)

communication_currentfloat, optional

Communication current in ampere if the power is on. (the default is 6.5)

motor_voltagefloat, optional

Motor voltage in volt if the power is on. (the default is 23.0)

motor_currentfloat, optional

Motor current in ampere if the power is on. (the default is 8.5)

Attributes:
loglogging.Logger

A logger.

control_open_loopMockControlOpenLoop

Open-loop control.

control_closed_loopMockControlClosedLoop

Closed-loop control.

telemetry_intervalfloat

Telemetry interval in second.

inclination_sourceMTM2.InclinationTelemetrySource

Source of the inclination.

mirror_positiondict

Mirror’s position. The key is the axis (x, y, z, xRot, yRot, zRot) of mirror. The units are the micron and arcsec.

mirror_position_offsetdict

Offset value of the mirror position. The key is the axis (x, y, z, xRot, yRot, zRot) of mirror. The units are the micron and arcsec. This is a workaround to deal with the rigid body movement at this moment. Need to remove this after the translation of forward modeling of hardpoint correction.

power_communicationMockPowerSystem

Power system of communication.

power_motorMockPowerSystem

Power system of motor.

in_positionbool

M2 assembly is in position or not.

list_ilclist [MockInnerLoopController]

List of the inner-loop controllers (ILC).

mtmount_in_positionbool

MTMount in position or not.

script_engineMockScriptEngine

Script engine to run the binary script.

error_handlerMockErrorHandler

Error handler to manage the error codes.

Attributes Summary

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 Summary

balance_forces_and_steps([force_rms, ...])

Balance the forces and steps.

check_set_point_position_mirror(...)

Check the set point of mirror's position.

clear_errors()

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

Get the current hardpoint displacements in meter.

get_default_mirror_position()

Get the default mirror position.

get_digital_input()

Get the value of digital input that represents the current state of the system.

get_digital_output()

Get the value of digital output.

get_mode_ilc(addresses)

Get the mode of inner-loop controller (ILC).

get_telemetry_data()

Get the telemetry data.

handle_position_mirror(mirror_position_set_point)

Handle positioning the mirror.

is_actuator_force_out_limit()

The actuator force is out of limit or not.

is_force_error_tangent_out_limit()

The force error of tangent link is out of limit or not.

reset_breakers(power_type)

Reset the breakers.

select_inclination_source(source)

Select the inclination source.

set_inclinometer_angle(angle)

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(force_rms: float = 0.5, force_per_cycle: float = 5.0, update_steps: bool = True) bool

Balance the forces and steps.

This function will check the actuators are in position or not and udpate the self.in_position. If the closed-loop control is running, it will do the force dynamics based on the “force_per_cycle” to try to balance the forces of actuators. In addition, it will try to make sure the internal data in open-loop and closed-loop controls are consistent.

Parameters:
force_rmsfloat, optional

Force rms variation in Newton. (default is 0.5)

force_per_cyclefloat, optional

Force per cycle to apply in Newton. (the default is 5.0)

update_stepsbool, optional

If True, update the steps based on the force change. Otherwise, no update. This takes a significant CPU usage (np.linalg.inv()). (the default is True)

Returns:
bool

True if the steps had been updated according to the force change. Otherwise, False.

Raises:
RuntimeError

When the open-loop and closed-loop controls are running at the same time.

check_set_point_position_mirror(mirror_position_set_point: dict) bool

Check the set point of mirror’s position.

Parameters:
mirror_position_set_pointdict

Dictionary with the same format as self.mirror_position.

Returns:
bool

True if all check pass. Otherwise, False.

clear_errors() None

Clear the errors.

configure(config_dir: Path, lut_path: str) None

Do the configuration.

Parameters:
config_dirpathlib.PosixPath

Configuration directory.

lut_pathstr

Look-up table (LUT) path.

enable_open_loop_max_limit(status: bool) bool

Enable the maximum limit of open-loop control.

Parameters:
statusbool

True if allow the maximum limit of open-loop control. Otherwise, False.

Returns:
resultbool

True if succeeds. Otherwise, False.

fault(error_code: MockErrorCode) None

Fault the model.

Parameters:
error_codeenum MockErrorCode

Error code.

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_inputint

Value of the digital input.

get_digital_output() int

Get the value of digital output.

Returns:
digital_outputint

Value of the digital output.

get_mode_ilc(addresses: list[int]) list[lsst.ts.m2com.enum.InnerLoopControlMode]

Get the mode of inner-loop controller (ILC).

Parameters:
addresseslist [int]

0-based addresses.

Returns:
list_modelist [InnerLoopControlMode]

List of the ILC mode.

get_telemetry_data() dict

Get the telemetry data.

Returns:
telemetry_datadict

Telemetry data.

handle_position_mirror(mirror_position_set_point: dict) None

Handle positioning the mirror.

Parameters:
mirror_position_set_pointdict

Dictionary with the same format as self.mirror_position.

Notes

This is just a placeholder at this moment. To do this correctly, need:

1. Translate the calculation of forward modeling of hardpoint correction.

2. Apply MockControlClosedLoop.rigid_body_to_actuator_displacement() and get the expected displacement of actuator.

3. Put the displacement to the forward-modeling and get correct hardpoint correction in force.

4. Put the hardpoint correction to MockControlClosedLoop.axial_forces[“hardpointCorrection”] and MockControlClosedLoop.tangent_forces[“hardpointCorrection”].

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_limitbool

True if the actuator force is out of limit. Otherwise, False.

error_codeenum MockErrorCode

Error code.

limit_switches_retractlist

Triggered retracted limit switches.

limit_switches_extendlist

Triggered extended limit switches.

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_limitbool

True if the force error is out of limit. Otherwise, False.

error_codeenum MockErrorCode

Error code.

reset_breakers(power_type: PowerType) bool

Reset the breakers.

Parameters:
power_typePowerType

Power type.

Returns:
resultbool

True if succeeds. Otherwise, False.

select_inclination_source(source: int) None

Select the inclination source.

Parameters:
sourceint

Inclination source based on the enum: MTM2.InclinationTelemetrySource.

set_inclinometer_angle(angle: float) None

Set the angle of inclinometer.

Parameters:
anglefloat

Inclinometer angle in degree.

set_mode_ilc(addresses: list[int], mode: InnerLoopControlMode) None

Set the mode of inner-loop controller (ILC).

Parameters:
addresseslist [int]

0-based addresses.

modeenum InnerLoopControlMode

ILC mode.

switch_digital_output(digital_output: int, bit: DigitalOutput, status: DigitalOutputStatus) int

Switch the digital output with the specific bit.

Parameters:
digital_outputint

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.

switch_force_balance_system(status: bool) bool

Switch the force balance system.

Parameters:
statusbool

True if turn on the force balance system. Otherwise, False.

Returns:
resultbool

True if succeeds. Otherwise, False.