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