##// END OF EJS Templates
Operation mode: Automatic or Manual...
Fiorella Quino -
r192:18678523d9f7
parent child
Show More
@@ -174,10 +174,17 def fromChar2Binary(char):
174 bits = bits.zfill(6)
174 bits = bits.zfill(6)
175 return bits
175 return bits
176
176
177 OPERATION_MODES = (
178 (0, 'Manual'),
179 (1, 'Automatic'),
180 )
181
177
182
178 class ABSConfiguration(Configuration):
183 class ABSConfiguration(Configuration):
179 active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}")
184 active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, default="{}")
180 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
185 module_status = models.CharField(verbose_name='Module Status', max_length=10000, default=json.dumps(status_default))
186 operation_mode = models.CharField(verbose_name='Operation Mode', max_length = 20, choices=OPERATION_MODES, default = 0)
187 operation_value = models.CharField(verbose_name='Periodic (seconds)', max_length=20000, default="10", null=True, blank=True)
181
188
182 class Meta:
189 class Meta:
183 db_table = 'abs_configurations'
190 db_table = 'abs_configurations'
@@ -357,6 +364,11 class ABSConfiguration(Configuration):
357
364
358 return module_bits
365 return module_bits
359
366
367
368 def read_module(self, module):
369
370 return True
371
360 def status_device(self):
372 def status_device(self):
361 """
373 """
362 This function gets the status of each abs module. It sends GET method to Web Application
374 This function gets the status of each abs module. It sends GET method to Web Application
@@ -396,14 +408,9 class ABSConfiguration(Configuration):
396 It needs 'module_conf' function
408 It needs 'module_conf' function
397 """
409 """
398
410
399 ###beams_list = ast.literal_eval(self.beams)
400 ###beams = []
401 beams = ABSBeam.objects.filter(abs_conf=self)
411 beams = ABSBeam.objects.filter(abs_conf=self)
402 ###for bl in range(1,len(beams_list)+1):
403 ### b = ABSBeam.objects.get(pk=beams_list['beam'+str(bl)])
404 ### beams.append(b)
405
412
406 #---Write each abs module---
413 #-------------Write each abs module-----------
407 if beams:
414 if beams:
408 beams_status = ast.literal_eval(self.module_status)
415 beams_status = ast.literal_eval(self.module_status)
409 for i in range(62,65): #(62,65)
416 for i in range(62,65): #(62,65)
@@ -412,9 +419,7 class ABSConfiguration(Configuration):
412 beams_status[str(i)] = 1
419 beams_status[str(i)] = 1
413 self.module_status = json.dumps(beams_status)
420 self.module_status = json.dumps(beams_status)
414 self.save()
421 self.save()
415 #self.module_conf(63,beams)
422
416 #beams_status[str(63)] = 1
417 #self.module_status = json.dumps(beams_status)
418 except:
423 except:
419 beams_status[str(i)] = 0
424 beams_status[str(i)] = 0
420 self.module_status = json.dumps(beams_status)
425 self.module_status = json.dumps(beams_status)
@@ -429,9 +434,9 class ABSConfiguration(Configuration):
429 ##
434 ##
430 if answer==1:
435 if answer==1:
431 self.message = "ABS Beams List have been sent to ABS Modules"
436 self.message = "ABS Beams List have been sent to ABS Modules"
437 beams[0].set_as_activebeam()
432 else:
438 else:
433 self.message = "Could not read ABS parameters"
439 self.message = "Could not read ABS parameters"
434
435 ##
440 ##
436 self.save()
441 self.save()
437 return 1
442 return 1
@@ -809,18 +814,6 class ABSBeam(models.Model):
809
814
810 return self
815 return self
811
816
812 def set_activebeam(self):
813 """
814 This function change de active beam of ABS Configuration
815 """
816 conf = self.abs_conf
817 active_beam = {}
818 active_beam['active_beam'] = self.id
819 conf.active_beam = json.dumps(active_beam)
820 conf.save()
821
822 return
823
824
817
825
818
826 def module_6bits(self, module):
819 def module_6bits(self, module):
@@ -860,14 +853,16 class ABSBeam(models.Model):
860 return self.modules_conf
853 return self.modules_conf
861
854
862
855
863 def active_beam(self):
856 def set_as_activebeam(self):
864 """
857 """
865 This function set this beam as the active beam of its ABS Configuration.
858 This function set this beam as the active beam of its ABS Configuration.
866 """
859 """
867 self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
860 self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
868 self.abs_conf.save()
861 self.abs_conf.save()
862
869 return
863 return
870
864
865
871 @property
866 @property
872 def get_upvalues(self):
867 def get_upvalues(self):
873 """
868 """
General Comments 0
You need to be logged in to leave comments. Login now