Skip to content

Commit

Permalink
Solution for the exposure time property
Browse files Browse the repository at this point in the history
  • Loading branch information
erinpougheon committed Jul 16, 2024
1 parent 8e2c572 commit 6a4267d
Showing 1 changed file with 9 additions and 31 deletions.
40 changes: 9 additions & 31 deletions catkit2/services/hamamatsu_camera/hamamatsu_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
def _create_property(property_name, read_only=False, stopped_acquisition=True):
def getter(self):
with self.mutex:
return getattr(self.cam, property_name).prop_getvalue(dcam.DCAM_IDPROP.property_name)
if property_name != 'EXPOSURETIME':
return getattr(self.cam, property_name).prop_getvalue(dcam.DCAM_IDPROP.property_name)
else:
return getattr(self.cam, property_name).prop_getvalue(dcam.DCAM_IDPROP.property_name) * 1e6

if read_only:
setter = None
Expand All @@ -40,7 +43,10 @@ def setter(self, value):
time.sleep(0.001)

with self.mutex:
getattr(self.cam, property_name).prop_setvalue(dcam.DCAM_IDPROP.property_name, value)
if property_name != 'EXPOSURETIME':
getattr(self.cam, property_name).prop_setvalue(dcam.DCAM_IDPROP.property_name, value)
else:
getattr(self.cam, property_name).prop_setvalue(dcam.DCAM_IDPROP.property_name, value / 1e6)

if was_running and stopped_acquisition:
self.start_acquisition()
Expand Down Expand Up @@ -298,7 +304,7 @@ def end_acquisition(self):
"""
self.should_be_acquiring.clear()

# exposure_time = _create_property('EXPOSURETIME', stopped_acquisition=False) * 1e6
exposure_time = _create_property('EXPOSURETIME', stopped_acquisition=False)
gain = _create_property('CONTRASTGAIN', stopped_acquisition=False)
brightness = _create_property('SENSITIVITY', stopped_acquisition=False)

Expand All @@ -323,34 +329,6 @@ def get_temperature(self):
"""
return self.cam.prop_getvalue(dcam.DCAM_IDPROP.SENSORTEMPERATURE)

@property
def exposure_time(self):
"""
The exposure time in microseconds.
This property can be used to get the exposure time of the camera.
Returns:
--------
float:
The exposure time in microseconds.
"""
return self.cam.prop_getvalue(dcam.DCAM_IDPROP.EXPOSURETIME) * 1e6

@exposure_time.setter
def exposure_time(self, exposure_time: float):
"""
Set the exposure time in microseconds.
This property can be used to set the exposure time of the camera.
Parameters
----------
exposure_time : float
The exposure time in microseconds.
"""
self.cam.prop_setvalue(dcam.DCAM_IDPROP.EXPOSURETIME, exposure_time / 1e6)


if __name__ == '__main__':
service = HamamatsuCamera()
Expand Down

0 comments on commit 6a4267d

Please sign in to comment.