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