@@ -35,7 +35,7 | |||||
35 |
|
35 | |||
36 | {% endif %} |
|
36 | {% endif %} | |
37 |
|
37 | |||
38 |
{% if d |
|
38 | {% if device == 'dds' %} | |
39 | <script src="{% static 'js/dds_conversion.js' %}"></script> |
|
39 | <script src="{% static 'js/dds_conversion.js' %}"></script> | |
40 | <script type="text/javascript"> |
|
40 | <script type="text/javascript"> | |
41 |
|
41 | |||
@@ -106,4 +106,8 | |||||
106 | </script> |
|
106 | </script> | |
107 | {% endif %} |
|
107 | {% endif %} | |
108 |
|
108 | |||
|
109 | {% if device == 'rc' %} | |||
|
110 | <script src="{% static 'js/cr.js' %}"></script> | |||
|
111 | {% endif %} | |||
|
112 | ||||
109 | {% endblock %} No newline at end of file |
|
113 | {% endblock %} |
@@ -844,6 +844,7 def dev_conf_new(request, id_exp=0, id_dev=0): | |||||
844 | else: |
|
844 | else: | |
845 | kwargs['button'] = 'Create' |
|
845 | kwargs['button'] = 'Create' | |
846 | conf = Configuration.objects.get(pk=request.GET['template']) |
|
846 | conf = Configuration.objects.get(pk=request.GET['template']) | |
|
847 | id_dev = conf.device.pk | |||
847 | DevConfForm = CONF_FORMS[conf.device.device_type.name] |
|
848 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |
848 | form = DevConfForm(instance=conf, |
|
849 | form = DevConfForm(instance=conf, | |
849 | initial={'name': '{} [{:%Y/%m/%d}]'.format(conf.name, datetime.now()), |
|
850 | initial={'name': '{} [{:%Y/%m/%d}]'.format(conf.name, datetime.now()), | |
@@ -881,8 +882,7 def dev_conf_new(request, id_exp=0, id_dev=0): | |||||
881 |
|
882 | |||
882 | if id_dev != 0: |
|
883 | if id_dev != 0: | |
883 | device = Device.objects.get(pk=id_dev) |
|
884 | device = Device.objects.get(pk=id_dev) | |
884 |
|
|
885 | kwargs['device'] = device.device_type.name | |
885 | kwargs['dds_device'] = True |
|
|||
886 |
|
886 | |||
887 | return render(request, 'dev_conf_edit.html', kwargs) |
|
887 | return render(request, 'dev_conf_edit.html', kwargs) | |
888 |
|
888 |
@@ -179,13 +179,14 class RCConfiguration(Configuration): | |||||
179 | self.time_after = data['time_after'] |
|
179 | self.time_after = data['time_after'] | |
180 | self.sync = data['sync'] |
|
180 | self.sync = data['sync'] | |
181 | self.sampling_reference = data['sampling_reference'] |
|
181 | self.sampling_reference = data['sampling_reference'] | |
|
182 | self.total_units = self.ipp*self.ntx*self.km2unit | |||
182 | self.save() |
|
183 | self.save() | |
183 | self.clean_lines() |
|
184 | self.clean_lines() | |
184 |
|
185 | |||
185 | lines = [] |
|
186 | lines = [] | |
186 | positions = {'tx':0, 'tr':0} |
|
187 | positions = {'tx':0, 'tr':0} | |
187 |
|
188 | |||
188 | for i, line_data in enumerate(data['lines']): |
|
189 | for i, line_data in enumerate(data['lines']): | |
189 | line_type = RCLineType.objects.get(name=line_data.pop('type')) |
|
190 | line_type = RCLineType.objects.get(name=line_data.pop('type')) | |
190 | if line_type.name=='codes': |
|
191 | if line_type.name=='codes': | |
191 | code = RCLineCode.objects.get(name=line_data['code']) |
|
192 | code = RCLineCode.objects.get(name=line_data['code']) | |
@@ -345,7 +346,7 class RCConfiguration(Configuration): | |||||
345 | def update_pulses(self): |
|
346 | def update_pulses(self): | |
346 |
|
347 | |||
347 | for line in self.get_lines(): |
|
348 | for line in self.get_lines(): | |
348 |
line.update_pulses() |
|
349 | line.update_pulses() | |
349 |
|
350 | |||
350 | def plot_pulses(self): |
|
351 | def plot_pulses(self): | |
351 |
|
352 | |||
@@ -552,9 +553,10 class RCLine(models.Model): | |||||
552 |
|
553 | |||
553 | for tx in txs: |
|
554 | for tx in txs: | |
554 | params = json.loads(tx.params) |
|
555 | params = json.loads(tx.params) | |
|
556 | ||||
555 | if float(params['pulse_width'])==0: |
|
557 | if float(params['pulse_width'])==0: | |
556 | continue |
|
558 | continue | |
557 | delays = [float(d)*km2unit for d in params['delays'].split(',') if d] |
|
559 | delays = [float(d)*km2unit for d in params['delays'].split(',') if d] | |
558 | width = float(params['pulse_width'])*km2unit+int(self.rc_configuration.time_before*us2unit) |
|
560 | width = float(params['pulse_width'])*km2unit+int(self.rc_configuration.time_before*us2unit) | |
559 | before = 0 |
|
561 | before = 0 | |
560 | after = int(self.rc_configuration.time_after*us2unit) |
|
562 | after = int(self.rc_configuration.time_after*us2unit) | |
@@ -576,12 +578,12 class RCLine(models.Model): | |||||
576 | y_tx = self.mask_ranges(y_tx, tr_ranges) |
|
578 | y_tx = self.mask_ranges(y_tx, tr_ranges) | |
577 |
|
579 | |||
578 | y.extend(y_tx) |
|
580 | y.extend(y_tx) | |
579 |
|
581 | |||
580 | self.pulses = unicode(y) |
|
582 | self.pulses = unicode(y) | |
581 | y = self.array_to_points(self.pulses_as_array()) |
|
583 | y = self.array_to_points(self.pulses_as_array()) | |
582 |
|
584 | |||
583 | elif self.line_type.name=='tx': |
|
585 | elif self.line_type.name=='tx': | |
584 | params = json.loads(self.params) |
|
586 | params = json.loads(self.params) | |
585 | delays = [float(d)*km2unit for d in params['delays'].split(',') if d] |
|
587 | delays = [float(d)*km2unit for d in params['delays'].split(',') if d] | |
586 | width = float(params['pulse_width'])*km2unit |
|
588 | width = float(params['pulse_width'])*km2unit | |
587 |
|
589 | |||
@@ -715,8 +717,7 class RCLine(models.Model): | |||||
715 | y = y & y_temp |
|
717 | y = y & y_temp | |
716 | elif ops[i]=='NAND': |
|
718 | elif ops[i]=='NAND': | |
717 | y = y & ~y_temp |
|
719 | y = y & ~y_temp | |
718 | else: |
|
720 | else: | |
719 | print len(y), len(Y) |
|
|||
720 | y = np.concatenate([y, Y]) |
|
721 | y = np.concatenate([y, Y]) | |
721 |
|
722 | |||
722 | total = len(y) |
|
723 | total = len(y) | |
@@ -727,7 +728,7 class RCLine(models.Model): | |||||
727 |
|
728 | |||
728 | if self.rc_configuration.total_units <> total: |
|
729 | if self.rc_configuration.total_units <> total: | |
729 | self.rc_configuration.total_units = total |
|
730 | self.rc_configuration.total_units = total | |
730 |
self.rc_configuration.save() |
|
731 | self.rc_configuration.save() | |
731 |
|
732 | |||
732 | self.pulses = unicode(y) |
|
733 | self.pulses = unicode(y) | |
733 | self.save() |
|
734 | self.save() |
@@ -14,7 +14,7 function str2unit(s){ | |||||
14 | var ret = ""; |
|
14 | var ret = ""; | |
15 | values = s.split(","); |
|
15 | values = s.split(","); | |
16 | for (i=0; i<values.length; i++) { |
|
16 | for (i=0; i<values.length; i++) { | |
17 | ret += parseFloat(values[i])*km2unit; |
|
17 | ret += Math.round(parseFloat(values[i]))*km2unit; | |
18 | ret += ","; |
|
18 | ret += ","; | |
19 | } |
|
19 | } | |
20 | return ret.substring(0, ret.length-1); |
|
20 | return ret.substring(0, ret.length-1); |
@@ -328,13 +328,14 def import_file(request, conf_id): | |||||
328 | if request.method=='POST': |
|
328 | if request.method=='POST': | |
329 | form = RCImportForm(request.POST, request.FILES) |
|
329 | form = RCImportForm(request.POST, request.FILES) | |
330 | if form.is_valid(): |
|
330 | if form.is_valid(): | |
331 |
|
|
331 | if True: | |
|
332 | #try: | |||
332 | conf.update_from_file(request.FILES['file_name']) |
|
333 | conf.update_from_file(request.FILES['file_name']) | |
333 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) |
|
334 | messages.success(request, 'Configuration "%s" loaded succesfully' % request.FILES['file_name']) | |
334 | return redirect(conf.get_absolute_url_edit()) |
|
335 | return redirect(conf.get_absolute_url_edit()) | |
335 |
|
336 | |||
336 | except Exception as e: |
|
337 | #except Exception as e: | |
337 | messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e)) |
|
338 | # messages.error(request, 'Error parsing file: "%s" - %s' % (request.FILES['file_name'], e)) | |
338 |
|
339 | |||
339 | else: |
|
340 | else: | |
340 | messages.warning(request, 'Your current configuration will be replaced') |
|
341 | messages.warning(request, 'Your current configuration will be replaced') |
@@ -25,15 +25,19 class KmUnitWidget(forms.widgets.TextInput): | |||||
25 |
|
25 | |||
26 | disabled = 'disabled' if attrs.get('disabled', False) else '' |
|
26 | disabled = 'disabled' if attrs.get('disabled', False) else '' | |
27 | name = attrs.get('name', label) |
|
27 | name = attrs.get('name', label) | |
|
28 | if attrs['id'] in ('id_delays',): | |||
|
29 | input_type = 'text' | |||
|
30 | else: | |||
|
31 | input_type = 'number' | |||
28 |
|
32 | |||
29 | if 'line' in attrs: |
|
33 | if 'line' in attrs: | |
30 | label += '_{0}'.format(attrs['line'].pk) |
|
34 | label += '_{0}'.format(attrs['line'].pk) | |
31 |
|
35 | |||
32 | html = '''<div class="col-md-12 col-no-padding"> |
|
36 | html = '''<div class="col-md-12 col-no-padding"> | |
33 |
<div class="col-md-5 col-no-padding"><input type=" |
|
37 | <div class="col-md-5 col-no-padding"><input type="{0}" step="any" {1} class="form-control" id="id_{2}" name="{3}" value="{4}"></div> | |
34 | <div class="col-md-1 col-no-padding">Km</div> |
|
38 | <div class="col-md-1 col-no-padding">Km</div> | |
35 |
<div class="col-md-5 col-no-padding"><input type=" |
|
39 | <div class="col-md-5 col-no-padding"><input type="{0}" {1} class="form-control" id="id_{2}_unit" value="{5}"></div> | |
36 |
<div class="col-md-1 col-no-padding">Units</div></div><br>'''.format(disabled, label, name, value, |
|
40 | <div class="col-md-1 col-no-padding">Units</div></div><br>'''.format(input_type, disabled, label, name, value, unit) | |
37 |
|
41 | |||
38 | script = '''<script type="text/javascript"> |
|
42 | script = '''<script type="text/javascript"> | |
39 | $(document).ready(function () {{ |
|
43 | $(document).ready(function () {{ | |
@@ -42,11 +46,11 class KmUnitWidget(forms.widgets.TextInput): | |||||
42 | unit_fields.push("id_{label}_unit"); |
|
46 | unit_fields.push("id_{label}_unit"); | |
43 |
|
47 | |||
44 | $("#id_{label}").change(function() {{ |
|
48 | $("#id_{label}").change(function() {{ | |
45 |
$("#id_{label}_unit").val( |
|
49 | $("#id_{label}_unit").val(str2unit($(this).val())); | |
46 | $("#id_{label}").val(str2km($("#id_{label}_unit").val())); |
|
50 | $("#id_{label}").val(str2km($("#id_{label}_unit").val())); | |
47 | }}); |
|
51 | }}); | |
48 | $("#id_{label}_unit").change(function() {{ |
|
52 | $("#id_{label}_unit").change(function() {{ | |
49 |
$(this).val( |
|
53 | $(this).val(parseFloat($(this).val())); | |
50 | $("#id_{label}").val(str2km($(this).val())); |
|
54 | $("#id_{label}").val(str2km($(this).val())); | |
51 | }}); |
|
55 | }}); | |
52 | }}); |
|
56 | }}); |
General Comments 0
You need to be logged in to leave comments.
Login now