• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

QtSDK と NI-DAQmxBase (Linux) を使った単純なサンプル


Commit MetaInfo

Revisão1ed5db835fc216132340089c6329066ffb7048e1 (tree)
Hora2012-08-29 17:13:46
Autorarakaki <alucky4416@user...>
Commiterarakaki

Mensagem de Log

CHG: add DevName combobox Widget for selectable DeviceName.

Mudança Sumário

Diff

--- a/daqthread.cpp
+++ b/daqthread.cpp
@@ -25,8 +25,11 @@ void DAQThread::stop()
2525 stopped = true;
2626 }
2727
28-void DAQThread::startPulseOutput(float freq, float duty)
28+void DAQThread::startPulseOutput(QString &devname, float freq, float duty)
2929 {
30+ QString tmpname = devname + "/ctr0";
31+ // qDebug() << "counter name is " << tmpname;
32+ ctrname = tmpname.toLocal8Bit();
3033 pulse_freq = freq;
3134 pulse_duty = (float64)(duty / 100.0);
3235 EvtQue->enqueue(Ev_Start);
@@ -48,9 +51,10 @@ void DAQThread::run()
4851 {
4952 int32 error = 0;
5053 char errBuff[2048] = { '\0' };
51- char ctrname[128] = "Dev1/ctr0";
54+// char ctrname[128] = "Dev1/ctr0";
5255
5356 taskHandle = 0;
57+ ctrname = "Dev1/ctr0";
5458 pulse_freq = (float64)1000.0;
5559 pulse_duty = (float64)0.50; // 0.50 is 50%
5660 int event = 0;
--- a/daqthread.h
+++ b/daqthread.h
@@ -15,7 +15,7 @@ public:
1515 ~DAQThread();
1616 void stop();
1717
18- void startPulseOutput(float freq, float duty);
18+ void startPulseOutput(QString &devname, float freq, float duty);
1919 void stopPulseOutput();
2020 void changePulseOutput(float freq, float duty);
2121
@@ -35,6 +35,7 @@ private:
3535 volatile bool stopped;
3636
3737 TaskHandle taskHandle; // Daqmxbase task handle
38+ QByteArray ctrname; // = "Dev1/ctr0";
3839 float64 pulse_freq;
3940 float64 pulse_duty;
4041
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -4,12 +4,22 @@
44 #include <QDebug>
55 #include <QMessageBox>
66
7+#include <QRegExp>
8+#include <QRegExpValidator>
9+
710 MainWindow::MainWindow(QWidget *parent) :
811 QMainWindow(parent),
912 ui(new Ui::MainWindow)
1013 {
1114 ui->setupUi(this);
1215
16+ QRegExp regexpDevName("Dev[1-9][0-9]*");
17+ ui->comboBox_DevName->setValidator(new QRegExpValidator(regexpDevName, this));
18+ ui->comboBox_DevName->setEditable(true);
19+ ui->comboBox_DevName->setEnabled(true);
20+ ui->comboBox_DevName->setCurrentIndex(0);
21+ DevName = "Dev1";
22+
1323 ui->statusBar->showMessage("DaqmxBase Initialize...");
1424 ui->pushButton_Output->setEnabled(false);
1525 ui->pushButton_Output->setText("ON");
@@ -49,15 +59,23 @@ MainWindow::~MainWindow()
4959 delete ui;
5060 }
5161
62+void MainWindow::on_comboBox_DevName_editTextChanged(const QString &arg1)
63+{
64+ DevName = arg1;
65+// qDebug() << QString("combobox_Devname is %1").arg(DevName);
66+}
67+
5268 void MainWindow::on_pushButton_Output_clicked()
5369 {
5470 if (flag_output_status) {
5571 DaqTh->stopPulseOutput();
5672 ui->pushButton_Output->setText("ON");
73+ ui->comboBox_DevName->setEnabled(true);
5774 flag_output_status = false;
5875 } else {
59- DaqTh->startPulseOutput((float)ui->doubleSpinBox_Freq->value(), (float)ui->doubleSpinBox_Duty->value());
76+ DaqTh->startPulseOutput(DevName, (float)ui->doubleSpinBox_Freq->value(), (float)ui->doubleSpinBox_Duty->value());
6077 ui->pushButton_Output->setText("OFF");
78+ ui->comboBox_DevName->setEnabled(false);
6179 flag_output_status = true;
6280 }
6381 }
@@ -113,5 +131,3 @@ void MainWindow::pulse_output_stopped()
113131 {
114132 ui->statusBar->showMessage("Idle...");
115133 }
116-
117-
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -18,6 +18,8 @@ public:
1818 ~MainWindow();
1919
2020 private slots:
21+ void on_comboBox_DevName_editTextChanged(const QString &arg1);
22+
2123 void on_pushButton_Output_clicked();
2224
2325 void on_doubleSpinBox_Freq_valueChanged(double arg1);
@@ -35,11 +37,13 @@ private slots:
3537 void pulse_output_stopped();
3638
3739
40+
3841 private:
3942 Ui::MainWindow *ui;
4043
4144 DAQThread *DaqTh;
4245 bool flag_output_status;
46+ QString DevName;
4347 };
4448
4549 #endif // MAINWINDOW_H
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -6,8 +6,8 @@
66 <rect>
77 <x>0</x>
88 <y>0</y>
9- <width>500</width>
10- <height>439</height>
9+ <width>562</width>
10+ <height>500</height>
1111 </rect>
1212 </property>
1313 <property name="windowTitle">
@@ -18,7 +18,7 @@
1818 <property name="geometry">
1919 <rect>
2020 <x>80</x>
21- <y>200</y>
21+ <y>260</y>
2222 <width>101</width>
2323 <height>31</height>
2424 </rect>
@@ -43,7 +43,7 @@
4343 <property name="geometry">
4444 <rect>
4545 <x>40</x>
46- <y>40</y>
46+ <y>110</y>
4747 <width>121</width>
4848 <height>18</height>
4949 </rect>
@@ -62,7 +62,7 @@
6262 <property name="geometry">
6363 <rect>
6464 <x>280</x>
65- <y>190</y>
65+ <y>250</y>
6666 <width>141</width>
6767 <height>51</height>
6868 </rect>
@@ -75,7 +75,7 @@
7575 <property name="geometry">
7676 <rect>
7777 <x>80</x>
78- <y>310</y>
78+ <y>370</y>
7979 <width>101</width>
8080 <height>31</height>
8181 </rect>
@@ -100,7 +100,7 @@
100100 <property name="geometry">
101101 <rect>
102102 <x>280</x>
103- <y>170</y>
103+ <y>230</y>
104104 <width>101</width>
105105 <height>18</height>
106106 </rect>
@@ -119,7 +119,7 @@
119119 <property name="geometry">
120120 <rect>
121121 <x>40</x>
122- <y>260</y>
122+ <y>320</y>
123123 <width>81</width>
124124 <height>18</height>
125125 </rect>
@@ -151,7 +151,7 @@
151151 <property name="geometry">
152152 <rect>
153153 <x>40</x>
154- <y>280</y>
154+ <y>340</y>
155155 <width>160</width>
156156 <height>19</height>
157157 </rect>
@@ -173,7 +173,7 @@
173173 <property name="geometry">
174174 <rect>
175175 <x>30</x>
176- <y>60</y>
176+ <y>120</y>
177177 <width>181</width>
178178 <height>131</height>
179179 </rect>
@@ -216,7 +216,7 @@
216216 <property name="geometry">
217217 <rect>
218218 <x>290</x>
219- <y>250</y>
219+ <y>310</y>
220220 <width>191</width>
221221 <height>20</height>
222222 </rect>
@@ -229,7 +229,7 @@
229229 <property name="geometry">
230230 <rect>
231231 <x>60</x>
232- <y>170</y>
232+ <y>230</y>
233233 <width>21</width>
234234 <height>18</height>
235235 </rect>
@@ -242,7 +242,7 @@
242242 <property name="geometry">
243243 <rect>
244244 <x>170</x>
245- <y>170</y>
245+ <y>230</y>
246246 <width>61</width>
247247 <height>18</height>
248248 </rect>
@@ -251,13 +251,65 @@
251251 <string>1000000</string>
252252 </property>
253253 </widget>
254+ <widget class="QComboBox" name="comboBox_DevName">
255+ <property name="geometry">
256+ <rect>
257+ <x>40</x>
258+ <y>60</y>
259+ <width>121</width>
260+ <height>28</height>
261+ </rect>
262+ </property>
263+ <property name="editable">
264+ <bool>true</bool>
265+ </property>
266+ <item>
267+ <property name="text">
268+ <string>Dev1</string>
269+ </property>
270+ </item>
271+ <item>
272+ <property name="text">
273+ <string>Dev2</string>
274+ </property>
275+ </item>
276+ <item>
277+ <property name="text">
278+ <string>Dev3</string>
279+ </property>
280+ </item>
281+ <item>
282+ <property name="text">
283+ <string>Dev4</string>
284+ </property>
285+ </item>
286+ </widget>
287+ <widget class="QLabel" name="label_8">
288+ <property name="geometry">
289+ <rect>
290+ <x>40</x>
291+ <y>40</y>
292+ <width>121</width>
293+ <height>18</height>
294+ </rect>
295+ </property>
296+ <property name="font">
297+ <font>
298+ <weight>75</weight>
299+ <bold>true</bold>
300+ </font>
301+ </property>
302+ <property name="text">
303+ <string>DevName</string>
304+ </property>
305+ </widget>
254306 </widget>
255307 <widget class="QMenuBar" name="menuBar">
256308 <property name="geometry">
257309 <rect>
258310 <x>0</x>
259311 <y>0</y>
260- <width>500</width>
312+ <width>562</width>
261313 <height>26</height>
262314 </rect>
263315 </property>