#include "mainwindow.h" #include "ui_mainwindow.h" QThread* MainWindow::_uiThread; MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); _uiThread = QThread::currentThread(); this->setFixedSize(this->width(), this->height()); _settings = new QSettings("Hasis", "HwTester"); _usd = new UltraSoundDevice(); _timeout = new QTimer; _bCtrl = new BoardsCtrlMngt(_usd->device); _healStatus = new HealthStatus; _supRbValue = new SupervisorRbValue; _faultStatus = new MpsFaultStatus; _version = new FpgaCodeVersion; _vec = new StatusVec; _emul = new EmulatorProperties; _prb = new PrbCase; movie = new QMovie("/home/hasis/Desktop/Develop_HardwareTest/gifs/Glass lines.gif"); ui->l_programming->hide(); _colorMap = new QCPColorMap(ui->plot_2->xAxis, ui->plot_2->yAxis); ui->plot_2->setInteractions(QCP::iRangeZoom | QCP::iRangeDrag); ui->plot_2->axisRect()->setupFullAxesBox(true); ui->plot_2->xAxis->setLabel("Line"); ui->plot_2->yAxis->setLabel("Point"); ui->tb_fpgaBit->setReadOnly(true); ui->rbtn_reg->setChecked(_settings->value(REG_ACCESS_SEL).value()); ui->rbtn_offset->setChecked(!_settings->value(REG_ACCESS_SEL).value()); ui->tb_fpgaBit->setText(_settings->value(FPGA_FILE_PATH).value()); ui->tb_scenFilesPath->setText(_settings->value(SCENARIO_FILE_PATH).value()); ui->tb_biteFilesPath->setText(_settings->value(BITE_FILE_PATH).value()); ui->tb_trxRomId->setPlaceholderText("id(hex)"); ui->tb_trxRomInfo->setPlaceholderText("info"); ui->tb_mpsRomId->setPlaceholderText("id(hex)"); ui->tb_mpsRomInfo->setPlaceholderText("info"); ui->tb_prbCtrlRomId->setPlaceholderText("id(hex)"); ui->tb_prbCtrlRomInfo->setPlaceholderText("info"); ui->tb_prbRomIdRead->setPlaceholderText("id(hex)"); ui->tb_prbRomImpulseRead->setPlaceholderText("impulse"); ui->tb_scenInfo->setPlaceholderText("Scenario Information"); connect(ui->action_Exit, &QAction::triggered, this, &MainWindow::exitApp); connect(this, &MainWindow::showMessage, this, &MainWindow::newMessage); connect(this, &MainWindow::connectedPrbChange, this, &MainWindow::getPrbChange); connect(this, &MainWindow::frameLostCall, this, &MainWindow::getFrameLost); connect(_timeout, &QTimer::timeout, this, &MainWindow::timeout); connect(this, &MainWindow::scenarioReady, this, &MainWindow::setScenario); connect(this, &MainWindow::labelState, this, &MainWindow::getLabelState); connect(this, &MainWindow::fpgaProgrammer, this, &MainWindow::getFpgaProgrammer); connect(&biteLogWatcher, &QFutureWatcher::finished, this, &MainWindow::biteLogThreadFinished); connect(&dmaLogWatcher, &QFutureWatcher::finished, this, &MainWindow::dmaLogThreadFinished); connect(this, &MainWindow::programmingGif, this, &MainWindow::getProgrammingGif); //////////////////////// DMA Packet Connections ////////////////////////////// connect(&_trx, &TrxBoard::sendFramePacket, this, &MainWindow::getFramePacket); connect(this, &MainWindow::sendLogCount, this, &MainWindow::catchLogCount); connect(this, &MainWindow::twoDReady, this, &MainWindow::show2d, Qt::BlockingQueuedConnection); connect(this, &MainWindow::threeDReady, this, &MainWindow::show3d, Qt::BlockingQueuedConnection); /////////////////// Scenario Verification Connections ///////////////////////// connect(&_trx, &TrxBoard::sramBinaryCreateFlag, this, &MainWindow::getSramBinaryCreateFlag); connect(&_trx, &TrxBoard::registerCsvCompareFlag, this, &MainWindow::getRegisterCsvCompareFlag); connect(&_trx, &TrxBoard::sramVerifyMessage, this, &MainWindow::getSramVerifyMessage); ui->btn_updateRdbackValue->setText(UPDATE); dmaLogLayoutVisible(false); _dmaLog = false; _dmaRun = false; _fpsFlag = false; _dmaShow = false; _getPacket = false; _frameCount = 0; setAfeConfig(); try { _trx.init(); } catch(SonoException& e) { qDebug() << e.what(); } _timeout->start(1000); //////////////////////////// First Time Probe Detection ////////////////////////////// #ifdef MPS_BOARD emit connectedPrbChange(); #endif QFont fontTitle; fontTitle.setBold(true); fontTitle.setItalic(true); ui->table_probe->verticalHeaderItem(0)->setFont(fontTitle); ui->table_probe->horizontalHeaderItem(0)->setFont(fontTitle); ui->table_probe->horizontalHeaderItem(1)->setFont(fontTitle); ui->table_probe->horizontalHeaderItem(2)->setFont(fontTitle); ui->table_probe->horizontalHeaderItem(3)->setFont(fontTitle); } MainWindow::~MainWindow() { delete ui; delete _settings; delete _usd; delete _timeout; delete _healStatus; delete _bCtrl; delete _supRbValue; delete _faultStatus; delete _version; delete _vec; delete _emul; delete movie; } /*************************************************************************************************/ void MainWindow::timeout() { fps =static_cast(float_t(_frameCount)/(float_t(_timeout->interval())/1000.0f)); if (ui->chk_continuousShowing->isChecked() || _fpsFlag) { ui->l_frameTime->setText(QString::number(fpsBuf,'g',3) + " fps"); } else ui->l_frameTime->setText(QString::number(fps,'g',3) + " fps"); _frameCount=0; _fpsFlag = false; auto pcie_pid = _trx.deviceId(); auto pcie_vid = _trx.vendorId(); auto pcie_id = (pcie_pid << 16) | pcie_vid; ui->l_PCIeID->setText(QString::number(pcie_id, 16)); delay(10); _trx.getHealthStatus(_healStatus); delay(10); /******************* System Monitoring *********************/ float tempSensor = _healStatus->systemTemperature; ui->l_Temp->setText(QString("%1").arg(static_cast(tempSensor))); delay(10); auto adcCh1 = _healStatus->adcMon->mon12Vin; ui->l_adcCh1->setText(QString("%1").arg(static_cast(adcCh1))); delay(10); auto adcCh2 = _healStatus->adcMon->mon5Vin; ui->l_adcCh2->setText(QString("%1").arg(static_cast(adcCh2))); delay(10); auto adcCh3 = _healStatus->adcMon->prbZeroEncoder; ui->l_adcCh3->setText(QString("%1").arg(static_cast(adcCh3))); delay(10); auto adcCh4 = _healStatus->adcMon->prbCtrl3P3V; ui->l_adcCh4->setText(QString("%1").arg(static_cast(adcCh4))); delay(10); auto adcCh5 = _healStatus->adcMon->afeVcntlp; ui->l_adcCh5->setText(QString("%1").arg(static_cast(adcCh5))); delay(10); auto adcCh6 = _healStatus->adcMon->mon3P3V; ui->l_adcCh6->setText(QString("%1").arg(static_cast(adcCh6))); delay(10); auto adcCh7 = _healStatus->adcMon->monAfeA1P8V; ui->l_adcCh7->setText(QString("%1").arg(static_cast(adcCh7))); delay(10); auto adcCh8 = _healStatus->adcMon->monAfeD1P8V; ui->l_adcCh8->setText(QString("%1").arg(static_cast(adcCh8))); delay(10); /******************* Power Good *********************/ auto regAPg = _healStatus->voltsPg->regulatorA; ui->l_pgRegA->setText(enum2String(regAPg)); delay(10); auto regBPg = _healStatus->voltsPg->regulatorB; ui->l_pgRegB->setText(enum2String(regBPg)); delay(10); auto pg12v = _healStatus->voltsPg->mon12Vin; ui->l_pg12Vin->setText(enum2String(pg12v)); delay(10); auto pg5v = _healStatus->voltsPg->mon5Vin; ui->l_pg5Vin->setText(enum2String(pg5v)); delay(10); auto Pg3P3 = _healStatus->voltsPg->mon3P3V; ui->l_pg3P3->setText(enum2String(Pg3P3)); delay(10); auto pgAvdd = _healStatus->voltsPg->monAfeA1P8V; ui->l_pg1P8Avdd->setText(enum2String(pgAvdd)); delay(10); auto pgDvdd = _healStatus->voltsPg->monAfeD1P8V; ui->l_pg1P8Dvdd->setText(enum2String(pgDvdd)); delay(10); auto pgPrbCtrl = _healStatus->voltsPg->prbCtrl3P3V; ui->l_pgPrbCtrl3P3->setText(enum2String(pgPrbCtrl)); delay(10); /******************* Status Vector *********************/ _trx.getTrxStatus(_vec); delay(10); bool pgErr = _vec->pgErr; ui->l_pg->setText(QVariant(pgErr).toString()); auto color = pgErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pg, color); delay(10); bool mpsErr = _vec->mpsErr; ui->l_mps->setText(QVariant(mpsErr).toString()); color = mpsErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_mps, color); delay(10); bool frameLost = _vec->frameLost; ui->l_frameLost->setText(QVariant(frameLost).toString()); color = frameLost ? Qt::red : Qt::green; changeLabelTextColor(ui->l_frameLost, color); delay(10); bool fanFault = _vec->fanFault; ui->l_fan->setText(QVariant(fanFault).toString()); color = fanFault ? Qt::red : Qt::green; changeLabelTextColor(ui->l_fan, color); delay(10); bool pulserThd = _vec->pulserThd; ui->l_pulserThd->setText(QVariant(pulserThd).toString()); color = pulserThd ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pulserThd, color); delay(10); bool scenGtErr = _vec->scenGtErr; ui->l_scenGt->setText(QVariant(scenGtErr).toString()); color = scenGtErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenGt, color); delay(10); bool scenPriErr = _vec->scenPriErr; ui->l_scenPri->setText(QVariant(scenPriErr).toString()); color = scenPriErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenPri, color); delay(10); bool thermalErr = _vec->thermalErr; ui->l_thermal->setText(QVariant(thermalErr).toString()); color = thermalErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_thermal, color); delay(10); bool scenSramErr = _vec->scenSramErr; ui->l_scenSram->setText(QVariant(scenSramErr).toString()); color = scenSramErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenSram, color); delay(10); bool syncFifoErr = _vec->syncFifoErr; ui->l_syncFifo->setText(QVariant(syncFifoErr).toString()); color = syncFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncFifo, color); delay(10); bool syncPointErr = _vec->syncPointErr; ui->l_syncPoint->setText(QVariant(syncPointErr).toString()); color = syncPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncPoint, color); delay(10); bool dintrlvFifoErr = _vec->dintrlvFifoErr; ui->l_dintrlvFifo->setText(QVariant(dintrlvFifoErr).toString()); color = dintrlvFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvFifo, color); delay(10); bool dintrlvPointErr = _vec->dintrlvPointErr; ui->l_dintrlvPoint->setText(QVariant(dintrlvPointErr).toString()); color = dintrlvPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvPoint, color); delay(10); bool sram1ParityErr = _vec->sram1ParityErr; ui->l_sram1Parity->setText(QVariant(sram1ParityErr).toString()); color = sram1ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram1Parity, color); delay(10); bool sram2ParityErr = _vec->sram2ParityErr; ui->l_sram2Parity->setText(QVariant(sram2ParityErr).toString()); color = sram2ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram2Parity, color); delay(10); bool dmaCtrlTransferErr = _vec->dmaCtrlTransferErr; ui->l_DmaCtrlTrans->setText(QVariant(dmaCtrlTransferErr).toString()); color = dmaCtrlTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_DmaCtrlTrans, color); delay(10); bool emulDmaTransferErr = _vec->emulDmaTransferErr; ui->l_emulDmaTrans->setText(QVariant(emulDmaTransferErr).toString()); color = emulDmaTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_emulDmaTrans, color); delay(10); bool probeDisconnectErr = _vec->probeDisconnectErr; ui->l_prbDiscon->setText(QVariant(probeDisconnectErr).toString()); color = probeDisconnectErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDiscon, color); delay(10); bool probeDetChanInterrupt = _vec->probeDetChanInterrupt; ui->l_prbDetChg->setText(QVariant(probeDetChanInterrupt).toString()); color = probeDetChanInterrupt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDetChg, color); if(probeDetChanInterrupt) { emit connectedPrbChange(); } if(frameLost) { emit frameLostCall(); } } /*************************************************************************************************/ void MainWindow::getPrbChange() { const quint32 id9L_D = 0x212; const quint32 idC1_5_D = 0x225; try { _trx.prbState(_prb); } catch(SonoException& e) { qDebug() << e.what(); } try { if(_prb->prbA.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 0); switch(_prb->prbA.id) { case id9L_D: ui->table_probe->setItem(0, 0, new QTableWidgetItem("9L-D")); break; case idC1_5_D: ui->table_probe->setItem(0, 0, new QTableWidgetItem("C1-5-D")); break; default: ui->table_probe->setItem(0, 0, new QTableWidgetItem("Unknown")); } if(_prb->prbA.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe A eeprom is occured."; } } else { ui->table_probe->setItem(0, 0, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 0); } } catch(const char* exception) { qDebug() << exception; } try { if(_prb->prbB.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 1); switch(_prb->prbB.id) { case id9L_D: ui->table_probe->setItem(0, 1, new QTableWidgetItem("9L-D")); break; case idC1_5_D: ui->table_probe->setItem(0, 1, new QTableWidgetItem("C1-5-D")); break; default: ui->table_probe->setItem(0, 1, new QTableWidgetItem("Unknown")); } if(_prb->prbB.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe B eeprom is occured."; } } else { ui->table_probe->setItem(0, 1, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 1); } } catch(const char* exception) { qDebug() << exception; } try { if(_prb->prbC.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 2); switch(_prb->prbC.id) { case id9L_D: ui->table_probe->setItem(0, 2, new QTableWidgetItem("9L-D")); break; case idC1_5_D: ui->table_probe->setItem(0, 2, new QTableWidgetItem("C1-5-D")); break; default: ui->table_probe->setItem(0, 2, new QTableWidgetItem("Unknown")); } if(_prb->prbC.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe C eeprom is occured."; } } else { ui->table_probe->setItem(0, 2, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 2); } } catch(const char* exception) { qDebug() << exception; } try { if(_prb->prbD.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 3); switch(_prb->prbD.id) { case id9L_D: ui->table_probe->setItem(0, 3, new QTableWidgetItem("9L-D")); break; case idC1_5_D: ui->table_probe->setItem(0, 3, new QTableWidgetItem("C1-5-D")); break; default: ui->table_probe->setItem(0, 3, new QTableWidgetItem("Unknown")); } if(_prb->prbD.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe D eeprom is occured."; } } else { ui->table_probe->setItem(0, 3, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 3); } } catch(const char* exception) { qDebug() << exception; } } /*************************************************************************************************/ void MainWindow::getFrameLost() { MESSAGE_BOX(QString::number(_trx.getFrameLostCounter(), 10)); //qDebug() << _trx.getFrameLostCounter(); } /*************************************************************************************************/ void MainWindow::getProbeColor(const QBrush brush, const int item) { ui->table_probe->item(0, item)->setBackground(brush); } /*************************************************************************************************/ void MainWindow::changeLabelTextColor(QLabel* label, QColor color) { auto palette = label->palette(); palette.setColor(QPalette::Foreground, color); label->setAutoFillBackground(true); label->setPalette(palette); label->update(); } /*************************************************************************************************/ void MainWindow::on_rbtn_reg_toggled(bool checked) { if(checked) { _settings->setValue(REG_ACCESS_SEL, true); ui->l_regIndicator->setText("Register number: (Hex)"); } } /*************************************************************************************************/ void MainWindow::on_rbtn_offset_toggled(bool checked) { if(checked) { _settings->setValue(REG_ACCESS_SEL, false); ui->l_regIndicator->setText("Register offset: (Hex)"); } } /*************************************************************************************************/ void MainWindow::on_btn_readReg_clicked() { auto bar = ui->cb_regBarNum->currentText().toUInt(); auto offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 16); if(offset == 0 && ui->tb_regIndicator->text() != "0") { MESSAGE_BOX("Invalid input format for offset"); return; } quint64 value = 0; auto width = ui->cb_regWidth->currentIndex(); switch(width) { case 0: if(ui->rbtn_reg->isChecked()) { offset *= 4; } value = _usd->readWord(offset, bar); ui->lcd_regvalue->setDigitCount(8); break; case 1: if(ui->rbtn_reg->isChecked()) { offset *= 8; } value = _usd->readLong(offset, bar); ui->lcd_regvalue->setDigitCount(16); break; } ui->lcd_regvalue->display(QString::number(value, 16)); } /*************************************************************************************************/ void MainWindow::on_btn_writeReg_clicked() { auto bar = ui->cb_regBarNum->currentText().toUInt(); auto offset = ui->tb_regIndicator->text().toUInt(Q_NULLPTR, 16); if(offset == 0 && ui->tb_regIndicator->text() != "0") { MESSAGE_BOX("Invalid input format for offset"); return; } auto value = ui->tb_regValue->text().toULong(Q_NULLPTR, 16); if(value == 0 && ui->tb_regValue->text() != "0") { MESSAGE_BOX("Invalid input format for write value"); return; } auto width = ui->cb_regWidth->currentIndex(); switch(width) { case 0: if(ui->rbtn_reg->isChecked()) { offset *= 4; } _usd->writeWord(offset, bar, static_cast(value)); break; case 1: if(ui->rbtn_reg->isChecked()) { offset *= 8; } _usd->writeLong(offset, bar, value); break; } } /*************************************************************************************************/ void MainWindow::on_btn_fpgaBrowse_clicked() { QFileDialog fileDialog; fileDialog.setNameFilters({"FPGA program file (*.bit)"}); auto result = fileDialog.exec(); if(result) { auto selectedPath = fileDialog.selectedFiles()[0]; ui->tb_fpgaBit->setText(selectedPath); _settings->setValue(FPGA_FILE_PATH, selectedPath); } } /*************************************************************************************************/ void MainWindow::getFpgaProgrammer(QString path) { try { _trx.slaveFpgaProgram(path); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::getProgrammingGif() { movie->setSpeed(100); ui->l_programming->setMovie(movie); ui->l_programming->show(); movie->start(); //ui->l_programming->update(); //qApp->processEvents(); } /*************************************************************************************************/ void MainWindow::getLabelState(QLabel *label, QString str, QColor color) { label->setText(str); changeLabelTextColor(label, color); label->repaint(); qApp->processEvents(); } /*************************************************************************************************/ void MainWindow::on_btn_fpgaProgram_clicked() { auto path = ui->tb_fpgaBit->text(); //QtConcurrent::run(this, &MainWindow::gifActive); QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); emit fpgaProgrammer(path); str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); //ui->l_programming->hide(); } void MainWindow::gifActive() { //emit programmingGif(); } /*************************************************************************************************/ void MainWindow::newMessage(QString message) { QMessageBox msgBox; msgBox.setText(message); msgBox.exec(); } /*************************************************************************************************/ void MainWindow::on_cb_selectedProbe_currentIndexChanged(int index) { auto indx = index; if(indx == 0) { _trx.selectProbe(prbA); } else if(indx == 1) { _trx.selectProbe(prbB); } else if(indx == 2) { _trx.selectProbe(prbC); } else { _trx.selectProbe(prbD); } } /*************************************************************************************************/ void MainWindow::delay(int ms) { delayTimer.singleShot(ms, &loop, &QEventLoop::quit); loop.exec(); } const QString MainWindow::enum2String(ePg state) const { QString pg; pg = (state) ? "good" : "bad"; return pg; } /*************************************************************************************************/ /*********************************************DMA*************************************************/ /*************************************************************************************************/ void MainWindow::getFramePacket(QByteArray packet) { _mutex.lock(); _dmaBuffer.push_back(packet); _lastBuffer = packet; _mutex.unlock(); quint16 batchId = ((static_cast(_lastBuffer[128])) & 0x00FF) | (((static_cast(_lastBuffer[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(_lastBuffer[130])); // quint8 frmType = (static_cast(_lastBuffer[131])); // quint8 cri = (static_cast(_lastBuffer[132])); // quint16 bLine = ((static_cast(_lastBuffer[136])) & 0x00FF) | // (((static_cast(_lastBuffer[137])) << 8) & 0xFF00); // quint16 bPoint = ((static_cast(_lastBuffer[138])) & 0x00FF) | // (((static_cast(_lastBuffer[139])) << 8) & 0xFF00); // quint8 mLine = (static_cast(_lastBuffer[140])); // quint16 mPoint = ((static_cast(_lastBuffer[141])) & 0x00FF) | // (((static_cast(_lastBuffer[142])) << 8) & 0xFF00); if (subBatchId == 0) { _frameCount++; if (_getPacket) { if (_batchIdBuff == batchId && (batchId - _batchIdBuff) > 1) MESSAGE_BOX("The batch id error is happened."); } _batchIdBuff = batchId; _getPacket = true; } // if(batchId < 3) // { // qDebug() << "batchId" << batchId; // qDebug() << "subBatchId" << subBatchId; // qDebug() << "bLine" << bLine; // qDebug() << "bPoint" << bPoint; // qDebug() << "frmType" << frmType; // qDebug() << "cri" << cri; // qDebug() << "mLine" << mLine; // qDebug() << "mPoint" << mPoint; // } } /*************************************************************************************************/ void MainWindow::on_chk_continuousShowing_clicked() { fpsBuf = fps; _fpsFlag = true; if(_dmaRun && ui->chk_continuousShowing->isChecked()) { QtConcurrent::run(this, &MainWindow::on_btn_dmaShow_clicked); _dmaShow = true; ui->btn_dmaShow->hide(); } else { _dmaShow = false; ui->btn_dmaShow->show(); } } /*************************************************************************************************/ void MainWindow::on_btn_scenStart_clicked() { _frameCount=0; try { auto str = ui->btn_scenStart->text(); if(str == "Scenario Start") { ui->btn_scenStart->setText("Scenario Stop"); ui->btn_emulator->setText("Emulator Start"); dmaLogLayoutVisible(true); _trx.scenPlayerStart(true); _dmaLog = true; _dmaRun = true; //flag _dmaBuffer.clear(); } else { ui->btn_scenStart->setText("Scenario Start"); ui->chk_continuousShowing->setChecked(false); on_chk_continuousShowing_clicked(); dmaLogLayoutVisible(false); _dmaLog = false; _dmaRun = false; _trx.scenPlayerStop(true); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_emulator_clicked() { auto name = ui->btn_emulator->text(); try { if(name == "Emulator Start") { QString emulPath = QFileDialog::getOpenFileName(this, tr("emulator"), _emulFolder, "*.bin"); if (emulPath.isEmpty() || emulPath.isNull()) { throw SonoException("No file is selected."); } ui->btn_emulator->setText("Filling RAM..."); ui->btn_emulator->repaint(); _trx.fillRam(emulPath); ui->btn_emulator->setText("Emulator Stop"); _emul->transferLength = TRANSFER_LENGTH; _emul->ramBufAddress = RAM_BUFFER_OFFSET; _emul->transferRate = TRANSFER_RATE; _emul->emulOption = performance; _emul->emulMode = dynamically; _trx.emulatorInit(_emul); ui->btn_scenStart->setText("Scenario Start"); dmaLogLayoutVisible(true); _trx.emulatorStart(); _dmaLog = true; _dmaRun = true; _dmaBuffer.clear(); } else { ui->btn_emulator->setText("Emulator Start"); dmaLogLayoutVisible(false); _dmaLog = false; _dmaRun = false; _trx.emulatorStop(); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::logPcie(QString logPath, quint32 logCount) { try { _dmaLogCount = 0; quint32 i(0); QProgressDialog* progress = new QProgressDialog(this); progress->show(); while(_dmaLog) { if(_dmaBuffer.size() == 0) { std::this_thread::sleep_for(std::chrono::milliseconds(3)); continue; } QByteArray temp; _mutex.lock(); temp = _dmaBuffer.front(); _dmaBuffer.pop_front(); _mutex.unlock(); _dmaLogCount += 1; if(_dmaLogCount == logCount) { _dmaLog = false; } quint16 batchId = ((static_cast(temp[128])) & 0x00FF) | (((static_cast(temp[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(temp[130])); QString path = logPath + QString("/batch(%2)_sbatch(%3)_%1.bin").arg(i++).arg(batchId).arg( subBatchId); QFile file(path); if(!file.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't save DMA log file for frame logging"); } file.write(temp); file.close(); emit sendLogCount(_dmaLogCount, logCount, progress); } delete progress; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_dmaLogLast_clicked() { if(_dmaRun) { try { auto dmaLogCnt = ui->tb_dmaLogCount->text().toUInt(Q_NULLPTR, 10); if(dmaLogCnt == 0 && ui->tb_biteLogCount->text() != "0") { MESSAGE_BOX("Invalid input format for DMA log count"); return; } QString dmaLogPath = QFileDialog::getExistingDirectory(this, tr("Dma Log"), _dmaLogFolder, QFileDialog::ShowDirsOnly); QFile dmaLogFile(dmaLogPath); if(dmaLogFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_dmaLogDone, str, color); _dmaBuffer.clear(); _dmaLog = true; QFuture dmaLogFuture = QtConcurrent::run(this, &MainWindow::logPcie, dmaLogPath, dmaLogCnt); dmaLogWatcher.setFuture(dmaLogFuture); } catch(SonoException& e) { qDebug() << e.what(); } } } /*************************************************************************************************/ void MainWindow::dmaLogThreadFinished() { QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_dmaLogDone, str, color); } /*************************************************************************************************/ void MainWindow::dmaLogLayoutVisible(bool show) { QList widgets {ui->btn_dmaLogLast, ui->tb_dmaLogCount, ui->l_dmaLogDone, ui->l_logCount, ui->l_logging }; if (show) { foreach (auto& w, widgets) { w->setVisible(true); w->repaint(); } } else { foreach (auto& w, widgets) { w->setHidden(true); w->repaint(); } } } /*************************************************************************************************/ void MainWindow::on_btn_dmaShow_clicked() { do { if(ui->chk_2D_3DPlot->isChecked()) { if(QThread::currentThread() == _uiThread) { show2d(); } else { emit twoDReady(); } } else { if(QThread::currentThread() == _uiThread) { show3d(); } else { emit threeDReady(); } } std::this_thread::sleep_for(std::chrono::milliseconds(5)); }while (_dmaShow); } /*************************************************************************************************/ void MainWindow::show3d() { _mutex.lock(); QByteArray temp = _lastBuffer; _mutex.unlock(); //--------------------------------------------------------------------- //3D Plot //--------------------------------------------------------------------- ui->plot_2->clearGraphs(); //qDebug() << "//3D Frame Plot //////////////////"; //ui->plot_2->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag); ui->plot_2->axisRect()->setupFullAxesBox(true); ui->plot_2->xAxis->setLabel("Line"); ui->plot_2->yAxis->setLabel("Point"); quint16 batchId = ((static_cast(temp[128])) & 0x00FF) | (((static_cast(temp[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(temp[130])); quint8 frmType = (static_cast(temp[131])); quint8 cri = (static_cast(temp[132])); quint16 bLine = ((static_cast(temp[136])) & 0x00FF) | (((static_cast(temp[137])) << 8) & 0xFF00); quint16 bPoint = ((static_cast(temp[138])) & 0x00FF) | (((static_cast(temp[139])) << 8) & 0xFF00); quint8 mLine = (static_cast(temp[140])); quint16 mPoint = ((static_cast(temp[141])) & 0x00FF) | (((static_cast(temp[142])) << 8) & 0xFF00); if(bLine > 256*8) { qDebug() << "ERROR :: (B Line)" << bLine; return; } if(bPoint > 8192) { qDebug() << "ERROR :: (B Point)" << bPoint; return; } if(frmType != 0) { qDebug() << "ERROR :: (Invalid Frame Type)" << frmType; return; } qDebug() << "batchId" << batchId; qDebug() << "subBatchId" << subBatchId; qDebug() << "bLine" << bLine; qDebug() << "bPoint" << bPoint; qDebug() << "frmType" << frmType; qDebug() << "cri" << cri; qDebug() << "mLine" << mLine; qDebug() << "mPoint" << mPoint; _colorMap->data()->clear(); _colorMap->data()->setSize(bLine, bPoint); _colorMap->data()->setRange(QCPRange(1, bLine), QCPRange(1, bPoint)); //double x,y,z; //int xIndex = 0; //int yIndex = 0; quint32 max = 0; auto indx = 0; for(auto line = 0; line < bLine; line += 1) { for(auto pnt = 0; pnt < bPoint; pnt += 1) { indx = (line * bPoint + pnt) * 4 + 160; auto val = ((static_cast(temp[indx])) & 0x000000FF) | (((static_cast(temp[indx + 1])) << 8) & 0x0000FF00) | (((static_cast(temp[indx + 2])) << 16) & 0x00FF0000) | (((static_cast(temp[indx + 3])) << 24) & 0xFF000000); //xIndex = line; //yIndex = pnt; //z = double(val); //colorMap->data()->cellToCoord(xIndex,yIndex,&x,&y); if(max < val) { max = val; } _colorMap->data()->setCell(line, pnt, double(val)); } } //qDebug() << "indx" << indx; //qDebug() << "max" << max; //qDebug() << ui->plot_2->plotLayout()->hasElement(0, 1); if(!ui->plot_2->plotLayout()->hasElement(0, 1)) { QCPColorScale* colorScale = new QCPColorScale(ui->plot_2); ui->plot_2->plotLayout()->addElement(0, 1, colorScale); colorScale->setType(QCPAxis::atRight); _colorMap->setColorScale(colorScale); colorScale->axis()->setLabel("Number"); _colorMap->setGradient((QCPColorGradient::gpJet)); //colorMap->rescaleDataRange(); QCPMarginGroup* marginGroup = new QCPMarginGroup(ui->plot_2); ui->plot_2->axisRect()->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup); colorScale->setMarginGroup(QCP::msBottom | QCP::msTop, marginGroup); } _colorMap->setGradient((QCPColorGradient::gpJet)); _colorMap->rescaleDataRange(); ui->plot_2->rescaleAxes(true); ui->plot_2->replot(); } /*************************************************************************************************/ void MainWindow::show2d() { _mutex.lock(); QByteArray temp = _lastBuffer; _mutex.unlock(); //--------------------------------------------------------------------- //2D Plot //--------------------------------------------------------------------- ui->plot_2->clearGraphs(); ui->plot_2->clearItems(); ui->plot_2->setInteraction(QCP::iRangeZoom); ui->plot_2->setInteraction(QCP::iRangeDrag); ui->plot_2->setInteraction(QCP::iSelectPlottables); ui->plot_2->setSelectionRectMode(QCP::srmZoom); QVector x, y; int i = 0; for(auto j = 0; j < TRANSFER_LENGTH; j += 8) { x.push_back(i++); auto val = ((static_cast(temp[j])) & 0x00000000000000FF) | (((static_cast(temp[j + 1])) << 8) & 0x000000000000FF00) | (((static_cast(temp[j + 2])) << 16) & 0x0000000000FF0000) | (((static_cast(temp[j + 3])) << 24) & 0x00000000FF000000) | (((static_cast(temp[j + 4])) << 32) & 0x000000FF00000000) | (((static_cast(temp[j + 5])) << 40) & 0x0000FF0000000000) | (((static_cast(temp[j + 6])) << 48) & 0x00FF000000000000) | (((static_cast(temp[j + 7])) << 56) & 0xFF00000000000000); y.push_back(val); } ui->plot_2->addGraph(); ui->plot_2->graph(0)->setData(x, y); //give the axes some labels: ui->plot_2->xAxis->setLabel("sample no"); ui->plot_2->yAxis->setLabel("sample value"); //set axes ranges, so we see all data: ui->plot_2->rescaleAxes(); ui->plot_2->replot(); } /*************************************************************************************************/ void MainWindow::catchLogCount(quint32 counter, quint32 logRange, QProgressDialog* _progress) { _progress->setMinimumSize(300, 100); _progress->setLabelText("Please wait..."); _progress->setWindowTitle("Frame Packets Logging"); _progress->setRange(0, static_cast(logRange)); _progress->setModal(true); try { _progress->setValue(static_cast(counter)); if(_progress->wasCanceled()) { throw SonoException("Frame Packets Logging is canceled"); } } catch(SonoException& e) { qDebug() << e.what(); } } ///*************************************************************************************************/ ///********************************************Power************************************************/ ///*************************************************************************************************/ //void MainWindow::on_btn_hvRegulatorConfig_clicked() //{ //auto name=ui->btn_hvRegulatorConfig->text(); //auto freq=ui->tb_hvFreq->text().toFloat(Q_NULLPTR); //if(name==ENABLE) //{ //// freq<65.00f ? freq=65.00f : freq=freq; //// freq>130.00f ? freq=130.00f : freq=freq; //// pwr.setHVsRegulator(true, true, freq); //// pwr.setHVsRegulator(true, false, freq); //// auto real_freq=pwr.getHVsRegulatorFreq(); //// ui->tb_hvFreq->setText(QString("%1").arg(real_freq)); //// ui->btn_hvRegulatorConfig->setText(DISABLE); //} //else //{ //// pwr.setHVsRegulator(false, false, freq); //// ui->btn_hvRegulatorConfig->setText(ENABLE); //} //} ///*************************************************************************************************/ //void MainWindow::on_btn_pm5RegulatorConfig_clicked() //{ //auto name=ui->btn_pm5RegulatorConfig->text(); //auto freq=ui->tb_pm5Freq->text().toFloat(Q_NULLPTR); //if(name==ENABLE) //{ //// freq<280.00f ? freq=280.00f : freq=freq; //// freq>400.00f ? freq=400.00f : freq=freq; //// pwr.setPM5vRegulator(true, true, freq); //// pwr.setPM5vRegulator(true, false, freq); //// auto real_freq=pwr.getPM5vRegulatorFreq(); //// ui->tb_pm5Freq->setText(QString("%1").arg(real_freq)); //// ui->btn_pm5RegulatorConfig->setText(DISABLE); //} //else //{ //// pwr.setPM5vRegulator(false, false, freq); //// ui->btn_pm5RegulatorConfig->setText(ENABLE); //} //} ///*************************************************************************************************/ //void MainWindow::on_btn_pwrDacsEnable_clicked() //{ //// bool i2cBusy, i2cDone; //auto hvaValue=ui->tb_hvaDacValue->text().toFloat(Q_NULLPTR); //auto hvbValue=ui->tb_hvbDacValue->text().toFloat(Q_NULLPTR); //auto cwdValue=ui->tb_cwdDacValue->text().toFloat(Q_NULLPTR); //// if (hvaValue>85) { //// MESSAGE_BOX("HVA value is greater than determined limits"); //// hvaValue=85.00f; //// } //// else if (hvaValue<1.53f){ //// MESSAGE_BOX("HVA value is less than determined limits"); //// hvaValue=1.53f; //// } //// if (hvaValue6.90f) { //// MESSAGE_BOX("CWD value is greater than determined limits"); //// cwdValue=6.90f; //// } //// else if (cwdValue<1.54f){ //// MESSAGE_BOX("CWD value is less than determined limits"); //// cwdValue=1.54f; //// } //// auto cwdDacsEnable=pwr.getSetupCmdCwdOnOff(); //// if (cwdDacsEnable){ //// hvbValue=1.53f; //// hvaValue<10.00f ? hvaValue=10.00f : hvaValue=hvaValue; //// } //// i2cBusy=pwr.getI2cBusy(); //// while (i2cBusy==true) { //// i2cBusy=pwr.getI2cBusy(); //// } ////// delay(100); //// pwr.setDAcs(true, cwdValue, hvbValue, hvaValue); //// pwr.setDAcs(false, cwdValue, hvbValue, hvaValue); //// i2cDone=pwr.getI2cCmdDone(); //// while (i2cDone==false){ //// i2cDone=pwr.getI2cCmdDone(); //// } //// auto real_HVaValue=pwr.getHVaDAcs(); //// auto real_HVbValue=pwr.getHVbDAcs(); //// auto real_CWdValue=pwr.getCWdDAcs(); //// ui->tb_hvaDacValue->setText(QString::number(real_HVaValue, 'f', 2)); //// ui->tb_hvbDacValue->setText(QString::number(real_HVbValue, 'f', 2)); //// ui->tb_cwdDacValue->setText(QString::number(real_CWdValue, 'f', 2)); //} void MainWindow::on_btn_setAo_clicked() { auto hvaValue = ui->tb_hvaDacValue->text().toFloat(Q_NULLPTR); auto hvbValue = ui->tb_hvbDacValue->text().toFloat(Q_NULLPTR); //auto cwdValue=ui->tb_cwdDacValue->text().toFloat(Q_NULLPTR); try { _trx.mpsSetAo(hvaValue, hvbValue); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_mpsInit_clicked() { try { if(ui->chk_mpsInit->isChecked()) { _trx.mpsPwrOn(); } else { _trx.mpsPwrOff(); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_supJump_clicked() { try { _trx.mpsReset(); //jump ui->chk_mpsInit->setChecked(false); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_updateRdbackValue_clicked() { try { _trx.supervisorRbValue(_supRbValue); } catch(SonoException& e) { qDebug() << e.what(); } auto hvapValue = _supRbValue->hvap; ui->l_hvap->setText(QString::number(static_cast(hvapValue), 'f', 3)); delay(10); auto hvbpValue = _supRbValue->hvbp; ui->l_hvbp->setText(QString::number(static_cast(hvbpValue), 'f', 3)); delay(10); auto cwdpValue = _supRbValue->cwdp; ui->l_cwdp->setText(QString::number(static_cast(cwdpValue), 'f', 3)); delay(10); auto curr24vValue = _supRbValue->curr24V; ui->l_curr24v->setText(QString::number(static_cast(curr24vValue), 'f', 3)); delay(10); auto p24vValue = _supRbValue->p24V; ui->l_p24v->setText(QString::number(static_cast(p24vValue), 'f', 3)); delay(10); auto p12vValue = _supRbValue->p12V; ui->l_p12v->setText(QString::number(static_cast(p12vValue), 'f', 3)); delay(10); auto p5vValue = _supRbValue->p5V; ui->l_p5v->setText(QString::number(static_cast(p5vValue), 'f', 3)); delay(10); auto m5vValue = _supRbValue->m5V; ui->l_m5v->setText(QString::number(static_cast(m5vValue), 'f', 3)); delay(10); auto hvStopValue = _supRbValue->hvStop; ui->l_hvStop->setText(QString::number(static_cast(hvStopValue), 'f', 3)); delay(10); auto p4dValue = _supRbValue->p4D; ui->l_p4d->setText(QString::number(static_cast(p4dValue), 'f', 3)); delay(10); /********************Faults***********************/ try { _trx.mpsFaultStatus(_faultStatus); } catch(SonoException& e) { qDebug() << e.what(); } bool hvapFlt = _faultStatus->hvap; ui->l_hvapFlt->setText(QVariant(hvapFlt).toString()); auto colorHvapFlt = hvapFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_hvapFlt, colorHvapFlt); delay(10); bool hvbpFlt = _faultStatus->hvbp; ui->l_hvbpFlt->setText(QVariant(hvbpFlt).toString()); auto colorHvbpFlt = hvbpFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_hvbpFlt, colorHvbpFlt); delay(10); bool cwdpFlt = _faultStatus->cwdp; ui->l_cwdFlt->setText(QVariant(cwdpFlt).toString()); auto colorCwdpFlt = cwdpFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_cwdFlt, colorCwdpFlt); delay(10); bool cur24vFlt = _faultStatus->curr24V; ui->l_curr24vFlt->setText(QVariant(cur24vFlt).toString()); auto colorCur24vFlt = cur24vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_curr24vFlt, colorCur24vFlt); delay(10); bool p24vFlt = _faultStatus->p24v; ui->l_p24vFlt->setText(QVariant(p24vFlt).toString()); auto colorP24vFlt = p24vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_p24vFlt, colorP24vFlt); delay(10); bool p12vFlt = _faultStatus->p12v; ui->l_p12vFlt->setText(QVariant(p12vFlt).toString()); auto colorP12vFlt = p12vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_p12vFlt, colorP12vFlt); delay(10); bool p5vFlt = _faultStatus->p5v; ui->l_p5vFlt->setText(QVariant(p5vFlt).toString()); auto colorP5vFlt = p5vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_p5vFlt, colorP5vFlt); delay(10); bool m5vFlt = _faultStatus->m5v; ui->l_m5vFlt->setText(QVariant(m5vFlt).toString()); auto colorM5vFlt = m5vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_m5vFlt, colorM5vFlt); delay(10); bool hvFlt = _faultStatus->hvError; ui->l_hvFlt->setText(QVariant(hvFlt).toString()); auto colorHvFlt = hvFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_hvFlt, colorHvFlt); delay(10); bool sup4dFlt = _faultStatus->sup4d; ui->l_p4dFlt->setText(QVariant(sup4dFlt).toString()); auto colorP4dFlt = sup4dFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_p4dFlt, colorP4dFlt); delay(10); /******************Faults_Over*********************/ bool ovrHvapFlt = _faultStatus->overHvap; ui->l_ovrHVapFlt->setText(QVariant(ovrHvapFlt).toString()); auto colorOvrHvapFlt = ovrHvapFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrHVapFlt, colorOvrHvapFlt); delay(10); bool ovrHvbpFlt = _faultStatus->overHvbp; ui->l_ovrHVbpFlt->setText(QVariant(ovrHvbpFlt).toString()); auto colorOvrHvbpFlt = ovrHvbpFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrHVbpFlt, colorOvrHvbpFlt); delay(10); bool ovrCwdpFlt = _faultStatus->overCwdp; ui->l_ovrCWdpFlt->setText(QVariant(ovrCwdpFlt).toString()); auto colorOvrCwdpFlt = ovrCwdpFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrCWdpFlt, colorOvrCwdpFlt); delay(10); bool ovrCur24vFlt = _faultStatus->overCurr24V; ui->l_ovrCur24vFlt->setText(QVariant(ovrCur24vFlt).toString()); auto colorOvrCur24vFlt = ovrCur24vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrCur24vFlt, colorOvrCur24vFlt); delay(10); bool ovrP24vFlt = _faultStatus->overP24v; ui->l_ovrP24vFlt->setText(QVariant(ovrP24vFlt).toString()); auto colorOvrP24vFlt = ovrP24vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrP24vFlt, colorOvrP24vFlt); delay(10); bool ovrP12vFlt = _faultStatus->overP12v; ui->l_ovrP12vFlt->setText(QVariant(ovrP12vFlt).toString()); auto colorOvrP12vFlt = ovrP12vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrP12vFlt, colorOvrP12vFlt); delay(10); bool ovrP5vFlt = _faultStatus->overP5v; ui->l_ovrP5vFlt->setText(QVariant(ovrP5vFlt).toString()); auto colorOvrP5vFlt = ovrP5vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrP5vFlt, colorOvrP5vFlt); delay(10); bool ovrM5vFlt = _faultStatus->overM5v; ui->l_ovrM5vFlt->setText(QVariant(ovrM5vFlt).toString()); auto colorOvrM5vFlt = ovrM5vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrM5vFlt, colorOvrM5vFlt); delay(10); bool ovrHvFlt = _faultStatus->overHvError; ui->l_ovrHvFlt->setText(QVariant(ovrHvFlt).toString()); auto colorOvrHvFlt = ovrHvFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovrHvFlt, colorOvrHvFlt); delay(10); bool ovrSup4dFlt = _faultStatus->overSup4d; ui->l_ovr4dFlt->setText(QVariant(ovrSup4dFlt).toString()); auto colorOvrP4dFlt = ovrSup4dFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ovr4dFlt, colorOvrP4dFlt); delay(10); /******************Faults_Under*********************/ bool udrHvapFlt = _faultStatus->underHvap; ui->l_udrHVapFlt->setText(QVariant(udrHvapFlt).toString()); auto colorUdrHvapFlt = udrHvapFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrHVapFlt, colorUdrHvapFlt); delay(10); bool udrHvbpFlt = _faultStatus->underHvbp; ui->l_udrHVbpFlt->setText(QVariant(udrHvbpFlt).toString()); auto colorUdrHvbpFlt = udrHvbpFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrHVbpFlt, colorUdrHvbpFlt); delay(10); bool udrCwdpFlt = _faultStatus->underCwdp; ui->l_udrCWdpFlt->setText(QVariant(udrCwdpFlt).toString()); auto colorUdrCwdpFlt = udrCwdpFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrCWdpFlt, colorUdrCwdpFlt); delay(10); bool udrCur24vFlt = _faultStatus->underCurr24V; ui->l_udrCurr24vFlt->setText(QVariant(udrCur24vFlt).toString()); auto colorUdrCur24vFlt = udrCur24vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrCurr24vFlt, colorUdrCur24vFlt); delay(10); bool udrP24vFlt = _faultStatus->underP24v; ui->l_udrP24vFlt->setText(QVariant(udrP24vFlt).toString()); auto colorUdrP24vFlt = udrP24vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrP24vFlt, colorUdrP24vFlt); delay(10); bool udrP12vFlt = _faultStatus->underP12v; ui->l_udrP12vFlt->setText(QVariant(udrP12vFlt).toString()); auto colorUdrP12vFlt = udrP12vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrP12vFlt, colorUdrP12vFlt); delay(10); bool udrP5vFlt = _faultStatus->underP5v; ui->l_udrP5vFlt->setText(QVariant(udrP5vFlt).toString()); auto colorUdrP5vFlt = udrP5vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrP5vFlt, colorUdrP5vFlt); delay(10); bool udrM5vFlt = _faultStatus->underM5v; ui->l_udrM5vFlt->setText(QVariant(udrM5vFlt).toString()); auto colorUdrM5vFlt = udrM5vFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrM5vFlt, colorUdrM5vFlt); delay(10); bool udrHvFlt = _faultStatus->underHvError; ui->l_udrHvFlt->setText(QVariant(udrHvFlt).toString()); auto colorUdrHvFlt = udrHvFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udrHvFlt, colorUdrHvFlt); delay(10); bool udrSup4dFlt = _faultStatus->underSup4d; ui->l_udr4dFlt->setText(QVariant(udrSup4dFlt).toString()); auto colorUdrP4dFlt = udrSup4dFlt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_udr4dFlt, colorUdrP4dFlt); delay(10); } /*************************************************************************************************/ QString MainWindow::releaseCodeVersion(quint32& value) { QString str = QString::number(value, 10); QList strList; foreach(auto ch, str) { strList.push_back(ch); } str.clear(); str = strList[0] + strList[1] + "/" + strList[2] + strList[3] + "/" + strList[4] + strList[5] + " " + strList[6] + strList[7] + ":" + strList[8] + strList[9]; return str; } /*************************************************************************************************/ void MainWindow::on_btn_getFpgaVersion_clicked() { _trx.getFpgasCodeVersion(_version); auto value = _version->masterCode; ui->l_masterVersion->setText(releaseCodeVersion(value)); value = _version->slave0Code; ui->l_slave0Version->setText(releaseCodeVersion(value)); value = _version->slave1Code; ui->l_slave1Version->setText(releaseCodeVersion(value)); value = _version->slave2Code; ui->l_slave2Version->setText(releaseCodeVersion(value)); } /*************************************************************************************************/ /************************************* Scenario Setting ******************************************/ /*************************************************************************************************/ void MainWindow::setScenario(const string& h5Path) { Hdf5 hdf; ScenGenHardwareOutput_t scenParams; ScenPrbDepHardwareParam prbDepParams; QVector lineFilterLut; QVector stbLut; hdf.hdf5Path(h5Path); hdf.scenarioRead(scenParams); hdf.prbDependParamsRead(prbDepParams); prbDepParams.afeCfg = _afeConfig; stbLut = hdf.stbRead(); lineFilterLut = hdf.lineFilterRead(); try { _trx.setScenario(scenParams); _trx.setProbeDependParams(prbDepParams); _trx.setLineFilterCoefficient(lineFilterLut); _trx.setStbCoefficient(stbLut); } catch(SonoException& e) { qDebug() << e.what(); } ui->btn_scenStart->setText("Scenario Start"); ui->btn_emulator->setText("Emulator Start"); auto startIdx = _usd->readWord(0x804, 0); auto endIdx = _usd->readWord(0x808, 0); ui->tb_startIdx->setText(QString::number(startIdx, 16)); ui->tb_endIdx->setText(QString::number(endIdx, 16)); } /*************************************************************************************************/ void MainWindow::on_btn_setScenario_clicked() { QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_scenFillingDone, str, color); QString sramScenario = "/scenGenOutput/scenario.h5"; QString h5Path = ui->tb_scenFilesPath->text() + sramScenario; emit scenarioReady(h5Path.toStdString()); str = "done"; color = Qt::green; emit labelState(ui->l_scenFillingDone, str, color); } /*************************************************************************************************/ void MainWindow::getSramBinaryCreateFlag() { ui->l_createSramBinary->setText("done"); changeLabelTextColor(ui->l_createSramBinary, Qt::green); } /*************************************************************************************************/ void MainWindow::getRegisterCsvCompareFlag() { ui->l_verifyRegisterParams->setText("done"); changeLabelTextColor(ui->l_verifyRegisterParams, Qt::green); } /*************************************************************************************************/ void MainWindow::getSramVerifyMessage(QString message) { ui->l_verifySramParams->setText("done"); changeLabelTextColor(ui->l_verifySramParams, Qt::green); MESSAGE_BOX(message); } /*************************************************************************************************/ void MainWindow::setScenarioCompare(const QString& scenPath) { try { _trx.setScenarioCompare(scenPath); } catch(SonoException& e) { if(!(ui->l_verifySramParams->text() == "done")) { ui->l_verifySramParams->setText("failed"); changeLabelTextColor(ui->l_verifySramParams, Qt::red); } if(!(ui->l_verifyRegisterParams->text() == "done")) { ui->l_verifyRegisterParams->setText("failed"); changeLabelTextColor(ui->l_verifyRegisterParams, Qt::red); } if(!(ui->l_createSramBinary->text() == "done")) { ui->l_createSramBinary->setText("failed"); changeLabelTextColor(ui->l_createSramBinary, Qt::red); } qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_setScenVerification_clicked() { ui->l_createSramBinary->setText("doing"); changeLabelTextColor(ui->l_createSramBinary, Qt::red); ui->l_verifyRegisterParams->setText("doing"); changeLabelTextColor(ui->l_verifyRegisterParams, Qt::red); ui->l_verifySramParams->setText("doing"); changeLabelTextColor(ui->l_verifySramParams, Qt::red); const QString scenPath = ui->tb_scenFilesPath->text(); QtConcurrent::run(this, &MainWindow::setScenarioCompare, scenPath); } /*************************************************************************************************/ void MainWindow::on_btn_scenBrowse_clicked() { QFileDialog fileDialog; fileDialog.setFileMode(QFileDialog::Directory); fileDialog.setOption(QFileDialog::ShowDirsOnly); auto result = fileDialog.exec(); if(result) { auto selectedPath = fileDialog.selectedFiles()[0]; ui->tb_scenFilesPath->setText(selectedPath); _settings->setValue(SCENARIO_FILE_PATH, selectedPath); ui->tb_scenInfo->clear(); } } /*************************************************************************************************/ void MainWindow::on_btn_scenInfo_clicked() { QString scenInfo = "/hardware/systemCheckParam.csv"; QString path = ui->tb_scenFilesPath->text() + scenInfo; QFile sysFile(path); if(sysFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!sysFile.open(QIODevice::ReadOnly)) { throw SonoException("Couldn't open system check param file programming"); } QTextStream checkParam(&sysFile); QString systemStr = checkParam.readAll(); ui->tb_scenInfo->setPlainText(systemStr); sysFile.close(); } /*************************************************************************************************/ void MainWindow::on_btn_setAtgcMode_clicked() { auto aTgcMode = ui->cb_aTgcMode->currentIndex(); auto aTgcValue = ui->tb_aTgcValue->text().toUInt(); if(aTgcMode == 0) { _trx.setAtgcMode(Auto, 0); } else { _trx.setAtgcMode(Manual, static_cast(aTgcValue)); } } /*************************************************************************************************/ void MainWindow::on_btn_setIdx_clicked() { quint32 bar(0); auto startIndex = ui->tb_startIdx->text().toUInt(Q_NULLPTR, 16); if(startIndex == 0 && ui->tb_startIdx->text() != "0") { MESSAGE_BOX("Invalid input format for start index"); return; } auto endIndex = ui->tb_endIdx->text().toUInt(Q_NULLPTR, 16); if(endIndex == 0 && ui->tb_endIdx->text() != "0") { MESSAGE_BOX("Invalid input format for stop index"); return; } if((endIndex < startIndex) || (endIndex > 131071) || (startIndex > 131071)) { MESSAGE_BOX("Stop index should be greater than or equal to start index"); return; } _usd->writeWord(0x804, bar, startIndex); _usd->writeWord(0x808, bar, endIndex); } /*************************************************************************************************/ /**************************************** EEPROM *************************************************/ /*************************************************************************************************/ QByteArray MainWindow::str2ByteArray (QString& str) { QByteArray finalArray; QByteArray temp; qint8 value; auto asciiArray = str.toUpper().toUtf8(); foreach(auto i, asciiArray) { if(i <= 0x39 && i >= 0x30) { temp.push_back(i - 0x30); } else if(i <= 0x46 && i >= 0x41) { temp.push_back(i - 0x37); } else { throw"Out of range"; } } for(quint8 k = 0; k < temp.size() / 2; k++) { value = static_cast(((temp.at(2 * k) << 4) & 0xF0) + ((temp.at(2 * k + 1)) & 0xF)); finalArray.push_back(value); } return finalArray; } QString MainWindow::uint2IdString (quint32& id) { QString idStr = QString::number(id, 16); return idStr; } QString MainWindow::byteArray2InfoString (QByteArray& arr) { QString infoStr; foreach(auto j, arr) { quint8 l = static_cast(j); if(l <= 15) { infoStr += "0" + QString::number(l, 16); } else { infoStr += QString::number(l, 16); } } return infoStr; } /*************************************************************************************************/ /*************************************************************************************************/ void MainWindow::on_btn_trxRomIdWrite_clicked() { QString idStr = ui->tb_trxRomId->text(); try { QByteArray sendingArray = str2ByteArray(idStr); trxEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_trxRomInfoWrite_clicked() { QString infoStr = ui->tb_trxRomInfo->toPlainText(); try { QByteArray sendingArray = infoStr.toLatin1(); trxEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); //QByteArray sendingArray; //unsigned char crcArray[] = {0x4, 0x0, 0x13, 0x0, 0x27, 0x0, 0x28, 0x0, 0xEB, 0x1, //0xAC, 0x5, 0xAC, 0x6, 0x4C, 0x6, 0xB0, 0x6, 0xB2, //0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //for(auto var : crcArray) //sendingArray.push_back(static_cast(var)); //trxEepromWrite(sendingArray, EEPROM_CRC_BEGIN, _bCtrl); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_trxRomIdRead_clicked() { EepromStatus romStatus; try { _trx.trxState(romStatus); if(romStatus.ConnectionMode == connected) { ui->tb_trxRomId->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the trx eeprom is occured."; } } else { MESSAGE_BOX("Trx board is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_trxRomInfoRead_clicked() { try { QString receivingStr = _trx.trxInfo(); ui->tb_trxRomInfo->setText(receivingStr); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomIdWrite_clicked() { QString idStr = ui->tb_mpsRomId->text(); try { QByteArray sendingArray = str2ByteArray(idStr); mpsEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomInfoWrite_clicked() { QString infoStr = ui->tb_mpsRomInfo->toPlainText(); try { QByteArray sendingArray = infoStr.toLatin1(); mpsEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomIdRead_clicked() { EepromStatus romStatus; try { _trx.mpsState(romStatus); if(romStatus.ConnectionMode == connected) { ui->tb_mpsRomId->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the mps eeprom is occured."; } } else { MESSAGE_BOX("Mps board is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomInfoRead_clicked() { try { QString receivingStr = _trx.mpsInfo(); ui->tb_mpsRomInfo->setText(receivingStr); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbCtrlRomIdWrite_clicked() { QString idStr = ui->tb_prbCtrlRomId->text(); try { QByteArray sendingArray = str2ByteArray(idStr); prbCtrlEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbCtrlRomInfoWrite_clicked() { QString infoStr = ui->tb_prbCtrlRomInfo->toPlainText(); try { QByteArray sendingArray = infoStr.toLatin1(); prbCtrlEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbCtrlRomIdRead_clicked() { EepromStatus romStatus; try { _trx.prbCtrlState(romStatus); if(romStatus.ConnectionMode == connected) { ui->tb_prbCtrlRomId->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the prbCtrl eeprom is occured."; } } else { MESSAGE_BOX("PrbCtrl board is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbCtrlRomInfoRead_clicked() { try { QString receivingStr = _trx.prbCtrlInfo(); ui->tb_prbCtrlRomInfo->setText(receivingStr); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbRomIdRead_clicked() { auto sel = ui->cb_prbSelRom->currentIndex(); EepromStatus romStatus; try { switch(sel) { case 0: try { _trx.selectedPrbState(romStatus, prbA); if(romStatus.ConnectionMode == connected) { ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe A eeprom is occured."; } } else { MESSAGE_BOX("Probe A is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } break; case 1: try { _trx.selectedPrbState(romStatus, prbB); if(romStatus.ConnectionMode == connected) { ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe B eeprom is occured."; } } else { MESSAGE_BOX("Probe B is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } break; case 2: try { _trx.selectedPrbState(romStatus, prbC); if(romStatus.ConnectionMode == connected) { ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe C eeprom is occured."; } } else { MESSAGE_BOX("Probe C is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } break; case 3: try { _trx.selectedPrbState(romStatus, prbD); if(romStatus.ConnectionMode == connected) { ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw"The crc error of the probe D eeprom is occured."; } } else { MESSAGE_BOX("Probe D is disconnected."); } } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } break; } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbRomImpulseRead_clicked() { try { auto sel = ui->cb_prbSelRom->currentIndex(); QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ /*********************************** AFE Configuration *******************************************/ /*************************************************************************************************/ void MainWindow::on_btn_afeRead_clicked() { auto sel = ui->cb_afeSlaveSelect->currentIndex(); auto offset = ui->tb_afeRegAddr->text().toUInt(nullptr, 16); QList afeArray; afeArray.clear(); ui->tb_afeRegsValueArray->clear(); switch(sel) { case 0: afeArray = _trx.getAfeReg(slave0, offset); break; case 1: afeArray = _trx.getAfeReg(slave1, offset); break; case 2: afeArray = _trx.getAfeReg(slave2, offset); break; } for(quint8 i = 0; i < afeArray.size(); i++) { ui->tb_afeRegsValueArray->appendPlainText(QString::number((afeArray.at(i)), 16)); } } /*************************************************************************************************/ void MainWindow::setAfeConfig() { _afeConfig.lowNf = lowNfDisable; _afeConfig.lnaHpf = lnaHpfEnable; _afeConfig.pgaHpf = pgaHpfEnable; _afeConfig.lpfProg = LpfProg10MHz; _afeConfig.pgaGain = pgaGain30db; _afeConfig.pgaClamp = pgaClampDisable; _afeConfig.powModes = lowNoise; _afeConfig.actTermEn = actTermEnable; _afeConfig.lnaGainGbl = lnaGainGbl24db; _afeConfig.lnaHpfProg = lnaHpfProg200Khz; _afeConfig.gblActiveTerm = gblActiveTerm50; _afeConfig.pgaClampLevel = minus2dbfs; _afeConfig.activeTermIndRes = actTermIndRes0; _afeConfig.activeTermIndResEn = actTermIndResDisable; _afeConfig.inputClampLevel = inputClampLvlAuto; } /*************************************************************************************************/ /*************************************** Built-in Test *******************************************/ /*************************************************************************************************/ void MainWindow::on_btn_biteBrowse_clicked() { QFileDialog fileDialog; fileDialog.setNameFilter("*.csv"); auto result = fileDialog.exec(); if(result) { auto selectedPath = fileDialog.selectedFiles()[0]; ui->tb_biteFilesPath->setText(selectedPath); _settings->setValue(BITE_FILE_PATH, selectedPath); } } /*************************************************************************************************/ void MainWindow::on_btn_setBiteLog_clicked() { try { auto scenStr = ui->btn_scenStart->text(); if(scenStr == "Scenario Stop") on_btn_scenStart_clicked(); // BITe log count registering auto biteLogCnt = ui->tb_biteLogCount->text().toUInt(Q_NULLPTR, 10); if(biteLogCnt == 0 && ui->tb_biteLogCount->text() != "0") { MESSAGE_BOX("Invalid input format for BITe log count"); return; } // BITe file reading to determine the I & Q of txDAC QString bitePath = ui->tb_biteFilesPath->text(); QFile biteFile(bitePath); QTextStream biteLog(&biteFile); if(biteFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!biteFile.open(QIODevice::ReadOnly)) { throw SonoException("Couldn't open built-in test file for frame logging"); } QStringList txDac; QByteArray I; QByteArray Q; while (!biteLog.atEnd()) { txDac.clear(); txDac = biteLog.readLine().split(","); I.append(static_cast(txDac.at(0).toInt())); Q.append(static_cast(txDac.at(1).toInt())); } _trx.setBiteDacData(I , Q); biteFile.close(); // BITe log file writing after scen player start and getting the frame packet QString biteLogPath = QFileDialog::getExistingDirectory(this, tr("BITe Log"), _biteLogFolder, QFileDialog::ShowDirsOnly); QFile biteLogFile(biteLogPath); if(biteLogFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_biteLogDone, str, color); _dmaBuffer.clear(); _dmaLog = true; _trx.biteScenPlayerStart(); QFuture biteLogFuture = QtConcurrent::run(this, &MainWindow::logPcie, biteLogPath, biteLogCnt); biteLogWatcher.setFuture(biteLogFuture); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::biteLogThreadFinished() { _trx.biteScenPlayerStop(); QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_biteLogDone, str, color); } /*************************************************************************************************/ void MainWindow::exitApp() { auto str = ui->btn_scenStart->text(); if(str == "Scenario Stop") on_btn_scenStart_clicked(); this->QWidget::close(); } /*************************************************************************************************/ /*************************************** Capture_Logger ******************************************/ /*************************************************************************************************/ void MainWindow::on_btn_setAdcLog_clicked() { // ADC log count registering auto adcLogCnt = ui->tb_adcLogCount->text().toUInt(); if(adcLogCnt == 0 && ui->tb_adcLogCount->text() != "0") { MESSAGE_BOX("Invalid input format for ADC logger count"); return; } // Sample count registering auto sampleCnt = ui->tb_sampleCount->text().toUInt(); if(sampleCnt == 0 && ui->tb_sampleCount->text() != "0") sampleCnt = 0; // sync count registering auto syncCnt = ui->tb_syncCount->text().toUInt(); if(syncCnt == 0 && ui->tb_syncCount->text() != "0") syncCnt = 0; // ADC capture start configuration eSyncMode syncMode; captureConfig capConfig; capConfig.capMode = allChannel; capConfig.manualTrig = false; capConfig.syncCount = syncCnt; capConfig.sampleCount = sampleCnt; _trx.adcCaptureStart(capConfig, syncMode); }