diff --git a/src/openflexure_microscope_server/things/camera/simulation.py b/src/openflexure_microscope_server/things/camera/simulation.py index 1f956661..521fc7cc 100644 --- a/src/openflexure_microscope_server/things/camera/simulation.py +++ b/src/openflexure_microscope_server/things/camera/simulation.py @@ -342,7 +342,11 @@ class SimulatedCamera(BaseCamera): def generate_frame(self) -> Image.Image: """Generate a frame with blobs based on the stage coordinates.""" pos = self._stage.instantaneous_position - return self.generate_image((pos["y"], pos["x"], pos["z"])) + frame = self.generate_image((pos["y"], pos["x"], pos["z"])) + # Simulate LED turning off by setting all channels to 0 + if not self._stage.led_on: + frame = np.full((self.shape[0], self.shape[1], 3), 0, dtype=np.uint8) + return frame def __enter__(self) -> Self: """Start the capture thread when the Thing context manager is opened.""" diff --git a/src/openflexure_microscope_server/things/stage/dummy.py b/src/openflexure_microscope_server/things/stage/dummy.py index 7130fcb7..82515d17 100644 --- a/src/openflexure_microscope_server/things/stage/dummy.py +++ b/src/openflexure_microscope_server/things/stage/dummy.py @@ -4,7 +4,7 @@ from __future__ import annotations import time from types import TracebackType -from typing import Any, Optional, Self +from typing import Any, Literal, Optional, Self import labthings_fastapi as lt @@ -18,6 +18,8 @@ class DummyStage(BaseStage): hardware attached. """ + led_on: bool = lt.property(default=True) + def __init__( self, thing_server_interface: lt.ThingServerInterface, @@ -115,3 +117,18 @@ class DummyStage(BaseStage): """ self._hardware_position = dict.fromkeys(self.axis_names, 0) self.instantaneous_position = self._hardware_position + + # led_channel is unused in the simulation, but must exist to match the real API + @lt.action + def flash_led( + self, + number_of_flashes: int = 10, + dt: float = 0.5, + led_channel: Literal["cc"] = "cc", # noqa: ARG002 + ) -> None: + """Flash the LED to identify the board (simulated).""" + for _ in range(number_of_flashes): + self.led_on = False + time.sleep(dt) + self.led_on = True + time.sleep(dt)