view data-provider.h @ 127:2479ad53982b

User iterface tweaks. Better thousands separators number formatting function.
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 13 Dec 2013 17:04:28 +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