# HG changeset patch # User Daniele Nicolodi # Date 1390398324 -3600 # Node ID 931ebae87964cad2d068eeb813c3c5172a8a7605 # Parent ceac0c01661f1ebca51e66428fdf5cd5be94cb34 Tweaks to FakeDataProvider Make generated counter data more realistic. Add the possibility to add noise to the generated data. Make the sampling period easier to change. diff -r ceac0c01661f -r 931ebae87964 fake-data-provider.c --- a/fake-data-provider.c Wed Jan 22 14:45:24 2014 +0100 +++ b/fake-data-provider.c Wed Jan 22 14:45:24 2014 +0100 @@ -1,19 +1,24 @@ /* FXAnalise fake data provider */ +#include #include #include #include #include "data-provider.h" +#define PERIOD 1.0 +#define INCREMENT 0.1 +#define NOISE 0.25 + + int CVICALLBACK FakeDataProvider (void *functionData) { - int mainThreadId; + int i, mainThreadId; double mark; - struct event event = { - .time = { 0, }, - .data = { 55000000.0, 2.0, 3.0, 4.0 } - }; + struct event event = { 0, }; + double f[NCHAN] = { 55000000.0, 10000.0, 10000.0, 275000.0 }; + double noise[NCHAN]; /* get main thread id to post messages to it */ mainThreadId = CmtGetMainThreadID(); @@ -23,13 +28,22 @@ /* update data */ gettimeofday(&event.time, NULL); - event.data[0] += 0.1; + f[0] += INCREMENT; + for (i = 0; i < NCHAN; i++) + event.data[i] = f[i]; + +#ifdef NOISE + /* add noise */ + GaussNoise(NCHAN, NOISE, -1, noise); + for (i = 0; i < NCHAN; i++) + event.data[i] += noise[i]; +#endif /* push data into the data queue */ CmtWriteTSQData(dataQueue, &event, 1, TSQ_INFINITE_TIMEOUT, 0); /* wait till next second */ - SyncWait(mark, 1.00); + SyncWait(mark, PERIOD); } return 0;