##// END OF EJS Templates
automatic check of the antenna
imanay -
r149:150
parent child
Show More
@@ -1,6 +1,7
1 import os
1 import os
2 import library3
2 import library3
3 import time
3 import time
4 import threading
4
5
5 class ABSServer:
6 class ABSServer:
6
7
@@ -20,7 +21,10
20
21
21 self.createObjects()
22 self.createObjects()
22
23
24 print "Checking control modules, please wait ..."
23 self.enaModules = self.checkAntenna()
25 self.enaModules = self.checkAntenna()
26 print "Starting automatic control module status."
27 self.__AutomaticControlModules()
24
28
25 def createObjects(self):
29 def createObjects(self):
26
30
@@ -32,32 +36,26
32 def waitRequest(self):
36 def waitRequest(self):
33
37
34 #Using rx buffer
38 #Using rx buffer
35 ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData()
39 # ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData()
40 ipSource, ipDestino, cmd, rx_buffer = self.commServerObj.waitData()
36
41
37 if cmd == "SNDF":
42 if cmd == "SNDF":
38 datarpta = self.__sendFile2Modules(cmd = cmd)
43 datarpta = self.__sendFile2Modules(cmd = cmd, rx_buffer = rx_buffer)
39
44
40 if cmd == "CHGB":
45 if cmd == "CHGB":
41 datarpta = self.__changeBeam(cmd = cmd)
46 datarpta = self.__changeBeam(cmd = cmd, rx_buffer = rx_buffer)
42
47
43 if cmd == "ANST":
48 if cmd == "ANST":
44 self.__getControlModuleStatus(cmd = cmd)
49 datarpta = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer)
45 #Using tx buffer
46 datarpta = self.tx_buffer
47
50
48 if cmd == "BGPH":
51 if cmd == "BGPH":
49 self.__getControlModuleBigPhase(cmd = cmd)
52 datarpta = self.__getControlModuleBigPhase(cmd = cmd, rx_buffer = rx_buffer)
50 #Using tx buffer
51 datarpta = self.tx_buffer
52
53
53 if cmd == "LWPH":
54 if cmd == "LWPH":
54 self.__getControlModuleLowPhase(cmd = cmd)
55 datarpta = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer)
55 #Using tx buffer
56 datarpta = self.tx_buffer
57
56
58 if cmd == "NTST":
57 if cmd == "NTST":
59 #Using tx buffer
58 datarpta = self.__getConnectionStatus(cmd = cmd, rx_buffer = rx_buffer)
60 datarpta = self.__getConnectionStatus(cmd = cmd)
61
59
62 self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource)
60 self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource)
63
61
@@ -149,9 +147,10
149 return header, control_modules_lst
147 return header, control_modules_lst
150
148
151
149
152 def __sendFile2Modules(self,cmd):
150 def __sendFile2Modules(self,cmd, rx_buffer):
153
151
154 rx_buffer_lst = self.rx_buffer.split('\n',1)
152 # rx_buffer_lst = self.rx_buffer.split('\n',1)
153 rx_buffer_lst = rx_buffer.split('\n',1)
155 #Getting the filename from the begining of data
154 #Getting the filename from the begining of data
156 filename = rx_buffer_lst[0]
155 filename = rx_buffer_lst[0]
157 tmp = rx_buffer_lst[1]
156 tmp = rx_buffer_lst[1]
@@ -176,7 +175,7
176
175
177 return rpta
176 return rpta
178
177
179 def __changeBeam(self, cmd):
178 def __changeBeam(self, cmd, rx_buffer):
180
179
181 correct = 0
180 correct = 0
182 # enaModules = self.checkAntenna()
181 # enaModules = self.checkAntenna()
@@ -186,7 +185,7
186 if id not in self.enaModules:
185 if id not in self.enaModules:
187 continue
186 continue
188
187
189 if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK":
188 if self.__ConnectionWithControlModules(rx_buffer,cmd,id) == "OK":
190 correct = correct + 1
189 correct = correct + 1
191
190
192 if correct == len(self.enaModules):
191 if correct == len(self.enaModules):
@@ -196,7 +195,7
196
195
197 return rpta
196 return rpta
198
197
199 def __getControlModuleStatus(self, cmd):
198 def __getControlModuleStatus(self, cmd, rx_buffer):
200
199
201 all_blocks = ""
200 all_blocks = ""
202 # enaModules = self.checkAntenna()
201 # enaModules = self.checkAntenna()
@@ -206,14 +205,14
206 if id not in self.enaModules:
205 if id not in self.enaModules:
207 continue
206 continue
208
207
209 one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
208 one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id)
210
209
211 all_blocks = all_blocks + one_block
210 all_blocks = all_blocks + one_block
212 #Using tx buffer
211 #Using tx buffer
213 print all_blocks
212
214 self.tx_buffer = all_blocks
213 return all_blocks
215
214
216 def __getControlModuleBigPhase(self, cmd):
215 def __getControlModuleBigPhase(self, cmd, rx_buffer):
217
216
218 all_blocks = ""
217 all_blocks = ""
219 # enaModules = self.checkAntenna()
218 # enaModules = self.checkAntenna()
@@ -223,14 +222,13
223 if id not in self.enaModules:
222 if id not in self.enaModules:
224 continue
223 continue
225
224
226 one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
225 one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id)
227
226
228 all_blocks = all_blocks + one_block
227 all_blocks = all_blocks + one_block
229 #Using tx buffer
228 #Using tx buffer
230 print all_blocks
229 return all_blocks
231 self.tx_buffer = all_blocks
230
232
231 def __getControlModuleLowPhase(self, cmd, rx_buffer):
233 def __getControlModuleLowPhase(self, cmd):
234
232
235 all_blocks = ""
233 all_blocks = ""
236 # enaModules = self.checkAntenna()
234 # enaModules = self.checkAntenna()
@@ -240,14 +238,13
240 if id not in self.enaModules:
238 if id not in self.enaModules:
241 continue
239 continue
242
240
243 one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
241 one_block = self.__ConnectionWithControlModules(rx_buffer,cmd,id)
244
242
245 all_blocks = all_blocks + one_block
243 all_blocks = all_blocks + one_block
246 #Using tx buffer
244 #Using tx buffer
247 print all_blocks
245 return all_blocks
248 self.tx_buffer = all_blocks
246
249
247 def __getConnectionStatus(self, cmd, rx_buffer):
250 def __getConnectionStatus(self, cmd):
251
248
252 ena = self.checkAntenna()
249 ena = self.checkAntenna()
253 print ena
250 print ena
@@ -259,6 +256,24
259 if id not in self.enaModules:
256 if id not in self.enaModules:
260 continue
257 continue
261
258
259 blockStr = self.__ConnectionWithControlModules(rx_buffer,cmd,id)
260 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n")
261 #Using tx buffer
262 all_blocks = "".join(blockLst)
263
264 return all_blocks
265
266 def getConnectionStatus(self, cmd):
267
268 ena = self.checkAntenna()
269 self.enaModules = ena
270
271 blockLst = []
272
273 for id in range(1,65):
274 if id not in self.enaModules:
275 continue
276
262 blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
277 blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
263 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n")
278 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n")
264 #Using tx buffer
279 #Using tx buffer
@@ -266,25 +281,6
266 print self.tx_buffer
281 print self.tx_buffer
267
282
268 return self.tx_buffer
283 return self.tx_buffer
269
270 def getConnectionStatus(self, cmd):
271
272 ena = self.checkAntenna()
273 self.enaModules = ena
274
275 blockLst = []
276
277 for id in range(1,65):
278 if id not in self.enaModules:
279 continue
280
281 blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
282 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n")
283 #Using tx buffer
284 self.tx_buffer = "".join(blockLst)
285 print self.tx_buffer
286
287 return self.tx_buffer
288
284
289 def getControlModuleStatus(self, cmd):
285 def getControlModuleStatus(self, cmd):
290
286
@@ -304,6 +300,21
304 self.tx_buffer = all_blocks
300 self.tx_buffer = all_blocks
305
301
306 return all_blocks
302 return all_blocks
303
304 def __AutomaticControlModules(self):
305
306 cmd = "ANST"
307 rx_buffer = "1"
308 tmp1 = self.__getControlModuleStatus(cmd = cmd, rx_buffer = rx_buffer)
309
310 cmd = "LWPH"
311 rx_buffer = "0"
312 tmp2 = self.__getControlModuleLowPhase(cmd = cmd, rx_buffer = rx_buffer)
313 print "getting this: "
314 print tmp1
315 print tmp2
316
317 threading.Timer(30, self.__AutomaticControlModules).start()
307
318
308
319
309 if __name__ == '__main__':
320 if __name__ == '__main__':
@@ -1,8 +1,12
1 import file
1 import file
2 from client3 import *
2 from client3 import *
3 import sys
3
4
4 ns = "4"
5
6 absObj = ABSClient(ipDestino="10.10.10.97")
5 absObj = ABSClient(ipDestino="10.10.10.97")
7 #absObj = ABSClient()
6 #absObj = ABSClient()
8 absObj.getControlModuleStatus(ns) No newline at end of file
7 if len(sys.argv) == 2:
8 # ns = "4"
9 ns = sys.argv[1]
10 absObj.getControlModuleStatus(ns)
11 else:
12 print "Only one argument needed." No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now