##// END OF EJS Templates
Review & fix ABS module
Juan C. Espinoza -
r307:678cf1e292ab
parent child
Show More
This diff has been collapsed as it changes many lines, (631 lines changed) Show them Hide them
@@ -1,1345 +1,864
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 from celery.execute import send_task
6 6 from datetime import datetime
7 7 import ast
8 8 import socket
9 9 import json
10 10 import requests
11 11 import struct
12 12 import sys, time
13 13
14 14 import multiprocessing
15 15
16 16
17 17 antenna_default = json.dumps({
18 18 "antenna_up": [[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.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
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 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
26 26 ]
27 27 ,
28 28 "antenna_down": [[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.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
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 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
36 36 })
37 37
38 38
39 39 tx_default = json.dumps({
40 40 "up": [[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 [1,1,1,1,0,0,0,0],
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 [0,0,0,0,1,1,1,1]],
48 48
49 49 "down": [[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 [1,1,1,1,0,0,0,0],
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 [0,0,0,0,1,1,1,1]],
57 57 })
58 58
59 59 rx_default = json.dumps({
60 60 "up": [[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 [1,1,1,1,0,0,0,0],
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 [0,0,0,0,1,1,1,1]],
68 68
69 69 "down": [[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 [1,1,1,1,0,0,0,0],
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 [0,0,0,0,1,1,1,1]],
77 77 })
78 78
79 conf_default = {}
80 status_default = {}
79 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
81 80 default_messages = {}
82 default_modulemode = {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0, "7": 0, "8": 0, "9": 0, "10": 0,
83 "11": 0, "12": 0, "13": 0, "14": 0, "15": 0, "16": 0, "17": 0, "18": 0, "19": 0, "20": 0,
84 "21": 0, "22": 0, "23": 0, "24": 0, "25": 0, "26": 0, "27": 0, "28": 0, "29": 0, "30": 0,
85 "31": 0, "32": 0, "33": 0, "34": 0, "35": 0, "36": 0, "37": 0, "38": 0, "39": 0, "40": 0,
86 "41": 0, "42": 0, "43": 0, "44": 0, "45": 0, "46": 0, "47": 0, "48": 0, "49": 0, "50": 0,
87 "51": 0, "52": 0, "53": 0, "54": 0, "55": 0, "56": 0, "57": 0, "58": 0, "59": 0, "60": 0,
88 "61": 0, "62": 0, "63": 0, "64": 0} # 0 : Socket // 1: API Rest
89 81
90 82 for i in range(1,65):
91 conf_default[str(i)] = ""
92 status_default[str(i)] = 0
93 83 default_messages[str(i)] = "Module "+str(i)
94 84
95 85
96 86 ues_default = json.dumps({
97 87 "up": [0.533333,0.00000,1.06667,0.00000],
98 88 "down": [0.533333,0.00000,1.06667,0.00000]
99 89 })
100 90
101 91 onlyrx_default = json.dumps({
102 92 "up": False,
103 93 "down": False
104 94 })
105 95
106 96 def up_convertion(cadena):
107 97 valores = []
108 98 for c in cadena:
109 99 if c == 1.0: valores=valores+['000']
110 100 if c == 2.0: valores=valores+['001']
111 101 if c == 3.0: valores=valores+['010']
112 102 if c == 0.0: valores=valores+['011']
113 103 if c == 0.5: valores=valores+['100']
114 104 if c == 1.5: valores=valores+['101']
115 105 if c == 2.5: valores=valores+['110']
116 106 if c == 3.5: valores=valores+['111']
117 107
118 108 return valores
119 109
120 110 def up_conv_bits(value):
121 111
122 112 if value == 1.0: bits="000"
123 113 if value == 2.0: bits="001"
124 114 if value == 3.0: bits="010"
125 115 if value == 0.0: bits="011"
126 116 if value == 0.5: bits="100"
127 117 if value == 1.5: bits="101"
128 118 if value == 2.5: bits="110"
129 119 if value == 3.5: bits="111"
130 120
131 121 return bits
132 122
133 123 def down_convertion(cadena):
134 124 valores = []
135 125 for c in cadena:
136 126 if c == 1.0: valores=valores+['000']
137 127 if c == 2.0: valores=valores+['001']
138 128 if c == 3.0: valores=valores+['010']
139 129 if c == 0.0: valores=valores+['011']
140 130 if c == 0.5: valores=valores+['100']
141 131 if c == 1.5: valores=valores+['101']
142 132 if c == 2.5: valores=valores+['110']
143 133 if c == 3.5: valores=valores+['111']
144 134
145 135 return valores
146 136
147 137 def down_conv_bits(value):
148 138
149 139 if value == 1.0: bits="000"
150 140 if value == 2.0: bits="001"
151 141 if value == 3.0: bits="010"
152 142 if value == 0.0: bits="011"
153 143 if value == 0.5: bits="100"
154 144 if value == 1.5: bits="101"
155 145 if value == 2.5: bits="110"
156 146 if value == 3.5: bits="111"
157 147
158 148 return bits
159 149
160 150 def up_conv_value(bits):
161 151
162 152 if bits == "000": value=1.0
163 153 if bits == "001": value=2.0
164 154 if bits == "010": value=3.0
165 155 if bits == "011": value=0.0
166 156 if bits == "100": value=0.5
167 157 if bits == "101": value=1.5
168 158 if bits == "110": value=2.5
169 159 if bits == "111": value=3.5
170 160
171 161 return value
172 162
173 163 def down_conv_value(bits):
174 164
175 165 if bits == "000": value=1.0
176 166 if bits == "001": value=2.0
177 167 if bits == "010": value=3.0
178 168 if bits == "011": value=0.0
179 169 if bits == "100": value=0.5
180 170 if bits == "101": value=1.5
181 171 if bits == "110": value=2.5
182 172 if bits == "111": value=3.5
183 173
184 174 return value
185 175
186 176 def ip2position(module_number):
187 177 j=0
188 178 i=0
189 179 for x in range(0,module_number-1):
190 180 j=j+1
191 181 if j==8:
192 182 i=i+1
193 183 j=0
194 184
195 185 pos = [i,j]
196 186 return pos
197 187
198 188
199 189 def fromBinary2Char(binary_string):
200 190 number = int(binary_string, 2)
201 191 #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
202 192 number = number + 33
203 193 char = chr(number)
204 194 return char
205 195
206 196 def fromChar2Binary(char):
207 197 number = ord(char) - 33
208 198 #Minus 33 to get the real value
209 199 bits = bin(number)[2:]
210 200 #To ensure we have a string with 6bits
211 201 if len(bits) < 6:
212 202 bits = bits.zfill(6)
213 203 return bits
214 204
215 205 OPERATION_MODES = (
216 206 (0, 'Manual'),
217 207 (1, 'Automatic'),
218 208 )
219 209
220 210
221 211 class ABSConfiguration(Configuration):
222 active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}")
212 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
223 213 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
224 214 operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
225 215 operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
226 216 module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
227 module_mode = models.CharField(verbose_name='Modules Mode', max_length=10000, default=json.dumps(default_modulemode))
228 217
229 218 class Meta:
230 219 db_table = 'abs_configurations'
231 220
232 221 def get_absolute_url_plot(self):
233 222 return reverse('url_plot_abs_patterns', args=[str(self.id)])
234 223
235 224
236 225 def parms_to_dict(self):
237 226
238 227 parameters = {}
239 228
240 229 parameters['device_id'] = self.device.id
241 230 parameters['name'] = self.name
242 231 parameters['device_type'] = self.device.device_type.name
243 232 parameters['beams'] = {}
244 233
245 234 beams = ABSBeam.objects.filter(abs_conf=self)
246 235 b=1
247 236 for beam in beams:
248 237 #absbeam = ABSBeam.objects.get(pk=beams[beam])
249 238 parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
250 239 b+=1
251 240
252 241 return parameters
253 242
254 243
255 244 def dict_to_parms(self, parameters):
256 245
257 246 self.name = parameters['name']
258 247
259 248 absbeams = ABSBeam.objects.filter(abs_conf=self)
260 249 beams = parameters['beams']
261 250
262 251 if absbeams:
263 252 beams_number = len(beams)
264 253 absbeams_number = len(absbeams)
265 254 if beams_number==absbeams_number:
266 255 i = 1
267 256 for absbeam in absbeams:
268 257 absbeam.dict_to_parms(beams['beam'+str(i)])
269 258 i = i+1
270 259 elif beams_number > absbeams_number:
271 260 i = 1
272 261 for absbeam in absbeams:
273 262 absbeam.dict_to_parms(beams['beam'+str(i)])
274 263 i=i+1
275 264 for x in range(i,beams_number+1):
276 265 new_beam = ABSBeam(
277 266 name =beams['beam'+str(i)]['name'],
278 267 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
279 268 abs_conf = self,
280 269 tx =json.dumps(beams['beam'+str(i)]['tx']),
281 270 rx =json.dumps(beams['beam'+str(i)]['rx']),
282 271 ues =json.dumps(beams['beam'+str(i)]['ues']),
283 272 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
284 273 )
285 274 new_beam.save()
286 275 i=i+1
287 276 else: #beams_number < absbeams_number:
288 277 i = 1
289 278 for absbeam in absbeams:
290 279 if i <= beams_number:
291 280 absbeam.dict_to_parms(beams['beam'+str(i)])
292 281 i=i+1
293 282 else:
294 283 absbeam.delete()
295 284 else:
296 285 for beam in beams:
297 286 new_beam = ABSBeam(
298 287 name =beams[beam]['name'],
299 288 antenna =json.dumps(beams[beam]['antenna']),
300 289 abs_conf = self,
301 290 tx =json.dumps(beams[beam]['tx']),
302 291 rx =json.dumps(beams[beam]['rx']),
303 292 ues =json.dumps(beams[beam]['ues']),
304 293 only_rx =json.dumps(beams[beam]['only_rx'])
305 294 )
306 295 new_beam.save()
307 296
308 297
309 298
310 299 def update_from_file(self, parameters):
311 300
312 301 self.dict_to_parms(parameters)
313 302 self.save()
314 303
315 304
316 305 def get_beams(self, **kwargs):
317 306 '''
318 307 This function returns ABS Configuration beams
319 308 '''
320 309 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
321 310
322 311 def clone(self, **kwargs):
323 312
324 313 beams = self.get_beams()
325 314 self.pk = None
326 315 self.id = None
327 316 for attr, value in kwargs.items():
328 317 setattr(self, attr, value)
329 318 self.save()
330 319
331 320 for beam in beams:
332 321 beam.clone(abs_conf=self)
333 322
334 323 #-----For Active Beam-----
335 active_beam = json.loads(self.active_beam)
336 324 new_beams = ABSBeam.objects.filter(abs_conf=self)
337 active_beam['active_beam'] = new_beams[0].id
338
339 self.active_beam = json.dumps(active_beam)
325 self.active_beam = new_beams[0].id
340 326 self.save()
341 327 #-----For Active Beam-----
342 328 #-----For Device Status---
343 329 self.device.status = 3
344 330 self.device.save()
345 331 #-----For Device Status---
346 332
347 333 return self
348 334
349 335
350 336 def start_device(self):
351 337
352 338 if self.device.status == 3:
353 339
354 340 try:
355 341 #self.write_device()
356 342 send_task('task_change_beam', [self.id],)
357 343 self.message = 'ABS running'
358 344
359 345 except Exception as e:
360 346 self.message = str(e)
361 347 return False
362 348
363 349 return True
364 350
365 351 else:
366 352 self.message = 'Please, select Write ABS Device first.'
367 353 return False
368 354
369 355
370 356 def stop_device(self):
371 357
372 358 self.device.status = 2
373 359 self.device.save()
374 360 self.message = 'ABS has been stopped.'
375 361 self.save()
376 362
377 363 return True
378 364
379 def monitoring_device(self):
380
381 monitoreo_tx = 'JROABSClnt_01CeCnMod000000MNTR10'
382 beam_tx = 'JROABSCeCnModCnMod01000001CHGB10'
383
384 beam_pos = 1
385 module_address = ('192.168.1.63', 5500)
386
387 message_tx = monitoreo_tx
388 # Create the datagram socket
389 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
390 sock.connect(module_address)
391
392 sock.send(message_tx)
393 t = sock.recv(1024)
394 print 'Respuesta: \n',t
395 sock.close()
396 sock = None
397
398 return True
399
400
401 def module_conf(self, module_num, beams):
402 """
403 This function creates beam configurations for one abs module.
404 """
405 ip_address = self.device.ip_address
406 ip_address = ip_address.split('.')
407 module_seq = (ip_address[0],ip_address[1],ip_address[2])
408 dot = '.'
409 module_ip = dot.join(module_seq)+'.'+str(module_num)
410 module_port = self.device.port_address
411 write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
412
413 #header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
414 #module = 'ABS_'+str(module_num)
415 bs = '' #{}
416 i=1
417
418 for beam in beams:
419 #bs[i] = fromBinary2Char(beam.module_6bits(module_num))
420 bs = bs + fromBinary2Char(beam.module_6bits(module_num))
421 i=i+1
422
423 beams = bs
424
425 parameters = {}
426 parameters['beams'] = beams #json.dumps(beams)
427 print parameters
428 answer = ''
429
430 try:
431 #r_write = requests.post(write_route, parameters, timeout=0.5)
432 r_write = requests.post(write_route, json = parameters, timeout=0.7)
433 answer = r_write.json()
434 #self.message = answer['message']
435 except:
436 #self.message = "Could not write ABS parameters"
437 return False
438
439 return answer
440
441
442 365
443 366 def write_device(self):
444 367
445 368 """
446 369 This function sends the beams list to every abs module.
447 370 It needs 'module_conf' function
448 371 """
449 372
450 373 beams = ABSBeam.objects.filter(abs_conf=self)
451 connected_modules = ast.literal_eval(self.module_status)
452 suma_connected_modules = 0
453
454 for c in connected_modules:
455 suma_connected_modules = suma_connected_modules+connected_modules[c]
456 if not suma_connected_modules > 0 :
374 nbeams = len(beams)
375 if self.connected_modules() == 0 :
457 376 self.message = "No ABS Module detected."
458 377 return False
459 378
460 379 #-------------Write each abs module-----------
461 380 if beams:
462 beams_status = ast.literal_eval(self.module_status)
463 disconnected_modules = 0
464 for i in range(1,65): #(62,65)
465 #--------------JUEVES-------------
466 if beams_status[str(i)] != 0:
467 try:
468 answer = self.module_conf(i,beams)
469 if answer:
470 if answer['status']:
471 beams_status[str(i)] = 3
472 print answer
473
474 except:
475 beams_status[str(i)] = 1
381 message = 'SNDF{:02d}'.format(nbeams)
382 for i, status in enumerate(self.module_status):
383 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
384 status = ['0'] * 64
385 n = 0
476 386
477 pass
478 else:
479 disconnected_modules += 1
387 sock = self.send_multicast(message)
480 388
389 for i in range(64):
390 try:
391 data, address = sock.recvfrom(1024)
392 if data == '1':
393 status[int(address[0][10:])-1] = '3'
394 elif data == '0':
395 status[int(address[0][10:])-1] = '1'
396 except:
397 n += 1
398 sock.close()
481 399 else:
482 400 self.message = "ABS Configuration does not have beams"
483 401 return False
484 402
485 #self.device.status = 1
486 ##
487 #-------------Jueves-------------
488 if disconnected_modules == 64:
403 if n == 64:
489 404 self.message = "Could not write ABS Modules"
490 405 self.device.status = 0
406 self.module_status = ''.join(status)
407 self.save()
491 408 return False
492 409 else:
493 410 self.message = "ABS Beams List have been sent to ABS Modules"
494 411 beams[0].set_as_activebeam()
495 412
496 413 self.device.status = 3
497 self.module_status = json.dumps(beams_status)
498
499
500
414 self.module_status = ''.join(status)
501 415 self.save()
502 416 return True
503 417
504 418
505
506
507 419 def read_module(self, module):
508 420
509 421 """
510 422 Read out-bits (up-down) of 1 abs module NOT for Configuration
511 423 """
512 424
513 425 ip_address = self.device.ip_address
514 426 ip_address = ip_address.split('.')
515 427 module_seq = (ip_address[0],ip_address[1],ip_address[2])
516 428 dot = '.'
517 429 module_ip = dot.join(module_seq)+'.'+str(module)
518 430 module_port = self.device.port_address
519 431 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
520 432
521 433 module_status = json.loads(self.module_status)
522 434 print(read_route)
523 435
524 436 module_bits = ''
525 437
526 438 try:
527 439 r_read = requests.get(read_route, timeout=0.5)
528 440 answer = r_read.json()
529 441 module_bits = answer['allbits']
530 442 except:
531 443 return {}
532 444
533 445 return module_bits
534 446
535 447 def read_device(self):
536 448
537 449 parms = {}
538 450 # Reads active modules.
539 451 module_status = json.loads(self.module_status)
540 452 total = 0
541 453 for status in module_status:
542 454 if module_status[status] != 0:
543 455 module_bits = self.read_module(int(status))
544 456 bits={}
545 457 if module_bits:
546 458 bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
547 459 str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
548 460 parms[str(status)] = bits
549 461
550 462 total +=1
551 463
552 464 if total==0:
553 465 self.message = "No ABS Module detected. Please select 'Status'."
554 466 return False
555 467
556 468
557 469
558 470 self.message = "ABS Modules have been read"
559 471 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
560 472 return parms
561 473
562 474
563 def absmodule_status(self):
564 """
565 This function gets the status of each abs module. It sends GET method to Web Application
566 in Python Bottle.
567 This function updates "module_status" field from ABSconfiguration.
568 """
569 ip_address = self.device.ip_address
570 ip_address = ip_address.split('.')
571 module_seq = (ip_address[0],ip_address[1],ip_address[2])
572 dot = '.'
573 module_port = self.device.port_address
574
575 modules_status = json.loads(self.module_status)
576 module_messages = json.loads(self.module_messages)
577
578 for i in range(1,65):
579 module_ip = dot.join(module_seq)+'.'+str(i)
580 print module_ip
581
582 route = 'http://'+module_ip+':'+str(module_port)+'/status'
583
584 try:
585 r = requests.get(route, timeout=0.8)#, timeout=0.7)
586 answer = r.json()
587 modules_status[str(i)] = answer['status']
588 module_messages[str(i)] = answer['message']
589 except:
590 modules_status[str(i)] = 0
591 pass
592
593
594 self.module_status = json.dumps(modules_status)
595 self.module_messages = json.dumps(module_messages)
596 self.save()
597
598 print 'Termino (='
599
600 return
601
602
603 475 def connected_modules(self):
604 476 """
605 477 This function returns the number of connected abs-modules without updating.
606 478 """
607 modules_status = json.loads(self.module_status)
608 479 num = 0
609 for status in modules_status:
610 if modules_status[status] != 0:
480 print(self.module_status)
481 for i, status in enumerate(self.module_status):
482 if status != '0':
611 483 num += 1
612
484 print('status {}:{}'.format(i+1, status))
613 485 return num
614 486
487 def send_multicast(self, message):
488
489 multicast_group = ('224.3.29.71', 10000)
490 # Create the datagram socket
491 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
492 sock.settimeout(0.01)
493 local_ip = "0.0.0.0"
494 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
495 sent = sock.sendto(message, multicast_group)
496 print('Sending ' + message)
497 return sock
615 498
616 499 def status_device(self):
617 500 """
618 501 This function returns the status of all abs-modules as one.
619 502 If at least one module is connected, its answer is "1"
620 503 """
621 #self.absmodule_status()
622 send_task('status_absdevice', [self.id],)
623 connected_modules = self.connected_modules()
624 if connected_modules>0:
625 self.message = 'ABS modules Status have been updated.'
626 return 1
627 else:
628 self.device.status=0
629
630 self.message = 'No ABS module is connected.'
631 self.save()
632 return 0
633
634
635
636 def write_module(self, module):
637
638 """
639 Send configuration to one abs module
640 """
641
642 parameters = {}
643 ip_address = self.device.ip_address
644 ip_address = ip_address.split('.')
645 module_seq = (ip_address[0],ip_address[1],ip_address[2])
646 dot = '.'
647 module_ip = dot.join(module_seq)+'.'+str(module)
648 module_port = self.device.port_address
649 write_route = 'http://'+module_ip+':'+str(module_port)+'/write'
650
651 #print write_route
652 504
653 #header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
654 #module = 'ABS_'+str(module)
655 beams = '!`*3<ENW'#{1: '001000', 2: '010001', 3: '010010', 4: '000011', 5: '101100', 6: '101101',
656 # 7: '110110', 8: '111111', 9: '000000', 10: '001001', 11: '010010', 12: '011011'}
657
658 #parameters['header'] = header
659 parameters['module'] = module
660 parameters['beams'] = json.dumps(beams)
661
662 answer = ''
505 sock = self.send_multicast('MNTR')
663 506
507 n = 0
508 status = ['0'] * 64
509 for i in range(64):
664 510 try:
665 r_write = requests.post(write_route, parameters, timeout=0.5)
666 answer = r_write.json()
667 self.message = answer['message']
511 data, address = sock.recvfrom(1024)
512 if data == '1':
513 status[int(address[0][10:])-1] = '3'
514 elif data == '0':
515 status[int(address[0][10:])-1] = '1'
516 n += 1
517 print('Module: {} connected'.format(address))
668 518 except:
669 self.message = "Could not write ABS parameters"
670 return 0
671
672
673 #self.device.status = int(answer['status'])
674
675 return 1
676
677
678 def write_module_socket(self, module):
679 """
680 This function sends beams list to one abs-module to TCP_Control_Module using sockets
681 """
682
683 ip_address = self.device.ip_address
684 ip_address = ip_address.split('.')
685 module_seq = (ip_address[0],ip_address[1],ip_address[2])
686 dot = '.'
687 module_ip = dot.join(module_seq)+'.'+str(module)
688 module_port = self.device.port_address
689
690 header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1'
691 abs_module = 'ABS_'+str(module)
692
693 beams = self.get_beams()
694 beams_text = ''
695 for beam in beams:
696 modules_conf=json.loads(beam.modules_conf)
697 beams_text = beams_text + modules_conf[str(module)] + '\n'
698
699 message_tx = header + '\n' + abs_module + '\n' + beams_text + '0'
700 print "Send: ", message_tx
701
702 # Create the datagram socket
703 module_address = (module_ip, 5500)
704 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
705 try:
706 sock.connect(module_address)
707 sock.send(message_tx)
708 t = sock.recv(1024)
709 print 'Respuesta: \n',t
710
711 except Exception as e:
712 print str(e)
713 sock.close()
714 sock = None
715 return False
716
519 pass
717 520 sock.close()
718 sock = None
719
720 return True
721
722 def write_device_socket(self):
723 """
724 This function sends beams list to every connected abs-module to TCP_Control_Module using sockets
725 """
726 module_mode = json.loads(self.module_mode)
727 module_status = json.loads(self.module_status)
728
729 for i in range(1,65):
730 if module_mode[str(i)] == 0 and module_status[str(i)] == 1: # 0: Sockets + Cserver & 1: Connected
731 try:
732 self.write_module_socket(i)
733 except Exception as e:
734 print 'Error ABS '+str(i)+': '+str(e)
735
736 return True
737
738 521
739 def beam_selector(self, module, beam_pos):
740 """
741 This function selects the beam number for one absmodule.
742 """
743
744 if beam_pos > 0:
745 beam_pos = beam_pos - 1
522 if n > 0:
523 self.message = 'ABS modules Status have been updated.'
524 self.device.status = 1
746 525 else:
747 beam_pos = 0
748
749 #El indice del apunte debe ser menor que el numero total de apuntes
750 #El servidor tcp en el embebido comienza a contar desde 0
751 beams_list = ABSBeam.objects.filter(abs_conf=self)
752 if len(beams_list) < beam_pos:
753 return 0
754
755 flag = 1
756 if beam_pos>9:
757 flag = 2
758
759 module_address = ('192.168.1.'+str(module), 5500)
760 header = 'JROABSCeCnModCnMod0100000'
761 numbers = len(str(beam_pos))
762 function = 'CHGB'
763
764 message_tx = header+str(numbers)+function+str(beam_pos)+'0'
765
766 # Create the datagram socket
767 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
768 #sock.connect(module_address)
769 try:
770 sock.connect(module_address)
771 sock.send(message_tx)
772 sock.close()
773 print("Writing abs module:"+module_address[0]+"...")
774 except:
775 sock = None
776 print("Problem writing abs module:"+module_address[0])
777 return 0
778
779 return 1
780
526 self.device.status = 0
527 self.message = 'No ABS module is connected.'
528 self.module_status = ''.join(status)
529 self.save()
781 530
782 def change_beam(self, beam_pos):
783 """
784 This function selects the beam number for all absmodules.
785 """
786 for i in range(1,65):
787 try:
788 self.beam_selector(i,beam_pos)
789 except:
790 print("Problem with module: 192.168.1."+str(i))
791 self.message = "Problem with module: 192.168.1."+str(i)
792 #return 0
793 return 1
531 return self.device.status
794 532
795 533
796 def send_beam_num(self, beam_pos):
534 def send_beam(self, beam_pos):
797 535 """
798 536 This function connects to a multicast group and sends the beam number
799 537 to all abs modules.
800 538 """
801 539
802 540 # Se manda a cero RC para poder realizar cambio de beam
803 541 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
804 542 confdds = ''
805 543 confjars = ''
806 544 confrc = ''
807 545
808 546 #TO STOP DEVICES: DDS-JARS-RC
809 547 for i in range(0,len(confs)):
810 548 if i==0:
811 549 for conf in confs:
812 550 if conf.device.device_type.name == 'dds':
813 551 confdds = conf
814 552 confdds.stop_device()
815 553 break
816 554 if i==1:
817 555 for conf in confs:
818 556 if conf.device.device_type.name == 'jars':
819 557 confjars = conf
820 558 confjars.stop_device()
821 559 break
822 560 if i==2:
823 561 for conf in confs:
824 562 if conf.device.device_type.name == 'rc':
825 563 confrc = conf
826 564 confrc.stop_device()
827 565 break
828 566
829 567 if beam_pos > 0:
830 568 beam_pos = beam_pos - 1
831 569 else:
832 570 beam_pos = 0
833 571
834 572 #El indice del apunte debe ser menor que el numero total de apuntes
835 573 #El servidor tcp en el embebido comienza a contar desde 0
836 beams_list = ABSBeam.objects.filter(abs_conf=self)
837 if len(beams_list) < beam_pos:
838 return 0
839
840 flag = 1
841 if beam_pos>9:
842 flag = 2
843
844 header = 'JROABSCeCnModCnMod0100000'
845 flag = str(flag)
846 function = 'CHGB'
847 message_tx = header+flag+function+str(beam_pos)+'0'
848 print message_tx
849 multicast_group = '224.3.29.71'
850 server_address = ('',10000)
851 #Specific Netwrok Interface
852 local_ip='192.168.1.153'
853 # Create the socket
854 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
855 # Bind to the server address
856 sock.bind(server_address)
857 # Telling the OS add the socket to the multicast on all interfaces
858 group = socket.inet_aton(multicast_group)
859 mreq = struct.pack('4sL', group, 1) #socket.INADDR_ANY
574 status = ['0'] * 64
575 message = 'CHGB{}'.format(beam_pos)
576 sock = self.send_multicast(message)
860 577
578 for i in range(64):
861 579 try:
862 #sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
863 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip)) #Specific Netwrok Interface
864 except Exception as e:
865 self.message = str(e)
866 print str(e)
867 sock.close()
868 sock = None
869 return False
580 data, address = sock.recvfrom(1024)
581 print address, data
582 if data == '1':
583 status[int(address[0][10:])-1] = '3'
584 elif data == '0':
585 status[int(address[0][10:])-1] = '1'
586 except:
587 pass
870 588
871 #print 'sending acknowledgement to all: \n' + message_tx
872 try:
873 sock.sendto(message_tx, (multicast_group, 10000))
874 except Exception as e:
875 self.message = str(e)
876 print str(e)
877 sock.close()
878 sock = None
879 return False
880 589 sock.close()
881 sock = None
882 590
883 591 #Start DDS-RC-JARS
884 592 if confdds:
885 593 confdds.start_device()
886 594 if confrc:
887 595 #print confrc
888 596 confrc.start_device()
889 597 if confjars:
890 598 confjars.start_device()
891 599
892 600 self.message = "ABS Beam has been changed"
893 print self.message
894
601 self.module_status = ''.join(status)
602 self.save()
895 603 return True
896 604
897 def test1(self):
898 t1 = time.time()
899 t2 = 0
900 while (t2-t1)<100:#300
901 t2 = time.time()
902 self.send_beam_num(2)
903 time.sleep(0.04)
904 self.send_beam_num(1)
905 time.sleep(0.04)
906 return
907
908 def change_procs_test1(self, module):
909
910 for i in range (1,300):#300
911 beam_pos = 1
912 module_address = ('192.168.1.'+str(module), 5500)
913 header = 'JROABSCeCnModCnMod0100000'
914 numbers = len(str(beam_pos))
915 function = 'CHGB'
916
917 message_tx = header+str(numbers)+function+str(beam_pos)+'0'
918
919 # Create the datagram socket
920 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
921 sock.connect(module_address)
922
923 sock.send(message_tx)
924 #t = sock.recv(1024)
925 sock.close()
926 sock = None
927
928
929 time.sleep(0.04)
930
931
932 beam_pos = 0
933 numbers = len(str(beam_pos))
934
935 message_tx = header+str(numbers)+function+str(beam_pos)+'0'
936
937 # Create the datagram socket
938 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
939 sock.connect(module_address)
940 sock.send(message_tx)
941 sock.close()
942 sock = None
943
944 time.sleep(0.04)
945
946
947 def multi_procs_test1(self):
948
949 """
950 This function sends the beam number to all abs modules using multiprocessing.
951 """
952
953 #if __name__ == "__main__":
954 size = 10000000 # Number of random numbers to add
955 procs = 65 # (Number-1) of processes to create (absmodule)
956
957 # Create a list of jobs and then iterate through
958 # the number of processes appending each process to
959 # the job list
960 jobs = []
961 for i in range(1, procs):
962
963 process = multiprocessing.Process(target=self.change_procs_test1,args=(i,))
964 jobs.append(process)
965 #print jobs
966
967 # Start the processes (i.e. calculate the random number lists)
968 for j in jobs:
969 #time.sleep(0.4)
970 #print j
971 j.start()
972
973 # Ensure all of the processes have finished
974 for j in jobs:
975 j.join()
976
977 print("List processing complete.")
978 return 1
979
980
981
982 def multi_procs_test2(self):
983 """
984 This function use multiprocessing python library. Importing Pool we can select
985 the number of cores we want to use
986 After 'nproc' linux command, we know how many cores computer has.
987 NOT WORKING
988 """
989 import multiprocessing
990 pool = multiprocessing.Pool(3) # cores
991
992 tasks = []
993 procs = 65
994 for i in range(62, procs):
995 tasks.append( (i,))
996 #print tasks
997 #pool.apply_async(self.change_procs_test1, 62)
998 results = [pool.apply( self.change_procs_test1, t ) for t in tasks]
999 #for result in results:
1000 #result.get()
1001 #(plotNum, plotFilename) = result.get()
1002 #print("Result: plot %d written to %s" % (plotNum, plotFilename) )
1003
1004 return 1
1005
1006
1007 def multi_procs_test3(self):
1008 """
1009 This function use multiprocessing python library. Importing Pool we can select
1010 the number of cores we want to use
1011 After 'nproc' linux command, we know how many cores computer has.
1012 """
1013 from multiprocessing import Pool
1014 import time
1015
1016 def f(x):
1017 return x*x
1018
1019 tasks = []
1020 procs = 65
1021 pool = Pool(processes=4)
1022
1023 #for i in range(62, procs):
1024 #result = pool.map(f, range(62,65))
1025 it = pool.imap(self.change_procs_test1, range(62,65))
1026 #result.get(timeout=5)
1027
1028 return 1
1029
1030
1031 def multi_procs_test4(self):
1032 import multiprocessing as mp
1033
1034
1035 num_workers = mp.cpu_count()
1036
1037 pool = mp.Pool(num_workers)
1038 procs = 65
1039 for i in range(62, procs):
1040 #for task in tasks:
1041 pool.apply_async(self.f, args = (i,))
1042
1043 pool.close()
1044 pool.join()
1045
1046 return 1
1047
1048 605
1049 606 def get_absolute_url_import(self):
1050 607 return reverse('url_import_abs_conf', args=[str(self.id)])
1051 608
1052 609
1053 def get_absolute_url_status(self):
1054 return reverse('url_status_abs_conf', args=[str(self.id)])
1055
1056
1057
1058 610 class ABSBeam(models.Model):
1059 611
1060 612 name = models.CharField(max_length=60, default='Beam')
1061 613 antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
1062 614 abs_conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration')
1063 615 tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
1064 616 rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
1065 617 s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
1066 618 e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
1067 modules_conf = models.CharField(verbose_name='Modules', max_length=2000, default=json.dumps(conf_default))
1068 619 ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
1069 620 only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
1070 621
1071 622 class Meta:
1072 623 db_table = 'abs_beams'
1073 624
1074 625 def __unicode__(self):
1075 626 return u'%s' % (self.name)
1076 627
1077 628 def parms_to_dict(self):
1078 629
1079 #Update data
1080 self.modules_6bits()
1081
1082 630 parameters = {}
1083
1084 631 parameters['name'] = self.name
1085 632 parameters['antenna'] = ast.literal_eval(self.antenna)
1086 633 parameters['abs_conf'] = self.abs_conf.name
1087 634 parameters['tx'] = ast.literal_eval(self.tx)
1088 635 parameters['rx'] = ast.literal_eval(self.rx)
1089 636 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
1090 637 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
1091 parameters['configuration'] = ast.literal_eval(self.modules_conf)
1092 638 parameters['ues'] = ast.literal_eval(self.ues)
1093 639 parameters['only_rx'] = json.loads(self.only_rx)
1094 640
1095 641 return parameters
1096 642
1097 643 def dict_to_parms(self, parameters):
1098 644
1099 645 self.name = parameters['name']
1100 646 self.antenna = json.dumps(parameters['antenna'])
1101 647 #self.abs_conf = parameters['abs_conf']
1102 648 self.tx = json.dumps(parameters['tx'])
1103 649 self.rx = json.dumps(parameters['rx'])
1104 650 #self.s_time = parameters['s_time']
1105 651 #self.e_time = parameters['e_time']
1106 652 self.ues = json.dumps(parameters['ues'])
1107 653 self.only_rx = json.dumps(parameters['only_rx'])
1108
1109 self.modules_6bits()
1110 654 self.save()
1111 655
1112 656
1113 657 def clone(self, **kwargs):
1114 658
1115 659 self.pk = None
1116 660 self.id = None
1117 661 for attr, value in kwargs.items():
1118 662 setattr(self, attr, value)
1119 663
1120 664 self.save()
1121 665
1122 666 return self
1123 667
1124 668
1125
1126 669 def module_6bits(self, module):
1127 670 """
1128 671 This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
1129 672 """
1130 673 if module > 64:
1131 674 beam_bits = ""
1132 675 return beam_bits
1133 676
1134 677 data = ast.literal_eval(self.antenna)
1135 678 up_data = data['antenna_up']
1136 679 down_data = data['antenna_down']
1137 680
1138 681 pos = ip2position(module)
1139 682 up_value = up_data[pos[0]][pos[1]]
1140 683 down_value = down_data[pos[0]][pos[1]]
1141 684
1142 685 up_bits = up_conv_bits(up_value)
1143 686 down_bits = down_conv_bits(down_value)
1144 687 beam_bits = up_bits+down_bits
1145 688
1146 689 return beam_bits
1147 690
1148 def modules_6bits(self):
1149 """
1150 This function returns 6bits from every abs module (1-64) in a dict
1151 """
1152 modules_configuration = ast.literal_eval(self.modules_conf)
1153
1154 for i in range(1,65):
1155 modules_configuration[str(i)] = self.module_6bits(i)
1156
1157 self.modules_conf = json.dumps(modules_configuration)
1158 self.save()
1159
1160 return self.modules_conf
1161
1162
1163 def set_as_activebeam(self):
1164 """
1165 This function set this beam as the active beam of its ABS Configuration.
1166 """
1167 self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
1168 self.abs_conf.save()
1169
1170 return
1171
1172 691
1173 692 @property
1174 693 def get_upvalues(self):
1175 694 """
1176 695 This function reads antenna pattern and show the up-value of one abs module
1177 696 """
1178 697
1179 698 data = ast.literal_eval(self.antenna)
1180 699 up_data = data['antenna_up']
1181 700
1182 701 up_values = []
1183 702 for data in up_data:
1184 703 for i in range(0,8):
1185 704 up_values.append(data[i])
1186 705
1187 706 return up_values
1188 707
1189 708 @property
1190 709 def antenna_upvalues(self):
1191 710 """
1192 711 This function reads antenna pattern and show the up - values of one abs beam
1193 712 in a particular order
1194 713 """
1195 714 data = ast.literal_eval(self.antenna)
1196 715 up_data = data['antenna_up']
1197 716
1198 717 return up_data
1199 718
1200 719 @property
1201 720 def antenna_downvalues(self):
1202 721 """
1203 722 This function reads antenna pattern and show the down - values of one abs beam
1204 723 in a particular order
1205 724 """
1206 725 data = ast.literal_eval(self.antenna)
1207 726 down_data = data['antenna_down']
1208 727
1209 728 return down_data
1210 729
1211 730 @property
1212 731 def get_downvalues(self):
1213 732 """
1214 733 This function reads antenna pattern and show the down-value of one abs module
1215 734 """
1216 735
1217 736 data = ast.literal_eval(self.antenna)
1218 737 down_data = data['antenna_down']
1219 738
1220 739 down_values = []
1221 740 for data in down_data:
1222 741 for i in range(0,8):
1223 742 down_values.append(data[i])
1224 743
1225 744 return down_values
1226 745
1227 746 @property
1228 747 def get_up_ues(self):
1229 748 """
1230 749 This function shows the up-ues-value of one beam
1231 750 """
1232 751 data = ast.literal_eval(self.ues)
1233 752 up_ues = data['up']
1234 753
1235 754 return up_ues
1236 755
1237 756 @property
1238 757 def get_down_ues(self):
1239 758 """
1240 759 This function shows the down-ues-value of one beam
1241 760 """
1242 761 data = ast.literal_eval(self.ues)
1243 762 down_ues = data['down']
1244 763
1245 764 return down_ues
1246 765
1247 766 @property
1248 767 def get_up_onlyrx(self):
1249 768 """
1250 769 This function shows the up-onlyrx-value of one beam
1251 770 """
1252 771 data = json.loads(self.only_rx)
1253 772 up_onlyrx = data['up']
1254 773
1255 774 return up_onlyrx
1256 775
1257 776 @property
1258 777 def get_down_onlyrx(self):
1259 778 """
1260 779 This function shows the down-onlyrx-value of one beam
1261 780 """
1262 781 data = json.loads(self.only_rx)
1263 782 down_onlyrx = data['down']
1264 783
1265 784 return down_onlyrx
1266 785
1267 786 @property
1268 787 def get_tx(self):
1269 788 """
1270 789 This function shows the tx-values of one beam
1271 790 """
1272 791 data = json.loads(self.tx)
1273 792
1274 793 return data
1275 794
1276 795 @property
1277 796 def get_uptx(self):
1278 797 """
1279 798 This function shows the up-tx-values of one beam
1280 799 """
1281 800 data = json.loads(self.tx)
1282 801 up_data = data['up']
1283 802
1284 803 up_values = []
1285 804 for data in up_data:
1286 805 for i in range(0,8):
1287 806 up_values.append(data[i])
1288 807
1289 808 return up_values
1290 809
1291 810 @property
1292 811 def get_downtx(self):
1293 812 """
1294 813 This function shows the down-tx-values of one beam
1295 814 """
1296 815 data = json.loads(self.tx)
1297 816 down_data = data['down']
1298 817
1299 818 down_values = []
1300 819 for data in down_data:
1301 820 for i in range(0,8):
1302 821 down_values.append(data[i])
1303 822
1304 823 return down_values
1305 824
1306 825
1307 826
1308 827 @property
1309 828 def get_rx(self):
1310 829 """
1311 830 This function shows the rx-values of one beam
1312 831 """
1313 832 data = json.loads(self.rx)
1314 833
1315 834 return data
1316 835
1317 836 @property
1318 837 def get_uprx(self):
1319 838 """
1320 839 This function shows the up-rx-values of one beam
1321 840 """
1322 841 data = json.loads(self.rx)
1323 842 up_data = data['up']
1324 843
1325 844 up_values = []
1326 845 for data in up_data:
1327 846 for i in range(0,8):
1328 847 up_values.append(data[i])
1329 848
1330 849 return up_values
1331 850
1332 851 @property
1333 852 def get_downrx(self):
1334 853 """
1335 854 This function shows the down-rx-values of one beam
1336 855 """
1337 856 data = json.loads(self.rx)
1338 857 down_data = data['down']
1339 858
1340 859 down_values = []
1341 860 for data in down_data:
1342 861 for i in range(0,8):
1343 862 down_values.append(data[i])
1344 863
1345 864 return down_values
@@ -1,550 +1,476
1 {% extends "dev_conf.html" %}
2
3 {% load static %}
4 {% load bootstrap3 %}
5 {% load main_tags %}
6
7 {% block extra-menu-actions %}
8 <li><a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank"><span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Patterns </a></li>
9 {% endblock %}
10
11 {% block extra-content %}
1 {% extends "dev_conf.html" %} {% load static %} {% load bootstrap3 %} {% load main_tags %}
2 {% block extra-head %}
12 3 <style>
13
14 4 .abs {
15 5 border: 2px solid #00334d;
16 6 vertical-align: center;
17 7 display: inline-block;
18 8 }
9
19 10 .abs tr:nth-child(1){
20 11 border-bottom: 1px dashed #00334d;
21 12 }
13
22 14 .abs tr{
23 15 border-bottom: 0px solid #00334d;
24 16 }
17
25 18 .abs td {
26 19 border-right: 1px dashed #00334d;
27 20 text-align: center;
28 21 padding: 5px;
29 22 }
30 23
31 24
32 25 .legend {
33 26 margin-left: 15px;
34 27 display: inline-block;
35 28 border: 2px solid #00334d;
36 29 vertical-align: top;
37 30 }
31
38 32 .legend th{
39 33 border-bottom: 1px dashed #00334d;
40 34 font-weight: bold;
41 35 vertical-align: center;
42 36 text-align: center;
43 37 }
38
44 39 .legend td {
45 40 padding: 2px;
46 41 text-align: center;
47 42 }
48 43
49 44
50 45 .north {
51 46 border: 2px solid #00334d;
52 47 vertical-align: center;
53 48 font-weight: bold;
54 49 }
50
55 51 .north tr{
56 52 border: 1px solid #ffffff;
57 53
58 54 }
55
59 56 .north td{
60 57 border: 2px solid #e2e2e7;
61 58 text-align: center;
62 59 padding: 1px 15px 1px 15px;
63 60 }
61
64 62 .north tr:nth-child(even) td:nth-child(n){
65 63 border-bottom: 12px solid #e2e2e7;
66 64 }
65
67 66 .north td:nth-child(n) {
68 67 border-right: 12px solid #e2e2e7;
69 68 }
69
70 70 .north td:nth-last-child(4n+1) {
71 71 border-right: 2px solid #e2e2e7;
72 72 }
73
73 74 .north tr:nth-last-child(1) td:nth-child(n){
74 75 border-bottom: 3px solid #e2e2e7;
75 76 }
76 77
77
78
79 78 .east {
80 79 border: 2px solid #00334d;
81 80 vertical-align: center;
82 81 font-weight: bold;
83 82 }
83
84 84 .east tr{
85 85 border: 1px solid #ffffff;
86 86 }
87
87 88 .east td{
88 89 border: 2px solid #e2e2e7;
89 90 text-align: center;
90 91 padding: 1px 15px 1px 15px;
91 92 }
93
92 94 .east tr:nth-child(even) td:nth-child(n){
93 95 border-bottom: 12px solid #e2e2e7;
94 96 }
97
95 98 .east td:nth-child(n) {
96 99 border-right: 12px solid #e2e2e7;
97 100 }
101
98 102 .east td:nth-last-child(4n+1) {
99 103 border-right: 2px solid #e2e2e7;
100 104 }
105
101 106 .east tr:nth-last-child(1) td:nth-child(n){
102 107 border-bottom: 3px solid #e2e2e7;
103 108 }
104 109
105
106
107
108 110 .west {
109 111 border: 2px solid #00334d;
110 112 vertical-align: center;
111 113 font-weight: bold;
112 114 }
115
113 116 .west tr{
114 117 border: 1px solid #ffffff;
115 118 }
119
116 120 .west td{
117 121 border: 2px solid #e2e2e7;
118 122 text-align: center;
119 123 padding: 1px 15px 1px 15px;
120 124 }
125
121 126 .west tr:nth-child(even) td:nth-child(n){
122 127 border-bottom: 12px solid #e2e2e7;
123 128 }
129
124 130 .west td:nth-child(n) {
125 131 border-right: 12px solid #e2e2e7;
126 132 }
133
127 134 .west td:nth-last-child(4n+1) {
128 135 border-right: 2px solid #e2e2e7;
129 136 }
137
130 138 .west tr:nth-last-child(1) td:nth-child(n){
131 139 border-bottom: 3px solid #e2e2e7;
132 140 }
133 141
134
135
136
137 142 .south {
138 143 border: 2px solid #00334d;
139 144 vertical-align: center;
140 145 font-weight: bold;
141 146 }
147
142 148 .south tr{
143 149 border: 1px solid #ffffff;
144 150 }
151
145 152 .south td{
146 153 border: 2px solid #e2e2e7;
147 154 text-align: center;
148 155 padding: 1px 15px 1px 15px;
149 156 }
157
150 158 .south tr:nth-child(even) td:nth-child(n){
151 159 border-bottom: 12px solid #e2e2e7;
152 160 }
161
153 162 .south td:nth-child(n) {
154 163 border-right: 12px solid #e2e2e7;
155 164 }
165
156 166 .south td:nth-last-child(4n+1) {
157 167 border-right: 2px solid #e2e2e7;
158 168 }
169
159 170 .south tr:nth-last-child(1) td:nth-child(n){
160 171 border-bottom: 3px solid #e2e2e7;
161 172 }
162
163
164
165
166 173 </style>
167
168 {% if status_request %}
169 <img id="loading" src="{% static 'images/loader.gif' %}">
170 {% endif %}
171
172
174 {% endblock %}
175 {% block extra-menu-actions %}
176 <li>
177 <a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank">
178 <span class="glyphicon glyphicon-picture" aria-hidden="true"></span> View Patterns </a>
179 </li>
180 {% endblock %}
181 {% block extra-content %}
173 182 {% if beams %}
174
175
176
177 183 <h4>Beams:</h4>
178 184 <div class="container">
179 185 <ul class="nav nav-pills">
180 186 {% for beam in beams %}
181 <li {% if active_beam.id == beam.id %} class="active" {% endif %} >
187 <li {%if beam.pk == active_beam %} class="active" {% endif %}>
182 188 <a data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
183 189 </li>
184 190 {% endfor %}
185 191 </ul>
186 192
187
188 193 <div class="tab-content">
189 <div id="home" class="tab-pane fade in active">
190 <!---->
191 {% if active_beam %}
192 <h3>Active Beam: {{active_beam.name}}</h3>
193
194 <table id="abs_pattern" class="abs">
194 {% for beam in beams %}
195 <div id="menu{{forloop.counter}}" class="tab-pane fade {%if beam.pk == active_beam %}active in{% endif %}">
196 <h3>{%if beam.pk == active_beam %}Active Beam: {%endif%}{{beam.name}}</h3>
197 <table id="abs_pattern{{forloop.counter}}" class="abs">
195 198 <tr>
196 <td> <b>North Quarter</b>
199 <td>
200 <b>North Quarter</b>
197 201 <table class="north ">
198 202 <tr>
199 <td {{color_status.1}} title='{{module_messages.1}}'>{{active_beam.get_upvalues.0}}</td> <td {{color_status.2}} title='{{module_messages.2}}'>{{active_beam.get_upvalues.1}}</td> <td {{color_status.3}} title='{{module_messages.3}}'>{{active_beam.get_upvalues.2}}</td> <td {{color_status.4}} title='{{module_messages.4}}'>{{active_beam.get_upvalues.3}}</td>
203 <td {%if beam.pk == active_beam %} {{color_status.1}} t{%endif%} itle='{{module_messages.1}}'>{{beam.get_upvalues.0}}</td>
204 <td {%if beam.pk == active_beam %} {{color_status.2}} t{%endif%} itle='{{module_messages.2}}'>{{beam.get_upvalues.1}}</td>
205 <td {%if beam.pk == active_beam %} {{color_status.3}} t{%endif%} itle='{{module_messages.3}}'>{{beam.get_upvalues.2}}</td>
206 <td {%if beam.pk == active_beam %} {{color_status.4}} t{%endif%} itle='{{module_messages.4}}'>{{beam.get_upvalues.3}}</td>
200 207 </tr>
201 208 <tr>
202 <td {{color_status.1}} title='{{module_messages.1}}'>{{active_beam.get_downvalues.0}}</td> <td {{color_status.2}} title='{{module_messages.2}}'>{{active_beam.get_downvalues.1}}</td> <td {{color_status.3}} title='{{module_messages.3}}'>{{active_beam.get_downvalues.2}}</td> <td {{color_status.4}} title='{{module_messages.4}}'>{{active_beam.get_downvalues.3}}</td>
209 <td {%if beam.pk == active_beam %} {{color_status.1}} t{%endif%} itle='{{module_messages.1}}'>{{beam.get_downvalues.0}}</td>
210 <td {%if beam.pk == active_beam %} {{color_status.2}} t{%endif%} itle='{{module_messages.2}}'>{{beam.get_downvalues.1}}</td>
211 <td {%if beam.pk == active_beam %} {{color_status.3}} t{%endif%} itle='{{module_messages.3}}'>{{beam.get_downvalues.2}}</td>
212 <td {%if beam.pk == active_beam %} {{color_status.4}} t{%endif%} itle='{{module_messages.4}}'>{{beam.get_downvalues.3}}</td>
203 213 </tr>
204 214 <tr>
205 <td {{color_status.9}} title='{{module_messages.9}}'>{{active_beam.get_upvalues.8}}</td> <td {{color_status.10}} title='{{module_messages.10}}'>{{active_beam.get_upvalues.9}}</td> <td {{color_status.11}} title='{{module_messages.11}}'>{{active_beam.get_upvalues.10}}</td> <td {{color_status.12}} title='{{module_messages.12}}'>{{active_beam.get_upvalues.11}}</td>
215 <td {%if beam.pk == active_beam %} {{color_status.9}} t{%endif%} itle='{{module_messages.9}}'>{{beam.get_upvalues.8}}</td>
216 <td {%if beam.pk == active_beam %} {{color_status.10}} {%endif%} title='{{module_messages.10}}'>{{beam.get_upvalues.9}}</td>
217 <td {%if beam.pk == active_beam %} {{color_status.11}} {%endif%} title='{{module_messages.11}}'>{{beam.get_upvalues.10}}</td>
218 <td {%if beam.pk == active_beam %} {{color_status.12}} {%endif%} title='{{module_messages.12}}'>{{beam.get_upvalues.11}}</td>
206 219 </tr>
207 220 <tr>
208 <td {{color_status.9}} title='{{module_messages.9}}'>{{active_beam.get_downvalues.8}}</td> <td {{color_status.10}} title='{{module_messages.10}}'>{{active_beam.get_downvalues.9}}</td> <td {{color_status.11}} title='{{module_messages.11}}'>{{active_beam.get_downvalues.10}}</td> <td {{color_status.12}} title='{{module_messages.12}}'>{{active_beam.get_downvalues.11}}</td>
221 <td {%if beam.pk == active_beam %} {{color_status.9}} t{%endif%} itle='{{module_messages.9}}'>{{beam.get_downvalues.8}}</td>
222 <td {%if beam.pk == active_beam %} {{color_status.10}} {%endif%} title='{{module_messages.10}}'>{{beam.get_downvalues.9}}</td>
223 <td {%if beam.pk == active_beam %} {{color_status.11}} {%endif%} title='{{module_messages.11}}'>{{beam.get_downvalues.10}}</td>
224 <td {%if beam.pk == active_beam %} {{color_status.12}} {%endif%} title='{{module_messages.12}}'>{{beam.get_downvalues.11}}</td>
209 225 </tr>
210 226 <tr>
211 <td {{color_status.17}} title='{{module_messages.17}}'>{{active_beam.get_upvalues.16}}</td> <td {{color_status.18}} title='{{module_messages.18}}'>{{active_beam.get_upvalues.17}}</td> <td {{color_status.19}} title='{{module_messages.19}}'>{{active_beam.get_upvalues.18}}</td> <td {{color_status.20}} title='{{module_messages.20}}'>{{active_beam.get_upvalues.19}}</td>
227 <td {%if beam.pk == active_beam %} {{color_status.17}} {%endif%} title='{{module_messages.17}}'>{{beam.get_upvalues.16}}</td>
228 <td {%if beam.pk == active_beam %} {{color_status.18}} {%endif%} title='{{module_messages.18}}'>{{beam.get_upvalues.17}}</td>
229 <td {%if beam.pk == active_beam %} {{color_status.19}} {%endif%} title='{{module_messages.19}}'>{{beam.get_upvalues.18}}</td>
230 <td {%if beam.pk == active_beam %} {{color_status.20}} {%endif%} title='{{module_messages.20}}'>{{beam.get_upvalues.19}}</td>
212 231 </tr>
213 232 <tr>
214 <td {{color_status.17}} title='{{module_messages.17}}'>{{active_beam.get_downvalues.16}}</td> <td {{color_status.18}} title='{{module_messages.18}}'>{{active_beam.get_downvalues.17}}</td> <td {{color_status.19}} title='{{module_messages.19}}'>{{active_beam.get_downvalues.18}}</td> <td {{color_status.20}} title='{{module_messages.20}}'>{{active_beam.get_downvalues.19}}</td>
233 <td {%if beam.pk == active_beam %} {{color_status.17}} {%endif%} title='{{module_messages.17}}'>{{beam.get_downvalues.16}}</td>
234 <td {%if beam.pk == active_beam %} {{color_status.18}} {%endif%} title='{{module_messages.18}}'>{{beam.get_downvalues.17}}</td>
235 <td {%if beam.pk == active_beam %} {{color_status.19}} {%endif%} title='{{module_messages.19}}'>{{beam.get_downvalues.18}}</td>
236 <td {%if beam.pk == active_beam %} {{color_status.20}} {%endif%} title='{{module_messages.20}}'>{{beam.get_downvalues.19}}</td>
215 237 </tr>
216 238 <tr>
217 <td {{color_status.25}} title='{{module_messages.25}}'>{{active_beam.get_upvalues.24}}</td> <td {{color_status.26}} title='{{module_messages.26}}'>{{active_beam.get_upvalues.25}}</td> <td {{color_status.27}} title='{{module_messages.27}}'>{{active_beam.get_upvalues.26}}</td> <td {{color_status.28}} title='{{module_messages.28}}'>{{active_beam.get_upvalues.27}}</td>
239 <td {%if beam.pk == active_beam %} {{color_status.25}} {%endif%} title='{{module_messages.25}}'>{{beam.get_upvalues.24}}</td>
240 <td {%if beam.pk == active_beam %} {{color_status.26}} {%endif%} title='{{module_messages.26}}'>{{beam.get_upvalues.25}}</td>
241 <td {%if beam.pk == active_beam %} {{color_status.27}} {%endif%} title='{{module_messages.27}}'>{{beam.get_upvalues.26}}</td>
242 <td {%if beam.pk == active_beam %} {{color_status.28}} {%endif%} title='{{module_messages.28}}'>{{beam.get_upvalues.27}}</td>
218 243 </tr>
219 244 <tr>
220 <td {{color_status.25}} title='{{module_messages.25}}'>{{active_beam.get_downvalues.24}}</td> <td {{color_status.26}} title='{{module_messages.26}}'>{{active_beam.get_downvalues.25}}</td> <td {{color_status.27}} title='{{module_messages.27}}'>{{active_beam.get_downvalues.26}}</td> <td {{color_status.28}} title='{{module_messages.28}}'>{{active_beam.get_downvalues.27}}</td>
245 <td {%if beam.pk == active_beam %} {{color_status.25}} {%endif%} title='{{module_messages.25}}'>{{beam.get_downvalues.24}}</td>
246 <td {%if beam.pk == active_beam %} {{color_status.26}} {%endif%} title='{{module_messages.26}}'>{{beam.get_downvalues.25}}</td>
247 <td {%if beam.pk == active_beam %} {{color_status.27}} {%endif%} title='{{module_messages.27}}'>{{beam.get_downvalues.26}}</td>
248 <td {%if beam.pk == active_beam %} {{color_status.28}} {%endif%} title='{{module_messages.28}}'>{{beam.get_downvalues.27}}</td>
221 249 </tr>
222 250 </table>
223 251 </td>
224 <td> <b>East Quarter</b>
252 <td>
253 <b>East Quarter</b>
225 254 <table class="east ">
226 255 <tr>
227 <td {{color_status.5}} title='{{module_messages.5}}'>{{active_beam.get_upvalues.4}}</td> <td {{color_status.6}} title='{{module_messages.6}}'>{{active_beam.get_upvalues.5}}</td> <td {{color_status.7}} title='{{module_messages.7}}'>{{active_beam.get_upvalues.6}}</td> <td {{color_status.8}} title='{{module_messages.8}}'>{{active_beam.get_upvalues.7}}</td>
256 <td {%if beam.pk == active_beam %} {{color_status.5}} t{%endif%} itle='{{module_messages.5}}'>{{beam.get_upvalues.4}}</td>
257 <td {%if beam.pk == active_beam %} {{color_status.6}} t{%endif%} itle='{{module_messages.6}}'>{{beam.get_upvalues.5}}</td>
258 <td {%if beam.pk == active_beam %} {{color_status.7}} t{%endif%} itle='{{module_messages.7}}'>{{beam.get_upvalues.6}}</td>
259 <td {%if beam.pk == active_beam %} {{color_status.8}} t{%endif%} itle='{{module_messages.8}}'>{{beam.get_upvalues.7}}</td>
228 260 </tr>
229 261 <tr>
230 <td {{color_status.5}} title='{{module_messages.5}}'>{{active_beam.get_downvalues.4}}</td> <td {{color_status.6}} title='{{module_messages.6}}'>{{active_beam.get_downvalues.5}}</td> <td {{color_status.7}} title='{{module_messages.7}}'>{{active_beam.get_downvalues.6}}</td> <td {{color_status.8}} title='{{module_messages.8}}'>{{active_beam.get_downvalues.7}}</td>
262 <td {%if beam.pk == active_beam %} {{color_status.5}} t{%endif%} itle='{{module_messages.5}}'>{{beam.get_downvalues.4}}</td>
263 <td {%if beam.pk == active_beam %} {{color_status.6}} t{%endif%} itle='{{module_messages.6}}'>{{beam.get_downvalues.5}}</td>
264 <td {%if beam.pk == active_beam %} {{color_status.7}} t{%endif%} itle='{{module_messages.7}}'>{{beam.get_downvalues.6}}</td>
265 <td {%if beam.pk == active_beam %} {{color_status.8}} t{%endif%} itle='{{module_messages.8}}'>{{beam.get_downvalues.7}}</td>
231 266 </tr>
232 267 <tr>
233 <td {{color_status.13}} title='{{module_messages.13}}'>{{active_beam.get_upvalues.12}}</td> <td {{color_status.14}} title='{{module_messages.14}}'>{{active_beam.get_upvalues.13}}</td> <td {{color_status.15}} title='{{module_messages.15}}'>{{active_beam.get_upvalues.14}}</td> <td {{color_status.16}} title='{{module_messages.16}}'>{{active_beam.get_upvalues.15}}</td>
268 <td {%if beam.pk == active_beam %} {{color_status.13}} {%endif%} title='{{module_messages.13}}'>{{beam.get_upvalues.12}}</td>
269 <td {%if beam.pk == active_beam %} {{color_status.14}} {%endif%} title='{{module_messages.14}}'>{{beam.get_upvalues.13}}</td>
270 <td {%if beam.pk == active_beam %} {{color_status.15}} {%endif%} title='{{module_messages.15}}'>{{beam.get_upvalues.14}}</td>
271 <td {%if beam.pk == active_beam %} {{color_status.16}} {%endif%} title='{{module_messages.16}}'>{{beam.get_upvalues.15}}</td>
234 272 </tr>
235 273 <tr>
236 <td {{color_status.13}} title='{{module_messages.13}}'>{{active_beam.get_downvalues.12}}</td> <td {{color_status.14}} title='{{module_messages.14}}'>{{active_beam.get_downvalues.13}}</td> <td {{color_status.15}} title='{{module_messages.15}}'>{{active_beam.get_downvalues.14}}</td> <td {{color_status.16}} title='{{module_messages.16}}'>{{active_beam.get_downvalues.15}}</td>
274 <td {%if beam.pk == active_beam %} {{color_status.13}} {%endif%} title='{{module_messages.13}}'>{{beam.get_downvalues.12}}</td>
275 <td {%if beam.pk == active_beam %} {{color_status.14}} {%endif%} title='{{module_messages.14}}'>{{beam.get_downvalues.13}}</td>
276 <td {%if beam.pk == active_beam %} {{color_status.15}} {%endif%} title='{{module_messages.15}}'>{{beam.get_downvalues.14}}</td>
277 <td {%if beam.pk == active_beam %} {{color_status.16}} {%endif%} title='{{module_messages.16}}'>{{beam.get_downvalues.15}}</td>
237 278 </tr>
238 279 <tr>
239 <td {{color_status.21}} title='{{module_messages.21}}'>{{active_beam.get_upvalues.20}}</td> <td {{color_status.22}} title='{{module_messages.22}}'>{{active_beam.get_upvalues.21}}</td> <td {{color_status.23}} title='{{module_messages.23}}'>{{active_beam.get_upvalues.22}}</td> <td {{color_status.24}} title='{{module_messages.24}}'>{{active_beam.get_upvalues.23}}</td>
280 <td {%if beam.pk == active_beam %} {{color_status.21}} {%endif%} title='{{module_messages.21}}'>{{beam.get_upvalues.20}}</td>
281 <td {%if beam.pk == active_beam %} {{color_status.22}} {%endif%} title='{{module_messages.22}}'>{{beam.get_upvalues.21}}</td>
282 <td {%if beam.pk == active_beam %} {{color_status.23}} {%endif%} title='{{module_messages.23}}'>{{beam.get_upvalues.22}}</td>
283 <td {%if beam.pk == active_beam %} {{color_status.24}} {%endif%} title='{{module_messages.24}}'>{{beam.get_upvalues.23}}</td>
240 284 </tr>
241 285 <tr>
242 <td {{color_status.21}} title='{{module_messages.21}}'>{{active_beam.get_downvalues.20}}</td> <td {{color_status.22}} title='{{module_messages.22}}'>{{active_beam.get_downvalues.21}}</td> <td {{color_status.23}} title='{{module_messages.23}}'>{{active_beam.get_downvalues.22}}</td> <td {{color_status.24}} title='{{module_messages.24}}'>{{active_beam.get_downvalues.23}}</td>
286 <td {%if beam.pk == active_beam %} {{color_status.21}} {%endif%} title='{{module_messages.21}}'>{{beam.get_downvalues.20}}</td>
287 <td {%if beam.pk == active_beam %} {{color_status.22}} {%endif%} title='{{module_messages.22}}'>{{beam.get_downvalues.21}}</td>
288 <td {%if beam.pk == active_beam %} {{color_status.23}} {%endif%} title='{{module_messages.23}}'>{{beam.get_downvalues.22}}</td>
289 <td {%if beam.pk == active_beam %} {{color_status.24}} {%endif%} title='{{module_messages.24}}'>{{beam.get_downvalues.23}}</td>
243 290 </tr>
244 291 <tr>
245 <td {{color_status.29}} title='{{module_messages.29}}'>{{active_beam.get_upvalues.28}}</td> <td {{color_status.30}} title='{{module_messages.30}}'>{{active_beam.get_upvalues.29}}</td> <td {{color_status.31}} title='{{module_messages.31}}'>{{active_beam.get_upvalues.30}}</td> <td {{color_status.32}} title='{{module_messages.32}}'>{{active_beam.get_upvalues.31}}</td>
292 <td {%if beam.pk == active_beam %} {{color_status.29}} {%endif%} title='{{module_messages.29}}'>{{beam.get_upvalues.28}}</td>
293 <td {%if beam.pk == active_beam %} {{color_status.30}} {%endif%} title='{{module_messages.30}}'>{{beam.get_upvalues.29}}</td>
294 <td {%if beam.pk == active_beam %} {{color_status.31}} {%endif%} title='{{module_messages.31}}'>{{beam.get_upvalues.30}}</td>
295 <td {%if beam.pk == active_beam %} {{color_status.32}} {%endif%} title='{{module_messages.32}}'>{{beam.get_upvalues.31}}</td>
246 296 </tr>
247 297 <tr>
248 <td {{color_status.29}} title='{{module_messages.29}}'>{{active_beam.get_downvalues.28}}</td> <td {{color_status.30}} title='{{module_messages.30}}'>{{active_beam.get_downvalues.29}}</td> <td {{color_status.31}} title='{{module_messages.31}}'>{{active_beam.get_downvalues.30}}</td> <td {{color_status.32}} title='{{module_messages.32}}'>{{active_beam.get_downvalues.31}}</td>
298 <td {%if beam.pk == active_beam %} {{color_status.29}} {%endif%} title='{{module_messages.29}}'>{{beam.get_downvalues.28}}</td>
299 <td {%if beam.pk == active_beam %} {{color_status.30}} {%endif%} title='{{module_messages.30}}'>{{beam.get_downvalues.29}}</td>
300 <td {%if beam.pk == active_beam %} {{color_status.31}} {%endif%} title='{{module_messages.31}}'>{{beam.get_downvalues.30}}</td>
301 <td {%if beam.pk == active_beam %} {{color_status.32}} {%endif%} title='{{module_messages.32}}'>{{beam.get_downvalues.31}}</td>
249 302 </tr>
250 303 </table>
251 304 </td>
252 305 </tr>
253 306 <tr>
254 <td> <b>West Quarter</b>
307 <td>
308 <b>West Quarter</b>
255 309 <table class="west ">
256 310 <tr>
257 <td {{color_status.33}} title='{{module_messages.33}}'>{{active_beam.get_upvalues.32}}</td> <td {{color_status.34}} title='{{module_messages.34}}'>{{active_beam.get_upvalues.33}}</td> <td {{color_status.35}} title='{{module_messages.35}}'>{{active_beam.get_upvalues.34}}</td> <td {{color_status.36}} title='{{module_messages.36}}'>{{active_beam.get_upvalues.35}}</td>
311 <td {%if beam.pk == active_beam %} {{color_status.33}} {%endif%} title='{{module_messages.33}}'>{{beam.get_upvalues.32}}</td>
312 <td {%if beam.pk == active_beam %} {{color_status.34}} {%endif%} title='{{module_messages.34}}'>{{beam.get_upvalues.33}}</td>
313 <td {%if beam.pk == active_beam %} {{color_status.35}} {%endif%} title='{{module_messages.35}}'>{{beam.get_upvalues.34}}</td>
314 <td {%if beam.pk == active_beam %} {{color_status.36}} {%endif%} title='{{module_messages.36}}'>{{beam.get_upvalues.35}}</td>
258 315 </tr>
259 316 <tr>
260 <td {{color_status.33}} title='{{module_messages.33}}'>{{active_beam.get_downvalues.32}}</td> <td {{color_status.34}} title='{{module_messages.34}}'>{{active_beam.get_downvalues.33}}</td> <td {{color_status.35}} title='{{module_messages.35}}'>{{active_beam.get_downvalues.34}}</td> <td {{color_status.36}} title='{{module_messages.36}}'>{{active_beam.get_downvalues.35}}</td>
317 <td {%if beam.pk == active_beam %} {{color_status.33}} {%endif%} title='{{module_messages.33}}'>{{beam.get_downvalues.32}}</td>
318 <td {%if beam.pk == active_beam %} {{color_status.34}} {%endif%} title='{{module_messages.34}}'>{{beam.get_downvalues.33}}</td>
319 <td {%if beam.pk == active_beam %} {{color_status.35}} {%endif%} title='{{module_messages.35}}'>{{beam.get_downvalues.34}}</td>
320 <td {%if beam.pk == active_beam %} {{color_status.36}} {%endif%} title='{{module_messages.36}}'>{{beam.get_downvalues.35}}</td>
261 321 </tr>
262 322 <tr>
263 <td {{color_status.41}} title='{{module_messages.41}}'>{{active_beam.get_upvalues.40}}</td> <td {{color_status.42}} title='{{module_messages.42}}'>{{active_beam.get_upvalues.41}}</td> <td {{color_status.43}} title='{{module_messages.43}}'>{{active_beam.get_upvalues.42}}</td> <td {{color_status.44}} title='{{module_messages.44}}'>{{active_beam.get_upvalues.43}}</td>
323 <td {%if beam.pk == active_beam %} {{color_status.41}} {%endif%} title='{{module_messages.41}}'>{{beam.get_upvalues.40}}</td>
324 <td {%if beam.pk == active_beam %} {{color_status.42}} {%endif%} title='{{module_messages.42}}'>{{beam.get_upvalues.41}}</td>
325 <td {%if beam.pk == active_beam %} {{color_status.43}} {%endif%} title='{{module_messages.43}}'>{{beam.get_upvalues.42}}</td>
326 <td {%if beam.pk == active_beam %} {{color_status.44}} {%endif%} title='{{module_messages.44}}'>{{beam.get_upvalues.43}}</td>
264 327 </tr>
265 328 <tr>
266 <td {{color_status.41}} title='{{module_messages.41}}'>{{active_beam.get_downvalues.40}}</td> <td {{color_status.42}} title='{{module_messages.42}}'>{{active_beam.get_downvalues.41}}</td> <td {{color_status.43}} title='{{module_messages.43}}'>{{active_beam.get_downvalues.42}}</td> <td {{color_status.44}} title='{{module_messages.44}}'>{{active_beam.get_downvalues.43}}</td>
329 <td {%if beam.pk == active_beam %} {{color_status.41}} {%endif%} title='{{module_messages.41}}'>{{beam.get_downvalues.40}}</td>
330 <td {%if beam.pk == active_beam %} {{color_status.42}} {%endif%} title='{{module_messages.42}}'>{{beam.get_downvalues.41}}</td>
331 <td {%if beam.pk == active_beam %} {{color_status.43}} {%endif%} title='{{module_messages.43}}'>{{beam.get_downvalues.42}}</td>
332 <td {%if beam.pk == active_beam %} {{color_status.44}} {%endif%} title='{{module_messages.44}}'>{{beam.get_downvalues.43}}</td>
267 333 </tr>
268 334 <tr>
269 <td {{color_status.49}} title='{{module_messages.49}}'>{{active_beam.get_upvalues.48}}</td> <td {{color_status.50}} title='{{module_messages.50}}'>{{active_beam.get_upvalues.49}}</td> <td {{color_status.51}} title='{{module_messages.51}}'>{{active_beam.get_upvalues.50}}</td> <td {{color_status.52}} title='{{module_messages.52}}'>{{active_beam.get_upvalues.51}}</td>
335 <td {%if beam.pk == active_beam %} {{color_status.49}} {%endif%} title='{{module_messages.49}}'>{{beam.get_upvalues.48}}</td>
336 <td {%if beam.pk == active_beam %} {{color_status.50}} {%endif%} title='{{module_messages.50}}'>{{beam.get_upvalues.49}}</td>
337 <td {%if beam.pk == active_beam %} {{color_status.51}} {%endif%} title='{{module_messages.51}}'>{{beam.get_upvalues.50}}</td>
338 <td {%if beam.pk == active_beam %} {{color_status.52}} {%endif%} title='{{module_messages.52}}'>{{beam.get_upvalues.51}}</td>
270 339 </tr>
271 340 <tr>
272 <td {{color_status.49}} title='{{module_messages.49}}'>{{active_beam.get_downvalues.48}}</td> <td {{color_status.50}} title='{{module_messages.50}}'>{{active_beam.get_downvalues.49}}</td> <td {{color_status.51}} title='{{module_messages.51}}'>{{active_beam.get_downvalues.50}}</td> <td {{color_status.52}} title='{{module_messages.52}}'>{{active_beam.get_downvalues.51}}</td>
341 <td {%if beam.pk == active_beam %} {{color_status.49}} {%endif%} title='{{module_messages.49}}'>{{beam.get_downvalues.48}}</td>
342 <td {%if beam.pk == active_beam %} {{color_status.50}} {%endif%} title='{{module_messages.50}}'>{{beam.get_downvalues.49}}</td>
343 <td {%if beam.pk == active_beam %} {{color_status.51}} {%endif%} title='{{module_messages.51}}'>{{beam.get_downvalues.50}}</td>
344 <td {%if beam.pk == active_beam %} {{color_status.52}} {%endif%} title='{{module_messages.52}}'>{{beam.get_downvalues.51}}</td>
273 345 </tr>
274 346 <tr>
275 <td {{color_status.57}} title='{{module_messages.57}}'>{{active_beam.get_upvalues.56}}</td> <td {{color_status.58}} title='{{module_messages.58}}'>{{active_beam.get_upvalues.57}}</td> <td {{color_status.59}} title='{{module_messages.59}}'>{{active_beam.get_upvalues.58}}</td> <td {{color_status.60}} title='{{module_messages.60}}'>{{active_beam.get_upvalues.59}}</td>
347 <td {%if beam.pk == active_beam %} {{color_status.57}} {%endif%} title='{{module_messages.57}}'>{{beam.get_upvalues.56}}</td>
348 <td {%if beam.pk == active_beam %} {{color_status.58}} {%endif%} title='{{module_messages.58}}'>{{beam.get_upvalues.57}}</td>
349 <td {%if beam.pk == active_beam %} {{color_status.59}} {%endif%} title='{{module_messages.59}}'>{{beam.get_upvalues.58}}</td>
350 <td {%if beam.pk == active_beam %} {{color_status.60}} {%endif%} title='{{module_messages.60}}'>{{beam.get_upvalues.59}}</td>
276 351 </tr>
277 352 <tr>
278 <td {{color_status.57}} title='{{module_messages.57}}'>{{active_beam.get_downvalues.56}}</td> <td {{color_status.58}} title='{{module_messages.58}}'>{{active_beam.get_downvalues.57}}</td> <td {{color_status.59}} title='{{module_messages.59}}'>{{active_beam.get_downvalues.58}}</td> <td {{color_status.60}} title='{{module_messages.60}}'>{{active_beam.get_downvalues.59}}</td>
353 <td {%if beam.pk == active_beam %} {{color_status.57}} {%endif%} title='{{module_messages.57}}'>{{beam.get_downvalues.56}}</td>
354 <td {%if beam.pk == active_beam %} {{color_status.58}} {%endif%} title='{{module_messages.58}}'>{{beam.get_downvalues.57}}</td>
355 <td {%if beam.pk == active_beam %} {{color_status.59}} {%endif%} title='{{module_messages.59}}'>{{beam.get_downvalues.58}}</td>
356 <td {%if beam.pk == active_beam %} {{color_status.60}} {%endif%} title='{{module_messages.60}}'>{{beam.get_downvalues.59}}</td>
279 357 </tr>
280 358 </table>
281 359 </td>
282 <td> <b>South Quarter</b>
360 <td>
361 <b>South Quarter</b>
283 362 <table class="south ">
284 363 <tr>
285 <td {{color_status.37}} title='{{module_messages.37}}'>{{active_beam.get_upvalues.36}}</td> <td {{color_status.38}} title='{{module_messages.38}}'>{{active_beam.get_upvalues.37}}</td> <td {{color_status.39}} title='{{module_messages.39}}'>{{active_beam.get_upvalues.38}}</td> <td {{color_status.40}} title='{{module_messages.40}}'>{{active_beam.get_upvalues.39}}</td>
364 <td {%if beam.pk == active_beam %} {{color_status.37}} {%endif%} title='{{module_messages.37}}'>{{beam.get_upvalues.36}}</td>
365 <td {%if beam.pk == active_beam %} {{color_status.38}} {%endif%} title='{{module_messages.38}}'>{{beam.get_upvalues.37}}</td>
366 <td {%if beam.pk == active_beam %} {{color_status.39}} {%endif%} title='{{module_messages.39}}'>{{beam.get_upvalues.38}}</td>
367 <td {%if beam.pk == active_beam %} {{color_status.40}} {%endif%} title='{{module_messages.40}}'>{{beam.get_upvalues.39}}</td>
286 368 </tr>
287 369 <tr>
288 <td {{color_status.37}} title='{{module_messages.37}}'>{{active_beam.get_downvalues.36}}</td> <td {{color_status.38}} title='{{module_messages.38}}'>{{active_beam.get_downvalues.37}}</td> <td {{color_status.39}} title='{{module_messages.39}}'>{{active_beam.get_downvalues.38}}</td> <td {{color_status.40}} title='{{module_messages.40}}'>{{active_beam.get_downvalues.39}}</td>
370 <td {%if beam.pk == active_beam %} {{color_status.37}} {%endif%} title='{{module_messages.37}}'>{{beam.get_downvalues.36}}</td>
371 <td {%if beam.pk == active_beam %} {{color_status.38}} {%endif%} title='{{module_messages.38}}'>{{beam.get_downvalues.37}}</td>
372 <td {%if beam.pk == active_beam %} {{color_status.39}} {%endif%} title='{{module_messages.39}}'>{{beam.get_downvalues.38}}</td>
373 <td {%if beam.pk == active_beam %} {{color_status.40}} {%endif%} title='{{module_messages.40}}'>{{beam.get_downvalues.39}}</td>
289 374 </tr>
290 375 <tr>
291 <td {{color_status.45}} title='{{module_messages.45}}'>{{active_beam.get_upvalues.44}}</td> <td {{color_status.46}} title='{{module_messages.46}}'>{{active_beam.get_upvalues.45}}</td> <td {{color_status.47}} title='{{module_messages.47}}'>{{active_beam.get_upvalues.46}}</td> <td {{color_status.48}} title='{{module_messages.48}}'>{{active_beam.get_upvalues.47}}</td>
376 <td {%if beam.pk == active_beam %} {{color_status.45}} {%endif%} title='{{module_messages.45}}'>{{beam.get_upvalues.44}}</td>
377 <td {%if beam.pk == active_beam %} {{color_status.46}} {%endif%} title='{{module_messages.46}}'>{{beam.get_upvalues.45}}</td>
378 <td {%if beam.pk == active_beam %} {{color_status.47}} {%endif%} title='{{module_messages.47}}'>{{beam.get_upvalues.46}}</td>
379 <td {%if beam.pk == active_beam %} {{color_status.48}} {%endif%} title='{{module_messages.48}}'>{{beam.get_upvalues.47}}</td>
292 380 </tr>
293 381 <tr>
294 <td {{color_status.45}} title='{{module_messages.45}}'>{{active_beam.get_downvalues.44}}</td> <td {{color_status.46}} title='{{module_messages.46}}'>{{active_beam.get_downvalues.45}}</td> <td {{color_status.47}} title='{{module_messages.47}}'>{{active_beam.get_downvalues.46}}</td> <td {{color_status.48}} title='{{module_messages.48}}'>{{active_beam.get_downvalues.47}}</td>
382 <td {%if beam.pk == active_beam %} {{color_status.45}} {%endif%} title='{{module_messages.45}}'>{{beam.get_downvalues.44}}</td>
383 <td {%if beam.pk == active_beam %} {{color_status.46}} {%endif%} title='{{module_messages.46}}'>{{beam.get_downvalues.45}}</td>
384 <td {%if beam.pk == active_beam %} {{color_status.47}} {%endif%} title='{{module_messages.47}}'>{{beam.get_downvalues.46}}</td>
385 <td {%if beam.pk == active_beam %} {{color_status.48}} {%endif%} title='{{module_messages.48}}'>{{beam.get_downvalues.47}}</td>
295 386 </tr>
296 387 <tr>
297 <td {{color_status.53}} title='{{module_messages.53}}'>{{active_beam.get_upvalues.52}}</td> <td {{color_status.54}} title='{{module_messages.54}}'>{{active_beam.get_upvalues.53}}</td> <td {{color_status.55}} title='{{module_messages.55}}'>{{active_beam.get_upvalues.54}}</td> <td {{color_status.56}} title='{{module_messages.56}}'>{{active_beam.get_upvalues.55}}</td>
388 <td {%if beam.pk == active_beam %} {{color_status.53}} {%endif%} title='{{module_messages.53}}'>{{beam.get_upvalues.52}}</td>
389 <td {%if beam.pk == active_beam %} {{color_status.54}} {%endif%} title='{{module_messages.54}}'>{{beam.get_upvalues.53}}</td>
390 <td {%if beam.pk == active_beam %} {{color_status.55}} {%endif%} title='{{module_messages.55}}'>{{beam.get_upvalues.54}}</td>
391 <td {%if beam.pk == active_beam %} {{color_status.56}} {%endif%} title='{{module_messages.56}}'>{{beam.get_upvalues.55}}</td>
298 392 </tr>
299 393 <tr>
300 <td {{color_status.53}} title='{{module_messages.53}}'>{{active_beam.get_downvalues.52}}</td> <td {{color_status.54}} title='{{module_messages.54}}'>{{active_beam.get_downvalues.53}}</td> <td {{color_status.55}} title='{{module_messages.55}}'>{{active_beam.get_downvalues.54}}</td> <td {{color_status.56}} title='{{module_messages.56}}'>{{active_beam.get_downvalues.55}}</td>
394 <td {%if beam.pk == active_beam %} {{color_status.53}} {%endif%} title='{{module_messages.53}}'>{{beam.get_downvalues.52}}</td>
395 <td {%if beam.pk == active_beam %} {{color_status.54}} {%endif%} title='{{module_messages.54}}'>{{beam.get_downvalues.53}}</td>
396 <td {%if beam.pk == active_beam %} {{color_status.55}} {%endif%} title='{{module_messages.55}}'>{{beam.get_downvalues.54}}</td>
397 <td {%if beam.pk == active_beam %} {{color_status.56}} {%endif%} title='{{module_messages.56}}'>{{beam.get_downvalues.55}}</td>
301 398 </tr>
302 399 <tr>
303 <td {{color_status.61}} title='{{module_messages.61}}'>{{active_beam.get_upvalues.60}}</td> <td {{color_status.62}} title='{{module_messages.62}}'>{{active_beam.get_upvalues.61}}</td> <td {{color_status.63}} title='{{module_messages.63}}'>{{active_beam.get_upvalues.62}}</td> <td {{color_status.64}} title='{{module_messages.64}}'>{{active_beam.get_upvalues.63}}</td>
400 <td {%if beam.pk == active_beam %} {{color_status.61}} {%endif%} title='{{module_messages.61}}'>{{beam.get_upvalues.60}}</td>
401 <td {%if beam.pk == active_beam %} {{color_status.62}} {%endif%} title='{{module_messages.62}}'>{{beam.get_upvalues.61}}</td>
402 <td {%if beam.pk == active_beam %} {{color_status.63}} {%endif%} title='{{module_messages.63}}'>{{beam.get_upvalues.62}}</td>
403 <td {%if beam.pk == active_beam %} {{color_status.64}} {%endif%} title='{{module_messages.64}}'>{{beam.get_upvalues.63}}</td>
304 404 </tr>
305 405 <tr>
306 <td {{color_status.61}} title='{{module_messages.61}}'>{{active_beam.get_downvalues.60}}</td> <td {{color_status.62}} title='{{module_messages.62}}'>{{active_beam.get_downvalues.61}}</td> <td {{color_status.63}} title='{{module_messages.63}}'>{{active_beam.get_downvalues.62}}</td> <td {{color_status.64}} title='{{module_messages.64}}'>{{active_beam.get_downvalues.63}}</td>
406 <td {%if beam.pk == active_beam %} {{color_status.61}} {%endif%} title='{{module_messages.61}}'>{{beam.get_downvalues.60}}</td>
407 <td {%if beam.pk == active_beam %} {{color_status.62}} {%endif%} title='{{module_messages.62}}'>{{beam.get_downvalues.61}}</td>
408 <td {%if beam.pk == active_beam %} {{color_status.63}} {%endif%} title='{{module_messages.63}}'>{{beam.get_downvalues.62}}</td>
409 <td {%if beam.pk == active_beam %} {{color_status.64}} {%endif%} title='{{module_messages.64}}'>{{beam.get_downvalues.63}}</td>
307 410 </tr>
308 411 </table>
309 412 </td>
310 413 </tr>
311 414 </table>
312 415
313
314
416 {% if beam.id == active_beam %}
315 417 <table class="legend">
316 418 <tr>
317 419 <th colspan="2">Legend</th>
318 420 </tr>
319 421 <tr>
320 <td class="text-danger"><i>RED</i></td><td>Disconnected</td>
321 </tr>
322 <tr>
323 <td class="text-warning"><i>ORANGE</i></td><td>Connected</td>
324 </tr>
325 <tr>
326 <td class="text-success"><i>GREEN</i></td><td>Running </td>
327 </tr>
328 <!--
329 <tr>
330 <td colspan="2">
331 <button style="margin: 10px;" id="sendbeam" type="button" class="btn btn-default">
332 <span class="glyphicon glyphicon-export" aria-hidden="true"></span>
333 Change Beam</button>
334 </td>
335 </tr>
336 -->
337 </table>
338
339
340
341
342 {% else %}
343 <p><i>This ABS Configuration does not have a current active ABS Beam...<br>
344 Please send Beam List to ABS modules. </i></p>
345
346 {% endif %}
347
348
349 </div>
350
351
352
353 {% for beam in beams %}
354 <div id="menu{{forloop.counter}}" class="tab-pane fade">
355 <h3>{%if active_beam.id == beam.id%}Active Beam: {%endif%}{{beam.name}}</h3>
356 <!--<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>-->
357 <table id="abs_pattern{{forloop.counter}}" class="abs">
358 <tr>
359 <td> <b>North Quarter</b>
360 <table class="north ">
361 <tr>
362 <td {{beam.color_status.1}} title='{{beam.module_messages.1}}'>{{beam.get_upvalues.0}}</td> <td {{beam.color_status.2}} title='{{beam.module_messages.2}}'>{{beam.get_upvalues.1}}</td> <td {{beam.color_status.3}} title='{{beam.module_messages.3}}'>{{beam.get_upvalues.2}}</td> <td {{beam.color_status.4}} title='{{beam.module_messages.4}}'>{{beam.get_upvalues.3}}</td>
363 </tr>
364 <tr>
365 <td {{beam.color_status.1}} title='{{beam.module_messages.1}}'>{{beam.get_downvalues.0}}</td> <td {{beam.color_status.2}} title='{{beam.module_messages.2}}'>{{beam.get_downvalues.1}}</td> <td {{beam.color_status.3}} title='{{beam.module_messages.3}}'>{{beam.get_downvalues.2}}</td> <td {{beam.color_status.4}} title='{{beam.module_messages.4}}'>{{beam.get_downvalues.3}}</td>
366 </tr>
367 <tr>
368 <td {{beam.color_status.9}} title='{{beam.module_messages.9}}'>{{beam.get_upvalues.8}}</td> <td {{beam.color_status.10}} title='{{beam.module_messages.10}}'>{{beam.get_upvalues.9}}</td> <td {{beam.color_status.11}} title='{{beam.module_messages.11}}'>{{beam.get_upvalues.10}}</td> <td {{beam.color_status.12}} title='{{beam.module_messages.12}}'>{{beam.get_upvalues.11}}</td>
369 </tr>
370 <tr>
371 <td {{beam.color_status.9}} title='{{beam.module_messages.9}}'>{{beam.get_downvalues.8}}</td> <td {{beam.color_status.10}} title='{{beam.module_messages.10}}'>{{beam.get_downvalues.9}}</td> <td {{beam.color_status.11}} title='{{beam.module_messages.11}}'>{{beam.get_downvalues.10}}</td> <td {{beam.color_status.12}} title='{{beam.module_messages.12}}'>{{beam.get_downvalues.11}}</td>
372 </tr>
373 <tr>
374 <td {{beam.color_status.17}} title='{{beam.module_messages.17}}'>{{beam.get_upvalues.16}}</td> <td {{beam.color_status.18}} title='{{beam.module_messages.18}}'>{{beam.get_upvalues.17}}</td> <td {{beam.color_status.19}} title='{{beam.module_messages.19}}'>{{beam.get_upvalues.18}}</td> <td {{beam.color_status.20}} title='{{beam.module_messages.20}}'>{{beam.get_upvalues.19}}</td>
375 </tr>
376 <tr>
377 <td {{beam.color_status.17}} title='{{beam.module_messages.17}}'>{{beam.get_downvalues.16}}</td> <td {{beam.color_status.18}} title='{{beam.module_messages.18}}'>{{beam.get_downvalues.17}}</td> <td {{beam.color_status.19}} title='{{beam.module_messages.19}}'>{{beam.get_downvalues.18}}</td> <td {{beam.color_status.20}} title='{{beam.module_messages.20}}'>{{beam.get_downvalues.19}}</td>
378 </tr>
379 <tr>
380 <td {{beam.color_status.25}} title='{{beam.module_messages.25}}'>{{beam.get_upvalues.24}}</td> <td {{beam.color_status.26}} title='{{beam.module_messages.26}}'>{{beam.get_upvalues.25}}</td> <td {{beam.color_status.27}} title='{{beam.module_messages.27}}'>{{beam.get_upvalues.26}}</td> <td {{beam.color_status.28}} title='{{beam.module_messages.28}}'>{{beam.get_upvalues.27}}</td>
381 </tr>
382 <tr>
383 <td {{beam.color_status.25}} title='{{beam.module_messages.25}}'>{{beam.get_downvalues.24}}</td> <td {{beam.color_status.26}} title='{{beam.module_messages.26}}'>{{beam.get_downvalues.25}}</td> <td {{beam.color_status.27}} title='{{beam.module_messages.27}}'>{{beam.get_downvalues.26}}</td> <td {{beam.color_status.28}} title='{{beam.module_messages.28}}'>{{beam.get_downvalues.27}}</td>
384 </tr>
385 </table>
422 <td class="text-danger">
423 <i>RED</i>
386 424 </td>
387 <td> <b>East Quarter</b>
388 <table class="east ">
389 <tr>
390 <td {{beam.color_status.5}} title='{{beam.module_messages.5}}'>{{beam.get_upvalues.4}}</td> <td {{beam.color_status.6}} title='{{beam.module_messages.6}}'>{{beam.get_upvalues.5}}</td> <td {{beam.color_status.7}} title='{{beam.module_messages.7}}'>{{beam.get_upvalues.6}}</td> <td {{beam.color_status.8}} title='{{beam.module_messages.8}}'>{{beam.get_upvalues.7}}</td>
391 </tr>
392 <tr>
393 <td {{beam.color_status.5}} title='{{beam.module_messages.5}}'>{{beam.get_downvalues.4}}</td> <td {{beam.color_status.6}} title='{{beam.module_messages.6}}'>{{beam.get_downvalues.5}}</td> <td {{beam.color_status.7}} title='{{beam.module_messages.7}}'>{{beam.get_downvalues.6}}</td> <td {{beam.color_status.8}} title='{{beam.module_messages.8}}'>{{beam.get_downvalues.7}}</td>
394 </tr>
395 <tr>
396 <td {{beam.color_status.13}} title='{{beam.module_messages.13}}'>{{beam.get_upvalues.12}}</td> <td {{beam.color_status.14}} title='{{beam.module_messages.14}}'>{{beam.get_upvalues.13}}</td> <td {{beam.color_status.15}} title='{{beam.module_messages.15}}'>{{beam.get_upvalues.14}}</td> <td {{beam.color_status.16}} title='{{beam.module_messages.16}}'>{{beam.get_upvalues.15}}</td>
397 </tr>
398 <tr>
399 <td {{beam.color_status.13}} title='{{beam.module_messages.13}}'>{{beam.get_downvalues.12}}</td> <td {{beam.color_status.14}} title='{{beam.module_messages.14}}'>{{beam.get_downvalues.13}}</td> <td {{beam.color_status.15}} title='{{beam.module_messages.15}}'>{{beam.get_downvalues.14}}</td> <td {{beam.color_status.16}} title='{{beam.module_messages.16}}'>{{beam.get_downvalues.15}}</td>
400 </tr>
401 <tr>
402 <td {{beam.color_status.21}} title='{{beam.module_messages.21}}'>{{beam.get_upvalues.20}}</td> <td {{beam.color_status.22}} title='{{beam.module_messages.22}}'>{{beam.get_upvalues.21}}</td> <td {{beam.color_status.23}} title='{{beam.module_messages.23}}'>{{beam.get_upvalues.22}}</td> <td {{beam.color_status.24}} title='{{beam.module_messages.24}}'>{{beam.get_upvalues.23}}</td>
403 </tr>
404 <tr>
405 <td {{beam.color_status.21}} title='{{beam.module_messages.21}}'>{{beam.get_downvalues.20}}</td> <td {{beam.color_status.22}} title='{{beam.module_messages.22}}'>{{beam.get_downvalues.21}}</td> <td {{beam.color_status.23}} title='{{beam.module_messages.23}}'>{{beam.get_downvalues.22}}</td> <td {{beam.color_status.24}} title='{{beam.module_messages.24}}'>{{beam.get_downvalues.23}}</td>
406 </tr>
407 <tr>
408 <td {{beam.color_status.29}} title='{{beam.module_messages.29}}'>{{beam.get_upvalues.28}}</td> <td {{beam.color_status.30}} title='{{beam.module_messages.30}}'>{{beam.get_upvalues.29}}</td> <td {{beam.color_status.31}} title='{{beam.module_messages.31}}'>{{beam.get_upvalues.30}}</td> <td {{beam.color_status.32}} title='{{beam.module_messages.32}}'>{{beam.get_upvalues.31}}</td>
425 <td>Disconnected</td>
409 426 </tr>
410 427 <tr>
411 <td {{beam.color_status.29}} title='{{beam.module_messages.29}}'>{{beam.get_downvalues.28}}</td> <td {{beam.color_status.30}} title='{{beam.module_messages.30}}'>{{beam.get_downvalues.29}}</td> <td {{beam.color_status.31}} title='{{beam.module_messages.31}}'>{{beam.get_downvalues.30}}</td> <td {{beam.color_status.32}} title='{{beam.module_messages.32}}'>{{beam.get_downvalues.31}}</td>
412 </tr>
413 </table>
428 <td class="text-warning">
429 <i>ORANGE</i>
414 430 </td>
431 <td>Connected</td>
415 432 </tr>
416 433 <tr>
417 <td> <b>West Quarter</b>
418 <table class="west ">
419 <tr>
420 <td {{beam.color_status.33}} title='{{beam.module_messages.33}}'>{{beam.get_upvalues.32}}</td> <td {{beam.color_status.34}} title='{{beam.module_messages.34}}'>{{beam.get_upvalues.33}}</td> <td {{beam.color_status.35}} title='{{beam.module_messages.35}}'>{{beam.get_upvalues.34}}</td> <td {{beam.color_status.36}} title='{{beam.module_messages.36}}'>{{beam.get_upvalues.35}}</td>
421 </tr>
422 <tr>
423 <td {{beam.color_status.33}} title='{{beam.module_messages.33}}'>{{beam.get_downvalues.32}}</td> <td {{beam.color_status.34}} title='{{beam.module_messages.34}}'>{{beam.get_downvalues.33}}</td> <td {{beam.color_status.35}} title='{{beam.module_messages.35}}'>{{beam.get_downvalues.34}}</td> <td {{beam.color_status.36}} title='{{beam.module_messages.36}}'>{{beam.get_downvalues.35}}</td>
424 </tr>
425 <tr>
426 <td {{beam.color_status.41}} title='{{beam.module_messages.41}}'>{{beam.get_upvalues.40}}</td> <td {{beam.color_status.42}} title='{{beam.module_messages.42}}'>{{beam.get_upvalues.41}}</td> <td {{beam.color_status.43}} title='{{beam.module_messages.43}}'>{{beam.get_upvalues.42}}</td> <td {{beam.color_status.44}} title='{{beam.module_messages.44}}'>{{beam.get_upvalues.43}}</td>
427 </tr>
428 <tr>
429 <td {{beam.color_status.41}} title='{{beam.module_messages.41}}'>{{beam.get_downvalues.40}}</td> <td {{beam.color_status.42}} title='{{beam.module_messages.42}}'>{{beam.get_downvalues.41}}</td> <td {{beam.color_status.43}} title='{{beam.module_messages.43}}'>{{beam.get_downvalues.42}}</td> <td {{beam.color_status.44}} title='{{beam.module_messages.44}}'>{{beam.get_downvalues.43}}</td>
430 </tr>
431 <tr>
432 <td {{beam.color_status.49}} title='{{beam.module_messages.49}}'>{{beam.get_upvalues.48}}</td> <td {{beam.color_status.50}} title='{{beam.module_messages.50}}'>{{beam.get_upvalues.49}}</td> <td {{beam.color_status.51}} title='{{beam.module_messages.51}}'>{{beam.get_upvalues.50}}</td> <td {{beam.color_status.52}} title='{{beam.module_messages.52}}'>{{beam.get_upvalues.51}}</td>
433 </tr>
434 <tr>
435 <td {{beam.color_status.49}} title='{{beam.module_messages.49}}'>{{beam.get_downvalues.48}}</td> <td {{beam.color_status.50}} title='{{beam.module_messages.50}}'>{{beam.get_downvalues.49}}</td> <td {{beam.color_status.51}} title='{{beam.module_messages.51}}'>{{beam.get_downvalues.50}}</td> <td {{beam.color_status.52}} title='{{beam.module_messages.52}}'>{{beam.get_downvalues.51}}</td>
436 </tr>
437 <tr>
438 <td {{beam.color_status.57}} title='{{beam.module_messages.57}}'>{{beam.get_upvalues.56}}</td> <td {{beam.color_status.58}} title='{{beam.module_messages.58}}'>{{beam.get_upvalues.57}}</td> <td {{beam.color_status.59}} title='{{beam.module_messages.59}}'>{{beam.get_upvalues.58}}</td> <td {{beam.color_status.60}} title='{{beam.module_messages.60}}'>{{beam.get_upvalues.59}}</td>
439 </tr>
440 <tr>
441 <td {{beam.color_status.57}} title='{{beam.module_messages.57}}'>{{beam.get_downvalues.56}}</td> <td {{beam.color_status.58}} title='{{beam.module_messages.58}}'>{{beam.get_downvalues.57}}</td> <td {{beam.color_status.59}} title='{{beam.module_messages.59}}'>{{beam.get_downvalues.58}}</td> <td {{beam.color_status.60}} title='{{beam.module_messages.60}}'>{{beam.get_downvalues.59}}</td>
442 </tr>
443 </table>
434 <td class="text-success">
435 <i>GREEN</i>
444 436 </td>
445 <td> <b>South Quarter</b>
446 <table class="south ">
447 <tr>
448 <td {{beam.color_status.37}} title='{{beam.module_messages.37}}'>{{beam.get_upvalues.36}}</td> <td {{beam.color_status.38}} title='{{beam.module_messages.38}}'>{{beam.get_upvalues.37}}</td> <td {{beam.color_status.39}} title='{{beam.module_messages.39}}'>{{beam.get_upvalues.38}}</td> <td {{beam.color_status.40}} title='{{beam.module_messages.40}}'>{{beam.get_upvalues.39}}</td>
449 </tr>
450 <tr>
451 <td {{beam.color_status.37}} title='{{beam.module_messages.37}}'>{{beam.get_downvalues.36}}</td> <td {{beam.color_status.38}} title='{{beam.module_messages.38}}'>{{beam.get_downvalues.37}}</td> <td {{beam.color_status.39}} title='{{beam.module_messages.39}}'>{{beam.get_downvalues.38}}</td> <td {{beam.color_status.40}} title='{{beam.module_messages.40}}'>{{beam.get_downvalues.39}}</td>
452 </tr>
453 <tr>
454 <td {{beam.color_status.45}} title='{{beam.module_messages.45}}'>{{beam.get_upvalues.44}}</td> <td {{beam.color_status.46}} title='{{beam.module_messages.46}}'>{{beam.get_upvalues.45}}</td> <td {{beam.color_status.47}} title='{{beam.module_messages.47}}'>{{beam.get_upvalues.46}}</td> <td {{beam.color_status.48}} title='{{beam.module_messages.48}}'>{{beam.get_upvalues.47}}</td>
455 </tr>
456 <tr>
457 <td {{beam.color_status.45}} title='{{beam.module_messages.45}}'>{{beam.get_downvalues.44}}</td> <td {{beam.color_status.46}} title='{{beam.module_messages.46}}'>{{beam.get_downvalues.45}}</td> <td {{beam.color_status.47}} title='{{beam.module_messages.47}}'>{{beam.get_downvalues.46}}</td> <td {{beam.color_status.48}} title='{{beam.module_messages.48}}'>{{beam.get_downvalues.47}}</td>
458 </tr>
459 <tr>
460 <td {{beam.color_status.53}} title='{{beam.module_messages.53}}'>{{beam.get_upvalues.52}}</td> <td {{beam.color_status.54}} title='{{beam.module_messages.54}}'>{{beam.get_upvalues.53}}</td> <td {{beam.color_status.55}} title='{{beam.module_messages.55}}'>{{beam.get_upvalues.54}}</td> <td {{beam.color_status.56}} title='{{beam.module_messages.56}}'>{{beam.get_upvalues.55}}</td>
461 </tr>
462 <tr>
463 <td {{beam.color_status.53}} title='{{beam.module_messages.53}}'>{{beam.get_downvalues.52}}</td> <td {{beam.color_status.54}} title='{{beam.module_messages.54}}'>{{beam.get_downvalues.53}}</td> <td {{beam.color_status.55}} title='{{beam.module_messages.55}}'>{{beam.get_downvalues.54}}</td> <td {{beam.color_status.56}} title='{{beam.module_messages.56}}'>{{beam.get_downvalues.55}}</td>
464 </tr>
465 <tr>
466 <td {{beam.color_status.61}} title='{{beam.module_messages.61}}'>{{beam.get_upvalues.60}}</td> <td {{beam.color_status.62}} title='{{beam.module_messages.62}}'>{{beam.get_upvalues.61}}</td> <td {{beam.color_status.63}} title='{{beam.module_messages.63}}'>{{beam.get_upvalues.62}}</td> <td {{beam.color_status.64}} title='{{beam.module_messages.64}}'>{{beam.get_upvalues.63}}</td>
467 </tr>
468 <tr>
469 <td {{beam.color_status.61}} title='{{beam.module_messages.61}}'>{{beam.get_downvalues.60}}</td> <td {{beam.color_status.62}} title='{{beam.module_messages.62}}'>{{beam.get_downvalues.61}}</td> <td {{beam.color_status.63}} title='{{beam.module_messages.63}}'>{{beam.get_downvalues.62}}</td> <td {{beam.color_status.64}} title='{{beam.module_messages.64}}'>{{beam.get_downvalues.63}}</td>
470 </tr>
471 </table>
437 <td>Running
472 438 </td>
473 439 </tr>
474 440 </table>
475
476 {% if active_beam.id != beam.id %}
441 {% else %}
477 442 <div style="vertical-align: top; display:inline-block;">
478 <button style="" id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
443 <button id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
479 444 <span class="glyphicon glyphicon-export" aria-hidden="true"></span>
480 445 Change Beam</button>
481 446 </div>
482 447 {% endif %}
483
484
485
486
487 {% if active_beam %}
488 {% if active_beam.id == beam.id %}
489 <table class="legend">
490 <tr>
491 <th colspan="2">Legend</th>
492 </tr>
493 <tr>
494 <td class="text-danger"><i>RED</i></td><td>Disconnected</td>
495 </tr>
496 <tr>
497 <td class="text-warning"><i>ORANGE</i></td><td>Connected</td>
498 </tr>
499 <tr>
500 <td class="text-success"><i>GREEN</i></td><td>Running
501 </td>
502 </tr>
503 </table>
504
505 {% endif %}
506 {% endif %}
507
508
509 448 </div>
510
511
512 449 {% endfor %}
513
514
515
516 450 </div>
517 451 </div>
518 452
519 453
520 454 {% else %}
521 <p style="color:#b4bcc2; margin-left: 5%;"><i>No Beams...</i></p>
522 {% endif %}
523
524 {% endblock extra-content %}
525
526
527
528 {% block extra-js%}
455 <p style="color:#b4bcc2; margin-left: 5%;">
456 <i>No Beams...</i>
457 </p>
458 {% endif %} {% endblock extra-content %} {% block extra-js%}
529 459 <script>
530 460 $(document).ready(function() {
531 461
532 462 {% for beam in beams %}
533 463
534 464 {% if dev_conf.operation_mode == 1 %}
535 465 $("#send_beam{{forloop.counter}}").prop('disabled', true)
536 466 {% else %}
537 467 $("#send_beam{{forloop.counter}}").click(function() {
538 468 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
539 469 });
540 470 {% endif %}
541 471
542 472 {% endfor %}
543 473
544 {% if status_request %}
545 setTimeout("location.href = '{% url 'url_abs_conf' dev_conf.id %}'",53000);
546 {% endif %}
547 474
548 475 });
549 </script>
550 {% endblock %}
476 </script> {% endblock %} No newline at end of file
@@ -1,17 +1,17
1 1 from django.conf.urls import url
2 2
3 3 from apps.abs import views
4 4
5 5 urlpatterns = (
6 6 url(r'^(?P<id_conf>-?\d+)/$', views.abs_conf, name='url_abs_conf'),
7 7 url(r'^(?P<id_conf>-?\d+)/edit/$', views.abs_conf_edit, name='url_edit_abs_conf'),
8 8 url(r'^(?P<id_conf>-?\d+)/import/$', views.import_file, name='url_import_abs_conf'),
9 url(r'^(?P<id_conf>-?\d+)/status/', views.abs_conf, {'status_request':True},name='url_status_abs_conf'),
9 #url(r'^(?P<id_conf>-?\d+)/status/', views.abs_conf, {'status_request':True},name='url_status_abs_conf'),
10 10 url(r'^(?P<id_conf>-?\d+)/change_beam/(?P<id_beam>-?\d+)/$', views.send_beam, name='url_send_beam'),
11 11 url(r'^(?P<id_conf>-?\d+)/plot/$', views.plot_patterns, name='url_plot_abs_patterns'),
12 12 url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/$', views.plot_patterns, name='url_plot_abs_patterns'),
13 13 url(r'^(?P<id_conf>-?\d+)/plot/(?P<id_beam>-?\d+)/(?P<antenna>[\w\-]+)/pattern.png$', views.plot_pattern, name='url_plot_beam'),
14 14 url(r'^(?P<id_conf>-?\d+)/add_beam/$', views.add_beam, name='url_add_abs_beam'),
15 15 url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/delete/$', views.remove_beam, name='url_remove_abs_beam'),
16 16 url(r'^(?P<id_conf>-?\d+)/beam/(?P<id_beam>-?\d+)/edit/$', views.edit_beam, name='url_edit_abs_beam'),
17 17 )
@@ -1,442 +1,411
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, Experiment
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
123 def abs_conf(request, id_conf, status_request=None):
122 def abs_conf(request, id_conf):
124 123
125 124 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
126 125 beams = ABSBeam.objects.filter(abs_conf=conf)
127 active_beam_id = json.loads(conf.active_beam)
128
129 126 #------------Colors for Active Beam:-------------
130 modules_status = json.loads(conf.module_status)
127 all_status = {}
131 128 module_messages = json.loads(conf.module_messages)
132 129
133 130 color_status = {}
134 for status in modules_status:
135 if modules_status[status] == 3: #Running background-color: #00cc00;
136 color_status[status] = 'class=text-success'#'bgcolor=#00cc00'
137 elif modules_status[status] == 1: #Connected background-color: #ee902c;
138 color_status[status] = 'class=text-warning'#'bgcolor=#ee902c'
131 for i, status in enumerate(conf.module_status):
132 if status == '3': #Running background-color: #00cc00;
133 all_status['{}'.format(i+1)] = 2
134 color_status['{}'.format(i+1)] = 'class=text-success'#'bgcolor=#00cc00'
135 elif status == '1': #Connected background-color: #ee902c;
136 all_status['{}'.format(i+1)] = 1
137 color_status['{}'.format(i+1)] = 'class=text-warning'#'bgcolor=#ee902c'
139 138 else: #Disconnected background-color: #ff0000;
140 color_status[status] = 'class=text-danger'#'bgcolor=#FF0000'
139 all_status['{}'.format(i+1)] = 0
140 color_status['{}'.format(i+1)] = 'class=text-danger'#'bgcolor=#FF0000'
141 141 #------------------------------------------------
142 142
143 143 kwargs = {}
144 #kwargs['status'] = conf.device.get_status_display()
145 144 kwargs['connected_modules'] = str(conf.connected_modules())+'/64'
146
147 145 kwargs['dev_conf'] = conf
146
148 147 if conf.operation_mode == 0:
149 148 kwargs['dev_conf_keys'] = ['name', 'operation_mode']
150 149 else:
151 150 kwargs['dev_conf_keys'] = ['name', 'operation_mode', 'operation_value']
152 151
153 152 kwargs['title'] = 'ABS Configuration'
154 153 kwargs['suptitle'] = 'Details'
155 #kwargs['no_play'] = True
156
157 154 kwargs['button'] = 'Edit Configuration'
158 #------------------Active Beam-----------------------
159 try:
160 active_beam_id = active_beam_id['active_beam']
161 active_beam = ABSBeam.objects.get(pk=active_beam_id)
162 kwargs['active_beam'] = active_beam
163 for beam in beams:
164 if beam.id == active_beam.id:
165 beam.color_status = color_status
166 beam.module_messages = module_messages
167 except:
168 active_beam = ''
169 #----------------------------------------------------
155
156 if conf.active_beam != 0:
157 kwargs['active_beam'] = int(conf.active_beam)
158
170 159 kwargs['beams'] = beams
171 kwargs['modules_status'] = modules_status
160 kwargs['modules_status'] = all_status
172 161 kwargs['color_status'] = color_status
173 162 kwargs['module_messages'] = module_messages
174
175 #if conf.device.status in [0,1]:
176 if conf.connected_modules() == 0:
177 conf.device.status = 0
178 messages.error(request, 'No ABS module is connected.')#conf.message)
179 conf.device.save()
180 else:
181 messages.success(request, 'ABS modules are connected.')#conf.message)
182
183 163 ###### SIDEBAR ######
184 164 kwargs.update(sidebar(conf=conf))
185 165
186 if status_request:
187 conf.status_device()
188 kwargs['status_request'] = True
189 return render(request, 'abs_conf.html', kwargs)
190
191 166 return render(request, 'abs_conf.html', kwargs)
192 167
193 168
194 169 def abs_conf_edit(request, id_conf):
195 170
196 171 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
197 172
198 173 beams = ABSBeam.objects.filter(abs_conf=conf)
199 print beams
200 174
201 175 if request.method=='GET':
202 176 form = ABSConfigurationForm(instance=conf)
203 177
204 178 if request.method=='POST':
205 179 form = ABSConfigurationForm(request.POST, instance=conf)
206 180
207 181 if form.is_valid():
208 182 conf = form.save(commit=False)
209 183 conf.save()
210 184 return redirect('url_abs_conf', id_conf=conf.id)
211 185
212 186 ###### SIDEBAR ######
213 187 kwargs = {}
214 188
215 189 kwargs['dev_conf'] = conf
216 190 #kwargs['id_dev'] = conf.id
217 191 kwargs['id_conf'] = conf.id
218 192 kwargs['form'] = form
219 193 kwargs['abs_beams'] = beams
220 194 kwargs['title'] = 'Device Configuration'
221 195 kwargs['suptitle'] = 'Edit'
222 196 kwargs['button'] = 'Save'
223 197
224 198 kwargs['edit'] = True
225 199
226 200 return render(request, 'abs_conf_edit.html', kwargs)
227 201
228 202
229 203 def import_file(request, id_conf):
230 204
231 205 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
232 206 if request.method=='POST':
233 207 form = ABSImportForm(request.POST, request.FILES)
234 208 if form.is_valid():
235 209 try:
236 210 parms = conf.import_from_file(request.FILES['file_name'])
237 211
238 212 if parms:
239 213 conf.update_from_file(parms)
240 214 messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name'])
241 215 return redirect(conf.get_absolute_url_edit())
242 216
243 217 except Exception as e:
244 218 messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e))
245 219
246 220 else:
247 221 messages.warning(request, 'Your current configuration will be replaced')
248 222 form = ABSImportForm()
249 223
250 224 kwargs = {}
251 225 kwargs['form'] = form
252 226 kwargs['title'] = 'ABS Configuration'
253 227 kwargs['suptitle'] = 'Import file'
254 228 kwargs['button'] = 'Upload'
255 229 kwargs['previous'] = conf.get_absolute_url()
256 230
257 231 return render(request, 'abs_import.html', kwargs)
258 232
259 233
260 234 def send_beam(request, id_conf, id_beam):
261 235
262 236 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
263 237 beam = get_object_or_404(ABSBeam, pk=id_beam)
264 238 beams_list = ABSBeam.objects.filter(abs_conf=conf)
265 #To set this beam as an Active Beam
266 beam.set_as_activebeam()
267 #To send beam position to abs-modules
239 conf.active_beam = id_beam
240
268 241 i = 0
269 242 for b in beams_list:
270 243 if b.id == int(id_beam):
271 244 break
272 245 else:
273 246 i += 1
274 247 beam_pos = i + 1 #Estandarizar
275 248 print '%s Position: %s' % (beam.name, str(beam_pos))
276 conf.send_beam_num(beam_pos)
249 conf.send_beam(beam_pos)
277 250
278 251 return redirect('url_abs_conf', conf.id)
279 252
280 253
281 254 def add_beam(request, id_conf):
282 255
283 256 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
284 257 confs = Configuration.objects.all()
285 258
286 259 if request.method=='GET':
287 #form = ABSBeamEditForm()
288 260 form = ABSBeamAddForm()
289 261
290 262 if request.method=='POST':
291 263 form = ABSBeamAddForm(request.POST)
292 264
293 265 beam_data = get_values_from_form(request.POST)
294 266
295 267 new_beam = ABSBeam(
296 268 name =beam_data['name'],
297 269 antenna =json.dumps(beam_data['antenna']),
298 270 abs_conf=conf,
299 271 tx =json.dumps(beam_data['tx']),
300 272 rx =json.dumps(beam_data['rx']),
301 273 ues =json.dumps(beam_data['ues']),
302 274 only_rx =json.dumps(beam_data['only_rx'])
303 275 )
304 276 new_beam.save()
305 #---Update 6bits configuration and add beam to abs configuration beams list.
306 new_beam.modules_6bits()
307 #new_beam.add_beam2list()
308 277 messages.success(request, 'Beam: "%s" has been added.' % new_beam.name)
309 278
310 279 return redirect('url_edit_abs_conf', conf.id)
311 280
312 281 ###### SIDEBAR ######
313 282 kwargs = {}
314 283
315 284 #kwargs['dev_conf'] = conf.device
316 285 #kwargs['id_dev'] = conf.device
317 286 kwargs['id_conf'] = conf.id
318 287 kwargs['form'] = form
319 288 kwargs['title'] = 'ABS Beams'
320 289 kwargs['suptitle'] = 'Add Beam'
321 290 kwargs['button'] = 'Add'
322 291 kwargs['no_sidebar'] = True
323 292
324 293 #kwargs['previous'] = conf.get_absolute_url_edit()
325 294 kwargs['edit'] = True
326 295
327 296 return render(request, 'abs_add_beam.html', kwargs)
328 297
329 298
330 299 def edit_beam(request, id_conf, id_beam):
331 300
332 301 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
333 302 beam = get_object_or_404(ABSBeam, pk=id_beam)
334 303
335 304 if request.method=='GET':
336 305 form = ABSBeamEditForm(initial={'beam': beam})
337 306
338 307 if request.method=='POST':
339 308 form = ABSBeamEditForm(request.POST)
340 309
341 310 beam_data = get_values_from_form(request.POST)
342 311
343 312 beam.dict_to_parms(beam_data)
344 313 beam.save()
345 314
346 315 messages.success(request, 'Beam: "%s" has been updated.' % beam.name)
347 316
348 317 return redirect('url_edit_abs_conf', conf.id)
349 318
350 319 ###### SIDEBAR ######
351 320 kwargs = {}
352 321
353 322 kwargs['id_conf'] = conf.id
354 323 kwargs['form'] = form
355 324 kwargs['title'] = 'ABS Beams'
356 325 kwargs['suptitle'] = 'Edit Beam'
357 326 kwargs['button'] = 'Save'
358 327 kwargs['no_sidebar'] = True
359 328
360 329 #kwargs['previous'] = conf.get_absolute_url_edit()
361 330 kwargs['edit'] = True
362 331
363 332 return render(request, 'abs_edit_beam.html', kwargs)
364 333
365 334
366 335
367 336 def remove_beam(request, id_conf, id_beam):
368 337
369 338 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
370 339 beam = get_object_or_404(ABSBeam, pk=id_beam)
371 340
372 341 if request.method=='POST':
373 342 if beam:
374 343 try:
375 344 beam.remove_beamfromlist()
376 345 beam.delete()
377 346 messages.success(request, 'Beam: "%s" has been deleted.' % beam)
378 347 except:
379 348 messages.error(request, 'Unable to delete beam: "%s".' % beam)
380 349
381 350 return redirect('url_edit_abs_conf', conf.id)
382 351
383 352 ###### SIDEBAR ######
384 353 kwargs = {}
385 354
386 355 kwargs['object'] = beam
387 356 kwargs['delete'] = True
388 357 kwargs['title'] = 'Delete'
389 358 kwargs['suptitle'] = 'Beam'
390 359 kwargs['previous'] = conf.get_absolute_url_edit()
391 360 return render(request, 'confirm.html', kwargs)
392 361
393 362
394 363
395 364 def plot_patterns(request, id_conf, id_beam=None):
396 365
397 366 kwargs = {}
398 367 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
399 368 beams = ABSBeam.objects.filter(abs_conf=conf)
400 369
401 370 if id_beam:
402 371 beam = get_object_or_404(ABSBeam, pk=id_beam)
403 372 kwargs['beam'] = beam
404 373
405 374
406 375 ###### SIDEBAR ######
407 376
408 377 kwargs['dev_conf'] = conf.device
409 378 kwargs['id_dev'] = conf.device
410 379 kwargs['id_conf'] = conf.id
411 380 kwargs['abs_beams'] = beams
412 381 kwargs['title'] = 'ABS Patterns'
413 382 kwargs['suptitle'] = conf.name
414 383 kwargs['no_sidebar'] = True
415 384
416 385 return render(request, 'abs_patterns.html', kwargs)
417 386
418 387
419 388 def plot_pattern(request, id_conf, id_beam, antenna):
420 389
421 390 if antenna=='down':
422 391 sleep(3)
423 392
424 393 conf = get_object_or_404(ABSConfiguration, pk=id_conf)
425 394 beam = get_object_or_404(ABSBeam, pk=id_beam)
426 395
427 396 name = conf.experiment.name
428 397
429 398 just_rx = 1 if json.loads(beam.only_rx)[antenna] else 0
430 399 phases = json.loads(beam.antenna)['antenna_{}'.format(antenna)]
431 400 gain_tx = json.loads(beam.tx)[antenna]
432 401 gain_rx = json.loads(beam.rx)[antenna]
433 402 ues = json.loads(beam.ues)[antenna]
434 403
435 404 newOverJro = overJroShow(name)
436 405 fig = newOverJro.plotPattern2(datetime.today(), phases, gain_tx, gain_rx, ues, just_rx)
437 406
438 407 response=HttpResponse(content_type='image/png')
439 408
440 409 fig.canvas.print_png(response)
441 410
442 411 return response
General Comments 0
You need to be logged in to leave comments. Login now