Mercurial > hg > fxanalyse
diff 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 |
line wrap: on
line diff
--- a/FXAnalyse.c Mon Mar 18 12:36:34 2013 +0100 +++ b/FXAnalyse.c Wed Mar 20 12:08:49 2013 +0100 @@ -158,6 +158,34 @@ struct stat stat_math1, stat_ch2, stat_ch4, freq; +#define MIN(x, y) (x) < (y) ? (x) : (y) + +void logmsg(const char *frmt, ...) +{ + char msg[1024]; + int len = 0; + + // timestamp + len += sprintf(msg, "%014.3f ", utc); + time_t now = time(NULL); + struct tm *t = localtime(&now); + len += strftime(msg + len, sizeof(msg) - len, "%d-%m-%Y %H:%M:%S ", t); + + // message + va_list args; + va_start(args, frmt); + len += vsnprintf(msg + len, sizeof(msg) - len, frmt, args); + va_end(args); + + // add newline + len = MIN(len, sizeof(msg) - 2); + msg[len] = '\n'; + msg[len + 1] = '\0'; + + // display message + SetCtrlVal(MainPanel, PANEL_LOGGING, msg); +} + muParserHandle_t initMathParser() { @@ -478,8 +506,11 @@ CurrentFileName(LogFileName); GetFileInfo(LogFileName, &OldLogFilePtr); OldLogFilePtr -= OldLogFilePtr%FXLINELENGTH + FXLINELENGTH - 2; + + logmsg("Start"); + break; - } + } return 0; } @@ -1264,6 +1295,8 @@ SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope); DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope); + logmsg("Slope correction update (%+6g) %6g", freq.slope, appliedSlope); + stat_zero(&freq); SlopeMeasuringTimeBegin = utc; } @@ -2005,6 +2038,8 @@ CenterFrequencyCh2ToDetermine = TRUE ; CenterFrequencyCh2 = 0.0; + logmsg("Start slope measurement"); + } else { if (! KeepSlope) { appliedSlope = 0.0; @@ -2016,6 +2051,8 @@ } stat_zero(&freq); SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope); + + logmsg("Stop slope measurement"); } break; } @@ -2036,6 +2073,7 @@ appliedSlope = 0.0; SetCtrlVal(panel, PANEL_SLOPE_APPLIED, appliedSlope); DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope); + logmsg("Reset slope measurement"); break; } return 0;