@@ -0,0 +1,124 | |||
|
1 | $(document).ready(function() { | |
|
2 | var type = $("#id_exp_type").val(); | |
|
3 | spectral_number = $("#id_spectral_number") | |
|
4 | spectral = $("#id_spectral") | |
|
5 | fftpoints = $("#id_fftpoints") | |
|
6 | save_ch_dc = $("#id_save_ch_dc") | |
|
7 | add_spec_button = $("#add_spectral_button") | |
|
8 | del_spec_button = $("#delete_spectral_button") | |
|
9 | sel_spec_button = $("#self_spectral_button") | |
|
10 | cro_spec_button = $("#cross_spectral_button") | |
|
11 | all_spec_button = $("#all_spectral_button") | |
|
12 | ||
|
13 | if (type == 0) { | |
|
14 | $(spectral_number).attr('readonly', true); | |
|
15 | $(spectral).attr('readonly', true); | |
|
16 | $(fftpoints).attr('readonly', true); | |
|
17 | $(save_ch_dc).attr('disabled', true); | |
|
18 | $(save_ch_dc).attr('readonly', true); | |
|
19 | $(add_spec_button).attr('disabled', true); | |
|
20 | $(del_spec_button).attr('disabled', true); | |
|
21 | $(sel_spec_button).attr('disabled', true); | |
|
22 | $(cro_spec_button).attr('disabled', true); | |
|
23 | $(all_spec_button).attr('disabled', true); | |
|
24 | } | |
|
25 | else { | |
|
26 | $(spectral_number).attr('readonly', false); | |
|
27 | $(spectral).attr('readonly', false); | |
|
28 | $(fftpoints).attr('readonly', false); | |
|
29 | $(save_ch_dc).attr('disabled', false); | |
|
30 | $(save_ch_dc).attr('readonly', false); | |
|
31 | $(add_spec_button).attr('disabled', false); | |
|
32 | $(del_spec_button).attr('disabled', false); | |
|
33 | $(sel_spec_button).attr('disabled', false); | |
|
34 | $(cro_spec_button).attr('disabled', false); | |
|
35 | $(all_spec_button).attr('disabled', false); | |
|
36 | } | |
|
37 | }); | |
|
38 | ||
|
39 | $("#id_exp_type").change(function() { | |
|
40 | var type = $("#id_exp_type").val(); | |
|
41 | spectral_number = $("#id_spectral_number") | |
|
42 | spectral = $("#id_spectral") | |
|
43 | fftpoints = $("#id_fftpoints") | |
|
44 | save_ch_dc = $("#id_save_ch_dc") | |
|
45 | add_spec_button = $("#add_spectral_button") | |
|
46 | del_spec_button = $("#delete_spectral_button") | |
|
47 | sel_spec_button = $("#self_spectral_button") | |
|
48 | cro_spec_button = $("#cross_spectral_button") | |
|
49 | all_spec_button = $("#all_spectral_button") | |
|
50 | ||
|
51 | if (type == 0) { | |
|
52 | $(spectral_number).attr('readonly', true); | |
|
53 | $(spectral).attr('readonly', true); | |
|
54 | $(fftpoints).attr('readonly', true); | |
|
55 | $(save_ch_dc).attr('disabled', true); | |
|
56 | $(save_ch_dc).attr('readonly', true); | |
|
57 | $(add_spec_button).attr('disabled', true); | |
|
58 | $(del_spec_button).attr('disabled', true); | |
|
59 | $(sel_spec_button).attr('disabled', true); | |
|
60 | $(cro_spec_button).attr('disabled', true); | |
|
61 | $(all_spec_button).attr('disabled', true); | |
|
62 | } | |
|
63 | else { | |
|
64 | $(spectral_number).attr('readonly', false); | |
|
65 | $(spectral).attr('readonly', false); | |
|
66 | $(fftpoints).attr('readonly', false); | |
|
67 | $(save_ch_dc).attr('disabled', false); | |
|
68 | $(save_ch_dc).attr('readonly', false); | |
|
69 | $(add_spec_button).attr('disabled', false); | |
|
70 | $(del_spec_button).attr('disabled', false); | |
|
71 | $(sel_spec_button).attr('disabled', false); | |
|
72 | $(cro_spec_button).attr('disabled', false); | |
|
73 | $(all_spec_button).attr('disabled', false); | |
|
74 | } | |
|
75 | }); | |
|
76 | ||
|
77 | ||
|
78 | $("#id_cards_number").on('change', function() { | |
|
79 | var cards_number = $("#id_cards_number").val(); | |
|
80 | channels_number = $("#id_channels_number") | |
|
81 | $(channels_number).val(cards_number*2) | |
|
82 | updateChannelsNumber(); | |
|
83 | }); | |
|
84 | ||
|
85 | ||
|
86 | $("#id_channels_number").on('change', function() { | |
|
87 | updateChannelsNumber(); | |
|
88 | }); | |
|
89 | ||
|
90 | ||
|
91 | $("#id_spectral").on('change', function() { | |
|
92 | updateSpectralNumber(); | |
|
93 | }); | |
|
94 | ||
|
95 | ||
|
96 | function updateSpectralNumber(){ | |
|
97 | var spectral_comb = $("#id_spectral").val(); | |
|
98 | var num = spectral_comb.length; | |
|
99 | var cont = 0 | |
|
100 | for (i = 0; i < num; i++) { | |
|
101 | if (spectral_comb[i] == "]"){ | |
|
102 | cont = cont + 1 | |
|
103 | } | |
|
104 | } | |
|
105 | $("#id_spectral_number").val(cont) | |
|
106 | } | |
|
107 | ||
|
108 | ||
|
109 | function updateChannelsNumber() { | |
|
110 | ||
|
111 | var channels_number = $("#id_channels_number").val(); | |
|
112 | channels = $("#id_channels") | |
|
113 | sequence = "" | |
|
114 | ||
|
115 | for (i = 1; i <= channels_number; i++) { | |
|
116 | if (i==1){ | |
|
117 | sequence = i.toString() | |
|
118 | } | |
|
119 | else{ | |
|
120 | sequence = sequence + "," + i.toString() | |
|
121 | } | |
|
122 | } | |
|
123 | $(channels).val(sequence) | |
|
124 | } No newline at end of file |
@@ -1,31 +1,31 | |||
|
1 | 1 | from django import forms |
|
2 | 2 | from apps.main.models import Device, Experiment |
|
3 | 3 | from .models import JARSConfiguration |
|
4 | 4 | from .widgets import SpectralWidget |
|
5 | 5 | |
|
6 | 6 | class JARSConfigurationForm(forms.ModelForm): |
|
7 | 7 | def __init__(self, *args, **kwargs): |
|
8 | 8 | super(JARSConfigurationForm, self).__init__(*args, **kwargs) |
|
9 | 9 | instance = getattr(self, 'instance', None) |
|
10 | 10 | |
|
11 | 11 | if instance and instance.pk: |
|
12 | 12 | devices = Device.objects.filter(device_type__name='jars') |
|
13 | 13 | |
|
14 | 14 | if instance.experiment: |
|
15 | 15 | experiments = Experiment.objects.filter(pk=instance.experiment.id) |
|
16 | 16 | self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments] |
|
17 | 17 | |
|
18 | 18 | self.fields['device'].widget.choices = [(device.id, device) for device in devices] |
|
19 | self.fields['spectral'].widget = SpectralWidget() | |
|
20 | ||
|
19 | #self.fields['spectral'].widget = SpectralWidget() | |
|
20 | self.fields['spectral'].widget = SpectralWidget() | |
|
21 | 21 | #-------------JARS Configuration needs an Experiment----------------- |
|
22 | 22 | def clean(self): |
|
23 | 23 | cleaned_data = super(JARSConfigurationForm, self).clean() |
|
24 | 24 | experiment = cleaned_data.get('experiment') |
|
25 | 25 | if experiment == None: |
|
26 | 26 | msg = "Error: Jars Configuration needs an Experiment" |
|
27 | 27 | self.add_error('experiment', msg) |
|
28 | 28 | |
|
29 | 29 | class Meta: |
|
30 | 30 | model = JARSConfiguration |
|
31 | 31 | exclude = ('type', 'parameters', 'status') No newline at end of file |
@@ -1,134 +1,8 | |||
|
1 | 1 | {% extends "dev_conf_edit.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | 6 | {% block extra-js%} |
|
7 | <script type="text/javascript"> | |
|
8 | ||
|
9 | $(document).ready(function() { | |
|
10 | var type = $("#id_exp_type").val(); | |
|
11 | spectral_number = $("#id_spectral_number") | |
|
12 | spectral = $("#id_spectral") | |
|
13 | fftpoints = $("#id_fftpoints") | |
|
14 | save_ch_dc = $("#id_save_ch_dc") | |
|
15 | add_spec_button = $("#add_spectral_button") | |
|
16 | del_spec_button = $("#delete_spectral_button") | |
|
17 | sel_spec_button = $("#self_spectral_button") | |
|
18 | cro_spec_button = $("#cross_spectral_button") | |
|
19 | all_spec_button = $("#all_spectral_button") | |
|
20 | ||
|
21 | if (type == 0) { | |
|
22 | $(spectral_number).attr('readonly', true); | |
|
23 | $(spectral).attr('readonly', true); | |
|
24 | $(fftpoints).attr('readonly', true); | |
|
25 | $(save_ch_dc).attr('disabled', true); | |
|
26 | $(save_ch_dc).attr('readonly', true); | |
|
27 | $(add_spec_button).attr('disabled', true); | |
|
28 | $(del_spec_button).attr('disabled', true); | |
|
29 | $(sel_spec_button).attr('disabled', true); | |
|
30 | $(cro_spec_button).attr('disabled', true); | |
|
31 | $(all_spec_button).attr('disabled', true); | |
|
32 | } | |
|
33 | else { | |
|
34 | $(spectral_number).attr('readonly', false); | |
|
35 | $(spectral).attr('readonly', false); | |
|
36 | $(fftpoints).attr('readonly', false); | |
|
37 | $(save_ch_dc).attr('disabled', false); | |
|
38 | $(save_ch_dc).attr('readonly', false); | |
|
39 | $(add_spec_button).attr('disabled', false); | |
|
40 | $(del_spec_button).attr('disabled', false); | |
|
41 | $(sel_spec_button).attr('disabled', false); | |
|
42 | $(cro_spec_button).attr('disabled', false); | |
|
43 | $(all_spec_button).attr('disabled', false); | |
|
44 | } | |
|
45 | }); | |
|
46 | ||
|
47 | $("#id_exp_type").change(function() { | |
|
48 | var type = $("#id_exp_type").val(); | |
|
49 | spectral_number = $("#id_spectral_number") | |
|
50 | spectral = $("#id_spectral") | |
|
51 | fftpoints = $("#id_fftpoints") | |
|
52 | save_ch_dc = $("#id_save_ch_dc") | |
|
53 | add_spec_button = $("#add_spectral_button") | |
|
54 | del_spec_button = $("#delete_spectral_button") | |
|
55 | sel_spec_button = $("#self_spectral_button") | |
|
56 | cro_spec_button = $("#cross_spectral_button") | |
|
57 | all_spec_button = $("#all_spectral_button") | |
|
58 | ||
|
59 | if (type == 0) { | |
|
60 | $(spectral_number).attr('readonly', true); | |
|
61 | $(spectral).attr('readonly', true); | |
|
62 | $(fftpoints).attr('readonly', true); | |
|
63 | $(save_ch_dc).attr('disabled', true); | |
|
64 | $(save_ch_dc).attr('readonly', true); | |
|
65 | $(add_spec_button).attr('disabled', true); | |
|
66 | $(del_spec_button).attr('disabled', true); | |
|
67 | $(sel_spec_button).attr('disabled', true); | |
|
68 | $(cro_spec_button).attr('disabled', true); | |
|
69 | $(all_spec_button).attr('disabled', true); | |
|
70 | } | |
|
71 | else { | |
|
72 | $(spectral_number).attr('readonly', false); | |
|
73 | $(spectral).attr('readonly', false); | |
|
74 | $(fftpoints).attr('readonly', false); | |
|
75 | $(save_ch_dc).attr('disabled', false); | |
|
76 | $(save_ch_dc).attr('readonly', false); | |
|
77 | $(add_spec_button).attr('disabled', false); | |
|
78 | $(del_spec_button).attr('disabled', false); | |
|
79 | $(sel_spec_button).attr('disabled', false); | |
|
80 | $(cro_spec_button).attr('disabled', false); | |
|
81 | $(all_spec_button).attr('disabled', false); | |
|
82 | } | |
|
83 | }); | |
|
84 | ||
|
85 | ||
|
86 | $("#id_cards_number").on('change', function() { | |
|
87 | var cards_number = $("#id_cards_number").val(); | |
|
88 | channels_number = $("#id_channels_number") | |
|
89 | $(channels_number).val(cards_number*2) | |
|
90 | updateChannelsNumber(); | |
|
91 | }); | |
|
92 | ||
|
93 | ||
|
94 | $("#id_channels_number").on('change', function() { | |
|
95 | updateChannelsNumber(); | |
|
96 | }); | |
|
97 | ||
|
98 | ||
|
99 | $("#id_spectral").on('change', function() { | |
|
100 | updateSpectralNumber(); | |
|
101 | }); | |
|
102 | ||
|
103 | ||
|
104 | function updateSpectralNumber(){ | |
|
105 | var spectral_comb = $("#id_spectral").val(); | |
|
106 | var num = spectral_comb.length; | |
|
107 | var cont = 0 | |
|
108 | for (i = 0; i < num; i++) { | |
|
109 | if (spectral_comb[i] == "]"){ | |
|
110 | cont = cont + 1 | |
|
111 | } | |
|
112 | } | |
|
113 | $("#id_spectral_number").val(cont) | |
|
114 | } | |
|
115 | ||
|
116 | ||
|
117 | function updateChannelsNumber() { | |
|
118 | ||
|
119 | var channels_number = $("#id_channels_number").val(); | |
|
120 | channels = $("#id_channels") | |
|
121 | sequence = "" | |
|
122 | ||
|
123 | for (i = 1; i <= channels_number; i++) { | |
|
124 | if (i==1){ | |
|
125 | sequence = i.toString() | |
|
126 | } | |
|
127 | else{ | |
|
128 | sequence = sequence + "," + i.toString() | |
|
129 | } | |
|
130 | } | |
|
131 | $(channels).val(sequence) | |
|
132 | } | |
|
133 | </script> | |
|
7 | <script src="{% static 'js/jars.js' %}"></script> | |
|
134 | 8 | {% endblock %} No newline at end of file |
@@ -1,113 +1,117 | |||
|
1 | 1 | {% extends "base_edit.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | 6 | |
|
7 | 7 | {% block extra-js%} |
|
8 | 8 | |
|
9 | 9 | {% if id_exp %} |
|
10 | 10 | |
|
11 | 11 | <script type="text/javascript"> |
|
12 | 12 | |
|
13 | 13 | $("#id_device").change(function() { |
|
14 | 14 | var url = "{% url 'url_add_dev_conf' id_exp %}"; |
|
15 | 15 | document.location = url+ $(this).val() + "/?name=" + $("#id_name").val(); |
|
16 | 16 | }); |
|
17 | 17 | |
|
18 | 18 | $('#id_create_from').change(function() { |
|
19 | 19 | var url = "{% url 'url_add_dev_conf' id_exp %}"; |
|
20 | 20 | if ($(this).val()=="2"){ |
|
21 | 21 | document.location = url+"?template=0"; |
|
22 | 22 | }else if ($(this).val()=="1"){ |
|
23 | 23 | document.location = url+"?blank=0"; |
|
24 | 24 | }else{ |
|
25 | 25 | document.location = url; |
|
26 | 26 | } |
|
27 | 27 | }); |
|
28 | 28 | |
|
29 | 29 | $('#id_choose_template').change(function() { |
|
30 | 30 | var url = "{% url 'url_add_dev_conf' id_exp %}"; |
|
31 | 31 | document.location = url+"?template="+$(this).val(); |
|
32 | 32 | }); |
|
33 | 33 | |
|
34 | 34 | </script> |
|
35 | 35 | |
|
36 | 36 | {% endif %} |
|
37 | 37 | |
|
38 | 38 | {% if device == 'dds' %} |
|
39 | 39 | <script src="{% static 'js/dds_conversion.js' %}"></script> |
|
40 | 40 | <script type="text/javascript"> |
|
41 | 41 | |
|
42 | 42 | $("#id_clock").on('change', function() { |
|
43 | 43 | updateFrequencies(); |
|
44 | 44 | }); |
|
45 | 45 | |
|
46 | 46 | $("#id_multiplier").on('change', function() { |
|
47 | 47 | updateFrequencies(); |
|
48 | 48 | }); |
|
49 | 49 | |
|
50 | 50 | $("#id_frequencyA_Mhz").on('change', function() { |
|
51 | 51 | updateBinaryFrequencies(); |
|
52 | 52 | }); |
|
53 | 53 | |
|
54 | 54 | $("#id_frequencyA").on('change', function() { |
|
55 | 55 | updateFrequencies(); |
|
56 | 56 | }); |
|
57 | 57 | |
|
58 | 58 | $("#id_frequencyB_Mhz").on('change', function() { |
|
59 | 59 | updateBinaryFrequencies(); |
|
60 | 60 | }); |
|
61 | 61 | |
|
62 | 62 | $("#id_frequencyB").on('change', function() { |
|
63 | 63 | updateFrequencies(); |
|
64 | 64 | }); |
|
65 | 65 | |
|
66 | 66 | function updateBinaryFrequencies() { |
|
67 | 67 | |
|
68 | 68 | var clock = $("#id_clock").val(); |
|
69 | 69 | var multiplier = $("#id_multiplier").val(); |
|
70 | 70 | var freq = $("#id_frequencyA_Mhz").val(); |
|
71 | 71 | var freq_mod = $("#id_frequencyB_Mhz").val(); |
|
72 | 72 | |
|
73 | 73 | var mclock = clock*multiplier; |
|
74 | 74 | |
|
75 | 75 | var freq_bin = freq2Binary(mclock, freq); |
|
76 | 76 | var freq_mod_bin = freq2Binary(mclock, freq_mod); |
|
77 | 77 | |
|
78 | 78 | $("#id_frequencyA").val(freq_bin); |
|
79 | 79 | $("#id_frequencyB").val(freq_mod_bin); |
|
80 | 80 | |
|
81 | 81 | freq = binary2Freq(mclock, freq_bin); |
|
82 | 82 | freq_mod = binary2Freq(mclock, freq_mod_bin); |
|
83 | 83 | |
|
84 | 84 | $("#id_frequencyA_Mhz").val(freq); |
|
85 | 85 | $("#id_frequencyB_Mhz").val(freq_mod); |
|
86 | 86 | |
|
87 | 87 | } |
|
88 | 88 | |
|
89 | 89 | function updateFrequencies() { |
|
90 | 90 | |
|
91 | 91 | var clock = $("#id_clock").val(); |
|
92 | 92 | var multiplier = $("#id_multiplier").val(); |
|
93 | 93 | var freq_bin = $("#id_frequencyA").val(); |
|
94 | 94 | var freq_mod_bin = $("#id_frequencyB").val(); |
|
95 | 95 | |
|
96 | 96 | var mclock = clock*multiplier; |
|
97 | 97 | |
|
98 | 98 | var freq = binary2Freq(mclock, freq_bin); |
|
99 | 99 | var freq_mod = binary2Freq(mclock, freq_mod_bin); |
|
100 | 100 | |
|
101 | 101 | $("#id_frequencyA_Mhz").val(freq); |
|
102 | 102 | $("#id_frequencyB_Mhz").val(freq_mod); |
|
103 | 103 | |
|
104 | 104 | } |
|
105 | 105 | |
|
106 | 106 | </script> |
|
107 | 107 | {% endif %} |
|
108 | 108 | |
|
109 | 109 | {% if device == 'rc' %} |
|
110 | 110 | <script src="{% static 'js/cr.js' %}"></script> |
|
111 | 111 | {% endif %} |
|
112 | 112 | |
|
113 | {% if device == 'jars' %} | |
|
114 | <script src="{% static 'js/jars.js' %}"></script> | |
|
115 | {% endif %} | |
|
116 | ||
|
113 | 117 | {% endblock %} No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now