Mercurial > hg > fxanalyse
diff FXAnalyse.c @ 144:be87c8e78266
Code cleanup
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 22 Jan 2014 14:45:24 +0100 |
parents | 09a4548e1436 |
children | 75aad9969f87 |
line wrap: on
line diff
--- a/FXAnalyse.c Wed Jan 22 14:45:23 2014 +0100 +++ b/FXAnalyse.c Wed Jan 22 14:45:24 2014 +0100 @@ -7,29 +7,21 @@ #include <string.h> #include <future.h> -#include "YLCStuff.h" #include "FXAnalyse.h" #include "Plot.h" #include "Allan.h" #include "DDS4xAD9912.h" #include "DDS_Fox.h" #include "muParserDLL.h" +#include "utils.h" #include "stat.h" +#include "data-provider.h" #define SR_LOGGER_IP "145.238.204.91" #define DATAFOLDER "Z:\\Measures-2013" #define FREP_STEP_SIZE 50000.0 -// number of channels read -#define NCHAN 4 - -// data acquisition event -struct event { - struct timeval time; - double data[NCHAN]; -}; - // data acquisition status int acquiring; // data queue @@ -37,14 +29,12 @@ // data provider thread CmtThreadFunctionID dataProviderThread; -// data providers -int CVICALLBACK FakeDataProvider (void *functionData); -int CVICALLBACK FileDataProvider (void *functionData); -int CVICALLBACK KKDataProvider (void *functionData); - - // select which data provider to use +#ifdef NDEBUG #define DataProvider KKDataProvider +#else +#define DataProvider FakeDataProvider +#endif struct event event; double utc; @@ -52,7 +42,6 @@ double Math1, Math2, Math3, Math4, Math5; double N1, N2, N3; - // panels static int MainPanel; static int CalcNPanel; @@ -223,7 +212,7 @@ double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; -volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; +int Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; double Sign1=1.0, Sign2=1.0, Sign3=0.0; @@ -269,18 +258,18 @@ // recenter struct recenter { int enabled; // recenter enabled - int Lo; // recenter microwave beatnote - int Sr; // recenter Sr beatnote - int Hg; // recenter Hg beatnote + int lo; // recenter microwave beatnote + int sr; // recenter Sr beatnote + int hg; // recenter Hg beatnote double interval; // interval double t0; // beginning of current interval }; struct recenter recenter = { .enabled = FALSE, - .Lo = FALSE, - .Sr = FALSE, - .Hg = FALSE, + .lo = FALSE, + .sr = FALSE, + .hg = FALSE, .interval = 1800.0, .t0 = 0.0 }; @@ -342,41 +331,6 @@ } -static const char * thousands(char *buffer, int size, char *fmt, double val) -{ - // compute how many separators we need - #pragma DisableFunctionRuntimeChecking log10 - int nsep = log10(fabs(val)); - nsep = (nsep > 0 ? nsep / 3 : 0); - // format value - int len = snprintf(buffer, size, fmt, val); - char *src = buffer + len; - char *dst = src + nsep; - // copy till decimal separator - while (*src != '.') - *dst-- = *src--; - // the next char is the decimal separator - int n = -1; - // copy till src and dst point to the same location - while (src != dst) { - *dst-- = *src--; - // insert separator - if (isdigit(*src) && (++n) && ((n % 3) == 0)) - *dst-- = ' '; - } - return buffer; -} - - -#define MIN(x, y) (x) < (y) ? (x) : (y) - -// MJD functiom used by the Sr programs -static inline double utc2mjd(double utc) -{ - return 15020.0 + utc / 86400.0; -} - - void logmsg(const char *frmt, ...) { char msg[1024]; @@ -669,7 +623,6 @@ return 0; } - int CVICALLBACK CB_OnStart (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -718,14 +671,6 @@ return 0; } - -void CVICALLBACK MessageCB (void *msg) -{ - if (msg != NULL) - logmsg(msg); -} - - void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int ev, int value, void *callbackData) { @@ -1383,7 +1328,7 @@ if ((utc - recenter.t0) > recenter.interval) { - if (recenter.Lo) { + if (recenter.lo) { // adjust DDS2 frequency to keep Ch4 reading at 275 kHz double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 2); double adj = 275000.0 - rollmean_ch4.mean; @@ -1393,7 +1338,7 @@ logmsg("recenter ch4 to 275 kHz: DDS2 adjustment=%+3e", adj); } - if (recenter.Hg) { + if (recenter.hg) { // adjust DDS3 frequency to keep Ch2 reading at 10 kHz double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3); double adj = 10000 - rollmean_ch2.mean; @@ -1403,7 +1348,7 @@ logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e", adj); } - if (recenter.Sr) { + if (recenter.sr) { // adjust DDS3 frequency to keep Ch3 reading at 10 kHz double freq = DDS4xAD9912_GetFrequency(&DDS4xAD9912, 3); double adj = 10000 - rollmean_ch3.mean; @@ -1452,7 +1397,6 @@ } } - int CVICALLBACK CB_OnFreqPlot (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1468,7 +1412,6 @@ return 0; } - int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1637,7 +1580,6 @@ return 0; } - int CVICALLBACK CB_OnMinus10k (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1678,7 +1620,6 @@ return 0; } - int CVICALLBACK CB_OnAcceptN (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1703,7 +1644,6 @@ return 0; } - int CVICALLBACK CB_OnNCalculus (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1758,7 +1698,6 @@ return 0; } - int CVICALLBACK CB_OnStartNCalculus (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1789,8 +1728,6 @@ return 0; } - - int CVICALLBACK CB_OnNStop (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1829,7 +1766,6 @@ return 0; } - int CVICALLBACK CB_OnFindSign (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1870,7 +1806,6 @@ return 0; } - int CVICALLBACK CB_OnFind275K (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1900,8 +1835,7 @@ return 0; } - - int CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event, +int CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) @@ -1916,8 +1850,7 @@ return 0; } - - int CVICALLBACK CB_MeasureSlope (int panel, int control, int event, +int CVICALLBACK CB_MeasureSlope (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) @@ -1946,7 +1879,6 @@ return 0; } - int CVICALLBACK CB_OnResetSlope (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1963,7 +1895,6 @@ return 0; } - int CVICALLBACK CB_ChangeSlopeTime (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1977,7 +1908,6 @@ return 0; } - int CVICALLBACK CB_OnCROX (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -1999,8 +1929,6 @@ return 0; } - - int CVICALLBACK CB_RecenterEnable (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -2017,7 +1945,6 @@ return 0; } - int CVICALLBACK CB_OnStopSlopeCancellingOnUnlocked (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -2044,7 +1971,6 @@ return 0; } - int CVICALLBACK CB_OnEstimateN (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { @@ -2258,19 +2184,31 @@ switch (control) { case PANEL_RECENTER_LO: - GetCtrlVal(panel, control, &recenter.Lo); + GetCtrlVal(panel, control, &recenter.lo); break; case PANEL_RECENTER_HG: - GetCtrlVal(panel, control, &recenter.Hg); + GetCtrlVal(panel, control, &recenter.hg); break; case PANEL_RECENTER_SR: - GetCtrlVal(panel, control, &recenter.Sr); + GetCtrlVal(panel, control, &recenter.sr); break; } break; } return 0; } + +int CVICALLBACK CB_SrDatalogger (int panel, int control, int event, + void *callbackData, int eventData1, int eventData2) +{ + switch (event) + { + case EVENT_COMMIT: + GetCtrlVal(panel, control, &Sr_datalogger_enabled); + break; + } + return 0; +} int CVICALLBACK CB_DedriftDDSFreq (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) {