#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); _bpi = new BpiFlash(_usd->device); _spi = new SpiFlash(_usd->device); _healStatus = new HealthStatus; _supRbValue = new SupervisorRbValue; _faultStatus = new MpsFaultStatus; _version = new FpgaCodeVersion; _vec = new StatusVec; _emul = new EmulatorProperties; _prb = new PrbCase; _headerLogFile = new QFile(_headerLogPath); _headerEndurance = new QFile(_headerEndurancePath); QTime t = QTime::currentTime(); QDate d = QDate::currentDate(); QString statusLogPSPath = _statusVectorPSPath + "/" + "StatusPerSec" + "_" + QString::number(d.month()) + "." + QString::number(d.day()) + " " + QString::number(t.hour()) + ":" + QString::number(t.minute()) + ":" + QString::number(t.second()); _statusLogPSFile = new QFile(statusLogPSPath); movie = new QMovie("/home/hasis/Desktop/hardware/Develop_HardwareTest/gifs/Glass lines.gif"); movie->stop(); 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->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_mcsFilePath->setText(_settings->value(MCS_FILE_PATH).value()); ui->tb_scenFilesPath->setText(_settings->value(SCENARIO_FILE_PATH).value()); ui->tb_scenFolder->setText(_settings->value(SCENARIOS_FOLDER_PATH).value()); ui->tb_frameLogPath->setText(_settings->value(FRAME_LOG_PATH).value()); ui->tb_biteScenPath->setText(_settings->value(BITE_SCEN_FILE_PATH).value()); ui->tb_biteFilesPath->setText(_settings->value(BITE_FILE_PATH).value()); ui->tb_adcLogPath->setText(_settings->value(ADC_LOG_PATH).value()); ui->tb_prbRelayLogPath->setText(_settings->value(PROBE_LOG_PATH).value()); ui->tb_prbRomFilePath->setText(_settings->value(PRB_FILE_PATH).value()); ui->tb_trxRomId->setPlaceholderText("hex"); ui->tb_trxRomPid->setPlaceholderText("hex"); ui->tb_trxRomPcbVersion->setPlaceholderText("dec"); ui->tb_trxRomSerialNumber->setPlaceholderText("dec"); ui->tb_trxRomMasterCodeVersion->setPlaceholderText("dec"); ui->tb_trxRomSlaveCodeVersion->setPlaceholderText("dec"); ui->tb_prbCtrlRomId->setPlaceholderText("hex"); ui->tb_prbCtrlRomPid->setPlaceholderText("hex"); ui->tb_prbCtrlRomPcbVersion->setPlaceholderText("dec"); ui->tb_prbCtrlRomSerialNumber->setPlaceholderText("dec"); ui->tb_mpsRomId->setPlaceholderText("hex"); ui->tb_mpsRomPid->setPlaceholderText("hex"); ui->tb_mpsRomPcbVersion->setPlaceholderText("dec"); ui->tb_mpsRomSerialNumber->setPlaceholderText("dec"); ui->tb_mpsRomUcCodeVersion->setPlaceholderText("dec"); ui->tb_mpsRomSupCodeVersion->setPlaceholderText("dec"); ui->tb_prbRomIdRead->setPlaceholderText("id(hex)"); ui->tb_prbRomImpulseRead->setPlaceholderText("impulse"); ui->tb_prbRomFilePath->setPlaceholderText("Probe ROM File Path"); ui->tb_scenInfo->setPlaceholderText("Scenario Information"); ui->tb_minLogInput->setPlaceholderText(QString::number(MIN_LOG_INPUT_DEFAULT)); ui->tb_maxLogInput->setPlaceholderText(QString::number(MAX_LOG_INPUT_DEFAULT)); ui->tb_dynamicGain->setPlaceholderText(QString::number(GAIN_DEFAULT)); ui->tb_contrastNum->setPlaceholderText(QString::number(CONTRAST_NUM_DEFAULT)); trxIdWrEn = false; trxPidWrEn = false; trxPcbVesionWrEn = false; trxSerialNoWrEn = false; trxMasterCodeVersionWrEn = false; trxSlaveCodeVersionWrEn = false; prbCtrlIdWrEn = false; prbCtrlPidWrEn = false; prbCtrlPcbVesionWrEn = false; prbCtrlSerialNoWrEn = false; mpsIdWrEn = false; mpsPidWrEn = false; mpsPcbVesionWrEn = false; mpsSerialNoWrEn = false; mpsUcCodeVersionWrEn = false; mpsSupCodeVersionWrEn = false; connect(this, &MainWindow::adcLog, this, &MainWindow::catchAdcLog); 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(this, &MainWindow::statusLogPS, this, &MainWindow::catchStatusLogPS); connect(_timeout, &QTimer::timeout, this, &MainWindow::timeout); connect(this, &MainWindow::scenarioReady, this, &MainWindow::setScenario); connect(this, &MainWindow::labelState, this, &MainWindow::getLabelState); connect(&biteLogWatcher, &QFutureWatcher::finished, this, &MainWindow::biteLogThreadFinished); connect(&dmaLogWatcher, &QFutureWatcher::finished, this, &MainWindow::dmaLogThreadFinished); connect(&programWatcher, &QFutureWatcher::finished, this, &MainWindow::programThreadFinish); connect(&mcsProgWatcher, &QFutureWatcher::finished, this, &MainWindow::mcsThreadFinish); connect(&mcsReadWatcher, &QFutureWatcher::finished, this, &MainWindow::mcsReadFinish); connect(this, &MainWindow::programmingGif, this, &MainWindow::getProgrammingGif); //////////////////////// DMA Packet Connections ////////////////////////////// connect(&_trx, &TrxBoard::sendFramePacket, this, &MainWindow::getFramePacket); 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); ///////////////////////// BPI Timeout Connections ///////////////////////////// connect(_bpi, &BpiFlash::startTimerShot, this, &MainWindow::flashTimerShot); connect(_bpi, &BpiFlash::remainingTime, this, &MainWindow::flashTimeout); connect(_bpi, &BpiFlash::stopTimer, this, &MainWindow::flashStopTimer); ///////////////////////// Temp Connections ///////////////////////////// connect(this, &MainWindow::gtReset, this, &MainWindow::catchGtReset); connect(this, &MainWindow::statusLog, this, &MainWindow::catchStatusLog); connect(this, &MainWindow::endurance, this, &MainWindow::catchEndurance); ui->btn_updateRdbackValue->setText(UPDATE); dmaLogLayoutVisible(false); ui->chk_continuousShowing->hide(); ui->btn_dmaShow->hide(); ui->chk_logCountEn->setChecked(false); ui->tb_adcLogCount->setEnabled(false); ui->chk_pulserTstModeEn->setChecked(false); ui->tb_afeRegAddr->setText("C5"); ui->chk_prbRomWrEn->setChecked(false); ui->sb_Fan1Pwm->setSuffix(" %"); ui->sb_Fan2Pwm->setSuffix(" %"); QColor discardColor = Qt::darkRed; ui->btn_discard->button(QDialogButtonBox::Discard)->setStyleSheet(QString("background:%1").arg( discardColor.name())); ui->btn_discard->update(); QColor discardAdcLogColor = Qt::red; ui->btn_discardAdcLog->button(QDialogButtonBox::Discard)->setStyleSheet(QString( "background:%1").arg( discardAdcLogColor. name())); ui->btn_discardAdcLog->update(); 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); _dmaLog = false; _dmaRun = false; _fpsFlag = false; _dmaShow = false; _headerLogEn = false; _statusLogEn = false; _headerEndur = false; _firstFrameEn = false; _discardTempTest = false; _discardAdcLog = false; _isDynamicContrast = false; _programFlag = true; _frameCount = 0; lcdStyle(ui->lcd_dmaCounter); lcdStyle(ui->lcd_biteCounter); lcdStyle(ui->lcd_adcCounter); dynamicContrastMinLogInput = MIN_LOG_INPUT_DEFAULT; dynamicContrastMaxLogInput = MAX_LOG_INPUT_DEFAULT; dynamicContrastGain = GAIN_DEFAULT; contrastNumber = CONTRAST_NUM_DEFAULT; readDynamicContrastParameters(dynamicContrastParams); try { _trx.init(); if(_trx.isScenarioStart()) { ui->btn_scenStart->setText("Scenario Stop"); on_btn_scenStart_clicked(); } ui->cb_selectedProbe->setCurrentIndex(3); ui->cb_prbSelRom->setCurrentIndex(3); currentSelectedPrb = prbD; _trx.setTrxFanRpm(fan1, static_cast(ui->sb_Fan1Pwm->value())); _trx.setTrxFanRpm(fan2, static_cast(ui->sb_Fan2Pwm->value())); } catch(const char* exception) { qDebug() << exception; } catch(SonoException& e) { qDebug() << e.what(); } _timeout->start(1000); //////////////////////////// First Time Probe Detection ////////////////////////////// #ifdef MPS_BOARD emit connectedPrbChange(); #endif } MainWindow::~MainWindow() { if(!(_statusLogPSFile->isOpen())) { _statusLogPSFile->flush(); _statusLogPSFile->close(); } delete ui; delete _settings; delete _usd; delete _timeout; delete _healStatus; delete _bCtrl; delete _bpi; delete _spi; delete _supRbValue; delete _faultStatus; delete _version; delete _vec; delete _emul; delete _prb; delete movie; delete _headerLogFile; delete _headerEndurance; delete _colorMap; delete _statusLogPSFile; } /*************************************************************************************************/ void MainWindow::timeout() { try { 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); /***************** Fpga Core Monitoring ********************/ double masterCoreTemp = static_cast(_healStatus->fpgaCoreTemperature->master); ui->l_masterCoreTemp->setText(QString::number(masterCoreTemp, 'g', 4)); delay(1); double masterCoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.master); ui->l_masterCoreVccInt->setText(QString::number(masterCoreVccInt, 'g', 3)); delay(1); double masterCoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.master); ui->l_masterCoreVccAux->setText(QString::number(masterCoreVccAux, 'g', 4)); delay(1); double masterCoreVccBram = static_cast(_healStatus->fpgaCoreVoltages->vccBram.master); ui->l_masterCoreVccBram->setText(QString::number(masterCoreVccBram, 'g', 3)); delay(1); if(_programFlag) { if(MOUNTED_SLAVE_FPGA & 1) { double slave0CoreTemp = static_cast(_healStatus->fpgaCoreTemperature->slave0); ui->l_slave0CoreTemp->setText(QString::number(slave0CoreTemp, 'g', 4)); delay(1); double slave0CoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.slave0); ui->l_slave0CoreVccInt->setText(QString::number(slave0CoreVccInt, 'g', 3)); delay(1); double slave0CoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.slave0); ui->l_slave0CoreVccAux->setText(QString::number(slave0CoreVccAux, 'g', 4)); delay(1); double slave0CoreVccBram = static_cast(_healStatus->fpgaCoreVoltages->vccBram.slave0); ui->l_slave0CoreVccBram->setText(QString::number(slave0CoreVccBram, 'g', 3)); delay(1); } if(MOUNTED_SLAVE_FPGA & 2) { double slave1CoreTemp = static_cast(_healStatus->fpgaCoreTemperature->slave1); ui->l_slave1CoreTemp->setText(QString::number(slave1CoreTemp, 'g', 4)); delay(1); double slave1CoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.slave1); ui->l_slave1CoreVccInt->setText(QString::number(slave1CoreVccInt, 'g', 3)); delay(1); double slave1CoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.slave1); ui->l_slave1CoreVccAux->setText(QString::number(slave1CoreVccAux, 'g', 4)); delay(1); double slave1CoreVccBram = static_cast(_healStatus->fpgaCoreVoltages->vccBram.slave1); ui->l_slave1CoreVccBram->setText(QString::number(slave1CoreVccBram, 'g', 3)); delay(1); } if(MOUNTED_SLAVE_FPGA & 4) { double slave2CoreTemp = static_cast(_healStatus->fpgaCoreTemperature->slave2); ui->l_slave2CoreTemp->setText(QString::number(slave2CoreTemp, 'g', 4)); delay(1); double slave2CoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.slave2); ui->l_slave2CoreVccInt->setText(QString::number(slave2CoreVccInt, 'g', 3)); delay(1); double slave2CoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.slave2); ui->l_slave2CoreVccAux->setText(QString::number(slave2CoreVccAux, 'g', 4)); delay(1); double slave2CoreVccBram = static_cast(_healStatus->fpgaCoreVoltages->vccBram.slave2); ui->l_slave2CoreVccBram->setText(QString::number(slave2CoreVccBram, 'g', 3)); delay(1); } } else { QList label {ui->l_slave0CoreTemp, ui->l_slave1CoreTemp, ui->l_slave2CoreTemp, ui->l_slave0CoreVccInt, ui->l_slave1CoreVccInt, ui->l_slave2CoreVccInt, ui->l_slave0CoreVccAux, ui->l_slave1CoreVccAux, ui->l_slave2CoreVccAux, ui->l_slave0CoreVccBram, ui->l_slave1CoreVccBram, ui->l_slave2CoreVccBram}; foreach(auto& l, label) { l->setText("ukn"); delay(1); } } /******************* System Monitoring *********************/ float tempSensor = _healStatus->systemTemperature; ui->l_Temp->setText(QString("%1").arg(static_cast(tempSensor))); delay(1); float mpsTempSensor = _healStatus->mpsTemperature; ui->l_mpsTemp->setText(QString("%1").arg(static_cast(mpsTempSensor))); delay(1); auto adcCh1 = _healStatus->adcMon->mon12Vin; ui->l_adcCh1->setText(QString("%1").arg(static_cast(adcCh1))); delay(1); auto adcCh2 = _healStatus->adcMon->mon5Vin; ui->l_adcCh2->setText(QString("%1").arg(static_cast(adcCh2))); delay(1); auto adcCh3 = _healStatus->adcMon->prbZeroEncoder; ui->l_adcCh3->setText(QString("%1").arg(static_cast(adcCh3))); delay(1); auto adcCh4 = _healStatus->adcMon->prbCtrl3P3V; ui->l_adcCh4->setText(QString("%1").arg(static_cast(adcCh4))); delay(1); auto adcCh5 = _healStatus->adcMon->afeVcntlp; ui->l_adcCh5->setText(QString("%1").arg(static_cast(adcCh5))); delay(1); auto adcCh6 = _healStatus->adcMon->mon3P3V; ui->l_adcCh6->setText(QString("%1").arg(static_cast(adcCh6))); delay(1); auto adcCh7 = _healStatus->adcMon->monAfeA1P8V; ui->l_adcCh7->setText(QString("%1").arg(static_cast(adcCh7))); delay(1); auto adcCh8 = _healStatus->adcMon->monAfeD1P8V; ui->l_adcCh8->setText(QString("%1").arg(static_cast(adcCh8))); delay(1); quint32 tachoFan1 = static_cast(_healStatus->fanRpm->fan1); ui->l_tachoFan1->setText((tachoFan1) ? "On" : "Off"); delay(1); quint32 tachoFan2 = static_cast(_healStatus->fanRpm->fan2); ui->l_tachoFan2->setText((tachoFan2) ? "On" : "Off"); delay(1); /******************* Power Good *********************/ auto regAPg = _healStatus->voltsPg->regulatorA; ui->l_pgRegA->setText(enum2String(regAPg)); delay(1); auto regBPg = _healStatus->voltsPg->regulatorB; ui->l_pgRegB->setText(enum2String(regBPg)); delay(1); auto pg12v = _healStatus->voltsPg->mon12Vin; ui->l_pg12Vin->setText(enum2String(pg12v)); delay(1); auto pg5v = _healStatus->voltsPg->mon5Vin; ui->l_pg5Vin->setText(enum2String(pg5v)); delay(1); auto Pg3P3 = _healStatus->voltsPg->mon3P3V; ui->l_pg3P3->setText(enum2String(Pg3P3)); delay(1); auto pgAvdd = _healStatus->voltsPg->monAfeA1P8V; ui->l_pg1P8Avdd->setText(enum2String(pgAvdd)); delay(1); auto pgDvdd = _healStatus->voltsPg->monAfeD1P8V; ui->l_pg1P8Dvdd->setText(enum2String(pgDvdd)); delay(1); auto pgPrbCtrl = _healStatus->voltsPg->prbCtrl3P3V; ui->l_pgPrbCtrl3P3->setText(enum2String(pgPrbCtrl)); delay(1); /******************* 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(1); bool mpsErr = _vec->mpsErr; ui->l_mps->setText(QVariant(mpsErr).toString()); color = mpsErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_mps, color); delay(1); bool frameLost = _vec->dintrlvFrameLost; ui->l_frameLost->setText(QVariant(frameLost).toString()); color = frameLost ? Qt::red : Qt::green; changeLabelTextColor(ui->l_frameLost, color); delay(1); bool fanFault = (_vec->fan1Fault) | (_vec->fan2Fault); ui->l_fan->setText(QVariant(fanFault).toString()); color = fanFault ? Qt::red : Qt::green; changeLabelTextColor(ui->l_fan, color); delay(1); bool pulserThd = _vec->pulserThd; ui->l_pulserThd->setText(QVariant(pulserThd).toString()); color = pulserThd ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pulserThd, color); delay(1); bool scenSyncAckErr = _vec->scenSyncAckErr; ui->l_scenSyncAck->setText(QVariant(scenSyncAckErr).toString()); color = scenSyncAckErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenSyncAck, color); delay(1); bool scenPriErr = _vec->scenPriErr; ui->l_scenPri->setText(QVariant(scenPriErr).toString()); color = scenPriErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenPri, color); delay(1); bool thermalErr = _vec->thermalErr; ui->l_thermal->setText(QVariant(thermalErr).toString()); color = thermalErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_thermal, color); delay(1); bool scenSramErr = _vec->scenSramErr; ui->l_scenSram->setText(QVariant(scenSramErr).toString()); color = scenSramErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenSram, color); delay(1); bool syncFifoErr = _vec->mlaSyncFifoErr; ui->l_syncFifo->setText(QVariant(syncFifoErr).toString()); color = syncFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncFifo, color); delay(1); bool syncPointErr = _vec->mlaSyncPointErr; ui->l_syncPoint->setText(QVariant(syncPointErr).toString()); color = syncPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncPoint, color); delay(1); bool dintrlvFifoErr = _vec->dintrlvFifoErr; ui->l_dintrlvFifo->setText(QVariant(dintrlvFifoErr).toString()); color = dintrlvFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvFifo, color); delay(1); bool dintrlvPointErr = _vec->dintrlvPointErr; ui->l_dintrlvPoint->setText(QVariant(dintrlvPointErr).toString()); color = dintrlvPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvPoint, color); delay(1); bool sram1ParityErr = _vec->sram1ParityErr; ui->l_sram1Parity->setText(QVariant(sram1ParityErr).toString()); color = sram1ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram1Parity, color); delay(1); bool sram2ParityErr = _vec->sram2ParityErr; ui->l_sram2Parity->setText(QVariant(sram2ParityErr).toString()); color = sram2ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram2Parity, color); delay(1); bool dmaCtrlTransferErr = _vec->dmaCtrlTransferErr; ui->l_DmaCtrlTrans->setText(QVariant(dmaCtrlTransferErr).toString()); color = dmaCtrlTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_DmaCtrlTrans, color); delay(1); bool emulDmaTransferErr = _vec->emulDmaTransferErr; ui->l_emulDmaTrans->setText(QVariant(emulDmaTransferErr).toString()); color = emulDmaTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_emulDmaTrans, color); delay(1); bool probeDisconnectErr = _vec->probeDisconnectErr; ui->l_prbDiscon->setText(QVariant(probeDisconnectErr).toString()); color = probeDisconnectErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDiscon, color); delay(1); bool probeDetChanInterrupt = _vec->probeDetChanInterrupt; ui->l_prbDetChg->setText(QVariant(probeDetChanInterrupt).toString()); color = probeDetChanInterrupt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDetChg, color); delay(1); bool adcFlagSyncErr = _vec->adcFlagSyncErr; ui->l_adcFlagSync->setText(QVariant(adcFlagSyncErr).toString()); color = adcFlagSyncErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_adcFlagSync, color); delay(1); bool ddcLpfReloadErr = _vec->ddcLpfReloadErr; ui->l_ddcLpfReload->setText(QVariant(ddcLpfReloadErr).toString()); color = ddcLpfReloadErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_ddcLpfReload, color); delay(1); bool dintrlvOffsetAddrErr = _vec->dintrlvOffsetAddrErr; ui->l_dintrlvOffsetAddr->setText(QVariant(dintrlvOffsetAddrErr).toString()); color = dintrlvOffsetAddrErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvOffsetAddr, color); delay(1); bool dintrlvSramOver4MErr = _vec->dintrlvSramOver4MErr; ui->l_dintrlvSramOver4M->setText(QVariant(dintrlvSramOver4MErr).toString()); color = dintrlvSramOver4MErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvSramOver4M, color); delay(1); if(_statusLogEn) { emit statusLogPS(_usd->readWord(0, 0)); } if(probeDetChanInterrupt) { emit connectedPrbChange(); } if(frameLost) { emit frameLostCall(); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_statusLogPS_clicked(bool checked) { try { if(checked) { if(!(_statusLogPSFile->isOpen())) { if(_statusLogPSFile->fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!_statusLogPSFile->open(QIODevice::WriteOnly)) { throw SonoException("Couldn't open file for logging"); } } _statusLogEn = true; } else { _statusLogEn = false; } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::catchStatusLogPS(const quint32& statLogPS) { try { QTextStream statusLogPS(_statusLogPSFile); statusLogPS << QString::number(statLogPS, 16) << endl; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ 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 SonoException("The crc error of the probe A eeprom is occured."); } } else { if(currentSelectedPrb == prbA && _trx.isScenarioStart()) { on_btn_scenStart_clicked(); } ui->table_probe->setItem(0, 0, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 0); } } catch(SonoException& e) { qDebug() << e.what(); } 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 SonoException("The crc error of the probe B eeprom is occured."); } } else { if(currentSelectedPrb == prbB && _trx.isScenarioStart()) { on_btn_scenStart_clicked(); } ui->table_probe->setItem(0, 1, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 1); } } catch(SonoException& e) { qDebug() << e.what(); } 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 SonoException("The crc error of the probe C eeprom is occured."); } } else { if(currentSelectedPrb == prbC && _trx.isScenarioStart()) { on_btn_scenStart_clicked(); } ui->table_probe->setItem(0, 2, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 2); } } catch(SonoException& e) { qDebug() << e.what(); } 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 SonoException("The crc error of the probe D eeprom is occured."); } } else { if(currentSelectedPrb == prbD && _trx.isScenarioStart()) { on_btn_scenStart_clicked(); } ui->table_probe->setItem(0, 3, new QTableWidgetItem("Disconnected")); QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 3); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ 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::lcdStyle(QLCDNumber* lcdNum) { QFont font; font.setBold(true); font.setItalic(true); QPalette lcdPalette; lcdPalette.setColor(QPalette::Background, QColor(0, 180, 255)); lcdPalette.setColor(QPalette::Foreground, QColor(0, 0, 0)); lcdNum->setMode(QLCDNumber::Dec); lcdNum->setSegmentStyle(QLCDNumber::Flat); lcdNum->setPalette(lcdPalette); lcdNum->setAutoFillBackground(true); lcdNum->setFont(font); } /*************************************************************************************************/ 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); } } /*************************************************************************************************/ 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 *= 2; } value = _usd->readShort(offset, bar); ui->lcd_regvalue->setDigitCount(8); break; case 1: if(ui->rbtn_reg->isChecked()) { offset *= 4; } value = _usd->readWord(offset, bar); ui->lcd_regvalue->setDigitCount(8); break; case 2: 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 *= 2; } _usd->writeShort(offset, bar, static_cast(value)); break; case 1: if(ui->rbtn_reg->isChecked()) { offset *= 4; } _usd->writeWord(offset, bar, static_cast(value)); break; case 2: if(ui->rbtn_reg->isChecked()) { offset *= 8; } _usd->writeLong(offset, bar, value); break; } } /*************************************************************************************************/ /************************************* Slave Programming *****************************************/ /*************************************************************************************************/ void MainWindow::on_btn_fpgaBrowse_clicked() { try { QString fpgaProgramPath = QFileDialog::getOpenFileName(this, tr("FPGA Programming File"), _fpgaProgramFolder, "*.bit"); if(fpgaProgramPath.isEmpty()) { throw SonoException("No file is selected."); } ui->tb_fpgaBit->setText(fpgaProgramPath); _settings->setValue(FPGA_FILE_PATH, fpgaProgramPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::fpgaProgram(QString& path) { try { if(path.isEmpty()) { throw SonoException("No file is selected."); } _trx.slaveFpgaProgram(path); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::programThreadFinish() { try { #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); _trx.gtReadReset(); _trx.sonoHeartBeatsEnable(); #endif QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_programDone, str, color); movie->stop(); ui->l_programming->hide(); _programFlag = true; slaveProgButtonsEnable(true); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_fpgaProgram_clicked() { try { _programFlag = false; slaveProgButtonsEnable(false); auto path = ui->tb_fpgaBit->text(); if(path.isEmpty()) { throw SonoException("No file is selected."); } QFuture programFuture = QtConcurrent::run(this, &MainWindow::fpgaProgram, path); programWatcher.setFuture(programFuture); QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); emit programmingGif(ui->l_programming); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ /************************************* MCS Programming *******************************************/ /*************************************************************************************************/ void MainWindow::mcsProgram(QString& path) { try { if(path.isEmpty()) { throw SonoException("No file is selected."); } auto flashSel = ui->cb_flashSelect->currentIndex(); switch(flashSel) { case 0: _trx.spiFlashProgram(path); break; case 1: _trx.mcsProgram(path); break; } } catch(SonoException& e) { mcsButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::mcsThreadFinish() { try { QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_mcsProgramDone, str, color); movie->stop(); ui->l_mcsProgramming->hide(); mcsButtonsEnable(true); } catch(SonoException& e) { mcsButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::mcsRead(QString& path) { try { if(path.isNull()) { throw SonoException("No file is selected."); } auto flashSel = ui->cb_flashSelect->currentIndex(); switch(flashSel) { case 0: _trx.spiFlashRead(path); break; case 1: _trx.mcsVerify(path); break; } } catch(SonoException& e) { mcsButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::mcsReadFinish() { try { QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_mcsReadDone, str, color); movie->stop(); ui->l_mcsProgramming->hide(); mcsButtonsEnable(true); } catch(SonoException& e) { mcsButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mcsBrowse_clicked() { try { QString mcsProgramPath = QFileDialog::getOpenFileName(this, tr("Flash Bin File"), _mcsProgramFolder, "*.bin"); if(mcsProgramPath.isEmpty() || mcsProgramPath.isNull()) { throw SonoException("No file is selected."); } ui->tb_mcsFilePath->setText(mcsProgramPath); _settings->setValue(MCS_FILE_PATH, mcsProgramPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mcsProgram_clicked() { try { mcsButtonsEnable(false); auto path = ui->tb_mcsFilePath->text(); if(path.isEmpty()) { throw SonoException("No file is selected."); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_mcsProgramDone, str, color); QFuture mcsProgFuture = QtConcurrent::run(this, &MainWindow::mcsProgram, path); mcsProgWatcher.setFuture(mcsProgFuture); emit programmingGif(ui->l_mcsProgramming); } catch(SonoException& e) { mcsButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_mcsRead_clicked() { try { mcsButtonsEnable(false); QString mcsSavePath = QFileDialog::getExistingDirectory(this, tr("Flash Bin Reading"), _mcsVerifyFolder, QFileDialog::ShowDirsOnly); if(mcsSavePath.isEmpty()) { throw SonoException("No file is selected"); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_mcsReadDone, str, color); QFuture mcsReadFuture = QtConcurrent::run(this, &MainWindow::mcsRead, mcsSavePath); mcsReadWatcher.setFuture(mcsReadFuture); emit programmingGif(ui->l_mcsProgramming); } catch(SonoException& e) { mcsButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::flashTimerShot(qint32 ms) { _flashTimer.setSingleShot(true); _flashTimer.setInterval(ms); _flashTimer.start(); } /*************************************************************************************************/ void MainWindow::flashTimeout(QString message) { if(_flashTimer.remainingTime() == 0) { throw SonoException(message.toStdString()); } } /*************************************************************************************************/ void MainWindow::flashStopTimer() { _flashTimer.stop(); } /*************************************************************************************************/ /*************************************************************************************************/ void MainWindow::mcsButtonsEnable(bool Enable) { QList button = {ui->btn_fpgaProgram, ui->btn_mcsProgram, ui->btn_mcsRead}; foreach(auto& btn, button) { btn->setEnabled(Enable); } } /*************************************************************************************************/ void MainWindow::slaveProgButtonsEnable(bool Enable) { QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_mcsProgram, ui->btn_mcsRead, ui->btn_gtReg, }; foreach(auto& btn, button) { btn->setEnabled(Enable); } } /*************************************************************************************************/ void MainWindow::logButtonsEnable(bool Enable) { QList button = {ui->btn_setBiteLog, ui->btn_setAdcLog, ui->btn_dmaLogLast}; foreach(auto& btn, button) { btn->setEnabled(Enable); } } /*************************************************************************************************/ void MainWindow::getProgrammingGif(QLabel* label) { movie->setSpeed(100); label->setMovie(movie); label->show(); movie->start(); } /*************************************************************************************************/ void MainWindow::getLabelState(QLabel* label, QString str, QColor color) { label->setText(str); changeLabelTextColor(label, color); label->repaint(); qApp->processEvents(); } /*************************************************************************************************/ void MainWindow::newMessage(QString message) { QMessageBox msgBox; msgBox.setText(message); msgBox.exec(); } /*************************************************************************************************/ void MainWindow::on_cb_selectedProbe_currentIndexChanged(int index) { auto indx = index; if(_trx.isScenarioStart()) { on_btn_scenStart_clicked(); } if(indx == 0) { _trx.selectProbe(prbA); currentSelectedPrb = prbA; } else if(indx == 1) { _trx.selectProbe(prbB); currentSelectedPrb = prbB; } else if(indx == 2) { _trx.selectProbe(prbC); currentSelectedPrb = prbC; } else { _trx.selectProbe(prbD); currentSelectedPrb = prbD; } } /*************************************************************************************************/ void MainWindow::delay(quint16 ms) { this->_bCtrl->timerShot(ms); //uncrustify off while(!(this->_bCtrl->checkTimeout())); //uncrustify on } /*************************************************************************************************/ void MainWindow::delayEvents(quint16 ms) { QEventLoop loop; QTimer timer; connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); timer.start(ms); loop.exec(); timer.stop(); } /*************************************************************************************************/ const QString MainWindow::enum2String(ePg state) const { QString pg; pg = (state) ? "good" : "bad"; return pg; } /*************************************************************************************************/ void MainWindow::dynamicContrastCsvRead(const QString &path) { QFile csvReadFile(path); if(!csvReadFile.open(QFile::ReadOnly)) { return; } qint64 readSize = 0; QString line; QList data; auto size = csvReadFile.size(); while(readSize < size) { data.clear(); line = csvReadFile.readLine(); auto sl = line.split(','); foreach(auto &str, sl) { data.push_back(str.toFloat()); } dynamicTotalData.push_back(data); readSize += static_cast(line.length()); } csvReadFile.close(); } /*************************************************************************************************/ void MainWindow::on_btn_dynConSetParams_clicked() { try { if(ui->tb_minLogInput->text().length() > 0) { dynamicContrastMinLogInput = ui->tb_minLogInput->text().toFloat(); } else { dynamicContrastMinLogInput = MIN_LOG_INPUT_DEFAULT; } if(ui->tb_maxLogInput->text().length() > 0) { dynamicContrastMaxLogInput = ui->tb_maxLogInput->text().toFloat(); } else { dynamicContrastMaxLogInput = MAX_LOG_INPUT_DEFAULT; } if(ui->tb_dynamicGain->text().length() > 0) { dynamicContrastGain = ui->tb_dynamicGain->text().toFloat(); } else { dynamicContrastGain = GAIN_DEFAULT; } if(ui->tb_contrastNum->text().length() > 0) { contrastNumber = static_cast(ui->tb_contrastNum->text().toUShort()); } else { contrastNumber = CONTRAST_NUM_DEFAULT; } readDynamicContrastParameters(dynamicContrastParams); } catch(SonoException &e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_dynamicContrast_clicked(bool checked) { _isDynamicContrast = checked; } /*************************************************************************************************/ void MainWindow::readDynamicContrastParameters(DynamicContrastParameters ¶ms) { params.gain = log2(pow(10.0f, (dynamicContrastGain / 20.0f))) * pow(2.0f, 11.0f); params.max_output_level = MAX_OUTPUT_LEVEL; params.min_output_level = MIN_OUTPUT_LEVEL; params.max_log_input_level = MAX_LOG_INPUT_LEVEL; params.app_max_log_input_level = dynamicContrastMaxLogInput * pow(2.0f, 11.0f); params.app_min_log_input_level = dynamicContrastMinLogInput * pow(2.0f, 11.0f); params.const_piecewise_y = dynamicTotalData.at(contrastNumber - 1); QList piecewise_x; for (auto i = 0; i < 256; i++) { piecewise_x.push_back(i); } params.const_piecewise_x = piecewise_x; } /*************************************************************************************************/ /*********************************************DMA*************************************************/ /*************************************************************************************************/ void MainWindow::getFramePacket(QByteArray packet) { quint16 batchId = ((static_cast(packet[128])) & 0x00FF) | (((static_cast(packet[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(packet[130])); quint8 frmType = (static_cast(packet[131])); quint8 cri = (static_cast(packet[132])); quint16 bLine = ((static_cast(packet[136])) & 0x00FF) | (((static_cast(packet[137])) << 8) & 0xFF00); quint16 bPoint = ((static_cast(packet[138])) & 0x00FF) | (((static_cast(packet[139])) << 8) & 0xFF00); quint8 mLine = (static_cast(packet[140])); quint16 mPoint = ((static_cast(packet[141])) & 0x00FF) | (((static_cast(packet[142])) << 8) & 0xFF00); if(_headerLogEn) { QTextStream _headerLog(_headerLogFile); _headerLog << batchId << ","; _headerLog << subBatchId << ","; _headerLog << bLine << ","; _headerLog << bPoint << ","; _headerLog << frmType << ","; _headerLog << cri << ","; _headerLog << mLine << ","; _headerLog << mPoint << ","; _headerLog << endl; } if(_headerEndur) { QTextStream headerLog(_headerEndurance); headerLog << batchId << ","; headerLog << subBatchId << ","; headerLog << bLine << ","; headerLog << bPoint << ","; headerLog << frmType << ","; headerLog << cri << ","; headerLog << mLine << ","; headerLog << mPoint << ","; headerLog << endl; } _mutex.lock(); _dmaBuffer.push_back(packet); if(_lastBuffer.size() != 0) { quint16 batchIdBuffer = ((static_cast(_lastBuffer[128])) & 0x00FF) | (((static_cast(_lastBuffer[129])) << 8) & 0xFF00); if(ui->btn_scenStart->text() == "Scenario Stop") { if((batchId - batchIdBuffer) > 1) { on_btn_scenStart_clicked(); qDebug() << "The batch id error is happened."; _mutex.unlock(); return; } } _frame.push_back(_lastBuffer); if((batchId != batchIdBuffer) && (subBatchId == 0)) { _bufferedFrame.clear(); _bufferedFrame = _frame; _frame.clear(); _frameCount++; } } _lastBuffer = packet; _mutex.unlock(); } /*************************************************************************************************/ 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(); dmaLogLayoutVisible(false); } else { _dmaShow = false; ui->btn_dmaShow->show(); dmaLogLayoutVisible(true); } } /*************************************************************************************************/ bool MainWindow::hvPermission() { bool permission(false); try { _trx.supervisorRbValue(_supRbValue); auto hvapValue = _supRbValue->hvap; if(hvapValue >= 3.0f) { _trx.prbState(_prb); if(currentSelectedPrb == prbA) { if(_prb->prbA.ConnectionMode == connected) { permission = true; } else { permission = false; throw SonoException("Probe A not connected, so can't be selected."); } } if(currentSelectedPrb == prbB) { if(_prb->prbB.ConnectionMode == connected) { permission = true; } else { permission = false; throw SonoException("Probe B not connected, so can't be selected."); } } if(currentSelectedPrb == prbC) { if(_prb->prbC.ConnectionMode == connected) { permission = true; } else { permission = false; throw SonoException("Probe C not connected, so can't be selected."); } } if(currentSelectedPrb == prbD) { if(_prb->prbD.ConnectionMode == connected) { permission = true; } else { permission = false; throw SonoException("Probe D not connected, so can't be selected."); } } } else { permission = true; } } catch(SonoException& e) { permission = false; qDebug() << e.what(); } return permission; } /*************************************************************************************************/ void MainWindow::on_btn_scenStart_clicked() { _frameCount = 0; try { auto str = ui->btn_scenStart->text(); if(str == "Scenario Start") { _trx.powerAo(true); delay(100); if(hvPermission()) { _trx.preSubBatch = -1; _trx.preBatch = 0; _frame.clear(); _lastBuffer.clear(); _bufferedFrame.clear(); QString dmaLogPath = ui->tb_frameLogPath->text(); if(dmaLogPath.isEmpty()) { throw SonoException("No file is selected"); } ui->btn_scenStart->setText("Scenario Stop"); ui->btn_emulator->setText("Emulator Start"); _trx.scenPlayerStart(true); _dmaRun = true; //flag _dmaBuffer.clear(); dmaLogLayoutVisible(true); ui->chk_continuousShowing->show(); ui->btn_dmaShow->show(); if(ui->chk_firstFrameLogEn->isChecked()) { _dmaLog = true; QtConcurrent::run(this, &MainWindow::logPcie, dmaLogPath, LOG_COUNT_FROM_FIRST, ui->lcd_dmaCounter); } } else { _trx.powerAo(false); } } else { _dmaRun = false; _dmaLog = false; ui->btn_scenStart->setText("Scenario Start"); ui->chk_continuousShowing->setChecked(false); on_chk_continuousShowing_clicked(); dmaLogLayoutVisible(false); ui->chk_continuousShowing->hide(); ui->btn_dmaShow->hide(); ui->chk_headerLogEn->setChecked(false); on_chk_headerLogEn_clicked(false); _trx.scenPlayerStop(true); } } catch(SonoException& e) { _frame.clear(); _lastBuffer.clear(); _bufferedFrame.clear(); ui->chk_headerLogEn->setChecked(false); on_chk_headerLogEn_clicked(false); ui->chk_continuousShowing->hide(); ui->btn_dmaShow->hide(); ui->btn_scenStart->setText("Scenario Start"); _trx.scenPlayerStop(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_emulator_clicked() { _frameCount = 0; auto name = ui->btn_emulator->text(); try { if(name == "Emulator Start") { _frame.clear(); _lastBuffer.clear(); _bufferedFrame.clear(); QString dmaLogPath = ui->tb_frameLogPath->text(); if(dmaLogPath.isEmpty()) { throw SonoException("No file is selected"); } 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); ui->chk_continuousShowing->show(); ui->btn_dmaShow->show(); _trx.emulatorStart(); _dmaRun = true; _dmaBuffer.clear(); if(ui->chk_firstFrameLogEn->isChecked()) { _dmaLog = true; QtConcurrent::run(this, &MainWindow::logPcie, dmaLogPath, LOG_COUNT_FROM_FIRST, ui->lcd_dmaCounter); } } else { _dmaLog = false; _dmaRun = false; ui->btn_emulator->setText("Emulator Start"); ui->chk_continuousShowing->setChecked(false); on_chk_continuousShowing_clicked(); dmaLogLayoutVisible(false); ui->chk_continuousShowing->hide(); ui->btn_dmaShow->hide(); ui->chk_headerLogEn->setChecked(false); on_chk_headerLogEn_clicked(false); _trx.emulatorStop(); } } catch(SonoException& e) { _frame.clear(); _lastBuffer.clear(); _bufferedFrame.clear(); ui->chk_headerLogEn->setChecked(false); on_chk_headerLogEn_clicked(false); ui->chk_continuousShowing->hide(); ui->btn_dmaShow->hide(); ui->btn_emulator->setText("Emulator Start"); _trx.emulatorStop(); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::logPcie(QString logPath, quint32 logCount, QLCDNumber* lcdCounter) { try { if(logPath.isEmpty()) { throw SonoException("No file is selected"); } _dmaLogCount = 0; quint32 i(0); while(_dmaLog) { qApp->processEvents(); if(_dmaBuffer.size() == 0) { std::this_thread::sleep_for(std::chrono::milliseconds(3)); continue; } QByteArray temp; qApp->processEvents(); _mutex.lock(); temp = _dmaBuffer.front(); _dmaBuffer.pop_front(); _mutex.unlock(); _dmaLogCount += 1; quint16 batchId = ((static_cast(temp[128])) & 0x00FF) | (((static_cast(temp[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(temp[130])); qApp->processEvents(); QString path = logPath + QString("/batch(%2)_sbatch(%3)_%1.bin").arg(i++).arg(batchId).arg( subBatchId); QFile file(path); qApp->processEvents(); if(!file.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't save DMA log file for frame logging"); } qApp->processEvents(); file.write(temp); file.close(); lcdCounter->display(qint32(_dmaLogCount)); qApp->processEvents(); if(_dmaLogCount == logCount) { _dmaLog = false; } } } catch(SonoException& e) { qDebug() << e.what(); _dmaLog = false; } } /*************************************************************************************************/ void MainWindow::on_btn_frameLogBrowse_clicked() { try { QString frameLogPath = QFileDialog::getExistingDirectory(this, tr("Frame Log"), _frameLogFolder, QFileDialog::ShowDirsOnly); if(frameLogPath.isEmpty()) { throw SonoException("No file is selected"); } ui->tb_frameLogPath->setText(frameLogPath); _settings->setValue(FRAME_LOG_PATH, frameLogPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_dmaLogLast_clicked() { try { auto dmaLogCnt = ui->tb_dmaLogCount->text().toUInt(Q_NULLPTR, 10); if(dmaLogCnt == 0 && ui->tb_dmaLogCount->text() != "0") { MESSAGE_BOX("Invalid input format for DMA log count"); return; } QString dmaLogPath = ui->tb_frameLogPath->text(); if(dmaLogPath.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, ui->lcd_dmaCounter); dmaLogWatcher.setFuture(dmaLogFuture); logButtonsEnable(false); } catch(SonoException& e) { logButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::dmaLogThreadFinished() { QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_dmaLogDone, str, color); logButtonsEnable(true); } /*************************************************************************************************/ void MainWindow::dmaLogLayoutVisible(bool show) { QList widgets {ui->btn_dmaLogLast, ui->tb_dmaLogCount, ui->lcd_dmaCounter, ui->l_dmaLogDone, 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() { try { _mutex.lock(); QList plotFrame = _bufferedFrame; _bufferedFrame.clear(); _mutex.unlock(); QList subBatchId, frmType, cri, mLine; QList batchId, bLine, bPoint, mPoint; quint16 line(0), point(0); ui->plot_2->clearGraphs(); ui->plot_2->axisRect()->setupFullAxesBox(true); ui->plot_2->xAxis->setLabel("Line"); ui->plot_2->yAxis->setLabel("Point"); if(plotFrame.size() != 0) { foreach(const QByteArray& framePacket, plotFrame) { batchId.append(((static_cast(framePacket[128])) & 0x00FF) | (((static_cast(framePacket[129])) << 8) & 0xFF00)); bPoint.append(((static_cast(framePacket[138])) & 0x00FF) | (((static_cast(framePacket[139])) << 8) & 0xFF00)); mPoint.append(((static_cast(framePacket[141])) & 0x00FF) | (((static_cast(framePacket[142])) << 8) & 0xFF00)); bLine.append(((static_cast(framePacket[136])) & 0x00FF) | (((static_cast(framePacket[137])) << 8) & 0xFF00)); subBatchId.append(static_cast(framePacket[130])); frmType.append(static_cast(framePacket[131])); mLine.append(static_cast(framePacket[140])); cri.append(static_cast(framePacket[132])); } } else { return; } foreach(auto& bL, bLine) { if(bL > 256 * 8) { qDebug() << "ERROR :: (B Line)" << bLine; return; } line += bL; } foreach(auto& bP, bPoint) { if(bP > 8192) { qDebug() << "ERROR :: (B Point)" << bPoint; return; } point = bP; } foreach(auto& fType, frmType) { if(fType != 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(line, point); _colorMap->data()->setRange(QCPRange(1, line), QCPRange(1, point)); quint32 max = 0; auto indx = 0; auto lnSum = 0; foreach(const QByteArray& plotPacket, plotFrame) { auto lnPacket = (((static_cast(plotPacket[136])) & 0x00FF) | (((static_cast(plotPacket[137])) << 8) & 0xFF00)); for(auto ln = 0; ln < lnPacket; ln += 1) { for(auto pnt = 0; pnt < point; pnt += 1) { indx = (ln * point + pnt) * 4 + 160; auto val = ((static_cast(plotPacket[indx])) & 0x000000FF) | (((static_cast(plotPacket[indx + 1])) << 8) & 0x0000FF00) | (((static_cast(plotPacket[indx + 2])) << 16) & 0x00FF0000) | (((static_cast(plotPacket[indx + 3])) << 24) & 0xFF000000); if(max < val) { max = val; } if(_isDynamicContrast) { val = static_cast(DynamicContrast(val, dynamicContrastParams)); } _colorMap->data()->setCell(lnSum + ln, pnt, double(val)); } } lnSum = lnSum + lnPacket; } 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)); 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(); } catch(...) { qDebug() << "Error"; } } /*************************************************************************************************/ 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("Logging"); //_progress->setRange(0, static_cast(logRange)); //_progress->setModal(true); //_progress->setValue(static_cast(counter)); //} /*************************************************************************************************/ void MainWindow::on_chk_headerLogEn_clicked(bool checked) { try { if(checked) { if(_headerLogFile->fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!_headerLogFile->open(QIODevice::WriteOnly)) { throw SonoException("Couldn't open file for logging"); } QTextStream _headerLog(_headerLogFile); _headerLog << "batchId, " << "subBatchId, " << "bLine, " << "bPoint, "; _headerLog << "frmType, " << "cri, " << "mLine, " << "mPoint, "; _headerLog << endl; _headerLogEn = true; } else { _headerLogEn = false; if(_headerLogFile->isOpen()) { _headerLogFile->flush(); _headerLogFile->close(); } } } 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); if(!hvPermission()) { if(_trx.isScenarioStart()) { on_btn_scenStart_clicked(); } } } 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(); //off _ 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(); if(strList.size() < 10) { return "0"; } else { 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)); if(MOUNTED_SLAVE_FPGA & 1) { value = _version->slave0Code; ui->l_slave0Version->setText(releaseCodeVersion(value)); } if(MOUNTED_SLAVE_FPGA & 2) { value = _version->slave1Code; ui->l_slave1Version->setText(releaseCodeVersion(value)); } if(MOUNTED_SLAVE_FPGA & 4) { value = _version->slave2Code; ui->l_slave2Version->setText(releaseCodeVersion(value)); } } /*************************************************************************************************/ /************************************* Scenario Setting ******************************************/ /*************************************************************************************************/ void MainWindow::setScenario(const QString& h5Path) { try { if(ui->tb_scenFilesPath->text().isEmpty()) { throw SonoException("No file is selected."); } AfeConfig afeConfigObj; afeConfig(afeConfigObj); Hdf5 hdf; ScenHardware scenParams; ScenPrbDepHardwareParam prbDepParams; QVector lineFilterLut; QVector stbLut; hdf.hdf5Path(h5Path.toStdString()); hdf.scenarioRead(scenParams); hdf.prbDependParamsRead(prbDepParams); prbDepParams.afeCfg = afeConfigObj; stbLut = hdf.stbRead(); //lineFilterLut = hdf.lineFilterRead(); _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() { try { 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; if(ui->tb_scenFilesPath->text().isEmpty()) { throw SonoException("No file is selected."); } emit scenarioReady(h5Path); str = "done"; color = Qt::green; emit labelState(ui->l_scenFillingDone, str, color); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ 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 { if(scenPath.isEmpty()) { throw SonoException("No file is selected."); } _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() { try { QString scenPath = QFileDialog::getExistingDirectory(this, tr("Scenario File"), _scenarioFolder, QFileDialog::ShowDirsOnly); if(scenPath.isEmpty()) { throw SonoException("No file is selected."); } ui->tb_scenFilesPath->setText(scenPath); _settings->setValue(SCENARIO_FILE_PATH, scenPath); ui->tb_scenInfo->clear(); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_scenInfo_clicked() { QString scenInfo = "/hardware/systemCheckParam.csv"; QString path = ui->tb_scenFilesPath->text() + scenInfo; try { 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(); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ 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 str2BigEndianByteArray(QString str, int base, qint8 byteLength) { QString strInt = str; quint32 intStr = strInt.toUInt(nullptr, base); QByteArray qbInt; for(qint8 i = byteLength - 1; i >= 0; i--) { qbInt.append(static_cast((intStr >> (i * 8)) & 0xFF)); } return qbInt; } QString bigEndianByteArray2Str(QByteArray btArr, int base) { quint32 reconstructedNum(0); for(auto i = btArr.length() - 1; i >= 0; i--) { reconstructedNum += static_cast((static_cast(btArr[btArr.length() - 1 - i]) << (i * 8))); } QString str = QString::number(reconstructedNum, base); return str; } QByteArray str2BigEndianByteArray4SerialNo(QString str) { if(str.length() == 7) { QStringRef strByte1(&str, 0, 2); QStringRef strByte2(&str, 2, 2); QStringRef strByte34(&str, 4, 3); QByteArray qbInt; qbInt.append(static_cast(strByte1.toInt())); qbInt.append(static_cast(strByte2.toInt())); for(qint8 i = 1; i >= 0; i--) { qbInt.append(static_cast(((strByte34.toShort()) >> (i * 8)) & 0xFF)); } return qbInt; } else { throw SonoException("Invalid board serial number."); } } QString bigEndianByteArray2Str4SerialNo(QByteArray btArr) { quint16 reconstructedNum(0); for(auto i = btArr.length() - 3; i >= 0; i--) { reconstructedNum += static_cast((static_cast(btArr[btArr.length() - 1 - i]) << (i * 8))); } QString str = "SPN." + QString::number(static_cast(btArr[0])) + "." + QString::number(static_cast(btArr[1])) + "." + QString::number( reconstructedNum); return str; } 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 SonoException("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 (quint16& 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; } QByteArray MainWindow::crcCalc(const QByteArray array) { quint8 crcValue = _trx.crcGenerator(array); QByteArray crc; crc.append(static_cast(crcValue)); return crc; } void MainWindow::trxCrcWrite(const QByteArray array, quint32 offset) { trxEepromWrite(crcCalc(array), offset, _bCtrl); } void MainWindow::prbCtrlCrcWrite(const QByteArray array, quint32 offset) { prbCtrlEepromWrite(crcCalc(array), offset, _bCtrl); } void MainWindow::mpsCrcWrite(const QByteArray array, quint32 offset) { mpsEepromWrite(crcCalc(array), offset, _bCtrl); } QByteArray MainWindow::e2promClear(quint32 length) { QByteArray clearRom; for(quint32 i = 0; i < length; i++) { clearRom.push_back(char(0)); } return clearRom; } /*************************************************************************************************/ /*************************************************************************************************/ void MainWindow::on_chk_trxIdWrEn_clicked(bool checked) { trxIdWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_trxRomId_clicked() { try { if(trxIdWrEn) { QString idStr = ui->tb_trxRomId->text(); QByteArray clearId = e2promClear(EEPROM_ID_NUMBER); trxEepromWrite(clearId, EEPROM_ID_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(idStr, 16, 2); trxEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); trxCrcWrite(sendingArray, EEPROM_ID_CRC); } else { QString idStr = bigEndianByteArray2Str(_trx.trxRomId(), 16); ui->tb_trxRomId->setText(idStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_trxPidWrEn_clicked(bool checked) { trxPidWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_trxRomPid_clicked() { try { if(trxPidWrEn) { QString pidStr = ui->tb_trxRomPid->text(); QByteArray clearPid = e2promClear(EEPROM_PID_NUMBER); trxEepromWrite(clearPid, EEPROM_PID_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(pidStr, 16, 2); trxEepromWrite(sendingArray, EEPROM_PID_BEGIN, _bCtrl); trxCrcWrite(sendingArray, EEPROM_PID_CRC); } else { QString pidStr = bigEndianByteArray2Str(_trx.trxRomPid(), 16); ui->tb_trxRomPid->setText(pidStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_trxPcbVersionWrEn_clicked(bool checked) { trxPcbVesionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_trxRomPcbVersion_clicked() { try { if(trxPcbVesionWrEn) { QString pcbVesionStr = ui->tb_trxRomPcbVersion->text(); QByteArray clearPcbVesion = e2promClear(EEPROM_PCB_VERSION_NUMBER); trxEepromWrite(clearPcbVesion, EEPROM_PCB_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(pcbVesionStr, 10, 2); trxEepromWrite(sendingArray, EEPROM_PCB_VERSION_BEGIN, _bCtrl); trxCrcWrite(sendingArray, EEPROM_PCB_VERSION_CRC); } else { QString pcbVersionStr = bigEndianByteArray2Str(_trx.trxRomPcbVersion(), 10); ui->tb_trxRomPcbVersion->setText(pcbVersionStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_trxSerialNumberWrEn_clicked(bool checked) { trxSerialNoWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_trxRomSerialNumber_clicked() { try { if(trxSerialNoWrEn) { QString serialNoStr = ui->tb_trxRomSerialNumber->text(); QByteArray sendingArray = str2BigEndianByteArray4SerialNo(serialNoStr); QByteArray clearSerialNo = e2promClear(EEPROM_BOARD_SERIAL_NO_NUMBER); trxEepromWrite(clearSerialNo, EEPROM_BOARD_SERIAL_NO_BEGIN, _bCtrl); trxEepromWrite(sendingArray, EEPROM_BOARD_SERIAL_NO_BEGIN, _bCtrl); trxCrcWrite(sendingArray, EEPROM_BOARD_SERIAL_NO_CRC); } else { QString serialNoStr = bigEndianByteArray2Str4SerialNo(_trx.trxRomSerialNo()); ui->tb_trxRomSerialNumber->setText(serialNoStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_trxMasterCodeVersionWrEn_clicked(bool checked) { trxMasterCodeVersionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_trxRomMasterCodeVersion_clicked() { try { if(trxMasterCodeVersionWrEn) { QString masterCodeVersionStr = ui->tb_trxRomMasterCodeVersion->text(); QByteArray clearMasterCodeVersion = e2promClear(EEPROM_FIRST_MBED_CODE_VERSION_NUMBER); trxEepromWrite(clearMasterCodeVersion, EEPROM_FIRST_MBED_CODE_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(masterCodeVersionStr, 10, 4); trxEepromWrite(sendingArray, EEPROM_FIRST_MBED_CODE_VERSION_BEGIN, _bCtrl); trxCrcWrite(sendingArray, EEPROM_FIRST_MBED_CODE_VERSION_CRC); } else { QString firstMbedStr = bigEndianByteArray2Str(_trx.trxRomFirstMbedCode(), 10); ui->tb_trxRomMasterCodeVersion->setText("MFV." + firstMbedStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_trxSlaveCodeVersionWrEn_clicked(bool checked) { trxSlaveCodeVersionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_trxRomSlaveCodeVersion_clicked() { try { if(trxSlaveCodeVersionWrEn) { QString slaveCodeVersionWrStr = ui->tb_trxRomSlaveCodeVersion->text(); QByteArray clearSlaveCodeVersion = e2promClear(EEPROM_SECOND_MBED_CODE_VERSION_NUMBER); trxEepromWrite(clearSlaveCodeVersion, EEPROM_SECOND_MBED_CODE_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(slaveCodeVersionWrStr, 10, 4); trxEepromWrite(sendingArray, EEPROM_SECOND_MBED_CODE_VERSION_BEGIN, _bCtrl); trxCrcWrite(sendingArray, EEPROM_SECOND_MBED_CODE_VERSION_CRC); } else { QString secondMbedStr = bigEndianByteArray2Str(_trx.trxRomSecondMbedCode(), 10); ui->tb_trxRomSlaveCodeVersion->setText("SFV." + secondMbedStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_writeHeaderTrxRom_clicked(bool checked) { try { if(checked) { QByteArray clearHeader = e2promClear(EEPROM_HEADER_NUMBER); trxEepromWrite(clearHeader, EEPROM_HEADER_BEGIN, _bCtrl); trxEepromWrite(headerArray, EEPROM_HEADER_BEGIN, _bCtrl); delay(200); qDebug() << bigEndianByteArray2Str(_trx.trxRomHeader(), 16); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_clearTrxRom_clicked(bool checked) { try { if(checked) { QByteArray clearAll = e2promClear(TRX_RLY_MPS_E2PROM_SIZE_BYTE); trxEepromWrite(clearAll, 0, _bCtrl); } } catch(SonoException& e) { qDebug() << e.what(); } } ///*************************************************************************************************/ //void MainWindow::on_btn_trxRomInfoWrite_clicked() //{ //QString infoStr = ui->tb_trxRomInfo->toPlainText(); //try //{ //QByteArray clearInfo = e2promClear(EEPROM_INFO_NUMBER); //trxEepromWrite(clearInfo, EEPROM_INFO_BEGIN, _bCtrl); //QByteArray sendingArray = infoStr.toLatin1(); //trxEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); //} //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_chk_mpsIdWrEn_clicked(bool checked) { mpsIdWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomId_clicked() { try { if(mpsIdWrEn) { QString idStr = ui->tb_mpsRomId->text(); QByteArray clearId = e2promClear(EEPROM_ID_NUMBER); mpsEepromWrite(clearId, EEPROM_ID_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(idStr, 16, 2); mpsEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); mpsCrcWrite(sendingArray, EEPROM_ID_CRC); } else { QString idStr = bigEndianByteArray2Str(_trx.mpsRomId(), 16); ui->tb_mpsRomId->setText(idStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_mpsPidWrEn_clicked(bool checked) { mpsPidWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomPid_clicked() { try { if(mpsPidWrEn) { QString pidStr = ui->tb_mpsRomPid->text(); QByteArray clearPid = e2promClear(EEPROM_PID_NUMBER); mpsEepromWrite(clearPid, EEPROM_PID_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(pidStr, 16, 2); mpsEepromWrite(sendingArray, EEPROM_PID_BEGIN, _bCtrl); mpsCrcWrite(sendingArray, EEPROM_PID_CRC); } else { QString pidStr = bigEndianByteArray2Str(_trx.mpsRomPid(), 16); ui->tb_mpsRomPid->setText(pidStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_mpsPcbVersionWrEn_clicked(bool checked) { mpsPcbVesionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomPcbVersion_clicked() { try { if(mpsPcbVesionWrEn) { QString pcbVesionStr = ui->tb_mpsRomPcbVersion->text(); QByteArray clearPcbVesion = e2promClear(EEPROM_PCB_VERSION_NUMBER); mpsEepromWrite(clearPcbVesion, EEPROM_PCB_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(pcbVesionStr, 10, 2); mpsEepromWrite(sendingArray, EEPROM_PCB_VERSION_BEGIN, _bCtrl); mpsCrcWrite(sendingArray, EEPROM_PCB_VERSION_CRC); } else { QString pcbVersionStr = bigEndianByteArray2Str(_trx.mpsRomPcbVersion(), 10); ui->tb_mpsRomPcbVersion->setText(pcbVersionStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_mpsSerialNumberWrEn_clicked(bool checked) { mpsSerialNoWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomSerialNumber_clicked() { try { if(mpsSerialNoWrEn) { QString serialNoStr = ui->tb_mpsRomSerialNumber->text(); QByteArray sendingArray = str2BigEndianByteArray4SerialNo(serialNoStr); QByteArray clearSerialNo = e2promClear(EEPROM_BOARD_SERIAL_NO_NUMBER); mpsEepromWrite(clearSerialNo, EEPROM_BOARD_SERIAL_NO_BEGIN, _bCtrl); mpsEepromWrite(sendingArray, EEPROM_BOARD_SERIAL_NO_BEGIN, _bCtrl); mpsCrcWrite(sendingArray, EEPROM_BOARD_SERIAL_NO_CRC); } else { QString serialNoStr = bigEndianByteArray2Str4SerialNo(_trx.mpsRomSerialNo()); ui->tb_mpsRomSerialNumber->setText(serialNoStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_mpsUcCodeVersionWrEn_clicked(bool checked) { mpsUcCodeVersionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomUcCodeVersion_clicked() { try { if(mpsUcCodeVersionWrEn) { QString ucCodeVersionStr = ui->tb_mpsRomUcCodeVersion->text(); QByteArray clearUcCodeVersion = e2promClear(EEPROM_FIRST_MBED_CODE_VERSION_NUMBER); mpsEepromWrite(clearUcCodeVersion, EEPROM_FIRST_MBED_CODE_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(ucCodeVersionStr, 10, 4); mpsEepromWrite(sendingArray, EEPROM_FIRST_MBED_CODE_VERSION_BEGIN, _bCtrl); mpsCrcWrite(sendingArray, EEPROM_FIRST_MBED_CODE_VERSION_CRC); } else { QString firstMbedStr = bigEndianByteArray2Str(_trx.mpsRomFirstMbedCode(), 10); ui->tb_mpsRomUcCodeVersion->setText("UCV." + firstMbedStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_mpsSupCodeVersionWrEn_clicked(bool checked) { mpsSupCodeVersionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_mpsRomSupCodeVersion_clicked() { try { if(mpsSupCodeVersionWrEn) { QString supCodeVersionWrStr = ui->tb_mpsRomSupCodeVersion->text(); QByteArray clearSupCodeVersion = e2promClear(EEPROM_SECOND_MBED_CODE_VERSION_NUMBER); mpsEepromWrite(clearSupCodeVersion, EEPROM_SECOND_MBED_CODE_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(supCodeVersionWrStr, 10, 4); mpsEepromWrite(sendingArray, EEPROM_SECOND_MBED_CODE_VERSION_BEGIN, _bCtrl); mpsCrcWrite(sendingArray, EEPROM_SECOND_MBED_CODE_VERSION_CRC); } else { QString secondMbedStr = bigEndianByteArray2Str(_trx.mpsRomSecondMbedCode(), 10); ui->tb_mpsRomSupCodeVersion->setText("SVV." + secondMbedStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_writeHeaderMpsRom_clicked(bool checked) { try { if(checked) { QByteArray clearHeader = e2promClear(EEPROM_HEADER_NUMBER); mpsEepromWrite(clearHeader, EEPROM_HEADER_BEGIN, _bCtrl); mpsEepromWrite(headerArray, EEPROM_HEADER_BEGIN, _bCtrl); delay(200); qDebug() << bigEndianByteArray2Str(_trx.mpsRomHeader(), 16); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_clearMpsRom_clicked(bool checked) { try { if(checked) { QByteArray clearAll = e2promClear(TRX_RLY_MPS_E2PROM_SIZE_BYTE); mpsEepromWrite(clearAll, 0, _bCtrl); } } catch(SonoException& e) { qDebug() << e.what(); } } ///*************************************************************************************************/ //void MainWindow::on_btn_mpsRomInfoWrite_clicked() //{ //QString infoStr = ui->tb_mpsRomInfo->toPlainText(); //try //{ //QByteArray clearInfo = e2promClear(EEPROM_INFO_NUMBER); //mpsEepromWrite(clearInfo, EEPROM_INFO_BEGIN, _bCtrl); //QByteArray sendingArray = infoStr.toLatin1(); //mpsEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); //} //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_chk_prbCntlIdWrEn_clicked(bool checked) { prbCtrlIdWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_prbCtrlRomId_clicked() { try { if(prbCtrlIdWrEn) { QString idStr = ui->tb_prbCtrlRomId->text(); QByteArray clearId = e2promClear(EEPROM_ID_NUMBER); prbCtrlEepromWrite(clearId, EEPROM_ID_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(idStr, 16, 2); prbCtrlEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); prbCtrlCrcWrite(sendingArray, EEPROM_ID_CRC); } else { QString idStr = bigEndianByteArray2Str(_trx.prbCtrlRomId(), 16); ui->tb_prbCtrlRomId->setText(idStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_prbCntlPidWrEn_clicked(bool checked) { prbCtrlPidWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_prbCntlRomPid_clicked() { try { if(prbCtrlPidWrEn) { QString pidStr = ui->tb_prbCtrlRomPid->text(); QByteArray clearPid = e2promClear(EEPROM_PID_NUMBER); prbCtrlEepromWrite(clearPid, EEPROM_PID_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(pidStr, 16, 2); prbCtrlEepromWrite(sendingArray, EEPROM_PID_BEGIN, _bCtrl); prbCtrlCrcWrite(sendingArray, EEPROM_PID_CRC); } else { QString pidStr = bigEndianByteArray2Str(_trx.prbCtrlRomPid(), 16); ui->tb_prbCtrlRomPid->setText(pidStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_prbCntlPcbVersionWrEn_clicked(bool checked) { prbCtrlPcbVesionWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_prbCntlRomPcbVersion_clicked() { try { if(prbCtrlPcbVesionWrEn) { QString pcbVesionStr = ui->tb_prbCtrlRomPcbVersion->text(); QByteArray clearPcbVesion = e2promClear(EEPROM_PCB_VERSION_NUMBER); prbCtrlEepromWrite(clearPcbVesion, EEPROM_PCB_VERSION_BEGIN, _bCtrl); QByteArray sendingArray = str2BigEndianByteArray(pcbVesionStr, 10, 2); prbCtrlEepromWrite(sendingArray, EEPROM_PCB_VERSION_BEGIN, _bCtrl); prbCtrlCrcWrite(sendingArray, EEPROM_PCB_VERSION_CRC); } else { QString pcbVersionStr = bigEndianByteArray2Str(_trx.prbCtrlRomPcbVersion(), 10); ui->tb_prbCtrlRomPcbVersion->setText(pcbVersionStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_prbCntlSerialNumberWrEn_clicked(bool checked) { prbCtrlSerialNoWrEn = checked; } /*************************************************************************************************/ void MainWindow::on_btn_prbCntlRomSerialNumber_clicked() { try { if(prbCtrlSerialNoWrEn) { QString serialNoStr = ui->tb_prbCtrlRomSerialNumber->text(); QByteArray sendingArray = str2BigEndianByteArray4SerialNo(serialNoStr); QByteArray clearSerialNo = e2promClear(EEPROM_BOARD_SERIAL_NO_NUMBER); prbCtrlEepromWrite(clearSerialNo, EEPROM_BOARD_SERIAL_NO_BEGIN, _bCtrl); prbCtrlEepromWrite(sendingArray, EEPROM_BOARD_SERIAL_NO_BEGIN, _bCtrl); prbCtrlCrcWrite(sendingArray, EEPROM_BOARD_SERIAL_NO_CRC); } else { QString serialNoStr = bigEndianByteArray2Str4SerialNo(_trx.prbCtrlRomSerialNo()); ui->tb_prbCtrlRomSerialNumber->setText(serialNoStr); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_writeHeaderPrbCtrlRom_clicked(bool checked) { try { if(checked) { QByteArray clearHeader = e2promClear(EEPROM_HEADER_NUMBER); prbCtrlEepromWrite(clearHeader, EEPROM_HEADER_BEGIN, _bCtrl); prbCtrlEepromWrite(headerArray, EEPROM_HEADER_BEGIN, _bCtrl); delay(200); qDebug() << bigEndianByteArray2Str(_trx.prbCtrlRomHeader(), 16); } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_clearPrbCtrlRom_clicked(bool checked) { try { if(checked) { QByteArray clearAll = e2promClear(TRX_RLY_MPS_E2PROM_SIZE_BYTE); prbCtrlEepromWrite(clearAll, 0, _bCtrl); } } catch(SonoException& e) { qDebug() << e.what(); } } ///*************************************************************************************************/ //void MainWindow::on_btn_prbCtrlRomInfoWrite_clicked() //{ //QString infoStr = ui->tb_prbCtrlRomInfo->toPlainText(); //try //{ //QByteArray clearInfo = e2promClear(EEPROM_INFO_NUMBER); //prbCtrlEepromWrite(clearInfo, EEPROM_INFO_BEGIN, _bCtrl); //QByteArray sendingArray = infoStr.toLatin1(); //prbCtrlEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); //} //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_chk_sysCompatibilityCheck_clicked(bool checked) { try { if(checked) { _trx.checkSystemCompatibility(); } } catch(SonoException& e) { qDebug() << e.what(); MESSAGE_BOX("Failed! \n\r" "The system parameters are not compatible."); } } /*************************************************************************************************/ /*************************************************************************************************/ /*************************************************************************************************/ 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 SonoException("The crc error of the probe A eeprom is occured."); } } else { MESSAGE_BOX("Probe A is disconnected."); } } 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 SonoException("The crc error of the probe B eeprom is occured."); } } else { MESSAGE_BOX("Probe B is disconnected."); } } 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 SonoException("The crc error of the probe C eeprom is occured."); } } else { MESSAGE_BOX("Probe C is disconnected."); } } 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 SonoException("The crc error of the probe D eeprom is occured."); } } else { MESSAGE_BOX("Probe D is disconnected."); } } 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(); EepromStatus romStatus; switch(sel) { case 0: try { _trx.selectedPrbState(romStatus, prbA); if(romStatus.ConnectionMode == connected) { QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe A eeprom is occured."); } } else { MESSAGE_BOX("Probe A is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 1: try { _trx.selectedPrbState(romStatus, prbB); if(romStatus.ConnectionMode == connected) { QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe B eeprom is occured."); } } else { MESSAGE_BOX("Probe B is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 2: try { _trx.selectedPrbState(romStatus, prbC); if(romStatus.ConnectionMode == connected) { QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe C eeprom is occured."); } } else { MESSAGE_BOX("Probe C is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 3: try { _trx.selectedPrbState(romStatus, prbD); if(romStatus.ConnectionMode == connected) { QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe D eeprom is occured."); } } else { MESSAGE_BOX("Probe D is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::prbRead(const QString& prbSelData, qint32 prbSel) { try { QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_prbRomDone, str, color); QTime t = QTime::currentTime(); QString path = ui->tb_prbRomFilePath->text(); QString prbRomPath = path + "/" + prbSelData + QString("_%1_%2_%3.txt") .arg(t.hour()) .arg(t.minute()) .arg(t.second()); QFile prbRomFile(prbRomPath); QTextStream prbLog(&prbRomFile); if(prbRomPath.isEmpty()) { throw SonoException("No file is selected"); } if(!prbRomFile.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't open file for probe ROM data writing."); } QByteArray prbAll = this->_bCtrl->prbEepromRead(PROBE_E2PROM_BYTE_ORIGIN, PROBE_E2PROM_BYTE_SIZE, static_cast(prbSel)); foreach(auto j, prbAll) { quint8 l = static_cast(j); prbLog << QString::number(l, 16) << endl; } prbRomFile.flush(); prbRomFile.close(); str = "done"; color = Qt::green; emit labelState(ui->l_prbRomDone, str, color); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::prbWrite(qint32 prbSel) { QString prbRomPath = ui->tb_prbRomFilePath->text(); try { QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_prbRomDone, str, color); QFile prbRomFile(prbRomPath); if(prbRomFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!prbRomFile.open(QIODevice::ReadOnly | QFile::Text)) { throw SonoException("Couldn't open file for probe ROM data reading."); } QByteArray prbAll; QString prbStr; while(!prbRomFile.atEnd()) { prbStr = prbRomFile.readLine(); prbAll.push_back(static_cast(prbStr.toUInt(nullptr, 16))); } prbRomFile.close(); prbEepromWrite(prbAll, PROBE_E2PROM_BYTE_ORIGIN, static_cast(prbSel), _bCtrl); str = "done"; color = Qt::green; emit labelState(ui->l_prbRomDone, str, color); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbRomBrowse_clicked() { try { QString prbRomPath; if(ui->chk_prbRomWrEn->isChecked()) { prbRomPath = QFileDialog::getOpenFileName(this, tr("Probe E2PROM File"), _probeRomPath, "*.txt"); } else { prbRomPath = QFileDialog::getExistingDirectory(this, tr("Probe E2PROM File"), _probeRomPath, QFileDialog::ShowDirsOnly); } if(prbRomPath.isEmpty()) { throw SonoException("No file is selected."); } ui->tb_prbRomFilePath->setText(prbRomPath); _settings->setValue(PRB_FILE_PATH, prbRomPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_prbRomWrEn_clicked(bool checked) { if(checked) { ui->btn_prbRomWriteAll->setEnabled(true); ui->btn_prbRomReadAll->setEnabled(false); } else { ui->btn_prbRomWriteAll->setEnabled(false); ui->btn_prbRomReadAll->setEnabled(true); } } /*************************************************************************************************/ void MainWindow::on_btn_prbRomWriteAll_clicked() { try { auto sel = ui->cb_prbSelRom->currentIndex(); EepromStatus romStatus; switch(sel) { case 0: try { _trx.selectedPrbState(romStatus, prbA); if(romStatus.ConnectionMode == connected) { prbWrite(sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe A eeprom is occured."); } } else { MESSAGE_BOX("Probe A is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 1: try { _trx.selectedPrbState(romStatus, prbB); if(romStatus.ConnectionMode == connected) { prbWrite(sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe B eeprom is occured."); } } else { MESSAGE_BOX("Probe B is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 2: try { _trx.selectedPrbState(romStatus, prbC); if(romStatus.ConnectionMode == connected) { prbWrite(sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe C eeprom is occured."); } } else { MESSAGE_BOX("Probe C is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 3: try { _trx.selectedPrbState(romStatus, prbD); if(romStatus.ConnectionMode == connected) { prbWrite(sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe D eeprom is occured."); } } else { MESSAGE_BOX("Probe D is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; } } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbRomReadAll_clicked() { try { auto sel = ui->cb_prbSelRom->currentIndex(); EepromStatus romStatus; switch(sel) { case 0: try { _trx.selectedPrbState(romStatus, prbA); if(romStatus.ConnectionMode == connected) { prbRead("probeA_data", sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe A eeprom is occured."); } } else { MESSAGE_BOX("Probe A is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 1: try { _trx.selectedPrbState(romStatus, prbB); if(romStatus.ConnectionMode == connected) { prbRead("probeB_data", sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe B eeprom is occured."); } } else { MESSAGE_BOX("Probe B is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 2: try { _trx.selectedPrbState(romStatus, prbC); if(romStatus.ConnectionMode == connected) { prbRead("probeC_data", sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe C eeprom is occured."); } } else { MESSAGE_BOX("Probe C is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; case 3: try { _trx.selectedPrbState(romStatus, prbD); if(romStatus.ConnectionMode == connected) { prbRead("probeD_data", sel); if(romStatus.errorCode == EEPROM_CRC_ERROR) { throw SonoException("The crc error of the probe D eeprom is occured."); } } else { MESSAGE_BOX("Probe D is disconnected."); } } catch(SonoException& e) { qDebug() << e.what(); } break; } } 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::afeConfig(AfeConfig& afeConfig) { afeConfig.lowNf = lowNfDisable; afeConfig.lnaHpf = lnaHpfEnable; afeConfig.pgaHpf = pgaHpfEnable; afeConfig.lpfProg = LpfProg15MHz; 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; } void MainWindow::setAfeConfig() { AfeConfig afeConfigObj; afeConfig(afeConfigObj); _trx.setAfeConfig(afeConfigObj); } /*************************************************************************************************/ /*************************************** Built-in Test *******************************************/ /*************************************************************************************************/ void MainWindow::on_btn_biteScenBrowse_clicked() { try { QString biteScenPath = QFileDialog::getExistingDirectory(this, tr("Built-in test Scenario File"), _BITeScenFolder, QFileDialog::ShowDirsOnly); if(biteScenPath.isEmpty()) { throw SonoException("No file is selected."); } ui->tb_biteScenPath->setText(biteScenPath); _settings->setValue(BITE_SCEN_FILE_PATH, biteScenPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_biteSetScenario_clicked() { try { QString sramScenario = "/scenGenOutput/scenario.h5"; QString h5Path = ui->tb_biteScenPath->text() + sramScenario; if(ui->tb_biteScenPath->text().isEmpty()) { throw SonoException("No file is selected."); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_biteScenFillingDone, str, color); emit scenarioReady(h5Path); str = "done"; color = Qt::green; emit labelState(ui->l_biteScenFillingDone, str, color); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_biteBrowse_clicked() { try { QString biteIqPath = QFileDialog::getOpenFileName(this, tr("TxDAC File"), _BITeIqFolder, "*.csv"); if(biteIqPath.isEmpty()) { throw SonoException("No file is selected."); } ui->tb_biteFilesPath->setText(biteIqPath); _settings->setValue(BITE_FILE_PATH, biteIqPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_biteIQ_clicked() { try { //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"); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_biteIQFillingDone, str, color); 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())); } biteFile.close(); _trx.setBiteDacData(I, Q); delay(100); str = "done"; color = Qt::green; emit labelState(ui->l_biteIQFillingDone, str, color); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ 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 log file writing after scen player start and getting the frame packet QString biteLogPath = QFileDialog::getExistingDirectory(this, tr("BITe Log"), _biteLogFolder, QFileDialog::ShowDirsOnly); if(biteLogPath.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, ui->lcd_biteCounter); biteLogWatcher.setFuture(biteLogFuture); logButtonsEnable(false); } catch(SonoException& e) { qDebug() << e.what(); logButtonsEnable(true); } } /*************************************************************************************************/ void MainWindow::biteLogThreadFinished() { _trx.biteScenPlayerStop(); QString str = "done"; QColor color = Qt::green; emit labelState(ui->l_biteLogDone, str, color); logButtonsEnable(true); } /*************************************************************************************************/ /*************************************** Capture_Logger ******************************************/ /*************************************************************************************************/ void MainWindow::on_chk_logCountEn_clicked(bool checked) { QList checkBox {ui->chk_scenFrameAdcLog, ui->chk_syncAdcLog}; foreach(auto& chk, checkBox) { chk->setChecked(false); chk->setEnabled(!checked); } ui->cb_syncMode->setEnabled(!checked); ui->tb_sampleCount->setEnabled(!checked); ui->tb_syncCount->setEnabled(!checked); ui->tb_adcLogCount->setEnabled(checked); } /*************************************************************************************************/ void MainWindow::on_chk_syncAdcLog_clicked(bool checked) { QList checkBox {ui->chk_scenFrameAdcLog, ui->chk_logCountEn, ui->chk_afeConfig}; foreach(auto& chk, checkBox) { chk->setChecked(false); chk->setEnabled(!checked); } ui->tb_adcLogCount->setEnabled(false); if(ui->cb_syncMode->currentIndex() == 1) { ui->tb_syncCount->setEnabled(!checked); } } /*************************************************************************************************/ void MainWindow::on_chk_scenFrameAdcLog_clicked(bool checked) { QList checkBox {ui->chk_syncAdcLog, ui->chk_logCountEn, ui->chk_afeConfig}; foreach(auto& chk, checkBox) { chk->setChecked(false); chk->setEnabled(!checked); } ui->tb_syncCount->setEnabled(!checked); ui->cb_syncMode->setEnabled(!checked); if(checked) { if(ui->chk_batchLogEn->isChecked()) { ui->tb_adcLogCount->setEnabled(checked); } } else { ui->tb_adcLogCount->setEnabled(false); } } /*************************************************************************************************/ void MainWindow::on_chk_batchLogEn_clicked(bool checked) { if(checked) { if(ui->chk_scenFrameAdcLog->isChecked()) { ui->tb_adcLogCount->setEnabled(checked); } } else { ui->tb_adcLogCount->setEnabled(false); } } /*************************************************************************************************/ void MainWindow::on_cb_syncMode_currentIndexChanged(int index) { if(ui->chk_syncAdcLog->isChecked() && index == 1) { ui->tb_syncCount->setEnabled(false); } else { ui->tb_syncCount->setEnabled(true); } } /*************************************************************************************************/ void MainWindow::on_btn_adcLogBrowse_clicked() { try { //Determine ADC log path QString adcLoggerPath = QFileDialog::getExistingDirectory(this, tr("ADC Logger"), _adcLoggerFolder, QFileDialog::ShowDirsOnly); if(adcLoggerPath.isEmpty()) { throw SonoException("No file is selected"); } ui->tb_adcLogPath->setText(adcLoggerPath); _settings->setValue(ADC_LOG_PATH, adcLoggerPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::catchAdcLog() { try { QString str; QColor color; QDir dir; QString adcLoggerPath = ui->tb_adcLogPath->text(); if(adcLoggerPath.isEmpty()) { throw SonoException("No file is selected"); } //ADC log count registering quint32 adcLogCnt(0); if(ui->tb_adcLogCount->isEnabled()) { adcLogCnt = ui->tb_adcLogCount->text().toUInt(); if(adcLogCnt == 0) { MESSAGE_BOX("Invalid input format for ADC logger count"); return; } } //Sample count registering quint32 sampleCnt(0); if(ui->tb_sampleCount->isEnabled()) { sampleCnt = ui->tb_sampleCount->text().toUInt(); if(sampleCnt == 0 && ui->tb_sampleCount->text() != "0") { MESSAGE_BOX("Invalid input format for sample count"); return; } } //sync count registering quint32 syncCnt(0); if(ui->tb_syncCount->isEnabled()) { syncCnt = ui->tb_syncCount->text().toUInt(); if(syncCnt == 0 && ui->tb_syncCount->text() != "0") { MESSAGE_BOX("Invalid input format for sync count"); return; } } logButtonsEnable(false); //ADC sync mode eSyncMode syncMode = autoSync; if(ui->cb_syncMode->isEnabled()) { auto syncIdx = ui->cb_syncMode->currentIndex(); if(syncIdx == 0) { syncMode = autoSync; } else { syncMode = manualSync; } } if(ui->chk_txdacEn->isChecked()) { _trx.setAdgCfg(adgIQ); _trx.setTxDacEnable(BITE_INTERVAL, true); } //ADC capture configuration captureConfig capConfig; capConfig.capMode = allChannel; capConfig.manualTrig = false; capConfig.syncCount = syncCnt; capConfig.sampleCount = sampleCnt; delay(1000); _trx.setAfesPwr(afePwrdnDisable); _trx.adcCaptureConfig(capConfig); //Sync ADC log state for both mode: Auto & Manual if(ui->chk_syncAdcLog->isChecked()) { str = "doing"; color = Qt::red; emit labelState(ui->l_adcLogDone, str, color); _trx.adcCaptureStart(); if(syncMode == autoSync) { _trx.scenPlayerStart(true); _trx.adcCaptureDone(); _trx.scenPlayerStop(true); _trx.adcLoggerStart(adcLoggerPath, "autoSync"); } if(syncMode == manualSync) { _trx.setCaptureManualSync(); _trx.adcCaptureDone(); _trx.adcLoggerStart(adcLoggerPath, "manualSync"); } str = "done"; color = Qt::green; emit labelState(ui->l_adcLogDone, str, color); ui->lcd_adcCounter->display(1); qApp->processEvents(); } //ADC log state regardless of sample/sync count if(ui->chk_logCountEn->isChecked()) { str = "doing"; color = Qt::red; emit labelState(ui->l_adcLogDone, str, color); for(quint16 var = 0; var < adcLogCnt; var++) { _trx.adcCaptureStart(); _trx.setCaptureManualSync(); _trx.adcCaptureDone(); _trx.adcLoggerStart(adcLoggerPath, "logCnt(" + QString::number(var) + ")"); ui->lcd_adcCounter->display(var + 1); qApp->processEvents(); if(_discardAdcLog) { _discardAdcLog = false; break; } } str = "done"; color = Qt::green; emit labelState(ui->l_adcLogDone, str, color); } //Scen frame ADC log state based-on scenario end index number if(ui->chk_scenFrameAdcLog->isChecked()) { quint16 startIdx = static_cast(_usd->readWord(0x804, 0)); quint16 endIdx = static_cast(_usd->readWord(0x808, 0)); str = "doing"; color = Qt::red; emit labelState(ui->l_adcLogDone, str, color); quint32 iter(1); if(ui->chk_batchLogEn->isChecked()) { iter = adcLogCnt; } for(quint32 i = 0; i < iter; i++) { qApp->processEvents(); QString logFolder = QString::number(i + 1); QString updatePath = adcLoggerPath + "/" + logFolder; ui->tb_adcLogPath->setText(updatePath); qApp->processEvents(); if(!dir.exists(updatePath)) { dir.mkpath(updatePath); } else { dir.cd(updatePath); dir.removeRecursively(); dir.mkpath(updatePath); } for(quint16 var = startIdx; var <= endIdx; var++) { capConfig.syncCount = var; capConfig.sampleCount = sampleCnt + i * 2048; ui->tb_sampleCount->setText(QString::number(sampleCnt)); _trx.adcCaptureConfig(capConfig); _trx.adcCaptureStart(); _trx.scenPlayerStart(true); _trx.adcCaptureDone(); _trx.scenPlayerStop(true); _trx.adcLoggerStart(updatePath, "scenIndx(" + QString::number(var) + ")"); ui->lcd_adcCounter->display((var - startIdx) + 1); qApp->processEvents(); if(_discardAdcLog) { _discardAdcLog = false; break; } } if(_discardAdcLog) { _discardAdcLog = false; break; } } str = "done"; color = Qt::green; emit labelState(ui->l_adcLogDone, str, color); } _trx.setAfesPwr(afePwrdnEnable); _trx.setTxDacEnable(BITE_INTERVAL, false); _trx.setAdgCfg(adgGnd); logButtonsEnable(true); } catch(SonoException& e) { _trx.setAfesPwr(afePwrdnEnable); _trx.setDebuggerMode(pulserHz, true); _trx.setDebuggerMode(pulserHz, false); _trx.setTxDacEnable(BITE_INTERVAL, false); _trx.setAdgCfg(adgGnd); logButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_setAdcLog_clicked() { try { emit adcLog(); } catch(SonoException& e) { _trx.setAfesPwr(afePwrdnEnable); _trx.setDebuggerMode(pulserHz, true); _trx.setDebuggerMode(pulserHz, false); _trx.setTxDacEnable(BITE_INTERVAL, false); _trx.setAdgCfg(adgGnd); logButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_chk_pulserTstModeEn_clicked(bool checked) { auto tstModeIdx = ui->cb_pulserTstMode->currentIndex(); if(checked) { if(tstModeIdx == 0) { _trx.setDebuggerMode(pulserHz, checked); } if(tstModeIdx == 1) { _trx.setDebuggerMode(pulserTr, checked); } } else { _trx.setDebuggerMode(pulserHz, true); _trx.setDebuggerMode(pulserHz, false); } } /*************************************************************************************************/ void MainWindow::on_cb_pulserTstMode_currentIndexChanged(int index) { if(ui->chk_pulserTstModeEn->isChecked()) { if(index == 0) { _trx.setDebuggerMode(pulserHz, true); } if(index == 1) { _trx.setDebuggerMode(pulserTr, true); } } else { _trx.setDebuggerMode(pulserHz, true); _trx.setDebuggerMode(pulserHz, false); } } /*************************************************************************************************/ void MainWindow::on_chk_afeConfig_clicked(bool checked) { if(checked) { setAfeConfig(); } } /*************************************************************************************************/ void MainWindow::on_btn_discardAdcLog_clicked(void) { _discardAdcLog = true; } /*************************************************************************************************/ /***************************************** Boards Test *******************************************/ /*************************************************************************************************/ void MainWindow::on_btn_prbRelayLogBrowse_clicked() { try { QString logPath = QFileDialog::getExistingDirectory(this, tr("Probe Logger"), _probeLoggerFolder, QFileDialog::ShowDirsOnly); if(logPath.isEmpty()) { throw SonoException("No file is selected"); } ui->tb_prbRelayLogPath->setText(logPath); _settings->setValue(PROBE_LOG_PATH, logPath); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_prbRelayTestStart_clicked() { const quint32 logCnt = 5; const qint32 thresholdValue = 2000; const quint32 pulserMode = 1; //0 ---> Hz | 1 ---> T/R const QString logPath = ui->tb_prbRelayLogPath->text(); try { if(logPath.isEmpty()) { throw SonoException("No file is selected"); } ui->btn_prbRelayTestStart->setEnabled(false); ui->cb_pulserTstMode->setCurrentIndex(pulserMode); on_cb_pulserTstMode_currentIndexChanged(pulserMode); //T/R pulser mode is selected. ui->chk_pulserTstModeEn->setChecked(true); on_chk_pulserTstModeEn_clicked(true); //T/R pulser mode is enabled. ui->chk_logCountEn->setChecked(true); on_chk_logCountEn_clicked(true); //Log count is enabled. ui->tb_adcLogCount->setText(QString::number(logCnt, 10)); //All probe elements is set to //log for logCnt times. ui->tb_adcLogPath->setText(logPath); //Log path is set same as //prbRelayLogPath. QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_prbRelayDone, str, color); QDir dir(logPath); dir.removeRecursively(); //Delete directory contains of //all old files. dir.mkpath(logPath); on_btn_setAdcLog_clicked(); //Probe elements logging. dir.setFilter(QDir::Files); //Filter just log files in //directory, no dot & no dotdot quint32 logCount(0); QList correctProbeElementsCountFile; foreach(auto dirFiles, dir.entryList()) //Read csv log file data and //compare them to the noise //value. { logCount++; qDebug() << "****************************** Log No: " + QString::number(logCount) + " ******************************"; QString finalPath = dir.path() + "/" + dirFiles; QFile prbElementsFile(finalPath); if(prbElementsFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!prbElementsFile.open(QIODevice::ReadOnly)) { throw SonoException("Couldn't open file for probe elements data reading."); } QString prbStr; quint32 lineCount(0); quint32 correctProbeElementsCount(0); QList damagedProbeElementIndexes; while(!prbElementsFile.atEnd()) { prbStr = prbElementsFile.readLine(); lineCount++; if(lineCount <= 3) { qDebug() << prbStr; } else { QStringList prbStrList = prbStr.split(','); bool isProbeElementCorrect(false); quint8 thresholdCount(0); foreach(auto str, prbStrList) { qint32 prbValue = str.toInt(nullptr, 10); if(prbValue > thresholdValue) { thresholdCount++; //isProbeElementCorrect = true; } } if(thresholdCount >= 10) { isProbeElementCorrect = true; } if(isProbeElementCorrect) { correctProbeElementsCount++; } else { damagedProbeElementIndexes.append(lineCount - 3); } } } prbElementsFile.close(); correctProbeElementsCountFile.append(correctProbeElementsCount); foreach(auto index, damagedProbeElementIndexes) { qDebug() << "Deactivated Element:" << index; } } quint32 finalCorrectProbeElementsCount(0); foreach(auto minCorrectProbeElementsCount, correctProbeElementsCountFile) { finalCorrectProbeElementsCount = correctProbeElementsCountFile.at(0); if(finalCorrectProbeElementsCount > minCorrectProbeElementsCount) { finalCorrectProbeElementsCount = minCorrectProbeElementsCount; } } ui->tb_prbElements->setText(QString::number(finalCorrectProbeElementsCount, 10)); str = "done"; color = Qt::green; emit labelState(ui->l_prbRelayDone, str, color); ui->chk_logCountEn->setChecked(false); on_chk_logCountEn_clicked(false); ui->cb_pulserTstMode->setCurrentIndex(0); ui->chk_pulserTstModeEn->setChecked(false); on_chk_pulserTstModeEn_clicked(false); ui->btn_prbRelayTestStart->setEnabled(true); if(finalCorrectProbeElementsCount == TOTAL_PROBE_ELEMENTS) { MESSAGE_BOX("Successfull! \n\r" "All elements are corrected."); } } catch(SonoException& e) { ui->chk_logCountEn->setChecked(false); on_chk_logCountEn_clicked(false); ui->cb_pulserTstMode->setCurrentIndex(0); ui->chk_pulserTstModeEn->setChecked(false); on_chk_pulserTstModeEn_clicked(false); ui->btn_prbRelayTestStart->setEnabled(true); QString str = "failed"; QColor color = Qt::red; emit labelState(ui->l_prbRelayDone, str, color); qDebug() << e.what(); } } /*************************************************************************************************/ /***************************************** Misc Widget *******************************************/ /*************************************************************************************************/ void MainWindow::on_btn_gtReg_clicked() { auto result = "OK"; QList offsetRd = {0x14008 * 4, 0x114008 * 4, 0x214008 * 4, 0x314008 * 4, 0x1400B * 4, 0x11400B * 4, 0x21400B * 4, 0x31400B * 4, 0x1400C * 4, 0x11400C * 4, 0x21400C * 4, 0x31400C * 4, 0x1400D * 4, 0x11400D * 4, 0x21400D * 4, 0x31400D * 4, 0x14010 * 4, 0x114010 * 4, 0x214010 * 4, 0x314010 * 4, 0x14011 * 4, 0x114011 * 4, 0x214011 * 4, 0x314011 * 4}; QList correctVal = {0x0, 0xFF43, 0xFF43, 0xFF43, 0x0, 0xFFFF, 0xFFFF, 0xFFFF, 0x0, 0xF0F, 0xF0F, 0xF0F, 0xFF43, 0xF04F, 0xFF43, 0xFF43, 0xFFFF, 0xFF00, 0xFFFF, 0xFFFF, 0xF0F, 0xF00, 0xF0F, 0xF0F}; qDebug() << ""; qDebug() << "--- GT Status Registers Before Reset--- "; for(auto i = 0; i < 24; i++) { auto value = _usd->readWord(offsetRd.at(i), BAR_REG); if(value == correctVal.at(i)) { result = "OK"; } else { result = "NOK"; } qDebug() << QString::number(offsetRd.at(i) / 4, 16) << QString::number(value, 16) << result; } qDebug() << "--- ------------------- --- "; qDebug() << ""; qDebug() << "-------- Reset Start ---------"; QList resetAddr; resetAddr << 0x14000 << 0x14003 << 0x114000 << 0x114003 << 0x214000 << 0x214003 << 0x314000 << 0x314003; for(auto value = 2; value >= 0; value--) { foreach(auto& offset, resetAddr) { _usd->writeWord(offset * 4, BAR_REG, static_cast(value)); } } qDebug() << "-------- Reset Done ---------"; qDebug() << ""; delay(1000); qDebug() << "--- GT Status Registers After Reset--- "; for(auto i = 0; i < 24; i++) { auto value = _usd->readWord(offsetRd.at(i), BAR_REG); if(value == correctVal.at(i)) { result = "OK"; } else { result = "NOK"; } qDebug() << QString::number(offsetRd.at(i) / 4, 16) << QString::number(value, 16) << result; } qDebug() << "--- ------------------- --- "; qDebug() << ""; } /*************************************************************************************************/ /*************************************************************************************************/ void MainWindow::exitApp() { QList > afePwrCheck {_trx.getAfeReg(slave0, 0xC5), _trx.getAfeReg(slave1, 0xC5), _trx.getAfeReg(slave2, 0xC5)}; foreach(auto& afePwr, afePwrCheck) { quint32 afe0 = afePwr.at(0) & 0x80000000; quint32 afe1 = afePwr.at(1) & 0x80000000; quint32 afe2 = afePwr.at(2) & 0x80000000; quint32 afe3 = afePwr.at(3) & 0x80000000; if((afe0 & afe1 & afe2 & afe3) == 0) { ui->btn_scenStart->setText("Scenario Stop"); on_btn_scenStart_clicked(); break; } } _trx.emulatorStop(); on_chk_pulserTstModeEn_clicked(false); _trx.setTxDacEnable(BITE_INTERVAL, false); _trx.setAdgCfg(adgGnd); _trx.mpsReset(); this->QWidget::close(); } /*************************************************************************************************/ void MainWindow::on_chk_powerAo_clicked(bool checked) { _trx.powerAo(checked); } /*************************************************************************************************/ void MainWindow::catchGtReset(quint32 progCnt, quint32 taskItr, quint16 delayPerTask) { try { for(quint32 i = 0; i < progCnt; i++) { _programFlag = false; delay(delayPerTask); qApp->processEvents(); QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_gtReg}; foreach(auto& btn, button) { btn->setEnabled(false); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); auto path = ui->tb_fpgaBit->text(); _trx.slaveFpgaProgram(path); #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); #endif str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); delay(delayPerTask); _programFlag = true; qApp->processEvents(); foreach(auto& btn, button) { btn->setEnabled(true); qApp->processEvents(); } for(quint32 j = 0; j < taskItr; j++) { delay(delayPerTask); on_btn_gtReg_clicked(); if(_discardTempTest) { _discardTempTest = false; return; } } } } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_tempTest_clicked() { auto progCnt = ui->tb_progCnt->text().toUInt(); auto taskItr = ui->tb_taskItr->text().toUInt(); auto delayPerTask = ui->tb_taskDelay->text().toUShort(); try { emit gtReset(progCnt, taskItr, delayPerTask); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::catchStatusLog(quint32 progCnt, quint32 taskItr, quint16 delayPerTask, quint16 scenStartDuration) { try { QString sramScenario = "/scenGenOutput/scenario.h5"; QString h5Path = ui->tb_scenFilesPath->text() + sramScenario; if(ui->tb_scenFilesPath->text().isEmpty()) { throw SonoException("No file is selected."); } QString path = "/home/hasis/Desktop/hardware/Log/statusVector/statusLog.txt"; QFile file(path); QTextStream statusLog(&file); if(!file.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't save status log file."); } for(quint32 i = 0; i < progCnt; i++) { _programFlag = false; delay(delayPerTask); qApp->processEvents(); QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_gtReg}; foreach(auto& btn, button) { btn->setEnabled(false); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); auto path = ui->tb_fpgaBit->text(); _trx.slaveFpgaProgram(path); qApp->processEvents(); #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); _trx.gtReadReset(); #endif str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); delay(delayPerTask); _programFlag = true; qApp->processEvents(); foreach(auto& btn, button) { btn->setEnabled(true); qApp->processEvents(); } delay(delayPerTask); str = "doing"; color = Qt::red; emit labelState(ui->l_scenFillingDone, str, color); setScenario(h5Path); str = "done"; color = Qt::green; emit labelState(ui->l_scenFillingDone, str, color); qApp->processEvents(); for(quint32 j = 0; j < taskItr; j++) { delay(delayPerTask); on_btn_scenStart_clicked(); qApp->processEvents(); delay(scenStartDuration); quint32 statusVec = _usd->readWord(0, 0); statusLog << QString::number(statusVec, 16) << endl; qApp->processEvents(); on_btn_scenStart_clicked(); qApp->processEvents(); //if(statusVec != 0x18000) //{ //break; //} if(_discardTempTest) { break; } } if(_discardTempTest) { _discardTempTest = false; break; } } file.flush(); file.close(); qApp->processEvents(); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_tempStatusLog_clicked() { auto progCnt = ui->tb_progCnt->text().toUInt(); auto taskItr = ui->tb_taskItr->text().toUInt(); auto delayPerTask = ui->tb_taskDelay->text().toUShort(); quint16 scenStartDuration = ui->tb_scenStartDuration->text().toUShort() * 1000; try { emit statusLog(progCnt, taskItr, delayPerTask, scenStartDuration); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::catchEndurance(quint32 progCnt, quint32 taskItr, quint16 delayPerTask) { try { _timeout->stop(); quint32 statusVec; QString statusPath = "/home/hasis/Desktop/hardware/Log/statusVector/statusLog.txt"; QFile statusFile(statusPath); QTextStream statusLog(&statusFile); if(!statusFile.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't save status log file."); } QDir dir; QString sramScenario = "/scenGenOutput/scenario.h5"; QString h5Path = ui->tb_scenFilesPath->text() + sramScenario; if(ui->tb_scenFilesPath->text().isEmpty()) { throw SonoException("No file is selected."); } QString enduranceLogPath = "/home/hasis/Desktop/hardware/Log/enduranceTest/"; ui->chk_firstFrameLogEn->setChecked(true); for(quint32 i = 0; i < progCnt; i++) { _programFlag = false; delay(delayPerTask); qApp->processEvents(); QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_gtReg}; foreach(auto& btn, button) { btn->setEnabled(false); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); auto path = ui->tb_fpgaBit->text(); _trx.slaveFpgaProgram(path); qApp->processEvents(); #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); _trx.gtReadReset(); #endif str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); delay(delayPerTask); _programFlag = true; qApp->processEvents(); foreach(auto& btn, button) { btn->setEnabled(true); qApp->processEvents(); } delay(delayPerTask); str = "doing"; color = Qt::red; emit labelState(ui->l_scenFillingDone, str, color); setScenario(h5Path); str = "done"; color = Qt::green; emit labelState(ui->l_scenFillingDone, str, color); qApp->processEvents(); QString progFolder = "prog(" + QString::number(i + 1) + ")/"; for(quint32 j = 0; j < taskItr; j++) { statusVec = _usd->readWord(0, 0); qApp->processEvents(); QString logFolder = QString::number(j + 1) + "/"; QString updatePath = enduranceLogPath + progFolder + logFolder; ui->tb_frameLogPath->setText(updatePath); qApp->processEvents(); if(!dir.exists(updatePath)) { dir.mkpath(updatePath); } else { dir.cd(updatePath); dir.removeRecursively(); dir.mkpath(updatePath); } on_btn_scenStart_clicked(); qApp->processEvents(); while(_dmaLog) { qApp->processEvents(); qApp->sync(); } delayEvents(delayPerTask); statusVec = _usd->readWord(0, 0); statusLog << QString::number(statusVec, 16) << endl; qApp->processEvents(); on_btn_scenStart_clicked(); qApp->processEvents(); if(_discardTempTest) { break; } } if(_discardTempTest) { _discardTempTest = false; break; } } statusFile.flush(); statusFile.close(); qApp->processEvents(); ui->chk_firstFrameLogEn->setChecked(false); _timeout->start(1000); } catch(SonoException& e) { _timeout->start(1000); slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_endurance_clicked() { auto progCnt = ui->tb_progCnt->text().toUInt(); auto taskItr = ui->tb_taskItr->text().toUInt(); auto delayPerTask = ui->tb_taskDelay->text().toUShort(); try { emit endurance(progCnt, taskItr, delayPerTask); } catch(SonoException& e) { slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_builtINTemp_clicked() { auto progCnt = ui->tb_progCnt->text().toUInt(); auto taskItr = ui->tb_taskItr->text().toUInt(); auto delayPerTask = ui->tb_taskDelay->text().toUShort(); try { _timeout->stop(); QDir dir; QString enduranceBiteLogPath = "/home/hasis/Desktop/hardware/Log/BITe_endurance/"; QString sramScenario = "/scenGenOutput/scenario.h5"; QString h5Path = ui->tb_biteScenPath->text() + sramScenario; if(ui->tb_biteScenPath->text().isEmpty()) { throw SonoException("No file is selected."); } for(quint32 i = 0; i < progCnt; i++) { _programFlag = false; delay(delayPerTask); qApp->processEvents(); QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_gtReg}; foreach(auto& btn, button) { btn->setEnabled(false); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); auto path = ui->tb_fpgaBit->text(); _trx.slaveFpgaProgram(path); qApp->processEvents(); #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); _trx.gtReadReset(); #endif str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); delay(delayPerTask); _programFlag = true; qApp->processEvents(); foreach(auto& btn, button) { btn->setEnabled(true); qApp->processEvents(); } delay(delayPerTask); str = "doing"; color = Qt::red; emit labelState(ui->l_biteScenFillingDone, str, color); setScenario(h5Path); str = "done"; color = Qt::green; emit labelState(ui->l_biteScenFillingDone, str, color); qApp->processEvents(); delay(delayPerTask); on_btn_biteIQ_clicked(); qApp->processEvents(); QString progFolder = "prog(" + QString::number(i + 1) + ")/"; delay(delayPerTask); for(quint32 j = 0; j < taskItr; j++) { qApp->processEvents(); QString logFolder = QString::number(j + 1) + "/"; QString updatePath = enduranceBiteLogPath + progFolder + logFolder; qApp->processEvents(); if(!dir.exists(updatePath)) { dir.mkpath(updatePath); } else { dir.cd(updatePath); dir.removeRecursively(); dir.mkpath(updatePath); } qApp->processEvents(); delay(delayPerTask); QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_biteLogDone, str, color); _dmaBuffer.clear(); _dmaLog = true; _trx.biteScenPlayerStart(); qApp->processEvents(); QtConcurrent::run(this, &MainWindow::logPcie, updatePath, 50, ui->lcd_biteCounter); logButtonsEnable(false); qApp->processEvents(); while(_dmaLog) { qApp->processEvents(); } qApp->processEvents(); delay(delayPerTask); _trx.biteScenPlayerStop(); str = "done"; color = Qt::green; emit labelState(ui->l_biteLogDone, str, color); logButtonsEnable(true); qApp->processEvents(); if(_discardTempTest) { break; } } if(_discardTempTest) { _discardTempTest = false; break; } } _timeout->start(1000); qApp->processEvents(); } catch(SonoException& e) { _timeout->start(1000); logButtonsEnable(true); slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_headerEndurance_clicked() { auto progCnt = ui->tb_progCnt->text().toUInt(); auto taskItr = ui->tb_taskItr->text().toUInt(); auto delayPerTask = ui->tb_taskDelay->text().toUShort(); quint16 scenStartDuration = ui->tb_scenStartDuration->text().toUShort() * 1000; try { _timeout->stop(); if(!_headerEndurance->open(QIODevice::WriteOnly)) { throw SonoException("Couldn't save status log file."); } QString sramScenario = "/scenGenOutput/scenario.h5"; QString h5Path = ui->tb_scenFilesPath->text() + sramScenario; if(ui->tb_scenFilesPath->text().isEmpty()) { throw SonoException("No file is selected."); } for(quint32 i = 0; i < progCnt; i++) { _programFlag = false; delay(delayPerTask); qApp->processEvents(); QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_gtReg}; foreach(auto& btn, button) { btn->setEnabled(false); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); auto path = ui->tb_fpgaBit->text(); _trx.slaveFpgaProgram(path); qApp->processEvents(); #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); _trx.gtReadReset(); #endif str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); delay(delayPerTask); _programFlag = true; qApp->processEvents(); foreach(auto& btn, button) { btn->setEnabled(true); qApp->processEvents(); } delay(delayPerTask); str = "doing"; color = Qt::red; emit labelState(ui->l_biteScenFillingDone, str, color); setScenario(h5Path); str = "done"; color = Qt::green; emit labelState(ui->l_biteScenFillingDone, str, color); qApp->processEvents(); _frame.clear(); _lastBuffer.clear(); _bufferedFrame.clear(); _trx.scenPlayerStart(true); _trx.scenPlayerStop(); for(quint32 j = 0; j < taskItr; j++) { qApp->processEvents(); delayEvents(scenStartDuration); QTextStream headerLog(_headerEndurance); headerLog << "batchId, " << "subBatchId, " << "bLine, " << "bPoint, "; headerLog << "frmType, " << "cri, " << "mLine, " << "mPoint, "; headerLog << endl; _headerEndur = true; qApp->processEvents(); _frameCount = 0; _frame.clear(); _lastBuffer.clear(); _bufferedFrame.clear(); ui->btn_scenStart->setText("Scenario Stop"); _trx.scenPlayerStart(); _dmaRun = true; //flag _dmaBuffer.clear(); qApp->processEvents(); delayEvents(scenStartDuration); qApp->processEvents(); _dmaRun = false; ui->btn_scenStart->setText("Scenario Start"); _trx.scenPlayerStop(); qApp->processEvents(); if(_discardTempTest) { break; } } _trx.scenPlayerStop(true); if(_discardTempTest) { _discardTempTest = false; break; } } _timeout->start(1000); _headerEndurance->flush(); _headerEndurance->close(); _headerEndur = false; qApp->processEvents(); } catch(SonoException& e) { _timeout->start(1000); _headerEndurance->flush(); _headerEndurance->close(); _headerEndur = false; slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_scenFolderBrowse_clicked() { try { QString scenPath = QFileDialog::getExistingDirectory(this, tr("Scenarios Folder"), _scenFolder, QFileDialog::ShowDirsOnly); if(scenPath.isEmpty()) { throw SonoException("No file is selected."); } ui->tb_scenFolder->setText(scenPath); _settings->setValue(SCENARIOS_FOLDER_PATH, scenPath); ui->tb_scenInfo->clear(); } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_scenChange_clicked() { auto progCnt = ui->tb_progCnt->text().toUInt(); auto taskItr = ui->tb_taskItr->text().toUInt(); auto delayPerTask = ui->tb_taskDelay->text().toUShort(); try { _timeout->stop(); QString scenFolder = ui->tb_scenFolder->text(); QDir scenDir(scenFolder); scenDir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs); QStringList scenList = scenDir.entryList(); qDebug() << scenList; quint32 statusVec; QString statusPath = "/home/hasis/Desktop/hardware/Log/statusVector/statusLog.txt"; QFile statusFile(statusPath); QTextStream statusLog(&statusFile); if(!statusFile.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't save status log file."); } QDir dir; ui->chk_firstFrameLogEn->setChecked(true); for(quint32 i = 0; i < progCnt; i++) { _programFlag = false; delay(delayPerTask); qApp->processEvents(); QList button = {ui->btn_getFpgaVersion, ui->btn_fpgaProgram, ui->btn_gtReg}; foreach(auto& btn, button) { btn->setEnabled(false); } QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); auto path = ui->tb_fpgaBit->text(); _trx.slaveFpgaProgram(path); qApp->processEvents(); #ifdef DEVELOP_UI _trx.afeAdcsSync(MOUNTED_SLAVE_FPGA); _trx.gtReadReset(); #endif str = "done"; color = Qt::green; emit labelState(ui->l_programDone, str, color); delay(delayPerTask); _programFlag = true; qApp->processEvents(); foreach(auto& btn, button) { btn->setEnabled(true); qApp->processEvents(); } delay(delayPerTask); QString sramScenario = "/scenGenOutput/scenario.h5"; QString progFolder = "hwLog/prog(" + QString::number(i + 1) + ")/"; for(quint32 j = 0; j < taskItr; j++) { foreach(auto& scenStr, scenList) { statusVec = _usd->readWord(0, 0); qApp->processEvents(); QString h5Path = scenFolder + "/" + scenStr + sramScenario; QString scenChangeLogPath = scenFolder + "/" + scenStr + "/"; if(scenFolder.isEmpty()) { throw SonoException("No file is selected."); } setScenario(h5Path); qApp->processEvents(); QString logFolder = QString::number(j + 1) + "/"; QString updatePath = scenChangeLogPath + progFolder + logFolder; ui->tb_frameLogPath->setText(updatePath); qApp->processEvents(); if(!dir.exists(updatePath)) { dir.mkpath(updatePath); } else { dir.cd(updatePath); dir.removeRecursively(); dir.mkpath(updatePath); } qApp->processEvents(); on_btn_scenStart_clicked(); qApp->processEvents(); while(_dmaLog) { qApp->processEvents(); qApp->sync(); } delayEvents(delayPerTask); statusVec = _usd->readWord(0, 0); statusLog << QString::number(statusVec, 16) << endl; qApp->processEvents(); on_btn_scenStart_clicked(); qApp->processEvents(); if(_discardTempTest) { break; } } if(_discardTempTest) { break; } } if(_discardTempTest) { _discardTempTest = false; break; } } statusFile.flush(); statusFile.close(); qApp->processEvents(); ui->chk_firstFrameLogEn->setChecked(false); _timeout->start(1000); } catch(SonoException& e) { _timeout->start(1000); slaveProgButtonsEnable(true); qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_seRead_clicked() { quint32 offset = 0x26028; quint32 bar(0); quint32 value1 = 0x29301; quint32 value2 = 0x9301; quint32 value3 = 0x1E900; quint32 value4 = 0xE900; quint32 value5 = 0x29300; quint32 value6 = 0x9300; _usd->writeWord(offset, bar, value1); _usd->writeWord(offset, bar, value2); delay(1); _usd->writeWord(offset, bar, value3); _usd->writeWord(offset, bar, value4); delay(1); quint32 value7 = _usd->readWord(0x26090, bar); ui->tb_seRead->setText(QString::number(value7)); _usd->writeWord(offset, bar, value5); _usd->writeWord(offset, bar, value6); } /*************************************************************************************************/ void MainWindow::on_btn_discard_clicked(void) { _discardTempTest = true; } /*************************************************************************************************/ void MainWindow::on_sb_Fan1Pwm_valueChanged(int arg1) { try { quint8 dutyCycle = static_cast(arg1); _trx.setTrxFanRpm(fan1, dutyCycle); qDebug() << "Fan1 (D.C.): " << dutyCycle; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_sb_Fan2Pwm_valueChanged(int arg1) { try { quint8 dutyCycle = static_cast(arg1); _trx.setTrxFanRpm(fan2, dutyCycle); qDebug() << "Fan2 (D.C.): " << dutyCycle; } catch(SonoException& e) { qDebug() << e.what(); } } /*************************************************************************************************/ void MainWindow::on_btn_spiFlash_clicked() { static quint32 fifoCount(0); QList data; quint32 baseAddr = 0x4000000; quint32 bar = 0x1; _usd->writeWord(baseAddr + 0x68, bar, 0x3); for(quint8 i(0); i < 15; i++) { _usd->writeWord(baseAddr + 0x68, bar, 0x0); } _usd->writeWord(baseAddr + 0x70, bar, 0xFFFFFFFE); _usd->writeWord(baseAddr + 0x60, bar, 0x86); delay(2); _usd->writeWord(baseAddr + 0x60, bar, 0x186); fifoCount++; qDebug() << "****************" << "FIFO Count:" << fifoCount << "****************"; for(quint8 j(0); j < 16; j++) { data.push_back(_usd->readWord(baseAddr + 0x6C, bar)); qDebug() << QString::number(data.at(j), 16); } } /*************************************************************************************************/ void MainWindow::on_btn_spiVerify_clicked() { _trx.spiFlashVerify(); }