##// END OF EJS Templates
Monitoring test
imanay -
r259:260
parent child
Show More
@@ -1,548 +1,549
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 No newline at end of file
11
12 def __init__(self, ipSource, iDSource, ipDestino, iDDestino, portDestino, asServer=False): No newline at end of file
12 def __init__(self, ipSource, iDSource, ipDestino, iDDestino, portDestino, asServer=False):
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.iDSource = iDSource
16 self.ipDestino = ipDestino No newline at end of file
16 self.ipDestino = ipDestino
17 self.iDDestino = iDDestino No newline at end of file
17 self.iDDestino = iDDestino
18 self.portDestino = portDestino No newline at end of file
18 self.portDestino = portDestino
19 self.addr = (ipDestino,portDestino) No newline at end of file
19 self.addr = (ipDestino,portDestino)
20 No newline at end of file
20
21 self.sc = "none" No newline at end of file
21 self.sc = "none"
22 self.answer = "none" #test No newline at end of file
22 self.answer = "none" #test
23 self.asServer = False No newline at end of file
23 self.asServer = False
24 self.len = "000000" No newline at end of file
24 self.len = "000000"
25 self.crc = "0" No newline at end of file
25 self.crc = "0"
26 No newline at end of file
26
27 self.openSocket(asServer) No newline at end of file
27 self.openSocket(asServer)
28 No newline at end of file
28
29 def openSocket(self, asServer): No newline at end of file
29 def openSocket(self, asServer):
30 No newline at end of file
30
31 #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)
32 # self.socket_c = socket.socket() No newline at end of file
32 # self.socket_c = socket.socket()
33 # self.socket_c.connect((self.ipDestino, self.portDestino)) No newline at end of file
33 # self.socket_c.connect((self.ipDestino, self.portDestino))
34 No newline at end of file
34
35 if asServer: No newline at end of file
35 if asServer:
36 self.socket_c = socket.socket() No newline at end of file
36 self.socket_c = socket.socket()
37 # self.configAsServer() No newline at end of file
37 # self.configAsServer()
38 self.socket_c.bind(self.addr) No newline at end of file
38 self.socket_c.bind(self.addr)
39 self.asServer = True No newline at end of file
39 self.asServer = True
40 else: No newline at end of file
40 else:
41 # self.configAsClient() No newline at end of file
41 # self.configAsClient()
42 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
43 No newline at end of file
43
44 # def configAsClient(self): No newline at end of file
44 # def configAsClient(self):
45 #Buscar broadcast TCP No newline at end of file
45 #Buscar broadcast TCP
46 # 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)
47 # self.socket_c.connect(self.addr) No newline at end of file
47 # self.socket_c.connect(self.addr)
48 # pass No newline at end of file
48 # pass
49 No newline at end of file
49
50 # def configAsServer(self): No newline at end of file
50 # def configAsServer(self):
51 # No newline at end of file
51 #
52 # self.socket_c.bind(self.addr) No newline at end of file
52 # self.socket_c.bind(self.addr)
53 No newline at end of file
53
54 def waitData(self): No newline at end of file
54 def waitData(self):
55 if self.asServer == True: No newline at end of file
55 if self.asServer == True:
56 trama_rx, l = self.waitAsServer() No newline at end of file
56 trama_rx, l = self.waitAsServer()
57 else: No newline at end of file
57 else:
58 trama_rx, l = self.waitAsClient() No newline at end of file
58 trama_rx, l = self.waitAsClient()
59 No newline at end of file
59
60 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx, l) No newline at end of file
60 ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx, l)
61 No newline at end of file
61
62 return ipSource, ipDestino, cmd, data No newline at end of file
62 return ipSource, ipDestino, cmd, data
63 No newline at end of file
63
64 def waitAsClient2(self, nbytes = 1024): No newline at end of file
64 def waitAsClient2(self, nbytes = 1024):
65 print "\nWaiting the server." No newline at end of file
65 print "\nWaiting the server."
66 # Short data through ethernet No newline at end of file
66 # Short data through ethernet
67 trama_rx = self.socket_c.recv(nbytes) No newline at end of file
67 trama_rx = self.socket_c.recv(nbytes)
68 print "\nThis socket has received this data: " + str(trama_rx) No newline at end of file
68 print "\nThis socket has received this data: " + str(trama_rx)
69 No newline at end of file
69
70 return trama_rx No newline at end of file
70 return trama_rx
71 No newline at end of file
71
72 def waitAsServer2(self, nbytes = 1024): No newline at end of file
72 def waitAsServer2(self, nbytes = 1024):
73 print "\nWaiting some client." No newline at end of file
73 print "\nWaiting some client."
74 self.socket_c.listen(1) No newline at end of file
74 self.socket_c.listen(1)
75 sc, addr = self.socket_c.accept() No newline at end of file
75 sc, addr = self.socket_c.accept()
76 self.sc = sc No newline at end of file
76 self.sc = sc
77 self.answer = addr No newline at end of file
77 self.answer = addr
78 # Big data through ethernet No newline at end of file
78 # Big data through ethernet
79 trama_rx = "" No newline at end of file
79 trama_rx = ""
80 while True: No newline at end of file
80 while True:
81 tmp = self.sc.recv(nbytes) No newline at end of file
81 tmp = self.sc.recv(nbytes)
82 trama_rx = trama_rx + tmp No newline at end of file
82 trama_rx = trama_rx + tmp
83 if trama_rx[-4:] == "quit": No newline at end of file
83 if trama_rx[-4:] == "quit":
84 break No newline at end of file
84 break
85 No newline at end of file
85
86 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)
87 No newline at end of file
87
88 return trama_rx No newline at end of file
88 return trama_rx
89 No newline at end of file
89
90 def waitAsServer(self, nbytes = 1024): No newline at end of file
90 def waitAsServer(self, nbytes = 1024):
91 print "\nWaiting some client." No newline at end of file
91 print "\nWaiting some client."
92 self.socket_c.listen(1) No newline at end of file
92 self.socket_c.listen(1)
93 sc, addr = self.socket_c.accept() No newline at end of file
93 sc, addr = self.socket_c.accept()
94 self.sc = sc No newline at end of file
94 self.sc = sc
95 self.answer = addr No newline at end of file
95 self.answer = addr
96 # Big data through ethernet No newline at end of file
96 # Big data through ethernet
97 cnt = 0; No newline at end of file
97 cnt = 0;
98 first = 0; No newline at end of file
98 first = 0;
99 trama_rx = "" No newline at end of file
99 trama_rx = ""
100 while True: No newline at end of file
100 while True:
101 tmp = self.sc.recv(nbytes) No newline at end of file
101 tmp = self.sc.recv(nbytes)
102 trama_rx = trama_rx + tmp No newline at end of file
102 trama_rx = trama_rx + tmp
103 cnt = len(trama_rx) No newline at end of file
103 cnt = len(trama_rx)
104 if first == 0: No newline at end of file
104 if first == 0:
105 first = 1 No newline at end of file
105 first = 1
106 lng = int(trama_rx[20:26]) No newline at end of file
106 lng = int(trama_rx[20:26])
107 frm_lng= lng + 31 # 31 bytes are fixed and added to the data size to get the frame size No newline at end of file
107 frm_lng= lng + 31 # 31 bytes are fixed and added to the data size to get the frame size
108 if cnt == frm_lng: No newline at end of file
108 if cnt == frm_lng:
109 break No newline at end of file
109 break
110 No newline at end of file
110
111 print "\nThis socket has received some data from: " + str(self.answer) No newline at end of file
111 print "\nThis socket has received some data from: " + str(self.answer)
112 print trama_rx No newline at end of file
112 No newline at end of file
113
113 return trama_rx, lng No newline at end of file
114 return trama_rx, lng
114 No newline at end of file
115
115 def waitAsClient(self, nbytes = 2048): No newline at end of file
116 def waitAsClient(self, nbytes = 2048):
116 print "\nWaiting the server." No newline at end of file
117 print "\nWaiting the server."
117 # Short data through ethernet No newline at end of file
118 # Short data through ethernet
118 try: No newline at end of file
119 try:
119 trama_rx = self.socket_c.recv(nbytes) No newline at end of file
120 trama_rx = self.socket_c.recv(nbytes)
120 lng = int(trama_rx[20:26]) No newline at end of file
121 lng = int(trama_rx[20:26])
121 except: No newline at end of file
122 except:
122 print "Waiting error" No newline at end of file
123 print "Waiting error"
123 trama_rx = "Error" No newline at end of file
124 trama_rx = "Error"
124 lng = 0 No newline at end of file
125 lng = 0
125 else: No newline at end of file
126 else:
126 print "\nThis socket has received this data: " + str(trama_rx) No newline at end of file
127 print "\nThis socket has received this data: " + str(trama_rx)
127 No newline at end of file
128
128 return trama_rx, lng No newline at end of file
129 return trama_rx, lng
129 No newline at end of file
130
130 def sendData2(self, cmd, data, ipDestino): No newline at end of file
131 def sendData2(self, cmd, data, ipDestino):
131 No newline at end of file
132
132 trama_tx = self.__HEADER + ":" + self.__TYPE + ":" + str(self.ipSource) + ":" + str(ipDestino) + \ No newline at end of file
133 trama_tx = self.__HEADER + ":" + self.__TYPE + ":" + str(self.ipSource) + ":" + str(ipDestino) + \
133 ":" + str(self.len) + ":" + str(cmd) + ":" + str(data) + ":" + str(self.crc) + ":" + "quit" No newline at end of file
134 ":" + str(self.len) + ":" + str(cmd) + ":" + str(data) + ":" + str(self.crc) + ":" + "quit"
134 No newline at end of file
135
135 if self.asServer == True: No newline at end of file
136 if self.asServer == True:
136 self.SendAsServer(trama_tx) No newline at end of file
137 self.SendAsServer(trama_tx)
137 else: No newline at end of file
138 else:
138 self.SendAsClient(ipDestino, trama_tx) No newline at end of file
139 self.SendAsClient(ipDestino, trama_tx)
139 No newline at end of file
140
140 def sendData(self, cmd, data, ipDestino): No newline at end of file
141 def sendData(self, cmd, data, ipDestino):
141 No newline at end of file
142
142 trama_tx = self.__HEADER + self.__TYPE + self.iDSource + \ No newline at end of file
143 trama_tx = self.__HEADER + self.__TYPE + self.iDSource + \
143 self.iDDestino + self.len + str(cmd) + str(data) + self.crc No newline at end of file
144 self.iDDestino + self.len + str(cmd) + str(data) + self.crc
144 No newline at end of file
145
145 self.len = self.int2str(len(data)) No newline at end of file
146 self.len = self.int2str(len(data))
146 No newline at end of file
147
147 trama_tx = self.__HEADER + self.__TYPE + self.iDSource + \ No newline at end of file
148 trama_tx = self.__HEADER + self.__TYPE + self.iDSource + \
148 self.iDDestino + self.len + str(cmd) + str(data) + self.crc No newline at end of file
149 self.iDDestino + self.len + str(cmd) + str(data) + self.crc
149 No newline at end of file
150
150 if self.asServer == True: No newline at end of file
151 if self.asServer == True:
151 self.SendAsServer(trama_tx) No newline at end of file
152 self.SendAsServer(trama_tx)
152 else: No newline at end of file
153 else:
153 self.SendAsClient(ipDestino, trama_tx) No newline at end of file
154 self.SendAsClient(ipDestino, trama_tx)
154 No newline at end of file
155
155 def SendAsServer(self, trama_tx): No newline at end of file
156 def SendAsServer(self, trama_tx):
156 No newline at end of file
157
157 self.sc.send(trama_tx) No newline at end of file
158 self.sc.send(trama_tx)
158 print "Sending message:[" + trama_tx + "] to: " + str(self.answer) No newline at end of file
159 print "Sending message:[" + trama_tx + "] to: " + str(self.answer)
159 No newline at end of file
160
160 No newline at end of file
161
161 def SendAsClient(self, ipDestino, trama_tx): No newline at end of file
162 def SendAsClient(self, ipDestino, trama_tx):
162 No newline at end of file
163
163 try: No newline at end of file
164 try:
164 self.socket_c.connect((ipDestino, self.portDestino)) No newline at end of file
165 self.socket_c.connect((ipDestino, self.portDestino))
165 except: No newline at end of file
166 except:
166 print "Connection error with:" + ipDestino No newline at end of file
167 print "Connection error with:" + ipDestino
167 else: No newline at end of file
168 else:
168 self.socket_c.send(trama_tx) No newline at end of file
169 self.socket_c.send(trama_tx)
169 print "Sending message:[" + trama_tx + "] to: " + ipDestino No newline at end of file
170 print "Sending message:[" + trama_tx + "] to: " + ipDestino
170 No newline at end of file
171
171 def __getTrama2(self, trama): No newline at end of file
172 def __getTrama2(self, trama):
172 No newline at end of file
173
173 FrameList = trama.split(':') No newline at end of file
174 FrameList = trama.split(':')
174 No newline at end of file
175
175 header = FrameList[0] No newline at end of file
176 header = FrameList[0]
176 TypeOfInstrument = FrameList[1] No newline at end of file
177 TypeOfInstrument = FrameList[1]
177 ipSource = FrameList[2] No newline at end of file
178 ipSource = FrameList[2]
178 ipDestino = FrameList[3] No newline at end of file
179 ipDestino = FrameList[3]
179 len = FrameList[4] No newline at end of file
180 len = FrameList[4]
180 cmd = FrameList[5] No newline at end of file
181 cmd = FrameList[5]
181 data = FrameList[6] No newline at end of file
182 data = FrameList[6]
182 crc = FrameList[7] No newline at end of file
183 crc = FrameList[7]
183 trash = FrameList[8] No newline at end of file
184 trash = FrameList[8]
184 No newline at end of file
185
185 return ipSource, ipDestino, cmd, data No newline at end of file
186 return ipSource, ipDestino, cmd, data
186 No newline at end of file
187
187 def __getTrama(self, trama, l): No newline at end of file
188 def __getTrama(self, trama, l):
188 No newline at end of file
189
189 header = trama[0:3] No newline at end of file
190 header = trama[0:3]
190 TypeOfInstrument = trama[3:6] No newline at end of file
191 TypeOfInstrument = trama[3:6]
191 ipSource = trama[6:13] No newline at end of file
192 ipSource = trama[6:13]
192 ipDestino = trama[13:20] No newline at end of file
193 ipDestino = trama[13:20]
193 len = trama[20:26] No newline at end of file
194 len = trama[20:26]
194 cmd = trama[26:30] No newline at end of file
195 cmd = trama[26:30]
195 data = trama[30:30+int(l)] No newline at end of file
196 data = trama[30:30+int(l)]
196 crc = trama[30+ int(l):] No newline at end of file
197 crc = trama[30+ int(l):]
197 No newline at end of file
198
198 return ipSource, ipDestino, cmd, data No newline at end of file
199 return ipSource, ipDestino, cmd, data
199 No newline at end of file
200
200 def close_socket(self): No newline at end of file
201 def close_socket(self):
201 self.socket_c.close() No newline at end of file
202 self.socket_c.close()
202 No newline at end of file
203
203 def open_socket(self): No newline at end of file
204 def open_socket(self):
204 self.socket_c = socket.socket() No newline at end of file
205 self.socket_c = socket.socket()
205 No newline at end of file
206
206 def int2str(self, n): No newline at end of file
207 def int2str(self, n):
207 No newline at end of file
208
208 str_n = str(n) No newline at end of file
209 str_n = str(n)
209 l_n = len(str_n) No newline at end of file
210 l_n = len(str_n)
210 if l_n == 1: No newline at end of file
211 if l_n == 1:
211 str_n = "00000" + str_n No newline at end of file
212 str_n = "00000" + str_n
212 elif l_n == 2: No newline at end of file
213 elif l_n == 2:
213 str_n = "0000" + str_n No newline at end of file
214 str_n = "0000" + str_n
214 elif l_n == 3: No newline at end of file
215 elif l_n == 3:
215 str_n = "000" + str_n No newline at end of file
216 str_n = "000" + str_n
216 elif l_n == 4: No newline at end of file
217 elif l_n == 4:
217 str_n = "00" + str_n No newline at end of file
218 str_n = "00" + str_n
218 elif l_n == 5: No newline at end of file
219 elif l_n == 5:
219 str_n = "0" + str_n No newline at end of file
220 str_n = "0" + str_n
220 return str_n No newline at end of file
221 return str_n
221 No newline at end of file
222
222 class FilesStuff(): No newline at end of file
223 class FilesStuff():
223 No newline at end of file
224
224 def lst2string(self, lst): No newline at end of file
225 def lst2string(self, lst):
225 string='' No newline at end of file
226 string=''
226 for i in lst: No newline at end of file
227 for i in lst:
227 string=string+i No newline at end of file
228 string=string+i
228 return string No newline at end of file
229 return string
229 No newline at end of file
230
230 def string2lst(self, string): No newline at end of file
231 def string2lst(self, string):
231 lst = [] No newline at end of file
232 lst = []
232 for i in string: No newline at end of file
233 for i in string:
233 lst.append(i) No newline at end of file
234 lst.append(i)
234 return lst No newline at end of file
235 return lst
235 No newline at end of file
236
236 No newline at end of file
237
237 def file1(self, filename, type): No newline at end of file
238 def file1(self, filename, type):
238 lst = self.string2lst(filename) No newline at end of file
239 lst = self.string2lst(filename)
239 fin = -1 No newline at end of file
240 fin = -1
240 t = len(lst) No newline at end of file
241 t = len(lst)
241 for i in np.arange(-1,-t,-1): No newline at end of file
242 for i in np.arange(-1,-t,-1):
242 if lst[i]=='/': No newline at end of file
243 if lst[i]=='/':
243 fin=i No newline at end of file
244 fin=i
244 break No newline at end of file
245 break
245 if type == '1': No newline at end of file
246 if type == '1':
246 nombre2 = lst[fin+1:] No newline at end of file
247 nombre2 = lst[fin+1:]
247 nombre2[-1]='s' No newline at end of file
248 nombre2[-1]='s'
248 nombre2 = self.lst2string(nombre2) No newline at end of file
249 nombre2 = self.lst2string(nombre2)
249 return nombre2 No newline at end of file
250 return nombre2
250 if type == '2': No newline at end of file
251 if type == '2':
251 nombre2 = lst[fin+1:] No newline at end of file
252 nombre2 = lst[fin+1:]
252 nombre2[-1]='1' No newline at end of file
253 nombre2[-1]='1'
253 nombre2 = self.lst2string(nombre2) No newline at end of file
254 nombre2 = self.lst2string(nombre2)
254 return nombre2 No newline at end of file
255 return nombre2
255 No newline at end of file
256
256 No newline at end of file
257
257 def EliminaSaltoDeLinea(self,cadena): No newline at end of file
258 def EliminaSaltoDeLinea(self,cadena):
258 i = 0 No newline at end of file
259 i = 0
259 for elemento in cadena: No newline at end of file
260 for elemento in cadena:
260 if elemento =='\n' or elemento =='\r': No newline at end of file
261 if elemento =='\n' or elemento =='\r':
261 pass No newline at end of file
262 pass
262 else: No newline at end of file
263 else:
263 i=i+1 No newline at end of file
264 i=i+1
264 return cadena [:i] No newline at end of file
265 return cadena [:i]
265 No newline at end of file
266
266 def NumeroDeExperimentos(self, path): No newline at end of file
267 def NumeroDeExperimentos(self, path):
267 fichero1=open(path,'r') No newline at end of file
268 fichero1=open(path,'r')
268 cont=0 No newline at end of file
269 cont=0
269 for cadena in fichero1: No newline at end of file
270 for cadena in fichero1:
270 cont=cont+1 No newline at end of file
271 cont=cont+1
271 if cont==3: No newline at end of file
272 if cont==3:
272 nexp='' No newline at end of file
273 nexp=''
273 pos=0 No newline at end of file
274 pos=0
274 for elemento in cadena: No newline at end of file
275 for elemento in cadena:
275 pos=pos+1 No newline at end of file
276 pos=pos+1
276 if elemento=='=': No newline at end of file
277 if elemento=='=':
277 nexp=int(cadena[pos:]) No newline at end of file
278 nexp=int(cadena[pos:])
278 return nexp No newline at end of file
279 return nexp
279 fichero1.close() No newline at end of file
280 fichero1.close()
280 No newline at end of file
281
281 def Paridad(self, numero): No newline at end of file
282 def Paridad(self, numero):
282 if numero%2==0: return 'par' No newline at end of file
283 if numero%2==0: return 'par'
283 elif numero%2==1: return 'impar' No newline at end of file
284 elif numero%2==1: return 'impar'
284 No newline at end of file
285
285 def EvaluaCadena(self,cadena): No newline at end of file
286 def EvaluaCadena(self,cadena):
286 if len(cadena)>35: No newline at end of file
287 if len(cadena)>35:
287 if cadena[-1]=='$': No newline at end of file
288 if cadena[-1]=='$':
288 return cadena[-35:-2] No newline at end of file
289 return cadena[-35:-2]
289 elif cadena[-1]==']': No newline at end of file
290 elif cadena[-1]==']':
290 return cadena[-34:-1] No newline at end of file
291 return cadena[-34:-1]
291 else: No newline at end of file
292 else:
292 return None No newline at end of file
293 return None
293 No newline at end of file
294
294 def GuardaEnLista(self,path): No newline at end of file
295 def GuardaEnLista(self,path):
295 fichero=open(path,'r') No newline at end of file
296 fichero=open(path,'r')
296 lista=[] No newline at end of file
297 lista=[]
297 for cadena in fichero: No newline at end of file
298 for cadena in fichero:
298 cadena = self.EliminaSaltoDeLinea(cadena) No newline at end of file
299 cadena = self.EliminaSaltoDeLinea(cadena)
299 cadena = self.EvaluaCadena(cadena) No newline at end of file
300 cadena = self.EvaluaCadena(cadena)
300 if cadena != None: No newline at end of file
301 if cadena != None:
301 lista.append(cadena) No newline at end of file
302 lista.append(cadena)
302 fichero.close() No newline at end of file
303 fichero.close()
303 return lista No newline at end of file
304 return lista
304 No newline at end of file
305
305 def CreaFicherosPrevios(self, path, archivo): No newline at end of file
306 def CreaFicherosPrevios(self, path, archivo):
306 vector = self.GuardaEnLista(archivo) No newline at end of file
307 vector = self.GuardaEnLista(archivo)
307 for i in range(1,self.NumeroDeExperimentos(archivo)+1): No newline at end of file
308 for i in range(1,self.NumeroDeExperimentos(archivo)+1):
308 fichero =open(path + str(i)+ '.txt','w') No newline at end of file
309 fichero =open(path + str(i)+ '.txt','w')
309 for j in range(0,16): No newline at end of file
310 for j in range(0,16):
310 fichero.write(vector[j+16*(i-1)]+'\n') No newline at end of file
311 fichero.write(vector[j+16*(i-1)]+'\n')
311 fichero.close() No newline at end of file
312 fichero.close()
312 No newline at end of file
313
313 def CapturaValoresEnArchivo(self, path, polarizacion='up'): No newline at end of file
314 def CapturaValoresEnArchivo(self, path, polarizacion='up'):
314 # No newline at end of file
315 #
315 # N01 N02 N03 N04 E01 E02 E03 E04 M01 M02 M03 M04 M05 M06 M07 M08 No newline at end of file
316 # N01 N02 N03 N04 E01 E02 E03 E04 M01 M02 M03 M04 M05 M06 M07 M08
316 # N05 N06 N07 N08 E05 E06 E07 E08 M09 M10 M11 M12 M13 M14 M15 M16 No newline at end of file
317 # N05 N06 N07 N08 E05 E06 E07 E08 M09 M10 M11 M12 M13 M14 M15 M16
317 # N09 N10 N11 N12 E09 E10 E11 E12 M17 M18 M19 M20 M21 M22 M23 M24 No newline at end of file
318 # N09 N10 N11 N12 E09 E10 E11 E12 M17 M18 M19 M20 M21 M22 M23 M24
318 # N13 N14 N15 N16 E13 E14 E15 E16 M25 M26 M27 M28 M29 M30 M31 M32 No newline at end of file
319 # N13 N14 N15 N16 E13 E14 E15 E16 M25 M26 M27 M28 M29 M30 M31 M32
319 # No newline at end of file
320 #
320 # W01 W02 W03 W04 S01 S02 S03 S04 M33 M34 M35 M36 M37 M38 M39 M40 No newline at end of file
321 # W01 W02 W03 W04 S01 S02 S03 S04 M33 M34 M35 M36 M37 M38 M39 M40
321 # W05 W06 W07 W08 S05 S06 S07 S08 M41 M42 M43 M44 M45 M46 M47 M48 No newline at end of file
322 # W05 W06 W07 W08 S05 S06 S07 S08 M41 M42 M43 M44 M45 M46 M47 M48
322 # W09 W10 W11 W12 S09 S10 S11 S12 M49 M50 M51 M52 M53 M54 M55 M56 No newline at end of file
323 # W09 W10 W11 W12 S09 S10 S11 S12 M49 M50 M51 M52 M53 M54 M55 M56
323 # W13 W14 W15 W16 S13 S14 S15 S16 M57 M58 M59 M60 M61 M62 M63 M64 No newline at end of file
324 # W13 W14 W15 W16 S13 S14 S15 S16 M57 M58 M59 M60 M61 M62 M63 M64
324 # No newline at end of file
325 #
325 fichero =open(path,'r') No newline at end of file
326 fichero =open(path,'r')
326 cnt=0 No newline at end of file
327 cnt=0
327 lstup=[] No newline at end of file
328 lstup=[]
328 lstdw=[] No newline at end of file
329 lstdw=[]
329 for cadena in fichero: No newline at end of file
330 for cadena in fichero:
330 cnt=cnt+1 No newline at end of file
331 cnt=cnt+1
331 if cnt==1: No newline at end of file
332 if cnt==1:
332 nu01=cadena[1:4] No newline at end of file
333 nu01=cadena[1:4]
333 nu02=cadena[5:8] No newline at end of file
334 nu02=cadena[5:8]
334 nu03=cadena[9:12] No newline at end of file
335 nu03=cadena[9:12]
335 nu04=cadena[13:16] No newline at end of file
336 nu04=cadena[13:16]
336 eu01=cadena[17:20] No newline at end of file
337 eu01=cadena[17:20]
337 eu02=cadena[21:24] No newline at end of file
338 eu02=cadena[21:24]
338 eu03=cadena[25:28] No newline at end of file
339 eu03=cadena[25:28]
339 eu04=cadena[29:32] No newline at end of file
340 eu04=cadena[29:32]
340 if cnt==2: No newline at end of file
341 if cnt==2:
341 nu05=cadena[1:4] No newline at end of file
342 nu05=cadena[1:4]
342 nu06=cadena[5:8] No newline at end of file
343 nu06=cadena[5:8]
343 nu07=cadena[9:12] No newline at end of file
344 nu07=cadena[9:12]
344 nu08=cadena[13:16] No newline at end of file
345 nu08=cadena[13:16]
345 eu05=cadena[17:20] No newline at end of file
346 eu05=cadena[17:20]
346 eu06=cadena[21:24] No newline at end of file
347 eu06=cadena[21:24]
347 eu07=cadena[25:28] No newline at end of file
348 eu07=cadena[25:28]
348 eu08=cadena[29:32] No newline at end of file
349 eu08=cadena[29:32]
349 if cnt==3: No newline at end of file
350 if cnt==3:
350 nu09=cadena[1:4] No newline at end of file
351 nu09=cadena[1:4]
351 nu10=cadena[5:8] No newline at end of file
352 nu10=cadena[5:8]
352 nu11=cadena[9:12] No newline at end of file
353 nu11=cadena[9:12]
353 nu12=cadena[13:16] No newline at end of file
354 nu12=cadena[13:16]
354 eu09=cadena[17:20] No newline at end of file
355 eu09=cadena[17:20]
355 eu10=cadena[21:24] No newline at end of file
356 eu10=cadena[21:24]
356 eu11=cadena[25:28] No newline at end of file
357 eu11=cadena[25:28]
357 eu12=cadena[29:32] No newline at end of file
358 eu12=cadena[29:32]
358 if cnt==4: No newline at end of file
359 if cnt==4:
359 nu13=cadena[1:4] No newline at end of file
360 nu13=cadena[1:4]
360 nu14=cadena[5:8] No newline at end of file
361 nu14=cadena[5:8]
361 nu15=cadena[9:12] No newline at end of file
362 nu15=cadena[9:12]
362 nu16=cadena[13:16] No newline at end of file
363 nu16=cadena[13:16]
363 eu13=cadena[17:20] No newline at end of file
364 eu13=cadena[17:20]
364 eu14=cadena[21:24] No newline at end of file
365 eu14=cadena[21:24]
365 eu15=cadena[25:28] No newline at end of file
366 eu15=cadena[25:28]
366 eu16=cadena[29:32] No newline at end of file
367 eu16=cadena[29:32]
367 if cnt==5: No newline at end of file
368 if cnt==5:
368 wu01=cadena[1:4] No newline at end of file
369 wu01=cadena[1:4]
369 wu02=cadena[5:8] No newline at end of file
370 wu02=cadena[5:8]
370 wu03=cadena[9:12] No newline at end of file
371 wu03=cadena[9:12]
371 wu04=cadena[13:16] No newline at end of file
372 wu04=cadena[13:16]
372 su01=cadena[17:20] No newline at end of file
373 su01=cadena[17:20]
373 su02=cadena[21:24] No newline at end of file
374 su02=cadena[21:24]
374 su03=cadena[25:28] No newline at end of file
375 su03=cadena[25:28]
375 su04=cadena[29:32] No newline at end of file
376 su04=cadena[29:32]
376 if cnt==6: No newline at end of file
377 if cnt==6:
377 wu05=cadena[1:4] No newline at end of file
378 wu05=cadena[1:4]
378 wu06=cadena[5:8] No newline at end of file
379 wu06=cadena[5:8]
379 wu07=cadena[9:12] No newline at end of file
380 wu07=cadena[9:12]
380 wu08=cadena[13:16] No newline at end of file
381 wu08=cadena[13:16]
381 su05=cadena[17:20] No newline at end of file
382 su05=cadena[17:20]
382 su06=cadena[21:24] No newline at end of file
383 su06=cadena[21:24]
383 su07=cadena[25:28] No newline at end of file
384 su07=cadena[25:28]
384 su08=cadena[29:32] No newline at end of file
385 su08=cadena[29:32]
385 if cnt==7: No newline at end of file
386 if cnt==7:
386 wu09=cadena[1:4] No newline at end of file
387 wu09=cadena[1:4]
387 wu10=cadena[5:8] No newline at end of file
388 wu10=cadena[5:8]
388 wu11=cadena[9:12] No newline at end of file
389 wu11=cadena[9:12]
389 wu12=cadena[13:16] No newline at end of file
390 wu12=cadena[13:16]
390 su09=cadena[17:20] No newline at end of file
391 su09=cadena[17:20]
391 su10=cadena[21:24] No newline at end of file
392 su10=cadena[21:24]
392 su11=cadena[25:28] No newline at end of file
393 su11=cadena[25:28]
393 su12=cadena[29:32] No newline at end of file
394 su12=cadena[29:32]
394 if cnt==8: No newline at end of file
395 if cnt==8:
395 wu13=cadena[1:4] No newline at end of file
396 wu13=cadena[1:4]
396 wu14=cadena[5:8] No newline at end of file
397 wu14=cadena[5:8]
397 wu15=cadena[9:12] No newline at end of file
398 wu15=cadena[9:12]
398 wu16=cadena[13:16] No newline at end of file
399 wu16=cadena[13:16]
399 su13=cadena[17:20] No newline at end of file
400 su13=cadena[17:20]
400 su14=cadena[21:24] No newline at end of file
401 su14=cadena[21:24]
401 su15=cadena[25:28] No newline at end of file
402 su15=cadena[25:28]
402 su16=cadena[29:32] No newline at end of file
403 su16=cadena[29:32]
403 if cnt==9: No newline at end of file
404 if cnt==9:
404 nd01=cadena[1:4] No newline at end of file
405 nd01=cadena[1:4]
405 nd02=cadena[5:8] No newline at end of file
406 nd02=cadena[5:8]
406 nd03=cadena[9:12] No newline at end of file
407 nd03=cadena[9:12]
407 nd04=cadena[13:16] No newline at end of file
408 nd04=cadena[13:16]
408 ed01=cadena[17:20] No newline at end of file
409 ed01=cadena[17:20]
409 ed02=cadena[21:24] No newline at end of file
410 ed02=cadena[21:24]
410 ed03=cadena[25:28] No newline at end of file
411 ed03=cadena[25:28]
411 ed04=cadena[29:32] No newline at end of file
412 ed04=cadena[29:32]
412 if cnt==10: No newline at end of file
413 if cnt==10:
413 nd05=cadena[1:4] No newline at end of file
414 nd05=cadena[1:4]
414 nd06=cadena[5:8] No newline at end of file
415 nd06=cadena[5:8]
415 nd07=cadena[9:12] No newline at end of file
416 nd07=cadena[9:12]
416 nd08=cadena[13:16] No newline at end of file
417 nd08=cadena[13:16]
417 ed05=cadena[17:20] No newline at end of file
418 ed05=cadena[17:20]
418 ed06=cadena[21:24] No newline at end of file
419 ed06=cadena[21:24]
419 ed07=cadena[25:28] No newline at end of file
420 ed07=cadena[25:28]
420 ed08=cadena[29:32] No newline at end of file
421 ed08=cadena[29:32]
421 if cnt==11: No newline at end of file
422 if cnt==11:
422 nd09=cadena[1:4] No newline at end of file
423 nd09=cadena[1:4]
423 nd10=cadena[5:8] No newline at end of file
424 nd10=cadena[5:8]
424 nd11=cadena[9:12] No newline at end of file
425 nd11=cadena[9:12]
425 nd12=cadena[13:16] No newline at end of file
426 nd12=cadena[13:16]
426 ed09=cadena[17:20] No newline at end of file
427 ed09=cadena[17:20]
427 ed10=cadena[21:24] No newline at end of file
428 ed10=cadena[21:24]
428 ed11=cadena[25:28] No newline at end of file
429 ed11=cadena[25:28]
429 ed12=cadena[29:32] No newline at end of file
430 ed12=cadena[29:32]
430 if cnt==12: No newline at end of file
431 if cnt==12:
431 nd13=cadena[1:4] No newline at end of file
432 nd13=cadena[1:4]
432 nd14=cadena[5:8] No newline at end of file
433 nd14=cadena[5:8]
433 nd15=cadena[9:12] No newline at end of file
434 nd15=cadena[9:12]
434 nd16=cadena[13:16] No newline at end of file
435 nd16=cadena[13:16]
435 ed13=cadena[17:20] No newline at end of file
436 ed13=cadena[17:20]
436 ed14=cadena[21:24] No newline at end of file
437 ed14=cadena[21:24]
437 ed15=cadena[25:28] No newline at end of file
438 ed15=cadena[25:28]
438 ed16=cadena[29:32] No newline at end of file
439 ed16=cadena[29:32]
439 if cnt==13: No newline at end of file
440 if cnt==13:
440 wd01=cadena[1:4] No newline at end of file
441 wd01=cadena[1:4]
441 wd02=cadena[5:8] No newline at end of file
442 wd02=cadena[5:8]
442 wd03=cadena[9:12] No newline at end of file
443 wd03=cadena[9:12]
443 wd04=cadena[13:16] No newline at end of file
444 wd04=cadena[13:16]
444 sd01=cadena[17:20] No newline at end of file
445 sd01=cadena[17:20]
445 sd02=cadena[21:24] No newline at end of file
446 sd02=cadena[21:24]
446 sd03=cadena[25:28] No newline at end of file
447 sd03=cadena[25:28]
447 sd04=cadena[29:32] No newline at end of file
448 sd04=cadena[29:32]
448 if cnt==14: No newline at end of file
449 if cnt==14:
449 wd05=cadena[1:4] No newline at end of file
450 wd05=cadena[1:4]
450 wd06=cadena[5:8] No newline at end of file
451 wd06=cadena[5:8]
451 wd07=cadena[9:12] No newline at end of file
452 wd07=cadena[9:12]
452 wd08=cadena[13:16] No newline at end of file
453 wd08=cadena[13:16]
453 sd05=cadena[17:20] No newline at end of file
454 sd05=cadena[17:20]
454 sd06=cadena[21:24] No newline at end of file
455 sd06=cadena[21:24]
455 sd07=cadena[25:28] No newline at end of file
456 sd07=cadena[25:28]
456 sd08=cadena[29:32] No newline at end of file
457 sd08=cadena[29:32]
457 if cnt==15: No newline at end of file
458 if cnt==15:
458 wd09=cadena[1:4] No newline at end of file
459 wd09=cadena[1:4]
459 wd10=cadena[5:8] No newline at end of file
460 wd10=cadena[5:8]
460 wd11=cadena[9:12] No newline at end of file
461 wd11=cadena[9:12]
461 wd12=cadena[13:16] No newline at end of file
462 wd12=cadena[13:16]
462 sd09=cadena[17:20] No newline at end of file
463 sd09=cadena[17:20]
463 sd10=cadena[21:24] No newline at end of file
464 sd10=cadena[21:24]
464 sd11=cadena[25:28] No newline at end of file
465 sd11=cadena[25:28]
465 sd12=cadena[29:32] No newline at end of file
466 sd12=cadena[29:32]
466 if cnt==16: No newline at end of file
467 if cnt==16:
467 wd13=cadena[1:4] No newline at end of file
468 wd13=cadena[1:4]
468 wd14=cadena[5:8] No newline at end of file
469 wd14=cadena[5:8]
469 wd15=cadena[9:12] No newline at end of file
470 wd15=cadena[9:12]
470 wd16=cadena[13:16] No newline at end of file
471 wd16=cadena[13:16]
471 sd13=cadena[17:20] No newline at end of file
472 sd13=cadena[17:20]
472 sd14=cadena[21:24] No newline at end of file
473 sd14=cadena[21:24]
473 sd15=cadena[25:28] No newline at end of file
474 sd15=cadena[25:28]
474 sd16=cadena[29:32] No newline at end of file
475 sd16=cadena[29:32]
475 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
476 blck_1_up = [nu01,nu02,nu03,nu04,eu01,eu02,eu03,eu04,nu05,nu06,nu07,nu08,eu05,eu06,eu07,eu08]
476 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
477 blck_1_dw = [nd01,nd02,nd03,nd04,ed01,ed02,ed03,ed04,nd05,nd06,nd07,nd08,ed05,ed06,ed07,ed08]
477 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
478 blck_2_up = [nu09,nu10,nu11,nu12,eu09,eu10,eu11,eu12,nu13,nu14,nu15,nu16,eu13,eu14,eu15,eu16]
478 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
479 blck_2_dw = [nd09,nd10,nd11,nd12,ed09,ed10,ed11,ed12,nd13,nd14,nd15,nd16,ed13,ed14,ed15,ed16]
479 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
480 blck_3_up = [wu01,wu02,wu03,wu04,su01,su02,su03,su04,wu05,wu06,wu07,wu08,su05,su06,su07,su08]
480 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
481 blck_3_dw = [wd01,wd02,wd03,wd04,sd01,sd02,sd03,sd04,wd05,wd06,wd07,wd08,sd05,sd06,sd07,sd08]
481 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
482 blck_4_up = [wu09,wu10,wu11,wu12,su09,su10,su11,su12,wu13,wu14,wu15,wu16,su13,su14,su15,su16]
482 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
483 blck_4_dw = [wd09,wd10,wd11,wd12,sd09,sd10,sd11,sd12,wd13,wd14,wd15,wd16,sd13,sd14,sd15,sd16]
483 No newline at end of file
484
484 lstup = blck_1_up + blck_2_up + blck_3_up + blck_4_up No newline at end of file
485 lstup = blck_1_up + blck_2_up + blck_3_up + blck_4_up
485 lstdw = blck_1_dw + blck_2_dw + blck_3_dw + blck_4_dw No newline at end of file
486 lstdw = blck_1_dw + blck_2_dw + blck_3_dw + blck_4_dw
486 No newline at end of file
487
487 if polarizacion=='up': No newline at end of file
488 if polarizacion=='up':
488 return lstup No newline at end of file
489 return lstup
489 elif polarizacion=='dw': No newline at end of file
490 elif polarizacion=='dw':
490 return lstdw No newline at end of file
491 return lstdw
491 fichero.close() No newline at end of file
492 fichero.close()
492 No newline at end of file
493
493 def CreaFormatoFinal(self, path, filename): No newline at end of file
494 def CreaFormatoFinal(self, path, filename):
494 ne=self.NumeroDeExperimentos(filename) No newline at end of file
495 ne=self.NumeroDeExperimentos(filename)
495 No newline at end of file
496
496 #nombre01 = file1(archivo,'1') No newline at end of file
497 #nombre01 = file1(archivo,'1')
497 nombre02 = self.file1(filename,'2') No newline at end of file
498 nombre02 = self.file1(filename,'2')
498 fichero=open(path + 'CentralControlFormat.txt','w') No newline at end of file
499 fichero=open(path + 'CentralControlFormat.txt','w')
499 fichero.write(nombre02+'\n') No newline at end of file
500 fichero.write(nombre02+'\n')
500 fichero.write(str(ne)+'\n') No newline at end of file
501 fichero.write(str(ne)+'\n')
501 No newline at end of file
502
502 for i in range(1,65): No newline at end of file
503 for i in range(1,65):
503 No newline at end of file
504
504 if i<10: No newline at end of file
505 if i<10:
505 nmod = '0'+str(i) No newline at end of file
506 nmod = '0'+str(i)
506 else: nmod = str(i) No newline at end of file
507 else: nmod = str(i)
507 No newline at end of file
508
508 fichero.write("ABS_" + nmod+'\n') No newline at end of file
509 fichero.write("ABS_" + nmod+'\n')
509 No newline at end of file
510
510 for j in range(1,ne+1): No newline at end of file
511 for j in range(1,ne+1):
511 ruta=path+str(j)+'.txt' No newline at end of file
512 ruta=path+str(j)+'.txt'
512 lu=self.CapturaValoresEnArchivo(ruta,polarizacion='up') No newline at end of file
513 lu=self.CapturaValoresEnArchivo(ruta,polarizacion='up')
513 ld=self.CapturaValoresEnArchivo(ruta,polarizacion='dw') No newline at end of file
514 ld=self.CapturaValoresEnArchivo(ruta,polarizacion='dw')
514 part1='' No newline at end of file
515 part1=''
515 part2='' No newline at end of file
516 part2=''
516 if lu[i-1]=='1.0': part1='000' No newline at end of file
517 if lu[i-1]=='1.0': part1='000'
517 if lu[i-1]=='2.0': part1='001' No newline at end of file
518 if lu[i-1]=='2.0': part1='001'
518 if lu[i-1]=='3.0': part1='010' No newline at end of file
519 if lu[i-1]=='3.0': part1='010'
519 if lu[i-1]=='0.0': part1='011' No newline at end of file
520 if lu[i-1]=='0.0': part1='011'
520 if lu[i-1]=='0.5': part1='100' No newline at end of file
521 if lu[i-1]=='0.5': part1='100'
521 if lu[i-1]=='1.5': part1='101' No newline at end of file
522 if lu[i-1]=='1.5': part1='101'
522 if lu[i-1]=='2.5': part1='110' No newline at end of file
523 if lu[i-1]=='2.5': part1='110'
523 if lu[i-1]=='3.5': part1='111' No newline at end of file
524 if lu[i-1]=='3.5': part1='111'
524 if ld[i-1]=='1.0': part2='000' No newline at end of file
525 if ld[i-1]=='1.0': part2='000'
525 if ld[i-1]=='2.0': part2='001' No newline at end of file
526 if ld[i-1]=='2.0': part2='001'
526 if ld[i-1]=='3.0': part2='010' No newline at end of file
527 if ld[i-1]=='3.0': part2='010'
527 if ld[i-1]=='0.0': part2='011' No newline at end of file
528 if ld[i-1]=='0.0': part2='011'
528 if ld[i-1]=='0.5': part2='100' No newline at end of file
529 if ld[i-1]=='0.5': part2='100'
529 if ld[i-1]=='1.5': part2='101' No newline at end of file
530 if ld[i-1]=='1.5': part2='101'
530 if ld[i-1]=='2.5': part2='110' No newline at end of file
531 if ld[i-1]=='2.5': part2='110'
531 if ld[i-1]=='3.5': part2='111' No newline at end of file
532 if ld[i-1]=='3.5': part2='111'
532 fichero.write(part1+part2+'\n') No newline at end of file
533 fichero.write(part1+part2+'\n')
533 fichero.write('------'+'\n') No newline at end of file
534 fichero.write('------'+'\n')
534 fichero.close() No newline at end of file
535 fichero.close()
535 No newline at end of file
536
536 def EliminaArchivosEnLaCarpeta(self, path, filename): No newline at end of file
537 def EliminaArchivosEnLaCarpeta(self, path, filename):
537 ne=self.NumeroDeExperimentos(filename) No newline at end of file
538 ne=self.NumeroDeExperimentos(filename)
538 for i in range(1,ne+1): No newline at end of file
539 for i in range(1,ne+1):
539 os.remove(path + str(i)+'.txt') No newline at end of file
540 os.remove(path + str(i)+'.txt')
540 No newline at end of file
541
541 No newline at end of file
542
542 def toCentralControlFormat(self, filename): No newline at end of file
543 def toCentralControlFormat(self, filename):
543 """ Funcion que genera un archivo para el control central""" No newline at end of file
544 """ Funcion que genera un archivo para el control central"""
544 No newline at end of file
545
545 path = os.getcwd() + '/' No newline at end of file
546 path = os.getcwd() + '/'
546 self.CreaFicherosPrevios(path, filename) No newline at end of file
547 self.CreaFicherosPrevios(path, filename)
547 self.CreaFormatoFinal(path, filename) No newline at end of file
548 self.CreaFormatoFinal(path, filename)
548 self.EliminaArchivosEnLaCarpeta(path, filename) No newline at end of file
549 self.EliminaArchivosEnLaCarpeta(path, filename)
General Comments 0
You need to be logged in to leave comments. Login now