summaryrefslogtreecommitdiffhomepage
path: root/tracker-test/test.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-19 13:58:41 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-19 13:58:41 +0200
commit70d5fdedd5fd6d88d2d7453ac49af6aa75cbd5fb (patch)
tree012f84a050764a3b651e752791d92a0f56d60f53 /tracker-test/test.cpp
parenta3e8c8bae2467b7fad43b9d6068defb7b54dd534 (diff)
tracker/test: test emitting NaN values
Diffstat (limited to 'tracker-test/test.cpp')
-rw-r--r--tracker-test/test.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp
index 32ff5336..b6cc742e 100644
--- a/tracker-test/test.cpp
+++ b/tracker-test/test.cpp
@@ -32,6 +32,10 @@ void FTNoIR_Tracker::start_tracker(QFrame*)
t.start();
}
+#ifdef EMIT_NAN
+# include <cstdlib>
+#endif
+
void FTNoIR_Tracker::data(double *data)
{
using std::fmod;
@@ -42,28 +46,36 @@ void FTNoIR_Tracker::data(double *data)
const double dt = t.elapsed_seconds();
t.start();
- for (int i = 0; i < 6; i++)
+#ifdef EMIT_NAN
+ if ((rand()%4) == 0)
{
- double x = fmod(last_x[i] + incr[i] * d2r * dt,
- 2 * pi);
- last_x[i] = x;
-
- if (i >= 3)
+ for (int i = 0; i < 6; i++)
+ data[i] = 0./0.;
+ }
+ else
+#endif
+ for (int i = 0; i < 6; i++)
{
-#if 0
- if (x > pi + pi/2)
- x -= pi;
- else if (x > pi/2 && x < pi)
- x += pi;
+ double x = fmod(last_x[i] + incr[i] * d2r * dt,
+ 2 * pi);
+ last_x[i] = x;
+
+ if (i >= 3)
+ {
+#ifdef DISCONTINUITY
+ if (x > pi + pi/2)
+ x -= pi;
+ else if (x > pi/2 && x < pi)
+ x += pi;
#endif
- data[i] = sin(x) * 180;
- }
- else
- {
- data[i] = sin(x) * 100;
+ data[i] = sin(x) * 180;
+ }
+ else
+ {
+ data[i] = sin(x) * 100;
+ }
}
- }
}
TrackerControls::TrackerControls()