##// 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 174 bits = bits.zfill(6)
175 175 return bits
176 176
177 OPERATION_MODES = (
178 (0, 'Manual'),
179 (1, 'Automatic'),
180 )
181
177 182
178 183 class ABSConfiguration(Configuration):
179 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))
184 active_beam = models.CharField(verbose_name='Active Beam', max_length=20000, 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 189 class Meta:
183 190 db_table = 'abs_configurations'
@@ -357,6 +364,11 class ABSConfiguration(Configuration):
357 364
358 365 return module_bits
359 366
367
368 def read_module(self, module):
369
370 return True
371
360 372 def status_device(self):
361 373 """
362 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 408 It needs 'module_conf' function
397 409 """
398 410
399 ###beams_list = ast.literal_eval(self.beams)
400 ###beams = []
401 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 414 if beams:
408 415 beams_status = ast.literal_eval(self.module_status)
409 416 for i in range(62,65): #(62,65)
@@ -412,9 +419,7 class ABSConfiguration(Configuration):
412 419 beams_status[str(i)] = 1
413 420 self.module_status = json.dumps(beams_status)
414 421 self.save()
415 #self.module_conf(63,beams)
416 #beams_status[str(63)] = 1
417 #self.module_status = json.dumps(beams_status)
422
418 423 except:
419 424 beams_status[str(i)] = 0
420 425 self.module_status = json.dumps(beams_status)
@@ -429,9 +434,9 class ABSConfiguration(Configuration):
429 434 ##
430 435 if answer==1:
431 436 self.message = "ABS Beams List have been sent to ABS Modules"
437 beams[0].set_as_activebeam()
432 438 else:
433 439 self.message = "Could not read ABS parameters"
434
435 440 ##
436 441 self.save()
437 442 return 1
@@ -809,18 +814,6 class ABSBeam(models.Model):
809 814
810 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 819 def module_6bits(self, module):
@@ -860,14 +853,16 class ABSBeam(models.Model):
860 853 return self.modules_conf
861 854
862 855
863 def active_beam(self):
856 def set_as_activebeam(self):
864 857 """
865 858 This function set this beam as the active beam of its ABS Configuration.
866 859 """
867 860 self.abs_conf.active_beam = json.dumps({'active_beam': self.id})
868 861 self.abs_conf.save()
862
869 863 return
870 864
865
871 866 @property
872 867 def get_upvalues(self):
873 868 """
General Comments 0
You need to be logged in to leave comments. Login now