Skip to content

Commit

Permalink
Add shutter support to camera and update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mmouchous-ledger committed Jan 24, 2025
1 parent 0593f90 commit d015463
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config_schema/camera.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
"objective": {
"type": "number",
"description": "If there is a optical magnifier, specify the zooming factor of the objective."
},
"shutter": {
"allOf": [
{
"$ref": "instrument.schema.json"
},
{
"description": "A shutter from https://github.com/Ledger-Donjon/shutter-controller."
}
]
}
},
"oneOf": [
Expand Down
6 changes: 6 additions & 0 deletions laserstudio/instruments/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Optional, Literal, cast
from ..utils.util import yaml_to_qtransform, qtransform_to_yaml
from .instrument import Instrument
from .shutter import ShutterInstrument


class CameraInstrument(Instrument):
Expand Down Expand Up @@ -39,6 +40,11 @@ def __init__(self, config: dict):
# Correction matrix
self.correction_matrix: Optional[QTransform] = None

# Shutter
shutter = config.get("shutter")
if shutter is not None:
self.shutter = ShutterInstrument(shutter)

def select_objective(self, factor: float):
"""Select an objective with a magnifying factor.
Expand Down
23 changes: 23 additions & 0 deletions laserstudio/instruments/shutter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pystages import Tic, TicDirection, Vector
from .instrument import Instrument


class ShutterInstrument(Instrument):
def __init__(self, config: dict):
super().__init__(config=config)
self.tic = Tic()
self.tic.exit_safe_start()
self.tic.go_home(TicDirection.FORWARD)
self.__open = True # Open after homing

@property
def open(self) -> bool:
return self.__open

@open.setter
def open(self, value: bool):
if type(value) is not bool:
raise ValueError("Expected bool")
if value != self.__open:
self.tic.position = Vector({False: -106, True: 0}[value])
self.__open = value

0 comments on commit d015463

Please sign in to comment.