##// END OF EJS Templates
revision app ABS
lgonzales -
r335:472668b9b709
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,75 +1,75
1 1 from django import forms
2 2 from .models import ABSConfiguration, ABSBeam
3 3 from .widgets import UpDataWidget, DownDataWidget, EditUpDataWidget, EditDownDataWidget
4 4 from apps.main.models import Configuration
5 5 import os
6 6
7 7 class ABSConfigurationForm(forms.ModelForm):
8 8 def __init__(self, *args, **kwargs):
9 9 super(ABSConfigurationForm, self).__init__(*args, **kwargs)
10 10
11 11 class Meta:
12 12 model = ABSConfiguration
13 exclude = ('type', 'status', 'parameters', 'active_beam',
13 exclude = ('type', 'status', 'parameters', 'active_beam',
14 14 'module_status', 'module_messages', 'module_mode',
15 15 'author', 'hash')
16 16
17 17
18 18 class ABSBeamAddForm(forms.Form):
19 19
20 20 up_data = forms.CharField(widget=UpDataWidget, label='')
21 21 down_data = forms.CharField(widget=DownDataWidget, label='')
22 22
23 23 def __init__(self, *args, **kwargs):
24 24 super(ABSBeamAddForm, self).__init__(*args, **kwargs)
25 25
26 26
27 27
28 28 class ABSBeamEditForm(forms.Form):
29 29
30 30 up_data = forms.CharField(widget=EditUpDataWidget, label='')
31 31 down_data = forms.CharField(widget=EditDownDataWidget, label='')
32 32
33 33 def __init__(self, *args, **kwargs):
34 34 super(ABSBeamEditForm, self).__init__(*args, **kwargs)
35 35
36 36 if 'initial' in kwargs:
37 37 if 'beam' in self.initial:
38 38 self.fields['up_data'].initial = self.initial['beam']
39 39 self.fields['down_data'].initial = self.initial['beam']
40 40
41 41
42 42 class ExtFileField(forms.FileField):
43 43 """
44 44 Same as forms.FileField, but you can specify a file extension whitelist.
45 45
46 46 >>> from django.core.files.uploadedfile import SimpleUploadedFile
47 47 >>>
48 48 >>> t = ExtFileField(ext_whitelist=(".pdf", ".txt"))
49 49 >>>
50 50 >>> t.clean(SimpleUploadedFile('filename.pdf', 'Some File Content'))
51 51 >>> t.clean(SimpleUploadedFile('filename.txt', 'Some File Content'))
52 52 >>>
53 53 >>> t.clean(SimpleUploadedFile('filename.exe', 'Some File Content'))
54 54 Traceback (most recent call last):
55 55 ...
56 56 ValidationError: [u'Not allowed filetype!']
57 57 """
58 58 def __init__(self, *args, **kwargs):
59 59 extensions = kwargs.pop("extensions")
60 60 self.extensions = [i.lower() for i in extensions]
61 61
62 62 super(ExtFileField, self).__init__(*args, **kwargs)
63 63
64 64 def clean(self, *args, **kwargs):
65 65 data = super(ExtFileField, self).clean(*args, **kwargs)
66 66 filename = data.name
67 67 ext = os.path.splitext(filename)[1]
68 68 ext = ext.lower()
69 69 if ext not in self.extensions:
70 70 raise forms.ValidationError('Not allowed file type: %s' % ext)
71 71
72 72
73 73 class ABSImportForm(forms.Form):
74 74
75 75 file_name = ExtFileField(extensions=['.json'])
@@ -1,878 +1,997
1 1 from django.db import models
2 2 from apps.main.models import Configuration , User
3 3 from django.urls import reverse
4 4 from celery.execute import send_task
5 5 from datetime import datetime
6 6 import ast
7 7 import socket
8 8 import json
9 9 import requests
10 10 import struct
11 11 import os, sys, time
12 12
13 13 antenna_default = json.dumps({
14 14 "antenna_up": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
15 15 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
16 16 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
17 17 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
18 18 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
19 19 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
20 20 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0],
21 21 [0.5,0.5,0.5,0.5,1.0,1.0,1.0,1.0]
22 22 ]
23 23 ,
24 24 "antenna_down": [[0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
25 25 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
26 26 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
27 27 [0.0,0.0,0.0,0.0,0.5,0.5,0.5,0.5],
28 28 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
29 29 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
30 30 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0],
31 31 [0.5,0.5,0.5,0.5,3.0,3.0,3.0,3.0]],
32 32 })
33 33
34 34
35 35 tx_default = json.dumps({
36 36 "up": [[1,1,1,1,0,0,0,0],
37 37 [1,1,1,1,0,0,0,0],
38 38 [1,1,1,1,0,0,0,0],
39 39 [1,1,1,1,0,0,0,0],
40 40 [0,0,0,0,1,1,1,1],
41 41 [0,0,0,0,1,1,1,1],
42 42 [0,0,0,0,1,1,1,1],
43 43 [0,0,0,0,1,1,1,1]],
44 44
45 45 "down": [[1,1,1,1,0,0,0,0],
46 46 [1,1,1,1,0,0,0,0],
47 47 [1,1,1,1,0,0,0,0],
48 48 [1,1,1,1,0,0,0,0],
49 49 [0,0,0,0,1,1,1,1],
50 50 [0,0,0,0,1,1,1,1],
51 51 [0,0,0,0,1,1,1,1],
52 52 [0,0,0,0,1,1,1,1]],
53 53 })
54 54
55 55 rx_default = json.dumps({
56 56 "up": [[1,1,1,1,0,0,0,0],
57 57 [1,1,1,1,0,0,0,0],
58 58 [1,1,1,1,0,0,0,0],
59 59 [1,1,1,1,0,0,0,0],
60 60 [0,0,0,0,1,1,1,1],
61 61 [0,0,0,0,1,1,1,1],
62 62 [0,0,0,0,1,1,1,1],
63 63 [0,0,0,0,1,1,1,1]],
64 64
65 65 "down": [[1,1,1,1,0,0,0,0],
66 66 [1,1,1,1,0,0,0,0],
67 67 [1,1,1,1,0,0,0,0],
68 68 [1,1,1,1,0,0,0,0],
69 69 [0,0,0,0,1,1,1,1],
70 70 [0,0,0,0,1,1,1,1],
71 71 [0,0,0,0,1,1,1,1],
72 72 [0,0,0,0,1,1,1,1]],
73 73 })
74 74
75 75 status_default = '0000000000000000000000000000000000000000000000000000000000000000'
76 76 default_messages = {}
77 77
78 78 for i in range(1,65):
79 79 default_messages[str(i)] = "Module "+str(i)
80 80
81 81
82 82 ues_default = json.dumps({
83 83 "up": [0.533333,0.00000,1.06667,0.00000],
84 84 "down": [0.533333,0.00000,1.06667,0.00000]
85 85 })
86 86
87 87 onlyrx_default = json.dumps({
88 88 "up": False,
89 89 "down": False
90 90 })
91 91
92 92 def up_convertion(cadena):
93 93 valores = []
94 94 for c in cadena:
95 95 if c == 1.0: valores=valores+['000']
96 96 if c == 2.0: valores=valores+['001']
97 97 if c == 3.0: valores=valores+['010']
98 98 if c == 0.0: valores=valores+['011']
99 99 if c == 0.5: valores=valores+['100']
100 100 if c == 1.5: valores=valores+['101']
101 101 if c == 2.5: valores=valores+['110']
102 102 if c == 3.5: valores=valores+['111']
103 103
104 104 return valores
105 105
106 106 def up_conv_bits(value):
107 107
108 108 if value == 1.0: bits="000"
109 109 if value == 2.0: bits="001"
110 110 if value == 3.0: bits="010"
111 111 if value == 0.0: bits="011"
112 112 if value == 0.5: bits="100"
113 113 if value == 1.5: bits="101"
114 114 if value == 2.5: bits="110"
115 115 if value == 3.5: bits="111"
116 116
117 117 return bits
118 118
119 119 def down_convertion(cadena):
120 120 valores = []
121 121 for c in cadena:
122 122 if c == 1.0: valores=valores+['000']
123 123 if c == 2.0: valores=valores+['001']
124 124 if c == 3.0: valores=valores+['010']
125 125 if c == 0.0: valores=valores+['011']
126 126 if c == 0.5: valores=valores+['100']
127 127 if c == 1.5: valores=valores+['101']
128 128 if c == 2.5: valores=valores+['110']
129 129 if c == 3.5: valores=valores+['111']
130 130
131 131 return valores
132 132
133 133 def down_conv_bits(value):
134 134
135 135 if value == 1.0: bits="000"
136 136 if value == 2.0: bits="001"
137 137 if value == 3.0: bits="010"
138 138 if value == 0.0: bits="011"
139 139 if value == 0.5: bits="100"
140 140 if value == 1.5: bits="101"
141 141 if value == 2.5: bits="110"
142 142 if value == 3.5: bits="111"
143 143
144 144 return bits
145 145
146 146 def up_conv_value(bits):
147 147
148 148 if bits == "000": value=1.0
149 149 if bits == "001": value=2.0
150 150 if bits == "010": value=3.0
151 151 if bits == "011": value=0.0
152 152 if bits == "100": value=0.5
153 153 if bits == "101": value=1.5
154 154 if bits == "110": value=2.5
155 155 if bits == "111": value=3.5
156 156
157 157 return value
158 158
159 159 def down_conv_value(bits):
160 160
161 161 if bits == "000": value=1.0
162 162 if bits == "001": value=2.0
163 163 if bits == "010": value=3.0
164 164 if bits == "011": value=0.0
165 165 if bits == "100": value=0.5
166 166 if bits == "101": value=1.5
167 167 if bits == "110": value=2.5
168 168 if bits == "111": value=3.5
169 169
170 170 return value
171 171
172 172 def ip2position(module_number):
173 173 j=0
174 174 i=0
175 175 for x in range(0,module_number-1):
176 176 j=j+1
177 177 if j==8:
178 178 i=i+1
179 179 j=0
180 180
181 181 pos = [i,j]
182 182 return pos
183 183
184 184
185 185 def fromBinary2Char(binary_string):
186 186 number = int(binary_string, 2)
187 187 #Plus 33 to avoid more than 1 characters values such as: '\x01'-'\x1f'
188 188 number = number + 33
189 189 char = chr(number)
190 190 return char
191 191
192 192 def fromChar2Binary(char):
193 193 number = ord(char) - 33
194 194 #Minus 33 to get the real value
195 195 bits = bin(number)[2:]
196 196 #To ensure we have a string with 6bits
197 197 if len(bits) < 6:
198 198 bits = bits.zfill(6)
199 199 return bits
200 200
201 201 OPERATION_MODES = (
202 202 (0, 'Manual'),
203 203 (1, 'Automatic'),
204 204 )
205 205
206 class ABSActive(models.Model):
207 conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration', on_delete=models.CASCADE)
206 208
207 209 class ABSConfiguration(Configuration):
208 210 active_beam = models.PositiveSmallIntegerField(verbose_name='Active Beam', default=0)
209 211 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=status_default)
210 212 operation_mode = models.PositiveSmallIntegerField(verbose_name='Operation Mode', choices=OPERATION_MODES, default = 0)
211 213 operation_value = models.FloatField(verbose_name='Periodic (seconds)', default="10", null=True, blank=True)
212 214 module_messages = models.CharField(verbose_name='Modules Messages', max_length=10000, default=json.dumps(default_messages))
213 215
214 216 class Meta:
215 217 db_table = 'abs_configurations'
216 218
217 219 def get_absolute_url_plot(self):
218 220 return reverse('url_plot_abs_patterns', args=[str(self.id)])
219 221
220 222
221 223 def parms_to_dict(self):
222 224
223 225 parameters = {}
224 226
225 227 parameters['device_id'] = self.device.id
226 228 parameters['label'] = self.label
227 229 parameters['device_type'] = self.device.device_type.name
228 230 parameters['beams'] = {}
229 231
230 232 beams = ABSBeam.objects.filter(abs_conf=self)
231 233 b=1
232 234 for beam in beams:
233 235 #absbeam = ABSBeam.objects.get(pk=beams[beam])
234 236 parameters['beams']['beam'+str(b)] = beam.parms_to_dict()#absbeam.parms_to_dict()
235 237 b+=1
236 238
237 239 return parameters
238 240
239 241
240 242 def dict_to_parms(self, parameters):
241 243
242 244 self.label = parameters['label']
243 245
244 246 absbeams = ABSBeam.objects.filter(abs_conf=self)
245 247 beams = parameters['beams']
246 248
247 249 if absbeams:
248 250 beams_number = len(beams)
249 251 absbeams_number = len(absbeams)
250 252 if beams_number==absbeams_number:
251 253 i = 1
252 254 for absbeam in absbeams:
253 255 absbeam.dict_to_parms(beams['beam'+str(i)])
254 256 i = i+1
255 257 elif beams_number > absbeams_number:
256 258 i = 1
257 259 for absbeam in absbeams:
258 260 absbeam.dict_to_parms(beams['beam'+str(i)])
259 261 i=i+1
260 262 for x in range(i,beams_number+1):
261 263 new_beam = ABSBeam(
262 264 name =beams['beam'+str(i)]['name'],
263 265 antenna =json.dumps(beams['beam'+str(i)]['antenna']),
264 266 abs_conf = self,
265 267 tx =json.dumps(beams['beam'+str(i)]['tx']),
266 268 rx =json.dumps(beams['beam'+str(i)]['rx']),
267 269 ues =json.dumps(beams['beam'+str(i)]['ues']),
268 270 only_rx =json.dumps(beams['beam'+str(i)]['only_rx'])
269 271 )
270 272 new_beam.save()
271 273 i=i+1
272 274 else: #beams_number < absbeams_number:
273 275 i = 1
274 276 for absbeam in absbeams:
275 277 if i <= beams_number:
276 278 absbeam.dict_to_parms(beams['beam'+str(i)])
277 279 i=i+1
278 280 else:
279 281 absbeam.delete()
280 282 else:
281 283 for beam in beams:
282 284 new_beam = ABSBeam(
283 285 name =beams[beam]['name'],
284 286 antenna =json.dumps(beams[beam]['antenna']),
285 287 abs_conf = self,
286 288 tx =json.dumps(beams[beam]['tx']),
287 289 rx =json.dumps(beams[beam]['rx']),
288 290 ues =json.dumps(beams[beam]['ues']),
289 291 only_rx =json.dumps(beams[beam]['only_rx'])
290 292 )
291 293 new_beam.save()
292 294
293 295
294 296
295 297 def update_from_file(self, parameters):
296 298
297 299 self.dict_to_parms(parameters)
298 300 self.save()
299 301
300 302
301 303 def get_beams(self, **kwargs):
302 304 '''
303 305 This function returns ABS Configuration beams
304 306 '''
305 307 return ABSBeam.objects.filter(abs_conf=self.pk, **kwargs)
306 308
307 309 def clone(self, **kwargs):
308 310
309 311 beams = self.get_beams()
310 312 self.pk = None
311 313 self.id = None
312 314 for attr, value in kwargs.items():
313 315 setattr(self, attr, value)
314 316 self.save()
315 317
316 318 for beam in beams:
317 319 beam.clone(abs_conf=self)
318 320
319 321 #-----For Active Beam-----
320 322 new_beams = ABSBeam.objects.filter(abs_conf=self)
321 323 self.active_beam = new_beams[0].id
322 324 self.save()
323 325 #-----For Active Beam-----
324 326 #-----For Device Status---
325 327 self.device.status = 3
326 328 self.device.save()
327 329 #-----For Device Status---
328 330
329 331 return self
330 332
331 333
332 334 def start_device(self):
333 335
334 336 if self.device.status == 3:
335 337
336 338 try:
337 339 #self.write_device()
338 340 send_task('task_change_beam', [self.id],)
339 341 self.message = 'ABS running'
340 342
341 343 except Exception as e:
342 344 self.message = str(e)
343 345 return False
344 346
345 347 return True
346 348
347 349 else:
348 350 self.message = 'Please, select Write ABS Device first.'
349 351 return False
350 352
351 353
352 354 def stop_device(self):
353 355
354 356 self.device.status = 2
355 357 self.device.save()
356 358 self.message = 'ABS has been stopped.'
357 359 self.save()
358 360
359 361 return True
360 362
361 363
362 364 def write_device(self):
363 365
364 366 """
365 367 This function sends the beams list to every abs module.
366 368 It needs 'module_conf' function
367 369 """
368
370 print("Write")
369 371 beams = ABSBeam.objects.filter(abs_conf=self)
370 372 nbeams = len(beams)
373
374 # Se manda a cero RC para poder realizar cambio de beam
375 if self.experiment is None:
376 confs = []
377 else:
378 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
379 confdds = ''
380 confjars = ''
381 confrc = ''
382 #TO STOP DEVICES: DDS-JARS-RC
383 for i in range(0,len(confs)):
384 if i==0:
385 for conf in confs:
386 if conf.device.device_type.name == 'dds':
387 confdds = conf
388 confdds.stop_device()
389 break
390 if i==1:
391 for conf in confs:
392 if conf.device.device_type.name == 'jars':
393 confjars = conf
394 confjars.stop_device()
395 break
396 if i==2:
397 for conf in confs:
398 if conf.device.device_type.name == 'rc':
399 confrc = conf
400 confrc.stop_device()
401 break
402
403 '''
371 404 if self.connected_modules() == 0 :
405 print("No encuentra modulos")
372 406 self.message = "No ABS Module detected."
373 407 return False
374
408 '''
375 409 #-------------Write each abs module-----------
376 410
377 411 if beams:
378 412 block_id = 0
379 413 message = 'SNDF{:03d}{:02d}{:02d}'.format(nbeams, nbeams, block_id)
380 414 for i, status in enumerate(self.module_status):
381 415 message += ''.join([fromBinary2Char(beam.module_6bits(i)) for beam in beams])
382 416 status = ['0'] * 64
383 417 n = 0
384
418 print("Llega una antes entrar a multicast")
385 419 sock = self.send_multicast(message)
386 420
387 for i in range(32):
421 while True:
422 #for i in range(32):
388 423 try:
389 424 data, address = sock.recvfrom(1024)
390 425 print (address, data)
426
391 427 if data == '1':
392 428 status[int(address[0][10:])-1] = '3'
393 429 elif data == '0':
394 430 status[int(address[0][10:])-1] = '1'
431 except socket.timeout:
432 print('Timeout')
433 break
395 434 except Exception as e:
396 435 print ('Error {}'.format(e))
397 436 n += 1
398 437 sock.close()
399 438 else:
400 439 self.message = "ABS Configuration does not have beams"
440 #Start DDS-RC-JARS
441 if confdds:
442 confdds.start_device()
443 if confrc:
444 #print confrc
445 confrc.start_device()
446 if confjars:
447 confjars.start_device()
401 448 return False
402 449
403 450 if n == 64:
404 451 self.message = "Could not write ABS Modules"
405 452 self.device.status = 0
406 453 self.module_status = ''.join(status)
407 454 self.save()
455 #Start DDS-RC-JARS
456 if confdds:
457 confdds.start_device()
458 if confrc:
459 #print confrc
460 confrc.start_device()
461 if confjars:
462 confjars.start_device()
408 463 return False
409 464 else:
410 465 self.message = "ABS Beams List have been sent to ABS Modules"
411 466 self.active_beam = beams[0].pk
412 467
468 #Start DDS-RC-JARS
469 if confdds:
470 confdds.start_device()
471 if confrc:
472 #print confrc
473 confrc.start_device()
474 if confjars:
475 confjars.start_device()
476
413 477 self.device.status = 3
414 478 self.module_status = ''.join(status)
415 479 self.save()
416
480 conf_active = ABSActive.objects.get(pk=1)
481 conf_active.conf = self
482 conf_active.save()
417 483 return True
418 484
419 485
420 486 def read_module(self, module):
421 487
422 488 """
423 489 Read out-bits (up-down) of 1 abs module NOT for Configuration
424 490 """
425 491
426 492 ip_address = self.device.ip_address
427 493 ip_address = ip_address.split('.')
428 494 module_seq = (ip_address[0],ip_address[1],ip_address[2])
429 495 dot = '.'
430 496 module_ip = dot.join(module_seq)+'.'+str(module)
431 497 module_port = self.device.port_address
432 498 read_route = 'http://'+module_ip+':'+str(module_port)+'/read'
433 499
434 500 module_status = json.loads(self.module_status)
435 501 print(read_route)
436 502
437 503 module_bits = ''
438 504
439 505 try:
440 506 r_read = requests.get(read_route, timeout=0.5)
441 507 answer = r_read.json()
442 508 module_bits = answer['allbits']
443 509 except:
444 510 return {}
445 511
446 512 return module_bits
447 513
448 514 def read_device(self):
449 515
450 516 parms = {}
451 517 # Reads active modules.
452 518 module_status = json.loads(self.module_status)
453 519 total = 0
454 520 for status in module_status:
455 521 if module_status[status] != 0:
456 522 module_bits = self.read_module(int(status))
457 523 bits={}
458 524 if module_bits:
459 525 bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) +
460 526 str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) )
461 527 parms[str(status)] = bits
462 528
463 529 total +=1
464 530
465 531 if total==0:
466 532 self.message = "No ABS Module detected. Please select 'Status'."
467 533 return False
468 534
469 535
470 536
471 537 self.message = "ABS Modules have been read"
472 538 #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10
473 539 return parms
474 540
475 541
476 542 def connected_modules(self):
477 543 """
478 544 This function returns the number of connected abs-modules without updating.
479 545 """
480 546 num = 0
481 547 print(self.module_status)
482 548 for i, status in enumerate(self.module_status):
483 549 if status != '0':
484 550 num += 1
485 551 #print('status {}:{}'.format(i+1, status))
486 552 return num
487 553
488 554 def send_multicast(self, message):
489
555 #print("Send multicast")
490 556 multicast_group = ('224.3.29.71', 10000)
491 557 # Create the datagram socket
492 558 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
493 559 sock.settimeout(1)
494 local_ip = os.environ.get('LOCAL_IP', '192.168.1.128')
560 local_ip = os.environ.get('LOCAL_IP', '192.168.2.128')
495 561 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
496 sock.sendto(message, multicast_group)
562 sock.sendto(message.encode(), multicast_group)
497 563 print('Sending ' + message)
498 564 return sock
499 565
500 566 def status_device(self):
501 567 """
502 568 This function returns the status of all abs-modules as one.
503 569 If at least one module is connected, its answer is "1"
504 570 """
505
571 print ('Status device')
572 print (self.active_beam)
573 beams = ABSBeam.objects.filter(abs_conf=self)
574 #print beams[self.active_beam-1].module_6bits(0)
575 active = ABSActive.objects.get(pk=1)
576 if active.conf != self:
577 self.message = 'La configuracion actual es la del siguiente enlace %s.' % active.conf.get_absolute_url()
578 self.message += "\n"
579 self.message += 'Se debe realizar un write en esta configuracion para luego obtener un status valido.'
580
581 return False
582
506 583 sock = self.send_multicast('MNTR')
507
584
508 585 n = 0
509 586 status = ['0'] * 64
510 for i in range(32):
587
588 while True:
589 #for i in range(32):
511 590 #if True:
512 591 try:
592 print("Recibiendo")
513 593 address = None
514 data, address = sock.recvfrom(1024)
515 x = int(address[0][10:])-1
594 data, address = sock.recvfrom(2)
595 print (address, data)
596 print("!!!!")
597 data = data.decode()
598 aux_mon = "1"
599 aux_expected = aux_mon
600 if(len(data)==2):
601 print ("data[1]: ")
602 print (data[1])
603 aux_mon = fromChar2Binary(data[1])
604 print (aux_mon)
605 aux_i = (str(address[0]).split('.'))[3]
606 print (aux_i)
607 print ('Active beam')
608 beam_active = ABSBeam.objects.get(pk=self.active_beam)
609 print (beam_active)
610 aux_expected = beam_active.module_6bits(int(aux_i)-1)
611 print (aux_expected)
612
613 print ("data[0]: ")
614 print (data[0])
615
516 616 if data[0] == '1':
517 remote = fromChar2Binary(data[1])
518 local = ABSBeam.objects.get(pk=self.active_beam).module_6bits(x)
519 if local == remote:
520 status[x] = '3'
521 print('Module: {} connected...igual'.format(address))
617 status[int(address[0][10:])-1] = '3'
618 if aux_mon == aux_expected:
619 print ('Es igual')
522 620 else:
523 status[x] = '2'
524 print('Module: {} connected...diferente'.format(address))
621 print ('Es diferente')
622 status[int(address[0][10:])-1] = '2'
623
525 624 elif data[0] == '0':
526 status[x] = '1'
625 status[int(address[0][10:])-1] = '1'
527 626 n += 1
627 print('Module: {} connected'.format(address))
628 except socket.timeout:
629 print('Timeout')
630 break
528 631 except:
529 632 print('Module: {} error'.format(address))
530 633 pass
634
531 635 sock.close()
532
636
533 637 if n > 0:
534 638 self.message = 'ABS modules Status have been updated.'
535 639 self.device.status = 1
536 640 else:
537 641 self.device.status = 0
538 642 self.message = 'No ABS module is connected.'
539 643 self.module_status = ''.join(status)
540 644 self.save()
541 645
542 646 return self.device.status
543 647
544 648
545 649 def send_beam(self, beam_pos):
546 650 """
547 651 This function connects to a multicast group and sends the beam number
548 652 to all abs modules.
549 653 """
654 print ('Send beam')
655 print (self.active_beam)
656 beams = ABSBeam.objects.filter(abs_conf=self)
657 #print beams[self.active_beam-1].module_6bits(0)
658 active = ABSActive.objects.get(pk=1)
659 if active.conf != self:
660 self.message = 'La configuracion actual es la del siguiente enlace %s.' % active.conf.get_absolute_url()
661 self.message += "\n"
662 self.message += 'Se debe realizar un write en esta configuracion para luego obtener un status valido.'
663
664 return False
550 665
551 666 # Se manda a cero RC para poder realizar cambio de beam
552 667 if self.experiment is None:
553 668 confs = []
554 669 else:
555 670 confs = Configuration.objects.filter(experiment = self.experiment).filter(type=0)
556 671 confdds = ''
557 672 confjars = ''
558 673 confrc = ''
559 674 #TO STOP DEVICES: DDS-JARS-RC
560 675 for i in range(0,len(confs)):
561 676 if i==0:
562 677 for conf in confs:
563 678 if conf.device.device_type.name == 'dds':
564 679 confdds = conf
565 680 confdds.stop_device()
566 681 break
567 682 if i==1:
568 683 for conf in confs:
569 684 if conf.device.device_type.name == 'jars':
570 685 confjars = conf
571 686 confjars.stop_device()
572 687 break
573 688 if i==2:
574 689 for conf in confs:
575 690 if conf.device.device_type.name == 'rc':
576 691 confrc = conf
577 692 confrc.stop_device()
578 693 break
579 694 if beam_pos > 0:
580 695 beam_pos = beam_pos - 1
581 696 else:
582 697 beam_pos = 0
583 698
584 699 #El indice del apunte debe ser menor que el numero total de apuntes
585 700 #El servidor tcp en el embebido comienza a contar desde 0
586 701 status = ['0'] * 64
587 message = 'CHGB{}'.format(beam_pos)
702 message = 'CHGB{}'.format(beam_pos)
588 703 sock = self.send_multicast(message)
589 for i in range(32):
704 while True:
705 #for i in range(32):
590 706 try:
591 707 data, address = sock.recvfrom(1024)
592 708 print (address, data)
709 data = data.decode()
593 710 if data == '1':
594 711 status[int(address[0][10:])-1] = '3'
595 712 elif data == '0':
596 713 status[int(address[0][10:])-1] = '1'
714 except socket.timeout:
715 print('Timeout')
716 break
597 717 except Exception as e:
598 718 print ('Error {}'.format(e))
599 719 pass
600 720
601 721 sock.close()
602 722
603 723 #Start DDS-RC-JARS
604 724 if confdds:
605 725 confdds.start_device()
606 726 if confrc:
607 727 #print confrc
608 728 confrc.start_device()
609 729 if confjars:
610 730 confjars.start_device()
611 731
612 732 self.message = "ABS Beam has been changed"
613 733 self.module_status = ''.join(status)
614 734 self.save()
615 735 return True
616 736
617 737
618 738 def get_absolute_url_import(self):
619 739 return reverse('url_import_abs_conf', args=[str(self.id)])
620 740
621
622 741 class ABSBeam(models.Model):
623 742
624 743 name = models.CharField(max_length=60, default='Beam')
625 744 antenna = models.CharField(verbose_name='Antenna', max_length=1000, default=antenna_default)
626 abs_conf = models.ForeignKey('ABSConfiguration', null=True,
745 abs_conf = models.ForeignKey('ABSConfiguration', null=True,
627 746 verbose_name='ABS Configuration', on_delete=models.CASCADE)
628 747 tx = models.CharField(verbose_name='Tx', max_length=1000, default=tx_default)
629 748 rx = models.CharField(verbose_name='Rx', max_length=1000, default=rx_default)
630 749 s_time = models.TimeField(verbose_name='Star Time', default='00:00:00')
631 750 e_time = models.TimeField(verbose_name='End Time', default='23:59:59')
632 751 ues = models.CharField(verbose_name='Ues', max_length=100, default=ues_default)
633 752 only_rx = models.CharField(verbose_name='Only RX', max_length=40, default=onlyrx_default)
634 753
635 754 class Meta:
636 755 db_table = 'abs_beams'
637 756
638 757 def __unicode__(self):
639 758 return u'%s' % (self.name)
640 759
641 760 def parms_to_dict(self):
642 761
643 762 parameters = {}
644 763 parameters['name'] = self.name
645 764 parameters['antenna'] = ast.literal_eval(self.antenna)
646 765 parameters['abs_conf'] = self.abs_conf.name
647 766 parameters['tx'] = ast.literal_eval(self.tx)
648 767 parameters['rx'] = ast.literal_eval(self.rx)
649 768 parameters['s_time'] = self.s_time.strftime("%H:%M:%S")
650 769 parameters['e_time'] = self.e_time.strftime("%H:%M:%S")
651 770 parameters['ues'] = ast.literal_eval(self.ues)
652 771 parameters['only_rx'] = json.loads(self.only_rx)
653 772
654 773 return parameters
655 774
656 775 def dict_to_parms(self, parameters):
657 776
658 777 self.name = parameters['name']
659 778 self.antenna = json.dumps(parameters['antenna'])
660 779 #self.abs_conf = parameters['abs_conf']
661 780 self.tx = json.dumps(parameters['tx'])
662 781 self.rx = json.dumps(parameters['rx'])
663 782 #self.s_time = parameters['s_time']
664 783 #self.e_time = parameters['e_time']
665 784 self.ues = json.dumps(parameters['ues'])
666 785 self.only_rx = json.dumps(parameters['only_rx'])
667 786 self.save()
668 787
669 788
670 789 def clone(self, **kwargs):
671 790
672 791 self.pk = None
673 792 self.id = None
674 793 for attr, value in kwargs.items():
675 794 setattr(self, attr, value)
676 795
677 796 self.save()
678 797
679 798 return self
680 799
681 800
682 801 def module_6bits(self, module):
683 802 """
684 803 This function reads antenna pattern and choose 6bits (upbits-downbits) for one abs module
685 804 """
686 805 module += 1
687 806 if module > 64:
688 807 beam_bits = ""
689 808 return beam_bits
690 809
691 810 data = ast.literal_eval(self.antenna)
692 811 up_data = data['antenna_up']
693 812 down_data = data['antenna_down']
694 813
695 814 pos = ip2position(module)
696 815 up_value = up_data[pos[0]][pos[1]]
697 816 down_value = down_data[pos[0]][pos[1]]
698 817
699 818 up_bits = up_conv_bits(up_value)
700 819 down_bits = down_conv_bits(down_value)
701 820 beam_bits = up_bits+down_bits
702 821
703 822 return beam_bits
704 823
705 824
706 825 @property
707 826 def get_upvalues(self):
708 827 """
709 828 This function reads antenna pattern and show the up-value of one abs module
710 829 """
711 830
712 831 data = ast.literal_eval(self.antenna)
713 832 up_data = data['antenna_up']
714 833
715 834 up_values = []
716 835 for data in up_data:
717 836 for i in range(0,8):
718 837 up_values.append(data[i])
719 838
720 839 return up_values
721 840
722 841 @property
723 842 def antenna_upvalues(self):
724 843 """
725 844 This function reads antenna pattern and show the up - values of one abs beam
726 845 in a particular order
727 846 """
728 847 data = ast.literal_eval(self.antenna)
729 848 up_data = data['antenna_up']
730 849
731 850 return up_data
732 851
733 852 @property
734 853 def antenna_downvalues(self):
735 854 """
736 855 This function reads antenna pattern and show the down - values of one abs beam
737 856 in a particular order
738 857 """
739 858 data = ast.literal_eval(self.antenna)
740 859 down_data = data['antenna_down']
741 860
742 861 return down_data
743 862
744 863 @property
745 864 def get_downvalues(self):
746 865 """
747 866 This function reads antenna pattern and show the down-value of one abs module
748 867 """
749 868
750 869 data = ast.literal_eval(self.antenna)
751 870 down_data = data['antenna_down']
752 871
753 872 down_values = []
754 873 for data in down_data:
755 874 for i in range(0,8):
756 875 down_values.append(data[i])
757 876
758 877 return down_values
759 878
760 879 @property
761 880 def get_up_ues(self):
762 881 """
763 882 This function shows the up-ues-value of one beam
764 883 """
765 884 data = ast.literal_eval(self.ues)
766 885 up_ues = data['up']
767 886
768 887 return up_ues
769 888
770 889 @property
771 890 def get_down_ues(self):
772 891 """
773 892 This function shows the down-ues-value of one beam
774 893 """
775 894 data = ast.literal_eval(self.ues)
776 895 down_ues = data['down']
777 896
778 897 return down_ues
779 898
780 899 @property
781 900 def get_up_onlyrx(self):
782 901 """
783 902 This function shows the up-onlyrx-value of one beam
784 903 """
785 904 data = json.loads(self.only_rx)
786 905 up_onlyrx = data['up']
787 906
788 907 return up_onlyrx
789 908
790 909 @property
791 910 def get_down_onlyrx(self):
792 911 """
793 912 This function shows the down-onlyrx-value of one beam
794 913 """
795 914 data = json.loads(self.only_rx)
796 915 down_onlyrx = data['down']
797 916
798 917 return down_onlyrx
799 918
800 919 @property
801 920 def get_tx(self):
802 921 """
803 922 This function shows the tx-values of one beam
804 923 """
805 924 data = json.loads(self.tx)
806 925
807 926 return data
808 927
809 928 @property
810 929 def get_uptx(self):
811 930 """
812 931 This function shows the up-tx-values of one beam
813 932 """
814 933 data = json.loads(self.tx)
815 934 up_data = data['up']
816 935
817 936 up_values = []
818 937 for data in up_data:
819 938 for i in range(0,8):
820 939 up_values.append(data[i])
821 940
822 941 return up_values
823 942
824 943 @property
825 944 def get_downtx(self):
826 945 """
827 946 This function shows the down-tx-values of one beam
828 947 """
829 948 data = json.loads(self.tx)
830 949 down_data = data['down']
831 950
832 951 down_values = []
833 952 for data in down_data:
834 953 for i in range(0,8):
835 954 down_values.append(data[i])
836 955
837 956 return down_values
838 957
839 958
840 959
841 960 @property
842 961 def get_rx(self):
843 962 """
844 963 This function shows the rx-values of one beam
845 964 """
846 965 data = json.loads(self.rx)
847 966
848 967 return data
849 968
850 969 @property
851 970 def get_uprx(self):
852 971 """
853 972 This function shows the up-rx-values of one beam
854 973 """
855 974 data = json.loads(self.rx)
856 975 up_data = data['up']
857 976
858 977 up_values = []
859 978 for data in up_data:
860 979 for i in range(0,8):
861 980 up_values.append(data[i])
862 981
863 982 return up_values
864 983
865 984 @property
866 985 def get_downrx(self):
867 986 """
868 987 This function shows the down-rx-values of one beam
869 988 """
870 989 data = json.loads(self.rx)
871 990 down_data = data['down']
872 991
873 992 down_values = []
874 993 for data in down_data:
875 994 for i in range(0,8):
876 995 down_values.append(data[i])
877 996
878 997 return down_values
@@ -1,19 +1,21
1 1 {% extends "dev_conf_edit.html" %}
2 2
3 3 {% load bootstrap4 %}
4 4 {% load static %}
5 5 {% load main_tags %}
6 6
7
8
7 9 {% block content %}
8 10 <form class="form" method="post">
9 11 {% csrf_token %}
10 12 {#% bootstrap_form form layout='horizontal' size='medium' %#}
11 13 {{form}}
12 14 <div style="clear: both;"></div>
13 15 <br>
14 16 <div class="pull-right">
15 17 <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button>
16 18 <button type="submit" class="btn btn-primary">{{button}}</button>
17 19 </div>
18 20 </form>
19 21 {% endblock %}
@@ -1,42 +1,42
1 1 {% load bootstrap4 %}
2 2
3 3 {% if abs_beams %}
4 4
5 5 <div class="pull-right">
6 6 <button id="bt_toggle" type="button" class="btn btn-default btn-sm" >
7 7 Expand/Collapse
8 8 </button>
9 9 </div><br><br>
10 10
11 11
12 12 {% for beam in abs_beams %}
13 13 <div class="panel panel-default" id="panel-{{beam.id}}">
14 14 <div class="panel-heading" role="tab" id="heading{{beam.id}}">
15 15 <h4 class="panel-title">
16 16 <a role="button" onclick="beam_values(beam.id)" data-toggle="collapse" data-parent="#div_lines" href="#collapse{{beam.id}}" aria-expanded="true" aria-controls="collapse{{beam.id}}">
17 17 #{{forloop.counter}}: {{beam.name}}
18 18 </a>
19 19 {% if edit %}
20 20 <button id="bt_remove_beam-{{ beam.id }}" type="button" class="btn-xs btn-default pull-right" name="bt_remove_beam" value="{{beam.pk}}"><span class="far fa-trash-alt" aria-hidden="true"></span></button>
21 <button id="bt_edit_beam-{{ beam.id }}" type="button" class="btn-xs btn-default pull-right" name="bt_edit_beam" value="{{beam.pk}}"><span class="fas fa-pencil" aria-hidden="true"></span></button>
21 <button id="bt_edit_beam-{{ beam.id }}" type="button" class="btn-xs btn-default pull-right" name="bt_edit_beam" value="{{beam.pk}}"><span class="fa fa-pencil" aria-hidden="true"></span></button>
22 22 {% endif %}
23 23 </h4>
24 24 </div>
25 25 <div id="collapse{{beam.id}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{beam.id}}">
26 26 <div class="panel-body">
27 27 {% include "abs_beam_values.html" %}
28 28 {# bootstrap_form beam.form layout='horizontal' size='small' #}
29 29 <br>
30 30
31 31 <br>
32 32 <!--<button type="button" class="btn btn-sm btn-default" style="margin-left: 10px" name="bt_add_subline" value="{{line.pk}}">Add {{line.line_type.name}}</button>-->
33 33 {# endif #}
34 34
35 35 </div>
36 36 </div>
37 37 </div>
38 38 {% endfor%}
39 39
40 40 {% else %}
41 41 <p style="color:#b4bcc2; margin-left: 5%;"><i>No Beams...</i></p>
42 42 {% endif %}
@@ -1,336 +1,339
1 1 {% extends "dev_conf.html" %} {% load static %} {% load bootstrap4 %} {% load main_tags %}
2 2 {% block extra-head %}
3 3 <style>
4 4 .abs {
5 5 width: auto;
6 6 display: inline-block;
7 7 text-align: center;
8 8 }
9 9
10 10 .abs td {
11 11 padding: 4px;
12 12 }
13 13
14 14 .module td {
15 15 padding: 4px 15px 4px 15px;
16 16 font-weight: bold;
17 17 border: 1px solid
18 18 }
19 19
20 20 .legend {
21 21 margin-left: 15px;
22 22 display: inline-block;
23 23 border: 2px solid;
24 24 vertical-align: top;
25 25 }
26 26
27 27 .legend th {
28 28 border-bottom: 1px dashed;
29 29 font-weight: bold;
30 30 vertical-align: center;
31 31 text-align: center;
32 32 }
33 33
34 34 .legend td {
35 35 padding: 2px;
36 36 text-align: center;
37 37 font-weight: bold;
38 38 }
39 39
40 40 </style>
41 41 {% endblock %}
42 42 {% block extra-menu-actions %}
43 43 <li>
44 44 <a href="{{ dev_conf.get_absolute_url_plot }}" target="_blank">
45 45 <span class="far fa-image" aria-hidden="true"></span> View Patterns </a>
46 46 </li>
47 47 {% endblock %}
48 48 {% block extra-content %}
49 49 {% if beams %}
50 50 <h4>Beams:</h4>
51 51 <div class="container">
52 52 <ul class="nav nav-pills">
53 53 {% for beam in beams %}
54 <li {%if beam.pk == active_beam %} class="active" {% endif %}>
55 <a data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
54 <li class="nav-item">
55 <a {%if beam.pk == active_beam %} class="nav-link active" {% else %} class="nav-link" {% endif %} data-toggle="pill" href="#menu{{forloop.counter}}">{{forloop.counter}}</a>
56 56 </li>
57 57 {% endfor %}
58 58 </ul>
59 59
60 60 <div class="tab-content">
61 61 {% for beam in beams %}
62 <div id="menu{{forloop.counter}}" class="tab-pane fade {%if beam.pk == active_beam %}active in{% endif %}">
62 <div id="menu{{forloop.counter}}" class="tab-pane fade {%if beam.pk == active_beam %}in active show{% endif %}">
63 63 <h3>{%if beam.pk == active_beam %}Active Beam: {%endif%}{{beam.name}}</h3>
64 64 <table id="abs_pattern{{forloop.counter}}" class="abs">
65 65 <tr>
66 66 <td>
67 67 <b>North Quarter</b>
68 68 <table class="module">
69 69 <tr>
70 70 <td title='{{module_messages.1}}'><span {%if beam.pk == active_beam %} {{color_status.1}} {%endif%}>{{beam.get_upvalues.0}}</span></td>
71 71 <td title='{{module_messages.2}}'><span {%if beam.pk == active_beam %} {{color_status.2}} {%endif%}>{{beam.get_upvalues.1}}</span></td>
72 72 <td title='{{module_messages.3}}'><span {%if beam.pk == active_beam %} {{color_status.3}} {%endif%}>{{beam.get_upvalues.2}}</span></td>
73 73 <td title='{{module_messages.4}}'><span {%if beam.pk == active_beam %} {{color_status.4}} {%endif%}>{{beam.get_upvalues.3}}</span></td>
74 74 </tr>
75 75 <tr>
76 76 <td title='{{module_messages.1}}'><span {%if beam.pk == active_beam %} {{color_status.1}} {%endif%}>{{beam.get_downvalues.0}}</span></td>
77 77 <td title='{{module_messages.2}}'><span {%if beam.pk == active_beam %} {{color_status.2}} {%endif%}>{{beam.get_downvalues.1}}</span></td>
78 78 <td title='{{module_messages.3}}'> <span {%if beam.pk == active_beam %} {{color_status.3}} {%endif%}>{{beam.get_downvalues.2}}</span></td>
79 79 <td title='{{module_messages.4}}'> <span {%if beam.pk == active_beam %} {{color_status.4}} {%endif%}>{{beam.get_downvalues.3}}</span></td>
80 80 </tr>
81 81 <tr>
82 82 <td title='{{module_messages.9}}'> <span {%if beam.pk == active_beam %} {{color_status.9}} {%endif%}>{{beam.get_upvalues.8}}</span></td>
83 83 <td title='{{module_messages.10}}'><span {%if beam.pk == active_beam %} {{color_status.10}} {%endif%}>{{beam.get_upvalues.9}}</span></td>
84 84 <td title='{{module_messages.11}}'><span {%if beam.pk == active_beam %} {{color_status.11}} {%endif%}>{{beam.get_upvalues.10}}</span></td>
85 85 <td title='{{module_messages.12}}'><span {%if beam.pk == active_beam %} {{color_status.12}} {%endif%}>{{beam.get_upvalues.11}}</span></td>
86 86 </tr>
87 87 <tr>
88 88 <td title='{{module_messages.9}}'> <span {%if beam.pk == active_beam %} {{color_status.9}} {%endif%}>{{beam.get_downvalues.8}}</span></td>
89 89 <td title='{{module_messages.10}}'><span {%if beam.pk == active_beam %} {{color_status.10}} {%endif%}>{{beam.get_downvalues.9}}</span></td>
90 90 <td title='{{module_messages.11}}'><span {%if beam.pk == active_beam %} {{color_status.11}} {%endif%}>{{beam.get_downvalues.10}}</span></td>
91 91 <td title='{{module_messages.12}}'><span {%if beam.pk == active_beam %} {{color_status.12}} {%endif%}>{{beam.get_downvalues.11}}</span></td>
92 92 </tr>
93 93 <tr>
94 94 <td title='{{module_messages.17}}'><span {%if beam.pk == active_beam %} {{color_status.17}} {%endif%}>{{beam.get_upvalues.16}}</span></td>
95 95 <td title='{{module_messages.18}}'><span {%if beam.pk == active_beam %} {{color_status.18}} {%endif%}>{{beam.get_upvalues.17}}</span></td>
96 96 <td title='{{module_messages.19}}'><span {%if beam.pk == active_beam %} {{color_status.19}} {%endif%}>{{beam.get_upvalues.18}}</span></td>
97 97 <td title='{{module_messages.20}}'><span {%if beam.pk == active_beam %} {{color_status.20}} {%endif%}>{{beam.get_upvalues.19}}</span></td>
98 98 </tr>
99 99 <tr>
100 100 <td title='{{module_messages.17}}'><span {%if beam.pk == active_beam %} {{color_status.17}} {%endif%}>{{beam.get_downvalues.16}}</span></td>
101 101 <td title='{{module_messages.18}}'><span {%if beam.pk == active_beam %} {{color_status.18}} {%endif%}>{{beam.get_downvalues.17}}</span></td>
102 102 <td title='{{module_messages.19}}'><span {%if beam.pk == active_beam %} {{color_status.19}} {%endif%}>{{beam.get_downvalues.18}}</span></td>
103 103 <td title='{{module_messages.20}}'><span {%if beam.pk == active_beam %} {{color_status.20}} {%endif%}>{{beam.get_downvalues.19}}</span></td>
104 104 </tr>
105 105 <tr>
106 106 <td title='{{module_messages.25}}'><span {%if beam.pk == active_beam %} {{color_status.25}} {%endif%}>{{beam.get_upvalues.24}}</span></td>
107 107 <td title='{{module_messages.26}}'><span {%if beam.pk == active_beam %} {{color_status.26}} {%endif%}>{{beam.get_upvalues.25}}</span></td>
108 108 <td title='{{module_messages.27}}'><span {%if beam.pk == active_beam %} {{color_status.27}} {%endif%}>{{beam.get_upvalues.26}}</span></td>
109 109 <td title='{{module_messages.28}}'><span {%if beam.pk == active_beam %} {{color_status.28}} {%endif%}>{{beam.get_upvalues.27}}</span></td>
110 110 </tr>
111 111 <tr>
112 112 <td title='{{module_messages.25}}'><span {%if beam.pk == active_beam %} {{color_status.25}} {%endif%}>{{beam.get_downvalues.24}}</span></td>
113 113 <td title='{{module_messages.26}}'><span {%if beam.pk == active_beam %} {{color_status.26}} {%endif%}>{{beam.get_downvalues.25}}</span></td>
114 114 <td title='{{module_messages.27}}'><span {%if beam.pk == active_beam %} {{color_status.27}} {%endif%}>{{beam.get_downvalues.26}}</span></td>
115 115 <td title='{{module_messages.28}}'><span {%if beam.pk == active_beam %} {{color_status.28}} {%endif%}>{{beam.get_downvalues.27}}</span></td>
116 116 </tr>
117 117 </table>
118 118 </td>
119 119 <td>
120 120 <b>East Quarter</b>
121 121 <table class="module">
122 122 <tr>
123 123 <td title='{{module_messages.5}}'> <span {%if beam.pk == active_beam %} {{color_status.5}} {%endif%}>{{beam.get_upvalues.4}}</span></td>
124 124 <td title='{{module_messages.6}}'> <span {%if beam.pk == active_beam %} {{color_status.6}} {%endif%}>{{beam.get_upvalues.5}}</span></td>
125 125 <td title='{{module_messages.7}}'> <span {%if beam.pk == active_beam %} {{color_status.7}} {%endif%}>{{beam.get_upvalues.6}}</span></td>
126 126 <td title='{{module_messages.8}}'> <span {%if beam.pk == active_beam %} {{color_status.8}} {%endif%}>{{beam.get_upvalues.7}}</span></td>
127 127 </tr>
128 128 <tr>
129 129 <td title='{{module_messages.5}}'> <span {%if beam.pk == active_beam %} {{color_status.5}} {%endif%}>{{beam.get_downvalues.4}}</span></td>
130 130 <td title='{{module_messages.6}}'> <span {%if beam.pk == active_beam %} {{color_status.6}} {%endif%}>{{beam.get_downvalues.5}}</span></td>
131 131 <td title='{{module_messages.7}}'> <span {%if beam.pk == active_beam %} {{color_status.7}} {%endif%}>{{beam.get_downvalues.6}}</span></td>
132 132 <td title='{{module_messages.8}}'> <span {%if beam.pk == active_beam %} {{color_status.8}} {%endif%}>{{beam.get_downvalues.7}}</span></td>
133 133 </tr>
134 134 <tr>
135 135 <td title='{{module_messages.13}}'><span {%if beam.pk == active_beam %} {{color_status.13}} {%endif%}>{{beam.get_upvalues.12}}</span></td>
136 136 <td title='{{module_messages.14}}'><span {%if beam.pk == active_beam %} {{color_status.14}} {%endif%}>{{beam.get_upvalues.13}}</span></td>
137 137 <td title='{{module_messages.15}}'><span {%if beam.pk == active_beam %} {{color_status.15}} {%endif%}>{{beam.get_upvalues.14}}</span></td>
138 138 <td title='{{module_messages.16}}'><span {%if beam.pk == active_beam %} {{color_status.16}} {%endif%}>{{beam.get_upvalues.15}}</span></td>
139 139 </tr>
140 140 <tr>
141 141 <td title='{{module_messages.13}}'><span {%if beam.pk == active_beam %} {{color_status.13}} {%endif%}>{{beam.get_downvalues.12}}</span></td>
142 142 <td title='{{module_messages.14}}'><span {%if beam.pk == active_beam %} {{color_status.14}} {%endif%}>{{beam.get_downvalues.13}}</span></td>
143 143 <td title='{{module_messages.15}}'><span {%if beam.pk == active_beam %} {{color_status.15}} {%endif%}>{{beam.get_downvalues.14}}</span></td>
144 144 <td title='{{module_messages.16}}'><span {%if beam.pk == active_beam %} {{color_status.16}} {%endif%}>{{beam.get_downvalues.15}}</span></td>
145 145 </tr>
146 146 <tr>
147 147 <td title='{{module_messages.21}}'><span {%if beam.pk == active_beam %} {{color_status.21}} {%endif%}>{{beam.get_upvalues.20}}</span></td>
148 148 <td title='{{module_messages.22}}'><span {%if beam.pk == active_beam %} {{color_status.22}} {%endif%}>{{beam.get_upvalues.21}}</span></td>
149 149 <td title='{{module_messages.23}}'><span {%if beam.pk == active_beam %} {{color_status.23}} {%endif%}>{{beam.get_upvalues.22}}</span></td>
150 150 <td title='{{module_messages.24}}'><span {%if beam.pk == active_beam %} {{color_status.24}} {%endif%}>{{beam.get_upvalues.23}}</span></td>
151 151 </tr>
152 152 <tr>
153 153 <td title='{{module_messages.21}}'><span {%if beam.pk == active_beam %} {{color_status.21}} {%endif%}>{{beam.get_downvalues.20}}</span></td>
154 154 <td title='{{module_messages.22}}'><span {%if beam.pk == active_beam %} {{color_status.22}} {%endif%}>{{beam.get_downvalues.21}}</span></td>
155 155 <td title='{{module_messages.23}}'><span {%if beam.pk == active_beam %} {{color_status.23}} {%endif%}>{{beam.get_downvalues.22}}</span></td>
156 156 <td title='{{module_messages.24}}'><span {%if beam.pk == active_beam %} {{color_status.24}} {%endif%}>{{beam.get_downvalues.23}}</span></td>
157 157 </tr>
158 158 <tr>
159 159 <td title='{{module_messages.29}}'><span {%if beam.pk == active_beam %} {{color_status.29}} {%endif%}>{{beam.get_upvalues.28}}</span></td>
160 160 <td title='{{module_messages.30}}'><span {%if beam.pk == active_beam %} {{color_status.30}} {%endif%}>{{beam.get_upvalues.29}}</span></td>
161 161 <td title='{{module_messages.31}}'><span {%if beam.pk == active_beam %} {{color_status.31}} {%endif%}>{{beam.get_upvalues.30}}</span></td>
162 162 <td title='{{module_messages.32}}'><span {%if beam.pk == active_beam %} {{color_status.32}} {%endif%}>{{beam.get_upvalues.31}}</span></td>
163 163 </tr>
164 164 <tr>
165 165 <td title='{{module_messages.29}}'><span {%if beam.pk == active_beam %} {{color_status.29}} {%endif%}>{{beam.get_downvalues.28}}</span></td>
166 166 <td title='{{module_messages.30}}'><span {%if beam.pk == active_beam %} {{color_status.30}} {%endif%}>{{beam.get_downvalues.29}}</span></td>
167 167 <td title='{{module_messages.31}}'><span {%if beam.pk == active_beam %} {{color_status.31}} {%endif%}>{{beam.get_downvalues.30}}</span></td>
168 168 <td title='{{module_messages.32}}'><span {%if beam.pk == active_beam %} {{color_status.32}} {%endif%}>{{beam.get_downvalues.31}}</span></td>
169 169 </tr>
170 170 </table>
171 171 </td>
172 172 </tr>
173 173 <tr>
174 174 <td>
175 175 <b>West Quarter</b>
176 176 <table class="module">
177 177 <tr>
178 178 <td title='{{module_messages.33}}'><span {%if beam.pk == active_beam %} {{color_status.33}} {%endif%}>{{beam.get_upvalues.32}}</span></td>
179 179 <td title='{{module_messages.34}}'><span {%if beam.pk == active_beam %} {{color_status.34}} {%endif%}>{{beam.get_upvalues.33}}</span></td>
180 180 <td title='{{module_messages.35}}'><span {%if beam.pk == active_beam %} {{color_status.35}} {%endif%}>{{beam.get_upvalues.34}}</span></td>
181 181 <td title='{{module_messages.36}}'><span {%if beam.pk == active_beam %} {{color_status.36}} {%endif%}>{{beam.get_upvalues.35}}</span></td>
182 182 </tr>
183 183 <tr>
184 184 <td title='{{module_messages.33}}'><span {%if beam.pk == active_beam %} {{color_status.33}} {%endif%}>{{beam.get_downvalues.32}}</span></td>
185 185 <td title='{{module_messages.34}}'><span {%if beam.pk == active_beam %} {{color_status.34}} {%endif%}>{{beam.get_downvalues.33}}</span></td>
186 186 <td title='{{module_messages.35}}'><span {%if beam.pk == active_beam %} {{color_status.35}} {%endif%}>{{beam.get_downvalues.34}}</span></td>
187 187 <td title='{{module_messages.36}}'><span {%if beam.pk == active_beam %} {{color_status.36}} {%endif%}>{{beam.get_downvalues.35}}</span></td>
188 188 </tr>
189 189 <tr>
190 190 <td title='{{module_messages.41}}'><span {%if beam.pk == active_beam %} {{color_status.41}} {%endif%}>{{beam.get_upvalues.40}}</span></td>
191 191 <td title='{{module_messages.42}}'><span {%if beam.pk == active_beam %} {{color_status.42}} {%endif%}>{{beam.get_upvalues.41}}</span></td>
192 192 <td title='{{module_messages.43}}'><span {%if beam.pk == active_beam %} {{color_status.43}} {%endif%}>{{beam.get_upvalues.42}}</span></td>
193 193 <td title='{{module_messages.44}}'><span {%if beam.pk == active_beam %} {{color_status.44}} {%endif%}>{{beam.get_upvalues.43}}</span></td>
194 194 </tr>
195 195 <tr>
196 196 <td title='{{module_messages.41}}'><span {%if beam.pk == active_beam %} {{color_status.41}} {%endif%}>{{beam.get_downvalues.40}}</span></td>
197 197 <td title='{{module_messages.42}}'><span {%if beam.pk == active_beam %} {{color_status.42}} {%endif%}>{{beam.get_downvalues.41}}</span></td>
198 198 <td title='{{module_messages.43}}'><span {%if beam.pk == active_beam %} {{color_status.43}} {%endif%}>{{beam.get_downvalues.42}}</span></td>
199 199 <td title='{{module_messages.44}}'><span {%if beam.pk == active_beam %} {{color_status.44}} {%endif%}>{{beam.get_downvalues.43}}</span></td>
200 200 </tr>
201 201 <tr>
202 202 <td title='{{module_messages.49}}'><span {%if beam.pk == active_beam %} {{color_status.49}} {%endif%}>{{beam.get_upvalues.48}}</span></td>
203 203 <td title='{{module_messages.51}}'><span {%if beam.pk == active_beam %} {{color_status.50}} {%endif%}>{{beam.get_upvalues.49}}</span></td>
204 204 <td title='{{module_messages.52}}'><span {%if beam.pk == active_beam %} {{color_status.51}} {%endif%}>{{beam.get_upvalues.50}}</span></td>
205 205 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.52}} {%endif%}>{{beam.get_upvalues.51}}</span></td>
206 206 </tr>
207 207 <tr>
208 208 <td title='{{module_messages.49}}'><span {%if beam.pk == active_beam %} {{color_status.49}} {%endif%}>{{beam.get_downvalues.48}}</span></td>
209 209 <td title='{{module_messages.50}}'><span {%if beam.pk == active_beam %} {{color_status.50}} {%endif%}>{{beam.get_downvalues.49}}</span></td>
210 210 <td title='{{module_messages.51}}'><span {%if beam.pk == active_beam %} {{color_status.51}} {%endif%}>{{beam.get_downvalues.50}}</span></td>
211 211 <td title='{{module_messages.52}}'><span {%if beam.pk == active_beam %} {{color_status.52}} {%endif%}>{{beam.get_downvalues.51}}</span></td>
212 212 </tr>
213 213 <tr>
214 214 <td title='{{module_messages.57}}'><span {%if beam.pk == active_beam %} {{color_status.57}} {%endif%}>{{beam.get_upvalues.56}}</span></td>
215 215 <td title='{{module_messages.58}}'><span {%if beam.pk == active_beam %} {{color_status.58}} {%endif%}>{{beam.get_upvalues.57}}</span></td>
216 216 <td title='{{module_messages.59}}'><span {%if beam.pk == active_beam %} {{color_status.59}} {%endif%}>{{beam.get_upvalues.58}}</span></td>
217 217 <td title='{{module_messages.60}}'><span {%if beam.pk == active_beam %} {{color_status.60}} {%endif%}>{{beam.get_upvalues.59}}</span></td>
218 218 </tr>
219 219 <tr>
220 220 <td title='{{module_messages.57}}'><span {%if beam.pk == active_beam %} {{color_status.57}} {%endif%}>{{beam.get_downvalues.56}}</span></td>
221 221 <td title='{{module_messages.58}}'><span {%if beam.pk == active_beam %} {{color_status.58}} {%endif%}>{{beam.get_downvalues.57}}</span></td>
222 222 <td title='{{module_messages.59}}'><span {%if beam.pk == active_beam %} {{color_status.59}} {%endif%}>{{beam.get_downvalues.58}}</span></td>
223 223 <td title='{{module_messages.60}}'><span {%if beam.pk == active_beam %} {{color_status.60}} {%endif%}>{{beam.get_downvalues.59}}</span></td>
224 224 </tr>
225 225 </table>
226 226 </td>
227 227 <td>
228 228 <b>South Quarter</b>
229 229 <table class="module">
230 230 <tr>
231 231 <td title='{{module_messages.37}}'><span {%if beam.pk == active_beam %} {{color_status.37}} {%endif%}>{{beam.get_upvalues.36}}</span></td>
232 232 <td title='{{module_messages.38}}'><span {%if beam.pk == active_beam %} {{color_status.38}} {%endif%}>{{beam.get_upvalues.37}}</span></td>
233 233 <td title='{{module_messages.39}}'><span {%if beam.pk == active_beam %} {{color_status.39}} {%endif%}>{{beam.get_upvalues.38}}</span></td>
234 234 <td title='{{module_messages.40}}'><span {%if beam.pk == active_beam %} {{color_status.40}} {%endif%}>{{beam.get_upvalues.39}}</span></td>
235 235 </tr>
236 236 <tr>
237 237 <td title='{{module_messages.37}}'><span {%if beam.pk == active_beam %} {{color_status.37}} {%endif%}>{{beam.get_downvalues.36}}</span></td>
238 238 <td title='{{module_messages.38}}'><span {%if beam.pk == active_beam %} {{color_status.38}} {%endif%}>{{beam.get_downvalues.37}}</span></td>
239 239 <td title='{{module_messages.39}}'><span {%if beam.pk == active_beam %} {{color_status.39}} {%endif%}>{{beam.get_downvalues.38}}</span></td>
240 240 <td title='{{module_messages.40}}'><span {%if beam.pk == active_beam %} {{color_status.40}} {%endif%}>{{beam.get_downvalues.39}}</span></td>
241 241 </tr>
242 242 <tr>
243 243 <td title='{{module_messages.45}}'><span {%if beam.pk == active_beam %} {{color_status.45}} {%endif%}>{{beam.get_upvalues.44}}</span></td>
244 244 <td title='{{module_messages.46}}'><span {%if beam.pk == active_beam %} {{color_status.46}} {%endif%}>{{beam.get_upvalues.45}}</span></td>
245 245 <td title='{{module_messages.47}}'><span {%if beam.pk == active_beam %} {{color_status.47}} {%endif%}>{{beam.get_upvalues.46}}</span></td>
246 246 <td title='{{module_messages.48}}'><span {%if beam.pk == active_beam %} {{color_status.48}} {%endif%}>{{beam.get_upvalues.47}}</span></td>
247 247 </tr>
248 248 <tr>
249 249 <td title='{{module_messages.45}}'><span {%if beam.pk == active_beam %} {{color_status.45}} {%endif%}>{{beam.get_downvalues.44}}</span></td>
250 250 <td title='{{module_messages.46}}'><span {%if beam.pk == active_beam %} {{color_status.46}} {%endif%}>{{beam.get_downvalues.45}}</span></td>
251 251 <td title='{{module_messages.47}}'><span {%if beam.pk == active_beam %} {{color_status.47}} {%endif%}>{{beam.get_downvalues.46}}</span></td>
252 252 <td title='{{module_messages.48}}'><span {%if beam.pk == active_beam %} {{color_status.48}} {%endif%}>{{beam.get_downvalues.47}}</span></td>
253 253 </tr>
254 254 <tr>
255 255 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.53}} {%endif%}>{{beam.get_upvalues.52}}</span></td>
256 256 <td title='{{module_messages.54}}'><span {%if beam.pk == active_beam %} {{color_status.54}} {%endif%}>{{beam.get_upvalues.53}}</span></td>
257 257 <td title='{{module_messages.55}}'><span {%if beam.pk == active_beam %} {{color_status.55}} {%endif%}>{{beam.get_upvalues.54}}</span></td>
258 258 <td title='{{module_messages.56}}'><span {%if beam.pk == active_beam %} {{color_status.56}} {%endif%}>{{beam.get_upvalues.55}}</span></td>
259 259 </tr>
260 260 <tr>
261 261 <td title='{{module_messages.53}}'><span {%if beam.pk == active_beam %} {{color_status.53}} {%endif%}>{{beam.get_downvalues.52}}</span></td>
262 262 <td title='{{module_messages.54}}'><span {%if beam.pk == active_beam %} {{color_status.54}} {%endif%}>{{beam.get_downvalues.53}}</span></td>
263 263 <td title='{{module_messages.55}}'><span {%if beam.pk == active_beam %} {{color_status.55}} {%endif%}>{{beam.get_downvalues.54}}</span></td>
264 264 <td title='{{module_messages.56}}'><span {%if beam.pk == active_beam %} {{color_status.56}} {%endif%}>{{beam.get_downvalues.55}}</span></td>
265 265 </tr>
266 266 <tr>
267 267 <td title='{{module_messages.61}}'><span {%if beam.pk == active_beam %} {{color_status.61}} {%endif%}>{{beam.get_upvalues.60}}</span></td>
268 268 <td title='{{module_messages.62}}'><span {%if beam.pk == active_beam %} {{color_status.62}} {%endif%}>{{beam.get_upvalues.61}}</span></td>
269 269 <td title='{{module_messages.63}}'><span {%if beam.pk == active_beam %} {{color_status.63}} {%endif%}>{{beam.get_upvalues.62}}</span></td>
270 270 <td title='{{module_messages.64}}'><span {%if beam.pk == active_beam %} {{color_status.64}} {%endif%}>{{beam.get_upvalues.63}}</span></td>
271 271 </tr>
272 272 <tr>
273 273 <td title='{{module_messages.61}}'><span {%if beam.pk == active_beam %} {{color_status.61}} {%endif%}>{{beam.get_downvalues.60}}</span></td>
274 274 <td title='{{module_messages.62}}'><span {%if beam.pk == active_beam %} {{color_status.62}} {%endif%}>{{beam.get_downvalues.61}}</span></td>
275 275 <td title='{{module_messages.63}}'><span {%if beam.pk == active_beam %} {{color_status.63}} {%endif%}>{{beam.get_downvalues.62}}</span></td>
276 276 <td title='{{module_messages.64}}'><span {%if beam.pk == active_beam %} {{color_status.64}} {%endif%}>{{beam.get_downvalues.63}}</span></td>
277 277 </tr>
278 278 </table>
279 279 </td>
280 280 </tr>
281 281 </table>
282 282
283 283 {% if beam.id == active_beam %}
284 284 <table class="legend">
285 285 <tr>
286 286 <th>Legend</th>
287 287 </tr>
288 288 <tr>
289 289 <td class="text-warning">Connected</td>
290 290 </tr>
291 291 <tr>
292 292 <td class="text-success">Running</td>
293 293 </tr>
294 294 <tr>
295 295 <td class="text-info">Mismath</td>
296 296 </tr>
297 297 <tr>
298 298 <td class="text-danger">Disconnected</td>
299 299 </tr>
300 300 </table>
301 301 {% else %}
302 302 <div style="vertical-align: top; display:inline-block;">
303 303 <button id="send_beam{{forloop.counter}}" type="button" class="btn btn-default">
304 304 <span class="fas fa-external-link-square-alt" aria-hidden="true"></span>
305 305 Change Beam</button>
306 306 </div>
307 307 {% endif %}
308 308 </div>
309 309 {% endfor %}
310 310 </div>
311 311 </div>
312 312
313 313
314 314 {% else %}
315 315 <p style="color:#b4bcc2; margin-left: 5%;">
316 316 <i>No Beams...</i>
317 317 </p>
318 {% endif %} {% endblock extra-content %} {% block extra-js%}
318 {% endif %}
319 {% endblock extra-content %}
320 {% block extra-js%}
319 321 <script>
320 322 $(document).ready(function () {
321 323
322 324 {% for beam in beams %}
323 325
324 {% if dev_conf.operation_mode == 1 %}
325 $("#send_beam{{forloop.counter}}").prop('disabled', true)
326 {% else %}
327 $("#send_beam{{forloop.counter}}").click(function () {
328 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
329 });
330 {% endif %}
326 {% if dev_conf.operation_mode == 1 %}
327 $("#send_beam{{forloop.counter}}").prop('disabled', true)
328 {% else %}
329 $("#send_beam{{forloop.counter}}").click(function () {
330 document.location = "{% url 'url_send_beam' dev_conf.id beam.id %}";
331 });
332 {% endif %}
331 333
332 334 {% endfor %}
333 335
334 336
335 337 });
336 </script> {% endblock %} No newline at end of file
338 </script>
339 {% endblock %}
@@ -1,47 +1,47
1 1 {% extends "dev_conf_edit.html" %}
2 2 {% load bootstrap4 %}
3 3 {% load static %}
4 4
5 5 {% block extra-head %}
6 6 <style type="text/css">
7 7 /* show the move cursor as the user moves the mouse over the panel header.*/
8 8 .panel-default { cursor: move; }
9 9 </style>
10 <script src="{% static 'js/jquery-ui.min.js' %}"></script>
10
11 11
12 12 {% endblock %}
13 13
14 14 {% block content %}
15 15 <form class="form" method="post">
16 16 {% csrf_token %}
17 17 {% bootstrap_form form layout='horizontal' size='medium' %}
18 18 <div style="clear: both;"></div>
19 19 <h2>ABS Beams</h2><hr>
20 20 <div class="panel-group" id="div_beams" role="tablist" aria-multiselectable="true">
21 21 {% include "abs_beams_list.html" %}
22 22 </div>
23 23 <div style="clear: both;"></div>
24 24 <br>
25 25 <div class="pull-right">
26 26 <button type="button" class="btn btn-primary" onclick="{% if previous %}window.location.replace('{{ previous }}');{% else %}history.go(-1);{% endif %}">Cancel</button>
27 27 <button type="button" class="btn btn-primary" id="bt_add_beam">Add Beam</button>
28 28 <button type="submit" class="btn btn-primary">{{button}}</button>
29 29 </div>
30 30 </form>
31 31 {% endblock %}
32 32
33 33
34 34 {% block extra-js%}
35 35 <script src="{% static 'js/abs.js' %}"></script>
36 36 <script type="text/javascript">
37 37
38 38 $("#bt_toggle").click(function() {
39 39 $(".panel-collapse").collapse('toggle')
40 40 });
41 41
42 42 $("#bt_add_beam").click(function() {
43 43 document.location = "{% url 'url_add_abs_beam' id_conf %}";
44 44 });
45 45
46 46 </script>
47 47 {% endblock %}
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now