@@ -80,7 +80,6 class RCConfiguration(Configuration): | |||||
80 | time_before = models.PositiveIntegerField(verbose_name='Time before [μS]', default=12) |
|
80 | time_before = models.PositiveIntegerField(verbose_name='Time before [μS]', default=12) | |
81 | time_after = models.PositiveIntegerField(verbose_name='Time after [μS]', default=1) |
|
81 | time_after = models.PositiveIntegerField(verbose_name='Time after [μS]', default=1) | |
82 | sync = models.PositiveIntegerField(verbose_name='Synchro delay', default=0) |
|
82 | sync = models.PositiveIntegerField(verbose_name='Synchro delay', default=0) | |
83 | ch_monitor = models.PositiveIntegerField(verbose_name='Channel Monitor', validators=[MinValueValidator(0), MaxValueValidator(15)], default=6) |
|
|||
84 | sampling_reference = models.CharField(verbose_name='Sampling Reference', choices=SAMPLING_REFS, default='none', max_length=40) |
|
83 | sampling_reference = models.CharField(verbose_name='Sampling Reference', choices=SAMPLING_REFS, default='none', max_length=40) | |
85 | control_tx = models.BooleanField(verbose_name='Control Switch TX', default=False) |
|
84 | control_tx = models.BooleanField(verbose_name='Control Switch TX', default=False) | |
86 | control_sw = models.BooleanField(verbose_name='Control Switch SW', default=False) |
|
85 | control_sw = models.BooleanField(verbose_name='Control Switch SW', default=False) | |
@@ -253,10 +252,11 class RCConfiguration(Configuration): | |||||
253 | #print('ups_arr', ups_arr) |
|
252 | #print('ups_arr', ups_arr) | |
254 | #print('dws_arr', dws_arr) |
|
253 | #print('dws_arr', dws_arr) | |
255 |
|
254 | |||
|
255 | #####################Code for load configuration######################### | |||
256 | for x in points: |
|
256 | for x in points: | |
257 | dum = [] |
|
257 | dum = [] | |
258 | print('loading', x*100/max(points)) |
|
258 | print('loading', x*100/max(points)) | |
259 |
|
259 | |||
260 | for i in range(n_pulses): |
|
260 | for i in range(n_pulses): | |
261 | if x in ups_arr[i]: |
|
261 | if x in ups_arr[i]: | |
262 | dum.append(1) |
|
262 | dum.append(1) | |
@@ -267,6 +267,8 class RCConfiguration(Configuration): | |||||
267 | #print(dum) |
|
267 | #print(dum) | |
268 | states.append(dum) |
|
268 | states.append(dum) | |
269 | last = dum |
|
269 | last = dum | |
|
270 | print("Finish loading") | |||
|
271 | ######################################################################### | |||
270 |
|
272 | |||
271 | if binary: |
|
273 | if binary: | |
272 | ret = [] |
|
274 | ret = [] | |
@@ -577,39 +579,49 class RCConfiguration(Configuration): | |||||
577 |
|
579 | |||
578 | def write_device(self, raw=False): |
|
580 | def write_device(self, raw=False): | |
579 | print("write device") |
|
581 | print("write device") | |
|
582 | ##############Comando status a CGS para hacer programacion ############ | |||
|
583 | try: | |||
|
584 | self.device.status = 0 | |||
|
585 | cgs = self.request('status_cgs') | |||
|
586 | print('CGS status ok') # solo para depurar lo que devuelve CGS | |||
|
587 | except Exception as e: | |||
|
588 | cgs = {'multiplier': 60, 'divider': 10, 'reference_clk': 1} # simulando parametros devueltos por el cgs | |||
|
589 | if 'No route to host' not in str(e): | |||
|
590 | self.device.status = 4 | |||
|
591 | self.device.save() | |||
|
592 | self.message = 'CGS status: {}'.format(str(e)) | |||
|
593 | print('not cgs status') | |||
580 |
|
594 | |||
581 | if not raw: |
|
595 | print(cgs) | |
582 |
|
||||
583 |
|
||||
584 |
|
596 | |||
|
597 | if not raw: | |||
585 | clock = RCClock.objects.get(rc_configuration=self) |
|
598 | clock = RCClock.objects.get(rc_configuration=self) | |
|
599 | print('clock_freq', clock.frequency) | |||
|
600 | print('clock_mult', clock.multiplier) | |||
|
601 | print('clock_div', clock.divisor) | |||
|
602 | print('clock_ref', clock.reference) | |||
|
603 | print('cgs', cgs) | |||
586 | if clock.mode: |
|
604 | if clock.mode: | |
587 | data = {'default': clock.frequency} |
|
605 | data = {'default': clock.frequency} # mult=72, div=12 | |
588 | else: |
|
606 | else: | |
589 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} |
|
607 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} | |
590 | payload = self.request('setfreq', 'post', data=json.dumps(data)) |
|
608 | print('data', data) | |
591 | #if payload['setfreq'] != 'ok': |
|
609 | int_cgs_multiplier=int(cgs['multiplier']) | |
592 | if payload['command'] != 'ok': |
|
610 | int_cgs_divisor=int(cgs['divider']) | |
593 | #self.message = 'RC write: {}'.format(payload['setfreq']) |
|
611 | int_cgs_reference=int(cgs['reference_clk']) | |
594 | self.message = 'RC write: {}'.format(payload['command']) |
|
612 | print(cgs['divider']) | |
595 | else: |
|
613 | ||
596 | #self.message = payload['setfreq'] |
|
614 | if clock.multiplier != int_cgs_multiplier or clock.divisor != int_cgs_divisor or clock.reference != int_cgs_reference: | |
597 | self.message = payload['programming'] |
|
615 | print("Program CGS...") | |
598 | #if payload['setfreq'] == 'fail': |
|
616 | payload = self.request('setfreq', 'post', data=json.dumps(data))#data=data)#data=json.dumps(data)) | |
599 |
if payload[' |
|
617 | if payload['command'] != 'ok': | |
600 |
self.message = 'RC write: |
|
618 | self.message = 'RC write: {}'.format(payload['command']) | |
601 |
|
619 | else: | ||
602 | ############################################################## |
|
620 | self.message = payload['programming'] | |
603 | data = {'setwindow': self.ch_monitor} |
|
621 | if payload['programming'] == 'fail': | |
604 | print(data) |
|
622 | self.message = 'RC write: error programming CGS chip' | |
605 | payload = self.request('setwin', 'post', data=json.dumps(data)) |
|
|||
606 |
|
||||
607 | if payload['setwindow'] == 'ok': |
|
|||
608 | self.message = 'RC write: {}'.format(payload['setwindow']) |
|
|||
609 | else: |
|
623 | else: | |
610 | if payload['command'] != 'wrong format or key': |
|
624 | print("Not program CGS...") | |
611 | self.message = 'Error RC monitor channel: {}'.format(payload['command']) |
|
|||
612 | ############################################################## |
|
|||
613 |
|
625 | |||
614 | values = [] |
|
626 | values = [] | |
615 | print('wait delay values...') |
|
627 | print('wait delay values...') | |
@@ -660,8 +672,8 class RCConfiguration(Configuration): | |||||
660 | cnt = 0 |
|
672 | cnt = 0 | |
661 | while x < n: |
|
673 | while x < n: | |
662 | print('writing...', cnt) |
|
674 | print('writing...', cnt) | |
663 |
payload = self.request('write', 'post', data=b64encode(data[x:x+ |
|
675 | payload = self.request('write', 'post', data=b64encode(data[x:x+16384]))#(data))# | |
664 |
x += |
|
676 | x += 16384 | |
665 | cnt += 1#time.sleep(1) |
|
677 | cnt += 1#time.sleep(1) | |
666 | print('writing...', x*100/n) |
|
678 | print('writing...', x*100/n) | |
667 |
|
679 |
General Comments 0
You need to be logged in to leave comments.
Login now