comparison FXAnalyse.c @ 2:bd7501b65f56

Implement reference selection (microwave or Hg cavity) for slope cancelling
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 03 Jul 2012 13:11:40 +0200
parents a6fb5d3d0ec0
children 7028b7982af3
comparison
equal deleted inserted replaced
1:a6fb5d3d0ec0 2:bd7501b65f56
158 double MoyMath2 = 0.0, CenterFrequencyCh2 = 0.0; 158 double MoyMath2 = 0.0, CenterFrequencyCh2 = 0.0;
159 volatile bool CenterFrequencyCh2ToDetermine=FALSE; 159 volatile bool CenterFrequencyCh2ToDetermine=FALSE;
160 160
161 double limitotakoff=70.0; 161 double limitotakoff=70.0;
162 162
163 163 enum {
164 164 SLOPE_REFERENCE_MICROWAVE = 0,
165 SLOPE_REFERENCE_HG_CAVITY = 1,
166 };
167
168 int slopeReference = SLOPE_REFERENCE_MICROWAVE;
165 169
166 ////////////////////////////////// 170 //////////////////////////////////
167 // Keep Centered Variables 171 // Keep Centered Variables
168 172
169 volatile bool KeepCentering=FALSE; 173 volatile bool KeepCentering=FALSE;
632 636
633 GetFileInfo(LogFileName, &LogFileSize) ; 637 GetFileInfo(LogFileName, &LogFileSize) ;
634 638
635 if (LogFileSize > OldLogFilePtr+2*FXLINELENGTH-2) { // if a complete newline has been written 639 if (LogFileSize > OldLogFilePtr+2*FXLINELENGTH-2) { // if a complete newline has been written
636 640
637 SuspendTimerCallbacks ; 641 SuspendTimerCallbacks() ;
638 642
639 // Open Log file and get to the beginning of newly completed line 643 // Open Log file and get to the beginning of newly completed line
640 LogFile = OpenFile(LogFileName, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII) ; 644 LogFile = OpenFile(LogFileName, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII) ;
641 OldLogFilePtr += FXLINELENGTH; 645 OldLogFilePtr += FXLINELENGTH;
642 SetFilePtr(LogFile, OldLogFilePtr, 0) ; 646 SetFilePtr(LogFile, OldLogFilePtr, 0) ;
1294 * Slope Cancelling 1298 * Slope Cancelling
1295 */ 1299 */
1296 1300
1297 if (SlopeMeasuring == TRUE) 1301 if (SlopeMeasuring == TRUE)
1298 { 1302 {
1303 double currentFreq;
1304
1305 /* select reference */
1306 switch (slopeReference) {
1307 case SLOPE_REFERENCE_MICROWAVE:
1308 currentFreq = Math2;
1309 break;
1310 case SLOPE_REFERENCE_HG_CAVITY:
1311 currentFreq = Math3;
1312 break;
1313 }
1314
1299 if (utc-SlopeMeasuringTimeBegin > TimetoSlope) 1315 if (utc-SlopeMeasuringTimeBegin > TimetoSlope)
1300 { 1316 {
1301 Nratio = Nratio + 1; 1317 Nratio = Nratio + 1;
1302 1318
1303 if (Nratio >= 1) 1319 if (Nratio >= 1)
1341 else 1357 else
1342 { 1358 {
1343 if (nstabilisationSlopeMeasuring < 5) 1359 if (nstabilisationSlopeMeasuring < 5)
1344 { 1360 {
1345 nstabilisationSlopeMeasuring = nstabilisationSlopeMeasuring + 1; 1361 nstabilisationSlopeMeasuring = nstabilisationSlopeMeasuring + 1;
1346 Math2_slope = Math2; 1362 Math2_slope = currentFreq;
1347 } 1363 }
1348 else 1364 else
1349 { 1365 {
1350 if ((Math2-Math2_slope) < limitotakoff && (Math2-Math2_slope) > -limitotakoff) 1366 if ((currentFreq-Math2_slope) < limitotakoff && (currentFreq-Math2_slope) > -limitotakoff)
1351 { 1367 {
1352 N_Math2slope = N_Math2slope + 1; 1368 N_Math2slope = N_Math2slope + 1;
1353 Math2_slope = Math2; 1369 Math2_slope = currentFreq;
1354 Moy_Math2slope = ((N_Math2slope-1)*Moy_Math2slope + Math2_slope)/N_Math2slope; 1370 Moy_Math2slope = ((N_Math2slope-1)*Moy_Math2slope + Math2_slope)/N_Math2slope;
1355 Slope_Math2slope = (Slope_Math2slope*(N_Math2slope-2) + 6*(Math2_slope-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1) ; 1371 Slope_Math2slope = (Slope_Math2slope*(N_Math2slope-2) + 6*(Math2_slope-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1) ;
1356 } 1372 }
1357 else 1373 else
1358 { 1374 {
1538 printf("new file : %s \r\n\r\n",Date, Time, LogFileName); 1554 printf("new file : %s \r\n\r\n",Date, Time, LogFileName);
1539 Acquiring = TRUE ; 1555 Acquiring = TRUE ;
1540 OldLogFilePtr = 2; 1556 OldLogFilePtr = 2;
1541 } 1557 }
1542 1558
1543 ResumeTimerCallbacks ; 1559 ResumeTimerCallbacks() ;
1544 1560
1545 } ; 1561 } ;
1546 1562
1547 break; 1563 break;
1548 case FALSE: 1564 case FALSE:
2868 break; 2884 break;
2869 2885
2870 } 2886 }
2871 return 0; 2887 return 0;
2872 } 2888 }
2889
2890 int CVICALLBACK SlopeReference_cb (int panel, int control, int event,
2891 void *callbackData, int eventData1, int eventData2)
2892 {
2893 switch (event)
2894 {
2895 case EVENT_COMMIT:
2896 GetCtrlVal(MainPanel, PANEL_SLOPE_REFERENCE, &slopeReference);
2897 break;
2898 }
2899 return 0;
2900 }