~janisozaur/janisozaur-inz/ogl_viewer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef SAMPLINGTHREAD_H
#define SAMPLINGTHREAD_H

#include <QThread>
#include <QVector>
#include <QMutexLocker>
#include <QFile>
#include <QSerialPort>
#include <QTime>

using namespace TNX;

#include "sample.h"

class SamplingThread : public QThread
{
	Q_OBJECT
public:
	explicit SamplingThread(QObject *parent = 0);
	~SamplingThread();
	QVector<Sample> takeSamples();
	void open(QString fileName, QPortSettings::BaudRate baudRate);
	void close();

protected:
	void sample(double elapsed);
	void append(Sample mySample);
	void append(const QByteArray &data, double elapsed);
	void timerEvent(QTimerEvent *event);
	void run();

signals:
	void dataArrived();

private:
	QVector<Sample> samples;
	QByteArray mTempData;
	QMutex mSampleMutex, mStopMutex;
	volatile bool mRun;
	QSerialPort *mpSerport;
	int mTimerId;
	QTime mTime;
};

#endif // SAMPLINGTHREAD_H