view data-provider.h @ 129:24db0c2d5219

Add more N3 measurement debug information in the log
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 17 Dec 2013 12:26:29 +0100
parents 8b90fbba59ef
children be87c8e78266
line wrap: on
line source

#ifndef __DATA_PROVIDER_H__
#define __DATA_PROVIDER_H__

#include <future.h>

/* data acquisition flag */
extern int acquiring;

/* data queue */
extern CmtTSQHandle dataQueue;

/* callback receiving messages in the main thread */
void CVICALLBACK MessageCB (void *callbackData);

/* data acquisition event */
struct event {
	struct timeval time;
	double data[4];
};

/* message buffer */
#define DATA_PROVIDER_MSGLEN 256
#define DATA_PROVIDER_MSGNUM 16
static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM];
static unsigned int messageid = 0;

#define SendMessage(threadId, ...)                                     \
	do {                                                               \
		char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM];  \
		snprintf(message, DATA_PROVIDER_MSGLEN - 1, ##__VA_ARGS__);    \
		PostDeferredCallToThread(MessageCB, message, threadId);        \
	} while (0)

#endif