Skip to content

Commit

Permalink
Some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
ivalaginja committed Apr 17, 2024
1 parent 1a03b3b commit 8068f38
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions catkit2/services/hamamatsu_camera/hamamatsu_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,15 @@ def open(self):
self.cam.prop_setvalue(dcam.DCAM_IDPROP.SUBARRAYMODE, 2.0) # TODO: ? - 2.0 for subarray mode on

# Set binning
self.cam.prop_setvalue(dcam.DCAM_IDPROP.BINNING, 1.0) # TODO: read from config
binning = self.config.get('binning', 1)
self.cam.prop_setvalue(dcam.DCAM_IDPROP.BINNING, binning)

# Set camera mode
dcam.prop_setvalue(dcam.DCAM_IDPROP.READOUTSPEED, 2.0) # TODO: read from config - 2.0 for "standard", 1.0 for "ultraquiet"
# Set camera mode to "ultraquiet" (1.0) rather than "standard" (2.0)
dcam.prop_setvalue(dcam.DCAM_IDPROP.READOUTSPEED, 1.0)

self.current_pixel_format = self.config.get('pixel_format', 'Mono16')
if self.current_pixel_format not in self.pixel_formats:
raise ValueError('Invalid pixel format: ' +
self.current_pixel_format +
', must be one of ' +
str(list(self.pixel_formats.keys())))
raise ValueError(f'Invalid pixel format: {self.current_pixel_format}, must be one of {str(list(self.pixel_formats.keys()))}')
self.log.info('Using pixel format: %s', self.current_pixel_format)
self.cam.prop_setvalue(dcam.DCAM_IDPROP.IMAGE_PIXELTYPE, self.pixel_formats[self.current_pixel_format])

Expand Down Expand Up @@ -153,8 +151,6 @@ def make_property_helper(name, read_only=False):
make_property_helper('sensor_width', read_only=True)
make_property_helper('sensor_height', read_only=True)

make_property_helper('device_name', read_only=True)

self.make_command('start_acquisition', self.start_acquisition)
self.make_command('end_acquisition', self.end_acquisition)

Expand Down Expand Up @@ -203,7 +199,7 @@ def acquisition_loop(self):
if self.cam.lasterr().is_timeout():
self.log.warning('Timeout while waiting for frame')
if self.cam.wait_capevent_frameready(timeout_millisec) is False:
raise RuntimeError(f'Dcam.wait_capevent_frameready() fails with error {self.cam.lasterr()}')
raise RuntimeError(f'Dcam.wait_capevent_frameready({timeout_millisec}) fails with error {self.cam.lasterr()}')
img = self.cam.buf_getlastframedata()
self.images.submit_data(img)

Expand Down Expand Up @@ -295,7 +291,7 @@ def gain(self):
int:
The gain of the camera.
"""
return self.cam.Gain.get() # TODO
return self.cam.prop_getvalue(dcam.DCAM_IDPROP.CONTRASTGAIN) # TODO: verify this

@gain.setter
def gain(self, gain: int):
Expand All @@ -309,7 +305,7 @@ def gain(self, gain: int):
gain : int
The gain of the camera.
"""
self.cam.Gain.set(gain) # TODO
self.cam.prop_setvalue(dcam.DCAM_IDPROP.CONTRASTGAIN, gain) # TODO: verify this

@property
def brightness(self):
Expand All @@ -323,7 +319,7 @@ def brightness(self):
int:
The brightness of the camera.
"""
return self.cam.Brightness.get() # TODO
return self.cam.prop_getvalue(dcam.DCAM_IDPROP.XXX) # TODO: find correct property

@brightness.setter
def brightness(self, brightness: int):
Expand All @@ -337,7 +333,7 @@ def brightness(self, brightness: int):
brightness : int
The brightness of the camera.
"""
self.cam.Brightness.set(brightness) # TODO
self.cam.prop_setvalue(dcam.DCAM_IDPROP.XXX, brightness) # TODO: find correct property

@property
def sensor_width(self):
Expand Down

0 comments on commit 8068f38

Please sign in to comment.