##// END OF EJS Templates
imanay -
r123:124
parent child
Show More
@@ -0,0 +1,66
1 Status of modules
No newline at end of file
2 ----------------
No newline at end of file
3 192.168.1.1 [1 1]
No newline at end of file
4 192.168.1.2 [1 1]
No newline at end of file
5 192.168.1.3 [0 0]
No newline at end of file
6 192.168.1.4 [0 0]
No newline at end of file
7 192.168.1.5 [0 0]
No newline at end of file
8 192.168.1.6 [0 0]
No newline at end of file
9 192.168.1.7 [0 0]
No newline at end of file
10 192.168.1.8 [0 0]
No newline at end of file
11 192.168.1.9 [0 0]
No newline at end of file
12 192.168.1.10 [0 0]
No newline at end of file
13 192.168.1.11 [0 0]
No newline at end of file
14 192.168.1.12 [1 1]
No newline at end of file
15 192.168.1.13 [0 0]
No newline at end of file
16 192.168.1.14 [0 0]
No newline at end of file
17 192.168.1.15 [0 0]
No newline at end of file
18 192.168.1.16 [0 0]
No newline at end of file
19 192.168.1.17 [0 0]
No newline at end of file
20 192.168.1.18 [0 0]
No newline at end of file
21 192.168.1.19 [0 0]
No newline at end of file
22 192.168.1.20 [0 0]
No newline at end of file
23 192.168.1.21 [0 0]
No newline at end of file
24 192.168.1.22 [0 0]
No newline at end of file
25 192.168.1.23 [1 1]
No newline at end of file
26 192.168.1.24 [0 0]
No newline at end of file
27 192.168.1.25 [0 0]
No newline at end of file
28 192.168.1.26 [0 0]
No newline at end of file
29 192.168.1.27 [0 0]
No newline at end of file
30 192.168.1.28 [0 0]
No newline at end of file
31 192.168.1.29 [0 0]
No newline at end of file
32 192.168.1.30 [0 0]
No newline at end of file
33 192.168.1.31 [0 0]
No newline at end of file
34 192.168.1.32 [0 0]
No newline at end of file
35 192.168.1.33 [0 0]
No newline at end of file
36 192.168.1.34 [0 0]
No newline at end of file
37 192.168.1.35 [0 0]
No newline at end of file
38 192.168.1.36 [0 0]
No newline at end of file
39 192.168.1.37 [0 0]
No newline at end of file
40 192.168.1.38 [0 0]
No newline at end of file
41 192.168.1.39 [0 0]
No newline at end of file
42 192.168.1.40 [0 0]
No newline at end of file
43 192.168.1.41 [0 0]
No newline at end of file
44 192.168.1.42 [0 0]
No newline at end of file
45 192.168.1.43 [0 0]
No newline at end of file
46 192.168.1.44 [0 0]
No newline at end of file
47 192.168.1.45 [0 0]
No newline at end of file
48 192.168.1.46 [0 0]
No newline at end of file
49 192.168.1.47 [0 0]
No newline at end of file
50 192.168.1.48 [0 0]
No newline at end of file
51 192.168.1.49 [0 0]
No newline at end of file
52 192.168.1.50 [0 0]
No newline at end of file
53 192.168.1.51 [0 0]
No newline at end of file
54 192.168.1.52 [0 0]
No newline at end of file
55 192.168.1.53 [0 0]
No newline at end of file
56 192.168.1.54 [0 0]
No newline at end of file
57 192.168.1.55 [0 0]
No newline at end of file
58 192.168.1.56 [0 0]
No newline at end of file
59 192.168.1.57 [0 0]
No newline at end of file
60 192.168.1.58 [0 0]
No newline at end of file
61 192.168.1.59 [0 0]
No newline at end of file
62 192.168.1.60 [0 0]
No newline at end of file
63 192.168.1.61 [0 0]
No newline at end of file
64 192.168.1.62 [0 0]
No newline at end of file
65 192.168.1.63 [0 0]
No newline at end of file
66 192.168.1.64 [0 0] No newline at end of file
@@ -1,199 +1,239
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 No newline at end of file
4
5 class ABSServer: No newline at end of file
5 class ABSServer:
6
6
No newline at end of file
7 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
7 def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500): No newline at end of file
8 No newline at end of file
8
9 self.ipSource = ipSource No newline at end of file
9 self.ipSource = ipSource
10 self.ipDestino = ipDestino No newline at end of file
10 self.ipDestino = ipDestino
11 self.portDestino = portDestino No newline at end of file
11 self.portDestino = portDestino
12 No newline at end of file
12
13 self.ipDestino2 = ipDestino2 No newline at end of file
13 self.ipDestino2 = ipDestino2
14 self.portDestino2 = portDestino2 No newline at end of file
14 self.portDestino2 = portDestino2
15 No newline at end of file
15
16 self.tx_buffer = "default"
16 self.tx_buffer = "default"
No newline at end of file
17 # self.rx_buffer = "default"
17 self.rx_buffer = "default" No newline at end of file
No newline at end of file
18 self.rx_buffer = rx_buffer No newline at end of file
18 self.enaModules = [] No newline at end of file
19 self.enaModules = []
19 No newline at end of file
20
20 self.createObjects() No newline at end of file
21 self.createObjects()
21 No newline at end of file
22
22 def createObjects(self): No newline at end of file
23 def createObjects(self):
23 No newline at end of file
24
24 asServer = True No newline at end of file
25 asServer = True
25 self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) No newline at end of file
26 self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer)
26 self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) No newline at end of file
27 self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2)
27 No newline at end of file
28
28 def waitRequest(self): No newline at end of file
29 def waitRequest(self):
29 No newline at end of file
30
30 #Using rx buffer No newline at end of file
31 #Using rx buffer
31 ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() No newline at end of file
32 ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData()
32 No newline at end of file
33
33 if cmd == "SNDF": No newline at end of file
34 if cmd == "SNDF":
34 datarpta = self.__sendFile2Modules(cmd = cmd) No newline at end of file
35 datarpta = self.__sendFile2Modules(cmd = cmd)
35 No newline at end of file
36
36 if cmd == "CHGB": No newline at end of file
37 if cmd == "CHGB":
37 datarpta = self.__changeBeam(cmd = cmd) No newline at end of file
38 datarpta = self.__changeBeam(cmd = cmd)
38 No newline at end of file
39
39 if cmd == "ANST": No newline at end of file
40 if cmd == "ANST":
40 self.__getControlModuleStatus(cmd = cmd) No newline at end of file
41 self.__getControlModuleStatus(cmd = cmd)
41 #Using tx buffer No newline at end of file
42 #Using tx buffer
42 datarpta = self.tx_buffer No newline at end of file
43 datarpta = self.tx_buffer
43 No newline at end of file
44
44 if cmd == "NTST": No newline at end of file
45 if cmd == "NTST":
45 #Using tx buffer No newline at end of file
46 #Using tx buffer
46 datarpta = self.__getConnectionStatus(cmd = cmd) No newline at end of file
47 datarpta = self.__getConnectionStatus(cmd = cmd)
47 No newline at end of file
48
48 self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource) No newline at end of file
49 self.commServerObj.sendData(cmd=cmd, data=datarpta, ipDestino = ipSource)
49 No newline at end of file
50
50 def checkModule(self, address): No newline at end of file
51 def checkModule(self, address):
51 No newline at end of file
52
52 cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" No newline at end of file
53 cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null"
53 status = os.system(cmd) No newline at end of file
54 status = os.system(cmd)
54 No newline at end of file
55
55 if status == 256: No newline at end of file
56 if status == 256:
56 return False No newline at end of file
57 return False
57 No newline at end of file
58
58 return True No newline at end of file
59 return True
59 No newline at end of file
60
60 def __writeReport(self, enaModules): No newline at end of file
61 def __writeReport(self, enaModules):
61 No newline at end of file
62
62 status_array = ["Status of modules\n"] No newline at end of file
63 status_array = ["Status of modules\n"]
63 status_array.append("----------------\n") No newline at end of file
64 status_array.append("----------------\n")
64 No newline at end of file
65
65 for address in range(1,65): No newline at end of file
66 for address in range(1,65):
66 if address in enaModules: No newline at end of file
67 if address in enaModules:
67 status_array.append("192.168.1." + str(address) + " [1 1]\n") No newline at end of file
68 status_array.append("192.168.1." + str(address) + " [1 1]\n")
68 else: No newline at end of file
69 else:
69 status_array.append("192.168.1." + str(address) + " [0 0]\n") No newline at end of file
70 status_array.append("192.168.1." + str(address) + " [0 0]\n")
70 No newline at end of file
71
71 f = open("module_status.txt","w") No newline at end of file
72 f = open("module_status.txt","w")
72 f.writelines(status_array) No newline at end of file
73 f.writelines(status_array)
73 f.close() No newline at end of file
74 f.close()
74 No newline at end of file
75
75 def checkAntenna(self): No newline at end of file
76 def checkAntenna(self):
76 No newline at end of file
77
77 """ No newline at end of file
78 """
78 Direccion de los modulos de las antenas: No newline at end of file
79 Direccion de los modulos de las antenas:
79 No newline at end of file
80
80 Norte : 01-16 No newline at end of file
81 Norte : 01-16
81 Este : 17-32 No newline at end of file
82 Este : 17-32
82 Oeste: : 33-48 No newline at end of file
83 Oeste: : 33-48
83 Sur : 49-64 No newline at end of file
84 Sur : 49-64
84 No newline at end of file
85
85 """ No newline at end of file
86 """
86 No newline at end of file
87
87 enaModules2 = [] No newline at end of file
88 enaModules2 = []
88 No newline at end of file
89
89 for address in range(1,65): No newline at end of file
90 for address in range(1,65):
90 if self.checkModule(address): No newline at end of file
91 if self.checkModule(address):
91 enaModules2.append(address) No newline at end of file
92 enaModules2.append(address)
92 No newline at end of file
93
93 self.__writeReport(enaModules2) No newline at end of file
94 self.__writeReport(enaModules2)
94 return enaModules2 No newline at end of file
95 return enaModules2
95 No newline at end of file
96
96 def __ConnectionWithControlModules(self,data,cmd,id): No newline at end of file
97 def __ConnectionWithControlModules(self,data,cmd,id):
97 No newline at end of file
98
98 self.commClientObj.open_socket() No newline at end of file
99 self.commClientObj.open_socket()
99 ip = "192.168.1." + str(id) No newline at end of file
100 ip = "192.168.1." + str(id)
100 self.commClientObj.sendData(cmd, data, ip) No newline at end of file
101 self.commClientObj.sendData(cmd, data, ip)
101 ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() No newline at end of file
102 ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData()
102 self.commClientObj.close_socket() No newline at end of file
103 self.commClientObj.close_socket()
103 No newline at end of file
104
104 return tmp No newline at end of file
105 return tmp
105 No newline at end of file
106
106 def __All2Blocks(self,input): No newline at end of file
107 def __All2Blocks(self,input):
107 No newline at end of file
108
108 rx_frame_lst = input.split('\n',2) No newline at end of file
109 rx_frame_lst = input.split('\n',2)
109 No newline at end of file
110
110 header = rx_frame_lst[0] + "\n" No newline at end of file
111 header = rx_frame_lst[0] + "\n"
111 control_modules_str = rx_frame_lst[2] No newline at end of file
112 control_modules_str = rx_frame_lst[2]
112 control_modules_lst = control_modules_str.split("------\n") No newline at end of file
113 control_modules_lst = control_modules_str.split("------\n")
113 No newline at end of file
114
114 return header, control_modules_lst No newline at end of file
115 return header, control_modules_lst
115 No newline at end of file
116
116 No newline at end of file
117
117 def __sendFile2Modules(self,cmd): No newline at end of file
118 def __sendFile2Modules(self,cmd):
118 No newline at end of file
119
119 #Needed for the loop No newline at end of file
120 #Needed for the loop
120 header, control_modules_lst = self.__All2Blocks(self.rx_buffer) No newline at end of file
121 header, control_modules_lst = self.__All2Blocks(self.rx_buffer)
121 correct = 0 No newline at end of file
122 correct = 0
122 No newline at end of file
123
123 for id in range(1,65): No newline at end of file
124 for id in range(1,65):
124 No newline at end of file
125
125 if id not in self.enaModules: No newline at end of file
126 if id not in self.enaModules:
126 continue No newline at end of file
127 continue
127 No newline at end of file
128
128 if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK": No newline at end of file
129 if self.__ConnectionWithControlModules(header + control_modules_lst[id-1], cmd, id) == "OK":
129 correct = correct + 1 No newline at end of file
130 correct = correct + 1
130 No newline at end of file
131
131 if correct == len(self.enaModules): No newline at end of file
132 if correct == len(self.enaModules):
132 rpta = "OK" No newline at end of file
133 rpta = "OK"
133 else: No newline at end of file
134 else:
134 rpta = "Failure" No newline at end of file
135 rpta = "Failure"
135 No newline at end of file
136
136 return rpta No newline at end of file
137 return rpta
137 No newline at end of file
138
138 def __changeBeam(self, cmd): No newline at end of file
139 def __changeBeam(self, cmd):
139 No newline at end of file
140
140 correct = 0 No newline at end of file
141 correct = 0
141 # enaModules = self.checkAntenna() No newline at end of file
142 # enaModules = self.checkAntenna()
142 # enaModules = [11,12,13,14] No newline at end of file
143 # enaModules = [11,12,13,14]
143 No newline at end of file
144
144 for id in range(1,65): No newline at end of file
145 for id in range(1,65):
145 if id not in self.enaModules: No newline at end of file
146 if id not in self.enaModules:
146 continue No newline at end of file
147 continue
147 No newline at end of file
148
148 if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK": No newline at end of file
149 if self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) == "OK":
149 correct = correct + 1 No newline at end of file
150 correct = correct + 1
150 No newline at end of file
151
151 if correct == len(self.enaModules): No newline at end of file
152 if correct == len(self.enaModules):
152 rpta = "OK" No newline at end of file
153 rpta = "OK"
153 else: No newline at end of file
154 else:
154 rpta = "Failure" No newline at end of file
155 rpta = "Failure"
155 No newline at end of file
156
156 return rpta No newline at end of file
157 return rpta
157 No newline at end of file
158
158 def __getControlModuleStatus(self, cmd): No newline at end of file
159 def __getControlModuleStatus(self, cmd):
159 No newline at end of file
160
160 all_blocks = "" No newline at end of file
161 all_blocks = ""
161 # enaModules = self.checkAntenna() No newline at end of file
162 # enaModules = self.checkAntenna()
162 # enaModules = [11,12,13,14] No newline at end of file
163 # enaModules = [11,12,13,14]
163 No newline at end of file
164
164 for id in range(1,65): No newline at end of file
165 for id in range(1,65):
165 if id not in self.enaModules: No newline at end of file
166 if id not in self.enaModules:
166 continue No newline at end of file
167 continue
167 No newline at end of file
168
168 one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) No newline at end of file
169 one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
169 No newline at end of file
170
170 all_blocks = all_blocks + one_block No newline at end of file
171 all_blocks = all_blocks + one_block
171 #Using tx buffer No newline at end of file
172 #Using tx buffer
172 print all_blocks No newline at end of file
173 print all_blocks
173 self.tx_buffer = all_blocks No newline at end of file
174 self.tx_buffer = all_blocks
174 No newline at end of file
175
175 def __getConnectionStatus(self, cmd): No newline at end of file
176 def __getConnectionStatus(self, cmd):
176 No newline at end of file
177
177 ena = self.checkAntenna() No newline at end of file
178 ena = self.checkAntenna()
178 self.enaModules = ena No newline at end of file
179 self.enaModules = ena
179 No newline at end of file
180
180 blockLst = [] No newline at end of file
181 blockLst = []
181 No newline at end of file
182
182 for id in range(1,65): No newline at end of file
183 for id in range(1,65):
183 if id not in self.enaModules: No newline at end of file
184 if id not in self.enaModules:
184 continue No newline at end of file
185 continue
185 No newline at end of file
186
186 blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id) No newline at end of file
187 blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
187 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n") No newline at end of file
188 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n")
188 #Using tx buffer No newline at end of file
189 #Using tx buffer
189 self.tx_buffer = "".join(blockLst) No newline at end of file
190 self.tx_buffer = "".join(blockLst)
190 print self.tx_buffer No newline at end of file
191 print self.tx_buffer
191 No newline at end of file
192
192 return self.tx_buffer No newline at end of file
193 return self.tx_buffer
193 No newline at end of file
194
195 def getConnectionStatus(self, cmd):
No newline at end of file
196
No newline at end of file
197 ena = self.checkAntenna()
No newline at end of file
198 self.enaModules = ena
No newline at end of file
199
No newline at end of file
200 blockLst = []
No newline at end of file
201
No newline at end of file
202 for id in range(1,65):
No newline at end of file
203 if id not in self.enaModules:
No newline at end of file
204 continue
No newline at end of file
205
No newline at end of file
206 blockStr = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
No newline at end of file
207 blockLst.append(blockStr + ", 192.168.1." + str(id) + "\n")
No newline at end of file
208 #Using tx buffer
No newline at end of file
209 self.tx_buffer = "".join(blockLst)
No newline at end of file
210 print self.tx_buffer
No newline at end of file
211
No newline at end of file
212 return self.tx_buffer
No newline at end of file
213
No newline at end of file
214 def getControlModuleStatus(self, cmd):
No newline at end of file
215
No newline at end of file
216 all_blocks = ""
No newline at end of file
217 # enaModules = self.checkAntenna()
No newline at end of file
218 # enaModules = [11,12,13,14]
No newline at end of file
219
No newline at end of file
220 for id in range(1,65):
No newline at end of file
221 if id not in self.enaModules:
No newline at end of file
222 continue
No newline at end of file
223
No newline at end of file
224 one_block = self.__ConnectionWithControlModules(self.rx_buffer,cmd,id)
No newline at end of file
225
No newline at end of file
226 all_blocks = all_blocks + one_block
No newline at end of file
227 #Using tx buffer
No newline at end of file
228 print all_blocks
No newline at end of file
229 self.tx_buffer = all_blocks
No newline at end of file
230
No newline at end of file
231 return all_blocks
No newline at end of file
232
No newline at end of file
233 No newline at end of file
194 if __name__ == '__main__': No newline at end of file
234 if __name__ == '__main__':
195 No newline at end of file
235
196 absObj = ABSServer() No newline at end of file
236 absObj = ABSServer()
197 No newline at end of file
237
198 while 1: No newline at end of file
238 while 1:
199 absObj.waitRequest() No newline at end of file
239 absObj.waitRequest()
General Comments 0
You need to be logged in to leave comments. Login now