##// END OF EJS Templates
imanay -
r55:56
parent child
Show More
@@ -1,100 +1,100
1 #import tftpy No newline at end of file
1 #import tftpy
2 import socket No newline at end of file
2 import socket
3 No newline at end of file
3
4 class UDPComm: No newline at end of file
4 class UDPComm:
5 No newline at end of file
5
6 __HEADER = "ABS" No newline at end of file
6 __HEADER = "ABS"
7 No newline at end of file
7
8 def __init__(self, ipSource, ipDestino, portDestino, asServer=False): No newline at end of file
8 def __init__(self, ipSource, ipDestino, portDestino, asServer=False):
9 No newline at end of file
9
10 self.ipSource = ipSource No newline at end of file
10 self.ipSource = ipSource
11 self.ipDestino = ipDestino No newline at end of file
11 self.ipDestino = ipDestino
12 self.portDestino = portDestino No newline at end of file
12 self.portDestino = portDestino
13 self.addr = (ipDestino,portDestino) No newline at end of file
13 self.addr = (ipDestino,portDestino)
14 self.answer = ipDestino #test No newline at end of file
14 self.answer = ipDestino #test
15 self.mode = "none" No newline at end of file
15 self.mode = "none"
16 No newline at end of file
16
17 self.openSocket(asServer) No newline at end of file
17 self.openSocket(asServer)
18 No newline at end of file
18
19 def openSocket(self, asServer): No newline at end of file
19 def openSocket(self, asServer):
20 No newline at end of file
20
21 #self.socket_c = socket.socket(AF_INET,SOCK_DGRAM) No newline at end of file
21 #self.socket_c = socket.socket(AF_INET,SOCK_DGRAM)
22 self.socket_c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,0) No newline at end of file
22 self.socket_c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,0)
23 # self.socket_c.connect((self.ipDestino, self.portDestino)) No newline at end of file
23 # self.socket_c.connect((self.ipDestino, self.portDestino))
24 No newline at end of file
24
25 if asServer: No newline at end of file
25 if asServer:
26 self.configAsServer() No newline at end of file
26 self.configAsServer()
27 self.mode = "server" No newline at end of file
27 self.mode = "server"
28 else: No newline at end of file
28 else:
29 self.configAsClient() No newline at end of file
29 self.configAsClient()
30 self.mode = "client" No newline at end of file
30 self.mode = "client"
31 No newline at end of file
31
32 def configAsClient(self): No newline at end of file
32 def configAsClient(self):
33 #Configurar broadcast No newline at end of file
33 #Configurar broadcast
34 self.socket_c.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) No newline at end of file
34 self.socket_c.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
35 No newline at end of file
35
36 def configAsServer(self): No newline at end of file
36 def configAsServer(self):
37 No newline at end of file
37
38 self.socket_c.bind(self.addr) No newline at end of file
38 self.socket_c.bind(self.addr)
39 print "\nServer initialized" No newline at end of file
39 print "\nServer initialized"
40 No newline at end of file
40
41 def waitData(self, nbytes = 16384): No newline at end of file
41 def waitData(self, nbytes = 16384):
42 No newline at end of file
42
43 print "\nWaiting some data" No newline at end of file
43 print "\nWaiting some data"
44 trama_rx, self.answer = self.socket_c.recvfrom(nbytes)
44 trama_rx, self.answer = self.socket_c.recvfrom(nbytes)
No newline at end of file
45 print "\nThis socket has received some data from:" No newline at end of file
45 print "\nThis socket has received some data" No newline at end of file
46 print self.answer No newline at end of file
46 print self.answer
47 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx) No newline at end of file
47 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx)
48 No newline at end of file
48
49 return ipSource, ipDestino, cmd, data No newline at end of file
49 return ipSource, ipDestino, cmd, data
50 No newline at end of file
50
51 def sendData(self, cmd, data): No newline at end of file
51 def sendData(self, cmd, data):
52 No newline at end of file
52
53 if self.portDestino == 7000: No newline at end of file
53 if self.portDestino == 7000:
54 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":" No newline at end of file
54 trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":"
55 else: No newline at end of file
55 else:
56 trama_tx = data No newline at end of file
56 trama_tx = data
57 No newline at end of file
57
58 if self.mode == "client": No newline at end of file
58 if self.mode == "client":
59 destiny = self.addr No newline at end of file
59 destiny = self.addr
60 else: No newline at end of file
60 else:
61 destiny = self.answer No newline at end of file
61 destiny = self.answer
62 # Send messages No newline at end of file
62 # Send messages
63 if(self.socket_c.sendto(trama_tx, destiny)):
63 if(self.socket_c.sendto(trama_tx, destiny)):
No newline at end of file
64 print "Sending message:[" + trama_tx + "] to " + str(destiny) No newline at end of file
64 print "Sending message:[" + trama_tx + "]" No newline at end of file
65 No newline at end of file
65
66 def __getTrama(self, trama): No newline at end of file
66 def __getTrama(self, trama):
67 No newline at end of file
67
68 FrameList = trama.split(':') No newline at end of file
68 FrameList = trama.split(':')
69 No newline at end of file
69
70 header = FrameList[0] No newline at end of file
70 header = FrameList[0]
71 ipSource = FrameList[1] No newline at end of file
71 ipSource = FrameList[1]
72 ipDestino = FrameList[2] No newline at end of file
72 ipDestino = FrameList[2]
73 cmd = FrameList[3] No newline at end of file
73 cmd = FrameList[3]
74 data = FrameList[4] No newline at end of file
74 data = FrameList[4]
75 trash = FrameList[5] No newline at end of file
75 trash = FrameList[5]
76 No newline at end of file
76
77 return ipSource, ipDestino, cmd, data No newline at end of file
77 return ipSource, ipDestino, cmd, data
78 No newline at end of file
78
79 #class FTPComm: No newline at end of file
79 #class FTPComm:
80 # No newline at end of file
80 #
81 # ftp_servidor = 'ftp.servidor.com' No newline at end of file
81 # ftp_servidor = 'ftp.servidor.com'
82 # ftp_usuario = 'miusuario' No newline at end of file
82 # ftp_usuario = 'miusuario'
83 # ftp_clave = 'miclave' No newline at end of file
83 # ftp_clave = 'miclave'
84 # ftp_raiz = '/public_html' No newline at end of file
84 # ftp_raiz = '/public_html'
85 # No newline at end of file
85 #
86 # def __init__(self): No newline at end of file
86 # def __init__(self):
87 # No newline at end of file
87 #
88 # self.client = tftpy.TftpClient(self.ftp_servidor, '69') No newline at end of file
88 # self.client = tftpy.TftpClient(self.ftp_servidor, '69')
89 # No newline at end of file
89 #
90 # No newline at end of file
90 #
91 # def sendFile(self, filename): No newline at end of file
91 # def sendFile(self, filename):
92 # No newline at end of file
92 #
93 # self.client.upload(filename) No newline at end of file
93 # self.client.upload(filename)
94 # No newline at end of file
94 #
95 #if __name__ == '__main__': No newline at end of file
95 #if __name__ == '__main__':
96 # No newline at end of file
96 #
97 # obj = FTPComm() No newline at end of file
97 # obj = FTPComm()
98 No newline at end of file
98
99 No newline at end of file
99
100 No newline at end of file
100
@@ -1,282 +1,280
1 import os No newline at end of file
1 import os
2 import library No newline at end of file
2 import library
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 No newline at end of file
6
7 def __init__(self,ipSource="localhost", ipDestino="192.168.1.255", portDestino=7000, ipDestino2="192.168.1.255", portDestino2=5500, ftpPortDestino=None): No newline at end of file
7 def __init__(self,ipSource="localhost", ipDestino="192.168.1.255", portDestino=7000, ipDestino2="192.168.1.255", portDestino2=5500, ftpPortDestino=None):
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.ftpPortDestino = ftpPortDestino No newline at end of file
16 self.ftpPortDestino = ftpPortDestino
17 self.experiment_name = "default" No newline at end of file
17 self.experiment_name = "default"
18 self.tx_buffer = "default" No newline at end of file
18 self.tx_buffer = "default"
19 No newline at end of file
19
20 self.createObjects() No newline at end of file
20 self.createObjects()
21 No newline at end of file
21
22 def createObjects(self): No newline at end of file
22 def createObjects(self):
23 No newline at end of file
23
24 asServer = True No newline at end of file
24 asServer = True
25 self.commServerObj = library.UDPComm(self.ipSource, self.ipDestino, self.portDestino, asServer) No newline at end of file
25 self.commServerObj = library.UDPComm(self.ipSource, self.ipDestino, self.portDestino, asServer)
26 self.commClientObj = library.UDPComm(self.ipSource, self.ipDestino2, self.portDestino2) No newline at end of file
26 self.commClientObj = library.UDPComm(self.ipSource, self.ipDestino2, self.portDestino2)
27 #self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino) No newline at end of file
27 #self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino)
28 No newline at end of file
28
29 No newline at end of file
29
30 def waitRequest(self): No newline at end of file
30 def waitRequest(self):
31 No newline at end of file
31
32 ipSource, ipDestino, cmd, self.datarx = self.commServerObj.waitData() No newline at end of file
32 ipSource, ipDestino, cmd, self.datarx = self.commServerObj.waitData()
33 No newline at end of file
33
34 datarpta = "OK" No newline at end of file
34 datarpta = "OK"
35 No newline at end of file
35
36 if cmd == "SNDF": No newline at end of file
36 if cmd == "SNDF":
37 self.sendFile2Modules() No newline at end of file
37 self.sendFile2Modules()
38 No newline at end of file
38
39 if cmd == "CHGB": No newline at end of file
39 if cmd == "CHGB":
40 self.changeBeam() No newline at end of file
40 self.changeBeam()
41 No newline at end of file
41
42 if cmd == "ANST": No newline at end of file
42 if cmd == "ANST":
43 self.getStatus(mode=3) No newline at end of file
43 self.getStatus(mode=3)
44 datarpta = self.tx_buffer No newline at end of file
44 datarpta = self.tx_buffer
45 No newline at end of file
45
46 self.commServerObj.sendData(cmd=cmd, data=datarpta) No newline at end of file
46 self.commServerObj.sendData(cmd=cmd, data=datarpta)
47 No newline at end of file
47
48 def checkModule(self, address): No newline at end of file
48 def checkModule(self, address):
49 No newline at end of file
49
50 cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null" No newline at end of file
50 cmd = "ping -c 1 -w 1 192.168.1."+ str(address) + " >> /dev/null"
51 status = os.system(cmd) No newline at end of file
51 status = os.system(cmd)
52 No newline at end of file
52
53 if status == 256: No newline at end of file
53 if status == 256:
54 return False No newline at end of file
54 return False
55 No newline at end of file
55
56 return True No newline at end of file
56 return True
57 No newline at end of file
57
58 def __writeReport(self, enaModules): No newline at end of file
58 def __writeReport(self, enaModules):
59 No newline at end of file
59
60 status_array = ["Status of modules\n"] No newline at end of file
60 status_array = ["Status of modules\n"]
61 status_array.append("----------------\n") No newline at end of file
61 status_array.append("----------------\n")
62 No newline at end of file
62
63 for address in range(1,65): No newline at end of file
63 for address in range(1,65):
64 if address in enaModules: No newline at end of file
64 if address in enaModules:
65 # status_array.append("192.168.1." + str(base + i + 1) + " [1 1]\n") No newline at end of file
65 # status_array.append("192.168.1." + str(base + i + 1) + " [1 1]\n")
66 status_array.append("192.168.1." + str(address) + " [1 1]\n") No newline at end of file
66 status_array.append("192.168.1." + str(address) + " [1 1]\n")
67 else: No newline at end of file
67 else:
68 status_array.append("192.168.1." + str(address) + " [0 0]\n") No newline at end of file
68 status_array.append("192.168.1." + str(address) + " [0 0]\n")
69 No newline at end of file
69
70 f = open("module_status.txt","w") No newline at end of file
70 f = open("module_status.txt","w")
71 f.writelines(status_array) No newline at end of file
71 f.writelines(status_array)
72 f.close() No newline at end of file
72 f.close()
73 No newline at end of file
73
74 def checkAntenna(self): No newline at end of file
74 def checkAntenna(self):
75 No newline at end of file
75
76 """ No newline at end of file
76 """
77 Direccion de los modulos de las antenas: No newline at end of file
77 Direccion de los modulos de las antenas:
78 No newline at end of file
78
79 Norte : 01-16 No newline at end of file
79 Norte : 01-16
80 Este : 17-32 No newline at end of file
80 Este : 17-32
81 Oeste: : 33-48 No newline at end of file
81 Oeste: : 33-48
82 Sur : 49-64 No newline at end of file
82 Sur : 49-64
83 No newline at end of file
83
84 """ No newline at end of file
84 """
85 No newline at end of file
85
86 enaModules = [] No newline at end of file
86 enaModules = []
87 No newline at end of file
87
88 for address in range(1,65): No newline at end of file
88 for address in range(1,65):
89 if self.checkModule(address): No newline at end of file
89 if self.checkModule(address):
90 enaModules.append(address) No newline at end of file
90 enaModules.append(address)
91 No newline at end of file
91
92 self.__writeReport(enaModules) No newline at end of file
92 self.__writeReport(enaModules)
93 return enaModules No newline at end of file
93 return enaModules
94 No newline at end of file
94
95 def sendFile2Modules(self): No newline at end of file
95 def sendFile2Modules(self):
96 No newline at end of file
96
97 #Needed for the loop No newline at end of file
97 #Needed for the loop
98 rx_frame_list = self.datarx.split('\n',2) No newline at end of file
98 rx_frame_list = self.datarx.split('\n',2)
99
99
No newline at end of file
100 self.experiment_name = rx_frame_list[0] No newline at end of file
100 experiment_name = rx_frame_list[0] No newline at end of file
101 experiment_number = rx_frame_list[1] No newline at end of file
101 experiment_number = rx_frame_list[1]
102 str_control_modules = rx_frame_list[2] No newline at end of file
102 str_control_modules = rx_frame_list[2]
103 No newline at end of file
103
104 lst_control_modules = str_control_modules.split("------\n") No newline at end of file
104 lst_control_modules = str_control_modules.split("------\n")
105 No newline at end of file
105
106 enaModules = self.checkAntenna() No newline at end of file
106 enaModules = self.checkAntenna()
107 No newline at end of file
107
108 for address in range(1,65): No newline at end of file
108 for address in range(1,65):
109 No newline at end of file
109
110 if address not in enaModules: No newline at end of file
110 if address not in enaModules:
111 continue No newline at end of file
111 continue
112
112
No newline at end of file
113 self.__writeModuleFile(self.experiment_name, lst_control_modules[address-1])
113 self.__writeModuleFile(experiment_name, lst_control_modules[address-1])
No newline at end of file
No newline at end of file
114
114
No newline at end of file
No newline at end of file
115 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c put " + self.experiment_name No newline at end of file
115 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c put " + experiment_name No newline at end of file
116 print cmd No newline at end of file
116 print cmd
117 os.system(cmd)
117 os.system(cmd)
No newline at end of file
118
No newline at end of file
119 self.experiment_name = experiment_name No newline at end of file
120 No newline at end of file
118
121 self.__loadFile() No newline at end of file
119 self.__loadFile()
122 No newline at end of file
120
123 def __writeModuleFile(self, filename, str): No newline at end of file
121 def __writeModuleFile(self, filename, str):
124 No newline at end of file
122
125 fobj = open(filename,"w") No newline at end of file
123 fobj = open(filename,"w")
126 fobj.write(filename + "\n") No newline at end of file
124 fobj.write(filename + "\n")
127 fobj.write("------\n") No newline at end of file
125 fobj.write("------\n")
128 fobj.write(str) No newline at end of file
126 fobj.write(str)
129 fobj.write("------\n") No newline at end of file
127 fobj.write("------\n")
130 fobj.close() No newline at end of file
128 fobj.close()
131 No newline at end of file
129
132 def __readModuleFile(self, filename): No newline at end of file
130 def __readModuleFile(self, filename):
133 No newline at end of file
131
134 fobj1 = open(filename,"r") No newline at end of file
132 fobj1 = open(filename,"r")
135 file_list_1 = fobj1.readlines() No newline at end of file
133 file_list_1 = fobj1.readlines()
136 fobj1.close() No newline at end of file
134 fobj1.close()
137 content_str = ''.join(file_list_1[2:-1]) No newline at end of file
135 content_str = ''.join(file_list_1[2:-1])
138 No newline at end of file
136
139 return content_str No newline at end of file
137 return content_str
140 No newline at end of file
138
141 def __loadFile(self): No newline at end of file
139 def __loadFile(self):
142 No newline at end of file
140
143 #Working with the UDP socket No newline at end of file
141 #Working with the UDP socket
144 self.commClientObj.sendData("none", "CARGA:" + self.experiment_name + ":") No newline at end of file
142 self.commClientObj.sendData("none", "CARGA:" + self.experiment_name + ":")
145 self.commClientObj.sendData("none", "CAMBIA:0:") No newline at end of file
143 self.commClientObj.sendData("none", "CAMBIA:0:")
146 No newline at end of file
144
147 def changeBeam(self): No newline at end of file
145 def changeBeam(self):
148 No newline at end of file
146
149 #rpta = self.commClientObj.sendTxRxCommand(cmd='CAMBIA', data="0") No newline at end of file
147 #rpta = self.commClientObj.sendTxRxCommand(cmd='CAMBIA', data="0")
150 self.commClientObj.sendData("CAMBIA:" + self.datarx + ":") No newline at end of file
148 self.commClientObj.sendData("CAMBIA:" + self.datarx + ":")
151 No newline at end of file
149
152 def getStatus(self,mode): No newline at end of file
150 def getStatus(self,mode):
153 No newline at end of file
151
154 if mode == 1: No newline at end of file
152 if mode == 1:
155 self.__getStsMode1() No newline at end of file
153 self.__getStsMode1()
156 elif mode == 2: No newline at end of file
154 elif mode == 2:
157 self.__getStsMode2() No newline at end of file
155 self.__getStsMode2()
158 else: No newline at end of file
156 else:
159 self.__getStsMode3() No newline at end of file
157 self.__getStsMode3()
160 No newline at end of file
158
161 No newline at end of file
159
162 def __getStsMode1(self): No newline at end of file
160 def __getStsMode1(self):
163 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0") No newline at end of file
161 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0")
164 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":") No newline at end of file
162 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":")
165 seconds = int (self.datarx) No newline at end of file
163 seconds = int (self.datarx)
166 # Give 5 seconds to the control modules No newline at end of file
164 # Give 5 seconds to the control modules
167 time.sleep(seconds) No newline at end of file
165 time.sleep(seconds)
168 # Checking the module connection No newline at end of file
166 # Checking the module connection
169 module_list = self.connection_status(10) No newline at end of file
167 module_list = self.connection_status(10)
170 #Generating the complete report No newline at end of file
168 #Generating the complete report
171 module = 1 No newline at end of file
169 module = 1
172 number_of_modules = 16 No newline at end of file
170 number_of_modules = 16
173 filename1 = "Verificacion" No newline at end of file
171 filename1 = "Verificacion"
174 filename2 = "report.txt" No newline at end of file
172 filename2 = "report.txt"
175 fobj2 = open(filename2,"w") No newline at end of file
173 fobj2 = open(filename2,"w")
176 fobj2.write("Verification_file\n") No newline at end of file
174 fobj2.write("Verification_file\n")
177 fobj2.write("-----------------\n") No newline at end of file
175 fobj2.write("-----------------\n")
178 fobj2.close() No newline at end of file
176 fobj2.close()
179 while module <= number_of_modules: No newline at end of file
177 while module <= number_of_modules:
180 if module_list[module -1] == "1": No newline at end of file
178 if module_list[module -1] == "1":
181 #Preparing and doing the tftp command No newline at end of file
179 #Preparing and doing the tftp command
182 cmd = "tftp -m binary 192.168.1."+ str(base + module) +" 69 -c get " + filename1 No newline at end of file
180 cmd = "tftp -m binary 192.168.1."+ str(base + module) +" 69 -c get " + filename1
183 print cmd No newline at end of file
181 print cmd
184 os.system(cmd) No newline at end of file
182 os.system(cmd)
185 # Getting data from the control module file No newline at end of file
183 # Getting data from the control module file
186 fobj1 = open(filename1,"r") No newline at end of file
184 fobj1 = open(filename1,"r")
187 file_list_1 = fobj1.readlines() No newline at end of file
185 file_list_1 = fobj1.readlines()
188 fobj1.close() No newline at end of file
186 fobj1.close()
189 content = file_list_1[2:-1] No newline at end of file
187 content = file_list_1[2:-1]
190 # No newline at end of file
188 #
191 fobj2 = open(filename2,"a") No newline at end of file
189 fobj2 = open(filename2,"a")
192 if base == 10: No newline at end of file
190 if base == 10:
193 fobj2.write("S" + str(module) + "\n") No newline at end of file
191 fobj2.write("S" + str(module) + "\n")
194 else: No newline at end of file
192 else:
195 fobj2.write("N" + str(module) + "\n") No newline at end of file
193 fobj2.write("N" + str(module) + "\n")
196 fobj2.writelines(content) No newline at end of file
194 fobj2.writelines(content)
197 fobj2.write("------\n") No newline at end of file
195 fobj2.write("------\n")
198 fobj2.close() No newline at end of file
196 fobj2.close()
199 module = module + 1 No newline at end of file
197 module = module + 1
200 No newline at end of file
198
201 def __getStsMode2(self): No newline at end of file
199 def __getStsMode2(self):
202 No newline at end of file
200
203 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0") No newline at end of file
201 #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0")
204 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":") No newline at end of file
202 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":")
205 seconds = int (self.datarx) No newline at end of file
203 seconds = int (self.datarx)
206 # Give 5 seconds to the control modules No newline at end of file
204 # Give 5 seconds to the control modules
207 time.sleep(seconds) No newline at end of file
205 time.sleep(seconds)
208 # Checking the module connection No newline at end of file
206 # Checking the module connection
209 enaModules = self.checkAntenna() No newline at end of file
207 enaModules = self.checkAntenna()
210 #Generating the complete report No newline at end of file
208 #Generating the complete report
211 filename1 = "Verificacion" No newline at end of file
209 filename1 = "Verificacion"
212 line1 = "Verification_file\n" No newline at end of file
210 line1 = "Verification_file\n"
213 line2 = "-----------------\n" No newline at end of file
211 line2 = "-----------------\n"
214 report_list = [line1, line2] No newline at end of file
212 report_list = [line1, line2]
215 No newline at end of file
213
216 for address in range(1,65): No newline at end of file
214 for address in range(1,65):
217 No newline at end of file
215
218 if address not in enaModules: No newline at end of file
216 if address not in enaModules:
219 continue No newline at end of file
217 continue
220 #Preparing and doing the tftp command No newline at end of file
218 #Preparing and doing the tftp command
221 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c get " + filename1 No newline at end of file
219 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c get " + filename1
222 print cmd No newline at end of file
220 print cmd
223 os.system(cmd) No newline at end of file
221 os.system(cmd)
224 #Sub_header No newline at end of file
222 #Sub_header
225 report_list.append("ABS_" + str(address) + "\n") No newline at end of file
223 report_list.append("ABS_" + str(address) + "\n")
226 # Content No newline at end of file
224 # Content
227 fobj1 = open(filename1,"r") No newline at end of file
225 fobj1 = open(filename1,"r")
228 file_list_1 = fobj1.readlines() No newline at end of file
226 file_list_1 = fobj1.readlines()
229 fobj1.close() No newline at end of file
227 fobj1.close()
230 content = ''.join(file_list_1[2:-1]) No newline at end of file
228 content = ''.join(file_list_1[2:-1])
231 report_list.append(content) No newline at end of file
229 report_list.append(content)
232 #Ending No newline at end of file
230 #Ending
233 report_list.append("------\n") No newline at end of file
231 report_list.append("------\n")
234 #print "\nFinalizado" No newline at end of file
232 #print "\nFinalizado"
235 self.tx_buffer = ''.join(report_list) No newline at end of file
233 self.tx_buffer = ''.join(report_list)
236 No newline at end of file
234
237 def __AddingHeader(self,content_list, title): No newline at end of file
235 def __AddingHeader(self,content_list, title):
238 No newline at end of file
236
239 line1 = title + "\n" No newline at end of file
237 line1 = title + "\n"
240 line2 = "-----------------\n" No newline at end of file
238 line2 = "-----------------\n"
241 header_list = [line1, line2] No newline at end of file
239 header_list = [line1, line2]
242 verification_list = header_list + content_list No newline at end of file
240 verification_list = header_list + content_list
243 # Arming the frame No newline at end of file
241 # Arming the frame
244 self.tx_buffer = ''.join(verification_list) No newline at end of file
242 self.tx_buffer = ''.join(verification_list)
245 No newline at end of file
243
246 def __getModuleFile(self, filename): No newline at end of file
244 def __getModuleFile(self, filename):
247 No newline at end of file
245
248 enaModules = self.checkAntenna() No newline at end of file
246 enaModules = self.checkAntenna()
249 content_list = [] No newline at end of file
247 content_list = []
250 for address in range(1,65): No newline at end of file
248 for address in range(1,65):
251 No newline at end of file
249
252 if address not in enaModules: No newline at end of file
250 if address not in enaModules:
253 continue No newline at end of file
251 continue
254 #Preparing and doing the tftp command No newline at end of file
252 #Preparing and doing the tftp command
255 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c get " + filename No newline at end of file
253 cmd = "tftp -m binary 192.168.1."+ str(address) +" 69 -c get " + filename
256 print cmd No newline at end of file
254 print cmd
257 os.system(cmd) No newline at end of file
255 os.system(cmd)
258 #Sub_header No newline at end of file
256 #Sub_header
259 content_list.append("ABS_" + str(address) + "\n") No newline at end of file
257 content_list.append("ABS_" + str(address) + "\n")
260 # From module file to list No newline at end of file
258 # From module file to list
261 content_str = self.__readModuleFile(filename) No newline at end of file
259 content_str = self.__readModuleFile(filename)
262 content_list.append(content_str) No newline at end of file
260 content_list.append(content_str)
263 content_list.append("------\n") No newline at end of file
261 content_list.append("------\n")
264 No newline at end of file
262
265 self.__AddingHeader(content_list, title = "Verification_file") No newline at end of file
263 self.__AddingHeader(content_list, title = "Verification_file")
266 No newline at end of file
264
267 def __getStsMode3(self): No newline at end of file
265 def __getStsMode3(self):
268 No newline at end of file
266
269 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":") No newline at end of file
267 self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":")
270 seconds = int (self.datarx) No newline at end of file
268 seconds = int (self.datarx)
271 # Give 5 seconds to the control modules No newline at end of file
269 # Give 5 seconds to the control modules
272 time.sleep(seconds) No newline at end of file
270 time.sleep(seconds)
273 No newline at end of file
271
274 self.__getModuleFile(filename = "Verificacion") No newline at end of file
272 self.__getModuleFile(filename = "Verificacion")
275 No newline at end of file
273
276 No newline at end of file
274
277 if __name__ == '__main__': No newline at end of file
275 if __name__ == '__main__':
278 No newline at end of file
276
279 absObj = ABSServer() No newline at end of file
277 absObj = ABSServer()
280 No newline at end of file
278
281 while 1: No newline at end of file
279 while 1:
282 absObj.waitRequest() No newline at end of file
280 absObj.waitRequest()
General Comments 0
You need to be logged in to leave comments. Login now