@@ -289,6 +289,14 class ABSConfiguration(Configuration): | |||
|
289 | 289 | for beam in beams: |
|
290 | 290 | beam.clone(abs_conf=self) |
|
291 | 291 | |
|
292 | #-----For Active Beam----- | |
|
293 | active_beam = json.loads(self.active_beam) | |
|
294 | new_beams = ABSBeam.objects.filter(abs_conf=self) | |
|
295 | active_beam['active_beam'] = new_beams[0].id | |
|
296 | self.active_beam = json.dumps(active_beam) | |
|
297 | self.save() | |
|
298 | #-----For Active Beam----- | |
|
299 | ||
|
292 | 300 | return self |
|
293 | 301 | |
|
294 | 302 | |
@@ -304,8 +312,8 class ABSConfiguration(Configuration): | |||
|
304 | 312 | module_port = self.device.port_address |
|
305 | 313 | write_route = 'http://'+module_ip+':'+str(module_port)+'/write' |
|
306 | 314 | |
|
307 | header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' | |
|
308 | module = 'ABS_'+str(module_num) | |
|
315 | #header = 'JROABSCeCnModCnMod01000108SNDFexperimento1.ab1' | |
|
316 | #module = 'ABS_'+str(module_num) | |
|
309 | 317 | bs = '' #{} |
|
310 | 318 | i=1 |
|
311 | 319 | |
@@ -317,11 +325,7 class ABSConfiguration(Configuration): | |||
|
317 | 325 | beams = bs |
|
318 | 326 | |
|
319 | 327 | parameters = {} |
|
320 | #parameters['header'] = header | |
|
321 | #parameters['module'] = module | |
|
322 | 328 | parameters['beams'] = beams #json.dumps(beams) |
|
323 | #print beams | |
|
324 | #print parameters['beams'] | |
|
325 | 329 | print parameters |
|
326 | 330 | answer = '' |
|
327 | 331 | |
@@ -329,11 +333,12 class ABSConfiguration(Configuration): | |||
|
329 | 333 | #r_write = requests.post(write_route, parameters, timeout=0.5) |
|
330 | 334 | r_write = requests.post(write_route, json = parameters, timeout=0.5) |
|
331 | 335 | answer = r_write.json() |
|
332 | self.message = answer['message'] | |
|
336 | #self.message = answer['message'] | |
|
333 | 337 | except: |
|
334 | self.message = "Could not write ABS parameters" | |
|
335 |
return |
|
|
336 | return 1 | |
|
338 | #self.message = "Could not write ABS parameters" | |
|
339 | return False | |
|
340 | ||
|
341 | return answer | |
|
337 | 342 | |
|
338 | 343 | |
|
339 | 344 | |
@@ -348,33 +353,61 class ABSConfiguration(Configuration): | |||
|
348 | 353 | #-------------Write each abs module----------- |
|
349 | 354 | if beams: |
|
350 | 355 | beams_status = ast.literal_eval(self.module_status) |
|
351 | for i in range(61,64): #(62,65) | |
|
352 | try: | |
|
353 | answer = self.module_conf(i, beams) | |
|
354 |
|
|
|
355 | self.module_status = json.dumps(beams_status) | |
|
356 |
self. |
|
|
357 | ||
|
358 | except: | |
|
359 |
beams_status[str(i)] = |
|
|
360 | self.module_status = json.dumps(beams_status) | |
|
361 |
|
|
|
362 |
|
|
|
363 | return 0 | |
|
356 | disconnected_modules = 0 | |
|
357 | for i in range(1,65): #(62,65) | |
|
358 | #--------------JUEVES------------- | |
|
359 | if beams_status[str(i)] != 0: | |
|
360 | try: | |
|
361 | answer = self.module_conf(i,beams) | |
|
362 | if answer: | |
|
363 | if answer['status']: | |
|
364 | beams_status[str(i)] = 3 | |
|
365 | ||
|
366 | except: | |
|
367 | beams_status[str(i)] = 1 | |
|
368 | ||
|
369 | pass | |
|
370 | else: | |
|
371 | disconnected_modules += 1 | |
|
372 | #--------------JUEVES------------- | |
|
373 | #try: | |
|
374 | # answer = self.module_conf(i, beams) | |
|
375 | # beams_status[str(i)] = 1 | |
|
376 | # self.module_status = json.dumps(beams_status) | |
|
377 | # self.save() | |
|
378 | ||
|
379 | #except: | |
|
380 | # beams_status[str(i)] = 0 | |
|
381 | # self.module_status = json.dumps(beams_status) | |
|
382 | # self.save() | |
|
383 | # answer = 0 | |
|
384 | # return 0 | |
|
364 | 385 | else: |
|
365 | 386 | self.message = "ABS Configuration does not have beams" |
|
366 |
return |
|
|
387 | return False | |
|
367 | 388 | |
|
368 | 389 | #self.device.status = 1 |
|
369 | 390 | ## |
|
370 | if answer==1: | |
|
391 | #-------------Jueves------------- | |
|
392 | if disconnected_modules == 64: | |
|
393 | self.message = "Could not write ABS Modules" | |
|
394 | return False | |
|
395 | else: | |
|
371 | 396 | self.message = "ABS Beams List have been sent to ABS Modules" |
|
372 | 397 | beams[0].set_as_activebeam() |
|
373 | else: | |
|
374 | self.message = "Could not read ABS parameters" | |
|
398 | ||
|
399 | self.module_status = json.dumps(beams_status) | |
|
400 | self.save() | |
|
401 | ||
|
402 | #-------------Jueves------------- | |
|
403 | #if answer==1: | |
|
404 | # self.message = "ABS Beams List have been sent to ABS Modules" | |
|
405 | # beams[0].set_as_activebeam() | |
|
406 | #else: | |
|
407 | # self.message = "Could not read ABS parameters" | |
|
375 | 408 | ## |
|
376 | 409 | self.save() |
|
377 |
return |
|
|
410 | return True | |
|
378 | 411 | |
|
379 | 412 | |
|
380 | 413 | |
@@ -453,7 +486,8 class ABSConfiguration(Configuration): | |||
|
453 | 486 | modules_status = json.loads(self.module_status) |
|
454 | 487 | num = 0 |
|
455 | 488 | for status in modules_status: |
|
456 |
|
|
|
489 | if modules_status[status] != 0: | |
|
490 | num += 1 | |
|
457 | 491 | |
|
458 | 492 | return num |
|
459 | 493 |
@@ -131,7 +131,7 def abs_conf(request, id_conf): | |||
|
131 | 131 | |
|
132 | 132 | color_status = {} |
|
133 | 133 | for status in modules_status: |
|
134 |
if modules_status[status] == |
|
|
134 | if modules_status[status] == 3: #Running background-color: #00cc00; | |
|
135 | 135 | color_status[status] = 'class=text-success'#'bgcolor=#00cc00' |
|
136 | 136 | elif modules_status[status] == 1: #Connected background-color: #ee902c; |
|
137 | 137 | color_status[status] = 'class=text-warning'#'bgcolor=#ee902c' |
General Comments 0
You need to be logged in to leave comments.
Login now