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