@@ -252,10 +252,11 class RCConfiguration(Configuration): | |||||
252 | #print('ups_arr', ups_arr) |
|
252 | #print('ups_arr', ups_arr) | |
253 | #print('dws_arr', dws_arr) |
|
253 | #print('dws_arr', dws_arr) | |
254 |
|
254 | |||
|
255 | #####################Code for load configuration######################### | |||
255 | for x in points: |
|
256 | for x in points: | |
256 | dum = [] |
|
257 | dum = [] | |
257 | print('loading', x*100/max(points)) |
|
258 | print('loading', x*100/max(points)) | |
258 |
|
259 | |||
259 | for i in range(n_pulses): |
|
260 | for i in range(n_pulses): | |
260 | if x in ups_arr[i]: |
|
261 | if x in ups_arr[i]: | |
261 | dum.append(1) |
|
262 | dum.append(1) | |
@@ -266,6 +267,8 class RCConfiguration(Configuration): | |||||
266 | #print(dum) |
|
267 | #print(dum) | |
267 | states.append(dum) |
|
268 | states.append(dum) | |
268 | last = dum |
|
269 | last = dum | |
|
270 | print("Finish loading") | |||
|
271 | ######################################################################### | |||
269 |
|
272 | |||
270 | if binary: |
|
273 | if binary: | |
271 | ret = [] |
|
274 | ret = [] | |
@@ -576,24 +579,49 class RCConfiguration(Configuration): | |||||
576 |
|
579 | |||
577 | def write_device(self, raw=False): |
|
580 | def write_device(self, raw=False): | |
578 | 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') | |||
|
594 | ||||
|
595 | print(cgs) | |||
579 |
|
596 | |||
580 | if not raw: |
|
597 | if not raw: | |
581 | 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) | |||
582 | if clock.mode: |
|
604 | if clock.mode: | |
583 | data = {'default': clock.frequency} |
|
605 | data = {'default': clock.frequency} # mult=72, div=12 | |
584 | else: |
|
606 | else: | |
585 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} |
|
607 | data = {'manual': [clock.multiplier, clock.divisor, clock.reference]} | |
586 | payload = self.request('setfreq', 'post', data=json.dumps(data)) |
|
608 | print('data', data) | |
587 | #if payload['setfreq'] != 'ok': |
|
609 | int_cgs_multiplier=int(cgs['multiplier']) | |
588 | if payload['command'] != 'ok': |
|
610 | int_cgs_divisor=int(cgs['divider']) | |
589 | #self.message = 'RC write: {}'.format(payload['setfreq']) |
|
611 | int_cgs_reference=int(cgs['reference_clk']) | |
590 | self.message = 'RC write: {}'.format(payload['command']) |
|
612 | print(cgs['divider']) | |
|
613 | ||||
|
614 | if clock.multiplier != int_cgs_multiplier or clock.divisor != int_cgs_divisor or clock.reference != int_cgs_reference: | |||
|
615 | print("Program CGS...") | |||
|
616 | payload = self.request('setfreq', 'post', data=json.dumps(data))#data=data)#data=json.dumps(data)) | |||
|
617 | if payload['command'] != 'ok': | |||
|
618 | self.message = 'RC write: {}'.format(payload['command']) | |||
|
619 | else: | |||
|
620 | self.message = payload['programming'] | |||
|
621 | if payload['programming'] == 'fail': | |||
|
622 | self.message = 'RC write: error programming CGS chip' | |||
591 | else: |
|
623 | else: | |
592 | #self.message = payload['setfreq'] |
|
624 | print("Not program CGS...") | |
593 | self.message = payload['programming'] |
|
|||
594 | #if payload['setfreq'] == 'fail': |
|
|||
595 | if payload['programming'] == 'fail': |
|
|||
596 | self.message = 'RC write: error programming CGS chip' |
|
|||
597 |
|
625 | |||
598 | values = [] |
|
626 | values = [] | |
599 | print('wait delay values...') |
|
627 | print('wait delay values...') | |
@@ -644,8 +672,8 class RCConfiguration(Configuration): | |||||
644 | cnt = 0 |
|
672 | cnt = 0 | |
645 | while x < n: |
|
673 | while x < n: | |
646 | print('writing...', cnt) |
|
674 | print('writing...', cnt) | |
647 |
payload = self.request('write', 'post', data=b64encode(data[x:x+ |
|
675 | payload = self.request('write', 'post', data=b64encode(data[x:x+16384]))#(data))# | |
648 |
x += |
|
676 | x += 16384 | |
649 | cnt += 1#time.sleep(1) |
|
677 | cnt += 1#time.sleep(1) | |
650 | print('writing...', x*100/n) |
|
678 | print('writing...', x*100/n) | |
651 |
|
679 |
General Comments 0
You need to be logged in to leave comments.
Login now