Mercurial > hg > fxanalyse
view fake-data-provider.c @ 268:ec4462c7f8b7
Extensive cleanup of beatnote specific variables
Reorganize the beatnote specific variables in arrays indexed by the
beatnote enum constants LO, HG, SR. Also reorganize DDS frequency
related variables in arrays indexed by the DDS channel number.
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 09 Jul 2015 23:11:00 +0200 |
parents | a40c8af8b028 |
children |
line wrap: on
line source
/* 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 NOISE 0.01 #define SLOPE 0.1 #define BADPOINTS 0.01 #define UNLOCK 100 int CVICALLBACK FakeDataProvider (void *functionData) { int i, mainThreadId, random, count = 0; double mark; 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(); while (acquiring) { mark = Timer(); /* update data */ gettimeofday(&event.time, NULL); 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); /* wait till next second */ SyncWait(mark, PERIOD); } count++; return 0; }