From b15a64cc30ba9ef5a401ff00354b37b03bf71c30 Mon Sep 17 00:00:00 2001 From: Arash Aletayeb Date: Wed, 23 Jun 2021 14:07:06 +0200 Subject: [PATCH] The adcs of afe is synchronized after slave fpga programming The mps reset bug is fixed The dacs of supervisory bug is fixed The preprocessors of compiler are added to switch between some fitures --- developHw.pro | 2 +- developHw.pro.user | 2 +- hdf5Scenario/hdf5Scenario.cpp | 4 +- include/model/hardware/core/TrxBoard.h | 16 +- .../core/TrxBoardUtils/PreProcessorDef.h | 6 +- .../model/hardware/core/register/afe/Afe.h | 7 + .../afe/registerDefinition/AdcSyncStatus.h | 30 +- .../registerDefinition/RxBeamformerLut.h | 2 +- .../register/boardsCtrlMngt/BoardsCtrlMngt.h | 8 +- .../mps/SupervisorSetupCmd.h | 3 + .../register/dsp/registerDefinition/LpfLut.h | 2 +- .../core/register/fpgaProgram/FpgaProgram.h | 25 +- .../model/hardware/core/register/misc/Misc.h | 7 +- .../misc/registerDefinition/FrameLostCount.h | 30 + .../misc/registerDefinition/StatusVector.h | 4 + main.cpp | 27 +- mainwindow.cpp | 2322 +++++++++-------- mainwindow.h | 22 +- mainwindow.ui | 115 +- src/model/hardware/core/TrxBoard.cpp | 434 ++- src/model/hardware/core/register/afe/Afe.cpp | 36 +- .../boardsCtrlMngt/BoardsCtrlMngt.cpp | 599 +++-- .../core/register/fpgaProgram/FpgaProgram.cpp | 80 +- .../hardware/core/register/misc/Misc.cpp | 38 +- 24 files changed, 2192 insertions(+), 1629 deletions(-) create mode 100644 include/model/hardware/core/register/misc/registerDefinition/FrameLostCount.h diff --git a/developHw.pro b/developHw.pro index ba8cd92..215fa3a 100644 --- a/developHw.pro +++ b/developHw.pro @@ -25,7 +25,7 @@ SOURCES += \ $$files(hdf5Scenario/*.cpp, true) \ HEADERS += \ - include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h \ + include/model/hardware/core/register/misc/registerDefinition/FrameLostCount.h \ mainwindow.h \ qcustomplot.h \ api.h \ diff --git a/developHw.pro.user b/developHw.pro.user index 284c63c..14b71cd 100644 --- a/developHw.pro.user +++ b/developHw.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/hdf5Scenario/hdf5Scenario.cpp b/hdf5Scenario/hdf5Scenario.cpp index 1436732..8620711 100644 --- a/hdf5Scenario/hdf5Scenario.cpp +++ b/hdf5Scenario/hdf5Scenario.cpp @@ -667,8 +667,8 @@ QVector Hdf5::stbRead() QVector Hdf5::lineFilterRead() { - /**************** /registerParameters/lineFilterLutQ ********************/ - datasetBranch ("/registerParameters/lineFilterLutQ", floatArray); + /**************** /registerParameters/lineFilterLut ********************/ + datasetBranch ("/registerParameters/lineFilterLut", floatArray); QVector lineFilter; for (quint8 var = 0; var < 3; var++) lineFilter.push_back(floatArray[var]); diff --git a/include/model/hardware/core/TrxBoard.h b/include/model/hardware/core/TrxBoard.h index b72490f..c94213d 100644 --- a/include/model/hardware/core/TrxBoard.h +++ b/include/model/hardware/core/TrxBoard.h @@ -77,7 +77,6 @@ private: BeamFormer* _beamFormerSlave1; BeamFormer* _beamFormerSlave2; BoardsCtrlMngt* _bCtrlMngt; - FpgaProgram* _fpgaProgram; ScenPalyer* _scenPlayer; BpiFlash* _bpiFlash; Afe* _afeSlave0; @@ -87,6 +86,9 @@ private: Misc* _misc; Sram* _sram; Dsp* _dsp; +#ifndef DEVELOP_UI + FpgaProgram* _fpgaProgram; +#endif enum eScenParams : quint8 { @@ -140,6 +142,8 @@ private: void scenParamsFilling(eScenParams cmd); //QList signedVector2unsignedList(QVector& sgnVec); + void afeAdcsSync (void) const; + template QByteArray uintLittleEndian2ByteArray(T& data) const; @@ -154,8 +158,6 @@ signals: public: - HardwarePacketEngine packetEngine; - TrxBoard(); ~TrxBoard(); @@ -227,9 +229,17 @@ public: void getTrxStatus(StatusVec* status) const; void getFpgasCodeVersion(FpgaCodeVersion* version) const; void sramParityClear(); + quint32 getFrameLostCounter(void) const; /////////////////////////////// DMA Data Packet //////////////////////////////////// void readData(); + +#ifdef DEVELOP_UI + FpgaProgram* _fpgaProgram; +#endif +#ifndef DEVELOP_UI + HardwarePacketEngine packetEngine; +#endif }; #endif //TRXBOARD_H diff --git a/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h b/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h index b5d6c1b..fd35bb7 100644 --- a/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h +++ b/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h @@ -2,9 +2,9 @@ #define PREPROCESSORDEF_H #define MPS_BOARD -//#undef MPS_BOARD +#undef MPS_BOARD #define DEVELOP_UI -#undef DEVELOP_UI +//#undef DEVELOP_UI -#endif // PREPROCESSORDEF_H +#endif //PREPROCESSORDEF_H diff --git a/include/model/hardware/core/register/afe/Afe.h b/include/model/hardware/core/register/afe/Afe.h index 3042178..28a1f50 100644 --- a/include/model/hardware/core/register/afe/Afe.h +++ b/include/model/hardware/core/register/afe/Afe.h @@ -1,6 +1,7 @@ #ifndef AFE_H #define AFE_H +#include "registerDefinition/AdcSyncStatus.h" #include "registerDefinition/ActiveTerm.h" #include "registerDefinition/LnaHpf.h" #include "registerDefinition/Global.h" @@ -133,6 +134,7 @@ Q_DECLARE_METATYPE(AfeConfig) class Afe { private: + AdcSyncStatus* _adcSync; ActiveTerm* _actTerm; LnaHpf* _lnaHpf; Global* _global; @@ -151,6 +153,11 @@ public: void setAfeParams(const AfeConfig afe) const; void setAfeGblPwr(const bool pwrdn) const; void setReadRegEnable(const bool rdEn) const; + + bool getAfeSyncDone(void) const; + quint32 getAfeSyncError(void) const; + quint32 getAfeSyncAddress(void) const; + quint32 getAfeDataValid(void) const; }; #endif // AFE_H diff --git a/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h b/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h index c65a600..aac45a9 100644 --- a/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h +++ b/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h @@ -6,30 +6,36 @@ #undef BAR -#define GEN_SYNC_CHECKER_MASK 0x0000000C -#define SYNC_CHECK_DONE_MASK 0x0000000C -#define SYNC_CHECK_ERROR_MASK 0x0000000C -#define LNA_HPF_PROG_MASK 0x0000000C +#define SYNC_DONE_MASK 0x00000001 +#define SYNC_ERROR_MASK 0x000000FE +#define SYNC_ADDRESS_MASK 0x00003F00 +#define DATA_VALID_OFFSET_MASK 0x0000C000 -#define BAR 0U -#define OFFSET 0x43C384 +#define BAR 0U +#define OFFSET 0x43C384 class AdcSyncStatus : public Register { public: - Field* lnaHpfProg; + Field* syncDone; + Field* syncError; + Field* syncAddress; + Field* dataValidOffset; AdcSyncStatus(SonoDevice* device, quint32 offset) : Register(BAR, OFFSET + offset, device) { - ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); - ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); - ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); - ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); + ADD_UNSIGNED_FIELD(syncDone, SYNC_DONE_MASK); + ADD_UNSIGNED_FIELD(syncError, SYNC_ERROR_MASK); + ADD_UNSIGNED_FIELD(syncAddress, SYNC_ADDRESS_MASK); + ADD_UNSIGNED_FIELD(dataValidOffset, DATA_VALID_OFFSET_MASK); } }; -#undef LNA_HPF_PROG_MASK +#undef SYNC_DONE_MASK +#undef SYNC_ERROR_MASK +#undef SYNC_ADDRESS_MASK +#undef DATA_VALID_OFFSET_MASK #undef BAR #undef OFFSET diff --git a/include/model/hardware/core/register/beamFormer/registerDefinition/RxBeamformerLut.h b/include/model/hardware/core/register/beamFormer/registerDefinition/RxBeamformerLut.h index 868aeec..349b96c 100644 --- a/include/model/hardware/core/register/beamFormer/registerDefinition/RxBeamformerLut.h +++ b/include/model/hardware/core/register/beamFormer/registerDefinition/RxBeamformerLut.h @@ -34,7 +34,7 @@ private: void prepareData(quint32 index) override { - lagPrp->setValue(_rxBfLut->lag.at(static_cast(index))); + lagPrp->setValue(_rxBfLut->lag.at(static_cast(index)) - 1); apodizationSelPrp->setValue(_rxBfLut->apodization.at(static_cast(index)) - 1); diff --git a/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h b/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h index 3700bcc..5c6cf88 100644 --- a/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h +++ b/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h @@ -195,18 +195,20 @@ private: bool getI2cBusy(void) const; void getSupervisorI2cTimeout(void) const; void getSupervisorI2cDone(void) const; + bool getSetupCmdP24vOnOff(void) const; void setSetupCmdP24vOnOff(bool p24vOnOff) const; void setSetupCmdJmp(bool jmpDacCmd) const; void setSetupCmdDacsOnOff(bool cwd, bool hvb, bool hva) const; + void setPwrDacsValid(bool pwrValid) const; void setMpsDacsValue(MpsDacs* _mpsDacs) const; friend void trxEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt* boards); friend void mpsEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt* boards); friend void prbCtrlEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt* boards); friend void prbEepromWrite(QByteArray arr, - quint32 address, - quint8 prbSel, - BoardsCtrlMngt* boards); + quint32 address, + quint8 prbSel, + BoardsCtrlMngt* boards); public: explicit BoardsCtrlMngt(SonoDevice* device) : BoardsSpecs(device) diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/SupervisorSetupCmd.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/SupervisorSetupCmd.h index cfef204..1ba3728 100644 --- a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/SupervisorSetupCmd.h +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/SupervisorSetupCmd.h @@ -11,6 +11,7 @@ #define CWD_ON_OFF_MASK 0x00000004 #define HVB_ON_OFF_MASK 0x00000008 #define HVA_ON_OFF_MASK 0x00000010 +#define PWR_DAC_VALID_MASK 0x00000020 #define BAR 0 #define OFFSET 0X26030 @@ -23,6 +24,7 @@ public: Field* cwdOnOff; Field* hvbOnOff; Field* hvaOnOff; + Field* pwrDacValid; SupervisorSetupCmd(SonoDevice* device) : Register(BAR, OFFSET, device) @@ -32,6 +34,7 @@ public: ADD_UNSIGNED_FIELD(cwdOnOff, CWD_ON_OFF_MASK); ADD_UNSIGNED_FIELD(hvbOnOff, HVB_ON_OFF_MASK); ADD_UNSIGNED_FIELD(hvaOnOff, HVA_ON_OFF_MASK); + ADD_UNSIGNED_FIELD(pwrDacValid, PWR_DAC_VALID_MASK); } }; diff --git a/include/model/hardware/core/register/dsp/registerDefinition/LpfLut.h b/include/model/hardware/core/register/dsp/registerDefinition/LpfLut.h index 12d6782..b38a6e6 100644 --- a/include/model/hardware/core/register/dsp/registerDefinition/LpfLut.h +++ b/include/model/hardware/core/register/dsp/registerDefinition/LpfLut.h @@ -6,7 +6,7 @@ #undef BAR -#define LPF_LUT_MASK 0x0000FFFF +#define LPF_LUT_MASK 0x0003FFFF #define BAR 0 #define OFFSET 0x81000 diff --git a/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h b/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h index 2f51795..f9e7f9d 100644 --- a/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h +++ b/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h @@ -1,6 +1,7 @@ #ifndef FPGAPROGRAM_H #define FPGAPROGRAM_H +#include #include #include #include @@ -11,10 +12,6 @@ #include "registerDefinition/SerialProgramData.h" #include "registerDefinition/SerialProgramStatus.h" -//#define FPGA_S0_DONE 1 -//#define FPGA_S1_DONE 2 -//#define FPGA_S2_DONE 4 - #define FPGA_S0_INIT_B 1 #define FPGA_S1_INIT_B 2 #define FPGA_S2_INIT_B 4 @@ -30,13 +27,15 @@ T byteArray2UintBigEndian(QByteArray& byte) return data; } -class FpgaProgram +class FpgaProgram : public QObject { + Q_OBJECT + private: SerialProgramData* _progData; SlaveFpgaNumber* _fpgaNumber; - struct ProgramStatus { + struct ProgramStatus { SerialProgramStatus* _progStatus; bool getProgramBusy() const; bool getProgramDone() const; @@ -46,18 +45,22 @@ private: bool getFpgaS0InitB() const; bool getFpgaS1InitB() const; bool getFpgaS2InitB() const; -//bool getFpgaS0Done(); -//bool getFpgaS1Done(); -//bool getFpgaS2Done(); - }* _status; + }* _status; + + void setSlaveFpgaNumber(quint8& number) const; - void setSlaveFpgaNumber(quint8& number) const; +#ifdef DEVELOP_UI +signals: + void programmingProgress(qint32 progressValue, qint32 bitFileSize); +#endif public: explicit FpgaProgram(SonoDevice* device); ~FpgaProgram(); void program(QByteArray& bitFileData, quint8 number); + + }; #endif //PROGRAM_H diff --git a/include/model/hardware/core/register/misc/Misc.h b/include/model/hardware/core/register/misc/Misc.h index 318d663..a86e838 100644 --- a/include/model/hardware/core/register/misc/Misc.h +++ b/include/model/hardware/core/register/misc/Misc.h @@ -1,9 +1,10 @@ #ifndef MISC_H #define MISC_H +#include "registerDefinition/FrameLostCount.h" +#include "registerDefinition/StatusVector.h" #include "registerDefinition/FpgaVersion.h" #include "registerDefinition/GtSendMode.h" -#include "registerDefinition/StatusVector.h" #include "registerDefinition/SyncMode.h" struct StatusVec @@ -24,6 +25,7 @@ struct StatusVec bool pgErr; bool probeDisconnectErr; bool fanFault; + bool frameLost; bool emulDmaTransferErr; bool dmaCtrlTransferErr; }; @@ -65,6 +67,7 @@ private: StatusVector* _status; GtSendMode* _gt; SyncMode* _sync; + FrameLostCount* _lostCount; template quint32 getVersion (T* version) const; @@ -77,6 +80,8 @@ public: void getFpgaVersion(FpgaCodeVersion* version) const; void setGtSendMode (eGtSendCtrl gtMode) const; void setSyncMode (eSyncCtrl syncMode) const; + void setManualSync (bool sync) const; + quint32 getFrameLostCount(void) const; }; diff --git a/include/model/hardware/core/register/misc/registerDefinition/FrameLostCount.h b/include/model/hardware/core/register/misc/registerDefinition/FrameLostCount.h new file mode 100644 index 0000000..b17bfca --- /dev/null +++ b/include/model/hardware/core/register/misc/registerDefinition/FrameLostCount.h @@ -0,0 +1,30 @@ +#ifndef FRAMELOSTCOUNT_H +#define FRAMELOSTCOUNT_H + +#include "model/hardware/core/register/Register.h" +#include "model/hardware/core/register/RegUtils.h" + +#undef BAR + +#define LOST_COUNT 0x000000FF + +#define BAR 0U +#define OFFSET 0x86024 + +class FrameLostCount : public Register +{ +public: + Field* lostCount; + + FrameLostCount(SonoDevice* device) : Register(BAR, OFFSET, device) + { + ADD_UNSIGNED_FIELD(lostCount, LOST_COUNT); + } +}; + +#undef LOST_COUNT + +#undef BAR +#undef OFFSET + +#endif // FRAMELOSTCOUNT_H diff --git a/include/model/hardware/core/register/misc/registerDefinition/StatusVector.h b/include/model/hardware/core/register/misc/registerDefinition/StatusVector.h index d8f453e..86564e1 100644 --- a/include/model/hardware/core/register/misc/registerDefinition/StatusVector.h +++ b/include/model/hardware/core/register/misc/registerDefinition/StatusVector.h @@ -22,6 +22,7 @@ #define PG_Err_MASK 0x00002000 #define PROBE_DISCONNECT_Err_MASK 0x00004000 #define FAN_FAULT_MASK 0x00008000 +#define FRAME_LOST_MASK 0x00020000 #define EMUL_DMA_TRANSFER_Err_MASK 0x40000000 #define DMA_CTRL_TRANSFER_Err_MASK 0x80000000 @@ -47,6 +48,7 @@ public: Field* pgErr; Field* probeDisconnectErr; Field* fanFault; + Field* frameLost; Field* emulDmaTransferErr; Field* dmaCtrlTransferErr; @@ -68,6 +70,7 @@ public: ADD_UNSIGNED_FIELD(pgErr, PG_Err_MASK); ADD_UNSIGNED_FIELD(probeDisconnectErr, PROBE_DISCONNECT_Err_MASK); ADD_UNSIGNED_FIELD(fanFault, FAN_FAULT_MASK); + ADD_UNSIGNED_FIELD(frameLost, FRAME_LOST_MASK); ADD_UNSIGNED_FIELD(emulDmaTransferErr, EMUL_DMA_TRANSFER_Err_MASK); ADD_UNSIGNED_FIELD(dmaCtrlTransferErr, DMA_CTRL_TRANSFER_Err_MASK); } @@ -89,6 +92,7 @@ public: #undef PG_Err_MASK #undef PROBE_DISCONNECT_Err_MASK #undef FAN_FAULT_MASK +#undef FRAME_LOST_MASK #undef EMUL_DMA_TRANSFER_Err_MASK #undef DMA_CTRL_TRANSFER_Err_MASK diff --git a/main.cpp b/main.cpp index 9d59637..f0e8ee0 100644 --- a/main.cpp +++ b/main.cpp @@ -7,14 +7,21 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; - w.setGeometry( - QStyle::alignedRect( - Qt::LeftToRight, - Qt::AlignCenter, - w.size(), - qApp->desktop()->availableGeometry() - ) - ); - w.show(); - return a.exec(); + try + { + w.setGeometry( + QStyle::alignedRect( + Qt::LeftToRight, + Qt::AlignCenter, + w.size(), + qApp->desktop()->availableGeometry() + ) + ); + w.show(); + return a.exec(); + } + catch(SonoException& e) + { + qDebug() << e.what(); + } } diff --git a/mainwindow.cpp b/mainwindow.cpp index 9db1b49..f71fb4a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -3,52 +3,52 @@ QThread* MainWindow::_uiThread; -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) , +MainWindow::MainWindow(QWidget* parent) + : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); _uiThread = QThread::currentThread(); - this->setFixedSize(this->width(),this->height()); + this->setFixedSize(this->width(), this->height()); - _settings = new QSettings("Hasis", "HwTester"); + _settings = new QSettings("Hasis", "HwTester"); - _usd = new UltraSoundDevice(); + _usd = new UltraSoundDevice(); - _timeout = new QTimer; + _timeout = new QTimer; - _bCtrl = new BoardsCtrlMngt (_usd->device); - _healStatus = new HealthStatus; - _supRbValue = new SupervisorRbValue; + _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; + _version = new FpgaCodeVersion; + _vec = new StatusVec; + _emul = new EmulatorProperties; + _prb = new PrbCase; - _colorMap = new QCPColorMap(ui->plot_2->xAxis,ui->plot_2->yAxis); + _colorMap = new QCPColorMap(ui->plot_2->xAxis, ui->plot_2->yAxis); - ui->plot_2->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag); + 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->prg_adcSim->setVisible(false); - // ui->prg_scenarioUpload->setVisible(false); - // ui->prg_txDacUpload->setVisible(false); - // ui->prg_fpgaProgram->setVisible(false); - // ui->prg_adcLoggerFileWr->setVisible(false); + //ui->prg_adcSim->setVisible(false); + //ui->prg_scenarioUpload->setVisible(false); + //ui->prg_txDacUpload->setVisible(false); + //ui->prg_fpgaProgram->setVisible(false); + //ui->prg_adcLoggerFileWr->setVisible(false); - // ui->tb_scenarioFile->setReadOnly(true); - // ui->tb_paramFile->setReadOnly(true); - // ui->tb_txDacFile->setReadOnly(true); + //ui->tb_scenarioFile->setReadOnly(true); + //ui->tb_paramFile->setReadOnly(true); + //ui->tb_txDacFile->setReadOnly(true); ui->tb_fpgaBit->setReadOnly(true); - // ui->tb_scenarioFile->setText(_settings->value(SCENARIO_FILE_PATH).value()); - // ui->tb_paramFile->setText(_settings->value(PARAM_FILE_PATH).value()); - // ui->tb_txDacFile->setText(_settings->value(TX_DAC_FILE_PATH).value()); + //ui->tb_scenarioFile->setText(_settings->value(SCENARIO_FILE_PATH).value()); + //ui->tb_paramFile->setText(_settings->value(PARAM_FILE_PATH).value()); + //ui->tb_txDacFile->setText(_settings->value(TX_DAC_FILE_PATH).value()); 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()); @@ -62,25 +62,36 @@ MainWindow::MainWindow(QWidget *parent) ui->tb_prbCtrlRomInfo->setPlaceholderText("info"); ui->tb_prbRomIdRead->setPlaceholderText("id(hex)"); ui->tb_prbRomImpulseRead->setPlaceholderText("impulse"); + ui->prg_programming->setVisible(false); - // connect(this, &MainWindow::updateBlockProgressValue, this, &MainWindow::newBlockProgressValue); - // connect(this, &MainWindow::updateFpgaProgressValue, this, &MainWindow::newFpgaProgressValue); - // connect(this, &MainWindow::updateBlockProgressVisibility, this, &MainWindow::newBlockProgressVisibility); - // connect(this, &MainWindow::updateFpgaProgressVisibility, this, &MainWindow::newFpgaProgressVisibility); + //connect(this, &MainWindow::updateBlockProgressValue, this, + //&MainWindow::newBlockProgressValue); + //connect(this, &MainWindow::updateFpgaProgressValue, this, &MainWindow::newFpgaProgressValue); + //connect(this, &MainWindow::updateBlockProgressVisibility, this, + //&MainWindow::newBlockProgressVisibility); + //connect(this, &MainWindow::updateFpgaProgressVisibility, this, + //&MainWindow::newFpgaProgressVisibility); - //connect(this, &MainWindow::updateAdcLoggerProgressValue, this, &MainWindow::newAdcLoggerProgressValue); - //connect(this, &MainWindow::updateAdcLoggerProgressVisibility, this, &MainWindow::newAdcLoggerProgressVisibility); + //connect(this, &MainWindow::updateAdcLoggerProgressValue, this, + //&MainWindow::newAdcLoggerProgressValue); + //connect(this, &MainWindow::updateAdcLoggerProgressVisibility, this, + //&MainWindow::newAdcLoggerProgressVisibility); 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(&scenEndWather, &QFutureWatcher::finished, this, &MainWindow::restartTimer); + connect(this, &MainWindow::scenarioReady, this, &MainWindow::setScenario); + connect(this, &MainWindow::labelState, this, &MainWindow::getLabelState); + connect(this, &MainWindow::fpgaProgrammer, this, &MainWindow::getFpgaProgrammer); + connect(_trx._fpgaProgram,&FpgaProgram::programmingProgress, this, &MainWindow::getProgrammingProgress); //////////////////////// 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); + connect(this, &MainWindow::threeDReady, this, &MainWindow::show3d, + Qt::BlockingQueuedConnection); /////////////////// Scenario Verification Connections ///////////////////////// connect(&_trx, &TrxBoard::sramBinaryCreateFlag, this, &MainWindow::getSramBinaryCreateFlag); @@ -90,16 +101,16 @@ MainWindow::MainWindow(QWidget *parent) ui->btn_updateRdbackValue->setText(UPDATE); ui->btn_dmaLogLast->setHidden(true); - // uint32_t offsetdbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; - // auto value = 0; - // for (auto i=0 ; i<3;i++) - // { - // value = (_usd->readWord(offsetdbgCmd[i], 0)) & 0xC; - // if(value != 0) - // break; - // } - // if(value != 0) - // ui->ch_testMode->setCheckState(Qt::CheckState::Checked); + //uint32_t offsetdbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; + //auto value = 0; + //for (auto i=0 ; i<3;i++) + //{ + //value = (_usd->readWord(offsetdbgCmd[i], 0)) & 0xC; + //if(value != 0) + //break; + //} + //if(value != 0) + //ui->ch_testMode->setCheckState(Qt::CheckState::Checked); _dmaLog = false; _dmaRun = false; @@ -111,16 +122,17 @@ MainWindow::MainWindow(QWidget *parent) { _trx.init(); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } _timeout->start(1000); - //////////////////////////// First Time Probe Detection ////////////////////////////// - //emit connectedPrbChange(); +#ifdef MPS_BOARD + emit connectedPrbChange(); +#endif QFont fontTitle; fontTitle.setBold(true); @@ -156,205 +168,190 @@ MainWindow::~MainWindow() delete _vec; delete _emul; - } ///*************************************************************************************************/ //void MainWindow::binAdcFileUploader(quint32 bar, QString path, QProgressBar* prg) //{ -// QFile file(path); - -// if (!file.open(QFile::ReadOnly)) -// { -// MESSAGE_BOX("Could not open binary file, aborting operation"); -// return; -// } +//QFile file(path); -// emit updateBlockProgressVisibility(true, prg); -// emit updateBlockProgressValue(0, prg); +//if (!file.open(QFile::ReadOnly)) +//{ +//MESSAGE_BOX("Could not open binary file, aborting operation"); +//return; +//} -// const auto actualSize = file.size(); -// qint64 readSize = 0; -// quint32 addr = 0; -// quint32 data = 0; -// auto syncNum = 0; -// while((readSize < actualSize) & !_csvReadStopFlag) -// { -// QByteArray chunk = file.read(8); -// auto value = byteArrayTo64LittleEndian(chunk); -// try -// { -// addr = static_cast(value >> 32); -// data = static_cast(value & 0xFFFFFFFF); +//emit updateBlockProgressVisibility(true, prg); +//emit updateBlockProgressValue(0, prg); -// _usd->writeWord(addr, bar, data); -// if (addr != 3076) -// { -// qDebug() << syncNum << "==> " << addr << "::" << data; -// syncNum +=1; +//const auto actualSize = file.size(); +//qint64 readSize = 0; +//quint32 addr = 0; +//quint32 data = 0; +//auto syncNum = 0; +//while((readSize < actualSize) & !_csvReadStopFlag) +//{ +//QByteArray chunk = file.read(8); +//auto value = byteArrayTo64LittleEndian(chunk); +//try +//{ +//addr = static_cast(value >> 32); +//data = static_cast(value & 0xFFFFFFFF); -// } +//_usd->writeWord(addr, bar, data); +//if (addr != 3076) +//{ +//qDebug() << syncNum << "==> " << addr << "::" << data; +//syncNum +=1; +//} -// } catch (myexception e) -// { -// MESSAGE_BOX(e.what()); +//} catch (myexception e) +//{ +//MESSAGE_BOX(e.what()); -// emit updateBlockProgressVisibility(false, prg); +//emit updateBlockProgressVisibility(false, prg); -// file.close(); +//file.close(); -// return; -// } -// readSize += 8; -// auto percentage = (readSize * 100 / actualSize); -// emit updateBlockProgressValue(percentage, prg); -// } +//return; +//} +//readSize += 8; +//auto percentage = (readSize * 100 / actualSize); +//emit updateBlockProgressValue(percentage, prg); +//} -// //MESSAGE_BOX("Binary file upload finished with success"); +////MESSAGE_BOX("Binary file upload finished with success"); -// emit updateBlockProgressVisibility(false, prg); +//emit updateBlockProgressVisibility(false, prg); -// file.close(); +//file.close(); //} ///*************************************************************************************************/ //#define NO_AFE_CHANNEL 192 //#define NO_LOGGER_SMPL_COUNT 2048 //void MainWindow::AdcLogCsvFileWriter(QString folderPath, QProgressBar* prg) //{ -// quint32 bar = 0; -// quint32 offset = 0x2000; -// uint32_t offsetDbgTrsfr[3] = {0x140002*4,0x240002*4,0x340002*4}; -// uint32_t offsetDbgTrsfrDone[3] = {0x14000A*4,0x24000A*4,0x34000A*4}; -// _adcLoggerTrnsDone = false; - -// QTime t = QTime::currentTime(); -// QString path = folderPath + "/adcLog_" + QString("%1_%2_%3.csv").arg(t.hour()).arg(t.minute()).arg(t.second()); -// QFile file(path); -// file.open(QIODevice::WriteOnly); - -// emit updateBlockProgressVisibility(true, prg); -// emit updateBlockProgressValue(0, prg); - -// auto timeOut = 0; -// quint32 doneFlag = 0; -// quint32 value = 0; -// quint32 fpgaNum = 0; - -// offset = 0x4 * 4; -// auto gtSndMd = _usd->readWord(offset, bar); -// qDebug() << "--- SET GT Send Mode :: ADC Raw Logger --- "; -// _usd->writeWord(offset, bar, 0x2); // set GT Send mode (ADC Raw Logger) - -// for (auto j = 0; j < 3; j+=1) -// _usd->writeWord(offsetDbgTrsfr[j], bar,0x0); - -// for (quint16 i = 0; i < NO_AFE_CHANNEL; i += 1) -// { -// fpgaNum = (i / 64); - -// offset = 0x400*4;// set adc logger stop -// value = (fpgaNum << 1); -// _usd->writeWord(offset, bar,value); - -// value = value | 0x01;// set adc logger fpgaSel and start -// _usd->writeWord(offset, bar,value); - -// _usd->writeWord(offsetDbgTrsfr[fpgaNum], bar,0x0); -// value = i % 64; -// value = static_cast(((static_cast(0X01))) | ((static_cast(value & 0xFF)) << 8)); -// _usd->writeWord(offsetDbgTrsfr[fpgaNum], bar,value); - -// timeOut = 0; -// doneFlag = 0; -// while (timeOut < 10 && doneFlag == 0 ) -// { -// doneFlag = ((_usd->readWord(offsetDbgTrsfrDone[fpgaNum], bar)) & 0x100) >> 8; // wait Until transfer done -// timeOut += 1; -// delay(2); -// } -// if(timeOut == 10) -// { -// qDebug() << "Unable to transfer done"; -// //MESSAGE_BOX("Unable to transfer done"); -// //return; -// } - -// doneFlag = 0; -// timeOut = 0; -// offset = 0x401*4; -// while (timeOut < 10 && doneFlag == 0 ) -// { -// doneFlag = (_usd->readWord(offset, bar) & 0x1); // wait until adc logger MemDone Flag true -// timeOut += 1; -// delay(2); -// } -// if(timeOut == 10) -// { -// //MESSAGE_BOX("Unable to reach adc logger memory done"); -// qDebug() << "Unable to reach adc logger memory done :: 0x" << _usd->readWord(offset, bar); -// //return; -// } - -// _usd->writeWord(offsetDbgTrsfr[fpgaNum], bar,0); // Stop Debug transfer - -// offset = 0x2000; -// qint16 val = 0; -// for(auto j = 0; j < NO_LOGGER_SMPL_COUNT; j += 1) -// { -// value = _usd->readWord(offset, bar); // Read Adc logger Bram - -// val = static_cast(value & 0x3FFF) << 2; -// val = val >> 2; -// auto str = QStringLiteral("%1,").arg(val); -// file.write(str.toStdString().c_str(), str.length()); - -// offset += 4; -// } -// file.write("\r\n", 2); - -// value = (fpgaNum << 1) | 0x00;// set adc logger fpgaSel and Stop -// offset = 0x400*4; -// _usd->writeWord(offset, bar,value); - -// emit updateBlockProgressValue(i * 100 / NO_AFE_CHANNEL, prg); -// delay(10); - -// } -// offset = 0x400*4; -// _usd->writeWord(offset, bar,0x0); - -// qDebug() << "--- SET GT Send Mode :: Previous Mode --- "; -// offset = 0x4 * 4; -// _usd->writeWord(offset, bar, gtSndMd); // set GT Send mode -// emit updateBlockProgressVisibility(false, prg); - -// file.close(); -// _adcLoggerTrnsDone = true; -//} - -/*************************************************************************************************/ -void MainWindow::fpgaProgrammer(QString path) -{ - try - { - _trx.slaveFpgaProgram(path); - ui->l_programDone->setText("done"); - changeLabelTextColor(ui->l_programDone, Qt::green); - } - catch (SonoException& e) - { - qDebug() << e.what(); - } +//quint32 bar = 0; +//quint32 offset = 0x2000; +//uint32_t offsetDbgTrsfr[3] = {0x140002*4,0x240002*4,0x340002*4}; +//uint32_t offsetDbgTrsfrDone[3] = {0x14000A*4,0x24000A*4,0x34000A*4}; +//_adcLoggerTrnsDone = false; + +//QTime t = QTime::currentTime(); +//QString path = folderPath + "/adcLog_" + +//QString("%1_%2_%3.csv").arg(t.hour()).arg(t.minute()).arg(t.second()); +//QFile file(path); +//file.open(QIODevice::WriteOnly); + +//emit updateBlockProgressVisibility(true, prg); +//emit updateBlockProgressValue(0, prg); + +//auto timeOut = 0; +//quint32 doneFlag = 0; +//quint32 value = 0; +//quint32 fpgaNum = 0; + +//offset = 0x4 * 4; +//auto gtSndMd = _usd->readWord(offset, bar); +//qDebug() << "--- SET GT Send Mode :: ADC Raw Logger --- "; +//_usd->writeWord(offset, bar, 0x2); // set GT Send mode (ADC Raw Logger) + +//for (auto j = 0; j < 3; j+=1) +//_usd->writeWord(offsetDbgTrsfr[j], bar,0x0); + +//for (quint16 i = 0; i < NO_AFE_CHANNEL; i += 1) +//{ +//fpgaNum = (i / 64); -} +//offset = 0x400*4;// set adc logger stop +//value = (fpgaNum << 1); +//_usd->writeWord(offset, bar,value); + +//value = value | 0x01;// set adc logger fpgaSel and start +//_usd->writeWord(offset, bar,value); + +//_usd->writeWord(offsetDbgTrsfr[fpgaNum], bar,0x0); +//value = i % 64; +//value = static_cast(((static_cast(0X01))) | ((static_cast(value & +//0xFF)) << 8)); +//_usd->writeWord(offsetDbgTrsfr[fpgaNum], bar,value); + +//timeOut = 0; +//doneFlag = 0; +//while (timeOut < 10 && doneFlag == 0 ) +//{ +//doneFlag = ((_usd->readWord(offsetDbgTrsfrDone[fpgaNum], bar)) & 0x100) >> 8; // wait Until +//transfer done +//timeOut += 1; +//delay(2); +//} +//if(timeOut == 10) +//{ +//qDebug() << "Unable to transfer done"; +////MESSAGE_BOX("Unable to transfer done"); +////return; +//} + +//doneFlag = 0; +//timeOut = 0; +//offset = 0x401*4; +//while (timeOut < 10 && doneFlag == 0 ) +//{ +//doneFlag = (_usd->readWord(offset, bar) & 0x1); // wait until adc logger MemDone Flag true +//timeOut += 1; +//delay(2); +//} +//if(timeOut == 10) +//{ +////MESSAGE_BOX("Unable to reach adc logger memory done"); +//qDebug() << "Unable to reach adc logger memory done :: 0x" << _usd->readWord(offset, bar); +////return; +//} + +//_usd->writeWord(offsetDbgTrsfr[fpgaNum], bar,0); // Stop Debug transfer + +//offset = 0x2000; +//qint16 val = 0; +//for(auto j = 0; j < NO_LOGGER_SMPL_COUNT; j += 1) +//{ +//value = _usd->readWord(offset, bar); // Read Adc logger Bram + +//val = static_cast(value & 0x3FFF) << 2; +//val = val >> 2; +//auto str = QStringLiteral("%1,").arg(val); +//file.write(str.toStdString().c_str(), str.length()); + +//offset += 4; +//} +//file.write("\r\n", 2); + +//value = (fpgaNum << 1) | 0x00;// set adc logger fpgaSel and Stop +//offset = 0x400*4; +//_usd->writeWord(offset, bar,value); + +//emit updateBlockProgressValue(i * 100 / NO_AFE_CHANNEL, prg); +//delay(10); + +//} +//offset = 0x400*4; +//_usd->writeWord(offset, bar,0x0); + +//qDebug() << "--- SET GT Send Mode :: Previous Mode --- "; +//offset = 0x4 * 4; +//_usd->writeWord(offset, bar, gtSndMd); // set GT Send mode +//emit updateBlockProgressVisibility(false, prg); + +//file.close(); +//_adcLoggerTrnsDone = true; +//} /*************************************************************************************************/ void MainWindow::timeout() { auto pcie_pid = _trx.deviceId(); auto pcie_vid = _trx.vendorId(); - auto pcie_id = (pcie_pid << 16)|pcie_vid; + auto pcie_id = (pcie_pid << 16) | pcie_vid; ui->l_PCIeID->setText(QString::number(pcie_id, 16)); delay(10); @@ -436,116 +433,128 @@ void MainWindow::timeout() _trx.getTrxStatus(_vec); delay(10); - bool pgErr=_vec->pgErr; + bool pgErr = _vec->pgErr; ui->l_pg->setText(QVariant(pgErr).toString()); auto color = pgErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pg, color); delay(10); - bool mpsErr=_vec->mpsErr; + bool mpsErr = _vec->mpsErr; ui->l_mps->setText(QVariant(mpsErr).toString()); color = mpsErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_mps, color); delay(10); - bool fanFault=_vec->fanFault; + bool frameLost = _vec->frameLost; + ui->l_frameLost->setText(QVariant(frameLost).toString()); + color = frameLost ? Qt::red : Qt::green; + changeLabelTextColor(ui->l_frameLost, color); + delay(10); + + bool fanFault = _vec->fanFault; ui->l_fan->setText(QVariant(fanFault).toString()); color = fanFault ? Qt::red : Qt::green; changeLabelTextColor(ui->l_fan, color); delay(10); - bool pulserThd=_vec->pulserThd; + bool pulserThd = _vec->pulserThd; ui->l_pulserThd->setText(QVariant(pulserThd).toString()); color = pulserThd ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pulserThd, color); delay(10); - bool scenGtErr=_vec->scenGtErr; + bool scenGtErr = _vec->scenGtErr; ui->l_scenGt->setText(QVariant(scenGtErr).toString()); color = scenGtErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenGt, color); delay(10); - bool scenPriErr=_vec->scenPriErr; + bool scenPriErr = _vec->scenPriErr; ui->l_scenPri->setText(QVariant(scenPriErr).toString()); color = scenPriErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenPri, color); delay(10); - bool thermalErr=_vec->thermalErr; + bool thermalErr = _vec->thermalErr; ui->l_thermal->setText(QVariant(thermalErr).toString()); color = thermalErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_thermal, color); delay(10); - bool scenSramErr=_vec->scenSramErr; + bool scenSramErr = _vec->scenSramErr; ui->l_scenSram->setText(QVariant(scenSramErr).toString()); color = scenSramErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenSram, color); delay(10); - bool syncFifoErr=_vec->syncFifoErr; + bool syncFifoErr = _vec->syncFifoErr; ui->l_syncFifo->setText(QVariant(syncFifoErr).toString()); color = syncFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncFifo, color); delay(10); - bool syncPointErr=_vec->syncPointErr; + bool syncPointErr = _vec->syncPointErr; ui->l_syncPoint->setText(QVariant(syncPointErr).toString()); color = syncPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncPoint, color); delay(10); - bool dintrlvFifoErr=_vec->dintrlvFifoErr; + bool dintrlvFifoErr = _vec->dintrlvFifoErr; ui->l_dintrlvFifo->setText(QVariant(dintrlvFifoErr).toString()); color = dintrlvFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvFifo, color); delay(10); - bool dintrlvPointErr=_vec->dintrlvPointErr; + bool dintrlvPointErr = _vec->dintrlvPointErr; ui->l_dintrlvPoint->setText(QVariant(dintrlvPointErr).toString()); color = dintrlvPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvPoint, color); delay(10); - bool sram1ParityErr=_vec->sram1ParityErr; + bool sram1ParityErr = _vec->sram1ParityErr; ui->l_sram1Parity->setText(QVariant(sram1ParityErr).toString()); color = sram1ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram1Parity, color); delay(10); - bool sram2ParityErr=_vec->sram2ParityErr; + bool sram2ParityErr = _vec->sram2ParityErr; ui->l_sram2Parity->setText(QVariant(sram2ParityErr).toString()); color = sram2ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram2Parity, color); delay(10); - bool dmaCtrlTransferErr=_vec->dmaCtrlTransferErr; + bool dmaCtrlTransferErr = _vec->dmaCtrlTransferErr; ui->l_DmaCtrlTrans->setText(QVariant(dmaCtrlTransferErr).toString()); color = dmaCtrlTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_DmaCtrlTrans, color); delay(10); - bool emulDmaTransferErr=_vec->emulDmaTransferErr; + bool emulDmaTransferErr = _vec->emulDmaTransferErr; ui->l_emulDmaTrans->setText(QVariant(emulDmaTransferErr).toString()); color = emulDmaTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_emulDmaTrans, color); delay(10); - bool probeDisconnectErr=_vec->probeDisconnectErr; + bool probeDisconnectErr = _vec->probeDisconnectErr; ui->l_prbDiscon->setText(QVariant(probeDisconnectErr).toString()); color = probeDisconnectErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDiscon, color); delay(10); - bool probeDetChanInterrupt=_vec->probeDetChanInterrupt; + bool probeDetChanInterrupt = _vec->probeDetChanInterrupt; ui->l_prbDetChg->setText(QVariant(probeDetChanInterrupt).toString()); color = probeDetChanInterrupt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDetChg, color); - if (probeDetChanInterrupt) + if(probeDetChanInterrupt) + { emit connectedPrbChange(); + } + if(frameLost) + { + emit frameLostCall(); + } } /*************************************************************************************************/ @@ -558,66 +567,67 @@ void MainWindow::getPrbChange() { _trx.prbState(_prb); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } try { - if (_prb->prbA.ConnectionMode == connected) + if(_prb->prbA.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 0); - switch (_prb->prbA.id) + 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; + case id9L_D: + ui->table_probe->setItem(0, 0, new QTableWidgetItem("9L-D")); + break; - default: - ui->table_probe->setItem(0, 0, new QTableWidgetItem("Unknown")); + 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."; } - 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) + catch(const char* exception) { qDebug() << exception; } try { - if (_prb->prbB.ConnectionMode == connected) + if(_prb->prbB.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 1); - switch (_prb->prbB.id) + switch(_prb->prbB.id) { - case id9L_D: - ui->table_probe->setItem(0, 1, new QTableWidgetItem("9L-D")); - break; + 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")); + 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."; } - if (_prb->prbB.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe B eeprom is occured."; } else { @@ -625,32 +635,33 @@ void MainWindow::getPrbChange() QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 1); } } - catch (const char* exception) + catch(const char* exception) { qDebug() << exception; } try { - if (_prb->prbC.ConnectionMode == connected) + if(_prb->prbC.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 2); - switch (_prb->prbC.id) + 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; + case id9L_D: + ui->table_probe->setItem(0, 2, new QTableWidgetItem("9L-D")); + break; - default: - ui->table_probe->setItem(0, 2, new QTableWidgetItem("Unknown")); + 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."; } - if (_prb->prbC.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe C eeprom is occured."; } else { @@ -658,32 +669,33 @@ void MainWindow::getPrbChange() QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 2); } } - catch (const char* exception) + catch(const char* exception) { qDebug() << exception; } try { - if (_prb->prbD.ConnectionMode == connected) + if(_prb->prbD.ConnectionMode == connected) { QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 3); - switch (_prb->prbD.id) + switch(_prb->prbD.id) { - case id9L_D: - ui->table_probe->setItem(0, 3, new QTableWidgetItem("9L-D")); - break; + 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")); + 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."; } - if (_prb->prbD.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe D eeprom is occured."; } else { @@ -691,11 +703,17 @@ void MainWindow::getPrbChange() QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 3); } } - catch (const char* exception) + catch(const char* exception) { qDebug() << exception; } +} +/*************************************************************************************************/ +void MainWindow::getFrameLost() +{ + MESSAGE_BOX(QString::number(_trx.getFrameLostCounter(), 10)); + //qDebug() << _trx.getFrameLostCounter(); } /*************************************************************************************************/ @@ -703,34 +721,35 @@ void MainWindow::getProbeColor(const QBrush brush, const int item) { ui->table_probe->item(0, item)->setBackground(brush); } + /*************************************************************************************************/ //void MainWindow::scenarioStart() //{ -// auto value = 0x1; -// _usd->writeWord(0x800, 0, value); +//auto value = 0x1; +//_usd->writeWord(0x800, 0, value); -// qDebug() << "--- SET GT Send Mode :: BF --- "; -// _usd->writeWord(0x10, 0, 0x1); +//qDebug() << "--- SET GT Send Mode :: BF --- "; +//_usd->writeWord(0x10, 0, 0x1); -// auto bar = 0; -// uint32_t offsetSlvScenCmd[3] = {0x134000*4,0x234000*4,0x334000*4}; -// uint32_t offsetDbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; +//auto bar = 0; +//uint32_t offsetSlvScenCmd[3] = {0x134000*4,0x234000*4,0x334000*4}; +//uint32_t offsetDbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; -// for (auto i=0 ; i<3;i++) -// { -// value = _usd->readWord(offsetSlvScenCmd[i], bar); -// _usd->writeWord(offsetSlvScenCmd[i], bar, value | 0x2); -// } -// for (auto i=0 ; i<3;i++) -// { -// auto value = _usd->readWord(offsetDbgCmd[i], 0); -// value &= 0xFFFFFFF0; -// _usd->writeWord(offsetDbgCmd[i], 0, value); -// } +//for (auto i=0 ; i<3;i++) +//{ +//value = _usd->readWord(offsetSlvScenCmd[i], bar); +//_usd->writeWord(offsetSlvScenCmd[i], bar, value | 0x2); +//} +//for (auto i=0 ; i<3;i++) +//{ +//auto value = _usd->readWord(offsetDbgCmd[i], 0); +//value &= 0xFFFFFFF0; +//_usd->writeWord(offsetDbgCmd[i], 0, value); +//} //} -void MainWindow::changeLabelTextColor(QLabel *label, QColor color) +void MainWindow::changeLabelTextColor(QLabel* label, QColor color) { auto palette = label->palette(); palette.setColor(QPalette::Foreground, color); @@ -746,8 +765,6 @@ void MainWindow::on_rbtn_reg_toggled(bool checked) { _settings->setValue(REG_ACCESS_SEL, true); - - ui->l_regIndicator->setText("Register number: (Hex)"); } } @@ -771,6 +788,7 @@ void MainWindow::on_btn_readReg_clicked() if(offset == 0 && ui->tb_regIndicator->text() != "0") { MESSAGE_BOX("Invalid input format for offset"); + return; } @@ -778,18 +796,23 @@ void MainWindow::on_btn_readReg_clicked() 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; + case 0: + if(ui->rbtn_reg->isChecked()) + { + offset *= 4; + } + value = _usd->readWord(offset, bar); + ui->lcd_regvalue->setDigitCount(8); + break; + + case 1: + if(ui->rbtn_reg->isChecked()) + { + offset *= 8; + } + value = _usd->readLong(offset, bar); + ui->lcd_regvalue->setDigitCount(16); + break; } ui->lcd_regvalue->display(QString::number(value, 16)); @@ -804,6 +827,7 @@ void MainWindow::on_btn_writeReg_clicked() if(offset == 0 && ui->tb_regIndicator->text() != "0") { MESSAGE_BOX("Invalid input format for offset"); + return; } @@ -811,41 +835,47 @@ void MainWindow::on_btn_writeReg_clicked() if(value == 0 && ui->tb_regValue->text() != "0") { MESSAGE_BOX("Invalid input format for write value"); + return; } auto width = ui->cb_regWidth->currentIndex(); switch(width) { - case 0: - if(ui->rbtn_reg->isChecked()) - offset *= 4; - _usd->writeWord(offset, bar, static_cast(value)); - break; - case 1: - if(ui->rbtn_reg->isChecked()) - offset *= 8; - _usd->writeLong(offset, bar, value); - break; + case 0: + if(ui->rbtn_reg->isChecked()) + { + offset *= 4; + } + _usd->writeWord(offset, bar, static_cast(value)); + break; + + case 1: + if(ui->rbtn_reg->isChecked()) + { + offset *= 8; + } + _usd->writeLong(offset, bar, value); + break; } } /*************************************************************************************************/ //void MainWindow::newBlockProgressValue(int percentage, QProgressBar* prg) //{ -// prg->setValue(percentage); +//prg->setValue(percentage); //} ///*************************************************************************************************/ //void MainWindow::newFpgaProgressValue(int percentage) //{ -// ui->prg_fpgaProgram->setValue(percentage); +//ui->prg_fpgaProgram->setValue(percentage); //} ///*************************************************************************************************/ //void MainWindow::newBlockProgressVisibility(bool show, QProgressBar* prg) //{ -// prg->setVisible(show); +//prg->setVisible(show); //} /*************************************************************************************************/ @@ -864,15 +894,50 @@ void MainWindow::on_btn_fpgaBrowse_clicked() } /*************************************************************************************************/ -void MainWindow::on_btn_fpgaProgram_clicked() +void MainWindow::getProgrammingProgress(qint32 progressValue, qint32 bitFileSize) { - ui->l_programDone->setText("doing"); - changeLabelTextColor(ui->l_programDone, Qt::red); + ui->prg_programming->setVisible(true); + ui->prg_programming->setRange(0, bitFileSize); + ui->prg_programming->setValue(progressValue); +} +/*************************************************************************************************/ +void MainWindow::getFpgaProgrammer(QString path) +{ + try + { + _trx.slaveFpgaProgram(path); + ui->prg_programming->setVisible(false); + } + catch(SonoException& e) + { + qDebug() << e.what(); + } +} + +/*************************************************************************************************/ +void MainWindow::getLabelState(QLabel *label, QString str, QColor color) +{ + label->setText(str); + changeLabelTextColor(label, color); + label->repaint(); + qApp->processEvents(); +} + +/*************************************************************************************************/ +void MainWindow::on_btn_fpgaProgram_clicked() +{ auto path = ui->tb_fpgaBit->text(); - QtConcurrent::run(this, &MainWindow::fpgaProgrammer, path); + 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); } /*************************************************************************************************/ @@ -886,81 +951,82 @@ void MainWindow::newMessage(QString message) ///*************************************************************************************************/ //void MainWindow::on_btn_txDacBrowse_clicked() //{ -// QFileDialog fileDialog; -// fileDialog.setNameFilters({"TxDAC file (*.csv)"}); -// auto result = fileDialog.exec(); +//QFileDialog fileDialog; +//fileDialog.setNameFilters({"TxDAC file (*.csv)"}); +//auto result = fileDialog.exec(); -// if(result) -// { -// auto selectedPath = fileDialog.selectedFiles()[0]; -// ui->tb_txDacFile->setText(selectedPath); -// _settings->setValue(TX_DAC_FILE_PATH, selectedPath); -// } +//if(result) +//{ +//auto selectedPath = fileDialog.selectedFiles()[0]; +//ui->tb_txDacFile->setText(selectedPath); +//_settings->setValue(TX_DAC_FILE_PATH, selectedPath); +//} //} ///*************************************************************************************************/ //void MainWindow::on_btn_txDacUpload_clicked() //{ -// auto bar = 0; - -// auto offset = 0xE000; - -// auto path = ui->tb_txDacFile->text(); -// _csvReadStopFlag = false; -// QFutureWatcher watcher; -// connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// auto future = QtConcurrent::run(this, &MainWindow::CsvFileUploader, bar, path, ui->prg_txDacUpload); -// watcher.setFuture(future); -// _dial->exec(); -// disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); +//auto bar = 0; + +//auto offset = 0xE000; + +//auto path = ui->tb_txDacFile->text(); +//_csvReadStopFlag = false; +//QFutureWatcher watcher; +//connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); +//auto future = QtConcurrent::run(this, &MainWindow::CsvFileUploader, bar, path, +//ui->prg_txDacUpload); +//watcher.setFuture(future); +//_dial->exec(); +//disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); //} ///*************************************************************************************************/ //void MainWindow::on_btn_txDacStartStop_clicked() //{ -// auto bar = 0; -// auto offset = 0x10000; - -// auto interval = ui->tb_txDacInterval->text().toUInt(Q_NULLPTR, 16); -// if(interval == 0 && ui->tb_txDacInterval->text() != "0") -// { -// MESSAGE_BOX("Invalid input format for interval"); -// return; -// } -// uint32_t value = 0; -// value = ((interval & 0x000000FF) << 8) ; -// auto str = ui->btn_txDacStartStop->text(); -// if(str == START) -// { -// _usd->writeWord(offset, bar, value | 0x1); -// ui->btn_txDacStartStop->setText(STOP); -// } -// else -// { -// _usd->writeWord(offset, bar, value); -// ui->btn_txDacStartStop->setText(START); -// } +//auto bar = 0; +//auto offset = 0x10000; + +//auto interval = ui->tb_txDacInterval->text().toUInt(Q_NULLPTR, 16); +//if(interval == 0 && ui->tb_txDacInterval->text() != "0") +//{ +//MESSAGE_BOX("Invalid input format for interval"); +//return; +//} +//uint32_t value = 0; +//value = ((interval & 0x000000FF) << 8) ; +//auto str = ui->btn_txDacStartStop->text(); +//if(str == START) +//{ +//_usd->writeWord(offset, bar, value | 0x1); +//ui->btn_txDacStartStop->setText(STOP); +//} +//else +//{ +//_usd->writeWord(offset, bar, value); +//ui->btn_txDacStartStop->setText(START); +//} //} ///*************************************************************************************************/ //void MainWindow::on_btn_txDacOnOff_clicked() //{ -// auto bar = 0; -// auto offset = 0x10004; +//auto bar = 0; +//auto offset = 0x10004; -// auto str = ui->btn_txDacOnOff->text(); -// if(str == ON) -// { -// auto value = 0xf; -// _usd->writeWord(offset, bar, value); -// ui->btn_txDacOnOff->setText(OFF); -// } -// else -// { -// auto value = 0x0; -// _usd->writeWord(offset, bar, value); -// ui->btn_txDacOnOff->setText(ON); -// } +//auto str = ui->btn_txDacOnOff->text(); +//if(str == ON) +//{ +//auto value = 0xf; +//_usd->writeWord(offset, bar, value); +//ui->btn_txDacOnOff->setText(OFF); +//} +//else +//{ +//auto value = 0x0; +//_usd->writeWord(offset, bar, value); +//ui->btn_txDacOnOff->setText(ON); +//} //} /*************************************************************************************************/ @@ -969,22 +1035,26 @@ void MainWindow::on_cb_selectedProbe_currentIndexChanged(int index) auto indx = index; if(indx == 0) + { _trx.selectProbe(prbA); - + } else if(indx == 1) + { _trx.selectProbe(prbB); - + } else if(indx == 2) + { _trx.selectProbe(prbC); - + } else + { _trx.selectProbe(prbD); - + } } /*************************************************************************************************/ /*void MainWindow::on_btn_pllClkSt_clicked() -{ + { auto bar = 0; auto offset = 0x26000; @@ -1020,72 +1090,72 @@ void MainWindow::on_cb_selectedProbe_currentIndexChanged(int index) ui->btn_pllClkSt->setText(ON); } -} - - -//void MainWindow::on_btn_pllClkTps_clicked() -//{ -// auto bar = 0; -// auto offset = 0x26004; - -// auto str = ui->btn_pllClkTps->text(); -// if(str == ON) -// { -// auto temp = ui->tb_pllClkTps->text().toUInt(Q_NULLPTR, 10); -// if(temp == 0 && ui->tb_pllClkTps->text() != "0" || temp < 400 || temp > 2000) -// { -// MESSAGE_BOX("Invalid input format for PLL CLK TPS"); -// return; -// } - -// float halfPeriod = 50000.0f / temp; -// uint roundHalfPeriod = uint(roundf(halfPeriod)) & 0xFF; -// float t = roundf(50000.0f / roundHalfPeriod); -// ui->tb_pllClkTps->setText(QString::number(t, 'f', 0)); - -// auto value =0; -// value = roundHalfPeriod | 0x00000300; -// _usd->writeWord(offset, bar, value ); -// value = value & 0x000002FF; -// _usd->writeWord(offset, bar, value ); - -// ui->btn_pllClkTps->setText(OFF); -// } -// else -// { -// auto value = 0; -// _usd->writeWord(offset, bar, value); -// ui->btn_pllClkTps->setText(ON); -// } - -//} - -//&************************************************************************************************* -//void MainWindow::on_btn_mulDacTrig_clicked() -//{ -// auto bar = 0; -// auto offset = 0x86018; - -// // auto str = ui->btn_mulDacTrig->text(); -// //if(str == TRIG_ON) -// //{ -// auto temp = ui->tb_mlDac->text().toUInt(Q_NULLPTR, 16); -// _usd->writeWord(offset, bar, temp ); -// if (ui->chk_usrMulDac->isChecked()) -// { -// _usd->writeWord(offset, bar, temp|0x3000 ); -// _usd->writeWord(offset, bar, temp|0x2000 ); -// } - -//// ui->btn_mulDacTrig->setText(TRIG_OFF); -// //} -// //else -// //{ -// // auto value = 0; -// //_usd->writeWord(offset, bar, value); -// // ui->btn_mulDacTrig->setText(TRIG_ON); -// //} -//}*/ + } + + + //void MainWindow::on_btn_pllClkTps_clicked() + //{ + // auto bar = 0; + // auto offset = 0x26004; + + // auto str = ui->btn_pllClkTps->text(); + // if(str == ON) + // { + // auto temp = ui->tb_pllClkTps->text().toUInt(Q_NULLPTR, 10); + // if(temp == 0 && ui->tb_pllClkTps->text() != "0" || temp < 400 || temp > 2000) + // { + // MESSAGE_BOX("Invalid input format for PLL CLK TPS"); + // return; + // } + + // float halfPeriod = 50000.0f / temp; + // uint roundHalfPeriod = uint(roundf(halfPeriod)) & 0xFF; + // float t = roundf(50000.0f / roundHalfPeriod); + // ui->tb_pllClkTps->setText(QString::number(t, 'f', 0)); + + // auto value =0; + // value = roundHalfPeriod | 0x00000300; + // _usd->writeWord(offset, bar, value ); + // value = value & 0x000002FF; + // _usd->writeWord(offset, bar, value ); + + // ui->btn_pllClkTps->setText(OFF); + // } + // else + // { + // auto value = 0; + // _usd->writeWord(offset, bar, value); + // ui->btn_pllClkTps->setText(ON); + // } + + //} + + //&************************************************************************************************* + //void MainWindow::on_btn_mulDacTrig_clicked() + //{ + // auto bar = 0; + // auto offset = 0x86018; + + // // auto str = ui->btn_mulDacTrig->text(); + // //if(str == TRIG_ON) + // //{ + // auto temp = ui->tb_mlDac->text().toUInt(Q_NULLPTR, 16); + // _usd->writeWord(offset, bar, temp ); + // if (ui->chk_usrMulDac->isChecked()) + // { + // _usd->writeWord(offset, bar, temp|0x3000 ); + // _usd->writeWord(offset, bar, temp|0x2000 ); + // } + + //// ui->btn_mulDacTrig->setText(TRIG_OFF); + // //} + // //else + // //{ + // // auto value = 0; + // //_usd->writeWord(offset, bar, value); + // // ui->btn_mulDacTrig->setText(TRIG_ON); + // //} + //}*/ /********************************************************************/ void MainWindow::delay(int ms) @@ -1098,12 +1168,8 @@ const QString MainWindow::enum2String(ePg state) const { QString pg; pg = (state) ? "good" : "bad"; - return pg; -} -void MainWindow::restartTimer() -{ - _timeout->start(1000); + return pg; } /*************************************************************************************************/ @@ -1126,8 +1192,9 @@ void MainWindow::on_chk_continuousShowing_clicked() _dmaShow = true; } else + { _dmaShow = false; - + } } /*************************************************************************************************/ @@ -1151,7 +1218,7 @@ void MainWindow::on_btn_scenStart_clicked() ui->btn_dmaLogLast->setVisible(true); _trx.scenPlayerStart(); _dmaLog = true; - _dmaRun = true; // flag + _dmaRun = true; //flag _dmaBuffer.clear(); //QtConcurrent::run(this, &MainWindow::logPcie); } @@ -1184,9 +1251,10 @@ void MainWindow::on_btn_emulBrowse_clicked() _emulFolder = fileDialog.selectedFiles()[0]; } - if (name == "Emulator Browse") + if(name == "Emulator Browse") + { QtConcurrent::run(this, &MainWindow::fillRam, _emulFolder); - + } } /*************************************************************************************************/ @@ -1196,7 +1264,7 @@ void MainWindow::on_btn_emulator_clicked() try { - if (name == "Emulator Start") + if(name == "Emulator Start") { _emul->transferLength = TRANSFER_LENGTH; _emul->ramBufAddress = RAM_BUFFER_OFFSET; @@ -1226,7 +1294,6 @@ void MainWindow::on_btn_emulator_clicked() { qDebug() << e.what(); } - } /*************************************************************************************************/ @@ -1246,53 +1313,66 @@ void MainWindow::on_btn_logBrowse_clicked() /*************************************************************************************************/ void MainWindow::logPcie() { - ui->btn_dmaLogLast->setText("Logging..."); + try + { + ui->btn_dmaLogLast->setText("Logging..."); - _dmaLogCount = 0; + _dmaLogCount = 0; - quint32 i(0); + quint32 i(0); - QProgressDialog* progress = new QProgressDialog(this); - progress->show(); + QProgressDialog* progress = new QProgressDialog(this); + progress->show(); - while(_dmaLog) - { - if(_dmaBuffer.size() == 0) + while(_dmaLog) { - std::this_thread::sleep_for(std::chrono::milliseconds(3)); - continue; - } - QByteArray temp; + 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(); + _mutex.lock(); + temp = _dmaBuffer.front(); + _dmaBuffer.pop_front(); + _mutex.unlock(); - _dmaLogCount +=1; - if (_dmaLogCount == ULTIMATE_LOG_COUNT) - _dmaLog = false; + _dmaLogCount += 1; + if(_dmaLogCount == ULTIMATE_LOG_COUNT) + { + _dmaLog = false; + } - quint16 batchId = ((static_cast(temp[128]))& 0x00FF) | - (((static_cast(temp[129])) << 8) & 0xFF00); - quint8 subBatchId = (static_cast(temp[130])); + quint16 batchId = ((static_cast(temp[128])) & 0x00FF) | + (((static_cast(temp[129])) << 8) & 0xFF00); + quint8 subBatchId = (static_cast(temp[130])); - QString path = _logFolder + QString("/batch(%2)_sbatch(%3)_%1.bin").arg(i++).arg(batchId).arg(subBatchId); - QFile file(path); + QString path = _logFolder + + QString("/batch(%2)_sbatch(%3)_%1.bin").arg(i++).arg(batchId).arg( + subBatchId); + QFile file(path); - file.open(QIODevice::WriteOnly); - file.write(temp); - file.close(); + file.open(QIODevice::WriteOnly); + //file.write(temp); + file.close(); - emit sendLogCount(_dmaLogCount, progress); + emit sendLogCount(_dmaLogCount, progress); + } + ui->btn_dmaLogLast->setText("InstantLog"); + + delete progress; + } + catch(SonoException& e) + { + qDebug() << e.what(); } - ui->btn_dmaLogLast->setText("InstantLog"); } - +/*************************************************************************************************/ void MainWindow::on_btn_dmaLogLast_clicked() { - if (_dmaRun && (ui->btn_dmaLogLast->text() == "InstantLog")) + if(_dmaRun && (ui->btn_dmaLogLast->text() == "InstantLog")) { _dmaBuffer.clear(); _dmaLog = true; @@ -1308,16 +1388,24 @@ void MainWindow::on_btn_dmaShow_clicked() 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); @@ -1333,39 +1421,42 @@ void MainWindow::show3d() //3D Plot //--------------------------------------------------------------------- ui->plot_2->clearGraphs(); - // qDebug() << "//3D Frame Plot //////////////////"; - // ui->plot_2->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag); + //qDebug() << "//3D Frame Plot //////////////////"; + //ui->plot_2->setInteractions(QCP::iRangeZoom|QCP::iRangeDrag); ui->plot_2->axisRect()->setupFullAxesBox(true); ui->plot_2->xAxis->setLabel("Line"); ui->plot_2->yAxis->setLabel("Point"); - quint16 batchId = ((static_cast(temp[128]))& 0x00FF) | - (((static_cast(temp[129])) << 8) & 0xFF00); + quint16 batchId = ((static_cast(temp[128])) & 0x00FF) | + (((static_cast(temp[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(temp[130])); quint8 frmType = (static_cast(temp[131])); quint8 cri = (static_cast(temp[132])); - quint16 bLine = ((static_cast(temp[136]))& 0x00FF) | - (((static_cast(temp[137])) << 8) & 0xFF00); - quint16 bPoint = ((static_cast(temp[138]))& 0x00FF) | - (((static_cast(temp[139])) << 8) & 0xFF00); + quint16 bLine = ((static_cast(temp[136])) & 0x00FF) | + (((static_cast(temp[137])) << 8) & 0xFF00); + quint16 bPoint = ((static_cast(temp[138])) & 0x00FF) | + (((static_cast(temp[139])) << 8) & 0xFF00); quint8 mLine = (static_cast(temp[140])); - quint16 mPoint = ((static_cast(temp[141]))& 0x00FF) | - (((static_cast(temp[142])) << 8) & 0xFF00); + quint16 mPoint = ((static_cast(temp[141])) & 0x00FF) | + (((static_cast(temp[142])) << 8) & 0xFF00); if(bLine > 256) { qDebug() << "ERROR :: (B Line)" << bLine; + return; } if(bPoint > 8192) { qDebug() << "ERROR :: (B Point)" << bPoint; + return; } if(frmType != 0) { qDebug() << "ERROR :: (Invalid Frame Type)" << frmType; + return; } qDebug() << "batchId" << batchId; @@ -1378,8 +1469,8 @@ void MainWindow::show3d() qDebug() << "mPoint" << mPoint; _colorMap->data()->clear(); - _colorMap->data()->setSize(bLine,bPoint); - _colorMap->data()->setRange(QCPRange(1,bLine),QCPRange(1,bPoint)); + _colorMap->data()->setSize(bLine, bPoint); + _colorMap->data()->setRange(QCPRange(1, bLine), QCPRange(1, bPoint)); //double x,y,z; //int xIndex = 0; //int yIndex = 0; @@ -1390,43 +1481,43 @@ void MainWindow::show3d() for(auto pnt = 0; pnt < bPoint; pnt += 1) { indx = (line * bPoint + pnt) * 4 + 160; - auto val = ((static_cast(temp[indx])) & 0x000000FF) | - (((static_cast(temp[indx + 1])) << 8) & 0x0000FF00) | - (((static_cast(temp[indx + 2])) << 16) & 0x00FF0000) | - (((static_cast(temp[indx + 3])) << 24) & 0xFF000000); + auto val = ((static_cast(temp[indx])) & 0x000000FF) | + (((static_cast(temp[indx + 1])) << 8) & 0x0000FF00) | + (((static_cast(temp[indx + 2])) << 16) & 0x00FF0000) | + (((static_cast(temp[indx + 3])) << 24) & 0xFF000000); //xIndex = line; //yIndex = pnt; //z = double(val); //colorMap->data()->cellToCoord(xIndex,yIndex,&x,&y); - if(maxdata()->setCell(line,pnt,double(val)); + } + _colorMap->data()->setCell(line, pnt, double(val)); } - } - // qDebug() << "indx" << indx; - // qDebug() << "max" << max; - qDebug() << ui->plot_2->plotLayout()->hasElement(0,1); + //qDebug() << "indx" << indx; + //qDebug() << "max" << max; + qDebug() << ui->plot_2->plotLayout()->hasElement(0, 1); - if(!ui->plot_2->plotLayout()->hasElement(0,1)) + if(!ui->plot_2->plotLayout()->hasElement(0, 1)) { - QCPColorScale *colorScale = new QCPColorScale(ui->plot_2); - ui->plot_2->plotLayout()->addElement(0,1,colorScale); + 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); + 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(); - } /*************************************************************************************************/ @@ -1451,14 +1542,14 @@ void MainWindow::show2d() 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); + 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); } @@ -1476,7 +1567,7 @@ void MainWindow::show2d() /*************************************************************************************************/ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) { - _progress->setMinimumSize(300,100); + _progress->setMinimumSize(300, 100); _progress->setLabelText("Please wait..."); _progress->setWindowTitle("Frame Packets Logging"); _progress->setRange(0, ULTIMATE_LOG_COUNT); @@ -1485,7 +1576,7 @@ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) try { _progress->setValue(counter); - if (_progress->wasCanceled()) + if(_progress->wasCanceled()) { throw SonoException("Frame Packets Logging is canceled"); } @@ -1502,11 +1593,11 @@ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) //void MainWindow::on_btn_hvRegulatorConfig_clicked() //{ -// auto name=ui->btn_hvRegulatorConfig->text(); -// auto freq=ui->tb_hvFreq->text().toFloat(Q_NULLPTR); +//auto name=ui->btn_hvRegulatorConfig->text(); +//auto freq=ui->tb_hvFreq->text().toFloat(Q_NULLPTR); -// if(name==ENABLE) -// { +//if(name==ENABLE) +//{ //// freq<65.00f ? freq=65.00f : freq=freq; //// freq>130.00f ? freq=130.00f : freq=freq; //// pwr.setHVsRegulator(true, true, freq); @@ -1514,23 +1605,23 @@ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) //// auto real_freq=pwr.getHVsRegulatorFreq(); //// ui->tb_hvFreq->setText(QString("%1").arg(real_freq)); //// ui->btn_hvRegulatorConfig->setText(DISABLE); -// } -// else -// { +//} +//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); +//auto name=ui->btn_pm5RegulatorConfig->text(); +//auto freq=ui->tb_pm5Freq->text().toFloat(Q_NULLPTR); -// if(name==ENABLE) -// { +//if(name==ENABLE) +//{ //// freq<280.00f ? freq=280.00f : freq=freq; //// freq>400.00f ? freq=400.00f : freq=freq; //// pwr.setPM5vRegulator(true, true, freq); @@ -1538,20 +1629,20 @@ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) //// auto real_freq=pwr.getPM5vRegulatorFreq(); //// ui->tb_pm5Freq->setText(QString("%1").arg(real_freq)); //// ui->btn_pm5RegulatorConfig->setText(DISABLE); -// } -// else -// { +//} +//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); +//// 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"); @@ -1592,7 +1683,6 @@ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) //// } ////// delay(100); - //// pwr.setDAcs(true, cwdValue, hvbValue, hvaValue); //// pwr.setDAcs(false, cwdValue, hvbValue, hvaValue); @@ -1610,14 +1700,14 @@ void MainWindow::catchLogCount(qint32 counter, QProgressDialog* _progress) 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 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) + catch(SonoException& e) { qDebug() << e.what(); } @@ -1628,14 +1718,16 @@ void MainWindow::on_chk_mpsInit_clicked() { try { - if (ui->chk_mpsInit->isChecked()) + if(ui->chk_mpsInit->isChecked()) + { _trx.mpsPwrOn(); - + } else + { _trx.mpsPwrOff(); - + } } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -1650,64 +1742,61 @@ void MainWindow::on_btn_supJump_clicked() _trx.mpsReset(); //jump ui->chk_mpsInit->setChecked(false); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } - } /*************************************************************************************************/ void MainWindow::on_btn_updateRdbackValue_clicked() { - try { _trx.supervisorRbValue(_supRbValue); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } - - auto hvapValue=_supRbValue->hvap; + auto hvapValue = _supRbValue->hvap; ui->l_hvap->setText(QString::number(static_cast(hvapValue), 'f', 3)); delay(10); - auto hvbpValue=_supRbValue->hvbp; + auto hvbpValue = _supRbValue->hvbp; ui->l_hvbp->setText(QString::number(static_cast(hvbpValue), 'f', 3)); delay(10); - auto cwdpValue=_supRbValue->cwdp; + auto cwdpValue = _supRbValue->cwdp; ui->l_cwdp->setText(QString::number(static_cast(cwdpValue), 'f', 3)); delay(10); - auto curr24vValue=_supRbValue->curr24V; + auto curr24vValue = _supRbValue->curr24V; ui->l_curr24v->setText(QString::number(static_cast(curr24vValue), 'f', 3)); delay(10); - auto p24vValue=_supRbValue->p24V; + auto p24vValue = _supRbValue->p24V; ui->l_p24v->setText(QString::number(static_cast(p24vValue), 'f', 3)); delay(10); - auto p12vValue=_supRbValue->p12V; + auto p12vValue = _supRbValue->p12V; ui->l_p12v->setText(QString::number(static_cast(p12vValue), 'f', 3)); delay(10); - auto p5vValue=_supRbValue->p5V; + auto p5vValue = _supRbValue->p5V; ui->l_p5v->setText(QString::number(static_cast(p5vValue), 'f', 3)); delay(10); - auto m5vValue=_supRbValue->m5V; + auto m5vValue = _supRbValue->m5V; ui->l_m5v->setText(QString::number(static_cast(m5vValue), 'f', 3)); delay(10); - auto hvStopValue=_supRbValue->hvStop; + auto hvStopValue = _supRbValue->hvStop; ui->l_hvStop->setText(QString::number(static_cast(hvStopValue), 'f', 3)); delay(10); - auto p4dValue=_supRbValue->p4D; + auto p4dValue = _supRbValue->p4D; ui->l_p4d->setText(QString::number(static_cast(p4dValue), 'f', 3)); delay(10); @@ -1716,302 +1805,301 @@ void MainWindow::on_btn_updateRdbackValue_clicked() { _trx.mpsFaultStatus(_faultStatus); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } - - bool hvapFlt=_faultStatus->hvap; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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); } - //void MainWindow::on_chk_usrMulDac_stateChanged(int arg1) //{ -// auto bar = 0; -// auto offset = 0x86018; -// auto value = _usd->readWord(offset, bar); -// if (!ui->chk_usrMulDac->isChecked()) -// _usd->writeWord(offset, bar, value&0xFFF); +//auto bar = 0; +//auto offset = 0x86018; +//auto value = _usd->readWord(offset, bar); +//if (!ui->chk_usrMulDac->isChecked()) +//_usd->writeWord(offset, bar, value&0xFFF); //} //void MainWindow::on_btn_afeProg_clicked() //{ -// auto bar = 0; -// uint32_t offsetWr[3] = {0x10F0DA*4,0x20F0DA*4,0x30F0DA*4}; -// uint32_t offsetRd[3] = {0x10F0DE*4,0x20F0DE*4,0x30F0DE*4}; +//auto bar = 0; +//uint32_t offsetWr[3] = {0x10F0DA*4,0x20F0DA*4,0x30F0DA*4}; +//uint32_t offsetRd[3] = {0x10F0DE*4,0x20F0DE*4,0x30F0DE*4}; -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetWr[i], bar, 0xF0); -// _usd->writeWord(offsetWr[i], bar, 0x0F); -// } -// qDebug() << "--- AFE Registers --- "; -// for (int i=0 ; i<3;i++) -// { -// auto value = _usd->readWord(offsetRd[i], bar); -// qDebug() << QString::number(offsetRd[i], 16) << QString::number(value, 16); -// } -// qDebug() << "--- ------------- --- "; +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetWr[i], bar, 0xF0); +//_usd->writeWord(offsetWr[i], bar, 0x0F); +//} +//qDebug() << "--- AFE Registers --- "; +//for (int i=0 ; i<3;i++) +//{ +//auto value = _usd->readWord(offsetRd[i], bar); +//qDebug() << QString::number(offsetRd[i], 16) << QString::number(value, 16); +//} +//qDebug() << "--- ------------- --- "; //} //void MainWindow::on_btn_gtReg_clicked() //{ -// auto result = "OK"; -// auto bar = 0; -// uint32_t offsetRd[24] = {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}; -// uint32_t correctVal[24] = {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() << "--- GT Status Registers --- "; -// for (auto i=0 ; i<20;i++) -// { -// auto value = _usd->readWord(offsetRd[i], bar); -// if (value == correctVal[i]) -// result = "OK"; -// else -// result = "NOK"; -// qDebug() << QString::number(offsetRd[i]/4, 16) << QString::number(value, 16) << result; -// } -// qDebug() << "--- ------------------- --- "; +//auto result = "OK"; +//auto bar = 0; +//uint32_t offsetRd[24] = {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}; +//uint32_t correctVal[24] = {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() << "--- GT Status Registers --- "; +//for (auto i=0 ; i<20;i++) +//{ +//auto value = _usd->readWord(offsetRd[i], bar); +//if (value == correctVal[i]) +//result = "OK"; +//else +//result = "NOK"; +//qDebug() << QString::number(offsetRd[i]/4, 16) << QString::number(value, 16) << result; +//} +//qDebug() << "--- ------------------- --- "; //} //void MainWindow::on_btn_browse_clicked() //{ -// QFileDialog dialog; -// dialog.setFileMode(QFileDialog::Directory); -// dialog.setOption(QFileDialog::ShowDirsOnly); -// auto result = dialog.exec(); +//QFileDialog dialog; +//dialog.setFileMode(QFileDialog::Directory); +//dialog.setOption(QFileDialog::ShowDirsOnly); +//auto result = dialog.exec(); -// if(result) -// { -// //_adcloggerFolder = dialog.selectedFiles()[0]; +//if(result) +//{ +////_adcloggerFolder = dialog.selectedFiles()[0]; -// ui->tb_adcLoggerPath->setText(dialog.selectedFiles()[0]); -// } +//ui->tb_adcLoggerPath->setText(dialog.selectedFiles()[0]); +//} //} //void MainWindow::on_btn_dbgTransferStrt_clicked() //{ -// ui->btn_dbgTransferStrt->setText("Trans..."); -// auto path = ui->tb_adcLoggerPath->text(); - -// QFutureWatcher watcher; -// connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// auto future = QtConcurrent::run(this, &MainWindow::AdcLogCsvFileWriter, path, ui->prg_adcLoggerFileWr); -// watcher.setFuture(future); -// _dial->exec(); -// disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// ui->btn_dbgTransferStrt->setText(START); +//ui->btn_dbgTransferStrt->setText("Trans..."); +//auto path = ui->tb_adcLoggerPath->text(); + +//QFutureWatcher watcher; +//connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); +//auto future = QtConcurrent::run(this, &MainWindow::AdcLogCsvFileWriter, path, +//ui->prg_adcLoggerFileWr); +//watcher.setFuture(future); +//_dial->exec(); +//disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); +//ui->btn_dbgTransferStrt->setText(START); //} //void MainWindow::on_btn_adcLoggerStrt_clicked() //{ -// ui->btn_adcLoggerStrt->setText("Log..."); -// uint32_t bar = 0; -// uint32_t offsetTrnsfrCmdLen[3] = {0x140001*4,0x240001*4,0x340001*4}; +//ui->btn_adcLoggerStrt->setText("Log..."); +//uint32_t bar = 0; +//uint32_t offsetTrnsfrCmdLen[3] = {0x140001*4,0x240001*4,0x340001*4}; -// qDebug() << "--- ADC Logger Start --- "; +//qDebug() << "--- ADC Logger Start --- "; -// auto temp = ui->tb_dbgSmplCnt->text().toUInt(Q_NULLPTR, 16); -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x1); //reset Logger -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x0); //reset done +//auto temp = ui->tb_dbgSmplCnt->text().toUInt(Q_NULLPTR, 16); +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x1); //reset Logger +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x0); //reset done -// auto value = temp<<8; -// value |= 0x4; -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Start ADC Logger and set Counter -// } -// QtConcurrent::run(this, &MainWindow::adcLoggerStatusCheck); +//auto value = temp<<8; +//value |= 0x4; +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Start ADC Logger and set Counter +//} +//QtConcurrent::run(this, &MainWindow::adcLoggerStatusCheck); //} //void MainWindow::on_prg_adcLoggerFileWr_valueChanged(int value) @@ -2019,215 +2107,213 @@ void MainWindow::on_btn_updateRdbackValue_clicked() //} - //void MainWindow::adcLoggerStatusCheck() //{ -// uint32_t offsetTrnsStatus[3] = {0x14000A*4,0x24000A*4,0x34000A*4}; -// uint32_t offsetTrnsfrCmdLen[3] = {0x140001*4,0x240001*4,0x340001*4}; -// _adcLoggerDone = false; -// auto timeOut = 0; -// auto doneFlag = 0; -// while (timeOut < 1000 && doneFlag < 3 ) -// { -// for (auto i=0 ; i<3;i++) -// { -// doneFlag += (_usd->readWord(offsetTrnsStatus[i], 0) & 0X1); -// } -// timeOut += 1; -// delay(10); -// } -// for (auto i=0 ; i<3;i++) -// { -// auto value = _usd->readWord(offsetTrnsfrCmdLen[i], 0); -// value &= 0xFFFFFFF0; -// _usd->writeWord(offsetTrnsfrCmdLen[i], 0, value); -// } - -// ui->btn_adcLoggerStrt->setText(START); -// _adcLoggerDone = true; -// if(timeOut == 1000) -// { -// MESSAGE_BOX("Logger incomplete"); -// return; -// } -// else -// qDebug() << "--- ADC Logger done --- "; +//uint32_t offsetTrnsStatus[3] = {0x14000A*4,0x24000A*4,0x34000A*4}; +//uint32_t offsetTrnsfrCmdLen[3] = {0x140001*4,0x240001*4,0x340001*4}; +//_adcLoggerDone = false; +//auto timeOut = 0; +//auto doneFlag = 0; +//while (timeOut < 1000 && doneFlag < 3 ) +//{ +//for (auto i=0 ; i<3;i++) +//{ +//doneFlag += (_usd->readWord(offsetTrnsStatus[i], 0) & 0X1); +//} +//timeOut += 1; +//delay(10); +//} +//for (auto i=0 ; i<3;i++) +//{ +//auto value = _usd->readWord(offsetTrnsfrCmdLen[i], 0); +//value &= 0xFFFFFFF0; +//_usd->writeWord(offsetTrnsfrCmdLen[i], 0, value); //} +//ui->btn_adcLoggerStrt->setText(START); +//_adcLoggerDone = true; +//if(timeOut == 1000) +//{ +//MESSAGE_BOX("Logger incomplete"); +//return; +//} +//else +//qDebug() << "--- ADC Logger done --- "; +//} //void MainWindow::on_btn_adcSimBrowse_clicked() //{ -// QFileDialog fileDialog; -// fileDialog.setNameFilters({"ADC Sim Scenario file (*.bin)"}); -// auto result = fileDialog.exec(); +//QFileDialog fileDialog; +//fileDialog.setNameFilters({"ADC Sim Scenario file (*.bin)"}); +//auto result = fileDialog.exec(); -// if(result) -// { -// auto selectedPath = fileDialog.selectedFiles()[0]; -// ui->tb_adcSimPath->setText(selectedPath); -// _settings->setValue(ADC_SIM_FILE_PATH, selectedPath); -// } +//if(result) +//{ +//auto selectedPath = fileDialog.selectedFiles()[0]; +//ui->tb_adcSimPath->setText(selectedPath); +//_settings->setValue(ADC_SIM_FILE_PATH, selectedPath); +//} //} //void MainWindow::on_btn_adcSimStart_clicked() //{ -// auto bar = 0; -// //auto offset = 0; -// uint32_t offsetDbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; -// uint32_t offsetSlvScenCmd[3] = {0x134000*4,0x234000*4,0x334000*4}; -// auto startIndex = ui->tb_adcSimStartIndex->text().toUInt(Q_NULLPTR, 16); -// if(startIndex == 0 && ui->tb_adcSimStartIndex->text() != "0") -// { -// MESSAGE_BOX("Invalid input format for start index"); -// return; -// } - -// auto stopIndex = ui->tb_adcSimStopIndex->text().toUInt(Q_NULLPTR, 16); -// if(stopIndex == 0 && ui->tb_adcSimStopIndex->text() != "0") -// { -// MESSAGE_BOX("Invalid input format for stop index"); -// return; -// } - -// if((stopIndex < startIndex) || (stopIndex>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, stopIndex); -// auto value = 0; -// auto str = ui->btn_adcSimStart->text(); -// if(str == START) -// { -// qDebug() << "--- SET GT Send Mode :: BF --- "; -// _usd->writeWord(0x10, 0, 0x1); -// _csvReadStopFlag = false; -// ui->btn_adcSimStart->setText(STOP); -// for (auto i=0 ; i<3;i++) -// { -// value = _usd->readWord(offsetDbgCmd[i], 0); -// value |= 0x1; -// _usd->writeWord(offsetDbgCmd[i], 0, value); -// } - -// delay(100); -// for (auto i=0 ; i<3;i++) -// { -// value = _usd->readWord(offsetSlvScenCmd[i], bar); -// _usd->writeWord(offsetSlvScenCmd[i], bar, value | 0x2); -// } -// auto path = ui->tb_adcSimPath->text(); -// auto future = QtConcurrent::run(this, &MainWindow::binAdcFileUploader, 0, path , ui->prg_adcSim); -// } -// else -// { -// _csvReadStopFlag = true; -// ui->btn_adcSimStart->setText(START); -// _usd->writeWord(0x800, bar, 0); - -// for (auto i=0 ; i<3;i++) -// { -// auto value = _usd->readWord(offsetDbgCmd[i], 0); -// value &= 0xFFFFFFF0; -// _usd->writeWord(offsetDbgCmd[i], 0, value); -// } -// delay(100); -// for (auto i=0 ; i<3;i++) -// { -// value = _usd->readWord(offsetSlvScenCmd[i], bar); -// _usd->writeWord(offsetSlvScenCmd[i], bar, value & 0x1); -// } - -// //scenarioStop(); -// } +//auto bar = 0; +////auto offset = 0; +//uint32_t offsetDbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; +//uint32_t offsetSlvScenCmd[3] = {0x134000*4,0x234000*4,0x334000*4}; +//auto startIndex = ui->tb_adcSimStartIndex->text().toUInt(Q_NULLPTR, 16); +//if(startIndex == 0 && ui->tb_adcSimStartIndex->text() != "0") +//{ +//MESSAGE_BOX("Invalid input format for start index"); +//return; +//} +//auto stopIndex = ui->tb_adcSimStopIndex->text().toUInt(Q_NULLPTR, 16); +//if(stopIndex == 0 && ui->tb_adcSimStopIndex->text() != "0") +//{ +//MESSAGE_BOX("Invalid input format for stop index"); +//return; //} -//void MainWindow::on_btn_adcLoggerAutoCount_clicked() +//if((stopIndex < startIndex) || (stopIndex>131071) || (startIndex>131071)) //{ -// uint32_t bar = 0; -// uint32_t offsetTrnsfrCmdLen[3] = {0x140001*4,0x240001*4,0x340001*4}; +//MESSAGE_BOX("Stop index should be greater than or equal to start index"); +//return; +//} -// auto logCount = ui->tb_dbgAutoLogCount->text().toUInt(); -// if(logCount == 0 && ui->tb_dbgAutoLogCount->text() != "0") -// { -// MESSAGE_BOX("Invalid input format for logCount"); -// return; -// } +//_usd->writeWord(0x804, bar, startIndex); +//_usd->writeWord(0x808, bar, stopIndex); +//auto value = 0; +//auto str = ui->btn_adcSimStart->text(); +//if(str == START) +//{ +//qDebug() << "--- SET GT Send Mode :: BF --- "; +//_usd->writeWord(0x10, 0, 0x1); +//_csvReadStopFlag = false; +//ui->btn_adcSimStart->setText(STOP); +//for (auto i=0 ; i<3;i++) +//{ +//value = _usd->readWord(offsetDbgCmd[i], 0); +//value |= 0x1; +//_usd->writeWord(offsetDbgCmd[i], 0, value); +//} -// ui->btn_adcLoggerAutoCount->setText("Log..."); -// uint32_t offsetAfePwrDn[3] = {0x10F0C5*4,0x20F0C5*4,0x30F0C5*4}; -// uint32_t offsetAfeLpf[3] = {0x10F0C4*4,0x20F0C4*4,0x30F0C4*4}; +//delay(100); +//for (auto i=0 ; i<3;i++) +//{ +//value = _usd->readWord(offsetSlvScenCmd[i], bar); +//_usd->writeWord(offsetSlvScenCmd[i], bar, value | 0x2); +//} +//auto path = ui->tb_adcSimPath->text(); +//auto future = QtConcurrent::run(this, &MainWindow::binAdcFileUploader, 0, path , ui->prg_adcSim); +//} +//else +//{ +//_csvReadStopFlag = true; +//ui->btn_adcSimStart->setText(START); +//_usd->writeWord(0x800, bar, 0); -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetAfePwrDn[i], bar, 0x0); -// _usd->writeWord(offsetAfeLpf[i], bar, 0x0100); -// } -// qDebug() << "--- AFE Registers --- "; -// delay(1); +//for (auto i=0 ; i<3;i++) +//{ +//auto value = _usd->readWord(offsetDbgCmd[i], 0); +//value &= 0xFFFFFFF0; +//_usd->writeWord(offsetDbgCmd[i], 0, value); +//} +//delay(100); +//for (auto i=0 ; i<3;i++) +//{ +//value = _usd->readWord(offsetSlvScenCmd[i], bar); +//_usd->writeWord(offsetSlvScenCmd[i], bar, value & 0x1); +//} +////scenarioStop(); +//} -// for (auto j = 0 ; j < logCount ; j++) -// { +//} -// qDebug() << "--- ADC Auto Logger Start --- "; -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x1); //reset Logger -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x0); //reset done +//void MainWindow::on_btn_adcLoggerAutoCount_clicked() +//{ +//uint32_t bar = 0; +//uint32_t offsetTrnsfrCmdLen[3] = {0x140001*4,0x240001*4,0x340001*4}; -// auto value = 1<<8; -// value |= 0x4; -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Start ADC Logger and set Counter +//auto logCount = ui->tb_dbgAutoLogCount->text().toUInt(); +//if(logCount == 0 && ui->tb_dbgAutoLogCount->text() != "0") +//{ +//MESSAGE_BOX("Invalid input format for logCount"); +//return; +//} -// value |= 0x8; -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Set Manual Trig +//ui->btn_adcLoggerAutoCount->setText("Log..."); +//uint32_t offsetAfePwrDn[3] = {0x10F0C5*4,0x20F0C5*4,0x30F0C5*4}; +//uint32_t offsetAfeLpf[3] = {0x10F0C4*4,0x20F0C4*4,0x30F0C4*4}; -// value &= 0xF7; -// _usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Set Manual Trig +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetAfePwrDn[i], bar, 0x0); +//_usd->writeWord(offsetAfeLpf[i], bar, 0x0100); +//} +//qDebug() << "--- AFE Registers --- "; +//delay(1); -// } -// QtConcurrent::run(this, &MainWindow::adcLoggerStatusCheck); -// delay(10); -// while (!_adcLoggerDone); +//for (auto j = 0 ; j < logCount ; j++) +//{ -// auto path = ui->tb_adcLoggerPath->text(); +//qDebug() << "--- ADC Auto Logger Start --- "; +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x1); //reset Logger +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, 0x0); //reset done -// QFutureWatcher watcher; -// connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// auto future = QtConcurrent::run(this, &MainWindow::AdcLogCsvFileWriter, path, ui->prg_adcLoggerFileWr); -// watcher.setFuture(future); -// _dial->exec(); -// disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// ui->btn_dbgTransferStrt->setText(START); +//auto value = 1<<8; +//value |= 0x4; +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Start ADC Logger and set Counter -// delay(10); -// while (!_adcLoggerTrnsDone); -// } -// ui->btn_adcLoggerAutoCount->setText(START); +//value |= 0x8; +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Set Manual Trig -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetAfePwrDn[i], bar, 0x8000); -// } -// qDebug() << "--- AFE Registers Power Down --- "; +//value &= 0xF7; +//_usd->writeWord(offsetTrnsfrCmdLen[i], bar, value); // Set Manual Trig + +//} +//QtConcurrent::run(this, &MainWindow::adcLoggerStatusCheck); +//delay(10); +//while (!_adcLoggerDone); + +//auto path = ui->tb_adcLoggerPath->text(); + +//QFutureWatcher watcher; +//connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); +//auto future = QtConcurrent::run(this, &MainWindow::AdcLogCsvFileWriter, path, +//ui->prg_adcLoggerFileWr); +//watcher.setFuture(future); +//_dial->exec(); +//disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); +//ui->btn_dbgTransferStrt->setText(START); + +//delay(10); +//while (!_adcLoggerTrnsDone); //} +//ui->btn_adcLoggerAutoCount->setText(START); +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetAfePwrDn[i], bar, 0x8000); +//} +//qDebug() << "--- AFE Registers Power Down --- "; +//} //void MainWindow::on_btn_scenRead_clicked() //{ -// auto paramPath = ui->tb_paramFile->text(); -// auto paramBar = 0; -// auto boardParamPath = "/home/hasis/Desktop/TrxBoardFile/_log/readBack.csv"; -// QtConcurrent::run(this, &MainWindow::CsvFileChecker,paramBar, paramPath , boardParamPath , ui->prg_scenarioUpload); +//auto paramPath = ui->tb_paramFile->text(); +//auto paramBar = 0; +//auto boardParamPath = "/home/hasis/Desktop/TrxBoardFile/_log/readBack.csv"; +//QtConcurrent::run(this, &MainWindow::CsvFileChecker,paramBar, paramPath , boardParamPath , +//ui->prg_scenarioUpload); //} /*************************************************************************************************/ -QString MainWindow::releaseCodeVersion(quint32 &value) +QString MainWindow::releaseCodeVersion(quint32& value) { QString str = QString::number(value, 10); QList strList; @@ -2241,6 +2327,7 @@ QString MainWindow::releaseCodeVersion(quint32 &value) strList[4] + strList[5] + " " + strList[6] + strList[7] + ":" + strList[8] + strList[9]; + return str; } @@ -2266,69 +2353,67 @@ void MainWindow::on_btn_getFpgaVersion_clicked() //void MainWindow::on_btn_txTrig_clicked() //{ -// auto bar = 0; -// uint32_t offsetAfeAdc2[3] = {0x10F002*4,0x20F002*4,0x30F002*4}; +//auto bar = 0; +//uint32_t offsetAfeAdc2[3] = {0x10F002*4,0x20F002*4,0x30F002*4}; //// qDebug() << "--- SET AFE Ramp Count Mode --- "; //// for (auto i=0 ; i<3;i++) //// { //// _usd->writeWord(offsetAfeAdc2[i], bar, 0x1380); //// } -// delay(20); - +//delay(20); -// uint32_t offsetAfePwrDn[3] = {0x10F0C5*4,0x20F0C5*4,0x30F0C5*4}; -// //uint32_t offsetAfeLpf[3] = {0x10F0C4*4,0x20F0C4*4,0x30F0C4*4}; +//uint32_t offsetAfePwrDn[3] = {0x10F0C5*4,0x20F0C5*4,0x30F0C5*4}; +////uint32_t offsetAfeLpf[3] = {0x10F0C4*4,0x20F0C4*4,0x30F0C4*4}; -// qDebug() << "--- SET AFE Power On Mode --- "; -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetAfePwrDn[i], bar, 0x0); -// //_usd->writeWord(offsetAfeLpf[i], bar, 0x0100); -// } -// delay(100); - - -// qDebug() << "--- Set TX Trig --- "; - -// auto offset = 0x5*4; -// auto value = 0x1; -// _usd->writeWord(offset,bar,value); -// value = 0x5; -// _usd->writeWord(offset,bar,value); -// value = 0x1; -// _usd->writeWord(offset,bar,value); -// delay(100); -// value = 0x0; -// _usd->writeWord(offset,bar,value); -// qDebug() << "--- TX Trig Done--- "; - -// delay(10); +//qDebug() << "--- SET AFE Power On Mode --- "; +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetAfePwrDn[i], bar, 0x0); +////_usd->writeWord(offsetAfeLpf[i], bar, 0x0100); +//} +//delay(100); + +//qDebug() << "--- Set TX Trig --- "; + +//auto offset = 0x5*4; +//auto value = 0x1; +//_usd->writeWord(offset,bar,value); +//value = 0x5; +//_usd->writeWord(offset,bar,value); +//value = 0x1; +//_usd->writeWord(offset,bar,value); +//delay(100); +//value = 0x0; +//_usd->writeWord(offset,bar,value); +//qDebug() << "--- TX Trig Done--- "; + +//delay(10); //// qDebug() << "--- SET AFE Normal Mode --- "; //// for (auto i=0 ; i<3;i++) //// { //// _usd->writeWord(offsetAfeAdc2[i], bar, 0x1000); //// } -// qDebug() << "--- SET AFE Power On Mode --- "; -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetAfePwrDn[i], bar, 0x8000); -// //_usd->writeWord(offsetAfeLpf[i], bar, 0x0100); -// } -// delay(1); -// delay(20); +//qDebug() << "--- SET AFE Power On Mode --- "; +//for (auto i=0 ; i<3;i++) +//{ +//_usd->writeWord(offsetAfePwrDn[i], bar, 0x8000); +////_usd->writeWord(offsetAfeLpf[i], bar, 0x0100); +//} +//delay(1); +//delay(20); //} /*************************************************************************************************/ /************************************* Scenario Setting ******************************************/ /*************************************************************************************************/ -void MainWindow::setScenario(const string &h5Path) +void MainWindow::setScenario(const string& h5Path) { Hdf5 hdf; ScenGenHardwareOutput_t scenParams; ScenPrbDepHardwareParam prbDepParams; - QVector lineFilterLut; - QVector stbLut; + QVector lineFilterLut; + QVector stbLut; hdf.hdf5Path(h5Path); @@ -2346,7 +2431,7 @@ void MainWindow::setScenario(const string &h5Path) _trx.setLineFilterCoefficient(lineFilterLut); _trx.setStbCoefficient(stbLut); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2359,23 +2444,23 @@ void MainWindow::setScenario(const string &h5Path) ui->tb_startIdx->setText(QString::number(startIdx, 16)); ui->tb_endIdx->setText(QString::number(endIdx, 16)); - - ui->l_scenFillingDone->setText("done"); - changeLabelTextColor(ui->l_scenFillingDone, Qt::green); } /*************************************************************************************************/ void MainWindow::on_btn_setScenario_clicked() { - _timeout->stop(); - ui->l_scenFillingDone->setText("doing"); - changeLabelTextColor(ui->l_scenFillingDone, Qt::red); + 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; - auto scenFuture = QtConcurrent::run(this, &MainWindow::setScenario, h5Path.toStdString()); - scenEndWather.setFuture(scenFuture); + emit scenarioReady(h5Path.toStdString()); + + str = "done"; + color = Qt::green; + emit labelState(ui->l_scenFillingDone, str, color); } /*************************************************************************************************/ @@ -2402,9 +2487,31 @@ void MainWindow::getSramVerifyMessage(QString message) } /*************************************************************************************************/ -void MainWindow::setScenarioCompare(const QString &scenPath) +void MainWindow::setScenarioCompare(const QString& scenPath) { - _trx.setScenarioCompare(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(); + } } /*************************************************************************************************/ @@ -2422,7 +2529,6 @@ void MainWindow::on_btn_setScenVerification_clicked() const QString scenPath = ui->tb_scenFilesPath->text(); QtConcurrent::run(this, &MainWindow::setScenarioCompare, scenPath); - } /*************************************************************************************************/ @@ -2447,11 +2553,14 @@ void MainWindow::on_btn_setAtgcMode_clicked() auto aTgcMode = ui->cb_aTgcMode->currentIndex(); auto aTgcValue = ui->tb_aTgcValue->text().toUInt(); - if (aTgcMode == 0) + if(aTgcMode == 0) + { _trx.setAtgcMode(Auto, 0); - + } else + { _trx.setAtgcMode(Manual, static_cast(aTgcValue)); + } } /*************************************************************************************************/ @@ -2462,6 +2571,7 @@ void MainWindow::on_btn_setIdx_clicked() if(startIndex == 0 && ui->tb_startIdx->text() != "0") { MESSAGE_BOX("Invalid input format for start index"); + return; } @@ -2469,12 +2579,14 @@ void MainWindow::on_btn_setIdx_clicked() if(endIndex == 0 && ui->tb_endIdx->text() != "0") { MESSAGE_BOX("Invalid input format for stop index"); + return; } - if((endIndex < startIndex) || (endIndex>131071) || (startIndex>131071)) + if((endIndex < startIndex) || (endIndex > 131071) || (startIndex > 131071)) { MESSAGE_BOX("Stop index should be greater than or equal to start index"); + return; } @@ -2495,26 +2607,32 @@ QByteArray MainWindow::str2ByteArray (QString& str) foreach(auto i, asciiArray) { - if (i <= 0x39 && i >= 0x30) + if(i <= 0x39 && i >= 0x30) + { temp.push_back(i - 0x30); - else if (i <= 0x46 && i >= 0x41) + } + else if(i <= 0x46 && i >= 0x41) + { temp.push_back(i - 0x37); + } else { - throw "Out of range"; + throw"Out of range"; } } - for (quint8 k = 0; k < temp.size()/2; k++) + for(quint8 k = 0; k < temp.size() / 2; k++) { - value = static_cast(((temp.at(2*k) << 4) & 0xF0)+((temp.at(2*k + 1)) & 0xF)); + value = static_cast(((temp.at(2 * k) << 4) & 0xF0) + ((temp.at(2 * k + 1)) & 0xF)); finalArray.push_back(value); } + return finalArray; } QString MainWindow::uint2IdString (quint32& id) { QString idStr = QString::number(id, 16); + return idStr; } @@ -2524,11 +2642,16 @@ QString MainWindow::byteArray2InfoString (QByteArray& arr) foreach(auto j, arr) { quint8 l = static_cast(j); - if (l <= 15) + if(l <= 15) + { infoStr += "0" + QString::number(l, 16); + } else + { infoStr += QString::number(l, 16); + } } + return infoStr; } @@ -2542,12 +2665,11 @@ void MainWindow::on_btn_trxRomIdWrite_clicked() QByteArray sendingArray = str2ByteArray(idStr); trxEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } - catch (const char* exception) + catch(const char* exception) { qDebug() << exception; } - - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2561,17 +2683,17 @@ void MainWindow::on_btn_trxRomInfoWrite_clicked() { QByteArray sendingArray = infoStr.toLatin1(); trxEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); -// QByteArray sendingArray; -// unsigned char crcArray[] = {0x4, 0x0, 0x13, 0x0, 0x27, 0x0, 0x28, 0x0, 0xEB, 0x1, -// 0xAC, 0x5, 0xAC, 0x6, 0x4C, 0x6, 0xB0, 0x6, 0xB2, -// 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -// for(auto var : crcArray) -// sendingArray.push_back(static_cast(var)); +//QByteArray sendingArray; +//unsigned char crcArray[] = {0x4, 0x0, 0x13, 0x0, 0x27, 0x0, 0x28, 0x0, 0xEB, 0x1, +//0xAC, 0x5, 0xAC, 0x6, 0x4C, 0x6, 0xB0, 0x6, 0xB2, +//0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +//0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +//for(auto var : crcArray) +//sendingArray.push_back(static_cast(var)); //trxEepromWrite(sendingArray, EEPROM_CRC_BEGIN, _bCtrl); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2584,24 +2706,27 @@ void MainWindow::on_btn_trxRomIdRead_clicked() try { _trx.trxState(romStatus); - if (romStatus.ConnectionMode == connected) + 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."; + 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) + catch(const char* exception) { qDebug() << exception; } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } - } /*************************************************************************************************/ @@ -2612,7 +2737,7 @@ void MainWindow::on_btn_trxRomInfoRead_clicked() QString receivingStr = _trx.trxInfo(); ui->tb_trxRomInfo->setText(receivingStr); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2627,12 +2752,11 @@ void MainWindow::on_btn_mpsRomIdWrite_clicked() QByteArray sendingArray = str2ByteArray(idStr); mpsEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } - catch (const char* exception) + catch(const char* exception) { qDebug() << exception; } - - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2647,7 +2771,7 @@ void MainWindow::on_btn_mpsRomInfoWrite_clicked() QByteArray sendingArray = infoStr.toLatin1(); mpsEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2660,24 +2784,27 @@ void MainWindow::on_btn_mpsRomIdRead_clicked() try { _trx.mpsState(romStatus); - if (romStatus.ConnectionMode == connected) + 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."; + 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) + catch(const char* exception) { qDebug() << exception; } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } - } /*************************************************************************************************/ @@ -2688,7 +2815,7 @@ void MainWindow::on_btn_mpsRomInfoRead_clicked() QString receivingStr = _trx.mpsInfo(); ui->tb_mpsRomInfo->setText(receivingStr); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2703,12 +2830,11 @@ void MainWindow::on_btn_prbCtrlRomIdWrite_clicked() QByteArray sendingArray = str2ByteArray(idStr); prbCtrlEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } - catch (const char* exception) + catch(const char* exception) { qDebug() << exception; } - - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2723,7 +2849,7 @@ void MainWindow::on_btn_prbCtrlRomInfoWrite_clicked() QByteArray sendingArray = infoStr.toLatin1(); prbCtrlEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2736,24 +2862,27 @@ void MainWindow::on_btn_prbCtrlRomIdRead_clicked() try { _trx.prbCtrlState(romStatus); - if (romStatus.ConnectionMode == connected) + 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."; + 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) + catch(const char* exception) { qDebug() << exception; } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } - } /*************************************************************************************************/ @@ -2764,7 +2893,7 @@ void MainWindow::on_btn_prbCtrlRomInfoRead_clicked() QString receivingStr = _trx.prbCtrlInfo(); ui->tb_prbCtrlRomInfo->setText(receivingStr); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2777,103 +2906,118 @@ void MainWindow::on_btn_prbRomIdRead_clicked() EepromStatus romStatus; try { - switch (sel) + switch(sel) { - case 0: - try - { - _trx.selectedPrbState(romStatus, prbA); - if (romStatus.ConnectionMode == connected) + case 0: + try { - ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); - if (romStatus.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe A eeprom is occured."; + _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."); + } } - else - MESSAGE_BOX("Probe A is disconnected."); - } - catch (const char* exception) - { - qDebug() << exception; - } - catch (SonoException& e) - { - qDebug() << e.what(); - } - break; + catch(const char* exception) + { + qDebug() << exception; + } + catch(SonoException& e) + { + qDebug() << e.what(); + } + break; - case 1: - try - { - _trx.selectedPrbState(romStatus, prbB); - if (romStatus.ConnectionMode == connected) + case 1: + try { - ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); - if (romStatus.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe B eeprom is occured."; + _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."); + } } - else - MESSAGE_BOX("Probe B is disconnected."); - } - catch (const char* exception) - { - qDebug() << exception; - } - catch (SonoException& e) - { - qDebug() << e.what(); - } - break; + catch(const char* exception) + { + qDebug() << exception; + } + catch(SonoException& e) + { + qDebug() << e.what(); + } + break; - case 2: - try - { - _trx.selectedPrbState(romStatus, prbC); - if (romStatus.ConnectionMode == connected) + case 2: + try { - ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); - if (romStatus.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe C eeprom is occured."; + _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."); + } } - else - MESSAGE_BOX("Probe C is disconnected."); - } - catch (const char* exception) - { - qDebug() << exception; - } - catch (SonoException& e) - { - qDebug() << e.what(); - } - break; + catch(const char* exception) + { + qDebug() << exception; + } + catch(SonoException& e) + { + qDebug() << e.what(); + } + break; - case 3: - try - { - _trx.selectedPrbState(romStatus, prbD); - if (romStatus.ConnectionMode == connected) + case 3: + try { - ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); - if (romStatus.errorCode == EEPROM_CRC_ERROR) - throw "The crc error of the probe D eeprom is occured."; + _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."); + } } - else - MESSAGE_BOX("Probe D is disconnected."); - } - catch (const char* exception) - { - qDebug() << exception; - } - catch (SonoException& e) - { - qDebug() << e.what(); - } - break; + catch(const char* exception) + { + qDebug() << exception; + } + catch(SonoException& e) + { + qDebug() << e.what(); + } + break; } - } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2888,7 +3032,7 @@ void MainWindow::on_btn_prbRomImpulseRead_clicked() QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); } - catch (SonoException& e) + catch(SonoException& e) { qDebug() << e.what(); } @@ -2905,37 +3049,45 @@ void MainWindow::on_btn_afeRead_clicked() afeArray.clear(); ui->tb_afeRegsValueArray->clear(); - switch (sel) + 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; - } + case 0: + afeArray = _trx.getAfeReg(slave0, offset); + break; - for (quint8 i = 0; i < afeArray.size(); i++) - ui->tb_afeRegsValueArray->appendPlainText(QString::number((afeArray.at(i)), 16)); + 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.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; + _afeConfig.inputClampLevel = inputClampLvlAuto; } + /*************************************************************************************************/ diff --git a/mainwindow.h b/mainwindow.h index ce6493d..fb7b73a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -60,7 +60,7 @@ #define TRANSFER_RATE 30.0f #define RAM_BUFFER_OFFSET 0U -#define ULTIMATE_LOG_COUNT 50 +#define ULTIMATE_LOG_COUNT 1000 QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -116,14 +116,8 @@ private: AfeConfig _afeConfig; - QFutureWatcher scenEndWather; - - void setScenario(const string& h5Path); - void setScenarioCompare(const QString& scenPath); - void fpgaProgrammer(QString path); - void timeout(); void delay(int ms); @@ -167,6 +161,8 @@ private: private slots: + void setScenario(const string& h5Path); + void getFramePacket (QByteArray packet); void getSramBinaryCreateFlag (void); @@ -177,7 +173,13 @@ private slots: void getPrbChange(); - void restartTimer(); + void getFrameLost(); + + void getProgrammingProgress(qint32 progressValue, qint32 bitFileSize); + + void getLabelState(QLabel* label, QString str, QColor color); + + void getFpgaProgrammer (QString path); void on_rbtn_reg_toggled(bool checked); @@ -364,6 +366,10 @@ signals: void twoDReady(); void sendLogCount(qint32 counter, QProgressDialog* _progress); void connectedPrbChange(); + void frameLostCall(); + void labelState(QLabel* label, QString str, QColor color); + void fpgaProgrammer(QString path); + void scenarioReady(const string& h5Path); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index dcf6766..445e83a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -296,7 +296,7 @@ 0 150 741 - 105 + 141 @@ -308,13 +308,13 @@ 0 - 105 + 0 16777215 - 105 + 150 @@ -361,8 +361,8 @@ 10 70 - 128 - 17 + 138 + 19 @@ -395,6 +395,19 @@ Program + + + + 10 + 100 + 721 + 23 + + + + 24 + + @@ -488,7 +501,7 @@ 0 190 - 331 + 321 101 @@ -553,9 +566,9 @@ 250 - 30 + 20 71 - 61 + 81 @@ -640,8 +653,8 @@ 690 70 - 91 - 48 + 92 + 52 @@ -677,8 +690,8 @@ 460 70 - 205 - 94 + 222 + 102 @@ -757,7 +770,7 @@ 10 70 281 - 60 + 64 @@ -1435,8 +1448,8 @@ 310 30 - 126 - 17 + 136 + 19 @@ -1461,8 +1474,8 @@ 310 50 - 119 - 17 + 128 + 19 @@ -1487,8 +1500,8 @@ 310 70 - 121 - 17 + 131 + 19 @@ -1513,8 +1526,8 @@ 310 90 - 151 - 17 + 163 + 19 @@ -1539,8 +1552,8 @@ 310 110 - 152 - 17 + 164 + 19 @@ -1565,8 +1578,8 @@ 540 30 - 147 - 17 + 158 + 19 @@ -1591,8 +1604,8 @@ 310 130 - 143 - 17 + 154 + 19 @@ -1617,8 +1630,8 @@ 540 50 - 164 - 17 + 178 + 19 @@ -1643,8 +1656,8 @@ 470 30 - 62 - 122 + 63 + 134 @@ -1715,7 +1728,7 @@ 540 90 - 145 + 156 62 @@ -1769,8 +1782,8 @@ 0 60 - 285 - 67 + 302 + 98 @@ -1975,6 +1988,20 @@ + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Frame Lost</span></p></body></html> + + + false + + + + + @@ -1984,7 +2011,7 @@ 140 30 - 163 + 176 21 @@ -2011,7 +2038,7 @@ 710 40 101 - 111 + 119 @@ -2091,8 +2118,8 @@ 540 20 - 142 - 25 + 150 + 27 @@ -2134,8 +2161,8 @@ 0 20 - 481 - 61 + 486 + 51 @@ -3272,8 +3299,8 @@ 710 140 - 82 - 17 + 88 + 19 @@ -3298,8 +3325,8 @@ 710 170 - 82 - 17 + 88 + 19 diff --git a/src/model/hardware/core/TrxBoard.cpp b/src/model/hardware/core/TrxBoard.cpp index 8be4440..38897ed 100644 --- a/src/model/hardware/core/TrxBoard.cpp +++ b/src/model/hardware/core/TrxBoard.cpp @@ -4,7 +4,7 @@ template QByteArray TrxBoard::uintLittleEndian2ByteArray(T& data) const { QByteArray byte; - QDataStream out (&byte, QIODevice::WriteOnly); + QDataStream out(&byte, QIODevice::WriteOnly); out.setByteOrder(QDataStream::LittleEndian); out << data; @@ -15,7 +15,7 @@ template T TrxBoard::byteArray2UintLittleEndian(QByteArray& byte) const { T data; - QDataStream in (byte); + QDataStream in(byte); in.setByteOrder(QDataStream::LittleEndian); in >> data; @@ -39,8 +39,10 @@ void TrxBoard::readData() { _hwCounter++; - if (_hwCounter > HW_BUFFER_NUM) + if(_hwCounter > HW_BUFFER_NUM) + { _hwCounter = 1; + } _device.copy(_hwCounter - 1, _swCounter); @@ -66,20 +68,20 @@ void TrxBoard::readData() void TrxBoard::sramClear(eSramClear clearMode) { quint32 num(0); - if (clearMode == all) + if(clearMode == all) { - while (num < SRAM_SIZE) + while(num < SRAM_SIZE) { - this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); - num += sizeof (quint64); + this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); + num += sizeof(quint64); } } - if (clearMode == first4M) + if(clearMode == first4M) { - while (num < SRAM_SIZE / 4) + while(num < SRAM_SIZE / 4) { - this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); - num += sizeof (quint64); + this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); + num += sizeof(quint64); } } } @@ -96,28 +98,66 @@ void TrxBoard::scenParamsFilling(TrxBoard::eScenParams cmd) else { _allow = false; - } + } +} + +void TrxBoard::afeAdcsSync() const +{ + quint32 syncErr(0); + + this->_bCtrlMngt->timerShot(20); + while(!(this->_bCtrlMngt->checkTimeout())) + { + ; + } + + this->_misc->setSyncMode(AdcSyncMode); + this->_misc->setManualSync(true); + this->_misc->setManualSync(false); + this->_misc->setManualSync(BfSyncMode); + + this->_bCtrlMngt->timerShot(1); + while(!((this->_afeSlave0->getAfeSyncDone()) && + (this->_afeSlave1->getAfeSyncDone()) && + (this->_afeSlave2->getAfeSyncDone()))) + { + if(this->_bCtrlMngt->checkTimeout()) + { + throw SonoException( + "The timeout of the afe adcs sync is happend without receiving of sync done."); + } + } + this->_bCtrlMngt->timerStop(); + + syncErr = this->_afeSlave0->getAfeSyncError(); + syncErr += this->_afeSlave1->getAfeSyncError(); + syncErr += this->_afeSlave2->getAfeSyncError(); + + if(syncErr != 0) + { + throw SonoException("The error of the afe adcs sync is happend."); + } } void TrxBoard::setSwapVector() { _swapVec.clear(); - _swapVec << 0 << 113 << 98 << 19 << 4 << 117 << 102 << 23 << 8 << 121 << 106 << 27 - << 12 << 125 << 110 << 31 << 16 << 1 << 114 << 99 << 20 << 5 << 118 << 103 - << 24 << 9 << 122 << 107 << 28 << 13 << 126 << 111 << 96 << 17 << 2 << 115 - << 100 << 21 << 6 << 119 << 104 << 25 << 10 << 123 << 108 << 29 << 14 << 127 - << 112 << 97 << 18 << 3 << 116 << 101 << 22 << 7 << 120 << 105 << 26 << 11 - << 124 << 109 << 30 << 15 << 32 << 145 << 130 << 51 << 36 << 149 << 134 << 55 - << 40 << 153 << 138 << 59 << 44 << 157 << 142 << 63 << 48 << 33 << 146 << 131 - << 52 << 37 << 150 << 135 << 56 << 41 << 154 << 139 << 60 << 45 << 158 << 143 - << 128 << 49 << 34 << 147 << 132 << 53 << 38 << 151 << 136 << 57 << 42 << 155 - << 140 << 61 << 46 << 159 << 144 << 129 << 50 << 35 << 148 << 133 << 54 << 39 - << 152 << 137 << 58 << 43 << 156 << 141 << 62 << 47 << 64 << 177 << 162 << 83 - << 68 << 181 << 166 << 87 << 72 << 185 << 170 << 91 << 76 << 189 << 174 << 95 - << 80 << 65 << 178 << 163 << 84 << 69 << 182 << 167 << 88 << 73 << 186 << 171 - << 92 << 77 << 190 << 175 << 160 << 81 << 66 << 179 << 164 << 85 << 70 << 183 - << 168 << 89 << 74 << 187 << 172 << 93 << 78 << 191 << 176 << 161 << 82 << 67 - << 180 << 165 << 86 << 71 << 184 << 169 << 90 << 75 << 188 << 173 << 94 << 79; + _swapVec << 0 << 113 << 98 << 19 << 4 << 117 << 102 << 23 << 8 << 121 << 106 << 27 + << 12 << 125 << 110 << 31 << 16 << 1 << 114 << 99 << 20 << 5 << 118 << 103 + << 24 << 9 << 122 << 107 << 28 << 13 << 126 << 111 << 96 << 17 << 2 << 115 + << 100 << 21 << 6 << 119 << 104 << 25 << 10 << 123 << 108 << 29 << 14 << 127 + << 112 << 97 << 18 << 3 << 116 << 101 << 22 << 7 << 120 << 105 << 26 << 11 + << 124 << 109 << 30 << 15 << 32 << 145 << 130 << 51 << 36 << 149 << 134 << 55 + << 40 << 153 << 138 << 59 << 44 << 157 << 142 << 63 << 48 << 33 << 146 << 131 + << 52 << 37 << 150 << 135 << 56 << 41 << 154 << 139 << 60 << 45 << 158 << 143 + << 128 << 49 << 34 << 147 << 132 << 53 << 38 << 151 << 136 << 57 << 42 << 155 + << 140 << 61 << 46 << 159 << 144 << 129 << 50 << 35 << 148 << 133 << 54 << 39 + << 152 << 137 << 58 << 43 << 156 << 141 << 62 << 47 << 64 << 177 << 162 << 83 + << 68 << 181 << 166 << 87 << 72 << 185 << 170 << 91 << 76 << 189 << 174 << 95 + << 80 << 65 << 178 << 163 << 84 << 69 << 182 << 167 << 88 << 73 << 186 << 171 + << 92 << 77 << 190 << 175 << 160 << 81 << 66 << 179 << 164 << 85 << 70 << 183 + << 168 << 89 << 74 << 187 << 172 << 93 << 78 << 191 << 176 << 161 << 82 << 67 + << 180 << 165 << 86 << 71 << 184 << 169 << 90 << 75 << 188 << 173 << 94 << 79; } void TrxBoard::setRomCrc() @@ -125,7 +165,9 @@ void TrxBoard::setRomCrc() unsigned char crcArray[] = {0x4, 0x0, 0x13, 0x0, 0x27, 0x0, 0x28, 0x0, 0xEB, 0x1, 0xAC, 0x5, 0xAC, 0x6, 0x4C, 0x6, 0xB0, 0x6, 0xB2}; for(auto var : crcArray) + { _eepromCrc.push_back(static_cast(var)); + } } void TrxBoard::setAfeModuleOffset() @@ -142,15 +184,15 @@ void TrxBoard::setFpgaOffset() //QList TrxBoard::signedVector2unsignedList (QVector& sgnVec) //{ -// _unsignedQntzrList.clear(); +//_unsignedQntzrList.clear(); //// std::list _usgnList (sgnVec.begin(), sgnVec.end()); //// _unsignedQntzrList.fromStdList(_usgnList); -// foreach (auto i, sgnVec) -// { -// _unsignedQntzrList.push_back(static_cast(i)); -// } +//foreach (auto i, sgnVec) +//{ +//_unsignedQntzrList.push_back(static_cast(i)); +//} -// return _unsignedQntzrList; +//return _unsignedQntzrList; //} TrxBoard::TrxBoard() : _offsetSlave0(0), _offsetSlave1(0x400000), _offsetSlave2(0x800000) @@ -242,11 +284,13 @@ void TrxBoard::init() sramClear(all); } -void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams) +void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam& prbDepParams) { /////////////////////////// DSP setting /////////////////////////// - if (prbDepParams.prbDepParams.apodizationLut.size() != APODIZATIONLUT_LUT_MAX) + if(prbDepParams.prbDepParams.apodizationLut.size() != APODIZATIONLUT_LUT_MAX) + { throw SonoException("Apodization lut is out of range"); + } QList > apodizationQ; foreach(auto vec, prbDepParams.prbDepParams.apodizationLut) { @@ -257,8 +301,10 @@ void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams) this->_beamFormerSlave2->apodizationLut(apodizationQ); scenParamsFilling(set); - if (prbDepParams.prbDepParams.atgcLut.size() != ATGC_LUT_MAX) + if(prbDepParams.prbDepParams.atgcLut.size() != ATGC_LUT_MAX) + { throw SonoException("Atgc lut is out of range"); + } QList > atgcLutQ; foreach(auto vec, prbDepParams.prbDepParams.atgcLut) { @@ -266,8 +312,10 @@ void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams) } this->_dsp->atgcLut(atgcLutQ); - if (prbDepParams.prbDepParams.lpfLut.size() != LPF_LUT_MAX) + if(prbDepParams.prbDepParams.lpfLut.size() != LPF_LUT_MAX) + { throw SonoException("Lpf lut is out of range"); + } QList > lpfLutQ; foreach(auto vec, prbDepParams.prbDepParams.lpfLut) { @@ -279,73 +327,106 @@ void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams) this->_afeSlave0->setAfeParams(prbDepParams.afeCfg); this->_afeSlave1->setAfeParams(prbDepParams.afeCfg); this->_afeSlave2->setAfeParams(prbDepParams.afeCfg); + this->_afeSlave0->setAfeGblPwr(afePwrdnEnable); + this->_afeSlave1->setAfeGblPwr(afePwrdnEnable); + this->_afeSlave2->setAfeGblPwr(afePwrdnEnable); } -void TrxBoard::setScenario(ScenGenHardwareOutput_t &scenGenHw) +void TrxBoard::setScenario(ScenGenHardwareOutput_t& scenGenHw) { - if (this->_scenPlayer->control.getCommand()) + if(this->_scenPlayer->control.getCommand()) + { scenPlayerStop(); + } emulatorStop(); sramClear(first4M); scenParams->focusTypeNumber = scenGenHw.focusTypeNumber; - if (scenParams->focusTypeNumber > FOCUS_TYPE_NUMBER_MAX) + if(scenParams->focusTypeNumber > FOCUS_TYPE_NUMBER_MAX) + { throw SonoException("Focus type number is out of range"); + } scenParams->totalTxShotNumber = scenGenHw.totalTxShotNumber; - if (scenParams->totalTxShotNumber > TOTAL_TX_SHOT_NUMBER_MAX) + if(scenParams->totalTxShotNumber > TOTAL_TX_SHOT_NUMBER_MAX) + { throw SonoException("Total tx shot number is out of range"); + } scenParams->rxBeamFormerNumber = scenGenHw.rxBeamFormerNumber.toVector(); - if (scenParams->rxBeamFormerNumber.size() > RX_BEAMFORMER_NUMBER_MAX) + if(scenParams->rxBeamFormerNumber.size() > RX_BEAMFORMER_NUMBER_MAX) + { throw SonoException("Rx beam former number is out of range"); + } scenParams->scenarioStartIndex = scenGenHw.hwRegister.scenarioStartIndex; scenParams->scenarioEndIndex = scenGenHw.hwRegister.scenarioEndIndex; - if (scenParams->scenarioEndIndex > SCENARIO_INDEX_MAX) + if(scenParams->scenarioEndIndex > SCENARIO_INDEX_MAX) + { throw SonoException("Scenario end index is out of range"); + } if(scenParams->scenarioEndIndex < scenParams->scenarioStartIndex) + { throw SonoException( "The scenario end index must be greater than or equal to the scenario start index"); + } scenParams->hwRegister->blendWeight = scenGenHw.hwRegister.blendWeight; - if (scenParams->hwRegister->blendWeight.size() != BLENDWEIGHT_LUT_MAX) + if(scenParams->hwRegister->blendWeight.size() != BLENDWEIGHT_LUT_MAX) + { throw SonoException("Blend weight lut is out of range"); + } scenParams->hwRegister->elementPosition->xPosition = scenGenHw.hwRegister.elementXPosition; - if (scenParams->hwRegister->elementPosition->xPosition.size() != ELEMENT_POSITION_LUT_MAX) + if(scenParams->hwRegister->elementPosition->xPosition.size() != ELEMENT_POSITION_LUT_MAX) + { throw SonoException("Element position x is out of range"); + } scenParams->hwRegister->elementPosition->yPosition = scenGenHw.hwRegister.elementYPosition; - if (scenParams->hwRegister->elementPosition->yPosition.size() != ELEMENT_POSITION_LUT_MAX) + if(scenParams->hwRegister->elementPosition->yPosition.size() != ELEMENT_POSITION_LUT_MAX) + { throw SonoException("Element position y is out of range"); + } scenParams->hwRegister->elementPosition->zPosition = scenGenHw.hwRegister.elementZPosition; - if (scenParams->hwRegister->elementPosition->zPosition.size() != ELEMENT_POSITION_LUT_MAX) + if(scenParams->hwRegister->elementPosition->zPosition.size() != ELEMENT_POSITION_LUT_MAX) + { throw SonoException("Element position z is out of range"); + } scenParams->hwRegister->freqLut = scenGenHw.hwRegister.freqLut; - if (scenParams->hwRegister->freqLut.size() != FREQUENCY_LUT_MAX) + if(scenParams->hwRegister->freqLut.size() != FREQUENCY_LUT_MAX) + { throw SonoException("Frequency lut is out of range"); + } scenParams->hwRegister->dtgcLut = scenGenHw.hwRegister.dtgcLut; - if (scenParams->hwRegister->dtgcLut.size() != DTGC_LUT_MAX) + if(scenParams->hwRegister->dtgcLut.size() != DTGC_LUT_MAX) + { throw SonoException("Dtgc lut is out of range"); + } scenParams->hwRegister->pulseTypeNumber = scenGenHw.hwRegister.pulseTypeNumber; - if (scenParams->hwRegister->pulseTypeNumber > PULSE_LUT_MAX) + if(scenParams->hwRegister->pulseTypeNumber > PULSE_LUT_MAX) + { throw SonoException("Pulse type number is out of range"); + } scenParams->hwRegister->rxBeamFormerTypeNumber = scenGenHw.hwRegister.rxBeamFormerTypeNumber; - if (scenParams->hwRegister->rxBeamFormerTypeNumber > RXBEAMFORMER_LUT_MAX) + if(scenParams->hwRegister->rxBeamFormerTypeNumber > RXBEAMFORMER_LUT_MAX) + { throw SonoException("Rx beam former type number is out of range"); + } scenParams->hwRegister->receiverConfigTypeNumber = scenGenHw.hwRegister.receiverConfigTypeNumber; - if (scenParams->hwRegister->receiverConfigTypeNumber > RRECEIVER_CONFIGURATION_LUT_MAX) + if(scenParams->hwRegister->receiverConfigTypeNumber > RRECEIVER_CONFIGURATION_LUT_MAX) + { throw SonoException("Receiver config type number is out of range"); + } scenParams->hwRegister->pulse->clear(); foreach(auto i, scenGenHw.hwRegister.pulseProps) @@ -366,7 +447,7 @@ void TrxBoard::setScenario(ScenGenHardwareOutput_t &scenGenHw) } scenParams->hwRegister->configLut->clear(); - foreach (auto k, scenGenHw.hwRegister.receiverConfigProps) + foreach(auto k, scenGenHw.hwRegister.receiverConfigProps) { scenParams->hwRegister->configLut->mla.append(k.mla); scenParams->hwRegister->configLut->stb.append(k.stb); @@ -386,7 +467,7 @@ void TrxBoard::setScenario(ScenGenHardwareOutput_t &scenGenHw) } scenParams->indexParams->dLineNum = scenGenHw.indexParams.dLineNum; - scenParams->indexParams->frameType=scenGenHw.frameType; + scenParams->indexParams->frameType = scenGenHw.frameType; scenParams->indexParams->dEnsembleNum = scenGenHw.indexParams.dEnsembleNum; scenParams->indexParams->lastLineInFrame = scenGenHw.indexParams.lastLineInFrame; scenParams->indexParams->firstLineInFrame = scenGenHw.indexParams.firstLineInFrame; @@ -529,7 +610,8 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) QList freqLutQ = _unsignedQntzrVec.toList(); this->_dsp->frequencyLut(freqLutQ); - _unsignedQntzrVec = Calculation::qntzr(scenParams->hwRegister->dtgcLut, 0, 12, 8, 0, true, false); + _unsignedQntzrVec = + Calculation::qntzr(scenParams->hwRegister->dtgcLut, 0, 12, 8, 0, true, false); QList dtgcLutQ = _unsignedQntzrVec.toList(); this->_dsp->dtgcLut(dtgcLutQ); @@ -551,21 +633,22 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) this->_sram->setSramTx(scenParams->focusTypeNumber, scenParams->txParams); this->_sram->setSramRx(scenParams->rxBeamFormerNumber, - scenParams->focusTypeNumber, - scenParams->rxParams); + scenParams->focusTypeNumber, + scenParams->rxParams); scenParamsFilling(set); ////////////////////////////// Scen Index setting //////////////////////////// this->_scenPlayer->setStartIndex(scenParams->scenarioStartIndex); this->_scenPlayer->setEndIndex(scenParams->scenarioEndIndex); - } void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) { - if (lineFilterLut.size() != LINE_FILTER_LUT_MAX) + if(lineFilterLut.size() != LINE_FILTER_LUT_MAX) + { throw SonoException("Line filter lut is out of range"); + } _unsignedQntzrVec = Calculation::qntzr(lineFilterLut, 0, 9, 8, 0, true, false); QList lineFilterLutQ = _unsignedQntzrVec.toList(); this->_dsp->lineFilterCoefficient(lineFilterLutQ); @@ -573,8 +656,10 @@ void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) void TrxBoard::setStbCoefficient(QVector& stbLut) { - if (stbLut.size() != STB_COEFFICIENT_LUT_MAX) + if(stbLut.size() != STB_COEFFICIENT_LUT_MAX) + { throw SonoException("Stb lut is out of range"); + } QList stbLutQ = stbLut.toList(); this->_dsp->stbCoefficient(stbLutQ); } @@ -586,29 +671,31 @@ void TrxBoard::setAtgcMode(eAtgcMode mode, quint16 value) const void TrxBoard::setDtgcLut(QVector& dtgcLut) { - if (dtgcLut.size() != DTGC_LUT_MAX) + if(dtgcLut.size() != DTGC_LUT_MAX) + { throw SonoException("Dtgc lut is out of range"); + } _unsignedQntzrVec = Calculation::qntzr(dtgcLut, 0, 12, 8, 0, true, false); QList dtgcLutQ = _unsignedQntzrVec.toList(); this->_dsp->dtgcLut(dtgcLutQ); } -void TrxBoard::setFramesMetaData(const QByteArray &metaData) const +void TrxBoard::setFramesMetaData(const QByteArray& metaData) const { QList data; QByteArray temp; qint32 num(0); - while (num < metaData.size()) + while(num < metaData.size()) { - for (quint8 j=0; j < sizeof (quint64); j++) + for(quint8 j = 0; j < sizeof(quint64); j++) { - temp.append(metaData[j+num]); + temp.append(metaData[j + num]); } - data.push_back(byteArray2UintLittleEndian (temp)); + data.push_back(byteArray2UintLittleEndian(temp)); temp.clear(); - num += sizeof (quint64); + num += sizeof(quint64); } this->_sram->setSramMetaData(data); } @@ -620,18 +707,18 @@ void TrxBoard::setScenarioCompare(const QString scenPath) QString saveFile = scenPath + createSramBinary; QFile sramFile(saveFile); - if (!sramFile.open(QIODevice::WriteOnly)) + if(!sramFile.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't create the sram binary file due to the wrong path probably."); } quint32 num(0); quint64 value(0); - while (num < SRAM_SIZE/4) + while(num < SRAM_SIZE / 4) { - value = _device.device.readLong(BAR_SRAM, static_cast(num)); - sramFile.write(uintLittleEndian2ByteArray(value)); - num += sizeof (quint64); + value = _device.device.readLong(BAR_SRAM, static_cast(num)); + sramFile.write(uintLittleEndian2ByteArray(value)); + num += sizeof(quint64); } sramFile.flush(); @@ -648,20 +735,22 @@ void TrxBoard::setScenarioCompare(const QString scenPath) if(!csvReadFile.open(QFile::ReadOnly)) { - throw SonoException("Could not open the register's scenario params due to the wrong path probably."); + throw SonoException( + "Could not open the register's scenario params due to the wrong path probably."); } QString registerCompareScenario = "/hardware/registerCompare.csv"; QString regCompareParamsPath = scenPath + registerCompareScenario; QFile csvWriteFile(regCompareParamsPath); - if (!csvWriteFile.open(QFile::WriteOnly)) + if(!csvWriteFile.open(QFile::WriteOnly)) { - throw SonoException("Couldn't create the register compare file due to the wrong path probably."); + throw SonoException( + "Couldn't create the register compare file due to the wrong path probably."); } quint32 bar = 0; - qint64 readSize = 0; + qint64 readSize = 0; QString line; auto size = csvReadFile.size(); @@ -674,16 +763,15 @@ void TrxBoard::setScenarioCompare(const QString scenPath) auto boardValue = _device.device.readWord(bar, address); auto res = "NOK"; - if (boardValue == baseValue) + if(boardValue == baseValue) { res = "OK"; } auto str = QStringLiteral("%1,%2,%3,%4") - .arg(address, 8, 16, QLatin1Char('0')) - .arg(baseValue, 8, 16, QLatin1Char('0')) - .arg(boardValue, 8, 16, QLatin1Char('0')).arg(res); - + .arg(address, 8, 16, QLatin1Char('0')) + .arg(baseValue, 8, 16, QLatin1Char('0')) + .arg(boardValue, 8, 16, QLatin1Char('0')).arg(res); csvWriteFile.write(str.toStdString().c_str(), str.length()); csvWriteFile.write("\r\n", 2); @@ -706,7 +794,8 @@ void TrxBoard::setScenarioCompare(const QString scenPath) if(!sramReadFile.open(QFile::ReadOnly)) { - throw SonoException("Could not open the sram's scenario params due to the wrong path probably."); + throw SonoException( + "Could not open the sram's scenario params due to the wrong path probably."); } qint64 sramScenarioLength = sramReadFile.size(); @@ -719,29 +808,28 @@ void TrxBoard::setScenarioCompare(const QString scenPath) quint64 fileValue(0); QByteArray temp; - while (num < sramScenarioLength) + while(num < sramScenarioLength) { boardValue = _device.device.readLong(BAR_SRAM, static_cast(num)); - for (quint8 j=0; j < sizeof (quint64); j++) + for(quint8 j = 0; j < sizeof(quint64); j++) { - temp.append(fileByte[j+num]); + temp.append(fileByte[j + num]); } - fileValue = byteArray2UintLittleEndian (temp); + fileValue = byteArray2UintLittleEndian(temp); - if (boardValue != fileValue) + if(boardValue != fileValue) { throw SonoException("The sram scenario file is different to the sram params of board."); } temp.clear(); - num += sizeof (quint64); + num += sizeof(quint64); } #ifdef DEVELOP_UI emit sramVerifyMessage("Successful comparision without any difference."); #endif - } QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) @@ -750,15 +838,18 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) quint32 offset(0); afeRegValue.clear(); - switch (sel) + switch(sel) { case slave0: this->_afeSlave0->setReadRegEnable(true); this->_bCtrlMngt->timerShot(1); - while(!(this->_bCtrlMngt->checkTimeout())); + while(!(this->_bCtrlMngt->checkTimeout())) + { + ; + } - for (quint8 i=0; i < _afeModuleOffset.size(); i++) + for(quint8 i = 0; i < _afeModuleOffset.size(); i++) { offset = (_fpgaOffset.at(slave0) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); @@ -770,9 +861,12 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) this->_afeSlave1->setReadRegEnable(true); this->_bCtrlMngt->timerShot(1); - while(!(this->_bCtrlMngt->checkTimeout())); + while(!(this->_bCtrlMngt->checkTimeout())) + { + ; + } - for (quint8 i=0; i < _afeModuleOffset.size(); i++) + for(quint8 i = 0; i < _afeModuleOffset.size(); i++) { offset = (_fpgaOffset.at(slave1) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); @@ -784,9 +878,12 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) this->_afeSlave2->setReadRegEnable(true); this->_bCtrlMngt->timerShot(1); - while(!(this->_bCtrlMngt->checkTimeout())); + while(!(this->_bCtrlMngt->checkTimeout())) + { + ; + } - for (quint8 i=0; i < _afeModuleOffset.size(); i++) + for(quint8 i = 0; i < _afeModuleOffset.size(); i++) { offset = (_fpgaOffset.at(slave2) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); @@ -800,7 +897,6 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) void TrxBoard::slaveFpgaProgram(const QString path) { - scenParamsFilling(clear); if(MOUNTED_SLAVE_FPGA <= 0 || MOUNTED_SLAVE_FPGA >= 8) @@ -827,7 +923,7 @@ void TrxBoard::slaveFpgaProgram(const QString path) this->_fpgaProgram->program(bitFileData, MOUNTED_SLAVE_FPGA); - + afeAdcsSync(); } void TrxBoard::setBeamFormerMode(eClkMode mode) const @@ -837,7 +933,6 @@ void TrxBoard::setBeamFormerMode(eClkMode mode) const void TrxBoard::scenPlayerStart(void) { - if(_allow) { _run = false; @@ -905,8 +1000,10 @@ void TrxBoard::emulatorInit(EmulatorProperties* config) const void TrxBoard::fillRam(QString path) { - if (this->_scenPlayer->control.getCommand()) + if(this->_scenPlayer->control.getCommand()) + { scenPlayerStop(); + } emulatorStop(); QFile emulFile(path); @@ -929,16 +1026,18 @@ void TrxBoard::fillRam(QString path) sramData = emulFile.readAll(); emulFile.close(); - while (num < sramData.size()) + while(num < sramData.size()) { - for (quint8 j=0; j < sizeof (quint64); j++) + for(quint8 j = 0; j < sizeof(quint64); j++) { - temp.append(sramData[j+num]); + temp.append(sramData[j + num]); } - this->_device.device.writeLong(BAR_SRAM, static_cast(num), byteArray2UintLittleEndian (temp)); + this->_device.device.writeLong(BAR_SRAM, + static_cast(num), + byteArray2UintLittleEndian(temp)); temp.clear(); - num += sizeof (quint64); + num += sizeof(quint64); } } @@ -980,7 +1079,7 @@ quint32 TrxBoard::vendorId() const return vid; } -void TrxBoard::trxState(EepromStatus &romStatus) const +void TrxBoard::trxState(EepromStatus& romStatus) const { QByteArray id; QByteArray crcChk; @@ -988,16 +1087,20 @@ void TrxBoard::trxState(EepromStatus &romStatus) const romStatus.ConnectionMode = connected; id = this->_bCtrlMngt->trxEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER); - romStatus.id = byteArray2UintBigEndian (id); + romStatus.id = byteArray2UintBigEndian(id); crcChk = this->_bCtrlMngt->trxEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER); - if (crcChk == _eepromCrc) + if(crcChk == _eepromCrc) + { romStatus.errorCode = EEPROM_NO_ERROR; + } else + { romStatus.errorCode = EEPROM_CRC_ERROR; + } } -void TrxBoard::mpsState(EepromStatus &romStatus) const +void TrxBoard::mpsState(EepromStatus& romStatus) const { QByteArray id; QByteArray crcChk; @@ -1005,16 +1108,20 @@ void TrxBoard::mpsState(EepromStatus &romStatus) const romStatus.ConnectionMode = connected; id = this->_bCtrlMngt->mpsEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER); - romStatus.id = byteArray2UintBigEndian (id); + romStatus.id = byteArray2UintBigEndian(id); crcChk = this->_bCtrlMngt->mpsEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER); - if (crcChk == _eepromCrc) + if(crcChk == _eepromCrc) + { romStatus.errorCode = EEPROM_NO_ERROR; + } else + { romStatus.errorCode = EEPROM_CRC_ERROR; + } } -void TrxBoard::prbCtrlState(EepromStatus &romStatus) const +void TrxBoard::prbCtrlState(EepromStatus& romStatus) const { QByteArray id; QByteArray crcChk; @@ -1022,44 +1129,60 @@ void TrxBoard::prbCtrlState(EepromStatus &romStatus) const romStatus.ConnectionMode = connected; id = this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER); - romStatus.id = byteArray2UintBigEndian (id); + romStatus.id = byteArray2UintBigEndian(id); crcChk = this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER); - if (crcChk == _eepromCrc) + if(crcChk == _eepromCrc) + { romStatus.errorCode = EEPROM_NO_ERROR; + } else + { romStatus.errorCode = EEPROM_CRC_ERROR; + } } -void TrxBoard::selectedPrbState(EepromStatus &romStatus, eSelectProbe prbSel) const +void TrxBoard::selectedPrbState(EepromStatus& romStatus, eSelectProbe prbSel) const { QVector vec; QByteArray id; QByteArray crcChk; vec = this->_bCtrlMngt->getConnectedPrb(); - if (prbSel == prbA && !vec.at(0)) + if(prbSel == prbA && !vec.at(0)) + { throw SonoException("This probe is disconnected"); + } - if (prbSel == prbB && !vec.at(1)) + if(prbSel == prbB && !vec.at(1)) + { throw SonoException("This probe is disconnected"); + } - if (prbSel == prbC && !vec.at(2)) + if(prbSel == prbC && !vec.at(2)) + { throw SonoException("This probe is disconnected"); + } - if (prbSel == prbD && !vec.at(3)) + if(prbSel == prbD && !vec.at(3)) + { throw SonoException("This probe is disconnected"); + } romStatus.ConnectionMode = connected; - id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, prbSel-1); - romStatus.id = byteArray2UintBigEndian (id); + id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, prbSel - 1); + romStatus.id = byteArray2UintBigEndian(id); - crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, prbSel-1); - if (crcChk == _eepromCrc) + crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, prbSel - 1); + if(crcChk == _eepromCrc) + { romStatus.errorCode = EEPROM_NO_ERROR; + } else + { romStatus.errorCode = EEPROM_CRC_ERROR; + } } void TrxBoard::prbState(PrbCase* prb) const @@ -1080,13 +1203,18 @@ void TrxBoard::prbState(PrbCase* prb) const prb->prbA.ConnectionMode = connected; id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); - prb->prbA.id = byteArray2UintBigEndian (id); + prb->prbA.id = byteArray2UintBigEndian(id); - crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); - if (crcChk == _eepromCrc) + crcChk = + this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if(crcChk == _eepromCrc) + { prb->prbA.errorCode = EEPROM_NO_ERROR; + } else + { prb->prbA.errorCode = EEPROM_CRC_ERROR; + } } else { @@ -1102,13 +1230,18 @@ void TrxBoard::prbState(PrbCase* prb) const prb->prbB.ConnectionMode = connected; id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); - prb->prbB.id = byteArray2UintBigEndian (id); + prb->prbB.id = byteArray2UintBigEndian(id); - crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); - if (crcChk == _eepromCrc) + crcChk = + this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if(crcChk == _eepromCrc) + { prb->prbB.errorCode = EEPROM_NO_ERROR; + } else + { prb->prbB.errorCode = EEPROM_CRC_ERROR; + } } else { @@ -1124,13 +1257,18 @@ void TrxBoard::prbState(PrbCase* prb) const prb->prbC.ConnectionMode = connected; id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); - prb->prbC.id = byteArray2UintBigEndian (id); + prb->prbC.id = byteArray2UintBigEndian(id); - crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); - if (crcChk == _eepromCrc) + crcChk = + this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if(crcChk == _eepromCrc) + { prb->prbC.errorCode = EEPROM_NO_ERROR; + } else + { prb->prbC.errorCode = EEPROM_CRC_ERROR; + } } else { @@ -1146,13 +1284,18 @@ void TrxBoard::prbState(PrbCase* prb) const prb->prbD.ConnectionMode = connected; id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); - prb->prbD.id = byteArray2UintBigEndian (id); + prb->prbD.id = byteArray2UintBigEndian(id); - crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); - if (crcChk == _eepromCrc) + crcChk = + this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if(crcChk == _eepromCrc) + { prb->prbD.errorCode = EEPROM_NO_ERROR; + } else + { prb->prbD.errorCode = EEPROM_CRC_ERROR; + } } else { @@ -1173,8 +1316,9 @@ QString TrxBoard::trxInfo() const getFpgasCodeVersion(&version); QString info = QString(this->_bCtrlMngt->trxEepromRead(EEPROM_INFO_BEGIN, EEPROM_INFO_NUMBER)); - return (info + "(FPM-V " + QString::number(version.masterCode, 10) - + ", FPS-V " + QString::number(version.slave0Code, 10) + ")"); + + return (info + "(FPM-V " + QString::number(version.masterCode, 10) + + ", FPS-V " + QString::number(version.slave0Code, 10) + ")"); } QString TrxBoard::mpsInfo() const @@ -1189,7 +1333,9 @@ QString TrxBoard::prbCtrlInfo() const QByteArray TrxBoard::selectedPrbImpulseResponse(quint8 prbSel) const { - return this->_bCtrlMngt->prbEepromRead(EEPROM_IMPULSE_RESPONSE_BEGIN, EEPROM_IMPULSE_RESPONSE_NUMBER, prbSel); + return this->_bCtrlMngt->prbEepromRead(EEPROM_IMPULSE_RESPONSE_BEGIN, + EEPROM_IMPULSE_RESPONSE_NUMBER, + prbSel); } void TrxBoard::prbImpulseResponse(ConnectedPrbInfo* prbInfo) const @@ -1268,7 +1414,10 @@ void TrxBoard::mpsSetAo(float voltA, float voltB) const void TrxBoard::selectProbe(eSelectProbe prbSel) { - scenPlayerStop(); + if(this->_scenPlayer->control.getCommand()) + { + scenPlayerStop(); + } this->_bCtrlMngt->setProbeSelect(prbSel); } @@ -1348,3 +1497,8 @@ void TrxBoard::sramParityClear() val = this->_device.device.readLong(BAR_SRAM, 0); this->_device.device.writeLong(BAR_SRAM, 0, val); } + +quint32 TrxBoard::getFrameLostCounter() const +{ + return (this->_misc->getFrameLostCount()); +} diff --git a/src/model/hardware/core/register/afe/Afe.cpp b/src/model/hardware/core/register/afe/Afe.cpp index 86bba8b..07f234f 100644 --- a/src/model/hardware/core/register/afe/Afe.cpp +++ b/src/model/hardware/core/register/afe/Afe.cpp @@ -51,15 +51,17 @@ void Afe::setPga(const AfeConfig afe) const Afe::Afe(SonoDevice *device, quint32 offset) { - _actTerm = new ActiveTerm(device, offset); - _lnaHpf = new LnaHpf (device, offset); - _global = new Global (device, offset); - _lowNf = new LowNf (device, offset); - _pga = new Pga (device, offset); + _adcSync = new AdcSyncStatus (device, offset); + _actTerm = new ActiveTerm (device, offset); + _lnaHpf = new LnaHpf (device, offset); + _global = new Global (device, offset); + _lowNf = new LowNf (device, offset); + _pga = new Pga (device, offset); } Afe::~Afe() { + delete _adcSync; delete _actTerm; delete _lnaHpf; delete _global; @@ -88,3 +90,27 @@ void Afe::setReadRegEnable(const bool rdEn) const this->_global->regReadEn->setValue(value); this->_global->update(); } + +bool Afe::getAfeSyncDone() const +{ + this->_adcSync->sync(); + return (this->_adcSync->syncDone->getValue() != 0); +} + +quint32 Afe::getAfeSyncError() const +{ + this->_adcSync->sync(); + return (this->_adcSync->syncError->getValue()); +} + +quint32 Afe::getAfeSyncAddress() const +{ + this->_adcSync->sync(); + return (this->_adcSync->syncAddress->getValue()); +} + +quint32 Afe::getAfeDataValid() const +{ + this->_adcSync->sync(); + return (this->_adcSync->dataValidOffset->getValue()); +} diff --git a/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp b/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp index 0ca581c..054958e 100644 --- a/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp +++ b/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp @@ -2,85 +2,99 @@ BoardsCtrlMngt::AttenuationFactor::AttenuationFactor() { - p12v=10.4727f; - p5v=4.3636f; - p4d=4.3636f; - m5v=2.1818f; - curP24v=1.0f; - hvStop=1.0f; - p24v=1.0f; - hva=1.0f; - hvb=1.0f; - cwd=1.0f; + p12v = 10.4727f; + p5v = 4.3636f; + p4d = 4.3636f; + m5v = 2.1818f; + curP24v = 1.0f; + hvStop = 1.0f; + p24v = 1.0f; + hva = 1.0f; + hvb = 1.0f; + cwd = 1.0f; } BoardsCtrlMngt::Gain::Gain() { - curP24v=2.778f; - cwd=6.555f; - m5v=-3.3f; - hvStop=1.0f; - p24v=23.0f; - hva=66.0f; - hvb=66.0f; - p12v=1.0f; - p5v=1.0f; - p4d=1.0f; + curP24v = 2.778f; + cwd = 6.555f; + m5v = -3.3f; + hvStop = 1.0f; + p24v = 23.0f; + hva = 66.0f; + hvb = 66.0f; + p12v = 1.0f; + p5v = 1.0f; + p4d = 1.0f; } + /***************************************************************************************************/ -/************************************* Write Functions Template ************************************/ +/************************************* Write Functions Template + ************************************/ /***************************************************************************************************/ template -void BoardsCtrlMngt::eepromWrite(QByteArray& arr, quint32 addr, quint8 prbSel, T1* request, T2* status) +void BoardsCtrlMngt::eepromWrite(QByteArray& arr, + quint32 addr, + quint8 prbSel, + T1* request, + T2* status) { quint32 j(0); - bool busy=true, error=false, done=false; + bool busy = true, error = false, done = false; - foreach (auto i, arr) + foreach(auto i, arr) { - status->sync(); - busy = ((status->busy->getValue())!=0); + busy = ((status->busy->getValue()) != 0); timerShot(1); - while (busy) + while(busy) { status->sync(); - busy = ((status->busy->getValue())!=0); - if (checkTimeout()) + busy = ((status->busy->getValue()) != 0); + if(checkTimeout()) + { throw SonoException("Eeprom writing timeout is happened due to the I2C busy"); + } } timerStop(); - timerShot(5); // must be >= 4 - while (!checkTimeout()); + timerShot(5); //must be >= 4 + while(!checkTimeout()) + { + ; + } //_rom->dataIn = static_cast(i.toLatin1()); - _rom->dataIn = i; - _rom->address = addr+j; + _rom->dataIn = i; + _rom->address = addr + j; _rom->probeSelect = prbSel; setEepromWrite(_rom, request); j++; status->sync(); - done = ((status->reqDone->getValue())!=0); - error = ((status->reqError->getValue())!=0); + done = ((status->reqDone->getValue()) != 0); + error = ((status->reqError->getValue()) != 0); timerShot(1); - while (!error && !done) + while(!error && !done) { status->sync(); - done = ((status->reqDone->getValue())!=0); - error = ((status->reqError->getValue())!=0); - if (checkTimeout()) + done = ((status->reqDone->getValue()) != 0); + error = ((status->reqError->getValue()) != 0); + if(checkTimeout()) + { throw SonoException("Eeprom writing is corrupted due to the failure to receive done"); + } } timerStop(); - if (error) + if(error) + { throw SonoException("Eeprom writing is corrupted due to the error occurrence"); + } } } @@ -98,66 +112,75 @@ void BoardsCtrlMngt::setEepromWrite(EepromReq* _rom, T3* request) } /***************************************************************************************************/ -/************************************* Read Functions Template *************************************/ +/************************************* Read Functions Template + *************************************/ /***************************************************************************************************/ template -QByteArray BoardsCtrlMngt::eepromRead(quint32 addr, quint32 length, quint8 prbSel, T4 *request, T5 *status) +QByteArray BoardsCtrlMngt::eepromRead(quint32 addr, + quint32 length, + quint8 prbSel, + T4* request, + T5* status) { - bool busy=true, error=false, done=false; + bool busy = true, error = false, done = false; QByteArray rdArray; rdArray.clear(); - for (quint32 i(0); isync(); - busy = ((status->busy->getValue())!=0); + busy = ((status->busy->getValue()) != 0); timerShot(1); - while (busy) + while(busy) { status->sync(); - busy = ((status->busy->getValue())!=0); - if (checkTimeout()) + busy = ((status->busy->getValue()) != 0); + if(checkTimeout()) + { throw SonoException("Eeprom reading timeout is happened due to the I2C busy"); + } } timerStop(); - _rom->address = addr+i; + _rom->address = addr + i; _rom->probeSelect = prbSel; setEepromRead(_rom, request); status->sync(); - done = ((status->reqDone->getValue())!=0); - error = ((status->reqError->getValue())!=0); + done = ((status->reqDone->getValue()) != 0); + error = ((status->reqError->getValue()) != 0); timerShot(1); - while (!error && !done) + while(!error && !done) { status->sync(); - done = ((status->reqDone->getValue())!=0); - error = ((status->reqError->getValue())!=0); - if (checkTimeout()) + done = ((status->reqDone->getValue()) != 0); + error = ((status->reqError->getValue()) != 0); + if(checkTimeout()) + { throw SonoException("Eeprom reading is corrupted due to the failure to receive done"); + } } timerStop(); - if (error) + if(error) + { throw SonoException("Eeprom reading is corrupted due to the error occurrence"); + } rdArray.append(static_cast(status->dataOut->getValue())); - } return rdArray; } template -void BoardsCtrlMngt::setEepromRead(BoardsCtrlMngt::EepromReq *_rom, T6 *request) +void BoardsCtrlMngt::setEepromRead(BoardsCtrlMngt::EepromReq* _rom, T6* request) { request->address->setValue(_rom->address); request->prbSel->setValue(_rom->probeSelect); @@ -172,7 +195,8 @@ void BoardsCtrlMngt::setEepromRead(BoardsCtrlMngt::EepromReq *_rom, T6 *request) /***************************************************************************************************/ float BoardsCtrlMngt::resDiv(float r1, float r2, quint32 adcValue) { - float result = (static_cast(adcValue)) * (r1+r2)/(r2*1000); + float result = (static_cast(adcValue)) * (r1 + r2) / (r2 * 1000); + return result; } @@ -180,101 +204,127 @@ QVector BoardsCtrlMngt::voltPg(float adcVolt) { QVector pgVec; pgVec.clear(); - pgVec.append(adcVolt * (95.0f/100.0f)); - pgVec.append(adcVolt * (105.0f/100.0f)); + pgVec.append(adcVolt * (95.0f / 100.0f)); + pgVec.append(adcVolt * (105.0f / 100.0f)); + return pgVec; } float BoardsCtrlMngt::getCWdpValue() const { _sRbCwdp->sync(); - auto adcValue=_sRbCwdp->cwdpAvgValue->getValue(); - auto cwdpValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.cwd*_gn.cwd; + auto adcValue = _sRbCwdp->cwdpAvgValue->getValue(); + auto cwdpValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.cwd * _gn.cwd; + return cwdpValue; } float BoardsCtrlMngt::getCurr24vValue() const { _sRbCurr24V->sync(); - auto adcValue=_sRbCurr24V->currentP24vAvgValue->getValue(); - auto curr24vValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.curP24v*_gn.curP24v; + auto adcValue = _sRbCurr24V->currentP24vAvgValue->getValue(); + auto curr24vValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.curP24v * _gn.curP24v; + return curr24vValue; } float BoardsCtrlMngt::getHVapValue() const { _sRbHvap->sync(); - auto adcValue=_sRbHvap->hvapAvgValue->getValue(); - auto hvapValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.hva*_gn.hva; + auto adcValue = _sRbHvap->hvapAvgValue->getValue(); + auto hvapValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.hva * _gn.hva; + return hvapValue; } float BoardsCtrlMngt::getHVbpValue() const { _sRbHvbp->sync(); - auto adcValue=_sRbHvbp->hvbpAvgValue->getValue(); - auto hvbpValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.hvb*_gn.hvb; + auto adcValue = _sRbHvbp->hvbpAvgValue->getValue(); + auto hvbpValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.hvb * _gn.hvb; + return hvbpValue; } float BoardsCtrlMngt::getHvStopValue() const { _sRbHvStop->sync(); - auto adcValue=_sRbHvStop->hvStopAvgValue->getValue(); - auto hvStopValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.hvStop*_gn.hvStop; + auto adcValue = _sRbHvStop->hvStopAvgValue->getValue(); + auto hvStopValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.hvStop * _gn.hvStop; + return hvStopValue; } float BoardsCtrlMngt::getM5vValue() const { _sRbM5V->sync(); - auto adcValue=_sRbM5V->m5vAvgValue->getValue(); - auto m5vValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.m5v*_gn.m5v; + auto adcValue = _sRbM5V->m5vAvgValue->getValue(); + auto m5vValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.m5v * _gn.m5v; + return m5vValue; } float BoardsCtrlMngt::getP12vValue() const { _sRbP12V->sync(); - auto adcValue=_sRbP12V->p12vAvgValue->getValue(); - auto p12vValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.p12v*_gn.p12v; + auto adcValue = _sRbP12V->p12vAvgValue->getValue(); + auto p12vValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.p12v * _gn.p12v; + return p12vValue; } float BoardsCtrlMngt::getP24vValue() const { _sRbP24V->sync(); - auto adcValue=_sRbP24V->p24vAvgValue->getValue(); - auto p24vValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.p24v*_gn.p24v; + auto adcValue = _sRbP24V->p24vAvgValue->getValue(); + auto p24vValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.p24v * _gn.p24v; + return p24vValue; } float BoardsCtrlMngt::getP4dValue() const { _sRbP4D->sync(); - auto adcValue=_sRbP4D->p4dAvgValue->getValue(); - auto p4dValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.p4d*_gn.p4d; + auto adcValue = _sRbP4D->p4dAvgValue->getValue(); + auto p4dValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.p4d * _gn.p4d; + return p4dValue; } float BoardsCtrlMngt::getP5vValue() const { _sRbP5V->sync(); - auto adcValue=_sRbP5V->p5vAvgValue->getValue(); - auto p5vValue= ((static_cast(adcValue))/SUPERVISOR_RB_RESOLUTION)*SUPERVISOR_RB_V_REF*_af.p5v*_gn.p5v; + auto adcValue = _sRbP5V->p5vAvgValue->getValue(); + auto p5vValue = ((static_cast(adcValue)) / SUPERVISOR_RB_RESOLUTION) * + SUPERVISOR_RB_V_REF * _af.p5v * _gn.p5v; + return p5vValue; } - void BoardsCtrlMngt::setReadbackCmd(bool stopWr, bool avgValue, bool roundRobinConfig) const { - quint32 stopWrValue=0, avgValueValue=0, roundRobinConfigValue=0; - if (avgValue) - avgValueValue=1; - if (roundRobinConfig) - roundRobinConfigValue=1; - if (stopWr) - stopWrValue=1; + quint32 stopWrValue = 0, avgValueValue = 0, roundRobinConfigValue = 0; + if(avgValue) + { + avgValueValue = 1; + } + if(roundRobinConfig) + { + roundRobinConfigValue = 1; + } + if(stopWr) + { + stopWrValue = 1; + } _sRbCmd->roundRobinConfig->setValue(roundRobinConfigValue); _sRbCmd->averageValueRdReq->setValue(avgValueValue); _sRbCmd->resetStopWr->setValue(stopWrValue); @@ -284,61 +334,84 @@ void BoardsCtrlMngt::setReadbackCmd(bool stopWr, bool avgValue, bool roundRobinC bool BoardsCtrlMngt::getI2cCmdErr() const { _sI2cStatus->sync(); - auto status =_sI2cStatus->cmdError->getValue(); - return (status!=0); + auto status = _sI2cStatus->cmdError->getValue(); + + return (status != 0); } bool BoardsCtrlMngt::getI2cCmdDone() const { _sI2cStatus->sync(); - auto status =_sI2cStatus->cmdDone->getValue(); - return (status!=0); + auto status = _sI2cStatus->cmdDone->getValue(); + + return (status != 0); } bool BoardsCtrlMngt::getI2cBusy() const { _sI2cStatus->sync(); - auto status =_sI2cStatus->busy->getValue(); - return (status!=0); + auto status = _sI2cStatus->busy->getValue(); + + return (status != 0); } void BoardsCtrlMngt::getSupervisorI2cTimeout() const { timerShot(1); - while (getI2cBusy()) { - if (checkTimeout()) + while(getI2cBusy()) + { + if(checkTimeout()) + { throw SonoException("Supervisor request timeout is happened due to the MPS I2C busy"); + } } timerStop(); } void BoardsCtrlMngt::getSupervisorI2cDone() const { - timerShot(12); // must be >= 11 - while (!getI2cCmdDone() && !getI2cCmdErr()){ - if (checkTimeout()) - throw SonoException("Supervisor request is corrupted due to the failure to receive MPS I2C done"); + timerShot(15); //must be >= 11 + while(!getI2cCmdDone() && !getI2cCmdErr()) + { + if(checkTimeout()) + { + throw SonoException( + "Supervisor request is corrupted due to the failure to receive MPS I2C done"); + } } timerStop(); - if (getI2cCmdErr()) + if(getI2cCmdErr()) + { throw SonoException("Supervisor request is corrupted due to the MPS I2C error occurrence"); + } +} + +bool BoardsCtrlMngt::getSetupCmdP24vOnOff() const +{ + _sSetupCmd->sync(); + + return ((_sSetupCmd->p24vOnOff->getValue()) != 0); } void BoardsCtrlMngt::setSetupCmdP24vOnOff(bool p24vOnOff) const { - quint32 p24vOnOffValue=0; - if (p24vOnOff) - p24vOnOffValue=1; + quint32 p24vOnOffValue = 0; + if(p24vOnOff) + { + p24vOnOffValue = 1; + } _sSetupCmd->p24vOnOff->setValue(p24vOnOffValue); _sSetupCmd->update(); } void BoardsCtrlMngt::setSetupCmdJmp(bool jmpDacCmd) const { - quint32 jmpDacCmdValue=0; - if (jmpDacCmd) - jmpDacCmdValue=1; + quint32 jmpDacCmdValue = 0; + if(jmpDacCmd) + { + jmpDacCmdValue = 1; + } _sSetupCmd->jmpCmd->setValue(jmpDacCmdValue); _sSetupCmd->update(); } @@ -346,36 +419,48 @@ void BoardsCtrlMngt::setSetupCmdJmp(bool jmpDacCmd) const void BoardsCtrlMngt::setSetupCmdDacsOnOff(bool cwd, bool hvb, bool hva) const { quint32 cwdValue(0), hvbValue(0), hvaValue(0); - if (cwd) - cwdValue=1; + if(cwd) + { + cwdValue = 1; + } _sSetupCmd->cwdOnOff->setValue(cwdValue); - if (hvb) - hvbValue=1; + if(hvb) + { + hvbValue = 1; + } _sSetupCmd->hvbOnOff->setValue(hvbValue); - if (hva) - hvaValue=1; + if(hva) + { + hvaValue = 1; + } _sSetupCmd->hvaOnOff->setValue(hvaValue); _sSetupCmd->update(); } -void BoardsCtrlMngt::setMpsDacsValue(BoardsCtrlMngt::MpsDacs *_mpsDacs) const +void BoardsCtrlMngt::setPwrDacsValid(bool pwrValid) const +{ + quint32 valid = pwrValid ? 1 : 0; + _sSetupCmd->pwrDacValid->setValue(valid); + _sSetupCmd->update(); +} + +void BoardsCtrlMngt::setMpsDacsValue(BoardsCtrlMngt::MpsDacs* _mpsDacs) const { quint32 value(0); _sDacValue->dacsValueValid->setValue(1); - value=static_cast(((_mpsDacs->cwdValue)-CWD_Offset)*CWD_GAIN); + value = static_cast(((_mpsDacs->cwdValue) - CWD_Offset) * CWD_GAIN); _sDacValue->cwdValue->setValue(value); - value=static_cast(((_mpsDacs->hvbValue)-HVB_Offset)*HVB_GAIN); + value = static_cast(((_mpsDacs->hvbValue) - HVB_Offset) * HVB_GAIN); _sDacValue->hvbValue->setValue(value); - value=static_cast(((_mpsDacs->hvaValue)-HVA_Offset)*HVA_GAIN); + value = static_cast(((_mpsDacs->hvaValue) - HVA_Offset) * HVA_GAIN); _sDacValue->hvaValue->setValue(value); _sDacValue->update(); _sDacValue->dacsValueValid->setValue(0); _sDacValue->update(); } - void BoardsCtrlMngt::timerShot(quint16 ms) const { //_timer->singleShot(ms, this, SLOT(checkTimerShot)); @@ -386,7 +471,7 @@ void BoardsCtrlMngt::timerShot(quint16 ms) const bool BoardsCtrlMngt::checkTimeout() const { - return (_timer->remainingTime()==0) ? true : false; + return (_timer->remainingTime() == 0) ? true : false; } void BoardsCtrlMngt::timerStop() const @@ -394,11 +479,11 @@ void BoardsCtrlMngt::timerStop() const _timer->stop(); } - quint32 BoardsCtrlMngt::getPid() const { this->_pcie->sync(); auto pid = this->_pcie->pid->getValue(); + return pid; } @@ -406,6 +491,7 @@ quint32 BoardsCtrlMngt::getVid() const { this->_pcie->sync(); auto vid = this->_pcie->vid->getValue(); + return vid; } @@ -414,10 +500,11 @@ QVector BoardsCtrlMngt::getConnectedPrb() const QVector vec; vec.clear(); this->_pStatus->sync(); - vec.append((this->_pStatus->probeADetection->getValue())==0); // active low - vec.append((this->_pStatus->probeBDetection->getValue())==0); // active low - vec.append((this->_pStatus->probeCDetection->getValue())==0); // active low - vec.append((this->_pStatus->probeDDetection->getValue())==0); // active low + vec.append((this->_pStatus->probeADetection->getValue()) == 0); //active low + vec.append((this->_pStatus->probeBDetection->getValue()) == 0); //active low + vec.append((this->_pStatus->probeCDetection->getValue()) == 0); //active low + vec.append((this->_pStatus->probeDDetection->getValue()) == 0); //active low + return vec; } @@ -439,11 +526,11 @@ void BoardsCtrlMngt::prbCtrlInit() const this->_pCmd->update(); } - float BoardsCtrlMngt::getTrxTempSensor() const { this->_tempSensor->sync(); qint32 temp = static_cast(this->_tempSensor->temperature->getValue()); + return (temp * TEMP_SENSOR_RESOLUTION); } @@ -455,138 +542,141 @@ void BoardsCtrlMngt::getTrxBoardVoltages(AdcVoltages* adc, VoltagesPg* pg) this->_adc3P3V->sync(); value = this->_adc3P3V->channel5Mon->getValue(); - voltValue = resDiv(51.0f,100000.0f,value); + voltValue = resDiv(51.0f, 100000.0f, value); adc->mon3P3V = voltValue; - pgVec= voltPg(3.3f); + pgVec = voltPg(3.3f); pg->mon3P3V = (voltValue >= pgVec.at(0) && voltValue <= pgVec.at(1)) ? good : bad; this->_adc5Vin->sync(); value = this->_adc5Vin->channel1Mon->getValue(); - voltValue = resDiv(1.2f,2.0f,value); + voltValue = resDiv(1.2f, 2.0f, value); adc->mon5Vin = voltValue; - pgVec= voltPg(5.0f); + pgVec = voltPg(5.0f); pg->mon5Vin = (voltValue >= pgVec.at(0) && voltValue <= pgVec.at(1)) ? good : bad; this->_adc12Vin->sync(); value = this->_adc12Vin->channel0Mon->getValue(); voltValue = resDiv(30.0f, 10.0f, value); adc->mon12Vin = voltValue; - pgVec= voltPg(12.0f); + pgVec = voltPg(12.0f); pg->mon12Vin = (voltValue >= pgVec.at(0) && voltValue <= pgVec.at(1)) ? good : bad; this->_adcA1P8V->sync(); value = this->_adcA1P8V->channel6Mon->getValue(); - voltValue = resDiv(51.0f,100000.0f,value); + voltValue = resDiv(51.0f, 100000.0f, value); adc->monAfeA1P8V = voltValue; - pgVec= voltPg(1.8f); + pgVec = voltPg(1.8f); pg->monAfeA1P8V = (voltValue >= pgVec.at(0) && voltValue <= pgVec.at(1)) ? good : bad; this->_adcD1P8V->sync(); value = this->_adcD1P8V->channel7Mon->getValue(); - voltValue = resDiv(51.0f,100000.0f,value); + voltValue = resDiv(51.0f, 100000.0f, value); adc->monAfeD1P8V = voltValue; - pgVec= voltPg(1.8f); + pgVec = voltPg(1.8f); pg->monAfeD1P8V = (voltValue >= pgVec.at(0) && voltValue <= pgVec.at(1)) ? good : bad; this->_adcVcntlp->sync(); value = this->_adcVcntlp->channel4Mon->getValue(); - float vcntlp = resDiv(0.0f,100.0f,value); - // Assumptions for Gain Vs. VCNTLP curve: - // first_point=(0,42) , second_point=(1.2,2.5) - if (vcntlp <= 1.2f) - adc->afeVcntlp = (((-39.5f) / 1.2f) * vcntlp ) + 42; + float vcntlp = resDiv(0.0f, 100.0f, value); + //Assumptions for Gain Vs. VCNTLP curve: + //first_point=(0,42) , second_point=(1.2,2.5) + if(vcntlp <= 1.2f) + { + adc->afeVcntlp = (((-39.5f) / 1.2f) * vcntlp) + 42; + } else + { adc->afeVcntlp = 2.5f; - + } this->_adcPrb3P3V->sync(); value = this->_adcPrb3P3V->channel3Mon->getValue(); - voltValue = resDiv(47.0f,47.0f,value); + voltValue = resDiv(47.0f, 47.0f, value); adc->prbCtrl3P3V = voltValue; - pgVec= voltPg(3.3f); + pgVec = voltPg(3.3f); pg->prbCtrl3P3V = (voltValue >= pgVec.at(0) && voltValue <= pgVec.at(1)) ? good : bad; this->_adcPrbEncoder->sync(); value = this->_adcPrbEncoder->channel2Mon->getValue(); - adc->prbZeroEncoder = resDiv(47.0f,47.0f,value); + adc->prbZeroEncoder = resDiv(47.0f, 47.0f, value); } void BoardsCtrlMngt::getTrxVoltagesPg(VoltagesPg* pg) { this->_tRgltorPg->sync(); - pg->regulatorA = ((this->_tRgltorPg->regA->getValue())!=0) ? good : bad; - pg->regulatorB = ((this->_tRgltorPg->regB->getValue())!=0) ? good : bad; + pg->regulatorA = ((this->_tRgltorPg->regA->getValue()) != 0) ? good : bad; + pg->regulatorB = ((this->_tRgltorPg->regB->getValue()) != 0) ? good : bad; } - -void BoardsCtrlMngt::getSupervisorValue(SupervisorRbValue *sValue) const +void BoardsCtrlMngt::getSupervisorValue(SupervisorRbValue* sValue) const { - getSupervisorI2cTimeout(); - setReadbackCmd(false, false, true); // roundRobin_pulse + setReadbackCmd(false, false, true); //roundRobin_pulse setReadbackCmd(false, false, false); getSupervisorI2cDone(); timerShot(72); - while (!checkTimeout()); + while(!checkTimeout()) + { + ; + } getSupervisorI2cTimeout(); - setReadbackCmd(false, true, false); // avgValueCommand_pulse + setReadbackCmd(false, true, false); //avgValueCommand_pulse setReadbackCmd(false, false, false); getSupervisorI2cDone(); getSupervisorI2cTimeout(); - setReadbackCmd(true, false, false); // resetStopWrite + setReadbackCmd(true, false, false); //resetStopWrite setReadbackCmd(false, false, false); getSupervisorI2cDone(); - sValue->m5V = getM5vValue(); - sValue->p4D = getP4dValue(); - sValue->p5V = getP5vValue(); - sValue->cwdp = getCWdpValue(); - sValue->hvap = getHVapValue(); - sValue->hvbp = getHVbpValue(); - sValue->p12V = getP12vValue(); - sValue->p24V = getP24vValue(); - sValue->hvStop = getHvStopValue(); + sValue->m5V = getM5vValue(); + sValue->p4D = getP4dValue(); + sValue->p5V = getP5vValue(); + sValue->cwdp = getCWdpValue(); + sValue->hvap = getHVapValue(); + sValue->hvbp = getHVbpValue(); + sValue->p12V = getP12vValue(); + sValue->p24V = getP24vValue(); + sValue->hvStop = getHvStopValue(); sValue->curr24V = getCurr24vValue(); - } void BoardsCtrlMngt::getMpsFault(MpsFaultStatus* faultStatus) const { this->_sFaultStatus->sync(); - faultStatus->m5v = ((this->_sFaultStatus->m5v->getValue()) != 0); - faultStatus->p5v = ((this->_sFaultStatus->p5v->getValue()) != 0); - faultStatus->cwdp = ((this->_sFaultStatus->cwd->getValue()) != 0); - faultStatus->hvap = ((this->_sFaultStatus->hva->getValue()) != 0); - faultStatus->hvbp = ((this->_sFaultStatus->hvb->getValue()) != 0); - faultStatus->p12v = ((this->_sFaultStatus->p12v->getValue()) != 0); - faultStatus->p24v = ((this->_sFaultStatus->p24v->getValue()) != 0); - faultStatus->sup4d = ((this->_sFaultStatus->sup4d->getValue()) != 0); - faultStatus->curr24V = ((this->_sFaultStatus->cur24v->getValue()) != 0); - faultStatus->hvError = ((this->_sFaultStatus->hvError->getValue()) != 0); - - faultStatus->overM5v = ((this->_sFaultStatus->overM5v->getValue()) != 0); - faultStatus->overP5v = ((this->_sFaultStatus->overP5v->getValue()) != 0); - faultStatus->overCwdp = ((this->_sFaultStatus->overCwd->getValue()) != 0); - faultStatus->overHvap = ((this->_sFaultStatus->overHva->getValue()) != 0); - faultStatus->overHvbp = ((this->_sFaultStatus->overHvb->getValue()) != 0); - faultStatus->overP12v = ((this->_sFaultStatus->overP12v->getValue()) != 0); - faultStatus->overP24v = ((this->_sFaultStatus->overP24v->getValue()) != 0); - faultStatus->overSup4d = ((this->_sFaultStatus->overSup4d->getValue()) != 0); - faultStatus->overCurr24V = ((this->_sFaultStatus->overCur24v->getValue()) != 0); - faultStatus->overHvError = ((this->_sFaultStatus->overHvError->getValue()) != 0); - - faultStatus->underM5v = ((this->_sFaultStatus->underM5v->getValue()) != 0); - faultStatus->underP5v = ((this->_sFaultStatus->underP5v->getValue()) != 0); - faultStatus->underCwdp = ((this->_sFaultStatus->underCwd->getValue()) != 0); - faultStatus->underHvap = ((this->_sFaultStatus->underHva->getValue()) != 0); - faultStatus->underHvbp = ((this->_sFaultStatus->underHvb->getValue()) != 0); - faultStatus->underP12v = ((this->_sFaultStatus->underP12v->getValue()) != 0); - faultStatus->underP24v = ((this->_sFaultStatus->underP24v->getValue()) != 0); - faultStatus->underSup4d = ((this->_sFaultStatus->underSup4d->getValue()) != 0); + faultStatus->m5v = ((this->_sFaultStatus->m5v->getValue()) != 0); + faultStatus->p5v = ((this->_sFaultStatus->p5v->getValue()) != 0); + faultStatus->cwdp = ((this->_sFaultStatus->cwd->getValue()) != 0); + faultStatus->hvap = ((this->_sFaultStatus->hva->getValue()) != 0); + faultStatus->hvbp = ((this->_sFaultStatus->hvb->getValue()) != 0); + faultStatus->p12v = ((this->_sFaultStatus->p12v->getValue()) != 0); + faultStatus->p24v = ((this->_sFaultStatus->p24v->getValue()) != 0); + faultStatus->sup4d = ((this->_sFaultStatus->sup4d->getValue()) != 0); + faultStatus->curr24V = ((this->_sFaultStatus->cur24v->getValue()) != 0); + faultStatus->hvError = ((this->_sFaultStatus->hvError->getValue()) != 0); + + faultStatus->overM5v = ((this->_sFaultStatus->overM5v->getValue()) != 0); + faultStatus->overP5v = ((this->_sFaultStatus->overP5v->getValue()) != 0); + faultStatus->overCwdp = ((this->_sFaultStatus->overCwd->getValue()) != 0); + faultStatus->overHvap = ((this->_sFaultStatus->overHva->getValue()) != 0); + faultStatus->overHvbp = ((this->_sFaultStatus->overHvb->getValue()) != 0); + faultStatus->overP12v = ((this->_sFaultStatus->overP12v->getValue()) != 0); + faultStatus->overP24v = ((this->_sFaultStatus->overP24v->getValue()) != 0); + faultStatus->overSup4d = ((this->_sFaultStatus->overSup4d->getValue()) != 0); + faultStatus->overCurr24V = ((this->_sFaultStatus->overCur24v->getValue()) != 0); + faultStatus->overHvError = ((this->_sFaultStatus->overHvError->getValue()) != 0); + + faultStatus->underM5v = ((this->_sFaultStatus->underM5v->getValue()) != 0); + faultStatus->underP5v = ((this->_sFaultStatus->underP5v->getValue()) != 0); + faultStatus->underCwdp = ((this->_sFaultStatus->underCwd->getValue()) != 0); + faultStatus->underHvap = ((this->_sFaultStatus->underHva->getValue()) != 0); + faultStatus->underHvbp = ((this->_sFaultStatus->underHvb->getValue()) != 0); + faultStatus->underP12v = ((this->_sFaultStatus->underP12v->getValue()) != 0); + faultStatus->underP24v = ((this->_sFaultStatus->underP24v->getValue()) != 0); + faultStatus->underSup4d = ((this->_sFaultStatus->underSup4d->getValue()) != 0); faultStatus->underCurr24V = ((this->_sFaultStatus->underCur24v->getValue()) != 0); faultStatus->underHvError = ((this->_sFaultStatus->underHvError->getValue()) != 0); } @@ -607,9 +697,12 @@ void BoardsCtrlMngt::mpsDeInit() const void BoardsCtrlMngt::setMpsReset() const { - getSupervisorI2cTimeout(); - setSetupCmdP24vOnOff(false); - getSupervisorI2cDone(); + if(getSetupCmdP24vOnOff()) + { + getSupervisorI2cTimeout(); + setSetupCmdP24vOnOff(false); + getSupervisorI2cDone(); + } getSupervisorI2cTimeout(); setSetupCmdJmp(true); @@ -621,6 +714,9 @@ void BoardsCtrlMngt::mpsDacsOff() const { getSupervisorI2cTimeout(); setSetupCmdDacsOnOff(false, false, false); + setPwrDacsValid(false); + setPwrDacsValid(true); + setPwrDacsValid(false); getSupervisorI2cDone(); } @@ -628,14 +724,18 @@ void BoardsCtrlMngt::mpsDacsOn() const { getSupervisorI2cTimeout(); setSetupCmdDacsOnOff(false, true, true); + setPwrDacsValid(false); + setPwrDacsValid(true); + setPwrDacsValid(false); getSupervisorI2cDone(); } -void BoardsCtrlMngt::mpsHvSet(float &hva, float &hvb) const +void BoardsCtrlMngt::mpsHvSet(float& hva, float& hvb) const { - if (hva > hvb && hva <= HVA_MAX_VALUE) + if(hva > hvb && hva <= HVA_MAX_VALUE) { - if (hva > 3.3f){ + if(hva > 3.3f) + { _mpsDacs->cwdValue = 0.0f; _mpsDacs->hvaValue = 3.3f; _mpsDacs->hvbValue = 1.53f; @@ -648,85 +748,132 @@ void BoardsCtrlMngt::mpsHvSet(float &hva, float &hvb) const } getSupervisorI2cTimeout(); - setMpsDacsValue (_mpsDacs); + setMpsDacsValue(_mpsDacs); getSupervisorI2cDone(); } else + { throw SonoException("A and B voltage are out of range"); - + } } - - QByteArray BoardsCtrlMngt::trxEepromRead(quint32 address, quint32 length) { - if (address + length >= TRX_ROM_MAX_LEN) + if(address + length >= TRX_ROM_MAX_LEN) + { throw SonoException("Out of range reading from TRX eeprom "); + } quint8 prbSel = 0; - return eepromRead(address, length, prbSel, _tRomReq, _tRomStatus); + + return eepromRead(address, + length, + prbSel, + _tRomReq, + _tRomStatus); } QByteArray BoardsCtrlMngt::mpsEepromRead(quint32 address, quint32 length) { - if (address + length >= MPS_ROM_MAX_LEN) + if(address + length >= MPS_ROM_MAX_LEN) + { throw SonoException("Out of range reading from MPS eeprom "); + } quint8 prbSel = 0; - return eepromRead(address, length, prbSel, _mRomReq, _mRomStatus); + + return eepromRead(address, + length, + prbSel, + _mRomReq, + _mRomStatus); } QByteArray BoardsCtrlMngt::prbCtrlEepromRead(quint32 address, quint32 length) { - if (address + length >= PRB_CTRL_ROM_MAX_LEN) + if(address + length >= PRB_CTRL_ROM_MAX_LEN) + { throw SonoException("Out of range reading from Probe Control eeprom "); + } quint8 prbSel = 0; - return eepromRead(address, length, prbSel, _pCtrlRomReq, _pCtrlRomStatus); + + return eepromRead(address, + length, + prbSel, + _pCtrlRomReq, + _pCtrlRomStatus); } QByteArray BoardsCtrlMngt::prbEepromRead(quint32 address, quint32 length, quint8 prbSel) { - if (address + length >= PRB_ROM_MAX_LEN) + if(address + length >= PRB_ROM_MAX_LEN) + { throw SonoException("Out of range reading from Probe eeprom "); + } - return eepromRead(address, length, prbSel, _pRomReq, _pRomStatus); + return eepromRead(address, + length, + prbSel, + _pRomReq, + _pRomStatus); } - void trxEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt* boards) { - if (arr.size() >= static_cast(TRX_ROM_MAX_LEN)) + if(arr.size() >= static_cast(TRX_ROM_MAX_LEN)) + { throw SonoException("Out of range writing into TRX eeprom "); + } quint8 prbSel = 0; - boards->eepromWrite(arr, address, prbSel, boards->_tRomReq, boards->_tRomStatus); + boards->eepromWrite(arr, + address, + prbSel, + boards->_tRomReq, + boards->_tRomStatus); } -void mpsEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt *boards) +void mpsEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt* boards) { - if (arr.size() >= static_cast(MPS_ROM_MAX_LEN)) + if(arr.size() >= static_cast(MPS_ROM_MAX_LEN)) + { throw SonoException("Out of range writing into MPS eeprom "); + } quint8 prbSel = 0; - boards->eepromWrite(arr, address, prbSel, boards->_mRomReq, boards->_mRomStatus); + boards->eepromWrite(arr, + address, + prbSel, + boards->_mRomReq, + boards->_mRomStatus); } -void prbCtrlEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt *boards) +void prbCtrlEepromWrite(QByteArray arr, quint32 address, BoardsCtrlMngt* boards) { - if (arr.size() >= static_cast(PRB_CTRL_ROM_MAX_LEN)) + if(arr.size() >= static_cast(PRB_CTRL_ROM_MAX_LEN)) + { throw SonoException("Out of range writing into Probe Control eeprom "); + } quint8 prbSel = 0; - boards->eepromWrite(arr, address, prbSel, boards->_pCtrlRomReq, boards->_pCtrlRomStatus); + boards->eepromWrite(arr, + address, + prbSel, + boards->_pCtrlRomReq, + boards->_pCtrlRomStatus); } -void prbEepromWrite(QByteArray arr, quint32 address, quint8 prbSel, BoardsCtrlMngt *boards) +void prbEepromWrite(QByteArray arr, quint32 address, quint8 prbSel, BoardsCtrlMngt* boards) { - if (arr.size() >= static_cast(PRB_ROM_MAX_LEN)) + if(arr.size() >= static_cast(PRB_ROM_MAX_LEN)) + { throw SonoException("Out of range writing into Probe eeprom "); + } - boards->eepromWrite(arr, address, prbSel, boards->_pRomReq, boards->_pRomStatus); + boards->eepromWrite(arr, + address, + prbSel, + boards->_pRomReq, + boards->_pRomStatus); } - - diff --git a/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp b/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp index 6a95d73..d6bb8ef 100644 --- a/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp +++ b/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp @@ -3,23 +3,23 @@ void FpgaProgram::setSlaveFpgaNumber(quint8& number) const { _fpgaNumber->number->setValue(number); - _fpgaNumber->update(); + _fpgaNumber->update(); } FpgaProgram::FpgaProgram(SonoDevice* device) { - _status = new ProgramStatus(); + _status = new ProgramStatus(); _progData = new SerialProgramData(device); - _status->_progStatus = new SerialProgramStatus(device); - _fpgaNumber = new SlaveFpgaNumber(device); + _status->_progStatus = new SerialProgramStatus(device); + _fpgaNumber = new SlaveFpgaNumber(device); } FpgaProgram::~FpgaProgram() { delete _progData; - delete _status->_progStatus; - delete _fpgaNumber; - delete _status; + delete _status->_progStatus; + delete _fpgaNumber; + delete _status; } void FpgaProgram::program(QByteArray& bitFileData, quint8 number) @@ -27,63 +27,45 @@ void FpgaProgram::program(QByteArray& bitFileData, quint8 number) qint32 progByte(0); quint32 progData(0); QByteArray temp; + qint32 bitFileSize = bitFileData.size(); setSlaveFpgaNumber(number); -#ifdef DEVELOP_UI - QProgressDialog progress; - progress.setMinimumSize(300,100); - progress.setLabelText("Please wait..."); - progress.setWindowTitle("Slaves FPGA Programming"); - progress.setRange(0,bitFileData.size()); - progress.setModal(true); -#endif - - while(progByte < bitFileData.size()) + while(progByte < bitFileSize) { for(quint8 i(0); i < sizeof(quint32); i++) { - //temp.append(bitFileData.at(i+progByte)); assert size temp.append(bitFileData[i + progByte]); } - progData = byteArray2UintBigEndian(temp); + progData = byteArray2UintBigEndian(temp); _progData->slaveConfigData->setValue(progData); _progData->update(); while(_status->getProgramBusy()); - if(_status->getInitFail()) + if(_status->getInitFail()) { -//QString fail=""; -//if (_status->getFpgaS0InitB()) -//fail += "Slave0 FPGA "; - -//if (_status->getFpgaS1InitB()) -//fail += "Slave1 FPGA "; - -//if (_status->getFpgaS2InitB()) -//fail += "Slave2 FPGA "; throw SonoException("init fail happened"); } - if(_status->getProgramTimeout()) + if(_status->getProgramTimeout()) { throw SonoException( - "Timeout is happened and the programming of the slave FPGAs is failed"); + "Timeout is happened and the programming of the slave FPGAs is failed"); } + temp.clear(); + progByte += sizeof(quint32); + #ifdef DEVELOP_UI - progress.setValue(progByte); - if (progress.wasCanceled()) - throw SonoException("Slaves fpga programming is canceled"); + emit programmingProgress(progByte, bitFileSize); #endif - temp.clear(); - progByte += sizeof(quint32); + } while(!(_status->getProgramFail() || _status->getProgramDone())); - if(_status->getProgramFail()) + if(_status->getProgramFail()) { throw SonoException("programming was not successful"); } @@ -155,27 +137,3 @@ bool FpgaProgram::ProgramStatus::getFpgaS2InitB() const return (fpgaInitStatus != 0); } - -//bool FpgaProgram::ProgramStatus::getFpgaS0Done() -//{ -//_progStatus->sync(); -//auto fpgaDoneStatus=_progStatus->slaveFpgaDone->getValue(); -//fpgaDoneStatus&=FPGA_S0_DONE; -//return (fpgaDoneStatus!=0); -//} - -//bool FpgaProgram::ProgramStatus::getFpgaS1Done() -//{ -//_progStatus->sync(); -//auto fpgaDoneStatus=_progStatus->slaveFpgaDone->getValue(); -//fpgaDoneStatus&=FPGA_S1_DONE; -//return (fpgaDoneStatus!=0); -//} - -//bool FpgaProgram::ProgramStatus::getFpgaS2Done() -//{ -//_progStatus->sync(); -//auto fpgaDoneStatus=_progStatus->slaveFpgaDone->getValue(); -//fpgaDoneStatus&=FPGA_S2_DONE; -//return (fpgaDoneStatus!=0); -//} diff --git a/src/model/hardware/core/register/misc/Misc.cpp b/src/model/hardware/core/register/misc/Misc.cpp index 8485cfa..376ae4a 100644 --- a/src/model/hardware/core/register/misc/Misc.cpp +++ b/src/model/hardware/core/register/misc/Misc.cpp @@ -2,13 +2,14 @@ Misc::Misc(SonoDevice *device) : _offsetMaster(0), _offsetSlave0(0x50002C), _offsetSlave1(0x90002C), _offsetSlave2(0xD0002C) { - _s0Version = new FpgaVersion (device, _offsetSlave0); - _s1Version = new FpgaVersion (device, _offsetSlave1); - _s2Version = new FpgaVersion (device, _offsetSlave2); - _mVersion = new FpgaVersion (device, _offsetMaster); - _status = new StatusVector (device); - _gt = new GtSendMode (device); - _sync = new SyncMode (device); + _s0Version = new FpgaVersion (device, _offsetSlave0); + _s1Version = new FpgaVersion (device, _offsetSlave1); + _s2Version = new FpgaVersion (device, _offsetSlave2); + _mVersion = new FpgaVersion (device, _offsetMaster); + _lostCount = new FrameLostCount (device); + _status = new StatusVector (device); + _sync = new SyncMode (device); + _gt = new GtSendMode (device); } Misc::~Misc() @@ -16,6 +17,7 @@ Misc::~Misc() delete _s0Version; delete _s1Version; delete _s2Version; + delete _lostCount; delete _mVersion; delete _status; delete _sync; @@ -34,19 +36,20 @@ void Misc::getStatusVector(StatusVec *status) const this->_status->sync(); status->pgErr = ((this->_status->pgErr->getValue()) != 0); - status->fanFault = ((this->_status->fanFault->getValue()) != 0); status->mpsErr = ((this->_status->mpsErr->getValue()) != 0); + status->fanFault = ((this->_status->fanFault->getValue()) != 0); + status->frameLost = ((this->_status->frameLost->getValue()) != 0); status->pulserThd = ((this->_status->pulserThd->getValue()) != 0); status->scenGtErr = ((this->_status->scenGtErr->getValue()) != 0); - status->syncFifoErr = ((this->_status->syncFifoErr->getValue()) != 0); status->scenPriErr = ((this->_status->scenPriErr->getValue()) != 0); - status->syncPointErr = ((this->_status->syncPointErr->getValue()) != 0); status->thermalErr = ((this->_status->thermalErr->getValue()) != 0); + status->syncFifoErr = ((this->_status->syncFifoErr->getValue()) != 0); status->scenSramErr = ((this->_status->scenSramErr->getValue()) != 0); + status->syncPointErr = ((this->_status->syncPointErr->getValue()) != 0); status->dintrlvFifoErr = ((this->_status->dintrlvFifoErr->getValue()) != 0); - status->dintrlvPointErr = ((this->_status->dintrlvPointErr->getValue()) != 0); status->sram1ParityErr = ((this->_status->sram1ParityErr->getValue()) != 0); status->sram2ParityErr = ((this->_status->sram2ParityErr->getValue()) != 0); + status->dintrlvPointErr = ((this->_status->dintrlvPointErr->getValue()) != 0); status->dmaCtrlTransferErr = ((this->_status->dmaCtrlTransferErr->getValue()) != 0); status->emulDmaTransferErr = ((this->_status->emulDmaTransferErr->getValue()) != 0); status->probeDisconnectErr = ((this->_status->probeDisconnectErr->getValue()) != 0); @@ -65,6 +68,19 @@ void Misc::setSyncMode(eSyncCtrl syncMode) const this->_sync->update(); } +void Misc::setManualSync(bool sync) const +{ + quint32 val = sync ? 1 : 0; + this->_sync->manualSync->setValue(val); + this->_sync->update(); +} + +quint32 Misc::getFrameLostCount() const +{ + this->_lostCount->sync(); + return (this->_lostCount->lostCount->getValue()); +} + void Misc::getFpgaVersion(FpgaCodeVersion *version) const { version->masterCode = this->getVersion(_mVersion);