annotate data-provider.h @ 140:3f7eef731ccc

Adjust log messages
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 22 Jan 2014 14:45:22 +0100
parents 8b90fbba59ef
children be87c8e78266
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1 #ifndef __DATA_PROVIDER_H__
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2 #define __DATA_PROVIDER_H__
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
3
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
4 #include <future.h>
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
5
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
6 /* data acquisition flag */
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
7 extern int acquiring;
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
8
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
9 /* data queue */
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
10 extern CmtTSQHandle dataQueue;
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
11
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
12 /* callback receiving messages in the main thread */
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
13 void CVICALLBACK MessageCB (void *callbackData);
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
14
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
15 /* data acquisition event */
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
16 struct event {
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
17 struct timeval time;
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
18 double data[4];
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
19 };
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
20
98
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
21 /* message buffer */
101
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
22 #define DATA_PROVIDER_MSGLEN 256
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
23 #define DATA_PROVIDER_MSGNUM 16
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
24 static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM];
98
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
25 static unsigned int messageid = 0;
91
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
26
101
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
27 #define SendMessage(threadId, ...) \
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
28 do { \
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
29 char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM]; \
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
30 snprintf(message, DATA_PROVIDER_MSGLEN - 1, ##__VA_ARGS__); \
8b90fbba59ef Fix buffer size in SendMessage macro
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 98
diff changeset
31 PostDeferredCallToThread(MessageCB, message, threadId); \
91
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
32 } while (0)
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
33
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
34 #endif