Mercurial > hg > fxanalyse
diff fake-data-provider.c @ 146:931ebae87964
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.
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 22 Jan 2014 14:45:24 +0100 |
parents | 5bba1d1c3b46 |
children | 8a94f1913b4e |
line wrap: on
line diff
--- 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 <analysis.h> #include <userint.h> #include <utility.h> #include <future.h> #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;