comparison FXAnalyse.c @ 37:5e81800fe354

Cleanup
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 03 Oct 2012 15:05:45 +0200
parents 914e0f16b19a
children 2e1b3148d6e6
comparison
equal deleted inserted replaced
36:fb6092340979 37:5e81800fe354
18 #define FXLINELENGTH 123 18 #define FXLINELENGTH 123
19 #define LOGFILEPATH "C:\\Femto\\Software\\FXQE80" 19 #define LOGFILEPATH "C:\\Femto\\Software\\FXQE80"
20 20
21 #define DEDRIFT_DDS_FREQUENCY 70000000 21 #define DEDRIFT_DDS_FREQUENCY 70000000
22 22
23 //============================================================================== 23 // panel handling stuff
24 // Static global variables
25
26 /* multi threading stuff */ // to be used when I will replace timer by thread for counder readout
27 //static int ghPool;
28 //static volatile int vgExiting = 0;
29
30 /* panel handling stuff */
31 static PanelHandle MainPanel ; 24 static PanelHandle MainPanel ;
32 static PanelHandle CalcN1Panel ; 25 static PanelHandle CalcN1Panel ;
33 static PanelHandle CalcN2Panel ; 26 static PanelHandle CalcN2Panel ;
34 static PanelHandle CalcN3Panel ; 27 static PanelHandle CalcN3Panel ;
35 static PanelHandle EstimateN3Panel; 28 static PanelHandle EstimateN3Panel;
36 29
37 //==============================================================================
38 // Static functions
39
40 //static int CVICALLBACK ReadCounterThread(void *functionData); // to be used when I will replace timer by thread for counder readout
41
42 //==============================================================================
43 // Global variables
44
45 char LogFileName[MAX_PATHNAME_LEN]; 30 char LogFileName[MAX_PATHNAME_LEN];
46 char ExtraMathFileName[MAX_PATHNAME_LEN]; 31 char ExtraMathFileName[MAX_PATHNAME_LEN];
47 32
48 double utc = 0; 33 double utc = 0;
49 double mjd = 0; 34 double mjd = 0;
50 35
51 double Ch1, Ch2, Ch3, Ch4 ; // le type long double est identique au double (8 octets) sous CVI !!! 36 double Ch1, Ch2, Ch3, Ch4;
52 double Math1, Math2, Math3, Math4, Math5; // N est en fait un entier en pratique... 37 double Math1, Math2, Math3, Math4, Math5;
53 double N1, N2, N3, N4 ; 38 double N1, N2, N3, N4;
54 39
55 Plot_Data PlotCh1, PlotCh2, PlotCh3, PlotCh4, PlotMath1, PlotMath2, PlotMath3, PlotMath4, PlotMath5 ; 40 Plot_Data PlotCh1, PlotCh2, PlotCh3, PlotCh4, PlotMath1, PlotMath2, PlotMath3, PlotMath4, PlotMath5 ;
56 Allan_Data AllanCh1, AllanCh2, AllanCh3, AllanCh4, AllanMath1, AllanMath2, AllanMath3, AllanMath4, AllanMath5 ; 41 Allan_Data AllanCh1, AllanCh2, AllanCh3, AllanCh4, AllanMath1, AllanMath2, AllanMath3, AllanMath4, AllanMath5 ;
57 42
58 // 1xAD9956 DDS box 43 // 1xAD9956 DDS box
59 DDSParameter DDS1xAD9956; 44 DDSParameter DDS1xAD9956;
60 // 4xAD9912 DDS box 45 // 4xAD9912 DDS box
61 DDS4xAD9912_Data DDS4xAD9912; 46 DDS4xAD9912_Data DDS4xAD9912;
62 47
63 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5 ; 48 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5;
64 49
65 volatile bool Acquiring = FALSE ; 50 int Acquiring = FALSE;
66 51
67 long OldLogFilePtr = 0 ; 52 long OldLogFilePtr = 0;
68 double Ndiv=8.0; 53 double Ndiv = 8.0;
69
70 ///////////////////
71 //Pour les calculs des N
72 54
73 enum { 55 enum {
74 N_MEASUREMENT_STEP_0, 56 N_MEASUREMENT_STEP_0,
75 N_MEASUREMENT_STEP_1, 57 N_MEASUREMENT_STEP_1,
76 N_MEASUREMENT_STEP_2, 58 N_MEASUREMENT_STEP_2,
89 }; 71 };
90 72
91 int settling = 0; 73 int settling = 0;
92 74
93 int Measuring_1 = FALSE; 75 int Measuring_1 = FALSE;
94 bool Measuring_2 = FALSE, Step1_2 = FALSE, Step2_2 = FALSE, Step3_2 = FALSE; 76 int Measuring_2 = FALSE, Step1_2 = FALSE, Step2_2 = FALSE, Step3_2 = FALSE;
95 int Measuring_3 = FALSE; 77 int Measuring_3 = FALSE;
96 78
97 double FrequDDS1=110000000.0, FrequDDS2=15300000.0, FrequDDS3=150400000.0, FrequDDS4=110000000.0; 79 double FrequDDS1=110000000.0, FrequDDS2=15300000.0, FrequDDS3=150400000.0, FrequDDS4=110000000.0;
98 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; 80 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0;
99 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0; 81 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0;
120 102
121 double Ch4Plus=0.0,Ch4Minus=0.0; 103 double Ch4Plus=0.0,Ch4Minus=0.0;
122 104
123 int nDDSChange=0, nstabilization=0; 105 int nDDSChange=0, nstabilization=0;
124 106
125 //////
126 //Pour les signes de fb
127
128 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; 107 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0;
129 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; 108 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0;
130 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; 109 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0;
131 110
132 volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; 111 volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE;
133 double Signe1=1.0,Signe2=1.0,Signe3=0.0; 112 double Signe1=1.0,Signe2=1.0,Signe3=0.0;
134 113
135 114 // slope cancelling
136 115
137 116 int SlopeMeasuring = FALSE;
138 117 int AutoStopSlopeCancellingIfDelock = TRUE;
139 ///////////////////////// 118 int OnSlopeCancelling = FALSE;
140 // Slope Cancelling Variables 119 double SlopeMath2 = 0.0; // currently applied frequency dedrifiting slope
141 120 double TimetoSlope = 60.0;
142 volatile bool SlopeMeasuring=FALSE; 121 double SlopeMeasuringTimeBegin = 0.0;
143 volatile bool AutoStopSlopeCancellingIfDelock=TRUE;
144 volatile bool OnSlopeCancelling =FALSE;
145 double SlopeMath2=0.0;
146 double TimetoSlope=60.0;
147 double SlopeMeasuringTimeBegin=0.0;
148 122
149 double Slope_Math2slope=0.0,Math2_slope=0.0,Moy_Math2slope=0.0; 123 double Slope_Math2slope=0.0,Math2_slope=0.0,Moy_Math2slope=0.0;
150 int N_Math2slope=0.0,nstabilisationSlopeMeasuring=0; 124 int N_Math2slope=0.0,nstabilisationSlopeMeasuring=0;
151 125
152 double LimitToDelock=5.0; 126 double LimitToDelock=5.0;
153 double SlopeCorrection=0.0; 127 double SlopeCorrection=0.0;
154 double limitotakoff=70.0; 128 double limitotakoff=70.0;
155 129
156 int ratio=10; //Recentre la frequence tous les ratios 130 int ratio=10; //Recentre la frequence tous les ratios
157 131
158 volatile bool FrequCorrec=FALSE,KeepFrequ=TRUE, KeepSlope=TRUE ; 132 int FrequCorrec = FALSE, KeepFrequ = TRUE, KeepSlope = TRUE;
159 int Nratio=-1; 133 int Nratio = -1;
160 double MoyMath2 = 0.0, CenterFrequencyCh2 = 0.0; 134 double MoyMath2 = 0.0, CenterFrequencyCh2 = 0.0;
161 volatile bool CenterFrequencyCh2ToDetermine=FALSE; 135 int CenterFrequencyCh2ToDetermine = FALSE;
162
163
164 136
165 enum { 137 enum {
166 SLOPE_REFERENCE_MICROWAVE = 0, 138 SLOPE_REFERENCE_MICROWAVE = 0,
167 SLOPE_REFERENCE_HG_CAVITY = 1, 139 SLOPE_REFERENCE_HG_CAVITY = 1,
168 }; 140 };
169 141
170 int slopeReference = SLOPE_REFERENCE_MICROWAVE; 142 int slopeReference = SLOPE_REFERENCE_MICROWAVE;
171
172 //////////////////////////////////
173 // Keep Centered Variables
174 143
175 volatile bool KeepCentering=FALSE; 144 volatile bool KeepCentering=FALSE;
176 double Timetorecenter275K=3600.0*10; 145 double Timetorecenter275K=3600.0*10;
177 double Timetorecenter10K=3600.0*3; 146 double Timetorecenter10K=3600.0*3;
178 double CenteringTimeBegin275K=0.0; 147 double CenteringTimeBegin275K=0.0;
263 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, initfreqDDS) ; 232 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, initfreqDDS) ;
264 GetCtrlVal(MainPanel, PANEL_DDS3, &initfreqDDS) ; 233 GetCtrlVal(MainPanel, PANEL_DDS3, &initfreqDDS) ;
265 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, initfreqDDS) ; 234 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, initfreqDDS) ;
266 GetCtrlVal(MainPanel, PANEL_DDS4, &initfreqDDS) ; 235 GetCtrlVal(MainPanel, PANEL_DDS4, &initfreqDDS) ;
267 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, initfreqDDS) ; 236 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, initfreqDDS) ;
268
269 237
270 // initialyze 1x AD9956 DDS box 238 // initialyze 1x AD9956 DDS box
271 strcpy(DDS1xAD9956.ip, "145.238.205.58"); 239 strcpy(DDS1xAD9956.ip, "145.238.205.58");
272 DDS1xAD9956.Port = 6665; 240 DDS1xAD9956.Port = 6665;
273 DDS1xAD9956.Profil = 7; // configuration profile: single freq=0, sweep=7 241 DDS1xAD9956.Profil = 7; // configuration profile: single freq=0, sweep=7