@@ -0,0 +1,231 | |||
|
1 | title ='MST-ISR 2009 (NS-Up)' | |
|
2 | ||
|
3 | #Experiments = 12 | |
|
4 | ||
|
5 | 1 = | |
|
6 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
7 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
8 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
9 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
10 | [1.0,1.0,1.0,1.0,1.0,2.0,3.0,0.0],$ | |
|
11 | [0.5,0.5,0.5,1.0,3.0,2.0,1.0,0.0],$ | |
|
12 | [1.0,1.0,1.0,1.0,0.5,1.5,2.5,3.5],$ | |
|
13 | [0.5,0.5,0.5,0.5,2.5,1.5,0.5,0.0]] | |
|
14 | ||
|
15 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
16 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
17 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
18 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
19 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
20 | [0.5,0.5,0.5,1.0,1.0,1.0,1.0,1.0],$ | |
|
21 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
22 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]] | |
|
23 | ||
|
24 | 2 = | |
|
25 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
26 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
27 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
28 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
29 | [1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0],$ | |
|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0.5,0.5],$ | |
|
85 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
86 | [1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5],$ | |
|
87 | [0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5],$ | |
|
88 | [1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5],$ | |
|
89 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]] | |
|
90 | ||
|
91 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
92 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
93 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
94 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
95 | [1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5],$ | |
|
96 | [0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5],$ | |
|
97 | [1.0,1.0,1.0,1.0,0.5,0.5,0.5,0.5],$ | |
|
98 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]] | |
|
99 | ||
|
100 | 6= | |
|
101 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
102 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
103 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
104 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
105 | [1.0,1.0,1.0,1.0,1.5,1.5,1.5,1.5],$ | |
|
106 | [0.5,0.5,0.5,1.0,1.5,1.5,1.5,1.5],$ | |
|
107 | [1.0,1.0,1.0,1.0,1.5,1.5,1.5,1.5],$ | |
|
108 | [0.5,0.5,0.5,0.5,1.5,1.5,1.5,1.5]] | |
|
109 | ||
|
110 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
111 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
112 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
113 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
114 | [1.0,1.0,1.0,1.0,1.5,1.5,1.5,1.5],$ | |
|
115 | [0.5,0.5,0.5,1.0,1.5,1.5,1.5,1.5],$ | |
|
116 | [1.0,1.0,1.0,1.0,1.5,1.5,1.5,1.5],$ | |
|
117 | [0.5,0.5,0.5,0.5,1.5,1.5,1.5,1.5]] | |
|
118 | ||
|
119 | 7 = | |
|
120 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
121 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
122 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
123 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
124 | [1.0,1.0,1.0,1.0,2.5,2.5,2.5,2.5],$ | |
|
125 | [0.5,0.5,0.5,1.0,2.5,2.5,2.5,2.5],$ | |
|
126 | [1.0,1.0,1.0,1.0,2.5,2.5,2.5,2.5],$ | |
|
127 | [0.5,0.5,0.5,0.5,2.5,2.5,2.5,2.5]] | |
|
128 | ||
|
129 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
130 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
131 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
132 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
133 | [1.0,1.0,1.0,1.0,2.5,2.5,2.5,2.5],$ | |
|
134 | [0.5,0.5,0.5,1.0,2.5,2.5,2.5,2.5],$ | |
|
135 | [1.0,1.0,1.0,1.0,2.5,2.5,2.5,2.5],$ | |
|
136 | [0.5,0.5,0.5,0.5,2.5,2.5,2.5,2.5]] | |
|
137 | 8 = | |
|
No newline at end of file | ||
|
138 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
139 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
140 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
141 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
142 | [1.0,1.0,1.0,1.0,3.5,3.5,3.5,3.5],$ | |
|
143 | [0.5,0.5,0.5,1.0,3.5,3.5,3.5,3.5],$ | |
|
144 | [1.0,1.0,1.0,1.0,3.5,3.5,3.5,3.5],$ | |
|
145 | [0.5,0.5,0.5,0.5,3.5,3.5,3.5,3.5]] | |
|
146 | ||
|
147 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
148 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
149 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
150 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
151 | [1.0,1.0,1.0,1.0,3.5,3.5,3.5,3.5],$ | |
|
152 | [0.5,0.5,0.5,1.0,3.5,3.5,3.5,3.5],$ | |
|
153 | [1.0,1.0,1.0,1.0,3.5,3.5,3.5,3.5],$ | |
|
154 | [0.5,0.5,0.5,0.5,3.5,3.5,3.5,3.5]] | |
|
155 | ||
|
156 | 9 = | |
|
157 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
158 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
159 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
160 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
161 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
162 | [0.5,0.5,0.5,1.0,1.0,1.0,1.0,1.0],$ | |
|
163 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
164 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]] | |
|
165 | ||
|
166 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
167 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
168 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
169 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
170 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
171 | [0.5,0.5,0.5,1.0,1.0,1.0,1.0,1.0],$ | |
|
172 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
173 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]] | |
|
174 | ||
|
175 | 10 = | |
|
176 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
177 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
178 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
179 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
180 | [1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0],$ | |
|
181 | [0.5,0.5,0.5,1.0,2.0,2.0,2.0,2.0],$ | |
|
182 | [1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0],$ | |
|
183 | [0.5,0.5,0.5,0.5,2.0,2.0,2.0,2.0]] | |
|
184 | ||
|
185 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
186 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
187 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
188 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
189 | [1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0],$ | |
|
190 | [0.5,0.5,0.5,1.0,2.0,2.0,2.0,2.0],$ | |
|
191 | [1.0,1.0,1.0,1.0,2.0,2.0,2.0,2.0],$ | |
|
192 | [0.5,0.5,0.5,0.5,2.0,2.0,2.0,2.0]] | |
|
193 | ||
|
194 | 11 = | |
|
195 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
196 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
197 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
198 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
199 | [1.0,1.0,1.0,1.0,3.0,3.0,3.0,3.0],$ | |
|
200 | [0.5,0.5,0.5,1.0,3.0,3.0,3.0,3.0],$ | |
|
201 | [1.0,1.0,1.0,1.0,3.0,3.0,3.0,3.0],$ | |
|
202 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]] | |
|
203 | ||
|
204 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
205 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
206 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
207 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
208 | [1.0,1.0,1.0,1.0,3.0,3.0,3.0,3.0],$ | |
|
209 | [0.5,0.5,0.5,1.0,3.0,3.0,3.0,3.0],$ | |
|
210 | [1.0,1.0,1.0,1.0,3.0,3.0,3.0,3.0],$ | |
|
211 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]] | |
|
212 | ||
|
213 | 12 = | |
|
214 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
215 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
216 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
217 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
218 | [1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0],$ | |
|
219 | [0.5,0.5,0.5,1.0,0.0,0.0,0.0,0.0],$ | |
|
220 | [1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0],$ | |
|
221 | [0.5,0.5,0.5,0.5,0.0,0.0,0.0,0.0]] | |
|
222 | ||
|
223 | [[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
224 | [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0],$ | |
|
225 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
226 | [0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5],$ | |
|
227 | [1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0],$ | |
|
228 | [0.5,0.5,0.5,1.0,0.0,0.0,0.0,0.0],$ | |
|
229 | [1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0],$ | |
|
230 | [0.5,0.5,0.5,0.5,0.0,0.0,0.0,0.0]] | |
|
231 |
@@ -1,8 +1,14 | |||
|
1 | # imports needed for the file convertion | |
|
2 | import os | |
|
3 | import sys | |
|
4 | import time | |
|
5 | import numpy as np | |
|
6 | ||
|
1 | 7 | import library |
|
2 | 8 | |
|
3 | 9 | class ABSClient: |
|
4 | 10 | |
|
5 |
def __init__(self,ipSource="localhost", ipDestino=" |
|
|
11 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.255", portDestino=7000): | |
|
6 | 12 | |
|
7 | 13 | self.ipSource = ipSource |
|
8 | 14 | self.ipDestino = ipDestino |
@@ -13,25 +19,236 | |||
|
13 | 19 | def createObjects(self): |
|
14 | 20 | |
|
15 | 21 | self.commObj = library.UDPComm(self.ipSource, self.ipDestino, self.portDestino) |
|
16 | ||
|
22 | ||
|
17 | 23 | def sendFile(self, filename): |
|
18 | 24 | |
|
19 | fp = open(filename) | |
|
20 | data = fp.read() | |
|
21 | ||
|
22 | commObj.sendTxRxCommand(cmd="SND", data=data) | |
|
25 | #From matriz to control module format | |
|
26 | self.FuncionMaestra_GeneraFormatoControlCentral(filename) | |
|
27 | FileName = "FormatoControlCentral.txt" | |
|
28 | F_Obj = open(FileName,"r") | |
|
29 | FileList = F_Obj.readlines() | |
|
30 | F_Obj.close() | |
|
31 | FileStr = "".join(FileList) | |
|
32 | data = FileStr | |
|
33 | ||
|
34 | self.commObj.sendTxRxCommand(cmd="SNDF", data=data) | |
|
23 | 35 | |
|
24 | 36 | def changeBeam(self, newBeam): |
|
25 | 37 | |
|
26 | commObj.sendTxRxCommand(cmd="CHG", data=newBeam) | |
|
38 | self.commObj.sendTxRxCommand(cmd="CHGB", data=newBeam) | |
|
27 | 39 | |
|
28 | 40 | def getStatus(self): |
|
29 | 41 | |
|
30 | commObj.sendTxRxCommand(cmd="ANST", data="ABS") | |
|
42 | self.commObj.sendTxRxCommand(cmd="ANST", data="ABS") | |
|
43 | ||
|
44 | ########## | |
|
45 | ||
|
46 | def FuncionMaestra_GeneraFormatoControlCentral(self,archivo): | |
|
47 | """ Funcion que genera un archivo para el control central""" | |
|
48 | ||
|
49 | # CarpetaDeTrabajo='/home/redes/ABS_Control_2012_09_24/Control_Module_v1_Client_09_24/' | |
|
50 | CarpetaDeTrabajo = os.getcwd() + '/' | |
|
51 | #print CarpetaDeTrabajo | |
|
52 | #CarpetaDeTrabajo='/home/redes/workspace/ABS_Client_v2/Debug/' | |
|
53 | ||
|
54 | def lst2string(lst): | |
|
55 | string='' | |
|
56 | for i in lst: | |
|
57 | string=string+i | |
|
58 | return string | |
|
59 | ||
|
60 | def string2lst(string): | |
|
61 | lst = [] | |
|
62 | for i in string: | |
|
63 | lst.append(i) | |
|
64 | return lst | |
|
65 | ||
|
66 | ||
|
67 | def file1(string, type): | |
|
68 | lst = string2lst(archivo) | |
|
69 | fin = -1 | |
|
70 | t = len(lst) | |
|
71 | for i in np.arange(-1,-t,-1): | |
|
72 | if lst[i]=='/': | |
|
73 | fin=i | |
|
74 | break | |
|
75 | if type == '2': | |
|
76 | nombre2 = lst[fin+1:] | |
|
77 | nombre2[-1]='1' | |
|
78 | nombre2 = lst2string(nombre2) | |
|
79 | return nombre2 | |
|
80 | ||
|
81 | ||
|
82 | def EliminaSaltoDeLinea(cadena): | |
|
83 | i = 0 | |
|
84 | for elemento in cadena: | |
|
85 | if elemento =='\n' or elemento =='\r': | |
|
86 | pass | |
|
87 | else: | |
|
88 | i=i+1 | |
|
89 | return cadena [:i] | |
|
90 | ||
|
91 | def NumeroDeExperimentos(path): | |
|
92 | fichero1=open(path,'r') | |
|
93 | cont=0 | |
|
94 | for cadena in fichero1: | |
|
95 | cont=cont+1 | |
|
96 | if cont==3: | |
|
97 | nexp='' | |
|
98 | pos=0 | |
|
99 | for elemento in cadena: | |
|
100 | pos=pos+1 | |
|
101 | if elemento=='=': | |
|
102 | nexp=int(cadena[pos:]) | |
|
103 | return nexp | |
|
104 | fichero1.close() | |
|
105 | ||
|
106 | def Paridad(numero): | |
|
107 | if numero%2==0: return 'par' | |
|
108 | elif numero%2==1: return 'impar' | |
|
109 | ||
|
110 | def EvaluaCadena(cadena): | |
|
111 | if len(cadena)>35: | |
|
112 | if cadena[-1]=='$': | |
|
113 | return cadena[-35:-2] | |
|
114 | elif cadena[-1]==']': | |
|
115 | return cadena[-34:-1] | |
|
116 | else: | |
|
117 | return None | |
|
118 | ||
|
119 | def GuardaEnLista(path): | |
|
120 | fichero=open(path,'r') | |
|
121 | lista=[] | |
|
122 | for cadena in fichero: | |
|
123 | cadena = EliminaSaltoDeLinea(cadena) | |
|
124 | cadena = EvaluaCadena(cadena) | |
|
125 | if cadena != None: | |
|
126 | lista.append(cadena) | |
|
127 | fichero.close() | |
|
128 | return lista | |
|
129 | ||
|
130 | def CreaFicherosPrevios(): | |
|
131 | vector = GuardaEnLista(archivo) | |
|
132 | for i in range(1,NumeroDeExperimentos(archivo)+1): | |
|
133 | fichero =open(CarpetaDeTrabajo+str(i)+'.txt','w') | |
|
134 | for j in range(0,16): | |
|
135 | fichero.write(vector[j+16*(i-1)]+'\n') | |
|
136 | fichero.close() | |
|
137 | ||
|
138 | def CapturaValoresEnArchivo(path,polarizacion='up'): | |
|
139 | fichero =open(path,'r') | |
|
140 | cnt=0 | |
|
141 | lstup=[] | |
|
142 | lstdw=[] | |
|
143 | for cadena in fichero: | |
|
144 | cnt=cnt+1 | |
|
145 | if cnt==5: | |
|
146 | su01=cadena[17:20] | |
|
147 | su02=cadena[21:24] | |
|
148 | su03=cadena[25:28] | |
|
149 | su04=cadena[29:32] | |
|
150 | if cnt==6: | |
|
151 | su05=cadena[17:20] | |
|
152 | su06=cadena[21:24] | |
|
153 | su07=cadena[25:28] | |
|
154 | su08=cadena[29:32] | |
|
155 | if cnt==7: | |
|
156 | su09=cadena[17:20] | |
|
157 | su10=cadena[21:24] | |
|
158 | su11=cadena[25:28] | |
|
159 | su12=cadena[29:32] | |
|
160 | if cnt==8: | |
|
161 | su13=cadena[17:20] | |
|
162 | su14=cadena[21:24] | |
|
163 | su15=cadena[25:28] | |
|
164 | su16=cadena[29:32] | |
|
165 | if cnt==13: | |
|
166 | sd01=cadena[17:20] | |
|
167 | sd02=cadena[21:24] | |
|
168 | sd03=cadena[25:28] | |
|
169 | sd04=cadena[29:32] | |
|
170 | if cnt==14: | |
|
171 | sd05=cadena[17:20] | |
|
172 | sd06=cadena[21:24] | |
|
173 | sd07=cadena[25:28] | |
|
174 | sd08=cadena[29:32] | |
|
175 | if cnt==15: | |
|
176 | sd09=cadena[17:20] | |
|
177 | sd10=cadena[21:24] | |
|
178 | sd11=cadena[25:28] | |
|
179 | sd12=cadena[29:32] | |
|
180 | if cnt==16: | |
|
181 | sd13=cadena[17:20] | |
|
182 | sd14=cadena[21:24] | |
|
183 | sd15=cadena[25:28] | |
|
184 | sd16=cadena[29:32] | |
|
185 | lstup=[su01,su02,su03,su04,su05,su06,su07,su08,su09,su10,su11,su12,su13,su14,su15,su16] | |
|
186 | lstdw=[sd01,sd02,sd03,sd04,sd05,sd06,sd07,sd08,sd09,sd10,sd11,sd12,sd13,sd14,sd15,sd16] | |
|
187 | if polarizacion=='up': | |
|
188 | return lstup | |
|
189 | elif polarizacion=='dw': | |
|
190 | return lstdw | |
|
191 | fichero.close() | |
|
192 | ||
|
193 | def CreaFormatoFinal(): | |
|
194 | ne=NumeroDeExperimentos(archivo) | |
|
195 | ||
|
196 | #nombre01 = file1(archivo,'1') | |
|
197 | nombre02 = file1(archivo,'2') | |
|
198 | fichero=open(CarpetaDeTrabajo+'FormatoControlCentral.txt','w') | |
|
199 | fichero.write(nombre02+'\n') | |
|
200 | fichero.write(str(ne)+'\n') | |
|
201 | for i in range(1,17): | |
|
202 | ||
|
203 | if i<10: | |
|
204 | nmod = '0'+str(i) | |
|
205 | else: nmod = str(i) | |
|
206 | ||
|
207 | ||
|
208 | fichero.write('S'+nmod+'\n') | |
|
209 | for j in range(1,ne+1): | |
|
210 | ruta=CarpetaDeTrabajo+str(j)+'.txt' | |
|
211 | lu=CapturaValoresEnArchivo(ruta,polarizacion='up') | |
|
212 | ld=CapturaValoresEnArchivo(ruta,polarizacion='dw') | |
|
213 | part1='' | |
|
214 | part2='' | |
|
215 | if lu[i-1]=='1.0': part1='000' | |
|
216 | if lu[i-1]=='2.0': part1='001' | |
|
217 | if lu[i-1]=='3.0': part1='010' | |
|
218 | if lu[i-1]=='0.0': part1='011' | |
|
219 | if lu[i-1]=='0.5': part1='100' | |
|
220 | if lu[i-1]=='1.5': part1='101' | |
|
221 | if lu[i-1]=='2.5': part1='110' | |
|
222 | if lu[i-1]=='3.5': part1='111' | |
|
223 | if ld[i-1]=='1.0': part2='000' | |
|
224 | if ld[i-1]=='2.0': part2='001' | |
|
225 | if ld[i-1]=='3.0': part2='010' | |
|
226 | if ld[i-1]=='0.0': part2='011' | |
|
227 | if ld[i-1]=='0.5': part2='100' | |
|
228 | if ld[i-1]=='1.5': part2='101' | |
|
229 | if ld[i-1]=='2.5': part2='110' | |
|
230 | if ld[i-1]=='3.5': part2='111' | |
|
231 | fichero.write(part1+part2+'\n') | |
|
232 | fichero.write('------'+'\n') | |
|
233 | fichero.close() | |
|
234 | ||
|
235 | def EliminaArchivosEnLaCarpeta(): | |
|
236 | ne=NumeroDeExperimentos(archivo) | |
|
237 | for i in range(1,ne+1): | |
|
238 | os.remove(CarpetaDeTrabajo+str(i)+'.txt') | |
|
239 | ||
|
240 | CreaFicherosPrevios() | |
|
241 | CreaFormatoFinal() | |
|
242 | EliminaArchivosEnLaCarpeta() | |
|
243 | ||
|
244 | ########## | |
|
31 | 245 | |
|
32 | 246 | if __name__ == '__main__': |
|
33 | 247 | |
|
34 |
filename = " |
|
|
248 | filename = "experimento1.abs" | |
|
35 | 249 | |
|
36 | 250 | absObj = ABSClient() |
|
37 | absObj.sendFile(filename) No newline at end of file | |
|
251 | #absObj.sendFile(filename) | |
|
252 | #absObj.changeBeam("6") | |
|
253 | #absObj.changeBeam("2") | |
|
254 | absObj.changeBeam("7") No newline at end of file |
@@ -84,18 +84,20 | |||
|
84 | 84 | |
|
85 | 85 | __HEADER = "ABS" |
|
86 | 86 | |
|
87 |
def __init__(self, ipSource, ipDestino, portDestino |
|
|
87 | def __init__(self, ipSource, ipDestino, portDestino, asServer=False): | |
|
88 | 88 | |
|
89 | 89 | self.ipSource = ipSource |
|
90 | 90 | self.ipDestino = ipDestino |
|
91 | 91 | self.portDestino = portDestino |
|
92 | self.addr = (ipDestino,portDestino) | |
|
92 | 93 | |
|
93 | 94 | self.openSocket(asServer) |
|
94 | 95 | |
|
95 | 96 | def openSocket(self, asServer): |
|
96 | 97 | |
|
97 | self.socket_c = socket.socket(AF_INET,SOCK_DGRAM) | |
|
98 | self.socket_c.connect((self.ipDestino, self.portDestino)) | |
|
98 | #self.socket_c = socket.socket(AF_INET,SOCK_DGRAM) | |
|
99 | self.socket_c = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,0) | |
|
100 | # self.socket_c.connect((self.ipDestino, self.portDestino)) | |
|
99 | 101 | |
|
100 | 102 | if asServer: |
|
101 | 103 | self.configAsServer() |
@@ -103,52 +105,74 | |||
|
103 | 105 | self.configAsClient() |
|
104 | 106 | |
|
105 | 107 | def configAsClient(self): |
|
106 | ||
|
107 | 108 | #Configurar broadcast |
|
108 | self.commObj = UDPClient() | |
|
109 | ||
|
109 | self.socket_c.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) | |
|
110 | ||
|
110 | 111 | def configAsServer(self): |
|
111 | 112 | |
|
112 | self.commObj = UDPServer() | |
|
113 | self.socket_c.bind(self.addr) | |
|
114 | print "\nServer initialized" | |
|
113 | 115 | |
|
114 | 116 | def waitRequest(self, nbytes): |
|
117 | ||
|
118 | trama_rx, add = self.socket_c.recvfrom(nbytes) | |
|
119 | print "\nServer has received a data" | |
|
120 | ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx) | |
|
121 | ||
|
122 | return ipSource, ipDestino, cmd, data | |
|
123 | ||
|
124 | def sendData(self,TxFrame): | |
|
125 | ||
|
126 | # Send messages | |
|
127 | if(self.socket_c.sendto(TxFrame, self.addr)): | |
|
128 | print "Sending message:[" + TxFrame + "]" | |
|
129 | ||
|
130 | data_rx, server_rx = self.socket_c.recvfrom(16) | |
|
131 | ||
|
132 | print "Data received ", data_rx, server_rx | |
|
133 | ||
|
134 | # Close socket | |
|
135 | self.socket_c.close() | |
|
136 | ||
|
137 | def sendTxRxCommand(self, cmd, data, nbytes = 16384): | |
|
138 | ||
|
139 | self.sendRequest(cmd, data) | |
|
140 | ||
|
141 | #time.sleep(1) | |
|
142 | ||
|
143 | # ipSource_rx, ipDestino_rx, cmd_rx, data_rx = self.getRpta(nbytes) | |
|
144 | ||
|
145 | # if not(self.ipSource == ipDestino_rx): | |
|
146 | # print "Error" | |
|
147 | ||
|
148 | # return data_rx | |
|
149 | ||
|
150 | def sendRequest(self, cmd, data): | |
|
151 | ||
|
152 | trama_tx = self.__HEADER + ":" + str(self.ipSource) + ":" + str(self.ipDestino) + ":" + str(cmd) + ":" + str(data) + ":" | |
|
153 | #self.socket_c.send(trama_tx) | |
|
154 | # Send messages | |
|
155 | if(self.socket_c.sendto(trama_tx, self.addr)): | |
|
156 | print "Sending message:[" + trama_tx + "]" | |
|
157 | ||
|
158 | ||
|
159 | def getRpta(self, nbytes): | |
|
115 | 160 | |
|
116 | 161 | trama_rx = self.socket_c.recv(nbytes) |
|
117 | 162 | ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx) |
|
118 | 163 | |
|
119 | 164 | return ipSource, ipDestino, cmd, data |
|
120 | ||
|
121 | def sendTxRxCommand(self, cmd, data, nbytes): | |
|
122 | ||
|
123 | self.sendRequest(cmd, data) | |
|
124 | ||
|
125 | time.sleep(1) | |
|
126 | ||
|
127 | ipSource_rx, ipDestino_rx, cmd_rx, data_rx = self.getRpta(nbytes) | |
|
128 | ||
|
129 | if not(self.ipSource == ipDestino_rx): | |
|
130 | print "Error" | |
|
131 | ||
|
132 | return data_rx | |
|
133 | ||
|
134 | def sendRequest(self, cmd, data): | |
|
135 | ||
|
136 | trama_tx = self.__HEADER + str(self.ipSource) + str(self.ipDestino) + str(cmd) + str(data) | |
|
137 | self.socket_c.send(trama_tx) | |
|
138 | ||
|
139 | def getRpta(self, nbytes): | |
|
140 | ||
|
141 | trama_rx = self.socket_c.recv(nbytes) | |
|
142 | ipSource, ipDestino, cmd, data = self.__getTrama(trama_rx) | |
|
143 | ||
|
144 | return ipSource, ipDestino, cmd, data | |
|
145 | 165 | |
|
146 | 166 | def __getTrama(self, trama): |
|
147 | 167 | |
|
148 | ipSource = trama[5:15] | |
|
149 | ipDestino = trama[15:24] | |
|
150 |
|
|
|
151 | data = trama[30:-1] | |
|
168 | FrameList = trama.split(':') | |
|
169 | ||
|
170 | header = FrameList[0] | |
|
171 | ipSource = FrameList[1] | |
|
172 | ipDestino = FrameList[2] | |
|
173 | cmd = FrameList[3] | |
|
174 | data = FrameList[4] | |
|
175 | trash = FrameList[5] | |
|
152 | 176 | |
|
153 | 177 | return ipSource, ipDestino, cmd, data |
|
154 | 178 |
@@ -1,8 +1,9 | |||
|
1 | import os | |
|
1 | 2 | import library |
|
2 | 3 | |
|
3 | 4 | class ABSServer: |
|
4 | 5 | |
|
5 |
def __init__(self,ipSource="localhost", ipDestino=" |
|
|
6 | def __init__(self,ipSource="localhost", ipDestino="192.168.1.255", portDestino=7000, ipDestino2="192.168.1.255", portDestino2=5500, ftpPortDestino=None): | |
|
6 | 7 | |
|
7 | 8 | self.ipSource = ipSource |
|
8 | 9 | self.ipDestino = ipDestino |
@@ -20,43 +21,108 | |||
|
20 | 21 | asServer = True |
|
21 | 22 | self.commServerObj = library.UDPComm(self.ipSource, self.ipDestino, self.portDestino, asServer) |
|
22 | 23 | self.commClientObj = library.UDPComm(self.ipSource, self.ipDestino2, self.portDestino2) |
|
23 | self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino) | |
|
24 | #self.ftpCommObj = library.FTPComm(self.ipSource, self.ipDestino, self.ftpPortDestino) | |
|
24 | 25 | |
|
25 | def waitRequest(self): | |
|
26 | def waitRequest(self,nbytes = 16384): | |
|
26 | 27 | |
|
27 | ipSource, ipDestino, cmd, self.datarx = self.commServerObj.waitRequest() | |
|
28 | ipSource, ipDestino, cmd, self.datarx = self.commServerObj.waitRequest(nbytes) | |
|
28 | 29 | |
|
29 | if cmd == "SND": | |
|
30 | self.sendFile() | |
|
30 | if cmd == "SNDF": | |
|
31 | self.sendFile(10) | |
|
31 | 32 | |
|
32 | if cmd == "CHG": | |
|
33 | if cmd == "CHGB": | |
|
33 | 34 | self.changeBeam() |
|
34 | 35 | |
|
35 | 36 | if cmd == "ANST": |
|
36 | 37 | self.getStatus() |
|
37 | 38 | |
|
39 | def EliminaSaltoDeLinea(cadena): | |
|
40 | i = 0 | |
|
41 | for elemento in cadena: | |
|
42 | if elemento =='\n' or elemento =='\r': | |
|
43 | pass | |
|
44 | else: | |
|
45 | i=i+1 | |
|
46 | return cadena [:i] | |
|
47 | ||
|
48 | def connection_status(self,base): | |
|
49 | #File creation is neccesary? | |
|
50 | number_of_modules = 16 | |
|
51 | #base = 10 | |
|
52 | # Variables for the report | |
|
53 | status_array = ["Status of modules\n"] | |
|
54 | status_array.append("----------------\n") | |
|
55 | # Variables for the program | |
|
56 | module_list = [] | |
|
57 | ||
|
58 | for i in range(number_of_modules): | |
|
59 | cmd = "ping -c 1 -w 1 192.168.1."+ str(base + i + 1) + " >> /dev/null" | |
|
60 | status = os.system(cmd) | |
|
61 | if status == 256: | |
|
62 | status_array.append("192.168.1." + str(base + i + 1) + " [0 0]\n") #Un-connected | |
|
63 | module_list.append("0") | |
|
64 | else: | |
|
65 | status_array.append("192.168.1." + str(base + i + 1) + " [1 1]\n") | |
|
66 | module_list.append("1") | |
|
67 | # Generating a file report | |
|
68 | if base == 10: | |
|
69 | fobj = open("module_status_S.txt","w") | |
|
70 | else: | |
|
71 | fobj = open("module_status_N.txt","w") | |
|
72 | fobj.writelines(status_array) | |
|
73 | fobj.close() | |
|
74 | # For the program | |
|
75 | return module_list | |
|
38 | 76 | |
|
39 | def sendFile(self, filename = "/test/archivoabs.dat"): | |
|
77 | def sendFile(self, base): | |
|
78 | ||
|
79 | #Needed for the file creation | |
|
80 | file_list = self.datarx | |
|
81 | #Needed for the loop | |
|
82 | rx_frame_list = self.datarx.split('\n') | |
|
40 | 83 | |
|
41 | id = '------' | |
|
42 | modules = split(self.datarx, id) | |
|
43 | ||
|
44 | fp = open(filename, 'w') | |
|
45 | fp.write(self.datarx) | |
|
46 | fp.close() | |
|
47 | ||
|
48 | self.ftpCommObj.sendFile(filename) | |
|
49 | rpta = self.commClientObj.sendTxRxCommand(cmd='CARGA', data=filename) | |
|
84 | experiment_name = rx_frame_list[0] | |
|
85 | experiment_number = rx_frame_list[1] | |
|
86 | #Setting variables of the loop | |
|
87 | i =3 | |
|
88 | module = 1 | |
|
89 | number_of_modules = 16 | |
|
90 | number_of_beams = int (experiment_number) | |
|
91 | module_list = self.connection_status(10) | |
|
92 | #Loop for creating and sending the control module files | |
|
93 | while module <= number_of_modules: | |
|
94 | #Generating the control modules files | |
|
95 | fobj = open(experiment_name,"w") | |
|
96 | fobj.write(experiment_name + "\n") | |
|
97 | fobj.write("------\n") | |
|
98 | fobj.writelines(file_list[i:i + number_of_beams + 1]) | |
|
99 | fobj.close() | |
|
100 | if module_list[module -1] == "1": | |
|
101 | #Preparing and doing the tftp command | |
|
102 | cmd = "tftp -m binary 192.168.1."+ str(base + module) +" 69 -c put " + experiment_name | |
|
103 | print cmd | |
|
104 | os.system(cmd) | |
|
105 | #Updating variables of the loop | |
|
106 | i = i + number_of_beams + 2 | |
|
107 | module += 1 | |
|
108 | #Working with the UDP socket | |
|
109 | #self.commClientObj.sendData("CARGA:experimento1.ab1:") | |
|
110 | self.commClientObj.sendData("CARGA:" + experiment_name + ":") | |
|
111 | ||
|
112 | # | |
|
113 | # self.ftpCommObj.sendFile(filename) | |
|
114 | # rpta = self.commClientObj.sendTxRxCommand(cmd='CARGA', data=filename) | |
|
50 | 115 | |
|
51 | 116 | |
|
52 | 117 | def changeBeam(self): |
|
53 | 118 | |
|
54 | rpta = self.commClientObj.sendTxRxCommand(cmd='CAMBIA', data="0") | |
|
119 | #rpta = self.commClientObj.sendTxRxCommand(cmd='CAMBIA', data="0") | |
|
120 | self.commClientObj.sendData("CAMBIA:" + self.datarx + ":") | |
|
55 | 121 | |
|
56 | 122 | def getStatus(self): |
|
57 | 123 | |
|
58 | rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0") | |
|
59 | ||
|
124 | #rpta = self.commClientObj.sendTxRxCommand(cmd='CHEQUEO', data="0") | |
|
125 | self.commClientObj.sendData("CHEQUEO:" + self.datarx + ":") | |
|
60 | 126 | |
|
61 | 127 | if __name__ == '__main__': |
|
62 | 128 |
General Comments 0
You need to be logged in to leave comments.
Login now