File tree 1 file changed +10
-1
lines changed
src/aslm/model/devices/stages
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 45
45
46
46
47
47
def build_ASI_Stage_connection (com_port ,
48
- baud_rate ):
48
+ baud_rate ,
49
+ timeout = 1000 ):
49
50
"""Connect to the ASI Stage
50
51
51
52
Parameters
@@ -54,6 +55,8 @@ def build_ASI_Stage_connection(com_port,
54
55
Communication port for ASI Tiger Controller - e.g., COM1
55
56
baud_rate : int
56
57
Baud rate for ASI Tiger Controller - e.g., 9600
58
+ timeout: int
59
+ Time to wait for stage in milliseconds.
57
60
58
61
Returns
59
62
-------
@@ -63,14 +66,20 @@ def build_ASI_Stage_connection(com_port,
63
66
64
67
# wait until ASI device is ready
65
68
block_flag = True
69
+ wait_start = time .time ()
70
+ timeout_s = timeout / 1000
66
71
while block_flag :
67
72
asi_stage = TigerController (com_port , baud_rate )
68
73
asi_stage .connect_to_serial ()
69
74
if asi_stage .is_open ():
70
75
block_flag = False
71
76
else :
72
77
print ("Trying to connect to the ASI Stage again" )
78
+ elapsed = time .time ()
79
+ if (elapsed - wait_start ) > timeout_s :
80
+ break
73
81
time .sleep (0.1 )
82
+
74
83
return asi_stage
75
84
76
85
You can’t perform that action at this time.
0 commit comments