##// END OF EJS Templates
Task #99: Modulo web del JARS (static: jars.js)...
Fiorella Quino -
r131:67879d25c3ca
parent child
Show More
@@ -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 from django import forms
1 from django import forms
2 from apps.main.models import Device, Experiment
2 from apps.main.models import Device, Experiment
3 from .models import JARSConfiguration
3 from .models import JARSConfiguration
4 from .widgets import SpectralWidget
4 from .widgets import SpectralWidget
5
5
6 class JARSConfigurationForm(forms.ModelForm):
6 class JARSConfigurationForm(forms.ModelForm):
7 def __init__(self, *args, **kwargs):
7 def __init__(self, *args, **kwargs):
8 super(JARSConfigurationForm, self).__init__(*args, **kwargs)
8 super(JARSConfigurationForm, self).__init__(*args, **kwargs)
9 instance = getattr(self, 'instance', None)
9 instance = getattr(self, 'instance', None)
10
10
11 if instance and instance.pk:
11 if instance and instance.pk:
12 devices = Device.objects.filter(device_type__name='jars')
12 devices = Device.objects.filter(device_type__name='jars')
13
13
14 if instance.experiment:
14 if instance.experiment:
15 experiments = Experiment.objects.filter(pk=instance.experiment.id)
15 experiments = Experiment.objects.filter(pk=instance.experiment.id)
16 self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments]
16 self.fields['experiment'].widget.choices = [(experiment.id, experiment) for experiment in experiments]
17
17
18 self.fields['device'].widget.choices = [(device.id, device) for device in devices]
18 self.fields['device'].widget.choices = [(device.id, device) for device in devices]
19 #self.fields['spectral'].widget = SpectralWidget()
19 self.fields['spectral'].widget = SpectralWidget()
20 self.fields['spectral'].widget = SpectralWidget()
20
21 #-------------JARS Configuration needs an Experiment-----------------
21 #-------------JARS Configuration needs an Experiment-----------------
22 def clean(self):
22 def clean(self):
23 cleaned_data = super(JARSConfigurationForm, self).clean()
23 cleaned_data = super(JARSConfigurationForm, self).clean()
24 experiment = cleaned_data.get('experiment')
24 experiment = cleaned_data.get('experiment')
25 if experiment == None:
25 if experiment == None:
26 msg = "Error: Jars Configuration needs an Experiment"
26 msg = "Error: Jars Configuration needs an Experiment"
27 self.add_error('experiment', msg)
27 self.add_error('experiment', msg)
28
28
29 class Meta:
29 class Meta:
30 model = JARSConfiguration
30 model = JARSConfiguration
31 exclude = ('type', 'parameters', 'status') No newline at end of file
31 exclude = ('type', 'parameters', 'status')
@@ -1,134 +1,8
1 {% extends "dev_conf_edit.html" %}
1 {% extends "dev_conf_edit.html" %}
2 {% load bootstrap3 %}
2 {% load bootstrap3 %}
3 {% load static %}
3 {% load static %}
4 {% load main_tags %}
4 {% load main_tags %}
5
5
6 {% block extra-js%}
6 {% block extra-js%}
7 <script type="text/javascript">
7 <script src="{% static 'js/jars.js' %}"></script>
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>
134 {% endblock %} No newline at end of file
8 {% endblock %}
@@ -1,113 +1,117
1 {% extends "base_edit.html" %}
1 {% extends "base_edit.html" %}
2 {% load bootstrap3 %}
2 {% load bootstrap3 %}
3 {% load static %}
3 {% load static %}
4 {% load main_tags %}
4 {% load main_tags %}
5
5
6
6
7 {% block extra-js%}
7 {% block extra-js%}
8
8
9 {% if id_exp %}
9 {% if id_exp %}
10
10
11 <script type="text/javascript">
11 <script type="text/javascript">
12
12
13 $("#id_device").change(function() {
13 $("#id_device").change(function() {
14 var url = "{% url 'url_add_dev_conf' id_exp %}";
14 var url = "{% url 'url_add_dev_conf' id_exp %}";
15 document.location = url+ $(this).val() + "/?name=" + $("#id_name").val();
15 document.location = url+ $(this).val() + "/?name=" + $("#id_name").val();
16 });
16 });
17
17
18 $('#id_create_from').change(function() {
18 $('#id_create_from').change(function() {
19 var url = "{% url 'url_add_dev_conf' id_exp %}";
19 var url = "{% url 'url_add_dev_conf' id_exp %}";
20 if ($(this).val()=="2"){
20 if ($(this).val()=="2"){
21 document.location = url+"?template=0";
21 document.location = url+"?template=0";
22 }else if ($(this).val()=="1"){
22 }else if ($(this).val()=="1"){
23 document.location = url+"?blank=0";
23 document.location = url+"?blank=0";
24 }else{
24 }else{
25 document.location = url;
25 document.location = url;
26 }
26 }
27 });
27 });
28
28
29 $('#id_choose_template').change(function() {
29 $('#id_choose_template').change(function() {
30 var url = "{% url 'url_add_dev_conf' id_exp %}";
30 var url = "{% url 'url_add_dev_conf' id_exp %}";
31 document.location = url+"?template="+$(this).val();
31 document.location = url+"?template="+$(this).val();
32 });
32 });
33
33
34 </script>
34 </script>
35
35
36 {% endif %}
36 {% endif %}
37
37
38 {% if device == 'dds' %}
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
42 $("#id_clock").on('change', function() {
42 $("#id_clock").on('change', function() {
43 updateFrequencies();
43 updateFrequencies();
44 });
44 });
45
45
46 $("#id_multiplier").on('change', function() {
46 $("#id_multiplier").on('change', function() {
47 updateFrequencies();
47 updateFrequencies();
48 });
48 });
49
49
50 $("#id_frequencyA_Mhz").on('change', function() {
50 $("#id_frequencyA_Mhz").on('change', function() {
51 updateBinaryFrequencies();
51 updateBinaryFrequencies();
52 });
52 });
53
53
54 $("#id_frequencyA").on('change', function() {
54 $("#id_frequencyA").on('change', function() {
55 updateFrequencies();
55 updateFrequencies();
56 });
56 });
57
57
58 $("#id_frequencyB_Mhz").on('change', function() {
58 $("#id_frequencyB_Mhz").on('change', function() {
59 updateBinaryFrequencies();
59 updateBinaryFrequencies();
60 });
60 });
61
61
62 $("#id_frequencyB").on('change', function() {
62 $("#id_frequencyB").on('change', function() {
63 updateFrequencies();
63 updateFrequencies();
64 });
64 });
65
65
66 function updateBinaryFrequencies() {
66 function updateBinaryFrequencies() {
67
67
68 var clock = $("#id_clock").val();
68 var clock = $("#id_clock").val();
69 var multiplier = $("#id_multiplier").val();
69 var multiplier = $("#id_multiplier").val();
70 var freq = $("#id_frequencyA_Mhz").val();
70 var freq = $("#id_frequencyA_Mhz").val();
71 var freq_mod = $("#id_frequencyB_Mhz").val();
71 var freq_mod = $("#id_frequencyB_Mhz").val();
72
72
73 var mclock = clock*multiplier;
73 var mclock = clock*multiplier;
74
74
75 var freq_bin = freq2Binary(mclock, freq);
75 var freq_bin = freq2Binary(mclock, freq);
76 var freq_mod_bin = freq2Binary(mclock, freq_mod);
76 var freq_mod_bin = freq2Binary(mclock, freq_mod);
77
77
78 $("#id_frequencyA").val(freq_bin);
78 $("#id_frequencyA").val(freq_bin);
79 $("#id_frequencyB").val(freq_mod_bin);
79 $("#id_frequencyB").val(freq_mod_bin);
80
80
81 freq = binary2Freq(mclock, freq_bin);
81 freq = binary2Freq(mclock, freq_bin);
82 freq_mod = binary2Freq(mclock, freq_mod_bin);
82 freq_mod = binary2Freq(mclock, freq_mod_bin);
83
83
84 $("#id_frequencyA_Mhz").val(freq);
84 $("#id_frequencyA_Mhz").val(freq);
85 $("#id_frequencyB_Mhz").val(freq_mod);
85 $("#id_frequencyB_Mhz").val(freq_mod);
86
86
87 }
87 }
88
88
89 function updateFrequencies() {
89 function updateFrequencies() {
90
90
91 var clock = $("#id_clock").val();
91 var clock = $("#id_clock").val();
92 var multiplier = $("#id_multiplier").val();
92 var multiplier = $("#id_multiplier").val();
93 var freq_bin = $("#id_frequencyA").val();
93 var freq_bin = $("#id_frequencyA").val();
94 var freq_mod_bin = $("#id_frequencyB").val();
94 var freq_mod_bin = $("#id_frequencyB").val();
95
95
96 var mclock = clock*multiplier;
96 var mclock = clock*multiplier;
97
97
98 var freq = binary2Freq(mclock, freq_bin);
98 var freq = binary2Freq(mclock, freq_bin);
99 var freq_mod = binary2Freq(mclock, freq_mod_bin);
99 var freq_mod = binary2Freq(mclock, freq_mod_bin);
100
100
101 $("#id_frequencyA_Mhz").val(freq);
101 $("#id_frequencyA_Mhz").val(freq);
102 $("#id_frequencyB_Mhz").val(freq_mod);
102 $("#id_frequencyB_Mhz").val(freq_mod);
103
103
104 }
104 }
105
105
106 </script>
106 </script>
107 {% endif %}
107 {% endif %}
108
108
109 {% if device == 'rc' %}
109 {% if device == 'rc' %}
110 <script src="{% static 'js/cr.js' %}"></script>
110 <script src="{% static 'js/cr.js' %}"></script>
111 {% endif %}
111 {% endif %}
112
112
113 {% if device == 'jars' %}
114 <script src="{% static 'js/jars.js' %}"></script>
115 {% endif %}
116
113 {% endblock %} No newline at end of file
117 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now