Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 161:6ee23cb3d6bb
Coding style fixes
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 04 Feb 2014 17:07:59 +0100 |
parents | f609fb29536b |
children | 1517a56163de |
comparison
equal
deleted
inserted
replaced
160:f609fb29536b | 161:6ee23cb3d6bb |
---|---|
60 double normalization; | 60 double normalization; |
61 int control; | 61 int control; |
62 }; | 62 }; |
63 | 63 |
64 | 64 |
65 #define ADEV_INIT(__channel, __normalization) \ | 65 #define ADEV(__channel, __normalization) \ |
66 { \ | 66 { \ |
67 .data = & ## __channel, \ | 67 .data = & ## __channel, \ |
68 .title = #__channel, \ | 68 .title = #__channel, \ |
69 .normalization = __normalization, \ | 69 .normalization = __normalization, \ |
70 .control = PANEL_ADEV_ ## __channel \ | 70 .control = PANEL_ADEV_ ## __channel \ |
88 Allan_AddFrequency(&(adev->allan), *(adev->data)); | 88 Allan_AddFrequency(&(adev->allan), *(adev->data)); |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 struct adev adevs[] = { | 92 struct adev adevs[] = { |
93 ADEV_INIT(Ch1, 1.84e12), | 93 ADEV(Ch1, 1.84e12), |
94 ADEV_INIT(Ch2, 10.0e3), | 94 ADEV(Ch2, 10.0e3), |
95 ADEV_INIT(Ch3, 429.228e12), | 95 ADEV(Ch3, 429.228e12), |
96 ADEV_INIT(Ch4, 275.0e3), | 96 ADEV(Ch4, 275.0e3), |
97 ADEV_INIT(Math1, 250.0e6), | 97 ADEV(Math1, 250.0e6), |
98 ADEV_INIT(Math2, 194.395e12), | 98 ADEV(Math2, 194.395e12), |
99 ADEV_INIT(Math3, 282.143e12), | 99 ADEV(Math3, 282.143e12), |
100 ADEV_INIT(Math4, 429.228e12), | 100 ADEV(Math4, 429.228e12), |
101 ADEV_INIT(Math5, 1.0), | 101 ADEV(Math5, 1.0), |
102 { NULL } | 102 { NULL } |
103 }; | 103 }; |
104 | 104 |
105 | 105 |
106 struct plot { | 106 struct plot { |
111 double max; | 111 double max; |
112 int control; | 112 int control; |
113 }; | 113 }; |
114 | 114 |
115 | 115 |
116 #define PLOT_INIT(__channel, __min, __max) \ | 116 #define PLOT(__channel, __min, __max) \ |
117 { \ | 117 { \ |
118 .data = & ## __channel, \ | 118 .data = & ## __channel, \ |
119 .title = #__channel, \ | 119 .title = #__channel, \ |
120 .min = __min, \ | 120 .min = __min, \ |
121 .max = __max, \ | 121 .max = __max, \ |
139 if (plot->plot.active) | 139 if (plot->plot.active) |
140 Plot_AddFrequency(&(plot->plot), *(plot->data)); | 140 Plot_AddFrequency(&(plot->plot), *(plot->data)); |
141 } | 141 } |
142 | 142 |
143 struct plot plots[] = { | 143 struct plot plots[] = { |
144 PLOT_INIT(Ch1, 54.999e6, 55.001e6), | 144 PLOT(Ch1, 54.999e6, 55.001e6), |
145 PLOT_INIT(Ch2, 0.0, 0.0), | 145 PLOT(Ch2, 0.0, 0.0), |
146 PLOT_INIT(Ch3, 0.0, 0.0), | 146 PLOT(Ch3, 0.0, 0.0), |
147 PLOT_INIT(Ch4, 0.0, 0.0), | 147 PLOT(Ch4, 0.0, 0.0), |
148 PLOT_INIT(Math1, 0.0, 0.0), | 148 PLOT(Math1, 0.0, 0.0), |
149 PLOT_INIT(Math2, 0.0, 0.0), | 149 PLOT(Math2, 0.0, 0.0), |
150 PLOT_INIT(Math3, 0.0, 0.0), | 150 PLOT(Math3, 0.0, 0.0), |
151 PLOT_INIT(Math4, 0.0, 0.0), | 151 PLOT(Math4, 0.0, 0.0), |
152 PLOT_INIT(Math5, 0.0, 0.0), | 152 PLOT(Math5, 0.0, 0.0), |
153 { NULL } | 153 { NULL } |
154 }; | 154 }; |
155 | 155 |
156 | 156 |
157 // 1xAD9956 DDS box | 157 // 1xAD9956 DDS box |
160 DDS4xAD9912_Data DDS4xAD9912; | 160 DDS4xAD9912_Data DDS4xAD9912; |
161 | 161 |
162 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5; | 162 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5; |
163 | 163 |
164 enum { | 164 enum { |
165 N_NONE, | 165 LO = 1, |
166 N_LO, | 166 HG = 2, |
167 N_HG, | 167 SR = 4, |
168 N_SR, | |
169 }; | 168 }; |
170 | 169 |
171 enum { | 170 enum { |
172 N_MEASUREMENT_NONE, | 171 N_MEASUREMENT_NONE, |
173 N_MEASUREMENT_INIT, | 172 N_MEASUREMENT_INIT, |
193 double SlopeTime1=40.0, DeltaT_1=20.0, delta_f_lock_1=500.0; | 192 double SlopeTime1=40.0, DeltaT_1=20.0, delta_f_lock_1=500.0; |
194 double SlopeTime2=40.0, DeltaT_2=20.0, delta_f_lock_2=500.0; | 193 double SlopeTime2=40.0, DeltaT_2=20.0, delta_f_lock_2=500.0; |
195 double SlopeTime3=40.0, DeltaT_3=20.0, delta_f_lock_3=500.0; | 194 double SlopeTime3=40.0, DeltaT_3=20.0, delta_f_lock_3=500.0; |
196 | 195 |
197 double DeltaDDS3=0.0; | 196 double DeltaDDS3=0.0; |
198 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6; | |
199 | 197 |
200 double t1, t2, t3; | 198 double t1, t2, t3; |
201 double f_rep_slope, f_beat_slope; | 199 double f_rep_slope, f_beat_slope; |
202 double f_rep_plus, f_rep_minus; | 200 double f_rep_plus, f_rep_minus; |
203 double f_beat_plus, f_beat_minus; | 201 double f_beat_plus, f_beat_minus; |
213 struct stat stat_math1, stat_ch2, stat_ch3, freq; | 211 struct stat stat_math1, stat_ch2, stat_ch3, freq; |
214 struct rollmean rollmean_ch1, rollmean_ch2, rollmean_ch3, rollmean_ch4; | 212 struct rollmean rollmean_ch1, rollmean_ch2, rollmean_ch3, rollmean_ch4; |
215 | 213 |
216 | 214 |
217 // dedrift | 215 // dedrift |
216 enum { | |
217 DEDRIFT_REFERENCE_MICROWAVE = 0, | |
218 DEDRIFT_REFERENCE_HG = 1, | |
219 }; | |
220 | |
218 struct dedrift { | 221 struct dedrift { |
219 int enabled; // dedrift enabled | 222 int enabled; // dedrift enabled |
220 int reference; // reference frequency | 223 int reference; // reference frequency |
221 int invert; // invert applied slope sign | 224 int invert; // invert applied slope sign |
222 int doubleslope; // double applied slope | 225 int doubleslope; // double applied slope |
227 double applied; // currently applied slope | 230 double applied; // currently applied slope |
228 double interval; // measurement duration | 231 double interval; // measurement duration |
229 double t0; // beginning of currrent measurement interval | 232 double t0; // beginning of currrent measurement interval |
230 }; | 233 }; |
231 | 234 |
232 enum { | |
233 DEDRIFT_REFERENCE_MICROWAVE = 0, | |
234 DEDRIFT_REFERENCE_HG = 1, | |
235 }; | |
236 | |
237 struct dedrift dedrift = { | 235 struct dedrift dedrift = { |
238 .enabled = FALSE, | 236 .enabled = FALSE, |
239 .reference = DEDRIFT_REFERENCE_MICROWAVE, | 237 .reference = DEDRIFT_REFERENCE_MICROWAVE, |
240 .invert = FALSE, | 238 .invert = FALSE, |
241 .doubleslope = FALSE, | 239 .doubleslope = FALSE, |
276 int nchan; | 274 int nchan; |
277 int control; | 275 int control; |
278 int write; | 276 int write; |
279 }; | 277 }; |
280 | 278 |
279 #define DATAFILE(__name, __data, __nchan, __control, __write) \ | |
280 { \ | |
281 .name = __name, \ | |
282 .data = __data, \ | |
283 .nchan = __nchan, \ | |
284 .control = __control, \ | |
285 .write = __write \ | |
286 } | |
281 | 287 |
282 struct datafile datafiles[] = { | 288 struct datafile datafiles[] = { |
283 { "Raw", event.data, 4, PANEL_SAVE_RAW, TRUE }, | 289 DATAFILE("Raw", event.data, 4, PANEL_SAVE_RAW, TRUE), |
284 { "DDS", DDS4xAD9912.frequency, 4, PANEL_SAVE_DDS, FALSE }, | 290 DATAFILE("DDS", DDS4xAD9912.frequency, 4, PANEL_SAVE_DDS, FALSE), |
285 { "Lo", &Math2, 1, PANEL_SAVE_LO, FALSE }, | 291 DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE), |
286 { "Hg", &Math3, 1, PANEL_SAVE_HG, FALSE }, | 292 DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE), |
287 { "Sr", &Math4, 1, PANEL_SAVE_SR, FALSE }, | 293 DATAFILE("Sr", &Math4, 1, PANEL_SAVE_SR, FALSE), |
288 { "Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE }, | 294 DATAFILE("Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE), |
289 { NULL, } | 295 { NULL, } |
290 }; | 296 }; |
291 | 297 |
292 | 298 |
293 static void write_data(const char *folder, const char *name, const char *id, | 299 static void write_data(const char *folder, const char *name, const char *id, |
294 const char *timestr, double utc, double *v, int nchan) | 300 const char *timestr, double utc, double *v, int nchan) |
451 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); | 457 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); |
452 | 458 |
453 // initialyze 1x AD9956 DDS box | 459 // initialyze 1x AD9956 DDS box |
454 DDSFox_Initialize(&DDS1xAD9956, "145.238.205.58", 6665, dedrift.freq0); | 460 DDSFox_Initialize(&DDS1xAD9956, "145.238.205.58", 6665, dedrift.freq0); |
455 | 461 |
456 Ch1 = Ch2 = Ch3 = Ch4 = 0.0; | |
457 | |
458 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); | 462 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); |
459 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); | 463 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); |
460 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); | 464 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); |
461 | 465 |
462 MathParser1 = initMathParser(); | 466 MathParser1 = initMathParser(); |
518 } | 522 } |
519 | 523 |
520 int CVICALLBACK CB_OnEventMain(int panel, int event, | 524 int CVICALLBACK CB_OnEventMain(int panel, int event, |
521 void *callbackData, int eventData1, int eventData2) | 525 void *callbackData, int eventData1, int eventData2) |
522 { | 526 { |
523 int ActiveControl ; | 527 int control, index; |
524 int StepIndex ; | 528 double step; |
525 double Step ; | 529 |
530 #define do_arrow(__DDS, __STEP) \ | |
531 do { \ | |
532 GetCtrlIndex(MainPanel, __STEP, &index); \ | |
533 if ((eventData1 == VAL_RIGHT_ARROW_VKEY) && (index < 14)) \ | |
534 SetCtrlIndex(MainPanel, __STEP, index + 1); \ | |
535 if ((eventData1 == VAL_LEFT_ARROW_VKEY) && (index > 0)) \ | |
536 SetCtrlIndex(MainPanel, __STEP, index - 1); \ | |
537 GetCtrlVal(MainPanel, __STEP, &step); \ | |
538 SetCtrlAttribute(MainPanel, __DDS, ATTR_INCR_VALUE, step); \ | |
539 } while (0) | |
526 | 540 |
527 switch (event) { | 541 switch (event) { |
528 case EVENT_KEYPRESS: | 542 case EVENT_KEYPRESS: |
529 switch (eventData1) // ie the code of the key which has been stroke | 543 /* key code */ |
530 { | 544 switch (eventData1) { |
531 case VAL_RIGHT_ARROW_VKEY : | 545 case VAL_RIGHT_ARROW_VKEY: |
532 ActiveControl = GetActiveCtrl(panel); | 546 case VAL_LEFT_ARROW_VKEY: |
533 if (ActiveControl==PANEL_DDS1 || ActiveControl==PANEL_DDS1STEP) { | 547 control = GetActiveCtrl(panel); |
534 GetCtrlIndex(MainPanel, PANEL_DDS1STEP, &StepIndex); | 548 switch (control) { |
535 if (StepIndex<14){ | 549 case PANEL_DDS1: |
536 SetCtrlIndex(MainPanel, PANEL_DDS1STEP, ++StepIndex) ; | 550 case PANEL_DDS1STEP: |
537 GetCtrlVal(MainPanel, PANEL_DDS1STEP, &Step); | 551 do_arrow(PANEL_DDS1, PANEL_DDS1STEP); |
538 SetCtrlAttribute(MainPanel, PANEL_DDS1, ATTR_INCR_VALUE, Step) ; | 552 break; |
539 }; | 553 case PANEL_DDS2: |
540 }; | 554 case PANEL_DDS2STEP: |
541 if (ActiveControl==PANEL_DDS2 || ActiveControl==PANEL_DDS2STEP) { | 555 do_arrow(PANEL_DDS2, PANEL_DDS2STEP); |
542 GetCtrlIndex(MainPanel, PANEL_DDS2STEP, &StepIndex); | 556 break; |
543 if (StepIndex<14){ | 557 case PANEL_DDS3: |
544 SetCtrlIndex(MainPanel, PANEL_DDS2STEP, ++StepIndex) ; | 558 case PANEL_DDS3STEP: |
545 GetCtrlVal(MainPanel, PANEL_DDS2STEP, &Step); | 559 do_arrow(PANEL_DDS3, PANEL_DDS3STEP); |
546 SetCtrlAttribute(MainPanel, PANEL_DDS2, ATTR_INCR_VALUE, Step) ; | 560 break; |
547 }; | 561 case PANEL_DDS4: |
548 }; | 562 case PANEL_DDS4STEP: |
549 if (ActiveControl==PANEL_DDS3|| ActiveControl==PANEL_DDS3STEP) { | 563 do_arrow(PANEL_DDS4, PANEL_DDS4STEP); |
550 GetCtrlIndex(MainPanel, PANEL_DDS3STEP, &StepIndex); | 564 break; |
551 if (StepIndex<14){ | 565 } |
552 SetCtrlIndex(MainPanel, PANEL_DDS3STEP, ++StepIndex) ; | |
553 GetCtrlVal(MainPanel, PANEL_DDS3STEP, &Step); | |
554 SetCtrlAttribute(MainPanel, PANEL_DDS3, ATTR_INCR_VALUE, Step) ; | |
555 }; | |
556 }; | |
557 if (ActiveControl==PANEL_DDS4|| ActiveControl==PANEL_DDS4STEP) { | |
558 GetCtrlIndex(MainPanel, PANEL_DDS4STEP, &StepIndex); | |
559 if (StepIndex<14){ | |
560 SetCtrlIndex(MainPanel, PANEL_DDS4STEP, ++StepIndex) ; | |
561 GetCtrlVal(MainPanel, PANEL_DDS4STEP, &Step); | |
562 SetCtrlAttribute(MainPanel, PANEL_DDS4, ATTR_INCR_VALUE, Step) ; | |
563 }; | |
564 }; | |
565 break; | |
566 case VAL_LEFT_ARROW_VKEY : | |
567 ActiveControl = GetActiveCtrl(panel); | |
568 if (ActiveControl==PANEL_DDS1 || ActiveControl==PANEL_DDS1STEP) { | |
569 GetCtrlIndex(MainPanel, PANEL_DDS1STEP, &StepIndex); | |
570 if (StepIndex>0){ | |
571 SetCtrlIndex(MainPanel, PANEL_DDS1STEP, --StepIndex) ; | |
572 GetCtrlVal(MainPanel, PANEL_DDS1STEP, &Step); | |
573 SetCtrlAttribute(MainPanel, PANEL_DDS1, ATTR_INCR_VALUE, Step) ; | |
574 }; | |
575 }; | |
576 if (ActiveControl==PANEL_DDS2 || ActiveControl==PANEL_DDS2STEP) { | |
577 GetCtrlIndex(MainPanel, PANEL_DDS2STEP, &StepIndex); | |
578 if (StepIndex>0){ | |
579 SetCtrlIndex(MainPanel, PANEL_DDS2STEP, --StepIndex) ; | |
580 GetCtrlVal(MainPanel, PANEL_DDS2STEP, &Step); | |
581 SetCtrlAttribute(MainPanel, PANEL_DDS2, ATTR_INCR_VALUE, Step) ; | |
582 }; | |
583 }; | |
584 if (ActiveControl==PANEL_DDS3 || ActiveControl==PANEL_DDS3STEP) { | |
585 GetCtrlIndex(MainPanel, PANEL_DDS3STEP, &StepIndex); | |
586 if (StepIndex>0){ | |
587 SetCtrlIndex(MainPanel, PANEL_DDS3STEP, --StepIndex) ; | |
588 GetCtrlVal(MainPanel, PANEL_DDS3STEP, &Step); | |
589 SetCtrlAttribute(MainPanel, PANEL_DDS3, ATTR_INCR_VALUE, Step) ; | |
590 }; | |
591 }; | |
592 if (ActiveControl==PANEL_DDS4 || ActiveControl==PANEL_DDS4STEP) { | |
593 GetCtrlIndex(MainPanel, PANEL_DDS4STEP, &StepIndex); | |
594 if (StepIndex>0){ | |
595 SetCtrlIndex(MainPanel, PANEL_DDS4STEP, --StepIndex) ; | |
596 GetCtrlVal(MainPanel, PANEL_DDS4STEP, &Step); | |
597 SetCtrlAttribute(MainPanel, PANEL_DDS4, ATTR_INCR_VALUE, Step) ; | |
598 }; | |
599 }; | |
600 break; | 566 break; |
601 case VAL_F2_VKEY : | 567 case VAL_F2_VKEY : |
602 SetActiveCtrl(MainPanel, PANEL_DDS1); | 568 SetActiveCtrl(MainPanel, PANEL_DDS1); |
603 break; | 569 break; |
604 case VAL_F3_VKEY : | 570 case VAL_F3_VKEY : |
608 SetActiveCtrl(MainPanel, PANEL_DDS3); | 574 SetActiveCtrl(MainPanel, PANEL_DDS3); |
609 break; | 575 break; |
610 case VAL_F5_VKEY : | 576 case VAL_F5_VKEY : |
611 SetActiveCtrl(MainPanel, PANEL_DDS4); | 577 SetActiveCtrl(MainPanel, PANEL_DDS4); |
612 break; | 578 break; |
613 }; | 579 } |
614 break; | 580 break; |
615 | |
616 } | 581 } |
617 return 0; | 582 return 0; |
618 } | 583 } |
619 | 584 |
620 int CVICALLBACK CB_OnStart (int panel, int control, int event, | 585 int CVICALLBACK CB_OnStart (int panel, int control, int event, |
967 f_rep_minus = f_rep_minus / nobs; | 932 f_rep_minus = f_rep_minus / nobs; |
968 f_beat_minus = f_beat_minus / nobs; | 933 f_beat_minus = f_beat_minus / nobs; |
969 nobs = 0; | 934 nobs = 0; |
970 | 935 |
971 // compute N2 | 936 // compute N2 |
972 double delta_f_rep = f_rep_minus - f_rep_plus; | 937 double delta_f_rep_m = f_rep_minus - f_rep_plus; |
938 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1; | |
939 | |
940 logmsg("delta frep: measured=%e expected=%e difference=%e", | |
941 delta_f_rep_m, delta_f_rep, delta_f_rep_m - delta_f_rep); | |
942 | |
973 N_2 = -Sign2 * (DeltaDDS3 + f_beat_minus - f_beat_plus) / delta_f_rep; | 943 N_2 = -Sign2 * (DeltaDDS3 + f_beat_minus - f_beat_plus) / delta_f_rep; |
974 SetCtrlVal(CalcNPanel, CALCN_N, N_2); | 944 SetCtrlVal(CalcNPanel, CALCN_N, N_2); |
975 | 945 |
976 // back to nominal frequency | 946 // back to nominal frequency |
977 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); | 947 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); |
1114 nobs = 0; | 1084 nobs = 0; |
1115 | 1085 |
1116 // check delta frep | 1086 // check delta frep |
1117 double delta_f_rep_m = f_rep_plus - f_rep_minus; | 1087 double delta_f_rep_m = f_rep_plus - f_rep_minus; |
1118 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1; | 1088 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1; |
1119 logmsg("delta frep: measured=%.12e Hz expected=%.12e Hz difference=%.12e", | 1089 |
1090 logmsg("delta frep: measured=%e expected=%e difference=%e", | |
1120 delta_f_rep_m, delta_f_rep, delta_f_rep_m - delta_f_rep); | 1091 delta_f_rep_m, delta_f_rep, delta_f_rep_m - delta_f_rep); |
1121 | 1092 |
1122 logmsg("f_beat_minus=%.12e", f_beat_minus); | 1093 logmsg("f_beat_minus=%e", f_beat_minus); |
1123 logmsg("f_beat_plus =%.12e", f_beat_plus); | 1094 logmsg("f_beat_plus =%e", f_beat_plus); |
1124 | 1095 |
1125 // compute N3 | 1096 // compute N3 |
1126 double delta_f_beat = f_beat_plus - f_beat_minus + 2.0 * Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; | 1097 double delta_f_beat = f_beat_plus - f_beat_minus + 2.0 * Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; |
1127 double delta_f_beat_expected = delta_f_rep * N3; | 1098 double delta_f_beat_expected = delta_f_rep * N3; |
1128 logmsg("delta fbeat: measured=%.12e expected=%.12e difference=%.12e", | 1099 |
1100 logmsg("delta fbeat: measured=%e expected=%e difference=%e", | |
1129 delta_f_beat, delta_f_beat_expected, delta_f_beat - delta_f_beat_expected); | 1101 delta_f_beat, delta_f_beat_expected, delta_f_beat - delta_f_beat_expected); |
1102 | |
1130 N_3 = delta_f_beat / delta_f_rep; | 1103 N_3 = delta_f_beat / delta_f_rep; |
1104 SetCtrlVal(CalcNPanel, CALCN_N, N_3); | |
1105 | |
1131 logmsg("measured N3=%.3f", N_3); | 1106 logmsg("measured N3=%.3f", N_3); |
1132 SetCtrlVal(CalcNPanel, CALCN_N, N_3); | |
1133 | 1107 |
1134 // back to nominal frep | 1108 // back to nominal frep |
1135 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); | 1109 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); |
1136 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); | 1110 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); |
1137 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); | 1111 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); |
1559 | 1533 |
1560 switch (event) { | 1534 switch (event) { |
1561 case EVENT_COMMIT: | 1535 case EVENT_COMMIT: |
1562 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measure); | 1536 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measure); |
1563 switch (measure) { | 1537 switch (measure) { |
1564 case N_LO: | 1538 case LO: |
1565 N1 = round(N_1); | 1539 N1 = round(N_1); |
1566 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1); | 1540 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1); |
1567 break; | 1541 break; |
1568 case N_HG: | 1542 case HG: |
1569 N2 = round(N_2); | 1543 N2 = round(N_2); |
1570 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2); | 1544 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2); |
1571 break; | 1545 break; |
1572 case N_SR: | 1546 case SR: |
1573 N3 = round(N_3); | 1547 N3 = round(N_3); |
1574 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); | 1548 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); |
1575 break; | 1549 break; |
1576 } | 1550 } |
1577 break; | 1551 break; |
1589 case EVENT_COMMIT: | 1563 case EVENT_COMMIT: |
1590 switch (control) { | 1564 switch (control) { |
1591 case PANEL_N1CALCULUS: | 1565 case PANEL_N1CALCULUS: |
1592 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); | 1566 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); |
1593 if (! visible) { | 1567 if (! visible) { |
1594 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, N_LO); | 1568 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, LO); |
1595 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Lo"); | 1569 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Lo"); |
1596 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_1); | 1570 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_1); |
1597 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime1); | 1571 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime1); |
1598 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_1 / 1000.0); | 1572 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_1 / 1000.0); |
1599 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); | 1573 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); |
1601 } | 1575 } |
1602 break; | 1576 break; |
1603 case PANEL_N2CALCULUS: | 1577 case PANEL_N2CALCULUS: |
1604 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); | 1578 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); |
1605 if (! visible) { | 1579 if (! visible) { |
1606 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, N_HG); | 1580 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, HG); |
1607 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Hg"); | 1581 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Hg"); |
1608 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_2); | 1582 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_2); |
1609 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime2); | 1583 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime2); |
1610 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_2 / 1000.0); | 1584 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_2 / 1000.0); |
1611 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); | 1585 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); |
1613 } | 1587 } |
1614 break; | 1588 break; |
1615 case PANEL_N3CALCULUS: | 1589 case PANEL_N3CALCULUS: |
1616 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); | 1590 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); |
1617 if (! visible) { | 1591 if (! visible) { |
1618 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, N_SR); | 1592 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, SR); |
1619 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Sr"); | 1593 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Sr"); |
1620 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_3); | 1594 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_3); |
1621 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime3); | 1595 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime3); |
1622 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_3 / 1000.0); | 1596 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_3 / 1000.0); |
1623 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); | 1597 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); |
1637 | 1611 |
1638 switch (event) { | 1612 switch (event) { |
1639 case EVENT_COMMIT: | 1613 case EVENT_COMMIT: |
1640 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); | 1614 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); |
1641 switch (measuring) { | 1615 switch (measuring) { |
1642 case N_LO: | 1616 case LO: |
1643 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_1); | 1617 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_1); |
1644 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime1); | 1618 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime1); |
1645 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_1); | 1619 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_1); |
1646 // convert from kHz to Hz | 1620 // convert from kHz to Hz |
1647 delta_f_lock_1 = delta_f_lock_1 * 1000.0; | 1621 delta_f_lock_1 = delta_f_lock_1 * 1000.0; |
1648 Measuring_1 = TRUE; | 1622 Measuring_1 = TRUE; |
1649 break; | 1623 break; |
1650 case N_HG: | 1624 case HG: |
1651 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_2); | 1625 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_2); |
1652 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime2); | 1626 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime2); |
1653 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_2); | 1627 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_2); |
1654 // convert from kHz to Hz | 1628 // convert from kHz to Hz |
1655 delta_f_lock_2 = delta_f_lock_2 * 1000.0; | 1629 delta_f_lock_2 = delta_f_lock_2 * 1000.0; |
1656 Measuring_2 = TRUE; | 1630 Measuring_2 = TRUE; |
1657 break; | 1631 break; |
1658 case N_SR: | 1632 case SR: |
1659 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_3); | 1633 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_3); |
1660 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime3); | 1634 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime3); |
1661 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_3); | 1635 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_3); |
1662 // convert from kHz to Hz | 1636 // convert from kHz to Hz |
1663 delta_f_lock_3 = delta_f_lock_3 * 1000.0; | 1637 delta_f_lock_3 = delta_f_lock_3 * 1000.0; |
1677 switch (event) { | 1651 switch (event) { |
1678 case EVENT_COMMIT: | 1652 case EVENT_COMMIT: |
1679 HidePanel(CalcNPanel); | 1653 HidePanel(CalcNPanel); |
1680 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); | 1654 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); |
1681 switch (measuring) { | 1655 switch (measuring) { |
1682 case N_LO: | 1656 case LO: |
1683 Measuring_1 = FALSE; | 1657 Measuring_1 = FALSE; |
1684 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); | 1658 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); |
1685 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); | 1659 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); |
1686 break; | 1660 break; |
1687 case N_HG: | 1661 case HG: |
1688 Measuring_2 = FALSE; | 1662 Measuring_2 = FALSE; |
1689 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); | 1663 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); |
1690 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); | 1664 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); |
1691 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); | 1665 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); |
1692 break; | 1666 break; |
1693 case N_SR: | 1667 case SR: |
1694 Measuring_3 = FALSE; | 1668 Measuring_3 = FALSE; |
1695 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); | 1669 DDS4xAD9912_RampFrequency(&DDS4xAD9912, 1, f0_DDS1, FREP_STEP_SIZE); |
1696 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); | 1670 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, f0_DDS2); |
1697 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); | 1671 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, f0_DDS3); |
1698 break; | 1672 break; |
1931 SetCtrlVal(EstimateNPanel, ESTIMATEN_FREP, 250e6 + Math1); | 1905 SetCtrlVal(EstimateNPanel, ESTIMATEN_FREP, 250e6 + Math1); |
1932 switch (control) { | 1906 switch (control) { |
1933 case PANEL_ESTIMATE_N2: | 1907 case PANEL_ESTIMATE_N2: |
1934 SetCtrlVal(EstimateNPanel, ESTIMATEN_WAVELENGTH, HG_WAVELENGTH); | 1908 SetCtrlVal(EstimateNPanel, ESTIMATEN_WAVELENGTH, HG_WAVELENGTH); |
1935 SetPanelAttribute(panel, ATTR_TITLE, "Estimate N_Hg"); | 1909 SetPanelAttribute(panel, ATTR_TITLE, "Estimate N_Hg"); |
1936 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, N_HG); | 1910 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, HG); |
1937 break; | 1911 break; |
1938 case PANEL_ESTIMATE_N3: | 1912 case PANEL_ESTIMATE_N3: |
1939 SetCtrlVal(EstimateNPanel, ESTIMATEN_WAVELENGTH, SR_WAVELENGTH); | 1913 SetCtrlVal(EstimateNPanel, ESTIMATEN_WAVELENGTH, SR_WAVELENGTH); |
1940 SetPanelAttribute(panel, ATTR_TITLE, "Estimate N_Sr"); | 1914 SetPanelAttribute(panel, ATTR_TITLE, "Estimate N_Sr"); |
1941 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, N_SR); | 1915 SetPanelAttribute(panel, ATTR_CALLBACK_DATA, SR); |
1942 break; | 1916 break; |
1943 } | 1917 } |
1944 break; | 1918 break; |
1945 } | 1919 } |
1946 return 0; | 1920 return 0; |
1970 switch (event) | 1944 switch (event) |
1971 { | 1945 { |
1972 case EVENT_COMMIT: | 1946 case EVENT_COMMIT: |
1973 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &estimate); | 1947 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &estimate); |
1974 switch (estimate) { | 1948 switch (estimate) { |
1975 case N_HG: | 1949 case HG: |
1976 GetCtrlVal(panel, ESTIMATEN_N, &N2); | 1950 GetCtrlVal(panel, ESTIMATEN_N, &N2); |
1977 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N2); | 1951 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N2); |
1978 break; | 1952 break; |
1979 case N_SR: | 1953 case SR: |
1980 GetCtrlVal(panel, ESTIMATEN_N, &N3); | 1954 GetCtrlVal(panel, ESTIMATEN_N, &N3); |
1981 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); | 1955 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); |
1982 break; | 1956 break; |
1983 } | 1957 } |
1984 HidePanel(panel); | 1958 HidePanel(panel); |