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