comparison FXAnalyse.c @ 35:914e0f16b19a

Update displayed dedrifting slope when it is modified and not at each timer tick
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 03 Oct 2012 14:27:24 +0200
parents 1e4b8ba97faf
children 5e81800fe354
comparison
equal deleted inserted replaced
34:1e4b8ba97faf 35:914e0f16b19a
571 571
572 double FrequencyToChange=0.0; 572 double FrequencyToChange=0.0;
573 double DeltaCh2=0.0; 573 double DeltaCh2=0.0;
574 double DeltaCh4=0.0; 574 double DeltaCh4=0.0;
575 575
576 double ActualFrequ=0.0;
577 double ActualSlope=0.0;
578
579 switch (event) 576 switch (event)
580 { 577 {
581 case EVENT_TIMER_TICK: 578 case EVENT_TIMER_TICK:
582 switch(Acquiring) 579 switch(Acquiring)
583 { 580 {
650 SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3) ; 647 SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3) ;
651 SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4) ; 648 SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4) ;
652 SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1); 649 SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1);
653 SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2); 650 SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2);
654 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); 651 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3);
655 SetCtrlVal(CalcN1Panel, CALCN1_N, N_1) ; 652 SetCtrlVal(CalcN2Panel, CALCN2_N, N_2);
656 SetCtrlVal(CalcN1Panel, CALCN1_SLOPE, Slope_1) ; 653 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2);
657 SetCtrlVal(CalcN2Panel, CALCN2_N, N_2) ;
658 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2) ;
659 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
660 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2); 654 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2);
661 SetCtrlVal(MainPanel, PANEL_LED1, SlopeMeasuring); 655 SetCtrlVal(MainPanel, PANEL_LED1, SlopeMeasuring);
662 SetCtrlVal(MainPanel, PANEL_LED2, OnSlopeCancelling); 656 SetCtrlVal(MainPanel, PANEL_LED2, OnSlopeCancelling);
663 // Treat data 657 // Treat data
664 658
1341 } 1335 }
1342 Nratio = 0; 1336 Nratio = 0;
1343 MoyMath2 = 0.0; 1337 MoyMath2 = 0.0;
1344 } 1338 }
1345 1339
1340 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
1346 DDSFox_Set(&DDS1xAD9956, FoxFrequ, SlopeMath2); 1341 DDSFox_Set(&DDS1xAD9956, FoxFrequ, SlopeMath2);
1347 1342
1348 nstabilisationSlopeMeasuring = 0; 1343 nstabilisationSlopeMeasuring = 0;
1349 SlopeMeasuringTimeBegin = utc; 1344 SlopeMeasuringTimeBegin = utc;
1350 1345
1365 Moy_Math2slope = ((N_Math2slope-1)*Moy_Math2slope + Math2_slope)/N_Math2slope; 1360 Moy_Math2slope = ((N_Math2slope-1)*Moy_Math2slope + Math2_slope)/N_Math2slope;
1366 Slope_Math2slope = (Slope_Math2slope*(N_Math2slope-2) + 6*(Math2_slope-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1) ; 1361 Slope_Math2slope = (Slope_Math2slope*(N_Math2slope-2) + 6*(Math2_slope-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1) ;
1367 } 1362 }
1368 else 1363 else
1369 { 1364 {
1370 if (AutoStopSlopeCancellingIfDelock) 1365 if (AutoStopSlopeCancellingIfDelock) {
1371 { 1366 // stop slope cancelling if the comb is not locked
1367
1368 double frequency = DEDRIFT_DDS_FREQUENCY;
1369 if (KeepFrequ)
1370 frequency = DDSFox_ReadFreq(&DDS1xAD9956);
1371
1372 if (! KeepSlope) {
1373 SlopeMath2 = 0.0;
1374 OnSlopeCancelling = FALSE;
1375 }
1372 1376
1373 /* 1377 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
1374 * stop slope cancelling if the comb is not locked 1378 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
1375 */
1376
1377 if (KeepFrequ == TRUE)
1378 {
1379 ActualFrequ = DDSFox_ReadFreq(&DDS1xAD9956);
1380 }
1381 else
1382 {
1383 ActualFrequ = DEDRIFT_DDS_FREQUENCY;
1384 }
1385
1386 if (KeepSlope == TRUE)
1387 {
1388 ActualSlope = SlopeMath2;
1389 }
1390 else
1391 {
1392 ActualSlope = 0.0;
1393 OnSlopeCancelling = FALSE;
1394 }
1395
1396 DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope);
1397 1379
1398 SlopeMeasuring = FALSE; 1380 SlopeMeasuring = FALSE;
1399 N_Math2slope = 0.0; 1381 N_Math2slope = 0.0;
1400 Math2_slope = 0.0; 1382 Math2_slope = 0.0;
1401 MoyMath2 = 0.0; 1383 MoyMath2 = 0.0;
2369 2351
2370 int CVICALLBACK CB_OnStartSlopeCancelling (int panel, int control, int event, 2352 int CVICALLBACK CB_OnStartSlopeCancelling (int panel, int control, int event,
2371 void *callbackData, int eventData1, int eventData2) 2353 void *callbackData, int eventData1, int eventData2)
2372 { 2354 {
2373 2355
2374 double ActualFrequ = 0.0; 2356 double frequency;
2375 double ActualSlope = 0.0; 2357 int activate;
2376 int active;
2377 2358
2378 switch (event) 2359 switch (event)
2379 { 2360 {
2380 case EVENT_COMMIT: 2361 case EVENT_COMMIT:
2381 2362
2382 GetCtrlVal(MainPanel, PANEL_STARTCANCEL, &active); 2363 GetCtrlVal(MainPanel, PANEL_STARTCANCEL, &activate);
2383 2364
2384 if (active) { 2365 if (activate) {
2385 2366
2386 SlopeMeasuringTimeBegin=utc; 2367 SlopeMeasuringTimeBegin = utc;
2387 SlopeMeasuring=TRUE; 2368 SlopeMeasuring = TRUE;
2388 ActualFrequ=DDSFox_ReadFreq(&DDS1xAD9956); 2369
2389 ActualSlope= SlopeMath2; 2370 frequency = DDSFox_ReadFreq(&DDS1xAD9956);
2390 DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope); 2371 GetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, &SlopeMath2);
2391 Nratio=-1; 2372 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
2392 CenterFrequencyCh2ToDetermine=TRUE ; 2373
2393 CenterFrequencyCh2=0.0; 2374 Nratio = -1;
2375 CenterFrequencyCh2ToDetermine = TRUE ;
2376 CenterFrequencyCh2 = 0.0;
2394 2377
2395 } else { 2378 } else {
2396 2379
2397 if (KeepFrequ) { 2380 frequency = DEDRIFT_DDS_FREQUENCY;
2398 ActualFrequ = DDSFox_ReadFreq(&DDS1xAD9956); 2381 if (KeepFrequ)
2399 } else { 2382 frequency = DDSFox_ReadFreq(&DDS1xAD9956);
2400 ActualFrequ = DEDRIFT_DDS_FREQUENCY; 2383
2384 if (! KeepSlope) {
2385 SlopeMath2 = 0.0;
2386 OnSlopeCancelling = FALSE;
2401 } 2387 }
2402 2388
2403 if (KeepSlope) { 2389 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
2404 ActualSlope = SlopeMath2; 2390 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
2405 OnSlopeCancelling = TRUE; 2391
2406 } else { 2392 SlopeMeasuring = FALSE;
2407 ActualSlope = 0.0; 2393 N_Math2slope = 0.0;
2408 OnSlopeCancelling = FALSE; 2394 Math2_slope = 0.0;
2409 } 2395 Moy_Math2slope = 0.0;
2410 2396 Slope_Math2slope = 0.0;
2411 DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope); 2397 MoyMath2 = 0.0;
2412 SlopeMeasuring=FALSE; 2398 Slope_Math2slope = 0.0;
2413 N_Math2slope=0.0; 2399 CenterFrequencyCh2 = 0.0;
2414 Math2_slope=0.0; 2400 Nratio = -1;
2415 Moy_Math2slope=0.0; 2401 nstabilisationSlopeMeasuring = 0;
2416 Slope_Math2slope=0.0;
2417 MoyMath2=0.0;
2418 Slope_Math2slope=0.0;
2419 CenterFrequencyCh2= 0.0;
2420 Nratio=-1;
2421 nstabilisationSlopeMeasuring=0;
2422 2402
2423 } 2403 }
2424 break; 2404 break;
2425 } 2405 }
2426 return 0; 2406 return 0;
2431 void *callbackData, int eventData1, int eventData2) 2411 void *callbackData, int eventData1, int eventData2)
2432 { 2412 {
2433 2413
2434 switch (event) { 2414 switch (event) {
2435 case EVENT_COMMIT: 2415 case EVENT_COMMIT:
2436 SlopeMath2 = 0.0;
2437 CenterFrequencyCh2 = 0.0; 2416 CenterFrequencyCh2 = 0.0;
2438 MoyMath2 = 0.0; 2417 MoyMath2 = 0.0;
2439 Nratio = -1; 2418 Nratio = -1;
2440 CenterFrequencyCh2ToDetermine = TRUE ; 2419 CenterFrequencyCh2ToDetermine = TRUE ;
2441 OnSlopeCancelling = FALSE; 2420 OnSlopeCancelling = FALSE;
2442 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, 0.0); 2421 SlopeMath2 = 0.0;
2422 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
2423 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, SlopeMath2);
2443 break; 2424 break;
2444 } 2425 }
2445 return 0; 2426 return 0;
2446 } 2427 }
2447 2428
2623 } 2604 }
2624 2605
2625 int CVICALLBACK CB_SetSlope (int panel, int control, int event, 2606 int CVICALLBACK CB_SetSlope (int panel, int control, int event,
2626 void *callbackData, int eventData1, int eventData2) 2607 void *callbackData, int eventData1, int eventData2)
2627 { 2608 {
2628 double frequency, slope; 2609 double frequency;
2629 2610
2630 switch (event) 2611 switch (event)
2631 { 2612 {
2632 case EVENT_COMMIT: 2613 case EVENT_COMMIT:
2633 GetCtrlVal(panel, control, &slope); 2614 GetCtrlVal(panel, control, &SlopeMath2);
2634 frequency = DDSFox_ReadFreq(&DDS1xAD9956); 2615 frequency = DDSFox_ReadFreq(&DDS1xAD9956);
2635 DDSFox_Set(&DDS1xAD9956, frequency, slope); 2616 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
2636 break; 2617 break;
2637 } 2618 }
2638 return 0; 2619 return 0;
2639 } 2620 }