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