diff 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
line wrap: on
line diff
--- a/FXAnalyse.c	Wed Oct 03 12:56:22 2012 +0200
+++ b/FXAnalyse.c	Wed Oct 03 14:27:24 2012 +0200
@@ -573,9 +573,6 @@
 	double DeltaCh2=0.0;
 	double DeltaCh4=0.0;  
 	
-	double ActualFrequ=0.0;
-	double ActualSlope=0.0;
-	
 	switch (event)
 	{
 		case EVENT_TIMER_TICK:
@@ -652,11 +649,8 @@
 						SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1);
 						SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2); 
 						SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); 
-						SetCtrlVal(CalcN1Panel, CALCN1_N, N_1) ;
-						SetCtrlVal(CalcN1Panel, CALCN1_SLOPE, Slope_1) ;
-						SetCtrlVal(CalcN2Panel, CALCN2_N, N_2) ;
-						SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2) ;
-						SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
+						SetCtrlVal(CalcN2Panel, CALCN2_N, N_2);
+						SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2);
 						SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2);  
 						SetCtrlVal(MainPanel, PANEL_LED1, SlopeMeasuring); 	   
 						SetCtrlVal(MainPanel, PANEL_LED2, OnSlopeCancelling);
@@ -1343,6 +1337,7 @@
 									MoyMath2 = 0.0;
 								}
 								
+								SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
 								DDSFox_Set(&DDS1xAD9956, FoxFrequ, SlopeMath2);
 								
 								nstabilisationSlopeMeasuring = 0;
@@ -1367,33 +1362,20 @@
 									}
 									else
 									{
-										if (AutoStopSlopeCancellingIfDelock)
-										{
-											
-											/* 
-											 * stop slope cancelling if the comb is not locked
-											 */
-											
-											if (KeepFrequ == TRUE)
-											{
-												ActualFrequ = DDSFox_ReadFreq(&DDS1xAD9956);
+										if (AutoStopSlopeCancellingIfDelock) {
+											// stop slope cancelling if the comb is not locked
+											 
+											double frequency = DEDRIFT_DDS_FREQUENCY;
+											if (KeepFrequ)
+												frequency = DDSFox_ReadFreq(&DDS1xAD9956);
+												
+											if (! KeepSlope) {
+												SlopeMath2 = 0.0;
+												OnSlopeCancelling = FALSE;
 											}
-											else
-											{
-												ActualFrequ = DEDRIFT_DDS_FREQUENCY;
-											}  
-												
-											if (KeepSlope == TRUE)
-											{
-												ActualSlope = SlopeMath2;
-											}
-											else
-											{
-												ActualSlope = 0.0;
-											    OnSlopeCancelling = FALSE;
-											} 
-												
-											DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope);
+											
+											SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
+											DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
 											
 											SlopeMeasuring = FALSE;
 											N_Math2slope = 0.0;
@@ -2371,54 +2353,52 @@
 		 void *callbackData, int eventData1, int eventData2)
 {
 
-	double ActualFrequ = 0.0;
-	double ActualSlope = 0.0; 
-	int active;
+	double frequency;
+	int activate;
 	
 	switch (event)
 	{
 		case EVENT_COMMIT:
 				   
-			GetCtrlVal(MainPanel, PANEL_STARTCANCEL, &active);
+			GetCtrlVal(MainPanel, PANEL_STARTCANCEL, &activate);
 				   
-			if (active) {
+			if (activate) {
+				
+				SlopeMeasuringTimeBegin = utc;
+				SlopeMeasuring = TRUE;
 				
-				SlopeMeasuringTimeBegin=utc; 
-				SlopeMeasuring=TRUE;
-				ActualFrequ=DDSFox_ReadFreq(&DDS1xAD9956);
-				ActualSlope= SlopeMath2;
-				DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope);
-				Nratio=-1;
-				CenterFrequencyCh2ToDetermine=TRUE ;
-				CenterFrequencyCh2=0.0;
+				frequency = DDSFox_ReadFreq(&DDS1xAD9956);
+				GetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, &SlopeMath2);
+				DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
+				
+				Nratio = -1;
+				CenterFrequencyCh2ToDetermine = TRUE ;
+				CenterFrequencyCh2 = 0.0;
 				
 			} else {
 				
-				if (KeepFrequ) {
-					ActualFrequ = DDSFox_ReadFreq(&DDS1xAD9956);
-				} else {
-					ActualFrequ = DEDRIFT_DDS_FREQUENCY;
-				}
+				frequency = DEDRIFT_DDS_FREQUENCY;
+				if (KeepFrequ)
+					frequency = DDSFox_ReadFreq(&DDS1xAD9956);
 				
-				if (KeepSlope) {
-					ActualSlope = SlopeMath2;
-					OnSlopeCancelling = TRUE;
-				} else {
-					ActualSlope = 0.0;
+				if (! KeepSlope) {
+					SlopeMath2 = 0.0;
 					OnSlopeCancelling = FALSE;
 				}
-						
-				DDSFox_Set(&DDS1xAD9956, ActualFrequ, ActualSlope);
-				SlopeMeasuring=FALSE; 
-				N_Math2slope=0.0;
-				Math2_slope=0.0;
-				Moy_Math2slope=0.0;
-				Slope_Math2slope=0.0;
-				MoyMath2=0.0; 
-				Slope_Math2slope=0.0;
-				CenterFrequencyCh2= 0.0;
-				Nratio=-1;
-				nstabilisationSlopeMeasuring=0;
+				
+				SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
+				DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
+				
+				SlopeMeasuring = FALSE; 
+				N_Math2slope = 0.0;
+				Math2_slope = 0.0;
+				Moy_Math2slope = 0.0;
+				Slope_Math2slope = 0.0;
+				MoyMath2 = 0.0; 
+				Slope_Math2slope = 0.0;
+				CenterFrequencyCh2 = 0.0;
+				Nratio = -1;
+				nstabilisationSlopeMeasuring = 0;
 				
 			}
 			break;
@@ -2433,13 +2413,14 @@
 
 	switch (event) {
 		case EVENT_COMMIT:
-			SlopeMath2 = 0.0; 
 			CenterFrequencyCh2 = 0.0;
 			MoyMath2 = 0.0;
 			Nratio = -1;
 			CenterFrequencyCh2ToDetermine = TRUE ;
-			OnSlopeCancelling = FALSE; 
-			DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, 0.0);
+			OnSlopeCancelling = FALSE;
+			SlopeMath2 = 0.0; 
+			SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
+			DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, SlopeMath2);
 			break;
 	}
 	return 0;
@@ -2625,14 +2606,14 @@
 int CVICALLBACK CB_SetSlope (int panel, int control, int event,
 		void *callbackData, int eventData1, int eventData2)
 {
-	double frequency, slope;
+	double frequency;
 	
 	switch (event)
 	{
 		case EVENT_COMMIT:
-			GetCtrlVal(panel, control, &slope);
+			GetCtrlVal(panel, control, &SlopeMath2);
 			frequency = DDSFox_ReadFreq(&DDS1xAD9956);
-			DDSFox_Set(&DDS1xAD9956, frequency, slope);
+			DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2);
 			break;
 	}
 	return 0;