You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2544 lines
79 KiB

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