@@ -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 :
0 commit comments