##// END OF EJS Templates
Actualizacion de la app RC a python3 y django 2, antes del merge con cambios
gonzalesluisfrancisco -
r341:cb29d2ed7f9e merge
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -0,0 +1,463
1 {% extends "dev_conf_edit.html" %}
2 {% load bootstrap4 %}
3 {% load static %}
4 {% load main_tags %}
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
119 {% block extra-js%}
120 <script src="{% static 'js/dds_conversion.js' %}"></script>
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 });
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
152 $("#id_clock").on('change', function() {
153 updateFrequencies();
154 });
155
156 $("#id_multiplier").on('change', function() {
157 updateFrequencies();
158 });
159
160 $("#id_frequencyA_Mhz").on('change', function() {
161 updateBinaryFrequencies();
162 });
163
164 $("#id_frequencyA").on('change', function() {
165 updateFrequencies();
166 });
167
168 $("#id_frequencyB_Mhz").on('change', function() {
169 updateBinaryFrequencies();
170 });
171
172 $("#id_frequencyB").on('change', function() {
173 updateFrequencies();
174 });
175
176 $("#id_delta_frequency").on('change', function() {
177 updateFrequencyDelta();
178 });
179
180 $("#id_delta_frequency_Mhz").on('change', function() {
181 updateBinaryFrequencyDelta();
182 });
183
184 $("#id_ramp_rate_clock").on('change', function() {
185 updateFrequencyRamp();
186 });
187
188 $("#id_ramp_rate_clock_us").on('change', function() {
189 updateFrequencyMhzRamp();
190 });
191
192 $("#id_ramp_rate_clock_Mhz").on('change', function() {
193 updateBinaryFrequencyRamp();
194 });
195
196 $("#id_phaseA_degrees").on('change', function() {
197 updatephaseAbindec();
198 });
199
200 $("#id_phaseB_degrees").on('change', function() {
201 updatephaseBbindec();
202 });
203
204 function updateBinaryFrequencies() {
205
206 var clock = $("#id_clock").val();
207 var multiplier = $("#id_multiplier").val();
208 var freq = $("#id_frequencyA_Mhz").val();
209 var freq_mod = $("#id_frequencyB_Mhz").val();
210
211 var mclock = clock*multiplier;
212
213 var freq_bin = freq2Binary(mclock, freq);
214 var freq_mod_bin = freq2Binary(mclock, freq_mod);
215
216 $("#id_frequencyA").val(freq_bin);
217 $("#id_frequencyB").val(freq_mod_bin);
218
219 freq = binary2Freq(mclock, freq_bin);
220 freq_mod = binary2Freq(mclock, freq_mod_bin);
221
222 $("#id_frequencyA_Mhz").val(freq);
223 $("#id_frequencyB_Mhz").val(freq_mod);
224
225 }
226
227 function updateFrequencies() {
228 console.log("Ingreso a updateFrequencies");
229 var clock = $("#id_clock").val();
230 var multiplier = $("#id_multiplier").val();
231 var freq_bin = $("#id_frequencyA").val();
232 var freq_mod_bin = $("#id_frequencyB").val();
233 var freqdelta_bin = $("#id_delta_frequency").val();
234 var freqramp_bin = $("#id_ramp_rate_clock").val();
235
236 var mclock = clock*multiplier;
237
238 var freq = binary2Freq(mclock, freq_bin);
239 var freq_mod = binary2Freq(mclock, freq_mod_bin);
240 var freqdelta = binary2FreqDelta(mclock, freqdelta_bin);
241 var freq_ramp = binary2Ramp(mclock, freqramp_bin);
242
243 $("#id_frequencyA_Mhz").val(freq);
244 $("#id_frequencyB_Mhz").val(freq_mod);
245 $("#id_delta_frequency_Mhz").val(freqdelta);
246 $("#id_ramp_rate_clock_Mhz").val(freq_ramp);
247 }
248
249 function updateFrequencyDelta() {
250 console.log("Ingreso a updateFrequencyDelta");
251 var clock = $("#id_clock").val();
252 var multiplier = $("#id_multiplier").val();
253 var freq_bin = $("#id_delta_frequency").val();
254
255 var mclock = clock*multiplier;
256
257 var freq = binary2FreqDelta(mclock, freq_bin);
258 console.log(freq);
259 $("#id_delta_frequency_Mhz").val(freq);
260 }
261
262 function updateBinaryFrequencyDelta() {
263 console.log("Ingreso a updateBInaryFrequencyDelta");
264 var clock = $("#id_clock").val();
265 var multiplier = $("#id_multiplier").val();
266 var freq = $("#id_delta_frequency_Mhz").val();
267 console.log(clock);
268 console.log(multiplier);
269 console.log(freq);
270
271 var mclock = clock*multiplier;
272 console.log(mclock);
273
274 var freq_bin = freqDelta2Binary(mclock, freq);
275
276 console.log(freq_bin);
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(' ');
280 }
281
282 function updateFrequencyRamp() {
283 console.log("Ingreso a updateFrequencyRamp");
284 var clock = $("#id_clock").val();
285 var multiplier = $("#id_multiplier").val();
286 var freq_bin = $("#id_ramp_rate_clock").val();
287
288 var mclock = clock*multiplier;
289
290 var freq = binary2Ramp(mclock, freq_bin);
291 console.log(freq);
292 $("#id_ramp_rate_clock_Mhz").val(freq);
293 }
294
295 function updateBinaryFrequencyRamp() {
296 console.log("Ingreso a updateBInaryFrequencyRamp");
297 var clock = $("#id_clock").val();
298 var multiplier = $("#id_multiplier").val();
299 var freq = $("#id_ramp_rate_clock_Mhz").val();
300
301 var mclock = clock*multiplier;
302
303 var freq_bin = freqRamp2Binary(mclock, freq);
304 console.log(freq_bin);
305 $("#id_ramp_rate_clock").val(freq_bin);
306 }
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));
462 </script>
463 {% endblock %} No newline at end of file
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
@@ -8,5 +8,5 DB_PASSWORD=docker
8 PGDATA=/var/lib/postgresql/data
8 PGDATA=/var/lib/postgresql/data
9 LC_ALL=C.UTF-8
9 LC_ALL=C.UTF-8
10 TZ=America/Lima
10 TZ=America/Lima
11 DOCKER_DATA=/Volumes/dockers/radarsys/
11 DOCKER_DATA=/data/dockers/radarsys/
12 LOCAL_IP=192.168.1.128
12 LOCAL_IP=192.168.1.128
@@ -365,7 +365,7 class ABSConfiguration(Configuration):
365 It needs 'module_conf' function
365 It needs 'module_conf' function
366 """
366 """
367 print("Write")
367 print("Write")
368 beams = ABSBeam.objects.filter(abs_conf=self)
368 beams = ABSBeam.objects.filter(abs_conf=self)
369 nbeams = len(beams)
369 nbeams = len(beams)
370
370
371 # Se manda a cero RC para poder realizar cambio de beam
371 # Se manda a cero RC para poder realizar cambio de beam
@@ -479,7 +479,7 class ABSConfiguration(Configuration):
479 self.module_status = ''.join(status)
479 self.module_status = ''.join(status)
480 self.save()
480 self.save()
481 print('Estatus salvado')
481 print('Estatus salvado')
482 conf_active = ABSActive.objects.get_or_create(pk=1)
482 conf_active, __ = ABSActive.objects.get_or_create(pk=1)
483 conf_active.conf = self
483 conf_active.conf = self
484 conf_active.save()
484 conf_active.save()
485 return True
485 return True
@@ -121,46 +121,74 class DDSRestConfiguration(Configuration):
121
121
122 def reset_device(self):
122 def reset_device(self):
123
123
124 answer = api.reset(ip = self.device.ip_address,
124 try:
125 port = self.device.port_address)
125 payload = self.request('reset', 'post')
126
126 if payload['reset']=='ok':
127 if answer[0] != "1":
127 self.message = 'DDS REST restarted OK'
128 self.message = 'DDS - {}'.format(answer[2:])
128 self.device.status = 2
129 return 0
129 self.device.save()
130 else:
131 self.message = 'DDS REST restart fail'
132 self.device.status = 4
133 self.device.save()
134 except Exception as e:
135 self.message = 'DDS REST reset: {}'.format(str(e))
136 return False
130
137
131 self.message = 'DDS - {}'.format(answer[2:])
138 return True
132 return 1
133
139
134 def stop_device(self):
140 def stop_device(self):
135
141
136 try:
142 try:
137 answer = api.disable_rf(ip = self.device.ip_address,
143 payload = self.request('stop', 'post',data=json.dumps({'_rf_enable':0}))
138 port = self.device.port_address)
144 self.message = 'DDS REST: {}'.format(payload['stop'])
139
145 if payload['stop']=='ok':
140 return self.status_device()
146 self.device.status = 2
141
147 self.device.save()
148 else:
149 self.device.status = 4
150 self.device.save()
151 return False
142 except Exception as e:
152 except Exception as e:
143 self.message = str(e)
153 if 'No route to host' not in str(e):
154 self.device.status = 4
155 else:
156 self.device.status = 0
157 self.message = 'DDS REST stop: {}'.format(str(e))
158 self.device.save()
144 return False
159 return False
145
160
161 return True
162
146 def start_device(self):
163 def start_device(self):
147
164
148 try:
165 try:
149 answer = api.enable_rf(ip = self.device.ip_address,
166 payload = self.request('start', 'post',data=json.dumps({'_rf_enable':1}))
150 port = self.device.port_address)
167 self.message = 'DDS REST start: {}'.format(payload['start'])
151
168 if payload['start']=='ok':
152 return self.status_device()
169 self.device.status = 3
153
170 self.device.save()
171 else:
172 self.device.status = 2
173 self.device.save()
174 return False
154 except Exception as e:
175 except Exception as e:
155 self.message = str(e)
176 if 'No route to host' not in str(e):
177 self.device.status = 4
178 else:
179 self.device.status = 0
180 self.message = 'DDS REST start: {}'.format(str(e))
181 self.device.save()
156 return False
182 return False
157
183
184 return True
185
158 def read_device(self):
186 def read_device(self):
159
187
160 parms = api.read_config(ip = self.device.ip_address,
188 parms = self.request('read')
161 port = self.device.port_address)
189 print(parms)
162 if not parms:
190 if not parms:
163 self.message = "Could not read DDS parameters from this device"
191 self.message = "Could not read DDS REST parameters from this device"
164 return parms
192 return parms
165
193
166 self.message = ""
194 self.message = ""
@@ -211,7 +239,8 class DDSRestConfiguration(Configuration):
211 print(update_clock)
239 print(update_clock)
212 ramp_rate_clock = self.ramp_rate_clock or 0
240 ramp_rate_clock = self.ramp_rate_clock or 0
213 print(ramp_rate_clock)
241 print(ramp_rate_clock)
214
242 osrr = 0
243 qdac = 0
215 control = self.arma_control(clock,multiplier,modulation)
244 control = self.arma_control(clock,multiplier,modulation)
216 phase1 = self.conv_phase(phaseA_degrees)
245 phase1 = self.conv_phase(phaseA_degrees)
217 phase2 = self.conv_phase(phaseB_degrees)
246 phase2 = self.conv_phase(phaseB_degrees)
@@ -227,7 +256,9 class DDSRestConfiguration(Configuration):
227 'amplitudeI': (b64encode((amplitudeI).to_bytes(2,'little'))).decode("UTF-8"),\
256 'amplitudeI': (b64encode((amplitudeI).to_bytes(2,'little'))).decode("UTF-8"),\
228 'amplitudeQ': (b64encode((amplitudeQ).to_bytes(2,'little'))).decode("UTF-8"),\
257 'amplitudeQ': (b64encode((amplitudeQ).to_bytes(2,'little'))).decode("UTF-8"),\
229 '_phase1': (b64encode((phase1))).decode("UTF-8"),\
258 '_phase1': (b64encode((phase1))).decode("UTF-8"),\
230 '_phase2': (b64encode((phase2))).decode("UTF-8")
259 '_phase2': (b64encode((phase2))).decode("UTF-8"),\
260 'osrr': (b64encode((osrr).to_bytes(1,'little'))).decode("UTF-8"),\
261 'qdac': (b64encode((qdac).to_bytes(2,'little'))).decode("UTF-8")
231 }
262 }
232 return cadena_json
263 return cadena_json
233
264
@@ -110,8 +110,37
110 {% bootstrap_field form.modulation layout='horizontal' size='medium' %}
110 {% bootstrap_field form.modulation layout='horizontal' size='medium' %}
111 {% bootstrap_field form.amplitude_enabled layout='horizontal' size='medium' %}
111 {% bootstrap_field form.amplitude_enabled layout='horizontal' size='medium' %}
112
112
113 <div style="display: flex; justify-content: flex-end">
114 <div class="form-check">
115 <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_amplitudeI" value="" >Mostrar Decimal</label>
116 </div>
117 </div>
113 {% bootstrap_field form.amplitudeI layout='horizontal' size='medium' %}
118 {% bootstrap_field form.amplitudeI layout='horizontal' size='medium' %}
119 <div id='id_row_amplitudeI'>
120 <div style="display: flex; justify-content: flex-end">
121 <small type="text" id="id_aux_amplitudeIdec" class="form-text text-muted">35 </small>
122 </div>
123 <div style="display: flex; justify-content: flex-end">
124 <small type="text" id="id_aux_amplitudeIbin" class="form-text text-muted">0000 0000 0010 </small>
125 </div>
126 <br>
127 </div>
128
129 <div style="display: flex; justify-content: flex-end">
130 <div class="form-check">
131 <label class="form-check-label" ><input type="checkbox" class="form-check-input" id="id_chkbin_amplitudeQ" value="" >Mostrar Decimal</label>
132 </div>
133 </div>
114 {% bootstrap_field form.amplitudeQ layout='horizontal' size='medium' %}
134 {% bootstrap_field form.amplitudeQ layout='horizontal' size='medium' %}
135 <div id='id_row_amplitudeQ'>
136 <div style="display: flex; justify-content: flex-end">
137 <small type="text" id="id_aux_amplitudeQdec" class="form-text text-muted">40 </small>
138 </div>
139 <div style="display: flex; justify-content: flex-end">
140 <small type="text" id="id_aux_amplitudeQbin" class="form-text text-muted">0000 1010 1000 </small>
141 </div>
142 <br>
143 </div>
115
144
116
145
117 {% endblock %}
146 {% endblock %}
@@ -148,6 +177,16
148 $("#id_chkbin_phaseB").on('change', function() {
177 $("#id_chkbin_phaseB").on('change', function() {
149 hidephaseB();
178 hidephaseB();
150 });
179 });
180
181 $("#id_row_amplitudeI").hide();
182 $("#id_chkbin_amplitudeI").on('change', function() {
183 hideamplitudeI();
184 });
185
186 $("#id_row_amplitudeQ").hide();
187 $("#id_chkbin_amplitudeQ").on('change', function() {
188 hideamplitudeQ();
189 });
151
190
152 $("#id_clock").on('change', function() {
191 $("#id_clock").on('change', function() {
153 updateFrequencies();
192 updateFrequencies();
@@ -201,6 +240,14
201 updatephaseBbindec();
240 updatephaseBbindec();
202 });
241 });
203
242
243 $("#id_amplitudeI").on('change', function() {
244 updateamplitudeIindec();
245 });
246
247 $("#id_amplitudeQ").on('change', function() {
248 updateamplitudeQindec();
249 });
250
204 function updateBinaryFrequencies() {
251 function updateBinaryFrequencies() {
205
252
206 var clock = $("#id_clock").val();
253 var clock = $("#id_clock").val();
@@ -388,7 +435,7
388 if (checkbox.is(':checked')) {
435 if (checkbox.is(':checked')) {
389 freq_bin.show();
436 freq_bin.show();
390 console.log(phase_degree.val());
437 console.log(phase_degree.val());
391 var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10);
438 var phase_degree_dec = parseInt(phase_degree.val()*((2**14-1)/360.0),10);
392 console.log(phase_degree_dec);
439 console.log(phase_degree_dec);
393 document.getElementById("id_aux_phaseAdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' ');
440 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(' ');
441 document.getElementById("id_aux_phaseAbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' ');
@@ -408,7 +455,7
408 if (checkbox.is(':checked')) {
455 if (checkbox.is(':checked')) {
409 freq_bin.show();
456 freq_bin.show();
410 console.log(phase_degree.val());
457 console.log(phase_degree.val());
411 var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10);
458 var phase_degree_dec = parseInt(phase_degree.val()*((2**14-1)/360.0),10);
412 console.log(phase_degree_dec);
459 console.log(phase_degree_dec);
413 document.getElementById("id_aux_phaseBdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' ');
460 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(' ');
461 document.getElementById("id_aux_phaseBbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' ');
@@ -419,13 +466,53
419 }
466 }
420 }
467 }
421
468
469 function hideamplitudeI() {
470 var checkbox = $("#id_chkbin_amplitudeI");
471 var freq_bin = $("#id_row_amplitudeI");
472 var phase_degree = $("#id_amplitudeI");
473
474 console.log("Ingreso a hideamplitudeI");
475 if (checkbox.is(':checked')) {
476 freq_bin.show();
477 console.log(phase_degree.val());
478 var phase_degree_dec = parseInt(phase_degree.val()*((2**12-1)/100.0),10);
479 console.log(phase_degree_dec);
480 document.getElementById("id_aux_amplitudeIdec").innerHTML = numToString(phase_degree_dec, 10, 4).match(/.{1,4}/g).join(' ');
481 document.getElementById("id_aux_amplitudeIbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 12).match(/.{1,4}/g).join(' ');
482
483 }
484 else{
485 freq_bin.hide();
486 }
487 }
488
489 function hideamplitudeQ() {
490 var checkbox = $("#id_chkbin_amplitudeQ");
491 var freq_bin = $("#id_row_amplitudeQ");
492 var phase_degree = $("#id_amplitudeQ");
493
494 console.log("Ingreso a hideamplitudeQ");
495 if (checkbox.is(':checked')) {
496 freq_bin.show();
497 console.log(phase_degree.val());
498 var phase_degree_dec = parseInt(phase_degree.val()*((2**12-1)/100.0),10);
499 console.log(phase_degree_dec);
500 document.getElementById("id_aux_amplitudeQdec").innerHTML = numToString(phase_degree_dec, 10, 4).match(/.{1,4}/g).join(' ');
501 document.getElementById("id_aux_amplitudeQbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 12).match(/.{1,4}/g).join(' ');
502
503 }
504 else{
505 freq_bin.hide();
506 }
507 }
508
422 function updatephaseAbindec() {
509 function updatephaseAbindec() {
423 var freq_bin = $("#id_row_phaseA");
510 var freq_bin = $("#id_row_phaseA");
424 var phase_degree = $("#id_phaseA_degrees");
511 var phase_degree = $("#id_phaseA_degrees");
425
512
426 console.log("Ingreso a cupdatephaseAbindec");
513 console.log("Ingreso a updatephaseAbindec");
427 console.log(phase_degree.val());
514 console.log(phase_degree.val());
428 var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10);
515 var phase_degree_dec = parseInt(phase_degree.val()*((2**14-1)/360.0),10);
429 console.log(phase_degree_dec);
516 console.log(phase_degree_dec);
430 document.getElementById("id_aux_phaseAdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' ');
517 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(' ');
518 document.getElementById("id_aux_phaseAbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' ');
@@ -436,15 +523,41
436 var freq_bin = $("#id_row_phaseB");
523 var freq_bin = $("#id_row_phaseB");
437 var phase_degree = $("#id_phaseB_degrees");
524 var phase_degree = $("#id_phaseB_degrees");
438
525
439 console.log("Ingreso a cupdatephaseBbindec");
526 console.log("Ingreso a updatephaseBbindec");
440 console.log(phase_degree.val());
527 console.log(phase_degree.val());
441 var phase_degree_dec = parseInt(phase_degree.val()*((2**14)/360.0),10);
528 var phase_degree_dec = parseInt(phase_degree.val()*((2**14-1)/360.0),10);
442 console.log(phase_degree_dec);
529 console.log(phase_degree_dec);
443 document.getElementById("id_aux_phaseBdec").innerHTML = numToString(phase_degree_dec, 10, 5).match(/.{1,4}/g).join(' ');
530 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(' ');
531 document.getElementById("id_aux_phaseBbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 14).match(/.{1,4}/g).join(' ');
445
532
446 }
533 }
447
534
535 // Para ingresar amplitud CH1 como porcentaje y devuelve en decimal y binario
536 function updateamplitudeIindec() {
537 var freq_bin = $("#id_row_amplitudeI");
538 var phase_degree = $("#id_amplitudeI");
539
540 console.log("Ingreso a updateamplitudeIindec");
541 console.log(phase_degree.val());
542 var phase_degree_dec = parseInt(phase_degree.val()*((2**12-1)/100.0),10);
543 console.log(phase_degree_dec);
544 document.getElementById("id_aux_amplitudeIdec").innerHTML = numToString(phase_degree_dec, 10, 4).match(/.{1,4}/g).join(' ');
545 document.getElementById("id_aux_amplitudeIbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 12).match(/.{1,4}/g).join(' ');
546 }
547
548 // Para ingresar amplitud CH1 como porcentaje y devuelve en decimal y binario
549 function updateamplitudeQindec() {
550 var freq_bin = $("#id_row_amplitudeQ");
551 var phase_degree = $("#id_amplitudeQ");
552
553 console.log("Ingreso a updateamplitudeQindec");
554 console.log(phase_degree.val());
555 var phase_degree_dec = parseInt(phase_degree.val()*((2**12-1)/100.0),10);
556 console.log(phase_degree_dec);
557 document.getElementById("id_aux_amplitudeQdec").innerHTML = numToString(phase_degree_dec, 10, 4).match(/.{1,4}/g).join(' ');
558 document.getElementById("id_aux_amplitudeQbin").innerHTML = numToString(parseInt(phase_degree_dec, 10), 2, 12).match(/.{1,4}/g).join(' ');
559 }
560
448 function padStart(string, length, char) {
561 function padStart(string, length, char) {
449 return length > 0 ?
562 return length > 0 ?
450 padStart(char + string, --length, char) :
563 padStart(char + string, --length, char) :
@@ -89,6 +89,14
89 },
89 },
90 {
90 {
91 "fields": {
91 "fields": {
92 "name": "dds_rest",
93 "description": ""
94 },
95 "model": "main.devicetype",
96 "pk": 6
97 },
98 {
99 "fields": {
92 "name": "Operator"
100 "name": "Operator"
93 },
101 },
94 "model": "auth.group",
102 "model": "auth.group",
@@ -115,6 +115,82 a:link { -webkit-tap-highlight-color: var(--tertiary); }
115 font-size: 0.8rem;
115 font-size: 0.8rem;
116 }
116 }
117
117
118 /*------------------------------------------------*/
119
120 .panel {
121 margin-bottom: 20px;
122 background-color: #fafafa;
123 border: 1px solid transparent;
124 border-radius: 4px;
125 -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
126 box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
127 }
128 .panel-body {
129 padding: 15px;
130 }
131 .panel-heading {
132 padding: 10px 15px;
133 border-bottom: 1px solid transparent;
134 border-top-left-radius: 3px;
135 border-top-right-radius: 3px;
136 }
137
138 .panel-title {
139 margin-top: 0;
140 margin-bottom: 0;
141
142
143 }
144
145 .panel-footer {
146 padding: 10px 15px;
147 background-color: #fafafa;
148 border-top: 1px solid #fafafa;
149 border-bottom-right-radius: 3px;
150 border-bottom-left-radius: 3px;
151 }
152
153 .panel-group {
154 margin-bottom: 20px;
155 }
156 .panel-group .panel {
157 margin-bottom: 0;
158 border-radius: 4px;
159 }
160 .panel-group .panel + .panel {
161 margin-top: 5px;
162 }
163 .panel-group .panel-heading {
164 border-bottom: 0;
165 }
166 .panel-group .panel-heading + .panel-collapse > .panel-body,
167
168 .panel-group .panel-footer {
169 border-top: 0;
170 }
171 .panel-group .panel-footer + .panel-collapse .panel-body {
172 border-bottom: 1px solid #fafafa;
173 }
174 .panel-default {
175 border-color: #fafafa;
176 }
177 .panel-default > .panel-heading {
178
179 background-color: #fafafa;
180 border-color: #fafafa;
181 }
182 .panel-default > .panel-heading + .panel-collapse > .panel-body {
183 border-top-color: #fafafa;
184 }
185 .panel-default > .panel-heading .badge {
186 color: #fafafa;
187 background-color: #fafafa;
188 }
189 .panel-default > .panel-footer + .panel-collapse > .panel-body {
190 border-bottom-color: #fafafa;
191 }
192
193
118 /* cards */
194 /* cards */
119
195
120 @media (min-width: 480px) {
196 @media (min-width: 480px) {
@@ -139,4 +215,5 a:link { -webkit-tap-highlight-color: var(--tertiary); }
139 .card-columns {
215 .card-columns {
140 column-count: 5;
216 column-count: 5;
141 }
217 }
142 } No newline at end of file
218 }
219
@@ -41,6 +41,7
41 .gi-4x{font-size: 4em;}
41 .gi-4x{font-size: 4em;}
42 .gi-5x{font-size: 5em;}
42 .gi-5x{font-size: 5em;}
43 </style>
43 </style>
44 <script src="{% static 'js/jquery.min.js' %}"></script>
44 {% block extra-head %}{% endblock %}
45 {% block extra-head %}{% endblock %}
45 </head>
46 </head>
46
47
@@ -291,6 +291,7 class RCLineViewForm(forms.Form):
291 class RCLineEditForm(forms.ModelForm):
291 class RCLineEditForm(forms.ModelForm):
292
292
293 def __init__(self, *args, **kwargs):
293 def __init__(self, *args, **kwargs):
294 print("RCLineEditForm")
294
295
295 extra_fields = kwargs.pop('extra_fields', [])
296 extra_fields = kwargs.pop('extra_fields', [])
296 conf = kwargs.pop('conf', False)
297 conf = kwargs.pop('conf', False)
@@ -320,9 +321,16 class RCLineEditForm(forms.ModelForm):
320 all_choice = True
321 all_choice = True
321 else:
322 else:
322 all_choice = False
323 all_choice = False
323 self.fields[label] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'], conf.id, all_choice=all_choice),
324 #print("'name':'%s|%s|%s'" % (count, line.id, label))
325 aux_name = '%s|%s|%s' % (count, line.id, label)
326 print(aux_name)
327 print(label)
328
329 self.fields[aux_name] = forms.ChoiceField(choices=create_choices_from_model(params[label]['model'], conf.id, all_choice=all_choice),
324 initial=value,
330 initial=value,
325 widget=forms.Select(attrs={'name':'%s|%s|%s' % (count, line.id, label)}),
331 label=label,
332 widget=forms.Select(attrs={'name':'%s|%s|%s' % (count, line.id, label)}), #No trabaja con attrs esta versión de django 2.0 hacia adelante
333 #widget=forms.Select(attrs={'name':'HOLA'}), #No trabaja con attrs esta versión de django 2.0 hacia adelante
326 help_text=help_text)
334 help_text=help_text)
327
335
328 else:
336 else:
@@ -353,6 +361,7 class RCLineEditForm(forms.ModelForm):
353 class RCSubLineEditForm(forms.Form):
361 class RCSubLineEditForm(forms.Form):
354
362
355 def __init__(self, *args, **kwargs):
363 def __init__(self, *args, **kwargs):
364 print("RCSubLineEditForm")
356 extra_fields = kwargs.pop('extra_fields')
365 extra_fields = kwargs.pop('extra_fields')
357 count = kwargs.pop('count')
366 count = kwargs.pop('count')
358 line = kwargs.pop('line')
367 line = kwargs.pop('line')
@@ -360,7 +369,7 class RCSubLineEditForm(forms.Form):
360 for label, value in extra_fields.items():
369 for label, value in extra_fields.items():
361 self.fields[label] = forms.CharField(initial=value,
370 self.fields[label] = forms.CharField(initial=value,
362 widget=forms.TextInput(attrs={'name':'%s|%s|%s' % (count, line, label)}))
371 widget=forms.TextInput(attrs={'name':'%s|%s|%s' % (count, line, label)}))
363
372
364
373
365 class RCImportForm(forms.Form):
374 class RCImportForm(forms.Form):
366
375
@@ -158,6 +158,7 class RCConfiguration(Configuration):
158 else:
158 else:
159 data = Params(params).get_conf(dtype='rc')
159 data = Params(params).get_conf(dtype='rc')
160
160
161 #print(data)
161 # self.name = data['name']
162 # self.name = data['name']
162 self.ipp = data['ipp']
163 self.ipp = data['ipp']
163 self.ntx = data['ntx']
164 self.ntx = data['ntx']
@@ -172,6 +173,8 class RCConfiguration(Configuration):
172 self.save()
173 self.save()
173 self.clean_lines()
174 self.clean_lines()
174
175
176 #print(params)
177
175 positions = {'tx':0, 'tr':0}
178 positions = {'tx':0, 'tr':0}
176 for i, id in enumerate(data['lines']):
179 for i, id in enumerate(data['lines']):
177 line_data = params['lines']['byId'][id]
180 line_data = params['lines']['byId'][id]
@@ -210,8 +213,9 class RCConfiguration(Configuration):
210 params=json.dumps(ref_line['params'])
213 params=json.dumps(ref_line['params'])
211 ).pk
214 ).pk
212 line.params = json.dumps(line_params)
215 line.params = json.dumps(line_params)
216 print(line.params)
213 line.save()
217 line.save()
214
218 print("Fin de dict to param")
215
219
216 def get_delays(self):
220 def get_delays(self):
217
221
@@ -384,7 +388,7 class RCConfiguration(Configuration):
384 ax.set_yticklabels(labels)
388 ax.set_yticklabels(labels)
385 ax.set_xlabel = 'Units'
389 ax.set_xlabel = 'Units'
386 plot = to_bokeh(fig, use_pandas=False)
390 plot = to_bokeh(fig, use_pandas=False)
387 plot.tools = [PanTool(dimensions=['width']), WheelZoomTool(dimensions=['width']), ResetTool(), SaveTool()]
391 plot.tools = [PanTool(dimensions="width"), WheelZoomTool(dimensions="width"), ResetTool(), SaveTool()]
388 plot.toolbar_location="above"
392 plot.toolbar_location="above"
389
393
390 return components(plot, CDN)
394 return components(plot, CDN)
@@ -408,8 +412,8 class RCConfiguration(Configuration):
408 ("IPP", "@ipp"),
412 ("IPP", "@ipp"),
409 ("X", "@left")])
413 ("X", "@left")])
410
414
411 tools = [PanTool(dimensions=['width']),
415 tools = [PanTool(dimensions="width"),
412 WheelZoomTool(dimensions=['width']),
416 WheelZoomTool(dimensions="width"),
413 hover, SaveTool()]
417 hover, SaveTool()]
414
418
415 plot = figure(width=1000,
419 plot = figure(width=1000,
@@ -777,10 +781,11 class RCLine(models.Model):
777 ipp_u = int(ipp*km2unit)
781 ipp_u = int(ipp*km2unit)
778 total = ipp_u*ntx if self.rc_configuration.total_units==0 else self.rc_configuration.total_units
782 total = ipp_u*ntx if self.rc_configuration.total_units==0 else self.rc_configuration.total_units
779 y = []
783 y = []
780
784
781 if self.line_type.name=='tr':
785 if self.line_type.name=='tr':
782 tr_params = json.loads(self.params)
786 tr_params = json.loads(self.params)
783
787 #print(tr_params)
788 #print(tr_params['TX_ref'])
784 if tr_params['TX_ref'] in ('0', 0):
789 if tr_params['TX_ref'] in ('0', 0):
785 txs = self.get_lines(line_type__name='tx')
790 txs = self.get_lines(line_type__name='tx')
786 else:
791 else:
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now