# HG changeset patch # User Daniele Nicolodi # Date 1422553207 -3600 # Node ID 78fdba868884531bd1000014dc561b5900420e25 # Parent a41c872bce489dacda9569bf95caed4f0dccdf87 Drop ChX global variables diff -r a41c872bce48 -r 78fdba868884 FXAnalyse.c --- a/FXAnalyse.c Thu Jan 29 18:25:48 2015 +0100 +++ b/FXAnalyse.c Thu Jan 29 18:40:07 2015 +0100 @@ -50,9 +50,12 @@ CmtThreadFunctionID dataProviderThread; -struct event event; +struct event ev; double utc; -double Ch1, Ch2, Ch3, Ch4; +#define Ch1 ev.data[0] +#define Ch2 ev.data[1] +#define Ch3 ev.data[2] +#define Ch4 ev.data[3] double Math1, Math2, Math3, Math4, Math5; double N1, N2, N3; double Ndiv = 8.0; @@ -457,7 +460,7 @@ struct datafile datafiles[] = { // set the counter channels number to zero. it will // be updated when the configuration file is read - DATAFILE("Raw", event.data, 0, PANEL_SAVE_RAW, TRUE), + DATAFILE("Raw", ev.data, 0, PANEL_SAVE_RAW, TRUE), DATAFILE("DDS", ad9912.frequency, 4, PANEL_SAVE_DDS, FALSE), DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE), DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE), @@ -815,27 +818,23 @@ return 0; } -void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int ev, +void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int event, int value, void *callbackData) { int read; - switch (ev) { + switch (event) { case EVENT_TSQ_ITEMS_IN_QUEUE: // read data from the data queue while (value > 0) { - read = CmtReadTSQData(queueHandle, &event, 1, TSQ_INFINITE_TIMEOUT, 0); + read = CmtReadTSQData(queueHandle, &ev, 1, TSQ_INFINITE_TIMEOUT, 0); if (read != 1) logmsg("Error!"); value = value - read; // unpack event - utc = event.time.tv_sec + event.time.tv_usec * 1e-6; - Ch1 = event.data[0]; - Ch2 = event.data[1]; - Ch3 = event.data[2]; - Ch4 = event.data[3]; + utc = ev.time.tv_sec + ev.time.tv_usec * 1e-6; // update display SetCtrlVal(MainPanel, PANEL_UTC, utc); @@ -1428,9 +1427,9 @@ } // local time - struct tm *ltime = localtime(&event.time.tv_sec); + struct tm *ltime = localtime(&ev.time.tv_sec); // round to milliseconds - int msec = round(event.time.tv_usec / 1000.0); + int msec = round(ev.time.tv_usec / 1000.0); while (msec >= 1000) { ltime->tm_sec += 1; msec -= 1000;