Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 82:47860259afe2
Implement logging
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 20 Mar 2013 12:08:49 +0100 |
parents | 46fe62febcd0 |
children | c03263186dd7 |
comparison
equal
deleted
inserted
replaced
81:be814b934eca | 82:47860259afe2 |
---|---|
155 | 155 |
156 s->previous = value; | 156 s->previous = value; |
157 } | 157 } |
158 | 158 |
159 struct stat stat_math1, stat_ch2, stat_ch4, freq; | 159 struct stat stat_math1, stat_ch2, stat_ch4, freq; |
160 | |
161 #define MIN(x, y) (x) < (y) ? (x) : (y) | |
162 | |
163 void logmsg(const char *frmt, ...) | |
164 { | |
165 char msg[1024]; | |
166 int len = 0; | |
167 | |
168 // timestamp | |
169 len += sprintf(msg, "%014.3f ", utc); | |
170 time_t now = time(NULL); | |
171 struct tm *t = localtime(&now); | |
172 len += strftime(msg + len, sizeof(msg) - len, "%d-%m-%Y %H:%M:%S ", t); | |
173 | |
174 // message | |
175 va_list args; | |
176 va_start(args, frmt); | |
177 len += vsnprintf(msg + len, sizeof(msg) - len, frmt, args); | |
178 va_end(args); | |
179 | |
180 // add newline | |
181 len = MIN(len, sizeof(msg) - 2); | |
182 msg[len] = '\n'; | |
183 msg[len + 1] = '\0'; | |
184 | |
185 // display message | |
186 SetCtrlVal(MainPanel, PANEL_LOGGING, msg); | |
187 } | |
160 | 188 |
161 | 189 |
162 muParserHandle_t initMathParser() | 190 muParserHandle_t initMathParser() |
163 { | 191 { |
164 muParserHandle_t parser = mupCreate(); | 192 muParserHandle_t parser = mupCreate(); |
476 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__RESET"); | 504 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__RESET"); |
477 | 505 |
478 CurrentFileName(LogFileName); | 506 CurrentFileName(LogFileName); |
479 GetFileInfo(LogFileName, &OldLogFilePtr); | 507 GetFileInfo(LogFileName, &OldLogFilePtr); |
480 OldLogFilePtr -= OldLogFilePtr%FXLINELENGTH + FXLINELENGTH - 2; | 508 OldLogFilePtr -= OldLogFilePtr%FXLINELENGTH + FXLINELENGTH - 2; |
481 break; | 509 |
482 } | 510 logmsg("Start"); |
511 | |
512 break; | |
513 } | |
483 return 0; | 514 return 0; |
484 } | 515 } |
485 | 516 |
486 int CVICALLBACK CB_OnStop (int panel, int control, int event, | 517 int CVICALLBACK CB_OnStop (int panel, int control, int event, |
487 void *callbackData, int eventData1, int eventData2) | 518 void *callbackData, int eventData1, int eventData2) |
1261 } | 1292 } |
1262 } | 1293 } |
1263 | 1294 |
1264 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); | 1295 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); |
1265 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); | 1296 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); |
1297 | |
1298 logmsg("Slope correction update (%+6g) %6g", freq.slope, appliedSlope); | |
1266 | 1299 |
1267 stat_zero(&freq); | 1300 stat_zero(&freq); |
1268 SlopeMeasuringTimeBegin = utc; | 1301 SlopeMeasuringTimeBegin = utc; |
1269 } | 1302 } |
1270 } | 1303 } |
2003 Nratio = -1; | 2036 Nratio = -1; |
2004 MoyMath2 = 0.0; | 2037 MoyMath2 = 0.0; |
2005 CenterFrequencyCh2ToDetermine = TRUE ; | 2038 CenterFrequencyCh2ToDetermine = TRUE ; |
2006 CenterFrequencyCh2 = 0.0; | 2039 CenterFrequencyCh2 = 0.0; |
2007 | 2040 |
2041 logmsg("Start slope measurement"); | |
2042 | |
2008 } else { | 2043 } else { |
2009 if (! KeepSlope) { | 2044 if (! KeepSlope) { |
2010 appliedSlope = 0.0; | 2045 appliedSlope = 0.0; |
2011 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); | 2046 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); |
2012 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); | 2047 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); |
2014 if (! KeepFrequ) { | 2049 if (! KeepFrequ) { |
2015 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); | 2050 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); |
2016 } | 2051 } |
2017 stat_zero(&freq); | 2052 stat_zero(&freq); |
2018 SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope); | 2053 SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope); |
2054 | |
2055 logmsg("Stop slope measurement"); | |
2019 } | 2056 } |
2020 break; | 2057 break; |
2021 } | 2058 } |
2022 return 0; | 2059 return 0; |
2023 } | 2060 } |
2034 Nratio = -1; | 2071 Nratio = -1; |
2035 CenterFrequencyCh2ToDetermine = TRUE ; | 2072 CenterFrequencyCh2ToDetermine = TRUE ; |
2036 appliedSlope = 0.0; | 2073 appliedSlope = 0.0; |
2037 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, appliedSlope); | 2074 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, appliedSlope); |
2038 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); | 2075 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); |
2076 logmsg("Reset slope measurement"); | |
2039 break; | 2077 break; |
2040 } | 2078 } |
2041 return 0; | 2079 return 0; |
2042 } | 2080 } |
2043 | 2081 |