view 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 source

/* 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;
}