-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmanager.py
177 lines (147 loc) · 4.25 KB
/
manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import zmq
import random
import sys
import time
from ops.pyTLS import TLSaccess
# TLSHost = "lassi.ad.nrao.edu"
TLS_HOST = "galileo.gb.nrao.edu"
def runScan(config):
a = TLSaccess(TLS_HOST)
# wait till it's ready
status = a.get_status()
print ("scanner status:", status)
while status.state != "Ready":
time.sleep(1)
status = a.get_status()
# configure
proj = config["proj"] #"test"
res = "63mm@100m"
sensitivity = "Normal"
scan_mode = "Speed"
cntr_az = 270
cntr_el = 45
az_fov = 35
el_fov = 35
a.configure_scanner(proj, res, sensitivity, scan_mode, cntr_az, cntr_el, az_fov, el_fov)
simFile = "/home/scratch/pmargani/LASSI/scannerData/tmp/test.ptx"
print ("setting sim file to", simFile)
a.set_simulated_scan_data_file(simFile)
# get the device scan started,
a.start_scan()
# now wait until it's NOT in ready
while status.state == "Ready":
print("waiting for scan to start")
time.sleep(1)
status = a.get_status()
# dissconnect! Because it only supports one control connection
a.cntrl_exit()
del a
# then once it's started, get the processing going:
# connect to the process server
port = "5557"
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:%s" % port)
# # see what state the server is in
socket.send_string("get_state")
msg = socket.recv()
print ("process server state: ", msg)
time.sleep(1)
socket.send_string("set:proj=cat")
msg = socket.recv()
print ("server response: ", msg)
time.sleep(1)
# set the meta-data
for k, v in config.items():
cmd = "set:%s=%s" % (k, v)
print(cmd)
socket.send_string(cmd)
msg = socket.recv()
print ("server set response: ", msg)
time.sleep(1)
# start processing
socket.send_string("process")
msg = socket.recv()
msgStr = "".join( chr(x) for x in msg)
print ("process server response: ", msg)
time.sleep(3)
sec = 0
while msgStr != "Ready":
# while True:
try:
# status = a.get_status()
# print ("scanner state: ", status.state)
# see what state the server is in
socket.send_string("get_state")
msg = socket.recv()
msgStr = "".join( chr(x) for x in msg)
print ("process server state: ", msg)
time.sleep(1)
sec += 1
print(sec)
except KeyboardInterrupt:
# a.cntrl_exit()
break
print ("done processing Scan")
def runFakeScan(config):
port = "5557"
context = zmq.Context()
socket = context.socket(zmq.PAIR)
socket.connect("tcp://localhost:%s" % port)
# # see what state the server is in
socket.send_string("get_state")
msg = socket.recv()
print ("process server state: ", msg)
time.sleep(1)
# set the meta-data
for k, v in config.items():
cmd = "set:%s=%s" % (k, v)
print(cmd)
socket.send_string(cmd)
msg = socket.recv()
print ("server set response: ", msg)
time.sleep(1)
# start processing
socket.send_string("process")
msg = socket.recv()
msgStr = "".join( chr(x) for x in msg)
print ("process server response: ", msg)
time.sleep(3)
sec = 0
while msgStr != "Ready":
# while True:
try:
# status = a.get_status()
# print ("scanner state: ", status.state)
# see what state the server is in
socket.send_string("get_state")
msg = socket.recv()
msgStr = "".join( chr(x) for x in msg)
print ("process server state: ", msg)
time.sleep(1)
sec += 1
print(sec)
except KeyboardInterrupt:
# a.cntrl_exit()
break
print ("done processing Scan")
def main():
c = {
"proj": "TEST",
"scanNum": 1,
"refScan": "True",
"refScanNum": 0,
"filename": "1"
}
runScan(c)
time.sleep(3)
u = {
"scanNum": 2,
"refScan": "False",
"refScanNum": 1,
"filename": "2"
}
c.update(u)
runScan(c)
if __name__ == '__main__':
main()