Mercurial > hg > fxanalyse
diff FXAnalyse.c @ 223:7875436125dd
Variable names clarification and cleanup
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 18 Sep 2014 18:03:27 +0200 |
parents | db051dbf8d6e |
children | c244a1ecb6c3 |
line wrap: on
line diff
--- a/FXAnalyse.c Thu Sep 18 18:02:20 2014 +0200 +++ b/FXAnalyse.c Thu Sep 18 18:03:27 2014 +0200 @@ -241,24 +241,24 @@ N_MEASUREMENT_FREP_MINUS, }; -int Measuring_1 = N_MEASUREMENT_NONE; -int Measuring_2 = N_MEASUREMENT_NONE; -int Measuring_3 = N_MEASUREMENT_NONE; +int n_measurement_1 = N_MEASUREMENT_NONE; +int n_measurement_2 = N_MEASUREMENT_NONE; +int n_measurement_3 = N_MEASUREMENT_NONE; int nobs = 0; int settling = 0; double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, f0_DDS4, df_DDS3; -double SlopeTime1 = 40.0, DeltaT_1 = 40.0, delta_f_lock_1 = 500e3; -double SlopeTime2 = 40.0, DeltaT_2 = 40.0, delta_f_lock_2 = 500e3; -double SlopeTime3 = 40.0, DeltaT_3 = 40.0, delta_f_lock_3 = 500e3; +double slope_time_1 = 40.0, integration_time_1 = 40.0, delta_f_lock_1 = 500e3; +double slope_time_2 = 40.0, integration_time_2 = 40.0, delta_f_lock_2 = 500e3; +double slope_time_3 = 40.0, integration_time_3 = 40.0, delta_f_lock_3 = 500e3; double t1, t2, t3; double f_rep_slope, f_beat_slope; double f_rep_plus, f_rep_minus; double f_beat_plus, f_beat_minus; -double N_measured; + // Beatnote sign determination is done stepping the repetition rate by // stepping the comb phase-lock offset frequency f_lock generated by @@ -752,6 +752,7 @@ logmsg("Error!"); value = value - read; + // unpack event utc = event.time.tv_sec + event.time.tv_usec * 1e-6; Ch1 = event.data[0]; Ch2 = event.data[1]; @@ -792,7 +793,7 @@ // N measurement - switch (Measuring_1) { + switch (n_measurement_1) { case N_MEASUREMENT_NONE: // not measuring @@ -815,7 +816,7 @@ f_rep_plus = f_rep_minus = 0.0; // next step - Measuring_1 += 1; + n_measurement_1 += 1; break; case N_MEASUREMENT_SLOPE: @@ -823,7 +824,7 @@ stat_accumulate(&stat_math1, Math1); - if ((utc - t1) > SlopeTime1) { + if ((utc - t1) > slope_time_1) { f_rep_slope = stat_math1.slope; // frep positive step @@ -834,7 +835,7 @@ settling = 3; // next step - Measuring_1 += 1; + n_measurement_1 += 1; } break; @@ -853,7 +854,7 @@ settling = 3; // next step - Measuring_1 += 1; + n_measurement_1 += 1; break; case N_MEASUREMENT_FREP_PLUS: @@ -868,7 +869,7 @@ f_rep_plus += Math1 - f_rep_slope * (utc - t2); nobs += 1; - if ((utc - t2) > DeltaT_1) { + if ((utc - t2) > integration_time_1) { f_rep_plus = f_rep_plus / nobs; nobs = 0; @@ -880,7 +881,7 @@ settling = 3; // next step - Measuring_1 += 1; + n_measurement_1 += 1; } break; @@ -896,14 +897,14 @@ f_rep_minus += Math1 - f_rep_slope * (utc - t2); nobs += 1; - if ((utc - t3) > DeltaT_1) { + if ((utc - t3) > integration_time_1) { f_rep_minus = f_rep_minus / nobs; nobs = 0; // compute N1 double delta_f_rep = f_rep_minus - f_rep_plus; - N_measured = Sign1 * 2 * Ndiv * delta_f_lock_1 / delta_f_rep; - SetCtrlVal(CalcNPanel, CALCN_N, N_measured); + double measured = Sign1 * 2 * Ndiv * delta_f_lock_1 / delta_f_rep; + SetCtrlVal(CalcNPanel, CALCN_N, measured); // back to nominal frep ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); @@ -912,12 +913,12 @@ SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); // done - Measuring_1 = N_MEASUREMENT_NONE; + n_measurement_1 = N_MEASUREMENT_NONE; } break; } - switch (Measuring_2) { + switch (n_measurement_2) { case N_MEASUREMENT_NONE: // not measuring @@ -943,7 +944,7 @@ f_beat_plus = f_beat_minus = 0.0; // next step - Measuring_2 += 1; + n_measurement_2 += 1; break; case N_MEASUREMENT_SLOPE: @@ -952,7 +953,7 @@ stat_accumulate(&stat_math1, Math1); stat_accumulate(&stat_ch2, Ch2); - if ((utc - t1) > SlopeTime2) { + if ((utc - t1) > slope_time_2) { f_rep_slope = stat_math1.slope; f_beat_slope = stat_ch2.slope; @@ -971,7 +972,7 @@ settling = 3; // next step - Measuring_2 += 1; + n_measurement_2 += 1; } break; @@ -995,7 +996,7 @@ settling = 3; // next step - Measuring_2 += 1; + n_measurement_2 += 1; break; case N_MEASUREMENT_FREP_PLUS: @@ -1011,7 +1012,7 @@ f_beat_plus += Ch2 - f_beat_slope * (utc - t2); nobs += 1; - if ((utc - t2) > DeltaT_2) { + if ((utc - t2) > integration_time_2) { f_rep_plus = f_rep_plus / nobs; f_beat_plus = f_beat_plus / nobs; nobs = 0; @@ -1031,7 +1032,7 @@ settling = 3; // next step - Measuring_2 += 1; + n_measurement_2 += 1; } break; @@ -1048,7 +1049,7 @@ f_beat_minus += Ch2 + f_beat_slope * (utc - t2); nobs += 1; - if ((utc -t3) > DeltaT_2) { + if ((utc -t3) > integration_time_2) { f_rep_minus = f_rep_minus / nobs; f_beat_minus = f_beat_minus / nobs; nobs = 0; @@ -1061,8 +1062,8 @@ logmsg("delta frep: measured=%e expected=%e difference=%e rel=%e", delta_f_rep_m, delta_f_rep, delta, delta / delta_f_rep); - N_measured = -Sign2 * (df_DDS3 + f_beat_minus - f_beat_plus) / delta_f_rep; - SetCtrlVal(CalcNPanel, CALCN_N, N_measured); + double measured = -Sign2 * (df_DDS3 + f_beat_minus - f_beat_plus) / delta_f_rep; + SetCtrlVal(CalcNPanel, CALCN_N, measured); // back to nominal frequency ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); @@ -1073,12 +1074,12 @@ SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); // done - Measuring_2 = N_MEASUREMENT_NONE; + n_measurement_2 = N_MEASUREMENT_NONE; } break; } - switch (Measuring_3) { + switch (n_measurement_3) { case N_MEASUREMENT_NONE: // not measuring N3 @@ -1104,7 +1105,7 @@ f_beat_plus = f_beat_minus = 0.0; // next step - Measuring_3 += 1; + n_measurement_3 += 1; break; case N_MEASUREMENT_SLOPE: @@ -1116,7 +1117,7 @@ stat_accumulate(&stat_math1, Math1); stat_accumulate(&stat_ch3, Ch3); - if (utc - t1 > SlopeTime3) { + if (utc - t1 > slope_time_3) { // slope measurement f_rep_slope = stat_math1.slope; f_beat_slope = stat_ch3.slope; @@ -1137,7 +1138,7 @@ settling = 3; // next step - Measuring_3 += 1; + n_measurement_3 += 1; } break; @@ -1157,7 +1158,7 @@ settling = 3; // next step - Measuring_3 += 1; + n_measurement_3 += 1; break; case N_MEASUREMENT_FREP_PLUS: @@ -1173,7 +1174,7 @@ f_beat_plus += Ch3 - f_beat_slope * (utc - t2); nobs += 1; - if (utc - t2 > DeltaT_3) { + if (utc - t2 > integration_time_3) { f_rep_plus = f_rep_plus / nobs; f_beat_plus = f_beat_plus / nobs; nobs = 0; @@ -1191,7 +1192,7 @@ settling = 3; // next step - Measuring_3 += 1; + n_measurement_3 += 1; } break; @@ -1208,7 +1209,7 @@ f_beat_minus += Ch3 - f_beat_slope * (utc - t2); nobs += 1; - if (utc - t3 > DeltaT_3) { + if (utc - t3 > integration_time_3) { f_rep_minus = f_rep_minus / nobs; f_beat_minus = f_beat_minus / nobs; nobs = 0; @@ -1228,10 +1229,10 @@ logmsg("delta fbeat: measured=%e expected=%e difference=%e", delta_f_beat, delta_f_beat_expected, delta_f_beat - delta_f_beat_expected); - N_measured = delta_f_beat / delta_f_rep; - SetCtrlVal(CalcNPanel, CALCN_N, N_measured); + double measured = delta_f_beat / delta_f_rep; + SetCtrlVal(CalcNPanel, CALCN_N, measured); - logmsg("measured N3=%.3f", N_measured); + logmsg("measured N3=%.3f", measured); // back to nominal frep ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); @@ -1242,7 +1243,7 @@ SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); // done - Measuring_3 = N_MEASUREMENT_NONE; + n_measurement_3 = N_MEASUREMENT_NONE; } break; } @@ -1577,21 +1578,23 @@ void *callbackData, int eventData1, int eventData2) { int measure; - + double measured; + switch (event) { case EVENT_COMMIT: GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measure); + GetCtrlVal(panel, CALCN_N, &measured); switch (measure) { case LO: - N1 = round(N_measured); + N1 = round(measured); SetCtrlVal(MainPanel, PANEL_N1, N1); break; case HG: - N2 = round(N_measured); + N2 = round(measured); SetCtrlVal(MainPanel, PANEL_N2, N2); break; case SR: - N3 = round(N_measured); + N3 = round(measured); SetCtrlVal(MainPanel, PANEL_N3, N3); break; } @@ -1613,8 +1616,8 @@ if (! visible) { SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, LO); SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Lo"); - SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_1); - SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime1); + SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time_1); + SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time_1); SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_1 / 1000.0); SetCtrlVal(CalcNPanel, CALCN_N, 0.0); DisplayPanel(CalcNPanel); @@ -1625,8 +1628,8 @@ if (! visible) { SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, HG); SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Hg"); - SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_2); - SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime2); + SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time_2); + SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time_2); SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_2 / 1000.0); SetCtrlVal(CalcNPanel, CALCN_N, 0.0); DisplayPanel(CalcNPanel); @@ -1637,8 +1640,8 @@ if (! visible) { SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, SR); SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Sr"); - SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_3); - SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime3); + SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, integration_time_3); + SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, slope_time_3); SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_3 / 1000.0); SetCtrlVal(CalcNPanel, CALCN_N, 0.0); DisplayPanel(CalcNPanel); @@ -1660,28 +1663,28 @@ GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); switch (measuring) { case LO: - GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_1); - GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime1); + GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time_1); + GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time_1); GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_1); // convert from kHz to Hz delta_f_lock_1 = delta_f_lock_1 * 1000.0; - Measuring_1 = TRUE; + n_measurement_1 = TRUE; break; case HG: - GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_2); - GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime2); + GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time_2); + GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time_2); GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_2); // convert from kHz to Hz delta_f_lock_2 = delta_f_lock_2 * 1000.0; - Measuring_2 = TRUE; + n_measurement_2 = TRUE; break; case SR: - GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_3); - GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime3); + GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &integration_time_3); + GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &slope_time_3); GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_3); // convert from kHz to Hz delta_f_lock_3 = delta_f_lock_3 * 1000.0; - Measuring_3 = TRUE; + n_measurement_3 = TRUE; break; } break; @@ -1700,18 +1703,18 @@ GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); switch (measuring) { case LO: - Measuring_1 = FALSE; + n_measurement_1 = FALSE; ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); break; case HG: - Measuring_2 = FALSE; + n_measurement_2 = FALSE; ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); break; case SR: - Measuring_3 = FALSE; + n_measurement_3 = FALSE; ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); ad9912_set_frequency_w(&ad9912, 3, f0_DDS4);