diff fake-data-provider.c @ 91:4102fe614df2

Fix timestamping. Cleanup data providers
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 22 Mar 2013 16:32:15 +0100
parents 9b7588cd4013
children 6fd67aa13d10
line wrap: on
line diff
--- a/fake-data-provider.c	Fri Mar 22 18:49:58 2013 +0100
+++ b/fake-data-provider.c	Fri Mar 22 16:32:15 2013 +0100
@@ -2,17 +2,18 @@
 
 #include <userint.h>
 #include <utility.h>
+#include <future.h>
 
-/* data acquisition flag */
-extern int acquiring;
-/* data queue */
-extern CmtTSQHandle dataQueue;
+#include "data-provider.h"
 
 int CVICALLBACK FakeDataProvider (void *functionData)
 {
 	int mainThreadId;
 	double mark;
-	double data[5] = {0.0, 10000.0, 2.0, 3.0, 4.0};
+	struct event event = {
+		.time = { 0, }, 
+		.data = { 1000.0, 2.0, 3.0, 4.0 }
+	};
 	
 	/* get main thread id to post messages to it */
 	mainThreadId = CmtGetMainThreadID();
@@ -21,11 +22,12 @@
    		mark = Timer();
 		
 		/* update data */
-		GetCurrentDateTime(&data[0]);
-		data[1] = data[1] + 0.1;
+		gettimeofday(&event.time, NULL);
+		//data[0] = time.tv_sec + time.tv_usec * 1e-6;
+		event.data[0] = event.data[0] + 0.1;
 		
 		/* push data into the data queue */
-		CmtWriteTSQData(dataQueue, data, 5, TSQ_INFINITE_TIMEOUT, 0);
+		CmtWriteTSQData(dataQueue, &event, 1, TSQ_INFINITE_TIMEOUT, 0);
 		
 		/* wait till next second */
    		SyncWait(mark, 1.00);