Remove flash from stage baseclass, add to sim config
This commit is contained in:
parent
5682b4d28d
commit
4d788a2817
5 changed files with 26 additions and 26 deletions
|
|
@ -1,10 +1,13 @@
|
|||
"""A module to handle the illumination in LabThings."""
|
||||
|
||||
import time
|
||||
from typing import Literal
|
||||
|
||||
import labthings_fastapi as lt
|
||||
|
||||
from .camera import BaseCamera
|
||||
from .stage import BaseStage
|
||||
from .camera import BaseCam
|
||||
|
||||
|
||||
class Illumination(lt.Thing):
|
||||
"""Abstract illumination controller."""
|
||||
|
|
@ -17,9 +20,10 @@ class Illumination(lt.Thing):
|
|||
) -> None:
|
||||
"""Flash the illumination source."""
|
||||
raise NotImplementedError(
|
||||
'Flashing the LED can only be done from the simulator or sangaboard'
|
||||
"Flashing the LED can only be done from the simulator or sangaboard"
|
||||
)
|
||||
|
||||
|
||||
class SangaIllumination(Illumination):
|
||||
"""Illumination driven by a Sangaboard."""
|
||||
|
||||
|
|
@ -32,16 +36,22 @@ class SangaIllumination(Illumination):
|
|||
dt: float = 0.5,
|
||||
led_channel: Literal["cc"] = "cc",
|
||||
) -> None:
|
||||
"""Flash an LED a given number of times.
|
||||
|
||||
Flashes the LED on channel led_channel number_of_flashes times,
|
||||
for a duration of dt each.
|
||||
"""
|
||||
for _ in range(number_of_flashes):
|
||||
self._stage.set_led(False, led_channel)
|
||||
time.sleep(dt)
|
||||
self._stage.set_led(True, led_channel)
|
||||
time.sleep(dt)
|
||||
|
||||
|
||||
class SimulatorIllumination(Illumination):
|
||||
"""Illumination control in the simulator."""
|
||||
|
||||
_cam: BaseCam = lt.thing_slot()
|
||||
_cam: BaseCamera = lt.thing_slot()
|
||||
|
||||
@lt.action
|
||||
def flash(
|
||||
|
|
@ -50,6 +60,11 @@ class SimulatorIllumination(Illumination):
|
|||
dt: float = 0.5,
|
||||
led_channel: Literal["cc"] = "cc",
|
||||
) -> None:
|
||||
"""Flash an LED a given number of times.
|
||||
|
||||
Flashes the LED on channel led_channel number_of_flashes times,
|
||||
for a duration of dt each.
|
||||
"""
|
||||
for _ in range(number_of_flashes):
|
||||
self._cam.set_led(False, led_channel)
|
||||
time.sleep(dt)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue