changeset 0:d9aae7d7f2c6

Import
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 03 Jul 2012 10:38:59 +0200
parents
children a6fb5d3d0ec0
files .hgignore Allan.c Allan.h DDS4xAD9912.c DDS4xAD9912.h DDS4xAD9959.c DDS4xAD9959.h DDSBes.c DDSBes.h DDS_Fox.c DDS_Fox.h FXAllan.h FXAllan.uir FXAnalyse.c FXAnalyse.h FXAnalyse.uir FXAnalyse2.cws FXAnalyse2.prj FXAnalyze2.cds FXCalcN.h FXCalcN.uir FXPlot.h FXPlot.uir Plot.c Plot.h YLCStuff.c YLCStuff.h YLCTypes.h muParser.dll muParser.lib muParserDLL.h
diffstat 30 files changed, 6339 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Allan.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,303 @@
+#include <ansi_c.h>
+#include <userint.h>
+
+#include "YLCStuff.h"
+
+#include "FXAllan.h"   // Auto generated panel definitions and protypes
+#include "Allan.h"	   // My own .h file, containing prototypes and definitions for the class Allan...
+
+
+
+// ******************* Member functions : constructor and destructor *************************
+
+int Allan_InitPanel(Allan_Data * Instance, char * title, double Normalizer, void (*OnCloseFunc)(int)) {
+	
+	int i ;
+	
+	if ((Instance->AllanPanel = LoadPanel (0, "FXAllan.uir", ALLANPANEL)) < 0)
+	return -1;
+	SetPanelAttribute(Instance->AllanPanel, ATTR_TITLE, title) ; 
+	SetPanelAttribute (Instance->AllanPanel, ATTR_CALLBACK_DATA, (void *)Instance); // the panel callback therefore knows which data structure it is associated to
+	Instance->OnClosePanel = OnCloseFunc ;
+	for (i=0 ; i<ALLAN_MAXPOINTSNUMBER ; i++) {
+		Instance->AllanVar[i] = 0 ;
+		Instance->LastMean[i] = 0 ; 
+		Instance->BlocksNumber[i] = 0 ;
+		Instance->CurrentAverage[i] = 0 ; 
+		Instance->NbCurrentAverage[i] = 0 ;
+	} ;
+	Instance->Drift = 0 ;
+	DisplayPanel (Instance->AllanPanel);
+	SetCtrlVal(Instance->AllanPanel, ALLANPANEL_NORMALIZER, Normalizer) ;
+	return 0 ;
+	}
+
+
+
+int Allan_ClosePanel(Allan_Data * Instance) {
+	Instance->OnClosePanel(Instance->AllanPanel) ;
+	DiscardPanel (Instance->AllanPanel); 
+	return 0;
+	}
+
+	
+
+// ******************** Member functions, callbacks (private) *******************************    
+
+
+int  CVICALLBACK Allan_CB_Reset(int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int i ;
+	Allan_Data * Instance = NULL;
+	
+	switch(event) {
+
+		case EVENT_COMMIT:
+			GetPanelAttribute (panel, ATTR_CALLBACK_DATA, &Instance);
+			Allan_Reset(Instance) ;	
+			break;
+			
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+		
+	return 0;
+}
+
+int CVICALLBACK Allan_CB_ChangeMax (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{  
+	int YMin, YMax ;
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, ALLANPANEL_MIN, &YMin) ;
+			GetCtrlVal(panel, ALLANPANEL_MAX, &YMax) ;
+			if (YMin<YMax) {
+				SetAxisScalingMode(panel, ALLANPANEL_ALLANPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, pow(10,(double)YMin), pow(10,(double)YMax) ) ;
+				SetCtrlVal(panel, ALLANPANEL_CHECKBOX_AUTOSCALE, FALSE) ; 
+				} ;
+			break;
+			
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}	
+	return 0;
+}
+
+int CVICALLBACK Allan_CB_ChangeMin (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{   
+	int YMin, YMax ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+				GetCtrlVal(panel, ALLANPANEL_MIN, &YMin) ;
+				GetCtrlVal(panel, ALLANPANEL_MAX, &YMax) ;
+				if (YMin<YMax ) {     
+					SetAxisScalingMode(panel, ALLANPANEL_ALLANPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, pow(10,(double)YMin), pow(10,(double)YMax) ) ;
+					SetCtrlVal(panel, ALLANPANEL_CHECKBOX_AUTOSCALE, FALSE) ;
+					} ;
+			break;
+			
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}	  
+	return 0;
+}
+
+
+int CVICALLBACK Allan_CB_ChangeAutoScale (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{  
+	return 0; 
+} 
+
+
+int CVICALLBACK Allan_CB_ChangeNormalizer (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{  /*
+	bool AutoScale = FALSE;
+	int NotCare  = 20000000 ;
+	double YMin = 10000000 , YMax = 64000000 ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, ALLANPANEL_CHECKBOX_AUTOSCALE, &AutoScale) ;
+			if (AutoScale) {
+				SetAxisScalingMode(panel, ALLANPANEL_ALLANPLOT, VAL_LEFT_YAXIS, VAL_AUTOSCALE, YMin, YMax) ;
+				GetAxisScalingMode(panel, ALLANPANEL_ALLANPLOT,VAL_LEFT_YAXIS, &NotCare, &YMin, &YMax ) ;
+				SetCtrlVal(panel, ALLANPANEL_MIN, YMin);
+				SetCtrlVal(panel, ALLANPANEL_MAX, YMax);
+				}
+			else {
+				GetCtrlVal(panel, ALLANPANEL_MIN, &YMin);
+				GetCtrlVal(panel, ALLANPANEL_MAX, &YMax);
+				SetAxisScalingMode(panel, ALLANPANEL_ALLANPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, YMin, YMax) ;
+				} ;
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}	 */
+	return 0; 
+} 
+
+
+
+// ******************** Member functions, public *****************************************    
+
+int Allan_Reset(Allan_Data * Instance) {
+	
+	int i ;
+	
+	for (i=0 ; i<ALLAN_MAXPOINTSNUMBER ; i++) {
+		Instance->AllanVar[i] = 0 ;
+		Instance->LastMean[i] = 0 ; 
+		Instance->BlocksNumber[i] = 0 ;
+		Instance->CurrentAverage[i] = 0 ; 
+		Instance->NbCurrentAverage[i] = 0 ;
+	} ;
+	
+	return 0 ;
+
+}
+
+
+int Allan_AddFrequency(Allan_Data * Instance, double Freq) {
+
+	int i, N;  
+	double CurrentMean, LastMean, Drift, Mean, Normalizer ;
+	
+	N = Instance->BlocksNumber[0]+1 ;	   // the total number of points used, usefull to calculate drift rate
+	Mean = Instance->Mean ;
+	Drift = Instance->Drift ;
+	
+	GetCtrlVal(Instance->AllanPanel, ALLANPANEL_NORMALIZER, &Normalizer);
+	
+	if (N > 1) {   // Drift measure needs at least 2 values !
+		Instance->Drift = (Drift*(N-2) + 6*(Freq-Mean)/N)/(N+1) ;
+		SetCtrlVal(Instance->AllanPanel, ALLANPANEL_DRIFT, Instance->Drift/Normalizer ) ;
+	}
+	
+	// update mean value (usefull to calculate drift rate with linear regression incremental algorithm...)
+	Instance->Mean = (Mean*(N-1)+Freq)/N ; 
+	
+	
+	for (i=0 ; i<ALLAN_MAXPOINTSNUMBER ; i++) {
+		Instance->CurrentAverage[i] = (Instance->CurrentAverage[i]*Instance->NbCurrentAverage[i] + Freq)
+											/(Instance->NbCurrentAverage[i]+1) ;
+		Instance->NbCurrentAverage[i] +=1 ;
+		
+		if (Instance->NbCurrentAverage[i] >= pow(2,i) ) {
+
+			CurrentMean = Instance->CurrentAverage[i];
+			LastMean = Instance->LastMean[i] ;
+			N = Instance->BlocksNumber[i] ;
+			N++ ;
+			Instance->CurrentAverage[i] = 0 ;
+			Instance->NbCurrentAverage[i] = 0 ;
+			if (N>1) {
+				Instance->AllanVar[i] = (Instance->AllanVar[i]*(N-2)
+										+0.5*pow(CurrentMean-LastMean,2))/(N-1)  ;
+			}
+			else { // ie if N=1, which is realized for the first completed block
+				Instance->FirstMean[i] = CurrentMean ;
+			} ;
+			Instance->LastMean[i] = CurrentMean ;
+			Instance->BlocksNumber[i] = N ;
+		} ;
+	} ;
+	
+	Allan_Display(Instance, VAL_WHITE, VAL_BLUE) ;
+	
+	return 0 ;
+}
+
+int Allan_Display (Allan_Data * Instance, int ColorPt, int ColorErrorBar){
+
+	int PointsNumber = ALLAN_MAXPOINTSNUMBER ;
+	int i, N ;
+	double X[ALLAN_MAXPOINTSNUMBER] ;
+	double Y[ALLAN_MAXPOINTSNUMBER] ;
+	double Normalizer, DriftTau, FirstFreq, LastFreq, Error ;
+	bool DeDrift ;
+	
+	GetCtrlVal(Instance->AllanPanel, ALLANPANEL_NORMALIZER, &Normalizer) ;
+	GetCtrlVal(Instance->AllanPanel, ALLANPANEL_DEDRIFT, &DeDrift) ;
+	
+	for (i=0 ; i<PointsNumber ; i++) {
+		X[i] = pow(2,i) ;
+		if (!DeDrift) { Y[i] = sqrt(Instance->AllanVar[i])/Normalizer ;}
+		else { 
+			DriftTau = Instance->Drift*X[i] ;
+			N = Instance->BlocksNumber[i] ;
+			if (N>=2) { // if enough data to calculate AVAR for tau = 2^i*tau0, and therefore, AllanVar[i] is meaningful
+				FirstFreq = Instance->FirstMean[i] ;
+				LastFreq = Instance->LastMean[i] ;
+				Y[i] = sqrt(Instance->AllanVar[i]+DriftTau*(DriftTau/2-(LastFreq-FirstFreq)/(N-1)))/Normalizer ;
+				// Not totaly sure it works... to be checked thoroughly   
+				}
+			else { Y[i] = 0 ; } ;
+			} ;
+	} ;
+	
+	DeleteGraphPlot(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, -1, VAL_IMMEDIATE_DRAW) ; 
+	PlotXY (Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X, Y, PointsNumber,
+			VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SOLID_SQUARE, VAL_SOLID, 1, ColorPt);
+	
+	for (i=0 ; i<PointsNumber ; i++) {
+		Error = 1/sqrt(Instance->BlocksNumber[i]) ;
+		PlotLine  (Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X[i], Y[i]*(1-Error), X[i], Y[i]*(1+Error), ColorErrorBar);
+	} ;
+ 
+	
+	return 0 ;
+}
+
+int Allan_DisplayErrorBars (Allan_Data * Instance, int color){
+
+	int i;
+	double X[ALLAN_MAXPOINTSNUMBER] ;
+	double Val, Error, Normalizer;
+	
+	GetCtrlVal(Instance->AllanPanel, ALLANPANEL_NORMALIZER, &Normalizer) ;
+	for (i=0 ; i<ALLAN_MAXPOINTSNUMBER ; i++) {
+		X[i] = pow(2,i) ;
+		Val = sqrt(Instance->AllanVar[i])/Normalizer ;
+		Error = 1/sqrt(Instance->BlocksNumber[i]) ;      
+		PlotLine  (Instance->AllanPanel, ALLANPANEL_ALLANPLOT, X[i], Val*(1-Error), X[i], Val*(1+Error), color);
+	} ;
+	
+	return 0 ;
+}
+
+int CVICALLBACK CB_GeneralAllanPanel (int panel, int event, void *callbackData,
+		int eventData1, int eventData2)
+{
+	Allan_Data * Instance = NULL;
+	
+	
+	switch (event)
+		{
+		case EVENT_GOT_FOCUS:
+
+			break;
+		case EVENT_LOST_FOCUS:
+
+			break;
+		case EVENT_CLOSE:
+			GetPanelAttribute (panel, ATTR_CALLBACK_DATA, &Instance);
+			Allan_ClosePanel(Instance) ;
+			
+			break;
+		}
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Allan.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,30 @@
+#include "YLCStuff.h"
+
+#define ALLAN_MAXPOINTSNUMBER 13			// can compute Allan dev for tau from 1s to 2^13 s =8192 s ~ 2h15' < 10000 s
+
+
+// Allan_Data : the data of crypto class Allan
+
+typedef struct {
+	PanelHandle AllanPanel ;					// le handle sur le graphe
+	void (*OnClosePanel)(int);					// pointer on a function to execute when the panel is closed (argument is the panel Handle)	
+	double AllanVar[ALLAN_MAXPOINTSNUMBER] ;	// the values of variances for each tau = 2^n.tau_0 (with n from 0 to ALLAN_MAXPOINTSNUMBER)
+	double FirstMean[ALLAN_MAXPOINTSNUMBER] ;   // the means of the first block of 2^n data for which averaging was completed
+	double LastMean[ALLAN_MAXPOINTSNUMBER] ;    // the means of the last block of 2^n data for which averaging was completed
+	int BlocksNumber[ALLAN_MAXPOINTSNUMBER] ;	// the number of blocks of 2^n data (averaged) used for computing AVAR(2^ntau)       
+	double CurrentAverage[ALLAN_MAXPOINTSNUMBER] ;  // the sum of the last p data points retrieved (with p<2^2n). used for averaging as soon as p=2^n
+	int NbCurrentAverage[ALLAN_MAXPOINTSNUMBER] ;	// number of data point being summed in CurrentAverage (from 0 up to 2^n)
+	double Drift, Mean ; // the drift rate of the data (in Hz/s), and the mean value (in Hz) : only usefull for dedrifting...
+	} Allan_Data ;
+
+
+// The functions of crypto class Allan
+
+int Allan_InitPanel(Allan_Data * Instance, char * title, double Normalizer, void (*OnCloseFunc)(int)) ;
+int Allan_ClosePanel(Allan_Data * Instance) ;
+int Allan_AddFrequency(Allan_Data * Instance, double Freq) ;
+
+int Allan_Reset(Allan_Data * Instance) ;
+int Allan_AddFrequency(Allan_Data * Instance, double Freq);
+int Allan_Display(Allan_Data * Instance, int ColorPt, int ColorErrorBar);
+int Allan_DisplayErrorBars(Allan_Data * Instance, int color);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDS4xAD9912.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,232 @@
+#include <utility.h>
+
+//==============================================================================
+//
+// Title:       DDS4xAD9912.c
+// Purpose:     
+//
+// Created on:  by Volodimer Laurent, modified by YLC
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+//==============================================================================
+// Include files
+
+#include "DDS4xAD9912.h"
+#include <userint.h>
+#include <tcpsupp.h>
+#include <ansi_c.h>
+
+//==============================================================================
+// Global functions
+
+static int OnTCPEvent(unsigned handle, int xType, int errCode, void *callbackData)
+	{
+	switch(xType)
+		{
+		case TCP_DISCONNECT :
+			break;
+		case TCP_DATAREADY :
+			ClientTCPRead (handle, Response, sizeof(Response), 0);
+			break;
+		}
+		return 0;
+	}
+
+
+//==============================================================================
+// DDS4xAD9912_SendCmd
+//
+// FUNC   : envoie une chaine de caracteres sur un port du serveur TCP/IP de la foxboard
+// PARAM  : DDSNum contient le numero de la DDS (1,2,3 ou 4)
+// PARAM  : Buffer contenant la chaîne de caractères à envoyer
+// RETURN : 0 si la connexion et l'ecriture sur le serveur TCP/IP sont OK
+//==============================================================================
+
+
+static int DDS4xAD9912_SendCmd(int DDSNum, char * Buffer)  // essentially a private function
+	{
+	int res_1,res_2;
+
+	switch(DDSNum) 
+		{
+		case 1:
+			res_1=ConnectToTCPServer (&hConv, Port1, Adress, OnTCPEvent, 0, 0);
+			if(res_1 <0) MessagePopup("DDS4xAD9912_1 Serveur", "Connection to server failed !");	
+			break;
+		case 2:
+			res_1=ConnectToTCPServer (&hConv, Port2, Adress, OnTCPEvent, 0, 0); 
+			if(res_1 <0) MessagePopup("DDS4xAD9912_2 Serveur", "Connection to server failed !");
+			break;
+		
+		 case 3:
+			res_1=ConnectToTCPServer (&hConv, Port3, Adress, OnTCPEvent, 0, 0); 
+			if(res_1 <0) MessagePopup("DDS4xAD9912_3 Serveur", "Connection to server failed !");
+			break;
+		
+		 case 4:
+			res_1=ConnectToTCPServer (&hConv, Port4, Adress, OnTCPEvent, 0, 0); 
+			if(res_1 <0) MessagePopup("DDS4xAD9912_4 Serveur", "Connection to server failed !");
+			break;
+		
+		}
+	
+	res_2=ClientTCPWrite (hConv, Buffer, strlen(Buffer)+1, 0);
+	if(res_2 <0) MessagePopup("DDS Serveur", "Write to server failed !");
+	DisconnectFromTCPServer (hConv);
+	return (res_1+res_2) ;
+	}
+
+
+//==============================================================================
+// DDS4xAD9912_Reset
+//
+// FUNC   : reset des 4 DDS
+// PARAM  :
+// RETURN : 0 si le reset de la DDS 1 , DDS 2, DDS3 et DDS4 est OK
+//==============================================================================
+
+ int DDS4xAD9912_Reset(DDS4xAD9912_Data * Instance)
+ 	{
+	int res_1,res_2;
+	
+	sprintf(Request,"set;%i;%i",1,17);
+	res_1 = DDS4xAD9912_SendCmd(1,Request) ;
+	if(res_1 <0) {
+		MessagePopup("DDS Serveur", "DDS4xAD9912_1 Reset failed !") ;
+		}
+	else Instance->Frequency1 = 0.0 ;
+	
+	sprintf(Request,"set;%i;%i",1,17);
+	res_2 = DDS4xAD9912_SendCmd(2,Request) ; 	 
+	if(res_2 <0) {
+		MessagePopup("DDS Serveur", "DDS4xAD9912_2 Reset failed !") ;
+		}
+	else Instance->Frequency2 = 0.0;
+
+	 sprintf(Request,"set;%i;%i",1,17);
+	res_2 = DDS4xAD9912_SendCmd(3,Request) ; 	 
+	if(res_2 <0) {
+		MessagePopup("DDS Serveur", "DDS4xAD9912_3 Reset failed !") ;
+		}
+	else Instance->Frequency3 = 0.0;
+	
+	 sprintf(Request,"set;%i;%i",1,17);
+	res_2 = DDS4xAD9912_SendCmd(4,Request) ; 	 
+	if(res_2 <0) {
+		MessagePopup("DDS Serveur", "DDS4xAD9912_4 Reset failed !") ;
+		}
+	else Instance->Frequency4 = 0.0;
+	
+	
+	return (res_1+res_2);	 
+ 	}	 
+
+
+//==============================================================================
+// DDS4xAD9912_SetFreq
+//
+// FUNC   : sort une fréquence sur la DDS1 ,DDS2, DDS3 ou DDS4
+// PARAM  : DDSNum contient le numero de la DDS (1, 2 , 3 ou 4)
+// RETURN : 0 si la connexion et l'ecriture sur le serveur TCP/IP sont OK
+//============================================================================== 
+int DDS4xAD9912_SetFrequency(DDS4xAD9912_Data * Instance, int DDSNum, double Freq)
+	{
+		
+	double Word=WORD(Freq,Clk) ;
+	double reste ;
+	int res_0 ;
+	unsigned char b5,b4,b3,b2,b1,b0 ; 
+
+	b5=(unsigned char)(Word/E40);		
+	b4=(unsigned char)((Word - E40*b5)/E32);
+	b3=(unsigned char)((Word - E40*b5 - E32*b4)/E24);
+	b2=(unsigned char)((Word - E40*b5 - E32*b4 - E24*b3)/E16); 
+	b1=(unsigned char)((Word - E40*b5 - E32*b4 - E24*b3 - E16*b2)/E8);
+	b0=(unsigned char)((Word - E40*b5 - E32*b4 - E24*b3 - E16*b2 - E8*b1)/1.0);
+	reste = (Word - E40*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1-1.0*b0) ;
+
+	sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",0,10,b5,b4,b3,b2,b1,b0); 
+	res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ;
+	if (res_0 <0) {
+		MessagePopup("DDS Serveur", "SetFrequency function failed !") ;
+		}
+	else {
+		if (DDSNum==1) Instance->Frequency1 = Freq - reste*Clk/E48 ;
+		if (DDSNum==2) Instance->Frequency2 = Freq - reste*Clk/E48 ;
+		if (DDSNum==3) Instance->Frequency3 = Freq - reste*Clk/E48 ;
+		if (DDSNum==4) Instance->Frequency4 = Freq - reste*Clk/E48 ;
+		} ;
+	  	
+	sprintf(Request,"set;%i;%i",0,18); // IO_Update logiciel 
+	res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ;
+	if (res_0 <0) {
+		MessagePopup("DDS Serveur", "IO_Update function failed !") ;
+		}
+	return(res_0) ;
+	
+	} 
+
+ 
+
+int DDS4xAD9912_FrequencyRampe ( DDS4xAD9912_Data * Instance, int DDSNum, double Frequin,double Frequout, double Step )  
+{
+	int i=0,imax=0;
+	double Frequactu=0;
+	time_t Time ; 
+	double delaysecond=0.01;
+	
+	
+	 if ( (Frequout - Frequin)>0)
+	 {
+		 if ((Frequout-Frequin) > Step)
+			 {
+				 imax= (Frequout-Frequin)/Step ;
+				 for (i=0; i<imax;i++)
+				 {
+					Delay(delaysecond);
+					Frequactu= Frequin+i*Step;
+					DDS4xAD9912_SetFrequency(Instance, DDSNum, Frequactu);  
+
+				 }
+			 }
+	 }
+	 
+	 else
+	 {
+		if ((Frequin-Frequout) > Step)
+			 {
+				 imax= (Frequin-Frequout)/Step ;
+				 for (i=0; i<imax;i++)
+				 {
+					  Delay(delaysecond); 
+					  Frequactu= Frequin-i*Step;
+					  DDS4xAD9912_SetFrequency(Instance, DDSNum, Frequactu); 
+				 }
+			 }
+		 
+	 }
+	 
+	 DDS4xAD9912_SetFrequency(Instance, DDSNum, Frequout);    
+	 return(0);
+	
+}
+
+/*Word=WORD(Frequactu,Clk);
+					b5=(unsigned char)(Word/E48);
+					b4=(unsigned char)((Word - E48*b5)/E32);
+					b3=(unsigned char)((Word - E48*b5 -E32*b4)/E24);
+					b2=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3)/E16); 
+					b1=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3 -E16*b2)/E8);
+					b0=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1)/1.0);
+					reste = (Word - E48*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1-1.0*b0) ;
+					sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",0,10,b5,b4,b3,b2,b1,b0);
+					res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ; 
+					if (DDSNum==1) Instance->Frequency1 = Frequactu - reste*Clk/E48 ;
+					if (DDSNum==2) Instance->Frequency2 = Frequactu - reste*Clk/E48 ;
+					if (DDSNum==3) Instance->Frequency3 = Frequactu - reste*Clk/E48 ;
+					if (DDSNum==4) Instance->Frequency4 = Frequactu - reste*Clk/E48 ;
+					sprintf(Request,"set;%i;%i",0,18);
+					res_0 = DDS4xAD9912_SendCmd(DDSNum, Request) ; */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDS4xAD9912.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,76 @@
+//==============================================================================
+//
+// Title:       DDS4xAD9912.h
+// Purpose:     
+//
+// Created on:  by Volodimer Laurent, modified by YLC
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+#ifndef __DDS4XAD9912_H__
+#define __DDS42XAD9912_H__
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+//==============================================================================
+// Include files
+
+#include "cvidef.h"
+
+//==============================================================================
+// Defines
+		
+#define Adress	"145.238.205.55"
+#define Port1 	6665
+#define Port2	6666		
+#define Port3	6667
+#define Port4	6668		
+#define Clk		1000000000
+#define E48		281474976710656.0		
+#define E40		1099511627776.0
+#define E32		4294967296.0
+#define E24		16777216.0
+#define E16		65536.0
+#define E8		256.0
+
+//==============================================================================
+// Macros
+		
+#define WORD(Freq,Clk) pow(2,48)*(Freq/Clk)	
+		
+// DDS4xAD9912_Data : the data of crypto class DDS4xAD9912
+
+typedef struct {
+	double Frequency1 ; 
+	double Frequency2 ;
+	double Frequency3 ;
+	double Frequency4 ;
+} DDS4xAD9912_Data ;
+		
+//==============================================================================		
+// Variables
+		
+char  Request[255];
+char Response[255];
+unsigned int hConv;	
+
+
+//==============================================================================		
+// Functions
+
+
+static int DDS4xAD9912_SendCmd(int DDSNum,char *Buffer) ; // essentially a private function, hence the static scope... 
+int DDS4xAD9912_SetFrequency(DDS4xAD9912_Data * Instance, int DDSNum, double Freq) ;		
+int DDS4xAD9912_Reset(DDS4xAD9912_Data * Instance) ;
+int DDS4xAD9912_FrequencyRampe ( DDS4xAD9912_Data * Instance,int DDSNum, double Frequin,double Frequout, double Step ) ;
+
+
+#ifdef __cplusplus
+    }
+#endif
+
+#endif  /* ndef __DDS2XAD9858_H__ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDS4xAD9959.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,169 @@
+
+//==============================================================================
+//
+// Title:       DDS4xAD9959.c
+// Purpose:     
+//
+// Created on:  by Volodimer Laurent, modified by YLC
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+//==============================================================================
+// Include files
+
+#include "DDS4xAD9959.h"
+#include <userint.h>
+#include <tcpsupp.h>
+#include <ansi_c.h>
+
+//==============================================================================
+
+// Global functions
+
+static int OnTCPEvent(unsigned handle, int xType, int errCode, void *callbackData)
+	{
+	switch(xType)
+		{
+		case TCP_DISCONNECT :
+			break;
+		case TCP_DATAREADY :
+			ClientTCPRead (handle, Response, sizeof(Response), 0);
+			break;
+		}
+		return 0;
+	}
+
+
+//==============================================================================
+// DDS4xAD9912_SendCmd
+//
+// FUNC   : envoie une chaine de caracteres sur un port du serveur TCP/IP de la foxboard
+// PARAM  : DDSNum contient le numero de la DDS (1,2,3 ou 4)
+// PARAM  : Buffer contenant la chaîne de caractères à envoyer
+// RETURN : 0 si la connexion et l'ecriture sur le serveur TCP/IP sont OK
+//==============================================================================
+
+
+static int DDS4XAD9959_SendCmd(int DDSNum, char * Buffer)  // essentially a private function
+	{
+	int res_1,res_2;
+
+	switch(DDSNum) 
+		{
+		case 1:
+			res_1=ConnectToTCPServer (&hConv, Port1, Adress, OnTCPEvent, 0, 0);
+			if(res_1 <0) MessagePopup("DDS4XAD9959_1 Serveur", "Connection to server failed !");	
+			break;
+		case 2:
+			res_1=ConnectToTCPServer (&hConv, Port2, Adress, OnTCPEvent, 0, 0); 
+			if(res_1 <0) MessagePopup("DDS4XAD9959_2 Serveur", "Connection to server failed !");
+			break;
+		
+		 case 3:
+			res_1=ConnectToTCPServer (&hConv, Port3, Adress, OnTCPEvent, 0, 0); 
+			if(res_1 <0) MessagePopup("DDS4XAD9959_3 Serveur", "Connection to server failed !");
+			break;
+		
+		 case 4:
+			res_1=ConnectToTCPServer (&hConv, Port4, Adress, OnTCPEvent, 0, 0); 
+			if(res_1 <0) MessagePopup("DDS4XAD9959_4 Serveur", "Connection to server failed !");
+			break;
+		
+		}
+	
+	res_2=ClientTCPWrite (hConv, Buffer, strlen(Buffer)+1, 0);
+	if(res_2 <0) MessagePopup("DDS Serveur", "Write to server failed !");
+	DisconnectFromTCPServer (hConv);
+	return (res_1+res_2) ;
+	}
+
+
+//==============================================================================
+// DDS4xAD9912_Reset
+//
+// FUNC   : reset des 4 DDS
+// PARAM  :
+// RETURN : 0 si le reset de la DDS 1 , DDS 2, DDS3 et DDS4 est OK
+//==============================================================================
+
+ int DDS4XAD9959_Reset(DDS4XAD9959_Data * Instance)
+ 	{
+	int res_1,res_2;
+	
+	sprintf(Request,"set;%i;%i",1,17);
+	res_1 = DDS4XAD9959_SendCmd(1,Request) ;
+	if(res_1 <0) {
+		MessagePopup("DDS Serveur", "DDS4XAD9959_1 Reset failed !") ;
+		}
+	else Instance->Frequency1 = 0.0 ;
+	
+	sprintf(Request,"set;%i;%i",1,17);
+	res_2 = DDS4XAD9959_SendCmd(2,Request) ; 	 
+	if(res_2 <0) {
+		MessagePopup("DDS Serveur", "DDS4XAD9959_2 Reset failed !") ;
+		}
+	else Instance->Frequency2 = 0.0;
+
+	 sprintf(Request,"set;%i;%i",1,17);
+	res_2 = DDS4XAD9959_SendCmd(3,Request) ; 	 
+	if(res_2 <0) {
+		MessagePopup("DDS Serveur", "DDS4XAD9959_3 Reset failed !") ;
+		}
+	else Instance->Frequency3 = 0.0;
+	
+	 sprintf(Request,"set;%i;%i",1,17);
+	res_2 = DDS4XAD9959_SendCmd(4,Request) ; 	 
+	if(res_2 <0) {
+		MessagePopup("DDS Serveur", "DDS4XAD9959_4 Reset failed !") ;
+		}
+	else Instance->Frequency4 = 0.0;
+	
+	
+	return (res_1+res_2);	 
+ 	}	 
+
+
+//==============================================================================
+// DDS4xAD9912_SetFreq
+//
+// FUNC   : sort une fréquence sur la DDS1 ,DDS2, DDS3 ou DDS4
+// PARAM  : DDSNum contient le numero de la DDS (1, 2 , 3 ou 4)
+// RETURN : 0 si la connexion et l'ecriture sur le serveur TCP/IP sont OK
+//============================================================================== 
+int DDS4XAD9959_SetFrequency(DDS4XAD9959_Data * Instance, int DDSNum, double Freq)
+	{
+		
+	double Word=WORD(Freq,Clk) ;
+	double reste ;
+	int res_0 ;
+	unsigned char b5,b4,b3,b2,b1,b0 ; 
+
+	b5=(unsigned char)(Word/E48);		   // AD9858 is 32 bits, so this one is always zero. For future extension only...
+	b4=(unsigned char)((Word - E48*b5)/E32);
+	b3=(unsigned char)((Word - E48*b5 -E32*b4)/E24);
+	b2=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3)/E16); 
+	b1=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3 -E16*b2)/E8);
+	b0=(unsigned char)((Word - E48*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1)/1.0);
+	reste = (Word - E48*b5 -E32*b4 -E24*b3 -E16*b2 -E8*b1-1.0*b0) ;
+
+	sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",0,10,b5,b4,b3,b2,b1,b0); 
+	res_0 = DDS4XAD9959_SendCmd(DDSNum, Request) ;
+	if (res_0 <0) {
+		MessagePopup("DDS Serveur", "SetFrequency function failed !") ;
+		}
+	else {
+		if (DDSNum==1) Instance->Frequency1 = Freq - reste*Clk/E48 ;
+		if (DDSNum==2) Instance->Frequency2 = Freq - reste*Clk/E48 ;
+		if (DDSNum==3) Instance->Frequency3 = Freq - reste*Clk/E48 ;
+		if (DDSNum==4) Instance->Frequency4 = Freq - reste*Clk/E48 ;
+		} ;
+	  	
+	sprintf(Request,"set;%i;%i",0,18); // IO_Update logiciel 
+	res_0 = DDS4XAD9959_SendCmd(DDSNum, Request) ;
+	if (res_0 <0) {
+		MessagePopup("DDS Serveur", "IO_Update function failed !") ;
+		}
+	return(res_0) ;
+	
+	} 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDS4xAD9959.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,71 @@
+//==============================================================================
+//
+// Title:       DDS4xAD9959.h
+// Purpose:     
+//
+// Created on:  by Volodimer Laurent, modified by YLC
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+#ifndef __DDS4XAD9959_H__
+#define __DDS4XAD9959_H__
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+//==============================================================================
+// Include files
+
+#include "cvidef.h"
+
+//==============================================================================
+// Defines
+		
+#define Adress	"192.168.0.5"								
+#define Port1 	6665										 
+#define Port2	6666										
+#define Port3	6667
+#define Port4	6668
+#define Clk		1000000000									 
+#define E48		1099511627776.0								
+#define E32		4294967296.0								
+#define E24		16777216.0									 
+#define E16		65536.0										 
+#define E8		256.0										
+
+//==============================================================================
+// Macros
+		
+#define WORD(Freq,Clk) pow(2,32)*(Freq/Clk)	
+		
+// DDS2xAD9858_Data : the data of crypto class DDS2xAD9858
+
+typedef struct {
+	double Frequency1 ; 
+	double Frequency2 ;
+	double Frequency3 ;
+	double Frequency4 ;
+	} DDS4XAD9959_Data ;
+		
+//==============================================================================		
+// Variables
+		
+char  Request[255];
+char Response[255];
+unsigned int hConv;		
+
+//==============================================================================		
+// Functions
+
+
+static int DDS4XAD9959_SendCmd(int DDSNum,char *Buffer) ; // essentially a private function, hence the static scope... 
+int DDS4XAD9959_SetFrequency(DDS4XAD9959_Data * Instance, int DDSNum, double Freq) ;		
+int DDS4XAD9959_Reset(DDS4XAD9959_Data * Instance) ;
+
+#ifdef __cplusplus
+    }
+#endif
+
+#endif  /* ndef __DDS2XAD9858_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDSBes.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,193 @@
+#include <utility.h>
+#include <cvirte.h>		/* Needed if linking in external compiler; harmless otherwise */
+#include <userint.h>
+#include "DDSBes.h"
+#include <ansi_c.h>
+#include <gpib.h>
+
+#define PPORT	0x378
+#define PPCTRL	PPORT+2
+#define UPDate	0x040
+#define nWR	0x080
+#define MReset	0x0C0
+#define tempo   20
+
+// Private functions, hence declared as static ...
+
+static int delai(int t) {
+	int j ;
+	for (j=0;j<t; j++) ;
+	return(0) ;
+}
+
+
+static int Strb_adress(unsigned char ad) {
+	outp(PPCTRL,0x08) ;
+	outp(PPORT,ad) ;
+	outp(PPCTRL,0x09) ;
+	delai(tempo) ;
+	outp(PPCTRL,0x08) ;
+    delai(tempo); 
+	return(0) ;
+}
+
+static int Strb_data(unsigned char da) {
+	outp(PPCTRL,0x00) ;
+	outp(PPORT,da) ;   
+	outp(PPCTRL,0x01) ;
+	delai(tempo) ;
+	outp(PPCTRL,0x00) ;
+	delai(tempo) ;
+	return(0) ;
+}
+
+static int Strb_nWrite(void) {
+	outp(PPCTRL,0x08) ;
+	outp(PPORT,nWR) ;
+	outp(PPCTRL,0x09) ; 
+	delai(tempo) ;
+	outp(PPCTRL,0x08) ;
+	delai(tempo) ; 
+	return(0) ;   
+}
+
+static int Strb_Update(void) {
+	outp(PPCTRL,0x08) ;
+	outp(PPORT,UPDate) ;
+	outp(PPCTRL,0x09) ;
+	delai(tempo) ;
+	outp(PPCTRL,0x08) ;
+	delai(tempo) ;
+	return(0) ;
+}
+
+static int Strb_MReset(void) {
+	outp(PPCTRL,0x08) ;
+	outp(PPORT,MReset) ;
+	outp(PPCTRL,0x09) ;
+	delai(tempo) ;
+	outp(PPCTRL,0x08) ;
+	delai(tempo) ;
+	return(0) ;
+}
+
+// Public functions
+
+void DDSBes_Initialize(DDSBes_Data * Instance) {
+	Strb_MReset();
+	/* 0 dans 0x1F => update clock externe */
+	Strb_data(0x00);
+	Strb_adress(0x1F);
+	Strb_nWrite();
+	
+	return ;
+}
+
+void DDSBes_Close(DDSBes_Data * Instance){
+
+	return ;
+}
+
+void DDSBes_SetClockFrequency(DDSBes_Data * Instance, double clock_frequency){
+	
+	int fPLL  ;
+	unsigned char oPLL;
+	
+	fPLL = 1;
+	if(fPLL==1 || (fPLL>3 && fPLL<21)) { 
+		Instance->ClockFrequency = clock_frequency*fPLL;
+		if (Instance->ClockFrequency>300.0e6) {
+			Instance->ClockFrequency = 300.0e6 ;
+		}
+	}
+
+	if (fPLL==1) oPLL=0x60 ; 
+	else {
+		if (Instance->ClockFrequency>=2e8) oPLL=(unsigned char)(0x40 + fPLL) ;
+		else oPLL= (unsigned char)fPLL ;
+	}
+
+	Strb_data(oPLL);
+	Strb_adress(0x1E);
+	Strb_nWrite();
+	
+	return ;
+}
+
+void DDSBes_SetFrequency(DDSBes_Data * Instance, double frequency){
+
+	double pas ;
+	double reste ;
+	double coeff;
+	double fdiv[7];
+	double p[6];
+	
+	int i;
+	
+	unsigned char o[6];
+	
+	fdiv[6]=pow(2.0,48.0);
+	fdiv[5]=pow(2.0,40.0);
+	fdiv[4]=pow(2.0,32.0);
+	fdiv[3]=pow(2.0,24.0);
+	fdiv[2]=65536.0;
+	fdiv[1]=256.0;
+	fdiv[0]=1.0;
+	
+	coeff=fdiv[6]/Instance->ClockFrequency;
+	pas=coeff*frequency;
+	reste=pas;
+
+	for (i=5;i>0;i--){
+		p[i]=(reste/fdiv[i]);
+		reste=fmod(pas,fdiv[i]);
+	}
+	p[0]=reste;
+
+	for (i=5;i>=0;i--){
+		o[i]=(unsigned char) p[i];
+	}
+
+	/* frequence (6 octets) */
+	Strb_adress(0x04);Strb_data(o[5]);Strb_nWrite();
+	Strb_adress(0x05);Strb_data(o[4]);Strb_nWrite();
+	Strb_adress(0x06);Strb_data(o[3]);Strb_nWrite();
+	Strb_adress(0x07);Strb_data(o[2]);Strb_nWrite();
+	Strb_adress(0x08);Strb_data(o[1]);Strb_nWrite();
+	Strb_adress(0x09);Strb_data(o[0]);Strb_nWrite();
+
+	Strb_Update();
+	
+	// store in Instance->Frequency the real frequency generated by the DDS 
+	// (and not "frequency", which is only the requested frequency and might differ by as much as ClockFrequency/2^48
+	Instance->Frequency = Instance->ClockFrequency/fdiv[6]
+		*(fdiv[5]*o[5]+fdiv[4]*o[4]+fdiv[3]*o[3]+fdiv[2]*o[2]+fdiv[1]*o[1]+fdiv[0]*o[0]) ;
+	
+	
+	
+	return ;
+}
+
+
+void DDSBes_SetAmplitude(DDSBes_Data * Instance, int amplitude) {
+	unsigned char a[2];
+
+	if (amplitude > 0 && amplitude < 4096){ 
+		a[1]=(unsigned char)(amplitude>>8);
+		a[0]=(unsigned char)floor(fmod(amplitude,256.0));
+		Instance->Amplitude = amplitude ;
+		} 
+		
+	/* nibble fort adresse=0x21 data=a[1] */
+	Strb_data(a[1]);
+	Strb_adress(0x21);
+	Strb_nWrite();
+	/* octet faible adresse=0x22  data=a[0] */
+	Strb_data(a[0]);
+	Strb_adress(0x22);
+	Strb_nWrite();
+	/* mise a jour */
+	Strb_Update();
+
+	return ;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDSBes.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,50 @@
+//
+// Title:       DDSBes.h
+// Purpose:     header for the Besancon DDS crypto-class
+//
+// Created on:  by YLC
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+#ifndef __DDSBES_H__
+#define __DDSBES_H__
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+
+// DDSBes_Data : the data of crypto class DDSBesancon
+
+typedef struct {
+	double ClockFrequency ;		 // in Hz
+	double Frequency ; 			 // the real frequency (in Hz) which is at the DDS output
+	double Amplitude ;
+	} DDSBes_Data ;
+
+
+/************** Member Function Declarations (Private) **************/
+
+static int delai(int t);
+static int Strb_adress(unsigned char ad);
+static int Strb_data(unsigned char da);
+static int Strb_nWrite(void);
+static int Strb_Update(void);
+static int Strb_MReset(void);
+
+
+/************** Member Function Declarations (Public) **************/
+
+extern void DDSBes_Initialize(DDSBes_Data * Instance);
+extern void DDSBes_Close(DDSBes_Data * Instance);
+extern void DDSBes_SetClockFrequency(DDSBes_Data * Instance, double ClockFrequency);
+extern void DDSBes_SetFrequency(DDSBes_Data * Instance, double Frequency); // In Instance->Frequency, the real output frequency is stored
+																		   // (<> from requested frequency due to rounding effect
+extern void DDSBes_SetAmplitude(DDSBes_Data * Instance, int Amplitude);
+
+#ifdef __cplusplus
+    }
+#endif
+
+#endif  /* ndef __DDSBES_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDS_Fox.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,474 @@
+#include "DDS Fox control.h"
+#include <userint.h>
+#include <tcpsupp.h>
+#include <ansi_c.h>
+#include "DDS_Fox.h"
+
+//#define DDS_IP "192.168.0.3"
+//#define TCP_PORT 6665
+
+#define DIV 0			   // divided by 1
+#define CMD_SEP ";"
+#define BASE_TIME 0.01
+
+#define CMD_CONFIG_REG1 1  // cmd d'acces direct au rergistre 1 de config de la DDS (voir datasheet)
+#define CMD_CONFIG_REG2 2  // cmd d'acces direct au rergistre 1 de config de la DDS (voir datasheet)
+#define CMD_SINGLE_FREQ_PROF0 7
+#define CMD_PROFILE 15	   // cmd de choix du profile de fonctionnement de la DDS (voir datasheet)
+#define CMD_ATTENUATION 16
+#define CMD_RESET_DDS 17
+#define CMD_NOP 20
+#define CMD_FREQ_INF 21
+#define CMD_FREQ_SUP 22
+#define CMD_DF 23
+#define CMD_DT 24
+#define CMD_START_SWEEP 25
+#define CMD_STOP_SWEEP 26
+#define CMD_GET_FREQ 28
+#define CMD_SWEEP_SIGN 29
+
+
+/************************* Global variables ***********************************/ 
+//static char  Request[255]; 
+
+/************************* My own functions ***********************************/
+/*DDSParameter DDSGetParam (int panel, int control) {
+	DDSParameter Parameter ;
+	
+	GetCtrlVal (panel, CONTROL_DDS_IP, Parameter->ip) ;
+	GetCtrlVal (panel, CONTROL_DDS_PORT, &(Parameter->Port)) ;
+	GetCtrlVal (panel, CONTROL_DDS_CLOCK, &(Parameter->Clock)) ;
+	GetCtrlVal (panel, CONTROL_DDS_RATE, &(Parameter->SweepRate)) ;
+	GetCtrlVal (panel, CONTROL_DDS_DELTA_T, &(Parameter->Delta_T)) ;
+	return(Parameter);
+}*/
+
+
+
+void DDS_Initialize (DDSParameter *Param) {
+	char  Request[255]; 
+	//send NOP command 
+	sprintf(Request,"set;%i;%i",1,CMD_NOP);   
+	SendCmd(Request, Param) ;
+	//reset the DDS
+	DDSFox_Reset(Param);
+	
+	//Set Profile Number 0 (only one used for soft frequecy sweep)
+//	sprintf(Request,"set;%i;%i;%i",1,CMD_PROFILE,0);   
+//	SendCmd(Request, Param) ; 
+	
+	//Set Profile Number 7 (only one used for soft frequecy sweep)
+	sprintf(Request,"set;%i;%i;%i",1,CMD_PROFILE,7);   
+	SendCmd(Request, Param) ; 
+
+
+	//Set Clock Divider to 00b (which means 1)
+	DDSFox_SetDiv(Param);
+    //Set sweep rate at 0	
+	DDSFox_SetFreqMax (Param);
+	DDSFox_SetFreq (Param) ;
+	DDSFox_SetDT (Param) ;
+	DDSFox_SetDf (Param) ;
+	DDSFox_StartSweep (Param) ;
+	return ;
+}
+
+void DDS_ReInitialize (DDSParameter *Param) {
+	char  Request[255]; 
+	//send NOP command 
+	sprintf(Request,"set;%i;%i",1,CMD_NOP);   
+	SendCmd(Request, Param) ;
+	//reset the DDS
+	//DDSFox_Reset(Param);
+	
+	//Set Profile Number 0 (only one used for soft frequecy sweep)
+//	sprintf(Request,"set;%i;%i;%i",1,CMD_PROFILE,0);   
+//	SendCmd(Request, Param) ; 
+	
+	//Set Profile Number 7 (only one used for soft frequecy sweep)
+	sprintf(Request,"set;%i;%i;%i",1,CMD_PROFILE,7);   
+	SendCmd(Request, Param) ; 
+
+
+	//Set Clock Divider to 00b (which means 1)
+	DDSFox_SetDiv(Param);
+    //Set sweep rate at 0	
+	DDSFox_SetFreqMax (Param);
+	DDSFox_SetFreq (Param) ;
+	DDSFox_SetDT (Param) ;
+	DDSFox_SetDf (Param) ;
+	DDSFox_StartSweep (Param) ;
+	return ;
+}
+
+
+void DDSFox_Reset(DDSParameter *Param) {
+	char  Request[255]; 
+	sprintf(Request,"set;%i;%i",1,CMD_NOP);   
+	SendCmd(Request, Param) ;
+	sprintf(Request,"set;%i;%i",1,CMD_RESET_DDS);   
+	SendCmd(Request, Param) ;
+	return ;
+}
+
+
+void DDSFox_StopSweep(DDSParameter *Param) {
+	char  Request[255];
+    sprintf(Request,"set;%i;%i;%i",1,CMD_STOP_SWEEP,1); 
+  	SendCmd(Request, Param);
+	return ;
+}
+
+
+void DDSFox_StartSweep(DDSParameter *Param) {
+	char  Request[255];
+    sprintf(Request,"set;%i;%i;%i",1,CMD_START_SWEEP,1); 
+  	SendCmd(Request, Param);
+	return ;
+}
+
+void DDSFox_SetFreqMax (DDSParameter *Param) {
+	double word ;
+	unsigned char octets[6];
+	char  Request[255]; 
+	convert_double_6char(pow(2,48)/2,octets);	 // borne sup : clock / 2
+	sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",1,CMD_FREQ_SUP,
+		*(octets+5),*(octets+4),*(octets+3),*(octets+2),*(octets+1),*octets); 
+	SendCmd(Request, Param);
+	DDSFox_SetSweepSign (Param);
+	return ;
+}
+
+void DDSFox_SetFreqMin (DDSParameter *Param) {
+	double word ;
+	unsigned char octets[6];
+	char  Request[255]; 
+	convert_double_6char(1,octets);	 // borne inf : ~0
+	sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",1,CMD_FREQ_INF,
+		*(octets+5),*(octets+4),*(octets+3),*(octets+2),*(octets+1),*octets); 
+	SendCmd(Request, Param);
+	DDSFox_SetSweepSign (Param);
+	return ;
+}
+
+void DDSFox_SetFreq (DDSParameter *Param) {
+	double word ;
+	unsigned char octets[6];
+	int SweepSign = -1 ;
+	char  Request[255]; 
+	if (Param->Profil == 0) {
+		word = pow(2,48)*(Param->Frequency/Param->Clock);
+		convert_double_6char(word, octets);			// borne inf : la freq voulu	
+		sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",1,CMD_FREQ_INF,
+			*(octets+5),*(octets+4),*(octets+3),*(octets+2),*(octets+1),*octets); 
+		SendCmd(Request, Param);
+	}
+	else if(Param->Profil == 7) {
+		SweepSign = DDSFox_GetSweepSign(Param) ;
+		if(SweepSign == 0){								// sweep positif
+			word = pow(2,48)*(Param->Frequency/Param->Clock);
+			convert_double_6char(word, octets);			// borne inf : la freq voulu	
+			sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",1,CMD_FREQ_INF,
+				*(octets+5),*(octets+4),*(octets+3),*(octets+2),*(octets+1),*octets); 
+			SendCmd(Request, Param);
+			DDSFox_SetFreqMax (Param);
+		}
+		else {											// sweep neg
+			word = pow(2,48)*(Param->Frequency/Param->Clock);
+			convert_double_6char(word, octets);				// borne sup : la freq voulue	
+			sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",1,CMD_FREQ_SUP,
+				*(octets+5),*(octets+4),*(octets+3),*(octets+2),*(octets+1),*octets); 
+			SendCmd(Request, Param);
+			DDSFox_SetFreqMin (Param);
+		}
+	}
+	return ;
+}
+
+
+// Change le signe de sweep en frequence. Argument: struct de param de la DDS
+void DDSFox_SetSweepSign(DDSParameter *Param) {
+	char  Request[255] ; 
+	int SweepSign ;
+	SweepSign = DDSFox_GetSweepSign(Param) ;
+	sprintf(Request,"set;%i;%i;%i",1,CMD_SWEEP_SIGN, SweepSign) ; 
+	SendCmd(Request, Param) ;
+	return ;
+}
+
+/*void DDSFox_SetSweepSign(DDSParameter *Param) {
+	char  Request[255] ; 
+	int SweepSign ;
+	if (Param->Profil == 7)
+		Param->Frequency = DDSFox_ReadFreq(Param) ;
+	DDSFox_SetFreq (Param) ;
+	SweepSign = DDSFox_GetSweepSign(Param) ;
+	sprintf(Request,"set;%i;%i;%i",1,CMD_SWEEP_SIGN, SweepSign) ; 
+	SendCmd(Request, Param) ;
+	return ;
+}*/
+
+
+// Change la valeur de la base pour 'lincrement de frequence (sweep). Argument: delta T x 10ms, retourne rien.
+void DDSFox_SetDT(DDSParameter *Param) {
+	char  Request[255]; 
+	int dt= 0;
+	char FTW0[255]="0";	   /**** sinon le fichier inf.xx est faux 	   ***/
+	dt = ((Param->Delta_T)/BASE_TIME) - 1 ;
+	sprintf(FTW0,"%ims",dt);
+	sprintf(Request,"set;%i;%i;%i;%s",1,CMD_DT, dt ,FTW0);
+	SendCmd(Request, Param) ; 
+	return ;
+}
+
+
+// Change le facteur de division de la clock. Argument: facteur de div, retourne rien 
+void DDSFox_SetDiv(DDSParameter *Param) {
+	char  Request[255]; 
+	int Div = DIV ;
+	Command Rd;
+	char  temp;
+	init_command(&Rd);
+	sprintf(Request,"get;%i;%i",1,CMD_CONFIG_REG2);      
+	if (RecvCmd(&Rd, Request, Param) < 0)
+		return;
+	temp = atoi(Rd.value2) ;
+	temp = temp & 0x9F ; 
+	temp = temp | Div << 5 ;
+	sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i",1,CMD_CONFIG_REG2,atoi(Rd.value0),
+			atoi(Rd.value1),temp,atoi(Rd.value3),atoi(Rd.value4)) ;
+	SendCmd(Request, Param) ;
+	return ;
+}
+
+
+
+void DDSFox_SetDf(DDSParameter *Param) {
+	char  Request[255]; 
+	double word ;
+	unsigned char *octets;
+	word = pow(2,48)*(fabs(Param->SweepRate)*Param->Delta_T/Param->Clock);
+	octets=malloc(6*sizeof(unsigned char));
+	convert_double_6char(word, octets);	
+	sprintf(Request,"set;%i;%i;%i;%i;%i;%i;%i;%i",1,CMD_DF,
+		*(octets+5),*(octets+4),*(octets+3),*(octets+2),*(octets+1),*octets); 
+	SendCmd(Request, Param);
+	free(octets);
+	return ;
+}
+
+int DDSFox_GetSweepSign(DDSParameter *Param) {
+	if (Param->SweepRate >= 0) return(0);
+	else return(1);
+}
+
+
+double DDSFox_ReadFreq(DDSParameter *Param) {
+	char  Request[255]; 
+	unsigned int OctetA, OctetB, OctetC, OctetD, OctetE, OctetF ;
+	double FreqRead ;
+	int cmd[20];
+	Command Rd;
+	init_command(&Rd);
+	sprintf(Request,"get;%i;%i",1,CMD_GET_FREQ); 
+	if (RecvCmd(&Rd, Request, Param) == -1)
+		return -1.;
+	OctetA=atoi(Rd.value0);
+	OctetB=atoi(Rd.value1); 
+	OctetC=atoi(Rd.value2); 
+	OctetD=atoi(Rd.value3); 
+	OctetE=atoi(Rd.value4); 
+	OctetF=atoi(Rd.value5);
+	FreqRead=(double)(1099511627776*OctetA +4294967296*OctetB +16777216*OctetC +65536*OctetD +256*OctetE +OctetF);    
+	FreqRead=(FreqRead*Param->Clock)/ pow(2,48);
+	//sprintf(parsebuf,"%fMHz",FreqRead/1000000);
+	return(FreqRead);
+}
+
+
+/************************ Fonction de communications TCP ******************/
+static const double timeout = 0.5;
+
+
+int SendCmd(char *Buffer, DDSParameter *Param) {
+	unsigned int hConv=0;
+	char  Response[255];
+	char parsebuf[255];
+	if (ConnectToTCPServer (&hConv, Param->Port, Param->ip, OnTCPEvent, Response, 0) < 0) {
+		printf("Connect failed\n");
+		return -1;
+	}
+	if (ClientTCPWrite (hConv, Buffer, strlen(Buffer)+1, 0) < 0) {
+		printf("Write failed\n");
+		return -1;
+	}
+	sprintf(Response,"                              ");
+	if (ClientTCPRead (hConv, Response, 255, 0) < 0) {
+		printf("Read failed\n");
+		return -1;
+	}
+	if (strncmp("OK",Response,2)) {
+		printf("Response failed %s %s\n", Buffer, Response);
+		return -1;
+	}
+	return 0;
+}
+
+
+int RecvCmd(Command *Rd, char * Buffer, DDSParameter *Param) {
+	unsigned int hConv=0;
+	char parsebuf[255];
+	char  Response[255];
+	if (ConnectToTCPServer (&hConv, Param->Port, Param->ip, OnTCPEvent, Response, 0) < 0) {
+		printf("Connect failed\n");
+		return -1;     
+	}
+	if (ClientTCPWrite (hConv, Buffer, strlen(Buffer)+1, 0) < 0) {
+		printf("Write failed\n");
+		return -1;
+	}
+	sprintf(Response,"                              ");     
+	if (ClientTCPRead (hConv, Response, 255, 0) < 0) {
+		printf("Read failed\n");
+		return -1;
+	}
+
+	if (strncmp(Buffer,Response,strlen(Buffer))) {
+		printf("Response failed %s %s\n", Buffer, Response);
+		return -1;
+	}
+	
+	sprintf(parsebuf,"%s",Response) ;	 
+	parse_command(Rd, parsebuf) ; 	 
+	return 0;
+}
+
+
+int OnTCPEvent(unsigned handle, int xType, int errCode, void *callbackData) {
+	//char* Response = (char*)(callbackData);
+	//char Response[255];
+	//switch(xType) {
+	//	case TCP_DISCONNECT :
+			//printf("Server disconnected\n");
+	//		break;
+	//	case TCP_DATAREADY :
+			//printf("Server data ready\n");
+			//ClientTCPRead (handle, Response, 255, 5);
+	//		break;
+	//}
+	return 0;
+}
+
+/************************ Fonction de mise en forme des données pour le transfert ******************/
+
+void parse_command2(int* cmd, char* buf)
+{
+	char* pointer;
+	int c = 0;
+	
+	pointer = strtok( buf, CMD_SEP );
+	while( pointer ){
+		if ((c > 2) && ( c < 19 ))
+		{
+			cmd[c-3] = atoi(pointer);
+			printf("%i", cmd[c-3]);
+		}
+			
+			
+		pointer = strtok( NULL, CMD_SEP );
+		c++;
+	}
+}
+
+
+int parse_command(Command *cmd1, char *buf){
+	char* pointer;
+	int c = 0;
+	
+	pointer = strtok( buf, CMD_SEP );
+	while( pointer ){
+		if( c == 0 ){
+			cmd1->action = pointer;
+		}
+		else if( c == 1 ){
+			cmd1->canal = pointer;
+		}
+		else if( c == 2 ){
+			cmd1->command = pointer;
+		}
+		else if( c == 3 ){
+			cmd1->value0 = pointer;
+		}
+		else if( c == 4 ){
+			cmd1->value1 = pointer;
+		}
+		else if( c == 5 ){
+			cmd1->value2 = pointer;
+		}
+		else if( c == 6 ){
+			cmd1->value3 = pointer;
+		}
+		else if( c == 7 ){
+			cmd1->value4 = pointer;
+		}				 
+		else if( c == 8 ){
+			cmd1->value5 = pointer;
+		}
+		else if( c == 9 ){
+			cmd1->value6 = pointer;
+		}
+		else if( c == 10 ){
+			cmd1->value7 = pointer;
+		}
+		pointer = strtok( NULL, CMD_SEP );
+		c++;
+	}
+	return 0;
+}
+
+
+int init_command(Command *cmd1){
+	cmd1->action = NULL;
+	cmd1->canal = NULL;
+	cmd1->command = NULL;
+	cmd1->value0 = NULL;
+	cmd1->value1 = NULL;
+	cmd1->value2 = NULL;
+	cmd1->value3 = NULL;
+	cmd1->value4 = NULL;
+	cmd1->value5 = NULL;
+	cmd1->value6 = NULL;
+	cmd1->value7 = NULL;
+	cmd1->value8 = NULL;
+	cmd1->value9 = NULL;
+	cmd1->value10 = NULL;
+	cmd1->value11 = NULL;
+	cmd1->value12 = NULL;
+	cmd1->value13 = NULL;
+	cmd1->value14 = NULL;
+	cmd1->value15 = NULL;
+	cmd1->value16 = NULL;
+	cmd1->value17 = NULL;
+	cmd1->value18 = NULL;
+	cmd1->value19 = NULL;
+	return 0;
+}
+
+
+//Convert double into 6 bytes sent back by an unsigned char pointer
+int convert_double_6char (double fraction, unsigned char* octets) {
+	double  bita, bitb, bitc, bitd, bite, bitf;
+	bitf= fraction/(1099511627776.0); 
+	*(octets+5)=(unsigned char)bitf;
+	bite= (fraction-1099511627776.0*(*(octets+5)))/(4294967296.0);
+	*(octets+4)=(unsigned char)bite;
+	bitd=(fraction-1099511627776.0*(*(octets+5))- 4294967296.0*(*(octets+4)))/( 16777216.0);
+	*(octets+3)=(unsigned char)bitd;
+	bitc=(fraction-1099511627776.0*(*(octets+5))- 4294967296.0*(*(octets+4))-16777216.0*(*(octets+3)))/( 65536.0);
+	*(octets+2)=(unsigned char)bitc;
+	bitb= (fraction-1099511627776.0*(*(octets+5))- 4294967296.0*(*(octets+4))-16777216.0*(*(octets+3))-65536*(*(octets+2)))/ 256.0;
+	*(octets+1)=(unsigned char)bitb;
+	bita= (fraction-1099511627776.0*(*(octets+5))- 4294967296.0*(*(octets+4))-16777216.0*(*(octets+3))-65536*(*(octets+2))-256.0*(*(octets+1)))/ 1.0;  
+	*(octets)=(unsigned char)bita;
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDS_Fox.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,69 @@
+typedef struct {
+	char Name[255];
+	char ip[255];
+	int Port;
+	//int Divider;
+	double Clock;
+	double Frequency;
+	double SweepRate;
+	double Delta_T;
+	unsigned int Profil;  // numéro de profil de la DDS : single freq=0, sweep=7
+}DDSParameter;
+
+
+
+
+
+
+typedef struct {
+	char* action;
+	char* canal;
+	char* command;  
+	char* value0;
+	char* value1;
+	char* value2;
+	char* value3;
+	char* value4;
+	char* value5;
+	char* value6;
+	char* value7;
+	char* value8;
+	char* value9;
+	char* value10;
+	char* value11;
+	char* value12;
+	char* value13;
+	char* value14;
+	char* value15;
+	char* value16;
+	char* value17;
+	char* value18;
+	char* value19;
+	
+}Command;
+
+
+void DDS_Initialize (DDSParameter * Param) ;
+void DDSFox_Reset(DDSParameter * Param);
+void DDSFox_SetFreq (DDSParameter * Param) ;
+void DDSFox_SetFreqMax (DDSParameter *Param);
+void DDSFox_SetFreqMin (DDSParameter *Param) ;
+//void DDSFox_SetRate (DDSParameter * Param) ;
+void DDSFox_SetDiv(DDSParameter * Param) ;
+void DDSFox_SetDT(DDSParameter * Param);
+void DDSFox_SetDf(DDSParameter * Param);
+int DDSFox_GetSweepSign(DDSParameter * Param);
+void DDSFox_SetSweepSign(DDSParameter * Param) ;
+void DDSFox_StopSweep(DDSParameter * Param);
+void DDSFox_StartSweep(DDSParameter * Param);
+double DDSFox_ReadFreq(DDSParameter * Param);
+int SendCmd(char * Buffer, DDSParameter * Param) ;
+int RecvCmd2(int * cmd, char * Buffer, DDSParameter * Param) ;
+int RecvCmd(Command * Rd, char * Buffer, DDSParameter * Param) ;
+int OnTCPEvent(unsigned handle, int xType, int errCode, void *callbackData) ;
+void parse_command2(int * cmd, char * buf ) ;
+int parse_command(Command * cmd1, char * command ) ;
+int convert_double_6char (double fraction, unsigned char* octects) ;
+int init_command(Command * cmd1) ;
+void DDS_ReInitialize (DDSParameter *Param);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAllan.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,45 @@
+/**************************************************************************/
+/* LabWindows/CVI User Interface Resource (UIR) Include File              */
+/* Copyright (c) National Instruments 2010. All Rights Reserved.          */
+/*                                                                        */
+/* WARNING: Do not add to, delete from, or otherwise modify the contents  */
+/*          of this include file.                                         */
+/**************************************************************************/
+
+#include <userint.h>
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+     /* Panels and Controls: */
+
+#define  ALLANPANEL                       1       /* callback function: CB_GeneralAllanPanel */
+#define  ALLANPANEL_NORMALIZER            2       /* callback function: Allan_CB_ChangeNormalizer */
+#define  ALLANPANEL_ALLANPLOT             3
+#define  ALLANPANEL_MAX                   4       /* callback function: Allan_CB_ChangeMax */
+#define  ALLANPANEL_MIN                   5       /* callback function: Allan_CB_ChangeMin */
+#define  ALLANPANEL_CHECKBOX_AUTOSCALE    6       /* callback function: Allan_CB_ChangeAutoScale */
+#define  ALLANPANEL_RESETBUTTON           7       /* callback function: Allan_CB_Reset */
+#define  ALLANPANEL_DRIFT                 8
+#define  ALLANPANEL_DEDRIFT               9
+
+
+     /* Menu Bars, Menus, and Menu Items: */
+
+          /* (no menu bars in the resource file) */
+
+
+     /* Callback Prototypes: */ 
+
+int  CVICALLBACK Allan_CB_ChangeAutoScale(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Allan_CB_ChangeMax(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Allan_CB_ChangeMin(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Allan_CB_ChangeNormalizer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Allan_CB_Reset(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_GeneralAllanPanel(int panel, int event, void *callbackData, int eventData1, int eventData2);
+
+
+#ifdef __cplusplus
+    }
+#endif
Binary file FXAllan.uir has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAnalyse.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,2873 @@
+#include <utility.h>
+#include <ansi_c.h>
+#include <cvirte.h>		
+#include <userint.h>
+#include <formatio.h>
+#include <string.h>
+
+#include "YLCStuff.h"
+#include "FXAnalyse.h" 
+#include "Plot.h"
+#include "Allan.h"
+#include "DDSBes.h"
+#include "DDS4xAD9912.h"
+#include "DDS_Fox.h" 
+#include "muParserDLL.h"
+
+
+#define FXLINELENGTH 123
+#define DDSBESCLOCK (200.e6)	 // 200MHz de clock pour la DDS de Besancon...
+
+
+#define LOGFILEPATH "C:\\Femto\\Software\\FXQE80"		
+#define FREP_NORMAL_FORMULA "(0-15M+DDS-Ch1/200)/12+2M/3"
+#define NUOL_NORMAL_FORMULA "(N*250M-194400G)+N*Math1-8*DDS1"
+#define NUHG_NORMAL_FORMULA "(N*250M-282143G)+N*Math1-(DDS1-Ch2)"
+#define NUSR_NORMAL_FORMULA "(N*250M-429228G)+N*Math1+(DDS2-Ch3)"
+#define NU813_NORMAL_FORMULA "(N*766M-368554G)+N*Math1+000.000M"
+#define NU1064_NORMAL_FORMULA "(N*766M-281630G)+(DDS_1064-Ch4)"
+
+#define FACTORDDSBES 36*(8/770000)
+
+//==============================================================================
+// Static global variables
+
+/* multi threading stuff */  // to be used when I will replace timer by thread for counder readout
+//static int ghPool;
+//static volatile int vgExiting = 0;
+
+/* panel handling stuff */
+static PanelHandle MainPanel ;
+static PanelHandle CalcN1Panel ;
+static PanelHandle CalcN2Panel ;
+static PanelHandle CalcN3Panel ;
+
+//==============================================================================
+// Static functions
+
+//static int CVICALLBACK ReadCounterThread(void *functionData);	   // to be used when I will replace timer by thread for counder readout  
+
+//==============================================================================
+// Global variables
+
+char * LogFileName ;
+char ExtraMathFileName[MAX_PATHNAME_LEN] ;
+
+double utc = 0 ;
+double mjd =0 ;
+
+double Ch1, Ch2, Ch3, Ch4 ; // le type long double est identique au double (8 octets) sous CVI !!! 
+double Math1, Math2, Math3, Math4, Math5; // N est en fait un entier en pratique...
+double N1, N2, N3,N4 ;
+
+Plot_Data PlotCh1, PlotCh2, PlotCh3, PlotCh4, PlotMath1, PlotMath2, PlotMath3, PlotMath4, PlotMath5 ;  
+Allan_Data AllanCh1, AllanCh2, AllanCh3, AllanCh4, AllanMath1, AllanMath2, AllanMath3, AllanMath4, AllanMath5 ; 
+
+DDSBes_Data DDSBes ;
+DDS4xAD9912_Data DDS4xAD9912 ;
+
+muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5 ;
+
+volatile bool Acquiring = FALSE ;
+
+long OldLogFilePtr = 0 ;
+
+double NuOpt=0.0;
+double Ndiv=8.0;
+
+///////////////////
+//Pour les calculs des N
+
+volatile bool Measuring_1 = FALSE,Step1_1 = FALSE,Step2_1 = FALSE,Step3_1 = FALSE, Measuring_2 = FALSE,Step1_2 = FALSE,Step2_2 = FALSE,Step3_2 = FALSE;
+volatile bool Measuring_3 = FALSE,Step1_3 = FALSE,Step2_3 = FALSE,Step3_3 = FALSE;
+volatile bool TimetoBegin=FALSE;
+
+double FrequDDS1=110000000.0,FrequDDS2=15300000.0,FrequDDS3=150400000.000000;
+double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; 
+double SlopeTime1=60.0,SlopeTime2=60.0;
+
+double N_1=0.0,N_2=0.0,N_3=0.0;
+double DeltaT_1=8.0,DeltakHz_1=1800.0,t1_1=0.0,t2_1=0.0,t3_1=0.0, Frepplus_1=0.0, Frepminus_1=0.0;
+double DeltaT_2=8.0,DeltakHz_2=1500.0,t1_2=0.0,t2_2=0.0,t3_2=0.0, Frepplus_2=0.0, Frepminus_2=0.0;
+double DeltaT_3=20.0,DeltakHz_3=100.0,t1_3=0.0,t2_3=0.0,t3_3=0.0, Frepplus_3=0.0, Frepminus_3=0.0;
+
+
+int DeltaTMoy_1=3,n_1=0,DeltaTMoy_2=3,n_2=0,DeltaTMoy_3=3,n_3=0;
+double Tmoy_1_1=0.0,Tmoy_2_1=0.0,Tmoy_1_2=0.0,Tmoy_2_2=0.0,Tmoy_1_3=0.0,Tmoy_2_3=0.0; 
+double Frequ_slope_1=0.0,Moy_slope_1=0.0,Slope_slope_1=0.0,Frequ_slope_2=0.0,Moy_slope_2=0.0,Slope_slope_2=0.0,Frequ_slope_3=0.0,Moy_slope_3=0.0,Slope_slope_3=0.0;  
+int N_slope_1=0,N_slope_2=0,N_slope_3=0;
+double  Beat_slope_2=0.0 ,Moy_Beatslope_2=0.0,Slope_Beatslope_2=0.0; 
+double Ch4_slope=0.0,Moy_Ch4slope_1=0.0,Slope_Ch4slope_1=0.0,Ch4Slope=0.0;
+
+double FrequencyDDSBes=0.0,FrequencyDDSBesInit=0.0;
+double FrequencyDDS3=0.0,FrequencyDDS3Init=0.0;
+double DeltaFrep275=0.0,DeltaFrep10=0.0; ;
+double DDSBesChanged1=FALSE,DDSBesChanged2=FALSE;
+
+double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0;
+double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6;  
+
+double Step1=800000.0,Step2=800000.0;
+
+double Ch4Plus=0.0,Ch4Minus=0.0;
+
+int NDEJAPASSE=0, nDDSChange=0, nstabilization=0  ;
+
+//////
+//Pour les signes de fb
+
+double Frequencystep1=10000.0,tbegin1=0.0,Frepbefore1=0.0,Frequency1=0.0,Frequencystep2=10.0,tbegin2=0.0,Frepbefore2=0.0,Ch2before=0.0,Frequency2=0.0,Frequencystep3=100000.0,tbegin3=0.0,Frepbefore3=0.0,Frequency3=0.0;
+volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE;
+double Signe1=1.0,Signe2=1.0,Signe3=0.0;
+
+
+
+
+
+/////////////////////////
+// Slope Cancelling Variables
+
+volatile bool SlopeMeasuring=FALSE;
+volatile bool AutoStopSlopeCancellingIfDelock=TRUE;
+volatile bool OnSlopeCancelling =FALSE;  
+double SlopeMath2=0.0;
+double TimetoSlope=60.0;
+double SlopeMeasuringTimeBegin=0.0;
+char * OnOffMessage="OFF" ;
+
+char DDSFoxName[255] = "DDS Fox Control" ; 
+double DDSFoxClock=200000000;
+int DDSFoxSweepSign=0;
+double DDSFoxFrequency=70000000.0;
+char DDSFoxip[255]="145.238.205.58";
+int DDSFoxPort=6665 ;
+unsigned int DDSFoxProfil=7;
+double DDSFoxSweeprate=0.0;// numéro de profil de la DDS : single freq=0, sweep=7  ;
+double DDSFoxDeltaT=0.01;
+
+double Slope_Math2slope=0.0,Math2_slope=0.0,Moy_Math2slope=0.0;
+int N_Math2slope=0.0,nstabilisationSlopeMeasuring=0;
+
+double LimitToDelock=5.0;
+double SlopeCorrection=0.0;
+
+int ratio=10; //Recentre la frequence tous les ratios
+
+volatile bool FrequCorrec=FALSE,KeepFrequ=TRUE, KeepSlope=TRUE ;
+int Nratio=-1;
+double MoyMath2=0.0,CenterFrequencyCh2=0.0;
+volatile bool CenterFrequencyCh2ToDetermine=FALSE;
+
+double limitotakoff=70.0;
+
+
+
+
+//////////////////////////////////
+//  Keep Centered Variables
+
+volatile bool KeepCentering=FALSE; 
+double Timetorecenter275K=3600.0*10; 
+double Timetorecenter10K=3600.0*3;  
+double CenteringTimeBegin275K=0.0;
+double CenteringTimeBegin10K=0.0; 
+
+
+
+//==============================================================================
+// Functions
+ int LaunchDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate,int mode) ;
+ double ReadDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate) ;
+
+ 
+ 
+ 
+
+void initMathParser(muParserHandle_t * pMathParser) 
+{
+	(* pMathParser) = mupCreate() ;		// Math parser number 1, normally used for frep
+	mupDefineOprtChars( * pMathParser, "abcdefghijklmnopqrstuvwxyzµ"
+                              		   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                            		   "+-*^/?<>=#!$%&|~'_");
+	mupDefineVar( * pMathParser, "UTC", &utc);
+	mupDefineVar( * pMathParser, "MJD", &mjd);
+	mupDefineVar( * pMathParser, "Ch1", &Ch1);
+	mupDefineVar( * pMathParser, "Ch2", &Ch2);
+	mupDefineVar( * pMathParser, "Ch3", &Ch3);
+	mupDefineVar( * pMathParser, "Ch4", &Ch4);
+	mupDefineVar( * pMathParser, "DDS_Frep", &(DDSBes.Frequency));
+	mupDefineVar( * pMathParser, "DDS1", &(DDS4xAD9912.Frequency1));   
+	mupDefineVar( * pMathParser, "DDS2", &(DDS4xAD9912.Frequency2));
+	mupDefineVar( * pMathParser, "DDS3", &(DDS4xAD9912.Frequency3));  
+	mupDefineVar( * pMathParser, "DDS4", &(DDS4xAD9912.Frequency4));  
+	mupDefineVar( * pMathParser, "N1", &N1);
+	mupDefineVar( * pMathParser, "N2", &N2);
+	mupDefineVar( * pMathParser, "N3", &N3);
+	mupDefineVar( * pMathParser, "Nu1", &Nu1);
+	mupDefineVar( * pMathParser, "Nu2", &Nu2);
+	mupDefineVar( * pMathParser, "DeltaDDS3", &DeltaDDS3);
+	mupDefineVar( * pMathParser, "Signe1", &Signe1);
+	mupDefineVar( * pMathParser, "Signe2", &Signe2); 
+	mupDefineVar( * pMathParser, "Ndiv", &Ndiv); 
+	mupDefinePostfixOprt( * pMathParser, "P", &Peta , 1);
+	mupDefinePostfixOprt( * pMathParser, "T", &Tera , 1);
+	mupDefinePostfixOprt( * pMathParser, "G", &Giga , 1);
+	mupDefinePostfixOprt( * pMathParser, "M", &Mega , 1);
+	mupDefinePostfixOprt( * pMathParser, "k", &kilo , 1);
+	mupDefinePostfixOprt( * pMathParser, "m", &milli, 1);
+	mupDefinePostfixOprt( * pMathParser, "u", &micro, 1);
+	mupDefinePostfixOprt( * pMathParser, "µ", &micro, 1);
+	mupDefinePostfixOprt( * pMathParser, "n_1", &nano,  1);
+	mupDefinePostfixOprt( * pMathParser, "p", &pico,  1);
+	mupDefinePostfixOprt( * pMathParser, "f", &femto, 1);
+}
+
+int main (int argc, char *argv[])
+{
+	//int ThreadId ;   // to be used when I will replace timer by thread for counder readout
+	
+	char FileNamePrototype[MAX_PATHNAME_LEN] ;  
+	double initfreqDDS ;
+	char * MathString1 = "                                                             " ;
+	char * MathString2 = "                                                             " ;
+	char * MathString3 = "                                                             " ;
+	char * MathString4 = "                                                             " ;  
+	char * MathString5 = "                                                             " ;
+	
+	if (InitCVIRTE (0, argv, 0) == 0)
+		return -1;	/* out of memory */
+	if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0)
+		return -1;
+	if ((CalcN1Panel = LoadPanel (0, "FXAnalyse.uir", CALCN1)) < 0)
+		return -1;
+	if ((CalcN2Panel = LoadPanel (0, "FXAnalyse.uir", CALCN2)) < 0)
+		return -1;
+	if ((CalcN3Panel = LoadPanel (0, "FXAnalyse.uir", CALCN3)) < 0)
+		return -1;
+	SetPanelAttribute(MainPanel, ATTR_TITLE, "Femto Soft") ;
+	
+	DisplayPanel (MainPanel);
+	
+		// Initialize LogFileName pointer
+	
+	LogFileName = FileNamePrototype ;
+	
+	// Initialyze the DDS Besancon Output
+	
+	DDSBes_Initialize(&DDSBes) ;
+	DDSBes_SetClockFrequency(&DDSBes, DDSBESCLOCK) ;	   // Peut etre passer tout ca dans DDSBes-Initialize ?
+	DDSBes_SetAmplitude(&DDSBes, 4095) ;
+	GetCtrlVal(MainPanel, PANEL_DDSFREPOUT,&initfreqDDS) ;
+	DDSBes_SetFrequency(&DDSBes, initfreqDDS) ; 
+	
+	// Initialize the quadruple AD9959 DDS (Fox board interface)
+	
+	DDS4xAD9912_Reset(&DDS4xAD9912) ;
+	GetCtrlVal(MainPanel, PANEL_DDS1, &initfreqDDS) ;
+	DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, initfreqDDS) ;
+	GetCtrlVal(MainPanel, PANEL_DDS2, &initfreqDDS) ;
+	DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, initfreqDDS) ;
+	GetCtrlVal(MainPanel, PANEL_DDS3, &initfreqDDS) ;
+	DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, initfreqDDS) ;
+	GetCtrlVal(MainPanel, PANEL_DDS4, &initfreqDDS) ;
+	DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, initfreqDDS) ;
+	
+	
+	// Initialyze the DDSFOX Output  
+	LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate,1);  
+	
+	// Initialize the 5 (separate) math parsers for frep, Nu_Hg, Nu_Sr, N3 and ExtraMath
+
+	Ch1=0.0 ; Ch2=0.0 ; Ch3=0.0 ; Ch4=0.0 ;
+	GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1) ;
+	GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2) ;
+
+	GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3) ;
+	
+	initMathParser(&MathParser1) ;
+	mupDefineVar(MathParser1, "DDS", &(DDSBes.Frequency));
+	GetCtrlVal(MainPanel, PANEL_MATHSTRING1, MathString1) ;
+	mupSetExpr(MathParser1, MathString1);
+	
+	initMathParser(&MathParser2) ;
+	mupDefineVar( MathParser2, "Math1", &Math1);
+	mupDefineVar( MathParser2, "DDS", &(DDS4xAD9912.Frequency1));
+	GetCtrlVal(MainPanel, PANEL_MATHSTRING2, MathString2) ;
+	mupSetExpr(MathParser2, MathString2);
+	
+	initMathParser(&MathParser3) ;
+	mupDefineVar( MathParser3, "Math1", &Math1);
+	mupDefineVar( MathParser3, "Math2", &Math2);
+	mupDefineVar( MathParser3, "DDS", &(DDS4xAD9912.Frequency2));
+	GetCtrlVal(MainPanel, PANEL_MATHSTRING3, MathString3) ;
+	mupSetExpr(MathParser3, MathString3);
+	
+	initMathParser(&MathParser4) ;
+	mupDefineVar( MathParser4, "Math1", &Math1);
+	mupDefineVar( MathParser4, "Math2", &Math2);
+	mupDefineVar( MathParser4, "Math3", &Math3);
+	GetCtrlVal(MainPanel, PANEL_MATHSTRING4, MathString4) ;
+	mupSetExpr(MathParser4, MathString4);
+	
+	initMathParser(&MathParser5) ;
+	mupDefineVar( MathParser5, "Math1", &Math1);
+	mupDefineVar( MathParser5, "Math2", &Math2);
+	mupDefineVar( MathParser5, "Math3", &Math3);
+	mupDefineVar( MathParser5, "Math4", &Math4);
+	GetCtrlVal(MainPanel, PANEL_MATHSTRING5, MathString5) ;
+	mupSetExpr(MathParser5, MathString5);
+	
+	
+	RunUserInterface ();
+	
+	// Stops everything at the end
+	
+	DiscardPanel (MainPanel);
+	return 0;
+}
+
+
+void OnCloseViewPanel(int panel){
+	
+	if (panel==PlotCh1.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ1PLOT, FALSE) ; } ; 
+	if (panel==PlotCh2.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ2PLOT, FALSE) ; } ; 
+	if (panel==PlotCh3.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ3PLOT, FALSE) ; } ; 
+	if (panel==PlotCh4.PlotPanel) 		{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ4PLOT, FALSE) ; } ;
+	if (panel==PlotMath1.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH1PLOT, FALSE) ; } ; 
+	if (panel==PlotMath2.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH2PLOT, FALSE) ; } ;
+	if (panel==PlotMath3.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH3PLOT, FALSE) ; } ; 
+	if (panel==PlotMath4.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH4PLOT, FALSE) ; } ;
+	if (panel==PlotMath5.PlotPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH5PLOT, FALSE) ; } ;
+	
+	if (panel==AllanCh1.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ1ALLAN, FALSE) ; } ; 
+	if (panel==AllanCh2.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ2ALLAN, FALSE) ; } ; 
+	if (panel==AllanCh3.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ3ALLAN, FALSE) ; } ; 
+	if (panel==AllanCh4.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ4ALLAN, FALSE) ; } ; 
+	if (panel==AllanMath1.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH1ALLAN, FALSE) ; } ; 
+	if (panel==AllanMath2.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH2ALLAN, FALSE) ; } ; 
+	if (panel==AllanMath3.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH3ALLAN, FALSE) ; } ; 
+	if (panel==AllanMath4.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH4ALLAN, FALSE) ; } ; 
+	if (panel==AllanMath5.AllanPanel) 	{ SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH5ALLAN, FALSE) ; } ;  
+	
+	return ;
+}
+
+
+
+
+
+int CVICALLBACK QuitCallback (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			QuitUserInterface (0);
+			DDSBes_Close(&DDSBes);
+			mupRelease(MathParser1);
+			mupRelease(MathParser2); 
+			mupRelease(MathParser3);
+			mupRelease(MathParser4);
+			mupRelease(MathParser5);
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+	return 0;
+}
+
+int  CVICALLBACK CB_OnEventMain(int panel, int event, void *callbackData, int eventData1, int eventData2)
+{
+	int VirtualKeyCode ;
+	int ActiveControl ;
+	int StepIndex ;
+	double Step ;
+	
+	switch (event) {
+		case EVENT_CLOSE:
+			QuitUserInterface (0);
+			DDSBes_Close(&DDSBes);
+			mupRelease(MathParser1);
+			mupRelease(MathParser2); 
+			mupRelease(MathParser3);
+			break;
+		case EVENT_KEYPRESS:
+			switch (eventData1)	// ie the code of the key which has been stroke 
+				{
+				case VAL_RIGHT_ARROW_VKEY :
+					ActiveControl = GetActiveCtrl(panel);
+					if (ActiveControl==PANEL_DDSFREPOUT || ActiveControl==PANEL_DDSFREPSTEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDSFREPSTEP, &StepIndex);
+						if (StepIndex<14){
+							SetCtrlIndex(MainPanel, PANEL_DDSFREPSTEP, ++StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDSFREPSTEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDSFREPOUT, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS1 || ActiveControl==PANEL_DDS1STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS1STEP, &StepIndex);
+						if (StepIndex<14){
+							SetCtrlIndex(MainPanel, PANEL_DDS1STEP, ++StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS1STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS1, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS2 || ActiveControl==PANEL_DDS2STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS2STEP, &StepIndex);
+						if (StepIndex<14){
+							SetCtrlIndex(MainPanel, PANEL_DDS2STEP, ++StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS2STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS2, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS3|| ActiveControl==PANEL_DDS3STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS3STEP, &StepIndex);
+						if (StepIndex<14){
+							SetCtrlIndex(MainPanel, PANEL_DDS3STEP, ++StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS3STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS3, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS4|| ActiveControl==PANEL_DDS4STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS4STEP, &StepIndex);
+						if (StepIndex<14){
+							SetCtrlIndex(MainPanel, PANEL_DDS4STEP, ++StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS4STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS4, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					break;
+				case VAL_LEFT_ARROW_VKEY :
+					ActiveControl = GetActiveCtrl(panel);
+					if (ActiveControl==PANEL_DDSFREPOUT || ActiveControl==PANEL_DDSFREPSTEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDSFREPSTEP, &StepIndex);
+						if (StepIndex>0){
+							SetCtrlIndex(MainPanel, PANEL_DDSFREPSTEP, --StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDSFREPSTEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDSFREPOUT, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS1 || ActiveControl==PANEL_DDS1STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS1STEP, &StepIndex);
+						if (StepIndex>0){
+							SetCtrlIndex(MainPanel, PANEL_DDS1STEP, --StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS1STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS1, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS2 || ActiveControl==PANEL_DDS2STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS2STEP, &StepIndex);
+						if (StepIndex>0){
+							SetCtrlIndex(MainPanel, PANEL_DDS2STEP, --StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS2STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS2, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS3 || ActiveControl==PANEL_DDS3STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS3STEP, &StepIndex);
+						if (StepIndex>0){
+							SetCtrlIndex(MainPanel, PANEL_DDS3STEP, --StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS3STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS3, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					if (ActiveControl==PANEL_DDS4 || ActiveControl==PANEL_DDS4STEP) {
+						GetCtrlIndex(MainPanel, PANEL_DDS4STEP, &StepIndex);
+						if (StepIndex>0){
+							SetCtrlIndex(MainPanel, PANEL_DDS4STEP, --StepIndex) ;
+							GetCtrlVal(MainPanel, PANEL_DDS4STEP, &Step);
+							SetCtrlAttribute(MainPanel, PANEL_DDS4, ATTR_INCR_VALUE, Step) ;
+						};
+					};
+					break;
+				case VAL_F1_VKEY :
+					SetActiveCtrl(MainPanel, PANEL_DDSFREPOUT);
+					break;
+				case VAL_F2_VKEY :
+					SetActiveCtrl(MainPanel, PANEL_DDS1);
+					break;
+				case VAL_F3_VKEY :
+					SetActiveCtrl(MainPanel, PANEL_DDS2);
+					break;
+				case VAL_F4_VKEY :
+					SetActiveCtrl(MainPanel, PANEL_DDS3);
+					break;
+				case VAL_F5_VKEY :
+					SetActiveCtrl(MainPanel, PANEL_DDS4);
+					break;
+				};
+			break;
+			
+	}
+	return 0;
+}
+
+void FindCurrentFileName(void)
+{
+	char * date, day[3], month[3], year[3];	    // DD ; MM ; 20YY plus one space for NULL termination character
+	
+	date = DateStr();
+	Scan(date, "%s>%s[w2]-%s[w2]-20%s[w2]", month, day, year);	   
+	Fmt(LogFileName, "%s<%s\\%s%s%s_Frequ.txt", LOGFILEPATH, year, month, day);		 
+	return ;
+}
+
+
+
+int CVICALLBACK CB_OnStart (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int LogFile ;
+	char CharacterBuffer[]="\r" ; 
+	char LineBuffer[FXLINELENGTH+10] = "\r\n_1 ";  
+	
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (Acquiring) {
+				PlotCh1.IndexPoint = 0 ;
+				PlotCh2.IndexPoint = 0 ;
+				PlotCh3.IndexPoint = 0 ;
+				PlotCh4.IndexPoint = 0 ;
+				PlotMath1.IndexPoint = 0 ;
+				PlotMath2.IndexPoint = 0 ; 
+				PlotMath3.IndexPoint = 0 ; 
+				PlotMath4.IndexPoint = 0 ; 
+				PlotMath5.IndexPoint = 0 ;
+				Allan_Reset(&AllanCh1) ;
+				Allan_Reset(&AllanCh2) ;
+				Allan_Reset(&AllanCh3) ;
+				Allan_Reset(&AllanCh4) ;
+				Allan_Reset(&AllanMath1) ;
+				Allan_Reset(&AllanMath2) ;
+				Allan_Reset(&AllanMath3) ;
+				Allan_Reset(&AllanMath4) ;
+				Allan_Reset(&AllanMath5) ;
+				} ;
+			Acquiring = TRUE ;
+			SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__RESET"); 
+			
+			FindCurrentFileName() ; // LogFileName is the one corresponding to the date of today...
+			GetFileInfo(LogFileName, &OldLogFilePtr) ;
+			OldLogFilePtr -= OldLogFilePtr%FXLINELENGTH + FXLINELENGTH - 2;
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnStop (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			Acquiring = FALSE ;
+			SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__START");
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnTimer (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int LogFile, FileOpt, FileHg, FileSr, FileExtraMath ;
+	long LogFileSize ;
+	char CharacterBuffer[]="\r" ;
+	char LineBuffer[FXLINELENGTH+10] = "\r\n_1 ";
+	
+	char * dateNow, * timeNow, day[4], month[4], year[4] ;
+	char TimeTag[] = "100103 000000.000"  ;   // K+K time tag meaning here 2010 january the 3rd at 00:00:00.000
+	char Date[] = "03/01/2010" ;
+	char Time[] = "00:00:00.000" ;
+	char Year[] = "2010";
+	char ShortYear[] = "10";  // the last 2 digits of calendar year only
+	char Month[] = "01";
+	char Day[] = "03";
+	char Hour[] = "00";
+	char Min[] = "00" ;
+	char Sec[] = "00.000";
+	struct tm LocalTime ;
+	time_t utcTime ;
+	char * ReportString = "dd.mm.yy\t00:00:00\t3481610838.000\t0000000000000.00000000" ;
+
+	int NotCare = 0 ;
+	bool BoxChecked = FALSE; 
+	
+	double Target, NCalc ;
+
+	double FoxFrequ=0.0;
+	int Div = 1 ;  
+	
+	double FrequencyToChange=0.0;
+	double DeltaCh2=0.0;
+	double DeltaCh4=0.0;  
+	
+	double ActualFrequ=0.0;
+	double ActualSlope=0.0;
+	
+	double DDS3Bize ;
+	double DDS2Bize ;
+	int N2Bize ;
+	int Signe2Bize;
+	double Math3Bize;
+	double Math1Bize;
+	
+	
+	
+	switch (event)
+		{
+		case EVENT_TIMER_TICK:
+			switch(Acquiring) 
+				{
+				case TRUE:
+					
+					GetFileInfo(LogFileName, &LogFileSize) ;
+					
+					if (LogFileSize > OldLogFilePtr+2*FXLINELENGTH-2) {  // if a complete newline has been written
+						
+						SuspendTimerCallbacks ; 
+						
+						// Open Log file and get to the beginning of newly completed line
+						LogFile = OpenFile(LogFileName, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII) ;
+						OldLogFilePtr += FXLINELENGTH;
+						SetFilePtr(LogFile, OldLogFilePtr, 0) ;
+					
+						// return the last complete string from the log file and scan it for date and time information 
+						
+						// first, the time tag, and store it in various formats
+						ReadFile(LogFile, TimeTag, 17);
+						
+						CopyBytes(Date,0,TimeTag,4,2);
+						CopyBytes(Date,3,TimeTag,2,2);   
+						CopyBytes(Date,8,TimeTag,0,2);
+						CopyBytes(Time,0,TimeTag,7,2);
+						CopyBytes(Time,3,TimeTag,9,2);
+						CopyBytes(Time,6,TimeTag,11,6);
+						SetCtrlVal(MainPanel, PANEL_DATE, Date) ;
+						SetCtrlVal(MainPanel, PANEL_TIME, Time) ; 
+						
+						CopyBytes(Year,2,TimeTag,0,2); // first 2 bytes of year string remains "20"
+						CopyBytes(ShortYear,0,TimeTag,0,2);
+						CopyBytes(Month,0,TimeTag,2,2);
+						CopyBytes(Day,0,TimeTag,4,2);
+						CopyBytes(Hour,0,TimeTag,7,2);
+						CopyBytes(Min,0,TimeTag,9,2);
+						CopyBytes(Sec,0,TimeTag,11,6);
+						Fmt(&LocalTime.tm_year, "%d<%s", Year);
+						Fmt(&LocalTime.tm_mon,  "%d<%s", Month);
+						Fmt(&LocalTime.tm_mday, "%d<%s", Day);
+						Fmt(&LocalTime.tm_hour, "%d<%s", Hour);
+						Fmt(&LocalTime.tm_min,  "%d<%s", Min);
+						Fmt(&LocalTime.tm_sec,  "%d<%s", "00");    // special case to handle non integer number of UTC seconds
+						LocalTime.tm_hour += 0;
+						LocalTime.tm_min  -= 0;  
+						LocalTime.tm_sec  -= 0;  
+						LocalTime.tm_mon  -= 1 ;  	// january is month 0 for tm struct
+						LocalTime.tm_year -= 1900 ; // year is number of years since 1900 for tm struct
+						LocalTime.tm_isdst = -1;  // daylight saving flag MUST be set to -1 (unallocated is bugging and +1 is making 1 hour error in summer)
+						utcTime = mktime (&LocalTime);
+						utc = (double) utcTime + strtod(Sec,NULL) ;
+						mjd=utc/86400.;		//nb de jours depuis l'origine d'UTC (01/01/1900 à 00h00 GMT)
+						mjd+=15020;			//date MJD de la date origine d'UTC
+						SetCtrlVal(MainPanel, PANEL_UTC, utc);
+						SetCtrlVal(MainPanel, PANEL_MJD, mjd);
+				
+						// scan the line for counters's channels information
+						
+						ReadLine(LogFile, LineBuffer, FXLINELENGTH+9) ;
+						CloseFile(LogFile);
+						
+						Scan(LineBuffer, "%f%f%f%f", &Ch1, &Ch2, &Ch3, &Ch4) ;
+						Ch1 = 1000*Ch1;
+						Ch2 = 1000*Ch2;
+						Ch3 = 1000*Ch3;
+						Ch4 = 1000*Ch4;
+						
+						NuOpt=N1*(250000000+Math1)-Signe1*8*FrequDDS1 ;
+						
+						SetCtrlVal(MainPanel, PANEL_FREQ1, Ch1) ;
+						SetCtrlVal(MainPanel, PANEL_FREQ2, Ch2) ;
+						SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3) ;  
+						SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4) ;
+						SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1);
+						SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2); 
+						SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3); 
+						SetCtrlVal(CalcN1Panel, CALCN1_N_1, N_1) ;
+						SetCtrlVal(CalcN1Panel, CALCN1_SLOPE, Slope_1) ;
+						SetCtrlVal(CalcN2Panel, CALCN2_N_2, N_2) ;
+						SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2) ;
+						SetCtrlVal(CalcN3Panel, CALCN3_N_3, N_3) ;
+						SetCtrlVal(CalcN3Panel, CALCN3_SLOPE, Slope_3) ;
+						SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2);
+						/*SetCtrlVal(MainPanel, PANEL_SLOPECANCELONOFF, OnOffMessage); */
+						SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2);  
+						SetCtrlVal(MainPanel, PANEL_LED1, SlopeMeasuring); 	   
+						SetCtrlVal(MainPanel, PANEL_LED2, OnSlopeCancelling);
+						// Treat data
+						
+						Math1 = mupEval(MathParser1) ;
+						SetCtrlVal(MainPanel,PANEL_MATH1, Math1) ;
+
+						Math2 = mupEval(MathParser2) ;
+						//Math2=NuOpt;
+						SetCtrlVal(MainPanel,PANEL_MATH2, Math2) ;
+						
+						Math3 = mupEval(MathParser3) ;
+						SetCtrlVal(MainPanel,PANEL_MATH3, Math3) ;
+						
+						Math4 = mupEval(MathParser4) ;
+						SetCtrlVal(MainPanel,PANEL_MATH4, Math4) ;
+						
+						Math5 = mupEval(MathParser5) ;
+						SetCtrlVal(MainPanel,PANEL_MATH5, Math5) ;
+						
+						// Plot Data and calculus if required
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotCh1, Ch1) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanCh1, Ch1) ;
+							}
+
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ2PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotCh2, Ch2) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ2ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanCh2, Ch2) ;
+							}
+							
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ3PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotCh3, Ch3) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ3ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanCh3, Ch3) ;
+							}
+							
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ4PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotCh4, Ch4) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ4ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanCh4, Ch4) ;
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH1PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotMath1, Math1) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH1ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanMath1, Math1) ;
+							}
+	
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotMath2, Math2) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanMath2, Math2) ;
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotMath3, Math3) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanMath3, Math3) ;
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotMath4, Math4) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanMath4, Math4) ;
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5PLOT, &BoxChecked) ;
+						if (BoxChecked) {
+							Plot_AddFrequency(&PlotMath5, Math5) ;
+							}
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5ALLAN, &BoxChecked) ;
+						if (BoxChecked) {
+							Allan_AddFrequency(&AllanMath5, Math5) ;
+							}
+						// Calcul de N
+						
+						if (Measuring_1==TRUE)
+							{
+								if (Step1_1==FALSE) {
+									SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+									DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
+									
+									GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit) ;
+									t1_1=utc;
+									Frequ_slope_1=Math1;
+									Moy_slope_1= Frequ_slope_1;
+									Ch4_slope=Ch4;
+									Moy_Ch4slope_1= Ch4_slope;
+									N_slope_1=1;
+									Step1_1=TRUE ;
+									}
+								else {
+									if(Step2_1==FALSE){
+										N_slope_1=N_slope_1+1; 
+										Frequ_slope_1=Math1;
+										Ch4_slope=Ch4; 
+										Moy_slope_1=((N_slope_1-1)*Moy_slope_1 + Frequ_slope_1)/N_slope_1;
+										Moy_Ch4slope_1=((N_slope_1-1)*Moy_Ch4slope_1 + Ch4_slope)/N_slope_1; 
+										Slope_slope_1 = (Slope_slope_1*(N_slope_1-2) + 6*(Frequ_slope_1-Moy_slope_1)/N_slope_1)/(N_slope_1+1) ;
+										Slope_Ch4slope_1 = (Slope_Ch4slope_1*(N_slope_1-2) + 6*(Ch4_slope-Moy_Ch4slope_1)/N_slope_1)/(N_slope_1+1) ;
+										if (utc-t1_1>SlopeTime1) {
+											Slope_1 = Slope_slope_1;
+											Ch4Slope =  Slope_Ch4slope_1;
+											Step2_1=TRUE ;
+											N_slope_1=0;
+											Frequ_slope_1=0.0;
+											Moy_slope_1=0.0;
+											Slope_slope_1 =0.0;
+											Ch4_slope=0.0;
+											Moy_Ch4slope_1=0.0;
+											Slope_Ch4slope_1=0.0;
+											
+											DDS4xAD9912_FrequencyRampe (&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv ) ;
+											SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000)) ;
+											DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000)); 
+											
+											}
+										}
+									else {
+									  if (DDSBesChanged1==FALSE){
+										  
+										  		if (nDDSChange<3)
+												{ nDDSChange=nDDSChange+1;}
+												
+												else
+												{
+												nDDSChange=0;
+													
+												DeltaFrep275=275000-Ch4;
+												FrequencyDDSBes=FrequencyDDSBesInit+(DeltaFrep275);
+												SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes) ;
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes);
+												DDSBesChanged1=TRUE;
+												t2_1=utc;
+							
+												}
+										  	
+									  	}
+									   else{
+										  
+										if(Step3_1==FALSE){
+										  if (nstabilization<3)
+										  {nstabilization= nstabilization+1;
+										  TimetoBegin=TRUE;}
+										  else
+										  {
+											if (utc-t2_1<DeltaT_1) {
+													if (TimetoBegin==TRUE) 
+														{
+															t2_1=utc;
+															TimetoBegin=FALSE;
+														}
+													Frepplus_1=Frepplus_1 +Math1-Slope_1*(utc-t2_1);
+													Ch4Plus=Ch4Plus + Ch4 -Ch4Slope*(utc-t2_1);
+													n_1=n_1+1;
+													}
+											else{
+												Frepplus_1=Frepplus_1/n_1;
+												Ch4Plus=Ch4Plus/n_1; 
+												n_1=0;
+												Step3_1=TRUE ;
+												nstabilization=0;
+												DDS4xAD9912_FrequencyRampe ( &DDS4xAD9912,1, (FrequDDS1+DeltakHz_1*1000),(FrequDDS1-DeltakHz_1*1000), Step1/Ndiv ) ;  
+												SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_1*1000)) ;  
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1-DeltakHz_1*1000)); 
+												}
+										  }
+										}
+										
+										else {
+											if (DDSBesChanged2==FALSE){
+												
+												if (nDDSChange<3)
+												{ nDDSChange=nDDSChange+1;}
+												
+												else
+												{
+												nDDSChange=0;
+										
+												
+												DeltaFrep275=275000-Ch4;
+												FrequencyDDSBes=FrequencyDDSBes+(DeltaFrep275) ;
+												SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes) ;
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes);   
+												DDSBesChanged2=TRUE;
+												t3_1=utc;
+
+						
+												}
+											}
+											
+											else{
+											  if (nstabilization<3)
+											  { nstabilization=nstabilization+1;
+											  TimetoBegin=TRUE;}
+											  else
+											  {
+												if (utc-t3_1<DeltaT_1) {
+													if (TimetoBegin==TRUE) 
+														{
+															t3_1=utc;
+															TimetoBegin=FALSE;
+														}
+													
+													Frepminus_1=Frepminus_1 +Math1-Slope_1*(utc-t3_1);
+													Ch4Minus=Ch4Minus+Ch4-Ch4Slope*(utc-t3_1);
+													n_1=n_1+1;
+													}
+												else{
+													Frepminus_1=Frepminus_1/(n_1);
+													Ch4Minus=Ch4Minus/(n_1); 
+													N_1 = Signe1*(2*Ndiv*DeltakHz_1*1000 /*-(Ch4Plus-Ch4Minus)-Ch4Slope*(t3_1-t2_1)*/)/(Frepminus_1-Frepplus_1-Slope_1*(t3_1-t2_1));
+													n_1=0;
+													Frepminus_1=0.0;
+													Frepplus_1=0.0;
+													DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_1*1000,FrequDDS1, Step1/Ndiv ) ;
+													SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+													DDS4xAD9912_SetFrequency(&DDS4xAD9912,1,FrequDDS1);   
+													DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBesInit); 
+													SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ;
+													Measuring_1=FALSE ;
+													Step1_1=FALSE ;
+													Step2_1=FALSE ;
+													Step3_1=FALSE ;
+													t1_1=0.0;
+													t2_1=0.0;
+													t3_1=0.0;
+													DDSBesChanged1=FALSE;
+													DDSBesChanged2=FALSE;
+													FrequencyDDSBes=0.0;
+													nstabilization=0;
+													
+													}
+											  }
+											}
+										}
+										}
+										}
+									}
+							}
+						
+						
+						
+						
+						
+						
+						if (Measuring_2==TRUE)
+							{
+								if (Step1_2==FALSE) {
+									SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+									DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
+									
+								    GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit) ;
+									GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init) ;
+									t1_2=utc;
+									Frequ_slope_2=Math1;
+									Beat_slope_2=Ch2;
+									Moy_slope_2= Frequ_slope_2;
+									Moy_Beatslope_2= Beat_slope_2;
+									N_slope_2=1;
+									Step1_2=TRUE ;
+									Nu1=(250000000+Math1)*N1;
+									}
+								else {
+									if(Step2_2==FALSE){
+										N_slope_2=N_slope_2+1; 
+										Frequ_slope_2=Math1;
+										Beat_slope_2=Ch2;  
+										Moy_slope_2=((N_slope_2-1)*Moy_slope_2 + Frequ_slope_2)/N_slope_2;
+										Moy_Beatslope_2=((N_slope_2-1)*Moy_Beatslope_2 + Beat_slope_2)/N_slope_2;
+										Slope_slope_2 = (Slope_slope_2*(N_slope_2-2) + 6*(Frequ_slope_2-Moy_slope_2)/N_slope_2)/(N_slope_2+1) ;
+										Slope_Beatslope_2 = (Slope_Beatslope_2*(N_slope_2-2) + 6*(Beat_slope_2-Moy_Beatslope_2)/N_slope_2)/(N_slope_2+1) ;
+										if (utc-t1_2>SlopeTime2) {
+											Slope_2 = Slope_slope_2;
+											Beatslope_2 = Slope_Beatslope_2;
+											Step2_2=TRUE ;
+											N_slope_2=0;
+											Frequ_slope_2=0.0;
+											Moy_slope_2=0.0;
+											Slope_slope_2 =0.0;
+											Moy_Beatslope_2=0.0;
+											Slope_Beatslope_2 =0.0;
+											Beat_slope_2=0.0;
+											
+											DDS4xAD9912_FrequencyRampe (&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_2*1000), Step2/Ndiv ) ;
+											SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_2*1000)) ;   
+											DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_2*1000));
+											Delay(0.1); 
+											DeltaDDS3 = -DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2);
+											SetCtrlVal(MainPanel, PANEL_DDS3, (FrequencyDDS3Init+DeltaDDS3)) ; 
+											DDS4xAD9912_SetFrequency (&DDS4xAD9912,3,(FrequencyDDS3Init+DeltaDDS3)) ;
+											
+											}
+										}
+									else {
+									  if (DDSBesChanged1==FALSE){
+										  
+										  		if (nDDSChange<3)
+												{ nDDSChange=nDDSChange+1;}
+												
+												else
+												{
+												nDDSChange=0;
+													
+												DeltaFrep275=275000-Ch4;
+												DeltaFrep10=10000-Ch2;
+												DeltaDDS3= DeltaDDS3 +(DeltaFrep10);
+												FrequencyDDSBes=FrequencyDDSBesInit+(DeltaFrep275);
+												FrequencyDDS3=FrequencyDDS3Init+DeltaDDS3;
+												
+												SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes) ;
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes);
+												
+												Delay(0.1); 
+												SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3) ;    
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912,3,FrequencyDDS3);
+												 
+												DDSBesChanged1=TRUE;
+												t2_2=utc;
+							
+												}
+										  	
+									  }
+									   else{
+										  
+										if(Step3_2==FALSE){
+										  if (nstabilization<3)
+										  {nstabilization= nstabilization+1;}
+										  else
+										  {
+											if (utc-t2_2<DeltaT_2) {
+													Frepplus_2=Frepplus_2 +Math1+250000000-Slope_2*(utc-t2_2);
+													Delta10K_Plus= Delta10K_Plus + 10000 - (Ch2 -Beatslope_2*(utc-t2_2));
+													n_2=n_2+1;
+													}
+											else{
+												Frepplus_2=Frepplus_2/n_2;
+												Delta10K_Plus=Delta10K_Plus/n_2;
+												n_2=0;
+												Step3_2=TRUE ;
+												nstabilization=0;
+												DDS4xAD9912_FrequencyRampe ( &DDS4xAD9912,1, (FrequDDS1+DeltakHz_2*1000),(FrequDDS1-DeltakHz_2*1000), Step2/Ndiv ) ;
+												SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_2*1000)) ; 
+												DDS4xAD9912_SetFrequency (&DDS4xAD9912,1, (FrequDDS1-DeltakHz_2*1000) ) ;
+												
+												Delay(0.1); 
+												DeltaDDS3 = (FrequencyDDS3Init+DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1)) - FrequencyDDS3;
+												SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3+DeltaDDS3) ; 
+												DDS4xAD9912_SetFrequency (&DDS4xAD9912,3, FrequencyDDS3+DeltaDDS3 ) ; 
+												
+												}
+										  }
+										}
+										
+										else {
+											if (DDSBesChanged2==FALSE){
+												
+												if (nDDSChange<3)
+												{ nDDSChange=nDDSChange+1;}
+												
+												else
+												{
+												nDDSChange=0;
+										
+												
+												DeltaFrep275=275000-Ch4;
+												DeltaFrep10=10000-Ch2;
+												DeltaDDS3 = DeltaDDS3+(DeltaFrep10) ;
+												FrequencyDDSBes=FrequencyDDSBes+(DeltaFrep275) ;
+												FrequencyDDS3=FrequencyDDS3+DeltaDDS3 ; 
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912,2,FrequencyDDSBes);
+												SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBes);
+												
+												Delay(0.1); 
+												SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3) ; 
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912,3,FrequencyDDS3);
+												
+												DDSBesChanged2=TRUE;
+												t3_2=utc;
+
+						
+												}
+											}
+											
+											else{
+											  if (nstabilization<3)
+											  { nstabilization=nstabilization+1;}
+											  else
+											  {
+												if (utc-t3_2<DeltaT_2) {
+													Frepminus_2=Frepminus_2 +Math1+250000000-Slope_2*(utc-t3_2);
+													Delta10K_Minus=  Delta10K_Minus +10000 - ( Ch2 -Beatslope_2*(utc-t3_2));
+													n_2=n_2+1;
+													}
+												else{
+													Frepminus_2=Frepminus_2/(n_2);
+													Delta10K_Minus= Delta10K_Minus/n_2;
+													N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2));
+													n_2=0;
+													Frepminus_2=0.0;
+													Frepplus_2=0.0;
+													Delta10K_Minus=0.0;
+													Delta10K_Plus=0.0;  
+													DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv ) ;
+													SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+													DDS4xAD9912_SetFrequency(&DDS4xAD9912,1,FrequDDS1);
+													
+													Delay(0.1); 
+													
+													SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ;  
+													DDS4xAD9912_SetFrequency (&DDS4xAD9912, 2, FrequencyDDSBesInit ) ;
+													
+													Delay(0.1); 
+													
+													SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2)) ;
+													DDS4xAD9912_SetFrequency (&DDS4xAD9912, 3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2) ) ;
+													
+													Measuring_2=FALSE ;
+													Step1_2=FALSE ;
+													Step2_2=FALSE ;
+													Step3_2=FALSE ;
+													t1_2=0.0;
+													t2_2=0.0;
+													t3_2=0.0;
+													DDSBesChanged1=FALSE;
+													DDSBesChanged2=FALSE;
+													FrequencyDDSBes=0.0;
+													nstabilization=0;
+													
+													}
+											  }
+											}
+											}
+									  }
+										}
+									}
+							}
+						
+
+							
+						/*	if (Measuring_3==TRUE)
+							{
+								if (Step1_3==FALSE) {
+									DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequDDS3);
+									t1_3=utc;
+									Frequ_slope_3=Math1;
+									Moy_slope_3= Frequ_slope_3;
+									N_slope_3=1;
+									Step1_3=TRUE ;
+									}
+								else {
+									if(Step2_3==FALSE){
+										N_slope_3=N_slope_3+1; 
+										Frequ_slope_3=Math1;
+										Moy_slope_3=((N_slope_3-1)*Moy_slope_3 + Frequ_slope_3)/N_slope_3;
+										Slope_slope_3 = (Slope_slope_3*(N_slope_3-2) + 6*(Frequ_slope_3-Moy_slope_3)/N_slope_3)/(N_slope_3+1) ;
+										if (utc-t1_3>DeltaT_3) {
+											Slope_3 = Slope_slope_3;
+											GetCtrlVal(MainPanel, PANEL_DDSFREPOUT, &FrequencyDDSBes) ; 
+											DDSBes_SetFrequency(&DDSBes, FrequencyDDSBes+(FACTORDDSBES*DeltakHz_3*1000));
+											DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequDDS3+DeltakHz_3*1000);
+											t2_3=utc;
+											Step2_3=TRUE ;
+											N_slope_3=0;
+											Frequ_slope_3=0.0;
+											Moy_slope_3=0.0;
+											Slope_slope_3 =0.0;
+											}
+										}
+									else {
+										if(Step2_3==FALSE){
+											if (utc-t2_3<DeltaT_3) {
+													Frepplus_3=Frepplus_3 +Math1+250000000-Slope_3*(utc-t2_3);
+													n_3=n_3+1;
+													}
+											else{
+												Frepplus_3=Frepplus_3/n_3;
+												DDSBes_SetFrequency(&DDSBes, FrequencyDDSBes-(FACTORDDSBES*DeltakHz_3*1000)); 
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequDDS3-DeltakHz_3*1000);
+												n_3=0;
+												t3_3=utc;
+												Step3_3=TRUE ;
+												}
+											}
+										else {
+											if (utc-t3_3<DeltaT_3) {
+													Frepminus_3=Frepminus_3 +Math1+250000000-Slope_3*(utc-t3_3);
+													n_3=n_3+1;
+													}
+											else{
+												Frepminus_3=Frepminus_3/(n_3);
+												N_3 = (16*DeltakHz_3*1000 -Slope_3*(t3_3-t2_3))/(Frepplus_3-Frepminus_3);
+												n_3=0;
+												Frepminus_3=0.0;
+												Frepplus_3=0.0;
+												DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequDDS3);  
+												Measuring_2=FALSE ;
+												Step1_3=FALSE ;
+												Step2_3=FALSE ;
+												Step3_3=FALSE ;
+												t1_3=0.0;
+												t2_3=0.0;
+												t3_3=0.0;
+												}
+											}
+										}
+								}
+							}		*/
+						
+					
+						
+						
+						
+						// Calcul du signe de fb
+						
+						if (Getsign1 ==TRUE) {
+							if (utc> tbegin1+2){
+								if (Math1> Frepbefore1) { Signe1=-1.0;}
+								else {Signe1=1.0;}
+								SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1) ; 
+								DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency1);
+								Getsign1=FALSE;
+								}
+							}
+						if (Getsign2 ==TRUE) {
+							if (utc> tbegin2+2){
+								if (Math1> Frepbefore2) { 
+									if (Ch2>Ch2before) {Signe2=+1.0;}
+									else {Signe2=-1.0;} 
+								}
+								else { 
+									if (Ch2>Ch2before) {Signe2=-1.0;}
+									else {Signe2=+1.0;}
+								}
+								SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2) ; 
+								DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency2);
+								Getsign2=FALSE;
+								}
+							}
+						if (Getsign3 ==TRUE) {
+							if (utc> tbegin3+2){
+								if (Ch1> Frepbefore3) { Signe3=-1.0;}
+								else {Signe3=1.0;}
+								SetCtrlVal(MainPanel, PANEL_DDS3, Frequency3) ; 
+								DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency3);
+								Getsign3=FALSE;
+								}
+							}
+								
+						
+						
+						
+						//Pour le Slope Cancelling
+						
+						if (SlopeMeasuring==TRUE)
+						{ 
+							if  (utc-SlopeMeasuringTimeBegin>TimetoSlope)
+							{
+								Nratio=Nratio+1; 
+								
+								if (Nratio>=1)
+								{
+								MoyMath2= MoyMath2+Moy_Math2slope;
+								}
+								SlopeMath2=SlopeMath2+Slope_Math2slope;
+								N_Math2slope=0.0;
+								Math2_slope=0.0;
+								Moy_Math2slope=0.0;
+								Slope_Math2slope=0.0;
+								
+
+								
+								if (Nratio==1 && CenterFrequencyCh2ToDetermine==TRUE) {
+										CenterFrequencyCh2= MoyMath2;
+										CenterFrequencyCh2ToDetermine=FALSE;
+									}
+
+								OnOffMessage="ON " ;
+								OnSlopeCancelling =TRUE;
+									
+								//   S'occupe du slope
+								//   SweepSign =0 fait un slope +
+								//   SweepSign =1 fait un slope -
+									
+								/*	if  (SlopeMath2<0)
+									{
+										   DDSFoxSweepSign=0;
+										   SlopeMath2= -SlopeMath2;
+									}
+									else
+									{		DDSFoxSweepSign=1;  }	  */
+									
+								FoxFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);
+								
+								if (Nratio==ratio) {
+									
+									if (FrequCorrec==TRUE)  {
+										SlopeCorrection= (MoyMath2/ratio-CenterFrequencyCh2)/TimetoSlope;
+										SlopeMath2=SlopeMath2+ SlopeCorrection;
+														}
+									Nratio=0;
+									MoyMath2=0.0;
+									
+													}
+								
+								LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,FoxFrequ,SlopeMath2,0); 	
+								
+								nstabilisationSlopeMeasuring=0;
+								SlopeMeasuringTimeBegin=utc;
+								
+
+								
+							}
+							else
+							{
+									if (nstabilisationSlopeMeasuring<5)
+									{
+										  nstabilisationSlopeMeasuring= nstabilisationSlopeMeasuring+1;
+										  Math2_slope=Math2; 
+									}
+									else
+									{
+										if ((Math2-Math2_slope)<limitotakoff && (Math2-Math2_slope)>-limitotakoff )
+										{
+									N_Math2slope=N_Math2slope+1;
+									Math2_slope=Math2;
+									Moy_Math2slope=((N_Math2slope-1)*Moy_Math2slope + Math2_slope)/N_Math2slope;
+									Slope_Math2slope= (Slope_Math2slope*(N_Math2slope-2) + 6*(Math2_slope-Moy_Math2slope)/N_Math2slope)/(N_Math2slope+1) ;
+										}
+										
+										else
+										{
+										
+										if (AutoStopSlopeCancellingIfDelock)
+										{
+											//   S'occupe d'arreter le slope  en cas de delockage 
+
+											if (KeepFrequ==TRUE) {ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);}
+											else {  ActualFrequ= DDSFoxFrequency;}  
+											if (KeepSlope==TRUE) {ActualSlope= SlopeMath2;
+																  }
+											else {  ActualSlope= DDSFoxSweeprate;
+											        OnSlopeCancelling =FALSE;} 
+											LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,ActualSlope,0);
+											SlopeMeasuring=FALSE;
+											OnOffMessage="OFF " ;
+											N_Math2slope=0.0;
+											Math2_slope=0.0;
+											MoyMath2=0.0; 
+											Moy_Math2slope=0.0;
+											Slope_Math2slope=0.0;
+											CenterFrequencyCh2= 0.0;
+											CenterFrequencyCh2ToDetermine=TRUE;
+											Nratio=-1;
+											nstabilisationSlopeMeasuring=0;
+											SetCtrlVal(MainPanel, PANEL_STARTCANCEL, 0) ;
+											
+										}
+										}
+		
+									}
+									
+							}
+							
+						}
+						
+						
+						////   For re-centering
+						
+						if (KeepCentering) 
+						{
+							
+							DeltaCh4=275000-Ch4;
+							DeltaCh2=10000-Ch2;
+							
+							if (utc- CenteringTimeBegin275K > Timetorecenter275K && CenteringTimeBegin275K>10)
+							{
+								 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyToChange) ;
+								 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyToChange+DeltaCh4) ;
+					 		   	 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyToChange+DeltaCh4);
+								 CenteringTimeBegin275K=utc;
+								
+							
+							}
+							
+							if (utc- CenteringTimeBegin10K > Timetorecenter10K && CenteringTimeBegin10K>10)
+							{
+								  GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyToChange) ;
+								  SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyToChange+DeltaCh2) ; 
+					 			  DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyToChange+DeltaCh2);
+								  CenteringTimeBegin10K=utc; 
+								
+								
+							}
+							
+							
+						}
+						
+						
+						
+						
+						// Now, some special extra functions for some math value which have special 'default' meaning (like nu_Hg and nu_Sr)
+						
+						/*GetPanelAttribute(CalcNHgPanel, ATTR_VISIBLE, &BoxChecked) ;	 // correct name for answer would be more
+						if (BoxChecked) {												 // something like "&PanelOpened" here
+							N_1 = 0;	  // evaluate Math2 for N=0 gives 282143G-/+320M
+							GetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, &Target) ;
+							NCalc = (Target-mupEval(MathParser2))/(Math1+766e6) ;
+							SetCtrlVal(CalcNHgPanel, CALCNHG_NHGCALC,  (double) RoundRealToNearestInteger (NCalc) ) ;
+							SetCtrlVal(CalcNHgPanel, CALCNHG_ERROR, NCalc-RoundRealToNearestInteger (NCalc) ) ; 
+							GetCtrlVal(MainPanel, PANEL_N_HG, &N_1) ; // Set N_1 back to value user defined in main panel 
+							} 
+						
+						GetPanelAttribute(CalcNSrPanel, ATTR_VISIBLE, &BoxChecked) ;	 // correct name for answer would be more
+						if (BoxChecked) {												 // something like "&PanelOpened" here, but I reuse variable name for concision 
+							N2 = 0;	  // evaluate Math3 for N=0 gives 429228G-/+DDS2-/+Ch3
+							GetCtrlVal(CalcNSrPanel, CALCN2_TARGET, &Target) ;
+							NCalc = (Target-mupEval(MathParser3))/(Math1+766e6) ;
+							SetCtrlVal(CalcNSrPanel, CALCN2_NSRCALC,  (double) RoundRealToNearestInteger (NCalc) ) ;
+							SetCtrlVal(CalcNSrPanel, CALCNSR_ERROR, NCalc-RoundRealToNearestInteger (NCalc) ) ; 
+							GetCtrlVal(MainPanel, PANEL_N_SR, &N2) ; // Set N_2 back to value user defined in main panel 
+							}	
+						
+						GetPanelAttribute(CalcN813Panel, ATTR_VISIBLE, &BoxChecked) ;	 // correct name for answer would be more
+						if (BoxChecked) {												 // something like "&PanelOpened" here, but I reuse variable name for concision 
+							N3 = 0;	  // evaluate Math4 for N=0 gives ??????G-/+DDS_813-/+Ch4
+							GetCtrlVal(CalcN813Panel, CALCN83_TARGET, &Target) ;
+							NCalc = (Target-mupEval(MathParser4))/(Math1+766e6) ;
+							SetCtrlVal(CalcN813Panel, CALCN813_N813CALC,  (double) RoundRealToNearestInteger (NCalc) ) ;
+							SetCtrlVal(CalcN813Panel, CALCN813_ERROR, NCalc-RoundRealToNearestInteger (NCalc) ) ; 
+							GetCtrlVal(MainPanel, PANEL_N_813, &N3) ; // Set N3 back to value user defined in main panel 
+							}*/	
+							
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2AUTOSAV, &BoxChecked) ;		   // AutoSave OL
+						if (BoxChecked) {
+							SetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, TRUE) ;   // so that it will try to write it (at next block) if it seems reasonnable, even though it was off before
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, &BoxChecked) ;			   // Save OL (Math2)
+						if (BoxChecked) {
+							/*GetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, &Target) ;
+							if (abs(Math2-Target)>1e4) {	   // write it only if it's vaguely plausible (here outlier>10kHz ie approx 10000sigma but not dedrift applied !!!)
+								SetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, FALSE) ;
+								break ; 
+								} ;*/
+							FileOpt = OpenFile("z:\\MeasuresFifi1\\OptCavity.txt", VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII) ;
+							Fmt(ReportString, "%s\t%s\t%f[p3]\t%f[p3]", Date, Time, utc, Math2);
+							WriteLine(FileOpt, ReportString, -1) ;
+							CloseFile(FileOpt) ;
+							FileOpt = OpenFile("C:\\Femto\\Results\\OptCavity.txt", VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII) ;   // a local backup for debugging
+							Fmt(ReportString, "%s\t%s\t%f[p3]\t%f[p3]", Date, Time, utc, Math2);
+							WriteLine(FileOpt, ReportString, -1) ;
+							CloseFile(FileOpt) ;
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3AUTOSAV, &BoxChecked) ;		   // AutoSave Hg (Math3)
+						if (BoxChecked) {
+							SetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3SAVE, TRUE) ;   // so that it will try to write it (at next block) if it seems reasonnable, even though it was off before
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3SAVE, &BoxChecked) ;			   // Save Hg
+						
+						if (BoxChecked) {
+							/*GetCtrlVal(CalcNSrPanel, CALCN3_TARGET, &Target) ;     
+							if (abs(Math3-Target)>1.0e4) {	   // write it only if it's vaguely plausible (here outlier>10kHz ie approx 10000sigma but not dedrift applied !!!)
+								SetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3SAVE, FALSE) ;	// otherwise uncheck the save box
+								break ; 
+								} ;*/ 
+							FileHg = OpenFile("z:\\MeasuresFifi1\\HgCavity.txt", VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII) ;
+							Fmt(ReportString, "%s\t%s\t%f[p3]\t%f[p3]", Date, Time, utc, Math3);
+							WriteLine(FileHg, ReportString, -1) ;
+							CloseFile(FileHg) ;
+							FileHg = OpenFile("C:\\Femto\\Results\\HgCavity.txt", VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII) ;
+							Fmt(ReportString, "%s\t%s\t%f[p3]\t%f[p3]", Date, Time, utc, Math3);
+							WriteLine(FileHg, ReportString, -1) ;
+							CloseFile(FileHg) ;
+							
+							}
+						
+						GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5SAVE, &BoxChecked) ;				// Save ExtraMath (Math5)
+						if (BoxChecked) {
+							FileExtraMath = OpenFile(ExtraMathFileName, VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII) ;
+							Fmt(ReportString, "%s\t%s\t%f[p3]\t%f[p7]", Date, Time, utc, Math5);
+							WriteLine(FileExtraMath, ReportString, -1) ;
+							CloseFile(FileExtraMath) ;
+							}
+						
+						// Special case to handle change of day at next second
+						//if ( LocalTime.tm_hour==23 && LocalTime.tm_min==59 && strtod(Sec,NULL)>59 ) {
+						if ( LocalTime.tm_hour==23 && LocalTime.tm_min==59 && strtod(Sec,NULL)>=58 ) { 
+							printf("Entering change of date substructure\r\n"); 
+							printf("old file : %s %s %s \r\n",Date, Time, LogFileName);
+							Acquiring = FALSE ;
+							do {
+								Delay(5.1);
+								FindCurrentFileName() ;
+								}
+							while (!GetFileInfo(LogFileName, &OldLogFilePtr)) ;
+							printf("new file : %s \r\n\r\n",Date, Time, LogFileName);  
+							Acquiring = TRUE ;
+							OldLogFilePtr = 2;
+							}
+						
+						ResumeTimerCallbacks ; 
+						
+						} ;
+					
+					break;
+				case FALSE:
+					break;
+				}
+			break;
+		}
+	return 0;
+}
+
+
+
+
+int CVICALLBACK CB_OnFreqPlot (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int BoxChecked ;
+	Plot_Data * pPlot = NULL;
+	char PlotTitle[] = "Ch? Frequency Plot" ;
+	double PlotMin = 10e6 ;
+	double PlotMax = 65e6 ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+		
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			switch (control) {
+				case PANEL_CHECKBOX_FREQ1PLOT :
+					pPlot = &PlotCh1 ;
+					Fmt(PlotTitle, "Ch1 Frequency Plot") ;
+					PlotMin = 54.999e6 ; PlotMax = 55.001e6 ;
+					break ;
+				case PANEL_CHECKBOX_FREQ2PLOT :
+					pPlot = &PlotCh2 ;
+					Fmt(PlotTitle, "Ch2 Frequency Plot") ;
+					PlotMin = 8.0e3 ; PlotMax = 12.0e3 ;
+					break ;
+				case PANEL_CHECKBOX_FREQ3PLOT :
+					pPlot = &PlotCh3 ;
+					Fmt(PlotTitle, "Ch3 Frequency Plot") ;
+					PlotMin = 8.0e3 ; PlotMax = 12.0e3 ;
+					break ;
+				case PANEL_CHECKBOX_FREQ4PLOT :
+					pPlot = &PlotCh4 ;
+					Fmt(PlotTitle, "Ch4 Frequency Plot") ;
+					break ;
+				case PANEL_CHECKBOX_MATH1PLOT :
+					pPlot = &PlotMath1 ;
+					Fmt(PlotTitle, "Math1 Plot") ;
+					PlotMin = 765.0e6 ; PlotMax = 775.0e6 ;
+					break ;
+				case PANEL_CHECKBOX_MATH2PLOT :
+					pPlot = &PlotMath2 ;
+					Fmt(PlotTitle, "Math2 Plot") ;
+					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
+					break ;	
+				case PANEL_CHECKBOX_MATH3PLOT :
+					pPlot = &PlotMath3 ;
+					Fmt(PlotTitle, "Math3 Plot") ;
+					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
+					break ;	
+				case PANEL_CHECKBOX_MATH4PLOT :
+					pPlot = &PlotMath4 ;
+					Fmt(PlotTitle, "Math4 Plot") ;
+					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
+					break ;	
+				case PANEL_CHECKBOX_MATH5PLOT :
+					pPlot = &PlotMath5 ;
+					Fmt(PlotTitle, "Math5 Plot") ;
+					PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
+					break ;
+			}
+			
+			if (BoxChecked) {
+				Plot_InitPanel(pPlot, PlotTitle, PlotMin, PlotMax, &OnCloseViewPanel) ;	
+				}
+			else {
+				Plot_ClosePanel(pPlot) ;
+				} ;
+			break;
+			
+		case EVENT_RIGHT_CLICK:
+
+			break;
+			
+		}
+	return 0;
+}
+
+
+int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int BoxChecked ;
+	Allan_Data * pAllan = NULL;
+	char AllanTitle[] = "Ch? Allan Deviation  " ;
+	double Normalizer = 300e12 ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			switch (control) {
+				case PANEL_CHECKBOX_FREQ1ALLAN :
+					pAllan = &AllanCh1 ;
+					Fmt(AllanTitle, "Ch1 Allan Deviation") ;
+					Normalizer = 1.84e12 ;
+					break ;
+				case PANEL_CHECKBOX_FREQ2ALLAN :
+					pAllan = &AllanCh2 ;
+					Fmt(AllanTitle, "Ch2 Allan Deviation") ;
+					Normalizer = 10.e3 ; 
+					break ;
+				case PANEL_CHECKBOX_FREQ3ALLAN :
+					pAllan = &AllanCh3 ;
+					Fmt(AllanTitle, "Ch3 Allan Deviation") ;
+					Normalizer = 429.228e12 ; 
+					break ;
+				case PANEL_CHECKBOX_FREQ4ALLAN :
+					pAllan = &AllanCh4 ;
+					Fmt(AllanTitle, "Ch4 Allan Deviation") ;
+					Normalizer = 275.0e3 ; 
+					break ;
+				case PANEL_CHECKBOX_MATH1ALLAN :
+					pAllan = &AllanMath1 ;
+					Fmt(AllanTitle, "Math1 Allan Deviation") ;
+					Normalizer = 250.0e6 ;
+					break ;
+				case PANEL_CHECKBOX_MATH2ALLAN :
+					pAllan = &AllanMath2 ;
+					Fmt(AllanTitle, "Math2 Allan Deviation") ;
+					Normalizer = 194.395e12 ;
+					break ;
+				case PANEL_CHECKBOX_MATH3ALLAN :
+					pAllan = &AllanMath3 ;
+					Fmt(AllanTitle, "Math3 Allan Deviation") ;
+					Normalizer = 282.143e12 ;
+					break ;
+				case PANEL_CHECKBOX_MATH4ALLAN :
+					pAllan = &AllanMath4 ;
+					Fmt(AllanTitle, "Math4 Allan Deviation") ;
+					Normalizer = 429.228e12 ;
+					break ;
+				case PANEL_CHECKBOX_MATH5ALLAN :
+					pAllan = &AllanMath5 ;
+					Fmt(AllanTitle, "Math5 Allan Deviation") ;
+					Normalizer = 429.228e12 ;
+					break ;
+			}			
+			
+			if (BoxChecked) {
+				Allan_InitPanel(pAllan, AllanTitle, Normalizer, &OnCloseViewPanel) ;	
+				}
+			else {
+				Allan_ClosePanel(pAllan) ;
+				} ;
+			break;
+			
+		case EVENT_RIGHT_CLICK:
+
+			break;
+			
+		}
+	return 0;
+}
+
+int  CVICALLBACK CB_ChangeDDSOut (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	double Frequency ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(MainPanel, control, &Frequency) ;
+			if (control==PANEL_DDSFREPOUT) { DDSBes_SetFrequency(&DDSBes, Frequency) ;}
+			if (control==PANEL_DDS1)   { DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency);}
+			if (control==PANEL_DDS2)   { DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, Frequency);} 
+			if (control==PANEL_DDS3)   { DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency);}
+			if (control==PANEL_DDS4)   { DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency);} 
+		case EVENT_RIGHT_CLICK:
+
+			break;
+			
+		}
+	return 0;
+}
+
+int  CVICALLBACK CB_ChangeDDSStep (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	double Step ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(MainPanel, control, &Step) ;
+			if (control==PANEL_DDSFREPSTEP) { SetCtrlAttribute(panel, PANEL_DDSFREPOUT, ATTR_INCR_VALUE, Step) ;}
+			if (control==PANEL_DDS1STEP)   { SetCtrlAttribute(panel, PANEL_DDS1,   ATTR_INCR_VALUE, Step) ;}   
+			if (control==PANEL_DDS2STEP)   { SetCtrlAttribute(panel, PANEL_DDS2,   ATTR_INCR_VALUE, Step) ;}
+			if (control==PANEL_DDS3STEP)   { SetCtrlAttribute(panel, PANEL_DDS3,   ATTR_INCR_VALUE, Step) ;}   
+			if (control==PANEL_DDS4STEP)   { SetCtrlAttribute(panel, PANEL_DDS4,   ATTR_INCR_VALUE, Step) ;} 
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+			
+		}
+	return 0;
+}
+
+int  CVICALLBACK CB_ChangeDDSAmpli (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	unsigned short int Amplitude ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(MainPanel, control, &Amplitude) ;
+			if (control==PANEL_DDSFREPAMP) { DDSBes_SetAmplitude(&DDSBes, Amplitude) ;}
+		case EVENT_RIGHT_CLICK:
+
+			break;
+			
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_ChangeMath (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	
+	char * MathString = "                                                             " ;
+						// should be long enough for any reasonnable math expression...
+		
+	switch (event)
+	{
+		case EVENT_COMMIT:
+				GetCtrlVal(panel, control, MathString) ;
+				if (control==PANEL_MATHSTRING1) { mupSetExpr(MathParser1, MathString) ; }
+				if (control==PANEL_MATHSTRING2) { mupSetExpr(MathParser2, MathString) ; }
+				if (control==PANEL_MATHSTRING3) { mupSetExpr(MathParser3, MathString) ; }
+				if (control==PANEL_MATHSTRING4) { mupSetExpr(MathParser4, MathString) ; }
+				if (control==PANEL_MATHSTRING5) { mupSetExpr(MathParser5, MathString) ; } 
+			break;
+	}
+	return 0;
+}
+
+int CVICALLBACK CB_ChangeN (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==PANEL_N1CHOICE) GetCtrlVal(MainPanel, control, &N1) ;
+			if (control==PANEL_N2CHOICE) GetCtrlVal(MainPanel, control, &N2) ;
+			if (control==PANEL_N3CHOICE) GetCtrlVal(MainPanel, control, &N3) ;
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnPlus275k (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double Frequency ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+				GetCtrlVal(MainPanel, PANEL_DDSFREPOUT, &Frequency) ; 
+				Frequency += 275000.0 ;
+				DDSBes_SetFrequency(&DDSBes, Frequency) ;	
+				SetCtrlVal(MainPanel, PANEL_DDSFREPOUT, Frequency) ; 
+				/*SetCtrlVal(MainPanel, PANEL_MATHSTRING1, FREP_NORMAL_FORMULA) ;
+				mupSetExpr(MathParser1, FREP_NORMAL_FORMULA) ;
+				SetCtrlVal(MainPanel, PANEL_MATHSTRING2, NUHG_NORMAL_FORMULA) ;
+				mupSetExpr(MathParser2, NUHG_NORMAL_FORMULA) ;
+				SetCtrlVal(MainPanel, PANEL_MATHSTRING4, NU813_NORMAL_FORMULA) ;
+				mupSetExpr(MathParser4, NU813_NORMAL_FORMULA) ;
+				*/
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnMinus275k (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double Frequency ;
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(MainPanel, PANEL_DDSFREPOUT, &Frequency) ; 
+			Frequency -= 275000.0 ;
+			DDSBes_SetFrequency(&DDSBes, Frequency) ;	
+			SetCtrlVal(MainPanel, PANEL_DDSFREPOUT, Frequency) ; 
+			/*SetCtrlVal(MainPanel, PANEL_MATHSTRING1, "0") ;
+			mupSetExpr(MathParser1, "0") ;
+			SetCtrlVal(MainPanel, PANEL_MATHSTRING2, "0") ;
+			mupSetExpr(MathParser2, "0") ;
+			SetCtrlVal(MainPanel, PANEL_MATHSTRING4, "0") ;
+			mupSetExpr(MathParser4, "0") ;
+			*/
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnPlus10k (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double Frequency ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==PANEL_PLUS10KDDS1) {
+			GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency) ;
+			Frequency += 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS1, Frequency) ;
+			/*SetCtrlVal(MainPanel, PANEL_MATHSTRING3, NUHG_NORMAL_FORMULA) ;
+			mupSetExpr(MathParser3, NUHG_NORMAL_FORMULA) ;
+			*/
+			}
+			if (control==PANEL_PLUS10KDDS2) {
+			GetCtrlVal(MainPanel, PANEL_DDS2, &Frequency) ;
+			Frequency += 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS2, Frequency) ;
+			/*SetCtrlVal(MainPanel, PANEL_MATHSTRING3, NUSR_NORMAL_FORMULA) ;
+			mupSetExpr(MathParser3, NUSR_NORMAL_FORMULA) ;
+			*/
+			}
+			if (control==PANEL_PLUS10KDDS3) {
+			GetCtrlVal(MainPanel, PANEL_DDS3, &Frequency) ;
+			Frequency += 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS3, Frequency) ;
+			}
+			if (control==PANEL_PLUS10KDDS4) {
+			GetCtrlVal(MainPanel, PANEL_DDS4, &Frequency) ;
+			Frequency += 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS4, Frequency) ;
+			}
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnMinus10k (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double Frequency ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==PANEL_MINUS10KDDS1) {
+			GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency) ;
+			Frequency -= 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS1, Frequency) ;
+			/*SetCtrlVal(MainPanel, PANEL_MATHSTRING3, NUHG_NORMAL_FORMULA) ;
+			mupSetExpr(MathParser3, NUHG_NORMAL_FORMULA) ;
+			*/
+			}
+			if (control==PANEL_MINUS10KDDS2) {
+			GetCtrlVal(MainPanel, PANEL_DDS2, &Frequency) ;
+			Frequency -= 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS2, Frequency) ;
+			/*SetCtrlVal(MainPanel, PANEL_MATHSTRING3, NUSR_NORMAL_FORMULA) ;
+			mupSetExpr(MathParser3, NUSR_NORMAL_FORMULA) ;
+			*/
+			}
+			if (control==PANEL_MINUS10KDDS3) {
+			GetCtrlVal(MainPanel, PANEL_DDS3, &Frequency) ;
+			Frequency -= 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS3, Frequency) ;
+			}
+			if (control==PANEL_MINUS10KDDS4) {
+			GetCtrlVal(MainPanel, PANEL_DDS4, &Frequency) ;
+			Frequency -= 10000.0 ;
+			DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency);	
+			SetCtrlVal(MainPanel, PANEL_DDS4, Frequency) ;
+			}
+			break;
+		}
+	return 0;
+}
+
+
+
+
+int CVICALLBACK CB_OnSaveOpt (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool BoxChecked = FALSE ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			
+			if (BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH2AUTOSAV, ATTR_DIMMED, FALSE) ;
+				}
+			
+			if (!BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH2AUTOSAV, ATTR_DIMMED, TRUE) ;
+				}
+			
+			break;
+		}
+	return 0;
+}
+
+
+
+ 
+int CVICALLBACK CB_OnSaveHg (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool BoxChecked = FALSE ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			
+			if (BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH3AUTOSAV, ATTR_DIMMED, FALSE) ;
+				}
+			
+			if (!BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH3AUTOSAV, ATTR_DIMMED, TRUE) ;
+				}
+			
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnAutoSaveHg (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool BoxChecked = FALSE ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			
+			if (BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH2SAVE, ATTR_DIMMED, TRUE) ;
+				}
+			
+			if (!BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH2SAVE, ATTR_DIMMED, FALSE) ;
+				}
+
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnSaveSr (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool BoxChecked = FALSE ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			
+			if (BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH3AUTOSAV, ATTR_DIMMED, FALSE) ;
+				}
+			
+			if (!BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH3AUTOSAV, ATTR_DIMMED, TRUE) ;        
+				}
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnAutoSaveSr (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool BoxChecked = FALSE ; 
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+
+			GetCtrlVal(MainPanel, control, &BoxChecked);
+			
+			if (BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH3SAVE, ATTR_DIMMED, TRUE) ;
+				}
+			
+			if (!BoxChecked) {
+				SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH3SAVE, ATTR_DIMMED, FALSE) ;
+				}
+			
+			break;
+		}
+	return 0;
+}
+
+
+int CVICALLBACK OnAcceptN (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double N;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (panel == CalcN1Panel) {
+				N = floor(N_1);
+					if (N_1-N<0.5)
+					{
+						N1=N;
+					}
+					else
+					{
+						N1=N+1;
+					}
+				SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1) ;
+				} 
+			
+			if (panel == CalcN2Panel) {
+				N = floor(N_2);
+					if (N_2-N<0.5)
+					{
+						N2=N;
+					}
+					else
+					{
+						N2=N+1;
+					}
+				SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2) ;
+				} 
+
+			if (panel == CalcN3Panel) {
+				GetCtrlVal(CalcN3Panel, CALCN3_N_3, &N) ;
+				SetCtrlVal(MainPanel, PANEL_N3CHOICE, N) ;
+				N3=N;
+				} 
+			break;
+		}
+	return 0;
+}
+
+/*int CVICALLBACK OnFSRStep (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double Target, FSR ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (panel==CalcNHgPanel) {
+				if (control==CALCNHG_MINUSFSR) {
+					GetCtrlVal(CalcNHgPanel, CALCNHG_FSR, &FSR) ;
+					GetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, &Target) ;
+					Target -= FSR ;
+					SetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, Target) ;
+					} 
+				if (control==CALCNHG_PLUSFSR) {
+					GetCtrlVal(CalcNHgPanel, CALCNHG_FSR, &FSR) ;
+					GetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, &Target) ;
+					Target += FSR ;
+					SetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, Target) ;
+					}
+				}   
+			if (panel==CalcNSrPanel) {
+				if (control==CALCNSR_MINUSFSR) {
+					GetCtrlVal(CalcNSrPanel, CALCNSR_FSR, &FSR) ;
+					GetCtrlVal(CalcNSrPanel, CALCNSR_TARGET, &Target) ;
+					Target -= FSR ;
+					SetCtrlVal(CalcNSrPanel, CALCNSR_TARGET, Target) ;
+					}
+				if (control==CALCNSR_PLUSFSR) {
+					GetCtrlVal(CalcNSrPanel, CALCNSR_FSR, &FSR) ;
+					GetCtrlVal(CalcNSrPanel, CALCNSR_TARGET, &Target) ;
+					Target += FSR ;
+					SetCtrlVal(CalcNSrPanel, CALCNSR_TARGET, Target) ;
+					}
+				}
+			break;
+		}
+	return 0;
+} */ 
+
+ /*int CVICALLBACK OnExtrapolateTarget (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool BoxChecked = FALSE ;  
+	double extrapolFreq = 745967614;
+	time_t utcTime ; 
+	double utc ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(CalcNHgPanel, CALCNHG_EXTRAPOLATE, &BoxChecked) ;
+			if (BoxChecked) {
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_TARGET,     ATTR_DIMMED, TRUE) ;  
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_OFFSETFREQ, ATTR_DIMMED, TRUE) ;
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_PLUSFSR,    ATTR_DIMMED, TRUE) ;
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_MINUSFSR,   ATTR_DIMMED, TRUE) ; 
+				utc = time(&utcTime) ;
+				//extrapolFreq = 746127081 + 0.032*(utc-3491304000) ; // linear data extrapolation with slope from 18/08/2010-12/08/2010 
+				extrapolFreq = 746108328.707542 + 3.144737e-002 * (utc-3490779388.183) - 9.527612e-010 * (utc-3490779388.183) ;  // quad extrapol from fit of data in HgCavity.txt 5/10/2010
+				
+				
+				SetCtrlVal(CalcNHgPanel, CALCNHG_TARGET, extrapolFreq) ;
+				}
+			else {
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_TARGET,     ATTR_DIMMED, FALSE) ;
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_OFFSETFREQ, ATTR_DIMMED, FALSE) ;
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_PLUSFSR,    ATTR_DIMMED, FALSE) ; 
+				SetCtrlAttribute(CalcNHgPanel, CALCNHG_MINUSFSR,   ATTR_DIMMED, FALSE) ; 
+				}
+			break;
+		}
+	return 0;
+}  */
+
+
+int CVICALLBACK OnChooseSaveFile (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	switch (event)
+		{
+		case EVENT_COMMIT:
+
+			FileSelectPopup("D:\\Manip Femto", "*.txt", "*.txt", "Selection of the ExtraMath saving file", VAL_SAVE_BUTTON, 0, 0, 0, FALSE, ExtraMathFileName) ;
+			SetCtrlAttribute(MainPanel, PANEL_CHECKBOX_MATH5SAVE, ATTR_DIMMED, FALSE) ;
+			
+			break;
+		}
+	return 0;
+}
+
+
+// Changements pour Calcul de N
+
+
+
+int CVICALLBACK CB_OnNCalculus (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+
+	int PanelIsVisible, PanelTop, PanelLeft, PanelWidth ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			if (control==PANEL_N1CALCULUS){
+				GetPanelAttribute (CalcN1Panel, ATTR_VISIBLE , &PanelIsVisible);
+				if (PanelIsVisible) {
+				}
+				else {
+					GetPanelAttribute (MainPanel, ATTR_TOP,   &PanelTop) ;
+					GetPanelAttribute (MainPanel, ATTR_LEFT,  &PanelLeft) ;
+					GetPanelAttribute (MainPanel, ATTR_WIDTH, &PanelWidth) ;
+					SetPanelAttribute (CalcN1Panel, ATTR_TOP, PanelTop+170 ) ;
+					SetPanelAttribute (CalcN1Panel, ATTR_LEFT, PanelLeft+PanelWidth+4 ) ;
+					DisplayPanel(CalcN1Panel) ;
+				} 
+				}
+			if (control==PANEL_N2CALCULUS){
+				GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE , &PanelIsVisible);
+				if (PanelIsVisible) {
+				}
+				else {
+					GetPanelAttribute (MainPanel, ATTR_TOP,   &PanelTop) ;
+					GetPanelAttribute (MainPanel, ATTR_LEFT,  &PanelLeft) ;
+					GetPanelAttribute (MainPanel, ATTR_WIDTH, &PanelWidth) ;
+					SetPanelAttribute (CalcN2Panel, ATTR_TOP, PanelTop+310 ) ;
+					SetPanelAttribute (CalcN2Panel, ATTR_LEFT, PanelLeft+PanelWidth+4 ) ;
+					DisplayPanel(CalcN2Panel) ;
+				} 
+				}
+			if (control==PANEL_N3CALCULUS){
+				GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE , &PanelIsVisible);
+				if (PanelIsVisible) {
+				}
+				else {
+					GetPanelAttribute (MainPanel, ATTR_TOP,   &PanelTop) ;
+					GetPanelAttribute (MainPanel, ATTR_LEFT,  &PanelLeft) ;
+					GetPanelAttribute (MainPanel, ATTR_WIDTH, &PanelWidth) ;
+					SetPanelAttribute (CalcN3Panel, ATTR_TOP, PanelTop+480 ) ;
+					SetPanelAttribute (CalcN3Panel, ATTR_LEFT, PanelLeft+PanelWidth+4 ) ;
+					DisplayPanel(CalcN3Panel) ;
+				} 
+				}
+			break;
+		}
+	
+	return 0;
+}
+
+
+int CVICALLBACK CB_OnStartNCalculus (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==CALCN1_COMMANDBUTTON)
+			{
+					Measuring_1=TRUE;
+			}
+			if (control==CALCN2_COMMANDBUTTON) 
+			{
+					Measuring_2=TRUE;
+			}
+		break;
+		}
+			 
+
+	
+	return 0;
+}
+
+int CVICALLBACK CB_OnStartN3Calculus (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	
+	switch (event)
+	{
+		case EVENT_COMMIT:
+			Measuring_3=TRUE;
+			break;
+	}
+	return 0;
+}
+
+
+int CVICALLBACK CB_OnNStop (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int PanelIsVisible;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			//switch (control)
+			if (control==CALCN1_COMMANDBUTTON_2)
+			{
+			GetPanelAttribute (CalcN1Panel, ATTR_VISIBLE , &PanelIsVisible);
+					if (PanelIsVisible) {
+						HidePanel(CalcN1Panel) ;
+						}
+			
+						Measuring_1=FALSE;
+						Step1_1=FALSE ;
+						Step2_1=FALSE ;
+						Step3_1=FALSE ;
+						Frepminus_1=0.0;
+						Frepplus_1=0.0;
+			  		   t1_1=0.0;
+			 		   t2_1=0.0;
+			 		   t3_1=0.0; 
+						N_slope_1=0;
+						Frequ_slope_1=0.0;
+						Moy_slope_1=0.0;
+						Slope_slope_1 =0.0;
+						Ch4_slope=0.0;
+						Moy_Ch4slope_1=0.0;
+						Slope_Ch4slope_1=0.0;
+						DDSBesChanged1=FALSE;
+						DDSBesChanged2=FALSE; 
+						nDDSChange=0.0;
+						
+						SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+						DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
+						SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ;
+						DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); 
+						nstabilization=0;	
+			}
+			
+			
+			if (control==CALCN2_STOP2)
+			{  
+			GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE , &PanelIsVisible);
+					if (PanelIsVisible) {
+						HidePanel(CalcN2Panel) ;
+						}
+			
+						Measuring_2=FALSE;
+						Step1_2=FALSE ;
+						Step2_2=FALSE ;
+						Step3_2=FALSE ;
+						Frepminus_2=0.0;
+						Delta10K_Minus=0.0;
+						Frepplus_2=0.0;
+						Delta10K_Plus=0.0; 
+						DeltaDDS3=0.0; 
+			 		    t1_2=0.0;
+			  	  	    t2_2=0.0;
+			  		    t3_2=0.0; 
+						N_slope_2=0;
+						Frequ_slope_2=0.0;
+						Moy_slope_2=0.0;
+						Beat_slope_2=0.0;
+						Moy_Beatslope_2=0.0;
+						Slope_Beatslope_2 =0.0;
+						Slope_slope_2 =0.0;
+						DDSBesChanged1=FALSE;
+						DDSBesChanged2=FALSE; 
+						nDDSChange=0.0;
+						SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+						DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
+						SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ;
+						DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit);
+						SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init) ;
+						DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); 
+						nstabilization=0;
+			}
+				
+			
+		break;
+		}
+	return 0;
+}
+
+int CVICALLBACK CB_OnN3Stop (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	int PanelIsVisible;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+					GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE , &PanelIsVisible);
+					if (PanelIsVisible) {										  
+						HidePanel(CalcN3Panel) ;
+						}
+			
+						Measuring_3=FALSE;
+						Step1_3=FALSE ;
+						Step2_3=FALSE ;
+						Step3_3=FALSE ;
+						Frepminus_3=0.0;
+						Frepplus_3=0.0;
+			   		 t1_3=0.0;
+			  		  t2_3=0.0;
+			   		 t3_3=0.0; 
+						N_slope_3=0;
+						Frequ_slope_3=0.0;
+						Moy_slope_3=0.0;
+						Slope_slope_3 =0.0;
+			break;
+		}
+	return 0;
+}
+
+
+int  CVICALLBACK CB_OnIntegrationTime (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	double Time ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==CALCN1_INTEGRATIONTIME){
+				GetCtrlVal(CalcN1Panel, CALCN1_INTEGRATIONTIME, &Time) ;
+				DeltaT_1=Time;
+			}
+			if (control==CALCN2_INTEGRATIONTIME){
+				GetCtrlVal(CalcN2Panel, CALCN2_INTEGRATIONTIME, &Time) ;
+				DeltaT_2=Time;
+			}
+			if (control==CALCN3_INTEGRATIONTIME){
+				GetCtrlVal(CalcN3Panel, CALCN3_INTEGRATIONTIME, &Time) ;
+				DeltaT_3=Time;
+			}
+
+			break;
+			
+		}
+	return 0;
+}
+
+
+int  CVICALLBACK CB_OnDeltaFreq (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	double Frequ ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==CALCN1_DELTAFREQ){
+				GetCtrlVal(CalcN1Panel, CALCN1_DELTAFREQ, &Frequ) ;
+				DeltakHz_1=Frequ;
+			}
+			if (control==CALCN2_DELTAFREQ){
+				GetCtrlVal(CalcN2Panel, CALCN2_DELTAFREQ, &Frequ) ;
+				DeltakHz_2=Frequ;
+			}
+			if (control==CALCN3_DELTAFREQ){
+				GetCtrlVal(CalcN3Panel, CALCN3_DELTAFREQ, &Frequ) ;
+				DeltakHz_3=Frequ;
+			}
+
+			break;
+			
+		}
+	return 0;
+}
+
+
+int  CVICALLBACK CB_OnFindSign (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==PANEL_FINDSIGN1){
+				tbegin1=utc;
+				Frepbefore1=Math1;
+				GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency1) ;
+				SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1+Frequencystep1) ;  
+				DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency1+Frequencystep1);
+				Getsign1=TRUE;
+			}
+			if (control==PANEL_FINDSIGN2){
+				tbegin2=utc;
+				Frepbefore2=Math1;
+				Ch2before=Ch2;
+				GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency2) ;
+				SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2+Frequencystep2) ;
+				DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency2+Frequencystep2);
+				Getsign2=TRUE;
+			}
+			if (control==PANEL_FINDSIGN3){
+				tbegin3=utc;
+				Frepbefore3=Ch1;
+				GetCtrlVal(MainPanel, PANEL_DDS3, &Frequency3) ;
+				SetCtrlVal(MainPanel, PANEL_DDS3, Frequency3+Frequencystep3) ; 
+				DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency3+Frequencystep3);
+				Getsign3=TRUE;
+			}
+
+
+			break;
+			
+		}
+	return 0;
+} 
+
+
+
+int  CVICALLBACK CB_OnFind275K (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+ {
+	 
+	 
+	double FrequencyToChange,DeltaCh4,DeltaCh2;
+	
+	DeltaCh4=275000-Ch4;
+	DeltaCh2=10000-Ch2;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			 if (control==PANEL_FIND275K2){
+					 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyToChange) ;
+					 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyToChange+DeltaCh4) ;  
+					 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyToChange+DeltaCh4);
+					 
+			 }
+			 
+			 if (control==PANEL_FIND10K3){
+					 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyToChange) ;
+					 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyToChange+DeltaCh2) ; 
+					 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyToChange+DeltaCh2);
+					 
+			 }
+			
+		break;
+			
+		}
+	return 0;
+} 
+
+
+int  CVICALLBACK CB_OnSlopeTime (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	double Time ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			if (control==CALCN1_SLOPETIME){
+				GetCtrlVal(CalcN1Panel, CALCN1_SLOPETIME, &Time) ;
+				SlopeTime1=Time;
+			}
+
+			if (control==CALCN2_SLOPETIME){
+				GetCtrlVal(CalcN2Panel, CALCN2_SLOPETIME, &Time) ;
+				SlopeTime2=Time;
+			}
+
+			break;
+			
+		}
+	return 0;
+}
+
+
+ int  CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+	double NewN ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			   if (control==PANEL_CHANGENDIV){ 
+				GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &NewN) ;
+				Ndiv=NewN;
+				FrequDDS1=880000000.0/Ndiv;
+				DeltakHz_1=1800.0*8/Ndiv;
+				DeltakHz_2=1500.0*8/Ndiv;
+				SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ;
+				DDS4xAD9912_SetFrequency(&DDS4xAD9912,1,FrequDDS1);
+				SetCtrlVal(CalcN1Panel, CALCN1_DELTAFREQ, DeltakHz_1) ;
+				SetCtrlVal(CalcN2Panel, CALCN2_DELTAFREQ, DeltakHz_2) ; 
+			   }
+
+			break;
+			
+		}
+	return 0;
+}
+
+
+ int  CVICALLBACK CB_OnStartSlopeCancelling (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+
+	double   ActualFrequ=0.0;
+	double   ActualSlope=0.0; 
+	int buttonstatu=0;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			   if (control==PANEL_STARTCANCEL){ 
+				   
+				   GetCtrlVal(MainPanel, PANEL_STARTCANCEL, &buttonstatu) ; 
+				   
+				    if (buttonstatu==1)
+					{
+						SlopeMeasuringTimeBegin=utc; 
+						SlopeMeasuring=TRUE;
+						ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);
+						ActualSlope= SlopeMath2;
+						LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,ActualSlope,0);
+						Nratio=-1;
+					 	CenterFrequencyCh2ToDetermine=TRUE ;
+						CenterFrequencyCh2=0.0; 
+
+					}
+					else
+					{
+						if (KeepFrequ==TRUE) {ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);}
+						else {  ActualFrequ= DDSFoxFrequency;}
+						if (KeepSlope==TRUE) {ActualSlope= SlopeMath2;
+											  OnSlopeCancelling =TRUE; }
+						else {  ActualSlope= DDSFoxSweeprate;
+								OnSlopeCancelling =FALSE;     }
+						 LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,ActualSlope,0);
+						 SlopeMeasuring=FALSE; 
+						 OnOffMessage="OFF " ;
+						 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;
+			
+		}
+	return 0;
+}
+
+ 
+  int  CVICALLBACK CB_OnResetSlope (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			   if (control==PANEL_RESETSLOPE){ 
+				   
+				     SlopeMath2=0.0; 
+					 CenterFrequencyCh2=0.0;
+					 MoyMath2=0.0;
+					 Nratio=-1;
+					 CenterFrequencyCh2ToDetermine=TRUE ;
+					 OnSlopeCancelling =FALSE; 
+					 LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate,0);
+			   }
+
+			break;
+			
+		}
+	return 0;
+}
+  
+  
+    int  CVICALLBACK CB_ChangeSlopeTime (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			   if (control==PANEL_SLOPETIME){ 
+				   
+				     GetCtrlVal(MainPanel, PANEL_SLOPETIME, &TimetoSlope); 
+			   }
+
+			break;
+			
+		}
+	return 0;
+}
+
+
+  int LaunchDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate,int mode)
+{
+			  //mode =0 pour normal
+			  //mode =1 pour reset 
+	DDSParameter DDSState;
+			strcpy(DDSState.Name ,Name) ; 
+			DDSState.Profil = Profil ;
+			strcpy(DDSState.ip,ip) ; 
+			DDSState.Port = Port;
+			DDSState.Clock = Clock;
+			DDSState.Delta_T = DeltaT;
+			DDSState.Frequency = Frequency; 
+			DDSState.SweepRate = Sweeprate ; 
+			if (mode ==  1) {  DDS_Initialize (&DDSState) ; }
+			else {	DDS_ReInitialize (&DDSState) ; }
+	
+	return 0;
+}
+  
+    double ReadDDSFOX (char *Name,char *ip,int Port,unsigned int Profil,double Clock,double DeltaT,double Frequency,double Sweeprate)
+{
+
+	DDSParameter DDSState;
+	double FrequDDSFox;
+	
+			strcpy(DDSState.Name ,Name) ;
+			DDSState.Profil = Profil ;
+			strcpy(DDSState.ip,ip) ; 
+			DDSState.Port = Port;
+			DDSState.Clock = Clock;
+			DDSState.Delta_T = DeltaT;
+			DDSState.Frequency = Frequency; 
+			DDSState.SweepRate = Sweeprate ; 
+
+			FrequDDSFox=DDSFox_ReadFreq(&DDSState);
+
+	
+	return FrequDDSFox;
+}
+
+
+int  CVICALLBACK CB_OnCROX (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+		bool BoxChecked = FALSE; 
+		double ActualFrequ=0.0;
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			if (control== PANEL_CHECKBOX_CORRFREQU)  
+			{
+				   	GetCtrlVal(MainPanel, PANEL_CHECKBOX_CORRFREQU, &BoxChecked) ;
+						if (BoxChecked) {
+							FrequCorrec=TRUE ;
+							}
+						else {FrequCorrec=FALSE ;}
+							
+			}
+			
+			if (control== PANEL_CHECKBOX_KEEP)  
+			{
+				   	GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEP, &BoxChecked) ;
+						if (BoxChecked) {
+							KeepFrequ=TRUE ;
+							}
+						else {KeepFrequ=FALSE ;}
+							
+			}
+			
+			
+			if (control== PANEL_CHECKBOX_KEEPSLOPE)  
+			{
+				   	GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEPSLOPE, &BoxChecked) ;
+						if (BoxChecked) {
+							KeepSlope=TRUE ;
+							if (SlopeMeasuring==FALSE && OnSlopeCancelling==FALSE)
+							  {
+								    ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);
+									LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,SlopeMath2,0);
+							 		OnSlopeCancelling=TRUE;
+								  
+								  
+							  }
+							}
+						else {KeepSlope=FALSE ;
+							  if (SlopeMeasuring==FALSE && OnSlopeCancelling==TRUE)
+							  {
+								  	  ActualFrequ=ReadDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,DDSFoxFrequency,DDSFoxSweeprate);
+									  LaunchDDSFOX (DDSFoxName,DDSFoxip,DDSFoxPort,DDSFoxProfil,DDSFoxClock,DDSFoxDeltaT,ActualFrequ,DDSFoxSweeprate,0);
+							 		  OnSlopeCancelling=FALSE;
+							  }
+						
+						}
+							
+			}
+			
+ 			break;
+			
+		}
+	return 0;
+}
+
+
+
+int  CVICALLBACK CB_OnReCentering (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+		bool BoxChecked = FALSE; 
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			if (control== PANEL_CHECKBOX_RECENTER)  
+			{
+				   	GetCtrlVal(MainPanel, PANEL_CHECKBOX_RECENTER, &BoxChecked) ;
+						if (BoxChecked) {
+							KeepCentering=TRUE ;
+							CenteringTimeBegin275K=utc;
+							CenteringTimeBegin10K=utc;
+							}
+						else {KeepCentering=FALSE ;}
+							
+			}
+			
+			
+ 			break;
+			
+		}
+	return 0;
+}
+
+
+int  CVICALLBACK CB_OnAutoStopSlopeCancellingIfDelock (int panel, int control, int event, 
+		 void *callbackData, int eventData1, int eventData2)
+{
+		bool BoxChecked = FALSE; 
+		double   ActualFrequ=0.0;  
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			if (control== PANEL_CHECKBOX_STOPIFAUTODE)  
+			{
+				   	GetCtrlVal(MainPanel, PANEL_CHECKBOX_STOPIFAUTODE, &BoxChecked) ;
+						if (BoxChecked) {
+							AutoStopSlopeCancellingIfDelock=TRUE ;
+							}
+						else {AutoStopSlopeCancellingIfDelock=FALSE ;}
+							
+			}
+			
+			
+ 			break;
+			
+		}
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAnalyse.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,247 @@
+/**************************************************************************/
+/* LabWindows/CVI User Interface Resource (UIR) Include File              */
+/* Copyright (c) National Instruments 2011. All Rights Reserved.          */
+/*                                                                        */
+/* WARNING: Do not add to, delete from, or otherwise modify the contents  */
+/*          of this include file.                                         */
+/**************************************************************************/
+
+#include <userint.h>
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+     /* Panels and Controls: */
+
+#define  CALC3                            1
+
+#define  CALCN1                           2
+#define  CALCN1_TARGET_2                  2
+#define  CALCN1_COMMANDBUTTON_3           3
+#define  CALCN1_COMMANDBUTTON_4           4
+#define  CALCN1_NUMERIC_4                 5
+#define  CALCN1_NUMERIC_5                 6
+#define  CALCN1_N_1                       7
+#define  CALCN1_NUMERIC_6                 8
+#define  CALCN1_ACCEPTN1                  9       /* callback function: OnAcceptN */
+#define  CALCN1_CHECKBOX_2                10
+#define  CALCN1_TEXTMSG_2                 11
+#define  CALCN1_SLOPE                     12
+#define  CALCN1_TEXTMSG_8                 13
+#define  CALCN1_DELTAFREQ                 14      /* callback function: CB_OnDeltaFreq */
+#define  CALCN1_SLOPETIME                 15      /* callback function: CB_OnSlopeTime */
+#define  CALCN1_INTEGRATIONTIME           16      /* callback function: CB_OnIntegrationTime */
+#define  CALCN1_COMMANDBUTTON_2           17      /* callback function: CB_OnNStop */
+#define  CALCN1_COMMANDBUTTON             18      /* callback function: CB_OnStartNCalculus */
+
+#define  CALCN2                           3
+#define  CALCN2_SLOPE                     2
+#define  CALCN2_TEXTMSG_8                 3
+#define  CALCN2_DELTAFREQ                 4       /* callback function: CB_OnDeltaFreq */
+#define  CALCN2_INTEGRATIONTIME           5       /* callback function: CB_OnIntegrationTime */
+#define  CALCN2_N_2                       6
+#define  CALCN2_STOP2                     7       /* callback function: CB_OnNStop */
+#define  CALCN2_COMMANDBUTTON             8       /* callback function: CB_OnStartNCalculus */
+#define  CALCN2_ACCEPTN1                  9       /* callback function: OnAcceptN */
+#define  CALCN2_SLOPETIME                 10      /* callback function: CB_OnSlopeTime */
+
+#define  CALCN3                           4
+#define  CALCN3_SLOPE                     2
+#define  CALCN3_TEXTMSG_8                 3
+#define  CALCN3_DELTAFREQ                 4       /* callback function: CB_OnDeltaFreq */
+#define  CALCN3_INTEGRATIONTIME           5       /* callback function: CB_OnIntegrationTime */
+#define  CALCN3_N_3                       6
+#define  CALCN3_COMMANDBUTTON_2           7       /* callback function: CB_OnN3Stop */
+#define  CALCN3_COMMANDBUTTON             8       /* callback function: CB_OnStartN3Calculus */
+#define  CALCN3_ACCEPTN1                  9       /* callback function: OnAcceptN */
+
+#define  PANEL                            5       /* callback function: CB_OnEventMain */
+#define  PANEL_QUITBUTTON                 2       /* callback function: QuitCallback */
+#define  PANEL_STARTBUTTON                3       /* callback function: CB_OnStart */
+#define  PANEL_STOPBUTTON                 4       /* callback function: CB_OnStop */
+#define  PANEL_FREQ4                      5
+#define  PANEL_FREQ3                      6
+#define  PANEL_FREQ2                      7
+#define  PANEL_FREQ1                      8
+#define  PANEL_CHECKBOX_DDSSRALLAN        9
+#define  PANEL_CHECKBOX_DDSHGALLAN        10
+#define  PANEL_CHECKBOX_DDSFREPALLAN      11
+#define  PANEL_CHECKBOX_DDSSRPLOT         12
+#define  PANEL_CHECKBOX_MATH1ALLAN        13      /* callback function: CB_OnAllanPlot */
+#define  PANEL_CHECKBOX_DDSHGPLOT         14
+#define  PANEL_CHECKBOX_FREQ4ALLAN        15      /* callback function: CB_OnAllanPlot */
+#define  PANEL_CHECKBOX_DDSFREPPLOT       16
+#define  PANEL_CHECKBOX_FREQ3ALLAN        17      /* callback function: CB_OnAllanPlot */
+#define  PANEL_CHECKBOX_FREQ4PLOT         18      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_FREQ2ALLAN        19      /* callback function: CB_OnAllanPlot */
+#define  PANEL_CHECKBOX_FREQ3PLOT         20      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_CORRFREQU         21      /* callback function: CB_OnCROX */
+#define  PANEL_CHECKBOX_FREQ1ALLAN        22      /* callback function: CB_OnAllanPlot */
+#define  PANEL_CHECKBOX_FREQ2PLOT         23      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_MATH1PLOT         24      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_FREQ1PLOT         25      /* callback function: CB_OnFreqPlot */
+#define  PANEL_TIMER                      26      /* callback function: CB_OnTimer */
+#define  PANEL_DDS2                       27      /* callback function: CB_ChangeDDSOut */
+#define  PANEL_TEXTMSG                    28
+#define  PANEL_TEXTMSG_2                  29
+#define  PANEL_SLOPETIME                  30      /* callback function: CB_ChangeSlopeTime */
+#define  PANEL_DDS1                       31      /* callback function: CB_ChangeDDSOut */
+#define  PANEL_SPLITTER_4                 32
+#define  PANEL_SPLITTER                   33
+#define  PANEL_CHANGENDIV                 34      /* callback function: CB_OnChangeNdiv */
+#define  PANEL_DDSFREPOUT                 35      /* callback function: CB_ChangeDDSOut */
+#define  PANEL_N3CHOICE                   36      /* callback function: CB_ChangeN */
+#define  PANEL_N3CALCULUS                 37      /* callback function: CB_OnNCalculus */
+#define  PANEL_N1CHOICE                   38      /* callback function: CB_ChangeN */
+#define  PANEL_N2CHOICE                   39      /* callback function: CB_ChangeN */
+#define  PANEL_N2CALCULUS                 40      /* callback function: CB_OnNCalculus */
+#define  PANEL_TEXTMSG_14                 41
+#define  PANEL_TEXTMSG_3                  42
+#define  PANEL_TEXTMSG_4                  43
+#define  PANEL_TEXTMSG_5                  44
+#define  PANEL_DDS4STEP                   45      /* callback function: CB_ChangeDDSStep */
+#define  PANEL_DDS3STEP                   46      /* callback function: CB_ChangeDDSStep */
+#define  PANEL_DDS2STEP                   47      /* callback function: CB_ChangeDDSStep */
+#define  PANEL_CENTERFREQUENCY            48
+#define  PANEL_SLOPETOCANCEL              49
+#define  PANEL_MATH4                      50
+#define  PANEL_MATH5                      51
+#define  PANEL_MATH3                      52
+#define  PANEL_CHECKBOX_MATH5PLOT         53      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_MATH4PLOT         54      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_MATH4ALLAN        55      /* callback function: CB_OnAllanPlot */
+#define  PANEL_DDS1STEP                   56      /* callback function: CB_ChangeDDSStep */
+#define  PANEL_TEXTMSG_15                 57
+#define  PANEL_CHECKBOX_MATH5ALLAN        58      /* callback function: CB_OnAllanPlot */
+#define  PANEL_CHECKBOX_MATH3PLOT         59      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_MATH5SAVE         60
+#define  PANEL_CHECKBOX_MATH3SAVE_2       61      /* callback function: CB_OnSaveSr */
+#define  PANEL_CHECKBOX_MATH3ALLAN        62      /* callback function: CB_OnAllanPlot */
+#define  PANEL_DDSFREPSTEP                63      /* callback function: CB_ChangeDDSStep */
+#define  PANEL_DDSFREPAMP                 64      /* callback function: CB_ChangeDDSAmpli */
+#define  PANEL_MATHSTRING4                65      /* callback function: CB_ChangeMath */
+#define  PANEL_TEXTMSG_17                 66
+#define  PANEL_MATH2                      67
+#define  PANEL_SPLITTER_15                68
+#define  PANEL_SPLITTER_12                69
+#define  PANEL_CHECKBOX_MATH2PLOT         70      /* callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_MATH3SAVE         71      /* callback function: CB_OnSaveHg */
+#define  PANEL_CHECKBOX_MATH2SAVE         72      /* callback function: CB_OnSaveOpt */
+#define  PANEL_CHECKBOX_MATH2ALLAN        73      /* callback function: CB_OnAllanPlot */
+#define  PANEL_TEXTMSG_7                  74
+#define  PANEL_MATHSTRING3                75      /* callback function: CB_ChangeMath */
+#define  PANEL_MATH1                      76
+#define  PANEL_SPLITTER_7                 77
+#define  PANEL_SPLITTER_6                 78
+#define  PANEL_TEXTMSG_18                 79
+#define  PANEL_TEXTMSG_6                  80
+#define  PANEL_TEXTMSG_8                  81
+#define  PANEL_TEXTMSG_19                 82
+#define  PANEL_MATHSTRING1                83      /* callback function: CB_ChangeMath */
+#define  PANEL_TEXTMSG_9                  84
+#define  PANEL_TEXTMSG_10                 85
+#define  PANEL_MATHSTRING2                86      /* callback function: CB_ChangeMath */
+#define  PANEL_SPLITTER_10                87
+#define  PANEL_TEXTMSG_16                 88
+#define  PANEL_SPLITTER_11                89
+#define  PANEL_SPLITTER_9                 90
+#define  PANEL_SPLITTER_5                 91
+#define  PANEL_SPLITTER_3                 92
+#define  PANEL_MINUS10KDDS1               93      /* callback function: CB_OnMinus10k */
+#define  PANEL_MINUS10KDDS4               94      /* callback function: CB_OnMinus10k */
+#define  PANEL_MINUS10KDDS3               95      /* callback function: CB_OnMinus10k */
+#define  PANEL_MINUS10KDDS2               96      /* callback function: CB_OnMinus10k */
+#define  PANEL_PLUS10KDDS4                97      /* callback function: CB_OnPlus10k */
+#define  PANEL_MINUS275K                  98      /* callback function: CB_OnMinus275k */
+#define  PANEL_PLUS10KDDS3                99      /* callback function: CB_OnPlus10k */
+#define  PANEL_PLUS10KDDS1                100     /* callback function: CB_OnPlus10k */
+#define  PANEL_PLUS10KDDS2                101     /* callback function: CB_OnPlus10k */
+#define  PANEL_PLUS275K                   102     /* callback function: CB_OnPlus275k */
+#define  PANEL_TEXTMSG_11                 103
+#define  PANEL_MATHSTRING5                104     /* callback function: CB_ChangeMath */
+#define  PANEL_SPLITTER_8                 105
+#define  PANEL_MJD                        106
+#define  PANEL_UTC                        107
+#define  PANEL_TIME                       108
+#define  PANEL_DATE                       109
+#define  PANEL_CHECKBOX_MATH3AUTOSAV      110     /* callback function: CB_OnAutoSaveSr */
+#define  PANEL_CHECKBOX_MATH2AUTOSAV      111     /* callback function: CB_OnAutoSaveHg */
+#define  PANEL_CHOOSESAVEFILE             112     /* callback function: OnChooseSaveFile */
+#define  PANEL_SPLITTER_14                113
+#define  PANEL_SPLITTER_13                114
+#define  PANEL_DDS4                       115     /* callback function: CB_ChangeDDSOut */
+#define  PANEL_SPLITTER_2                 116
+#define  PANEL_DDS3                       117     /* callback function: CB_ChangeDDSOut */
+#define  PANEL_N1CALCULUS                 118     /* callback function: CB_OnNCalculus */
+#define  PANEL_FINDSIGN3                  119     /* callback function: CB_OnFindSign */
+#define  PANEL_SIGN3                      120
+#define  PANEL_FINDSIGN2                  121     /* callback function: CB_OnFindSign */
+#define  PANEL_SIGN2                      122
+#define  PANEL_FINDSIGN1                  123     /* callback function: CB_OnFindSign */
+#define  PANEL_SIGN1                      124
+#define  PANEL_FIND10K3                   125     /* callback function: CB_OnFind275K */
+#define  PANEL_FIND275K2                  126     /* callback function: CB_OnFind275K */
+#define  PANEL_RESETSLOPE                 127     /* callback function: CB_OnResetSlope */
+#define  PANEL_CHECKBOX_STOPIFAUTODE      128     /* callback function: CB_OnAutoStopSlopeCancellingIfDelock */
+#define  PANEL_CHECKBOX_RECENTER          129     /* callback function: CB_OnReCentering */
+#define  PANEL_CHECKBOX_KEEPSLOPE         130     /* callback function: CB_OnCROX */
+#define  PANEL_CHECKBOX_KEEP              131     /* callback function: CB_OnCROX */
+#define  PANEL_STARTCANCEL                132     /* callback function: CB_OnStartSlopeCancelling */
+#define  PANEL_LED1                       133
+#define  PANEL_LED2                       134
+#define  PANEL_TEXTMSG_20                 135
+
+
+     /* Menu Bars, Menus, and Menu Items: */
+
+          /* (no menu bars in the resource file) */
+
+
+     /* Callback Prototypes: */ 
+
+int  CVICALLBACK CB_ChangeDDSAmpli(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_ChangeDDSOut(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_ChangeDDSStep(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_ChangeMath(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_ChangeN(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_ChangeSlopeTime(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnAllanPlot(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnAutoSaveHg(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnAutoSaveSr(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnAutoStopSlopeCancellingIfDelock(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnChangeNdiv(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnCROX(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnDeltaFreq(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnEventMain(int panel, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnFind275K(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnFindSign(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnFreqPlot(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnIntegrationTime(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnMinus10k(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnMinus275k(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnN3Stop(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnNCalculus(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnNStop(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnPlus10k(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnPlus275k(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnReCentering(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnResetSlope(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnSaveHg(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnSaveOpt(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnSaveSr(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnSlopeTime(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnStart(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnStartN3Calculus(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnStartNCalculus(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnStartSlopeCancelling(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnStop(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK CB_OnTimer(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK OnAcceptN(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK OnChooseSaveFile(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK QuitCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+
+
+#ifdef __cplusplus
+    }
+#endif
Binary file FXAnalyse.uir has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAnalyse2.cws	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,356 @@
+[Workspace Header]
+Version = 910
+Pathname Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Pathname Line0002 = "al modif bize/FXAnalyse2.cws"
+CVI Dir = "/c/program files/national instruments/cvi2009"
+CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
+CVI Pub Local Dir Line0001 = "/C/Documents and Settings/All Users/Application Data/National Instruments/CVI200"
+CVI Pub Local Dir Line0002 = "9"
+CVI Pub Global Dir = "/C/Documents and Settings/All Users/Application Data/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
+IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
+VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
+Number of Projects = 1
+Active Project = 1
+Project 0001 = "FXAnalyse2.prj"
+Drag Bar Left = 335
+Window Top = 157
+Window Left = 442
+Window Bottom = 625
+Window Right = 1224
+Maximized = True
+Maximized Children = True
+Max32 Number Of Errors = 20
+Track Include File Dependencies = True
+Prompt For Missing Includes = True
+Stop On First Error File = False
+Bring Up Err Win For Warnings = True
+Show Build Dialog = False
+Save Changes Before Running = "Always"
+Hide Windows = False
+Break At First Statement = False
+Sort Type = "File Name"
+Number of Opened Files = 14
+Window Confinement Region Enabled = True
+MainColumnWidth = 318
+FileDateColumnWidth = 70
+FileSizeColumnWidth = 70
+StatusColumnWidth = 70
+
+[Project Header 0001]
+Version = 910
+Don't Update DistKit = False
+Platform Code = 4
+Build Configuration = "Debug"
+Build Platform = "Intel 32-bit"
+Warn User If Debugging Release = 1
+Batch Build Release = True
+Batch Build Debug = False
+Force Rebuild = False
+
+[File 0001]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS4xAD9912.h"
+File Type = "Include"
+Disk Date = 3398774404
+In Projects = "1,"
+Window Top = 62
+Window Left = 22
+Window Z-Order = 9
+Source Window State = "1,25,25,25,17,31,17,0,3,81,0,0,0,0,0,25,10,0,25,31,349,687,1,0,"
+
+[File 0002]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS_Fox.h"
+File Type = "Include"
+Disk Date = 3389621367
+In Projects = "1,"
+Window Top = 182
+Window Left = 86
+Window Z-Order = 12
+Source Window State = "1,0,0,0,0,0,0,0,0,81,0,0,0,0,0,25,3,0,0,0,349,687,1,0,"
+
+[File 0003]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/YLCStuff.h"
+File Type = "Include"
+Disk Date = 3301978486
+In Projects = "1,"
+Window Top = 32
+Window Left = 6
+Window Z-Order = 10
+Source Window State = "1,0,0,0,0,0,0,0,0,81,0,0,0,0,0,25,0,0,42,85,349,687,1,0,"
+
+[File 0004]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Allan.h"
+File Type = "Include"
+Disk Date = 3319553856
+In Projects = "1,"
+Source Window State = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
+
+[File 0005]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS2xAD9858.h"
+File Type = "Include"
+Disk Date = 3355223732
+In Projects = ""
+Window Top = 182
+Window Left = 86
+Window Z-Order = 5
+Source Window State = "1,58,58,58,11,30,30,0,3,80,0,0,0,0,0,25,12,0,58,11,349,683,1,0,"
+
+[File 0006]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDSBes.h"
+File Type = "Include"
+Disk Date = 3355477284
+In Projects = "1,"
+Source Window State = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
+
+[File 0007]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAllan.h"
+File Type = "Include"
+Disk Date = 3355142120
+In Projects = "1,"
+Source Window State = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
+
+[File 0008]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAnalyse.h"
+File Type = "Include"
+Disk Date = 3398932193
+In Projects = "1,"
+Window Top = 212
+Window Left = 102
+Window Z-Order = 8
+Source Window State = "1,190,190,190,9,26,26,0,3,81,0,0,0,0,0,25,27,0,190,9,349,687,1,0,"
+
+[File 0009]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXPlot.h"
+File Type = "Include"
+Disk Date = 3383805014
+In Projects = "1,"
+Source Window State = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"
+
+[File 0010]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/muParserDLL.h"
+File Type = "Include"
+Disk Date = 3301904986
+In Projects = "1,"
+Window Top = 92
+Window Left = 38
+Source Window State = "1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,349,687,1,0,"
+
+[File 0011]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Plot.h"
+File Type = "Include"
+Disk Date = 3385632418
+In Projects = "1,"
+Window Top = 182
+Window Left = 86
+Source Window State = "1,14,14,14,20,40,40,0,0,0,0,0,0,0,0,0,0,0,14,31,349,687,1,0,"
+
+[File 0012]
+Path = "/m/mes documents/Téléchargements/DDSdrivers/DDS4xAD9912.c"
+File Type = "CSource"
+Disk Date = 3398777284
+In Projects = ""
+Window Top = 32
+Window Left = 6
+Window Z-Order = 14
+Source Window State = "1,53,53,53,53,59,59,0,3,80,0,0,0,0,0,25,0,0,53,53,349,683,1,0,"
+
+[File 0013]
+Path = "/z/Backup Software/FemtoSoftYLC/FXAnalyse.c"
+File Type = "CSource"
+Disk Date = 3365169596
+In Projects = ""
+Window Top = 32
+Window Left = 6
+Window Z-Order = 13
+Source Window State = "1,423,479,423,0,15,0,0,0,81,0,0,0,0,0,25,117,0,397,60,349,687,1,0,"
+
+[File 0014]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAnalyse.uir"
+File Type = "User Interface Resource"
+Disk Date = 3398932192
+In Projects = "1,"
+Window Top = 212
+Window Left = 102
+Window Height = 349
+Window Width = 687
+Window Z-Order = 2
+
+[File 0015]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAnalyse.c"
+File Type = "CSource"
+Disk Date = 3398932550
+In Projects = "1,"
+Window Top = 62
+Window Left = 22
+Window Z-Order = 3
+Source Window State = "1,366,366,366,23,34,34,0,0,81,0,0,0,0,0,25,336,0,286,20,349,687,1,0,"
+
+[File 0016]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS4xAD9912.c"
+File Type = "CSource"
+Disk Date = 3398774847
+In Projects = "1,"
+Window Top = 32
+Window Left = 6
+Window Z-Order = 11
+Source Window State = "1,0,215,0,0,8160,0,1,0,81,0,1,0,1,0,25,0,0,209,12,349,687,1,0,"
+
+[File 0017]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS2xAD9858.c"
+File Type = "CSource"
+Disk Date = 3359389302
+In Projects = ""
+Window Top = 62
+Window Left = 22
+Window Z-Order = 4
+Source Window State = "1,123,123,123,12,31,31,0,3,81,0,0,0,0,0,25,111,0,123,12,349,687,1,0,"
+
+[File 0018]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Allan.c"
+File Type = "CSource"
+Disk Date = 3342617652
+In Projects = "1,"
+Window Top = 32
+Window Left = 6
+Window Z-Order = 1
+Source Window State = "1,0,0,0,0,0,0,0,0,163,0,0,0,0,0,56,0,0,0,0,349,687,1,0,"
+
+[File 0019]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS_Fox.c"
+File Type = "CSource"
+Disk Date = 3389621367
+In Projects = "1,"
+Window Top = 212
+Window Left = 102
+Source Window State = "1,9,9,9,89,90,90,0,0,0,0,0,0,0,0,0,0,0,28,40,349,687,1,0,"
+
+[File 0020]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDSBes.c"
+File Type = "CSource"
+Disk Date = 3370584710
+In Projects = "1,"
+Window Top = 122
+Window Left = 54
+Source Window State = "1,116,116,116,5,25,5,0,3,0,0,0,0,0,0,0,0,0,116,25,349,687,1,0,"
+
+[File 0021]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAllan.uir"
+File Type = "User Interface Resource"
+Disk Date = 3369722096
+In Projects = "1,"
+
+[File 0022]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXPlot.uir"
+File Type = "User Interface Resource"
+Disk Date = 3383805014
+In Projects = "1,"
+
+[File 0023]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/muParser.lib"
+File Type = "Library"
+Disk Date = 3266256404
+In Projects = "1,"
+
+[File 0024]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Plot.c"
+File Type = "CSource"
+Disk Date = 3383804966
+In Projects = "1,"
+Window Top = 122
+Window Left = 54
+Source Window State = "1,210,210,210,18,65,65,0,0,0,0,0,0,0,0,0,260,0,199,95,349,687,1,0,"
+
+[File 0025]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/YLCStuff.c"
+File Type = "CSource"
+Disk Date = 3301979202
+In Projects = "1,"
+Window Top = 92
+Window Left = 38
+Window Z-Order = 6
+Source Window State = "1,0,0,0,0,0,0,0,0,81,0,21,0,0,0,25,22,0,0,0,349,687,1,11,"
+
+[File 0026]
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/YLCTypes.h"
+File Type = "Include"
+Disk Date = 3260523586
+In Projects = ""
+Window Top = 62
+Window Left = 22
+Window Z-Order = 7
+Source Window State = "1,0,0,0,0,0,0,0,0,80,0,0,0,0,0,25,0,0,0,0,349,683,1,0,"
+
+[Build Options 0001]
+Generate Browse Info = True
+Enable Uninitialized Locals Runtime Warning = True
+Execution Trace = "Disabled"
+Profile = "Disabled"
+Debugging Level = "Standard"
+Break On Library Errors = True
+Break On First Chance Exceptions = False
+
+[Execution Target 0001]
+Execution Target Address = "Local desktop computer"
+Execution Target Port = 0
+Execution Target Type = 0
+
+[SCC Options 0001]
+Use global settings = True
+SCC Provider = ""
+SCC Project = ""
+Local Path = ""
+Auxiliary Path = ""
+Perform Same Action For .h File As For .uir File = "Ask"
+Perform Same Action For .cds File As For .prj File = "Ask"
+Username = ""
+Comment = ""
+Use Default Username = False
+Use Default Comment = False
+Suppress CVI Error Messages = False
+Always show confirmation dialog = True
+
+[DLL Debugging Support 0001]
+External Process Path = ""
+
+[DLLs Used By Executable 0001]
+DLL 0001 Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+DLL 0001 Line0002 = "al modif bize/muparser.dll"
+
+[Command Line Args 0001]
+Command Line Args = ""
+Working Directory = ""
+
+[Distributions]
+Active Index = 2
+AbsCDSPath 0001 Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+AbsCDSPath 0001 Line0002 = "al modif bize/FXAnalyze5.cds"
+RelCDSPath 0001 = "FXAnalyze5.cds"
+AbsCDSPath 0002 Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+AbsCDSPath 0002 Line0002 = "al modif bize/FXAnalyze2_2.cds"
+RelCDSPath 0002 = "FXAnalyze2_2.cds"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAnalyse2.prj	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,391 @@
+[Project Header]
+Version = 910
+Pathname Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Pathname Line0002 = "al modif bize/FXAnalyse2.prj"
+Project Label = "FXAnalyze2"
+CVI Dir = "/c/program files/national instruments/cvi2009"
+CVI Shared Dir = "/C/Program Files/National Instruments/Shared/CVI"
+CVI Pub Local Dir Line0001 = "/C/Documents and Settings/All Users/Application Data/National Instruments/CVI200"
+CVI Pub Local Dir Line0002 = "9"
+CVI Pub Global Dir = "/C/Documents and Settings/All Users/Application Data/National Instruments/CVI"
+IVI Standard Root Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework Dir = "/C/Program Files/IVI Foundation/VISA/winnt"
+IVI Standard Root 64-bit Dir = "/C/Program Files/IVI Foundation/IVI"
+VXIplug&play Framework 64-bit Dir = "/C/Program Files/IVI Foundation/VISA/win64"
+Number of Files = 21
+Target Type = "Executable"
+Flags = 16
+Copied From Locked InstrDrv Directory = False
+Copied from VXIPNP Directory = False
+Locked InstrDrv Name = ""
+Don't Display Deploy InstrDrv Dialog = False
+
+[File 0001]
+File Type = "CSource"
+Res Id = 1
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "Allan.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Allan.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0002]
+File Type = "Include"
+Res Id = 2
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "Allan.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Allan.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0003]
+File Type = "CSource"
+Res Id = 3
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "DDS4xAD9912.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS4xAD9912.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0004]
+File Type = "Include"
+Res Id = 4
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "DDS4xAD9912.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS4xAD9912.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0005]
+File Type = "CSource"
+Res Id = 5
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "DDS_Fox.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS_Fox.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0006]
+File Type = "Include"
+Res Id = 6
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "DDS_Fox.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDS_Fox.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0007]
+File Type = "CSource"
+Res Id = 7
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "DDSBes.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDSBes.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0008]
+File Type = "Include"
+Res Id = 8
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "DDSBes.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/DDSBes.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0009]
+File Type = "Include"
+Res Id = 9
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXAllan.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAllan.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0010]
+File Type = "User Interface Resource"
+Res Id = 10
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXAllan.uir"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAllan.uir"
+Exclude = False
+Project Flags = 0
+Folder = "User Interface Files"
+
+[File 0011]
+File Type = "CSource"
+Res Id = 11
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXAnalyse.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAnalyse.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0012]
+File Type = "Include"
+Res Id = 12
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXAnalyse.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAnalyse.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0013]
+File Type = "User Interface Resource"
+Res Id = 13
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXAnalyse.uir"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXAnalyse.uir"
+Exclude = False
+Project Flags = 0
+Folder = "User Interface Files"
+
+[File 0014]
+File Type = "Include"
+Res Id = 14
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXPlot.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXPlot.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0015]
+File Type = "User Interface Resource"
+Res Id = 15
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "FXPlot.uir"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/FXPlot.uir"
+Exclude = False
+Project Flags = 0
+Folder = "User Interface Files"
+
+[File 0016]
+File Type = "Library"
+Res Id = 16
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "muParser.lib"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/muParser.lib"
+Exclude = False
+Project Flags = 0
+Folder = "Librairy Files"
+
+[File 0017]
+File Type = "Include"
+Res Id = 17
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "muParserDLL.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/muParserDLL.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0018]
+File Type = "CSource"
+Res Id = 18
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "Plot.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Plot.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0019]
+File Type = "Include"
+Res Id = 19
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "Plot.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/Plot.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[File 0020]
+File Type = "CSource"
+Res Id = 20
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "YLCStuff.c"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/YLCStuff.c"
+Exclude = False
+Compile Into Object File = False
+Project Flags = 0
+Folder = "Source Files"
+
+[File 0021]
+File Type = "Include"
+Res Id = 21
+Path Is Rel = True
+Path Rel To = "Project"
+Path Rel Path = "YLCStuff.h"
+Path Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Path Line0002 = "al modif bize/YLCStuff.h"
+Exclude = False
+Project Flags = 0
+Folder = "Include Files"
+
+[Folders]
+Instrument Files Folder Not Added Yet = True
+Folder 0 = "Source Files"
+Folder 1 = "Include Files"
+Folder 2 = "User Interface Files"
+Folder 3 = "Librairy Files"
+
+[Compiler Options]
+Default Calling Convention = "cdecl"
+Require Prototypes = True
+Require Return Values = True
+Enable Pointer Mismatch Warning = False
+Enable Unreachable Code Warning = False
+Enable Unreferenced Identifiers Warning = False
+Enable Assignment In Conditional Warning = False
+O Option Compatible With 5.0 = False
+Enable C99 Extensions = False
+Uninitialized Locals Compile Warning = "Conservative"
+Precompile Prefix Header = False
+Prefix Header File = ""
+
+[Run Options]
+Stack Size = 250000
+Image Base Address = 4194304
+Image Base Address x64 = 4194304
+
+[Compiler Defines]
+Compiler Defines = "/DWIN32_LEAN_AND_MEAN"
+
+[Create Executable]
+Executable File_Debug Is Rel = True
+Executable File_Debug Rel To = "Project"
+Executable File_Debug Rel Path = "FXAnalyse2_dbg.exe"
+Executable File_Debug Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Executable File_Debug Line0002 = "al modif bize/FXAnalyse2_dbg.exe"
+Executable File_Release Is Rel = True
+Executable File_Release Rel To = "Project"
+Executable File_Release Rel Path = "FXAnalyse2.exe"
+Executable File_Release Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Executable File_Release Line0002 = "al modif bize/FXAnalyse2.exe"
+Executable File_Debug64 Is Rel = True
+Executable File_Debug64 Rel To = "Project"
+Executable File_Debug64 Rel Path = "FXAnalyse2.exe"
+Executable File_Debug64 Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Executable File_Debug64 Line0002 = "al modif bize/FXAnalyse2.exe"
+Executable File_Release64 Is Rel = True
+Executable File_Release64 Rel To = "Project"
+Executable File_Release64 Rel Path = "FXAnalyse2.exe"
+Executable File_Release64 Line0001 = "/p/nicolodi/blue/Sylvain/Programme FemtoSoft 4DDS + DDS Fox/FemtoSoft+DDSFOX Fin"
+Executable File_Release64 Line0002 = "al modif bize/FXAnalyse2.exe"
+Icon File Is Rel = False
+Icon File = ""
+Application Title = ""
+DLL Exports = "Include File Symbols"
+DLL Import Library Choice = "Gen Lib For Current Mode"
+Use IVI Subdirectories for Import Libraries = False
+Use VXIPNP Subdirectories for Import Libraries = False
+Use Dflt Import Lib Base Name = True
+Where to Copy DLL = "Do not copy"
+Custom Directory to Copy DLL Is Rel = False
+Custom Directory to Copy DLL = ""
+Generate Source Documentation = "None"
+Add Type Lib To DLL = False
+Include Type Lib Help Links = False
+TLB Help Style = "HLP"
+Type Lib FP File Is Rel = False
+Type Lib FP File = ""
+Type Lib Guid = ""
+Runtime Support = "Full Runtime Support"
+Instrument Driver Support Only = False
+Embed Project .UIRs = False
+Generate Map File = False
+
+[External Compiler Support]
+UIR Callbacks File Option = 0
+Using LoadExternalModule = False
+Create Project Symbols File = True
+UIR Callbacks Obj File Is Rel = False
+UIR Callbacks Obj File = ""
+Project Symbols H File Is Rel = False
+Project Symbols H File = ""
+Project Symbols Obj File Is Rel = False
+Project Symbols Obj File = ""
+
+[ActiveX Server Options]
+Specification File Is Rel = False
+Specification File = ""
+Source File Is Rel = False
+Source File = ""
+Include File Is Rel = False
+Include File = ""
+IDL File Is Rel = False
+IDL File = ""
+Register ActiveX Server = False
+
+[Signing Info]
+Sign = False
+Sign Debug Build = False
+Store = ""
+Certificate = ""
+Timestamp URL = ""
+URL = ""
+
+[Manifest Info]
+Embed = False
+
+[tpcSection]
+tpcEnabled = 0
+tpcOverrideEnvironment = 0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXAnalyze2.cds	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,16 @@
+<distribution version="8.5.0" name="FXAnalyze2" type="MSI">
+	<msi GUID="">
+		<general appName="" outputLocation="" outputLocationWithVars="" autoIncrement="true" version="1.0.0">
+			<arp company="" companyURL="" supportURL="" contact="" phone="" comments=""/>
+			<summary title="" subject="" keyWords="" comments="" author=""/></general>
+		<userinterface language="" readMe="" license=""><dlgstrings welcomeTitle="" welcomeText="">
+			</dlgstrings></userinterface>
+		<mergemodules/>
+		<runtimeEngine cvirte="true" instrsup="true" lvrt="true" analysis="true" netvarsup="true" dotnetsup="true" activeXsup="true" lowlevelsup="true" rtutilsup="true" installToAppDir="false"/>
+		<advanced mediaSize="0">
+			<includeConfigProducts>true</includeConfigProducts>
+			<maxImportVisible>silent</maxImportVisible>
+			<maxImportMode>merge</maxImportMode></advanced>
+		<Projects NumProjects="0"/>
+	</msi>
+</distribution>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXCalcN.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,38 @@
+/**************************************************************************/
+/* LabWindows/CVI User Interface Resource (UIR) Include File              */
+/* Copyright (c) National Instruments 2009. All Rights Reserved.          */
+/*                                                                        */
+/* WARNING: Do not add to, delete from, or otherwise modify the contents  */
+/*          of this include file.                                         */
+/**************************************************************************/
+
+#include <userint.h>
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+     /* Panels and Controls: */
+
+#define  CalcNHg                          1
+#define  CalcNHg_TARGET                   2
+#define  CalcNHg_COMMANDBUTTON            3
+#define  CalcNHg_COMMANDBUTTON_2          4
+#define  CalcNHg_NUMERIC                  5
+#define  CalcNHg_NUMERIC_2                6
+#define  CalcNHg_NUMERIC_3                7
+#define  CalcNHg_CHECKBOX                 8
+#define  CalcNHg_TEXTMSG                  9
+
+
+     /* Menu Bars, Menus, and Menu Items: */
+
+          /* (no menu bars in the resource file) */
+
+
+     /* (no callbacks specified in the resource file) */ 
+
+
+#ifdef __cplusplus
+    }
+#endif
Binary file FXCalcN.uir has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FXPlot.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,56 @@
+/**************************************************************************/
+/* LabWindows/CVI User Interface Resource (UIR) Include File              */
+/* Copyright (c) National Instruments 2011. All Rights Reserved.          */
+/*                                                                        */
+/* WARNING: Do not add to, delete from, or otherwise modify the contents  */
+/*          of this include file.                                         */
+/**************************************************************************/
+
+#include <userint.h>
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+     /* Panels and Controls: */
+
+#define  PLOTPANEL                        1       /* callback function: CB_PlotEvent */
+#define  PLOTPANEL_MAX                    2       /* callback function: Plot_CB_ChangeMax */
+#define  PLOTPANEL_MIN                    3       /* callback function: Plot_CB_ChangeMin */
+#define  PLOTPANEL_TEXTMSG_3              4
+#define  PLOTPANEL_TEXTMSG_4              5
+#define  PLOTPANEL_CHECKBOX_AUTOSCALE     6       /* callback function: Plot_CB_ChangeAutoScale */
+#define  PLOTPANEL_RESETBUTTON            7       /* callback function: Plot_CB_Reset */
+#define  PLOTPANEL_TEXTMSG_6              8
+#define  PLOTPANEL_FREQPLOT               9
+#define  PLOTPANEL_ADEV                   10
+#define  PLOTPANEL_SLOPE                  11
+#define  PLOTPANEL_MEAN                   12
+#define  PLOTPANEL_TEXTMSG                13
+#define  PLOTPANEL_SCALINGSTEP            14      /* callback function: Plot_CB_ChangeScalingStep */
+#define  PLOTPANEL_TEXTMSG_8              15
+#define  PLOTPANEL_DEDRIFT                16      /* callback function: Plot_CB_ChangeDrift */
+#define  PLOTPANEL_GETSLOPEBUTTON         17      /* callback function: Plot_CB_GetDrift */
+#define  PLOTPANEL_CHECKBOX_DEDRIFT       18      /* callback function: Plot_CB_Reset */
+
+
+     /* Menu Bars, Menus, and Menu Items: */
+
+          /* (no menu bars in the resource file) */
+
+
+     /* Callback Prototypes: */ 
+
+int  CVICALLBACK CB_PlotEvent(int panel, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_ChangeAutoScale(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_ChangeDrift(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_ChangeMax(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_ChangeMin(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_ChangeScalingStep(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_GetDrift(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+int  CVICALLBACK Plot_CB_Reset(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
+
+
+#ifdef __cplusplus
+    }
+#endif
Binary file FXPlot.uir has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plot.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,325 @@
+
+#include <ansi_c.h>
+#include <userint.h>
+
+#include "YLCStuff.h"
+#include "FXAnalyse.h"
+
+#include "FXPlot.h"   // Auto generated panel definitions and protypes
+#include "Plot.h"	  // My own .h file, containing prototypes and definitions for the class Plot...
+
+
+
+// ******************* Member functions : constructor and destructor **********************
+
+int Plot_InitPanel(Plot_Data * Instance, char * title, double PlotMin, double PlotMax, void (*OnCloseFunc)(int) ) {
+	
+	if ((Instance->PlotPanel = LoadPanel (0, "FXPlot.uir", PLOTPANEL)) < 0)
+	return -1;
+	SetPanelAttribute(Instance->PlotPanel, ATTR_TITLE, title) ;  
+	SetPanelAttribute (Instance->PlotPanel, ATTR_CALLBACK_DATA, (void *)Instance); // the panel callback therefore knows which data structure it is associated to 
+	Instance->OnClosePanel = OnCloseFunc ;
+	Instance->IndexPoint = 0 ;
+	Instance->Mean = 0 ;
+	Instance->Slope = 0;
+	Instance->ADev = 0 ;
+	Instance->Frequencies = calloc(MAXPOINTSNUMBER, sizeof(double)) ;
+	DisplayPanel (Instance->PlotPanel);
+	SetCtrlVal(Instance->PlotPanel, PLOTPANEL_MIN, PlotMin) ;
+	SetCtrlVal(Instance->PlotPanel, PLOTPANEL_MAX, PlotMax) ;
+	SetAxisScalingMode(Instance->PlotPanel, PLOTPANEL_FREQPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, PlotMin, PlotMax) ;
+	return 0 ;
+	}
+
+
+
+int Plot_ClosePanel(Plot_Data * Instance) {
+	free(Instance->Frequencies) ;
+	Instance->OnClosePanel(Instance->PlotPanel) ;
+	DiscardPanel (Instance->PlotPanel); 
+	return 0;
+	}
+			
+	
+
+// ******************** Member functions, callbacks (private) *******************************
+
+int CVICALLBACK CB_PlotEvent(int panel, int event, void *callbackData, int eventData1, int eventData2) {
+	
+	int VirtualKeyCode ;
+	int StepIndex ;
+	double Step ;
+	
+	Plot_Data * Instance = NULL; 
+	void (*truc)(void);
+	
+	switch (event)
+	{
+	case EVENT_CLOSE:
+		GetPanelAttribute (panel, ATTR_CALLBACK_DATA, &Instance);  
+		Plot_ClosePanel(Instance) ;
+		break;
+	
+	case EVENT_KEYPRESS:
+		VirtualKeyCode = GetKeyPressEventVirtualKey(eventData2);
+		switch (VirtualKeyCode)
+		{
+		case 2304: //ie right arrow
+			GetCtrlIndex(panel, PLOTPANEL_SCALINGSTEP, &StepIndex);
+			if (StepIndex<10){
+				SetCtrlIndex(panel, PLOTPANEL_SCALINGSTEP, ++StepIndex) ;
+				GetCtrlVal(panel, PLOTPANEL_SCALINGSTEP, &Step);
+				SetCtrlAttribute(panel, PLOTPANEL_MIN, ATTR_INCR_VALUE, Step) ;
+				SetCtrlAttribute(panel, PLOTPANEL_MAX, ATTR_INCR_VALUE, Step) ;
+			};
+			break;
+		case 2048: //ie left arrow
+			GetCtrlIndex(panel, PLOTPANEL_SCALINGSTEP, &StepIndex);
+			if (StepIndex>0){
+				SetCtrlIndex(panel, PLOTPANEL_SCALINGSTEP, --StepIndex) ;
+				GetCtrlVal(panel, PLOTPANEL_SCALINGSTEP, &Step);
+				SetCtrlAttribute(panel, PLOTPANEL_MIN, ATTR_INCR_VALUE, Step) ;
+				SetCtrlAttribute(panel, PLOTPANEL_MAX, ATTR_INCR_VALUE, Step) ;
+				};
+			break;
+		};
+		break;
+	}
+	return 0;
+}
+
+int CVICALLBACK Plot_CB_ChangeMax (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double YMin, YMax ;
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, PLOTPANEL_MIN, &YMin) ;
+			GetCtrlVal(panel, PLOTPANEL_MAX, &YMax) ;
+			if (YMin<YMax) {
+				SetAxisScalingMode(panel, PLOTPANEL_FREQPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, YMin, YMax) ;
+				SetCtrlVal(panel, PLOTPANEL_CHECKBOX_AUTOSCALE, FALSE) ; 
+				} ;
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK Plot_CB_ChangeMin (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double YMin, YMax ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+				GetCtrlVal(panel, PLOTPANEL_MIN, &YMin) ;
+				GetCtrlVal(panel, PLOTPANEL_MAX, &YMax) ;
+				if (YMin<YMax ) {     
+					SetAxisScalingMode(panel, PLOTPANEL_FREQPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, YMin, YMax) ;
+					SetCtrlVal(panel, PLOTPANEL_CHECKBOX_AUTOSCALE, FALSE) ;
+					} ;
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+	return 0;
+}
+
+
+int CVICALLBACK Plot_CB_ChangeAutoScale (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool AutoScale = FALSE;
+	int NotCare  = 20000000 ;
+	double YMin = 10000000 , YMax = 64000000 ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, PLOTPANEL_CHECKBOX_AUTOSCALE, &AutoScale) ;
+			if (AutoScale) {
+				SetAxisScalingMode(panel, PLOTPANEL_FREQPLOT, VAL_LEFT_YAXIS, VAL_AUTOSCALE, YMin, YMax) ;
+				GetAxisScalingMode(panel, PLOTPANEL_FREQPLOT,VAL_LEFT_YAXIS, &NotCare, &YMin, &YMax ) ;
+				SetCtrlVal(panel, PLOTPANEL_MIN, YMin);
+				SetCtrlVal(panel, PLOTPANEL_MAX, YMax);
+				}
+			else {
+				GetCtrlVal(panel, PLOTPANEL_MIN, &YMin);
+				GetCtrlVal(panel, PLOTPANEL_MAX, &YMax);
+				SetAxisScalingMode(panel, PLOTPANEL_FREQPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, YMin, YMax) ;
+				} ;
+			break;
+		case EVENT_RIGHT_CLICK:
+
+			break;
+		}
+	return 0;
+} 
+
+int  CVICALLBACK Plot_CB_ChangeScalingStep(int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	double ScalingStep ;
+
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, PLOTPANEL_SCALINGSTEP, &ScalingStep) ;
+			SetCtrlAttribute(panel, PLOTPANEL_MIN, ATTR_INCR_VALUE, ScalingStep) ;
+			SetCtrlAttribute(panel, PLOTPANEL_MAX, ATTR_INCR_VALUE, ScalingStep) ;
+			break;
+		case EVENT_RIGHT_CLICK:
+			break;
+		}
+	return 0;
+}
+
+
+// ******************** Member functions, public *******************************************
+
+int Plot_AddFrequency(Plot_Data * Instance, double Freq) {
+
+	double YMin = 10000000, YMax = 64000000, Mean = 0, ADev = 0 , Slope = 0 , Drift = 0 ;
+	bool AutoScale, DeDrift ;
+	int N = 0, NotCare ;
+
+	// Retrieve previous values for mean, adev and slope
+	Mean  = Instance->Mean ;
+	Slope = Instance->Slope;
+	ADev  = Instance->ADev; 
+	
+	// Correct Freq with drift (feed forward) if dedrift is on
+	GetCtrlVal(Instance->PlotPanel, PLOTPANEL_CHECKBOX_DEDRIFT, &DeDrift) ;
+	if(DeDrift) {
+		GetCtrlVal(Instance->PlotPanel, PLOTPANEL_DEDRIFT, &Drift) ;
+		Freq -= ((double) Instance->IndexPoint)*Drift ;
+		} ;
+	
+	// Add Freq to graph plot
+	Instance->Frequencies[Instance->IndexPoint++] = Freq ;
+	N = Instance->IndexPoint ; // N is now the new number of points in the graph
+	
+	
+	if (N > 1) {   // ADEV and SLOPE need at least 2 values !
+		Instance->Slope = (Slope*(N-2) + 6*(Freq-Mean)/N)/(N+1) ;
+		SetCtrlVal(Instance->PlotPanel, PLOTPANEL_SLOPE, Instance->Slope ) ;
+		Instance->ADev = sqrt( ( ADev*ADev*(N-2) + 0.5*pow(Freq-Instance->Frequencies[N-2],2) ) / (N-1) ) ;
+		SetCtrlVal(Instance->PlotPanel, PLOTPANEL_ADEV, Instance->ADev ) ;  	
+		} ;
+	Instance->Mean = (Mean*(N-1)+Freq)/N ; 
+	SetCtrlVal(Instance->PlotPanel, PLOTPANEL_MEAN, Instance->Mean);
+	
+	if (N > MAXPOINTSNUMBER - 2) { // If too many points recorded, restart new plot with new values of Mean, Slope and Adev
+		Instance->IndexPoint = 0;
+		Instance->Mean = 0;
+		Instance->Slope = 0;
+		Instance->ADev = 0;
+		SetCtrlVal(Instance->PlotPanel,PLOTPANEL_MEAN, 0.) ;
+		SetCtrlVal(Instance->PlotPanel,PLOTPANEL_SLOPE, 0.) ;
+		SetCtrlVal(Instance->PlotPanel,PLOTPANEL_ADEV, 0.) ;
+		} ;
+	
+	DeleteGraphPlot(Instance->PlotPanel, PLOTPANEL_FREQPLOT, -1,VAL_IMMEDIATE_DRAW) ;
+	PlotY(Instance->PlotPanel, PLOTPANEL_FREQPLOT, Instance->Frequencies, Instance->IndexPoint, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_BLUE) ; 
+	GetCtrlVal(Instance->PlotPanel, PLOTPANEL_CHECKBOX_AUTOSCALE, &AutoScale) ;
+	if (AutoScale) {
+		GetAxisScalingMode(Instance->PlotPanel, PLOTPANEL_FREQPLOT,VAL_LEFT_YAXIS, &NotCare, &YMin, &YMax ) ;
+		SetCtrlVal(Instance->PlotPanel, PLOTPANEL_MIN, YMin);
+		SetCtrlVal(Instance->PlotPanel, PLOTPANEL_MAX, YMax);
+		} ;
+	return 0 ;
+	}
+
+
+
+
+int CVICALLBACK Plot_CB_Reset (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	Plot_Data * Instance = NULL;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetPanelAttribute (panel, ATTR_CALLBACK_DATA, &Instance);
+			Instance->IndexPoint = 0 ;
+			Instance->Mean = 0 ;
+			Instance->Slope = 0;
+			Instance->ADev = 0 ;
+			
+			break;
+		}
+	return 0;
+}
+
+
+int CVICALLBACK Plot_CB_GetDrift (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	Plot_Data * Instance = NULL;
+	bool DeDrift ;
+	double Drift ;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			
+			//Instance = ThisPlot(panel) ;
+			GetPanelAttribute (panel, ATTR_CALLBACK_DATA, &Instance);  
+			GetCtrlVal(panel, PLOTPANEL_CHECKBOX_DEDRIFT, &DeDrift) ;
+			
+			if (!DeDrift) {
+				SetCtrlVal(panel,PLOTPANEL_DEDRIFT,Instance->Slope) ;
+				}
+			else {
+				GetCtrlVal(panel, PLOTPANEL_DEDRIFT, &Drift) ;
+				Drift += Instance->Slope ;
+				SetCtrlVal(panel, PLOTPANEL_DEDRIFT, Drift) ;
+				
+				Instance->IndexPoint = 0 ;
+				Instance->Mean = 0 ;
+				Instance->Slope = 0 ;
+				Instance->ADev = 0 ;
+				
+				} ;
+			
+			
+			break;
+		}
+	return 0;
+}
+
+int CVICALLBACK Plot_CB_ChangeDrift (int panel, int control, int event,
+		void *callbackData, int eventData1, int eventData2)
+{
+	bool DeDrift ;
+	Plot_Data * Instance = NULL;
+	
+	switch (event)
+		{
+		case EVENT_COMMIT:
+			GetCtrlVal(panel, PLOTPANEL_CHECKBOX_DEDRIFT, &DeDrift) ;
+			if(DeDrift) { 
+				
+				//Instance = ThisPlot(panel) ;
+				GetPanelAttribute (panel, ATTR_CALLBACK_DATA, &Instance);  
+			
+				Instance->IndexPoint = 0 ;
+				Instance->Mean = 0 ;
+				Instance->Slope = 0 ;
+				Instance->ADev = 0 ;
+				
+				} ;		
+
+			break;
+		}
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plot.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,19 @@
+#include "YLCStuff.h"
+
+#define MAXPOINTSNUMBER 10000         
+
+typedef struct {
+	PanelHandle PlotPanel ;					// le handle sur le graphe
+	void (*OnClosePanel)(int);				// pointer on a function to execute when the panel is closed (argument is the panel Handle)						 
+	int IndexPoint ;						// le nombre de points à plotter
+	double * Frequencies ; 					// les valeurs à plotter (alloué dynamiquement par le constructeur...)
+	double Mean, Slope, ADev ;				// les valeurs de moyenne, pente et deviation d'Allan calculés au fur et à mesure
+	} Plot_Data ;
+
+
+int Plot_InitPanel(Plot_Data * Instance, char * title, double PlotMin, double PlotMax, void (*OnCloseFunc)()) ;
+int Plot_ClosePanel(Plot_Data * Instance) ;
+
+int Plot_AddFrequency(Plot_Data * Instance, double Freq) ;
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/YLCStuff.c	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,77 @@
+//==============================================================================
+//
+// Title:       YLCStuff.c
+// Purpose:     Various stuff used by femtosoftYLC, like math parser callbacks
+//				and personnal types
+//
+// Created on:  19/08/2008 at 10:06:43 by Yann Le Coq.
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+//==============================================================================
+// Include files
+
+//#include "YLCStuff.h"
+
+//==============================================================================
+// Constants
+
+//==============================================================================
+// Types
+
+//==============================================================================
+// Static global variables
+
+//==============================================================================
+// Static functions
+
+//==============================================================================
+// Global variables
+
+//==============================================================================
+// Global functions
+
+/// HIFN  What does your function do?
+/// HIPAR x/What inputs does your function expect?
+/// HIRET What does your function return?
+double Peta (double x) {
+	return 1.0e15*x ;
+};
+
+double Tera (double x) {
+	return 1.0e12*x ;	
+};
+
+double Giga (double x) {
+	return 1.0e9*x ;	
+};
+
+double Mega (double x) {
+	return 1.0e6*x ;	
+};
+
+double kilo (double x) {
+	return 1.0e3*x ;
+};
+
+double milli(double x) {
+	return 1.0e-3*x ;
+};
+	
+double micro(double x){
+	return 1.0e-6*x ;
+};
+
+double nano (double x){
+	return 1.0e-9*x ;
+};
+
+double pico (double x){
+	return 1.e-12*x ;
+};
+
+double femto(double x){
+	return 1.0e-15*x ;
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/YLCStuff.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,59 @@
+//==============================================================================
+//
+// Title:       YLCStuff.h
+// Purpose:     A short description of the interface.
+//
+// Created on:  19/08/2008 at 10:06:43 by pascal blonde.
+// Copyright:   syrte. All Rights Reserved.
+//
+//==============================================================================
+
+#ifndef __YLCStuff_H__
+#define __YLCStuff_H__
+
+#ifdef __cplusplus
+    extern "C" {
+#endif
+
+//==============================================================================
+// Include files
+
+#include "cvidef.h"
+
+//==============================================================================
+// Constants
+
+//==============================================================================
+// Types
+
+typedef int bool;
+
+#define FALSE 0
+#define TRUE 1
+
+typedef int PanelHandle ;		
+		
+		
+//==============================================================================
+// External variables
+
+//==============================================================================
+// Global functions
+
+double Peta (double x);
+double Tera (double x);
+double Giga (double x);
+double Mega (double x);
+double kilo (double x);
+double milli(double x);
+double micro(double x);
+double nano (double x);
+double pico (double x);
+double femto(double x);
+double atto (double x);
+
+#ifdef __cplusplus
+    }
+#endif
+
+#endif  /* ndef __YLCStuff_H__ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/YLCTypes.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,7 @@
+typedef int bool;
+
+#define FALSE 0
+#define TRUE 1
+
+typedef int PanelHandle ;
+
Binary file muParser.dll has changed
Binary file muParser.lib has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/muParserDLL.h	Tue Jul 03 10:38:59 2012 +0200
@@ -0,0 +1,163 @@
+/*
+                 __________                                      
+    _____   __ __\______   \_____  _______  ______  ____ _______ 
+   /     \ |  |  \|     ___/\__  \ \_  __ \/  ___/_/ __ \\_  __ \
+  |  Y Y  \|  |  /|    |     / __ \_|  | \/\___ \ \  ___/ |  | \/
+  |__|_|  /|____/ |____|    (____  /|__|  /____  > \___  >|__|   
+        \/                       \/            \/      \/        
+  Copyright (C) 2004-2007 Ingo Berg
+
+  Permission is hereby granted, free of charge, to any person obtaining a copy of this 
+  software and associated documentation files (the "Software"), to deal in the Software
+  without restriction, including without limitation the rights to use, copy, modify, 
+  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 
+  permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included in all copies or 
+  substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
+  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
+  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
+  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
+*/
+#ifndef MU_PARSER_DLL_H
+#define MU_PARSER_DLL_H
+
+#if defined(_WIN32)
+    #ifdef MUPARSERLIB_EXPORTS
+//        #define MU_PARSER_API extern "C" __declspec(dllexport) 
+        #define API_EXPORT(TYPE) extern "C" __declspec(dllexport) TYPE __stdcall
+    #else
+//        #define MU_PARSER_API extern __declspec(dllimport) 
+        #define API_EXPORT(TYPE) extern __declspec(dllimport) TYPE __stdcall
+    #endif
+#else
+    #define MU_PARSER_API       /* empty macro */
+#endif
+
+// Basic types
+typedef void*  muParserHandle_t;    // parser handle
+typedef char   muChar_t;            // character type
+typedef int    muBool_t;            // boolean type
+typedef int    muInt_t;             // integer type 
+typedef double muFloat_t;           // floating point type
+
+// function types for calculation
+typedef muFloat_t (*muFun1_t)(muFloat_t); 
+typedef muFloat_t (*muFun2_t)(muFloat_t, muFloat_t); 
+typedef muFloat_t (*muFun3_t)(muFloat_t, muFloat_t, muFloat_t); 
+typedef muFloat_t (*muFun4_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t); 
+typedef muFloat_t (*muFun5_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t); 
+typedef muFloat_t (*muMultFun_t)(const muFloat_t*, muInt_t);
+typedef muFloat_t (*muStrFun1_t)(const muChar_t*);
+typedef muFloat_t (*muStrFun2_t)(const muChar_t*, muFloat_t);
+typedef muFloat_t (*muStrFun3_t)(const muChar_t*, muFloat_t, muFloat_t);
+
+// Functions for parser management
+typedef void (*muErrorHandler_t)(muParserHandle_t a_hParser);           // [optional] callback to an error handler
+typedef muFloat_t* (*muFacFun_t)(const muChar_t*, void*);               // [optional] callback for creating new variables
+typedef muInt_t (*muIdentFun_t)(const muChar_t*, muInt_t*, muFloat_t*); // [optional] value identification callbacks
+
+//-----------------------------------------------------------------------------------------------------
+//
+//
+// muParser C compatible bindings
+//
+//
+//-----------------------------------------------------------------------------------------------------
+
+// Basic operations / initialization  
+API_EXPORT(muParserHandle_t) mupCreate(void);
+API_EXPORT(void) mupRelease(muParserHandle_t a_hParser);
+API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser);
+API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t *a_szExpr);
+API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void* pUserData);
+
+API_EXPORT(muFloat_t) mupEval(muParserHandle_t a_hParser);
+
+// Defining callbacks / variables / constants
+API_EXPORT(void) mupDefineFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun1_t a_pFun, muBool_t a_bOptimize);
+API_EXPORT(void) mupDefineFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun2_t a_pFun, muBool_t a_bOptimize);
+API_EXPORT(void) mupDefineFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun3_t a_pFun, muBool_t a_bOptimize);
+API_EXPORT(void) mupDefineFun4(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun4_t a_pFun, muBool_t a_bOptimize);
+API_EXPORT(void) mupDefineFun5(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun5_t a_pFun, muBool_t a_bOptimize);
+// string functions
+API_EXPORT(void) mupDefineStrFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun1_t a_pFun);
+API_EXPORT(void) mupDefineStrFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun2_t a_pFun);
+API_EXPORT(void) mupDefineStrFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun3_t a_pFun);
+
+API_EXPORT(void) mupDefineMultFun( muParserHandle_t a_hParser, 
+                                   const muChar_t* a_szName, 
+                                   muMultFun_t a_pFun, 
+                                   muBool_t a_bOptimize);
+
+API_EXPORT(void) mupDefineOprt( muParserHandle_t a_hParser, 
+                                const muChar_t* a_szName, 
+                                muFun2_t a_pFun, 
+                                muInt_t a_iPri1, 
+                                muBool_t a_bOptimize);
+
+API_EXPORT(void) mupDefineConst( muParserHandle_t a_hParser, 
+                                 const muChar_t* a_szName, 
+                                 muFloat_t a_fVal );
+
+API_EXPORT(void) mupDefineStrConst( muParserHandle_t a_hParser, 
+                                    const muChar_t* a_szName, 
+                                    const muChar_t *a_sVal );
+
+API_EXPORT(void) mupDefineVar( muParserHandle_t a_hParser, 
+                               const muChar_t* a_szName, 
+                               muFloat_t *a_fVar);
+
+API_EXPORT(void) mupDefinePostfixOprt( muParserHandle_t a_hParser, 
+                                       const muChar_t* a_szName, 
+                                       muFun1_t a_pOprt, 
+                                       muBool_t a_bOptimize);
+
+
+API_EXPORT(void) mupDefineInfixOprt( muParserHandle_t a_hParser, 
+                                     const muChar_t* a_szName, 
+                                     muFun1_t a_pOprt, 
+                                     muBool_t a_bOptimize);
+
+// Define character sets for identifiers
+API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
+API_EXPORT(void) mupDefineOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
+API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
+
+// Remove all / single variables
+API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName);
+API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser);
+API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser);
+API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser);
+API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser);
+
+// Querying variables / expression variables / constants
+API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser);
+API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser);
+API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser);
+API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar);
+API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar);
+API_EXPORT(void) mupGetConst(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t* a_pVar);
+
+// Add value recognition callbacks
+API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, muIdentFun_t);
+
+// Error handling
+API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser);
+API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser);
+API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pErrHandler);
+API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser);
+API_EXPORT(muInt_t) mupGetErrorCode(muParserHandle_t a_hParser);
+API_EXPORT(muInt_t) mupGetErrorPos(muParserHandle_t a_hParser);
+API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser);
+API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser);
+
+// This is used for .NET only. It creates a new variable allowing the dll to
+// manage the variable rather than the .NET garbage collector.
+API_EXPORT(muFloat_t*) mupCreateVar(void);
+API_EXPORT(void) mupReleaseVar(muFloat_t*);
+
+#endif // include guard