##// END OF EJS Templates
Task #566: Verify Parameters...
Fiorella Quino -
r229:ebcde1925a60
parent child
Show More
@@ -17,7 +17,7
17 17
18 18 {% endblock %}
19 19
20
20 <form action="" method="post" class="form login">{% csrf_token %}
21 21
22 22 <table class="table table-bordered" style="text-align:center;">
23 23 <!--<h4 class="panel-title"> </h4>-->
@@ -26,44 +26,44
26 26 <th style="text-align:center;">DDS</th>
27 27 <th style="text-align:center;">RC</th>
28 28 <th style="text-align:center;">JARS</th>
29 <th style="text-align:center;">=P</th>
29 <th style="text-align:center;">Insert New Value</th>
30 30 </tr>
31
31
32 32 <tr>
33 33 <th>Clock In</th>
34 34 <td id="dds_clock">{{ dds.clock }}</td>
35 35 <td id="rc_clock">{{ rc.clock_in }}</td>
36 36 <td id="filter_clock">{{ filter_parms.clock }}</td>
37 <td><input id="suggest_clock"></input></td>
37 <td><input id="suggest_clock" name="suggest_clock"></input></td>
38 38 </tr>
39
39
40 40 <tr>
41 41 <th>Frequency A (Mhz)</th>
42 <td>{{ dds.frequencyA_Mhz }}</td>
42 <td id="dds_frequencyA">{{ dds.frequencyA_Mhz }}</td>
43 43 <td>x</td>
44 <td>{{ filter_parms.fch }}</td>
45 <td><input></input></td>
44 <td id="filter_frequencyA">{{ filter_parms.fch }}</td>
45 <td><input id="suggest_frequencyA" name="suggest_frequencyA"></input></td>
46 46 </tr>
47
48 <tr>
47
48 <!--<tr>
49 49 <th>Frequency A (Decimal)</th>
50 50 <td>{{ dds.frequencyA }}</td>
51 51 <td>x</td>
52 52 <td>{{ filter_parms.fch_decimal }}</td>
53 <td><input></input></td>
54 </tr>
55
56 <tr>
53 <td><input id="suggest_frequencyAdec"></input></td>
54 </tr>-->
55
56 <!--<tr>
57 57 <th>Sampling Frequency (MHz)</th>
58 58 <td id="dds_sampfreq">{{ dds.frequencyA }}</td>
59 59 <td id="rc_sampfreq">{{ samp_freq_rc }}</td>
60 60 <td id="jars_sampfreq">{{ samp_freq_jars }}</td>
61 <td><input id="suggest_sampfreq"></input></td>
62 </tr>
61 <td><input id="suggest_sampfreq" name="suggest_sampfreq"></input></td>
62 </tr>-->
63 63 </table>
64 64
65 65
66
66 <!--
67 67 <div class="">
68 68 <h4 class="panel-title"><b> Extra Parameters </b></h4>
69 69 <br>
@@ -76,13 +76,15
76 76 {% endif %}
77 77 {% endfor %}
78 78 </table>
79
79 -->
80 80
81 81 <div class="pull-right">
82 <button type="button" class="btn btn-primary" id="bt_back">Back</button>
83 <button type="button" class="btn btn-primary" id="bt_update">{{ button }}</button>
84 </div>
85 82
83 <button type="button" class="btn btn-primary" id="bt_back">Back</button>
84 <button type="submit" class="btn btn-primary" id="bt_update">{{ button }}</button>
85
86 </div>
87 </form>
86 88 {% endblock %}
87 89
88 90 {% block sidebar%}
@@ -90,56 +92,70
90 92 {% endblock %}
91 93
92 94 {% block extra-js%}
95 <script src="{% static 'js/dds_conversion.js' %}"></script>
93 96 <script type="text/javascript">
94 97
95 98 {% if dds_conf %}
96 99 $(document).ready(function() {
100 $("#suggest_frequencyA").on('change', function() {
101 updateBinaryFrequencies();
102 });
103
97 104 $('#dds_clock').click(function(event) {
98 105 clock = $("#dds_clock").text();
99 106 $("#suggest_clock").val(clock);
100 107 });
101 $('#dds_sampfreq').click(function(event) {
102 sampfreq = $("#dds_sampfreq").text();
103 $("#suggest_sampfreq").val(sampfreq);
108 $('#dds_frequencyA').click(function(event) {
109 sampfreq = $("#dds_frequencyA").text();
110 $("#suggest_frequencyA").val(sampfreq);
104 111 });
105 112 });
106 113 {% endif %}
114
107 115 {% if rc_conf %}
108 116 $(document).ready(function() {
109 117 $('#rc_clock').click(function(event) {
110 118 clock = $("#rc_clock").text();
111 119 $("#suggest_clock").val(clock);
112 120 });
113 $('#rc_sampfreq').click(function(event) {
114 sampfreq = $("#rc_sampfreq").text();
115 $("#suggest_sampfreq").val(sampfreq);
116 });
117 });
121 //$('#rc_sampfreq').click(function(event) {
122 // sampfreq = $("#rc_sampfreq").text();
123 // $("#suggest_sampfreq").val(sampfreq);
124 //});
125 });
118 126 {% endif %}
119 {% if jars_conf %}
127 {% if jars_conf %}
120 128 $(document).ready(function() {
121 129 $('#filter_clock').click(function(event) {
122 130 clock = $("#filter_clock").text();
123 131 $("#suggest_clock").val(clock);
124 132 });
125 $('#jars_sampfreq').click(function(event) {
126 sampfreq = $("#jars_sampfreq").text();
127 $("#suggest_sampfreq").val(sampfreq);
133 $('#filter_frequencyA').click(function(event) {
134 sampfreq = $("#filter_frequencyA").text();
135 $("#suggest_frequencyA").val(sampfreq);
136 updateBinaryFrequencies()
128 137 });
129 });
138 });
130 139 {% endif %}
131 140
141 function updateBinaryFrequencies() {
142 var clock = {{dds.clock}};
143 var multiplier = {{dds.multiplier}};
144 var freq = $("#suggest_frequencyA").val();
145 var mclock = clock*multiplier;
146 var freq_bin = freq2Binary(mclock, freq);
147 freq = binary2Freq(mclock, freq_bin);
148 $("#suggest_frequencyA").val(freq);
149 }
132 150
133
134
135 151 $(".clickable-row").click(function() {
136 152 document.location = $(this).data("href");
137 153 });
138
154
139 155 $("#bt_back").click(function() {
140 156 document.location = "{% url 'url_experiment' experiment.id%}";
141 157 });
142
143
158
159
144 160 </script>
145 {% endblock %} No newline at end of file
161 {% endblock %}
@@ -1009,6 +1009,7 def experiment_verify(request, id_exp):
1009 1009 #-------------------- JARS -----------------------:
1010 1010 if configuration.device.device_type.name == 'jars':
1011 1011 jars_conf = True
1012 jars = configuration
1012 1013 kwargs['jars_conf'] = jars_conf
1013 1014 filter_parms = configuration.filter_parms
1014 1015 filter_parms = ast.literal_eval(filter_parms)
@@ -1026,6 +1027,7 def experiment_verify(request, id_exp):
1026 1027 #--------------------- RC ----------------------:
1027 1028 if configuration.device.device_type.name == 'rc':
1028 1029 rc_conf = True
1030 rc = configuration
1029 1031 rc_parms = configuration.parms_to_dict()
1030 1032 if rc_parms['mix'] == 'True':
1031 1033 pass
@@ -1042,6 +1044,7 def experiment_verify(request, id_exp):
1042 1044 #-------------------- DDS ----------------------:
1043 1045 if configuration.device.device_type.name == 'dds':
1044 1046 dds_conf = True
1047 dds = configuration
1045 1048 dds_parms = configuration.parms_to_dict()
1046 1049
1047 1050 kwargs['dds_conf'] = dds_conf
@@ -1051,18 +1054,62 def experiment_verify(request, id_exp):
1051 1054 #------------Validation------------:
1052 1055 #Clock
1053 1056 if dds_conf and rc_conf and jars_conf:
1054 if filter_parms['clock'] != rc_parms['clock_in'] and rc_parms['clock_in'] != dds_parms['clock']:
1057 if float(filter_parms['clock']) != float(rc_parms['clock_in']) and float(rc_parms['clock_in']) != float(dds_parms['clock']):
1055 1058 messages.warning(request, "Devices don't have the same clock.")
1056 1059 elif rc_conf and jars_conf:
1057 if filter_parms['clock'] != rc_parms['clock_in']:
1060 if float(filter_parms['clock']) != float(rc_parms['clock_in']):
1058 1061 messages.warning(request, "Devices don't have the same clock.")
1059 1062 elif rc_conf and dds_conf:
1060 if rc_parms['clock_in'] != dds_parms['clock']:
1063 if float(rc_parms['clock_in']) != float(dds_parms['clock']):
1061 1064 messages.warning(request, "Devices don't have the same clock.")
1062 1065 if float(samp_freq_rc) != float(dds_parms['frequencyA']):
1063 1066 messages.warning(request, "Devices don't have the same Frequency A.")
1064 1067
1065 1068
1069 #------------POST METHOD------------:
1070 if request.method == 'POST':
1071 if request.POST['suggest_clock']:
1072 try:
1073 suggest_clock = float(request.POST['suggest_clock'])
1074 except:
1075 messages.warning(request, "Invalid value in CLOCK IN.")
1076 return redirect('url_verify_experiment', id_exp=experiment.id)
1077 else:
1078 suggest_clock = ""
1079 if suggest_clock:
1080 if rc_conf:
1081 rc.clock_in = suggest_clock
1082 rc.save()
1083 if jars_conf:
1084 filter_parms = jars.filter_parms
1085 filter_parms = ast.literal_eval(filter_parms)
1086 filter_parms['clock'] = suggest_clock
1087 jars.filter_parms = json.dumps(filter_parms)
1088 jars.save()
1089 kwargs['filter_parms'] = filter_parms
1090 if dds_conf:
1091 dds.clock = suggest_clock
1092 dds.save()
1093
1094 if request.POST['suggest_frequencyA']:
1095 try:
1096 suggest_frequencyA = float(request.POST['suggest_frequencyA'])
1097 except:
1098 messages.warning(request, "Invalid value in FREQUENCY A.")
1099 return redirect('url_verify_experiment', id_exp=experiment.id)
1100 else:
1101 suggest_frequencyA = ""
1102 if suggest_frequencyA:
1103 if jars_conf:
1104 filter_parms = jars.filter_parms
1105 filter_parms = ast.literal_eval(filter_parms)
1106 filter_parms['fch'] = suggest_frequencyA
1107 jars.filter_parms = json.dumps(filter_parms)
1108 jars.save()
1109 kwargs['filter_parms'] = filter_parms
1110 if dds_conf:
1111 dds.frequencyA_Mhz = request.POST['suggest_frequencyA']
1112 dds.save()
1066 1113
1067 1114 ###### SIDEBAR ######
1068 1115 kwargs.update(sidebar(experiment=experiment))
General Comments 0
You need to be logged in to leave comments. Login now