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:
configtypes.SimpleNamespace

Lamp-specific configuration.

csclsst.ts.salobj.BaseCsc

The CSC. This class writes to lamp-specific event topics and reads and writes two additional float attributes: lamp_on_time and lamp_off_time.

loglogging.Logger

Logger.

status_callbackawaitable or None, optional

Coroutine to call when evt_lampState or evt_lampConnected changes. It receives one argument: this model.

simulatebool, optional

Run in simulation mode?

make_connect_time_outbool, optional

Make the connect method timeout? Only useful for unit tests. Ignored if simulate false.

Attributes:
default_powerfloat

Default power after the lamp is started (Watts) in range 800-1200.

lamp_was_onbool

Was the lamp commanded on, as of the most recently read LabJack data?

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

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

basic_disconnect(cancel_status_loop)

call_status_callback()

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

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.

status_loop()

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

The text for the exception.

abort_lamp_on_future(reason)

Abort self.lamp_on_future (if not done) with a salobj.ExpectedError exception.

Parameters:
reasonstr

The text for the exception.

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.

Parameters:
taifloat or None, optional

TAI time (unix seconds).

get_remaining_warmup(tai=None)

Return the remaining warmup duration (seconds), or 0 if none.

Parameters:
taifloat or None, optional

TAI time (unix seconds).

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_openbool

Specify True to open the shutter, False to close it.

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_errorLampControllerError

Error reported by the lamp controller. Ignored if not connected.

controller_stateLampControllerState

Lamp controller state. Ignored if not connected.

light_detectedbool

Did the photo sensor detect light? Ignored if not connected.

lamp_commanded_onbool

Is the lamp commanded to be on? This should be based on read_lamp_set_voltage from the LabJack.

Ignored if not connected.

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

Force the lamp off, even if warming up. This can significantly reduce bulb life.

waitbool

Wait for the lamp to turn off?

reasonstr

Why is the lamp being turned off? Used as the full text of the lamp_on_future exception, if aborting turning on the lamp.

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

Lamp power. Must be in the range [800, 1200] W, inclusive.

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.