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