@@ -1,70 +1,72 | |||||
1 | import library3 No newline at end of file |
|
1 | import library3 | |
2 | No newline at end of file |
|
2 | ||
3 | class ABSClient: No newline at end of file |
|
3 | class ABSClient: | |
4 |
|
4 | |||
No newline at end of file |
|
5 | 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 | ||
5 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000): No newline at end of file |
|
|||
6 | No newline at end of file |
|
6 | ||
7 | self.ipSource = ipSource No newline at end of file |
|
7 | self.ipSource = ipSource | |
|
8 | self.iDSource = iDSource No newline at end of file | |||
8 | self.ipDestino = ipDestino No newline at end of file |
|
9 | self.ipDestino = ipDestino | |
|
10 | self.iDDestino = iDDestino No newline at end of file | |||
9 | self.portDestino = portDestino No newline at end of file |
|
11 | self.portDestino = portDestino | |
10 | No newline at end of file |
|
12 | ||
11 | self.createObjects() No newline at end of file |
|
13 | self.createObjects() | |
12 | No newline at end of file |
|
14 | ||
13 | def createObjects(self): No newline at end of file |
|
15 | def createObjects(self): | |
14 |
|
16 | |||
No newline at end of file |
|
17 | self.commObj = library3.TCPComm(self.ipSource, self.iDSource, self.ipDestino, self.iDDestino, self.portDestino) No newline at end of file | ||
15 | self.commObj = library3.TCPComm(self.ipSource, self.ipDestino, self.portDestino) No newline at end of file |
|
|||
16 | self.wFiles = library3.FilesStuff() No newline at end of file |
|
18 | self.wFiles = library3.FilesStuff() | |
17 | No newline at end of file |
|
19 | ||
18 | def __ConnectionWithCentralControl(self, cmd, data): No newline at end of file |
|
20 | def __ConnectionWithCentralControl(self, cmd, data): | |
19 | No newline at end of file |
|
21 | ||
20 | self.commObj.open_socket() No newline at end of file |
|
22 | self.commObj.open_socket() | |
21 | self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino) No newline at end of file |
|
23 | self.commObj.sendData(cmd = cmd, data = data, ipDestino = self.ipDestino) | |
22 | ipSource, ipDestino, cmd, output = self.commObj.waitData() No newline at end of file |
|
24 | ipSource, ipDestino, cmd, output = self.commObj.waitData() | |
23 | self.commObj.close_socket() No newline at end of file |
|
25 | self.commObj.close_socket() | |
24 | No newline at end of file |
|
26 | ||
25 | return output No newline at end of file |
|
27 | return output | |
26 | No newline at end of file |
|
28 | ||
27 | def abs2ControlModuleFormatFile(self, filename): No newline at end of file |
|
29 | def abs2ControlModuleFormatFile(self, filename): | |
28 | No newline at end of file |
|
30 | ||
29 | #From matriz to control module format No newline at end of file |
|
31 | #From matriz to control module format | |
30 | self.wFiles.toCentralControlFormat(filename) No newline at end of file |
|
32 | self.wFiles.toCentralControlFormat(filename) | |
31 | FileName = "CentralControlFormat.txt" No newline at end of file |
|
33 | FileName = "CentralControlFormat.txt" | |
32 | F_Obj = open(FileName,"r") No newline at end of file |
|
34 | F_Obj = open(FileName,"r") | |
33 | FileList = F_Obj.readlines() No newline at end of file |
|
35 | FileList = F_Obj.readlines() | |
34 | F_Obj.close() No newline at end of file |
|
36 | F_Obj.close() | |
35 | FileStr = "".join(FileList) No newline at end of file |
|
37 | FileStr = "".join(FileList) | |
36 | No newline at end of file |
|
38 | ||
37 | return FileStr No newline at end of file |
|
39 | return FileStr | |
38 | No newline at end of file |
|
40 | ||
39 | def sendFile(self, filename): No newline at end of file |
|
41 | def sendFile(self, filename): | |
40 | No newline at end of file |
|
42 | ||
41 | data = self.abs2ControlModuleFormatFile(filename) No newline at end of file |
|
43 | data = self.abs2ControlModuleFormatFile(filename) | |
42 | No newline at end of file |
|
44 | ||
43 | self.__ConnectionWithCentralControl(cmd = "SNDF", data = data) No newline at end of file |
|
45 | self.__ConnectionWithCentralControl(cmd = "SNDF", data = data) | |
44 | No newline at end of file |
|
46 | ||
45 | def changeBeam(self, newBeam): No newline at end of file |
|
47 | def changeBeam(self, newBeam): | |
46 | No newline at end of file |
|
48 | ||
47 | self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam) No newline at end of file |
|
49 | self.__ConnectionWithCentralControl(cmd = "CHGB", data = newBeam) | |
48 | No newline at end of file |
|
50 | ||
49 | def __writeFile(self, filename, data): No newline at end of file |
|
51 | def __writeFile(self, filename, data): | |
50 | No newline at end of file |
|
52 | ||
51 | fobj = open(filename,"w") No newline at end of file |
|
53 | fobj = open(filename,"w") | |
52 | fobj.writelines(data) No newline at end of file |
|
54 | fobj.writelines(data) | |
53 | fobj.close() No newline at end of file |
|
55 | fobj.close() | |
54 | No newline at end of file |
|
56 | ||
55 | def getControlModuleStatus(self, data): No newline at end of file |
|
57 | def getControlModuleStatus(self, data): | |
56 | No newline at end of file |
|
58 | ||
57 | data = self.__ConnectionWithCentralControl(cmd = "ANST", data = data) No newline at end of file |
|
59 | data = self.__ConnectionWithCentralControl(cmd = "ANST", data = data) | |
58 | self.__writeFile("report.txt", data) No newline at end of file |
|
60 | self.__writeFile("report.txt", data) | |
59 | No newline at end of file |
|
61 | ||
60 | def getConnectionStatus(self): No newline at end of file |
|
62 | def getConnectionStatus(self): | |
61 | No newline at end of file |
|
63 | ||
62 | data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none") No newline at end of file |
|
64 | data = self.__ConnectionWithCentralControl(cmd = "NTST", data = "none") | |
63 | self.__writeFile("connection_status.txt", data) No newline at end of file |
|
65 | self.__writeFile("connection_status.txt", data) | |
64 | No newline at end of file |
|
66 | ||
65 | if __name__ == '__main__': No newline at end of file |
|
67 | if __name__ == '__main__': | |
66 | No newline at end of file |
|
68 | ||
67 | filename = "experimento1.abs" No newline at end of file |
|
69 | filename = "experimento1.abs" | |
68 | No newline at end of file |
|
70 | ||
69 | absObj = ABSClient() No newline at end of file |
|
71 | absObj = ABSClient() | |
70 | absObj.sendFile(filename) No newline at end of file |
|
72 | absObj.sendFile(filename) |
@@ -1,447 +1,527 | |||||
1 | # Needed for the FilesStuff class No newline at end of file |
|
1 | # Needed for the FilesStuff class | |
2 | import os No newline at end of file |
|
2 | import os | |
3 | import numpy as np No newline at end of file |
|
3 | import numpy as np | |
4 | # Needed for the TCPComm class No newline at end of file |
|
4 | # Needed for the TCPComm class | |
5 | import socket No newline at end of file |
|
5 | import socket | |
6 | No newline at end of file |
|
6 | ||
7 | class TCPComm: No newline at end of file |
|
7 | class TCPComm: | |
8 | No newline at end of file |
|
8 | ||
9 | __HEADER = "JRO" No newline at end of file |
|
9 | __HEADER = "JRO" | |
10 | __TYPE = "ABS" No newline at end of file |
|
10 | __TYPE = "ABS" | |
11 |
|
11 | |||
No newline at end of file |
|
12 | def __init__(self, ipSource, iDSource, ipDestino, iDDestino, portDestino, asServer=False): No newline at end of file | ||
12 | def __init__(self, ipSource, ipDestino, portDestino, asServer=False): No newline at end of file |
|
|||
13 | No newline at end of file |
|
13 | ||
14 | self.ipSource = ipSource No newline at end of file |
|
14 | self.ipSource = ipSource | |
|
15 | self.iDSource = iDSource No newline at end of file | |||
15 | self.ipDestino = ipDestino No newline at end of file |
|
16 | self.ipDestino = ipDestino | |
|
17 | self.iDDestino = iDDestino No newline at end of file | |||
16 | self.portDestino = portDestino No newline at end of file |
|
18 | self.portDestino = portDestino | |
17 | self.addr = (ipDestino,portDestino) No newline at end of file |
|
19 | self.addr = (ipDestino,portDestino) | |
18 | No newline at end of file |
|
20 | ||
19 | self.sc = "none" No newline at end of file |
|
21 | self.sc = "none" | |
20 | self.answer = "none" #test No newline at end of file |
|
22 | self.answer = "none" #test | |
21 | self.asServer = False |
|
23 | self.asServer = False | |
No newline at end of file |
|
24 | self.len = "000000" | ||
22 | self.len = 0 |
|
No newline at end of file | ||
No newline at end of file |
|
25 | self.crc = "0" No newline at end of file | ||
23 | self.crc = 0 No newline at end of file |
|
|||
24 | No newline at end of file |
|
26 | ||
25 | self.openSocket(asServer) No newline at end of file |
|
27 | self.openSocket(asServer) | |
26 | No newline at end of file |
|
28 | ||
27 | def openSocket(self, asServer): No newline at end of file |
|
29 | def openSocket(self, asServer): | |
28 | No newline at end of file |
|
30 | ||
29 | #self.socket_c = socket.socket(AF_INET,SOCK_DGRAM) No newline at end of file |
|
31 | #self.socket_c = socket.socket(AF_INET,SOCK_DGRAM) | |
30 | # self.socket_c = socket.socket() No newline at end of file |
|
32 | # self.socket_c = socket.socket() | |
31 | # self.socket_c.connect((self.ipDestino, self.portDestino)) No newline at end of file |
|
33 | # self.socket_c.connect((self.ipDestino, self.portDestino)) | |
32 | No newline at end of file |
|
34 | ||
33 | if asServer: No newline at end of file |
|
35 | if asServer: | |
34 | self.socket_c = socket.socket() No newline at end of file |
|
36 | self.socket_c = socket.socket() | |
35 | # self.configAsServer() No newline at end of file |
|
37 | # self.configAsServer() | |
36 | self.socket_c.bind(self.addr) No newline at end of file |
|
38 | self.socket_c.bind(self.addr) | |
37 | self.asServer = True No newline at end of file |
|
39 | self.asServer = True | |
38 | else: No newline at end of file |
|
40 | else: | |
39 | # self.configAsClient() No newline at end of file |
|
41 | # self.configAsClient() | |
40 | self.asServer = False #Socket is opened at the sendData function No newline at end of file |
|
42 | self.asServer = False #Socket is opened at the sendData function | |
41 | No newline at end of file |
|
43 | ||
42 | # def configAsClient(self): No newline at end of file |
|
44 | # def configAsClient(self): | |
43 | #Buscar broadcast TCP No newline at end of file |
|
45 | #Buscar broadcast TCP | |
44 | # self.socket_c.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) No newline at end of file |
|
46 | # self.socket_c.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
45 | # self.socket_c.connect(self.addr) No newline at end of file |
|
47 | # self.socket_c.connect(self.addr) | |
46 | # pass No newline at end of file |
|
48 | # pass | |
47 | No newline at end of file |
|
49 | ||
48 | # def configAsServer(self): No newline at end of file |
|
50 | # def configAsServer(self): | |
49 | # No newline at end of file |
|
51 | # | |
50 | # self.socket_c.bind(self.addr) No newline at end of file |
|
52 | # self.socket_c.bind(self.addr) | |
51 | No newline at end of file |
|
53 | ||
52 | def waitData(self): No newline at end of file |
|
54 | def waitData(self): | |
53 | if self.asServer == True: |
|
55 | if self.asServer == True: | |
No newline at end of file |
|
56 | trama_rx, l = self.waitAsServer() No newline at end of file | ||
54 | trama_rx = self.waitAsServer() No newline at end of file |
|
|||
55 | else: |
|
57 | else: | |
No newline at end of file |
|
58 | trama_rx, l = self.waitAsClient() | ||
56 | trama_rx = self.waitAsClient() |
|
No newline at end of file | ||
No newline at end of file |
|
59 | |||
57 |
|
No newline at end of file | |||
No newline at end of file |
|
60 | ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx, l) No newline at end of file | ||
58 | ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx) No newline at end of file |
|
|||
59 | No newline at end of file |
|
61 | ||
60 | return ipSource, ipDestino, cmd, data No newline at end of file |
|
62 | return ipSource, ipDestino, cmd, data | |
61 |
|
63 | |||
No newline at end of file |
|
64 | def waitAsClient2(self, nbytes = 1024): | ||
62 | def waitAsServer(self, nbytes = 1024): No newline at end of file |
|
No newline at end of file | ||
|
65 | print "\nWaiting the server." | |||
|
No newline at end of file | ||||
|
66 | # Short data through ethernet | |||
|
No newline at end of file | ||||
|
67 | trama_rx = self.socket_c.recv(nbytes) | |||
|
No newline at end of file | ||||
|
68 | print "\nThis socket has received this data: " + str(trama_rx) | |||
|
No newline at end of file | ||||
|
69 | ||||
|
No newline at end of file | ||||
|
70 | return trama_rx | |||
|
No newline at end of file | ||||
|
71 | ||||
|
No newline at end of file | ||||
|
72 | def waitAsServer2(self, nbytes = 1024): No newline at end of file | |||
63 | print "\nWaiting some client." No newline at end of file |
|
73 | print "\nWaiting some client." | |
64 | self.socket_c.listen(1) No newline at end of file |
|
74 | self.socket_c.listen(1) | |
65 | sc, addr = self.socket_c.accept() No newline at end of file |
|
75 | sc, addr = self.socket_c.accept() | |
66 | self.sc = sc No newline at end of file |
|
76 | self.sc = sc | |
67 | self.answer = addr No newline at end of file |
|
77 | self.answer = addr | |
68 | # Big data through ethernet No newline at end of file |
|
78 | # Big data through ethernet | |
69 | trama_rx = "" No newline at end of file |
|
79 | trama_rx = "" | |
70 | while True: No newline at end of file |
|
80 | while True: | |
71 | tmp = self.sc.recv(nbytes) No newline at end of file |
|
81 | tmp = self.sc.recv(nbytes) | |
72 | trama_rx = trama_rx + tmp No newline at end of file |
|
82 | trama_rx = trama_rx + tmp | |
73 | if trama_rx[-4:] == "quit": No newline at end of file |
|
83 | if trama_rx[-4:] == "quit": | |
74 | break No newline at end of file |
|
84 | break | |
75 | No newline at end of file |
|
85 | ||
76 | print "\nThis socket has received some data from: " + str(self.answer) No newline at end of file |
|
86 | print "\nThis socket has received some data from: " + str(self.answer) | |
77 | No newline at end of file |
|
87 | ||
78 | return trama_rx No newline at end of file |
|
88 | return trama_rx | |
79 |
|
|
89 | ||
|
90 | def waitAsServer(self, nbytes = 1024): | |||
|
No newline at end of file | ||||
|
91 | print "\nWaiting some client." | |||
|
No newline at end of file | ||||
|
92 | self.socket_c.listen(1) | |||
|
No newline at end of file | ||||
|
93 | sc, addr = self.socket_c.accept() | |||
|
No newline at end of file | ||||
|
94 | self.sc = sc | |||
|
No newline at end of file | ||||
|
95 | self.answer = addr | |||
|
No newline at end of file | ||||
|
96 | # Big data through ethernet | |||
|
No newline at end of file | ||||
|
97 | cnt = 0; | |||
|
No newline at end of file | ||||
|
98 | first = 0; | |||
|
No newline at end of file | ||||
|
99 | trama_rx = "" | |||
|
No newline at end of file | ||||
|
100 | while True: | |||
|
No newline at end of file | ||||
|
101 | tmp = self.sc.recv(nbytes) | |||
|
No newline at end of file | ||||
|
102 | trama_rx = trama_rx + tmp | |||
|
No newline at end of file | ||||
|
103 | cnt = len(trama_rx) | |||
|
No newline at end of file | ||||
|
104 | if first == 0: | |||
|
No newline at end of file | ||||
|
105 | first = 1 | |||
|
No newline at end of file | ||||
|
106 | lng = int(trama_rx[20:26]) | |||
|
No newline at end of file | ||||
|
107 | if cnt == lng: | |||
|
No newline at end of file | ||||
|
108 | break | |||
|
No newline at end of file | ||||
|
109 | ||||
|
No newline at end of file | ||||
|
110 | print "\nThis socket has received some data from: " + str(self.answer) | |||
|
No newline at end of file | ||||
|
111 | ||||
|
No newline at end of file | ||||
|
112 | return trama_rx, lng | |||
|
No newline at end of file | ||||
|
113 | No newline at end of file | |||
80 | def waitAsClient(self, nbytes = 1024): No newline at end of file |
|
114 | def waitAsClient(self, nbytes = 1024): | |
81 | print "\nWaiting the server." No newline at end of file |
|
115 | print "\nWaiting the server." | |
82 | # Short data through ethernet No newline at end of file |
|
116 | # Short data through ethernet | |
83 | trama_rx = self.socket_c.recv(nbytes) No newline at end of file |
|
117 | trama_rx = self.socket_c.recv(nbytes) | |
|
118 | lng = int(trama_rx[20:26]) No newline at end of file | |||
84 | print "\nThis socket has received this data: " + str(trama_rx) No newline at end of file |
|
119 | print "\nThis socket has received this data: " + str(trama_rx) | |
85 |
|
120 | |||
No newline at end of file |
|
121 | return trama_rx, lng | ||
86 | return trama_rx |
|
No newline at end of file | ||
No newline at end of file |
|
122 | |||
87 |
|
No newline at end of file | |||
No newline at end of file |
|
123 | def sendData2(self, cmd, data, ipDestino): No newline at end of file | ||
88 | def sendData(self, cmd, data, ipDestino): No newline at end of file |
|
|||
89 | No newline at end of file |
|
124 | ||
90 | trama_tx = self.__HEADER + ":" + self.__TYPE + ":" + str(self.ipSource) + ":" + str(ipDestino) + \ No newline at end of file |
|
125 | trama_tx = self.__HEADER + ":" + self.__TYPE + ":" + str(self.ipSource) + ":" + str(ipDestino) + \ | |
91 | ":" + str(self.len) + ":" + str(cmd) + ":" + str(data) + ":" + str(self.crc) + ":" + "quit" No newline at end of file |
|
126 | ":" + str(self.len) + ":" + str(cmd) + ":" + str(data) + ":" + str(self.crc) + ":" + "quit" | |
92 | No newline at end of file |
|
127 | ||
93 | if self.asServer == True: No newline at end of file |
|
128 | if self.asServer == True: | |
94 | self.SendAsServer(trama_tx) No newline at end of file |
|
129 | self.SendAsServer(trama_tx) | |
95 | else: No newline at end of file |
|
130 | else: | |
96 | self.SendAsClient(ipDestino, trama_tx) No newline at end of file |
|
131 | self.SendAsClient(ipDestino, trama_tx) | |
97 | No newline at end of file |
|
132 | ||
|
133 | def sendData(self, cmd, data, ipDestino): | |||
|
No newline at end of file | ||||
|
134 | ||||
|
No newline at end of file | ||||
|
135 | trama_tx = self.__HEADER + self.__TYPE + self.iDSource + \ | |||
|
No newline at end of file | ||||
|
136 | self.iDDestino + self.len + str(cmd) + str(data) + self.crc | |||
|
No newline at end of file | ||||
|
137 | ||||
|
No newline at end of file | ||||
|
138 | self.len = self.int2str(len(trama_tx)) | |||
|
No newline at end of file | ||||
|
139 | ||||
|
No newline at end of file | ||||
|
140 | trama_tx = self.__HEADER + self.__TYPE + self.iDSource + \ | |||
|
No newline at end of file | ||||
|
141 | self.iDDestino + self.len + str(cmd) + str(data) + self.crc | |||
|
No newline at end of file | ||||
|
142 | ||||
|
No newline at end of file | ||||
|
143 | if self.asServer == True: | |||
|
No newline at end of file | ||||
|
144 | self.SendAsServer(trama_tx) | |||
|
No newline at end of file | ||||
|
145 | else: | |||
|
No newline at end of file | ||||
|
146 | self.SendAsClient(ipDestino, trama_tx) | |||
|
No newline at end of file | ||||
|
147 | No newline at end of file | |||
98 | def SendAsServer(self, trama_tx): No newline at end of file |
|
148 | def SendAsServer(self, trama_tx): | |
99 | No newline at end of file |
|
149 | ||
100 | self.sc.send(trama_tx) No newline at end of file |
|
150 | self.sc.send(trama_tx) | |
101 | print "Sending message:[" + trama_tx + "] to: " + str(self.answer) No newline at end of file |
|
151 | print "Sending message:[" + trama_tx + "] to: " + str(self.answer) | |
102 | No newline at end of file |
|
152 | ||
103 | No newline at end of file |
|
153 | ||
104 | def SendAsClient(self, ipDestino, trama_tx): No newline at end of file |
|
154 | def SendAsClient(self, ipDestino, trama_tx): | |
105 | No newline at end of file |
|
155 | ||
106 | self.socket_c.connect((ipDestino, self.portDestino)) No newline at end of file |
|
156 | self.socket_c.connect((ipDestino, self.portDestino)) | |
107 | self.socket_c.send(trama_tx) No newline at end of file |
|
157 | self.socket_c.send(trama_tx) | |
108 | print "Sending message:[" + trama_tx + "] to: " + ipDestino No newline at end of file |
|
158 | print "Sending message:[" + trama_tx + "] to: " + ipDestino | |
109 |
|
159 | |||
No newline at end of file |
|
160 | def __getTrama2(self, trama): No newline at end of file | ||
110 | def __getTrama(self, trama): No newline at end of file |
|
|||
111 | No newline at end of file |
|
161 | ||
112 | FrameList = trama.split(':') No newline at end of file |
|
162 | FrameList = trama.split(':') | |
113 | No newline at end of file |
|
163 | ||
114 | header = FrameList[0] No newline at end of file |
|
164 | header = FrameList[0] | |
115 | TypeOfInstrument = FrameList[1] No newline at end of file |
|
165 | TypeOfInstrument = FrameList[1] | |
116 | ipSource = FrameList[2] No newline at end of file |
|
166 | ipSource = FrameList[2] | |
117 | ipDestino = FrameList[3] No newline at end of file |
|
167 | ipDestino = FrameList[3] | |
118 | len = FrameList[4] No newline at end of file |
|
168 | len = FrameList[4] | |
119 | cmd = FrameList[5] No newline at end of file |
|
169 | cmd = FrameList[5] | |
120 | data = FrameList[6] No newline at end of file |
|
170 | data = FrameList[6] | |
121 | crc = FrameList[7] No newline at end of file |
|
171 | crc = FrameList[7] | |
122 | trash = FrameList[8] No newline at end of file |
|
172 | trash = FrameList[8] | |
123 | No newline at end of file |
|
173 | ||
124 | return ipSource, ipDestino, cmd, data No newline at end of file |
|
174 | return ipSource, ipDestino, cmd, data | |
125 | No newline at end of file |
|
175 | ||
|
176 | def __getTrama(self, trama, l): | |||
|
No newline at end of file | ||||
|
177 | ||||
|
No newline at end of file | ||||
|
178 | header = trama[0:3] | |||
|
No newline at end of file | ||||
|
179 | TypeOfInstrument = trama[3:6] | |||
|
No newline at end of file | ||||
|
180 | ipSource = trama[6:13] | |||
|
No newline at end of file | ||||
|
181 | ipDestino = trama[13:20] | |||
|
No newline at end of file | ||||
|
182 | len = trama[20:26] | |||
|
No newline at end of file | ||||
|
183 | cmd = trama[26:30] | |||
|
No newline at end of file | ||||
|
184 | ldata = l-31 | |||
|
No newline at end of file | ||||
|
185 | data = trama[30:30+ldata] | |||
|
No newline at end of file | ||||
|
186 | crc = trama[30+ldata:] | |||
|
No newline at end of file | ||||
|
187 | ||||
|
No newline at end of file | ||||
|
188 | return ipSource, ipDestino, cmd, data | |||
|
No newline at end of file | ||||
|
189 | No newline at end of file | |||
126 | def close_socket(self): No newline at end of file |
|
190 | def close_socket(self): | |
127 | self.socket_c.close() No newline at end of file |
|
191 | self.socket_c.close() | |
128 | No newline at end of file |
|
192 | ||
129 | def open_socket(self): No newline at end of file |
|
193 | def open_socket(self): | |
130 | self.socket_c = socket.socket() No newline at end of file |
|
194 | self.socket_c = socket.socket() | |
|
195 | ||||
|
No newline at end of file | ||||
|
196 | def int2str(self, n): | |||
|
No newline at end of file | ||||
|
197 | ||||
|
No newline at end of file | ||||
|
198 | str_n = str(n) | |||
|
No newline at end of file | ||||
|
199 | l_n = len(str_n) | |||
|
No newline at end of file | ||||
|
200 | if l_n == 1: | |||
|
No newline at end of file | ||||
|
201 | str_n = "00000" + str_n | |||
|
No newline at end of file | ||||
|
202 | elif l_n == 2: | |||
|
No newline at end of file | ||||
|
203 | str_n = "0000" + str_n | |||
|
No newline at end of file | ||||
|
204 | elif l_n == 3: | |||
|
No newline at end of file | ||||
|
205 | str_n = "000" + str_n | |||
|
No newline at end of file | ||||
|
206 | elif l_n == 4: | |||
|
No newline at end of file | ||||
|
207 | str_n = "00" + str_n | |||
|
No newline at end of file | ||||
|
208 | elif l_n == 5: | |||
|
No newline at end of file | ||||
|
209 | str_n = "0" + str_n | |||
|
No newline at end of file | ||||
|
210 | return str_n No newline at end of file | |||
131 | No newline at end of file |
|
211 | ||
132 | class FilesStuff(): No newline at end of file |
|
212 | class FilesStuff(): | |
133 | No newline at end of file |
|
213 | ||
134 | def lst2string(self, lst): No newline at end of file |
|
214 | def lst2string(self, lst): | |
135 | string='' No newline at end of file |
|
215 | string='' | |
136 | for i in lst: No newline at end of file |
|
216 | for i in lst: | |
137 | string=string+i No newline at end of file |
|
217 | string=string+i | |
138 | return string No newline at end of file |
|
218 | return string | |
139 | No newline at end of file |
|
219 | ||
140 | def string2lst(self, string): No newline at end of file |
|
220 | def string2lst(self, string): | |
141 | lst = [] No newline at end of file |
|
221 | lst = [] | |
142 | for i in string: No newline at end of file |
|
222 | for i in string: | |
143 | lst.append(i) No newline at end of file |
|
223 | lst.append(i) | |
144 | return lst No newline at end of file |
|
224 | return lst | |
145 | No newline at end of file |
|
225 | ||
146 | No newline at end of file |
|
226 | ||
147 | def file1(self, filename, type): No newline at end of file |
|
227 | def file1(self, filename, type): | |
148 | lst = self.string2lst(filename) No newline at end of file |
|
228 | lst = self.string2lst(filename) | |
149 | fin = -1 No newline at end of file |
|
229 | fin = -1 | |
150 | t = len(lst) No newline at end of file |
|
230 | t = len(lst) | |
151 | for i in np.arange(-1,-t,-1): No newline at end of file |
|
231 | for i in np.arange(-1,-t,-1): | |
152 | if lst[i]=='/': No newline at end of file |
|
232 | if lst[i]=='/': | |
153 | fin=i No newline at end of file |
|
233 | fin=i | |
154 | break No newline at end of file |
|
234 | break | |
155 | if type == '1': No newline at end of file |
|
235 | if type == '1': | |
156 | nombre2 = lst[fin+1:] No newline at end of file |
|
236 | nombre2 = lst[fin+1:] | |
157 | nombre2[-1]='s' No newline at end of file |
|
237 | nombre2[-1]='s' | |
158 | nombre2 = self.lst2string(nombre2) No newline at end of file |
|
238 | nombre2 = self.lst2string(nombre2) | |
159 | return nombre2 No newline at end of file |
|
239 | return nombre2 | |
160 | if type == '2': No newline at end of file |
|
240 | if type == '2': | |
161 | nombre2 = lst[fin+1:] No newline at end of file |
|
241 | nombre2 = lst[fin+1:] | |
162 | nombre2[-1]='1' No newline at end of file |
|
242 | nombre2[-1]='1' | |
163 | nombre2 = self.lst2string(nombre2) No newline at end of file |
|
243 | nombre2 = self.lst2string(nombre2) | |
164 | return nombre2 No newline at end of file |
|
244 | return nombre2 | |
165 | No newline at end of file |
|
245 | ||
166 | No newline at end of file |
|
246 | ||
167 | def EliminaSaltoDeLinea(self,cadena): No newline at end of file |
|
247 | def EliminaSaltoDeLinea(self,cadena): | |
168 | i = 0 No newline at end of file |
|
248 | i = 0 | |
169 | for elemento in cadena: No newline at end of file |
|
249 | for elemento in cadena: | |
170 | if elemento =='\n' or elemento =='\r': No newline at end of file |
|
250 | if elemento =='\n' or elemento =='\r': | |
171 | pass No newline at end of file |
|
251 | pass | |
172 | else: No newline at end of file |
|
252 | else: | |
173 | i=i+1 No newline at end of file |
|
253 | i=i+1 | |
174 | return cadena [:i] No newline at end of file |
|
254 | return cadena [:i] | |
175 | No newline at end of file |
|
255 | ||
176 | def NumeroDeExperimentos(self, path): No newline at end of file |
|
256 | def NumeroDeExperimentos(self, path): | |
177 | fichero1=open(path,'r') No newline at end of file |
|
257 | fichero1=open(path,'r') | |
178 | cont=0 No newline at end of file |
|
258 | cont=0 | |
179 | for cadena in fichero1: No newline at end of file |
|
259 | for cadena in fichero1: | |
180 | cont=cont+1 No newline at end of file |
|
260 | cont=cont+1 | |
181 | if cont==3: No newline at end of file |
|
261 | if cont==3: | |
182 | nexp='' No newline at end of file |
|
262 | nexp='' | |
183 | pos=0 No newline at end of file |
|
263 | pos=0 | |
184 | for elemento in cadena: No newline at end of file |
|
264 | for elemento in cadena: | |
185 | pos=pos+1 No newline at end of file |
|
265 | pos=pos+1 | |
186 | if elemento=='=': No newline at end of file |
|
266 | if elemento=='=': | |
187 | nexp=int(cadena[pos:]) No newline at end of file |
|
267 | nexp=int(cadena[pos:]) | |
188 | return nexp No newline at end of file |
|
268 | return nexp | |
189 | fichero1.close() No newline at end of file |
|
269 | fichero1.close() | |
190 | No newline at end of file |
|
270 | ||
191 | def Paridad(numero): No newline at end of file |
|
271 | def Paridad(numero): | |
192 | if numero%2==0: return 'par' No newline at end of file |
|
272 | if numero%2==0: return 'par' | |
193 | elif numero%2==1: return 'impar' No newline at end of file |
|
273 | elif numero%2==1: return 'impar' | |
194 | No newline at end of file |
|
274 | ||
195 | def EvaluaCadena(self,cadena): No newline at end of file |
|
275 | def EvaluaCadena(self,cadena): | |
196 | if len(cadena)>35: No newline at end of file |
|
276 | if len(cadena)>35: | |
197 | if cadena[-1]=='$': No newline at end of file |
|
277 | if cadena[-1]=='$': | |
198 | return cadena[-35:-2] No newline at end of file |
|
278 | return cadena[-35:-2] | |
199 | elif cadena[-1]==']': No newline at end of file |
|
279 | elif cadena[-1]==']': | |
200 | return cadena[-34:-1] No newline at end of file |
|
280 | return cadena[-34:-1] | |
201 | else: No newline at end of file |
|
281 | else: | |
202 | return None No newline at end of file |
|
282 | return None | |
203 | No newline at end of file |
|
283 | ||
204 | def GuardaEnLista(self,path): No newline at end of file |
|
284 | def GuardaEnLista(self,path): | |
205 | fichero=open(path,'r') No newline at end of file |
|
285 | fichero=open(path,'r') | |
206 | lista=[] No newline at end of file |
|
286 | lista=[] | |
207 | for cadena in fichero: No newline at end of file |
|
287 | for cadena in fichero: | |
208 | cadena = self.EliminaSaltoDeLinea(cadena) No newline at end of file |
|
288 | cadena = self.EliminaSaltoDeLinea(cadena) | |
209 | cadena = self.EvaluaCadena(cadena) No newline at end of file |
|
289 | cadena = self.EvaluaCadena(cadena) | |
210 | if cadena != None: No newline at end of file |
|
290 | if cadena != None: | |
211 | lista.append(cadena) No newline at end of file |
|
291 | lista.append(cadena) | |
212 | fichero.close() No newline at end of file |
|
292 | fichero.close() | |
213 | return lista No newline at end of file |
|
293 | return lista | |
214 | No newline at end of file |
|
294 | ||
215 | def CreaFicherosPrevios(self, path, archivo): No newline at end of file |
|
295 | def CreaFicherosPrevios(self, path, archivo): | |
216 | vector = self.GuardaEnLista(archivo) No newline at end of file |
|
296 | vector = self.GuardaEnLista(archivo) | |
217 | for i in range(1,self.NumeroDeExperimentos(archivo)+1): No newline at end of file |
|
297 | for i in range(1,self.NumeroDeExperimentos(archivo)+1): | |
218 | fichero =open(path + str(i)+ '.txt','w') No newline at end of file |
|
298 | fichero =open(path + str(i)+ '.txt','w') | |
219 | for j in range(0,16): No newline at end of file |
|
299 | for j in range(0,16): | |
220 | fichero.write(vector[j+16*(i-1)]+'\n') No newline at end of file |
|
300 | fichero.write(vector[j+16*(i-1)]+'\n') | |
221 | fichero.close() No newline at end of file |
|
301 | fichero.close() | |
222 | No newline at end of file |
|
302 | ||
223 | def CapturaValoresEnArchivo(self, path, polarizacion='up'): No newline at end of file |
|
303 | def CapturaValoresEnArchivo(self, path, polarizacion='up'): | |
224 | fichero =open(path,'r') No newline at end of file |
|
304 | fichero =open(path,'r') | |
225 | cnt=0 No newline at end of file |
|
305 | cnt=0 | |
226 | lstup=[] No newline at end of file |
|
306 | lstup=[] | |
227 | lstdw=[] No newline at end of file |
|
307 | lstdw=[] | |
228 | for cadena in fichero: No newline at end of file |
|
308 | for cadena in fichero: | |
229 | cnt=cnt+1 No newline at end of file |
|
309 | cnt=cnt+1 | |
230 | if cnt==1: No newline at end of file |
|
310 | if cnt==1: | |
231 | nu01=cadena[1:4] No newline at end of file |
|
311 | nu01=cadena[1:4] | |
232 | nu02=cadena[5:8] No newline at end of file |
|
312 | nu02=cadena[5:8] | |
233 | nu03=cadena[9:12] No newline at end of file |
|
313 | nu03=cadena[9:12] | |
234 | nu04=cadena[13:16] No newline at end of file |
|
314 | nu04=cadena[13:16] | |
235 | eu01=cadena[17:20] No newline at end of file |
|
315 | eu01=cadena[17:20] | |
236 | eu02=cadena[21:24] No newline at end of file |
|
316 | eu02=cadena[21:24] | |
237 | eu03=cadena[25:28] No newline at end of file |
|
317 | eu03=cadena[25:28] | |
238 | eu04=cadena[29:32] No newline at end of file |
|
318 | eu04=cadena[29:32] | |
239 | if cnt==2: No newline at end of file |
|
319 | if cnt==2: | |
240 | nu05=cadena[1:4] No newline at end of file |
|
320 | nu05=cadena[1:4] | |
241 | nu06=cadena[5:8] No newline at end of file |
|
321 | nu06=cadena[5:8] | |
242 | nu07=cadena[9:12] No newline at end of file |
|
322 | nu07=cadena[9:12] | |
243 | nu08=cadena[13:16] No newline at end of file |
|
323 | nu08=cadena[13:16] | |
244 | eu05=cadena[17:20] No newline at end of file |
|
324 | eu05=cadena[17:20] | |
245 | eu06=cadena[21:24] No newline at end of file |
|
325 | eu06=cadena[21:24] | |
246 | eu07=cadena[25:28] No newline at end of file |
|
326 | eu07=cadena[25:28] | |
247 | eu08=cadena[29:32] No newline at end of file |
|
327 | eu08=cadena[29:32] | |
248 | if cnt==3: No newline at end of file |
|
328 | if cnt==3: | |
249 | nu09=cadena[1:4] No newline at end of file |
|
329 | nu09=cadena[1:4] | |
250 | nu10=cadena[5:8] No newline at end of file |
|
330 | nu10=cadena[5:8] | |
251 | nu11=cadena[9:12] No newline at end of file |
|
331 | nu11=cadena[9:12] | |
252 | nu12=cadena[13:16] No newline at end of file |
|
332 | nu12=cadena[13:16] | |
253 | eu09=cadena[17:20] No newline at end of file |
|
333 | eu09=cadena[17:20] | |
254 | eu10=cadena[21:24] No newline at end of file |
|
334 | eu10=cadena[21:24] | |
255 | eu11=cadena[25:28] No newline at end of file |
|
335 | eu11=cadena[25:28] | |
256 | eu12=cadena[29:32] No newline at end of file |
|
336 | eu12=cadena[29:32] | |
257 | if cnt==4: No newline at end of file |
|
337 | if cnt==4: | |
258 | nu13=cadena[1:4] No newline at end of file |
|
338 | nu13=cadena[1:4] | |
259 | nu14=cadena[5:8] No newline at end of file |
|
339 | nu14=cadena[5:8] | |
260 | nu15=cadena[9:12] No newline at end of file |
|
340 | nu15=cadena[9:12] | |
261 | nu16=cadena[13:16] No newline at end of file |
|
341 | nu16=cadena[13:16] | |
262 | eu13=cadena[17:20] No newline at end of file |
|
342 | eu13=cadena[17:20] | |
263 | eu14=cadena[21:24] No newline at end of file |
|
343 | eu14=cadena[21:24] | |
264 | eu15=cadena[25:28] No newline at end of file |
|
344 | eu15=cadena[25:28] | |
265 | eu16=cadena[29:32] No newline at end of file |
|
345 | eu16=cadena[29:32] | |
266 | if cnt==5: No newline at end of file |
|
346 | if cnt==5: | |
267 | wu01=cadena[1:4] No newline at end of file |
|
347 | wu01=cadena[1:4] | |
268 | wu02=cadena[5:8] No newline at end of file |
|
348 | wu02=cadena[5:8] | |
269 | wu03=cadena[9:12] No newline at end of file |
|
349 | wu03=cadena[9:12] | |
270 | wu04=cadena[13:16] No newline at end of file |
|
350 | wu04=cadena[13:16] | |
271 | su01=cadena[17:20] No newline at end of file |
|
351 | su01=cadena[17:20] | |
272 | su02=cadena[21:24] No newline at end of file |
|
352 | su02=cadena[21:24] | |
273 | su03=cadena[25:28] No newline at end of file |
|
353 | su03=cadena[25:28] | |
274 | su04=cadena[29:32] No newline at end of file |
|
354 | su04=cadena[29:32] | |
275 | if cnt==6: No newline at end of file |
|
355 | if cnt==6: | |
276 | wu05=cadena[1:4] No newline at end of file |
|
356 | wu05=cadena[1:4] | |
277 | wu06=cadena[5:8] No newline at end of file |
|
357 | wu06=cadena[5:8] | |
278 | wu07=cadena[9:12] No newline at end of file |
|
358 | wu07=cadena[9:12] | |
279 | wu08=cadena[13:16] No newline at end of file |
|
359 | wu08=cadena[13:16] | |
280 | su05=cadena[17:20] No newline at end of file |
|
360 | su05=cadena[17:20] | |
281 | su06=cadena[21:24] No newline at end of file |
|
361 | su06=cadena[21:24] | |
282 | su07=cadena[25:28] No newline at end of file |
|
362 | su07=cadena[25:28] | |
283 | su08=cadena[29:32] No newline at end of file |
|
363 | su08=cadena[29:32] | |
284 | if cnt==7: No newline at end of file |
|
364 | if cnt==7: | |
285 | wu09=cadena[1:4] No newline at end of file |
|
365 | wu09=cadena[1:4] | |
286 | wu10=cadena[5:8] No newline at end of file |
|
366 | wu10=cadena[5:8] | |
287 | wu11=cadena[9:12] No newline at end of file |
|
367 | wu11=cadena[9:12] | |
288 | wu12=cadena[13:16] No newline at end of file |
|
368 | wu12=cadena[13:16] | |
289 | su09=cadena[17:20] No newline at end of file |
|
369 | su09=cadena[17:20] | |
290 | su10=cadena[21:24] No newline at end of file |
|
370 | su10=cadena[21:24] | |
291 | su11=cadena[25:28] No newline at end of file |
|
371 | su11=cadena[25:28] | |
292 | su12=cadena[29:32] No newline at end of file |
|
372 | su12=cadena[29:32] | |
293 | if cnt==8: No newline at end of file |
|
373 | if cnt==8: | |
294 | wu13=cadena[1:4] No newline at end of file |
|
374 | wu13=cadena[1:4] | |
295 | wu14=cadena[5:8] No newline at end of file |
|
375 | wu14=cadena[5:8] | |
296 | wu15=cadena[9:12] No newline at end of file |
|
376 | wu15=cadena[9:12] | |
297 | wu16=cadena[13:16] No newline at end of file |
|
377 | wu16=cadena[13:16] | |
298 | su13=cadena[17:20] No newline at end of file |
|
378 | su13=cadena[17:20] | |
299 | su14=cadena[21:24] No newline at end of file |
|
379 | su14=cadena[21:24] | |
300 | su15=cadena[25:28] No newline at end of file |
|
380 | su15=cadena[25:28] | |
301 | su16=cadena[29:32] No newline at end of file |
|
381 | su16=cadena[29:32] | |
302 | if cnt==9: No newline at end of file |
|
382 | if cnt==9: | |
303 | nd01=cadena[1:4] No newline at end of file |
|
383 | nd01=cadena[1:4] | |
304 | nd02=cadena[5:8] No newline at end of file |
|
384 | nd02=cadena[5:8] | |
305 | nd03=cadena[9:12] No newline at end of file |
|
385 | nd03=cadena[9:12] | |
306 | nd04=cadena[13:16] No newline at end of file |
|
386 | nd04=cadena[13:16] | |
307 | ed01=cadena[17:20] No newline at end of file |
|
387 | ed01=cadena[17:20] | |
308 | ed02=cadena[21:24] No newline at end of file |
|
388 | ed02=cadena[21:24] | |
309 | ed03=cadena[25:28] No newline at end of file |
|
389 | ed03=cadena[25:28] | |
310 | ed04=cadena[29:32] No newline at end of file |
|
390 | ed04=cadena[29:32] | |
311 | if cnt==10: No newline at end of file |
|
391 | if cnt==10: | |
312 | nd05=cadena[1:4] No newline at end of file |
|
392 | nd05=cadena[1:4] | |
313 | nd06=cadena[5:8] No newline at end of file |
|
393 | nd06=cadena[5:8] | |
314 | nd07=cadena[9:12] No newline at end of file |
|
394 | nd07=cadena[9:12] | |
315 | nd08=cadena[13:16] No newline at end of file |
|
395 | nd08=cadena[13:16] | |
316 | ed05=cadena[17:20] No newline at end of file |
|
396 | ed05=cadena[17:20] | |
317 | ed06=cadena[21:24] No newline at end of file |
|
397 | ed06=cadena[21:24] | |
318 | ed07=cadena[25:28] No newline at end of file |
|
398 | ed07=cadena[25:28] | |
319 | ed08=cadena[29:32] No newline at end of file |
|
399 | ed08=cadena[29:32] | |
320 | if cnt==11: No newline at end of file |
|
400 | if cnt==11: | |
321 | nd09=cadena[1:4] No newline at end of file |
|
401 | nd09=cadena[1:4] | |
322 | nd10=cadena[5:8] No newline at end of file |
|
402 | nd10=cadena[5:8] | |
323 | nd11=cadena[9:12] No newline at end of file |
|
403 | nd11=cadena[9:12] | |
324 | nd12=cadena[13:16] No newline at end of file |
|
404 | nd12=cadena[13:16] | |
325 | ed09=cadena[17:20] No newline at end of file |
|
405 | ed09=cadena[17:20] | |
326 | ed10=cadena[21:24] No newline at end of file |
|
406 | ed10=cadena[21:24] | |
327 | ed11=cadena[25:28] No newline at end of file |
|
407 | ed11=cadena[25:28] | |
328 | ed12=cadena[29:32] No newline at end of file |
|
408 | ed12=cadena[29:32] | |
329 | if cnt==12: No newline at end of file |
|
409 | if cnt==12: | |
330 | nd13=cadena[1:4] No newline at end of file |
|
410 | nd13=cadena[1:4] | |
331 | nd14=cadena[5:8] No newline at end of file |
|
411 | nd14=cadena[5:8] | |
332 | nd15=cadena[9:12] No newline at end of file |
|
412 | nd15=cadena[9:12] | |
333 | nd16=cadena[13:16] No newline at end of file |
|
413 | nd16=cadena[13:16] | |
334 | ed13=cadena[17:20] No newline at end of file |
|
414 | ed13=cadena[17:20] | |
335 | ed14=cadena[21:24] No newline at end of file |
|
415 | ed14=cadena[21:24] | |
336 | ed15=cadena[25:28] No newline at end of file |
|
416 | ed15=cadena[25:28] | |
337 | ed16=cadena[29:32] No newline at end of file |
|
417 | ed16=cadena[29:32] | |
338 | if cnt==13: No newline at end of file |
|
418 | if cnt==13: | |
339 | wd01=cadena[1:4] No newline at end of file |
|
419 | wd01=cadena[1:4] | |
340 | wd02=cadena[5:8] No newline at end of file |
|
420 | wd02=cadena[5:8] | |
341 | wd03=cadena[9:12] No newline at end of file |
|
421 | wd03=cadena[9:12] | |
342 | wd04=cadena[13:16] No newline at end of file |
|
422 | wd04=cadena[13:16] | |
343 | sd01=cadena[17:20] No newline at end of file |
|
423 | sd01=cadena[17:20] | |
344 | sd02=cadena[21:24] No newline at end of file |
|
424 | sd02=cadena[21:24] | |
345 | sd03=cadena[25:28] No newline at end of file |
|
425 | sd03=cadena[25:28] | |
346 | sd04=cadena[29:32] No newline at end of file |
|
426 | sd04=cadena[29:32] | |
347 | if cnt==14: No newline at end of file |
|
427 | if cnt==14: | |
348 | wd05=cadena[1:4] No newline at end of file |
|
428 | wd05=cadena[1:4] | |
349 | wd06=cadena[5:8] No newline at end of file |
|
429 | wd06=cadena[5:8] | |
350 | wd07=cadena[9:12] No newline at end of file |
|
430 | wd07=cadena[9:12] | |
351 | wd08=cadena[13:16] No newline at end of file |
|
431 | wd08=cadena[13:16] | |
352 | sd05=cadena[17:20] No newline at end of file |
|
432 | sd05=cadena[17:20] | |
353 | sd06=cadena[21:24] No newline at end of file |
|
433 | sd06=cadena[21:24] | |
354 | sd07=cadena[25:28] No newline at end of file |
|
434 | sd07=cadena[25:28] | |
355 | sd08=cadena[29:32] No newline at end of file |
|
435 | sd08=cadena[29:32] | |
356 | if cnt==15: No newline at end of file |
|
436 | if cnt==15: | |
357 | wd09=cadena[1:4] No newline at end of file |
|
437 | wd09=cadena[1:4] | |
358 | wd10=cadena[5:8] No newline at end of file |
|
438 | wd10=cadena[5:8] | |
359 | wd11=cadena[9:12] No newline at end of file |
|
439 | wd11=cadena[9:12] | |
360 | wd12=cadena[13:16] No newline at end of file |
|
440 | wd12=cadena[13:16] | |
361 | sd09=cadena[17:20] No newline at end of file |
|
441 | sd09=cadena[17:20] | |
362 | sd10=cadena[21:24] No newline at end of file |
|
442 | sd10=cadena[21:24] | |
363 | sd11=cadena[25:28] No newline at end of file |
|
443 | sd11=cadena[25:28] | |
364 | sd12=cadena[29:32] No newline at end of file |
|
444 | sd12=cadena[29:32] | |
365 | if cnt==16: No newline at end of file |
|
445 | if cnt==16: | |
366 | wd13=cadena[1:4] No newline at end of file |
|
446 | wd13=cadena[1:4] | |
367 | wd14=cadena[5:8] No newline at end of file |
|
447 | wd14=cadena[5:8] | |
368 | wd15=cadena[9:12] No newline at end of file |
|
448 | wd15=cadena[9:12] | |
369 | wd16=cadena[13:16] No newline at end of file |
|
449 | wd16=cadena[13:16] | |
370 | sd13=cadena[17:20] No newline at end of file |
|
450 | sd13=cadena[17:20] | |
371 | sd14=cadena[21:24] No newline at end of file |
|
451 | sd14=cadena[21:24] | |
372 | sd15=cadena[25:28] No newline at end of file |
|
452 | sd15=cadena[25:28] | |
373 | sd16=cadena[29:32] No newline at end of file |
|
453 | sd16=cadena[29:32] | |
374 | blck_1_up = [nu01,nu02,nu03,nu04,eu01,eu02,eu03,eu04,nu05,nu06,nu07,nu08,eu05,eu06,eu07,eu08] No newline at end of file |
|
454 | blck_1_up = [nu01,nu02,nu03,nu04,eu01,eu02,eu03,eu04,nu05,nu06,nu07,nu08,eu05,eu06,eu07,eu08] | |
375 | blck_1_dw = [nd01,nd02,nd03,nd04,ed01,ed02,ed03,ed04,nd05,nd06,nd07,nd08,ed05,ed06,ed07,ed08] No newline at end of file |
|
455 | blck_1_dw = [nd01,nd02,nd03,nd04,ed01,ed02,ed03,ed04,nd05,nd06,nd07,nd08,ed05,ed06,ed07,ed08] | |
376 | blck_2_up = [nu09,nu10,nu11,nu12,eu09,eu10,eu11,eu12,nu13,nu14,nu15,nu16,eu13,eu14,eu15,eu16] No newline at end of file |
|
456 | blck_2_up = [nu09,nu10,nu11,nu12,eu09,eu10,eu11,eu12,nu13,nu14,nu15,nu16,eu13,eu14,eu15,eu16] | |
377 | blck_2_dw = [nd09,nd10,nd11,nd12,ed09,ed10,ed11,ed12,nd13,nd14,nd15,nd16,ed13,ed14,ed15,ed16] No newline at end of file |
|
457 | blck_2_dw = [nd09,nd10,nd11,nd12,ed09,ed10,ed11,ed12,nd13,nd14,nd15,nd16,ed13,ed14,ed15,ed16] | |
378 | blck_3_up = [wu01,wu02,wu03,wu04,su01,su02,su03,su04,wu05,wu06,wu07,wu08,su05,su06,su07,su08] No newline at end of file |
|
458 | blck_3_up = [wu01,wu02,wu03,wu04,su01,su02,su03,su04,wu05,wu06,wu07,wu08,su05,su06,su07,su08] | |
379 | blck_3_dw = [wd01,wd02,wd03,wd04,sd01,sd02,sd03,sd04,wd05,wd06,wd07,wd08,sd05,sd06,sd07,sd08] No newline at end of file |
|
459 | blck_3_dw = [wd01,wd02,wd03,wd04,sd01,sd02,sd03,sd04,wd05,wd06,wd07,wd08,sd05,sd06,sd07,sd08] | |
380 | blck_4_up = [wu09,wu10,wu11,wu12,su09,su10,su11,su12,wu13,wu14,wu15,wu16,su13,su14,su15,su16] No newline at end of file |
|
460 | blck_4_up = [wu09,wu10,wu11,wu12,su09,su10,su11,su12,wu13,wu14,wu15,wu16,su13,su14,su15,su16] | |
381 | blck_4_dw = [wd09,wd10,wd11,wd12,sd09,sd10,sd11,sd12,wd13,wd14,wd15,wd16,sd13,sd14,sd15,sd16] No newline at end of file |
|
461 | blck_4_dw = [wd09,wd10,wd11,wd12,sd09,sd10,sd11,sd12,wd13,wd14,wd15,wd16,sd13,sd14,sd15,sd16] | |
382 | No newline at end of file |
|
462 | ||
383 | lstup = blck_1_up + blck_2_up + blck_3_up + blck_4_up No newline at end of file |
|
463 | lstup = blck_1_up + blck_2_up + blck_3_up + blck_4_up | |
384 | lstdw = blck_1_dw + blck_2_dw + blck_3_dw + blck_4_dw No newline at end of file |
|
464 | lstdw = blck_1_dw + blck_2_dw + blck_3_dw + blck_4_dw | |
385 | No newline at end of file |
|
465 | ||
386 | if polarizacion=='up': No newline at end of file |
|
466 | if polarizacion=='up': | |
387 | return lstup No newline at end of file |
|
467 | return lstup | |
388 | elif polarizacion=='dw': No newline at end of file |
|
468 | elif polarizacion=='dw': | |
389 | return lstdw No newline at end of file |
|
469 | return lstdw | |
390 | fichero.close() No newline at end of file |
|
470 | fichero.close() | |
391 | No newline at end of file |
|
471 | ||
392 | def CreaFormatoFinal(self, path, filename): No newline at end of file |
|
472 | def CreaFormatoFinal(self, path, filename): | |
393 | ne=self.NumeroDeExperimentos(filename) No newline at end of file |
|
473 | ne=self.NumeroDeExperimentos(filename) | |
394 | No newline at end of file |
|
474 | ||
395 | #nombre01 = file1(archivo,'1') No newline at end of file |
|
475 | #nombre01 = file1(archivo,'1') | |
396 | nombre02 = self.file1(filename,'2') No newline at end of file |
|
476 | nombre02 = self.file1(filename,'2') | |
397 | fichero=open(path + 'CentralControlFormat.txt','w') No newline at end of file |
|
477 | fichero=open(path + 'CentralControlFormat.txt','w') | |
398 | fichero.write(nombre02+'\n') No newline at end of file |
|
478 | fichero.write(nombre02+'\n') | |
399 | fichero.write(str(ne)+'\n') No newline at end of file |
|
479 | fichero.write(str(ne)+'\n') | |
400 | No newline at end of file |
|
480 | ||
401 | for i in range(1,65): No newline at end of file |
|
481 | for i in range(1,65): | |
402 | No newline at end of file |
|
482 | ||
403 | if i<10: No newline at end of file |
|
483 | if i<10: | |
404 | nmod = '0'+str(i) No newline at end of file |
|
484 | nmod = '0'+str(i) | |
405 | else: nmod = str(i) No newline at end of file |
|
485 | else: nmod = str(i) | |
406 | No newline at end of file |
|
486 | ||
407 | fichero.write("ABS_" + nmod+'\n') No newline at end of file |
|
487 | fichero.write("ABS_" + nmod+'\n') | |
408 | No newline at end of file |
|
488 | ||
409 | for j in range(1,ne+1): No newline at end of file |
|
489 | for j in range(1,ne+1): | |
410 | ruta=path+str(j)+'.txt' No newline at end of file |
|
490 | ruta=path+str(j)+'.txt' | |
411 | lu=self.CapturaValoresEnArchivo(ruta,polarizacion='up') No newline at end of file |
|
491 | lu=self.CapturaValoresEnArchivo(ruta,polarizacion='up') | |
412 | ld=self.CapturaValoresEnArchivo(ruta,polarizacion='dw') No newline at end of file |
|
492 | ld=self.CapturaValoresEnArchivo(ruta,polarizacion='dw') | |
413 | part1='' No newline at end of file |
|
493 | part1='' | |
414 | part2='' No newline at end of file |
|
494 | part2='' | |
415 | if lu[i-1]=='1.0': part1='000' No newline at end of file |
|
495 | if lu[i-1]=='1.0': part1='000' | |
416 | if lu[i-1]=='2.0': part1='001' No newline at end of file |
|
496 | if lu[i-1]=='2.0': part1='001' | |
417 | if lu[i-1]=='3.0': part1='010' No newline at end of file |
|
497 | if lu[i-1]=='3.0': part1='010' | |
418 | if lu[i-1]=='0.0': part1='011' No newline at end of file |
|
498 | if lu[i-1]=='0.0': part1='011' | |
419 | if lu[i-1]=='0.5': part1='100' No newline at end of file |
|
499 | if lu[i-1]=='0.5': part1='100' | |
420 | if lu[i-1]=='1.5': part1='101' No newline at end of file |
|
500 | if lu[i-1]=='1.5': part1='101' | |
421 | if lu[i-1]=='2.5': part1='110' No newline at end of file |
|
501 | if lu[i-1]=='2.5': part1='110' | |
422 | if lu[i-1]=='3.5': part1='111' No newline at end of file |
|
502 | if lu[i-1]=='3.5': part1='111' | |
423 | if ld[i-1]=='1.0': part2='000' No newline at end of file |
|
503 | if ld[i-1]=='1.0': part2='000' | |
424 | if ld[i-1]=='2.0': part2='001' No newline at end of file |
|
504 | if ld[i-1]=='2.0': part2='001' | |
425 | if ld[i-1]=='3.0': part2='010' No newline at end of file |
|
505 | if ld[i-1]=='3.0': part2='010' | |
426 | if ld[i-1]=='0.0': part2='011' No newline at end of file |
|
506 | if ld[i-1]=='0.0': part2='011' | |
427 | if ld[i-1]=='0.5': part2='100' No newline at end of file |
|
507 | if ld[i-1]=='0.5': part2='100' | |
428 | if ld[i-1]=='1.5': part2='101' No newline at end of file |
|
508 | if ld[i-1]=='1.5': part2='101' | |
429 | if ld[i-1]=='2.5': part2='110' No newline at end of file |
|
509 | if ld[i-1]=='2.5': part2='110' | |
430 | if ld[i-1]=='3.5': part2='111' No newline at end of file |
|
510 | if ld[i-1]=='3.5': part2='111' | |
431 | fichero.write(part1+part2+'\n') No newline at end of file |
|
511 | fichero.write(part1+part2+'\n') | |
432 | fichero.write('------'+'\n') No newline at end of file |
|
512 | fichero.write('------'+'\n') | |
433 | fichero.close() No newline at end of file |
|
513 | fichero.close() | |
434 | No newline at end of file |
|
514 | ||
435 | def EliminaArchivosEnLaCarpeta(self, path, filename): No newline at end of file |
|
515 | def EliminaArchivosEnLaCarpeta(self, path, filename): | |
436 | ne=self.NumeroDeExperimentos(filename) No newline at end of file |
|
516 | ne=self.NumeroDeExperimentos(filename) | |
437 | for i in range(1,ne+1): No newline at end of file |
|
517 | for i in range(1,ne+1): | |
438 | os.remove(path + str(i)+'.txt') No newline at end of file |
|
518 | os.remove(path + str(i)+'.txt') | |
439 | No newline at end of file |
|
519 | ||
440 | No newline at end of file |
|
520 | ||
441 | def toCentralControlFormat(self, filename): No newline at end of file |
|
521 | def toCentralControlFormat(self, filename): | |
442 | """ Funcion que genera un archivo para el control central""" No newline at end of file |
|
522 | """ Funcion que genera un archivo para el control central""" | |
443 | No newline at end of file |
|
523 | ||
444 | path = os.getcwd() + '/' No newline at end of file |
|
524 | path = os.getcwd() + '/' | |
445 | self.CreaFicherosPrevios(path, filename) No newline at end of file |
|
525 | self.CreaFicherosPrevios(path, filename) | |
446 | self.CreaFormatoFinal(path, filename) No newline at end of file |
|
526 | self.CreaFormatoFinal(path, filename) | |
447 | self.EliminaArchivosEnLaCarpeta(path, filename) No newline at end of file |
|
527 | self.EliminaArchivosEnLaCarpeta(path, filename) |
@@ -1,186 +1,186 | |||||
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 | No newline at end of file |
|
6 | ||
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 |
|
7 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.117", portDestino=7000, ipDestino2="192.168.1.11", portDestino2=5500): | |
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" No newline at end of file |
|
16 | self.tx_buffer = "default" | |
17 | self.rx_buffer = "default" No newline at end of file |
|
17 | self.rx_buffer = "default" | |
18 | self.enaModules = [] No newline at end of file |
|
18 | self.enaModules = [] | |
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 |
|
24 | asServer = True | |
No newline at end of file |
|
25 | self.commServerObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino, "CnMod01", self.portDestino, asServer) | ||
25 | self.commServerObj = library3.TCPComm("Central_Control", self.ipDestino, self.portDestino, asServer) |
|
No newline at end of file | ||
No newline at end of file |
|
26 | self.commClientObj = library3.TCPComm("Central_Control", "CeCnMod", self.ipDestino2, "CnMod01", self.portDestino2) No newline at end of file | ||
26 | self.commClientObj = library3.TCPComm("Central_Control", self.ipDestino2, self.portDestino2) No newline at end of file |
|
|||
27 | No newline at end of file |
|
27 | ||
28 | def waitRequest(self): No newline at end of file |
|
28 | def waitRequest(self): | |
29 | No newline at end of file |
|
29 | ||
30 | #Using rx buffer No newline at end of file |
|
30 | #Using rx buffer | |
31 | ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() No newline at end of file |
|
31 | ipSource, ipDestino, cmd, self.rx_buffer = self.commServerObj.waitData() | |
32 | No newline at end of file |
|
32 | ||
33 | if cmd == "SNDF": No newline at end of file |
|
33 | if cmd == "SNDF": | |
34 | datarpta = self.__sendFile2Modules(cmd = cmd) No newline at end of file |
|
34 | datarpta = self.__sendFile2Modules(cmd = cmd) | |
35 | No newline at end of file |
|
35 | ||
36 | if cmd == "CHGB": No newline at end of file |
|
36 | if cmd == "CHGB": | |
37 | datarpta = self.__changeBeam(cmd = cmd) No newline at end of file |
|
37 | datarpta = self.__changeBeam(cmd = cmd) | |
38 | No newline at end of file |
|
38 | ||
39 | if cmd == "ANST": No newline at end of file |
|
39 | if cmd == "ANST": | |
40 | self.__getControlModuleStatus(cmd = cmd) No newline at end of file |
|
40 | self.__getControlModuleStatus(cmd = cmd) | |
41 | #Using tx buffer No newline at end of file |
|
41 | #Using tx buffer | |
42 | datarpta = self.tx_buffer No newline at end of file |
|
42 | datarpta = self.tx_buffer | |
43 | No newline at end of file |
|
43 | ||
44 | if cmd == "NTST": No newline at end of file |
|
44 | if cmd == "NTST": | |
45 | self.enaModules = self.__getConnectionStatus() No newline at end of file |
|
45 | self.enaModules = self.__getConnectionStatus() | |
46 | #Using tx buffer No newline at end of file |
|
46 | #Using tx buffer | |
47 | datarpta = self.enaModules No newline at end of file |
|
47 | datarpta = self.enaModules | |
48 | No newline at end of file |
|
48 | ||
49 | 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) | |
50 | No newline at end of file |
|
50 | ||
51 | def checkModule(self, address): No newline at end of file |
|
51 | def checkModule(self, address): | |
52 | No newline at end of file |
|
52 | ||
53 | 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" | |
54 | status = os.system(cmd) No newline at end of file |
|
54 | status = os.system(cmd) | |
55 | No newline at end of file |
|
55 | ||
56 | if status == 256: No newline at end of file |
|
56 | if status == 256: | |
57 | return False No newline at end of file |
|
57 | return False | |
58 | No newline at end of file |
|
58 | ||
59 | return True No newline at end of file |
|
59 | return True | |
60 | No newline at end of file |
|
60 | ||
61 | def __writeReport(self, enaModules): No newline at end of file |
|
61 | def __writeReport(self, enaModules): | |
62 | No newline at end of file |
|
62 | ||
63 | status_array = ["Status of modules\n"] No newline at end of file |
|
63 | status_array = ["Status of modules\n"] | |
64 | status_array.append("----------------\n") No newline at end of file |
|
64 | status_array.append("----------------\n") | |
65 | No newline at end of file |
|
65 | ||
66 | for address in range(1,65): No newline at end of file |
|
66 | for address in range(1,65): | |
67 | if address in enaModules: No newline at end of file |
|
67 | if address in enaModules: | |
68 | 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") | |
69 | else: No newline at end of file |
|
69 | else: | |
70 | 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") | |
71 | No newline at end of file |
|
71 | ||
72 | f = open("module_status.txt","w") No newline at end of file |
|
72 | f = open("module_status.txt","w") | |
73 | f.writelines(status_array) No newline at end of file |
|
73 | f.writelines(status_array) | |
74 | f.close() No newline at end of file |
|
74 | f.close() | |
75 | No newline at end of file |
|
75 | ||
76 | def checkAntenna(self): No newline at end of file |
|
76 | def checkAntenna(self): | |
77 | No newline at end of file |
|
77 | ||
78 | """ No newline at end of file |
|
78 | """ | |
79 | Direccion de los modulos de las antenas: No newline at end of file |
|
79 | Direccion de los modulos de las antenas: | |
80 | No newline at end of file |
|
80 | ||
81 | Norte : 01-16 No newline at end of file |
|
81 | Norte : 01-16 | |
82 | Este : 17-32 No newline at end of file |
|
82 | Este : 17-32 | |
83 | Oeste: : 33-48 No newline at end of file |
|
83 | Oeste: : 33-48 | |
84 | Sur : 49-64 No newline at end of file |
|
84 | Sur : 49-64 | |
85 | No newline at end of file |
|
85 | ||
86 | """ No newline at end of file |
|
86 | """ | |
87 | No newline at end of file |
|
87 | ||
88 | enaModules2 = [] No newline at end of file |
|
88 | enaModules2 = [] | |
89 | No newline at end of file |
|
89 | ||
90 | for address in range(1,65): No newline at end of file |
|
90 | for address in range(1,65): | |
91 | if self.checkModule(address): No newline at end of file |
|
91 | if self.checkModule(address): | |
92 | enaModules2.append(address) No newline at end of file |
|
92 | enaModules2.append(address) | |
93 | No newline at end of file |
|
93 | ||
94 | self.__writeReport(enaModules2) No newline at end of file |
|
94 | self.__writeReport(enaModules2) | |
95 | return enaModules2 No newline at end of file |
|
95 | return enaModules2 | |
96 | No newline at end of file |
|
96 | ||
97 | def __ConnectionWithControlModules(self,data,cmd,id): No newline at end of file |
|
97 | def __ConnectionWithControlModules(self,data,cmd,id): | |
98 | No newline at end of file |
|
98 | ||
99 | self.commClientObj.open_socket() No newline at end of file |
|
99 | self.commClientObj.open_socket() | |
100 | ip = "192.168.1." + str(id) No newline at end of file |
|
100 | ip = "192.168.1." + str(id) | |
101 | self.commClientObj.sendData(cmd, data, ip) No newline at end of file |
|
101 | self.commClientObj.sendData(cmd, data, ip) | |
102 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() No newline at end of file |
|
102 | ipSource, ipDestino, cmd, tmp = self.commClientObj.waitData() | |
103 | self.commClientObj.close_socket() No newline at end of file |
|
103 | self.commClientObj.close_socket() | |
104 | No newline at end of file |
|
104 | ||
105 | return tmp No newline at end of file |
|
105 | return tmp | |
106 | No newline at end of file |
|
106 | ||
107 | def __All2Blocks(self,input): No newline at end of file |
|
107 | def __All2Blocks(self,input): | |
108 | No newline at end of file |
|
108 | ||
109 | rx_frame_lst = input.split('\n',2) No newline at end of file |
|
109 | rx_frame_lst = input.split('\n',2) | |
110 | No newline at end of file |
|
110 | ||
111 | header = rx_frame_lst[0] + "\n" No newline at end of file |
|
111 | header = rx_frame_lst[0] + "\n" | |
112 | control_modules_str = rx_frame_lst[2] No newline at end of file |
|
112 | control_modules_str = rx_frame_lst[2] | |
113 | control_modules_lst = control_modules_str.split("------\n") No newline at end of file |
|
113 | control_modules_lst = control_modules_str.split("------\n") | |
114 | No newline at end of file |
|
114 | ||
115 | return header, control_modules_lst No newline at end of file |
|
115 | return header, control_modules_lst | |
116 | No newline at end of file |
|
116 | ||
117 | No newline at end of file |
|
117 | ||
118 | def __sendFile2Modules(self,cmd): No newline at end of file |
|
118 | def __sendFile2Modules(self,cmd): | |
119 | No newline at end of file |
|
119 | ||
120 | #Needed for the loop No newline at end of file |
|
120 | #Needed for the loop | |
121 | 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) | |
122 | correct = 0 No newline at end of file |
|
122 | correct = 0 | |
123 | No newline at end of file |
|
123 | ||
124 | for id in range(1,65): No newline at end of file |
|
124 | for id in range(1,65): | |
125 | No newline at end of file |
|
125 | ||
126 | if id not in self.enaModules: No newline at end of file |
|
126 | if id not in self.enaModules: | |
127 | continue No newline at end of file |
|
127 | continue | |
128 | No newline at end of file |
|
128 | ||
129 | 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": | |
130 | correct = correct + 1 No newline at end of file |
|
130 | correct = correct + 1 | |
131 | No newline at end of file |
|
131 | ||
132 | if correct == len(self.enaModules): No newline at end of file |
|
132 | if correct == len(self.enaModules): | |
133 | rpta = "OK" No newline at end of file |
|
133 | rpta = "OK" | |
134 | else: No newline at end of file |
|
134 | else: | |
135 | rpta = "Failure" No newline at end of file |
|
135 | rpta = "Failure" | |
136 | No newline at end of file |
|
136 | ||
137 | return rpta No newline at end of file |
|
137 | return rpta | |
138 | No newline at end of file |
|
138 | ||
139 | def __changeBeam(self, cmd): No newline at end of file |
|
139 | def __changeBeam(self, cmd): | |
140 | No newline at end of file |
|
140 | ||
141 | correct = 0 No newline at end of file |
|
141 | correct = 0 | |
142 | # enaModules = self.checkAntenna() No newline at end of file |
|
142 | # enaModules = self.checkAntenna() | |
143 | # enaModules = [11,12,13,14] No newline at end of file |
|
143 | # enaModules = [11,12,13,14] | |
144 | No newline at end of file |
|
144 | ||
145 | for id in range(1,65): No newline at end of file |
|
145 | for id in range(1,65): | |
146 | if id not in self.enaModules: No newline at end of file |
|
146 | if id not in self.enaModules: | |
147 | continue No newline at end of file |
|
147 | continue | |
148 | No newline at end of file |
|
148 | ||
149 | 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": | |
150 | correct = correct + 1 No newline at end of file |
|
150 | correct = correct + 1 | |
151 | No newline at end of file |
|
151 | ||
152 | if correct == len(self.enaModules): No newline at end of file |
|
152 | if correct == len(self.enaModules): | |
153 | rpta = "OK" No newline at end of file |
|
153 | rpta = "OK" | |
154 | else: No newline at end of file |
|
154 | else: | |
155 | rpta = "Failure" No newline at end of file |
|
155 | rpta = "Failure" | |
156 | No newline at end of file |
|
156 | ||
157 | return rpta No newline at end of file |
|
157 | return rpta | |
158 | No newline at end of file |
|
158 | ||
159 | def __getControlModuleStatus(self, cmd): No newline at end of file |
|
159 | def __getControlModuleStatus(self, cmd): | |
160 | No newline at end of file |
|
160 | ||
161 | all_blocks = "" No newline at end of file |
|
161 | all_blocks = "" | |
162 | # enaModules = self.checkAntenna() No newline at end of file |
|
162 | # enaModules = self.checkAntenna() | |
163 | # enaModules = [11,12,13,14] No newline at end of file |
|
163 | # enaModules = [11,12,13,14] | |
164 | No newline at end of file |
|
164 | ||
165 | for id in range(1,65): No newline at end of file |
|
165 | for id in range(1,65): | |
166 | if id not in self.enaModules: No newline at end of file |
|
166 | if id not in self.enaModules: | |
167 | continue No newline at end of file |
|
167 | continue | |
168 | No newline at end of file |
|
168 | ||
169 | 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) | |
170 | No newline at end of file |
|
170 | ||
171 | all_blocks = all_blocks + one_block No newline at end of file |
|
171 | all_blocks = all_blocks + one_block | |
172 | #Using tx buffer No newline at end of file |
|
172 | #Using tx buffer | |
173 | self.tx_buffer = all_blocks No newline at end of file |
|
173 | self.tx_buffer = all_blocks | |
174 | No newline at end of file |
|
174 | ||
175 | def __getConnectionStatus(self): No newline at end of file |
|
175 | def __getConnectionStatus(self): | |
176 | No newline at end of file |
|
176 | ||
177 | enaModules = self.checkAntenna() No newline at end of file |
|
177 | enaModules = self.checkAntenna() | |
178 | No newline at end of file |
|
178 | ||
179 | return enaModules No newline at end of file |
|
179 | return enaModules | |
180 | No newline at end of file |
|
180 | ||
181 | if __name__ == '__main__': No newline at end of file |
|
181 | if __name__ == '__main__': | |
182 | No newline at end of file |
|
182 | ||
183 | absObj = ABSServer() No newline at end of file |
|
183 | absObj = ABSServer() | |
184 | No newline at end of file |
|
184 | ||
185 | while 1: No newline at end of file |
|
185 | while 1: | |
186 | absObj.waitRequest() No newline at end of file |
|
186 | absObj.waitRequest() |
General Comments 0
You need to be logged in to leave comments.
Login now