51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#ifndef PLOTFILE_H
|
|
#define PLOTFILE_H
|
|
|
|
#include <KLib/misc/gnuplot/Gnuplot.h>
|
|
#include <KLib/misc/gnuplot/GnuplotPlot.h>
|
|
#include <KLib/misc/gnuplot/GnuplotPlotElementLines.h>
|
|
|
|
#include "pca/Data.h"
|
|
#include "pca/Settings.h"
|
|
|
|
void runPlot() {
|
|
|
|
// read all sensor-values within the given data-file
|
|
Recording rec = SensorReader::read("/mnt/firma/kunden/HandyGames/datenOK/jumpingjack/jumpingjack_gl_5_subject_3_left.txt");
|
|
|
|
// get the value-interpolator
|
|
K::Interpolator<uint64_t, SensorAccelerometer> intAccel;
|
|
for (const auto& val : rec.accel.values) {intAccel.add(val.ts, val.val);}
|
|
intAccel.makeRelative();
|
|
|
|
K::Gnuplot gp;
|
|
K::GnuplotPlot plot;
|
|
K::GnuplotPlotElementLines lines[3];
|
|
plot.add(&lines[0]); lines[0].setColorHex("#0000ff");
|
|
plot.add(&lines[1]); lines[1].setColorHex("#00FF00");
|
|
plot.add(&lines[2]); lines[2].setColorHex("#ff0000");
|
|
|
|
for (int ms = 0; ms < 20000; ms += 50) {
|
|
SensorAccelerometer sa = intAccel.get(ms);
|
|
lines[0].add(K::GnuplotPoint2(ms, sa.x));
|
|
lines[1].add(K::GnuplotPoint2(ms, sa.y));
|
|
lines[2].add(K::GnuplotPoint2(ms, sa.z));
|
|
}
|
|
|
|
gp.draw(plot);
|
|
|
|
std::ofstream out("/tmp/1.dat");
|
|
out << gp.getBuffer();
|
|
out.close();
|
|
|
|
|
|
gp.flush();
|
|
|
|
sleep(1000);
|
|
|
|
|
|
}
|
|
|
|
#endif // PLOTFILE_H
|
|
|