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