QtSDKとDAQmxBase(Linux)を使ったアナログ信号収録ストリーミング
リビジョン | 151878d4cef034cc5f0226f2c070e88cc67ed4f7 (tree) |
---|---|
日時 | 2012-08-24 18:44:11 |
作者 | arakaki <alucky4416@user...> |
コミッター | arakaki |
ADD: add DataSaveThread.
@@ -12,11 +12,13 @@ TEMPLATE = app | ||
12 | 12 | |
13 | 13 | SOURCES += main.cpp \ |
14 | 14 | mainwindow.cpp \ |
15 | - daqthread.cpp | |
15 | + daqthread.cpp \ | |
16 | + savedatathread.cpp | |
16 | 17 | |
17 | 18 | HEADERS += mainwindow.h \ |
18 | 19 | daqthread.h \ |
19 | - NIDAQmxBase.h | |
20 | + NIDAQmxBase.h \ | |
21 | + savedatathread.h | |
20 | 22 | |
21 | 23 | |
22 | 24 | FORMS += mainwindow.ui |
@@ -4,6 +4,7 @@ | ||
4 | 4 | #include <QMainWindow> |
5 | 5 | |
6 | 6 | #include "daqthread.h" |
7 | +#include "savedatathread.h" | |
7 | 8 | |
8 | 9 | namespace Ui { |
9 | 10 | class MainWindow; |
@@ -29,6 +30,8 @@ private: | ||
29 | 30 | |
30 | 31 | DAQThread *DaqTh; |
31 | 32 | bool flag_aiexec_status; |
33 | + | |
34 | + SaveDataThread *SaveDataTh; | |
32 | 35 | }; |
33 | 36 | |
34 | 37 | #endif // MAINWINDOW_H |
@@ -0,0 +1,30 @@ | ||
1 | +#include <QDebug> | |
2 | +#include <QString> | |
3 | + | |
4 | +#include "savedatathread.h" | |
5 | + | |
6 | +SaveDataThread::SaveDataThread(QObject *parent) : | |
7 | + QThread(parent) | |
8 | +{ | |
9 | + stopped = false; | |
10 | + | |
11 | + state = State_IDLE; | |
12 | + EvtQue = new QQueue<int>(); | |
13 | +} | |
14 | + | |
15 | +SaveDataThread::~SaveDataThread() | |
16 | +{ | |
17 | + delete EvtQue; | |
18 | +} | |
19 | + | |
20 | +void SaveDataThread::stop() | |
21 | +{ | |
22 | + stopped = true; | |
23 | +} | |
24 | + | |
25 | +void SaveDataThread::run() | |
26 | +{ | |
27 | + while(!stopped) { | |
28 | + msleep(100); | |
29 | + } | |
30 | +} |
@@ -0,0 +1,40 @@ | ||
1 | +#ifndef SAVEDATATHREAD_H | |
2 | +#define SAVEDATATHREAD_H | |
3 | + | |
4 | +#include <QThread> | |
5 | +#include <QQueue> | |
6 | + | |
7 | +class SaveDataThread : public QThread | |
8 | +{ | |
9 | + Q_OBJECT | |
10 | +public: | |
11 | + explicit SaveDataThread(QObject *parent = 0); | |
12 | + ~SaveDataThread(); | |
13 | + void stop(); | |
14 | + | |
15 | +signals: | |
16 | + | |
17 | + | |
18 | +public slots: | |
19 | + | |
20 | + | |
21 | +protected: | |
22 | + void run(); | |
23 | + | |
24 | +private: | |
25 | + volatile bool stopped; | |
26 | + | |
27 | + // State Machine, state Id | |
28 | + enum { State_IDLE = 0, | |
29 | + State_EXEC // SaveData Executing | |
30 | + } state; | |
31 | + // State Machine, event Id | |
32 | + enum { Ev_Nop = 0, | |
33 | + Ev_Save_Start, // start SaveData to File | |
34 | + Ev_Save_Stop // stop SaveData to File | |
35 | + }; | |
36 | + | |
37 | + QQueue<int> *EvtQue; // EventQue | |
38 | +}; | |
39 | + | |
40 | +#endif // SAVEDATATHREAD_H |