Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 238:78fdba868884
Drop ChX global variables
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 29 Jan 2015 18:40:07 +0100 |
parents | a41c872bce48 |
children | 7fd5cb857d07 |
comparison
equal
deleted
inserted
replaced
237:a41c872bce48 | 238:78fdba868884 |
---|---|
48 CmtTSQHandle dataQueue; | 48 CmtTSQHandle dataQueue; |
49 // data provider thread | 49 // data provider thread |
50 CmtThreadFunctionID dataProviderThread; | 50 CmtThreadFunctionID dataProviderThread; |
51 | 51 |
52 | 52 |
53 struct event event; | 53 struct event ev; |
54 double utc; | 54 double utc; |
55 double Ch1, Ch2, Ch3, Ch4; | 55 #define Ch1 ev.data[0] |
56 #define Ch2 ev.data[1] | |
57 #define Ch3 ev.data[2] | |
58 #define Ch4 ev.data[3] | |
56 double Math1, Math2, Math3, Math4, Math5; | 59 double Math1, Math2, Math3, Math4, Math5; |
57 double N1, N2, N3; | 60 double N1, N2, N3; |
58 double Ndiv = 8.0; | 61 double Ndiv = 8.0; |
59 double Sign1 = 1, Sign2 = 1, Sign3 = 1; | 62 double Sign1 = 1, Sign2 = 1, Sign3 = 1; |
60 void *MathParser1, *MathParser2, *MathParser3, *MathParser4, *MathParser5; | 63 void *MathParser1, *MathParser2, *MathParser3, *MathParser4, *MathParser5; |
455 } | 458 } |
456 | 459 |
457 struct datafile datafiles[] = { | 460 struct datafile datafiles[] = { |
458 // set the counter channels number to zero. it will | 461 // set the counter channels number to zero. it will |
459 // be updated when the configuration file is read | 462 // be updated when the configuration file is read |
460 DATAFILE("Raw", event.data, 0, PANEL_SAVE_RAW, TRUE), | 463 DATAFILE("Raw", ev.data, 0, PANEL_SAVE_RAW, TRUE), |
461 DATAFILE("DDS", ad9912.frequency, 4, PANEL_SAVE_DDS, FALSE), | 464 DATAFILE("DDS", ad9912.frequency, 4, PANEL_SAVE_DDS, FALSE), |
462 DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE), | 465 DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE), |
463 DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE), | 466 DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE), |
464 DATAFILE("Sr", &Math4, 1, PANEL_SAVE_SR, FALSE), | 467 DATAFILE("Sr", &Math4, 1, PANEL_SAVE_SR, FALSE), |
465 DATAFILE("Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE), | 468 DATAFILE("Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE), |
813 break; | 816 break; |
814 } | 817 } |
815 return 0; | 818 return 0; |
816 } | 819 } |
817 | 820 |
818 void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int ev, | 821 void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int event, |
819 int value, void *callbackData) | 822 int value, void *callbackData) |
820 { | 823 { |
821 int read; | 824 int read; |
822 | 825 |
823 switch (ev) { | 826 switch (event) { |
824 case EVENT_TSQ_ITEMS_IN_QUEUE: | 827 case EVENT_TSQ_ITEMS_IN_QUEUE: |
825 // read data from the data queue | 828 // read data from the data queue |
826 while (value > 0) { | 829 while (value > 0) { |
827 | 830 |
828 read = CmtReadTSQData(queueHandle, &event, 1, TSQ_INFINITE_TIMEOUT, 0); | 831 read = CmtReadTSQData(queueHandle, &ev, 1, TSQ_INFINITE_TIMEOUT, 0); |
829 if (read != 1) | 832 if (read != 1) |
830 logmsg("Error!"); | 833 logmsg("Error!"); |
831 value = value - read; | 834 value = value - read; |
832 | 835 |
833 // unpack event | 836 // unpack event |
834 utc = event.time.tv_sec + event.time.tv_usec * 1e-6; | 837 utc = ev.time.tv_sec + ev.time.tv_usec * 1e-6; |
835 Ch1 = event.data[0]; | |
836 Ch2 = event.data[1]; | |
837 Ch3 = event.data[2]; | |
838 Ch4 = event.data[3]; | |
839 | 838 |
840 // update display | 839 // update display |
841 SetCtrlVal(MainPanel, PANEL_UTC, utc); | 840 SetCtrlVal(MainPanel, PANEL_UTC, utc); |
842 SetCtrlVal(MainPanel, PANEL_CH1, Ch1); | 841 SetCtrlVal(MainPanel, PANEL_CH1, Ch1); |
843 SetCtrlVal(MainPanel, PANEL_CH2, Ch2); | 842 SetCtrlVal(MainPanel, PANEL_CH2, Ch2); |
1426 rollmean_zero(&rollmean_ch4); | 1425 rollmean_zero(&rollmean_ch4); |
1427 } | 1426 } |
1428 } | 1427 } |
1429 | 1428 |
1430 // local time | 1429 // local time |
1431 struct tm *ltime = localtime(&event.time.tv_sec); | 1430 struct tm *ltime = localtime(&ev.time.tv_sec); |
1432 // round to milliseconds | 1431 // round to milliseconds |
1433 int msec = round(event.time.tv_usec / 1000.0); | 1432 int msec = round(ev.time.tv_usec / 1000.0); |
1434 while (msec >= 1000) { | 1433 while (msec >= 1000) { |
1435 ltime->tm_sec += 1; | 1434 ltime->tm_sec += 1; |
1436 msec -= 1000; | 1435 msec -= 1000; |
1437 } | 1436 } |
1438 // format local time | 1437 // format local time |