comparison fake-data-provider.c @ 91:4102fe614df2

Fix timestamping. Cleanup data providers
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 22 Mar 2013 16:32:15 +0100
parents 9b7588cd4013
children 6fd67aa13d10
comparison
equal deleted inserted replaced
90:c9aec93005a4 91:4102fe614df2
1 /* FXAnalise fake data provider */ 1 /* FXAnalise fake data provider */
2 2
3 #include <userint.h> 3 #include <userint.h>
4 #include <utility.h> 4 #include <utility.h>
5 #include <future.h>
5 6
6 /* data acquisition flag */ 7 #include "data-provider.h"
7 extern int acquiring;
8 /* data queue */
9 extern CmtTSQHandle dataQueue;
10 8
11 int CVICALLBACK FakeDataProvider (void *functionData) 9 int CVICALLBACK FakeDataProvider (void *functionData)
12 { 10 {
13 int mainThreadId; 11 int mainThreadId;
14 double mark; 12 double mark;
15 double data[5] = {0.0, 10000.0, 2.0, 3.0, 4.0}; 13 struct event event = {
14 .time = { 0, },
15 .data = { 1000.0, 2.0, 3.0, 4.0 }
16 };
16 17
17 /* get main thread id to post messages to it */ 18 /* get main thread id to post messages to it */
18 mainThreadId = CmtGetMainThreadID(); 19 mainThreadId = CmtGetMainThreadID();
19 20
20 while (acquiring) { 21 while (acquiring) {
21 mark = Timer(); 22 mark = Timer();
22 23
23 /* update data */ 24 /* update data */
24 GetCurrentDateTime(&data[0]); 25 gettimeofday(&event.time, NULL);
25 data[1] = data[1] + 0.1; 26 //data[0] = time.tv_sec + time.tv_usec * 1e-6;
27 event.data[0] = event.data[0] + 0.1;
26 28
27 /* push data into the data queue */ 29 /* push data into the data queue */
28 CmtWriteTSQData(dataQueue, data, 5, TSQ_INFINITE_TIMEOUT, 0); 30 CmtWriteTSQData(dataQueue, &event, 1, TSQ_INFINITE_TIMEOUT, 0);
29 31
30 /* wait till next second */ 32 /* wait till next second */
31 SyncWait(mark, 1.00); 33 SyncWait(mark, 1.00);
32 } 34 }
33 35