Revisão | 1c28ea63bc3a5bd76d38f8f0f141df7cd6d7beaf (tree) |
---|---|
Hora | 2013-05-25 16:19:25 |
Autor | alucky4416 <alucky4416@user...> |
Commiter | alucky4416 |
feature: add Init Button, add SIG/SLOT DIO&LCD ready -> enable Buttons.
@@ -10,7 +10,11 @@ MainWindow::MainWindow(QWidget *parent) : | ||
10 | 10 | ui->setupUi(this); |
11 | 11 | |
12 | 12 | ThLCDOut = new ThLCDOutput(this); |
13 | + connect(ThLCDOut, SIGNAL(notify_dio_ready(int)), | |
14 | + this, SLOT(slot_dio_ready(int))); | |
13 | 15 | ThLCDOut->start(); |
16 | + | |
17 | + ui->statusBar->showMessage("DIO & LCD initialize..."); | |
14 | 18 | } |
15 | 19 | |
16 | 20 | MainWindow::~MainWindow() |
@@ -22,6 +26,25 @@ MainWindow::~MainWindow() | ||
22 | 26 | delete ui; |
23 | 27 | } |
24 | 28 | |
29 | +void MainWindow::slot_dio_ready(int status) | |
30 | +{ | |
31 | + qDebug() << "DIO Ready."; | |
32 | + ui->statusBar->showMessage("Idle..."); | |
33 | + ui->pushButton_Init->setEnabled(true); | |
34 | + ui->pushButton_Clear->setEnabled(true); | |
35 | + ui->pushButton_Enter->setEnabled(true); | |
36 | +} | |
37 | + | |
38 | +void MainWindow::on_pushButton_Init_clicked() | |
39 | +{ | |
40 | + ThLCDOut->sendEvent_Init(); | |
41 | +} | |
42 | + | |
43 | +void MainWindow::on_pushButton_Clear_clicked() | |
44 | +{ | |
45 | + ThLCDOut->sendEvent_Clear(); | |
46 | +} | |
47 | + | |
25 | 48 | void MainWindow::on_pushButton_Enter_clicked() |
26 | 49 | { |
27 | 50 | if (ui->lineEdit_LCDOutputText->text().isEmpty()) { |
@@ -33,7 +56,3 @@ void MainWindow::on_pushButton_Enter_clicked() | ||
33 | 56 | } |
34 | 57 | } |
35 | 58 | |
36 | -void MainWindow::on_pushButton_Clear_clicked() | |
37 | -{ | |
38 | - ThLCDOut->sendEvent_Clear(); | |
39 | -} |
@@ -18,9 +18,11 @@ public: | ||
18 | 18 | ~MainWindow(); |
19 | 19 | |
20 | 20 | private slots: |
21 | - void on_pushButton_Enter_clicked(); | |
21 | + void slot_dio_ready(int status); | |
22 | 22 | |
23 | + void on_pushButton_Init_clicked(); | |
23 | 24 | void on_pushButton_Clear_clicked(); |
25 | + void on_pushButton_Enter_clicked(); | |
24 | 26 | |
25 | 27 | private: |
26 | 28 | Ui::MainWindow *ui; |
@@ -6,8 +6,8 @@ | ||
6 | 6 | <rect> |
7 | 7 | <x>0</x> |
8 | 8 | <y>0</y> |
9 | - <width>354</width> | |
10 | - <height>151</height> | |
9 | + <width>364</width> | |
10 | + <height>182</height> | |
11 | 11 | </rect> |
12 | 12 | </property> |
13 | 13 | <property name="windowTitle"> |
@@ -31,6 +31,9 @@ | ||
31 | 31 | </property> |
32 | 32 | </widget> |
33 | 33 | <widget class="QPushButton" name="pushButton_Enter"> |
34 | + <property name="enabled"> | |
35 | + <bool>false</bool> | |
36 | + </property> | |
34 | 37 | <property name="geometry"> |
35 | 38 | <rect> |
36 | 39 | <x>250</x> |
@@ -57,9 +60,12 @@ | ||
57 | 60 | </property> |
58 | 61 | </widget> |
59 | 62 | <widget class="QPushButton" name="pushButton_Clear"> |
63 | + <property name="enabled"> | |
64 | + <bool>false</bool> | |
65 | + </property> | |
60 | 66 | <property name="geometry"> |
61 | 67 | <rect> |
62 | - <x>70</x> | |
68 | + <x>100</x> | |
63 | 69 | <y>60</y> |
64 | 70 | <width>80</width> |
65 | 71 | <height>25</height> |
@@ -69,13 +75,29 @@ | ||
69 | 75 | <string>Clear</string> |
70 | 76 | </property> |
71 | 77 | </widget> |
78 | + <widget class="QPushButton" name="pushButton_Init"> | |
79 | + <property name="enabled"> | |
80 | + <bool>false</bool> | |
81 | + </property> | |
82 | + <property name="geometry"> | |
83 | + <rect> | |
84 | + <x>20</x> | |
85 | + <y>60</y> | |
86 | + <width>80</width> | |
87 | + <height>25</height> | |
88 | + </rect> | |
89 | + </property> | |
90 | + <property name="text"> | |
91 | + <string>Init</string> | |
92 | + </property> | |
93 | + </widget> | |
72 | 94 | </widget> |
73 | 95 | <widget class="QMenuBar" name="menuBar"> |
74 | 96 | <property name="geometry"> |
75 | 97 | <rect> |
76 | 98 | <x>0</x> |
77 | 99 | <y>0</y> |
78 | - <width>354</width> | |
100 | + <width>364</width> | |
79 | 101 | <height>26</height> |
80 | 102 | </rect> |
81 | 103 | </property> |
@@ -30,7 +30,7 @@ int ThLCDOutput::dio_init() | ||
30 | 30 | #endif |
31 | 31 | |
32 | 32 | #if DAQDRIVER_INSTALLED |
33 | - return 0; | |
33 | + return error; | |
34 | 34 | Error: |
35 | 35 | if (DAQmxFailed (error)) { |
36 | 36 | DAQmxBaseGetExtendedErrorInfo (errBuff, 2048); |
@@ -44,6 +44,7 @@ Error: | ||
44 | 44 | // printf ("DAQmxBase Error %ld: %s\n", error, errBuff); |
45 | 45 | qDebug() << "DAQmxBase Error : " << errBuff; |
46 | 46 | } |
47 | + ret = error; | |
47 | 48 | #endif |
48 | 49 | |
49 | 50 | return ret; |
@@ -261,8 +262,10 @@ void ThLCDOutput::run() | ||
261 | 262 | EventData event; |
262 | 263 | int event_id; |
263 | 264 | char text[128]; |
265 | + int err; | |
264 | 266 | |
265 | - dio_init(); | |
267 | + err = dio_init(); | |
268 | + emit notify_dio_ready(err); | |
266 | 269 | |
267 | 270 | lcd_init(); |
268 | 271 |
@@ -273,6 +276,9 @@ void ThLCDOutput::run() | ||
273 | 276 | event = EvtQue->dequeue(); |
274 | 277 | event_id = event.id; |
275 | 278 | switch(event_id) { |
279 | + case Ev_Init: | |
280 | + lcd_init(); | |
281 | + break; | |
276 | 282 | case Ev_Clear: |
277 | 283 | lcd_clear(); |
278 | 284 | break; |
@@ -292,15 +298,14 @@ void ThLCDOutput::run() | ||
292 | 298 | |
293 | 299 | dio_final(); |
294 | 300 | } |
295 | - | |
296 | -void ThLCDOutput::sendEvent_OutputText(QString text) | |
301 | +void ThLCDOutput::sendEvent_Init() | |
297 | 302 | { |
298 | 303 | EventData evt; |
299 | 304 | |
300 | - evt.id = Ev_OutputString; | |
301 | - evt.param = text; | |
305 | + evt.id = Ev_Init; | |
302 | 306 | EvtQue->enqueue(evt); |
303 | 307 | } |
308 | + | |
304 | 309 | void ThLCDOutput::sendEvent_Clear() |
305 | 310 | { |
306 | 311 | EventData evt; |
@@ -308,3 +313,12 @@ void ThLCDOutput::sendEvent_Clear() | ||
308 | 313 | evt.id = Ev_Clear; |
309 | 314 | EvtQue->enqueue(evt); |
310 | 315 | } |
316 | + | |
317 | +void ThLCDOutput::sendEvent_OutputText(QString text) | |
318 | +{ | |
319 | + EventData evt; | |
320 | + | |
321 | + evt.id = Ev_OutputString; | |
322 | + evt.param = text; | |
323 | + EvtQue->enqueue(evt); | |
324 | +} |
@@ -23,11 +23,13 @@ public: | ||
23 | 23 | ~ThLCDOutput(); |
24 | 24 | void stop(); |
25 | 25 | |
26 | - void sendEvent_OutputText(QString text); | |
26 | + void sendEvent_Init(); | |
27 | 27 | void sendEvent_Clear(); |
28 | + void sendEvent_OutputText(QString text); | |
28 | 29 | |
29 | 30 | signals: |
30 | - | |
31 | + void notify_dio_ready(int status); // dio ready signal. | |
32 | + | |
31 | 33 | public slots: |
32 | 34 | |
33 | 35 | protected: |
@@ -39,6 +41,7 @@ private: | ||
39 | 41 | // Event ID |
40 | 42 | enum { |
41 | 43 | Ev_Nop = 0, |
44 | + Ev_Init, | |
42 | 45 | Ev_Clear, |
43 | 46 | Ev_OutputString |
44 | 47 | }; |