Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 52:30146cc6cd77
Cleanup. Remove some C abominations
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 10 Oct 2012 18:16:02 +0200 |
parents | fbb172892253 |
children | 57e2e88aadb9 |
comparison
equal
deleted
inserted
replaced
51:fbb172892253 | 52:30146cc6cd77 |
---|---|
129 }; | 129 }; |
130 | 130 |
131 int invertSlopeSign = 0; | 131 int invertSlopeSign = 0; |
132 int slopeReference = SLOPE_REFERENCE_MICROWAVE; | 132 int slopeReference = SLOPE_REFERENCE_MICROWAVE; |
133 | 133 |
134 volatile bool KeepCentering=FALSE; | 134 int KeepCentering = FALSE; |
135 double Timetorecenter275K=3600.0*10; | 135 double Timetorecenter275K = 3600.0 * 10; |
136 double Timetorecenter10K=3600.0*3; | 136 double Timetorecenter10K = 3600.0 * 3; |
137 double CenteringTimeBegin275K=0.0; | 137 double CenteringTimeBegin275K = 0.0; |
138 double CenteringTimeBegin10K=0.0; | 138 double CenteringTimeBegin10K = 0.0; |
139 | 139 |
140 | 140 |
141 int DDSFox_Set(DDSParameter *DDS, double Frequency, double Sweeprate) | 141 int DDSFox_Set(DDSParameter *DDS, double Frequency, double Sweeprate) |
142 { | 142 { |
143 DDS->Frequency = Frequency; | 143 DDS->Frequency = Frequency; |
148 | 148 |
149 return 0; | 149 return 0; |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 void initMathParser(muParserHandle_t * pMathParser) | 153 muParserHandle_t initMathParser() |
154 { | 154 { |
155 (* pMathParser) = mupCreate() ; // Math parser number 1, normally used for frep | 155 muParserHandle_t parser = mupCreate(); |
156 mupDefineOprtChars( * pMathParser, "abcdefghijklmnopqrstuvwxyzµ" | 156 mupDefineOprtChars(parser, "abcdefghijklmnopqrstuvwxyzµ" |
157 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 157 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
158 "+-*^/?<>=#!$%&|~'_"); | 158 "+-*^/?<>=#!$%&|~'_"); |
159 mupDefineVar( * pMathParser, "UTC", &utc); | 159 mupDefineVar(parser, "UTC", &utc); |
160 mupDefineVar( * pMathParser, "MJD", &mjd); | 160 mupDefineVar(parser, "MJD", &mjd); |
161 mupDefineVar( * pMathParser, "Ch1", &Ch1); | 161 mupDefineVar(parser, "Ch1", &Ch1); |
162 mupDefineVar( * pMathParser, "Ch2", &Ch2); | 162 mupDefineVar(parser, "Ch2", &Ch2); |
163 mupDefineVar( * pMathParser, "Ch3", &Ch3); | 163 mupDefineVar(parser, "Ch3", &Ch3); |
164 mupDefineVar( * pMathParser, "Ch4", &Ch4); | 164 mupDefineVar(parser, "Ch4", &Ch4); |
165 mupDefineVar( * pMathParser, "DDS1", &(DDS4xAD9912.Frequency1)); | 165 mupDefineVar(parser, "DDS1", &(DDS4xAD9912.Frequency1)); |
166 mupDefineVar( * pMathParser, "DDS2", &(DDS4xAD9912.Frequency2)); | 166 mupDefineVar(parser, "DDS2", &(DDS4xAD9912.Frequency2)); |
167 mupDefineVar( * pMathParser, "DDS3", &(DDS4xAD9912.Frequency3)); | 167 mupDefineVar(parser, "DDS3", &(DDS4xAD9912.Frequency3)); |
168 mupDefineVar( * pMathParser, "DDS4", &(DDS4xAD9912.Frequency4)); | 168 mupDefineVar(parser, "DDS4", &(DDS4xAD9912.Frequency4)); |
169 mupDefineVar( * pMathParser, "N1", &N1); | 169 mupDefineVar(parser, "N1", &N1); |
170 mupDefineVar( * pMathParser, "N2", &N2); | 170 mupDefineVar(parser, "N2", &N2); |
171 mupDefineVar( * pMathParser, "N3", &N3); | 171 mupDefineVar(parser, "N3", &N3); |
172 mupDefineVar( * pMathParser, "Nu1", &Nu1); | 172 mupDefineVar(parser, "Nu1", &Nu1); |
173 mupDefineVar( * pMathParser, "Nu2", &Nu2); | 173 mupDefineVar(parser, "Nu2", &Nu2); |
174 mupDefineVar( * pMathParser, "DeltaDDS3", &DeltaDDS3); | 174 mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3); |
175 mupDefineVar( * pMathParser, "Signe1", &Signe1); | 175 mupDefineVar(parser, "Signe1", &Signe1); |
176 mupDefineVar( * pMathParser, "Signe2", &Signe2); | 176 mupDefineVar(parser, "Signe2", &Signe2); |
177 mupDefineVar( * pMathParser, "Ndiv", &Ndiv); | 177 mupDefineVar(parser, "Ndiv", &Ndiv); |
178 mupDefinePostfixOprt( * pMathParser, "P", &Peta , 1); | 178 mupDefinePostfixOprt(parser, "P", &Peta, 1); |
179 mupDefinePostfixOprt( * pMathParser, "T", &Tera , 1); | 179 mupDefinePostfixOprt(parser, "T", &Tera, 1); |
180 mupDefinePostfixOprt( * pMathParser, "G", &Giga , 1); | 180 mupDefinePostfixOprt(parser, "G", &Giga, 1); |
181 mupDefinePostfixOprt( * pMathParser, "M", &Mega , 1); | 181 mupDefinePostfixOprt(parser, "M", &Mega, 1); |
182 mupDefinePostfixOprt( * pMathParser, "k", &kilo , 1); | 182 mupDefinePostfixOprt(parser, "k", &kilo, 1); |
183 mupDefinePostfixOprt( * pMathParser, "m", &milli, 1); | 183 mupDefinePostfixOprt(parser, "m", &milli, 1); |
184 mupDefinePostfixOprt( * pMathParser, "u", µ, 1); | 184 mupDefinePostfixOprt(parser, "u", µ, 1); |
185 mupDefinePostfixOprt( * pMathParser, "µ", µ, 1); | 185 mupDefinePostfixOprt(parser, "µ", µ, 1); |
186 mupDefinePostfixOprt( * pMathParser, "n_1", &nano, 1); | 186 mupDefinePostfixOprt(parser, "n", &nano, 1); |
187 mupDefinePostfixOprt( * pMathParser, "p", &pico, 1); | 187 mupDefinePostfixOprt(parser, "p", &pico, 1); |
188 mupDefinePostfixOprt( * pMathParser, "f", &femto, 1); | 188 mupDefinePostfixOprt(parser, "f", &femto, 1); |
189 | |
190 return parser; | |
189 } | 191 } |
190 | 192 |
191 | 193 |
192 int main (int argc, char *argv[]) | 194 int main (int argc, char *argv[]) |
193 { | 195 { |
194 double initfreqDDS ; | 196 double frequency; |
195 char * MathString1 = " " ; | 197 char expr[1024]; |
196 char * MathString2 = " " ; | |
197 char * MathString3 = " " ; | |
198 char * MathString4 = " " ; | |
199 char * MathString5 = " " ; | |
200 | 198 |
201 if (InitCVIRTE (0, argv, 0) == 0) | 199 if (InitCVIRTE (0, argv, 0) == 0) |
202 return -1; /* out of memory */ | 200 return -1; |
203 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) | 201 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) |
204 return -1; | 202 return -1; |
205 if ((CalcN1Panel = LoadPanel (0, "FXAnalyse.uir", CALCN1)) < 0) | 203 if ((CalcN1Panel = LoadPanel (0, "FXAnalyse.uir", CALCN1)) < 0) |
206 return -1; | 204 return -1; |
207 if ((CalcN2Panel = LoadPanel (0, "FXAnalyse.uir", CALCN2)) < 0) | 205 if ((CalcN2Panel = LoadPanel (0, "FXAnalyse.uir", CALCN2)) < 0) |
212 return -1; | 210 return -1; |
213 | 211 |
214 DisplayPanel (MainPanel); | 212 DisplayPanel (MainPanel); |
215 | 213 |
216 // initialize 4x AD9959 DDS box | 214 // initialize 4x AD9959 DDS box |
217 DDS4xAD9912_Reset(&DDS4xAD9912) ; | 215 DDS4xAD9912_Reset(&DDS4xAD9912); |
218 GetCtrlVal(MainPanel, PANEL_DDS1, &initfreqDDS) ; | 216 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); |
219 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, initfreqDDS) ; | 217 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency); |
220 GetCtrlVal(MainPanel, PANEL_DDS2, &initfreqDDS) ; | 218 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); |
221 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, initfreqDDS) ; | 219 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency); |
222 GetCtrlVal(MainPanel, PANEL_DDS3, &initfreqDDS) ; | 220 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); |
223 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, initfreqDDS) ; | 221 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency); |
224 GetCtrlVal(MainPanel, PANEL_DDS4, &initfreqDDS) ; | 222 GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); |
225 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, initfreqDDS) ; | 223 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); |
226 | 224 |
227 // initialyze 1x AD9956 DDS box | 225 // initialyze 1x AD9956 DDS box |
228 strcpy(DDS1xAD9956.ip, "145.238.205.58"); | 226 strcpy(DDS1xAD9956.ip, "145.238.205.58"); |
229 DDS1xAD9956.Port = 6665; | 227 DDS1xAD9956.Port = 6665; |
230 DDS1xAD9956.Profil = 7; // configuration profile: single freq=0, sweep=7 | 228 DDS1xAD9956.Profil = 7; // configuration profile: single freq=0, sweep=7 |
232 DDS1xAD9956.Frequency = DEDRIFT_DDS_FREQUENCY; | 230 DDS1xAD9956.Frequency = DEDRIFT_DDS_FREQUENCY; |
233 DDS1xAD9956.Delta_T = 0.01; | 231 DDS1xAD9956.Delta_T = 0.01; |
234 DDS1xAD9956.SweepRate = 0.0; | 232 DDS1xAD9956.SweepRate = 0.0; |
235 DDS_Initialize(&DDS1xAD9956); | 233 DDS_Initialize(&DDS1xAD9956); |
236 | 234 |
237 // Initialize the 5 (separate) math parsers for frep, Nu_Hg, Nu_Sr, N3 and ExtraMath | 235 Ch1 = Ch2 = Ch3 = Ch4 = 0.0; |
238 | 236 |
239 Ch1=0.0 ; Ch2=0.0 ; Ch3=0.0 ; Ch4=0.0 ; | 237 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1); |
240 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1) ; | 238 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2); |
241 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2) ; | 239 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3); |
242 | 240 |
243 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3) ; | 241 MathParser1 = initMathParser(); |
244 | 242 GetCtrlVal(MainPanel, PANEL_MATHSTRING1, expr); |
245 initMathParser(&MathParser1); | 243 mupSetExpr(MathParser1, expr); |
246 GetCtrlVal(MainPanel, PANEL_MATHSTRING1, MathString1); | 244 |
247 mupSetExpr(MathParser1, MathString1); | 245 MathParser2 = initMathParser(); |
248 | 246 mupDefineVar(MathParser2, "Math1", &Math1); |
249 initMathParser(&MathParser2) ; | 247 mupDefineVar(MathParser2, "DDS", &(DDS4xAD9912.Frequency1)); |
250 mupDefineVar( MathParser2, "Math1", &Math1); | 248 GetCtrlVal(MainPanel, PANEL_MATHSTRING2, expr); |
251 mupDefineVar( MathParser2, "DDS", &(DDS4xAD9912.Frequency1)); | 249 mupSetExpr(MathParser2, expr); |
252 GetCtrlVal(MainPanel, PANEL_MATHSTRING2, MathString2) ; | 250 |
253 mupSetExpr(MathParser2, MathString2); | 251 MathParser3 = initMathParser(); |
254 | 252 mupDefineVar(MathParser3, "Math1", &Math1); |
255 initMathParser(&MathParser3) ; | 253 mupDefineVar(MathParser3, "Math2", &Math2); |
256 mupDefineVar( MathParser3, "Math1", &Math1); | 254 mupDefineVar(MathParser3, "DDS", &(DDS4xAD9912.Frequency2)); |
257 mupDefineVar( MathParser3, "Math2", &Math2); | 255 GetCtrlVal(MainPanel, PANEL_MATHSTRING3, expr); |
258 mupDefineVar( MathParser3, "DDS", &(DDS4xAD9912.Frequency2)); | 256 mupSetExpr(MathParser3, expr); |
259 GetCtrlVal(MainPanel, PANEL_MATHSTRING3, MathString3) ; | 257 |
260 mupSetExpr(MathParser3, MathString3); | 258 MathParser4 = initMathParser(); |
261 | 259 mupDefineVar(MathParser4, "Math1", &Math1); |
262 initMathParser(&MathParser4) ; | 260 mupDefineVar(MathParser4, "Math2", &Math2); |
263 mupDefineVar( MathParser4, "Math1", &Math1); | 261 mupDefineVar(MathParser4, "Math3", &Math3); |
264 mupDefineVar( MathParser4, "Math2", &Math2); | 262 GetCtrlVal(MainPanel, PANEL_MATHSTRING4, expr); |
265 mupDefineVar( MathParser4, "Math3", &Math3); | 263 mupSetExpr(MathParser4, expr); |
266 GetCtrlVal(MainPanel, PANEL_MATHSTRING4, MathString4) ; | 264 |
267 mupSetExpr(MathParser4, MathString4); | 265 MathParser5 = initMathParser(); |
268 | 266 mupDefineVar(MathParser5, "Math1", &Math1); |
269 initMathParser(&MathParser5) ; | 267 mupDefineVar(MathParser5, "Math2", &Math2); |
270 mupDefineVar( MathParser5, "Math1", &Math1); | 268 mupDefineVar(MathParser5, "Math3", &Math3); |
271 mupDefineVar( MathParser5, "Math2", &Math2); | 269 mupDefineVar(MathParser5, "Math4", &Math4); |
272 mupDefineVar( MathParser5, "Math3", &Math3); | 270 GetCtrlVal(MainPanel, PANEL_MATHSTRING5, expr); |
273 mupDefineVar( MathParser5, "Math4", &Math4); | 271 mupSetExpr(MathParser5, expr); |
274 GetCtrlVal(MainPanel, PANEL_MATHSTRING5, MathString5) ; | 272 |
275 mupSetExpr(MathParser5, MathString5); | 273 RunUserInterface(); |
276 | 274 |
277 | 275 DiscardPanel(MainPanel); |
278 RunUserInterface (); | |
279 | |
280 // Stops everything at the end | |
281 | |
282 DiscardPanel (MainPanel); | |
283 return 0; | 276 return 0; |
284 } | 277 } |
285 | 278 |
286 | 279 |
287 void OnCloseViewPanel(int panel){ | 280 void OnCloseViewPanel(int panel){ |
313 void *callbackData, int eventData1, int eventData2) | 306 void *callbackData, int eventData1, int eventData2) |
314 { | 307 { |
315 switch (event) | 308 switch (event) |
316 { | 309 { |
317 case EVENT_COMMIT: | 310 case EVENT_COMMIT: |
318 QuitUserInterface (0); | 311 QuitUserInterface(0); |
319 mupRelease(MathParser1); | 312 mupRelease(MathParser1); |
320 mupRelease(MathParser2); | 313 mupRelease(MathParser2); |
321 mupRelease(MathParser3); | 314 mupRelease(MathParser3); |
322 mupRelease(MathParser4); | 315 mupRelease(MathParser4); |
323 mupRelease(MathParser5); | 316 mupRelease(MathParser5); |
473 } | 466 } |
474 | 467 |
475 int CVICALLBACK CB_OnStop (int panel, int control, int event, | 468 int CVICALLBACK CB_OnStop (int panel, int control, int event, |
476 void *callbackData, int eventData1, int eventData2) | 469 void *callbackData, int eventData1, int eventData2) |
477 { | 470 { |
478 switch (event) | 471 switch (event) { |
479 { | |
480 case EVENT_COMMIT: | 472 case EVENT_COMMIT: |
481 Acquiring = FALSE ; | 473 Acquiring = FALSE ; |
482 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__START"); | 474 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__START"); |
483 break; | 475 break; |
484 case EVENT_RIGHT_CLICK: | 476 } |
485 | |
486 break; | |
487 } | |
488 return 0; | 477 return 0; |
489 } | 478 } |
490 | 479 |
491 int CVICALLBACK CB_OnTimer (int panel, int control, int event, | 480 int CVICALLBACK CB_OnTimer (int panel, int control, int event, |
492 void *callbackData, int eventData1, int eventData2) | 481 void *callbackData, int eventData1, int eventData2) |
508 struct tm LocalTime ; | 497 struct tm LocalTime ; |
509 time_t utcTime; | 498 time_t utcTime; |
510 char * ReportString = "dd.mm.yy\t00:00:00\t3481610838.000\t0000000000000.00000000"; | 499 char * ReportString = "dd.mm.yy\t00:00:00\t3481610838.000\t0000000000000.00000000"; |
511 | 500 |
512 int BoxChecked = FALSE; | 501 int BoxChecked = FALSE; |
513 | |
514 double FoxFrequ=0.0; | |
515 | |
516 double FrequencyToChange=0.0; | |
517 double DeltaCh2=0.0; | |
518 double DeltaCh4=0.0; | |
519 | 502 |
520 switch (event) | 503 switch (event) |
521 { | 504 { |
522 case EVENT_TIMER_TICK: | 505 case EVENT_TIMER_TICK: |
523 | 506 |
1238 case SLOPE_REFERENCE_HG_CAVITY: | 1221 case SLOPE_REFERENCE_HG_CAVITY: |
1239 currentFreq = Ch2 * 1542.2 / 1062.5; | 1222 currentFreq = Ch2 * 1542.2 / 1062.5; |
1240 break; | 1223 break; |
1241 } | 1224 } |
1242 | 1225 |
1243 if (utc-SlopeMeasuringTimeBegin > TimetoSlope) | 1226 if ((utc - SlopeMeasuringTimeBegin) > TimetoSlope) { |
1244 { | 1227 |
1245 Nratio = Nratio + 1; | 1228 Nratio = Nratio + 1; |
1246 | 1229 if Nratio >= 1 |
1247 if (Nratio >= 1) { | |
1248 MoyMath2 = MoyMath2 + Moy_Math2slope; | 1230 MoyMath2 = MoyMath2 + Moy_Math2slope; |
1249 } | 1231 |
1250 | 1232 if (invertSlopeSign) |
1251 if (invertSlopeSign) { | |
1252 SlopeMath2 = SlopeMath2 - Slope_Math2slope; | 1233 SlopeMath2 = SlopeMath2 - Slope_Math2slope; |
1253 } else { | 1234 else |
1254 SlopeMath2 = SlopeMath2 + Slope_Math2slope; | 1235 SlopeMath2 = SlopeMath2 + Slope_Math2slope; |
1255 } | |
1256 | 1236 |
1257 N_Math2slope = 0.0; | 1237 N_Math2slope = 0.0; |
1258 Math2_slope = 0.0; | 1238 Math2_slope = 0.0; |
1259 Moy_Math2slope = 0.0; | 1239 Moy_Math2slope = 0.0; |
1260 Slope_Math2slope = 0.0; | 1240 Slope_Math2slope = 0.0; |
1261 | 1241 |
1262 if (Nratio == 1 && CenterFrequencyCh2ToDetermine == TRUE) | 1242 if (Nratio == 1 && CenterFrequencyCh2ToDetermine == TRUE) { |
1263 { | |
1264 CenterFrequencyCh2 = MoyMath2; | 1243 CenterFrequencyCh2 = MoyMath2; |
1265 CenterFrequencyCh2ToDetermine = FALSE; | 1244 CenterFrequencyCh2ToDetermine = FALSE; |
1266 } | 1245 } |
1267 | 1246 |
1268 OnSlopeCancelling = TRUE; | 1247 OnSlopeCancelling = TRUE; |
1269 | 1248 |
1270 if (Nratio == ratio) | 1249 if (Nratio == ratio) { |
1271 { | 1250 if (FrequCorrec == TRUE) { |
1272 if (FrequCorrec == TRUE) | |
1273 { | |
1274 SlopeCorrection = (MoyMath2/ratio-CenterFrequencyCh2)/TimetoSlope; | 1251 SlopeCorrection = (MoyMath2/ratio-CenterFrequencyCh2)/TimetoSlope; |
1275 SlopeMath2 = SlopeMath2 + SlopeCorrection; | 1252 SlopeMath2 = SlopeMath2 + SlopeCorrection; |
1276 } | 1253 } |
1277 Nratio = 0; | 1254 Nratio = 0; |
1278 MoyMath2 = 0.0; | 1255 MoyMath2 = 0.0; |
1279 } | 1256 } |
1280 | 1257 |
1281 FoxFrequ = DDSFox_ReadFreq(&DDS1xAD9956); | 1258 double frequency = DDSFox_ReadFreq(&DDS1xAD9956); |
1282 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2); | 1259 SetCtrlVal(MainPanel, PANEL_SLOPETOCANCEL, SlopeMath2); |
1283 DDSFox_Set(&DDS1xAD9956, FoxFrequ, SlopeMath2); | 1260 DDSFox_Set(&DDS1xAD9956, frequency, SlopeMath2); |
1284 | 1261 |
1285 nstabilisationSlopeMeasuring = 0; | 1262 nstabilisationSlopeMeasuring = 0; |
1286 SlopeMeasuringTimeBegin = utc; | 1263 SlopeMeasuringTimeBegin = utc; |
1287 | 1264 |
1288 } | 1265 } |
1336 } | 1313 } |
1337 } | 1314 } |
1338 } | 1315 } |
1339 | 1316 |
1340 // re-centering | 1317 // re-centering |
1341 if (KeepCentering) | 1318 if (KeepCentering) { |
1342 { | 1319 if ((utc - CenteringTimeBegin275K) > Timetorecenter275K && CenteringTimeBegin275K > 10) { |
1343 | 1320 double frequency; |
1344 DeltaCh4=275000-Ch4; | 1321 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); |
1345 DeltaCh2=10000-Ch2; | 1322 // adjust DDS2 frequency to keep Ch4 reading around 275000 |
1346 | 1323 frequency = frequency + 275000 - Ch4; |
1347 if (utc- CenteringTimeBegin275K > Timetorecenter275K && CenteringTimeBegin275K>10) | 1324 SetCtrlVal(MainPanel, PANEL_DDS2, frequency); |
1348 { | 1325 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency); |
1349 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyToChange); | 1326 CenteringTimeBegin275K = utc; |
1350 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyToChange+DeltaCh4); | |
1351 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyToChange+DeltaCh4); | |
1352 CenteringTimeBegin275K=utc; | |
1353 } | 1327 } |
1354 | 1328 |
1355 if (utc- CenteringTimeBegin10K > Timetorecenter10K && CenteringTimeBegin10K>10) | 1329 if ((utc - CenteringTimeBegin10K) > Timetorecenter10K && CenteringTimeBegin10K > 10) { |
1356 { | 1330 double frequency; |
1357 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyToChange); | 1331 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); |
1358 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyToChange+DeltaCh2); | 1332 // adjust DDS3 frequency to keep Ch2 reading around 10000 |
1359 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyToChange+DeltaCh2); | 1333 frequency = frequency + 10000 - Ch2; |
1360 CenteringTimeBegin10K=utc; | 1334 SetCtrlVal(MainPanel, PANEL_DDS3, frequency); |
1361 } | 1335 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency); |
1336 CenteringTimeBegin10K = utc; | |
1337 } | |
1362 } | 1338 } |
1363 | 1339 |
1364 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2AUTOSAV, &BoxChecked); // AutoSave OL | 1340 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2AUTOSAV, &BoxChecked); // AutoSave OL |
1365 if (BoxChecked) { | 1341 if (BoxChecked) { |
1366 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 | 1342 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 |
1431 Plot_Data * pPlot = NULL; | 1407 Plot_Data * pPlot = NULL; |
1432 char PlotTitle[] = "Ch? Frequency Plot" ; | 1408 char PlotTitle[] = "Ch? Frequency Plot" ; |
1433 double PlotMin = 10e6 ; | 1409 double PlotMin = 10e6 ; |
1434 double PlotMax = 65e6 ; | 1410 double PlotMax = 65e6 ; |
1435 | 1411 |
1436 switch (event) | 1412 switch (event) { |
1437 { | |
1438 case EVENT_COMMIT: | 1413 case EVENT_COMMIT: |
1439 | 1414 |
1440 GetCtrlVal(MainPanel, control, &BoxChecked); | 1415 GetCtrlVal(MainPanel, control, &BoxChecked); |
1441 switch (control) { | 1416 switch (control) { |
1442 case PANEL_CHECKBOX_FREQ1PLOT : | 1417 case PANEL_CHECKBOX_FREQ1PLOT : |
1483 Fmt(PlotTitle, "Math5 Plot") ; | 1458 Fmt(PlotTitle, "Math5 Plot") ; |
1484 PlotMin = -1.0e9 ; PlotMax = 1.0e9 ; | 1459 PlotMin = -1.0e9 ; PlotMax = 1.0e9 ; |
1485 break ; | 1460 break ; |
1486 } | 1461 } |
1487 | 1462 |
1488 if (BoxChecked) { | 1463 if (BoxChecked) |
1489 Plot_InitPanel(pPlot, PlotTitle, PlotMin, PlotMax, &OnCloseViewPanel) ; | 1464 Plot_InitPanel(pPlot, PlotTitle, PlotMin, PlotMax, &OnCloseViewPanel); |
1490 } | 1465 else |
1491 else { | 1466 Plot_ClosePanel(pPlot); |
1492 Plot_ClosePanel(pPlot) ; | 1467 break; |
1493 } ; | 1468 } |
1494 break; | |
1495 | |
1496 case EVENT_RIGHT_CLICK: | |
1497 | |
1498 break; | |
1499 | |
1500 } | |
1501 return 0; | 1469 return 0; |
1502 } | 1470 } |
1503 | 1471 |
1504 | 1472 |
1505 int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event, | 1473 int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event, |