
Qt+MinGw環境でNIDAQmxを使ったパルス生成サンプル
| Revision | 9dbb6f4aa12696e6ef6e5f54a4767c7998858bf2 (tree) |
|---|---|
| Time | 2012-11-14 21:22:06 |
| Author | arakaki <alucky4416@user...> |
| Commiter | arakaki |
FIX: lost pulseout done. TaskDone() removed to EmptyEvent Procedure.
| @@ -73,6 +73,17 @@ void DAQThread::run() | ||
| 73 | 73 | |
| 74 | 74 | while(!stopped) { |
| 75 | 75 | if (EvtQue->isEmpty()) { |
| 76 | + if (state == State_OUTPUT) { | |
| 77 | + bool32 done = 0; | |
| 78 | + DAQmxIsTaskDone(taskHandle, &done); | |
| 79 | + if (done) { | |
| 80 | + DAQmxErrChk (DAQmxClearTask (taskHandle)); | |
| 81 | + taskHandle = 0; | |
| 82 | + emit pulse_output_stopped(); | |
| 83 | + qDebug() << "done, stop pulse output."; // stop Pulse | |
| 84 | + state = State_IDLE; | |
| 85 | + } | |
| 86 | + } | |
| 76 | 87 | msleep(100); |
| 77 | 88 | continue; // Jump to Next Loop |
| 78 | 89 | } |
| @@ -115,22 +126,11 @@ void DAQThread::run() | ||
| 115 | 126 | // int32 DAQmxBaseCfgImplicitTiming (TaskHandle taskHandle, int32 sampleMode, uInt64 sampsPerChanToAcquire); |
| 116 | 127 | DAQmxErrChk (DAQmxCfgImplicitTiming (taskHandle, DAQmx_Val_ContSamps, (uInt64)0)); |
| 117 | 128 | DAQmxErrChk (DAQmxStartTask (taskHandle)); |
| 118 | - } else { | |
| 119 | - bool32 done = 0; | |
| 120 | - DAQmxIsTaskDone(taskHandle, &done); | |
| 121 | - if (done) { | |
| 122 | - DAQmxErrChk (DAQmxClearTask (taskHandle)); | |
| 123 | - taskHandle = 0; | |
| 124 | - emit pulse_output_stopped(); | |
| 125 | - qDebug() << "done, stop pulse output."; // stop Pulse | |
| 126 | - state = State_IDLE; | |
| 127 | - } | |
| 128 | 129 | } |
| 129 | 130 | break; |
| 130 | 131 | default: |
| 131 | 132 | break; |
| 132 | 133 | } |
| 133 | - msleep(100); | |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | Error: |
| @@ -71,9 +71,9 @@ void MainWindow::on_pushButton_Output_clicked() | ||
| 71 | 71 | { |
| 72 | 72 | if (flag_output_status) { |
| 73 | 73 | DaqTh->stopPulseOutput(); |
| 74 | - ui->pushButton_Output->setText("ON"); | |
| 75 | - ui->comboBox_DevName->setEnabled(true); | |
| 76 | - flag_output_status = false; | |
| 74 | +// ui->pushButton_Output->setText("ON"); | |
| 75 | +// ui->comboBox_DevName->setEnabled(true); | |
| 76 | +// flag_output_status = false; | |
| 77 | 77 | } else { |
| 78 | 78 | int mode = ui->checkBox_ContMode->isChecked() ? 1 : 0; |
| 79 | 79 | DaqTh->startPulseOutput(DevName, |
| @@ -147,5 +147,9 @@ void MainWindow::pulse_output_started() | ||
| 147 | 147 | |
| 148 | 148 | void MainWindow::pulse_output_stopped() |
| 149 | 149 | { |
| 150 | + ui->pushButton_Output->setText("ON"); | |
| 151 | + ui->comboBox_DevName->setEnabled(true); | |
| 152 | + flag_output_status = false; | |
| 153 | + | |
| 150 | 154 | ui->statusBar->showMessage("Idle..."); |
| 151 | 155 | } |