# HG changeset patch # User Daniele Nicolodi # Date 1434469110 -7200 # Node ID a40c8af8b0288147885e138ce2e878b29c0d7b24 # Parent 8d9a4c5eb7a48086196f98fae5fd71d1107c970c Improve fake data generator used in testing diff -r 8d9a4c5eb7a4 -r a40c8af8b028 fake-data-provider.c --- a/fake-data-provider.c Tue Jun 16 17:19:15 2015 +0200 +++ b/fake-data-provider.c Tue Jun 16 17:38:30 2015 +0200 @@ -8,13 +8,15 @@ #include "data-provider.h" #define PERIOD 1.0 -#define INCREMENT 0.1 -#define NOISE 0.25 +#define NOISE 0.01 +#define SLOPE 0.1 +#define BADPOINTS 0.01 +#define UNLOCK 100 int CVICALLBACK FakeDataProvider (void *functionData) { - int i, mainThreadId; + int i, mainThreadId, random, count = 0; double mark; struct event event = { 0, }; double f[NCHAN] = { 55000000.0, 10000.0, 10000.0, 275000.0 }; @@ -28,16 +30,34 @@ /* update data */ gettimeofday(&event.time, NULL); - f[0] += INCREMENT; for (i = 0; i < NCHAN; i++) event.data[i] = f[i]; +#ifdef SLOPE + /* add frequency drift */ + f[0] += SLOPE; + f[2] += SLOPE * 10; +#endif + #ifdef NOISE /* add noise */ GaussNoise(NCHAN, NOISE, -1, noise); for (i = 0; i < NCHAN; i++) event.data[i] += noise[i]; #endif + +#ifdef BADPOINTS + /* simulate bad points */ + random = rand(); + if (random > BADPOINTS * RAND_MAX) + event.data[i] += 1000 * random; +#endif + +#ifdef UNLOCK + /* simulate unlock */ + if (count > UNLOCK) + f[0] += 10; +#endif /* push data into the data queue */ CmtWriteTSQData(dataQueue, &event, 1, TSQ_INFINITE_TIMEOUT, 0); @@ -46,5 +66,6 @@ SyncWait(mark, PERIOD); } + count++; return 0; }