diff fake-data-provider.c @ 88:9b7588cd4013

Move data acquisition into separate thread The data acquisition thread transfers data to the main thread trough a Thread Safe Queue. This separation allows for making the data acquisition system pluggable. The old file based communication to the KK counter is implemented along with a very simple fake data provider.
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Thu, 21 Mar 2013 18:24:45 +0100
parents
children 4102fe614df2
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fake-data-provider.c	Thu Mar 21 18:24:45 2013 +0100
@@ -0,0 +1,35 @@
+/* FXAnalise fake data provider */
+
+#include <userint.h>
+#include <utility.h>
+
+/* data acquisition flag */
+extern int acquiring;
+/* data queue */
+extern CmtTSQHandle dataQueue;
+
+int CVICALLBACK FakeDataProvider (void *functionData)
+{
+	int mainThreadId;
+	double mark;
+	double data[5] = {0.0, 10000.0, 2.0, 3.0, 4.0};
+	
+	/* get main thread id to post messages to it */
+	mainThreadId = CmtGetMainThreadID();
+	
+	while (acquiring) {
+   		mark = Timer();
+		
+		/* update data */
+		GetCurrentDateTime(&data[0]);
+		data[1] = data[1] + 0.1;
+		
+		/* push data into the data queue */
+		CmtWriteTSQData(dataQueue, data, 5, TSQ_INFINITE_TIMEOUT, 0);
+		
+		/* wait till next second */
+   		SyncWait(mark, 1.00);
+	}
+	
+	return 0;
+}