Mercurial > hg > fxanalyse
changeset 199:111610d871af
Show error state in main user inteface panel
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Mon, 31 Mar 2014 17:03:37 +0200 |
parents | 5cac684eb12e |
children | 0e0282010be3 |
files | FXAnalyse.c FXAnalyse.h FXAnalyse.uir logging.c logging.h |
diffstat | 5 files changed, 86 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/FXAnalyse.c Mon Mar 31 17:03:37 2014 +0200 +++ b/FXAnalyse.c Mon Mar 31 17:03:37 2014 +0200 @@ -201,7 +201,7 @@ }; int Measuring_1 = N_MEASUREMENT_NONE; -int Measuring_2 = N_MEASUREMENT_NONE; +int Measuring_2 = N_MEASUREMENT_NONE; int Measuring_3 = N_MEASUREMENT_NONE; int nobs = 0; @@ -359,7 +359,13 @@ static struct datalogger datalogger; -void * muParserNew() +static void onerror(int level, const char *msg) +{ + SetCtrlVal(MainPanel, PANEL_ERROR, 1); +} + + +static void * muParserNew() { void *parser = mupCreate(); @@ -420,7 +426,7 @@ return -1; // logging - logger_init(); + logger_init(&onerror); // load configuration file char path[MAX_PATHNAME_LEN]; @@ -461,7 +467,10 @@ return -1; // initialize AD9912 DDS box - ad9912_init(&ad9912, host, clock); + rv = ad9912_init(&ad9912, host, clock); + if (rv) + logmessage(ERROR, "ad9912 init erorr=%d", -rv); + GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); ad9912_set_frequency_w(&ad9912, 0, frequency); GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); @@ -1979,13 +1988,27 @@ switch (event) { case EVENT_COMMIT: - GetCtrlVal(panel, PANEL_SHOWLOG, &visible); + GetCtrlVal(panel, control, &visible); logger_panel_visible(visible); break; } return 0; } +int CVICALLBACK CB_ShowError (int panel, int control, int event, + void *callbackData, int eventData1, int eventData2) +{ + switch (event) + { + case EVENT_COMMIT: + logger_panel_visible(TRUE); + SetCtrlVal(panel, control, FALSE); + SetCtrlVal(panel, PANEL_SHOWLOG, TRUE); + break; + } + return 0; +} + int CVICALLBACK CB_OnLoggingPanelEvent(int panel, int event, void *callbackData, int eventData1, int eventData2) {
--- a/FXAnalyse.h Mon Mar 31 17:03:37 2014 +0200 +++ b/FXAnalyse.h Mon Mar 31 17:03:37 2014 +0200 @@ -96,51 +96,53 @@ #define PANEL_DDS3 60 /* control type: numeric, callback function: CB_ChangeDDSOut */ #define PANEL_N1CALCULUS 61 /* control type: command, callback function: CB_OnNCalculus */ #define PANEL_FINDSIGN3 62 /* control type: command, callback function: CB_OnFindSign */ -#define PANEL_SIGN3 63 /* control type: numeric, callback function: CB_Sign3 */ +#define PANEL_SIGN3 63 /* control type: numeric, callback function: CB_BeatnoteSign */ #define PANEL_FINDSIGN2 64 /* control type: command, callback function: CB_OnFindSign */ -#define PANEL_SIGN2 65 /* control type: numeric, callback function: (none) */ +#define PANEL_SIGN2 65 /* control type: numeric, callback function: CB_BeatnoteSign */ #define PANEL_FINDSIGN1 66 /* control type: command, callback function: CB_OnFindSign */ -#define PANEL_SIGN1 67 /* control type: numeric, callback function: (none) */ -#define PANEL_FIND10K3 68 /* control type: command, callback function: CB_OnFind275K */ -#define PANEL_FIND275K2 69 /* control type: command, callback function: CB_OnFind275K */ -#define PANEL_RESETSLOPE 70 /* control type: command, callback function: CB_OnResetSlope */ -#define PANEL_CHECKBOX_STOPIFAUTODE 71 /* control type: radioButton, callback function: CB_OnStopSlopeCancellingOnUnlocked */ -#define PANEL_CHECKBOX_KEEPSLOPE 72 /* control type: radioButton, callback function: CB_OnCROX */ -#define PANEL_CHECKBOX_KEEP 73 /* control type: radioButton, callback function: CB_OnCROX */ -#define PANEL_SLOPE_REFERENCE 74 /* control type: ring, callback function: CB_OnSlopeReference */ -#define PANEL_ESTIMATE_N2 75 /* control type: command, callback function: CB_OnEstimateN */ -#define PANEL_ESTIMATE_N3 76 /* control type: command, callback function: CB_OnEstimateN */ -#define PANEL_INVERT_SLOPE_SIGN 77 /* control type: radioButton, callback function: CB_InvertSlopeSign */ -#define PANEL_RECENTER 78 /* control type: LED, callback function: CB_RecenterEnable */ -#define PANEL_MEASURE_SLOPE 79 /* control type: LED, callback function: CB_MeasureSlope */ -#define PANEL_SLOPE_MEASURED 80 /* control type: numeric, callback function: (none) */ -#define PANEL_RESET_DEDRIFT_DDS 81 /* control type: command, callback function: CB_ResetDedriftDDS */ -#define PANEL_SAVE_RAW 82 /* control type: radioButton, callback function: CB_SaveData */ -#define PANEL_SHOWLOG 83 /* control type: radioButton, callback function: CB_ShowLog */ -#define PANEL_SLOPEX2 84 /* control type: radioButton, callback function: CB_SlopeX2 */ -#define PANEL_SAVE_DDS 85 /* control type: radioButton, callback function: CB_SaveData */ -#define PANEL_DECORATION_2 86 /* control type: deco, callback function: (none) */ -#define PANEL_DECORATION_8 87 /* control type: deco, callback function: (none) */ -#define PANEL_DECORATION 88 /* control type: deco, callback function: (none) */ -#define PANEL_DECORATION_3 89 /* control type: deco, callback function: (none) */ -#define PANEL_TEXTMSG_6 90 /* control type: textMsg, callback function: (none) */ -#define PANEL_TEXTMSG_22 91 /* control type: textMsg, callback function: (none) */ -#define PANEL_TEXTMSG_21 92 /* control type: textMsg, callback function: (none) */ -#define PANEL_TEXTMSG_7 93 /* control type: textMsg, callback function: (none) */ -#define PANEL_DECORATION_4 94 /* control type: deco, callback function: (none) */ -#define PANEL_DECORATION_7 95 /* control type: deco, callback function: (none) */ -#define PANEL_DECORATION_6 96 /* control type: deco, callback function: (none) */ -#define PANEL_DECORATION_5 97 /* control type: deco, callback function: (none) */ -#define PANEL_TEXTMSG_20 98 /* control type: textMsg, callback function: (none) */ -#define PANEL_TEXTMSG_19 99 /* control type: textMsg, callback function: (none) */ -#define PANEL_MATH4 100 /* control type: string, callback function: (none) */ -#define PANEL_MATH5 101 /* control type: string, callback function: (none) */ -#define PANEL_MATH3 102 /* control type: string, callback function: (none) */ -#define PANEL_MATH2 103 /* control type: string, callback function: (none) */ -#define PANEL_MATH1 104 /* control type: string, callback function: (none) */ -#define PANEL_RECENTER_SR 105 /* control type: radioButton, callback function: CB_RecenterChannel */ -#define PANEL_RECENTER_HG 106 /* control type: radioButton, callback function: CB_RecenterChannel */ -#define PANEL_RECENTER_LO 107 /* control type: radioButton, callback function: CB_RecenterChannel */ +#define PANEL_SIGN1 67 /* control type: numeric, callback function: CB_BeatnoteSign */ +#define PANEL_FIND10K3_2 68 /* control type: command, callback function: CB_OnFind275K */ +#define PANEL_FIND10K3 69 /* control type: command, callback function: CB_OnFind275K */ +#define PANEL_FIND275K2 70 /* control type: command, callback function: CB_OnFind275K */ +#define PANEL_RESETSLOPE 71 /* control type: command, callback function: CB_OnResetSlope */ +#define PANEL_CHECKBOX_STOPIFAUTODE 72 /* control type: radioButton, callback function: CB_OnStopSlopeCancellingOnUnlocked */ +#define PANEL_CHECKBOX_KEEPSLOPE 73 /* control type: radioButton, callback function: CB_OnCROX */ +#define PANEL_CHECKBOX_KEEP 74 /* control type: radioButton, callback function: CB_OnCROX */ +#define PANEL_SLOPE_REFERENCE 75 /* control type: ring, callback function: CB_OnSlopeReference */ +#define PANEL_ESTIMATE_N2 76 /* control type: command, callback function: CB_OnEstimateN */ +#define PANEL_ESTIMATE_N3 77 /* control type: command, callback function: CB_OnEstimateN */ +#define PANEL_INVERT_SLOPE_SIGN 78 /* control type: radioButton, callback function: CB_InvertSlopeSign */ +#define PANEL_RECENTER 79 /* control type: LED, callback function: CB_RecenterEnable */ +#define PANEL_MEASURE_SLOPE 80 /* control type: LED, callback function: CB_MeasureSlope */ +#define PANEL_SLOPE_MEASURED 81 /* control type: numeric, callback function: (none) */ +#define PANEL_RESET_DEDRIFT_DDS 82 /* control type: command, callback function: CB_ResetDedriftDDS */ +#define PANEL_SAVE_RAW 83 /* control type: radioButton, callback function: CB_SaveData */ +#define PANEL_SHOWLOG 84 /* control type: radioButton, callback function: CB_ShowLog */ +#define PANEL_SLOPEX2 85 /* control type: radioButton, callback function: CB_SlopeX2 */ +#define PANEL_SAVE_DDS 86 /* control type: radioButton, callback function: CB_SaveData */ +#define PANEL_DECORATION_2 87 /* control type: deco, callback function: (none) */ +#define PANEL_DECORATION_8 88 /* control type: deco, callback function: (none) */ +#define PANEL_DECORATION 89 /* control type: deco, callback function: (none) */ +#define PANEL_DECORATION_3 90 /* control type: deco, callback function: (none) */ +#define PANEL_TEXTMSG_6 91 /* control type: textMsg, callback function: (none) */ +#define PANEL_TEXTMSG_22 92 /* control type: textMsg, callback function: (none) */ +#define PANEL_TEXTMSG_21 93 /* control type: textMsg, callback function: (none) */ +#define PANEL_TEXTMSG_7 94 /* control type: textMsg, callback function: (none) */ +#define PANEL_DECORATION_4 95 /* control type: deco, callback function: (none) */ +#define PANEL_DECORATION_7 96 /* control type: deco, callback function: (none) */ +#define PANEL_DECORATION_6 97 /* control type: deco, callback function: (none) */ +#define PANEL_DECORATION_5 98 /* control type: deco, callback function: (none) */ +#define PANEL_TEXTMSG_20 99 /* control type: textMsg, callback function: (none) */ +#define PANEL_TEXTMSG_19 100 /* control type: textMsg, callback function: (none) */ +#define PANEL_MATH4 101 /* control type: string, callback function: (none) */ +#define PANEL_MATH5 102 /* control type: string, callback function: (none) */ +#define PANEL_MATH3 103 /* control type: string, callback function: (none) */ +#define PANEL_MATH2 104 /* control type: string, callback function: (none) */ +#define PANEL_MATH1 105 /* control type: string, callback function: (none) */ +#define PANEL_RECENTER_SR 106 /* control type: radioButton, callback function: CB_RecenterChannel */ +#define PANEL_RECENTER_HG 107 /* control type: radioButton, callback function: CB_RecenterChannel */ +#define PANEL_RECENTER_LO 108 /* control type: radioButton, callback function: CB_RecenterChannel */ +#define PANEL_ERROR 109 /* control type: LED, callback function: CB_ShowError */ /* Control Arrays: */ @@ -155,6 +157,7 @@ /* Callback Prototypes: */ +int CVICALLBACK CB_BeatnoteSign(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_ChangeDDSOut(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_ChangeDDSStep(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_ChangeMath(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); @@ -190,8 +193,8 @@ int CVICALLBACK CB_ResetDedriftDDS(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_SaveData(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_SetSlope(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); +int CVICALLBACK CB_ShowError(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_ShowLog(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); -int CVICALLBACK CB_Sign3(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_SlopeX2(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK CB_SrDatalogger(int panel, int control, int event, void *callbackData, int eventData1, int eventData2); int CVICALLBACK QuitCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2);
--- a/logging.c Mon Mar 31 17:03:37 2014 +0200 +++ b/logging.c Mon Mar 31 17:03:37 2014 +0200 @@ -7,13 +7,16 @@ /* this refers to the event time defined as a global variable in the main program */ extern double utc; +/* main panel id */ +extern unsigned int MainPanel; -int __logger_init(struct logger *l) +int __logger_init(struct logger *l, void(*onerror)(int, const char *)) { int rv, panel; char path[MAX_PATHNAME_LEN], *filename; + l->onerror = onerror; l->fd = -1; panel = LoadPanel(0, "FXAnalyse.uir", LOGGING); @@ -78,6 +81,10 @@ /* display message */ SetCtrlVal(l->panel, LOGGING_LOGGING, msg); + /* report error */ + if (level == ERROR) + l->onerror(level, msg); + /* write to log file */ if (l->fd >= 0) write(l->fd, msg, len);
--- a/logging.h Mon Mar 31 17:03:37 2014 +0200 +++ b/logging.h Mon Mar 31 17:03:37 2014 +0200 @@ -8,6 +8,7 @@ struct logger { unsigned int panel; int fd; + void(*onerror)(int, const char *); } __logger; enum loglevel { @@ -17,10 +18,10 @@ ERROR, }; -int __logger_init(struct logger *l); +int __logger_init(struct logger *l, void(*onerror)(int, const char *)); void __logmessage(struct logger *l, enum loglevel level, const char *frmt, ...); -#define logger_init() __logger_init(&__logger) +#define logger_init(onerror) __logger_init(&__logger, onerror) #define logmessage(level, msg, ...) __logmessage(&__logger, (level), (msg), ##__VA_ARGS__) #define logmsg(msg, ...) __logmessage(&__logger, INFO, msg, ##__VA_ARGS__) #define logger_panel_visible(visible) SetPanelAttribute(__logger.panel, ATTR_VISIBLE, visible)