diff --git a/developHw.pro.user b/developHw.pro.user index 1c2f4d3..9550037 100644 --- a/developHw.pro.user +++ b/developHw.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -69,7 +69,7 @@ 0 0 - /home/hasis/Desktop/Develop_HardwareTest/build-developHw-Desktop_Qt_5_13_1_GCC_64bit-Debug + /home/hasis/Desktop/hardware/Develop_HardwareTest/build-developHw-Desktop_Qt_5_13_1_GCC_64bit-Debug true @@ -304,8 +304,8 @@ 2 developHw - - Qt4ProjectManager.Qt4RunConfiguration:/home/hasis/Desktop/Develop_HardwareTest/developHw/developHw.pro + developHw2 + Qt4ProjectManager.Qt4RunConfiguration:/home/hasis/Desktop/hardware/Develop_HardwareTest/developHw/developHw.pro 3768 false @@ -315,7 +315,7 @@ false true - /home/hasis/Desktop/Develop_HardwareTest/build-developHw-Desktop_Qt_5_13_1_GCC_64bit-Debug + /home/hasis/Desktop/hardware/Develop_HardwareTest/build-developHw-Desktop_Qt_5_13_1_GCC_64bit-Debug 1 diff --git a/hdf5Scenario/hdf5Scenario.cpp b/hdf5Scenario/hdf5Scenario.cpp index efb649b..321e1d0 100644 --- a/hdf5Scenario/hdf5Scenario.cpp +++ b/hdf5Scenario/hdf5Scenario.cpp @@ -4,9 +4,10 @@ template void Hdf5::datasetBranch(const string &branchPath, T datasetValue[MAX_ARRAY_DEPTH]) { const H5std_string datasetPath(branchPath); - DataSet datasetType = _file.openDataSet(datasetPath); + DataSet datasetType = _file.openDataSet(datasetPath); datasetType.read(datasetValue, PredType::NATIVE_FLOAT, H5S_ALL, H5S_ALL); + datasetType.close(); } void Hdf5::hdf5Path(const string &h5Path) diff --git a/include/model/hardware/core/TrxBoard.h b/include/model/hardware/core/TrxBoard.h index a7ec2ac..594feb9 100644 --- a/include/model/hardware/core/TrxBoard.h +++ b/include/model/hardware/core/TrxBoard.h @@ -78,6 +78,9 @@ private: SonoDevice _device; AdcVoltages* _adc; VoltagesPg* _pg; + FanRpm* _tachoRpm; + criticalComponentVoltages* _coreVolt; + criticalComponentTemperature* _coreTemp; ClockDistributer* _clkDistributer; BeamFormer* _beamFormerSlave0; @@ -139,10 +142,10 @@ private: ~ScenGenHardwareParam(); } - * scenParams; + * _scenParams; void fpgaProgram(const QString path) const; - void setScenario(ScenGenHardwareParam* scenParams); + void setScenario(ScenGenHardwareParam* _scenParams); void sramClear (eSramClear clearMode); void setSwapVector(void); @@ -152,8 +155,12 @@ private: void scenParamsFilling(eScenParams cmd); //QList signedVector2unsignedList(QVector& sgnVec); +#ifndef DEVELOP_UI void afeAdcsSync(void) const; - +#endif + void waitForCaptureDone(Debug* _dbg) const; + void adcCaptureStop(Debug *_dbg) const; + void adcCaptureStart(Debug *_dbg) const; void adcLogTransferRoutine (Debug* _dbg, quint8 chNumPerFpga); void debuggerMode(Debug* _dbg, DebugMode& debug, DebugMode& debugRb, QString slaveN) const; @@ -174,6 +181,8 @@ public: #ifndef DEVELOP_UI HardwarePacketEngine packetEngine; +#else + void afeAdcsSync(void) const; #endif TrxBoard(); @@ -205,6 +214,8 @@ public: void setScenarioCompare (const QString scenPath); void setAtgcMode(eAtgcMode mode, quint16 value) const; QList getAfeReg(eSlaveSelect sel, quint32 afeRegAddr); + void setAdgCfg(eBiteDacOutput adg) const; + void setTxDacEnable(quint8 biteInterval, bool cmd) const; ////////////////////////////// Slave Programming API ////////////////////////// void slaveFpgaProgram(const QString path); @@ -255,8 +266,14 @@ public: quint32 getFrameLostCounter(void) const; ////////////////////////////////// Logger API ///////////////////////////////// - void adcCaptureStart(captureConfig &capCfg, eSyncMode syncMode); - void adcLoggerStart(const QString path); + void adcCaptureConfig(captureConfig &capCfg) const; + void adcCaptureStart(void) const; + void adcCaptureDone(void) const; + void setCaptureManualSync(void) const; + void adcLoggerStart(const QString path, const QString fileName); + void setDebuggerMode(eDebugMode bfMode, bool enable); + void setAfeConfig(AfeConfig& afeCfg) const; + void setAfePwr(eAfePwrdnMode pwrMode) const; /////////////////////////////// DMA Data Packet /////////////////////////////// void readData(); diff --git a/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h b/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h index ed2d061..2063672 100644 --- a/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h +++ b/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h @@ -2,6 +2,6 @@ #define PREPROCESSORDEF_H #define MPS_BOARD -#define DEVELOP_UI +//#define DEVELOP_UI #endif //PREPROCESSORDEF_H diff --git a/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h b/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h index 7ad2b43..769c129 100644 --- a/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h +++ b/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h @@ -23,9 +23,11 @@ struct ProbeElementPosition struct HealthStatus { float systemTemperature; - float criticalComponentTemperature; AdcVoltages* adcMon; VoltagesPg* voltsPg; + FanRpm* fanRpm; + criticalComponentTemperature* fpgaCoreTemperature; + criticalComponentVoltages* fpgaCoreVoltages; }; struct EepromStatus diff --git a/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h b/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h index 5c6cf88..e53aa64 100644 --- a/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h +++ b/include/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h @@ -16,7 +16,7 @@ #define SUPERVISOR_RB_RESOLUTION 65535 #define SUPERVISOR_RB_V_REF 2.048f -#define F_SYS_CLK 100000 //Dimension: KHz or 200MHz +#define F_SYS_CLK 1E8f //FPGAclk = 100MHz #define CWD_Offset 1.53f #define CWD_GAIN 47.065f #define HVA_Offset 1.525f @@ -106,6 +106,51 @@ struct MpsFaultStatus bool underP24v; }; +struct FpgaVccInt +{ + float master; + float slave0; + float slave1; + float slave2; +}; + +struct FpgaVccAux +{ + float master; + float slave0; + float slave1; + float slave2; +}; + +struct FpgaVccBram +{ + float master; + float slave0; + float slave1; + float slave2; +}; + +struct FanRpm +{ + float fan1; + float fan2; +}; + +struct criticalComponentVoltages +{ + FpgaVccInt vccInt; + FpgaVccAux vccAux; + FpgaVccBram vccBram; +}; + +struct criticalComponentTemperature +{ + float master; + float slave0; + float slave1; + float slave2; +}; + class BoardsCtrlMngt : private BoardsSpecs { private: @@ -175,8 +220,15 @@ private: template void setEepromRead(EepromReq* _rom, T6* request); + template + float fanTacho(T7* tachoMean); float resDiv(float r1, float r2, quint32 adcValue); QVector voltPg(float adcVolt); + float fpgaVoltage (quint32 coreVolt) const; + float fpgaTemp(FpgaXadc1 *coreTemp) const; + float fpgaVccInt(FpgaXadc1 *coreVccInt) const; + float fpgaVccAux(FpgaXadc2 *coreVccAux) const; + float fpgaVccBram(FpgaXadc2 *coreVccBram) const; float getCWdpValue(void) const; float getCurr24vValue(void) const; @@ -237,7 +289,6 @@ public: void prbCtrlInit(void) const; float getTrxTempSensor(void) const; - float getTrxFpgaTemp(void) const; void getTrxBoardVoltages(AdcVoltages* adc, VoltagesPg* pg); void getTrxVoltagesPg(VoltagesPg* pg); @@ -249,6 +300,11 @@ public: void mpsDacsOff(void) const; void mpsDacsOn(void) const; void mpsHvSet(float& hva, float& hvb) const; + void getFpgaTemp(criticalComponentTemperature *coreTemp); + void getFpgaVccInt(FpgaVccInt &coreVcc); + void getFpgaVccAux(FpgaVccAux &coreAux); + void getFpgaVccBram(FpgaVccBram &coreBram); + void getFanRpm(FanRpm* _rpm); QByteArray trxEepromRead(quint32 address, quint32 length); QByteArray mpsEepromRead(quint32 address, quint32 length); diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/BoardsSpecs.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/BoardsSpecs.h index 8db87d9..293c464 100644 --- a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/BoardsSpecs.h +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/BoardsSpecs.h @@ -25,6 +25,8 @@ #include "mps/MpsEepromRwReq.h" #include "mps/MpsHvStopState.h" #include "mps/FanStatus.h" +#include "mps/FanTacho1.h" +#include "mps/FanTacho2.h" //////////////// Prb Headers //////////////// #include "probe/PrbCtrlEepromRwStatus.h" @@ -44,6 +46,8 @@ #include "trx/AdcAfeVcntlp.h" #include "trx/AdcAfeA1P8V.h" #include "trx/AdcAfeD1P8V.h" +#include "trx/FpgaXadc1.h" +#include "trx/FpgaXadc2.h" #include "trx/Adc12Vin.h" #include "trx/Adc3P3V.h" #include "trx/Adc5Vin.h" @@ -51,6 +55,12 @@ class BoardsSpecs { +private: + const quint32 _offsetMXadc; + const quint32 _offsetS0Xadc; + const quint32 _offsetS1Xadc; + const quint32 _offsetS2Xadc; + protected: //////////////// MPS classes //////////////// SupervisorFaultStatus* _sFaultStatus; @@ -75,6 +85,8 @@ protected: SupervisorRwReq* _sRwReq; MpsEepromRwReq* _mRomReq; MpsHvStopState* _mHvStop; + FanTacho1* _fanTacho1; + FanTacho2* _fanTacho2; FanStatus* _fan; //////////////// Prb classes //////////////// @@ -96,11 +108,22 @@ protected: AdcAfeA1P8V* _adcA1P8V; AdcAfeD1P8V* _adcD1P8V; Adc12Vin* _adc12Vin; + FpgaXadc1* _s0Xadc1; + FpgaXadc1* _s1Xadc1; + FpgaXadc1* _s2Xadc1; + FpgaXadc1* _mXadc1; + FpgaXadc2* _s0Xadc2; + FpgaXadc2* _s1Xadc2; + FpgaXadc2* _s2Xadc2; + FpgaXadc2* _mXadc2; Adc3P3V* _adc3P3V; Adc5Vin* _adc5Vin; PcieId* _pcie; - explicit BoardsSpecs(SonoDevice* device) + explicit BoardsSpecs(SonoDevice* device) : _offsetMXadc (0), + _offsetS0Xadc(0x500034 - 0x260D4), + _offsetS1Xadc(0x900034 - 0x260D4), + _offsetS2Xadc(0xD00034 - 0x260D4) { ///////////////////// MPS Mem Alloc ///////////////////// _sFaultStatus = new SupervisorFaultStatus(device); @@ -125,6 +148,8 @@ protected: _sRwReq = new SupervisorRwReq(device); _mRomReq = new MpsEepromRwReq(device); _mHvStop = new MpsHvStopState(device); + _fanTacho1 = new FanTacho1(device); + _fanTacho2 = new FanTacho2(device); _fan = new FanStatus(device); ///////////////////// Prb Mem Alloc ///////////////////// @@ -136,6 +161,14 @@ protected: _pCmd = new PrbCtrlCmd(device); ///////////////////// TRX Mem Alloc ///////////////////// + _s0Xadc1 = new FpgaXadc1(device, _offsetS0Xadc); + _s1Xadc1 = new FpgaXadc1(device, _offsetS1Xadc); + _s2Xadc1 = new FpgaXadc1(device, _offsetS2Xadc); + _mXadc1 = new FpgaXadc1(device, _offsetMXadc); + _s0Xadc2 = new FpgaXadc2(device, _offsetS0Xadc); + _s1Xadc2 = new FpgaXadc2(device, _offsetS1Xadc); + _s2Xadc2 = new FpgaXadc2(device, _offsetS2Xadc); + _mXadc2 = new FpgaXadc2(device, _offsetMXadc); _adcPrbEncoder = new AdcPrbZeroEncoder(device); _tempSensor = new OnBoardTempSensor(device); _tRomStatus = new TrxEepromRwStatus(device); @@ -176,6 +209,8 @@ protected: delete _sRwReq; delete _mRomReq; delete _mHvStop; + delete _fanTacho1; + delete _fanTacho2; delete _fan; //// Prb Mem delete //// @@ -199,7 +234,15 @@ protected: delete _adc12Vin; delete _adc3P3V; delete _adc5Vin; - delete _pcie; + delete _s0Xadc1; + delete _s1Xadc1; + delete _s2Xadc1; + delete _mXadc1; + delete _s0Xadc2; + delete _s1Xadc2; + delete _s2Xadc2; + delete _mXadc2; + delete _pcie; } }; diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/FanTacho1.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/FanTacho1.h new file mode 100644 index 0000000..eaf953c --- /dev/null +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/FanTacho1.h @@ -0,0 +1,30 @@ +#ifndef FANTACHO1_H +#define FANTACHO1_H + +#include "model/hardware/core/register/Register.h" +#include "model/hardware/core/register/RegUtils.h" + +#undef BAR + +#define FAN_TACHO_MEAN_MASK 0x00FFFFFF + +#define BAR 0 +#define OFFSET 0x260CC + +class FanTacho1 : public Register +{ +public: + Field* fanTachoMean; + + FanTacho1(SonoDevice* device) : Register(BAR, OFFSET, device) + { + ADD_UNSIGNED_FIELD(fanTachoMean, FAN_TACHO_MEAN_MASK); + } +}; + +#undef FAN_TACHO_MEAN_MASK + +#undef BAR +#undef OFFSET + +#endif // FANTACHO1_H diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/FanTacho2.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/FanTacho2.h new file mode 100644 index 0000000..e56e1ff --- /dev/null +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/mps/FanTacho2.h @@ -0,0 +1,30 @@ +#ifndef FANTACHO2_H +#define FANTACHO2_H + +#include "model/hardware/core/register/Register.h" +#include "model/hardware/core/register/RegUtils.h" + +#undef BAR + +#define FAN_TACHO_MEAN_MASK 0x00FFFFFF + +#define BAR 0 +#define OFFSET 0x260D0 + +class FanTacho2 : public Register +{ +public: + Field* fanTachoMean; + + FanTacho2(SonoDevice* device) : Register(BAR, OFFSET, device) + { + ADD_UNSIGNED_FIELD(fanTachoMean, FAN_TACHO_MEAN_MASK); + } +}; + +#undef FAN_TACHO_MEAN_MASK + +#undef BAR +#undef OFFSET + +#endif // FANTACHO2_H diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/FpgaXadc1.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/FpgaXadc1.h new file mode 100644 index 0000000..426e3fb --- /dev/null +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/FpgaXadc1.h @@ -0,0 +1,34 @@ +#ifndef FPGAXADC1_H +#define FPGAXADC1_H + +#include "model/hardware/core/register/Register.h" +#include "model/hardware/core/register/RegUtils.h" + +#undef BAR + +#define FPGA_CORE_TEMP_MASK 0x00000FFF +#define FPGA_VCC_INT_MASK 0x0FFF0000 + +#define BAR 0U +#define OFFSET 0x260D4 + +class FpgaXadc1 : public Register +{ +public: + Field* fpgaCoreTemp; + Field* fpgaVccInt; + + FpgaXadc1(SonoDevice* device, quint32 offset) : Register(BAR, OFFSET+offset, device) + { + ADD_UNSIGNED_FIELD(fpgaCoreTemp, FPGA_CORE_TEMP_MASK); + ADD_UNSIGNED_FIELD(fpgaVccInt , FPGA_VCC_INT_MASK ); + } +}; + +#undef FPGA_CORE_TEMP_MASK +#undef FPGA_VCC_INT_MASK + +#undef BAR +#undef OFFSET + +#endif // FPGAXADC1_H diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/FpgaXadc2.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/FpgaXadc2.h new file mode 100644 index 0000000..fd27758 --- /dev/null +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/FpgaXadc2.h @@ -0,0 +1,34 @@ +#ifndef FPGAXADC2_H +#define FPGAXADC2_H + +#include "model/hardware/core/register/Register.h" +#include "model/hardware/core/register/RegUtils.h" + +#undef BAR + +#define FPGA_VCC_AUX_MASK 0x00000FFF +#define FPGA_VCC_BRAM_MASK 0x0FFF0000 + +#define BAR 0U +#define OFFSET 0x260D8 + +class FpgaXadc2 : public Register +{ +public: + Field* fpgaVccAux; + Field* fpgaVccBram; + + FpgaXadc2(SonoDevice* device, quint32 offset) : Register(BAR, OFFSET+offset, device) + { + ADD_UNSIGNED_FIELD(fpgaVccAux, FPGA_VCC_AUX_MASK ); + ADD_UNSIGNED_FIELD(fpgaVccBram, FPGA_VCC_BRAM_MASK); + } +}; + +#undef FPGA_VCC_AUX_MASK +#undef FPGA_VCC_BRAM_MASK + +#undef BAR +#undef OFFSET + +#endif // FPGAXADC2_H diff --git a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/OnBoardTempSensor.h b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/OnBoardTempSensor.h index fa2dcde..f659fcb 100644 --- a/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/OnBoardTempSensor.h +++ b/include/model/hardware/core/register/boardsCtrlMngt/registerDefinition/trx/OnBoardTempSensor.h @@ -18,7 +18,7 @@ public: OnBoardTempSensor(SonoDevice* device) : Register(BAR, OFFSET, device) { - ADD_UNSIGNED_FIELD(temperature, TEMPERATURE_MASK); + ADD_SIGNED_FIELD(temperature, TEMPERATURE_MASK); } }; diff --git a/include/model/hardware/core/register/bpiFlash/BpiFlash.h b/include/model/hardware/core/register/bpiFlash/BpiFlash.h index 8cab905..c59f544 100644 --- a/include/model/hardware/core/register/bpiFlash/BpiFlash.h +++ b/include/model/hardware/core/register/bpiFlash/BpiFlash.h @@ -14,7 +14,7 @@ public: ~BpiFlash(); void writeMcs (QByteArray& mcs) const; - void readMcs (QList* mcs) const; + QList readMcs (void) const; }; #endif // BPIFLASH_H diff --git a/include/model/hardware/core/register/misc/Misc.h b/include/model/hardware/core/register/misc/Misc.h index 7361262..fe88960 100644 --- a/include/model/hardware/core/register/misc/Misc.h +++ b/include/model/hardware/core/register/misc/Misc.h @@ -52,7 +52,8 @@ enum eSyncCtrl : quint8 { bfSyncMode, adcSyncMode, - bfAdcLogMode + bfAdcLogMode, + otherAdcLogMode }; class Misc @@ -94,7 +95,7 @@ public: void setAdcSamplerFpgaSel (quint8 fpgaSel) const; bool getAdcSamplerBramReady (void) const; bool getAdcSamplerError (void) const; - void getAdcDataBram (QList* adcData) const; + QList getAdcDataBram (void) const; }; diff --git a/mainwindow.cpp b/mainwindow.cpp index 9ead7ee..0a03eed 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -28,7 +28,8 @@ MainWindow::MainWindow(QWidget* parent) _emul = new EmulatorProperties; _prb = new PrbCase; - movie = new QMovie("/home/hasis/Desktop/Develop_HardwareTest/gifs/Glass lines.gif"); + movie = new QMovie("/home/hasis/Desktop/hardware/Develop_HardwareTest/gifs/Glass lines.gif"); + movie->stop(); ui->l_programming->hide(); _colorMap = new QCPColorMap(ui->plot_2->xAxis, ui->plot_2->yAxis); @@ -43,7 +44,10 @@ MainWindow::MainWindow(QWidget* parent) ui->rbtn_offset->setChecked(!_settings->value(REG_ACCESS_SEL).value()); ui->tb_fpgaBit->setText(_settings->value(FPGA_FILE_PATH).value()); ui->tb_scenFilesPath->setText(_settings->value(SCENARIO_FILE_PATH).value()); + ui->tb_frameLogPath->setText(_settings->value(FRAME_LOG_PATH).value()); + ui->tb_biteScenPath->setText(_settings->value(BITE_SCEN_FILE_PATH).value()); ui->tb_biteFilesPath->setText(_settings->value(BITE_FILE_PATH).value()); + ui->tb_adcLogPath->setText(_settings->value(ADC_LOG_PATH).value()); ui->tb_trxRomId->setPlaceholderText("id(hex)"); ui->tb_trxRomInfo->setPlaceholderText("info"); @@ -62,15 +66,21 @@ MainWindow::MainWindow(QWidget* parent) connect(_timeout, &QTimer::timeout, this, &MainWindow::timeout); connect(this, &MainWindow::scenarioReady, this, &MainWindow::setScenario); connect(this, &MainWindow::labelState, this, &MainWindow::getLabelState); - connect(this, &MainWindow::fpgaProgrammer, this, &MainWindow::getFpgaProgrammer); - connect(&biteLogWatcher, &QFutureWatcher::finished, this, &MainWindow::biteLogThreadFinished); - connect(&dmaLogWatcher, &QFutureWatcher::finished, this, &MainWindow::dmaLogThreadFinished); + connect(&biteLogWatcher, + &QFutureWatcher::finished, + this, + &MainWindow::biteLogThreadFinished); + connect(&dmaLogWatcher, &QFutureWatcher::finished, this, + &MainWindow::dmaLogThreadFinished); + connect(&programWatcher, &QFutureWatcher::finished, this, + &MainWindow::programThreadFinish); connect(this, &MainWindow::programmingGif, this, &MainWindow::getProgrammingGif); //////////////////////// DMA Packet Connections ////////////////////////////// connect(&_trx, &TrxBoard::sendFramePacket, this, &MainWindow::getFramePacket); connect(this, &MainWindow::sendLogCount, this, &MainWindow::catchLogCount); - connect(this, &MainWindow::twoDReady, this, &MainWindow::show2d, Qt::BlockingQueuedConnection); + connect(this, &MainWindow::twoDReady, this, &MainWindow::show2d, + Qt::BlockingQueuedConnection); connect(this, &MainWindow::threeDReady, this, &MainWindow::show3d, Qt::BlockingQueuedConnection); @@ -81,16 +91,32 @@ MainWindow::MainWindow(QWidget* parent) ui->btn_updateRdbackValue->setText(UPDATE); dmaLogLayoutVisible(false); + ui->chk_continuousShowing->hide(); + ui->btn_dmaShow->hide(); + ui->chk_logCountEn->setChecked(false); + ui->tb_adcLogCount->setEnabled(false); + ui->chk_pulserTstModeEn->setChecked(false); + ui->tb_afeRegAddr->setText("C5"); + + QFont fontTitle; + fontTitle.setBold(true); + fontTitle.setItalic(true); + + ui->table_probe->verticalHeaderItem(0)->setFont(fontTitle); + ui->table_probe->horizontalHeaderItem(0)->setFont(fontTitle); + ui->table_probe->horizontalHeaderItem(1)->setFont(fontTitle); + ui->table_probe->horizontalHeaderItem(2)->setFont(fontTitle); + ui->table_probe->horizontalHeaderItem(3)->setFont(fontTitle); _dmaLog = false; _dmaRun = false; _fpsFlag = false; _dmaShow = false; _getPacket = false; + _firstFrameEn = false; + _programFlag = true; _frameCount = 0; - setAfeConfig(); - try { _trx.init(); @@ -106,16 +132,6 @@ MainWindow::MainWindow(QWidget* parent) #ifdef MPS_BOARD emit connectedPrbChange(); #endif - - QFont fontTitle; - fontTitle.setBold(true); - fontTitle.setItalic(true); - - ui->table_probe->verticalHeaderItem(0)->setFont(fontTitle); - ui->table_probe->horizontalHeaderItem(0)->setFont(fontTitle); - ui->table_probe->horizontalHeaderItem(1)->setFont(fontTitle); - ui->table_probe->horizontalHeaderItem(2)->setFont(fontTitle); - ui->table_probe->horizontalHeaderItem(3)->setFont(fontTitle); } MainWindow::~MainWindow() @@ -148,14 +164,16 @@ MainWindow::~MainWindow() /*************************************************************************************************/ void MainWindow::timeout() { - fps =static_cast(float_t(_frameCount)/(float_t(_timeout->interval())/1000.0f)); - if (ui->chk_continuousShowing->isChecked() || _fpsFlag) + fps = static_cast(float_t(_frameCount) / (float_t(_timeout->interval()) / 1000.0f)); + if(ui->chk_continuousShowing->isChecked() || _fpsFlag) + { + ui->l_frameTime->setText(QString::number(fpsBuf, 'g', 3) + " fps"); + } + else { - ui->l_frameTime->setText(QString::number(fpsBuf,'g',3) + " fps"); + ui->l_frameTime->setText(QString::number(fps, 'g', 3) + " fps"); } - else - ui->l_frameTime->setText(QString::number(fps,'g',3) + " fps"); - _frameCount=0; + _frameCount = 0; _fpsFlag = false; auto pcie_pid = _trx.deviceId(); @@ -166,77 +184,170 @@ void MainWindow::timeout() _trx.getHealthStatus(_healStatus); delay(10); - /******************* System Monitoring *********************/ + /***************** Fpga Core Monitoring ********************/ + double masterCoreTemp = static_cast(_healStatus->fpgaCoreTemperature->master); + ui->l_masterCoreTemp->setText(QString::number(masterCoreTemp, 'g', 4)); + delay(1); + double masterCoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.master); + ui->l_masterCoreVccInt->setText(QString::number(masterCoreVccInt, 'g', 3)); + delay(1); + + double masterCoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.master); + ui->l_masterCoreVccAux->setText(QString::number(masterCoreVccAux, 'g', 4)); + delay(1); + + double masterCoreVccBram = static_cast(_healStatus->fpgaCoreVoltages->vccBram.master); + ui->l_masterCoreVccBram->setText(QString::number(masterCoreVccBram, 'g', 3)); + delay(1); + + if(_programFlag) + { + double slave0CoreTemp = static_cast(_healStatus->fpgaCoreTemperature->slave0); + ui->l_slave0CoreTemp->setText(QString::number(slave0CoreTemp, 'g', 4)); + delay(1); + + double slave1CoreTemp = static_cast(_healStatus->fpgaCoreTemperature->slave1); + ui->l_slave1CoreTemp->setText(QString::number(slave1CoreTemp, 'g', 4)); + delay(1); + + double slave2CoreTemp = static_cast(_healStatus->fpgaCoreTemperature->slave2); + ui->l_slave2CoreTemp->setText(QString::number(slave2CoreTemp, 'g', 4)); + delay(1); + + double slave0CoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.slave0); + ui->l_slave0CoreVccInt->setText(QString::number(slave0CoreVccInt, 'g', 3)); + delay(1); + + double slave1CoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.slave1); + ui->l_slave1CoreVccInt->setText(QString::number(slave1CoreVccInt, 'g', 3)); + delay(1); + + double slave2CoreVccInt = static_cast(_healStatus->fpgaCoreVoltages->vccInt.slave2); + ui->l_slave2CoreVccInt->setText(QString::number(slave2CoreVccInt, 'g', 3)); + delay(1); + + double slave0CoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.slave0); + ui->l_slave0CoreVccAux->setText(QString::number(slave0CoreVccAux, 'g', 4)); + delay(1); + + double slave1CoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.slave1); + ui->l_slave1CoreVccAux->setText(QString::number(slave1CoreVccAux, 'g', 4)); + delay(1); + + double slave2CoreVccAux = static_cast(_healStatus->fpgaCoreVoltages->vccAux.slave2); + ui->l_slave2CoreVccAux->setText(QString::number(slave2CoreVccAux, 'g', 4)); + delay(1); + + double slave0CoreVccBram = + static_cast(_healStatus->fpgaCoreVoltages->vccBram.slave0); + ui->l_slave0CoreVccBram->setText(QString::number(slave0CoreVccBram, 'g', 3)); + delay(1); + + double slave1CoreVccBram = + static_cast(_healStatus->fpgaCoreVoltages->vccBram.slave1); + ui->l_slave1CoreVccBram->setText(QString::number(slave1CoreVccBram, 'g', 3)); + delay(1); + + double slave2CoreVccBram = + static_cast(_healStatus->fpgaCoreVoltages->vccBram.slave2); + ui->l_slave2CoreVccBram->setText(QString::number(slave2CoreVccBram, 'g', 3)); + delay(1); + } + else + { + QList label {ui->l_slave0CoreTemp, ui->l_slave1CoreTemp, ui->l_slave2CoreTemp, + ui->l_slave0CoreVccInt, ui->l_slave1CoreVccInt, + ui->l_slave2CoreVccInt, + ui->l_slave0CoreVccAux, ui->l_slave1CoreVccAux, + ui->l_slave2CoreVccAux, + ui->l_slave0CoreVccBram, ui->l_slave1CoreVccBram, + ui->l_slave2CoreVccBram}; + foreach(auto& l, label) + { + l->setText("Ukn"); + delay(1); + } + } + + /******************* System Monitoring *********************/ float tempSensor = _healStatus->systemTemperature; ui->l_Temp->setText(QString("%1").arg(static_cast(tempSensor))); - delay(10); + delay(1); auto adcCh1 = _healStatus->adcMon->mon12Vin; ui->l_adcCh1->setText(QString("%1").arg(static_cast(adcCh1))); - delay(10); + delay(1); auto adcCh2 = _healStatus->adcMon->mon5Vin; ui->l_adcCh2->setText(QString("%1").arg(static_cast(adcCh2))); - delay(10); + delay(1); auto adcCh3 = _healStatus->adcMon->prbZeroEncoder; ui->l_adcCh3->setText(QString("%1").arg(static_cast(adcCh3))); - delay(10); + delay(1); auto adcCh4 = _healStatus->adcMon->prbCtrl3P3V; ui->l_adcCh4->setText(QString("%1").arg(static_cast(adcCh4))); - delay(10); + delay(1); auto adcCh5 = _healStatus->adcMon->afeVcntlp; ui->l_adcCh5->setText(QString("%1").arg(static_cast(adcCh5))); - delay(10); + delay(1); auto adcCh6 = _healStatus->adcMon->mon3P3V; ui->l_adcCh6->setText(QString("%1").arg(static_cast(adcCh6))); - delay(10); + delay(1); auto adcCh7 = _healStatus->adcMon->monAfeA1P8V; ui->l_adcCh7->setText(QString("%1").arg(static_cast(adcCh7))); - delay(10); + delay(1); auto adcCh8 = _healStatus->adcMon->monAfeD1P8V; ui->l_adcCh8->setText(QString("%1").arg(static_cast(adcCh8))); - delay(10); + delay(1); + + quint32 tachoFan1 = static_cast(_healStatus->fanRpm->fan1); + ui->l_tachoFan1->setText(QString::number(tachoFan1)); + delay(1); + + quint32 tachoFan2 = static_cast(_healStatus->fanRpm->fan2); + ui->l_tachoFan2->setText(QString::number(tachoFan2)); + delay(1); /******************* Power Good *********************/ auto regAPg = _healStatus->voltsPg->regulatorA; ui->l_pgRegA->setText(enum2String(regAPg)); - delay(10); + delay(1); auto regBPg = _healStatus->voltsPg->regulatorB; ui->l_pgRegB->setText(enum2String(regBPg)); - delay(10); + delay(1); auto pg12v = _healStatus->voltsPg->mon12Vin; ui->l_pg12Vin->setText(enum2String(pg12v)); - delay(10); + delay(1); auto pg5v = _healStatus->voltsPg->mon5Vin; ui->l_pg5Vin->setText(enum2String(pg5v)); - delay(10); + delay(1); auto Pg3P3 = _healStatus->voltsPg->mon3P3V; ui->l_pg3P3->setText(enum2String(Pg3P3)); - delay(10); + delay(1); auto pgAvdd = _healStatus->voltsPg->monAfeA1P8V; ui->l_pg1P8Avdd->setText(enum2String(pgAvdd)); - delay(10); + delay(1); auto pgDvdd = _healStatus->voltsPg->monAfeD1P8V; ui->l_pg1P8Dvdd->setText(enum2String(pgDvdd)); - delay(10); + delay(1); auto pgPrbCtrl = _healStatus->voltsPg->prbCtrl3P3V; ui->l_pgPrbCtrl3P3->setText(enum2String(pgPrbCtrl)); - delay(10); + delay(1); /******************* Status Vector *********************/ _trx.getTrxStatus(_vec); @@ -246,116 +357,115 @@ void MainWindow::timeout() ui->l_pg->setText(QVariant(pgErr).toString()); auto color = pgErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pg, color); - delay(10); + delay(1); bool mpsErr = _vec->mpsErr; ui->l_mps->setText(QVariant(mpsErr).toString()); color = mpsErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_mps, color); - delay(10); + delay(1); bool frameLost = _vec->frameLost; ui->l_frameLost->setText(QVariant(frameLost).toString()); color = frameLost ? Qt::red : Qt::green; changeLabelTextColor(ui->l_frameLost, color); - delay(10); + delay(1); bool fanFault = _vec->fanFault; ui->l_fan->setText(QVariant(fanFault).toString()); color = fanFault ? Qt::red : Qt::green; changeLabelTextColor(ui->l_fan, color); - delay(10); + delay(1); bool pulserThd = _vec->pulserThd; ui->l_pulserThd->setText(QVariant(pulserThd).toString()); color = pulserThd ? Qt::red : Qt::green; changeLabelTextColor(ui->l_pulserThd, color); - delay(10); + delay(1); bool scenGtErr = _vec->scenGtErr; ui->l_scenGt->setText(QVariant(scenGtErr).toString()); color = scenGtErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenGt, color); - delay(10); + delay(1); bool scenPriErr = _vec->scenPriErr; ui->l_scenPri->setText(QVariant(scenPriErr).toString()); color = scenPriErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenPri, color); - delay(10); + delay(1); bool thermalErr = _vec->thermalErr; ui->l_thermal->setText(QVariant(thermalErr).toString()); color = thermalErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_thermal, color); - delay(10); + delay(1); bool scenSramErr = _vec->scenSramErr; ui->l_scenSram->setText(QVariant(scenSramErr).toString()); color = scenSramErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_scenSram, color); - delay(10); + delay(1); bool syncFifoErr = _vec->syncFifoErr; ui->l_syncFifo->setText(QVariant(syncFifoErr).toString()); color = syncFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncFifo, color); - delay(10); + delay(1); bool syncPointErr = _vec->syncPointErr; ui->l_syncPoint->setText(QVariant(syncPointErr).toString()); color = syncPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_syncPoint, color); - delay(10); + delay(1); bool dintrlvFifoErr = _vec->dintrlvFifoErr; ui->l_dintrlvFifo->setText(QVariant(dintrlvFifoErr).toString()); color = dintrlvFifoErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvFifo, color); - delay(10); + delay(1); bool dintrlvPointErr = _vec->dintrlvPointErr; ui->l_dintrlvPoint->setText(QVariant(dintrlvPointErr).toString()); color = dintrlvPointErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_dintrlvPoint, color); - delay(10); + delay(1); bool sram1ParityErr = _vec->sram1ParityErr; ui->l_sram1Parity->setText(QVariant(sram1ParityErr).toString()); color = sram1ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram1Parity, color); - delay(10); + delay(1); bool sram2ParityErr = _vec->sram2ParityErr; ui->l_sram2Parity->setText(QVariant(sram2ParityErr).toString()); color = sram2ParityErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_sram2Parity, color); - delay(10); + delay(1); bool dmaCtrlTransferErr = _vec->dmaCtrlTransferErr; ui->l_DmaCtrlTrans->setText(QVariant(dmaCtrlTransferErr).toString()); color = dmaCtrlTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_DmaCtrlTrans, color); - delay(10); + delay(1); bool emulDmaTransferErr = _vec->emulDmaTransferErr; ui->l_emulDmaTrans->setText(QVariant(emulDmaTransferErr).toString()); color = emulDmaTransferErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_emulDmaTrans, color); - delay(10); + delay(1); bool probeDisconnectErr = _vec->probeDisconnectErr; ui->l_prbDiscon->setText(QVariant(probeDisconnectErr).toString()); color = probeDisconnectErr ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDiscon, color); - delay(10); + delay(1); bool probeDetChanInterrupt = _vec->probeDetChanInterrupt; ui->l_prbDetChg->setText(QVariant(probeDetChanInterrupt).toString()); color = probeDetChanInterrupt ? Qt::red : Qt::green; changeLabelTextColor(ui->l_prbDetChg, color); - if(probeDetChanInterrupt) { emit connectedPrbChange(); @@ -559,7 +669,6 @@ void MainWindow::on_rbtn_offset_toggled(bool checked) if(checked) { _settings->setValue(REG_ACCESS_SEL, false); - ui->l_regIndicator->setText("Register offset: (Hex)"); } } @@ -647,20 +756,16 @@ void MainWindow::on_btn_writeReg_clicked() /*************************************************************************************************/ void MainWindow::on_btn_fpgaBrowse_clicked() { - QFileDialog fileDialog; - fileDialog.setNameFilters({"FPGA program file (*.bit)"}); - auto result = fileDialog.exec(); - - if(result) - { - auto selectedPath = fileDialog.selectedFiles()[0]; - ui->tb_fpgaBit->setText(selectedPath); - _settings->setValue(FPGA_FILE_PATH, selectedPath); - } + QString fpgaProgramPath = QFileDialog::getOpenFileName(this, + tr("FPGA Programming File"), + _fpgaProgramFolder, + "*.bit"); + ui->tb_fpgaBit->setText(fpgaProgramPath); + _settings->setValue(FPGA_FILE_PATH, fpgaProgramPath); } /*************************************************************************************************/ -void MainWindow::getFpgaProgrammer(QString path) +void MainWindow::fpgaProgram(QString& path) { try { @@ -672,6 +777,23 @@ void MainWindow::getFpgaProgrammer(QString path) } } +/*************************************************************************************************/ +void MainWindow::programThreadFinish() +{ +#ifdef DEVELOP_UI + _trx.afeAdcsSync(); +#endif + + QString str = "done"; + QColor color = Qt::green; + emit labelState(ui->l_programDone, str, color); + + movie->stop(); + ui->l_programming->hide(); + _programFlag = true; + ui->btn_getFpgaVersion->setEnabled(true); +} + /*************************************************************************************************/ void MainWindow::getProgrammingGif() { @@ -684,7 +806,7 @@ void MainWindow::getProgrammingGif() } /*************************************************************************************************/ -void MainWindow::getLabelState(QLabel *label, QString str, QColor color) +void MainWindow::getLabelState(QLabel* label, QString str, QColor color) { label->setText(str); changeLabelTextColor(label, color); @@ -695,26 +817,18 @@ void MainWindow::getLabelState(QLabel *label, QString str, QColor color) /*************************************************************************************************/ void MainWindow::on_btn_fpgaProgram_clicked() { + _programFlag = false; + ui->btn_getFpgaVersion->setEnabled(false); auto path = ui->tb_fpgaBit->text(); - //QtConcurrent::run(this, &MainWindow::gifActive); + QFuture programFuture = QtConcurrent::run(this, &MainWindow::fpgaProgram, path); + programWatcher.setFuture(programFuture); QString str = "doing"; QColor color = Qt::red; emit labelState(ui->l_programDone, str, color); - emit fpgaProgrammer(path); - - str = "done"; - color = Qt::green; - emit labelState(ui->l_programDone, str, color); - - //ui->l_programming->hide(); -} - -void MainWindow::gifActive() -{ - //emit programmingGif(); + emit programmingGif(); } /*************************************************************************************************/ @@ -749,10 +863,15 @@ void MainWindow::on_cb_selectedProbe_currentIndexChanged(int index) } /*************************************************************************************************/ -void MainWindow::delay(int ms) +void MainWindow::delay(quint16 ms) { - delayTimer.singleShot(ms, &loop, &QEventLoop::quit); - loop.exec(); + this->_bCtrl->timerShot(ms); + //uncrustify off + while(!(this->_bCtrl->checkTimeout())); + //uncrustify on + + //delayTimer.singleShot(ms, &loop, &QEventLoop::quit); + //loop.exec(); } const QString MainWindow::enum2String(ePg state) const @@ -776,40 +895,20 @@ void MainWindow::getFramePacket(QByteArray packet) quint16 batchId = ((static_cast(_lastBuffer[128])) & 0x00FF) | (((static_cast(_lastBuffer[129])) << 8) & 0xFF00); quint8 subBatchId = (static_cast(_lastBuffer[130])); -// quint8 frmType = (static_cast(_lastBuffer[131])); -// quint8 cri = (static_cast(_lastBuffer[132])); - -// quint16 bLine = ((static_cast(_lastBuffer[136])) & 0x00FF) | -// (((static_cast(_lastBuffer[137])) << 8) & 0xFF00); -// quint16 bPoint = ((static_cast(_lastBuffer[138])) & 0x00FF) | -// (((static_cast(_lastBuffer[139])) << 8) & 0xFF00); -// quint8 mLine = (static_cast(_lastBuffer[140])); -// quint16 mPoint = ((static_cast(_lastBuffer[141])) & 0x00FF) | -// (((static_cast(_lastBuffer[142])) << 8) & 0xFF00); - if (subBatchId == 0) + if(subBatchId == 0) { _frameCount++; - if (_getPacket) + if(_getPacket) { - if (_batchIdBuff == batchId && (batchId - _batchIdBuff) > 1) + if(_batchIdBuff == batchId && (batchId - _batchIdBuff) > 1) + { MESSAGE_BOX("The batch id error is happened."); + } } _batchIdBuff = batchId; _getPacket = true; } - -// if(batchId < 3) -// { -// qDebug() << "batchId" << batchId; -// qDebug() << "subBatchId" << subBatchId; -// qDebug() << "bLine" << bLine; -// qDebug() << "bPoint" << bPoint; -// qDebug() << "frmType" << frmType; -// qDebug() << "cri" << cri; -// qDebug() << "mLine" << mLine; -// qDebug() << "mPoint" << mPoint; -// } } /*************************************************************************************************/ @@ -822,44 +921,58 @@ void MainWindow::on_chk_continuousShowing_clicked() QtConcurrent::run(this, &MainWindow::on_btn_dmaShow_clicked); _dmaShow = true; ui->btn_dmaShow->hide(); + dmaLogLayoutVisible(false); } else { _dmaShow = false; ui->btn_dmaShow->show(); + dmaLogLayoutVisible(true); } } /*************************************************************************************************/ void MainWindow::on_btn_scenStart_clicked() { - _frameCount=0; + _frameCount = 0; try { auto str = ui->btn_scenStart->text(); if(str == "Scenario Start") { + QString dmaLogPath = ui->tb_frameLogPath->text(); ui->btn_scenStart->setText("Scenario Stop"); ui->btn_emulator->setText("Emulator Start"); dmaLogLayoutVisible(true); + ui->chk_continuousShowing->show(); + ui->btn_dmaShow->show(); _trx.scenPlayerStart(true); - _dmaLog = true; _dmaRun = true; //flag _dmaBuffer.clear(); + if(ui->chk_firstFrameLogEn->isChecked()) + { + _dmaLog = true; + QtConcurrent::run(this, &MainWindow::logPcie, dmaLogPath, LOG_COUNT_FROM_FIRST); + } } else { + _dmaRun = false; + _dmaLog = false; ui->btn_scenStart->setText("Scenario Start"); ui->chk_continuousShowing->setChecked(false); on_chk_continuousShowing_clicked(); dmaLogLayoutVisible(false); - _dmaLog = false; - _dmaRun = false; + ui->chk_continuousShowing->hide(); + ui->btn_dmaShow->hide(); _trx.scenPlayerStop(true); } } catch(SonoException& e) { + ui->chk_continuousShowing->hide(); + ui->btn_dmaShow->hide(); + ui->btn_scenStart->setText("Scenario Start"); qDebug() << e.what(); } } @@ -868,13 +981,16 @@ void MainWindow::on_btn_scenStart_clicked() void MainWindow::on_btn_emulator_clicked() { auto name = ui->btn_emulator->text(); - try { if(name == "Emulator Start") { - QString emulPath = QFileDialog::getOpenFileName(this, tr("emulator"), _emulFolder, "*.bin"); - if (emulPath.isEmpty() || emulPath.isNull()) + QString dmaLogPath = ui->tb_frameLogPath->text(); + QString emulPath = QFileDialog::getOpenFileName(this, + tr("emulator"), + _emulFolder, + "*.bin"); + if(emulPath.isEmpty() || emulPath.isNull()) { throw SonoException("No file is selected."); } @@ -891,22 +1007,35 @@ void MainWindow::on_btn_emulator_clicked() _trx.emulatorInit(_emul); ui->btn_scenStart->setText("Scenario Start"); dmaLogLayoutVisible(true); + ui->chk_continuousShowing->show(); + ui->btn_dmaShow->show(); _trx.emulatorStart(); - _dmaLog = true; _dmaRun = true; _dmaBuffer.clear(); + if(ui->chk_firstFrameLogEn->isChecked()) + { + _dmaLog = true; + QtConcurrent::run(this, &MainWindow::logPcie, dmaLogPath, LOG_COUNT_FROM_FIRST); + } } else { - ui->btn_emulator->setText("Emulator Start"); - dmaLogLayoutVisible(false); _dmaLog = false; _dmaRun = false; + ui->btn_emulator->setText("Emulator Start"); + ui->chk_continuousShowing->setChecked(false); + on_chk_continuousShowing_clicked(); + dmaLogLayoutVisible(false); + ui->chk_continuousShowing->hide(); + ui->btn_dmaShow->hide(); _trx.emulatorStop(); } } catch(SonoException& e) { + ui->chk_continuousShowing->hide(); + ui->btn_dmaShow->hide(); + ui->btn_emulator->setText("Emulator Start"); qDebug() << e.what(); } } @@ -954,6 +1083,8 @@ void MainWindow::logPcie(QString logPath, quint32 logCount) if(!file.open(QIODevice::WriteOnly)) { + progress->hide(); + progress->setEnabled(false); throw SonoException("Couldn't save DMA log file for frame logging"); } file.write(temp); @@ -971,37 +1102,56 @@ void MainWindow::logPcie(QString logPath, quint32 logCount) } /*************************************************************************************************/ -void MainWindow::on_btn_dmaLogLast_clicked() -{ - if(_dmaRun) - { try +void MainWindow::on_btn_frameLogBrowse_clicked() +{ + try + { + QString frameLogPath = QFileDialog::getExistingDirectory(this, + tr("Frame Log"), + _frameLogFolder, + QFileDialog::ShowDirsOnly); + QFile frameLogFile(frameLogPath); + if(frameLogFile.fileName().isEmpty()) { - auto dmaLogCnt = ui->tb_dmaLogCount->text().toUInt(Q_NULLPTR, 10); - if(dmaLogCnt == 0 && ui->tb_biteLogCount->text() != "0") - { - MESSAGE_BOX("Invalid input format for DMA log count"); - return; - } - QString dmaLogPath = QFileDialog::getExistingDirectory(this, tr("Dma Log"), _dmaLogFolder, QFileDialog::ShowDirsOnly); - QFile dmaLogFile(dmaLogPath); - if(dmaLogFile.fileName().isEmpty()) - { - throw SonoException("No file is selected"); - } - - QString str = "doing"; - QColor color = Qt::red; - emit labelState(ui->l_dmaLogDone, str, color); + throw SonoException("No file is selected"); + } + ui->tb_frameLogPath->setText(frameLogPath); + _settings->setValue(FRAME_LOG_PATH, frameLogPath); + } + catch(SonoException& e) + { + qDebug() << e.what(); + } +} - _dmaBuffer.clear(); - _dmaLog = true; - QFuture dmaLogFuture = QtConcurrent::run(this, &MainWindow::logPcie, dmaLogPath, dmaLogCnt); - dmaLogWatcher.setFuture(dmaLogFuture); - } - catch(SonoException& e) +/*************************************************************************************************/ +void MainWindow::on_btn_dmaLogLast_clicked() +{ + try + { + auto dmaLogCnt = ui->tb_dmaLogCount->text().toUInt(Q_NULLPTR, 10); + if(dmaLogCnt == 0 && ui->tb_biteLogCount->text() != "0") { - qDebug() << e.what(); + MESSAGE_BOX("Invalid input format for DMA log count"); + + return; } + QString dmaLogPath = ui->tb_frameLogPath->text(); + QString str = "doing"; + QColor color = Qt::red; + emit labelState(ui->l_dmaLogDone, str, color); + + _dmaBuffer.clear(); + _dmaLog = true; + QFuture dmaLogFuture = QtConcurrent::run(this, + &MainWindow::logPcie, + dmaLogPath, + dmaLogCnt); + dmaLogWatcher.setFuture(dmaLogFuture); + } + catch(SonoException& e) + { + qDebug() << e.what(); } } @@ -1016,15 +1166,14 @@ void MainWindow::dmaLogThreadFinished() /*************************************************************************************************/ void MainWindow::dmaLogLayoutVisible(bool show) { - QList widgets {ui->btn_dmaLogLast, - ui->tb_dmaLogCount, - ui->l_dmaLogDone, - ui->l_logCount, - ui->l_logging - }; - if (show) + QList widgets {ui->btn_dmaLogLast, + ui->tb_dmaLogCount, + ui->l_dmaLogDone, + ui->l_logCount, + ui->l_logging}; + if(show) { - foreach (auto& w, widgets) + foreach(auto& w, widgets) { w->setVisible(true); w->repaint(); @@ -1032,7 +1181,7 @@ void MainWindow::dmaLogLayoutVisible(bool show) } else { - foreach (auto& w, widgets) + foreach(auto& w, widgets) { w->setHidden(true); w->repaint(); @@ -1100,7 +1249,7 @@ void MainWindow::show3d() quint8 mLine = (static_cast(temp[140])); quint16 mPoint = ((static_cast(temp[141])) & 0x00FF) | (((static_cast(temp[142])) << 8) & 0xFF00); - if(bLine > 256*8) + if(bLine > 256 * 8) { qDebug() << "ERROR :: (B Line)" << bLine; @@ -1230,7 +1379,8 @@ void MainWindow::catchLogCount(quint32 counter, quint32 logRange, QProgressDialo { _progress->setMinimumSize(300, 100); _progress->setLabelText("Please wait..."); - _progress->setWindowTitle("Frame Packets Logging"); + //_progress->setWindowTitle("Frame Packets Logging"); + _progress->setWindowTitle("Logging"); _progress->setRange(0, static_cast(logRange)); _progress->setModal(true); @@ -1239,7 +1389,8 @@ void MainWindow::catchLogCount(quint32 counter, quint32 logRange, QProgressDialo _progress->setValue(static_cast(counter)); if(_progress->wasCanceled()) { - throw SonoException("Frame Packets Logging is canceled"); + //throw SonoException("Frame packets logging is canceled"); + throw SonoException("The logging process is canceled"); } } catch(SonoException& e) @@ -1696,23 +1847,40 @@ void MainWindow::on_btn_getFpgaVersion_clicked() /*************************************************************************************************/ void MainWindow::setScenario(const string& h5Path) { - Hdf5 hdf; - ScenGenHardwareOutput_t scenParams; - ScenPrbDepHardwareParam prbDepParams; - QVector lineFilterLut; - QVector stbLut; - - hdf.hdf5Path(h5Path); - - hdf.scenarioRead(scenParams); - hdf.prbDependParamsRead(prbDepParams); - prbDepParams.afeCfg = _afeConfig; - - stbLut = hdf.stbRead(); - lineFilterLut = hdf.lineFilterRead(); - try { + AfeConfig _afeConfig; + _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; + + Hdf5 hdf; + ScenGenHardwareOutput_t scenParams; + ScenPrbDepHardwareParam prbDepParams; + QVector lineFilterLut; + QVector stbLut; + + hdf.hdf5Path(h5Path); + + hdf.scenarioRead(scenParams); + hdf.prbDependParamsRead(prbDepParams); + prbDepParams.afeCfg = _afeConfig; + + stbLut = hdf.stbRead(); + lineFilterLut = hdf.lineFilterRead(); + _trx.setScenario(scenParams); _trx.setProbeDependParams(prbDepParams); _trx.setLineFilterCoefficient(lineFilterLut); @@ -1821,18 +1989,16 @@ void MainWindow::on_btn_setScenVerification_clicked() /*************************************************************************************************/ void MainWindow::on_btn_scenBrowse_clicked() { - QFileDialog fileDialog; - fileDialog.setFileMode(QFileDialog::Directory); - fileDialog.setOption(QFileDialog::ShowDirsOnly); - auto result = fileDialog.exec(); + QString scenPath = QFileDialog::getExistingDirectory(this, + tr("Scenario File"), + _scenarioFolder, + QFileDialog::ShowDirsOnly); + if (scenPath.isEmpty()) + throw SonoException("No file is selected."); - if(result) - { - auto selectedPath = fileDialog.selectedFiles()[0]; - ui->tb_scenFilesPath->setText(selectedPath); - _settings->setValue(SCENARIO_FILE_PATH, selectedPath); - ui->tb_scenInfo->clear(); - } + ui->tb_scenFilesPath->setText(scenPath); + _settings->setValue(SCENARIO_FILE_PATH, scenPath); + ui->tb_scenInfo->clear(); } /*************************************************************************************************/ @@ -1844,11 +2010,11 @@ void MainWindow::on_btn_scenInfo_clicked() QFile sysFile(path); if(sysFile.fileName().isEmpty()) { - throw SonoException("No file is selected"); + throw SonoException("No file is selected"); } if(!sysFile.open(QIODevice::ReadOnly)) { - throw SonoException("Couldn't open system check param file programming"); + throw SonoException("Couldn't open system check param file programming"); } QTextStream checkParam(&sysFile); @@ -2383,6 +2549,7 @@ void MainWindow::on_btn_afeRead_clicked() /*************************************************************************************************/ void MainWindow::setAfeConfig() { + AfeConfig _afeConfig; _afeConfig.lowNf = lowNfDisable; _afeConfig.lnaHpf = lnaHpfEnable; _afeConfig.pgaHpf = pgaHpfEnable; @@ -2398,23 +2565,88 @@ void MainWindow::setAfeConfig() _afeConfig.activeTermIndRes = actTermIndRes0; _afeConfig.activeTermIndResEn = actTermIndResDisable; _afeConfig.inputClampLevel = inputClampLvlAuto; + _trx.setAfeConfig(_afeConfig); } /*************************************************************************************************/ /*************************************** Built-in Test *******************************************/ +/*************************************************************************************************/ +void MainWindow::on_btn_biteScenBrowse_clicked() +{ + QString biteScenPath = QFileDialog::getExistingDirectory(this, + tr("Built-in test Scenario File"), + _BITeScenFolder, + QFileDialog::ShowDirsOnly); + ui->tb_biteScenPath->setText(biteScenPath); + _settings->setValue(BITE_SCEN_FILE_PATH, biteScenPath); +} + +/*************************************************************************************************/ +void MainWindow::on_btn_biteSetScenario_clicked() +{ + QString str = "doing"; + QColor color = Qt::red; + emit labelState(ui->l_biteScenFillingDone, str, color); + + QString sramScenario = "/scenGenOutput/scenario.h5"; + QString h5Path = ui->tb_biteScenPath->text() + sramScenario; + + emit scenarioReady(h5Path.toStdString()); + + str = "done"; + color = Qt::green; + emit labelState(ui->l_biteScenFillingDone, str, color); +} + /*************************************************************************************************/ void MainWindow::on_btn_biteBrowse_clicked() { - QFileDialog fileDialog; - fileDialog.setNameFilter("*.csv"); - auto result = fileDialog.exec(); + QString biteIqPath = + QFileDialog::getOpenFileName(this, tr("TxDAC File"), _BITeIqFolder, "*.csv"); + ui->tb_biteFilesPath->setText(biteIqPath); + _settings->setValue(BITE_FILE_PATH, biteIqPath); +} + +/*************************************************************************************************/ +void MainWindow::on_btn_biteIQ_clicked() +{ + + QString str = "doing"; + QColor color = Qt::red; + emit labelState(ui->l_biteIQFillingDone, str, color); - if(result) + //BITe file reading to determine the I & Q of txDAC + QString bitePath = ui->tb_biteFilesPath->text(); + QFile biteFile(bitePath); + QTextStream biteLog(&biteFile); + if(biteFile.fileName().isEmpty()) { - auto selectedPath = fileDialog.selectedFiles()[0]; - ui->tb_biteFilesPath->setText(selectedPath); - _settings->setValue(BITE_FILE_PATH, selectedPath); + throw SonoException("No file is selected"); } + + if(!biteFile.open(QIODevice::ReadOnly)) + { + throw SonoException("Couldn't open built-in test file for frame logging"); + } + + QStringList txDac; + QByteArray I; + QByteArray Q; + while(!biteLog.atEnd()) + { + txDac.clear(); + txDac = biteLog.readLine().split(","); + I.append(static_cast(txDac.at(0).toInt())); + Q.append(static_cast(txDac.at(1).toInt())); + } + biteFile.close(); + _trx.setBiteDacData(I, Q); + + delay(100); + + str = "done"; + color = Qt::green; + emit labelState(ui->l_biteIQFillingDone, str, color); } /*************************************************************************************************/ @@ -2424,45 +2656,24 @@ void MainWindow::on_btn_setBiteLog_clicked() { auto scenStr = ui->btn_scenStart->text(); if(scenStr == "Scenario Stop") + { on_btn_scenStart_clicked(); + } - // BITe log count registering + //BITe log count registering auto biteLogCnt = ui->tb_biteLogCount->text().toUInt(Q_NULLPTR, 10); if(biteLogCnt == 0 && ui->tb_biteLogCount->text() != "0") { MESSAGE_BOX("Invalid input format for BITe log count"); - return; - } - - // BITe file reading to determine the I & Q of txDAC - QString bitePath = ui->tb_biteFilesPath->text(); - QFile biteFile(bitePath); - QTextStream biteLog(&biteFile); - if(biteFile.fileName().isEmpty()) - { - throw SonoException("No file is selected"); - } - if(!biteFile.open(QIODevice::ReadOnly)) - { - throw SonoException("Couldn't open built-in test file for frame logging"); - } - - QStringList txDac; - QByteArray I; - QByteArray Q; - while (!biteLog.atEnd()) - { - txDac.clear(); - txDac = biteLog.readLine().split(","); - I.append(static_cast(txDac.at(0).toInt())); - Q.append(static_cast(txDac.at(1).toInt())); + return; } - _trx.setBiteDacData(I , Q); - biteFile.close(); - // BITe log file writing after scen player start and getting the frame packet - QString biteLogPath = QFileDialog::getExistingDirectory(this, tr("BITe Log"), _biteLogFolder, QFileDialog::ShowDirsOnly); + //BITe log file writing after scen player start and getting the frame packet + QString biteLogPath = QFileDialog::getExistingDirectory(this, + tr("BITe Log"), + _biteLogFolder, + QFileDialog::ShowDirsOnly); QFile biteLogFile(biteLogPath); if(biteLogFile.fileName().isEmpty()) { @@ -2476,14 +2687,16 @@ void MainWindow::on_btn_setBiteLog_clicked() _dmaBuffer.clear(); _dmaLog = true; _trx.biteScenPlayerStart(); - QFuture biteLogFuture = QtConcurrent::run(this, &MainWindow::logPcie, biteLogPath, biteLogCnt); + QFuture biteLogFuture = QtConcurrent::run(this, + &MainWindow::logPcie, + biteLogPath, + biteLogCnt); biteLogWatcher.setFuture(biteLogFuture); } catch(SonoException& e) { qDebug() << e.what(); } - } /*************************************************************************************************/ @@ -2496,48 +2709,445 @@ void MainWindow::biteLogThreadFinished() } /*************************************************************************************************/ -void MainWindow::exitApp() +/*************************************** Capture_Logger ******************************************/ +/*************************************************************************************************/ +void MainWindow::on_chk_logCountEn_clicked(bool checked) { - auto str = ui->btn_scenStart->text(); - if(str == "Scenario Stop") - on_btn_scenStart_clicked(); - this->QWidget::close(); + QList checkBox {ui->chk_scenFrameAdcLog, + ui->chk_syncAdcLog}; + foreach(auto& chk, checkBox) + { + chk->setChecked(false); + chk->setEnabled(!checked); + } + ui->cb_syncMode->setEnabled(!checked); + ui->tb_sampleCount->setEnabled(!checked); + ui->tb_syncCount->setEnabled(!checked); + ui->tb_adcLogCount->setEnabled(checked); } /*************************************************************************************************/ -/*************************************** Capture_Logger ******************************************/ +void MainWindow::on_chk_syncAdcLog_clicked(bool checked) +{ + QList checkBox {ui->chk_scenFrameAdcLog, + ui->chk_logCountEn, + ui->chk_afeConfig}; + + foreach(auto& chk, checkBox) + { + chk->setChecked(false); + chk->setEnabled(!checked); + } + + ui->tb_adcLogCount->setEnabled(false); + + if(ui->cb_syncMode->currentIndex() == 1) + { + ui->tb_syncCount->setEnabled(!checked); + } +} + +/*************************************************************************************************/ +void MainWindow::on_chk_scenFrameAdcLog_clicked(bool checked) +{ + QList checkBox {ui->chk_syncAdcLog, + ui->chk_logCountEn, + ui->chk_afeConfig}; + + foreach(auto& chk, checkBox) + { + chk->setChecked(false); + chk->setEnabled(!checked); + } + + ui->tb_adcLogCount->setEnabled(false); + ui->tb_syncCount->setEnabled(!checked); + ui->cb_syncMode->setEnabled(!checked); +} + +/*************************************************************************************************/ +void MainWindow::on_cb_syncMode_currentIndexChanged(int index) +{ + if(ui->chk_syncAdcLog->isChecked() && index == 1) + { + ui->tb_syncCount->setEnabled(false); + } + else + { + ui->tb_syncCount->setEnabled(true); + } +} + +/*************************************************************************************************/ +void MainWindow::on_btn_adcLogBrowse_clicked() +{ + try + { + //Determine ADC log path + QString adcLoggerPath = QFileDialog::getExistingDirectory(this, + tr("ADC Logger"), + _adcLoggerFolder, + QFileDialog::ShowDirsOnly); + if(adcLoggerPath.isEmpty()) + { + throw SonoException("No file is selected"); + } + + ui->tb_adcLogPath->setText(adcLoggerPath); + _settings->setValue(ADC_LOG_PATH, adcLoggerPath); + } + catch(SonoException& e) + { + qDebug() << e.what(); + } +} + /*************************************************************************************************/ void MainWindow::on_btn_setAdcLog_clicked() { - // ADC log count registering - auto adcLogCnt = ui->tb_adcLogCount->text().toUInt(); - if(adcLogCnt == 0 && ui->tb_adcLogCount->text() != "0") + try { - MESSAGE_BOX("Invalid input format for ADC logger count"); - return; + QString str; + QColor color; + + QString adcLoggerPath = ui->tb_adcLogPath->text(); + + //ADC log count registering + quint32 adcLogCnt(0); + if(ui->tb_adcLogCount->isEnabled()) + { + adcLogCnt = ui->tb_adcLogCount->text().toUInt(); + if(adcLogCnt == 0) + { + MESSAGE_BOX("Invalid input format for ADC logger count"); + + return; + } + } + + //Sample count registering + quint32 sampleCnt(0); + if(ui->tb_sampleCount->isEnabled()) + { + sampleCnt = ui->tb_sampleCount->text().toUInt(); + if(sampleCnt == 0 && ui->tb_sampleCount->text() != "0") + { + MESSAGE_BOX("Invalid input format for sample count"); + + return; + } + } + //sync count registering + quint32 syncCnt(0); + if(ui->tb_syncCount->isEnabled()) + { + syncCnt = ui->tb_syncCount->text().toUInt(); + if(syncCnt == 0 && ui->tb_syncCount->text() != "0") + { + MESSAGE_BOX("Invalid input format for sync count"); + + return; + } + } + + //ADC sync mode + eSyncMode syncMode = autoSync; + if(ui->cb_syncMode->isEnabled()) + { + auto syncIdx = ui->cb_syncMode->currentIndex(); + if(syncIdx == 0) + { + syncMode = autoSync; + } + else + { + syncMode = manualSync; + } + } + + if (ui->chk_txdacEn->isChecked()) + { + _trx.setAdgCfg(adgIQ); + _trx.setTxDacEnable(BITE_INTERVAL, true); + } + + //ADC capture configuration + captureConfig capConfig; + capConfig.capMode = allChannel; + capConfig.manualTrig = false; + capConfig.syncCount = syncCnt; + capConfig.sampleCount = sampleCnt; + + delay(1000); ////////////////////////// check + _trx.setAfePwr(afePwrdnDisable); + _trx.adcCaptureConfig(capConfig); + + //Sync ADC log state for both mode: Auto & Manual + if(ui->chk_syncAdcLog->isChecked()) + { + str = "doing"; + color = Qt::red; + emit labelState(ui->l_adcLogDone, str, color); + + _trx.adcCaptureStart(); + if(syncMode == autoSync) + { + _trx.scenPlayerStart(true); + _trx.adcCaptureDone(); + _trx.scenPlayerStop(true); + _trx.adcLoggerStart(adcLoggerPath, "autoSync"); + } + if(syncMode == manualSync) + { + _trx.setCaptureManualSync(); + _trx.adcCaptureDone(); + _trx.adcLoggerStart(adcLoggerPath, "manualSync"); + } + str = "done"; + color = Qt::green; + emit labelState(ui->l_adcLogDone, str, color); + } + + //ADC log state regardless of sample/sync count + if(ui->chk_logCountEn->isChecked()) + { + QProgressDialog* progress = new QProgressDialog(this); + + if(adcLogCnt > 2) + { + progress->show(); + } + else + { + progress->hide(); + } + + for(quint16 var = 0; var < adcLogCnt; var++) + { + str = "doing"; + color = Qt::red; + emit labelState(ui->l_adcLogDone, str, color); + + _trx.adcCaptureStart(); + _trx.setCaptureManualSync(); + _trx.adcCaptureDone(); + _trx.adcLoggerStart(adcLoggerPath, "logCnt(" + QString::number(var) + ")"); + + str = "done"; + color = Qt::green; + emit labelState(ui->l_adcLogDone, str, color); + + emit sendLogCount(var, adcLogCnt, progress); + } + delete progress; + } + + //Scen frame ADC log state based-on scenario end index number + if(ui->chk_scenFrameAdcLog->isChecked()) + { + quint16 startIdx = static_cast(_usd->readWord(0x804, 0)); + quint16 endIdx = static_cast(_usd->readWord(0x808, 0)); + + QProgressDialog* progress1 = new QProgressDialog(this); + if((endIdx - startIdx) >= 1) + { + progress1->show(); + } + else + { + progress1->hide(); + } + + for(quint16 var = startIdx; var <= endIdx; var++) + { + str = "doing"; + color = Qt::red; + emit labelState(ui->l_adcLogDone, str, color); + + capConfig.syncCount = var; + _trx.adcCaptureConfig(capConfig); + _trx.adcCaptureStart(); + _trx.scenPlayerStart(true); + _trx.adcCaptureDone(); + _trx.scenPlayerStop(true); + _trx.adcLoggerStart(adcLoggerPath, "scenIndx(" + QString::number(var) + ")"); + + str = "done"; + color = Qt::green; + emit labelState(ui->l_adcLogDone, str, color); + + emit sendLogCount(var, endIdx, progress1); + } + delete progress1; + } + _trx.setAfePwr(afePwrdnEnable); + + _trx.setTxDacEnable(BITE_INTERVAL, false); + _trx.setAdgCfg(adgGnd); + } + catch(SonoException& e) + { + _trx.setAfePwr(afePwrdnEnable); + _trx.setDebuggerMode(pulserHz, true); + _trx.setDebuggerMode(pulserHz, false); + _trx.setTxDacEnable(BITE_INTERVAL, false); + _trx.setAdgCfg(adgGnd); + qDebug() << e.what(); + } +} - // Sample count registering - auto sampleCnt = ui->tb_sampleCount->text().toUInt(); - if(sampleCnt == 0 && ui->tb_sampleCount->text() != "0") - sampleCnt = 0; +/*************************************************************************************************/ +void MainWindow::on_chk_pulserTstModeEn_clicked(bool checked) +{ + auto tstModeIdx = ui->cb_pulserTstMode->currentIndex(); - // sync count registering - auto syncCnt = ui->tb_syncCount->text().toUInt(); - if(syncCnt == 0 && ui->tb_syncCount->text() != "0") - syncCnt = 0; + if(checked) + { + if(tstModeIdx == 0) + { + _trx.setDebuggerMode(pulserHz, checked); + } + if(tstModeIdx == 1) + { + _trx.setDebuggerMode(pulserTr, checked); + } + } + else + { + _trx.setDebuggerMode(pulserHz, true); + _trx.setDebuggerMode(pulserHz, false); + } +} - // ADC capture start configuration - eSyncMode syncMode; +/*************************************************************************************************/ +void MainWindow::on_cb_pulserTstMode_currentIndexChanged(int index) +{ + if (ui->chk_pulserTstModeEn->isChecked()) + { + if (index == 0) + { + _trx.setDebuggerMode(pulserHz, true); + } + if (index == 1) + { + _trx.setDebuggerMode(pulserTr, true); + } + } + else + { + _trx.setDebuggerMode(pulserHz, true); + _trx.setDebuggerMode(pulserHz, false); + } +} + +/*************************************************************************************************/ +void MainWindow::on_chk_afeConfig_clicked(bool checked) +{ + if(checked) + { + setAfeConfig(); + } +} + +/*************************************************************************************************/ +/***************************************** Misc Widget *******************************************/ +/*************************************************************************************************/ +void MainWindow::on_btn_gtReg_clicked() +{ + quint32 bar = 0; + auto result = "OK"; + 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() << ""; + qDebug() << "--- GT Status Registers Before Reset--- "; + 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() << "--- ------------------- --- "; + + qDebug() << ""; + qDebug() << "-------- Reset Start ---------"; + QList resetAddr; + resetAddr << 0x14000 << 0x14003 << 0x114000 << 0x114003 + << 0x214000 << 0x214003 << 0x314000 << 0x314003; + for(auto value = 2; value >= 0; value--) + { + foreach(auto& offset, resetAddr) + { + _usd->writeWord(offset * 4, bar, static_cast(value)); + } + } + qDebug() << "-------- Reset Done ---------"; + qDebug() << ""; + + delay(1000); + + qDebug() << "--- GT Status Registers After Reset--- "; + 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() << "--- ------------------- --- "; + qDebug() << ""; +} - captureConfig capConfig; - capConfig.capMode = allChannel; - capConfig.manualTrig = false; - capConfig.syncCount = syncCnt; - capConfig.sampleCount = sampleCnt; +/*************************************************************************************************/ +/*************************************************************************************************/ +void MainWindow::exitApp() +{ + QList > afePwrCheck {_trx.getAfeReg(slave0, 0xC5), + _trx.getAfeReg(slave1, 0xC5), + _trx.getAfeReg(slave2, 0xC5)}; - _trx.adcCaptureStart(capConfig, syncMode); + foreach (auto& afePwr, afePwrCheck) + { + quint32 afe0 = afePwr.at(0) & 0x80000000; + quint32 afe1 = afePwr.at(1) & 0x80000000; + quint32 afe2 = afePwr.at(2) & 0x80000000; + quint32 afe3 = afePwr.at(3) & 0x80000000; + if ((afe0 & afe1 & afe2 & afe3) == 0) + { + ui->btn_scenStart->setText("Scenario Stop"); + on_btn_scenStart_clicked(); + break; + } + } + + on_chk_pulserTstModeEn_clicked(false); + _trx.setTxDacEnable(BITE_INTERVAL, false); + _trx.setAdgCfg(adgGnd); + this->QWidget::close(); } diff --git a/mainwindow.h b/mainwindow.h index 0815a01..f031e83 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -31,10 +31,10 @@ emit showMessage(M) #define SCENARIO_FILE_PATH "scenarioFilePath" +#define BITE_SCEN_FILE_PATH "biteScenarioFilePath" +#define FRAME_LOG_PATH "frameLogPath" +#define ADC_LOG_PATH "adcLogPath" #define BITE_FILE_PATH "biteFilePath" -#define ADC_SIM_FILE_PATH "adcSimFilePath" -#define PARAM_FILE_PATH "paramFilePath" -#define TX_DAC_FILE_PATH "txDacFilePath" #define FPGA_FILE_PATH "fpgaFilePath" #define REG_ACCESS_SEL "regAccessType" @@ -59,6 +59,8 @@ #define ENABLE "Enable" #define DISABLE "Disable" +#define LOG_COUNT_FROM_FIRST 50U + #define TRANSFER_LENGTH 128 * 1024 #define TRANSFER_RATE 30.0f #define RAM_BUFFER_OFFSET 0U @@ -97,6 +99,8 @@ private: QFutureWatcher dmaLogWatcher; + QFutureWatcher programWatcher; + static QThread* _uiThread; QTimer* _timeout; @@ -121,13 +125,11 @@ private: PrbCase* _prb; - AfeConfig _afeConfig; - void setScenarioCompare(const QString& scenPath); void timeout(); - void delay(int ms); + void delay(quint16 ms); const QString enum2String (ePg state) const; @@ -149,17 +151,24 @@ private: void getProbeColor (const QBrush brush, const int item); - void gifActive(void); - void biteLogThreadFinished(); void dmaLogThreadFinished(); void dmaLogLayoutVisible(bool show); - QString _biteLogFolder = "/home/hasis/Desktop/TrxBoardFile/_log/BITe/"; - QString _dmaLogFolder = "/home/hasis/Desktop/TrxBoardFile/_log/dma/"; - QString _emulFolder = "/home/hasis/Desktop/TrxBoardFile/emulator/"; + void fpgaProgram(QString &path); + + void programThreadFinish(); + + QString _fpgaProgramFolder = "/home/hasis/Desktop/hardware/hwCode"; + QString _scenarioFolder = "/home/hasis/Desktop/hardware/Scenarios"; + QString _emulFolder = "/home/hasis/Desktop/hardware/emulator"; + QString _BITeScenFolder = "/home/hasis/Desktop/hardware"; + QString _BITeIqFolder = "/home/hasis/Desktop/hardware/BITe_IQ"; + QString _frameLogFolder = "/home/hasis/Desktop/hardware/Log/DMA"; + QString _biteLogFolder = "/home/hasis/Desktop/hardware/Log/BITe"; + QString _adcLoggerFolder = "/home/hasis/Desktop/hardware/Log/ADC"; QVector _dmaBuffer; QByteArray _lastBuffer; @@ -173,6 +182,8 @@ private: bool _dmaShow; bool _getPacket; bool _fpsFlag; + bool _firstFrameEn; + bool _programFlag; // uncrustify off private slots: @@ -195,8 +206,6 @@ private slots: void getLabelState(QLabel* label, QString str, QColor color); - void getFpgaProgrammer (QString path); - void getProgrammingGif(void); void on_rbtn_reg_toggled(bool checked); @@ -289,6 +298,32 @@ private slots: void on_btn_setAdcLog_clicked(); + void on_btn_gtReg_clicked(); + + void on_btn_frameLogBrowse_clicked(); + + void on_btn_biteScenBrowse_clicked(); + + void on_chk_logCountEn_clicked(bool checked); + + void on_chk_syncAdcLog_clicked(bool checked); + + void on_chk_scenFrameAdcLog_clicked(bool checked); + + void on_chk_pulserTstModeEn_clicked(bool checked); + + void on_chk_afeConfig_clicked(bool checked); + + void on_cb_syncMode_currentIndexChanged(int index); + + void on_btn_adcLogBrowse_clicked(); + + void on_btn_biteSetScenario_clicked(); + + void on_btn_biteIQ_clicked(); + + void on_cb_pulserTstMode_currentIndexChanged(int index); + signals: void showMessage(QString message); void threeDReady(); @@ -297,7 +332,6 @@ signals: void connectedPrbChange(); void frameLostCall(); void labelState(QLabel* label, QString str, QColor color); - void fpgaProgrammer(QString path); void scenarioReady(const string& h5Path); void programmingGif(); diff --git a/mainwindow.ui b/mainwindow.ui index f38d12b..92068a8 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -6,12 +6,15 @@ 0 0 - 854 - 883 + 841 + 1010 + + false + - MainWindow + Developed Hardware Ui @@ -19,8 +22,8 @@ 10 0 - 811 - 331 + 821 + 391 @@ -39,7 +42,7 @@ - 5 + 0 @@ -48,8 +51,8 @@ - 0 - 0 + 10 + 10 741 135 @@ -228,38 +231,40 @@ - : + Offset (Hex): + + + + + + + + 0 + 0 + + + + + 50 + true + false + false + false + + + + 32767 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 50 - true - false - false - false - - - - + + 6 + + + 7 + @@ -322,7 +327,7 @@ - Value: (Hex) + Value (Hex): @@ -390,7 +395,7 @@ - result: (Hex) + Result (Hex): @@ -450,8 +455,8 @@ - 0 - 150 + 10 + 160 741 111 @@ -615,10 +620,10 @@ - 260 + 290 70 221 - 20 + 31 @@ -626,6 +631,19 @@ + + + + 10 + 280 + 104 + 23 + + + + GT reset/read + + @@ -634,7 +652,7 @@ - 440 + 450 200 361 101 @@ -770,7 +788,7 @@ - 0 + 10 200 321 101 @@ -901,7 +919,7 @@ - 0 + 10 10 801 181 @@ -944,7 +962,7 @@ 10 30 781 - 27 + 31 @@ -1003,7 +1021,7 @@ 690 70 - 100 + 103 52 @@ -1346,8 +1364,8 @@ 10 20 - 153 - 23 + 163 + 25 @@ -1357,7 +1375,7 @@ - 170 + 180 20 331 241 @@ -1375,9 +1393,9 @@ - 670 - 270 - 112 + 660 + 290 + 131 23 @@ -1390,8 +1408,8 @@ 0 0 - 631 - 281 + 611 + 311 @@ -1404,9 +1422,9 @@ - 670 - 30 - 110 + 659 + 80 + 131 23 @@ -1417,10 +1435,10 @@ - 670 - 60 - 111 - 25 + 660 + 110 + 131 + 21 @@ -1436,13 +1454,82 @@ Show + + + + 660 + 229 + 131 + 54 + + + + + + + + 50 + true + false + false + false + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Continuous Frame Represent</span></p></body></html> + + + Continuously + + + + + + + + 50 + true + false + false + false + + + + <html><head/><body><p><span style=" font-size:8pt; font-weight:600; font-style:italic;">3D as default</span></p></body></html> + + + 2D Activate + + + + + + + + + 670 + 20 + 111 + 21 + + + + + 50 + false + + + + Header Log En + + 660 - 90 + 140 131 - 81 + 85 @@ -1529,51 +1616,61 @@ - + - 670 - 210 - 109 - 50 + 10 + 320 + 781 + 31 - + - + 50 true false + false false false - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Continuous Frame Represent</span></p></body></html> - - Continuously + Frame Log Path: - + 50 true false + false false false - - <html><head/><body><p><span style=" font-size:8pt; font-weight:600; font-style:italic;">3D as default</span></p></body></html> + + + + + + + 50 + true + false + false + false + false + - 2D Activate + Browse... @@ -1583,8 +1680,8 @@ 690 - 180 - 61 + 0 + 71 16 @@ -1601,12 +1698,12 @@ FPS - + - 670 - 0 - 128 + 660 + 50 + 131 21 @@ -1617,7 +1714,7 @@ - Header Log En + 1st Frame Log En @@ -1629,7 +1726,7 @@ 10 - 0 + 10 381 81 @@ -1734,9 +1831,9 @@ 410 - 90 + 100 381 - 131 + 151 @@ -1748,7 +1845,7 @@ 180 20 201 - 111 + 131 @@ -1844,7 +1941,7 @@ 410 - 0 + 10 381 81 @@ -1949,7 +2046,7 @@ 10 - 90 + 100 381 81 @@ -2058,10 +2155,10 @@ - 0 + 10 9 801 - 131 + 171 @@ -2071,9 +2168,9 @@ 10 - 30 + 70 781 - 27 + 31 @@ -2090,12 +2187,18 @@ - BITe File Path: + BITe I_Q Path: + + + 0 + 0 + + 50 @@ -2125,13 +2228,62 @@ + + + + 0 + + + + + + 0 + 0 + + + + + 98 + 0 + + + + + 80 + 16777215 + + + + Set I_Q + + + + + + + + 50 + true + false + false + false + false + + + + doing + + + + + 10 - 70 + 110 171 31 @@ -2165,10 +2317,10 @@ - 660 - 70 - 131 - 51 + 650 + 110 + 141 + 52 @@ -2219,36 +2371,134 @@ - - - - - -1 - 140 - 801 - 91 - - - - ADC Logger - - + - 660 + 10 30 - 130 - 51 + 781 + 31 - + - - - ADC Log - - - + + + + 50 + true + false + false + false + false + + + + BITe Scen Path: + + + + + + + + 50 + true + false + false + false + false + + + + + + + + + 50 + true + false + false + false + false + + + + Browse... + + + + + + + + + + 75 + true + true + false + false + false + + + + Set Scenario + + + + + + + + 50 + true + false + false + false + false + + + + doing + + + + + + + + + + + + 10 + 190 + 801 + 171 + + + + ADC Logger + + + + + 660 + 30 + 136 + 52 + + + + + + + ADC Log + + + @@ -2295,7 +2545,7 @@ 10 30 171 - 58 + 62 @@ -2310,7 +2560,7 @@ - Sample Count: + Sample Count: @@ -2322,6 +2572,9 @@ false + + 1 + @@ -2349,16 +2602,19 @@ false + + 0 + - + - 480 + 420 30 112 21 @@ -2371,7 +2627,7 @@ - Scen ADC Log + Sync ADC Log @@ -2379,15 +2635,15 @@ 190 30 - 211 - 56 + 218 + 60 - + 50 @@ -2400,7 +2656,7 @@ - + 50 @@ -2437,16 +2693,19 @@ false + + 1 + - + - 480 + 420 60 168 21 @@ -2462,55 +2721,175 @@ Scen Frame ADC Log - - - - - -2 - 240 - 181 - 61 - - - - Pulser Test Mode - - - - - 10 - 30 - 85 - 21 - - - - Enable - - - + - 90 + 540 30 - 79 + 81 23 + + + 50 + false + + - <html><head/><body><p><span style=" font-size:7pt;">Pulser Mode</span></p></body></html> + <html><head/><body><p><span style=" font-size:8pt;">Sync Mode</span></p></body></html> - Hz + Auto - T/R + Manual + + + + 190 + 120 + 601 + 41 + + + + + + + + 50 + true + false + false + false + false + + + + ADC Log Path: + + + + + + + + 50 + true + false + false + false + false + + + + + + + + + 50 + true + false + false + false + false + + + + Browse... + + + + + + + + + 10 + 100 + 161 + 61 + + + + Pulser Test Mode + + + + + 10 + 30 + 85 + 21 + + + + + 50 + false + + + + Enable + + + + + + 90 + 30 + 61 + 23 + + + + + 50 + false + + + + <html><head/><body><p><span style=" font-size:8pt;">Pulser Mode</span></p></body></html> + + + + HZ + + + + + T/R + + + + + + + + 420 + 90 + 113 + 21 + + + + + 50 + false + + + + TxDAC Enable + + @@ -2518,9 +2897,9 @@ 10 - 330 - 811 - 161 + 390 + 821 + 221 @@ -2532,39 +2911,13 @@ 300 30 16 - 111 + 121 Qt::Vertical - - - - 0 - 30 - 117 - 17 - - - - - - - PCIe_ID: - - - - - - - TextLabel - - - - - @@ -2699,7 +3052,7 @@ 540 - 30 + 50 158 19 @@ -2747,39 +3100,13 @@ - - - - 540 - 50 - 178 - 19 - - - - - - - AFE Vcntlp (db): - - - - - - - TextLabel - - - - - 470 30 - 58 - 122 + 63 + 134 @@ -2850,8 +3177,8 @@ 540 90 - 145 - 42 + 156 + 46 @@ -2903,9 +3230,9 @@ 0 - 60 - 285 - 90 + 30 + 302 + 101 @@ -3128,84 +3455,449 @@ - + + + + 20 + 140 + 176 + 21 + + + + + + + On Board Temp: + + + + + + + Unknown + + + + + + + + + 710 + 50 + 101 + 119 + + + + + + + FPGA Version + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Master Code</span></p></body></html> + + + Unknown + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave0 Code</span></p></body></html> + + + Unknown + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave1 Code</span></p></body></html> + + + Unknown + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave2 Code</span></p></body></html> + + + Unknown + + + + + + + + + 10 + 170 + 191 + 41 + + + + + + + + 8 + 75 + true + true + + + + Fpga Core Temp(oC) + + + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Master Temperature</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave0 Temperature</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave1 Temperature</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave2 Temperature</span></p></body></html> + + + ukn + + + + + + + + - 140 - 30 - 163 - 17 + 210 + 170 + 191 + 41 - - - + + + + + + 8 + 75 + true + true + + - On Board Temp: + Fpga Core Vcc Int(v) - - - Unknown - - + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Master VCC Int</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave0 VCC Int</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave1 VCC Int</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave2 VCC Int</span></p></body></html> + + + ukn + + + + - + - 710 - 50 - 101 - 109 + 410 + 170 + 191 + 41 - - - - - FPGA Version - - - - - - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Master Code</span></p></body></html> + + + + + + 8 + 75 + true + true + - TextLabel + Fpga Core Vcc Aux(v) + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Master Vcc Aux</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave0 Vcc Aux</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave1 Vcc Aux</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave2 Vcc Aux</span></p></body></html> + + + ukn + + + + + + + + + + + 610 + 170 + 191 + 41 + + + - - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave0 Code</span></p></body></html> + + + + 8 + 75 + true + true + - TextLabel + Fpga Core Vcc Bram(v) - - - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave1 Code</span></p></body></html> - + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Master Vcc Bram</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave0 Vcc Bram</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave1 Vcc Bram</span></p></body></html> + + + ukn + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave2 Vcc Bram</span></p></body></html> + + + ukn + + + + + + + + + + + 200 + 160 + 3 + 61 + + + + Qt::Vertical + + + + + + 400 + 160 + 3 + 61 + + + + Qt::Vertical + + + + + + 600 + 160 + 3 + 61 + + + + Qt::Vertical + + + + + + 730 + 30 + 71 + 16 + + + + <html><head/><body><p><span style=" font-size:8pt; font-weight:600; font-style:italic;">PCI_ID</span></p></body></html> + + + TextLabel + + + + + + 540 + 30 + 179 + 19 + + + + + - TextLabel + Gain VCNTLP (dB): - - - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Slave2 Code</span></p></body></html> - + + TextLabel @@ -3218,7 +3910,7 @@ 10 - 490 + 610 821 81 @@ -3283,7 +3975,7 @@ 0 20 - 489 + 509 51 @@ -3344,7 +4036,7 @@ 10 - 570 + 690 821 271 @@ -4516,6 +5208,53 @@ MPS Init + + + + 710 + 120 + 104 + 62 + + + + + + + + 8 + 75 + true + true + + + + Tacho Fan(rpm) + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Fan1</span></p></body></html> + + + Unknown + + + + + + + <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Fan2</span></p></body></html> + + + Unknown + + + + + @@ -4524,7 +5263,7 @@ 0 0 - 854 + 841 20 diff --git a/src/model/hardware/core/TrxBoard.cpp b/src/model/hardware/core/TrxBoard.cpp index 13b5cc1..9e28bea 100644 --- a/src/model/hardware/core/TrxBoard.cpp +++ b/src/model/hardware/core/TrxBoard.cpp @@ -134,12 +134,35 @@ void TrxBoard::afeAdcsSync() const } } +void TrxBoard::waitForCaptureDone(Debug *_dbg) const +{ + // Timeout to receive adc capture done. + this->_bCtrlMngt->timerShot(1000); + while (!(_dbg->getCapDone())) + { + if(this->_bCtrlMngt->checkTimeout()) + throw SonoException("Failure to receive adc capture done."); + + } + this->_bCtrlMngt->timerStop(); +} + +void TrxBoard::adcCaptureStop(Debug *_dbg) const +{ + _dbg->adcCaptureCmd(captureStop); +} + +void TrxBoard::adcCaptureStart(Debug *_dbg) const +{ + _dbg->adcCaptureCmd(captureStart); +} + void TrxBoard::adcLogTransferRoutine(Debug *_dbg, quint8 chNumPerFpga) { bool adcSamplerReady (false); bool adcSamplerError (false); - // Adc logger start according to selected afe channel + // Adc logger start according to selected afe channel. _dbg->adcLoggerTransferCmd(loggerStop); _dbg->adcLoggerChannelNum(chNumPerFpga); _dbg->adcLoggerTransferCmd(loggerStart); @@ -262,7 +285,10 @@ TrxBoard::TrxBoard() : _offsetSlave0(0), _offsetSlave1(0x400000), _offsetSlave2( _adc = new AdcVoltages; _pg = new VoltagesPg; - scenParams = new ScenGenHardwareParam; + _tachoRpm = new FanRpm; + _coreVolt = new criticalComponentVoltages; + _coreTemp = new criticalComponentTemperature; + _scenParams = new ScenGenHardwareParam; _allow = false; _run = false; @@ -312,7 +338,10 @@ TrxBoard::~TrxBoard() delete _adc; delete _pg; - delete scenParams; + delete _tachoRpm; + delete _coreVolt; + delete _coreTemp; + delete _scenParams; } TrxBoard::ScenHwRegister::~ScenHwRegister() @@ -411,12 +440,8 @@ void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam& prbDepParams) this->_dsp->lpfScaleCoefficient(prbDepParams.prbDepParams.lpfScaleCoeff); /////////////////////////// AFE setting /////////////////////////// - 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); + setAfeConfig (prbDepParams.afeCfg); + setAfePwr(afePwrdnEnable); } void TrxBoard::setScenario(ScenGenHardwareOutput_t& scenGenHw) @@ -428,178 +453,178 @@ void TrxBoard::setScenario(ScenGenHardwareOutput_t& scenGenHw) emulatorStop(); sramClear(first4M); - scenParams->focusTypeNumber = scenGenHw.focusTypeNumber; - if(scenParams->focusTypeNumber > FOCUS_TYPE_NUMBER_MAX) + _scenParams->focusTypeNumber = scenGenHw.focusTypeNumber; + 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) + _scenParams->totalTxShotNumber = scenGenHw.totalTxShotNumber; + 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) + _scenParams->rxBeamFormerNumber = scenGenHw.rxBeamFormerNumber.toVector(); + 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; + _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) + if(_scenParams->scenarioEndIndex < _scenParams->scenarioStartIndex) { throw SonoException( "The scenario end index must be greater than or equal to the scenario start index"); } - if(scenParams->scenarioEndIndex != (scenParams->totalTxShotNumber - 1)) + if(_scenParams->scenarioEndIndex != (_scenParams->totalTxShotNumber - 1)) { throw SonoException( "The scenario end index must be equal to the total tx shot number minus one"); } - scenParams->hwRegister->blendWeight = scenGenHw.hwRegister.blendWeight; - if(scenParams->hwRegister->blendWeight.size() != BLENDWEIGHT_LUT_MAX) + _scenParams->hwRegister->blendWeight = scenGenHw.hwRegister.blendWeight; + 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) + _scenParams->hwRegister->elementPosition->xPosition = scenGenHw.hwRegister.elementXPosition; + 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) + _scenParams->hwRegister->elementPosition->yPosition = scenGenHw.hwRegister.elementYPosition; + 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) + _scenParams->hwRegister->elementPosition->zPosition = scenGenHw.hwRegister.elementZPosition; + 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) + _scenParams->hwRegister->freqLut = scenGenHw.hwRegister.freqLut; + 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) + _scenParams->hwRegister->dtgcLut = scenGenHw.hwRegister.dtgcLut; + 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) + _scenParams->hwRegister->pulseTypeNumber = scenGenHw.hwRegister.pulseTypeNumber; + 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) + _scenParams->hwRegister->rxBeamFormerTypeNumber = scenGenHw.hwRegister.rxBeamFormerTypeNumber; + if(_scenParams->hwRegister->rxBeamFormerTypeNumber > RXBEAMFORMER_LUT_MAX) { throw SonoException("Rx beam former type number is out of range"); } - scenParams->hwRegister->receiverConfigTypeNumber = + _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(); + _scenParams->hwRegister->pulse->clear(); foreach(auto i, scenGenHw.hwRegister.pulseProps) { - scenParams->hwRegister->pulse->halfPeriod.append(i.halfPeriod); - scenParams->hwRegister->pulse->startPhase.append(i.startPhase); - scenParams->hwRegister->pulse->halfCycleNo.append(i.halfCycleNo); - scenParams->hwRegister->pulse->pulseVoltSel.append(i.pulseVoltSel); - scenParams->hwRegister->pulse->dampingPulseWidth.append(i.dampingPulseWidth); + _scenParams->hwRegister->pulse->halfPeriod.append(i.halfPeriod); + _scenParams->hwRegister->pulse->startPhase.append(i.startPhase); + _scenParams->hwRegister->pulse->halfCycleNo.append(i.halfCycleNo); + _scenParams->hwRegister->pulse->pulseVoltSel.append(i.pulseVoltSel); + _scenParams->hwRegister->pulse->dampingPulseWidth.append(i.dampingPulseWidth); } - scenParams->hwRegister->rxBeamformer->clear(); + _scenParams->hwRegister->rxBeamformer->clear(); foreach(auto j, scenGenHw.hwRegister.rxBeamFormerProps) { - scenParams->hwRegister->rxBeamformer->lag.append(j.lag); - scenParams->hwRegister->rxBeamformer->mla.append(j.mla); - scenParams->hwRegister->rxBeamformer->apodization.append(j.apodizationSel); + _scenParams->hwRegister->rxBeamformer->lag.append(j.lag); + _scenParams->hwRegister->rxBeamformer->mla.append(j.mla); + _scenParams->hwRegister->rxBeamformer->apodization.append(j.apodizationSel); } - scenParams->hwRegister->configLut->clear(); + _scenParams->hwRegister->configLut->clear(); foreach(auto k, scenGenHw.hwRegister.receiverConfigProps) { - scenParams->hwRegister->configLut->mla.append(k.mla); - scenParams->hwRegister->configLut->stb.append(k.stb); - scenParams->hwRegister->configLut->absEn.append(k.absEn); - scenParams->hwRegister->configLut->ddcEn.append(k.ddcn); - scenParams->hwRegister->configLut->dpeEn.append(k.dpeEn); - scenParams->hwRegister->configLut->stbEn.append(k.stbEn); - scenParams->hwRegister->configLut->wmfEn.append(k.wmfEn); - scenParams->hwRegister->configLut->lpfSel.append(k.lpfSel); - scenParams->hwRegister->configLut->aTgcSel.append(k.aTgcSel); - scenParams->hwRegister->configLut->focusNo.append(k.focusNo); - scenParams->hwRegister->configLut->lineMode.append(k.lineMode); - scenParams->hwRegister->configLut->ncoFreqSel.append(k.ncoFreqSel); - scenParams->hwRegister->configLut->dcCancelerEn.append(k.dcCancelEn); - scenParams->hwRegister->configLut->lineFilterEn.append(k.lineFilterEn); - scenParams->hwRegister->configLut->subtractFilterEn.append(k.subtractFilterEn); - } - - scenParams->indexParams->dLineNum = scenGenHw.indexParams.dLineNum; - scenParams->indexParams->frameType = scenGenHw.frameType; - scenParams->indexParams->dEnsembleNum = scenGenHw.indexParams.dEnsembleNum; - scenParams->indexParams->lastLineInFrame = scenGenHw.indexParams.lastLineInFrame; - scenParams->indexParams->firstLineInFrame = scenGenHw.indexParams.firstLineInFrame; - scenParams->indexParams->shotPropertiesIndex = scenGenHw.indexParams.shotPropertiesIndex; - scenParams->indexParams->pulsePropertiesIndex = scenGenHw.indexParams.pulsePropertiesIndex; - scenParams->indexParams->receiverConfigurationIndex = + _scenParams->hwRegister->configLut->mla.append(k.mla); + _scenParams->hwRegister->configLut->stb.append(k.stb); + _scenParams->hwRegister->configLut->absEn.append(k.absEn); + _scenParams->hwRegister->configLut->ddcEn.append(k.ddcn); + _scenParams->hwRegister->configLut->dpeEn.append(k.dpeEn); + _scenParams->hwRegister->configLut->stbEn.append(k.stbEn); + _scenParams->hwRegister->configLut->wmfEn.append(k.wmfEn); + _scenParams->hwRegister->configLut->lpfSel.append(k.lpfSel); + _scenParams->hwRegister->configLut->aTgcSel.append(k.aTgcSel); + _scenParams->hwRegister->configLut->focusNo.append(k.focusNo); + _scenParams->hwRegister->configLut->lineMode.append(k.lineMode); + _scenParams->hwRegister->configLut->ncoFreqSel.append(k.ncoFreqSel); + _scenParams->hwRegister->configLut->dcCancelerEn.append(k.dcCancelEn); + _scenParams->hwRegister->configLut->lineFilterEn.append(k.lineFilterEn); + _scenParams->hwRegister->configLut->subtractFilterEn.append(k.subtractFilterEn); + } + + _scenParams->indexParams->dLineNum = scenGenHw.indexParams.dLineNum; + _scenParams->indexParams->frameType = scenGenHw.frameType; + _scenParams->indexParams->dEnsembleNum = scenGenHw.indexParams.dEnsembleNum; + _scenParams->indexParams->lastLineInFrame = scenGenHw.indexParams.lastLineInFrame; + _scenParams->indexParams->firstLineInFrame = scenGenHw.indexParams.firstLineInFrame; + _scenParams->indexParams->shotPropertiesIndex = scenGenHw.indexParams.shotPropertiesIndex; + _scenParams->indexParams->pulsePropertiesIndex = scenGenHw.indexParams.pulsePropertiesIndex; + _scenParams->indexParams->receiverConfigurationIndex = scenGenHw.indexParams.receiverConfigurationIndex; - scenParams->txParams->maxDelayQ = scenGenHw.txParams.maxDelayQ; - scenParams->txParams->txFocusXPos = scenGenHw.txParams.txFocusXPos; - scenParams->txParams->txFocusYPos = scenGenHw.txParams.txFocusYPos; - scenParams->txParams->txFocusZPos = scenGenHw.txParams.txFocusZPos; - scenParams->txParams->pulseInterval = scenGenHw.pulseInterval; - scenParams->txParams->txActiveElementNumber = scenGenHw.txParams.txActiveElementNumber; - scenParams->txParams->txStartActiveElementNumber = + _scenParams->txParams->maxDelayQ = scenGenHw.txParams.maxDelayQ; + _scenParams->txParams->txFocusXPos = scenGenHw.txParams.txFocusXPos; + _scenParams->txParams->txFocusYPos = scenGenHw.txParams.txFocusYPos; + _scenParams->txParams->txFocusZPos = scenGenHw.txParams.txFocusZPos; + _scenParams->txParams->pulseInterval = scenGenHw.pulseInterval; + _scenParams->txParams->txActiveElementNumber = scenGenHw.txParams.txActiveElementNumber; + _scenParams->txParams->txStartActiveElementNumber = scenGenHw.txParams.txStartActiveElementNumber; - scenParams->rxParams->phiCos = scenGenHw.rxParams.phiCos; - scenParams->rxParams->phiSin = scenGenHw.rxParams.phiSin; - scenParams->rxParams->thetaCos = scenGenHw.rxParams.thetaCos; - scenParams->rxParams->thetaSin = scenGenHw.rxParams.thetaSin; - scenParams->rxParams->r0Position = scenGenHw.rxParams.r0Position; - scenParams->rxParams->interceptXPos = scenGenHw.rxParams.interceptXPos; - scenParams->rxParams->interceptYPos = scenGenHw.rxParams.interceptYPos; - scenParams->rxParams->interceptZPos = scenGenHw.rxParams.interceptZPos; - scenParams->rxParams->rxR0MaxDelayQ = scenGenHw.rxParams.rxR0MaxDelayQ; - scenParams->rxParams->rxR0MinDelayQ = scenGenHw.rxParams.rxR0MinDelayQ; - scenParams->rxParams->txR0MinDelayQ = scenGenHw.rxParams.txR0MinDelayQ; - scenParams->rxParams->rxFocusPointNumber = scenGenHw.rxParams.rxFocusPointNumber; - scenParams->rxParams->rxActiveElementStep = scenGenHw.rxParams.rxActiveElementStep; - scenParams->rxParams->rxR0ActiveElementNumber = scenGenHw.rxParams.rxR0ActiveElementNumber; - scenParams->rxParams->interceptPointFiringTime = scenGenHw.rxParams.interceptPointFiringTime; - scenParams->rxParams->rxR0CenterActiveElementNumber = + _scenParams->rxParams->phiCos = scenGenHw.rxParams.phiCos; + _scenParams->rxParams->phiSin = scenGenHw.rxParams.phiSin; + _scenParams->rxParams->thetaCos = scenGenHw.rxParams.thetaCos; + _scenParams->rxParams->thetaSin = scenGenHw.rxParams.thetaSin; + _scenParams->rxParams->r0Position = scenGenHw.rxParams.r0Position; + _scenParams->rxParams->interceptXPos = scenGenHw.rxParams.interceptXPos; + _scenParams->rxParams->interceptYPos = scenGenHw.rxParams.interceptYPos; + _scenParams->rxParams->interceptZPos = scenGenHw.rxParams.interceptZPos; + _scenParams->rxParams->rxR0MaxDelayQ = scenGenHw.rxParams.rxR0MaxDelayQ; + _scenParams->rxParams->rxR0MinDelayQ = scenGenHw.rxParams.rxR0MinDelayQ; + _scenParams->rxParams->txR0MinDelayQ = scenGenHw.rxParams.txR0MinDelayQ; + _scenParams->rxParams->rxFocusPointNumber = scenGenHw.rxParams.rxFocusPointNumber; + _scenParams->rxParams->rxActiveElementStep = scenGenHw.rxParams.rxActiveElementStep; + _scenParams->rxParams->rxR0ActiveElementNumber = scenGenHw.rxParams.rxR0ActiveElementNumber; + _scenParams->rxParams->interceptPointFiringTime = scenGenHw.rxParams.interceptPointFiringTime; + _scenParams->rxParams->rxR0CenterActiveElementNumber = scenGenHw.rxParams.rxR0CenterActiveElementNumber; - this->setScenario(scenParams); + this->setScenario(_scenParams); } -void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) +void TrxBoard::setScenario (ScenGenHardwareParam* _scenParams) { ///////////////////////////////// BeamFormer setting /////////////////////////////// QList > elementPosition; @@ -608,7 +633,7 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) QList z; //_signedQntzrVec.clear(); - _unsignedQntzrVec = Calculation::qntzr(scenParams->hwRegister->elementPosition->xPosition, + _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->elementPosition->xPosition, 1, 18, 0, @@ -619,7 +644,7 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) QList xPosQ = _unsignedQntzrVec.toList(); //QList xPosQ = signedVector2unsignedList(_signedQntzrVec); - _unsignedQntzrVec = Calculation::qntzr(scenParams->hwRegister->elementPosition->yPosition, + _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->elementPosition->yPosition, 1, 18, 0, @@ -629,7 +654,7 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) true); QList yPosQ = _unsignedQntzrVec.toList(); - _unsignedQntzrVec = Calculation::qntzr(scenParams->hwRegister->elementPosition->zPosition, + _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->elementPosition->zPosition, 0, 17, 0, @@ -674,44 +699,44 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) } scenParamsFilling(set); - this->_beamFormerSlave0->rxBeamformerProperties(scenParams->hwRegister->rxBeamFormerTypeNumber, - scenParams->hwRegister->rxBeamformer); - this->_beamFormerSlave1->rxBeamformerProperties(scenParams->hwRegister->rxBeamFormerTypeNumber, - scenParams->hwRegister->rxBeamformer); - this->_beamFormerSlave2->rxBeamformerProperties(scenParams->hwRegister->rxBeamFormerTypeNumber, - scenParams->hwRegister->rxBeamformer); + this->_beamFormerSlave0->rxBeamformerProperties(_scenParams->hwRegister->rxBeamFormerTypeNumber, + _scenParams->hwRegister->rxBeamformer); + this->_beamFormerSlave1->rxBeamformerProperties(_scenParams->hwRegister->rxBeamFormerTypeNumber, + _scenParams->hwRegister->rxBeamformer); + this->_beamFormerSlave2->rxBeamformerProperties(_scenParams->hwRegister->rxBeamFormerTypeNumber, + _scenParams->hwRegister->rxBeamformer); scenParamsFilling(set); - this->_beamFormerSlave0->pulseProperties(scenParams->hwRegister->pulseTypeNumber, - scenParams->hwRegister->pulse); - this->_beamFormerSlave1->pulseProperties(scenParams->hwRegister->pulseTypeNumber, - scenParams->hwRegister->pulse); - this->_beamFormerSlave2->pulseProperties(scenParams->hwRegister->pulseTypeNumber, - scenParams->hwRegister->pulse); + this->_beamFormerSlave0->pulseProperties(_scenParams->hwRegister->pulseTypeNumber, + _scenParams->hwRegister->pulse); + this->_beamFormerSlave1->pulseProperties(_scenParams->hwRegister->pulseTypeNumber, + _scenParams->hwRegister->pulse); + this->_beamFormerSlave2->pulseProperties(_scenParams->hwRegister->pulseTypeNumber, + _scenParams->hwRegister->pulse); scenParamsFilling(set); -////this->_beamFormerSlave0->afeLut(scenParams->hwRegister->afe); -////this->_beamFormerSlave1->afeLut(scenParams->hwRegister->afe); -////this->_beamFormerSlave2->afeLut(scenParams->hwRegister->afe); +////this->_beamFormerSlave0->afeLut(_scenParams->hwRegister->afe); +////this->_beamFormerSlave1->afeLut(_scenParams->hwRegister->afe); +////this->_beamFormerSlave2->afeLut(_scenParams->hwRegister->afe); ////scenParamsFilling(set); ///////////////////////////////// DSP setting /////////////////////////////// - this->_dsp->receiverConfigurationLut(scenParams->hwRegister->receiverConfigTypeNumber, - scenParams->hwRegister->configLut); + this->_dsp->receiverConfigurationLut(_scenParams->hwRegister->receiverConfigTypeNumber, + _scenParams->hwRegister->configLut); - _unsignedQntzrVec = Calculation::qntzr(scenParams->hwRegister->freqLut, 0, 24, 0, 0, true); + _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->freqLut, 0, 24, 0, 0, true); QList freqLutQ = _unsignedQntzrVec.toList(); this->_dsp->frequencyLut(freqLutQ); _unsignedQntzrVec = - Calculation::qntzr(scenParams->hwRegister->dtgcLut, 0, 12, 8, 0, true, false); + Calculation::qntzr(_scenParams->hwRegister->dtgcLut, 0, 12, 8, 0, true, false); QList dtgcLutQ = _unsignedQntzrVec.toList(); this->_dsp->dtgcLut(dtgcLutQ); QList temp; QList > blendWeightQ; //_signedQntzrVec.clear(); - foreach(auto vec, scenParams->hwRegister->blendWeight) + foreach(auto vec, _scenParams->hwRegister->blendWeight) { temp.clear(); _unsignedQntzrVec = Calculation::qntzr(vec, 0, 9, 8, 0, true, false, true); @@ -721,19 +746,19 @@ void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) this->_dsp->blendWeight(blendWeightQ); ///////////////////////////////// Sram setting /////////////////////////////// - this->_sram->setSramIndex(scenParams->totalTxShotNumber, scenParams->indexParams); + this->_sram->setSramIndex(_scenParams->totalTxShotNumber, _scenParams->indexParams); - this->_sram->setSramTx(scenParams->focusTypeNumber, scenParams->txParams); + this->_sram->setSramTx(_scenParams->focusTypeNumber, _scenParams->txParams); - this->_sram->setSramRx(scenParams->rxBeamFormerNumber, - scenParams->focusTypeNumber, - scenParams->rxParams); + this->_sram->setSramRx(_scenParams->rxBeamFormerNumber, + _scenParams->focusTypeNumber, + _scenParams->rxParams); scenParamsFilling(set); ////////////////////////////// Scen Index setting //////////////////////////// - this->_scenPlayer->setStartIndex(scenParams->scenarioStartIndex); - this->_scenPlayer->setEndIndex(scenParams->scenarioEndIndex); + this->_scenPlayer->setStartIndex(_scenParams->scenarioStartIndex); + this->_scenPlayer->setEndIndex(_scenParams->scenarioEndIndex); } void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) @@ -795,43 +820,32 @@ void TrxBoard::setFramesMetaData(const QByteArray& metaData) const void TrxBoard::setBiteDacData(const QByteArray &iData, const QByteArray &qData) const { + this->_builtInTest->biteDacEnable(BITE_INTERVAL, false); this->_builtInTest->biteDacMemoryWrite(iData, qData); } void TrxBoard::biteScenPlayerStart() { - DebugMode debug; - DebugMode debugRb; - debug.rxBfDbgModeEn = false; - debug.rxBfSimDataGenModeEn = false; - debug.txBfTestModeEn = true; - debug.txBfTestModeCfg = pulserTr; + setDebuggerMode(pulserTr, true); - this->debuggerMode(_debugSlave0, debug, debugRb, "slave0"); - this->debuggerMode(_debugSlave1, debug, debugRb, "slave1"); - this->debuggerMode(_debugSlave2, debug, debugRb, "slave2"); + setAdgCfg(adgIQ); + + setTxDacEnable(BITE_INTERVAL, true); - this->_builtInTest->biteAdgCfg(adgIQ); - this->_builtInTest->biteDacEnable(BITE_INTERVAL, true); this->scenPlayerStart(true); } void TrxBoard::biteScenPlayerStop() { - DebugMode debug; - DebugMode debugRb; - debug.rxBfDbgModeEn = false; - debug.rxBfSimDataGenModeEn = false; - debug.txBfTestModeEn = false; - debug.txBfTestModeCfg = pulserHz; - this->scenPlayerStop(true); - this->_builtInTest->biteDacEnable(BITE_INTERVAL, false); - this->_builtInTest->biteAdgCfg(adgGnd); - this->debuggerMode(_debugSlave0, debug, debugRb, "slave0"); - this->debuggerMode(_debugSlave1, debug, debugRb, "slave1"); - this->debuggerMode(_debugSlave2, debug, debugRb, "slave2"); + setTxDacEnable(BITE_INTERVAL, false); + + setAdgCfg(adgGnd); + + setDebuggerMode(pulserHz, true); + setDebuggerMode(pulserHz, false); + } void TrxBoard::setScenarioCompare(const QString scenPath) @@ -1020,13 +1034,25 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) return afeRegValue; } +void TrxBoard::setAdgCfg(eBiteDacOutput adg) const +{ + this->_builtInTest->biteAdgCfg(adg); +} + +void TrxBoard::setTxDacEnable(quint8 biteInterval, bool cmd) const +{ + this->_builtInTest->biteDacEnable(biteInterval, cmd); +} + void TrxBoard::slaveFpgaProgram(const QString path) { scenParamsFilling(clear); fpgaProgram (path); +#ifndef DEVELOP_UI afeAdcsSync(); +#endif } void TrxBoard::setBeamFormerMode(eClkMode mode) const @@ -1544,12 +1570,20 @@ void TrxBoard::selectProbe(eSelectProbe prbSel) void TrxBoard::getHealthStatus(HealthStatus* healStat) const { -//healStat->criticalComponentTemperature = this->_bCtrlMngt->getTrxFpgaTemp(); - healStat->systemTemperature = this->_bCtrlMngt->getTrxTempSensor(); - this->_bCtrlMngt->getTrxBoardVoltages(_adc, _pg); - this->_bCtrlMngt->getTrxVoltagesPg(_pg); - healStat->adcMon = _adc; - healStat->voltsPg = _pg; + this->_bCtrlMngt->getFanRpm(_tachoRpm); + this->_bCtrlMngt->getTrxVoltagesPg(_pg); + this->_bCtrlMngt->getFpgaTemp(_coreTemp); + this->_bCtrlMngt->getTrxBoardVoltages(_adc, _pg); + this->_bCtrlMngt->getFpgaVccInt(_coreVolt->vccInt); + this->_bCtrlMngt->getFpgaVccAux(_coreVolt->vccAux); + this->_bCtrlMngt->getFpgaVccBram(_coreVolt->vccBram); + + healStat->voltsPg = _pg; + healStat->adcMon = _adc; + healStat->fanRpm = _tachoRpm; + healStat->fpgaCoreVoltages = _coreVolt; + healStat->fpgaCoreTemperature = _coreTemp; + healStat->systemTemperature = this->_bCtrlMngt->getTrxTempSensor(); } void TrxBoard::mcsProgram(QString path) @@ -1592,7 +1626,7 @@ void TrxBoard::mcsVerify(QString path) const QTextStream save(&mcsFile); - this->_bpiFlash->readMcs(&mcsList); + mcsList = this->_bpiFlash->readMcs(); for(auto i = 0; i < MCS_FILE_SIZE; i++) { @@ -1624,7 +1658,15 @@ quint32 TrxBoard::getFrameLostCounter() const return (this->_misc->getFrameLostCount()); } -void TrxBoard::adcCaptureStart(captureConfig &capCfg, eSyncMode syncMode) +void TrxBoard::adcCaptureConfig(captureConfig &capCfg) const +{ + // ADC capture config + this->_debugSlave0->adcLoggerConfig(capCfg); + this->_debugSlave1->adcLoggerConfig(capCfg); + this->_debugSlave2->adcLoggerConfig(capCfg); +} + +void TrxBoard::adcCaptureStart(void) const { // ADC capture reset this->_debugSlave0->adcLoggerRst(true); @@ -1634,43 +1676,36 @@ void TrxBoard::adcCaptureStart(captureConfig &capCfg, eSyncMode syncMode) this->_debugSlave1->adcLoggerRst(false); this->_debugSlave2->adcLoggerRst(false); - // ADC capture config - this->_debugSlave0->adcLoggerConfig(capCfg); - this->_debugSlave1->adcLoggerConfig(capCfg); - this->_debugSlave2->adcLoggerConfig(capCfg); - - // Sync mode config in case of the manual sync is selected - if (syncMode == manualSync) - { - this->_misc->setSyncMode(bfAdcLogMode); - this->_misc->setManualSync(true); - this->_misc->setManualSync(false); - this->_misc->setSyncMode(bfSyncMode); - } - - // ADC capture enable - this->_debugSlave0->adcCaptureCmd(captureStart); - + // ADC capture start + adcCaptureStart(_debugSlave0); + adcCaptureStart(_debugSlave1); + adcCaptureStart(_debugSlave2); +} +void TrxBoard::setCaptureManualSync(void) const +{ + this->_misc->setSyncMode(otherAdcLogMode); + this->_misc->setManualSync(true); + this->_misc->setManualSync(false); + this->_misc->setSyncMode(bfSyncMode); } -void TrxBoard::adcLoggerStart(const QString path) +void TrxBoard::adcCaptureDone(void) const { -// // Timeout to receive adc capture done. -// this->_bCtrlMngt->timerShot(100); -// while (!(_dbg->getCapDone())) -// { -// if(this->_bCtrlMngt->checkTimeout()) -// throw SonoException("Failure to receive adc capture done."); + waitForCaptureDone(_debugSlave0); + waitForCaptureDone(_debugSlave1); + waitForCaptureDone(_debugSlave2); -// } -// this->_bCtrlMngt->timerStop(); - //this->_debugSlave0->adcCaptureCmd(captureStop); + adcCaptureStop(_debugSlave0); + adcCaptureStop(_debugSlave1); + adcCaptureStop(_debugSlave2); +} +void TrxBoard::adcLoggerStart(const QString path, const QString fileName) +{ quint8 fpgaSel(0); quint8 chNumPerFpga(0); - QList adcDataList; QTime t = QTime::currentTime(); - QString logPath = path + "/adcLog_" + QString("%1_%2_%3.csv") + QString logPath = path + "/" + fileName + "_adcLog" + QString("_%1_%2_%3.csv") .arg(t.hour()) .arg(t.minute()) .arg(t.second()); @@ -1688,27 +1723,24 @@ void TrxBoard::adcLoggerStart(const QString path) } log << "SYNC Offset(ns): "; - log << this->_debugSlave0->getCapSyncOffset() * 5 << ','; - log << this->_debugSlave1->getCapSyncOffset() * 5 << ','; - log << this->_debugSlave2->getCapSyncOffset() * 5 << ','; - log << endl; + log << this->_debugSlave0->getCapSyncOffset() * 5 << ", "; + log << this->_debugSlave1->getCapSyncOffset() * 5 << ", "; + log << this->_debugSlave2->getCapSyncOffset() * 5 << endl; log << "ADC Sample Latancy(ns): "; - log << this->_afeSlave0->getAdcLatency() * 2.5f << ','; - log << this->_afeSlave1->getAdcLatency() * 2.5f << ','; - log << this->_afeSlave2->getAdcLatency() * 2.5f << ','; - log << endl; + log << this->_afeSlave0->getAdcLatency() * 2.5f << ", "; + log << this->_afeSlave1->getAdcLatency() * 2.5f << ", "; + log << this->_afeSlave2->getAdcLatency() * 2.5f << endl; log << "ADC Sample Logger Offset(sample): "; - log << this->_debugSlave0->getCaptureSampleNo() << ','; - log << this->_debugSlave1->getCaptureSampleNo() << ','; - log << this->_debugSlave2->getCaptureSampleNo() << ','; - log << endl; + log << this->_debugSlave0->getCaptureSampleNo() << ", "; + log << this->_debugSlave1->getCaptureSampleNo() << ", "; + log << this->_debugSlave2->getCaptureSampleNo() << endl; - // Set gt to adc mode + // Set gt to adc mode. this->_misc->setGtSendMode(adcMode); - // Stop adc log transfer + // Stop adc log transfer. this->_debugSlave0->adcLoggerTransferCmd(loggerStop); this->_debugSlave1->adcLoggerTransferCmd(loggerStop); this->_debugSlave2->adcLoggerTransferCmd(loggerStop); @@ -1718,7 +1750,7 @@ void TrxBoard::adcLoggerStart(const QString path) fpgaSel = chNum / AFE_CHANNEL_NUM_PER_SLAVE; chNumPerFpga = chNum % AFE_CHANNEL_NUM_PER_SLAVE; - // ADC sampler start according to selected fpga + // ADC sampler start according to selected fpga. this->_misc->setAdcSamplerCmd(samplerStop); this->_misc->setAdcSamplerFpgaSel(fpgaSel); this->_misc->setAdcSamplerCmd(samplerStart); @@ -1738,21 +1770,49 @@ void TrxBoard::adcLoggerStart(const QString path) break; } - // Read adc data bram - this->_misc->getAdcDataBram(&adcDataList); + // Read adc data bram. + QList adcDataList = this->_misc->getAdcDataBram(); foreach (auto data, adcDataList) { log << data << ','; } log << endl; - // ADC sampler stop + // ADC sampler stop. this->_misc->setAdcSamplerCmd(samplerStop); } logFile.flush(); logFile.close(); - // Set gt to beamformer mode + // Set gt to beamformer mode. this->_misc->setGtSendMode(bfMode); } + +void TrxBoard::setDebuggerMode(eDebugMode bfMode, bool enable) +{ + DebugMode debug; + DebugMode debugRb; + debug.rxBfDbgModeEn = false; + debug.rxBfSimDataGenModeEn = false; + debug.txBfTestModeEn = enable; + debug.txBfTestModeCfg = bfMode; + + this->debuggerMode(_debugSlave0, debug, debugRb, "slave0"); + this->debuggerMode(_debugSlave1, debug, debugRb, "slave1"); + this->debuggerMode(_debugSlave2, debug, debugRb, "slave2"); +} + +void TrxBoard::setAfeConfig(AfeConfig& afeCfg) const +{ + this->_afeSlave0->setAfeParams(afeCfg); + this->_afeSlave1->setAfeParams(afeCfg); + this->_afeSlave2->setAfeParams(afeCfg); +} + +void TrxBoard::setAfePwr(eAfePwrdnMode pwrMode) const +{ + this->_afeSlave0->setAfeGblPwr(pwrMode); + this->_afeSlave1->setAfeGblPwr(pwrMode); + this->_afeSlave2->setAfeGblPwr(pwrMode); +} diff --git a/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp b/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp index 3475e65..d9a528c 100644 --- a/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp +++ b/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp @@ -60,10 +60,9 @@ void BoardsCtrlMngt::eepromWrite(QByteArray& arr, timerStop(); timerShot(6); //must be >= 4 - while(!checkTimeout()) - { - ; - } + // uncrustify off + while(!checkTimeout()); + // uncrustify on //_rom->dataIn = static_cast(i.toLatin1()); _rom->dataIn = i; @@ -191,10 +190,20 @@ void BoardsCtrlMngt::setEepromRead(BoardsCtrlMngt::EepromReq* _rom, T6* request) /***************************************************************************************************/ /***************************************************************************************************/ +template +float BoardsCtrlMngt::fanTacho(T7 *tachoMean) +{ + tachoMean->sync(); + quint32 meanValue = tachoMean->fanTachoMean->getValue(); + if (meanValue==0) + return 0.0f; + else + return (60.0f / (meanValue / F_SYS_CLK)); +} + float BoardsCtrlMngt::resDiv(float r1, float r2, quint32 adcValue) { float result = (static_cast(adcValue)) * (r1 + r2) / (r2 * 1000); - return result; } @@ -208,6 +217,40 @@ QVector BoardsCtrlMngt::voltPg(float adcVolt) return pgVec; } + +float BoardsCtrlMngt::fpgaVoltage(quint32 coreVolt) const +{ + return ((coreVolt / 4096.0f) * 3.0f); +} + +float BoardsCtrlMngt::fpgaTemp(FpgaXadc1 *coreTemp) const +{ + coreTemp->sync(); + quint32 temp = coreTemp->fpgaCoreTemp->getValue(); + return (((temp / 4096.0f) * 503.975f) - 273.15f); +} + +float BoardsCtrlMngt::fpgaVccInt(FpgaXadc1 *coreVccInt) const +{ + coreVccInt->sync(); + quint32 vccInt = coreVccInt->fpgaVccInt->getValue(); + return (fpgaVoltage(vccInt)); +} + +float BoardsCtrlMngt::fpgaVccAux(FpgaXadc2 *coreVccAux) const +{ + coreVccAux->sync(); + quint32 VccAux = coreVccAux->fpgaVccAux->getValue(); + return (fpgaVoltage(VccAux)); +} + +float BoardsCtrlMngt::fpgaVccBram(FpgaXadc2 *coreVccBram) const +{ + coreVccBram->sync(); + quint32 VccBram = coreVccBram->fpgaVccBram->getValue(); + return (fpgaVoltage(VccBram)); +} + float BoardsCtrlMngt::getCWdpValue() const { _sRbCwdp->sync(); @@ -527,8 +570,7 @@ void BoardsCtrlMngt::prbCtrlInit() const float BoardsCtrlMngt::getTrxTempSensor() const { this->_tempSensor->sync(); - qint32 temp = static_cast(this->_tempSensor->temperature->getValue()); - + qint16 temp = static_cast(this->_tempSensor->temperature->getValue()); return (temp * TEMP_SENSOR_RESOLUTION); } @@ -614,10 +656,9 @@ void BoardsCtrlMngt::getSupervisorValue(SupervisorRbValue* sValue) const getSupervisorI2cDone(); timerShot(72); - while(!checkTimeout()) - { - ; - } + // uncrustify off + while(!checkTimeout()); + // uncrustify on getSupervisorI2cTimeout(); setReadbackCmd(false, true, false); //avgValueCommand_pulse @@ -755,6 +796,44 @@ void BoardsCtrlMngt::mpsHvSet(float& hva, float& hvb) const } } +void BoardsCtrlMngt::getFpgaTemp(criticalComponentTemperature *coreTemp) +{ + coreTemp->master = this->fpgaTemp(_mXadc1); + coreTemp->slave0 = this->fpgaTemp(_s0Xadc1); + coreTemp->slave1 = this->fpgaTemp(_s1Xadc1); + coreTemp->slave2 = this->fpgaTemp(_s2Xadc1); +} + +void BoardsCtrlMngt::getFpgaVccInt(FpgaVccInt &coreVcc) +{ + coreVcc.master = this->fpgaVccInt(_mXadc1); + coreVcc.slave0 = this->fpgaVccInt(_s0Xadc1); + coreVcc.slave1 = this->fpgaVccInt(_s1Xadc1); + coreVcc.slave2 = this->fpgaVccInt(_s2Xadc1); +} + +void BoardsCtrlMngt::getFpgaVccAux(FpgaVccAux &coreAux) +{ + coreAux.master = this->fpgaVccAux(_mXadc2); + coreAux.slave0 = this->fpgaVccAux(_s0Xadc2); + coreAux.slave1 = this->fpgaVccAux(_s1Xadc2); + coreAux.slave2 = this->fpgaVccAux(_s2Xadc2); +} + +void BoardsCtrlMngt::getFpgaVccBram(FpgaVccBram &coreBram) +{ + coreBram.master = this->fpgaVccBram(_mXadc2); + coreBram.slave0 = this->fpgaVccBram(_s0Xadc2); + coreBram.slave1 = this->fpgaVccBram(_s1Xadc2); + coreBram.slave2 = this->fpgaVccBram(_s2Xadc2); +} + +void BoardsCtrlMngt::getFanRpm(FanRpm *_rpm) +{ + _rpm->fan1 = this->fanTacho(_fanTacho1); + _rpm->fan2 = this->fanTacho(_fanTacho2); +} + QByteArray BoardsCtrlMngt::trxEepromRead(quint32 address, quint32 length) { if(address + length >= TRX_ROM_MAX_LEN) diff --git a/src/model/hardware/core/register/bpiFlash/BpiFlash.cpp b/src/model/hardware/core/register/bpiFlash/BpiFlash.cpp index 2f11497..b6c45da 100644 --- a/src/model/hardware/core/register/bpiFlash/BpiFlash.cpp +++ b/src/model/hardware/core/register/bpiFlash/BpiFlash.cpp @@ -38,9 +38,9 @@ void BpiFlash::writeMcs(QByteArray& mcs) const this->_mcsRdWr->updateArray(); } -void BpiFlash::readMcs(QList* mcs) const +QList BpiFlash::readMcs(void) const { this->_mcsRdWr->mcsListRd.clear(); this->_mcsRdWr->syncArray(); - mcs = &(this->_mcsRdWr->mcsListRd); + return (this->_mcsRdWr->mcsListRd); } diff --git a/src/model/hardware/core/register/misc/Misc.cpp b/src/model/hardware/core/register/misc/Misc.cpp index 207730d..4b3c754 100644 --- a/src/model/hardware/core/register/misc/Misc.cpp +++ b/src/model/hardware/core/register/misc/Misc.cpp @@ -114,11 +114,11 @@ bool Misc::getAdcSamplerError() const return (this->_adcSamplerStatus->error->getValue() != 0); } -void Misc::getAdcDataBram(QList *adcDataList) const +QList Misc::getAdcDataBram(void) const { this->_adcDataBram->adcDataList.clear(); this->_adcDataBram->syncArray(); - adcDataList = &(this->_adcDataBram->adcDataList); + return (this->_adcDataBram->adcDataList); } void Misc::getFpgaVersion(FpgaCodeVersion *version) const