@@ -1,7 +1,8 | |||
|
1 | 1 | from django.contrib import admin |
|
2 | from .models import ABSConfiguration, ABSBeam | |
|
2 | from .models import ABSConfiguration, ABSBeam, ABSActive | |
|
3 | 3 | |
|
4 | 4 | # Register your models here. |
|
5 | 5 | |
|
6 | 6 | admin.site.register(ABSConfiguration) |
|
7 | 7 | admin.site.register(ABSBeam) |
|
8 | admin.site.register(ABSActive) No newline at end of file |
@@ -434,6 +434,7 class ABSConfiguration(Configuration): | |||
|
434 | 434 | sock.close() |
|
435 | 435 | else: |
|
436 | 436 | self.message = "ABS Configuration does not have beams" |
|
437 | print('No beams') | |
|
437 | 438 | #Start DDS-RC-JARS |
|
438 | 439 | if confdds: |
|
439 | 440 | confdds.start_device() |
@@ -449,6 +450,7 class ABSConfiguration(Configuration): | |||
|
449 | 450 | self.device.status = 0 |
|
450 | 451 | self.module_status = ''.join(status) |
|
451 | 452 | self.save() |
|
453 | print('Could not write ABS') | |
|
452 | 454 | #Start DDS-RC-JARS |
|
453 | 455 | if confdds: |
|
454 | 456 | confdds.start_device() |
@@ -460,6 +462,7 class ABSConfiguration(Configuration): | |||
|
460 | 462 | return False |
|
461 | 463 | else: |
|
462 | 464 | self.message = "ABS Beams List have been sent to ABS Modules" |
|
465 | print('ABS beams list sent') | |
|
463 | 466 | self.active_beam = beams[0].pk |
|
464 | 467 | |
|
465 | 468 | #Start DDS-RC-JARS |
@@ -471,10 +474,12 class ABSConfiguration(Configuration): | |||
|
471 | 474 | if confjars: |
|
472 | 475 | confjars.start_device() |
|
473 | 476 | |
|
477 | print('Inicia intento de salvar device.status') | |
|
474 | 478 | self.device.status = 3 |
|
475 | 479 | self.module_status = ''.join(status) |
|
476 | 480 | self.save() |
|
477 | conf_active = ABSActive.objects.get(pk=1) | |
|
481 | print('Estatus salvado') | |
|
482 | conf_active = ABSActive.objects.get_or_create(pk=1) | |
|
478 | 483 | conf_active.conf = self |
|
479 | 484 | conf_active.save() |
|
480 | 485 | return True |
@@ -734,9 +739,13 class ABSConfiguration(Configuration): | |||
|
734 | 739 | |
|
735 | 740 | def get_absolute_url_import(self): |
|
736 | 741 | return reverse('url_import_abs_conf', args=[str(self.id)]) |
|
742 | ||
|
737 | 743 | class ABSActive(models.Model): |
|
738 | 744 | conf = models.ForeignKey(ABSConfiguration, null=True, verbose_name='ABS Configuration', on_delete=models.CASCADE) |
|
739 | 745 | |
|
746 | class Meta: | |
|
747 | db_table = 'abs_absactive' | |
|
748 | ||
|
740 | 749 | class ABSBeam(models.Model): |
|
741 | 750 | |
|
742 | 751 | name = models.CharField(max_length=60, default='Beam') |
@@ -34,4 +34,11 function freqRamp2Binary(mclock, frequency) { | |||
|
34 | 34 | |
|
35 | 35 | var freq_bin = parseInt(mclock/frequency-1); |
|
36 | 36 | return freq_bin; |
|
37 | } No newline at end of file | |
|
37 | } | |
|
38 | ||
|
39 | function us2Ramp(step_us) { | |
|
40 | //periodo_delpaso = sysclockperiod x (N+1) | |
|
41 | // freqsys/(N+1)=freq_ddelpaso=1/step | |
|
42 | var freq = (1.0/(step_us)); | |
|
43 | return freq; | |
|
44 | } No newline at end of file |
@@ -32,23 +32,23 class DDSRestConfiguration(Configuration): | |||
|
32 | 32 | |
|
33 | 33 | DDS_NBITS = 48 |
|
34 | 34 | |
|
35 | clock = models.FloatField(verbose_name='Clock In (MHz)',validators=[MinValueValidator(5), MaxValueValidator(75)], null=True, default=60) | |
|
35 | clock = models.FloatField(verbose_name='Clock In (MHz)',validators=[MinValueValidator(5), MaxValueValidator(75)], null=True, default=60) | |
|
36 | 36 | multiplier = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator(1), MaxValueValidator(20)], default=4) |
|
37 | 37 | |
|
38 | 38 | frequencyA_Mhz = models.DecimalField(verbose_name='Frequency A (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, null=True, default=49.9200) |
|
39 | frequencyA = models.BigIntegerField(verbose_name='Frequency A (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True) | |
|
39 | frequencyA = models.BigIntegerField(verbose_name='Frequency A (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True) | |
|
40 | 40 | |
|
41 | 41 | frequencyB_Mhz = models.DecimalField(verbose_name='Frequency B (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, blank=True, null=True) |
|
42 | frequencyB = models.BigIntegerField(verbose_name='Frequency B (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True) | |
|
42 | frequencyB = models.BigIntegerField(verbose_name='Frequency B (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True) | |
|
43 | 43 | |
|
44 | 44 | delta_frequency_Mhz = models.DecimalField(verbose_name='Delta frequency (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, blank=True, null=True) |
|
45 | delta_frequency = models.BigIntegerField(verbose_name='Delta frequency (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True) | |
|
45 | delta_frequency = models.BigIntegerField(verbose_name='Delta frequency (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**DDS_NBITS-1)], blank=True, null=True) | |
|
46 | 46 | |
|
47 | 47 | update_clock_Mhz = models.DecimalField(verbose_name='Update clock (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, blank=True, null=True) |
|
48 | update_clock = models.BigIntegerField(verbose_name='Update clock (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) | |
|
48 | update_clock = models.BigIntegerField(verbose_name='Update clock (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) | |
|
49 | 49 | |
|
50 | 50 | ramp_rate_clock_Mhz = models.DecimalField(verbose_name='Ramp rate clock (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], max_digits=19, decimal_places=16, blank=True, null=True) |
|
51 | ramp_rate_clock = models.BigIntegerField(verbose_name='Ramp rate clock (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**18-1)], blank=True, null=True) | |
|
51 | ramp_rate_clock = models.BigIntegerField(verbose_name='Ramp rate clock (Decimal)',validators=[MinValueValidator(0), MaxValueValidator(2**18-1)], blank=True, null=True) | |
|
52 | 52 | |
|
53 | 53 | phaseA_degrees = models.FloatField(verbose_name='Phase A (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], default=0) |
|
54 | 54 | |
@@ -166,6 +166,19 class DDSRestConfiguration(Configuration): | |||
|
166 | 166 | self.message = "" |
|
167 | 167 | return parms |
|
168 | 168 | |
|
169 | def arma_control(self,l_clock,l_multiplier,l_modulation): | |
|
170 | sysclock = l_clock*l_multiplier | |
|
171 | pll_range = 0 | |
|
172 | if(sysclock>=200): | |
|
173 | pll_range = 1 | |
|
174 | l_control = ((l_modulation<<9)+(pll_range<<22)+(l_multiplier<<16)).to_bytes(4,'little') | |
|
175 | return l_control | |
|
176 | ||
|
177 | def conv_phase(self,l_phase): | |
|
178 | ||
|
179 | l_phase_2B = int((l_phase*(2**14)/360)).to_bytes(2,'little') | |
|
180 | return l_phase_2B | |
|
181 | ||
|
169 | 182 | def arma_data_write(self): |
|
170 | 183 | #clock = RCClock.objects.get(rc_configuration=self) |
|
171 | 184 | clock = self.clock |
@@ -180,25 +193,29 class DDSRestConfiguration(Configuration): | |||
|
180 | 193 | print(frequencyB_Mhz) |
|
181 | 194 | frequencyB = self.frequencyB |
|
182 | 195 | print(frequencyB) |
|
183 | phaseA_degrees = self.phaseA_degrees | |
|
196 | phaseA_degrees = self.phaseA_degrees or 0 | |
|
184 | 197 | print(phaseA_degrees) |
|
185 | phaseB_degrees = self.phaseB_degrees | |
|
198 | phaseB_degrees = self.phaseB_degrees or 0 | |
|
186 | 199 | print(phaseB_degrees) |
|
187 | modulation = self.modulation | |
|
200 | modulation = self.modulation or 0 | |
|
188 | 201 | print(modulation) |
|
189 | amplitude_enabled = self.amplitude_enabled | |
|
202 | amplitude_enabled = self.amplitude_enabled or 0 | |
|
190 | 203 | print(amplitude_enabled) |
|
191 | amplitudeI = self.amplitudeI | |
|
204 | amplitudeI = self.amplitudeI or 0 | |
|
192 | 205 | print(amplitudeI) |
|
193 | amplitudeQ = self.amplitudeQ | |
|
206 | amplitudeQ = self.amplitudeQ or 0 | |
|
194 | 207 | print(amplitudeQ) |
|
195 | delta_frequency = self.delta_frequency | |
|
208 | delta_frequency = self.delta_frequency or 0 | |
|
196 | 209 | print(delta_frequency) |
|
197 | update_clock = self.update_clock | |
|
210 | update_clock = self.update_clock or 0 | |
|
198 | 211 | print(update_clock) |
|
199 | ramp_rate_clock = self.ramp_rate_clock | |
|
212 | ramp_rate_clock = self.ramp_rate_clock or 0 | |
|
200 | 213 | print(ramp_rate_clock) |
|
201 | 214 | |
|
215 | control = self.arma_control(clock,multiplier,modulation) | |
|
216 | phase1 = self.conv_phase(phaseA_degrees) | |
|
217 | phase2 = self.conv_phase(phaseB_degrees) | |
|
218 | ||
|
202 | 219 | cadena_json = {'clock': (b64encode(pack('<f',clock))).decode("UTF-8"),\ |
|
203 | 220 | 'multiplier': (b64encode(pack('<B',multiplier))).decode("UTF-8"),\ |
|
204 | 221 | 'frequencyA': (b64encode((frequencyA).to_bytes(6,'little'))).decode("UTF-8"),\ |
@@ -206,9 +223,11 class DDSRestConfiguration(Configuration): | |||
|
206 | 223 | 'delta_frequency': (b64encode((delta_frequency).to_bytes(6,'little'))).decode("UTF-8"),\ |
|
207 | 224 | 'update_clock': (b64encode((update_clock).to_bytes(4,'little'))).decode("UTF-8"),\ |
|
208 | 225 | 'ramp_rate_clock': (b64encode((ramp_rate_clock).to_bytes(3,'little'))).decode("UTF-8"),\ |
|
209 |
'control': (b64encode( |
|
|
226 | 'control': (b64encode(control)).decode("UTF-8"),\ | |
|
210 | 227 | 'amplitudeI': (b64encode((amplitudeI).to_bytes(2,'little'))).decode("UTF-8"),\ |
|
211 |
'amplitudeQ': (b64encode((amplitudeQ).to_bytes( |
|
|
228 | 'amplitudeQ': (b64encode((amplitudeQ).to_bytes(2,'little'))).decode("UTF-8"),\ | |
|
229 | '_phase1': (b64encode((phase1))).decode("UTF-8"),\ | |
|
230 | '_phase2': (b64encode((phase2))).decode("UTF-8") | |
|
212 | 231 | } |
|
213 | 232 | return cadena_json |
|
214 | 233 |
@@ -35,4 +35,17 | |||
|
35 | 35 | |
|
36 | 36 | var freq_bin = parseInt(mclock/frequency-1); |
|
37 | 37 | return freq_bin; |
|
38 | } | |
|
39 | ||
|
40 | function us2Ramp(step_us) { | |
|
41 | //periodo_delpaso = sysclockperiod x (N+1) | |
|
42 | // freqsys/(N+1)=freq_ddelpaso=1/step | |
|
43 | var freq = (1.0/(step_us)); | |
|
44 | return freq; | |
|
45 | } | |
|
46 | ||
|
47 | function phase2Binary(phase) { | |
|
48 | ||
|
49 | var phase_bin = parseInt(phase*(Math.pow(2,48))/360); | |
|
50 | return phase_bin; | |
|
38 | 51 | } No newline at end of file |
@@ -3,10 +3,152 | |||
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | {% block dds_rest%} | |
|
7 | ||
|
8 | {% bootstrap_field form.template layout='horizontal' size='medium' %} | |
|
9 | {% bootstrap_field form.device layout='horizontal' size='medium' %} | |
|
10 | {% bootstrap_field form.label layout='horizontal' size='medium' %} | |
|
11 | {% bootstrap_field form.experiment layout='horizontal' size='medium' %} | |
|
12 | ||
|
13 | {% bootstrap_field form.clock layout='horizontal' size='medium' %} | |
|
14 | {% bootstrap_field form.multiplier layout='horizontal' size='medium' %} | |
|
15 | ||
|
16 | <div style="display: flex; justify-content: flex-end"> | |
|
17 | <div class="form-check"> | |
|
18 | <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_fA" value="" >Mostrar Decimal</label> | |
|
19 | </div> | |
|
20 | </div> | |
|
21 | {% bootstrap_field form.frequencyA_Mhz layout='horizontal' size='medium' %} | |
|
22 | <div id='id_row_fAbin'> | |
|
23 | {% bootstrap_field form.frequencyA layout='horizontal' size='medium' %} | |
|
24 | <div style="display: flex; justify-content: flex-end"> | |
|
25 | <small type="text" id="id_aux_fAbin" class="form-text text-muted">1000 0000 </small> | |
|
26 | </div> | |
|
27 | <br> | |
|
28 | </div> | |
|
29 | ||
|
30 | <div style="display: flex; justify-content: flex-end"> | |
|
31 | <div class="form-check"> | |
|
32 | <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_fB" value="" >Mostrar Decimal</label> | |
|
33 | </div> | |
|
34 | </div> | |
|
35 | {% bootstrap_field form.frequencyB_Mhz layout='horizontal' size='medium' %} | |
|
36 | <div id='id_row_fBbin'> | |
|
37 | {% bootstrap_field form.frequencyB layout='horizontal' size='medium' %} | |
|
38 | <div style="display: flex; justify-content: flex-end"> | |
|
39 | <small type="text" id="id_aux_fBbin" class="form-text text-muted">1000 0000 </small> | |
|
40 | </div> | |
|
41 | <br> | |
|
42 | </div> | |
|
43 | ||
|
44 | <div style="display: flex; justify-content: flex-end"> | |
|
45 | <div class="form-check"> | |
|
46 | <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_df" value="" >Mostrar Decimal</label> | |
|
47 | </div> | |
|
48 | </div> | |
|
49 | {% bootstrap_field form.delta_frequency_Mhz layout='horizontal' size='medium' %} | |
|
50 | <div id='id_row_dfbin'> | |
|
51 | {% bootstrap_field form.delta_frequency layout='horizontal' size='medium' %} | |
|
52 | <div style="display: flex; justify-content: flex-end"> | |
|
53 | <small type="text" id="id_aux_deltabin" class="form-text text-muted">1000 0000 </small> | |
|
54 | </div> | |
|
55 | <br> | |
|
56 | </div> | |
|
57 | ||
|
58 | <div style="display: flex; justify-content: flex-end"> | |
|
59 | <div class="form-check"> | |
|
60 | <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_ramp" value="" >Mostrar Decimal</label> | |
|
61 | </div> | |
|
62 | </div> | |
|
63 | <div class="form-group row"> | |
|
64 | <label class="col-md-3 col-form-label" for="id_ramp_rate_clock_us">Ramp rate clock(us)</label> | |
|
65 | <div class="col-md-9"> | |
|
66 | <input type="number" name="ramp_rate_clock_us" step="1e-16" class="form-control" placeHolder="Ramp rate clock(us)" title id="id_ramp_rate_clock_us"> | |
|
67 | </div> | |
|
68 | </div> | |
|
69 | <div id='id_row_rampbin'> | |
|
70 | {% bootstrap_field form.ramp_rate_clock_Mhz layout='horizontal' size='medium' %} | |
|
71 | {% bootstrap_field form.ramp_rate_clock layout='horizontal' size='medium' %} | |
|
72 | <div style="display: flex; justify-content: flex-end"> | |
|
73 | <small type="text" id="id_aux_rampbin" class="form-text text-muted">1000 0000 </small> | |
|
74 | </div> | |
|
75 | <br> | |
|
76 | </div> | |
|
77 | ||
|
78 | <div style="display: flex; justify-content: flex-end"> | |
|
79 | <div class="form-check"> | |
|
80 | <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_phaseA" value="" >Mostrar Decimal</label> | |
|
81 | </div> | |
|
82 | </div> | |
|
83 | {% bootstrap_field form.phaseA_degrees layout='horizontal' size='medium' %} | |
|
84 | <div id='id_row_phaseA'> | |
|
85 | <div style="display: flex; justify-content: flex-end"> | |
|
86 | <small type="text" id="id_aux_phaseAdec" class="form-text text-muted">9282 </small> | |
|
87 | </div> | |
|
88 | <div style="display: flex; justify-content: flex-end"> | |
|
89 | <small type="text" id="id_aux_phaseAbin" class="form-text text-muted">1000 0000 </small> | |
|
90 | </div> | |
|
91 | <br> | |
|
92 | </div> | |
|
93 | ||
|
94 | <div style="display: flex; justify-content: flex-end"> | |
|
95 | <div class="form-check"> | |
|
96 | <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_phaseB" value="" >Mostrar Decimal</label> | |
|
97 | </div> | |
|
98 | </div> | |
|
99 | {% bootstrap_field form.phaseB_degrees layout='horizontal' size='medium' %} | |
|
100 | <div id='id_row_phaseB'> | |
|
101 | <div style="display: flex; justify-content: flex-end"> | |
|
102 | <small type="text" id="id_aux_phaseBdec" class="form-text text-muted">9876 </small> | |
|
103 | </div> | |
|
104 | <div style="display: flex; justify-content: flex-end"> | |
|
105 | <small type="text" id="id_aux_phaseBbin" class="form-text text-muted">1000 0000 </small> | |
|
106 | </div> | |
|
107 | <br> | |
|
108 | </div> | |
|
109 | ||
|
110 | {% bootstrap_field form.modulation layout='horizontal' size='medium' %} | |
|
111 | {% bootstrap_field form.amplitude_enabled layout='horizontal' size='medium' %} | |
|
112 | ||
|
113 | {% bootstrap_field form.amplitudeI layout='horizontal' size='medium' %} | |
|
114 | {% bootstrap_field form.amplitudeQ layout='horizontal' size='medium' %} | |
|
115 | ||
|
116 | ||
|
117 | {% endblock %} | |
|
118 | ||
|
6 | 119 | {% block extra-js%} |
|
7 | 120 | <script src="{% static 'js/dds_conversion.js' %}"></script> |
|
8 | 121 | <script type="text/javascript"> |
|
122 | $("#id_row_fAbin").hide(); | |
|
123 | $("#id_chkbin_fA").on('change', function() { | |
|
124 | hidefA(); | |
|
125 | }); | |
|
126 | ||
|
127 | $("#id_row_fBbin").hide(); | |
|
128 | $("#id_chkbin_fB").on('change', function() { | |
|
129 | hidefB(); | |
|
130 | }); | |
|
131 | ||
|
132 | $("#id_row_dfbin").hide(); | |
|
133 | $("#id_chkbin_df").on('change', function() { | |
|
134 | hidedf(); | |
|
135 | }); | |
|
136 | ||
|
137 | $("#id_row_rampbin").hide(); | |
|
138 | $("#id_chkbin_ramp").on('change', function() { | |
|
139 | hideramp(); | |
|
140 | }); | |
|
9 | 141 | |
|
142 | $("#id_row_phaseA").hide(); | |
|
143 | $("#id_chkbin_phaseA").on('change', function() { | |
|
144 | hidephaseA(); | |
|
145 | }); | |
|
146 | ||
|
147 | $("#id_row_phaseB").hide(); | |
|
148 | $("#id_chkbin_phaseB").on('change', function() { | |
|
149 | hidephaseB(); | |
|
150 | }); | |
|
151 | ||
|
10 | 152 | $("#id_clock").on('change', function() { |
|
11 | 153 | updateFrequencies(); |
|
12 | 154 | }); |
@@ -43,40 +185,42 | |||
|
43 | 185 | updateFrequencyRamp(); |
|
44 | 186 | }); |
|
45 | 187 | |
|
188 | $("#id_ramp_rate_clock_us").on('change', function() { | |
|
189 | updateFrequencyMhzRamp(); | |
|
190 | }); | |
|
191 | ||
|
46 | 192 | $("#id_ramp_rate_clock_Mhz").on('change', function() { |
|
47 | 193 | updateBinaryFrequencyRamp(); |
|
48 | 194 | }); |
|
49 | ||
|
195 | ||
|
196 | $("#id_phaseA_degrees").on('change', function() { | |
|
197 | updatephaseAbindec(); | |
|
198 | }); | |
|
199 | ||
|
200 | $("#id_phaseB_degrees").on('change', function() { | |
|
201 | updatephaseBbindec(); | |
|
202 | }); | |
|
203 | ||
|
50 | 204 | function updateBinaryFrequencies() { |
|
51 | 205 | |
|
52 | 206 | var clock = $("#id_clock").val(); |
|
53 | 207 | var multiplier = $("#id_multiplier").val(); |
|
54 | 208 | var freq = $("#id_frequencyA_Mhz").val(); |
|
55 | 209 | var freq_mod = $("#id_frequencyB_Mhz").val(); |
|
56 | //var freq_delta = $("#id_delta_frequency_Mhz").val(); | |
|
57 | //var freq_ramp = $("#id_ramp_rate_clock_Mhz").val(); | |
|
58 | 210 |
|
|
59 | 211 | var mclock = clock*multiplier; |
|
60 | 212 | |
|
61 | 213 | var freq_bin = freq2Binary(mclock, freq); |
|
62 | 214 | var freq_mod_bin = freq2Binary(mclock, freq_mod); |
|
63 | //var freqdelta_bin = freqDelta2Binary(mclock, freq_delta); | |
|
64 | //var freqramp_bin = freqRamp2Binary(mclock, freq_ramp); | |
|
65 | 215 |
|
|
66 | 216 | $("#id_frequencyA").val(freq_bin); |
|
67 | 217 | $("#id_frequencyB").val(freq_mod_bin); |
|
68 | //$("#id_delta_frequency").val(freqdelta_bin); | |
|
69 | //$("#id_ramp_rate_clock").val(freqramp_bin); | |
|
70 | 218 |
|
|
71 | 219 | freq = binary2Freq(mclock, freq_bin); |
|
72 | 220 | freq_mod = binary2Freq(mclock, freq_mod_bin); |
|
73 | //freqdelta = binary2FreqDelta(mclock, freqdelta_bin); | |
|
74 | //freq_ramp = binary2Ramp(mclock, freqramp_bin); | |
|
75 | 221 |
|
|
76 | 222 | $("#id_frequencyA_Mhz").val(freq); |
|
77 | 223 | $("#id_frequencyB_Mhz").val(freq_mod); |
|
78 | //$("#id_delta_frequency_Mhz").val(freqdelta); | |
|
79 | //$("#id_ramp_rate_clock_Mhz").val(freq_ramp); | |
|
80 | 224 |
|
|
81 | 225 | } |
|
82 | 226 | |
@@ -119,13 +263,20 | |||
|
119 | 263 | console.log("Ingreso a updateBInaryFrequencyDelta"); |
|
120 | 264 | var clock = $("#id_clock").val(); |
|
121 | 265 | var multiplier = $("#id_multiplier").val(); |
|
122 |
var freq = $("#id_delta_frequency_M |
|
|
266 | var freq = $("#id_delta_frequency_Mhz").val(); | |
|
267 | console.log(clock); | |
|
268 | console.log(multiplier); | |
|
269 | console.log(freq); | |
|
123 | 270 | |
|
124 | 271 | var mclock = clock*multiplier; |
|
125 | ||
|
272 | console.log(mclock); | |
|
273 | ||
|
126 | 274 | var freq_bin = freqDelta2Binary(mclock, freq); |
|
275 | ||
|
127 | 276 | console.log(freq_bin); |
|
128 | 277 | $("#id_delta_frequency").val(freq_bin); |
|
278 | ||
|
279 | document.getElementById("id_aux_deltabin").innerHTML = numToString(parseInt(freq_bin, 10), 2, 48).match(/.{1,4}/g).join(' '); | |
|
129 | 280 | } |
|
130 | 281 | |
|
131 | 282 | function updateFrequencyRamp() { |
@@ -145,7 +296,7 | |||
|
145 | 296 | console.log("Ingreso a updateBInaryFrequencyRamp"); |
|
146 | 297 | var clock = $("#id_clock").val(); |
|
147 | 298 | var multiplier = $("#id_multiplier").val(); |
|
148 |
var freq = $("#id_ramp_rate_clock_M |
|
|
299 | var freq = $("#id_ramp_rate_clock_Mhz").val(); | |
|
149 | 300 | |
|
150 | 301 | var mclock = clock*multiplier; |
|
151 | 302 | |
@@ -154,5 +305,159 | |||
|
154 | 305 | $("#id_ramp_rate_clock").val(freq_bin); |
|
155 | 306 | } |
|
156 | 307 | |
|
308 | function updateFrequencyMhzRamp() { | |
|
309 | console.log("Ingreso a updateFrequencyMhzRamp"); | |
|
310 | var step_us = $("#id_ramp_rate_clock_us").val(); | |
|
311 | ||
|
312 | var freq = us2Ramp(step_us); | |
|
313 | console.log(freq); | |
|
314 | $("#id_ramp_rate_clock_Mhz").val(freq); | |
|
315 | updateBinaryFrequencyRamp(); | |
|
316 | } | |
|
317 | ||
|
318 | function hidefA() { | |
|
319 | var checkbox = $("#id_chkbin_fA"); | |
|
320 | var freq_bin = $("#id_row_fAbin"); | |
|
321 | var val_freq = $("#id_frequencyA"); | |
|
322 | ||
|
323 | console.log("Ingreso a hidefA"); | |
|
324 | if (checkbox.is(':checked')) { | |
|
325 | freq_bin.show(); | |
|
326 | console.log(val_freq.val()); | |
|
327 | document.getElementById("id_aux_fAbin").innerHTML = numToString(parseInt(val_freq.val(), 10), 2, 48).match(/.{1,4}/g).join(' '); | |
|
328 | } | |
|
329 | else{ | |
|
330 | freq_bin.hide(); | |
|
331 | } | |
|
332 | } | |
|
333 | ||
|
334 | function hidefB() { | |
|
335 | var checkbox = $("#id_chkbin_fB"); | |
|
336 | var freq_bin = $("#id_row_fBbin"); | |
|
337 | var val_freq = $("#id_frequencyB"); | |
|
338 | ||
|
339 | console.log("Ingreso a hidefB"); | |
|
340 | if (checkbox.is(':checked')) { | |
|
341 | freq_bin.show(); | |
|
342 | console.log(val_freq.val()); | |
|
343 | document.getElementById("id_aux_fBbin").innerHTML = numToString(parseInt(val_freq.val(), 10), 2, 48).match(/.{1,4}/g).join(' '); | |
|
344 | } | |
|
345 | else{ | |
|
346 | freq_bin.hide(); | |
|
347 | } | |
|
348 | } | |
|
349 | ||
|
350 | function hidedf() { | |
|
351 | var checkbox = $("#id_chkbin_df"); | |
|
352 | var freq_bin = $("#id_row_dfbin"); | |
|
353 | var val_freq = $("#id_delta_frequency"); | |
|
354 | ||
|
355 | console.log("Ingreso a hidedf"); | |
|
356 | if (checkbox.is(':checked')) { | |
|
357 | freq_bin.show(); | |
|
358 | console.log(val_freq.val()); | |
|
359 | document.getElementById("id_aux_deltabin").innerHTML = numToString(parseInt(val_freq.val(), 10), 2, 48).match(/.{1,4}/g).join(' '); | |
|
360 | } | |
|
361 | else{ | |
|
362 | freq_bin.hide(); | |
|
363 | } | |
|
364 | } | |
|
365 | ||
|
366 | function hideramp() { | |
|
367 | var checkbox = $("#id_chkbin_ramp"); | |
|
368 | var freq_bin = $("#id_row_rampbin"); | |
|
369 | var val_freq = $("#id_ramp_rate_clock"); | |
|
370 | ||
|
371 | console.log("Ingreso a hideramp"); | |
|
372 | if (checkbox.is(':checked')) { | |
|
373 | freq_bin.show(); | |
|
374 | console.log(val_freq.val()); | |
|
375 | document.getElementById("id_aux_rampbin").innerHTML = numToString(parseInt(val_freq.val(), 10), 2, 20).match(/.{1,4}/g).join(' '); | |
|
376 | } | |
|
377 | else{ | |
|
378 | freq_bin.hide(); | |
|
379 | } | |
|
380 | } | |
|
381 | ||
|
382 | function hidephaseA() { | |
|
383 | var checkbox = $("#id_chkbin_phaseA"); | |
|
384 | var freq_bin = $("#id_row_phaseA"); | |
|
385 | var phase_degree = $("#id_phaseA_degrees"); | |
|
386 | ||
|
387 | console.log("Ingreso a hidephaseA"); | |
|
388 | if (checkbox.is(':checked')) { | |
|
389 | freq_bin.show(); | |
|
390 | console.log(phase_degree.val()); | |
|
391 | var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10); | |
|
392 | console.log(phase_degree_dec); | |
|
393 | document.getElementById("id_aux_phaseAdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' '); | |
|
394 | document.getElementById("id_aux_phaseAbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' '); | |
|
395 | ||
|
396 | } | |
|
397 | else{ | |
|
398 | freq_bin.hide(); | |
|
399 | } | |
|
400 | } | |
|
401 | ||
|
402 | function hidephaseB() { | |
|
403 | var checkbox = $("#id_chkbin_phaseB"); | |
|
404 | var freq_bin = $("#id_row_phaseB"); | |
|
405 | var phase_degree = $("#id_phaseB_degrees"); | |
|
406 | ||
|
407 | console.log("Ingreso a hidephaseB"); | |
|
408 | if (checkbox.is(':checked')) { | |
|
409 | freq_bin.show(); | |
|
410 | console.log(phase_degree.val()); | |
|
411 | var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10); | |
|
412 | console.log(phase_degree_dec); | |
|
413 | document.getElementById("id_aux_phaseBdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' '); | |
|
414 | document.getElementById("id_aux_phaseBbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' '); | |
|
415 | ||
|
416 | } | |
|
417 | else{ | |
|
418 | freq_bin.hide(); | |
|
419 | } | |
|
420 | } | |
|
421 | ||
|
422 | function updatephaseAbindec() { | |
|
423 | var freq_bin = $("#id_row_phaseA"); | |
|
424 | var phase_degree = $("#id_phaseA_degrees"); | |
|
425 | ||
|
426 | console.log("Ingreso a cupdatephaseAbindec"); | |
|
427 | console.log(phase_degree.val()); | |
|
428 | var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10); | |
|
429 | console.log(phase_degree_dec); | |
|
430 | document.getElementById("id_aux_phaseAdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' '); | |
|
431 | document.getElementById("id_aux_phaseAbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' '); | |
|
432 | ||
|
433 | } | |
|
434 | ||
|
435 | function updatephaseBbindec() { | |
|
436 | var freq_bin = $("#id_row_phaseB"); | |
|
437 | var phase_degree = $("#id_phaseB_degrees"); | |
|
438 | ||
|
439 | console.log("Ingreso a cupdatephaseBbindec"); | |
|
440 | console.log(phase_degree.val()); | |
|
441 | var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10); | |
|
442 | console.log(phase_degree_dec); | |
|
443 | document.getElementById("id_aux_phaseBdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' '); | |
|
444 | document.getElementById("id_aux_phaseBbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' '); | |
|
445 | ||
|
446 | } | |
|
447 | ||
|
448 | function padStart(string, length, char) { | |
|
449 | return length > 0 ? | |
|
450 | padStart(char + string, --length, char) : | |
|
451 | string; | |
|
452 | } | |
|
453 | ||
|
454 | function numToString(num, radix, length = num.length) { | |
|
455 | const numString = num.toString(radix); | |
|
456 | return numString.length === length ? | |
|
457 | numString : | |
|
458 | padStart(numString, length - numString.length, "0") | |
|
459 | } | |
|
460 | ||
|
461 | console.log(numToString(parseInt("37529996894754", 10), 2, 48)); | |
|
157 | 462 | </script> |
|
158 | 463 | {% endblock %} No newline at end of file |
@@ -21,9 +21,9 def dds_rest_conf(request, id_conf): | |||
|
21 | 21 | |
|
22 | 22 | kwargs['dev_conf'] = conf |
|
23 | 23 | kwargs['dev_conf_keys'] = [ |
|
24 | 'clock', | |
|
25 | 'multiplier', | |
|
26 | 'frequencyA_Mhz', | |
|
24 | 'clock', | |
|
25 | 'multiplier', | |
|
26 | 'frequencyA_Mhz', | |
|
27 | 27 | 'frequencyA', |
|
28 | 28 | 'frequencyB_Mhz', |
|
29 | 29 | 'frequencyB', |
@@ -71,10 +71,10 def dds_rest_conf_edit(request, id_conf): | |||
|
71 | 71 | ##ERRORS |
|
72 | 72 | |
|
73 | 73 | kwargs = {} |
|
74 | kwargs['id_dev'] = conf.id | |
|
75 | kwargs['form'] = form | |
|
76 | kwargs['title'] = 'Device Configuration' | |
|
74 | kwargs['id_dev'] = conf.id | |
|
75 | kwargs['form'] = form | |
|
76 | kwargs['title'] = 'Device Configuration' | |
|
77 | 77 | kwargs['suptitle'] = 'Edit' |
|
78 | kwargs['button'] = 'Save' | |
|
79 | ||
|
78 | kwargs['button'] = 'Save' | |
|
79 | kwargs['device_dds'] = 'dds_rest' | |
|
80 | 80 | return render(request, 'dds_rest_conf_edit.html', kwargs) |
@@ -1,5 +1,6 | |||
|
1 | 1 | <!DOCTYPE html> |
|
2 |
{% load static %} |
|
|
2 | {% load static %} | |
|
3 | {% load bootstrap4 %} | |
|
3 | 4 | <html lang="en"> |
|
4 | 5 | <head> |
|
5 | 6 | <meta charset="utf-8"> |
@@ -18,12 +19,12 | |||
|
18 | 19 | |
|
19 | 20 | |
|
20 | 21 | <!--link href="{% static '' %}css/bootstrap-{{theme}}.min.css" media="all" rel="stylesheet"--> |
|
21 | <!-- <link href="{% static 'css/bootcards-desktop.min.css' %}" media="all" rel="stylesheet"> --> | |
|
22 | <!-- <link href="{% static 'css/bootcards-desktop.min.css' %}" media="all" rel="stylesheet"> --> | |
|
22 | 23 | <link href="{% static 'css/font-awesome.min.css' %}" media="all" rel="stylesheet"--> |
|
23 | 24 | <!--link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"--> |
|
24 | 25 | |
|
25 | 26 | <!-- Bootcards CSS for iOS: > |
|
26 | <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootcards/1.0.0/css/bootcards-ios.min.css"> | |
|
27 | <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootcards/1.0.0/css/bootcards-ios.min.css"--> | |
|
27 | 28 | |
|
28 | 29 | <!-- Bootcards CSS for Android: > |
|
29 | 30 | <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootcards/1.0.0/css/bootcards-android.min.css"--> |
@@ -31,26 +32,24 | |||
|
31 | 32 | <!-- Bootcards CSS for desktop: > |
|
32 | 33 | <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootcards/1.0.0/css/bootcards-desktop.min.css"--> |
|
33 | 34 | |
|
34 | <style type="text/css"> | |
|
35 | .logo {padding-top: 5px; height: 50px} | |
|
36 | .clickable-row {cursor: pointer;} | |
|
37 | .col-no-padding { padding-left:0;} | |
|
38 | .gi-2x{font-size: 2em;} | |
|
39 | .gi-3x{font-size: 3em;} | |
|
40 | .gi-4x{font-size: 4em;} | |
|
41 | .gi-5x{font-size: 5em;} | |
|
42 | </style> | |
|
43 |
|
|
|
35 | <style type="text/css"> | |
|
36 | .logo {padding-top: 5px; height: 50px} | |
|
37 | .clickable-row {cursor: pointer;} | |
|
38 | .col-no-padding { padding-left:0;} | |
|
39 | .gi-2x{font-size: 2em;} | |
|
40 | .gi-3x{font-size: 3em;} | |
|
41 | .gi-4x{font-size: 4em;} | |
|
42 | .gi-5x{font-size: 5em;} | |
|
43 | </style> | |
|
44 | {% block extra-head %}{% endblock %} | |
|
44 | 45 | </head> |
|
45 | <body> | |
|
46 | ||
|
47 | 46 | |
|
47 | <body> | |
|
48 | 48 | |
|
49 | 49 | {% include "header_igp.html" %} |
|
50 | 50 | |
|
51 | 51 | <div style="clear: both;"></div> |
|
52 | 52 | |
|
53 | ||
|
54 | 53 | <div class="container"> |
|
55 | 54 | <div id="page" class="row" style="min-height:600px"> |
|
56 | 55 | |
@@ -74,24 +73,25 | |||
|
74 | 73 | {% else %} |
|
75 | 74 | <div class="col-md-9 col-xs-12" role="main"> |
|
76 | 75 | {% endif %} |
|
77 | <div class="page-header"> | |
|
78 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> | |
|
79 | </div> | |
|
80 | {% block messages %} | |
|
81 |
|
|
|
82 |
|
|
|
83 | <div class="alert alert-{% if message.tags %}{% if 'error' in message.tags %}danger{% else %}{{ message.tags }}{% endif %}{% else %}info{% endif %} alert-dismissible" role="alert"> | |
|
84 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
|
85 | <strong>{{message.tags|title}}!</strong> {{ message }} | |
|
86 | </div> | |
|
87 |
|
|
|
88 |
{% end |
|
|
89 |
{% end |
|
|
76 | ||
|
77 | <div class="page-header"> | |
|
78 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> | |
|
79 | </div> | |
|
80 | {% block messages %} | |
|
81 | {% if messages %} | |
|
82 | {% for message in messages %} | |
|
83 | <div class="alert alert-{% if message.tags %}{% if 'error' in message.tags %}danger{% else %}{{ message.tags }}{% endif %}{% else %}info{% endif %} alert-dismissible" role="alert"> | |
|
84 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
|
85 | <strong>{{message.tags|title}}!</strong> {{ message }} | |
|
86 | </div> | |
|
87 | {% endfor %} | |
|
88 | {% endif %} | |
|
89 | {% endblock %} | |
|
90 | 90 | |
|
91 | 91 | {% block content %} |
|
92 | 92 | {% endblock %} |
|
93 | 93 | |
|
94 |
|
|
|
94 | </div> | |
|
95 | 95 | |
|
96 | 96 | |
|
97 | 97 | </div><!--/row--> |
@@ -13,7 +13,14 | |||
|
13 | 13 | <form class="form" method="post" action="{{action}}"> |
|
14 | 14 | {% endif %} |
|
15 | 15 | {% csrf_token %} |
|
16 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
16 | ||
|
17 | {% if device_dds == 'dds_rest' %} | |
|
18 | {% block dds_rest%} | |
|
19 | {% endblock %} | |
|
20 | {% else %} | |
|
21 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
22 | {% endif %} | |
|
23 | ||
|
17 | 24 | <div style="clear: both;"></div> |
|
18 | 25 | <br> |
|
19 | 26 | {% if extra_button %} |
@@ -27,7 +34,7 | |||
|
27 | 34 | <button type="submit" class="btn btn-primary">{{button}}</button> |
|
28 | 35 | </div> |
|
29 | 36 | {% endif %} |
|
30 | </form> | |
|
37 | </form> | |
|
31 | 38 | {% endblock %} |
|
32 | 39 | |
|
33 | 40 | {% block sidebar%} |
@@ -34,4 +34,11 function freqRamp2Binary(mclock, frequency) { | |||
|
34 | 34 | |
|
35 | 35 | var freq_bin = parseInt(mclock/frequency-1); |
|
36 | 36 | return freq_bin; |
|
37 | } No newline at end of file | |
|
37 | } | |
|
38 | ||
|
39 | function us2Ramp(step_us) { | |
|
40 | //periodo_delpaso = sysclockperiod x (N+1) | |
|
41 | // freqsys/(N+1)=freq_ddelpaso=1/step | |
|
42 | var freq = (1.0/(step_us)); | |
|
43 | return freq; | |
|
44 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now