changeset 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 ec81395bf08d
files FXAnalyse.c
diffstat 1 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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;