File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 26
26
"""
27
27
import os
28
28
import unittest
29
+ import warnings
29
30
30
31
import vmbpy
31
32
@@ -82,3 +83,33 @@ def calculate_acquisition_time(cam: vmbpy.Camera, num_frames: int) -> float:
82
83
"""
83
84
fps = cam .get_feature_by_name ('AcquisitionFrameRate' ).get ()
84
85
return num_frames / fps
86
+
87
+
88
+ def reset_default_user_set (cam_id : str ) -> None :
89
+ try :
90
+ with vmbpy .VmbSystem .get_instance () as vmb :
91
+ cam = vmb .get_camera_by_id (cam_id )
92
+ with cam :
93
+ try :
94
+ cam .get_feature_by_name ('UserSetDefault' ).set ('Default' )
95
+ except vmbpy .VmbFeatureError :
96
+ try :
97
+ cam .get_feature_by_name ('UserSetDefaultSelector' ).set ('Default' )
98
+ except vmbpy .VmbFeatureError :
99
+ warnings .warn ('Failed to reset default user set' )
100
+ except vmbpy .VmbCameraError :
101
+ warnings .warn ('Camera could not be found to reset the default user set' )
102
+
103
+
104
+ def load_default_user_set (cam_id : str ) -> None :
105
+ try :
106
+ with vmbpy .VmbSystem .get_instance () as vmb :
107
+ cam = vmb .get_camera_by_id (cam_id )
108
+ with cam :
109
+ try :
110
+ cam .get_feature_by_name ('UserSetSelector' ).set ('Default' )
111
+ cam .get_feature_by_name ('UserSetLoad' ).run ()
112
+ except vmbpy .VmbFeatureError :
113
+ warnings .warn ('Failed to load default user set' )
114
+ except vmbpy .VmbCameraError :
115
+ warnings .warn ('Camera could not be found to load default user set' )
Original file line number Diff line number Diff line change 32
32
# Add local directory to search path for test module import in this script.
33
33
sys .path .insert (0 , os .path .abspath (os .path .dirname (__file__ )))
34
34
35
- from helpers import VmbPyTestCase
35
+ from helpers import VmbPyTestCase , reset_default_user_set , load_default_user_set
36
36
37
37
# Add VmbPy module at the start of the search path. The tests should run against the
38
38
# local vmbpy sources regardless of any existing installations.
@@ -203,6 +203,9 @@ def aligned_print(first, second):
203
203
for mod in REAL_CAM_TEST_MODS :
204
204
test_suite .addTests (_blacklist_tests (loader .loadTestsFromModule (mod ), args .blacklist ))
205
205
206
+ reset_default_user_set (VmbPyTestCase .get_test_camera_id ())
207
+ load_default_user_set (VmbPyTestCase .get_test_camera_id ())
206
208
result = runner .run (test_suite )
207
-
209
+ reset_default_user_set (VmbPyTestCase .get_test_camera_id ())
210
+ load_default_user_set (VmbPyTestCase .get_test_camera_id ())
208
211
sys .exit (0 if result .wasSuccessful () else 1 )
You can’t perform that action at this time.
0 commit comments