@@ -1,1038 +1,1069 | |||
|
1 | 1 | from django.db import models |
|
2 | 2 | from apps.main.models import Configuration |
|
3 | 3 | from django.core.urlresolvers import reverse |
|
4 | 4 | # Create your models here. |
|
5 | 5 | |
|
6 | 6 | import ast |
|
7 | 7 | import socket |
|
8 | 8 | import json |
|
9 | 9 | import requests |
|
10 | 10 | import struct |
|
11 | 11 | import sys, time |
|
12 | 12 | |
|
13 | 13 | import multiprocessing |
|
14 | 14 | |
|
15 | 15 | |
|
16 | 16 | antenna_default = json.dumps({ |
|
17 | 17 | "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
18 | 18 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
19 | 19 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
20 | 20 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
21 | 21 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0], |
|
22 | 22 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0], |
|
23 | 23 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0], |
|
24 | 24 | [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0] |
|
25 | 25 | ] |
|
26 | 26 | , |
|
27 | 27 | "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
28 | 28 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
29 | 29 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
30 | 30 | [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5], |
|
31 | 31 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0], |
|
32 | 32 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0], |
|
33 | 33 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0], |
|
34 | 34 | [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]], |
|
35 | 35 | }) |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | tx_default = json.dumps({ |
|
39 | 39 | "up": [[1,1,1,1,0,0,0,0], |
|
40 | 40 | [1,1,1,1,0,0,0,0], |
|
41 | 41 | [1,1,1,1,0,0,0,0], |
|
42 | 42 | [1,1,1,1,0,0,0,0], |
|
43 | 43 | [0,0,0,0,1,1,1,1], |
|
44 | 44 | [0,0,0,0,1,1,1,1], |
|
45 | 45 | [0,0,0,0,1,1,1,1], |
|
46 | 46 | [0,0,0,0,1,1,1,1]], |
|
47 | 47 | |
|
48 | 48 | "down": [[1,1,1,1,0,0,0,0], |
|
49 | 49 | [1,1,1,1,0,0,0,0], |
|
50 | 50 | [1,1,1,1,0,0,0,0], |
|
51 | 51 | [1,1,1,1,0,0,0,0], |
|
52 | 52 | [0,0,0,0,1,1,1,1], |
|
53 | 53 | [0,0,0,0,1,1,1,1], |
|
54 | 54 | [0,0,0,0,1,1,1,1], |
|
55 | 55 | [0,0,0,0,1,1,1,1]], |
|
56 | 56 | }) |
|
57 | 57 | |
|
58 | 58 | rx_default = json.dumps({ |
|
59 | 59 | "up": [[1,1,1,1,0,0,0,0], |
|
60 | 60 | [1,1,1,1,0,0,0,0], |
|
61 | 61 | [1,1,1,1,0,0,0,0], |
|
62 | 62 | [1,1,1,1,0,0,0,0], |
|
63 | 63 | [0,0,0,0,1,1,1,1], |
|
64 | 64 | [0,0,0,0,1,1,1,1], |
|
65 | 65 | [0,0,0,0,1,1,1,1], |
|
66 | 66 | [0,0,0,0,1,1,1,1]], |
|
67 | 67 | |
|
68 | 68 | "down": [[1,1,1,1,0,0,0,0], |
|
69 | 69 | [1,1,1,1,0,0,0,0], |
|
70 | 70 | [1,1,1,1,0,0,0,0], |
|
71 | 71 | [1,1,1,1,0,0,0,0], |
|
72 | 72 | [0,0,0,0,1,1,1,1], |
|
73 | 73 | [0,0,0,0,1,1,1,1], |
|
74 | 74 | [0,0,0,0,1,1,1,1], |
|
75 | 75 | [0,0,0,0,1,1,1,1]], |
|
76 | 76 | }) |
|
77 | 77 | |
|
78 | 78 | conf_default = {} |
|
79 | 79 | status_default = {} |
|
80 | 80 | for i in range(1,65): |
|
81 | 81 | conf_default[str(i)] = "" |
|
82 | 82 | status_default[str(i)] = 0 |
|
83 | 83 | |
|
84 | 84 | ues_default = json.dumps({ |
|
85 | 85 | "up": [0.533333,0.00000,1.06667,0.00000], |
|
86 | 86 | "down": [0.533333,0.00000,1.06667,0.00000] |
|
87 | 87 | }) |
|
88 | 88 | |
|
89 | 89 | onlyrx_default = json.dumps({ |
|
90 | 90 | "up": False, |
|
91 | 91 | "down": False |
|
92 | 92 | }) |
|
93 | 93 | |
|
94 | 94 | def up_convertion(cadena): |
|
95 | 95 | valores = [] |
|
96 | 96 | for c in cadena: |
|
97 | 97 | if c == 1.0: valores=valores+['000'] |
|
98 | 98 | if c == 2.0: valores=valores+['001'] |
|
99 | 99 | if c == 3.0: valores=valores+['010'] |
|
100 | 100 | if c == 0.0: valores=valores+['011'] |
|
101 | 101 | if c == 0.5: valores=valores+['100'] |
|
102 | 102 | if c == 1.5: valores=valores+['101'] |
|
103 | 103 | if c == 2.5: valores=valores+['110'] |
|
104 | 104 | if c == 3.5: valores=valores+['111'] |
|
105 | 105 | |
|
106 | 106 | return valores |
|
107 | 107 | |
|
108 | 108 | def up_conv_bits(value): |
|
109 | 109 | |
|
110 | 110 | if value == 1.0: bits="000" |
|
111 | 111 | if value == 2.0: bits="001" |
|
112 | 112 | if value == 3.0: bits="010" |
|
113 | 113 | if value == 0.0: bits="011" |
|
114 | 114 | if value == 0.5: bits="100" |
|
115 | 115 | if value == 1.5: bits="101" |
|
116 | 116 | if value == 2.5: bits="110" |
|
117 | 117 | if value == 3.5: bits="111" |
|
118 | 118 | |
|
119 | 119 | return bits |
|
120 | 120 | |
|
121 | 121 | def down_convertion(cadena): |
|
122 | 122 | valores = [] |
|
123 | 123 | for c in cadena: |
|
124 | 124 | if c == 1.0: valores=valores+['000'] |
|
125 | 125 | if c == 2.0: valores=valores+['001'] |
|
126 | 126 | if c == 3.0: valores=valores+['010'] |
|
127 | 127 | if c == 0.0: valores=valores+['011'] |
|
128 | 128 | if c == 0.5: valores=valores+['100'] |
|
129 | 129 | if c == 1.5: valores=valores+['101'] |
|
130 | 130 | if c == 2.5: valores=valores+['110'] |
|
131 | 131 | if c == 3.5: valores=valores+['111'] |
|
132 | 132 | |
|
133 | 133 | return valores |
|
134 | 134 | |
|
135 | 135 | def down_conv_bits(value): |
|
136 | 136 | |
|
137 | 137 | if value == 1.0: bits="000" |
|
138 | 138 | if value == 2.0: bits="001" |
|
139 | 139 | if value == 3.0: bits="010" |
|
140 | 140 | if value == 0.0: bits="011" |
|
141 | 141 | if value == 0.5: bits="100" |
|
142 | 142 | if value == 1.5: bits="101" |
|
143 | 143 | if value == 2.5: bits="110" |
|
144 | 144 | if value == 3.5: bits="111" |
|
145 | 145 | |
|
146 | 146 | return bits |
|
147 | 147 | |
|
148 | 148 | def ip2position(module_number): |
|
149 | 149 | j=0 |
|
150 | 150 | i=0 |
|
151 | 151 | for x in range(0,module_number-1): |
|
152 | 152 | j=j+1 |
|
153 | 153 | if j==8: |
|
154 | 154 | i=i+1 |
|
155 | 155 | j=0 |
|
156 | 156 | |
|
157 | 157 | pos = [i,j] |
|
158 | 158 | return pos |
|
159 | 159 | |
|
160 | 160 | |
|
161 | 161 | def fromBinary2Char(binary_string): |
|
162 | 162 | number = int(binary_string, 2) |
|
163 | 163 | #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f' |
|
164 | 164 | number = number + 33 |
|
165 | 165 | char = chr(number) |
|
166 | 166 | return char |
|
167 | 167 | |
|
168 | 168 | def fromChar2Binary(char): |
|
169 | 169 | number = ord(char) - 33 |
|
170 | 170 | #Minus 33 to get the real value |
|
171 | 171 | bits = bin(number)[2:] |
|
172 | 172 | #To ensure we have a string with 6bits |
|
173 | 173 | if len(bits) < 6: |
|
174 | 174 | bits = bits.zfill(6) |
|
175 | 175 | return bits |
|
176 | 176 | |
|
177 | 177 | OPERATION_MODES = ( |
|
178 | 178 | (0, 'Manual'), |
|
179 | 179 | (1, 'Automatic'), |
|
180 | 180 | ) |
|
181 | 181 | |
|
182 | 182 | |
|
183 | 183 | class ABSConfiguration(Configuration): |
|
184 | 184 | active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}") |
|
185 | 185 | module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default)) |
|
186 | 186 | operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0) |
|
187 | 187 | operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True) |
|
188 | 188 | |
|
189 | 189 | class Meta: |
|
190 | 190 | db_table = 'abs_configurations' |
|
191 | 191 | |
|
192 | 192 | def get_absolute_url_plot(self): |
|
193 | 193 | return reverse('url_plot_abs_patterns', args=[str(self.id)]) |
|
194 | 194 | |
|
195 | 195 | |
|
196 | 196 | def parms_to_dict(self): |
|
197 | 197 | |
|
198 | 198 | parameters = {} |
|
199 | 199 | |
|
200 | 200 | parameters['device_id'] = self.device.id |
|
201 | 201 | parameters['name'] = self.name |
|
202 | 202 | parameters['beams'] = {} |
|
203 | 203 | |
|
204 | 204 | beams = ABSBeam.objects.filter(abs_conf=self) |
|
205 | 205 | b=1 |
|
206 | 206 | for beam in beams: |
|
207 | 207 | #absbeam = ABSBeam.objects.get(pk=beams[beam]) |
|
208 | 208 | parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict() |
|
209 | 209 | b+=1 |
|
210 | 210 | |
|
211 | 211 | return parameters |
|
212 | 212 | |
|
213 | 213 | def dict_to_parms(self, parameters): |
|
214 | 214 | |
|
215 | 215 | self.name = parameters['name'] |
|
216 | 216 | |
|
217 | 217 | absbeams = ABSBeam.objects.filter(abs_conf=self) |
|
218 | 218 | beams = parameters['beams'] |
|
219 | 219 | |
|
220 | 220 | if absbeams: |
|
221 | 221 | beams_number = len(beams) |
|
222 | 222 | absbeams_number = len(absbeams) |
|
223 | 223 | if beams_number==absbeams_number: |
|
224 | 224 | i = 1 |
|
225 | 225 | for absbeam in absbeams: |
|
226 | 226 | absbeam.dict_to_parms(beams['beam'+str(i)]) |
|
227 | 227 | i = i+1 |
|
228 | 228 | elif beams_number > absbeams_number: |
|
229 | 229 | i = 1 |
|
230 | 230 | for absbeam in absbeams: |
|
231 | 231 | absbeam.dict_to_parms(beams['beam'+str(i)]) |
|
232 | 232 | i=i+1 |
|
233 | 233 | for x in range(i,beams_number+1): |
|
234 | 234 | new_beam = ABSBeam( |
|
235 | 235 | name =beams['beam'+str(i)]['name'], |
|
236 | 236 | antenna =json.dumps(beams['beam'+str(i)]['antenna']), |
|
237 | 237 | abs_conf = self, |
|
238 | 238 | tx =json.dumps(beams['beam'+str(i)]['tx']), |
|
239 | 239 | rx =json.dumps(beams['beam'+str(i)]['rx']), |
|
240 | 240 | ues =json.dumps(beams['beam'+str(i)]['ues']), |
|
241 | 241 | only_rx =json.dumps(beams['beam'+str(i)]['only_rx']) |
|
242 | 242 | ) |
|
243 | 243 | new_beam.save() |
|
244 | 244 | i=i+1 |
|
245 | 245 | else: #beams_number < absbeams_number: |
|
246 | 246 | i = 1 |
|
247 | 247 | for absbeam in absbeams: |
|
248 | 248 | if i <= beams_number: |
|
249 | 249 | absbeam.dict_to_parms(beams['beam'+str(i)]) |
|
250 | 250 | i=i+1 |
|
251 | 251 | else: |
|
252 | 252 | absbeam.delete() |
|
253 | 253 | else: |
|
254 | 254 | for beam in beams: |
|
255 | 255 | new_beam = ABSBeam( |
|
256 | 256 | name =beams[beam]['name'], |
|
257 | 257 | antenna =json.dumps(beams[beam]['antenna']), |
|
258 | 258 | abs_conf = self, |
|
259 | 259 | tx =json.dumps(beams[beam]['tx']), |
|
260 | 260 | rx =json.dumps(beams[beam]['rx']), |
|
261 | 261 | ues =json.dumps(beams[beam]['ues']), |
|
262 | 262 | only_rx =json.dumps(beams[beam]['only_rx']) |
|
263 | 263 | ) |
|
264 | 264 | new_beam.save() |
|
265 | 265 | |
|
266 | 266 | |
|
267 | 267 | |
|
268 | 268 | def update_from_file(self, parameters): |
|
269 | 269 | |
|
270 | 270 | self.dict_to_parms(parameters) |
|
271 | 271 | self.save() |
|
272 | 272 | |
|
273 | 273 | |
|
274 | 274 | def get_beams(self, **kwargs): |
|
275 | 275 | ''' |
|
276 | 276 | This function returns ABS Configuration beams |
|
277 | 277 | ''' |
|
278 | 278 | return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs) |
|
279 | 279 | |
|
280 | 280 | def clone(self, **kwargs): |
|
281 | 281 | |
|
282 | 282 | beams = self.get_beams() |
|
283 | 283 | self.pk = None |
|
284 | 284 | self.id = None |
|
285 | 285 | for attr, value in kwargs.items(): |
|
286 | 286 | setattr(self, attr, value) |
|
287 | 287 | self.save() |
|
288 | 288 | |
|
289 | 289 | for beam in beams: |
|
290 | 290 | beam.clone(abs_conf=self) |
|
291 | 291 | |
|
292 | 292 | return self |
|
293 | 293 | |
|
294 | 294 | |
|
295 | 295 | def module_conf(self, module_num, beams): |
|
296 | 296 | """ |
|
297 | 297 | This function creates beam configurations for one abs module. |
|
298 | 298 | """ |
|
299 | 299 | ip_address = self.device.ip_address |
|
300 | 300 | ip_address = ip_address.split('.') |
|
301 | 301 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
302 | 302 | dot = '.' |
|
303 | 303 | module_ip = dot.join(module_seq)+'.'+str(module_num) |
|
304 | 304 | module_port = self.device.port_address |
|
305 | 305 | write_route = 'http://'+module_ip+':'+str(module_port)+'/write' |
|
306 | 306 | |
|
307 | 307 | header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' |
|
308 | 308 | module = 'ABS_'+str(module_num) |
|
309 | 309 | bs = '' #{} |
|
310 | 310 | i=1 |
|
311 | #beams = {1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101', | |
|
312 | # 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'} | |
|
311 | ||
|
313 | 312 | for beam in beams: |
|
314 | 313 | #bs[i] = fromBinary2Char(beam.module_6bits(module_num)) |
|
315 | 314 | bs = bs + fromBinary2Char(beam.module_6bits(module_num)) |
|
316 | 315 | i=i+1 |
|
317 | 316 | |
|
318 | 317 | beams = bs |
|
319 | 318 | |
|
320 | 319 | parameters = {} |
|
321 | parameters['header'] = header | |
|
322 | parameters['module'] = module | |
|
320 | #parameters['header'] = header | |
|
321 | #parameters['module'] = module | |
|
323 | 322 | parameters['beams'] = beams #json.dumps(beams) |
|
324 |
print |
|
|
323 | #print beams | |
|
324 | #print parameters['beams'] | |
|
325 | print parameters | |
|
325 | 326 | answer = '' |
|
326 | 327 | |
|
327 | 328 | try: |
|
328 | r_write = requests.post(write_route, parameters, timeout=0.5) | |
|
329 | #r_write = requests.post(write_route, parameters, timeout=0.5) | |
|
330 | r_write = requests.post(write_route, json = parameters, timeout=0.5) | |
|
329 | 331 | answer = r_write.json() |
|
330 | 332 | self.message = answer['message'] |
|
331 | 333 | except: |
|
332 | 334 | self.message = "Could not write ABS parameters" |
|
333 | 335 | return 0 |
|
334 | 336 | return 1 |
|
335 | 337 | |
|
338 | ||
|
339 | ||
|
340 | def write_device(self): | |
|
341 | """ | |
|
342 | This function sends the beams list to every abs module. | |
|
343 | It needs 'module_conf' function | |
|
344 | """ | |
|
345 | ||
|
346 | beams = ABSBeam.objects.filter(abs_conf=self) | |
|
347 | ||
|
348 | #-------------Write each abs module----------- | |
|
349 | if beams: | |
|
350 | beams_status = ast.literal_eval(self.module_status) | |
|
351 | for i in range(61,64): #(62,65) | |
|
352 | try: | |
|
353 | answer = self.module_conf(i, beams) | |
|
354 | beams_status[str(i)] = 1 | |
|
355 | self.module_status = json.dumps(beams_status) | |
|
356 | self.save() | |
|
357 | ||
|
358 | except: | |
|
359 | beams_status[str(i)] = 0 | |
|
360 | self.module_status = json.dumps(beams_status) | |
|
361 | self.save() | |
|
362 | answer = 0 | |
|
363 | return 0 | |
|
364 | else: | |
|
365 | self.message = "ABS Configuration does not have beams" | |
|
366 | return 0 | |
|
367 | ||
|
368 | #self.device.status = 1 | |
|
369 | ## | |
|
370 | if answer==1: | |
|
371 | self.message = "ABS Beams List have been sent to ABS Modules" | |
|
372 | beams[0].set_as_activebeam() | |
|
373 | else: | |
|
374 | self.message = "Could not read ABS parameters" | |
|
375 | ## | |
|
376 | self.save() | |
|
377 | return 1 | |
|
378 | ||
|
379 | ||
|
380 | ||
|
381 | ||
|
336 | 382 | def read_module(self, module): |
|
337 | 383 | |
|
338 | 384 | """ |
|
339 | 385 | Read out-bits (up-down) of 1 abs module NOT for Configuration |
|
340 | 386 | """ |
|
341 | 387 | |
|
342 | 388 | parameters = {} |
|
343 | 389 | ip_address = self.device.ip_address |
|
344 | 390 | ip_address = ip_address.split('.') |
|
345 | 391 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
346 | 392 | dot = '.' |
|
347 | 393 | module_ip = dot.join(module_seq)+'.'+str(module) |
|
348 | 394 | module_port = self.device.port_address |
|
349 | 395 | read_route = 'http://'+module_ip+':'+str(module_port)+'/read' |
|
350 | 396 | |
|
351 | 397 | print(read_route) |
|
352 | 398 | |
|
353 | 399 | answer = '' |
|
354 | 400 | module_bits = '' |
|
355 | 401 | |
|
356 | 402 | try: |
|
357 | 403 | r_write = requests.get(read_route, timeout=0.7) |
|
358 | 404 | answer = r_write.json() |
|
359 | 405 | self.message = answer['message'] |
|
360 | 406 | module_bits = answer['allbits'] |
|
361 | 407 | except: |
|
362 | 408 | #message = "Could not read ABS parameters" |
|
409 | answer = r_write.json() | |
|
363 | 410 | return 0 |
|
364 | 411 | |
|
365 | 412 | return module_bits |
|
366 | 413 | |
|
367 | 414 | |
|
368 |
def |
|
|
369 | ||
|
370 | return True | |
|
371 | ||
|
372 | def status_device(self): | |
|
415 | def absmodule_status(self): | |
|
373 | 416 | """ |
|
374 | 417 | This function gets the status of each abs module. It sends GET method to Web Application |
|
375 | 418 | in Python Bottle. |
|
419 | This function updates "module_status" field from ABSconfiguration. | |
|
376 | 420 | """ |
|
377 | 421 | ip_address = self.device.ip_address |
|
378 | 422 | ip_address = ip_address.split('.') |
|
379 | 423 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
380 | 424 | dot = '.' |
|
381 | 425 | module_port = self.device.port_address |
|
382 | 426 | |
|
383 | 427 | modules_status = json.loads(self.module_status) |
|
384 | 428 | |
|
385 | 429 | for i in range(1,65): |
|
386 | 430 | module_ip = dot.join(module_seq)+'.'+str(i) |
|
387 | 431 | print module_ip |
|
388 | 432 | |
|
389 | 433 | route = 'http://'+module_ip+':'+str(module_port)+'/hello' |
|
390 | 434 | |
|
391 | 435 | try: |
|
392 | 436 | r = requests.get(route, timeout=0.7) |
|
393 | 437 | modules_status[str(i)] = 1 |
|
394 | 438 | except: |
|
395 | 439 | modules_status[str(i)] = 0 |
|
396 | 440 | pass |
|
397 | 441 | |
|
398 | self.message = 'ABS modules Status have been updated.' | |
|
442 | ||
|
399 | 443 | self.module_status=json.dumps(modules_status) |
|
400 | 444 | self.save() |
|
401 | 445 | |
|
402 | 446 | return |
|
403 | 447 | |
|
404 | 448 | |
|
405 |
def |
|
|
449 | def connected_modules(self): | |
|
406 | 450 | """ |
|
407 |
This function |
|
|
408 | It needs 'module_conf' function | |
|
451 | This function returns the number of connected abs-modules without updating. | |
|
409 | 452 | """ |
|
453 | modules_status = json.loads(self.module_status) | |
|
454 | num = 0 | |
|
455 | for status in modules_status: | |
|
456 | num = num +modules_status[status] | |
|
410 | 457 | |
|
411 | beams = ABSBeam.objects.filter(abs_conf=self) | |
|
458 | return num | |
|
412 | 459 | |
|
413 | #-------------Write each abs module----------- | |
|
414 | if beams: | |
|
415 | beams_status = ast.literal_eval(self.module_status) | |
|
416 | for i in range(61,64): #(62,65) | |
|
417 | try: | |
|
418 | answer = self.module_conf(i, beams) | |
|
419 | beams_status[str(i)] = 1 | |
|
420 | self.module_status = json.dumps(beams_status) | |
|
421 | self.save() | |
|
422 | 460 | |
|
423 | except: | |
|
424 | beams_status[str(i)] = 0 | |
|
425 | self.module_status = json.dumps(beams_status) | |
|
426 | self.save() | |
|
427 | answer = 0 | |
|
428 | return 0 | |
|
429 | else: | |
|
430 | self.message = "ABS Configuration does not have beams" | |
|
431 | return 0 | |
|
461 | def status_device(self): | |
|
462 | """ | |
|
463 | This function returns the status of all abs-modules as one. | |
|
464 | If at least one module is connected, its answer is "1" | |
|
465 | """ | |
|
466 | self.absmodule_status() | |
|
467 | connected_modules = self.connected_modules() | |
|
468 | if connected_modules>0: | |
|
469 | self.message = 'ABS modules Status have been updated.' | |
|
470 | return 1 | |
|
471 | self.message = 'No ABS module is connected.' | |
|
472 | return 0 | |
|
432 | 473 | |
|
433 | #self.device.status = 1 | |
|
434 | ## | |
|
435 | if answer==1: | |
|
436 | self.message = "ABS Beams List have been sent to ABS Modules" | |
|
437 | beams[0].set_as_activebeam() | |
|
438 | else: | |
|
439 | self.message = "Could not read ABS parameters" | |
|
440 | ## | |
|
441 | self.save() | |
|
442 | return 1 | |
|
443 | 474 | |
|
444 | 475 | |
|
445 | 476 | def write_module(self, module): |
|
446 | 477 | |
|
447 | 478 | """ |
|
448 | 479 | Send configuration to one abs module |
|
449 | 480 | """ |
|
450 | 481 | |
|
451 | 482 | parameters = {} |
|
452 | 483 | ip_address = self.abs_conf.device.ip_address |
|
453 | 484 | ip_address = ip_address.split('.') |
|
454 | 485 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
|
455 | 486 | dot = '.' |
|
456 | 487 | module_ip = dot.join(module_seq)+'.'+str(module) |
|
457 | 488 | module_port = self.abs_conf.device.port_address |
|
458 | 489 | write_route = 'http://'+module_ip+':'+str(module_port)+'/write' |
|
459 | 490 | |
|
460 | 491 | #print write_route |
|
461 | 492 | |
|
462 | 493 | header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' |
|
463 | 494 | module = 'ABS_'+str(module) |
|
464 | 495 | beams = {1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101', |
|
465 | 496 | 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'} |
|
466 | 497 | |
|
467 | 498 | parameters['header'] = header |
|
468 | 499 | parameters['module'] = module |
|
469 | 500 | parameters['beams'] = json.dumps(beams) |
|
470 | 501 | |
|
471 | 502 | answer = '' |
|
472 | 503 | |
|
473 | 504 | try: |
|
474 | 505 | r_write = requests.post(write_route, parameters, timeout=0.5) |
|
475 | 506 | answer = r_write.json() |
|
476 | 507 | self.message = answer['message'] |
|
477 | 508 | except: |
|
478 | 509 | self.message = "Could not write ABS parameters" |
|
479 | 510 | return 0 |
|
480 | 511 | |
|
481 | 512 | |
|
482 | 513 | #self.device.status = int(answer['status']) |
|
483 | 514 | |
|
484 | 515 | return 1 |
|
485 | 516 | |
|
486 | 517 | |
|
487 | 518 | def beam_selector(self, module, beam_pos): |
|
488 | 519 | """ |
|
489 | 520 | This function selects the beam number for one absmodule. |
|
490 | 521 | """ |
|
491 | 522 | |
|
492 | 523 | if beam_pos > 0: |
|
493 | 524 | beam_pos = beam_pos - 1 |
|
494 | 525 | else: |
|
495 | 526 | beam_pos = 0 |
|
496 | 527 | |
|
497 | 528 | #El indice del apunte debe ser menor que el numero total de apuntes |
|
498 | 529 | #El servidor tcp en el embebido comienza a contar desde 0 |
|
499 | 530 | beams_list = ABSBeam.objects.filter(abs_conf=self) |
|
500 | 531 | if len(beams_list) < beam_pos: |
|
501 | 532 | return 0 |
|
502 | 533 | |
|
503 | 534 | flag = 1 |
|
504 | 535 | if beam_pos>9: |
|
505 | 536 | flag = 2 |
|
506 | 537 | |
|
507 | 538 | module_address = ('192.168.1.'+str(module), 5500) |
|
508 | 539 | header = 'JROABSCeCnModCnMod0100000' |
|
509 | 540 | numbers = len(str(beam_pos)) |
|
510 | 541 | function = 'CHGB' |
|
511 | 542 | |
|
512 | 543 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' |
|
513 | 544 | |
|
514 | 545 | # Create the datagram socket |
|
515 | 546 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
516 | 547 | #sock.connect(module_address) |
|
517 | 548 | try: |
|
518 | 549 | sock.connect(module_address) |
|
519 | 550 | sock.send(message_tx) |
|
520 | 551 | sock.close() |
|
521 | 552 | print("Writing abs module:"+module_address[0]+"...") |
|
522 | 553 | except: |
|
523 | 554 | sock = None |
|
524 | 555 | print("Problem writing abs module:"+module_address[0]) |
|
525 | 556 | return 0 |
|
526 | 557 | |
|
527 | 558 | return 1 |
|
528 | 559 | |
|
529 | 560 | |
|
530 | 561 | def change_beam(self, beam_pos): |
|
531 | 562 | """ |
|
532 | 563 | This function selects the beam number for all absmodules. |
|
533 | 564 | """ |
|
534 | 565 | for i in range(1,65): |
|
535 | 566 | try: |
|
536 | 567 | self.beam_selector(i,beam_pos) |
|
537 | 568 | except: |
|
538 | 569 | print("Problem with module: 192.168.1."+str(i)) |
|
539 | 570 | self.message = "Problem with module: 192.168.1."+str(i) |
|
540 | 571 | #return 0 |
|
541 | 572 | return 1 |
|
542 | 573 | |
|
543 | 574 | |
|
544 | 575 | def send_beam_num(self, beam_pos): |
|
545 | 576 | """ |
|
546 | 577 | This function connects to a multicast group and sends the beam number |
|
547 | 578 | to all abs modules. |
|
548 | 579 | """ |
|
549 | 580 | |
|
550 | 581 | if beam_pos > 0: |
|
551 | 582 | beam_pos = beam_pos - 1 |
|
552 | 583 | else: |
|
553 | 584 | beam_pos = 0 |
|
554 | 585 | |
|
555 | 586 | #El indice del apunte debe ser menor que el numero total de apuntes |
|
556 | 587 | #El servidor tcp en el embebido comienza a contar desde 0 |
|
557 | 588 | beams_list = ABSBeam.objects.filter(abs_conf=self) |
|
558 | 589 | if len(beams_list) < beam_pos: |
|
559 | 590 | return 0 |
|
560 | 591 | |
|
561 | 592 | flag = 1 |
|
562 | 593 | if beam_pos>9: |
|
563 | 594 | flag = 2 |
|
564 | 595 | |
|
565 | 596 | header = 'JROABSCeCnModCnMod0100000' |
|
566 | 597 | flag = str(flag) |
|
567 | 598 | function = 'CHGB' |
|
568 | 599 | message_tx = header+flag+function+str(beam_pos)+'0' |
|
569 | 600 | |
|
570 | 601 | multicast_group = '224.3.29.71' |
|
571 | 602 | server_address = ('',10000) |
|
572 | 603 | |
|
573 | 604 | # Create the socket |
|
574 | 605 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
|
575 | 606 | # Bind to the server address |
|
576 | 607 | sock.bind(server_address) |
|
577 | 608 | # Telling the OS add the socket to the multicast on all interfaces |
|
578 | 609 | group = socket.inet_aton(multicast_group) |
|
579 | 610 | mreq = struct.pack('4sL', group, socket.INADDR_ANY) |
|
580 | 611 | sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) |
|
581 | 612 | |
|
582 | 613 | #print 'sending acknowledgement to all: \n' + message_tx |
|
583 | 614 | sock.sendto(message_tx, (multicast_group, 10000)) |
|
584 | 615 | sock.close() |
|
585 | 616 | sock = None |
|
586 | 617 | |
|
587 | 618 | return 1 |
|
588 | 619 | |
|
589 | 620 | def test1(self): |
|
590 | 621 | t1 = time.time() |
|
591 | 622 | t2 = 0 |
|
592 | 623 | while (t2-t1)<100:#300 |
|
593 | 624 | t2 = time.time() |
|
594 | 625 | self.send_beam_num(2) |
|
595 | 626 | time.sleep(0.04) |
|
596 | 627 | self.send_beam_num(1) |
|
597 | 628 | time.sleep(0.04) |
|
598 | 629 | return |
|
599 | 630 | |
|
600 | 631 | def change_procs_test1(self, module): |
|
601 | 632 | |
|
602 | 633 | for i in range (1,300):#300 |
|
603 | 634 | beam_pos = 1 |
|
604 | 635 | module_address = ('192.168.1.'+str(module), 5500) |
|
605 | 636 | header = 'JROABSCeCnModCnMod0100000' |
|
606 | 637 | numbers = len(str(beam_pos)) |
|
607 | 638 | function = 'CHGB' |
|
608 | 639 | |
|
609 | 640 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' |
|
610 | 641 | |
|
611 | 642 | # Create the datagram socket |
|
612 | 643 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
613 | 644 | sock.connect(module_address) |
|
614 | 645 | |
|
615 | 646 | sock.send(message_tx) |
|
616 | 647 | #t = sock.recv(1024) |
|
617 | 648 | sock.close() |
|
618 | 649 | sock = None |
|
619 | 650 | |
|
620 | 651 | |
|
621 | 652 | time.sleep(0.04) |
|
622 | 653 | |
|
623 | 654 | |
|
624 | 655 | beam_pos = 0 |
|
625 | 656 | numbers = len(str(beam_pos)) |
|
626 | 657 | |
|
627 | 658 | message_tx = header+str(numbers)+function+str(beam_pos)+'0' |
|
628 | 659 | |
|
629 | 660 | # Create the datagram socket |
|
630 | 661 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
631 | 662 | sock.connect(module_address) |
|
632 | 663 | sock.send(message_tx) |
|
633 | 664 | sock.close() |
|
634 | 665 | sock = None |
|
635 | 666 | |
|
636 | 667 | time.sleep(0.04) |
|
637 | 668 | |
|
638 | 669 | |
|
639 | 670 | def multi_procs_test1(self): |
|
640 | 671 | |
|
641 | 672 | """ |
|
642 | 673 | This function sends the beam number to all abs modules using multiprocessing. |
|
643 | 674 | """ |
|
644 | 675 | |
|
645 | 676 | #if __name__ == "__main__": |
|
646 | 677 | size = 10000000 # Number of random numbers to add |
|
647 | 678 | procs = 65 # (Number-1) of processes to create (absmodule) |
|
648 | 679 | |
|
649 | 680 | # Create a list of jobs and then iterate through |
|
650 | 681 | # the number of processes appending each process to |
|
651 | 682 | # the job list |
|
652 | 683 | jobs = [] |
|
653 | 684 | for i in range(1, procs): |
|
654 | 685 | |
|
655 | 686 | process = multiprocessing.Process(target=self.change_procs_test1,args=(i,)) |
|
656 | 687 | jobs.append(process) |
|
657 | 688 | #print jobs |
|
658 | 689 | |
|
659 | 690 | # Start the processes (i.e. calculate the random number lists) |
|
660 | 691 | for j in jobs: |
|
661 | 692 | #time.sleep(0.4) |
|
662 | 693 | #print j |
|
663 | 694 | j.start() |
|
664 | 695 | |
|
665 | 696 | # Ensure all of the processes have finished |
|
666 | 697 | for j in jobs: |
|
667 | 698 | j.join() |
|
668 | 699 | |
|
669 | 700 | print("List processing complete.") |
|
670 | 701 | return 1 |
|
671 | 702 | |
|
672 | 703 | |
|
673 | 704 | |
|
674 | 705 | def multi_procs_test2(self): |
|
675 | 706 | """ |
|
676 | 707 | This function use multiprocessing python library. Importing Pool we can select |
|
677 | 708 | the number of cores we want to use |
|
678 | 709 | After 'nproc' linux command, we know how many cores computer has. |
|
679 | 710 | NOT WORKING |
|
680 | 711 | """ |
|
681 | 712 | import multiprocessing |
|
682 | 713 | pool = multiprocessing.Pool(3) # cores |
|
683 | 714 | |
|
684 | 715 | tasks = [] |
|
685 | 716 | procs = 65 |
|
686 | 717 | for i in range(62, procs): |
|
687 | 718 | tasks.append( (i,)) |
|
688 | 719 | #print tasks |
|
689 | 720 | #pool.apply_async(self.change_procs_test1, 62) |
|
690 | 721 | results = [pool.apply( self.change_procs_test1, t ) for t in tasks] |
|
691 | 722 | #for result in results: |
|
692 | 723 | #result.get() |
|
693 | 724 | #(plotNum, plotFilename) = result.get() |
|
694 | 725 | #print("Result: plot %d written to %s" % (plotNum, plotFilename) ) |
|
695 | 726 | |
|
696 | 727 | return 1 |
|
697 | 728 | |
|
698 | 729 | |
|
699 | 730 | def multi_procs_test3(self): |
|
700 | 731 | """ |
|
701 | 732 | This function use multiprocessing python library. Importing Pool we can select |
|
702 | 733 | the number of cores we want to use |
|
703 | 734 | After 'nproc' linux command, we know how many cores computer has. |
|
704 | 735 | """ |
|
705 | 736 | from multiprocessing import Pool |
|
706 | 737 | import time |
|
707 | 738 | |
|
708 | 739 | def f(x): |
|
709 | 740 | return x*x |
|
710 | 741 | |
|
711 | 742 | tasks = [] |
|
712 | 743 | procs = 65 |
|
713 | 744 | pool = Pool(processes=4) |
|
714 | 745 | |
|
715 | 746 | #for i in range(62, procs): |
|
716 | 747 | #result = pool.map(f, range(62,65)) |
|
717 | 748 | it = pool.imap(self.change_procs_test1, range(62,65)) |
|
718 | 749 | #result.get(timeout=5) |
|
719 | 750 | |
|
720 | 751 | return 1 |
|
721 | 752 | |
|
722 | 753 | |
|
723 | 754 | def f(x): |
|
724 | 755 | print x |
|
725 | 756 | return |
|
726 | 757 | |
|
727 | 758 | def multi_procs_test4(self): |
|
728 | 759 | import multiprocessing as mp |
|
729 | 760 | |
|
730 | 761 | |
|
731 | 762 | num_workers = mp.cpu_count() |
|
732 | 763 | |
|
733 | 764 | pool = mp.Pool(num_workers) |
|
734 | 765 | procs = 65 |
|
735 | 766 | for i in range(62, procs): |
|
736 | 767 | #for task in tasks: |
|
737 | 768 | pool.apply_async(self.f, args = (i,)) |
|
738 | 769 | |
|
739 | 770 | pool.close() |
|
740 | 771 | pool.join() |
|
741 | 772 | |
|
742 | 773 | return 1 |
|
743 | 774 | |
|
744 | 775 | |
|
745 | 776 | def get_absolute_url_import(self): |
|
746 | 777 | return reverse('url_import_abs_conf', args=[str(self.id)]) |
|
747 | 778 | |
|
748 | 779 | |
|
749 | 780 | |
|
750 | 781 | |
|
751 | 782 | class ABSBeam(models.Model): |
|
752 | 783 | |
|
753 | 784 | name = models.CharField(max_length=60, default='Beam') |
|
754 | 785 | antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default) |
|
755 | 786 | abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration') |
|
756 | 787 | tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default) |
|
757 | 788 | rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default) |
|
758 | 789 | s_time = models.TimeField(verbose_name='Star Time', default='00:00:00') |
|
759 | 790 | e_time = models.TimeField(verbose_name='End Time', default='23:59:59') |
|
760 | 791 | modules_conf = models.CharField(verbose_name='Modules', max_length=2000, default=json.dumps(conf_default)) |
|
761 | 792 | ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default) |
|
762 | 793 | only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default) |
|
763 | 794 | |
|
764 | 795 | class Meta: |
|
765 | 796 | db_table = 'abs_beams' |
|
766 | 797 | |
|
767 | 798 | def __unicode__(self): |
|
768 | 799 | return u'%s' % (self.name) |
|
769 | 800 | |
|
770 | 801 | def parms_to_dict(self): |
|
771 | 802 | |
|
772 | 803 | #Update data |
|
773 | 804 | self.modules_6bits() |
|
774 | 805 | |
|
775 | 806 | parameters = {} |
|
776 | 807 | |
|
777 | 808 | parameters['name'] = self.name |
|
778 | 809 | parameters['antenna'] = ast.literal_eval(self.antenna) |
|
779 | 810 | parameters['abs_conf'] = self.abs_conf.name |
|
780 | 811 | parameters['tx'] = ast.literal_eval(self.tx) |
|
781 | 812 | parameters['rx'] = ast.literal_eval(self.rx) |
|
782 | 813 | parameters['s_time'] = self.s_time.strftime("%H:%M:%S") |
|
783 | 814 | parameters['e_time'] = self.e_time.strftime("%H:%M:%S") |
|
784 | 815 | parameters['configuration'] = ast.literal_eval(self.modules_conf) |
|
785 | 816 | parameters['ues'] = ast.literal_eval(self.ues) |
|
786 | 817 | parameters['only_rx'] = json.loads(self.only_rx) |
|
787 | 818 | |
|
788 | 819 | return parameters |
|
789 | 820 | |
|
790 | 821 | def dict_to_parms(self, parameters): |
|
791 | 822 | |
|
792 | 823 | self.name = parameters['name'] |
|
793 | 824 | self.antenna = json.dumps(parameters['antenna']) |
|
794 | 825 | #self.abs_conf = parameters['abs_conf'] |
|
795 | 826 | self.tx = json.dumps(parameters['tx']) |
|
796 | 827 | self.rx = json.dumps(parameters['rx']) |
|
797 | 828 | #self.s_time = parameters['s_time'] |
|
798 | 829 | #self.e_time = parameters['e_time'] |
|
799 | 830 | self.ues = json.dumps(parameters['ues']) |
|
800 | 831 | self.only_rx = json.dumps(parameters['only_rx']) |
|
801 | 832 | |
|
802 | 833 | self.modules_6bits() |
|
803 | 834 | self.save() |
|
804 | 835 | |
|
805 | 836 | |
|
806 | 837 | def clone(self, **kwargs): |
|
807 | 838 | |
|
808 | 839 | self.pk = None |
|
809 | 840 | self.id = None |
|
810 | 841 | for attr, value in kwargs.items(): |
|
811 | 842 | setattr(self, attr, value) |
|
812 | 843 | |
|
813 | 844 | self.save() |
|
814 | 845 | |
|
815 | 846 | return self |
|
816 | 847 | |
|
817 | 848 | |
|
818 | 849 | |
|
819 | 850 | def module_6bits(self, module): |
|
820 | 851 | """ |
|
821 | 852 | This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module |
|
822 | 853 | """ |
|
823 | 854 | if module > 64: |
|
824 | 855 | beam_bits = "" |
|
825 | 856 | return beam_bits |
|
826 | 857 | |
|
827 | 858 | data = ast.literal_eval(self.antenna) |
|
828 | 859 | up_data = data['antenna_up'] |
|
829 | 860 | down_data = data['antenna_down'] |
|
830 | 861 | |
|
831 | 862 | pos = ip2position(module) |
|
832 | 863 | up_value = up_data[pos[0]][pos[1]] |
|
833 | 864 | down_value = down_data[pos[0]][pos[1]] |
|
834 | 865 | |
|
835 | 866 | up_bits = up_conv_bits(up_value) |
|
836 | 867 | down_bits = down_conv_bits(down_value) |
|
837 | 868 | beam_bits = up_bits+down_bits |
|
838 | 869 | |
|
839 | 870 | return beam_bits |
|
840 | 871 | |
|
841 | 872 | def modules_6bits(self): |
|
842 | 873 | """ |
|
843 | 874 | This function returns 6bits from every abs module (1-64) in a dict |
|
844 | 875 | """ |
|
845 | 876 | modules_configuration = ast.literal_eval(self.modules_conf) |
|
846 | 877 | |
|
847 | 878 | for i in range(1,65): |
|
848 | 879 | modules_configuration[str(i)] = self.module_6bits(i) |
|
849 | 880 | |
|
850 | 881 | self.modules_conf = json.dumps(modules_configuration) |
|
851 | 882 | self.save() |
|
852 | 883 | |
|
853 | 884 | return self.modules_conf |
|
854 | 885 | |
|
855 | 886 | |
|
856 | 887 | def set_as_activebeam(self): |
|
857 | 888 | """ |
|
858 | 889 | This function set this beam as the active beam of its ABS Configuration. |
|
859 | 890 | """ |
|
860 | 891 | self.abs_conf.active_beam = json.dumps({'active_beam': self.id}) |
|
861 | 892 | self.abs_conf.save() |
|
862 | 893 | |
|
863 | 894 | return |
|
864 | 895 | |
|
865 | 896 | |
|
866 | 897 | @property |
|
867 | 898 | def get_upvalues(self): |
|
868 | 899 | """ |
|
869 | 900 | This function reads antenna pattern and show the up-value of one abs module |
|
870 | 901 | """ |
|
871 | 902 | |
|
872 | 903 | data = ast.literal_eval(self.antenna) |
|
873 | 904 | up_data = data['antenna_up'] |
|
874 | 905 | |
|
875 | 906 | up_values = [] |
|
876 | 907 | for data in up_data: |
|
877 | 908 | for i in range(0,8): |
|
878 | 909 | up_values.append(data[i]) |
|
879 | 910 | |
|
880 | 911 | return up_values |
|
881 | 912 | |
|
882 | 913 | @property |
|
883 | 914 | def antenna_upvalues(self): |
|
884 | 915 | """ |
|
885 | 916 | This function reads antenna pattern and show the up - values of one abs beam |
|
886 | 917 | in a particular order |
|
887 | 918 | """ |
|
888 | 919 | data = ast.literal_eval(self.antenna) |
|
889 | 920 | up_data = data['antenna_up'] |
|
890 | 921 | |
|
891 | 922 | return up_data |
|
892 | 923 | |
|
893 | 924 | @property |
|
894 | 925 | def antenna_downvalues(self): |
|
895 | 926 | """ |
|
896 | 927 | This function reads antenna pattern and show the down - values of one abs beam |
|
897 | 928 | in a particular order |
|
898 | 929 | """ |
|
899 | 930 | data = ast.literal_eval(self.antenna) |
|
900 | 931 | down_data = data['antenna_down'] |
|
901 | 932 | |
|
902 | 933 | return down_data |
|
903 | 934 | |
|
904 | 935 | @property |
|
905 | 936 | def get_downvalues(self): |
|
906 | 937 | """ |
|
907 | 938 | This function reads antenna pattern and show the down-value of one abs module |
|
908 | 939 | """ |
|
909 | 940 | |
|
910 | 941 | data = ast.literal_eval(self.antenna) |
|
911 | 942 | down_data = data['antenna_down'] |
|
912 | 943 | |
|
913 | 944 | down_values = [] |
|
914 | 945 | for data in down_data: |
|
915 | 946 | for i in range(0,8): |
|
916 | 947 | down_values.append(data[i]) |
|
917 | 948 | |
|
918 | 949 | return down_values |
|
919 | 950 | |
|
920 | 951 | @property |
|
921 | 952 | def get_up_ues(self): |
|
922 | 953 | """ |
|
923 | 954 | This function shows the up-ues-value of one beam |
|
924 | 955 | """ |
|
925 | 956 | data = ast.literal_eval(self.ues) |
|
926 | 957 | up_ues = data['up'] |
|
927 | 958 | |
|
928 | 959 | return up_ues |
|
929 | 960 | |
|
930 | 961 | @property |
|
931 | 962 | def get_down_ues(self): |
|
932 | 963 | """ |
|
933 | 964 | This function shows the down-ues-value of one beam |
|
934 | 965 | """ |
|
935 | 966 | data = ast.literal_eval(self.ues) |
|
936 | 967 | down_ues = data['down'] |
|
937 | 968 | |
|
938 | 969 | return down_ues |
|
939 | 970 | |
|
940 | 971 | @property |
|
941 | 972 | def get_up_onlyrx(self): |
|
942 | 973 | """ |
|
943 | 974 | This function shows the up-onlyrx-value of one beam |
|
944 | 975 | """ |
|
945 | 976 | data = json.loads(self.only_rx) |
|
946 | 977 | up_onlyrx = data['up'] |
|
947 | 978 | |
|
948 | 979 | return up_onlyrx |
|
949 | 980 | |
|
950 | 981 | @property |
|
951 | 982 | def get_down_onlyrx(self): |
|
952 | 983 | """ |
|
953 | 984 | This function shows the down-onlyrx-value of one beam |
|
954 | 985 | """ |
|
955 | 986 | data = json.loads(self.only_rx) |
|
956 | 987 | down_onlyrx = data['down'] |
|
957 | 988 | |
|
958 | 989 | return down_onlyrx |
|
959 | 990 | |
|
960 | 991 | @property |
|
961 | 992 | def get_tx(self): |
|
962 | 993 | """ |
|
963 | 994 | This function shows the tx-values of one beam |
|
964 | 995 | """ |
|
965 | 996 | data = json.loads(self.tx) |
|
966 | 997 | |
|
967 | 998 | return data |
|
968 | 999 | |
|
969 | 1000 | @property |
|
970 | 1001 | def get_uptx(self): |
|
971 | 1002 | """ |
|
972 | 1003 | This function shows the up-tx-values of one beam |
|
973 | 1004 | """ |
|
974 | 1005 | data = json.loads(self.tx) |
|
975 | 1006 | up_data = data['up'] |
|
976 | 1007 | |
|
977 | 1008 | up_values = [] |
|
978 | 1009 | for data in up_data: |
|
979 | 1010 | for i in range(0,8): |
|
980 | 1011 | up_values.append(data[i]) |
|
981 | 1012 | |
|
982 | 1013 | return up_values |
|
983 | 1014 | |
|
984 | 1015 | @property |
|
985 | 1016 | def get_downtx(self): |
|
986 | 1017 | """ |
|
987 | 1018 | This function shows the down-tx-values of one beam |
|
988 | 1019 | """ |
|
989 | 1020 | data = json.loads(self.tx) |
|
990 | 1021 | down_data = data['down'] |
|
991 | 1022 | |
|
992 | 1023 | down_values = [] |
|
993 | 1024 | for data in down_data: |
|
994 | 1025 | for i in range(0,8): |
|
995 | 1026 | down_values.append(data[i]) |
|
996 | 1027 | |
|
997 | 1028 | return down_values |
|
998 | 1029 | |
|
999 | 1030 | |
|
1000 | 1031 | |
|
1001 | 1032 | @property |
|
1002 | 1033 | def get_rx(self): |
|
1003 | 1034 | """ |
|
1004 | 1035 | This function shows the rx-values of one beam |
|
1005 | 1036 | """ |
|
1006 | 1037 | data = json.loads(self.rx) |
|
1007 | 1038 | |
|
1008 | 1039 | return data |
|
1009 | 1040 | |
|
1010 | 1041 | @property |
|
1011 | 1042 | def get_uprx(self): |
|
1012 | 1043 | """ |
|
1013 | 1044 | This function shows the up-rx-values of one beam |
|
1014 | 1045 | """ |
|
1015 | 1046 | data = json.loads(self.rx) |
|
1016 | 1047 | up_data = data['up'] |
|
1017 | 1048 | |
|
1018 | 1049 | up_values = [] |
|
1019 | 1050 | for data in up_data: |
|
1020 | 1051 | for i in range(0,8): |
|
1021 | 1052 | up_values.append(data[i]) |
|
1022 | 1053 | |
|
1023 | 1054 | return up_values |
|
1024 | 1055 | |
|
1025 | 1056 | @property |
|
1026 | 1057 | def get_downrx(self): |
|
1027 | 1058 | """ |
|
1028 | 1059 | This function shows the down-rx-values of one beam |
|
1029 | 1060 | """ |
|
1030 | 1061 | data = json.loads(self.rx) |
|
1031 | 1062 | down_data = data['down'] |
|
1032 | 1063 | |
|
1033 | 1064 | down_values = [] |
|
1034 | 1065 | for data in down_data: |
|
1035 | 1066 | for i in range(0,8): |
|
1036 | 1067 | down_values.append(data[i]) |
|
1037 | 1068 | |
|
1038 | 1069 | return down_values |
@@ -1,538 +1,537 | |||
|
1 | 1 | {% extends "dev_conf.html" %} |
|
2 | 2 | |
|
3 | 3 | {% block extra-menu-actions %} |
|
4 | 4 | <li><a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank"><span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Patterns </a></li> |
|
5 | 5 | <!--<li><a href="{{ dev_conf.get_absolute_url_write }}"><span class="glyphicon glyphicon-download" aria-hidden="true"></span> Write</a></li>--> |
|
6 | 6 | {% endblock %} |
|
7 | 7 | |
|
8 | 8 | {% block extra-content %} |
|
9 | 9 | <style> |
|
10 | 10 | |
|
11 | 11 | .abs { |
|
12 | 12 | border: 2px solid #00334d; |
|
13 | 13 | vertical-align: center; |
|
14 | 14 | display: inline-block; |
|
15 | 15 | } |
|
16 | 16 | .abs tr:nth-child(1){ |
|
17 | 17 | border-bottom: 1px dashed #00334d; |
|
18 | 18 | } |
|
19 | 19 | .abs tr{ |
|
20 | 20 | border-bottom: 0px solid #00334d; |
|
21 | 21 | } |
|
22 | 22 | .abs td { |
|
23 | 23 | border-right: 1px dashed #00334d; |
|
24 | 24 | text-align: center; |
|
25 | 25 | padding: 5px; |
|
26 | 26 | } |
|
27 | 27 | |
|
28 | 28 | |
|
29 | 29 | .legend { |
|
30 | 30 | margin-left: 15px; |
|
31 | 31 | display: inline-block; |
|
32 | 32 | border: 2px solid #00334d; |
|
33 | 33 | vertical-align: top; |
|
34 | 34 | } |
|
35 | 35 | .legend th{ |
|
36 | 36 | border-bottom: 1px dashed #00334d; |
|
37 | 37 | font-weight: bold; |
|
38 | 38 | vertical-align: center; |
|
39 | 39 | text-align: center; |
|
40 | 40 | } |
|
41 | 41 | .legend td { |
|
42 | 42 | padding: 2px; |
|
43 | 43 | text-align: center; |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | |
|
47 | 47 | .north { |
|
48 | 48 | border: 2px solid #00334d; |
|
49 | 49 | vertical-align: center; |
|
50 | 50 | font-weight: bold; |
|
51 | 51 | } |
|
52 | 52 | .north tr{ |
|
53 | 53 | border: 1px solid #ffffff; |
|
54 | ||
|
54 | ||
|
55 | 55 | } |
|
56 | 56 | .north td{ |
|
57 | 57 | border: 2px solid #e2e2e7; |
|
58 | 58 | text-align: center; |
|
59 | 59 | padding: 1px 15px 1px 15px; |
|
60 | 60 | } |
|
61 | 61 | .north tr:nth-child(even) td:nth-child(n){ |
|
62 | 62 | border-bottom: 12px solid #e2e2e7; |
|
63 | 63 | } |
|
64 | 64 | .north td:nth-child(n) { |
|
65 | 65 | border-right: 12px solid #e2e2e7; |
|
66 | 66 | } |
|
67 | 67 | .north td:nth-last-child(4n+1) { |
|
68 | 68 | border-right: 2px solid #e2e2e7; |
|
69 | 69 | } |
|
70 | 70 | .north tr:nth-last-child(1) td:nth-child(n){ |
|
71 | 71 | border-bottom: 3px solid #e2e2e7; |
|
72 | 72 | } |
|
73 | 73 | |
|
74 | 74 | |
|
75 | 75 | |
|
76 | 76 | .east { |
|
77 | 77 | border: 2px solid #00334d; |
|
78 | 78 | vertical-align: center; |
|
79 | 79 | font-weight: bold; |
|
80 | 80 | } |
|
81 | 81 | .east tr{ |
|
82 | 82 | border: 1px solid #ffffff; |
|
83 | 83 | } |
|
84 | 84 | .east td{ |
|
85 | 85 | border: 2px solid #e2e2e7; |
|
86 | 86 | text-align: center; |
|
87 | 87 | padding: 1px 15px 1px 15px; |
|
88 | 88 | } |
|
89 | 89 | .east tr:nth-child(even) td:nth-child(n){ |
|
90 | 90 | border-bottom: 12px solid #e2e2e7; |
|
91 | 91 | } |
|
92 | 92 | .east td:nth-child(n) { |
|
93 | 93 | border-right: 12px solid #e2e2e7; |
|
94 | 94 | } |
|
95 | 95 | .east td:nth-last-child(4n+1) { |
|
96 | 96 | border-right: 2px solid #e2e2e7; |
|
97 | 97 | } |
|
98 | 98 | .east tr:nth-last-child(1) td:nth-child(n){ |
|
99 | 99 | border-bottom: 3px solid #e2e2e7; |
|
100 | 100 | } |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | |
|
104 | 104 | |
|
105 | 105 | .west { |
|
106 | 106 | border: 2px solid #00334d; |
|
107 | 107 | vertical-align: center; |
|
108 | 108 | font-weight: bold; |
|
109 | 109 | } |
|
110 | 110 | .west tr{ |
|
111 | 111 | border: 1px solid #ffffff; |
|
112 | 112 | } |
|
113 | 113 | .west td{ |
|
114 | 114 | border: 2px solid #e2e2e7; |
|
115 | 115 | text-align: center; |
|
116 | 116 | padding: 1px 15px 1px 15px; |
|
117 | 117 | } |
|
118 | 118 | .west tr:nth-child(even) td:nth-child(n){ |
|
119 | 119 | border-bottom: 12px solid #e2e2e7; |
|
120 | 120 | } |
|
121 | 121 | .west td:nth-child(n) { |
|
122 | 122 | border-right: 12px solid #e2e2e7; |
|
123 | 123 | } |
|
124 | 124 | .west td:nth-last-child(4n+1) { |
|
125 | 125 | border-right: 2px solid #e2e2e7; |
|
126 | 126 | } |
|
127 | 127 | .west tr:nth-last-child(1) td:nth-child(n){ |
|
128 | 128 | border-bottom: 3px solid #e2e2e7; |
|
129 | 129 | } |
|
130 | 130 | |
|
131 | 131 | |
|
132 | 132 | |
|
133 | 133 | |
|
134 | 134 | .south { |
|
135 | 135 | border: 2px solid #00334d; |
|
136 | 136 | vertical-align: center; |
|
137 | 137 | font-weight: bold; |
|
138 | 138 | } |
|
139 | 139 | .south tr{ |
|
140 | 140 | border: 1px solid #ffffff; |
|
141 | 141 | } |
|
142 | 142 | .south td{ |
|
143 | 143 | border: 2px solid #e2e2e7; |
|
144 | 144 | text-align: center; |
|
145 | 145 | padding: 1px 15px 1px 15px; |
|
146 | 146 | } |
|
147 | 147 | .south tr:nth-child(even) td:nth-child(n){ |
|
148 | 148 | border-bottom: 12px solid #e2e2e7; |
|
149 | 149 | } |
|
150 | 150 | .south td:nth-child(n) { |
|
151 | 151 | border-right: 12px solid #e2e2e7; |
|
152 | 152 | } |
|
153 | 153 | .south td:nth-last-child(4n+1) { |
|
154 | 154 | border-right: 2px solid #e2e2e7; |
|
155 | 155 | } |
|
156 | 156 | .south tr:nth-last-child(1) td:nth-child(n){ |
|
157 | 157 | border-bottom: 3px solid #e2e2e7; |
|
158 | 158 | } |
|
159 | 159 | |
|
160 | 160 | |
|
161 | 161 | |
|
162 | 162 | |
|
163 | 163 | </style> |
|
164 | 164 | |
|
165 | 165 | |
|
166 | 166 | {% if beams %} |
|
167 | 167 | |
|
168 | 168 | |
|
169 | 169 | |
|
170 | 170 | <h4>Beams:</h4> |
|
171 | 171 | <div class="container"> |
|
172 | 172 | <ul class="nav nav-pills"> |
|
173 | 173 | {% for beam in beams %} |
|
174 | 174 | <li > |
|
175 | 175 | <a data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a> |
|
176 | 176 | </li> |
|
177 | 177 | {% endfor %} |
|
178 | 178 | </ul> |
|
179 | 179 | |
|
180 | ||
|
180 | ||
|
181 | 181 | <div class="tab-content"> |
|
182 | 182 | <div id="home" class="tab-pane fade in active"> |
|
183 | 183 | <!----> |
|
184 | 184 | {% if active_beam %} |
|
185 |
<h3>Active Beam: {{active_beam.name}}</h3> |
|
|
185 | <h3>Active Beam: {{active_beam.name}}</h3> | |
|
186 | 186 | |
|
187 | 187 | <table id="abs_pattern" class="abs"> |
|
188 | 188 | <tr> |
|
189 | 189 | <td> <b>North Quarter</b> |
|
190 | 190 | <table class="north "> |
|
191 | 191 | <tr> |
|
192 | 192 | <td {{color_status.1}}>{{active_beam.get_upvalues.0}}</td> <td {{color_status.2}}>{{active_beam.get_upvalues.1}}</td> <td {{color_status.3}}>{{active_beam.get_upvalues.2}}</td> <td {{color_status.4}}>{{active_beam.get_upvalues.3}}</td> |
|
193 | 193 | </tr> |
|
194 | 194 | <tr> |
|
195 | 195 | <td {{color_status.1}}>{{active_beam.get_downvalues.0}}</td> <td {{color_status.2}}>{{active_beam.get_downvalues.1}}</td> <td {{color_status.3}}>{{active_beam.get_downvalues.2}}</td> <td {{color_status.4}}>{{active_beam.get_downvalues.3}}</td> |
|
196 | 196 | </tr> |
|
197 | 197 | <tr> |
|
198 | 198 | <td {{color_status.9}}>{{active_beam.get_upvalues.8}}</td> <td {{color_status.10}}>{{active_beam.get_upvalues.9}}</td> <td {{color_status.11}}>{{active_beam.get_upvalues.10}}</td> <td {{color_status.12}}>{{active_beam.get_upvalues.11}}</td> |
|
199 | 199 | </tr> |
|
200 | 200 | <tr> |
|
201 | 201 | <td {{color_status.9}}>{{active_beam.get_downvalues.8}}</td> <td {{color_status.10}}>{{active_beam.get_downvalues.9}}</td> <td {{color_status.11}}>{{active_beam.get_downvalues.10}}</td> <td {{color_status.12}}>{{active_beam.get_downvalues.11}}</td> |
|
202 | 202 | </tr> |
|
203 | 203 | <tr> |
|
204 | 204 | <td {{color_status.17}}>{{active_beam.get_upvalues.16}}</td> <td {{color_status.18}}>{{active_beam.get_upvalues.17}}</td> <td {{color_status.19}}>{{active_beam.get_upvalues.18}}</td> <td {{color_status.20}}>{{active_beam.get_upvalues.19}}</td> |
|
205 | 205 | </tr> |
|
206 | 206 | <tr> |
|
207 | 207 | <td {{color_status.17}}>{{active_beam.get_downvalues.16}}</td> <td {{color_status.18}}>{{active_beam.get_downvalues.17}}</td> <td {{color_status.19}}>{{active_beam.get_downvalues.18}}</td> <td {{color_status.20}}>{{active_beam.get_downvalues.19}}</td> |
|
208 | 208 | </tr> |
|
209 | 209 | <tr> |
|
210 | 210 | <td {{color_status.25}}>{{active_beam.get_upvalues.24}}</td> <td {{color_status.26}}>{{active_beam.get_upvalues.25}}</td> <td {{color_status.27}}>{{active_beam.get_upvalues.26}}</td> <td {{color_status.28}}>{{active_beam.get_upvalues.27}}</td> |
|
211 | 211 | </tr> |
|
212 | 212 | <tr> |
|
213 | 213 | <td {{color_status.25}}>{{active_beam.get_downvalues.24}}</td> <td {{color_status.26}}>{{active_beam.get_downvalues.25}}</td> <td {{color_status.27}}>{{active_beam.get_downvalues.26}}</td> <td {{color_status.28}}>{{active_beam.get_downvalues.27}}</td> |
|
214 | 214 | </tr> |
|
215 | 215 | </table> |
|
216 | 216 | </td> |
|
217 | 217 | <td> <b>East Quarter</b> |
|
218 | 218 | <table class="east "> |
|
219 | 219 | <tr> |
|
220 | 220 | <td {{color_status.5}}>{{active_beam.get_upvalues.4}}</td> <td {{color_status.6}}>{{active_beam.get_upvalues.5}}</td> <td {{color_status.7}}>{{active_beam.get_upvalues.6}}</td> <td {{color_status.8}}>{{active_beam.get_upvalues.7}}</td> |
|
221 | 221 | </tr> |
|
222 | 222 | <tr> |
|
223 | 223 | <td {{color_status.5}}>{{active_beam.get_downvalues.4}}</td> <td {{color_status.6}}>{{active_beam.get_downvalues.5}}</td> <td {{color_status.7}}>{{active_beam.get_downvalues.6}}</td> <td {{color_status.8}}>{{active_beam.get_downvalues.7}}</td> |
|
224 | 224 | </tr> |
|
225 | 225 | <tr> |
|
226 | 226 | <td {{color_status.13}}>{{active_beam.get_upvalues.12}}</td> <td {{color_status.14}}>{{active_beam.get_upvalues.13}}</td> <td {{color_status.15}}>{{active_beam.get_upvalues.14}}</td> <td {{color_status.16}}>{{active_beam.get_upvalues.15}}</td> |
|
227 | 227 | </tr> |
|
228 | 228 | <tr> |
|
229 | 229 | <td {{color_status.13}}>{{active_beam.get_downvalues.12}}</td> <td {{color_status.14}}>{{active_beam.get_downvalues.13}}</td> <td {{color_status.15}}>{{active_beam.get_downvalues.14}}</td> <td {{color_status.16}}>{{active_beam.get_downvalues.15}}</td> |
|
230 | 230 | </tr> |
|
231 | 231 | <tr> |
|
232 | 232 | <td {{color_status.21}}>{{active_beam.get_upvalues.20}}</td> <td {{color_status.22}}>{{active_beam.get_upvalues.21}}</td> <td {{color_status.23}}>{{active_beam.get_upvalues.22}}</td> <td {{color_status.24}}>{{active_beam.get_upvalues.23}}</td> |
|
233 | 233 | </tr> |
|
234 | 234 | <tr> |
|
235 | 235 | <td {{color_status.21}}>{{active_beam.get_downvalues.20}}</td> <td {{color_status.22}}>{{active_beam.get_downvalues.21}}</td> <td {{color_status.23}}>{{active_beam.get_downvalues.22}}</td> <td {{color_status.24}}>{{active_beam.get_downvalues.23}}</td> |
|
236 | 236 | </tr> |
|
237 | 237 | <tr> |
|
238 | 238 | <td {{color_status.29}}>{{active_beam.get_upvalues.28}}</td> <td {{color_status.30}}>{{active_beam.get_upvalues.29}}</td> <td {{color_status.31}}>{{active_beam.get_upvalues.30}}</td> <td {{color_status.32}}>{{active_beam.get_upvalues.31}}</td> |
|
239 | 239 | </tr> |
|
240 | 240 | <tr> |
|
241 | 241 | <td {{color_status.29}}>{{active_beam.get_downvalues.28}}</td> <td {{color_status.30}}>{{active_beam.get_downvalues.29}}</td> <td {{color_status.31}}>{{active_beam.get_downvalues.30}}</td> <td {{color_status.32}}>{{active_beam.get_downvalues.31}}</td> |
|
242 | 242 | </tr> |
|
243 | 243 | </table> |
|
244 | 244 | </td> |
|
245 | 245 | </tr> |
|
246 | 246 | <tr> |
|
247 | 247 | <td> <b>West Quarter</b> |
|
248 | 248 | <table class="west "> |
|
249 | 249 | <tr> |
|
250 | 250 | <td {{color_status.33}}>{{active_beam.get_upvalues.32}}</td> <td {{color_status.34}}>{{active_beam.get_upvalues.33}}</td> <td {{color_status.35}}>{{active_beam.get_upvalues.34}}</td> <td {{color_status.36}}>{{active_beam.get_upvalues.35}}</td> |
|
251 | 251 | </tr> |
|
252 | 252 | <tr> |
|
253 | 253 | <td {{color_status.33}}>{{active_beam.get_downvalues.32}}</td> <td {{color_status.34}}>{{active_beam.get_downvalues.33}}</td> <td {{color_status.35}}>{{active_beam.get_downvalues.34}}</td> <td {{color_status.36}}>{{active_beam.get_downvalues.35}}</td> |
|
254 | 254 | </tr> |
|
255 | 255 | <tr> |
|
256 | 256 | <td {{color_status.41}}>{{active_beam.get_upvalues.40}}</td> <td {{color_status.42}}>{{active_beam.get_upvalues.41}}</td> <td {{color_status.43}}>{{active_beam.get_upvalues.42}}</td> <td {{color_status.44}}>{{active_beam.get_upvalues.43}}</td> |
|
257 | 257 | </tr> |
|
258 | 258 | <tr> |
|
259 | 259 | <td {{color_status.41}}>{{active_beam.get_downvalues.40}}</td> <td {{color_status.42}}>{{active_beam.get_downvalues.41}}</td> <td {{color_status.43}}>{{active_beam.get_downvalues.42}}</td> <td {{color_status.44}}>{{active_beam.get_downvalues.43}}</td> |
|
260 | 260 | </tr> |
|
261 | 261 | <tr> |
|
262 | 262 | <td {{color_status.49}}>{{active_beam.get_upvalues.48}}</td> <td {{color_status.50}}>{{active_beam.get_upvalues.49}}</td> <td {{color_status.51}}>{{active_beam.get_upvalues.50}}</td> <td {{color_status.52}}>{{active_beam.get_upvalues.51}}</td> |
|
263 | 263 | </tr> |
|
264 | 264 | <tr> |
|
265 | 265 | <td {{color_status.49}}>{{active_beam.get_downvalues.48}}</td> <td {{color_status.50}}>{{active_beam.get_downvalues.49}}</td> <td {{color_status.51}}>{{active_beam.get_downvalues.50}}</td> <td {{color_status.52}}>{{active_beam.get_downvalues.51}}</td> |
|
266 | 266 | </tr> |
|
267 | 267 | <tr> |
|
268 | 268 | <td {{color_status.57}}>{{active_beam.get_upvalues.56}}</td> <td {{color_status.58}}>{{active_beam.get_upvalues.57}}</td> <td {{color_status.59}}>{{active_beam.get_upvalues.58}}</td> <td {{color_status.60}}>{{active_beam.get_upvalues.59}}</td> |
|
269 | 269 | </tr> |
|
270 | 270 | <tr> |
|
271 | 271 | <td {{color_status.57}}>{{active_beam.get_downvalues.56}}</td> <td {{color_status.58}}>{{active_beam.get_downvalues.57}}</td> <td {{color_status.59}}>{{active_beam.get_downvalues.58}}</td> <td {{color_status.60}}>{{active_beam.get_downvalues.59}}</td> |
|
272 | 272 | </tr> |
|
273 | 273 | </table> |
|
274 | 274 | </td> |
|
275 | 275 | <td> <b>South Quarter</b> |
|
276 | 276 | <table class="south "> |
|
277 | 277 | <tr> |
|
278 | 278 | <td {{color_status.37}}>{{active_beam.get_upvalues.36}}</td> <td {{color_status.38}}>{{active_beam.get_upvalues.37}}</td> <td {{color_status.39}}>{{active_beam.get_upvalues.38}}</td> <td {{color_status.40}}>{{active_beam.get_upvalues.39}}</td> |
|
279 | 279 | </tr> |
|
280 | 280 | <tr> |
|
281 | 281 | <td {{color_status.37}}>{{active_beam.get_downvalues.36}}</td> <td {{color_status.38}}>{{active_beam.get_downvalues.37}}</td> <td {{color_status.39}}>{{active_beam.get_downvalues.38}}</td> <td {{color_status.40}}>{{active_beam.get_downvalues.39}}</td> |
|
282 | 282 | </tr> |
|
283 | 283 | <tr> |
|
284 | 284 | <td {{color_status.45}}>{{active_beam.get_upvalues.44}}</td> <td {{color_status.46}}>{{active_beam.get_upvalues.45}}</td> <td {{color_status.47}}>{{active_beam.get_upvalues.46}}</td> <td {{color_status.48}}>{{active_beam.get_upvalues.47}}</td> |
|
285 | 285 | </tr> |
|
286 | 286 | <tr> |
|
287 | 287 | <td {{color_status.45}}>{{active_beam.get_downvalues.44}}</td> <td {{color_status.46}}>{{active_beam.get_downvalues.45}}</td> <td {{color_status.47}}>{{active_beam.get_downvalues.46}}</td> <td {{color_status.48}}>{{active_beam.get_downvalues.47}}</td> |
|
288 | 288 | </tr> |
|
289 | 289 | <tr> |
|
290 | 290 | <td {{color_status.53}}>{{active_beam.get_upvalues.52}}</td> <td {{color_status.54}}>{{active_beam.get_upvalues.53}}</td> <td {{color_status.55}}>{{active_beam.get_upvalues.54}}</td> <td {{color_status.56}}>{{active_beam.get_upvalues.55}}</td> |
|
291 | 291 | </tr> |
|
292 | 292 | <tr> |
|
293 | 293 | <td {{color_status.53}}>{{active_beam.get_downvalues.52}}</td> <td {{color_status.54}}>{{active_beam.get_downvalues.53}}</td> <td {{color_status.55}}>{{active_beam.get_downvalues.54}}</td> <td {{color_status.56}}>{{active_beam.get_downvalues.55}}</td> |
|
294 | 294 | </tr> |
|
295 | 295 | <tr> |
|
296 | 296 | <td {{color_status.61}}>{{active_beam.get_upvalues.60}}</td> <td {{color_status.62}}>{{active_beam.get_upvalues.61}}</td> <td {{color_status.63}}>{{active_beam.get_upvalues.62}}</td> <td {{color_status.64}}>{{active_beam.get_upvalues.63}}</td> |
|
297 | 297 | </tr> |
|
298 | 298 | <tr> |
|
299 | 299 | <td {{color_status.61}}>{{active_beam.get_downvalues.60}}</td> <td {{color_status.62}}>{{active_beam.get_downvalues.61}}</td> <td {{color_status.63}}>{{active_beam.get_downvalues.62}}</td> <td {{color_status.64}}>{{active_beam.get_downvalues.63}}</td> |
|
300 | 300 | </tr> |
|
301 | 301 | </table> |
|
302 | 302 | </td> |
|
303 | 303 | </tr> |
|
304 | 304 | </table> |
|
305 | 305 | |
|
306 | 306 | |
|
307 | ||
|
307 | ||
|
308 | 308 | <table class="legend"> |
|
309 | 309 | <tr> |
|
310 | 310 | <th colspan="2">Legend</th> |
|
311 | 311 | </tr> |
|
312 | 312 | <tr> |
|
313 |
<td |
|
|
313 | <td class="text-danger"><i>RED</i></td><td>Disconnected</td> | |
|
314 | 314 | </tr> |
|
315 | 315 | <tr> |
|
316 |
<td |
|
|
316 | <td class="text-warning"><i>ORANGE</i></td><td>Connected</td> | |
|
317 | 317 | </tr> |
|
318 | 318 | <tr> |
|
319 |
<td |
|
|
320 | </td> | |
|
319 | <td class="text-success"><i>GREEN</i></td><td>Running </td> | |
|
321 | 320 | </tr> |
|
322 | 321 | <!-- |
|
323 | 322 | <tr> |
|
324 | 323 | <td colspan="2"> |
|
325 | 324 | <button style="margin: 10px;" id="sendbeam" type="button" class="btn btn-default"> |
|
326 | 325 | <span class="glyphicon glyphicon-export" aria-hidden="true"></span> |
|
327 | 326 | Change Beam</button> |
|
328 | 327 | </td> |
|
329 | 328 | </tr> |
|
330 | 329 | --> |
|
331 | 330 | </table> |
|
332 | ||
|
333 | ||
|
331 | ||
|
332 | ||
|
334 | 333 | |
|
335 | 334 | |
|
336 | 335 | {% else %} |
|
337 | 336 | <p><i>This ABS Configuration does not have a current active ABS Beam...<br> |
|
338 | 337 | Please send Beam List to ABS modules. </i></p> |
|
339 | 338 | |
|
340 | 339 | {% endif %} |
|
341 | 340 | |
|
342 | 341 | |
|
343 | 342 | </div> |
|
344 | ||
|
345 | ||
|
343 | ||
|
344 | ||
|
346 | 345 | |
|
347 | 346 | {% for beam in beams %} |
|
348 | 347 | <div id="menu{{forloop.counter}}" class="tab-pane fade"> |
|
349 | 348 | <h3>{%if active_beam.id == beam.id%}Active Beam: {%endif%}{{beam.name}}</h3> |
|
350 | 349 | <!--<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>--> |
|
351 | 350 | <table id="abs_pattern{{forloop.counter}}" class="abs"> |
|
352 | 351 | <tr> |
|
353 | 352 | <td> <b>North Quarter</b> |
|
354 | 353 | <table class="north "> |
|
355 | 354 | <tr> |
|
356 | 355 | <td {{beam.color_status.1}}>{{beam.get_upvalues.0}}</td> <td {{beam.color_status.2}}>{{beam.get_upvalues.1}}</td> <td {{beam.color_status.3}}>{{beam.get_upvalues.2}}</td> <td {{beam.color_status.4}}>{{beam.get_upvalues.3}}</td> |
|
357 | 356 | </tr> |
|
358 | 357 | <tr> |
|
359 | 358 | <td {{beam.color_status.1}}>{{beam.get_downvalues.0}}</td> <td {{beam.color_status.2}}>{{beam.get_downvalues.1}}</td> <td {{beam.color_status.3}}>{{beam.get_downvalues.2}}</td> <td {{beam.color_status.4}}>{{beam.get_downvalues.3}}</td> |
|
360 | 359 | </tr> |
|
361 | 360 | <tr> |
|
362 | 361 | <td {{beam.color_status.9}}>{{beam.get_upvalues.8}}</td> <td {{beam.color_status.10}}>{{beam.get_upvalues.9}}</td> <td {{beam.color_status.11}}>{{beam.get_upvalues.10}}</td> <td {{beam.color_status.12}}>{{beam.get_upvalues.11}}</td> |
|
363 | 362 | </tr> |
|
364 | 363 | <tr> |
|
365 | 364 | <td {{beam.color_status.9}}>{{beam.get_downvalues.8}}</td> <td {{beam.color_status.10}}>{{beam.get_downvalues.9}}</td> <td {{beam.color_status.11}}>{{beam.get_downvalues.10}}</td> <td {{beam.color_status.12}}>{{beam.get_downvalues.11}}</td> |
|
366 | 365 | </tr> |
|
367 | 366 | <tr> |
|
368 | 367 | <td {{beam.color_status.17}}>{{beam.get_upvalues.16}}</td> <td {{beam.color_status.18}}>{{beam.get_upvalues.17}}</td> <td {{beam.color_status.19}}>{{beam.get_upvalues.18}}</td> <td {{beam.color_status.20}}>{{beam.get_upvalues.19}}</td> |
|
369 | 368 | </tr> |
|
370 | 369 | <tr> |
|
371 | 370 | <td {{beam.color_status.17}}>{{beam.get_downvalues.16}}</td> <td {{beam.color_status.18}}>{{beam.get_downvalues.17}}</td> <td {{beam.color_status.19}}>{{beam.get_downvalues.18}}</td> <td {{beam.color_status.20}}>{{beam.get_downvalues.19}}</td> |
|
372 | 371 | </tr> |
|
373 | 372 | <tr> |
|
374 | 373 | <td {{beam.color_status.25}}>{{beam.get_upvalues.24}}</td> <td {{beam.color_status.26}}>{{beam.get_upvalues.25}}</td> <td {{beam.color_status.27}}>{{beam.get_upvalues.26}}</td> <td {{beam.color_status.28}}>{{beam.get_upvalues.27}}</td> |
|
375 | 374 | </tr> |
|
376 | 375 | <tr> |
|
377 | 376 | <td {{beam.color_status.25}}>{{beam.get_downvalues.24}}</td> <td {{beam.color_status.26}}>{{beam.get_downvalues.25}}</td> <td {{beam.color_status.27}}>{{beam.get_downvalues.26}}</td> <td {{beam.color_status.28}}>{{beam.get_downvalues.27}}</td> |
|
378 | 377 | </tr> |
|
379 | 378 | </table> |
|
380 | 379 | </td> |
|
381 | 380 | <td> <b>East Quarter</b> |
|
382 | 381 | <table class="east "> |
|
383 | 382 | <tr> |
|
384 | 383 | <td {{beam.color_status.5}}>{{beam.get_upvalues.4}}</td> <td {{beam.color_status.6}}>{{beam.get_upvalues.5}}</td> <td {{beam.color_status.7}}>{{beam.get_upvalues.6}}</td> <td {{beam.color_status.8}}>{{beam.get_upvalues.7}}</td> |
|
385 | 384 | </tr> |
|
386 | 385 | <tr> |
|
387 | 386 | <td {{beam.color_status.5}}>{{beam.get_downvalues.4}}</td> <td {{beam.color_status.6}}>{{beam.get_downvalues.5}}</td> <td {{beam.color_status.7}}>{{beam.get_downvalues.6}}</td> <td {{beam.color_status.8}}>{{beam.get_downvalues.7}}</td> |
|
388 | 387 | </tr> |
|
389 | 388 | <tr> |
|
390 | 389 | <td {{beam.color_status.13}}>{{beam.get_upvalues.12}}</td> <td {{beam.color_status.14}}>{{beam.get_upvalues.13}}</td> <td {{beam.color_status.15}}>{{beam.get_upvalues.14}}</td> <td {{beam.color_status.16}}>{{beam.get_upvalues.15}}</td> |
|
391 | 390 | </tr> |
|
392 | 391 | <tr> |
|
393 | 392 | <td {{beam.color_status.13}}>{{beam.get_downvalues.12}}</td> <td {{beam.color_status.14}}>{{beam.get_downvalues.13}}</td> <td {{beam.color_status.15}}>{{beam.get_downvalues.14}}</td> <td {{beam.color_status.16}}>{{beam.get_downvalues.15}}</td> |
|
394 | 393 | </tr> |
|
395 | 394 | <tr> |
|
396 | 395 | <td {{beam.color_status.21}}>{{beam.get_upvalues.20}}</td> <td {{beam.color_status.22}}>{{beam.get_upvalues.21}}</td> <td {{beam.color_status.23}}>{{beam.get_upvalues.22}}</td> <td {{beam.color_status.24}}>{{beam.get_upvalues.23}}</td> |
|
397 | 396 | </tr> |
|
398 | 397 | <tr> |
|
399 | 398 | <td {{beam.color_status.21}}>{{beam.get_downvalues.20}}</td> <td {{beam.color_status.22}}>{{beam.get_downvalues.21}}</td> <td {{beam.color_status.23}}>{{beam.get_downvalues.22}}</td> <td {{beam.color_status.24}}>{{beam.get_downvalues.23}}</td> |
|
400 | 399 | </tr> |
|
401 | 400 | <tr> |
|
402 | 401 | <td {{beam.color_status.29}}>{{beam.get_upvalues.28}}</td> <td {{beam.color_status.30}}>{{beam.get_upvalues.29}}</td> <td {{beam.color_status.31}}>{{beam.get_upvalues.30}}</td> <td {{beam.color_status.32}}>{{beam.get_upvalues.31}}</td> |
|
403 | 402 | </tr> |
|
404 | 403 | <tr> |
|
405 | 404 | <td {{beam.color_status.29}}>{{beam.get_downvalues.28}}</td> <td {{beam.color_status.30}}>{{beam.get_downvalues.29}}</td> <td {{beam.color_status.31}}>{{beam.get_downvalues.30}}</td> <td {{beam.color_status.32}}>{{beam.get_downvalues.31}}</td> |
|
406 | 405 | </tr> |
|
407 | 406 | </table> |
|
408 | 407 | </td> |
|
409 | 408 | </tr> |
|
410 | 409 | <tr> |
|
411 | 410 | <td> <b>West Quarter</b> |
|
412 | 411 | <table class="west "> |
|
413 | 412 | <tr> |
|
414 | 413 | <td {{beam.color_status.33}}>{{beam.get_upvalues.32}}</td> <td {{beam.color_status.34}}>{{beam.get_upvalues.33}}</td> <td {{beam.color_status.35}}>{{beam.get_upvalues.34}}</td> <td {{beam.color_status.36}}>{{beam.get_upvalues.35}}</td> |
|
415 | 414 | </tr> |
|
416 | 415 | <tr> |
|
417 | 416 | <td {{beam.color_status.33}}>{{beam.get_downvalues.32}}</td> <td {{beam.color_status.34}}>{{beam.get_downvalues.33}}</td> <td {{beam.color_status.35}}>{{beam.get_downvalues.34}}</td> <td {{beam.color_status.36}}>{{beam.get_downvalues.35}}</td> |
|
418 | 417 | </tr> |
|
419 | 418 | <tr> |
|
420 | 419 | <td {{beam.color_status.41}}>{{beam.get_upvalues.40}}</td> <td {{beam.color_status.42}}>{{beam.get_upvalues.41}}</td> <td {{beam.color_status.43}}>{{beam.get_upvalues.42}}</td> <td {{beam.color_status.44}}>{{beam.get_upvalues.43}}</td> |
|
421 | 420 | </tr> |
|
422 | 421 | <tr> |
|
423 | 422 | <td {{beam.color_status.41}}>{{beam.get_downvalues.40}}</td> <td {{beam.color_status.42}}>{{beam.get_downvalues.41}}</td> <td {{beam.color_status.43}}>{{beam.get_downvalues.42}}</td> <td {{beam.color_status.44}}>{{beam.get_downvalues.43}}</td> |
|
424 | 423 | </tr> |
|
425 | 424 | <tr> |
|
426 | 425 | <td {{beam.color_status.49}}>{{beam.get_upvalues.48}}</td> <td {{beam.color_status.50}}>{{beam.get_upvalues.49}}</td> <td {{beam.color_status.51}}>{{beam.get_upvalues.50}}</td> <td {{beam.color_status.52}}>{{beam.get_upvalues.51}}</td> |
|
427 | 426 | </tr> |
|
428 | 427 | <tr> |
|
429 | 428 | <td {{beam.color_status.49}}>{{beam.get_downvalues.48}}</td> <td {{beam.color_status.50}}>{{beam.get_downvalues.49}}</td> <td {{beam.color_status.51}}>{{beam.get_downvalues.50}}</td> <td {{beam.color_status.52}}>{{beam.get_downvalues.51}}</td> |
|
430 | 429 | </tr> |
|
431 | 430 | <tr> |
|
432 | 431 | <td {{beam.color_status.57}}>{{beam.get_upvalues.56}}</td> <td {{beam.color_status.58}}>{{beam.get_upvalues.57}}</td> <td {{beam.color_status.59}}>{{beam.get_upvalues.58}}</td> <td {{beam.color_status.60}}>{{beam.get_upvalues.59}}</td> |
|
433 | 432 | </tr> |
|
434 | 433 | <tr> |
|
435 | 434 | <td {{beam.color_status.57}}>{{beam.get_downvalues.56}}</td> <td {{beam.color_status.58}}>{{beam.get_downvalues.57}}</td> <td {{beam.color_status.59}}>{{beam.get_downvalues.58}}</td> <td {{beam.color_status.60}}>{{beam.get_downvalues.59}}</td> |
|
436 | 435 | </tr> |
|
437 | 436 | </table> |
|
438 | 437 | </td> |
|
439 | 438 | <td> <b>South Quarter</b> |
|
440 | 439 | <table class="south "> |
|
441 | 440 | <tr> |
|
442 | 441 | <td {{beam.color_status.37}}>{{beam.get_upvalues.36}}</td> <td {{beam.color_status.38}}>{{beam.get_upvalues.37}}</td> <td {{beam.color_status.39}}>{{beam.get_upvalues.38}}</td> <td {{beam.color_status.40}}>{{beam.get_upvalues.39}}</td> |
|
443 | 442 | </tr> |
|
444 | 443 | <tr> |
|
445 | 444 | <td {{beam.color_status.37}}>{{beam.get_downvalues.36}}</td> <td {{beam.color_status.38}}>{{beam.get_downvalues.37}}</td> <td {{beam.color_status.39}}>{{beam.get_downvalues.38}}</td> <td {{beam.color_status.40}}>{{beam.get_downvalues.39}}</td> |
|
446 | 445 | </tr> |
|
447 | 446 | <tr> |
|
448 | 447 | <td {{beam.color_status.45}}>{{beam.get_upvalues.44}}</td> <td {{beam.color_status.46}}>{{beam.get_upvalues.45}}</td> <td {{beam.color_status.47}}>{{beam.get_upvalues.46}}</td> <td {{beam.color_status.48}}>{{beam.get_upvalues.47}}</td> |
|
449 | 448 | </tr> |
|
450 | 449 | <tr> |
|
451 | 450 | <td {{beam.color_status.45}}>{{beam.get_downvalues.44}}</td> <td {{beam.color_status.46}}>{{beam.get_downvalues.45}}</td> <td {{beam.color_status.47}}>{{beam.get_downvalues.46}}</td> <td {{beam.color_status.48}}>{{beam.get_downvalues.47}}</td> |
|
452 | 451 | </tr> |
|
453 | 452 | <tr> |
|
454 | 453 | <td {{beam.color_status.53}}>{{beam.get_upvalues.52}}</td> <td {{beam.color_status.54}}>{{beam.get_upvalues.53}}</td> <td {{beam.color_status.55}}>{{beam.get_upvalues.54}}</td> <td {{beam.color_status.56}}>{{beam.get_upvalues.55}}</td> |
|
455 | 454 | </tr> |
|
456 | 455 | <tr> |
|
457 | 456 | <td {{beam.color_status.53}}>{{beam.get_downvalues.52}}</td> <td {{beam.color_status.54}}>{{beam.get_downvalues.53}}</td> <td {{beam.color_status.55}}>{{beam.get_downvalues.54}}</td> <td {{beam.color_status.56}}>{{beam.get_downvalues.55}}</td> |
|
458 | 457 | </tr> |
|
459 | 458 | <tr> |
|
460 | 459 | <td {{beam.color_status.61}}>{{beam.get_upvalues.60}}</td> <td {{beam.color_status.62}}>{{beam.get_upvalues.61}}</td> <td {{beam.color_status.63}}>{{beam.get_upvalues.62}}</td> <td {{beam.color_status.64}}>{{beam.get_upvalues.63}}</td> |
|
461 | 460 | </tr> |
|
462 | 461 | <tr> |
|
463 | 462 | <td {{beam.color_status.61}}>{{beam.get_downvalues.60}}</td> <td {{beam.color_status.62}}>{{beam.get_downvalues.61}}</td> <td {{beam.color_status.63}}>{{beam.get_downvalues.62}}</td> <td {{beam.color_status.64}}>{{beam.get_downvalues.63}}</td> |
|
464 | 463 | </tr> |
|
465 | 464 | </table> |
|
466 | 465 | </td> |
|
467 | 466 | </tr> |
|
468 | 467 | </table> |
|
469 | 468 | |
|
470 | 469 | {% if active_beam.id != beam.id %} |
|
471 | 470 | <div style="vertical-align: top; display:inline-block;"> |
|
472 | 471 | <button style="" id="send_beam{{forloop.counter}}" type="button" class="btn btn-default"> |
|
473 | 472 | <span class="glyphicon glyphicon-export" aria-hidden="true"></span> |
|
474 | 473 | Change Beam</button> |
|
475 | 474 | </div> |
|
476 | 475 | {% endif %} |
|
477 | ||
|
478 | 476 | |
|
479 | ||
|
477 | ||
|
478 | ||
|
480 | 479 | |
|
481 | 480 | {% if active_beam %} |
|
482 | 481 | {% if active_beam.id == beam.id %} |
|
483 | 482 | <table class="legend"> |
|
484 | 483 | <tr> |
|
485 | 484 | <th colspan="2">Legend</th> |
|
486 | 485 | </tr> |
|
487 | 486 | <tr> |
|
488 |
<td |
|
|
487 | <td class="text-danger"><i>RED</i></td><td>Disconnected</td> | |
|
489 | 488 | </tr> |
|
490 | 489 | <tr> |
|
491 |
<td |
|
|
490 | <td class="text-warning"><i>ORANGE</i></td><td>Connected</td> | |
|
492 | 491 | </tr> |
|
493 | 492 | <tr> |
|
494 |
<td |
|
|
493 | <td class="text-success"><i>GREEN</i></td><td>Running | |
|
495 | 494 | </td> |
|
496 | 495 | </tr> |
|
497 | 496 | </table> |
|
498 | ||
|
497 | ||
|
499 | 498 | {% endif %} |
|
500 | 499 | {% endif %} |
|
501 | 500 | |
|
502 | ||
|
501 | ||
|
503 | 502 | </div> |
|
504 | 503 | |
|
505 | 504 | |
|
506 | 505 | {% endfor %} |
|
507 | 506 | |
|
508 | ||
|
507 | ||
|
509 | 508 | |
|
510 | 509 | </div> |
|
511 | 510 | </div> |
|
512 | 511 | |
|
513 | 512 | |
|
514 | 513 | |
|
515 | 514 | |
|
516 | 515 | <script> |
|
517 | 516 | $(document).ready(function() { |
|
518 | 517 | |
|
519 | 518 | {% for beam in beams %} |
|
520 | 519 | $("#send_beam{{forloop.counter}}").click(function() { |
|
521 | 520 | document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}"; |
|
522 |
}); |
|
|
521 | }); | |
|
523 | 522 | {%endfor%} |
|
524 | ||
|
523 | ||
|
525 | 524 | }); |
|
526 | 525 | </script> |
|
527 | 526 | |
|
528 | 527 | |
|
529 | 528 | |
|
530 | 529 | |
|
531 | 530 | |
|
532 | 531 | |
|
533 | 532 | {% else %} |
|
534 | 533 | <p style="color:#b4bcc2; margin-left: 5%;"><i>No Beams...</i></p> |
|
535 | 534 | {% endif %} |
|
536 | 535 | |
|
537 | 536 | |
|
538 | 537 | {% endblock %} |
@@ -1,424 +1,424 | |||
|
1 | 1 | from django.shortcuts import render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | 3 | from django.shortcuts import redirect, render, get_object_or_404 |
|
4 | 4 | from django.contrib import messages |
|
5 | 5 | from django.conf import settings |
|
6 | 6 | from django.http import HttpResponse |
|
7 | 7 | from django.core.urlresolvers import reverse |
|
8 | 8 | |
|
9 | 9 | from datetime import datetime |
|
10 | 10 | from time import sleep |
|
11 | 11 | import os |
|
12 | 12 | |
|
13 | 13 | from apps.main.models import Device, Configuration |
|
14 | 14 | from apps.main.views import sidebar |
|
15 | 15 | |
|
16 | 16 | from .models import ABSConfiguration, ABSBeam |
|
17 | 17 | from .forms import ABSConfigurationForm, ABSBeamEditForm, ABSBeamAddForm, ABSImportForm |
|
18 | 18 | |
|
19 | 19 | from .utils.overJroShow import overJroShow |
|
20 | 20 | from .utils.OverJRO import OverJRO |
|
21 | 21 | # Create your views here. |
|
22 | 22 | import json, ast |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | def get_values_from_form(form_data): |
|
26 | 26 | |
|
27 | 27 | sublistup = [] |
|
28 | 28 | sublistdown = [] |
|
29 | 29 | subtxlistup = [] |
|
30 | 30 | subtxlistdown = [] |
|
31 | 31 | subrxlistup = [] |
|
32 | 32 | subrxlistdown = [] |
|
33 | 33 | |
|
34 | 34 | up_values_list = [] |
|
35 | 35 | down_values_list = [] |
|
36 | 36 | up_txvalues_list = [] |
|
37 | 37 | down_txvalues_list = [] |
|
38 | 38 | up_rxvalues_list = [] |
|
39 | 39 | down_rxvalues_list = [] |
|
40 | 40 | |
|
41 | 41 | values_list = {} |
|
42 | 42 | cont = 1 |
|
43 | 43 | |
|
44 | 44 | for i in range(1,65): |
|
45 | 45 | x = float(form_data['abs_up'+str(i)]) |
|
46 | 46 | y = float(form_data['abs_down'+str(i)]) |
|
47 | 47 | sublistup.append(x) |
|
48 | 48 | sublistdown.append(y) |
|
49 | 49 | |
|
50 | 50 | if str(i) in form_data.getlist('uptx_checks'): |
|
51 | 51 | subtxlistup.append(1) |
|
52 | 52 | else: |
|
53 | 53 | subtxlistup.append(0) |
|
54 | 54 | if str(i) in form_data.getlist('downtx_checks'): |
|
55 | 55 | subtxlistdown.append(1) |
|
56 | 56 | else: |
|
57 | 57 | subtxlistdown.append(0) |
|
58 | 58 | |
|
59 | 59 | if str(i) in form_data.getlist('uprx_checks'): |
|
60 | 60 | subrxlistup.append(1) |
|
61 | 61 | else: |
|
62 | 62 | subrxlistup.append(0) |
|
63 | 63 | if str(i) in form_data.getlist('downrx_checks'): |
|
64 | 64 | subrxlistdown.append(1) |
|
65 | 65 | else: |
|
66 | 66 | subrxlistdown.append(0) |
|
67 | 67 | |
|
68 | 68 | cont = cont+1 |
|
69 | 69 | |
|
70 | 70 | if cont == 9: |
|
71 | 71 | up_values_list.append(sublistup) |
|
72 | 72 | down_values_list.append(sublistdown) |
|
73 | 73 | sublistup = [] |
|
74 | 74 | sublistdown = [] |
|
75 | 75 | |
|
76 | 76 | up_txvalues_list.append(subtxlistup) |
|
77 | 77 | down_txvalues_list.append(subtxlistdown) |
|
78 | 78 | subtxlistup = [] |
|
79 | 79 | subtxlistdown = [] |
|
80 | 80 | up_rxvalues_list.append(subrxlistup) |
|
81 | 81 | down_rxvalues_list.append(subrxlistdown) |
|
82 | 82 | subrxlistup = [] |
|
83 | 83 | subrxlistdown = [] |
|
84 | 84 | cont = 1 |
|
85 | 85 | |
|
86 | 86 | |
|
87 | 87 | list_uesup = [] |
|
88 | 88 | list_uesdown = [] |
|
89 | 89 | for i in range(1,5): |
|
90 | 90 | if form_data['ues_up'+str(i)] == '': |
|
91 | 91 | list_uesup.append(0.0) |
|
92 | 92 | else: |
|
93 | 93 | list_uesup.append(float(form_data['ues_up'+str(i)])) |
|
94 | 94 | |
|
95 | 95 | if form_data['ues_down'+str(i)] == '': |
|
96 | 96 | list_uesdown.append(0.0) |
|
97 | 97 | else: |
|
98 | 98 | list_uesdown.append(float(form_data['ues_down'+str(i)])) |
|
99 | 99 | |
|
100 | 100 | onlyrx_list = form_data.getlist('onlyrx') |
|
101 | 101 | only_rx = {} |
|
102 | 102 | if '1' in onlyrx_list: |
|
103 | 103 | only_rx['up'] = True |
|
104 | 104 | else: |
|
105 | 105 | only_rx['up'] = False |
|
106 | 106 | if '2' in onlyrx_list: |
|
107 | 107 | only_rx['down'] = True |
|
108 | 108 | else: |
|
109 | 109 | only_rx['down'] = False |
|
110 | 110 | |
|
111 | 111 | antenna = {'antenna_up': up_values_list, 'antenna_down': down_values_list} |
|
112 | 112 | tx = {'up': up_txvalues_list, 'down': down_txvalues_list} |
|
113 | 113 | rx = {'up': up_rxvalues_list, 'down': down_rxvalues_list} |
|
114 | 114 | ues = {'up': list_uesup, 'down': list_uesdown} |
|
115 | 115 | name = str(form_data['beam_name']) |
|
116 | 116 | |
|
117 | 117 | beam_data = {'name': name, 'antenna': antenna, 'tx': tx, 'rx': rx, 'ues': ues, 'only_rx': only_rx} |
|
118 | 118 | |
|
119 | 119 | return beam_data |
|
120 | 120 | |
|
121 | 121 | |
|
122 | 122 | |
|
123 | 123 | def abs_conf(request, id_conf): |
|
124 | 124 | |
|
125 | 125 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
126 | 126 | beams = ABSBeam.objects.filter(abs_conf=conf) |
|
127 | 127 | active_beam_id = json.loads(conf.active_beam) |
|
128 | 128 | |
|
129 | 129 | #------------Colors for Active Beam:------------- |
|
130 | 130 | modules_status = json.loads(conf.module_status) |
|
131 | 131 | |
|
132 | 132 | color_status = {} |
|
133 | 133 | for status in modules_status: |
|
134 |
if modules_status[status] == 2: #Running background-color: # |
|
|
135 |
color_status[status] = ' |
|
|
134 | if modules_status[status] == 2: #Running background-color: #00cc00; | |
|
135 | color_status[status] = 'class=text-success'#'bgcolor=#00cc00' | |
|
136 | 136 | elif modules_status[status] == 1: #Connected background-color: #ee902c; |
|
137 |
color_status[status] = ' |
|
|
138 |
else: #Disconnected background-color: #00 |
|
|
139 |
color_status[status] = ' |
|
|
137 | color_status[status] = 'class=text-warning'#'bgcolor=#ee902c' | |
|
138 | else: #Disconnected background-color: #ff0000; | |
|
139 | color_status[status] = 'class=text-danger'#'bgcolor=#FF0000' | |
|
140 | 140 | #------------------------------------------------ |
|
141 | 141 | |
|
142 | 142 | kwargs = {} |
|
143 | kwargs['status'] = conf.device.get_status_display() | |
|
144 | ||
|
143 | #kwargs['status'] = conf.device.get_status_display() | |
|
144 | kwargs['connected_modules'] = str(conf.connected_modules())+'/64' | |
|
145 | 145 | |
|
146 | 146 | kwargs['dev_conf'] = conf |
|
147 | 147 | kwargs['dev_conf_keys'] = ['name',] |
|
148 | 148 | |
|
149 | 149 | kwargs['title'] = 'ABS Configuration' |
|
150 | 150 | kwargs['suptitle'] = 'Details' |
|
151 | 151 | kwargs['no_play'] = True |
|
152 | 152 | |
|
153 | 153 | kwargs['button'] = 'Edit Configuration' |
|
154 | 154 | #------------------Active Beam----------------------- |
|
155 | 155 | try: |
|
156 | 156 | active_beam_id = active_beam_id['active_beam'] |
|
157 | 157 | active_beam = ABSBeam.objects.get(pk=active_beam_id) |
|
158 | 158 | kwargs['active_beam'] = active_beam |
|
159 | 159 | for beam in beams: |
|
160 | 160 | if beam.id == active_beam.id: |
|
161 | 161 | beam.color_status=color_status |
|
162 | 162 | except: |
|
163 | 163 | active_beam = '' |
|
164 | 164 | #---------------------------------------------------- |
|
165 | 165 | kwargs['beams'] = beams |
|
166 | 166 | kwargs['modules_status'] = modules_status |
|
167 | 167 | kwargs['color_status'] = color_status |
|
168 | 168 | |
|
169 | 169 | kwargs['only_stop'] = True |
|
170 | 170 | |
|
171 | 171 | ###### SIDEBAR ###### |
|
172 | 172 | kwargs.update(sidebar(conf=conf)) |
|
173 | 173 | |
|
174 | 174 | return render(request, 'abs_conf.html', kwargs) |
|
175 | 175 | |
|
176 | 176 | def abs_conf_edit(request, id_conf): |
|
177 | 177 | |
|
178 | 178 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
179 | 179 | |
|
180 | 180 | beams = ABSBeam.objects.filter(abs_conf=conf) |
|
181 | 181 | print beams |
|
182 | 182 | |
|
183 | 183 | if request.method=='GET': |
|
184 | 184 | form = ABSConfigurationForm(instance=conf) |
|
185 | 185 | |
|
186 | 186 | if request.method=='POST': |
|
187 | 187 | form = ABSConfigurationForm(request.POST, instance=conf) |
|
188 | 188 | |
|
189 | 189 | if form.is_valid(): |
|
190 | 190 | conf = form.save(commit=False) |
|
191 | 191 | conf.save() |
|
192 | 192 | return redirect('url_abs_conf', id_conf=conf.id) |
|
193 | 193 | |
|
194 | 194 | ###### SIDEBAR ###### |
|
195 | 195 | kwargs = {} |
|
196 | 196 | |
|
197 | 197 | kwargs['dev_conf'] = conf |
|
198 | 198 | #kwargs['id_dev'] = conf.id |
|
199 | 199 | kwargs['id_conf'] = conf.id |
|
200 | 200 | kwargs['form'] = form |
|
201 | 201 | kwargs['abs_beams'] = beams |
|
202 | 202 | kwargs['title'] = 'Device Configuration' |
|
203 | 203 | kwargs['suptitle'] = 'Edit' |
|
204 | 204 | kwargs['button'] = 'Save' |
|
205 | 205 | |
|
206 | 206 | kwargs['edit'] = True |
|
207 | 207 | |
|
208 | 208 | return render(request, 'abs_conf_edit.html', kwargs) |
|
209 | 209 | |
|
210 | 210 | |
|
211 | 211 | def import_file(request, id_conf): |
|
212 | 212 | |
|
213 | 213 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
214 | 214 | if request.method=='POST': |
|
215 | 215 | form = ABSImportForm(request.POST, request.FILES) |
|
216 | 216 | if form.is_valid(): |
|
217 | 217 | try: |
|
218 | 218 | parms = conf.import_from_file(request.FILES['file_name']) |
|
219 | 219 | |
|
220 | 220 | if parms: |
|
221 | 221 | conf.update_from_file(parms) |
|
222 | 222 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) |
|
223 | 223 | return redirect(conf.get_absolute_url_edit()) |
|
224 | 224 | |
|
225 | 225 | except Exception as e: |
|
226 | 226 | messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e)) |
|
227 | 227 | |
|
228 | 228 | else: |
|
229 | 229 | messages.warning(request, 'Your current configuration will be replaced') |
|
230 | 230 | form = ABSImportForm() |
|
231 | 231 | |
|
232 | 232 | kwargs = {} |
|
233 | 233 | kwargs['form'] = form |
|
234 | 234 | kwargs['title'] = 'ABS Configuration' |
|
235 | 235 | kwargs['suptitle'] = 'Import file' |
|
236 | 236 | kwargs['button'] = 'Upload' |
|
237 | 237 | kwargs['previous'] = conf.get_absolute_url() |
|
238 | 238 | |
|
239 | 239 | return render(request, 'abs_import.html', kwargs) |
|
240 | 240 | |
|
241 | 241 | |
|
242 | 242 | def send_beam(request, id_conf, id_beam): |
|
243 | 243 | |
|
244 | 244 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
245 | 245 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
246 | 246 | beams_list = ABSBeam.objects.filter(abs_conf=conf) |
|
247 | 247 | #To set this beam as an Active Beam |
|
248 | 248 | beam.set_as_activebeam() |
|
249 | 249 | #To send beam position to abs-modules |
|
250 | 250 | i = 0 |
|
251 | 251 | for b in beams_list: |
|
252 | 252 | if b.id == int(id_beam): |
|
253 | 253 | break |
|
254 | 254 | else: |
|
255 | 255 | i += 1 |
|
256 | 256 | beam_pos = i + 1 #Estandarizar |
|
257 | 257 | print 'Position: ',beam_pos |
|
258 | 258 | conf.send_beam_num(beam_pos) |
|
259 | 259 | |
|
260 | 260 | return redirect('url_abs_conf', conf.id) |
|
261 | 261 | |
|
262 | 262 | |
|
263 | 263 | def add_beam(request, id_conf): |
|
264 | 264 | |
|
265 | 265 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
266 | 266 | confs = Configuration.objects.all() |
|
267 | 267 | |
|
268 | 268 | if request.method=='GET': |
|
269 | 269 | #form = ABSBeamEditForm() |
|
270 | 270 | form = ABSBeamAddForm() |
|
271 | 271 | |
|
272 | 272 | if request.method=='POST': |
|
273 | 273 | form = ABSBeamAddForm(request.POST) |
|
274 | 274 | |
|
275 | 275 | beam_data = get_values_from_form(request.POST) |
|
276 | 276 | |
|
277 | 277 | new_beam = ABSBeam( |
|
278 | 278 | name =beam_data['name'], |
|
279 | 279 | antenna =json.dumps(beam_data['antenna']), |
|
280 | 280 | abs_conf=conf, |
|
281 | 281 | tx =json.dumps(beam_data['tx']), |
|
282 | 282 | rx =json.dumps(beam_data['rx']), |
|
283 | 283 | ues =json.dumps(beam_data['ues']), |
|
284 | 284 | only_rx =json.dumps(beam_data['only_rx']) |
|
285 | 285 | ) |
|
286 | 286 | new_beam.save() |
|
287 | 287 | #---Update 6bits configuration and add beam to abs configuration beams list. |
|
288 | 288 | new_beam.modules_6bits() |
|
289 | 289 | #new_beam.add_beam2list() |
|
290 | 290 | messages.success(request, 'Beam: "%s" has been added.' % new_beam.name) |
|
291 | 291 | |
|
292 | 292 | return redirect('url_edit_abs_conf', conf.id) |
|
293 | 293 | |
|
294 | 294 | ###### SIDEBAR ###### |
|
295 | 295 | kwargs = {} |
|
296 | 296 | |
|
297 | 297 | #kwargs['dev_conf'] = conf.device |
|
298 | 298 | #kwargs['id_dev'] = conf.device |
|
299 | 299 | kwargs['id_conf'] = conf.id |
|
300 | 300 | kwargs['form'] = form |
|
301 | 301 | kwargs['title'] = 'ABS Beams' |
|
302 | 302 | kwargs['suptitle'] = 'Add Beam' |
|
303 | 303 | kwargs['button'] = 'Add' |
|
304 | 304 | kwargs['no_sidebar'] = True |
|
305 | 305 | |
|
306 | 306 | #kwargs['previous'] = conf.get_absolute_url_edit() |
|
307 | 307 | kwargs['edit'] = True |
|
308 | 308 | |
|
309 | 309 | return render(request, 'abs_add_beam.html', kwargs) |
|
310 | 310 | |
|
311 | 311 | |
|
312 | 312 | def edit_beam(request, id_conf, id_beam): |
|
313 | 313 | |
|
314 | 314 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
315 | 315 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
316 | 316 | |
|
317 | 317 | if request.method=='GET': |
|
318 | 318 | form = ABSBeamEditForm(initial={'beam': beam}) |
|
319 | 319 | |
|
320 | 320 | if request.method=='POST': |
|
321 | 321 | form = ABSBeamEditForm(request.POST) |
|
322 | 322 | |
|
323 | 323 | beam_data = get_values_from_form(request.POST) |
|
324 | 324 | |
|
325 | 325 | beam.dict_to_parms(beam_data) |
|
326 | 326 | beam.save() |
|
327 | 327 | |
|
328 | 328 | messages.success(request, 'Beam: "%s" has been updated.' % beam.name) |
|
329 | 329 | |
|
330 | 330 | return redirect('url_edit_abs_conf', conf.id) |
|
331 | 331 | |
|
332 | 332 | ###### SIDEBAR ###### |
|
333 | 333 | kwargs = {} |
|
334 | 334 | |
|
335 | 335 | kwargs['id_conf'] = conf.id |
|
336 | 336 | kwargs['form'] = form |
|
337 | 337 | kwargs['title'] = 'ABS Beams' |
|
338 | 338 | kwargs['suptitle'] = 'Edit Beam' |
|
339 | 339 | kwargs['button'] = 'Save' |
|
340 | 340 | kwargs['no_sidebar'] = True |
|
341 | 341 | |
|
342 | 342 | #kwargs['previous'] = conf.get_absolute_url_edit() |
|
343 | 343 | kwargs['edit'] = True |
|
344 | 344 | |
|
345 | 345 | return render(request, 'abs_edit_beam.html', kwargs) |
|
346 | 346 | |
|
347 | 347 | |
|
348 | 348 | |
|
349 | 349 | def remove_beam(request, id_conf, id_beam): |
|
350 | 350 | |
|
351 | 351 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
352 | 352 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
353 | 353 | |
|
354 | 354 | if request.method=='POST': |
|
355 | 355 | if beam: |
|
356 | 356 | try: |
|
357 | 357 | beam.remove_beamfromlist() |
|
358 | 358 | beam.delete() |
|
359 | 359 | messages.success(request, 'Beam: "%s" has been deleted.' % beam) |
|
360 | 360 | except: |
|
361 | 361 | messages.error(request, 'Unable to delete beam: "%s".' % beam) |
|
362 | 362 | |
|
363 | 363 | return redirect('url_edit_abs_conf', conf.id) |
|
364 | 364 | |
|
365 | 365 | ###### SIDEBAR ###### |
|
366 | 366 | kwargs = {} |
|
367 | 367 | |
|
368 | 368 | kwargs['object'] = beam |
|
369 | 369 | kwargs['delete'] = True |
|
370 | 370 | kwargs['title'] = 'Delete' |
|
371 | 371 | kwargs['suptitle'] = 'Beam' |
|
372 | 372 | kwargs['previous'] = conf.get_absolute_url_edit() |
|
373 | 373 | return render(request, 'confirm.html', kwargs) |
|
374 | 374 | |
|
375 | 375 | |
|
376 | 376 | |
|
377 | 377 | def plot_patterns(request, id_conf, id_beam=None): |
|
378 | 378 | |
|
379 | 379 | kwargs = {} |
|
380 | 380 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
381 | 381 | beams = ABSBeam.objects.filter(abs_conf=conf) |
|
382 | 382 | |
|
383 | 383 | if id_beam: |
|
384 | 384 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
385 | 385 | kwargs['beam'] = beam |
|
386 | 386 | |
|
387 | 387 | |
|
388 | 388 | ###### SIDEBAR ###### |
|
389 | 389 | |
|
390 | 390 | kwargs['dev_conf'] = conf.device |
|
391 | 391 | kwargs['id_dev'] = conf.device |
|
392 | 392 | kwargs['id_conf'] = conf.id |
|
393 | 393 | kwargs['abs_beams'] = beams |
|
394 | 394 | kwargs['title'] = 'ABS Patterns' |
|
395 | 395 | kwargs['suptitle'] = conf.name |
|
396 | 396 | kwargs['no_sidebar'] = True |
|
397 | 397 | |
|
398 | 398 | return render(request, 'abs_patterns.html', kwargs) |
|
399 | 399 | |
|
400 | 400 | |
|
401 | 401 | def plot_pattern(request, id_conf, id_beam, antenna): |
|
402 | 402 | |
|
403 | 403 | if antenna=='down': |
|
404 | 404 | sleep(3) |
|
405 | 405 | |
|
406 | 406 | conf = get_object_or_404(ABSConfiguration, pk=id_conf) |
|
407 | 407 | beam = get_object_or_404(ABSBeam, pk=id_beam) |
|
408 | 408 | |
|
409 | 409 | name = conf.experiment.name |
|
410 | 410 | |
|
411 | 411 | just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0 |
|
412 | 412 | phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)] |
|
413 | 413 | gain_tx = json.loads(beam.tx)[antenna] |
|
414 | 414 | gain_rx = json.loads(beam.rx)[antenna] |
|
415 | 415 | ues = json.loads(beam.ues)[antenna] |
|
416 | 416 | |
|
417 | 417 | newOverJro = overJroShow(name) |
|
418 | 418 | fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx) |
|
419 | 419 | |
|
420 | 420 | response=HttpResponse(content_type='image/png') |
|
421 | 421 | |
|
422 | 422 | fig.canvas.print_png(response) |
|
423 | 423 | |
|
424 | 424 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now