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