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