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