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