@@ -1,400 +1,436 | |||||
1 | import os No newline at end of file |
|
1 | import os | |
2 | import library3 No newline at end of file |
|
2 | import library3 | |
3 | import time No newline at end of file |
|
3 | import time | |
|
4 | from threading import Thread No newline at end of file | |||
4 | import threading No newline at end of file |
|
5 | import threading | |
|
6 | import Queue No newline at end of file | |||
5 | No newline at end of file |
|
7 | ||
6 | class ABSServer: No newline at end of file |
|
8 | class ABSServer: | |
7 | No newline at end of file |
|
9 | ||
8 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500, rx_buffer = "default"): No newline at end of file |
|
10 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500, rx_buffer = "default"): | |
9 | No newline at end of file |
|
11 | ||
10 | self.ipSource = ipSource No newline at end of file |
|
12 | self.ipSource = ipSource | |
11 | self.ipDestino = ipDestino No newline at end of file |
|
13 | self.ipDestino = ipDestino | |
12 | self.portDestino = portDestino No newline at end of file |
|
14 | self.portDestino = portDestino | |
13 | No newline at end of file |
|
15 | ||
14 | self.ipDestino2 = ipDestino2 No newline at end of file |
|
16 | self.ipDestino2 = ipDestino2 | |
15 | self.portDestino2 = portDestino2 No newline at end of file |
|
17 | self.portDestino2 = portDestino2 | |
16 | No newline at end of file |
|
18 | ||
17 | self.tx_buffer = "default" No newline at end of file |
|
19 | self.tx_buffer = "default" | |
18 | # self.rx_buffer = "default" No newline at end of file |
|
20 | # self.rx_buffer = "default" | |
19 | self.rx_buffer = rx_buffer No newline at end of file |
|
21 | self.rx_buffer = rx_buffer | |
20 | self.enaModules = [] No newline at end of file |
|
22 | self.enaModules = [] | |
21 | self.bits = [] No newline at end of file |
|
23 | self.bits = [] | |
22 | self.phase = [] No newline at end of file |
|
24 | self.phase = [] | |
23 | self.txFile = [] No newline at end of file |
|
25 | self.txFile = [] | |
24 | self.rxFile = [] No newline at end of file |
|
26 | self.rxFile = [] | |
25 | No newline at end of file |
|
27 | ||
26 | self.createObjects() No newline at end of file |
|
28 | self.createObjects() | |
27 | No newline at end of file |
|
29 | ||
28 | print "Checking control modules, please wait ..." |
|
30 | print "Checking control modules, please wait ..." | |
No newline at end of file |
|
31 | self.enaModules = self.checkAntenna() | ||
29 | # self.enaModules = self.checkAntenna() |
|
No newline at end of file | ||
No newline at end of file |
|
32 | # self.enaModules = [1,12] No newline at end of file | ||
30 | self.enaModules = [1,12] No newline at end of file |
|
|||
31 | print "Starting automatic control module status." No newline at end of file |
|
33 | print "Starting automatic control module status." | |
32 | self.__StartingAutomaticControlModules() No newline at end of file |
|
34 | self.__StartingAutomaticControlModules() | |
33 | self.__AutomaticControlModules() No newline at end of file |
|
35 | self.__AutomaticControlModules() | |
34 | No newline at end of file |
|
36 | ||
35 | def createObjects(self): No newline at end of file |
|
37 | def createObjects(self): | |
36 | No newline at end of file |
|
38 | ||
37 | asServer = True No newline at end of file |
|
39 | asServer = True | |
38 | self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) No newline at end of file |
|
40 | self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) | |
39 | self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) No newline at end of file |
|
41 | self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) | |
40 | self.wFiles = library3.FilesStuff() No newline at end of file |
|
42 | self.wFiles = library3.FilesStuff() | |
41 | No newline at end of file |
|
43 | ||
42 | def waitRequest(self): No newline at end of file |
|
44 | def waitRequest(self): | |
43 | No newline at end of file |
|
45 | ||
44 | #Using rx buffer No newline at end of file |
|
46 | #Using rx buffer | |
45 | # ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() No newline at end of file |
|
47 | # ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() | |
46 | ipSource, ipDestino, cmd, rx_buffer = self.commServerObj.waitData() No newline at end of file |
|
48 | ipSource, ipDestino, cmd, rx_buffer = self.commServerObj.waitData() | |
47 | No newline at end of file |
|
49 | ||
48 | if cmd == "SNDF": No newline at end of file |
|
50 | if cmd == "SNDF": | |
49 | datarpta = self.__sendFile2Modules(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
51 | datarpta = self.__sendFile2Modules(cmd = cmd, rx_buffer = rx_buffer) | |
50 | No newline at end of file |
|
52 | ||
51 | if cmd == "GETF": No newline at end of file |
|
53 | if cmd == "GETF": | |
52 | datarpta = self.__getFileFromModules(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
54 | datarpta = self.__getFileFromModules(cmd = cmd, rx_buffer = rx_buffer) | |
53 | No newline at end of file |
|
55 | ||
54 | if cmd == "CHGB": No newline at end of file |
|
56 | if cmd == "CHGB": | |
55 | datarpta = self.__changeBeam(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
57 | datarpta = self.__changeBeam(cmd = cmd, rx_buffer = rx_buffer) | |
56 | No newline at end of file |
|
58 | ||
57 | if cmd == "ANST": No newline at end of file |
|
59 | if cmd == "ANST": | |
58 | datarpta = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
60 | datarpta = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) | |
59 | No newline at end of file |
|
61 | ||
60 | if cmd == "BGPH": No newline at end of file |
|
62 | if cmd == "BGPH": | |
61 | datarpta = self.__getControlModuleBigPhase(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
63 | datarpta = self.__getControlModuleBigPhase(cmd = cmd, rx_buffer = rx_buffer) | |
62 | No newline at end of file |
|
64 | ||
63 | if cmd == "LWPH": No newline at end of file |
|
65 | if cmd == "LWPH": | |
64 | datarpta = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
66 | datarpta = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) | |
65 | No newline at end of file |
|
67 | ||
66 | if cmd == "NTST": No newline at end of file |
|
68 | if cmd == "NTST": | |
67 | datarpta = self.__getConnectionStatus(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
69 | datarpta = self.__getConnectionStatus(cmd = cmd, rx_buffer = rx_buffer) | |
68 | No newline at end of file |
|
70 | ||
69 | self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) No newline at end of file |
|
71 | self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) | |
70 |
|
72 | |||
No newline at end of file |
|
73 | def __checkModule(self, address): No newline at end of file | ||
71 | def checkModule(self, address): No newline at end of file |
|
|||
72 | No newline at end of file |
|
74 | ||
73 | cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" No newline at end of file |
|
75 | cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" | |
74 | status = os.system(cmd) No newline at end of file |
|
76 | status = os.system(cmd) | |
75 | No newline at end of file |
|
77 | ||
76 | if status == 256: No newline at end of file |
|
78 | if status == 256: | |
77 | return False No newline at end of file |
|
79 | return False | |
78 | No newline at end of file |
|
80 | ||
79 | return True No newline at end of file |
|
81 | return True | |
80 | No newline at end of file |
|
82 | ||
81 | def __writeReport(self, enaModules): No newline at end of file |
|
83 | def __writeReport(self, enaModules): | |
82 | No newline at end of file |
|
84 | ||
83 | status_array = ["Status of modules\n"] No newline at end of file |
|
85 | status_array = ["Status of modules\n"] | |
84 | status_array.append("----------------\n") No newline at end of file |
|
86 | status_array.append("----------------\n") | |
85 | No newline at end of file |
|
87 | ||
86 | for address in range(1,65): No newline at end of file |
|
88 | for address in range(1,65): | |
87 | if address in enaModules: No newline at end of file |
|
89 | if address in enaModules: | |
88 | status_array.append("192.168.1." + str(address) + " [1 1]\n") No newline at end of file |
|
90 | status_array.append("192.168.1." + str(address) + " [1 1]\n") | |
89 | else: No newline at end of file |
|
91 | else: | |
90 | status_array.append("192.168.1." + str(address) + " [0 0]\n") No newline at end of file |
|
92 | status_array.append("192.168.1." + str(address) + " [0 0]\n") | |
91 | No newline at end of file |
|
93 | ||
92 | filename = "module_status.txt" No newline at end of file |
|
94 | filename = "module_status.txt" | |
93 | self.__writeFile(filename,status_array) No newline at end of file |
|
95 | self.__writeFile(filename,status_array) | |
94 | # f = open("module_status.txt","w") No newline at end of file |
|
96 | # f = open("module_status.txt","w") | |
95 | # f.writelines(status_array) No newline at end of file |
|
97 | # f.writelines(status_array) | |
96 | # f.close() No newline at end of file |
|
98 | # f.close() | |
97 | No newline at end of file |
|
99 | ||
98 | No newline at end of file |
|
100 | ||
99 | def __CreateFile(self, filename): No newline at end of file |
|
101 | def __CreateFile(self, filename): | |
100 | No newline at end of file |
|
102 | ||
101 | fobj = open(filename,"w") No newline at end of file |
|
103 | fobj = open(filename,"w") | |
102 | fobj.close() No newline at end of file |
|
104 | fobj.close() | |
103 | No newline at end of file |
|
105 | ||
104 | def __writeNewFile(self, filename, data): No newline at end of file |
|
106 | def __writeNewFile(self, filename, data): | |
105 | No newline at end of file |
|
107 | ||
106 | fobj = open(filename,"w") No newline at end of file |
|
108 | fobj = open(filename,"w") | |
107 | fobj.writelines(data) No newline at end of file |
|
109 | fobj.writelines(data) | |
108 | fobj.close() No newline at end of file |
|
110 | fobj.close() | |
109 | No newline at end of file |
|
111 | ||
110 | def __writeFile(self, filename, data): No newline at end of file |
|
112 | def __writeFile(self, filename, data): | |
111 | No newline at end of file |
|
113 | ||
112 | fobj = open(filename,"a") No newline at end of file |
|
114 | fobj = open(filename,"a") | |
113 | fobj.writelines(data) No newline at end of file |
|
115 | fobj.writelines(data) | |
114 | fobj.close() No newline at end of file |
|
116 | fobj.close() | |
115 |
|
117 | |||
No newline at end of file |
|
118 | def __checkAntenna(self): No newline at end of file | ||
116 | def checkAntenna(self): No newline at end of file |
|
|||
117 | No newline at end of file |
|
119 | ||
118 | """ No newline at end of file |
|
120 | """ | |
119 | Direccion de los modulos de las antenas: No newline at end of file |
|
121 | Direccion de los modulos de las antenas: | |
120 | No newline at end of file |
|
122 | ||
121 | Norte : 01-16 No newline at end of file |
|
123 | Norte : 01-16 | |
122 | Este : 17-32 No newline at end of file |
|
124 | Este : 17-32 | |
123 | Oeste: : 33-48 No newline at end of file |
|
125 | Oeste: : 33-48 | |
124 | Sur : 49-64 No newline at end of file |
|
126 | Sur : 49-64 | |
125 | No newline at end of file |
|
127 | ||
126 | """ No newline at end of file |
|
128 | """ | |
127 | No newline at end of file |
|
129 | ||
128 | enaModules2 = [] No newline at end of file |
|
130 | enaModules2 = [] | |
129 | No newline at end of file |
|
131 | ||
130 | for address in range(1,65): No newline at end of file |
|
132 | for address in range(1,65): | |
131 | if self.checkModule(address): No newline at end of file |
|
133 | if self.checkModule(address): | |
132 | enaModules2.append(address) No newline at end of file |
|
134 | enaModules2.append(address) | |
133 | No newline at end of file |
|
135 | ||
134 | self.__writeReport(enaModules2) No newline at end of file |
|
136 | self.__writeReport(enaModules2) | |
135 | return enaModules2 No newline at end of file |
|
137 | return enaModules2 | |
|
138 | ||||
|
No newline at end of file | ||||
|
139 | def checkModule(self, arg, queue): | |||
|
No newline at end of file | ||||
|
140 | cmd = "ping -c 1 -w 1 192.168.1."+ str(arg) + " >> /dev/null" | |||
|
No newline at end of file | ||||
|
141 | status = os.system(cmd) | |||
|
No newline at end of file | ||||
|
142 | if status == 256: | |||
|
No newline at end of file | ||||
|
143 | result = "failed" | |||
|
No newline at end of file | ||||
|
144 | else: | |||
|
No newline at end of file | ||||
|
145 | result = "ok" | |||
|
No newline at end of file | ||||
|
146 | queue.put({arg: result}) | |||
|
No newline at end of file | ||||
|
147 | ||||
|
No newline at end of file | ||||
|
148 | def checkAntenna(self): | |||
|
No newline at end of file | ||||
|
149 | ||||
|
No newline at end of file | ||||
|
150 | iD = range(1,256) | |||
|
No newline at end of file | ||||
|
151 | q = Queue.Queue() | |||
|
No newline at end of file | ||||
|
152 | threads = [] | |||
|
No newline at end of file | ||||
|
153 | tOut = [] | |||
|
No newline at end of file | ||||
|
154 | modules = [] | |||
|
No newline at end of file | ||||
|
155 | ||||
|
No newline at end of file | ||||
|
156 | for argument in iD: | |||
|
No newline at end of file | ||||
|
157 | t = Thread(target=self.checkModule, args=(argument, q)) | |||
|
No newline at end of file | ||||
|
158 | t.start() | |||
|
No newline at end of file | ||||
|
159 | threads.append(t) | |||
|
No newline at end of file | ||||
|
160 | ||||
|
No newline at end of file | ||||
|
161 | for t in threads: | |||
|
No newline at end of file | ||||
|
162 | t.join() | |||
|
No newline at end of file | ||||
|
163 | ||||
|
No newline at end of file | ||||
|
164 | for _ in range(len(iD)): | |||
|
No newline at end of file | ||||
|
165 | tOut.append(q.get()) | |||
|
No newline at end of file | ||||
|
166 | ||||
|
No newline at end of file | ||||
|
167 | for i in tOut: | |||
|
No newline at end of file | ||||
|
168 | if i.values()[0] == 'ok': | |||
|
No newline at end of file | ||||
|
169 | modules.append(i.keys()[0]) | |||
|
No newline at end of file | ||||
|
170 | ||||
|
No newline at end of file | ||||
|
171 | return modules No newline at end of file | |||
136 | No newline at end of file |
|
172 | ||
137 | def __ConnectionWithControlModules(self,data,cmd,id): No newline at end of file |
|
173 | def __ConnectionWithControlModules(self,data,cmd,id): | |
138 | No newline at end of file |
|
174 | ||
139 | self.commClientObj.open_socket() No newline at end of file |
|
175 | self.commClientObj.open_socket() | |
140 | ip = "192.168.1." + str(id) No newline at end of file |
|
176 | ip = "192.168.1." + str(id) | |
141 | self.commClientObj.sendData(cmd, data, ip) No newline at end of file |
|
177 | self.commClientObj.sendData(cmd, data, ip) | |
142 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() No newline at end of file |
|
178 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
143 | self.commClientObj.close_socket() No newline at end of file |
|
179 | self.commClientObj.close_socket() | |
144 | No newline at end of file |
|
180 | ||
145 | return tmp No newline at end of file |
|
181 | return tmp | |
146 | No newline at end of file |
|
182 | ||
147 | def abs2ControlModuleFormatFile(self, filename): No newline at end of file |
|
183 | def abs2ControlModuleFormatFile(self, filename): | |
148 | No newline at end of file |
|
184 | ||
149 | #From matriz to control module format No newline at end of file |
|
185 | #From matriz to control module format | |
150 | self.wFiles.toCentralControlFormat(filename) No newline at end of file |
|
186 | self.wFiles.toCentralControlFormat(filename) | |
151 | FileName = "CentralControlFormat.txt" No newline at end of file |
|
187 | FileName = "CentralControlFormat.txt" | |
152 | F_Obj = open(FileName,"r") No newline at end of file |
|
188 | F_Obj = open(FileName,"r") | |
153 | FileList = F_Obj.readlines() No newline at end of file |
|
189 | FileList = F_Obj.readlines() | |
154 | F_Obj.close() No newline at end of file |
|
190 | F_Obj.close() | |
155 | FileStr = "".join(FileList) No newline at end of file |
|
191 | FileStr = "".join(FileList) | |
156 | No newline at end of file |
|
192 | ||
157 | return FileStr No newline at end of file |
|
193 | return FileStr | |
158 | No newline at end of file |
|
194 | ||
159 | def __All2Blocks(self,input): No newline at end of file |
|
195 | def __All2Blocks(self,input): | |
160 | No newline at end of file |
|
196 | ||
161 | rx_frame_lst = input.split('\n',2) No newline at end of file |
|
197 | rx_frame_lst = input.split('\n',2) | |
162 | No newline at end of file |
|
198 | ||
163 | header = rx_frame_lst[0] + "\n" No newline at end of file |
|
199 | header = rx_frame_lst[0] + "\n" | |
164 | control_modules_str = rx_frame_lst[2] No newline at end of file |
|
200 | control_modules_str = rx_frame_lst[2] | |
165 | control_modules_lst = control_modules_str.split("------\n") No newline at end of file |
|
201 | control_modules_lst = control_modules_str.split("------\n") | |
166 | No newline at end of file |
|
202 | ||
167 | return header, control_modules_lst No newline at end of file |
|
203 | return header, control_modules_lst | |
168 | No newline at end of file |
|
204 | ||
169 | No newline at end of file |
|
205 | ||
170 | def __sendFile2Modules(self,cmd, rx_buffer): No newline at end of file |
|
206 | def __sendFile2Modules(self,cmd, rx_buffer): | |
171 | No newline at end of file |
|
207 | ||
172 | # rx_buffer_lst = self.rx_buffer.split('\n',1) No newline at end of file |
|
208 | # rx_buffer_lst = self.rx_buffer.split('\n',1) | |
173 | rx_buffer_lst = rx_buffer.split('\n',1) No newline at end of file |
|
209 | rx_buffer_lst = rx_buffer.split('\n',1) | |
174 | #Getting the filename from the begining of data No newline at end of file |
|
210 | #Getting the filename from the begining of data | |
175 | filename = rx_buffer_lst[0] No newline at end of file |
|
211 | filename = rx_buffer_lst[0] | |
176 | tmp = rx_buffer_lst[1] No newline at end of file |
|
212 | tmp = rx_buffer_lst[1] | |
177 | self.__writeFile(filename,tmp) No newline at end of file |
|
213 | self.__writeFile(filename,tmp) | |
178 | data = self.abs2ControlModuleFormatFile(filename) No newline at end of file |
|
214 | data = self.abs2ControlModuleFormatFile(filename) | |
179 | #Needed for the loop No newline at end of file |
|
215 | #Needed for the loop | |
180 | header, control_modules_lst = self.__All2Blocks(data) No newline at end of file |
|
216 | header, control_modules_lst = self.__All2Blocks(data) | |
181 | correct = 0 No newline at end of file |
|
217 | correct = 0 | |
182 | No newline at end of file |
|
218 | ||
183 | for id in range(1,65): No newline at end of file |
|
219 | for id in range(1,65): | |
184 | No newline at end of file |
|
220 | ||
185 | if id not in self.enaModules: No newline at end of file |
|
221 | if id not in self.enaModules: | |
186 | continue No newline at end of file |
|
222 | continue | |
187 | No newline at end of file |
|
223 | ||
188 | if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": No newline at end of file |
|
224 | if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": | |
189 | correct = correct + 1 No newline at end of file |
|
225 | correct = correct + 1 | |
190 | No newline at end of file |
|
226 | ||
191 | if correct == len(self.enaModules): No newline at end of file |
|
227 | if correct == len(self.enaModules): | |
192 | rpta = "OK" No newline at end of file |
|
228 | rpta = "OK" | |
193 | else: No newline at end of file |
|
229 | else: | |
194 | rpta = "Failure" No newline at end of file |
|
230 | rpta = "Failure" | |
195 | No newline at end of file |
|
231 | ||
196 | return rpta No newline at end of file |
|
232 | return rpta | |
197 | No newline at end of file |
|
233 | ||
198 | def __getFileFromModules(self, cmd, rx_buffer): No newline at end of file |
|
234 | def __getFileFromModules(self, cmd, rx_buffer): | |
199 | No newline at end of file |
|
235 | ||
200 | for id in range(1,65): No newline at end of file |
|
236 | for id in range(1,65): | |
201 | if id not in self.enaModules: No newline at end of file |
|
237 | if id not in self.enaModules: | |
202 | continue No newline at end of file |
|
238 | continue | |
203 | No newline at end of file |
|
239 | ||
204 | file = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
240 | file = self.__ConnectionWithControlModules(rx_buffer,cmd,id) | |
205 | del self.rxFile[id-1] No newline at end of file |
|
241 | del self.rxFile[id-1] | |
206 | self.rxFile.insert(id-1, file) No newline at end of file |
|
242 | self.rxFile.insert(id-1, file) | |
207 | No newline at end of file |
|
243 | ||
208 | def __changeBeam(self, cmd, rx_buffer): No newline at end of file |
|
244 | def __changeBeam(self, cmd, rx_buffer): | |
209 | No newline at end of file |
|
245 | ||
210 | correct = 0 No newline at end of file |
|
246 | correct = 0 | |
211 | # enaModules = self.checkAntenna() No newline at end of file |
|
247 | # enaModules = self.checkAntenna() | |
212 | # enaModules = [11,12,13,14] No newline at end of file |
|
248 | # enaModules = [11,12,13,14] | |
213 | No newline at end of file |
|
249 | ||
214 | for id in range(1,65): No newline at end of file |
|
250 | for id in range(1,65): | |
215 | if id not in self.enaModules: No newline at end of file |
|
251 | if id not in self.enaModules: | |
216 | continue No newline at end of file |
|
252 | continue | |
217 | No newline at end of file |
|
253 | ||
218 | if self.__ConnectionWithControlModules(rx_buffer,cmd,id) == "OK": No newline at end of file |
|
254 | if self.__ConnectionWithControlModules(rx_buffer,cmd,id) == "OK": | |
219 | correct = correct + 1 No newline at end of file |
|
255 | correct = correct + 1 | |
220 | No newline at end of file |
|
256 | ||
221 | if correct == len(self.enaModules): No newline at end of file |
|
257 | if correct == len(self.enaModules): | |
222 | rpta = "OK" No newline at end of file |
|
258 | rpta = "OK" | |
223 | else: No newline at end of file |
|
259 | else: | |
224 | rpta = "Failure" No newline at end of file |
|
260 | rpta = "Failure" | |
225 | No newline at end of file |
|
261 | ||
226 | return rpta No newline at end of file |
|
262 | return rpta | |
227 | No newline at end of file |
|
263 | ||
228 | def __getControlModuleStatus(self, cmd, rx_buffer): No newline at end of file |
|
264 | def __getControlModuleStatus(self, cmd, rx_buffer): | |
229 | No newline at end of file |
|
265 | ||
230 | # all_blocks = "" No newline at end of file |
|
266 | # all_blocks = "" | |
231 | # all_blocks = [] No newline at end of file |
|
267 | # all_blocks = [] | |
232 | # enaModules = self.checkAntenna() No newline at end of file |
|
268 | # enaModules = self.checkAntenna() | |
233 | # enaModules = [11,12,13,14] No newline at end of file |
|
269 | # enaModules = [11,12,13,14] | |
234 | No newline at end of file |
|
270 | ||
235 | for id in range(1,65): No newline at end of file |
|
271 | for id in range(1,65): | |
236 | if id not in self.enaModules: No newline at end of file |
|
272 | if id not in self.enaModules: | |
237 | continue No newline at end of file |
|
273 | continue | |
238 | No newline at end of file |
|
274 | ||
239 | bits = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
275 | bits = self.__ConnectionWithControlModules(rx_buffer,cmd,id) | |
240 | del self.bits[id-1] No newline at end of file |
|
276 | del self.bits[id-1] | |
241 | self.bits.insert(id-1, bits) No newline at end of file |
|
277 | self.bits.insert(id-1, bits) | |
242 | No newline at end of file |
|
278 | ||
243 | # all_blocks.append(one_block) No newline at end of file |
|
279 | # all_blocks.append(one_block) | |
244 | #Using tx buffer No newline at end of file |
|
280 | #Using tx buffer | |
245 | No newline at end of file |
|
281 | ||
246 | # return all_blocks No newline at end of file |
|
282 | # return all_blocks | |
247 | No newline at end of file |
|
283 | ||
248 | def __getControlModuleBigPhase(self, cmd, rx_buffer): No newline at end of file |
|
284 | def __getControlModuleBigPhase(self, cmd, rx_buffer): | |
249 | No newline at end of file |
|
285 | ||
250 | # all_blocks = "" No newline at end of file |
|
286 | # all_blocks = "" | |
251 | all_blocks = [] No newline at end of file |
|
287 | all_blocks = [] | |
252 | # enaModules = self.checkAntenna() No newline at end of file |
|
288 | # enaModules = self.checkAntenna() | |
253 | # enaModules = [11,12,13,14] No newline at end of file |
|
289 | # enaModules = [11,12,13,14] | |
254 | No newline at end of file |
|
290 | ||
255 | for id in range(1,65): No newline at end of file |
|
291 | for id in range(1,65): | |
256 | if id not in self.enaModules: No newline at end of file |
|
292 | if id not in self.enaModules: | |
257 | continue No newline at end of file |
|
293 | continue | |
258 | No newline at end of file |
|
294 | ||
259 | one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
295 | one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id) | |
260 | No newline at end of file |
|
296 | ||
261 | # all_blocks = all_blocks + one_block No newline at end of file |
|
297 | # all_blocks = all_blocks + one_block | |
262 | all_blocks.append(one_block) No newline at end of file |
|
298 | all_blocks.append(one_block) | |
263 | #Using tx buffer No newline at end of file |
|
299 | #Using tx buffer | |
264 | return all_blocks No newline at end of file |
|
300 | return all_blocks | |
265 | No newline at end of file |
|
301 | ||
266 | def __getControlModuleLowPhase(self, cmd, rx_buffer): No newline at end of file |
|
302 | def __getControlModuleLowPhase(self, cmd, rx_buffer): | |
267 | No newline at end of file |
|
303 | ||
268 | # all_blocks = "" No newline at end of file |
|
304 | # all_blocks = "" | |
269 | # all_blocks = [] No newline at end of file |
|
305 | # all_blocks = [] | |
270 | # enaModules = self.checkAntenna() No newline at end of file |
|
306 | # enaModules = self.checkAntenna() | |
271 | # enaModules = [11,12,13,14] No newline at end of file |
|
307 | # enaModules = [11,12,13,14] | |
272 | No newline at end of file |
|
308 | ||
273 | for id in range(1,65): No newline at end of file |
|
309 | for id in range(1,65): | |
274 | if id not in self.enaModules: No newline at end of file |
|
310 | if id not in self.enaModules: | |
275 | continue No newline at end of file |
|
311 | continue | |
276 | No newline at end of file |
|
312 | ||
277 | phase = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
313 | phase = self.__ConnectionWithControlModules(rx_buffer,cmd,id) | |
278 | del self.phase[id-1] No newline at end of file |
|
314 | del self.phase[id-1] | |
279 | self.phase.insert(id-1, phase) No newline at end of file |
|
315 | self.phase.insert(id-1, phase) | |
280 | # all_blocks = all_blocks + one_block No newline at end of file |
|
316 | # all_blocks = all_blocks + one_block | |
281 | # all_blocks.append(one_block) No newline at end of file |
|
317 | # all_blocks.append(one_block) | |
282 | #Using tx buffer No newline at end of file |
|
318 | #Using tx buffer | |
283 | # return all_blocks No newline at end of file |
|
319 | # return all_blocks | |
284 | No newline at end of file |
|
320 | ||
285 | def __getConnectionStatus(self, cmd, rx_buffer): No newline at end of file |
|
321 | def __getConnectionStatus(self, cmd, rx_buffer): | |
286 | No newline at end of file |
|
322 | ||
287 | ena = self.checkAntenna() No newline at end of file |
|
323 | ena = self.checkAntenna() | |
288 | print ena No newline at end of file |
|
324 | print ena | |
289 | self.enaModules = ena No newline at end of file |
|
325 | self.enaModules = ena | |
290 | No newline at end of file |
|
326 | ||
291 | blockLst = [] No newline at end of file |
|
327 | blockLst = [] | |
292 | No newline at end of file |
|
328 | ||
293 | for id in range(1,65): No newline at end of file |
|
329 | for id in range(1,65): | |
294 | if id not in self.enaModules: No newline at end of file |
|
330 | if id not in self.enaModules: | |
295 | continue No newline at end of file |
|
331 | continue | |
296 | No newline at end of file |
|
332 | ||
297 | blockStr = self.__ConnectionWithControlModules(rx_buffer,cmd,id) No newline at end of file |
|
333 | blockStr = self.__ConnectionWithControlModules(rx_buffer,cmd,id) | |
298 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") No newline at end of file |
|
334 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") | |
299 | #Using tx buffer No newline at end of file |
|
335 | #Using tx buffer | |
300 | all_blocks = "".join(blockLst) No newline at end of file |
|
336 | all_blocks = "".join(blockLst) | |
301 | No newline at end of file |
|
337 | ||
302 | return all_blocks No newline at end of file |
|
338 | return all_blocks | |
303 | No newline at end of file |
|
339 | ||
304 | def getConnectionStatus(self, cmd): No newline at end of file |
|
340 | def getConnectionStatus(self, cmd): | |
305 | No newline at end of file |
|
341 | ||
306 | ena = self.checkAntenna() No newline at end of file |
|
342 | ena = self.checkAntenna() | |
307 | self.enaModules = ena No newline at end of file |
|
343 | self.enaModules = ena | |
308 | No newline at end of file |
|
344 | ||
309 | blockLst = [] No newline at end of file |
|
345 | blockLst = [] | |
310 | No newline at end of file |
|
346 | ||
311 | for id in range(1,65): No newline at end of file |
|
347 | for id in range(1,65): | |
312 | if id not in self.enaModules: No newline at end of file |
|
348 | if id not in self.enaModules: | |
313 | continue No newline at end of file |
|
349 | continue | |
314 | No newline at end of file |
|
350 | ||
315 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) No newline at end of file |
|
351 | blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
316 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") No newline at end of file |
|
352 | blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") | |
317 | #Using tx buffer No newline at end of file |
|
353 | #Using tx buffer | |
318 | self.tx_buffer = "".join(blockLst) No newline at end of file |
|
354 | self.tx_buffer = "".join(blockLst) | |
319 | print self.tx_buffer No newline at end of file |
|
355 | print self.tx_buffer | |
320 | No newline at end of file |
|
356 | ||
321 | return self.tx_buffer No newline at end of file |
|
357 | return self.tx_buffer | |
322 | No newline at end of file |
|
358 | ||
323 | def getControlModuleStatus(self, cmd): No newline at end of file |
|
359 | def getControlModuleStatus(self, cmd): | |
324 | No newline at end of file |
|
360 | ||
325 | all_blocks = "" No newline at end of file |
|
361 | all_blocks = "" | |
326 | # enaModules = self.checkAntenna() No newline at end of file |
|
362 | # enaModules = self.checkAntenna() | |
327 | # enaModules = [11,12,13,14] No newline at end of file |
|
363 | # enaModules = [11,12,13,14] | |
328 | No newline at end of file |
|
364 | ||
329 | for id in range(1,65): No newline at end of file |
|
365 | for id in range(1,65): | |
330 | if id not in self.enaModules: No newline at end of file |
|
366 | if id not in self.enaModules: | |
331 | continue No newline at end of file |
|
367 | continue | |
332 | No newline at end of file |
|
368 | ||
333 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) No newline at end of file |
|
369 | one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) | |
334 | No newline at end of file |
|
370 | ||
335 | all_blocks = all_blocks + one_block No newline at end of file |
|
371 | all_blocks = all_blocks + one_block | |
336 | #Using tx buffer No newline at end of file |
|
372 | #Using tx buffer | |
337 | print all_blocks No newline at end of file |
|
373 | print all_blocks | |
338 | self.tx_buffer = all_blocks No newline at end of file |
|
374 | self.tx_buffer = all_blocks | |
339 | No newline at end of file |
|
375 | ||
340 | return all_blocks No newline at end of file |
|
376 | return all_blocks | |
341 | No newline at end of file |
|
377 | ||
342 | def __StartingAutomaticControlModules(self): No newline at end of file |
|
378 | def __StartingAutomaticControlModules(self): | |
343 | No newline at end of file |
|
379 | ||
344 | #Starting file No newline at end of file |
|
380 | #Starting file | |
345 | self.__CreateFile("Monitoring.txt") No newline at end of file |
|
381 | self.__CreateFile("Monitoring.txt") | |
346 | # data = "MOD.\t BITS\t\t PHASE\n" No newline at end of file |
|
382 | # data = "MOD.\t BITS\t\t PHASE\n" | |
347 | # self.__writeFile("Monitoring.txt", data) No newline at end of file |
|
383 | # self.__writeFile("Monitoring.txt", data) | |
348 | #Starting lists No newline at end of file |
|
384 | #Starting lists | |
349 | self.txFile = list("------\n------\n------\n" for i in range(64)) No newline at end of file |
|
385 | self.txFile = list("------\n------\n------\n" for i in range(64)) | |
350 | self.rxFile = list("------\n------\n------\n" for i in range(64)) No newline at end of file |
|
386 | self.rxFile = list("------\n------\n------\n" for i in range(64)) | |
351 | self.bits = list("------\n------\n------\n" for i in range(64)) No newline at end of file |
|
387 | self.bits = list("------\n------\n------\n" for i in range(64)) | |
352 | self.phase = list("----- -----\n----- -----\n----- -----\n" for i in range(64)) No newline at end of file |
|
388 | self.phase = list("----- -----\n----- -----\n----- -----\n" for i in range(64)) | |
353 | No newline at end of file |
|
389 | ||
354 | def __AutomaticControlModules(self): No newline at end of file |
|
390 | def __AutomaticControlModules(self): | |
355 | No newline at end of file |
|
391 | ||
356 | cmd = "GETF" No newline at end of file |
|
392 | cmd = "GETF" | |
357 | rx_buffer = "experimento1.ab1" + "\n" No newline at end of file |
|
393 | rx_buffer = "experimento1.ab1" + "\n" | |
358 | self.__getFileFromModules(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
394 | self.__getFileFromModules(cmd = cmd, rx_buffer = rx_buffer) | |
359 | No newline at end of file |
|
395 | ||
360 | print self.rxFile No newline at end of file |
|
396 | print self.rxFile | |
361 | No newline at end of file |
|
397 | ||
362 | cmd = "ANST" No newline at end of file |
|
398 | cmd = "ANST" | |
363 | rx_buffer = "1" No newline at end of file |
|
399 | rx_buffer = "1" | |
364 | self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
400 | self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer) | |
365 | No newline at end of file |
|
401 | ||
366 | cmd = "LWPH" No newline at end of file |
|
402 | cmd = "LWPH" | |
367 | rx_buffer = "0" No newline at end of file |
|
403 | rx_buffer = "0" | |
368 | self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) No newline at end of file |
|
404 | self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer) | |
369 | print "Saving file..." No newline at end of file |
|
405 | print "Saving file..." | |
370 | No newline at end of file |
|
406 | ||
371 | No newline at end of file |
|
407 | ||
372 | print self.bits No newline at end of file |
|
408 | print self.bits | |
373 | print self.phase No newline at end of file |
|
409 | print self.phase | |
374 | No newline at end of file |
|
410 | ||
375 | self.__WritingMonitoringFile() No newline at end of file |
|
411 | self.__WritingMonitoringFile() | |
376 | No newline at end of file |
|
412 | ||
377 | threading.Timer(60, self.__AutomaticControlModules).start() No newline at end of file |
|
413 | threading.Timer(60, self.__AutomaticControlModules).start() | |
378 | No newline at end of file |
|
414 | ||
379 | def __WritingMonitoringFile(self): No newline at end of file |
|
415 | def __WritingMonitoringFile(self): | |
380 | filename = "Monitoring.txt" No newline at end of file |
|
416 | filename = "Monitoring.txt" | |
381 | data = '===============================' + '\n' No newline at end of file |
|
417 | data = '===============================' + '\n' | |
382 | self.__writeFile(filename, data) No newline at end of file |
|
418 | self.__writeFile(filename, data) | |
383 | data = time.strftime('\t' + "%d%b%Y %I:%M:%S %p" + '\n', time.localtime()) No newline at end of file |
|
419 | data = time.strftime('\t' + "%d%b%Y %I:%M:%S %p" + '\n', time.localtime()) | |
384 | self.__writeFile(filename, data) No newline at end of file |
|
420 | self.__writeFile(filename, data) | |
385 | data = "MOD.\t BITS\t\t PHASE\n" No newline at end of file |
|
421 | data = "MOD.\t BITS\t\t PHASE\n" | |
386 | self.__writeFile(filename, data) No newline at end of file |
|
422 | self.__writeFile(filename, data) | |
387 | data = '===============================' + '\n' No newline at end of file |
|
423 | data = '===============================' + '\n' | |
388 | self.__writeFile(filename, data) No newline at end of file |
|
424 | self.__writeFile(filename, data) | |
389 | for i in range(64): No newline at end of file |
|
425 | for i in range(64): | |
390 | tmp = self.bits[i].split('\n',3) No newline at end of file |
|
426 | tmp = self.bits[i].split('\n',3) | |
391 | self.__writeFile(filename, ' ' + str(i + 1) + '\t\t' + tmp[2]) No newline at end of file |
|
427 | self.__writeFile(filename, ' ' + str(i + 1) + '\t\t' + tmp[2]) | |
392 | tmp = self.phase[i].split('\n',3) No newline at end of file |
|
428 | tmp = self.phase[i].split('\n',3) | |
393 | self.__writeFile(filename, '\t\t' + tmp[2] + '\n') No newline at end of file |
|
429 | self.__writeFile(filename, '\t\t' + tmp[2] + '\n') | |
394 | No newline at end of file |
|
430 | ||
395 | if __name__ == '__main__': No newline at end of file |
|
431 | if __name__ == '__main__': | |
396 | No newline at end of file |
|
432 | ||
397 | absObj = ABSServer() No newline at end of file |
|
433 | absObj = ABSServer() | |
398 | No newline at end of file |
|
434 | ||
399 | while 1: No newline at end of file |
|
435 | while 1: | |
400 | absObj.waitRequest() No newline at end of file |
|
436 | absObj.waitRequest() |
General Comments 0
You need to be logged in to leave comments.
Login now