Skip to content

Commit f4ecfdf

Browse files
authored
Merge pull request #99 from ispielma/CameraErrorControl
Camera error control
2 parents 137a057 + 404074d commit f4ecfdf

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

Diff for: labscript_devices/AndorSolis/blacs_workers.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self):
2020
from .andor_sdk.andor_utils import AndorCam
2121
self.camera = AndorCam()
2222
self.attributes = self.camera.default_acquisition_attrs
23+
self.exception_on_failed_shot = True
2324

2425
def set_attributes(self, attr_dict):
2526
self.attributes.update(attr_dict)

Diff for: labscript_devices/FlyCapture2Camera/blacs_workers.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def __init__(self, serial_number):
9191
self.pixel_formats = IntEnum('pixel_formats',fmts)
9292

9393
self._abort_acquisition = False
94-
94+
self.exception_on_failed_shot = True
95+
9596
# check if GigE camera. If so, ensure max packet size is used
9697
cam_info = self.camera.getCameraInfo()
9798
if cam_info.interfaceType == PyCapture2.INTERFACE_TYPE.GIGE:

Diff for: labscript_devices/IMAQdxCamera/blacs_workers.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class MockCamera(object):
6767
def __init__(self):
6868
print("Starting device worker as a mock device")
6969
self.attributes = {}
70+
self.exception_on_failed_shot = True
7071

7172
def set_attributes(self, attributes):
7273
self.attributes.update(attributes)
@@ -139,6 +140,7 @@ def __init__(self, serial_number):
139140
)
140141
# Keep an img attribute so we don't have to create it every time
141142
self.img = nv.imaqCreateImage(nv.IMAQ_IMAGE_U16)
143+
self.exception_on_failed_shot = True
142144
self._abort_acquisition = False
143145

144146
def set_attributes(self, attr_dict):
@@ -173,7 +175,7 @@ def get_attribute_names(self, visibility_level, writeable_only=True):
173175
if not a.Readable:
174176
continue
175177
attributes.append(a.Name.decode('utf8'))
176-
return sorted(attributes)
178+
return attributes
177179

178180
def get_attribute(self, name):
179181
"""Return current value of attribute of the given name"""
@@ -219,7 +221,16 @@ def grab_multiple(self, n_images, images, waitForNextBuffer=True):
219221
if e.code == nv.IMAQdxErrorTimeout.value:
220222
print('.', end='')
221223
continue
222-
raise
224+
225+
if self.exception_on_failed_shot:
226+
raise
227+
else:
228+
# stop acquisition
229+
print(e, file=sys.stderr)
230+
break
231+
232+
233+
223234
print(f"Got {len(images)} of {n_images} images.")
224235

225236
def stop_acquisition(self):
@@ -385,6 +396,7 @@ def transition_to_buffered(self, device_name, h5_filepath, initial_values, fresh
385396
self.stop_acquisition_timeout = properties['stop_acquisition_timeout']
386397
self.exception_on_failed_shot = properties['exception_on_failed_shot']
387398
saved_attr_level = properties['saved_attribute_visibility_level']
399+
self.camera.exception_on_failed_shot = self.exception_on_failed_shot
388400
# Only reprogram attributes that differ from those last programmed in, or all of
389401
# them if a fresh reprogramming was requested:
390402
if fresh:

Diff for: labscript_devices/PylonCamera/blacs_workers.py

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def __init__(self, serial_number):
4545
# Keep a nodeMap reference so we don't have to re-create a lot
4646
self.nodeMap = self.camera.GetNodeMap()
4747
self._abort_acquisition = False
48+
self.exception_on_failed_shot = True
49+
4850

4951
def set_attributes(self, attributes_dict):
5052
"""Sets all attribues in attr_dict.

Diff for: labscript_devices/SpinnakerCamera/blacs_workers.py

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(self, serial_number):
5555

5656
# Set the abort acquisition thingy:
5757
self._abort_acquisition = False
58+
self.exception_on_failed_shot = True
5859

5960
def get_attribute_names(self, visibility):
6061
names = []

0 commit comments

Comments
 (0)