LampModel¶
- class lsst.ts.atwhitelight.LampModel(config, csc, log, status_callback=None, simulate=False, make_connect_time_out=False)¶
Bases:
object
Interface to a Horiba KiloArc white light controller.
Keep track of the state and enforce warmup and cooldown periods described in the User’s Guide
- Parameters:
- config
types.SimpleNamespace
Lamp-specific configuration.
- csc
lsst.ts.salobj.BaseCsc
The CSC. This class writes to lamp-specific event topics and reads and writes two additional float attributes:
lamp_on_time
andlamp_off_time
.- log
logging.Logger
Logger.
- status_callback
awaitable
orNone
, optional Coroutine to call when evt_lampState or evt_lampConnected changes. It receives one argument: this model.
- simulate
bool
, optional Run in simulation mode?
- make_connect_time_out
bool
, optional Make the connect method timeout? Only useful for unit tests. Ignored if simulate false.
- config
- Attributes:
- Raises:
- TypeError
If
status_callback
is not None and not a coroutine.- ValueError
If
config.default_power
not in range [800, 1200], inclusive.
Attributes Summary
Return True if connected to the LabJack.
Get the lamp off time, or 0 if unknown.
Get the lamp on time, or 0 if unknown.
Return the simulate constructor argument.
Return True if connected and status has been seen.
Methods Summary
abort_lamp_off_future
(reason)Abort self.lamp_off_future (if not done) with a salobj.ExpectedError exception.
abort_lamp_on_future
(reason)Abort self.lamp_on_future (if not done) with a salobj.ExpectedError exception.
basic_disconnect
(cancel_status_loop)Call the status callback, if there is one.
connect
()disconnect
([cancel_status_loop])get_remaining_cooldown
([tai])Return the remaining cooldown duration (seconds), or 0 if none.
get_remaining_warmup
([tai])Return the remaining warmup duration (seconds), or 0 if none.
Get the current evt_lampState data.
move_shutter
(do_open)Open or close the shutter.
set_status
(controller_state, ...)Set status and, if changed, call the status callback.
Monitor the status.
turn_lamp_off
(force, wait, reason)Turn the lamp off (if on).
turn_lamp_on
(power)Turn the lamp on or change the power.
Attributes Documentation
- connected¶
Return True if connected to the LabJack.
- lamp_off_time¶
Get the lamp off time, or 0 if unknown.
- lamp_on_time¶
Get the lamp on time, or 0 if unknown.
- simulate¶
Return the simulate constructor argument.
- status_seen¶
Return True if connected and status has been seen.
Methods Documentation
- abort_lamp_off_future(reason)¶
Abort self.lamp_off_future (if not done) with a salobj.ExpectedError exception.
- Parameters:
- reason
str
The text for the exception.
- reason
- abort_lamp_on_future(reason)¶
Abort self.lamp_on_future (if not done) with a salobj.ExpectedError exception.
- Parameters:
- reason
str
The text for the exception.
- reason
- async basic_connect()¶
- async basic_disconnect(cancel_status_loop)¶
- async call_status_callback()¶
Call the status callback, if there is one.
- async connect()¶
- async disconnect(cancel_status_loop=True)¶
- get_remaining_cooldown(tai=None)¶
Return the remaining cooldown duration (seconds), or 0 if none.
Return 0 if the lamp is unexpectedly off. That means the lamp never turned on, or burned out, and either way, there is no point to a cooldown period.
- get_remaining_warmup(tai=None)¶
Return the remaining warmup duration (seconds), or 0 if none.
- get_state()¶
Get the current evt_lampState data.
Raise RuntimeError if not connected or if state data has not been seen since the connection was made (which would be a bug, since the model should not report being connected until state data is seen).
- async move_shutter(do_open)¶
Open or close the shutter.
- Parameters:
- do_open
bool
Specify True to open the shutter, False to close it.
- do_open
- Raises:
- asyncio.TimeoutError
If the shutter does not fully open or close in time specified by config.shutter_timeout. If this happens the motor is disabled.
- lsst.ts.salobj.ExpectedError
If both shutter sensing switches are active.
- async set_status(controller_state, controller_error, light_detected, read_lamp_set_voltage)¶
Set status and, if changed, call the status callback.
- Parameters:
- controller_error
LampControllerError
Error reported by the lamp controller. Ignored if not connected.
- controller_state
LampControllerState
Lamp controller state. Ignored if not connected.
- light_detected
bool
Did the photo sensor detect light? Ignored if not connected.
- lamp_commanded_on
bool
Is the lamp commanded to be on? This should be based on
read_lamp_set_voltage
from the LabJack.Ignored if not connected.
- controller_error
- async status_loop()¶
Monitor the status.
Also set the power to default_power if warmup is done. Doing it here makes sure that when basicState goes from warmup to on, that other values match.
- async turn_lamp_off(force, wait, reason)¶
Turn the lamp off (if on). Fail if warming up, unless force=True.
- Parameters:
- Raises:
- salobj.ExpectedError
If warming up and force=False.
- async turn_lamp_on(power)¶
Turn the lamp on or change the power.
Note that the lamp will be ignited at 1200W, then fall back to the specified power 2-20 seconds later.
- Parameters:
- power
float
Lamp power. Must be in the range [800, 1200] W, inclusive.
- power
- Raises:
- salobj.ExpectedError
If the lamp is already in the process of being turned on, or if the lamp is off but still cooling down.