annotate data-provider.h @ 99:dad4414051c4

Add 'KK_FX80E.dll' to the distributed files
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 26 Mar 2013 18:23:29 +0100
parents 99cbe2b57530
children 8b90fbba59ef
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 */
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
22 static char messages[256][16];
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
23 static unsigned int messageid = 0;
91
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
24
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 #define SendMessage(threadId, ...) \
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
26 do { \
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
27 char *message = messages[messageid++ % 16]; \
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
28 snprintf(message, sizeof(message), ##__VA_ARGS__); \
99cbe2b57530 Allow up to 16 messages to pile up in the communication between threads
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 91
diff changeset
29 PostDeferredCallToThread(MessageCB, message, threadId); \
91
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
30 } while (0)
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
31
4102fe614df2 Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
32 #endif