##// END OF EJS Templates
imanay -
r46:47
parent child
Show More
@@ -31,15 +31,18
31 FileStr = "".join(FileList)
31 FileStr = "".join(FileList)
32 data = FileStr
32 data = FileStr
33
33
34 self.commObj.sendTxRxCommand(cmd="SNDF", data=data)
34 self.commObj.sendData(cmd="SNDF", data=data)
35 self.commObj.waitData()
35
36
36 def changeBeam(self, newBeam):
37 def changeBeam(self, newBeam):
37
38
38 self.commObj.sendTxRxCommand(cmd="CHGB", data=newBeam)
39 self.commObj.sendData(cmd="CHGB", data=newBeam)
40 self.commObj.waitData()
39
41
40 def getStatus(self, data):
42 def getStatus(self, data):
41
43
42 self.commObj.sendTxRxCommand(cmd="ANST", data = data)
44 self.commObj.sendData(cmd="ANST", data = data)
45 self.commObj.waitData2()
43
46
44 ##########
47 ##########
45
48
@@ -7,29 +7,29
7 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
7 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
8 [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
8 [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
9 [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
9 [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
10 [1.0,1.0,1.0,1.0,1.0,2.0,3.0,0.0],$
11 [0.5,0.5,0.5,1.0,2.0,3.0,0.0,1.0],$
12 [1.0,1.0,1.0,1.0,3.0,0.0,1.0,2.0],$
13 [0.5,0.5,0.5,0.5,0.0,1.0,2.0,3.0]]
14
15 [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
16 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
17 [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
18 [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$
10 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
19 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
11 [0.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,0.5,0.5,0.5,0.5,0.5,0.5],$
92 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
92 [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$
@@ -1,84 +1,5
1 #import tftpy
1 #import tftpy
2 import socket
2 import socket
3
4 class UDPServer:
5
6 buf = 16384
7 #buf = 1024
8
9 def __init__(self, port):
10 # Set the socket parameters
11 host = "192.168.1.255"
12 #host = "localhost"
13 self.addr = (host,port)
14 self.createObjects()
15
16 def createObjects(self):
17
18 # Create socket and bind to address
19 self.sock_s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,0)
20 self.sock_s.bind(self.addr)
21
22 def listen(self,mode):
23
24 # Receive messages
25 print "Central Control initialized ...with UDP"
26 print
27 if mode == 0:
28 while 1:
29 data_rx, add = self.sock_s.recvfrom(self.buf)
30 if not data_rx:
31 print "Client has exited!"
32 break
33
34 print "\nCentral Control:"
35 print "Received message '", data_rx,"'"
36 #print "Sendinf ack ..."
37 #self.sock_s.sendto('ack', addr_rx)
38 else:
39 data_rx, add = self.sock_s.recvfrom(self.buf)
40 print "\nCentral Control:"
41 print "Received message '", data_rx,"'"
42
43 # Close socket
44 self.sock_s.close()
45 print "\nsocket closed"
46 return data_rx
47
48 class UDPClient:
49
50 buf = 1024
51
52 def __init__(self, port):
53 # Set the socket parameters
54 host = "192.168.1.255"
55 self.multicast_addr = (host,port)
56 self.createObjects()
57
58 def createObjects(self):
59
60 # Create socket
61 self.socket_c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,0)
62 #if self.socket_c == -1:
63 # print "No se pudo establecer conexion con el socket"
64
65 #self.socket_c.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 20)
66 self.socket_c.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
67
68
69
70 def sendData(self,TxFrame):
71
72 # Send messages
73 if(self.socket_c.sendto(TxFrame, self.multicast_addr)):
74 print "Sending message:[" + TxFrame + "]"
75
76 data_rx, server_rx = self.socket_c.recvfrom(16)
77
78 print "Data received ", data_rx, server_rx
79
80 # Close socket
81 self.socket_c.close()
82
3
83 class UDPComm:
4 class UDPComm:
84
5
@@ -90,6 +11,7
90 self.ipDestino = ipDestino
11 self.ipDestino = ipDestino
91 self.portDestino = portDestino
12 self.portDestino = portDestino
92 self.addr = (ipDestino,portDestino)
13 self.addr = (ipDestino,portDestino)
14 self.answer = ipDestino #test
93
15
94 self.openSocket(asServer)
16 self.openSocket(asServer)
95
17
@@ -113,55 +35,47
113 self.socket_c.bind(self.addr)
35 self.socket_c.bind(self.addr)
114 print "\nServer initialized"
36 print "\nServer initialized"
115
37
116 def waitRequest(self, nbytes):
38 def waitData(self, nbytes = 16384):
117
39
118 trama_rx, add = self.socket_c.recvfrom(nbytes)
40 print "\nWaiting some data"
119 print "\nServer has received a data"
41 trama_rx, self.answer = self.socket_c.recvfrom(nbytes)
42 print "\nThis socket has received some data"
120 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx)
43 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx)
121
44
122 return ipSource, ipDestino, cmd, data
45 return ipSource, ipDestino, cmd, data
123
46
124 def sendData(self,TxFrame):
47 def waitData2(self, nbytes = 16384):
125
48
126 # Send messages
49 print "\nWaiting some data"
127 if(self.socket_c.sendto(TxFrame, self.addr)):
50 trama_rx, self.answer = self.socket_c.recvfrom(nbytes)
128 print "Sending message:[" + TxFrame + "]"
51 print "\nThis socket has received some data"
129
52 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx)
130 # data_rx, server_rx = self.socket_c.recvfrom(16)
53 filename = "report.txt"
131 #
54 fobj = open(filename,"w")
132 # print "Data received ", data_rx, server_rx
55 fobj.writelines(data)
56 fobj.close()
133
57
134 # Close socket
58 return ipSource, ipDestino, cmd, data
135 #self.socket_c.close()
136
59
137 def sendTxRxCommand(self, cmd, data, nbytes = 16384):
60 def sendData(self, cmd, data):
138
139 self.sendRequest(cmd, data)
140
141 #time.sleep(1)
142
143 # ipSource_rx, ipDestino_rx, cmd_rx, data_rx = self.getRpta(nbytes)
144
145 # if not(self.ipSource == ipDestino_rx):
146 # print "Error"
147
148 # return data_rx
149
150 def sendRequest(self, cmd, data):
151
61
152 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":"
62 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":"
153 #self.socket_c.send(trama_tx)
154 # Send messages
63 # Send messages
155 if(self.socket_c.sendto(trama_tx, self.addr)):
64 if(self.socket_c.sendto(trama_tx, self.addr)):
156 print "Sending message:[" + trama_tx + "]"
65 print "Sending message:[" + trama_tx + "]"
66
67 def sendData2(self, cmd, data):
157
68
69 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":"
70 # Send messages
71 if(self.socket_c.sendto(trama_tx, self.answer)):
72 print "Sending message:[" + trama_tx + "]"
73
74 def sendData2ControlModules(self, trama_tx):
158
75
159 def getRpta(self, nbytes):
76 # Send messages
160
77 if(self.socket_c.sendto(trama_tx, self.addr)):
161 trama_rx = self.socket_c.recv(nbytes)
78 print "Sending message:[" + trama_tx + "]"
162 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx)
163
164 return ipSource, ipDestino, cmd, data
165
79
166 def __getTrama(self, trama):
80 def __getTrama(self, trama):
167
81
@@ -14,6 +14,8
14 self.portDestino2 = portDestino2
14 self.portDestino2 = portDestino2
15
15
16 self.ftpPortDestino = ftpPortDestino
16 self.ftpPortDestino = ftpPortDestino
17 self.experiment_name = "default"
18 self.tx_buffer = "default"
17
19
18 self.createObjects()
20 self.createObjects()
19
21
@@ -23,74 +25,16
23 self.commServerObj = library.UDPComm(self.ipSource, self.ipDestino, self.portDestino, asServer)
25 self.commServerObj = library.UDPComm(self.ipSource, self.ipDestino, self.portDestino, asServer)
24 self.commClientObj = library.UDPComm(self.ipSource, self.ipDestino2, self.portDestino2)
26 self.commClientObj = library.UDPComm(self.ipSource, self.ipDestino2, self.portDestino2)
25 #self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino)
27 #self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino)
26
28
27 def waitRequest(self,nbytes = 16384):
28
29 ipSource, ipDestino, cmd, self.datarx = self.commServerObj.waitRequest(nbytes)
30
31 if cmd == "SNDF":
32 self.sendFile(10)
33
34 if cmd == "CHGB":
35 self.changeBeam()
36
37 if cmd == "ANST":
38 self.getStatus(10)
39
40 def sendAnswer(self,nbytes = 16384):
41
42 # ipSource, ipDestino, cmd, self.datarx = self.commServerObj.sendData(nbytes)
43
44 pass
45
46 def EliminaSaltoDeLinea(cadena):
47 i = 0
48 for elemento in cadena:
49 if elemento =='\n' or elemento =='\r':
50 pass
51 else:
52 i=i+1
53 return cadena [:i]
54
55 def connection_status(self,base):
56 #File creation is neccesary?
57 number_of_modules = 16
58 #base = 10
59 # Variables for the report
60 status_array = ["Status of modules\n"]
61 status_array.append("----------------\n")
62 # Variables for the program
63 module_list = []
64
65 for i in range(number_of_modules):
66 cmd = "ping -c 1 -w 1 192.168.1."+ str(base + i + 1) + " >> /dev/null"
67 status = os.system(cmd)
68 if status == 256:
69 status_array.append("192.168.1." + str(base + i + 1) + " [0 0]\n") #Un-connected
70 module_list.append("0")
71 else:
72 status_array.append("192.168.1." + str(base + i + 1) + " [1 1]\n")
73 module_list.append("1")
74 # Generating a file report
75 if base == 10:
76 fobj = open("module_status_S.txt","w")
77 else:
78 fobj = open("module_status_N.txt","w")
79 fobj.writelines(status_array)
80 fobj.close()
81 # For the program
82 return module_list
83
84 def sendFile(self, base):
29 def sendFile(self, base):
85
30
86 #Needed for the file creation
87 # file_str = self.datarx
88 #Needed for the loop
31 #Needed for the loop
89 rx_frame_list = self.datarx.split('\n',2)
32 rx_frame_list = self.datarx.split('\n',2)
90
33
91 experiment_name = rx_frame_list[0]
34 experiment_name = rx_frame_list[0]
92 experiment_number = rx_frame_list[1]
35 experiment_number = rx_frame_list[1]
93 str_control_modules = rx_frame_list[2]
36 str_control_modules = rx_frame_list[2]
37
94 lst_control_modules = str_control_modules.split("------\n")
38 lst_control_modules = str_control_modules.split("------\n")
95 #Setting variables of the loop
39 #Setting variables of the loop
96 i =3
40 i =3
@@ -117,23 +61,148
117 i = i + number_of_beams + 2
61 i = i + number_of_beams + 2
118 module += 1
62 module += 1
119 #Working with the UDP socket
63 #Working with the UDP socket
120 #self.commClientObj.sendData("CARGA:experimento1.ab1:")
64 # self.commClientObj.sendData2ControlModules("CARGA:" + experiment_name + ":")
121 self.commClientObj.sendData("CARGA:" + experiment_name + ":")
65 # self.commClientObj.sendData2ControlModules("CAMBIA:0:")
122 self.commClientObj.sendData("CAMBIA:0:")
66 #Another tftp way
123 #
124 # self.ftpCommObj.sendFile(filename)
67 # self.ftpCommObj.sendFile(filename)
125 # rpta = self.commClientObj.sendTxRxCommand(cmd='CARGA', data=filename)
68 # rpta = self.commClientObj.sendTxRxCommand(cmd# filename2 = "report.txt"
126
69 #fobj2 = open(filename2,"w")
127
70 #fobj2.write("Verification_file\n")
71 #fobj2.write("-----------------\n")
72 #fobj2.close()='CARGA', data=filename)
73 self.experiment_name = experiment_name
74
75
76 def __sendAnswer(self, cmd):
77
78 data = "OK"
79
80 if cmd == "SNDF":
81 self.commServerObj.sendData2(cmd="SNDF", data=data)
82 if cmd == "CHGB":
83 self.commServerObj.sendData2(cmd="CHGB", data=data)
84 if cmd == "ANST":
85 data = self.tx_buffer
86 self.commServerObj.sendData2(cmd="ANST", data=data)
87
88 def waitRequest(self):
89
90 ipSource, ipDestino, cmd, self.datarx = self.commServerObj.waitData()
91
92 datarpta = "OK"
93
94 if cmd == "SNDF":
95 self.sendFile2Modules()
96
97 if cmd == "CHGB":
98 self.changeBeam()
99
100 if cmd == "ANST":
101 self.getStatus(10, mode=2)
102 datarpta = self.tx_buffer
103
104 self.commServerObj.sendData2(cmd=cmd, data=datarpta)
105
106 return cmd
107
108 def __writeReport(self, enaModules):
109
110 status_array = ["Status of modules\n"]
111 status_array.append("----------------\n")
112
113 for address in range(1,65):
114 if address in enaModules:
115 # status_array.append("192.168.1." + str(base + i + 1) + " [1 1]\n")
116 status_array.append("192.168.1." + str(address) + " [1 1]\n")
117 else:
118 status_array.append("192.168.1." + str(address) + " [0 0]\n")
119
120 f = open("module_status.txt","w")
121 f.writelines(status_array)
122 f.close()
123
124 def checkModule(self, address):
125
126 cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null"
127 status = os.system(cmd)
128
129 if status == 256:
130 return False
131
132 return True
133
134 def checkAntenna(self):
135
136 """
137 Direccion de los modulos de las antenas:
138
139 Norte : 01-16
140 Este : 17-32
141 Oeste: : 33-48
142 Sur : 49-64
143
144 """
145
146 enaModules = []
147
148 for address in range(1,65):
149 if self.checkModule(address):
150 enaModules.append(address)
151
152 self.__writeReport(enaModules)
153 return enaModules
154
155 def __loadFile(self):
156
157 #Working with the UDP socket
158 self.commClientObj.sendData2ControlModules("CARGA:" + self.experiment_name + ":")
159 self.commClientObj.sendData2ControlModules("CAMBIA:0:")
160
161 def __writeModuleFile(self, filename, str):
162
163 fobj = open(filename,"w")
164 fobj.write(filename + "\n")
165 fobj.write("------\n")
166 fobj.write(str)
167 fobj.write("------\n")
168 fobj.close()
169
170 def sendFile2Modules(self):
171
172 #Needed for the loop
173 rx_frame_list = self.datarx.split('\n',2)
174
175 experiment_name = rx_frame_list[0]
176 experiment_number = rx_frame_list[1]
177 str_control_modules = rx_frame_list[2]
178
179 lst_control_modules = str_control_modules.split("------\n")
180
181 enaModules = self.checkAntenna()
182
183 for address in range(1,65):
184
185 if address not in enaModules:
186 continue
187
188 self.__writeModuleFile(experiment_name, lst_control_modules[address-1])
189
190 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c put " + experiment_name
191 print cmd
192 os.system(cmd)
193
194 self.experiment_name = experiment_name
195
196 self.__loadFile()
197
128 def changeBeam(self):
198 def changeBeam(self):
129
199
130 #rpta = self.commClientObj.sendTxRxCommand(cmd='CAMBIA', data="0")
200 #rpta = self.commClientObj.sendTxRxCommand(cmd='CAMBIA', data="0")
131 self.commClientObj.sendData("CAMBIA:" + self.datarx + ":")
201 self.commClientObj.sendData2ControlModules("CAMBIA:" + self.datarx + ":")
132
202
133 def getStatus(self, base):
203 def __getStsMode1(self):
134
135 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0")
204 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0")
136 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":")
205 self.commClientObj.sendData2ControlModules("CHEQUEO:" + self.datarx + ":")
137 seconds = int (self.datarx)
206 seconds = int (self.datarx)
138 # Give 5 seconds to the control modules
207 # Give 5 seconds to the control modules
139 time.sleep(seconds)
208 time.sleep(seconds)
@@ -169,15 +238,99
169 fobj2.write("------\n")
238 fobj2.write("------\n")
170 fobj2.close()
239 fobj2.close()
171 module = module + 1
240 module = module + 1
172 # print "\nFinalizado"
241
242 def __getStsMode2(self):
243
244 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0")
245 self.commClientObj.sendData2ControlModules("CHEQUEO:" + self.datarx + ":")
246 seconds = int (self.datarx)
247 # Give 5 seconds to the control modules
248 time.sleep(seconds)
249 # Checking the module connection
250 module_list = self.connection_status(10)
251 #Generating the complete report
252 module = 1
253 number_of_modules = 16
254 filename1 = "Verificacion"
255 line1 = "Verification_file\n"
256 line2 = "-----------------\n"
257 report_list = [line1, line2]
258 while module <= number_of_modules:
259 if module_list[module -1] == "1":
260 #Preparing and doing the tftp command
261 cmd = "tftp -m binary 192.168.1."+ str(base + module) +" 69 -c get " + filename1
262 print cmd
263 os.system(cmd)
264 #Sub_header
265 if base == 10:
266 report_list.append("S" + str(module) + "\n")
267 else:
268 report_list.append("N" + str(module) + "\n")
269 # Content
270 fobj1 = open(filename1,"r")
271 file_list_1 = fobj1.readlines()
272 fobj1.close()
273 content = ''.join(file_list_1[2:-1])
274 # content = "010101\n"
275 report_list.append(content)
276 #Ending
277 report_list.append("------\n")
278 module = module + 1
279 #print "\nFinalizado"
280 self.tx_buffer = ''.join(report_list)
281
282 def __getStsMode3(self):
283
284 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0")
285 self.commClientObj.sendData2ControlModules("CHEQUEO:" + self.datarx + ":")
286 seconds = int (self.datarx)
287 # Give 5 seconds to the control modules
288 time.sleep(seconds)
289 # Checking the module connection
290 module_list = self.connection_status(10)
291 #Generating the complete report
292 module = 1
293 number_of_modules = 16
294 filename1 = "Verificacion"
295 line1 = "Verification_file\n"
296 line2 = "-----------------\n"
297 report_list = [line1, line2]
298 while module <= number_of_modules:
299 if module_list[module -1] == "1":
300 #Preparing and doing the tftp command
301 cmd = "tftp -m binary 192.168.1."+ str(base + module) +" 69 -c get " + filename1
302 print cmd
303 os.system(cmd)
304 #Sub_header
305 if base == 10:
306 report_list.append("S" + str(module) + "\n")
307 else:
308 report_list.append("N" + str(module) + "\n")
309 # Content
310 fobj1 = open(filename1,"r")
311 file_list_1 = fobj1.readlines()
312 fobj1.close()
313 content = ''.join(file_list_1[2:-1])
314 # content = "010101\n"
315 report_list.append(content)
316 #Ending
317 report_list.append("------\n")
318 module = module + 1
319 #print "\nFinalizado"
320 self.tx_buffer = ''.join(report_list)
321
322 def getStatus(self, base, mode):
323
324 if mode == 1:
325 self.__getStsMode1()
326 else:
327 self.__getStsMode2()
173
328
174
175
176
329
177 if __name__ == '__main__':
330 if __name__ == '__main__':
178
331
179 absObj = ABSServer()
332 absObj = ABSServer()
180
333
181 while 1:
334 while 1:
182 absObj.waitRequest()
335 cmd = absObj.waitRequest()
183 # absObj.sendAnswer(nbytes) No newline at end of file
336 absObj.__sendAnswer(cmd) No newline at end of file
@@ -0,0 +1,6
1 import abscontrol/client
2
3 filename = "experimento1.abs"
4
5 absObj = ABSClient()
6 absObj.sendFile(filename) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now