Skip to content

Commit

Permalink
abc: missing sim impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ianohara committed Feb 18, 2025
1 parent 386e83b commit 577cc0a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions software/squid/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def get_analog_gain(self) -> float:
"""
pass

@abc.abstractmethod
def get_gain_range(self) -> CameraGainRange:
"""
Returns the gain range, and minimum gain step, for this camera.
Expand Down
11 changes: 10 additions & 1 deletion software/squid/camera/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import squid.logging
from squid.config import CameraConfig, CameraPixelFormat, CameraVariant
from squid.abc import AbstractCamera, CameraAcquisitionMode, CameraFrameFormat, CameraFrame
from squid.abc import AbstractCamera, CameraAcquisitionMode, CameraFrameFormat, CameraFrame, CameraGainRange

_log = squid.logging.get_logger("squid.camera.utils")

Expand Down Expand Up @@ -184,12 +184,21 @@ def get_resolutions(self) -> Sequence[Tuple[int, int]]:

@debug_log
def set_analog_gain(self, analog_gain: float):
valid_range = self.get_gain_range()
if analog_gain > valid_range.max_gain or analog_gain < valid_range.min_gain:
raise ValueError("Gain outside valid range.")

self._analog_gain = analog_gain

@debug_log
def get_analog_gain(self) -> float:
return self._analog_gain

@debug_log
def get_gain_range(self) -> CameraGainRange:
# Arbitrary, just something to test with
return CameraGainRange(min_gain=0.0, max_gain=100.0, gain_step=2.0)

def _start_streaming_thread(self):
def stream_fn():
self._log.info("Starting streaming thread...")
Expand Down

0 comments on commit 577cc0a

Please sign in to comment.