From 9601096c43c815fc5d9b83631ab24b5a113aee1b Mon Sep 17 00:00:00 2001 From: Arash Aletayeb Date: Sun, 20 Jun 2021 10:26:17 +0200 Subject: [PATCH] DMA Busy is added Scen stop calling is depend to scen start Set scenario compare is added Eeproms are modified to new structures --- developHw.pro | 5 +- developHw.pro.user | 6 +- hdf5Scenario/hdf5Scenario.cpp | 676 +++++++ hdf5Scenario/hdf5Scenario.h | 35 + include/model/hardware/core/TrxBoard.h | 96 +- .../core/TrxBoardUtils/PreProcessorDef.h | 10 + .../core/TrxBoardUtils/ScenParamsRanges.h | 28 + .../core/TrxBoardUtils/TrxBoardEnums.h | 12 + .../core/TrxBoardUtils/TrxBoardStructures.h | 30 +- .../afe/registerDefinition/AdcSyncStatus.h | 37 + .../core/register/fpgaProgram/FpgaProgram.h | 1 + .../core/register/scenPlayer/ScenPlayer.h | 3 +- .../register/sram/registerDefinition/Index.h | 2 + include/model/hardware/device/SonoDevice.h | 1 + .../dto/hardware/HardwareOutput.h | 15 +- .../dto/hardware/HwScenarioDependent.h | 1 + mainwindow.cpp | 1778 +++++------------ mainwindow.h | 99 +- mainwindow.ui | 1090 +++++----- src/model/hardware/core/TrxBoard.cpp | 629 ++++-- .../boardsCtrlMngt/BoardsCtrlMngt.cpp | 10 +- .../core/register/fpgaProgram/FpgaProgram.cpp | 23 +- .../core/register/scenPlayer/ScenPlayer.cpp | 9 +- src/model/hardware/device/SonoDevice.cpp | 9 +- 24 files changed, 2434 insertions(+), 2171 deletions(-) create mode 100644 hdf5Scenario/hdf5Scenario.cpp create mode 100644 hdf5Scenario/hdf5Scenario.h create mode 100644 include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h create mode 100644 include/model/hardware/core/TrxBoardUtils/ScenParamsRanges.h create mode 100644 include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h diff --git a/developHw.pro b/developHw.pro index fa1dbc7..ba8cd92 100644 --- a/developHw.pro +++ b/developHw.pro @@ -21,13 +21,16 @@ SOURCES += \ mainwindow.cpp \ qcustomplot.cpp \ api.cpp \ - $$files(src/*.cpp, true) + $$files(src/*.cpp, true) \ + $$files(hdf5Scenario/*.cpp, true) \ HEADERS += \ + include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h \ mainwindow.h \ qcustomplot.h \ api.h \ $$files(include/*.h, true) + $$files(hdf5Scenario/*.h, true) INCLUDEPATH += \ "$$PWD/include" \ diff --git a/developHw.pro.user b/developHw.pro.user index 404eb68..284c63c 100644 --- a/developHw.pro.user +++ b/developHw.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -304,8 +304,8 @@ 2 developHw - developHw2 - Qt4ProjectManager.Qt4RunConfiguration:/home/hasis/Desktop/New/Develop_HardwareTest/developHw/developHw.pro + + Qt4ProjectManager.Qt4RunConfiguration:/home/hasis/Desktop/Develop_HardwareTest/developHw/developHw.pro 3768 false diff --git a/hdf5Scenario/hdf5Scenario.cpp b/hdf5Scenario/hdf5Scenario.cpp new file mode 100644 index 0000000..1436732 --- /dev/null +++ b/hdf5Scenario/hdf5Scenario.cpp @@ -0,0 +1,676 @@ +#include "hdf5Scenario.h" + +template +void Hdf5::datasetBranch(const string &branchPath, T datasetValue[MAX_ARRAY_DEPTH]) +{ + const H5std_string datasetPath(branchPath); + DataSet datasetType = _file.openDataSet(datasetPath); + + datasetType.read(datasetValue, PredType::NATIVE_FLOAT, H5S_ALL, H5S_ALL); +} + +void Hdf5::hdf5Path(const string &h5Path) +{ + const H5std_string filePath(h5Path); + H5File file (filePath, H5F_ACC_RDONLY); + _file = file; +} + +void Hdf5::scenarioRead(ScenGenHardwareOutput_t &scenParams) +{ + /****************** /sramParameters/frameType ******************/ + datasetBranch ("/sramParameters/frameType", floatArray); + scenParams.frameType = static_cast(floatArray[0]); + + /****************** /sramParameters/totalTxShotNo ******************/ + datasetBranch ("/sramParameters/totalTxShotNo", floatArray); + scenParams.totalTxShotNumber = static_cast(floatArray[0]); + + /******************* /sramParameters/focusTypeNo *******************/ + datasetBranch ("/sramParameters/focusTypeNo", floatArray); + scenParams.focusTypeNumber = static_cast(floatArray[0]); + + /******************* /sramParameters/rxBeamformerNo *******************/ + datasetBranch ("/sramParameters/rxBeamformerNo", floatArray); + scenParams.rxBeamFormerNumber.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.rxBeamFormerNumber.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/pulseInterval ********************/ + datasetBranch ("/sramParameters/pulseInterval", floatArray); + scenParams.pulseInterval.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.pulseInterval.push_back(floatArray[var]); + + /**************** /sramParameters/indexParameters/shotPropertiesIndex ********************/ + datasetBranch ("/sramParameters/indexParameters/shotPropertiesIndex", floatArray); + scenParams.indexParams.shotPropertiesIndex.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.shotPropertiesIndex.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/indexParameters/pulsePropertiesIndex ********************/ + datasetBranch ("/sramParameters/indexParameters/pulsePropertiesIndex", floatArray); + scenParams.indexParams.pulsePropertiesIndex.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.pulsePropertiesIndex.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/indexParameters/receiverConfigurationIndex ********************/ + datasetBranch ("/sramParameters/indexParameters/receiverConfigurationIndex", floatArray); + scenParams.indexParams.receiverConfigurationIndex.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.receiverConfigurationIndex.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/indexParameters/firstLineInFrame ********************/ + datasetBranch ("/sramParameters/indexParameters/firstLineInFrame", floatArray); + scenParams.indexParams.firstLineInFrame.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.firstLineInFrame.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/indexParameters/lastLineInFrame ********************/ + datasetBranch ("/sramParameters/indexParameters/lastLineInFrame", floatArray); + scenParams.indexParams.lastLineInFrame.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.lastLineInFrame.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/indexParameters/dLineNum ********************/ + datasetBranch ("/sramParameters/indexParameters/dLineNum", floatArray); + scenParams.indexParams.dLineNum.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.dLineNum.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/indexParameters/dEnsembleNum ********************/ + datasetBranch ("/sramParameters/indexParameters/dEnsembleNum", floatArray); + scenParams.indexParams.dEnsembleNum.clear(); + for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) + scenParams.indexParams.dEnsembleNum.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/txParameters/txFocusXPos ********************/ + datasetBranch ("/sramParameters/txParameters/txFocusXPos", floatArray); + scenParams.txParams.txFocusXPos.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.txParams.txFocusXPos.push_back(floatArray[var]); + + /**************** /sramParameters/txParameters/txFocusYPos ********************/ + datasetBranch ("/sramParameters/txParameters/txFocusYPos", floatArray); + scenParams.txParams.txFocusYPos.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.txParams.txFocusYPos.push_back(floatArray[var]); + + /**************** /sramParameters/txParameters/txFocusZPos ********************/ + datasetBranch ("/sramParameters/txParameters/txFocusZPos", floatArray); + scenParams.txParams.txFocusZPos.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.txParams.txFocusZPos.push_back(floatArray[var]); + + /**************** /sramParameters/txParameters/txStartActiveElementNo ********************/ + datasetBranch ("/sramParameters/txParameters/txStartActiveElementNo", floatArray); + scenParams.txParams.txStartActiveElementNumber.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.txParams.txStartActiveElementNumber.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/txParameters/txActiveElementNo ********************/ + datasetBranch ("/sramParameters/txParameters/txActiveElementNo", floatArray); + scenParams.txParams.txActiveElementNumber.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.txParams.txActiveElementNumber.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/txParameters/maxDelayQ ********************/ + datasetBranch ("/sramParameters/txParameters/maxDelayQ", floatArray); + scenParams.txParams.maxDelayQ.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.txParams.maxDelayQ.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/rxParameters/rxR0CenterActiveElementNo ********************/ + datasetBranch ("/sramParameters/rxParameters/rxR0CenterActiveElementNo", floatArray); + scenParams.rxParams.rxR0CenterActiveElementNumber.clear(); + quint32 accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.rxR0CenterActiveElementNumber.push_back(static_cast(floatArray[accum])); + accum++; + } + + /**************** /sramParameters/rxParameters/rxR0ActiveElementNo ********************/ + datasetBranch ("/sramParameters/rxParameters/rxR0ActiveElementNo", floatArray); + scenParams.rxParams.rxR0ActiveElementNumber.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.rxR0ActiveElementNumber.push_back(static_cast(floatArray[accum])); + accum++; + } + + /**************** /sramParameters/rxParameters/rxActiveElementStep ********************/ + datasetBranch ("/sramParameters/rxParameters/rxActiveElementStep", floatArray); + scenParams.rxParams.rxActiveElementStep.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.rxParams.rxActiveElementStep.push_back(floatArray[var]); + + /**************** /sramParameters/rxParameters/interceptPointFiringTime ********************/ + datasetBranch ("/sramParameters/rxParameters/interceptPointFiringTime", floatArray); + scenParams.rxParams.interceptPointFiringTime.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.rxParams.interceptPointFiringTime.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/rxParameters/rxFocusPointNo ********************/ + datasetBranch ("/sramParameters/rxParameters/rxFocusPointNo", floatArray); + scenParams.rxParams.rxFocusPointNumber.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.rxParams.rxFocusPointNumber.push_back(static_cast(floatArray[var])); + + /**************** /sramParameters/rxParameters/r0Position ********************/ + datasetBranch ("/sramParameters/rxParameters/r0Position", floatArray); + scenParams.rxParams.r0Position.clear(); + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + scenParams.rxParams.r0Position.push_back(floatArray[var]); + + /**************** /sramParameters/rxParameters/thetaCos ********************/ + datasetBranch ("/sramParameters/rxParameters/thetaCos", floatArray); + scenParams.rxParams.thetaCos.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.thetaCos.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/thetaSin ********************/ + datasetBranch ("/sramParameters/rxParameters/thetaSin", floatArray); + scenParams.rxParams.thetaSin.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.thetaSin.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/phiCos ********************/ + datasetBranch ("/sramParameters/rxParameters/phiCos", floatArray); + scenParams.rxParams.phiCos.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.phiCos.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/phiSin ********************/ + datasetBranch ("/sramParameters/rxParameters/phiSin", floatArray); + scenParams.rxParams.phiSin.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.phiSin.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/interceptXPos ********************/ + datasetBranch ("/sramParameters/rxParameters/interceptXPos", floatArray); + scenParams.rxParams.interceptXPos.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.interceptXPos.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/interceptYPos ********************/ + datasetBranch ("/sramParameters/rxParameters/interceptYPos", floatArray); + scenParams.rxParams.interceptYPos.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.interceptYPos.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/interceptZPos ********************/ + datasetBranch ("/sramParameters/rxParameters/interceptZPos", floatArray); + scenParams.rxParams.interceptZPos.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.interceptZPos.push_back(floatArray[accum]); + accum++; + } + + /**************** /sramParameters/rxParameters/txR0MinDelayQ ********************/ + datasetBranch ("/sramParameters/rxParameters/txR0MinDelayQ", floatArray); + scenParams.rxParams.txR0MinDelayQ.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.txR0MinDelayQ.push_back(static_cast(floatArray[accum])); + accum++; + } + + /**************** /sramParameters/rxParameters/rxR0MinDelayQ ********************/ + datasetBranch ("/sramParameters/rxParameters/rxR0MinDelayQ", floatArray); + scenParams.rxParams.rxR0MinDelayQ.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.rxR0MinDelayQ.push_back(static_cast(floatArray[accum])); + accum++; + } + + /**************** /sramParameters/rxParameters/rxR0MaxDelayQ ********************/ + datasetBranch ("/sramParameters/rxParameters/rxR0MaxDelayQ", floatArray); + scenParams.rxParams.rxR0MaxDelayQ.clear(); + accum = 0; + for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) + for (quint8 var1 = 0; var1 < scenParams.rxBeamFormerNumber[static_cast(var)]; var1++) + { + scenParams.rxParams.rxR0MaxDelayQ.push_back(static_cast(floatArray[accum])); + accum++; + } + + /**************** /registerParameters/pulseTypeNo ********************/ + datasetBranch ("/registerParameters/pulseTypeNo", floatArray); + scenParams.hwRegister.pulseTypeNumber = static_cast(floatArray[0]); + + /**************** /registerParameters/rxBeamformerTypeNo ********************/ + datasetBranch ("/registerParameters/rxBeamformerTypeNo", floatArray); + scenParams.hwRegister.rxBeamFormerTypeNumber = static_cast(floatArray[0]); + + /**************** /registerParameters/receiverConfigTypeNo ********************/ + datasetBranch ("/registerParameters/receiverConfigTypeNo", floatArray); + scenParams.hwRegister.receiverConfigTypeNumber = static_cast(floatArray[0]); + + /**************** /registerParameters/blendWeight ********************/ + datasetBranch ("/registerParameters/blendWeight", floatArray); + scenParams.hwRegister.blendWeight.clear(); + QVector tempBlendWeight; + + for (quint32 i = 0; i < 4; i++) + { + tempBlendWeight.clear(); + for (quint32 j = 0; j < 512; j++) + { + tempBlendWeight.push_back(floatArray[j + i * 512]); + } + scenParams.hwRegister.blendWeight.push_back(tempBlendWeight); + } + + /**************** /registerParameters/freqLut ********************/ + datasetBranch ("/registerParameters/freqLut", floatArray); + scenParams.hwRegister.freqLut.clear(); + for (quint32 var = 0; var < 8; var++) + scenParams.hwRegister.freqLut.push_back(floatArray[var]); + + /**************** /registerParameters/dTgcLut ********************/ + datasetBranch ("/registerParameters/dTgcLut", floatArray); + scenParams.hwRegister.dtgcLut.clear(); + for (quint32 var = 0; var < 1024; var++) + scenParams.hwRegister.dtgcLut.push_back(floatArray[var]); + + /**************** /registerParameters/elementXPositions ********************/ + datasetBranch ("/registerParameters/elementXPositions", floatArray); + scenParams.hwRegister.elementXPosition.clear(); + for (quint32 var = 0; var < 192; var++) + scenParams.hwRegister.elementXPosition.push_back(floatArray[var]); + + /**************** /registerParameters/elementYPositions ********************/ + datasetBranch ("/registerParameters/elementYPositions", floatArray); + scenParams.hwRegister.elementYPosition.clear(); + for (quint32 var = 0; var < 192; var++) + scenParams.hwRegister.elementYPosition.push_back(floatArray[var]); + + /**************** /registerParameters/elementZPositions ********************/ + datasetBranch ("/registerParameters/elementZPositions", floatArray); + scenParams.hwRegister.elementZPosition.clear(); + for (quint32 var = 0; var < 192; var++) + scenParams.hwRegister.elementZPosition.push_back(floatArray[var]); + + /**************** /registerParameters/scenarioStartIndex ********************/ + datasetBranch ("/registerParameters/scenarioStartIndex", floatArray); + scenParams.hwRegister.scenarioStartIndex = static_cast(floatArray[0]); + + /**************** /registerParameters/scenarioEndIndex ********************/ + datasetBranch ("/registerParameters/scenarioEndIndex", floatArray); + scenParams.hwRegister.scenarioEndIndex = static_cast(floatArray[0]); + + /**************** /registerParameters/pulseProperties/halfPeriod ********************/ + datasetBranch ("/registerParameters/pulseProperties/halfPeriod", floatArray); + QList halfPeriod; + + for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) + { + halfPeriod.push_back(static_cast(floatArray[j])); + } + + + /**************** /registerParameters/pulseProperties/halfCycleNo ********************/ + datasetBranch ("/registerParameters/pulseProperties/halfCycleNo", floatArray); + QList halfCycleNo; + + for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) + { + halfCycleNo.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/pulseProperties/pulseVoltSel ********************/ + datasetBranch ("/registerParameters/pulseProperties/pulseVoltSel", floatArray); + QList pulseVoltSel; + + for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) + { + pulseVoltSel.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/pulseProperties/startPhase ********************/ + datasetBranch ("/registerParameters/pulseProperties/startPhase", floatArray); + QList startPhase; + + for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) + { + startPhase.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/pulseProperties/dampingPulseWidth ********************/ + datasetBranch ("/registerParameters/pulseProperties/dampingPulseWidth", floatArray); + QList dampingPulseWidth; + + for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) + { + dampingPulseWidth.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/pulseProperties ********************/ + Pulse_t pulseObj; + scenParams.hwRegister.pulseProps.clear(); + + for (qint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) + { + pulseObj.halfPeriod = halfPeriod.at(j); + pulseObj.startPhase = startPhase.at(j); + pulseObj.halfCycleNo = halfCycleNo.at(j); + pulseObj.pulseVoltSel = pulseVoltSel.at(j); + pulseObj.dampingPulseWidth = dampingPulseWidth.at(j); + + scenParams.hwRegister.pulseProps.push_back(pulseObj); + } + + + /**************** /registerParameters/rxBeamformerProperties/mla ********************/ + datasetBranch ("/registerParameters/rxBeamformerProperties/mla", floatArray); + QList mla; + + for (quint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) + { + mla.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/rxBeamformerProperties/lag ********************/ + datasetBranch ("/registerParameters/rxBeamformerProperties/lag", floatArray); + QList lag; + + for (quint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) + { + lag.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/rxBeamformerProperties/apodizationSel ********************/ + datasetBranch ("/registerParameters/rxBeamformerProperties/apodizationSel", floatArray); + QList apodizationSel; + + for (quint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) + { + apodizationSel.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/rxBeamformerProperties ********************/ + RxBeamFormer_t rxBeamformerObj; + scenParams.hwRegister.rxBeamFormerProps.clear(); + + for (qint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) + { + rxBeamformerObj.mla = mla.at(j); + rxBeamformerObj.lag = lag.at(j); + rxBeamformerObj.apodizationSel = apodizationSel.at(j); + + scenParams.hwRegister.rxBeamFormerProps.push_back(rxBeamformerObj); + } + + + /**************** /registerParameters/receiverConfigProperties/mla ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/mla", floatArray); + QList receiverCfgMla; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + receiverCfgMla.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/lineMode ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/lineMode", floatArray); + QList lineMode; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + lineMode.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/aTgcSel ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/aTgcSel", floatArray); + QList aTgcSel; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + aTgcSel.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/stbEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/stbEn", floatArray); + QList stbEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + stbEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/stb ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/stb", floatArray); + QList stb; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + stb.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/subtractFilterEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/subtractFilterEn", floatArray); + QList subtractFilterEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + subtractFilterEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/dcCancelEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/dcCancelEn", floatArray); + QList dcCancelEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + dcCancelEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/ncoFreqSel ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/ncoFreqSel", floatArray); + QList ncoFreqSel; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + ncoFreqSel.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/lpfSel ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/lpfSel", floatArray); + QList lpfSel; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + lpfSel.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/absEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/absEn", floatArray); + QList absEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + absEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/focusNo ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/focusNo", floatArray); + QList focusNo; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + focusNo.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/lineFilterEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/lineFilterEn", floatArray); + QList lineFilterEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + lineFilterEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/dpeEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/dpeEn", floatArray); + QList dpeEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + dpeEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/ddcEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/ddcEn", floatArray); + QList ddcEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + ddcEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties/wmfEn ********************/ + datasetBranch ("/registerParameters/receiverConfigProperties/wmfEn", floatArray); + QList wmfEn; + + for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + wmfEn.push_back(static_cast(floatArray[j])); + } + + /**************** /registerParameters/receiverConfigProperties ********************/ + ReceiverConfig_t receiverCfgObj; + scenParams.hwRegister.receiverConfigProps.clear(); + + for (qint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) + { + receiverCfgObj.mla = receiverCfgMla.at(j); + receiverCfgObj.stb = stb.at(j); + receiverCfgObj.ddcn = ddcEn.at(j); + receiverCfgObj.absEn = absEn.at(j); + receiverCfgObj.dpeEn = dpeEn.at(j); + receiverCfgObj.stbEn = stbEn.at(j); + receiverCfgObj.wmfEn = wmfEn.at(j); + receiverCfgObj.lpfSel = lpfSel.at(j); + receiverCfgObj.aTgcSel = aTgcSel.at(j); + receiverCfgObj.focusNo = focusNo.at(j); + receiverCfgObj.lineMode = lineMode.at(j); + receiverCfgObj.dcCancelEn = dcCancelEn.at(j); + receiverCfgObj.ncoFreqSel = ncoFreqSel.at(j); + receiverCfgObj.lineFilterEn = lineFilterEn.at(j); + receiverCfgObj.subtractFilterEn = subtractFilterEn.at(j); + + scenParams.hwRegister.receiverConfigProps.push_back(receiverCfgObj); + } +} + + +void Hdf5::prbDependParamsRead(ScenPrbDepHardwareParam &prbDepParams) +{ + /**************** /registerParameters/apodizationLut ********************/ + datasetBranch ("/registerParameters/apodizationLut", floatArray); + prbDepParams.prbDepParams.apodizationLut.clear(); + QVector tempApodization; + + for (quint32 i = 0; i < 4; i++) + { + tempApodization.clear(); + for (quint32 j = 0; j < 3057; j++) + { + tempApodization.push_back(static_cast(floatArray[j + i * 3057])); + } + prbDepParams.prbDepParams.apodizationLut.push_back(tempApodization); + } + + /**************** /registerParameters/aTgcLut ********************/ + datasetBranch ("/registerParameters/aTgcLut", floatArray); + prbDepParams.prbDepParams.atgcLut.clear(); + QVector tempAtgc; + + for (quint32 i = 0; i < 4; i++) + { + tempAtgc.clear(); + for (quint32 j = 0; j < 128; j++) + { + tempAtgc.push_back(static_cast(floatArray[j + i * 128])); + } + prbDepParams.prbDepParams.atgcLut.push_back(tempAtgc); + } + + /**************** /registerParameters/lpfLut ********************/ + datasetBranch ("/registerParameters/lpfLut", floatArray); + prbDepParams.prbDepParams.lpfLut.clear(); + QVector tempLpf; + + for (quint32 i = 0; i < 4; i++) + { + tempLpf.clear(); + for (quint32 j = 0; j < 48; j++) + { + tempLpf.push_back(static_cast(floatArray[j + i * 48])); + } + prbDepParams.prbDepParams.lpfLut.push_back(tempLpf); + } +} + + +QVector Hdf5::stbRead() +{ + /**************** /registerParameters/stbLutQ ********************/ + datasetBranch ("/registerParameters/stbLutQ", floatArray); + QVector stb; + for (quint8 var = 0; var < 8; var++) + stb.push_back(static_cast(floatArray[var])); + return stb; +} + +QVector Hdf5::lineFilterRead() +{ + /**************** /registerParameters/lineFilterLutQ ********************/ + datasetBranch ("/registerParameters/lineFilterLutQ", floatArray); + QVector lineFilter; + for (quint8 var = 0; var < 3; var++) + lineFilter.push_back(floatArray[var]); + return lineFilter; +} diff --git a/hdf5Scenario/hdf5Scenario.h b/hdf5Scenario/hdf5Scenario.h new file mode 100644 index 0000000..3a458db --- /dev/null +++ b/hdf5Scenario/hdf5Scenario.h @@ -0,0 +1,35 @@ +#ifndef HDF5SCENARIO_H +#define HDF5SCENARIO_H + +#include "H5Cpp.h" +#include "hdf5.h" +#include "H5File.h" +#include "model/hardware/core/TrxBoard.h" + +#define MAX_ARRAY_DEPTH 131072U + +using namespace std; +using namespace H5; + +class Hdf5 +{ +private: + H5File _file; + + float_t floatArray[MAX_ARRAY_DEPTH]; + + template + void datasetBranch(const string& branchPath, T datasetValue[MAX_ARRAY_DEPTH]); + +public: + void hdf5Path (const string &h5Path); + + void scenarioRead (ScenGenHardwareOutput_t &scenParams); + void prbDependParamsRead (ScenPrbDepHardwareParam &prbDepParams); + + QVector stbRead (void); + QVector lineFilterRead (void); + +}; + +#endif // HDF5SCENARIO_H diff --git a/include/model/hardware/core/TrxBoard.h b/include/model/hardware/core/TrxBoard.h index 0a877bc..b72490f 100644 --- a/include/model/hardware/core/TrxBoard.h +++ b/include/model/hardware/core/TrxBoard.h @@ -23,6 +23,7 @@ #include "model/hardware/core/register/afe/Afe.h" #include "model/hardware/device/SonoDevice.h" #include "TrxBoardUtils/TrxBoardStructures.h" +#include "TrxBoardUtils/ScenParamsRanges.h" #include "TrxBoardUtils/TrxBoardEnums.h" #include "model/scenarioGenerator/dto/hardware/HardwareOutput.h" @@ -34,14 +35,17 @@ #define MOUNTED_SLAVE_FPGA 7U #define CLOCK_DIVISION 0x55 -#define EEPROM_ID_BYTE_BEGIN 19U -#define EEPROM_ID_BYTE_NUMBER 2U -#define EEPROM_INFO_BYTE_BEGIN 0U -#define EEPROM_INFO_BYTE_NUMBER 21U +#define EEPROM_CRC_BEGIN 0U +#define EEPROM_CRC_NUMBER 19U +#define EEPROM_ID_BEGIN 19U +#define EEPROM_ID_NUMBER 2U +#define EEPROM_INFO_BEGIN 30U +#define EEPROM_INFO_NUMBER 100U +#define EEPROM_IMPULSE_RESPONSE_BEGIN 428U +#define EEPROM_IMPULSE_RESPONSE_NUMBER 1024U - -template -T byteArray2UintLittleEndian(QByteArray& byte); +#define EEPROM_NO_ERROR 0x0 +#define EEPROM_CRC_ERROR 0x1 class TrxBoard : public QObject { @@ -54,6 +58,7 @@ private: QList* _mcsList; QList _afeModuleOffset; QList _fpgaOffset; + QByteArray _eepromCrc; const quint32 _offsetSlave0; const quint32 _offsetSlave1; const quint32 _offsetSlave2; @@ -89,11 +94,10 @@ private: set }; - struct HwRegister + struct ScenHwRegister { ///////////// BeamFormer ///////////// RxBeamformerProperties* rxBeamformer; - QList > apodization; ProbeElementPosition* elementPosition; PulseProperties* pulse; quint8 pulseTypeNumber; @@ -102,43 +106,51 @@ private: //////////////// DSP //////////////// QVector freqLut; QVector dtgcLut; - QList > lpfLut; - QList > atgcLut; ReceiverConfiguration* configLut; QVector > blendWeight; quint8 receiverConfigTypeNumber; - HwRegister(); - ~HwRegister(); + ScenHwRegister(); + ~ScenHwRegister(); }; - struct ScenGenHardwareOutput { + struct ScenGenHardwareParam { quint32 focusTypeNumber; quint32 totalTxShotNumber; QVector rxBeamFormerNumber; quint32 scenarioStartIndex; quint32 scenarioEndIndex; - HwRegister* hwRegister; + ScenHwRegister* hwRegister; SramIndex* indexParams; SramRx* rxParams; SramTx* txParams; - ScenGenHardwareOutput(); - ~ScenGenHardwareOutput(); + ScenGenHardwareParam(); + ~ScenGenHardwareParam(); } * scenParams; - void setScenario(ScenGenHardwareOutput* scenParams); + void setScenario(ScenGenHardwareParam* scenParams); - void sram_clear (void); + void sramClear (eSramClear clearMode); void setSwapVector(void); + void setRomCrc(void); void setFpgaOffset(void); void setAfeModuleOffset(void); void scenParamsFilling(eScenParams cmd); //QList signedVector2unsignedList(QVector& sgnVec); + template + QByteArray uintLittleEndian2ByteArray(T& data) const; + + template + T byteArray2UintLittleEndian(QByteArray& byte) const; + signals: void sendFramePacket(QByteArray newPacket); + void sramBinaryCreateFlag (void); + void registerCsvCompareFlag (void); + void sramVerifyMessage(QString message); public: @@ -149,26 +161,28 @@ public: ///////////////////////////////// Initialize API ////////////////////////////// void init(void); - ////////////////////////////////// Scenario API /////////////////////////////// + + ////////////////////////////////// Scenario API /////////////////////////////// + void setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams); + void setScenario(ScenGenHardwareOutput_t &scenGenHw); + void setLineFilterCoefficient(QVector& lineFilterLut); void setStbCoefficient(QVector& stbLut); void setDtgcLut(QVector& dtgcLut); - void setAtgcMode(eAtgcMode mode, quint16 value) const; - - void setMetaData(const QByteArray metaData) const; - - void setScenario(ScenGenHardwareOutput_t scenGenHw); - - void setAfeConfig(AfeConfig afe); - QList getAfeReg(eSlaveSelect sel, quint32 afeRegAddr); - void scenPlayerStart(void); void scenPlayerStop(void); //void scenPlayerPause (bool pause) const; + void setFramesMetaData(const QByteArray &metaData) const; + + ////////////////////////////////// UI Test API /////////////////////////////// + void setScenarioCompare (const QString scenPath); + void setAtgcMode(eAtgcMode mode, quint16 value) const; + QList getAfeReg(eSlaveSelect sel, quint32 afeRegAddr); + ////////////////////////////// Slave Programming API /////////////////////////// - void slaveFpgaProgram(QString path); + void slaveFpgaProgram(const QString path); /////////////////////////////// BeamFormer Mode API //////////////////////////// void setBeamFormerMode(eClkMode mode) const; @@ -183,17 +197,17 @@ public: quint32 deviceId(void) const; quint32 vendorId(void) const; - quint32 trxId(void) const; - quint32 mpsId(void) const; - quint32 prbCtrlId(void) const; - quint32 prbId(eSelectProbe prbSel) const; - void getConnectedPrbId(ConnectedPrbId* prbId) const; - - QByteArray trxInfo(void) const; - QByteArray mpsInfo(void) const; - QByteArray prbCtrlInfo(void) const; - QByteArray prbInfo(quint8 prbSel) const; - void getConnectedPrbInfo(ConnectedPrbInfo* prbInfo) const; + void trxState(EepromStatus &romStatus) const; + void mpsState(EepromStatus &romStatus) const; + void prbCtrlState(EepromStatus &romStatus) const; + void selectedPrbState(EepromStatus &romStatus, eSelectProbe prbSel) const; + void prbState(PrbCase* prb) const; + + QString trxInfo(void) const; + QString mpsInfo(void) const; + QString prbCtrlInfo(void) const; + QByteArray selectedPrbImpulseResponse(quint8 prbSel) const; + void prbImpulseResponse(ConnectedPrbInfo* prbInfo) const; void supervisorRbValue(SupervisorRbValue* sValue) const; void mpsFaultStatus(MpsFaultStatus* faultStatus) const; diff --git a/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h b/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h new file mode 100644 index 0000000..b5d6c1b --- /dev/null +++ b/include/model/hardware/core/TrxBoardUtils/PreProcessorDef.h @@ -0,0 +1,10 @@ +#ifndef PREPROCESSORDEF_H +#define PREPROCESSORDEF_H + +#define MPS_BOARD +//#undef MPS_BOARD + +#define DEVELOP_UI +#undef DEVELOP_UI + +#endif // PREPROCESSORDEF_H diff --git a/include/model/hardware/core/TrxBoardUtils/ScenParamsRanges.h b/include/model/hardware/core/TrxBoardUtils/ScenParamsRanges.h new file mode 100644 index 0000000..ef32695 --- /dev/null +++ b/include/model/hardware/core/TrxBoardUtils/ScenParamsRanges.h @@ -0,0 +1,28 @@ +#ifndef SCENPARAMSRANGE_H +#define SCENPARAMSRANGE_H + +/****************** DSP ******************/ +#define RRECEIVER_CONFIGURATION_LUT_MAX 8U +#define STB_COEFFICIENT_LUT_MAX 8 +#define LINE_FILTER_LUT_MAX 3 +#define BLENDWEIGHT_LUT_MAX 4 +#define FREQUENCY_LUT_MAX 8 +#define DTGC_LUT_MAX 1024 +#define ATGC_LUT_MAX 4 +#define LPF_LUT_MAX 4 + +/************** Beam Former **************/ +#define ELEMENT_POSITION_LUT_MAX 192 +#define APODIZATIONLUT_LUT_MAX 4 +#define RXBEAMFORMER_LUT_MAX 8U +#define PULSE_LUT_MAX 8U + +/****************** SRAM *****************/ +#define TOTAL_TX_SHOT_NUMBER_MAX 131072U +#define RX_BEAMFORMER_NUMBER_MAX 11264 +#define FOCUS_TYPE_NUMBER_MAX 11264U + +/************* Scenario Index ************/ +#define SCENARIO_INDEX_MAX 131072U + +#endif // SCENPARAMSRANGE_H diff --git a/include/model/hardware/core/TrxBoardUtils/TrxBoardEnums.h b/include/model/hardware/core/TrxBoardUtils/TrxBoardEnums.h index 1be00b9..829c4a3 100644 --- a/include/model/hardware/core/TrxBoardUtils/TrxBoardEnums.h +++ b/include/model/hardware/core/TrxBoardUtils/TrxBoardEnums.h @@ -3,6 +3,12 @@ #include +enum eSramClear : bool +{ + all = false, + first4M = true +}; + enum eEmulatorOption : bool { performance = false, @@ -36,4 +42,10 @@ enum eSlaveSelect : quint8 slave2 }; +enum eConnectionMode : bool +{ + disconnected = false, + connected = true +}; + #endif // TRXBOARDENUMS_H diff --git a/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h b/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h index b51c83f..87ac980 100644 --- a/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h +++ b/include/model/hardware/core/TrxBoardUtils/TrxBoardStructures.h @@ -28,12 +28,19 @@ struct HealthStatus VoltagesPg* voltsPg; }; -struct ConnectedPrbId +struct EepromStatus { - quint32 prbA; - quint32 prbB; - quint32 prbC; - quint32 prbD; + eConnectionMode ConnectionMode; + quint32 id; + quint8 errorCode; +}; + +struct PrbCase +{ + EepromStatus prbA; + EepromStatus prbB; + EepromStatus prbC; + EepromStatus prbD; }; struct ConnectedPrbInfo @@ -44,4 +51,17 @@ struct ConnectedPrbInfo QByteArray prbD; }; +struct ScenPrbDepHwRegister +{ + QList> lpfLut; + QList> atgcLut; + QList> apodizationLut; +}; + +struct ScenPrbDepHardwareParam +{ + AfeConfig afeCfg; + ScenPrbDepHwRegister prbDepParams; +}; + #endif // TRXBOARDSTRUCTURES_H diff --git a/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h b/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h new file mode 100644 index 0000000..c65a600 --- /dev/null +++ b/include/model/hardware/core/register/afe/registerDefinition/AdcSyncStatus.h @@ -0,0 +1,37 @@ +#ifndef ADCSYNCSTATUS_H +#define ADCSYNCSTATUS_H + +#include "model/hardware/core/register/Register.h" +#include "model/hardware/core/register/RegUtils.h" + +#undef BAR + +#define GEN_SYNC_CHECKER_MASK 0x0000000C +#define SYNC_CHECK_DONE_MASK 0x0000000C +#define SYNC_CHECK_ERROR_MASK 0x0000000C +#define LNA_HPF_PROG_MASK 0x0000000C + +#define BAR 0U +#define OFFSET 0x43C384 + +class AdcSyncStatus : public Register +{ + +public: + Field* lnaHpfProg; + + AdcSyncStatus(SonoDevice* device, quint32 offset) : Register(BAR, OFFSET + offset, device) + { + ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); + ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); + ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); + ADD_UNSIGNED_FIELD(lnaHpfProg, LNA_HPF_PROG_MASK); + } +}; + +#undef LNA_HPF_PROG_MASK + +#undef BAR +#undef OFFSET + +#endif // ADCSYNCSTATUS_H diff --git a/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h b/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h index 36b521b..2f51795 100644 --- a/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h +++ b/include/model/hardware/core/register/fpgaProgram/FpgaProgram.h @@ -6,6 +6,7 @@ #include #include +#include "model/hardware/core/TrxBoardUtils/PreProcessorDef.h" #include "registerDefinition/SlaveFpgaNumber.h" #include "registerDefinition/SerialProgramData.h" #include "registerDefinition/SerialProgramStatus.h" diff --git a/include/model/hardware/core/register/scenPlayer/ScenPlayer.h b/include/model/hardware/core/register/scenPlayer/ScenPlayer.h index 0da6ad9..6e63c4f 100644 --- a/include/model/hardware/core/register/scenPlayer/ScenPlayer.h +++ b/include/model/hardware/core/register/scenPlayer/ScenPlayer.h @@ -15,7 +15,8 @@ private: struct PlayerControl { ScenPlayerCtrl* _playerctrl; - void command(bool start) const; + void setCommand(bool start) const; + bool getCommand(void) const; void pause (bool pause) const; }; diff --git a/include/model/hardware/core/register/sram/registerDefinition/Index.h b/include/model/hardware/core/register/sram/registerDefinition/Index.h index 2909a58..e25dc17 100644 --- a/include/model/hardware/core/register/sram/registerDefinition/Index.h +++ b/include/model/hardware/core/register/sram/registerDefinition/Index.h @@ -50,6 +50,8 @@ private: if (index==0) frameType->setValueLong(_index->frameType); + else + frameType->setValueLong(0); } public: diff --git a/include/model/hardware/device/SonoDevice.h b/include/model/hardware/device/SonoDevice.h index 8eadde9..31d7e43 100644 --- a/include/model/hardware/device/SonoDevice.h +++ b/include/model/hardware/device/SonoDevice.h @@ -21,6 +21,7 @@ public: void startDma(); void stopDma(); int getCounter(); + bool isDmaBusy (); void copy(int srcIndex, int dstIndex); const char* getBufferPtr(int index); }; diff --git a/include/model/scenarioGenerator/dto/hardware/HardwareOutput.h b/include/model/scenarioGenerator/dto/hardware/HardwareOutput.h index 32747de..9fe05d8 100644 --- a/include/model/scenarioGenerator/dto/hardware/HardwareOutput.h +++ b/include/model/scenarioGenerator/dto/hardware/HardwareOutput.h @@ -7,18 +7,19 @@ #include "model/scenarioGenerator/dto/hardware/SramIndex.h" #include "model/scenarioGenerator/dto/hardware/SramRx.h" #include "model/scenarioGenerator/dto/hardware/SramTx.h" +#include "model/hardware/core/register/afe/Afe.h" struct ScenGenHardwareOutput_t { - quint32 focusTypeNumber; - quint32 totalTxShotNumber; + quint32 focusTypeNumber; + quint32 totalTxShotNumber; QList rxBeamFormerNumber; - QVector pulseInterval; + QVector pulseInterval; quint8 frameType; - HwRegister_t hwRegister; - SramIndex_t indexParams; - SramRx_t rxParams; - SramTx_t txParams; + HwRegister_t hwRegister; + SramIndex_t indexParams; + SramRx_t rxParams; + SramTx_t txParams; }; #endif //HARDWAREOUTPUT_H diff --git a/include/model/scenarioGenerator/dto/hardware/HwScenarioDependent.h b/include/model/scenarioGenerator/dto/hardware/HwScenarioDependent.h index cd030f7..b247bf7 100644 --- a/include/model/scenarioGenerator/dto/hardware/HwScenarioDependent.h +++ b/include/model/scenarioGenerator/dto/hardware/HwScenarioDependent.h @@ -26,4 +26,5 @@ struct HwRegister_t { QList> apodizationLut; }; + #endif //HWSCENARIODEPENDENT_H diff --git a/mainwindow.cpp b/mainwindow.cpp index f599998..9db1b49 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,8 +4,8 @@ QThread* MainWindow::_uiThread; MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) + : QMainWindow(parent) , + ui(new Ui::MainWindow) { ui->setupUi(this); @@ -26,6 +26,7 @@ MainWindow::MainWindow(QWidget *parent) _version = new FpgaCodeVersion; _vec = new StatusVec; _emul = new EmulatorProperties; + _prb = new PrbCase; _colorMap = new QCPColorMap(ui->plot_2->xAxis,ui->plot_2->yAxis); @@ -53,6 +54,15 @@ MainWindow::MainWindow(QWidget *parent) ui->tb_fpgaBit->setText(_settings->value(FPGA_FILE_PATH).value()); ui->tb_scenFilesPath->setText(_settings->value(SCENARIO_FILE_PATH).value()); + ui->tb_trxRomId->setPlaceholderText("id(hex)"); + ui->tb_trxRomInfo->setPlaceholderText("info"); + ui->tb_mpsRomId->setPlaceholderText("id(hex)"); + ui->tb_mpsRomInfo->setPlaceholderText("info"); + ui->tb_prbCtrlRomId->setPlaceholderText("id(hex)"); + ui->tb_prbCtrlRomInfo->setPlaceholderText("info"); + ui->tb_prbRomIdRead->setPlaceholderText("id(hex)"); + ui->tb_prbRomImpulseRead->setPlaceholderText("impulse"); + // connect(this, &MainWindow::updateBlockProgressValue, this, &MainWindow::newBlockProgressValue); // connect(this, &MainWindow::updateFpgaProgressValue, this, &MainWindow::newFpgaProgressValue); // connect(this, &MainWindow::updateBlockProgressVisibility, this, &MainWindow::newBlockProgressVisibility); @@ -65,18 +75,20 @@ MainWindow::MainWindow(QWidget *parent) connect(this, &MainWindow::connectedPrbChange, this, &MainWindow::getPrbChange); connect(_timeout, &QTimer::timeout, this, &MainWindow::timeout); connect(&scenEndWather, &QFutureWatcher::finished, this, &MainWindow::restartTimer); + //////////////////////// DMA Packet Connections ////////////////////////////// connect(&_trx, &TrxBoard::sendFramePacket, this, &MainWindow::getFramePacket); connect(this, &MainWindow::sendLogCount, this, &MainWindow::catchLogCount); connect(this, &MainWindow::twoDReady, this, &MainWindow::show2d, Qt::BlockingQueuedConnection); connect(this, &MainWindow::threeDReady, this, &MainWindow::show3d, Qt::BlockingQueuedConnection); - ui->btn_hvRegulatorConfig->setText(ENABLE); - ui->btn_pm5RegulatorConfig->setText(ENABLE); + /////////////////// Scenario Verification Connections ///////////////////////// + connect(&_trx, &TrxBoard::sramBinaryCreateFlag, this, &MainWindow::getSramBinaryCreateFlag); + connect(&_trx, &TrxBoard::registerCsvCompareFlag, this, &MainWindow::getRegisterCsvCompareFlag); + connect(&_trx, &TrxBoard::sramVerifyMessage, this, &MainWindow::getSramVerifyMessage); + ui->btn_updateRdbackValue->setText(UPDATE); - ui->l_detectedProbe->setText("None"); ui->btn_dmaLogLast->setHidden(true); - ui->btn_prbRomWrite->setDisabled(true); // uint32_t offsetdbgCmd[3] = {0x140000*4,0x240000*4,0x340000*4}; // auto value = 0; @@ -106,6 +118,19 @@ MainWindow::MainWindow(QWidget *parent) _timeout->start(1000); + + //////////////////////////// First Time Probe Detection ////////////////////////////// + //emit connectedPrbChange(); + + 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() @@ -134,61 +159,6 @@ MainWindow::~MainWindow() } -/*************************************************************************************************/ -//void MainWindow::binFileUploader(quint32 bar, quint32 offset, QString path, QProgressBar* prg) -//{ -// QFile file(path); - -// if (!file.open(QFile::ReadOnly)) -// { -// MESSAGE_BOX("Could not open binary file, aborting operation"); -// return; -// } - -// emit updateBlockProgressVisibility(true, prg); -// emit updateBlockProgressValue(0, prg); - -// const auto actualSize = file.size(); -// auto readSize = 0; -// while(readSize < actualSize) -// { -// QByteArray chunk = file.read(8); -// auto value = byteArrayTo64LittleEndian(chunk); -// try -// { -// _usd->writeLong(offset + readSize, bar, value); -// auto rdValue = _usd->readLong(offset + readSize, bar); -// if (value != rdValue) -// { -// MESSAGE_BOX("Binary File Write Error"); -// file.close(); - -// return; -// } - -// } catch (myexception e) -// { -// MESSAGE_BOX(e.what()); - -// emit updateBlockProgressVisibility(false, prg); - -// file.close(); - -// return; -// } -// readSize += 8; - -// auto percentage = (readSize * 100 / actualSize); -// emit updateBlockProgressValue(percentage, prg); -// } - -// //MESSAGE_BOX("Binary file upload finished with success"); - -// emit updateBlockProgressVisibility(false, prg); - -// file.close(); -//} - ///*************************************************************************************************/ //void MainWindow::binAdcFileUploader(quint32 bar, QString path, QProgressBar* prg) //{ @@ -247,90 +217,6 @@ MainWindow::~MainWindow() // file.close(); //} -///*************************************************************************************************/ -//void MainWindow::CsvFileUploader(quint32 bar, QString path, QProgressBar* prg) -//{ -// QFile file(path); - -// if(!file.open(QFile::ReadOnly)) -// { -// MESSAGE_BOX("Could not open param file, aborting operation"); -// return; -// } - -// emit updateBlockProgressVisibility(true, prg); -// emit updateBlockProgressValue(0, prg); - -// QString line; -// auto size = file.size(); -// qint64 readSize = 0; -// while((readSize < size) & !_csvReadStopFlag) -// { -// line = file.readLine(); -// auto sl = line.split(','); -// auto address = sl[0].toUInt(Q_NULLPTR, 16); -// auto value = sl[1].toUInt(Q_NULLPTR, 16); -// _usd->writeWord(address, bar, value); -// //qDebug() << _usd->readWord(address, bar); -// readSize += static_cast(line.length()); -// emit updateBlockProgressValue((readSize * 100 / size), prg); -// //delay(1); -// } - -// emit updateBlockProgressVisibility(false, prg); - -// file.close(); -//} -///*************************************************************************************************/ -//void MainWindow::CsvFileChecker(quint32 bar, QString pathBase, QString pathTarget, QProgressBar* prg) -//{ -// QFile baseFile(pathBase); -// QFile tragetFile(pathTarget); - -// if(!baseFile.open(QFile::ReadOnly)) -// { -// MESSAGE_BOX("Could not open param file, aborting operation"); -// return; -// } -// tragetFile.open(QFile::WriteOnly); - -// emit updateBlockProgressVisibility(true, prg); -// emit updateBlockProgressValue(0, prg); - -// QString line; -// auto size = baseFile.size(); -// qint64 readSize = 0; -// while(readSize < size) -// { -// line = baseFile.readLine(); -// auto sl = line.split(','); -// auto address = sl[0].toUInt(Q_NULLPTR, 16); -// auto baseValue = sl[1].toUInt(Q_NULLPTR, 16); -// auto boardValue = _usd->readWord(address, bar); -// auto res = "NOK"; -// if (boardValue == baseValue) -// { -// res = "OK"; -// } -// auto str = QStringLiteral("%1,%2,%3,%4").arg(address, 8, 16, QLatin1Char('0')).arg(baseValue, 8, 16, QLatin1Char('0')) -// .arg(boardValue, 8, 16, QLatin1Char('0')).arg(res); -// tragetFile.write(str.toStdString().c_str(), str.length()); -// tragetFile.write("\r\n", 2); - -// readSize += static_cast(line.length()); -// emit updateBlockProgressValue((readSize * 100 / size), prg); -// //delay(1); -// } - -// emit updateBlockProgressVisibility(false, prg); - -// baseFile.close(); - -// tragetFile.close(); - - -//} - ///*************************************************************************************************/ //#define NO_AFE_CHANNEL 192 //#define NO_LOGGER_SMPL_COUNT 2048 @@ -447,67 +333,6 @@ MainWindow::~MainWindow() // _adcLoggerTrnsDone = true; //} -///*************************************************************************************************/ -//void MainWindow::scenarioFileVerifier(quint32 bar, quint32 offset, QString path) -//{ -// QFile file(path); - -// if (!file.open(QFile::ReadOnly)) -// { -// MESSAGE_BOX("Could not open binary file, aborting operation"); -// return; -// } - -// emit updateBlockProgressVisibility(true, ui->prg_scenarioUpload); -// emit updateBlockProgressValue(0, ui->prg_scenarioUpload); - -// const auto actualSize = file.size(); -// auto readSize = 0; -// while(readSize < actualSize) -// { -// QByteArray chunk = file.read(8); -// auto value = byteArrayTo64LittleEndian(chunk); -// try -// { -// auto data = _usd->readLong(offset + readSize, bar); -// if(data != value) -// { -// auto message = QString("Error in data @ offset 0x%1, expected 0x%2 saw 0x%3") -// .arg(QString::number(offset + readSize)) -// .arg(QString::number(value, 16)) -// .arg(QString::number(data, 16)); -// MESSAGE_BOX(message); - -// emit updateBlockProgressVisibility(false, ui->prg_scenarioUpload); - -// file.close(); - -// return; -// } -// } -// catch (myexception e) -// { -// MESSAGE_BOX(e.what()); - -// emit updateBlockProgressVisibility(false, ui->prg_scenarioUpload); - -// file.close(); - -// return; -// } -// readSize += 8; - -// auto percentage = (readSize * 100 / actualSize); -// emit updateBlockProgressValue(percentage, ui->prg_scenarioUpload); -// } - -// MESSAGE_BOX("Binary verified with success"); - -// emit updateBlockProgressVisibility(false, ui->prg_scenarioUpload); - -// file.close(); -//} - /*************************************************************************************************/ void MainWindow::fpgaProgrammer(QString path) { @@ -524,47 +349,6 @@ void MainWindow::fpgaProgrammer(QString path) } -/*************************************************************************************************/ -//quint64 MainWindow::byteArrayTo64LittleEndian(QByteArray data) -//{ -// quint64 temp = 0; - -// temp = ((static_cast(data[0])) & 0x00000000000000FF) | -// (((static_cast(data[1])) << 8) & 0x000000000000FF00) | -// (((static_cast(data[2])) << 16) & 0x0000000000FF0000) | -// (((static_cast(data[3])) << 24) & 0x00000000FF000000) | -// (((static_cast(data[4])) << 32) & 0x000000FF00000000) | -// (((static_cast(data[5])) << 40) & 0x0000FF0000000000) | -// (((static_cast(data[6])) << 48) & 0x00FF000000000000) | -// (((static_cast(data[7])) << 56) & 0xFF00000000000000); - -// return temp; -//} -/*************************************************************************************************/ -//quint32 MainWindow::byteArrayTo32LittleEndian(QByteArray data) -//{ -// quint32 temp = 0; - -// temp = ((static_cast(data[0])) & 0x000000FF) | -// (((static_cast(data[1])) << 8) & 0x0000FF00) | -// (((static_cast(data[2])) << 16) & 0x00FF0000) | -// (((static_cast(data[3])) << 24) & 0xFF000000) ; - -// return temp; -//} -///*************************************************************************************************/ -//quint32 MainWindow::byteArrayTo32BigEndian(QByteArray data) -//{ -// quint32 temp = 0; - -// temp = (data[3] & 0x000000FF) | -// ((data[2] << 8) & 0x0000FF00) | -// ((data[1] << 16) & 0x00FF0000) | -// ((data[0] << 24) & 0xFF000000); - -// return temp; -//} - /*************************************************************************************************/ void MainWindow::timeout() { @@ -767,28 +551,158 @@ void MainWindow::timeout() /*************************************************************************************************/ void MainWindow::getPrbChange() { - bool probeADetected=_bCtrl->getConnectedPrb().at(0); - bool probeBDetected=_bCtrl->getConnectedPrb().at(1); - bool probeCDetected=_bCtrl->getConnectedPrb().at(2); - bool probeDDetected=_bCtrl->getConnectedPrb().at(3); + const quint32 id9L_D = 0x212; + const quint32 idC1_5_D = 0x225; + + try + { + _trx.prbState(_prb); + } + catch (SonoException& e) + { + qDebug() << e.what(); + } + + try + { + if (_prb->prbA.ConnectionMode == connected) + { + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 0); + switch (_prb->prbA.id) + { + case id9L_D: + ui->table_probe->setItem(0, 0, new QTableWidgetItem("9L-D")); + break; + + case idC1_5_D: + ui->table_probe->setItem(0, 0, new QTableWidgetItem("C1-5-D")); + break; + + default: + ui->table_probe->setItem(0, 0, new QTableWidgetItem("Unknown")); + + } + if (_prb->prbA.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe A eeprom is occured."; + } + else + { + ui->table_probe->setItem(0, 0, new QTableWidgetItem("Disconnected")); + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 0); + } + + } + catch (const char* exception) + { + qDebug() << exception; + } - if(probeDDetected == true){ - ui->l_detectedProbe->setText("D"); + try + { + if (_prb->prbB.ConnectionMode == connected) + { + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 1); + switch (_prb->prbB.id) + { + case id9L_D: + ui->table_probe->setItem(0, 1, new QTableWidgetItem("9L-D")); + break; + + case idC1_5_D: + ui->table_probe->setItem(0, 1, new QTableWidgetItem("C1-5-D")); + break; + + default: + ui->table_probe->setItem(0, 1, new QTableWidgetItem("Unknown")); + + } + if (_prb->prbB.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe B eeprom is occured."; + } + else + { + ui->table_probe->setItem(0, 1, new QTableWidgetItem("Disconnected")); + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 1); + } + } + catch (const char* exception) + { + qDebug() << exception; } - else if (probeCDetected == true) { - ui->l_detectedProbe->setText("C"); + + try + { + if (_prb->prbC.ConnectionMode == connected) + { + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 2); + switch (_prb->prbC.id) + { + case id9L_D: + ui->table_probe->setItem(0, 2, new QTableWidgetItem("9L-D")); + break; + + case idC1_5_D: + ui->table_probe->setItem(0, 2, new QTableWidgetItem("C1-5-D")); + break; + + default: + ui->table_probe->setItem(0, 2, new QTableWidgetItem("Unknown")); + + } + if (_prb->prbC.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe C eeprom is occured."; + } + else + { + ui->table_probe->setItem(0, 2, new QTableWidgetItem("Disconnected")); + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 2); + } } - else if (probeBDetected == true) { - ui->l_detectedProbe->setText("B"); + catch (const char* exception) + { + qDebug() << exception; } - else if (probeADetected == true) { - ui->l_detectedProbe->setText("A"); + + try + { + if (_prb->prbD.ConnectionMode == connected) + { + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::green, 3); + switch (_prb->prbD.id) + { + case id9L_D: + ui->table_probe->setItem(0, 3, new QTableWidgetItem("9L-D")); + break; + + case idC1_5_D: + ui->table_probe->setItem(0, 3, new QTableWidgetItem("C1-5-D")); + break; + + default: + ui->table_probe->setItem(0, 3, new QTableWidgetItem("Unknown")); + + } + if (_prb->prbD.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe D eeprom is occured."; + } + else + { + ui->table_probe->setItem(0, 3, new QTableWidgetItem("Disconnected")); + QtConcurrent::run(this, &MainWindow::getProbeColor, Qt::red, 3); + } } - else{ - ui->l_detectedProbe->setText("None"); + catch (const char* exception) + { + qDebug() << exception; } + } +/*************************************************************************************************/ +void MainWindow::getProbeColor(const QBrush brush, const int item) +{ + ui->table_probe->item(0, item)->setBackground(brush); +} /*************************************************************************************************/ //void MainWindow::scenarioStart() //{ @@ -816,27 +730,6 @@ void MainWindow::getPrbChange() //} -/*************************************************************************************************/ -//void MainWindow::scenarioStop() -//{ -// auto value = 0x0; -// _usd->writeWord(0x800, 0, value); - -// auto bar = 0; -// uint32_t offsetSlvScenCmd[3] = {0x134000*4,0x234000*4,0x334000*4}; -// delay(10); -// for (auto i=0 ; i<3;i++) -// { -// value = _usd->readWord(offsetSlvScenCmd[i], bar); -// _usd->writeWord(offsetSlvScenCmd[i], bar, value & 0x1); -// } -//} - -//bool MainWindow::checkTermalShutdown(quint8 value) -//{ -// return value == 0x0F; -//} - void MainWindow::changeLabelTextColor(QLabel *label, QColor color) { auto palette = label->palette(); @@ -991,138 +884,39 @@ void MainWindow::newMessage(QString message) } ///*************************************************************************************************/ -//void MainWindow::on_btn_scenarioBrowse_clicked() +//void MainWindow::on_btn_txDacBrowse_clicked() //{ // QFileDialog fileDialog; -// fileDialog.setNameFilters({"SRAM binary file (*.bin)"}); +// fileDialog.setNameFilters({"TxDAC file (*.csv)"}); // auto result = fileDialog.exec(); // if(result) // { // auto selectedPath = fileDialog.selectedFiles()[0]; -// ui->tb_scenarioFile->setText(selectedPath); -// _settings->setValue(SCENARIO_FILE_PATH, selectedPath); +// ui->tb_txDacFile->setText(selectedPath); +// _settings->setValue(TX_DAC_FILE_PATH, selectedPath); // } //} ///*************************************************************************************************/ -//void MainWindow::on_btn_scenarioVerify_clicked() +//void MainWindow::on_btn_txDacUpload_clicked() //{ -// auto bar = 1; - -// auto offset = 0; +// auto bar = 0; -// auto path = ui->tb_scenarioFile->text(); +// auto offset = 0xE000; +// auto path = ui->tb_txDacFile->text(); +// _csvReadStopFlag = false; // QFutureWatcher watcher; // connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// auto future = QtConcurrent::run(this, &MainWindow::scenarioFileVerifier, bar, offset, path); +// auto future = QtConcurrent::run(this, &MainWindow::CsvFileUploader, bar, path, ui->prg_txDacUpload); // watcher.setFuture(future); // _dial->exec(); // disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); //} ///*************************************************************************************************/ -//void MainWindow::on_btn_ParamBrowse_clicked() -//{ -// QFileDialog fileDialog; -// fileDialog.setNameFilters({"Scenario param file (*.csv)"}); -// auto result = fileDialog.exec(); - -// if(result) -// { -// auto selectedPath = fileDialog.selectedFiles()[0]; -// ui->tb_paramFile->setText(selectedPath); -// _settings->setValue(PARAM_FILE_PATH, selectedPath); -// } -//} - -///*************************************************************************************************/ -//void MainWindow::on_btn_scenarioUpload_clicked() -//{ -// uint32_t offsetSlvScenCmd[3] = {0x134000*4,0x234000*4,0x334000*4}; -// auto bar = 0; - -// auto scenarioBar = 1; -// auto paramBar = 0; - -// auto scenarioOffset = 0; - -// auto scenarioPath = ui->tb_scenarioFile->text(); -// auto paramPath = ui->tb_paramFile->text(); - -// scenarioStop(); - -// qDebug() << "--- Clear Scen Register Valid Register --- "; -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetSlvScenCmd[i], bar, 0X0); -// } - -// QFutureWatcher watcher; -// connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// auto future = QtConcurrent::run(this, &MainWindow::binFileUploader, scenarioBar, scenarioOffset, scenarioPath, ui->prg_scenarioUpload); -// watcher.setFuture(future); -// _dial->exec(); -// disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); - -// _csvReadStopFlag = false; -// connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// future = QtConcurrent::run(this, &MainWindow::CsvFileUploader, paramBar, paramPath, ui->prg_scenarioUpload); -// watcher.setFuture(future); -// _dial->exec(); -// disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); - - - -// qDebug() << "--- SET Scen Register Valid Register --- "; -// for (auto i=0 ; i<3;i++) -// { -// _usd->writeWord(offsetSlvScenCmd[i], bar, 0X1); -// } - -// qDebug() << "--- SET GT Send Mode :: BF --- "; -// _usd->writeWord(0x4*4, bar, 0X1); -// delay(20); - - - -//} - -///*************************************************************************************************/ -//void MainWindow::on_btn_txDacBrowse_clicked() -//{ -// QFileDialog fileDialog; -// fileDialog.setNameFilters({"TxDAC file (*.csv)"}); -// auto result = fileDialog.exec(); - -// if(result) -// { -// auto selectedPath = fileDialog.selectedFiles()[0]; -// ui->tb_txDacFile->setText(selectedPath); -// _settings->setValue(TX_DAC_FILE_PATH, selectedPath); -// } -//} - -///*************************************************************************************************/ -//void MainWindow::on_btn_txDacUpload_clicked() -//{ -// auto bar = 0; - -// auto offset = 0xE000; - -// auto path = ui->tb_txDacFile->text(); -// _csvReadStopFlag = false; -// QFutureWatcher watcher; -// connect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -// auto future = QtConcurrent::run(this, &MainWindow::CsvFileUploader, bar, path, ui->prg_txDacUpload); -// watcher.setFuture(future); -// _dial->exec(); -// disconnect(&watcher, &QFutureWatcher::finished, this, &MainWindow::threadFinished); -//} - -///*************************************************************************************************/ -//void MainWindow::on_btn_txDacStartStop_clicked() +//void MainWindow::on_btn_txDacStartStop_clicked() //{ // auto bar = 0; // auto offset = 0x10000; @@ -1291,32 +1085,6 @@ void MainWindow::on_cb_selectedProbe_currentIndexChanged(int index) // //_usd->writeWord(offset, bar, value); // // ui->btn_mulDacTrig->setText(TRIG_ON); // //} -//} -//&************************************************************************************************* -//void MainWindow::on_btn_thsdStateUpdate_clicked() -//{ -// auto bar = 0; -// auto offset = 0x43C37C; - -// auto thsd_f1_temp = _usd->readWord(offset, bar); -// auto thsd_f1 = thsd_f1_temp & 0x0000000F; -// auto color = checkTermalShutdown(thsd_f1) ? Qt::green : Qt::red; -// changeLabelTextColor(ui->l_thermalShutdownFpga1, color); -// ui->l_thermalShutdownFpga1->setText(QString::number(thsd_f1, 16)); -// delay (100); - -// auto thsd_f2_temp = _usd->readWord(offset+0x400000, bar); -// auto thsd_f2 = thsd_f2_temp&0x0000000F; -// color = checkTermalShutdown(thsd_f2) ? Qt::green : Qt::red; -// changeLabelTextColor(ui->l_thermalShutdownFpga2, color); -// ui->l_thermalShutdownFpga2->setText(QString::number(thsd_f2, 16)); -// delay (100); - -// auto thsd_f3_temp = _usd->readWord(offset+0x800000, bar); -// auto thsd_f3 = thsd_f3_temp&0x0000000F; -// color = checkTermalShutdown(thsd_f3) ? Qt::green : Qt::red; -// changeLabelTextColor(ui->l_thermalShutdownFpga3, color); -// ui->l_thermalShutdownFpga3->setText(QString::number(thsd_f3, 16)); //}*/ /********************************************************************/ @@ -1385,7 +1153,7 @@ void MainWindow::on_btn_scenStart_clicked() _dmaLog = true; _dmaRun = true; // flag _dmaBuffer.clear(); - QtConcurrent::run(this, &MainWindow::logPcie); + //QtConcurrent::run(this, &MainWindow::logPcie); } else { @@ -1443,7 +1211,7 @@ void MainWindow::on_btn_emulator_clicked() _dmaLog = true; _dmaRun = true; _dmaBuffer.clear(); - QtConcurrent::run(this, &MainWindow::logPcie); + //QtConcurrent::run(this, &MainWindow::logPcie); } else { @@ -1514,21 +1282,6 @@ void MainWindow::logPcie() file.open(QIODevice::WriteOnly); file.write(temp); - - // for(auto j = 0; j < TRANSFER_LENGTH; j += 8) - // { - // auto val = ((static_cast(temp[j])) & 0x00000000000000FF) | - // (((static_cast(temp[j + 1])) << 8) & 0x000000000000FF00) | - // (((static_cast(temp[j + 2])) << 16) & 0x0000000000FF0000) | - // (((static_cast(temp[j + 3])) << 24) & 0x00000000FF000000) | - // (((static_cast(temp[j + 4])) << 32) & 0x000000FF00000000) | - // (((static_cast(temp[j + 5])) << 40) & 0x0000FF0000000000) | - // (((static_cast(temp[j + 6])) << 48) & 0x00FF000000000000) | - // (((static_cast(temp[j + 7])) << 56) & 0xFF00000000000000); - // auto str = QStringLiteral("%1").arg(val, 16, 16, QLatin1Char('0')); - // file.write(str.toStdString().c_str(), str.length()); - // file.write("\r\n", 2); - // } file.close(); emit sendLogCount(_dmaLogCount, progress); @@ -1895,6 +1648,7 @@ void MainWindow::on_btn_supJump_clicked() try { _trx.mpsReset(); //jump + ui->chk_mpsInit->setChecked(false); } catch (SonoException& e) { @@ -2472,19 +2226,43 @@ void MainWindow::on_btn_updateRdbackValue_clicked() //} +/*************************************************************************************************/ +QString MainWindow::releaseCodeVersion(quint32 &value) +{ + QString str = QString::number(value, 10); + QList strList; + foreach(auto ch, str) + { + strList.push_back(ch); + } + str.clear(); + str = strList[0] + strList[1] + "/" + + strList[2] + strList[3] + "/" + + strList[4] + strList[5] + " " + + strList[6] + strList[7] + ":" + + strList[8] + strList[9]; + return str; +} + +/*************************************************************************************************/ void MainWindow::on_btn_getFpgaVersion_clicked() { _trx.getFpgasCodeVersion(_version); + auto value = _version->masterCode; - ui->l_masterVersion->setText(QStringLiteral("%1").arg(value, 8, 10)); + ui->l_masterVersion->setText(releaseCodeVersion(value)); + value = _version->slave0Code; - ui->l_slave0Version->setText(QStringLiteral("%1").arg(value, 8, 10)); + ui->l_slave0Version->setText(releaseCodeVersion(value)); + value = _version->slave1Code; - ui->l_slave1Version->setText(QStringLiteral("%1").arg(value, 8, 10)); + ui->l_slave1Version->setText(releaseCodeVersion(value)); + value = _version->slave2Code; - ui->l_slave2Version->setText(QStringLiteral("%1").arg(value, 8, 10)); + ui->l_slave2Version->setText(releaseCodeVersion(value)); } +/*************************************************************************************************/ //void MainWindow::on_btn_txTrig_clicked() //{ @@ -2543,618 +2321,30 @@ void MainWindow::on_btn_getFpgaVersion_clicked() //} /*************************************************************************************************/ /************************************* Scenario Setting ******************************************/ -/*************************************************************************************************/ - -template -void MainWindow::datasetBranch(const string &branchPath, T datasetValue[MAX_ARRAY_DEPTH]) -{ - const H5std_string datasetPath(branchPath); - DataSet datasetType = _file.openDataSet(datasetPath); - - datasetType.read(datasetValue, PredType::NATIVE_FLOAT, H5S_ALL, H5S_ALL); -} - /*************************************************************************************************/ void MainWindow::setScenario(const string &h5Path) { - const H5std_string filePath(h5Path); - H5File file (filePath, H5F_ACC_RDONLY); - _file = file; - - try - { - /****************** /sramParameters/frameType ******************/ -// datasetBranch ("/sramParameters/frameType", floatArray); -// scenParams.frameType = static_cast(floatArray[0]); - scenParams.frameType = 0; - - /****************** /sramParameters/totalTxShotNo ******************/ - datasetBranch ("/sramParameters/totalTxShotNo", floatArray); - scenParams.totalTxShotNumber = static_cast(floatArray[0]); - - /******************* /sramParameters/focusTypeNo *******************/ - datasetBranch ("/sramParameters/focusTypeNo", floatArray); - scenParams.focusTypeNumber = static_cast(floatArray[0]); - - /******************* /sramParameters/rxBeamformerNo *******************/ - datasetBranch ("/sramParameters/rxBeamformerNo", floatArray); - scenParams.rxBeamFormerNumber.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxBeamFormerNumber.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/pulseInterval ********************/ - datasetBranch ("/sramParameters/pulseInterval", floatArray); - scenParams.pulseInterval.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.pulseInterval.push_back(floatArray[var]); - - /**************** /sramParameters/indexParameters/shotPropertiesIndex ********************/ - datasetBranch ("/sramParameters/indexParameters/shotPropertiesIndex", floatArray); - scenParams.indexParams.shotPropertiesIndex.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.shotPropertiesIndex.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/indexParameters/pulsePropertiesIndex ********************/ - datasetBranch ("/sramParameters/indexParameters/pulsePropertiesIndex", floatArray); - scenParams.indexParams.pulsePropertiesIndex.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.pulsePropertiesIndex.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/indexParameters/receiverConfigurationIndex ********************/ - datasetBranch ("/sramParameters/indexParameters/receiverConfigurationIndex", floatArray); - scenParams.indexParams.receiverConfigurationIndex.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.receiverConfigurationIndex.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/indexParameters/firstLineInFrame ********************/ - datasetBranch ("/sramParameters/indexParameters/firstLineInFrame", floatArray); - scenParams.indexParams.firstLineInFrame.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.firstLineInFrame.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/indexParameters/lastLineInFrame ********************/ - datasetBranch ("/sramParameters/indexParameters/lastLineInFrame", floatArray); - scenParams.indexParams.lastLineInFrame.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.lastLineInFrame.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/indexParameters/dLineNum ********************/ - datasetBranch ("/sramParameters/indexParameters/dLineNum", floatArray); - scenParams.indexParams.dLineNum.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.dLineNum.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/indexParameters/dEnsembleNum ********************/ - datasetBranch ("/sramParameters/indexParameters/dEnsembleNum", floatArray); - scenParams.indexParams.dEnsembleNum.clear(); - for (quint32 var = 0; var < scenParams.totalTxShotNumber; var++) - scenParams.indexParams.dEnsembleNum.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/txParameters/txFocusXPos ********************/ - datasetBranch ("/sramParameters/txParameters/txFocusXPos", floatArray); - scenParams.txParams.txFocusXPos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.txParams.txFocusXPos.push_back(floatArray[var]); - - /**************** /sramParameters/txParameters/txFocusYPos ********************/ - datasetBranch ("/sramParameters/txParameters/txFocusYPos", floatArray); - scenParams.txParams.txFocusYPos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.txParams.txFocusYPos.push_back(floatArray[var]); - - /**************** /sramParameters/txParameters/txFocusZPos ********************/ - datasetBranch ("/sramParameters/txParameters/txFocusZPos", floatArray); - scenParams.txParams.txFocusZPos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.txParams.txFocusZPos.push_back(floatArray[var]); - - /**************** /sramParameters/txParameters/txStartActiveElementNo ********************/ - datasetBranch ("/sramParameters/txParameters/txStartActiveElementNo", floatArray); - scenParams.txParams.txStartActiveElementNumber.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.txParams.txStartActiveElementNumber.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/txParameters/txActiveElementNo ********************/ - datasetBranch ("/sramParameters/txParameters/txActiveElementNo", floatArray); - scenParams.txParams.txActiveElementNumber.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.txParams.txActiveElementNumber.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/txParameters/maxDelayQ ********************/ - datasetBranch ("/sramParameters/txParameters/maxDelayQ", floatArray); - scenParams.txParams.maxDelayQ.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.txParams.maxDelayQ.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/rxR0CenterActiveElementNo ********************/ - datasetBranch ("/sramParameters/rxParameters/rxR0CenterActiveElementNo", floatArray); - scenParams.rxParams.rxR0CenterActiveElementNumber.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.rxR0CenterActiveElementNumber.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/rxR0ActiveElementNo ********************/ - datasetBranch ("/sramParameters/rxParameters/rxR0ActiveElementNo", floatArray); - scenParams.rxParams.rxR0ActiveElementNumber.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.rxR0ActiveElementNumber.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/rxActiveElementStep ********************/ - datasetBranch ("/sramParameters/rxParameters/rxActiveElementStep", floatArray); - scenParams.rxParams.rxActiveElementStep.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.rxActiveElementStep.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/interceptPointFiringTime ********************/ - datasetBranch ("/sramParameters/rxParameters/interceptPointFiringTime", floatArray); - scenParams.rxParams.interceptPointFiringTime.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.interceptPointFiringTime.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/rxFocusPointNo ********************/ - datasetBranch ("/sramParameters/rxParameters/rxFocusPointNo", floatArray); - scenParams.rxParams.rxFocusPointNumber.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.rxFocusPointNumber.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/r0Position ********************/ - datasetBranch ("/sramParameters/rxParameters/r0Position", floatArray); - scenParams.rxParams.r0Position.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.r0Position.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/thetaCos ********************/ - datasetBranch ("/sramParameters/rxParameters/thetaCos", floatArray); - scenParams.rxParams.thetaCos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.thetaCos.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/thetaSin ********************/ - datasetBranch ("/sramParameters/rxParameters/thetaSin", floatArray); - scenParams.rxParams.thetaSin.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.thetaSin.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/phiCos ********************/ - datasetBranch ("/sramParameters/rxParameters/phiCos", floatArray); - scenParams.rxParams.phiCos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.phiCos.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/phiSin ********************/ - datasetBranch ("/sramParameters/rxParameters/phiSin", floatArray); - scenParams.rxParams.phiSin.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.phiSin.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/interceptXPos ********************/ - datasetBranch ("/sramParameters/rxParameters/interceptXPos", floatArray); - scenParams.rxParams.interceptXPos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.interceptXPos.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/interceptYPos ********************/ - datasetBranch ("/sramParameters/rxParameters/interceptYPos", floatArray); - scenParams.rxParams.interceptYPos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.interceptYPos.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/interceptZPos ********************/ - datasetBranch ("/sramParameters/rxParameters/interceptZPos", floatArray); - scenParams.rxParams.interceptZPos.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.interceptZPos.push_back(floatArray[var]); - - /**************** /sramParameters/rxParameters/txR0MinDelayQ ********************/ - datasetBranch ("/sramParameters/rxParameters/txR0MinDelayQ", floatArray); - scenParams.rxParams.txR0MinDelayQ.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.txR0MinDelayQ.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/rxR0MinDelayQ ********************/ - datasetBranch ("/sramParameters/rxParameters/rxR0MinDelayQ", floatArray); - scenParams.rxParams.rxR0MinDelayQ.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.rxR0MinDelayQ.push_back(static_cast(floatArray[var])); - - /**************** /sramParameters/rxParameters/rxR0MaxDelayQ ********************/ - datasetBranch ("/sramParameters/rxParameters/rxR0MaxDelayQ", floatArray); - scenParams.rxParams.rxR0MaxDelayQ.clear(); - for (quint32 var = 0; var < scenParams.focusTypeNumber; var++) - scenParams.rxParams.rxR0MaxDelayQ.push_back(static_cast(floatArray[var])); - - /**************** /registerParameters/pulseTypeNo ********************/ - datasetBranch ("/registerParameters/pulseTypeNo", floatArray); - scenParams.hwRegister.pulseTypeNumber = static_cast(floatArray[0]); - - /**************** /registerParameters/rxBeamformerTypeNo ********************/ - datasetBranch ("/registerParameters/rxBeamformerTypeNo", floatArray); - scenParams.hwRegister.rxBeamFormerTypeNumber = static_cast(floatArray[0]); - - /**************** /registerParameters/receiverConfigTypeNo ********************/ - datasetBranch ("/registerParameters/receiverConfigTypeNo", floatArray); - scenParams.hwRegister.receiverConfigTypeNumber = static_cast(floatArray[0]); - - /**************** /registerParameters/blendWeight ********************/ - datasetBranch ("/registerParameters/blendWeight", floatArray); - scenParams.hwRegister.blendWeight.clear(); - QVector tempBlendWeight; - - for (quint32 i = 0; i < 4; i++) - { - tempBlendWeight.clear(); - for (quint32 j = 0; j < 512; j++) - { - tempBlendWeight.push_back(floatArray[j + i * 512]); - } - scenParams.hwRegister.blendWeight.push_back(tempBlendWeight); - } - - /**************** /registerParameters/freqLut ********************/ - datasetBranch ("/registerParameters/freqLut", floatArray); - scenParams.hwRegister.freqLut.clear(); - for (quint32 var = 0; var < 8; var++) - scenParams.hwRegister.freqLut.push_back(floatArray[var]); - - /**************** /registerParameters/dTgcLut ********************/ - datasetBranch ("/registerParameters/dTgcLut", floatArray); - scenParams.hwRegister.dtgcLut.clear(); - for (quint32 var = 0; var < 1024; var++) - scenParams.hwRegister.dtgcLut.push_back(floatArray[var]); - - /**************** /registerParameters/elementXPositions ********************/ - datasetBranch ("/registerParameters/elementXPositions", floatArray); - scenParams.hwRegister.elementXPosition.clear(); - for (quint32 var = 0; var < 192; var++) - scenParams.hwRegister.elementXPosition.push_back(floatArray[var]); - - /**************** /registerParameters/elementYPositions ********************/ - datasetBranch ("/registerParameters/elementYPositions", floatArray); - scenParams.hwRegister.elementYPosition.clear(); - for (quint32 var = 0; var < 192; var++) - scenParams.hwRegister.elementYPosition.push_back(floatArray[var]); - - /**************** /registerParameters/elementZPositions ********************/ - datasetBranch ("/registerParameters/elementZPositions", floatArray); - scenParams.hwRegister.elementZPosition.clear(); - for (quint32 var = 0; var < 192; var++) - scenParams.hwRegister.elementZPosition.push_back(floatArray[var]); - - /**************** /registerParameters/scenarioStartIndex ********************/ - datasetBranch ("/registerParameters/scenarioStartIndex", floatArray); - scenParams.hwRegister.scenarioStartIndex = static_cast(floatArray[0]); - - /**************** /registerParameters/scenarioEndIndex ********************/ - datasetBranch ("/registerParameters/scenarioEndIndex", floatArray); - scenParams.hwRegister.scenarioEndIndex = static_cast(floatArray[0]); - - /**************** /registerParameters/apodizationLut ********************/ - datasetBranch ("/registerParameters/apodizationLut", floatArray); - scenParams.hwRegister.apodizationLut.clear(); - QVector tempApodization; - - for (quint32 i = 0; i < 4; i++) - { - tempApodization.clear(); - for (quint32 j = 0; j < 3057; j++) - { - tempApodization.push_back(static_cast(floatArray[j + i * 3057])); - } - scenParams.hwRegister.apodizationLut.push_back(tempApodization); - } - -// for(auto j=0; j<100; j++) -// { -// qDebug() << scenParams.hwRegister.apodizationLut[3][j]; -// } - - /**************** /registerParameters/aTgcLut ********************/ - datasetBranch ("/registerParameters/aTgcLut", floatArray); - scenParams.hwRegister.atgcLut.clear(); - QVector tempAtgc; - - for (quint32 i = 0; i < 4; i++) - { - tempAtgc.clear(); - for (quint32 j = 0; j < 128; j++) - { - tempAtgc.push_back(static_cast(floatArray[j + i * 128])); - } - scenParams.hwRegister.atgcLut.push_back(tempAtgc); - } - - /**************** /registerParameters/lpfLut ********************/ - datasetBranch ("/registerParameters/lpfLut", floatArray); - scenParams.hwRegister.lpfLut.clear(); - QVector tempLpf; - - for (quint32 i = 0; i < 4; i++) - { - tempLpf.clear(); - for (quint32 j = 0; j < 48; j++) - { - tempLpf.push_back(static_cast(floatArray[j + i * 48])); - } - scenParams.hwRegister.lpfLut.push_back(tempLpf); - } - - /**************** /registerParameters/lineFilter ********************/ - //datasetBranch ("/registerParameters/lpfLut", floatArray); - QVector lineFilter; - lineFilter.push_back(0x0); - lineFilter.push_back(0x0); - lineFilter.push_back(0x1); - _trx.setLineFilterCoefficient(lineFilter); - - /**************** /registerParameters/pulseProperties/halfPeriod ********************/ - datasetBranch ("/registerParameters/pulseProperties/halfPeriod", floatArray); - QList halfPeriod; - - for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) - { - halfPeriod.push_back(static_cast(floatArray[j])); - } - - - /**************** /registerParameters/pulseProperties/halfCycleNo ********************/ - datasetBranch ("/registerParameters/pulseProperties/halfCycleNo", floatArray); - QList halfCycleNo; - - for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) - { - halfCycleNo.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/pulseProperties/pulseVoltSel ********************/ - datasetBranch ("/registerParameters/pulseProperties/pulseVoltSel", floatArray); - QList pulseVoltSel; - - for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) - { - pulseVoltSel.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/pulseProperties/startPhase ********************/ - datasetBranch ("/registerParameters/pulseProperties/startPhase", floatArray); - QList startPhase; - - for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) - { - startPhase.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/pulseProperties/dampingPulseWidth ********************/ - datasetBranch ("/registerParameters/pulseProperties/dampingPulseWidth", floatArray); - QList dampingPulseWidth; + Hdf5 hdf; + ScenGenHardwareOutput_t scenParams; + ScenPrbDepHardwareParam prbDepParams; + QVector lineFilterLut; + QVector stbLut; - for (quint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) - { - dampingPulseWidth.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/pulseProperties ********************/ - Pulse_t pulseObj; - scenParams.hwRegister.pulseProps.clear(); - - for (qint32 j = 0; j < scenParams.hwRegister.pulseTypeNumber; j++) - { - pulseObj.halfPeriod = halfPeriod.at(j); - pulseObj.startPhase = startPhase.at(j); - pulseObj.halfCycleNo = halfCycleNo.at(j); - pulseObj.pulseVoltSel = pulseVoltSel.at(j); - pulseObj.dampingPulseWidth = dampingPulseWidth.at(j); - - scenParams.hwRegister.pulseProps.push_back(pulseObj); - } - - - /**************** /registerParameters/rxBeamformerProperties/mla ********************/ - datasetBranch ("/registerParameters/rxBeamformerProperties/mla", floatArray); - QList mla; - - for (quint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) - { - mla.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/rxBeamformerProperties/lag ********************/ - datasetBranch ("/registerParameters/rxBeamformerProperties/lag", floatArray); - QList lag; - - for (quint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) - { - lag.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/rxBeamformerProperties/apodizationSel ********************/ - datasetBranch ("/registerParameters/rxBeamformerProperties/apodizationSel", floatArray); - QList apodizationSel; - - for (quint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) - { - apodizationSel.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/rxBeamformerProperties ********************/ - RxBeamFormer_t rxBeamformerObj; - scenParams.hwRegister.rxBeamFormerProps.clear(); - - for (qint32 j = 0; j < scenParams.hwRegister.rxBeamFormerTypeNumber; j++) - { - rxBeamformerObj.mla = mla.at(j); - rxBeamformerObj.lag = lag.at(j); - rxBeamformerObj.apodizationSel = apodizationSel.at(j); - - scenParams.hwRegister.rxBeamFormerProps.push_back(rxBeamformerObj); - } - - - /**************** /registerParameters/receiverConfigProperties/mla ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/mla", floatArray); - QList receiverCfgMla; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - receiverCfgMla.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/lineMode ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/lineMode", floatArray); - QList lineMode; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - lineMode.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/aTgcSel ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/aTgcSel", floatArray); - QList aTgcSel; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - aTgcSel.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/stbEn ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/stbEn", floatArray); - QList stbEn; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - stbEn.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/stb ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/stb", floatArray); - QList stb; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - stb.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/subtractFilterEn ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/subtractFilterEn", floatArray); - QList subtractFilterEn; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - subtractFilterEn.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/dcCancelEn ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/dcCancelEn", floatArray); - QList dcCancelEn; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - dcCancelEn.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/ncoFreqSel ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/ncoFreqSel", floatArray); - QList ncoFreqSel; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - ncoFreqSel.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/lpfSel ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/lpfSel", floatArray); - QList lpfSel; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - lpfSel.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/absEn ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/absEn", floatArray); - QList absEn; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - absEn.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/focusNo ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/focusNo", floatArray); - QList focusNo; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - focusNo.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/lineFilterEn ********************/ - datasetBranch ("/registerParameters/receiverConfigProperties/lineFilterEn", floatArray); - QList lineFilterEn; - - for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - lineFilterEn.push_back(static_cast(floatArray[j])); - } - - /**************** /registerParameters/receiverConfigProperties/dpeEn ********************/ -// datasetBranch ("/registerParameters/receiverConfigProperties/dpeEn", floatArray); -// QList dpeEn; - -// for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) -// { -// dpeEn.push_back(static_cast(floatArray[j])); -// } - - /**************** /registerParameters/receiverConfigProperties/ddcEn ********************/ -// datasetBranch ("/registerParameters/receiverConfigProperties/ddcEn", floatArray); -// QList ddcEn; - -// for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) -// { -// ddcEn.push_back(static_cast(floatArray[j])); -// } - - /**************** /registerParameters/receiverConfigProperties/wmfEn ********************/ -// datasetBranch ("/registerParameters/receiverConfigProperties/wmfEn", floatArray); -// QList wmfEn; - -// for (quint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) -// { -// wmfEn.push_back(static_cast(floatArray[j])); -// } - - /**************** /registerParameters/receiverConfigProperties ********************/ - ReceiverConfig_t receiverCfgObj; - scenParams.hwRegister.receiverConfigProps.clear(); - - for (qint32 j = 0; j < scenParams.hwRegister.receiverConfigTypeNumber; j++) - { - receiverCfgObj.mla = receiverCfgMla.at(j); - receiverCfgObj.stb = stb.at(j); - //receiverCfgObj.ddcn = ddcEn.at(j); - receiverCfgObj.ddcn = 1; - receiverCfgObj.absEn = absEn.at(j); - //receiverCfgObj.dpeEn = dpeEn.at(j); - receiverCfgObj.dpeEn = 0; - receiverCfgObj.stbEn = stbEn.at(j); - //receiverCfgObj.wmfEn = wmfEn.at(j); - receiverCfgObj.wmfEn = 0; - receiverCfgObj.lpfSel = lpfSel.at(j); - receiverCfgObj.aTgcSel = aTgcSel.at(j); - receiverCfgObj.focusNo = focusNo.at(j); - receiverCfgObj.lineMode = lineMode.at(j); - receiverCfgObj.dcCancelEn = dcCancelEn.at(j); - receiverCfgObj.ncoFreqSel = ncoFreqSel.at(j); - receiverCfgObj.lineFilterEn = lineFilterEn.at(j); - receiverCfgObj.subtractFilterEn = subtractFilterEn.at(j); - - scenParams.hwRegister.receiverConfigProps.push_back(receiverCfgObj); - } + hdf.hdf5Path(h5Path); + hdf.scenarioRead(scenParams); + hdf.prbDependParamsRead(prbDepParams); + prbDepParams.afeCfg = _afeConfig; + stbLut = hdf.stbRead(); + lineFilterLut = hdf.lineFilterRead(); + try + { _trx.setScenario(scenParams); - + _trx.setProbeDependParams(prbDepParams); + _trx.setLineFilterCoefficient(lineFilterLut); + _trx.setStbCoefficient(stbLut); } catch (SonoException& e) { @@ -3164,6 +2354,12 @@ void MainWindow::setScenario(const string &h5Path) ui->btn_scenStart->setText("Scenario Start"); ui->btn_emulator->setText("Emulator Start"); + auto startIdx = _usd->readWord(0x804, 0); + auto endIdx = _usd->readWord(0x808, 0); + + ui->tb_startIdx->setText(QString::number(startIdx, 16)); + ui->tb_endIdx->setText(QString::number(endIdx, 16)); + ui->l_scenFillingDone->setText("done"); changeLabelTextColor(ui->l_scenFillingDone, Qt::green); } @@ -3183,130 +2379,66 @@ void MainWindow::on_btn_setScenario_clicked() } /*************************************************************************************************/ -void MainWindow::on_btn_scenBrowse_clicked() +void MainWindow::getSramBinaryCreateFlag() { - QFileDialog fileDialog; - fileDialog.setFileMode(QFileDialog::Directory); - fileDialog.setOption(QFileDialog::ShowDirsOnly); - auto result = fileDialog.exec(); - - if(result) - { - auto selectedPath = fileDialog.selectedFiles()[0]; - ui->tb_scenFilesPath->setText(selectedPath); - _settings->setValue(SCENARIO_FILE_PATH, selectedPath); - } + ui->l_createSramBinary->setText("done"); + changeLabelTextColor(ui->l_createSramBinary, Qt::green); } /*************************************************************************************************/ -void MainWindow::verifySramParams(QString& sramParamsPath) +void MainWindow::getRegisterCsvCompareFlag() { - + ui->l_verifyRegisterParams->setText("done"); + changeLabelTextColor(ui->l_verifyRegisterParams, Qt::green); } /*************************************************************************************************/ -void MainWindow::on_btn_sramParamsVerifying_clicked() +void MainWindow::getSramVerifyMessage(QString message) { + ui->l_verifySramParams->setText("done"); + changeLabelTextColor(ui->l_verifySramParams, Qt::green); - + MESSAGE_BOX(message); } /*************************************************************************************************/ -void MainWindow::verifyRegisterParams(QString& regParamsPath) +void MainWindow::setScenarioCompare(const QString &scenPath) { - QString registerScenario = "/hardware/register.csv"; - QString regReadParamsPath = regParamsPath + registerScenario; - QFile csvReadFile(regReadParamsPath); - if(!csvReadFile.open(QFile::ReadOnly)) - { - MESSAGE_BOX("Could not open the register's scenario params."); - return; - } - - QString registerCompareScenario = "/hardware/registerCompare.csv"; - QString regCompareParamsPath = regParamsPath + registerCompareScenario; - QFile csvWriteFile(regCompareParamsPath); - csvWriteFile.open(QFile::WriteOnly); - - quint32 bar = 0; - qint64 readSize = 0; - QString line; - - auto size = csvReadFile.size(); - while(readSize < size) - { - line = csvReadFile.readLine(); - auto sl = line.split(','); - auto address = sl[0].toUInt(Q_NULLPTR, 16); - auto baseValue = sl[1].toUInt(Q_NULLPTR, 16); - auto boardValue = _usd->readWord(address, bar); - - auto res = "NOK"; - if (boardValue == baseValue) - { - res = "OK"; - } - - auto str = QStringLiteral("%1,%2,%3,%4") - .arg(address, 8, 16, QLatin1Char('0')) - .arg(baseValue, 8, 16, QLatin1Char('0')) - .arg(boardValue, 8, 16, QLatin1Char('0')).arg(res); - - - csvWriteFile.write(str.toStdString().c_str(), str.length()); - csvWriteFile.write("\r\n", 2); - - readSize += static_cast(line.length()); - //delay(1); - } - - csvReadFile.close(); - - csvWriteFile.flush(); - csvWriteFile.close(); - - ui->l_verifyRegisterParams->setText("done"); - changeLabelTextColor(ui->l_verifyRegisterParams, Qt::green); - + _trx.setScenarioCompare(scenPath); } /*************************************************************************************************/ -void MainWindow::on_btn_registerParamsVerifying_clicked() +void MainWindow::on_btn_setScenVerification_clicked() { - _timeout->stop(); + ui->l_createSramBinary->setText("doing"); + changeLabelTextColor(ui->l_createSramBinary, Qt::red); + ui->l_verifyRegisterParams->setText("doing"); changeLabelTextColor(ui->l_verifyRegisterParams, Qt::red); - QString regParamsPath = ui->tb_scenFilesPath->text(); + ui->l_verifySramParams->setText("doing"); + changeLabelTextColor(ui->l_verifySramParams, Qt::red); + + const QString scenPath = ui->tb_scenFilesPath->text(); + + QtConcurrent::run(this, &MainWindow::setScenarioCompare, scenPath); - auto scenFuture = QtConcurrent::run(this, &MainWindow::verifyRegisterParams, regParamsPath); - scenEndWather.setFuture(scenFuture); } /*************************************************************************************************/ -void MainWindow::on_btn_sramParamsGenerating_clicked() +void MainWindow::on_btn_scenBrowse_clicked() { - //QString saveFile = QFileDialog::getSaveFileName(this, "Save"); - QString saveFile = "/home/hasis/Desktop/Develop_HardwareTest/saveSram.bin"; - - QFile sramFile(saveFile); - - if (!sramFile.open(QIODevice::WriteOnly)){ - QMessageBox::warning(this, "Warning", "Cann't save the file: " + sramFile.errorString()); - return; - } + QFileDialog fileDialog; + fileDialog.setFileMode(QFileDialog::Directory); + fileDialog.setOption(QFileDialog::ShowDirsOnly); + auto result = fileDialog.exec(); - quint32 num(0); - quint64 value(0); - while (num < SRAM_SIZE/4) + if(result) { - value = _usd->device->device.readLong(BAR_SRAM, static_cast(num)); - sramFile.write(Uint2ByteArray(value)); - num += sizeof (quint64); + auto selectedPath = fileDialog.selectedFiles()[0]; + ui->tb_scenFilesPath->setText(selectedPath); + _settings->setValue(SCENARIO_FILE_PATH, selectedPath); } - - sramFile.flush(); - sramFile.close(); } /*************************************************************************************************/ @@ -3323,21 +2455,36 @@ void MainWindow::on_btn_setAtgcMode_clicked() } /*************************************************************************************************/ -template -QByteArray MainWindow::Uint2ByteArray(T data) +void MainWindow::on_btn_setIdx_clicked() { - QByteArray byte; - QDataStream out (&byte, QIODevice::WriteOnly); - out.setByteOrder(QDataStream::LittleEndian); - out << data; + quint32 bar(0); + auto startIndex = ui->tb_startIdx->text().toUInt(Q_NULLPTR, 16); + if(startIndex == 0 && ui->tb_startIdx->text() != "0") + { + MESSAGE_BOX("Invalid input format for start index"); + return; + } - return byte; + auto endIndex = ui->tb_endIdx->text().toUInt(Q_NULLPTR, 16); + if(endIndex == 0 && ui->tb_endIdx->text() != "0") + { + MESSAGE_BOX("Invalid input format for stop index"); + return; + } + + if((endIndex < startIndex) || (endIndex>131071) || (startIndex>131071)) + { + MESSAGE_BOX("Stop index should be greater than or equal to start index"); + return; + } + + _usd->writeWord(0x804, bar, startIndex); + _usd->writeWord(0x808, bar, endIndex); } /*************************************************************************************************/ /**************************************** EEPROM *************************************************/ /*************************************************************************************************/ - QByteArray MainWindow::str2ByteArray (QString& str) { QByteArray finalArray; @@ -3378,23 +2525,22 @@ QString MainWindow::byteArray2InfoString (QByteArray& arr) { quint8 l = static_cast(j); if (l <= 15) - infoStr = infoStr + "0" + QString::number(l, 16); + infoStr += "0" + QString::number(l, 16); else - infoStr = infoStr + QString::number(l, 16); + infoStr += QString::number(l, 16); } return infoStr; } - -void MainWindow::on_btn_trxRomWrite_clicked() +/*************************************************************************************************/ +/*************************************************************************************************/ +void MainWindow::on_btn_trxRomIdWrite_clicked() { - - QString txtStr = ui->tb_trxRomWrite->toPlainText(); + QString idStr = ui->tb_trxRomId->text(); try { - QByteArray sendingArray = str2ByteArray(txtStr); - trxEepromWrite(sendingArray, 0, _bCtrl); - + QByteArray sendingArray = str2ByteArray(idStr); + trxEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } catch (const char* exception) { @@ -3405,16 +2551,51 @@ void MainWindow::on_btn_trxRomWrite_clicked() { qDebug() << e.what(); } +} +/*************************************************************************************************/ +void MainWindow::on_btn_trxRomInfoWrite_clicked() +{ + QString infoStr = ui->tb_trxRomInfo->toPlainText(); + try + { + QByteArray sendingArray = infoStr.toLatin1(); + trxEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); +// QByteArray sendingArray; +// unsigned char crcArray[] = {0x4, 0x0, 0x13, 0x0, 0x27, 0x0, 0x28, 0x0, 0xEB, 0x1, +// 0xAC, 0x5, 0xAC, 0x6, 0x4C, 0x6, 0xB0, 0x6, 0xB2, +// 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +// 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +// for(auto var : crcArray) +// sendingArray.push_back(static_cast(var)); + + //trxEepromWrite(sendingArray, EEPROM_CRC_BEGIN, _bCtrl); + } + catch (SonoException& e) + { + qDebug() << e.what(); + } } +/*************************************************************************************************/ void MainWindow::on_btn_trxRomIdRead_clicked() { - + EepromStatus romStatus; try { - quint32 id = _trx.trxId(); - ui->tb_trxRomIdRead->setText(uint2IdString(id)); + _trx.trxState(romStatus); + if (romStatus.ConnectionMode == connected) + { + ui->tb_trxRomId->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the trx eeprom is occured."; + } + else + MESSAGE_BOX("Trx board is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; } catch (SonoException& e) { @@ -3423,31 +2604,28 @@ void MainWindow::on_btn_trxRomIdRead_clicked() } +/*************************************************************************************************/ void MainWindow::on_btn_trxRomInfoRead_clicked() { - try { - QByteArray receivingArray = _trx.trxInfo(); - ui->tb_trxRomInfoRead->setText(byteArray2InfoString(receivingArray)); + QString receivingStr = _trx.trxInfo(); + ui->tb_trxRomInfo->setText(receivingStr); } catch (SonoException& e) { qDebug() << e.what(); } - } - -void MainWindow::on_btn_mpsRomWrite_clicked() +/*************************************************************************************************/ +void MainWindow::on_btn_mpsRomIdWrite_clicked() { - - QString txtStr = ui->tb_mpsRomWrite->toPlainText(); + QString idStr = ui->tb_mpsRomId->text(); try { - QByteArray sendingArray = str2ByteArray(txtStr); - mpsEepromWrite(sendingArray, 0, _bCtrl); - + QByteArray sendingArray = str2ByteArray(idStr); + mpsEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } catch (const char* exception) { @@ -3458,16 +2636,42 @@ void MainWindow::on_btn_mpsRomWrite_clicked() { qDebug() << e.what(); } +} +/*************************************************************************************************/ +void MainWindow::on_btn_mpsRomInfoWrite_clicked() +{ + QString infoStr = ui->tb_mpsRomInfo->toPlainText(); + try + { + QByteArray sendingArray = infoStr.toLatin1(); + mpsEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); + } + catch (SonoException& e) + { + qDebug() << e.what(); + } } +/*************************************************************************************************/ void MainWindow::on_btn_mpsRomIdRead_clicked() { - + EepromStatus romStatus; try { - quint32 id = _trx.mpsId(); - ui->tb_mpsRomIdRead->setText(uint2IdString(id)); + _trx.mpsState(romStatus); + if (romStatus.ConnectionMode == connected) + { + ui->tb_mpsRomId->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the mps eeprom is occured."; + } + else + MESSAGE_BOX("Mps board is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; } catch (SonoException& e) { @@ -3476,31 +2680,28 @@ void MainWindow::on_btn_mpsRomIdRead_clicked() } +/*************************************************************************************************/ void MainWindow::on_btn_mpsRomInfoRead_clicked() { - try { - QByteArray receivingArray = _trx.mpsInfo(); - ui->tb_mpsRomInfoRead->setText(byteArray2InfoString(receivingArray)); + QString receivingStr = _trx.mpsInfo(); + ui->tb_mpsRomInfo->setText(receivingStr); } catch (SonoException& e) { qDebug() << e.what(); } - } - -void MainWindow::on_btn_prbCtrlRomWrite_clicked() +/*************************************************************************************************/ +void MainWindow::on_btn_prbCtrlRomIdWrite_clicked() { - - QString txtStr = ui->tb_prbCtrlRomWrite->toPlainText(); + QString idStr = ui->tb_prbCtrlRomId->text(); try { - QByteArray sendingArray = str2ByteArray(txtStr); - prbCtrlEepromWrite(sendingArray, 0, _bCtrl); - + QByteArray sendingArray = str2ByteArray(idStr); + prbCtrlEepromWrite(sendingArray, EEPROM_ID_BEGIN, _bCtrl); } catch (const char* exception) { @@ -3511,31 +2712,42 @@ void MainWindow::on_btn_prbCtrlRomWrite_clicked() { qDebug() << e.what(); } - } -void MainWindow::on_btn_prbCtrlRomIdRead_clicked() +/*************************************************************************************************/ +void MainWindow::on_btn_prbCtrlRomInfoWrite_clicked() { - + QString infoStr = ui->tb_prbCtrlRomInfo->toPlainText(); try { - quint32 id = _trx.prbCtrlId(); - ui->tb_prbCtrlRomIdRead->setText(uint2IdString(id)); + QByteArray sendingArray = infoStr.toLatin1(); + prbCtrlEepromWrite(sendingArray, EEPROM_INFO_BEGIN, _bCtrl); } catch (SonoException& e) { qDebug() << e.what(); } - } -void MainWindow::on_btn_prbCtrlRomInfoRead_clicked() +/*************************************************************************************************/ +void MainWindow::on_btn_prbCtrlRomIdRead_clicked() { - + EepromStatus romStatus; try { - QByteArray receivingArray = _trx.prbCtrlInfo(); - ui->tb_prbCtrlRomInfoRead->setText(byteArray2InfoString(receivingArray)); + _trx.prbCtrlState(romStatus); + if (romStatus.ConnectionMode == connected) + { + ui->tb_prbCtrlRomId->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the prbCtrl eeprom is occured."; + } + else + MESSAGE_BOX("PrbCtrl board is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; } catch (SonoException& e) { @@ -3544,43 +2756,120 @@ void MainWindow::on_btn_prbCtrlRomInfoRead_clicked() } - -void MainWindow::on_btn_prbRomWrite_clicked() +/*************************************************************************************************/ +void MainWindow::on_btn_prbCtrlRomInfoRead_clicked() { - - auto sel = ui->cb_prbSelRom->currentIndex(); - QString txtStr = ui->tb_prbRomWrite->toPlainText(); try { - QByteArray sendingArray = str2ByteArray(txtStr); - prbEepromWrite(sendingArray, 0, static_cast(sel), _bCtrl); - - } - catch (const char* exception) - { - qDebug() << exception; + QString receivingStr = _trx.prbCtrlInfo(); + ui->tb_prbCtrlRomInfo->setText(receivingStr); } - catch (SonoException& e) { qDebug() << e.what(); } - } +/*************************************************************************************************/ void MainWindow::on_btn_prbRomIdRead_clicked() { - auto sel = ui->cb_prbSelRom->currentIndex(); - quint32 id(0); + EepromStatus romStatus; try { switch (sel) { - case 0: id = _trx.prbId(prbA); break; - case 1: id = _trx.prbId(prbB); break; - case 2: id = _trx.prbId(prbC); break; - case 3: id = _trx.prbId(prbD); break; + case 0: + try + { + _trx.selectedPrbState(romStatus, prbA); + if (romStatus.ConnectionMode == connected) + { + ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe A eeprom is occured."; + } + else + MESSAGE_BOX("Probe A is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; + } + catch (SonoException& e) + { + qDebug() << e.what(); + } + break; + + case 1: + try + { + _trx.selectedPrbState(romStatus, prbB); + if (romStatus.ConnectionMode == connected) + { + ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe B eeprom is occured."; + } + else + MESSAGE_BOX("Probe B is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; + } + catch (SonoException& e) + { + qDebug() << e.what(); + } + break; + + case 2: + try + { + _trx.selectedPrbState(romStatus, prbC); + if (romStatus.ConnectionMode == connected) + { + ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe C eeprom is occured."; + } + else + MESSAGE_BOX("Probe C is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; + } + catch (SonoException& e) + { + qDebug() << e.what(); + } + break; + + case 3: + try + { + _trx.selectedPrbState(romStatus, prbD); + if (romStatus.ConnectionMode == connected) + { + ui->tb_prbRomIdRead->setText(uint2IdString(romStatus.id)); + if (romStatus.errorCode == EEPROM_CRC_ERROR) + throw "The crc error of the probe D eeprom is occured."; + } + else + MESSAGE_BOX("Probe D is disconnected."); + } + catch (const char* exception) + { + qDebug() << exception; + } + catch (SonoException& e) + { + qDebug() << e.what(); + } + break; } } @@ -3588,74 +2877,26 @@ void MainWindow::on_btn_prbRomIdRead_clicked() { qDebug() << e.what(); } - ui->tb_prbRomIdRead->setText(uint2IdString(id)); - } -void MainWindow::on_btn_prbRomInfoRead_clicked() +/*************************************************************************************************/ +void MainWindow::on_btn_prbRomImpulseRead_clicked() { - try { auto sel = ui->cb_prbSelRom->currentIndex(); - QByteArray receivingArray = _trx.prbInfo(static_cast(sel)); - ui->tb_prbRomInfoRead->setText(byteArray2InfoString(receivingArray)); + QByteArray receivingArray = _trx.selectedPrbImpulseResponse(static_cast(sel)); + ui->tb_prbRomImpulseRead->setText(byteArray2InfoString(receivingArray)); } catch (SonoException& e) { qDebug() << e.what(); } - } /*************************************************************************************************/ /*********************************** AFE Configuration *******************************************/ /*************************************************************************************************/ - - -//void MainWindow::on_btn_scenParams_clicked() -//{ -// ui->l_scenParams->setText("doing"); -// changeLabelTextColor(ui->l_scenParams, Qt::red); - -// _scenParams.focusTypeNumber = 100; -// _scenParams.totalTxShotNumber = 100; - -// for (int var = 0; var < 100; var++) { -// _scenParams.rxBeamFormerNumber.append(5); -// } - -// auto startIndex = ui->tb_startIdx->text().toUInt(Q_NULLPTR, 16); -// if(startIndex == 0 && ui->tb_startIdx->text() != "0") -// { -// MESSAGE_BOX("Invalid input format for start index"); -// return; -// } - -// auto endIndex = ui->tb_endIdx->text().toUInt(Q_NULLPTR, 16); -// if(endIndex == 0 && ui->tb_endIdx->text() != "0") -// { -// MESSAGE_BOX("Invalid input format for stop index"); -// return; -// } -// _scenParams.hwRegister.scenarioStartIndex = startIndex; -// _scenParams.hwRegister.scenarioEndIndex = endIndex; - -// try -// { -// _trx.setScenario(_scenParams); -// } - -// catch(SonoException& e) -// { -// qDebug() << e.what(); -// } - -// ui->l_scenParams->setText("done"); -// changeLabelTextColor(ui->l_scenParams, Qt::green); -//} - -/*************************************************************************************************/ void MainWindow::on_btn_afeRead_clicked() { auto sel = ui->cb_afeSlaveSelect->currentIndex(); @@ -3698,10 +2939,3 @@ void MainWindow::setAfeConfig() _afeConfig.inputClampLevel = inputClampLvlAuto; } /*************************************************************************************************/ -void MainWindow::on_btn_afeConfig_clicked() -{ - _trx.setAfeConfig(_afeConfig); -} - -/*************************************************************************************************/ - diff --git a/mainwindow.h b/mainwindow.h index da05b93..ce6493d 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,10 +22,8 @@ #include "qcustomplot.h" #include "include/model/hardware/core/TrxBoard.h" +#include "hdf5Scenario/hdf5Scenario.h" #include "api.h" -#include "H5Cpp.h" -#include "hdf5.h" -#include "H5File.h" #define MESSAGE_BOX(M) \ emit showMessage(M) @@ -64,13 +62,10 @@ #define ULTIMATE_LOG_COUNT 50 -#define MAX_ARRAY_DEPTH 131072U - QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE -using namespace H5; using namespace std; class MainWindow : public QMainWindow @@ -117,27 +112,15 @@ private: StatusVec* _vec; - AfeConfig _afeConfig; + PrbCase* _prb; - ScenGenHardwareOutput_t scenParams; + AfeConfig _afeConfig; QFutureWatcher scenEndWather; - H5File _file; - - float_t floatArray[MAX_ARRAY_DEPTH]; - - template - void datasetBranch(const string& branchPath, T datasetValue[MAX_ARRAY_DEPTH]); - - template - QByteArray Uint2ByteArray(T data); - void setScenario(const string& h5Path); - void verifyRegisterParams(QString& regParamsPath); - - void verifySramParams(QString& sramParamsPath); + void setScenarioCompare(const QString& scenPath); void fpgaProgrammer(QString path); @@ -163,6 +146,10 @@ private: QString byteArray2InfoString (QByteArray& arr); + QString releaseCodeVersion (quint32 &value); + + void getProbeColor (const QBrush brush, const int item); + QString _logFolder = "/home/hasis/Desktop/TrxBoardFile/_log/dma/"; QString _emulFolder = "/home/hasis/Desktop/Develop_HardwareTest/developHw/sram_frame.bin"; @@ -180,10 +167,16 @@ private: private slots: - void getPrbChange(); - void getFramePacket (QByteArray packet); + void getSramBinaryCreateFlag (void); + + void getRegisterCsvCompareFlag (void); + + void getSramVerifyMessage(QString message); + + void getPrbChange(); + void restartTimer(); void on_rbtn_reg_toggled(bool checked); @@ -299,32 +292,6 @@ private slots: void on_btn_setAtgcMode_clicked(); - - void on_btn_trxRomWrite_clicked(); - - void on_btn_trxRomIdRead_clicked(); - - void on_btn_trxRomInfoRead_clicked(); - - void on_btn_mpsRomWrite_clicked(); - - void on_btn_mpsRomIdRead_clicked(); - - void on_btn_mpsRomInfoRead_clicked(); - - void on_btn_prbCtrlRomWrite_clicked(); - - void on_btn_prbCtrlRomIdRead_clicked(); - - void on_btn_prbCtrlRomInfoRead_clicked(); - - void on_btn_prbRomWrite_clicked(); - - void on_btn_prbRomIdRead_clicked(); - - void on_btn_prbRomInfoRead_clicked(); - - void on_btn_scenStart_clicked(); void on_btn_emulator_clicked(); @@ -349,17 +316,41 @@ private slots: void on_chk_mpsInit_clicked(); - void on_btn_afeConfig_clicked(); - void on_btn_scenBrowse_clicked(); void on_btn_setScenario_clicked(); - void on_btn_sramParamsVerifying_clicked(); + void on_btn_setScenVerification_clicked(); + + void on_btn_setIdx_clicked(); + + void on_btn_trxRomInfoWrite_clicked(); + + void on_btn_trxRomIdWrite_clicked(); + + void on_btn_mpsRomIdWrite_clicked(); + + void on_btn_mpsRomInfoWrite_clicked(); + + void on_btn_prbCtrlRomIdWrite_clicked(); - void on_btn_registerParamsVerifying_clicked(); + void on_btn_prbCtrlRomInfoWrite_clicked(); - void on_btn_sramParamsGenerating_clicked(); + void on_btn_prbRomImpulseRead_clicked(); + + void on_btn_trxRomIdRead_clicked(); + + void on_btn_trxRomInfoRead_clicked(); + + void on_btn_mpsRomIdRead_clicked(); + + void on_btn_mpsRomInfoRead_clicked(); + + void on_btn_prbCtrlRomIdRead_clicked(); + + void on_btn_prbCtrlRomInfoRead_clicked(); + + void on_btn_prbRomIdRead_clicked(); signals: // void updateBlockProgressValue(int percentage, QProgressBar* prg); diff --git a/mainwindow.ui b/mainwindow.ui index 373d8b7..dcf6766 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 854 - 907 + 883 @@ -18,16 +18,16 @@ 0 - 9 + 0 811 - 341 + 331 - 2 + 0 @@ -404,10 +404,10 @@ - 449 - 210 + 440 + 190 351 - 91 + 101 @@ -417,7 +417,7 @@ 10 - 40 + 50 37 15 @@ -430,7 +430,7 @@ 50 - 40 + 50 79 23 @@ -450,7 +450,7 @@ 140 - 40 + 50 38 15 @@ -463,7 +463,7 @@ 180 - 40 + 50 71 23 @@ -473,7 +473,7 @@ 260 - 40 + 50 80 23 @@ -487,9 +487,9 @@ 0 - 210 - 431 - 91 + 190 + 331 + 101 @@ -499,7 +499,7 @@ 0 - 40 + 50 71 23 @@ -527,7 +527,7 @@ 80 - 40 + 50 71 23 @@ -540,7 +540,7 @@ 160 - 40 + 50 80 23 @@ -553,9 +553,9 @@ 250 - 20 + 30 71 - 71 + 61 @@ -568,19 +568,6 @@ - - - - 330 - 40 - 95 - 23 - - - - Default Config - - @@ -588,7 +575,7 @@ 0 10 791 - 181 + 171 @@ -674,7 +661,7 @@ - + doing @@ -688,31 +675,37 @@ - 480 - 130 - 130 - 48 + 460 + 70 + 205 + 94 - + - + - Verify Sram Params + Scenario Verification - - - + + + + + + 70 + 15 + + - Verifying: + Sram Bin Creating: - - + + doing @@ -720,35 +713,16 @@ - - - - - - 310 - 130 - 148 - 48 - - - - - - - Verify Register Params - - - - + - Verifying: + Register CSV Comparision: - + doing @@ -757,36 +731,17 @@ - - - - - - 10 - 130 - 150 - 48 - - - - - - - Create Sram Binary - - - - + - + - Creating: + Sram Params Verification: - - + + doing @@ -796,6 +751,76 @@ + + + + 10 + 70 + 281 + 60 + + + + + + + + + + + Start Index: (hex) + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + + + End Index: (hex) + + + + + + + + + + + + + + + 90 + 0 + + + + Set Index + + + + + @@ -932,79 +957,30 @@ 10 0 - 791 - 71 + 381 + 81 TRX - + 0 20 - 291 - 51 - - - - - - - Text: - - - - - - - - 162 - 49 - - - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Write to TRX ROM</span></p></body></html> - - - <html><head/><body><p><br/></p></body></html> - - - - - - - Write - - - - - - - - - 310 - 20 - 181 - 51 + 151 + 61 - - - - - ID: - - - + - + - true + false @@ -1012,127 +988,141 @@ - - - Read - - + + + + + Read ID + + + + + + + Write ID + + + + - + - 510 + 160 20 - 281 - 51 + 221 + 61 - + - - - Info: - - + + + + + Read Info + + + + + + + Write Info + + + + - + + + + 0 + 0 + + - 160 + 100 49 - true - - - - - - - Read + false - + - 10 - 70 - 791 - 71 + 410 + 90 + 381 + 131 - MPS + Probe - + - 0 + 180 20 - 291 - 51 + 201 + 111 - + - + - Text: + Read Impulse Response - + - 162 - 49 + 120 + 20 - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Write to MPS ROM</span></p></body></html> - - - <html><head/><body><p><br/></p></body></html> + - - - - - - Write + + true - + - 310 + 90 20 - 181 - 51 + 82 + 61 - - - + + + - ID: + Read ID - - + + @@ -1141,350 +1131,251 @@ - - - - Read - - - - + - 510 + 0 20 - 281 - 51 + 79 + 23 - - - - - Info: - - - - - - - - 160 - 49 - - - - - - - true - - - - - - - Read - - - - + + <html><head/><body><p><span style=" font-size:8pt; font-weight:600; font-style:italic;">Select Probe</span></p></body></html> + + + + A + + + + + B + + + + + C + + + + + D + + - + - 10 - 140 - 791 - 71 + 410 + 0 + 381 + 81 - ProbeCtrl + MPS - + 0 20 - 291 - 51 + 151 + 61 - - - - - Text: - - - - - - - - 162 - 49 - - - - <html><head/><body><p><span style=" font-size:6pt; font-weight:600; font-style:italic;">Write to probe ctrl ROM</span></p></body></html> - - - - - - - Write - - - - - - - - - 310 - 20 - 181 - 51 - - - - - - - ID: - - - + - + - true + false + + + - - - Read - - + + + + + Read ID + + + + + + + Write ID + + + + - + - 510 + 160 20 - 281 - 51 + 221 + 61 - + - - - Info: - - + + + + + Read Info + + + + + + + Write Info + + + + - + + + + 0 + 0 + + - 160 + 100 49 - - - - true - - - - - - - Read + false - + 10 - 230 - 791 - 71 + 90 + 381 + 81 - Probe + Probe Control - + - 100 - 20 - 251 - 51 - - - - - - - Text: - - - - - - - - 122 - 49 - - - - <html><head/><body><p><span style=" font-size:7pt; font-weight:600; font-style:italic;">Write to probe ROM</span></p></body></html> - - - - - - - Write - - - - - - - - - 360 + 0 20 - 181 - 51 + 151 + 61 - - - - - ID: - - - + - + - true + false + + + - - - Read - - + + + + + Read ID + + + + + + + Write ID + + + + - + - 550 + 160 20 - 241 - 51 + 221 + 61 - + - - - Info: - - + + + + + Read Info + + + + + + + Write Info + + + + - + + + + 0 + 0 + + - 120 + 100 49 - - - - true - - - - - - - Read + false - - - - 10 - 20 - 79 - 23 - - - - <html><head/><body><p><span style=" font-size:8pt; font-weight:600; font-style:italic;">Select Probe</span></p></body></html> - - - - A - - - - - B - - - - - C - - - - - D - - - @@ -1492,7 +1383,7 @@ 0 - 350 + 330 811 161 @@ -2178,9 +2069,9 @@ 0 - 510 + 490 821 - 61 + 91 @@ -2190,68 +2081,16 @@ - Relay Board + Probe Board false - - - - 390 - 30 - 83 - 25 - - - - PushButton - - - - - - 470 - 30 - 83 - 25 - - - - PushButton - - - - - - 0 - 30 - 202 - 19 - - - - - - - Detected_probe: - - - - - - - None - - - - - - 230 - 30 + 540 + 20 142 25 @@ -2290,82 +2129,79 @@ + + + + 0 + 20 + 481 + 61 + + + + + Probe Type + + + + + Slot A + + + + + Slot B + + + + + Slot C + + + + + Slot D + + + + + Disconnected + + + + + Disconnected + + + + + Disconnected + + + + + Disconnected + + + 0 - 570 + 590 821 - 321 + 271 Power Board - - - - 0 - 30 - 281 - 31 - - - - - - - HV_Freq(KHz): - - - - - - - - - - PushButton - - - - - - - - - 340 - 30 - 291 - 31 - - - - - - - PM5_Freq(KHz): - - - - - - - - - - PushButton - - - - - 0 - 70 + 30 131 31 @@ -2387,7 +2223,7 @@ 140 - 70 + 30 131 31 @@ -2409,7 +2245,7 @@ 280 - 70 + 30 141 31 @@ -2431,7 +2267,7 @@ 0 - 150 + 110 141 21 @@ -2457,7 +2293,7 @@ 0 - 170 + 130 141 21 @@ -2483,7 +2319,7 @@ 0 - 190 + 150 141 21 @@ -2509,7 +2345,7 @@ 0 - 210 + 170 141 21 @@ -2535,7 +2371,7 @@ 0 - 230 + 190 141 21 @@ -2561,7 +2397,7 @@ 0 - 250 + 210 141 21 @@ -2587,7 +2423,7 @@ 0 - 270 + 230 141 21 @@ -2613,7 +2449,7 @@ 0 - 290 + 250 141 21 @@ -2639,7 +2475,7 @@ 0 - 130 + 90 141 21 @@ -2665,7 +2501,7 @@ 0 - 110 + 70 141 21 @@ -2691,7 +2527,7 @@ 170 - 110 + 70 161 21 @@ -2717,7 +2553,7 @@ 170 - 130 + 90 161 21 @@ -2743,7 +2579,7 @@ 170 - 150 + 110 161 21 @@ -2769,7 +2605,7 @@ 170 - 190 + 150 161 21 @@ -2795,7 +2631,7 @@ 170 - 210 + 170 161 21 @@ -2821,7 +2657,7 @@ 170 - 230 + 190 161 21 @@ -2847,7 +2683,7 @@ 170 - 250 + 210 161 21 @@ -2873,7 +2709,7 @@ 340 - 210 + 170 171 21 @@ -2899,7 +2735,7 @@ 340 - 130 + 90 171 21 @@ -2925,7 +2761,7 @@ 340 - 250 + 210 171 21 @@ -2951,7 +2787,7 @@ 340 - 190 + 150 171 21 @@ -2977,7 +2813,7 @@ 340 - 230 + 190 171 21 @@ -3003,7 +2839,7 @@ 340 - 110 + 70 171 21 @@ -3029,7 +2865,7 @@ 340 - 170 + 130 173 21 @@ -3055,7 +2891,7 @@ 520 - 210 + 170 181 21 @@ -3081,7 +2917,7 @@ 520 - 150 + 110 181 21 @@ -3107,7 +2943,7 @@ 520 - 130 + 90 181 21 @@ -3133,7 +2969,7 @@ 520 - 250 + 210 181 21 @@ -3159,7 +2995,7 @@ 520 - 190 + 150 181 21 @@ -3185,7 +3021,7 @@ 520 - 230 + 190 181 21 @@ -3211,7 +3047,7 @@ 520 - 110 + 70 181 21 @@ -3237,7 +3073,7 @@ 520 - 170 + 130 181 21 @@ -3263,7 +3099,7 @@ 170 - 290 + 250 161 21 @@ -3289,7 +3125,7 @@ 170 - 270 + 230 161 21 @@ -3315,7 +3151,7 @@ 340 - 270 + 230 171 21 @@ -3341,7 +3177,7 @@ 340 - 290 + 250 171 21 @@ -3370,7 +3206,7 @@ 520 - 290 + 250 181 21 @@ -3396,7 +3232,7 @@ 520 - 270 + 230 181 21 @@ -3422,7 +3258,7 @@ 710 - 280 + 230 101 25 @@ -3435,7 +3271,7 @@ 710 - 150 + 140 82 17 @@ -3461,7 +3297,7 @@ 710 - 180 + 170 82 17 @@ -3487,7 +3323,7 @@ 170 - 170 + 130 161 21 @@ -3513,7 +3349,7 @@ 340 - 150 + 110 171 21 @@ -3542,7 +3378,7 @@ 720 - 100 + 60 75 23 @@ -3555,7 +3391,7 @@ 440 - 70 + 30 75 23 @@ -3568,7 +3404,7 @@ 720 - 70 + 30 85 21 diff --git a/src/model/hardware/core/TrxBoard.cpp b/src/model/hardware/core/TrxBoard.cpp index 0b0d77e..8be4440 100644 --- a/src/model/hardware/core/TrxBoard.cpp +++ b/src/model/hardware/core/TrxBoard.cpp @@ -1,7 +1,18 @@ #include "model/hardware/core/TrxBoard.h" template -T byteArray2UintLittleEndian(QByteArray& byte) +QByteArray TrxBoard::uintLittleEndian2ByteArray(T& data) const +{ + QByteArray byte; + QDataStream out (&byte, QIODevice::WriteOnly); + out.setByteOrder(QDataStream::LittleEndian); + out << data; + + return byte; +} + +template +T TrxBoard::byteArray2UintLittleEndian(QByteArray& byte) const { T data; QDataStream in (byte); @@ -34,9 +45,14 @@ void TrxBoard::readData() _device.copy(_hwCounter - 1, _swCounter); auto temp = QByteArray::fromRawData(_device.getBufferPtr(_swCounter), BUFFER_SIZE); - packetEngine.newData(temp); +#ifdef DEVELOP_UI + //packetEngine.newData(temp); + emit sendFramePacket(temp); +#else + packetEngine.newData(temp); //emit sendFramePacket(temp); +#endif _swCounter++; if(_swCounter >= SW_BUFFER_NUM) @@ -47,13 +63,24 @@ void TrxBoard::readData() } } -void TrxBoard::sram_clear() +void TrxBoard::sramClear(eSramClear clearMode) { quint32 num(0); - while (num < SRAM_SIZE) + if (clearMode == all) { - this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); - num += sizeof (quint64); + while (num < SRAM_SIZE) + { + this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); + num += sizeof (quint64); + } + } + if (clearMode == first4M) + { + while (num < SRAM_SIZE / 4) + { + this->_device.device.writeLong(BAR_SRAM, static_cast(num), 0); + num += sizeof (quint64); + } } } @@ -93,6 +120,14 @@ void TrxBoard::setSwapVector() << 180 << 165 << 86 << 71 << 184 << 169 << 90 << 75 << 188 << 173 << 94 << 79; } +void TrxBoard::setRomCrc() +{ + unsigned char crcArray[] = {0x4, 0x0, 0x13, 0x0, 0x27, 0x0, 0x28, 0x0, 0xEB, 0x1, + 0xAC, 0x5, 0xAC, 0x6, 0x4C, 0x6, 0xB0, 0x6, 0xB2}; + for(auto var : crcArray) + _eepromCrc.push_back(static_cast(var)); +} + void TrxBoard::setAfeModuleOffset() { _afeModuleOffset.clear(); @@ -138,16 +173,17 @@ TrxBoard::TrxBoard() : _offsetSlave0(0), _offsetSlave1(0x400000), _offsetSlave2( _adc = new AdcVoltages; _pg = new VoltagesPg; - scenParams = new ScenGenHardwareOutput; + scenParams = new ScenGenHardwareParam; _allow = false; _run = false; setSwapVector(); + setRomCrc(); setFpgaOffset(); setAfeModuleOffset(); } -TrxBoard::HwRegister::HwRegister() +TrxBoard::ScenHwRegister::ScenHwRegister() { configLut = new ReceiverConfiguration; elementPosition = new ProbeElementPosition; @@ -155,9 +191,9 @@ TrxBoard::HwRegister::HwRegister() pulse = new PulseProperties; } -TrxBoard::ScenGenHardwareOutput::ScenGenHardwareOutput() +TrxBoard::ScenGenHardwareParam::ScenGenHardwareParam() { - hwRegister = new HwRegister; + hwRegister = new ScenHwRegister; indexParams = new SramIndex; rxParams = new SramRx; txParams = new SramTx; @@ -183,7 +219,7 @@ TrxBoard::~TrxBoard() delete scenParams; } -TrxBoard::HwRegister::~HwRegister() +TrxBoard::ScenHwRegister::~ScenHwRegister() { delete configLut; delete rxBeamformer; @@ -191,7 +227,7 @@ TrxBoard::HwRegister::~HwRegister() delete pulse; } -TrxBoard::ScenGenHardwareOutput::~ScenGenHardwareOutput() +TrxBoard::ScenGenHardwareParam::~ScenGenHardwareParam() { delete hwRegister; delete indexParams; @@ -203,32 +239,113 @@ void TrxBoard::init() { this->_device.init(); this->_bCtrlMngt->prbCtrlInit(); - sram_clear(); + sramClear(all); } -void TrxBoard::setScenario(ScenGenHardwareOutput_t scenGenHw) +void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams) { - scenPlayerStop(); + /////////////////////////// DSP setting /////////////////////////// + if (prbDepParams.prbDepParams.apodizationLut.size() != APODIZATIONLUT_LUT_MAX) + throw SonoException("Apodization lut is out of range"); + QList > apodizationQ; + foreach(auto vec, prbDepParams.prbDepParams.apodizationLut) + { + apodizationQ.push_back(vec.toList()); + } + this->_beamFormerSlave0->apodizationLut(apodizationQ); + this->_beamFormerSlave1->apodizationLut(apodizationQ); + this->_beamFormerSlave2->apodizationLut(apodizationQ); + scenParamsFilling(set); + + if (prbDepParams.prbDepParams.atgcLut.size() != ATGC_LUT_MAX) + throw SonoException("Atgc lut is out of range"); + QList > atgcLutQ; + foreach(auto vec, prbDepParams.prbDepParams.atgcLut) + { + atgcLutQ.push_back(vec.toList()); + } + this->_dsp->atgcLut(atgcLutQ); + + if (prbDepParams.prbDepParams.lpfLut.size() != LPF_LUT_MAX) + throw SonoException("Lpf lut is out of range"); + QList > lpfLutQ; + foreach(auto vec, prbDepParams.prbDepParams.lpfLut) + { + lpfLutQ.push_back(vec.toList()); + } + this->_dsp->lpfLut(lpfLutQ); + + /////////////////////////// AFE setting /////////////////////////// + this->_afeSlave0->setAfeParams(prbDepParams.afeCfg); + this->_afeSlave1->setAfeParams(prbDepParams.afeCfg); + this->_afeSlave2->setAfeParams(prbDepParams.afeCfg); +} + +void TrxBoard::setScenario(ScenGenHardwareOutput_t &scenGenHw) +{ + if (this->_scenPlayer->control.getCommand()) + scenPlayerStop(); emulatorStop(); + sramClear(first4M); + 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) + throw SonoException("Total tx shot number is out of range"); + 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->hwRegister->lpfLut = scenGenHw.hwRegister.lpfLut; - scenParams->hwRegister->atgcLut=scenGenHw.hwRegister.atgcLut; - scenParams->hwRegister->apodization=scenGenHw.hwRegister.apodizationLut; + if (scenParams->scenarioEndIndex > SCENARIO_INDEX_MAX) + throw SonoException("Scenario end index is out of range"); + + if(scenParams->scenarioEndIndex < scenParams->scenarioStartIndex) + throw SonoException( + "The scenario end index must be greater than or equal to the scenario start index"); + scenParams->hwRegister->blendWeight = scenGenHw.hwRegister.blendWeight; + if (scenParams->hwRegister->blendWeight.size() != BLENDWEIGHT_LUT_MAX) + 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) + 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) + 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) + throw SonoException("Element position z is out of range"); + 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) + throw SonoException("Dtgc lut is out of range"); + 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) + throw SonoException("Rx beam former type number is out of range"); + scenParams->hwRegister->receiverConfigTypeNumber = scenGenHw.hwRegister.receiverConfigTypeNumber; + if (scenParams->hwRegister->receiverConfigTypeNumber > RRECEIVER_CONFIGURATION_LUT_MAX) + throw SonoException("Receiver config type number is out of range"); scenParams->hwRegister->pulse->clear(); foreach(auto i, scenGenHw.hwRegister.pulseProps) @@ -308,7 +425,7 @@ void TrxBoard::setScenario(ScenGenHardwareOutput_t scenGenHw) this->setScenario(scenParams); } -void TrxBoard::setScenario (ScenGenHardwareOutput* scenParams) +void TrxBoard::setScenario (ScenGenHardwareParam* scenParams) { ///////////////////////////////// BeamFormer setting /////////////////////////////// QList > elementPosition; @@ -399,16 +516,6 @@ void TrxBoard::setScenario (ScenGenHardwareOutput* scenParams) scenParams->hwRegister->pulse); scenParamsFilling(set); - QList > apodizationQ; - foreach(auto vec, scenParams->hwRegister->apodization) - { - apodizationQ.push_back(vec.toList()); - } - this->_beamFormerSlave0->apodizationLut(apodizationQ); - this->_beamFormerSlave1->apodizationLut(apodizationQ); - this->_beamFormerSlave2->apodizationLut(apodizationQ); - scenParamsFilling(set); - ////this->_beamFormerSlave0->afeLut(scenParams->hwRegister->afe); ////this->_beamFormerSlave1->afeLut(scenParams->hwRegister->afe); ////this->_beamFormerSlave2->afeLut(scenParams->hwRegister->afe); @@ -438,20 +545,6 @@ void TrxBoard::setScenario (ScenGenHardwareOutput* scenParams) } this->_dsp->blendWeight(blendWeightQ); - QList > atgcLutQ; - foreach(auto vec, scenParams->hwRegister->atgcLut) - { - atgcLutQ.push_back(vec.toList()); - } - this->_dsp->atgcLut(atgcLutQ); - - QList > lpfLutQ; - foreach(auto vec, scenParams->hwRegister->lpfLut) - { - lpfLutQ.push_back(vec.toList()); - } - this->_dsp->lpfLut(lpfLutQ); - ///////////////////////////////// Sram setting /////////////////////////////// this->_sram->setSramIndex(scenParams->totalTxShotNumber, scenParams->indexParams); @@ -462,21 +555,17 @@ void TrxBoard::setScenario (ScenGenHardwareOutput* scenParams) scenParams->rxParams); scenParamsFilling(set); + ////////////////////////////// Scen Index setting //////////////////////////// - if(scenParams->scenarioEndIndex >= scenParams->scenarioStartIndex) - { - this->_scenPlayer->setStartIndex(scenParams->scenarioStartIndex); - this->_scenPlayer->setEndIndex(scenParams->scenarioEndIndex); - } - else - { - throw SonoException( - "The scenario end index must be greater than or equal to the scenario start index"); - } + this->_scenPlayer->setStartIndex(scenParams->scenarioStartIndex); + this->_scenPlayer->setEndIndex(scenParams->scenarioEndIndex); + } void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) { + if (lineFilterLut.size() != LINE_FILTER_LUT_MAX) + throw SonoException("Line filter lut is out of range"); _unsignedQntzrVec = Calculation::qntzr(lineFilterLut, 0, 9, 8, 0, true, false); QList lineFilterLutQ = _unsignedQntzrVec.toList(); this->_dsp->lineFilterCoefficient(lineFilterLutQ); @@ -484,6 +573,8 @@ void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) void TrxBoard::setStbCoefficient(QVector& stbLut) { + if (stbLut.size() != STB_COEFFICIENT_LUT_MAX) + throw SonoException("Stb lut is out of range"); QList stbLutQ = stbLut.toList(); this->_dsp->stbCoefficient(stbLutQ); } @@ -495,12 +586,14 @@ void TrxBoard::setAtgcMode(eAtgcMode mode, quint16 value) const void TrxBoard::setDtgcLut(QVector& dtgcLut) { + if (dtgcLut.size() != DTGC_LUT_MAX) + throw SonoException("Dtgc lut is out of range"); _unsignedQntzrVec = Calculation::qntzr(dtgcLut, 0, 12, 8, 0, true, false); QList dtgcLutQ = _unsignedQntzrVec.toList(); this->_dsp->dtgcLut(dtgcLutQ); } -void TrxBoard::setMetaData(const QByteArray metaData) const +void TrxBoard::setFramesMetaData(const QByteArray &metaData) const { QList data; QByteArray temp; @@ -520,6 +613,137 @@ void TrxBoard::setMetaData(const QByteArray metaData) const this->_sram->setSramMetaData(data); } +void TrxBoard::setScenarioCompare(const QString scenPath) +{ + /******************* Create SRAM Binary File *******************/ + QString createSramBinary = "/hardware/sramScenarioReadback.bin"; + QString saveFile = scenPath + createSramBinary; + QFile sramFile(saveFile); + + if (!sramFile.open(QIODevice::WriteOnly)) + { + throw SonoException("Couldn't create the sram binary file due to the wrong path probably."); + } + + quint32 num(0); + quint64 value(0); + while (num < SRAM_SIZE/4) + { + value = _device.device.readLong(BAR_SRAM, static_cast(num)); + sramFile.write(uintLittleEndian2ByteArray(value)); + num += sizeof (quint64); + } + + sramFile.flush(); + sramFile.close(); + +#ifdef DEVELOP_UI + emit sramBinaryCreateFlag(); +#endif + + /******************* Compare Register CSV File *******************/ + QString registerScenario = "/hardware/register.csv"; + QString regReadParamsPath = scenPath + registerScenario; + QFile csvReadFile(regReadParamsPath); + + if(!csvReadFile.open(QFile::ReadOnly)) + { + throw SonoException("Could not open the register's scenario params due to the wrong path probably."); + } + + QString registerCompareScenario = "/hardware/registerCompare.csv"; + QString regCompareParamsPath = scenPath + registerCompareScenario; + QFile csvWriteFile(regCompareParamsPath); + + if (!csvWriteFile.open(QFile::WriteOnly)) + { + throw SonoException("Couldn't create the register compare file due to the wrong path probably."); + } + + quint32 bar = 0; + qint64 readSize = 0; + QString line; + + auto size = csvReadFile.size(); + while(readSize < size) + { + line = csvReadFile.readLine(); + auto sl = line.split(','); + auto address = sl[0].toUInt(Q_NULLPTR, 16); + auto baseValue = sl[1].toUInt(Q_NULLPTR, 16); + auto boardValue = _device.device.readWord(bar, address); + + auto res = "NOK"; + if (boardValue == baseValue) + { + res = "OK"; + } + + auto str = QStringLiteral("%1,%2,%3,%4") + .arg(address, 8, 16, QLatin1Char('0')) + .arg(baseValue, 8, 16, QLatin1Char('0')) + .arg(boardValue, 8, 16, QLatin1Char('0')).arg(res); + + + csvWriteFile.write(str.toStdString().c_str(), str.length()); + csvWriteFile.write("\r\n", 2); + + readSize += static_cast(line.length()); + } + + csvReadFile.close(); + csvWriteFile.flush(); + csvWriteFile.close(); + +#ifdef DEVELOP_UI + emit registerCsvCompareFlag(); +#endif + + /******************* Compare & Verify SRAM Params *******************/ + QString sramScenario = "/hardware/sramScenario.bin"; + QString sramReadParamsPath = scenPath + sramScenario; + QFile sramReadFile(sramReadParamsPath); + + if(!sramReadFile.open(QFile::ReadOnly)) + { + throw SonoException("Could not open the sram's scenario params due to the wrong path probably."); + } + + qint64 sramScenarioLength = sramReadFile.size(); + QByteArray fileByte; + fileByte = sramReadFile.readAll(); + sramReadFile.close(); + + num = 0; + quint64 boardValue(0); + quint64 fileValue(0); + QByteArray temp; + + while (num < sramScenarioLength) + { + boardValue = _device.device.readLong(BAR_SRAM, static_cast(num)); + + for (quint8 j=0; j < sizeof (quint64); j++) + { + temp.append(fileByte[j+num]); + } + + fileValue = byteArray2UintLittleEndian (temp); + + if (boardValue != fileValue) + { + throw SonoException("The sram scenario file is different to the sram params of board."); + } + temp.clear(); + num += sizeof (quint64); + } + +#ifdef DEVELOP_UI + emit sramVerifyMessage("Successful comparision without any difference."); +#endif + +} + QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) { QList afeRegValue; @@ -574,14 +798,7 @@ QList TrxBoard::getAfeReg(eSlaveSelect sel, quint32 afeRegAddr) return afeRegValue; } -void TrxBoard::setAfeConfig(AfeConfig afe) -{ - this->_afeSlave0->setAfeParams(afe); - this->_afeSlave1->setAfeParams(afe); - this->_afeSlave2->setAfeParams(afe); -} - -void TrxBoard::slaveFpgaProgram(QString path) +void TrxBoard::slaveFpgaProgram(const QString path) { scenParamsFilling(clear); @@ -637,13 +854,15 @@ void TrxBoard::scenPlayerStart(void) this->_device.startDma(); +#ifdef MPS_BOARD this->_bCtrlMngt->mpsDacsOn(); +#endif this->_afeSlave0->setAfeGblPwr(afePwrdnDisable); this->_afeSlave1->setAfeGblPwr(afePwrdnDisable); this->_afeSlave2->setAfeGblPwr(afePwrdnDisable); - this->_scenPlayer->control.command(true); + this->_scenPlayer->control.setCommand(true); _run = true; @@ -661,13 +880,15 @@ void TrxBoard::scenPlayerStop(void) this->_device.stopDma(); - this->_scenPlayer->control.command(false); + this->_scenPlayer->control.setCommand(false); this->_afeSlave0->setAfeGblPwr(afePwrdnEnable); this->_afeSlave1->setAfeGblPwr(afePwrdnEnable); this->_afeSlave2->setAfeGblPwr(afePwrdnEnable); +#ifdef MPS_BOARD this->_bCtrlMngt->mpsDacsOff(); +#endif } //void TrxBoard::scenPlayerPause(bool pause) const @@ -684,7 +905,8 @@ void TrxBoard::emulatorInit(EmulatorProperties* config) const void TrxBoard::fillRam(QString path) { - scenPlayerStop(); + if (this->_scenPlayer->control.getCommand()) + scenPlayerStop(); emulatorStop(); QFile emulFile(path); @@ -724,7 +946,7 @@ void TrxBoard::emulatorStart() { _run = false; - this->_scenPlayer->control.command(false); + this->_scenPlayer->control.setCommand(false); this->_emul->setEmulatorEn(); @@ -758,141 +980,260 @@ quint32 TrxBoard::vendorId() const return vid; } -quint32 TrxBoard::trxId() const +void TrxBoard::trxState(EepromStatus &romStatus) const { - QByteArray id = this->_bCtrlMngt->trxEepromRead(EEPROM_ID_BYTE_BEGIN, EEPROM_ID_BYTE_NUMBER); + QByteArray id; + QByteArray crcChk; + + romStatus.ConnectionMode = connected; - return byteArray2UintBigEndian (id); + id = this->_bCtrlMngt->trxEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER); + romStatus.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->trxEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER); + if (crcChk == _eepromCrc) + romStatus.errorCode = EEPROM_NO_ERROR; + else + romStatus.errorCode = EEPROM_CRC_ERROR; } -quint32 TrxBoard::mpsId() const +void TrxBoard::mpsState(EepromStatus &romStatus) const { - QByteArray id = this->_bCtrlMngt->mpsEepromRead(EEPROM_ID_BYTE_BEGIN, EEPROM_ID_BYTE_NUMBER); + QByteArray id; + QByteArray crcChk; - return byteArray2UintBigEndian (id); + romStatus.ConnectionMode = connected; + + id = this->_bCtrlMngt->mpsEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER); + romStatus.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->mpsEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER); + if (crcChk == _eepromCrc) + romStatus.errorCode = EEPROM_NO_ERROR; + else + romStatus.errorCode = EEPROM_CRC_ERROR; } -quint32 TrxBoard::prbCtrlId() const +void TrxBoard::prbCtrlState(EepromStatus &romStatus) const { - QByteArray id = this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_ID_BYTE_BEGIN, EEPROM_ID_BYTE_NUMBER); + QByteArray id; + QByteArray crcChk; - return byteArray2UintBigEndian (id); + romStatus.ConnectionMode = connected; + + id = this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER); + romStatus.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER); + if (crcChk == _eepromCrc) + romStatus.errorCode = EEPROM_NO_ERROR; + else + romStatus.errorCode = EEPROM_CRC_ERROR; } -quint32 TrxBoard::prbId(eSelectProbe prbSel) const +void TrxBoard::selectedPrbState(EepromStatus &romStatus, eSelectProbe prbSel) const { - QByteArray id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BYTE_BEGIN, - EEPROM_ID_BYTE_NUMBER, - prbSel-1); + QVector vec; + QByteArray id; + QByteArray crcChk; + + vec = this->_bCtrlMngt->getConnectedPrb(); + if (prbSel == prbA && !vec.at(0)) + throw SonoException("This probe is disconnected"); + + if (prbSel == prbB && !vec.at(1)) + throw SonoException("This probe is disconnected"); + + if (prbSel == prbC && !vec.at(2)) + throw SonoException("This probe is disconnected"); - return byteArray2UintBigEndian (id); + if (prbSel == prbD && !vec.at(3)) + throw SonoException("This probe is disconnected"); + + romStatus.ConnectionMode = connected; + + id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, prbSel-1); + romStatus.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, prbSel-1); + if (crcChk == _eepromCrc) + romStatus.errorCode = EEPROM_NO_ERROR; + else + romStatus.errorCode = EEPROM_CRC_ERROR; } -void TrxBoard::getConnectedPrbId(ConnectedPrbId* prbId) const +void TrxBoard::prbState(PrbCase* prb) const { QVector vec; QByteArray id; - vec.clear(); - id.clear(); + QByteArray crcChk; vec = this->_bCtrlMngt->getConnectedPrb(); for(quint8 i(0); i < vec.size(); i++) - { - if(vec.at(i)) - { - id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BYTE_BEGIN, EEPROM_ID_BYTE_NUMBER, i); - } - else - { - id.append(nullptr); - id.append(nullptr); - } - + { switch(i) { - case 0: - prbId->prbA = byteArray2UintBigEndian (id); + case 0: + if(vec.at(i)) + { + prb->prbA.ConnectionMode = connected; + + id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); + prb->prbA.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if (crcChk == _eepromCrc) + prb->prbA.errorCode = EEPROM_NO_ERROR; + else + prb->prbA.errorCode = EEPROM_CRC_ERROR; + } + else + { + prb->prbA.ConnectionMode = disconnected; + prb->prbA.id = 0; + prb->prbA.errorCode = EEPROM_NO_ERROR; + } break; case 1: - prbId->prbB = byteArray2UintBigEndian (id); - break; + if(vec.at(i)) + { + prb->prbB.ConnectionMode = connected; + + id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); + prb->prbB.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if (crcChk == _eepromCrc) + prb->prbB.errorCode = EEPROM_NO_ERROR; + else + prb->prbB.errorCode = EEPROM_CRC_ERROR; + } + else + { + prb->prbB.ConnectionMode = disconnected; + prb->prbB.id = 0; + prb->prbB.errorCode = EEPROM_NO_ERROR; + } + break; case 2: - prbId->prbC = byteArray2UintBigEndian (id); - break; + if(vec.at(i)) + { + prb->prbC.ConnectionMode = connected; + + id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); + prb->prbC.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if (crcChk == _eepromCrc) + prb->prbC.errorCode = EEPROM_NO_ERROR; + else + prb->prbC.errorCode = EEPROM_CRC_ERROR; + } + else + { + prb->prbC.ConnectionMode = disconnected; + prb->prbC.id = 0; + prb->prbC.errorCode = EEPROM_NO_ERROR; + } + break; case 3: - prbId->prbD = byteArray2UintBigEndian (id); - break; + if(vec.at(i)) + { + prb->prbD.ConnectionMode = connected; + + id = this->_bCtrlMngt->prbEepromRead(EEPROM_ID_BEGIN, EEPROM_ID_NUMBER, i); + prb->prbD.id = byteArray2UintBigEndian (id); + + crcChk = this->_bCtrlMngt->prbEepromRead(EEPROM_CRC_BEGIN, EEPROM_CRC_NUMBER, i); + if (crcChk == _eepromCrc) + prb->prbD.errorCode = EEPROM_NO_ERROR; + else + prb->prbD.errorCode = EEPROM_CRC_ERROR; + } + else + { + prb->prbD.ConnectionMode = disconnected; + prb->prbD.id = 0; + prb->prbD.errorCode = EEPROM_NO_ERROR; + } + break; } id.clear(); + crcChk.clear(); } } -QByteArray TrxBoard::trxInfo() const +QString TrxBoard::trxInfo() const { - return this->_bCtrlMngt->trxEepromRead(EEPROM_INFO_BYTE_BEGIN, EEPROM_INFO_BYTE_NUMBER); + FpgaCodeVersion version; + getFpgasCodeVersion(&version); + + QString info = QString(this->_bCtrlMngt->trxEepromRead(EEPROM_INFO_BEGIN, EEPROM_INFO_NUMBER)); + return (info + "(FPM-V " + QString::number(version.masterCode, 10) + + ", FPS-V " + QString::number(version.slave0Code, 10) + ")"); } -QByteArray TrxBoard::mpsInfo() const +QString TrxBoard::mpsInfo() const { - return this->_bCtrlMngt->mpsEepromRead(EEPROM_INFO_BYTE_BEGIN, EEPROM_INFO_BYTE_NUMBER); + return QString(this->_bCtrlMngt->mpsEepromRead(EEPROM_INFO_BEGIN, EEPROM_INFO_NUMBER)); } -QByteArray TrxBoard::prbCtrlInfo() const +QString TrxBoard::prbCtrlInfo() const { - return this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_INFO_BYTE_BEGIN, EEPROM_INFO_BYTE_NUMBER); + return QString(this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_INFO_BEGIN, EEPROM_INFO_NUMBER)); } -QByteArray TrxBoard::prbInfo(quint8 prbSel) const +QByteArray TrxBoard::selectedPrbImpulseResponse(quint8 prbSel) const { - return this->_bCtrlMngt->prbEepromRead(EEPROM_INFO_BYTE_BEGIN, EEPROM_INFO_BYTE_NUMBER, prbSel); + return this->_bCtrlMngt->prbEepromRead(EEPROM_IMPULSE_RESPONSE_BEGIN, EEPROM_IMPULSE_RESPONSE_NUMBER, prbSel); } -void TrxBoard::getConnectedPrbInfo(ConnectedPrbInfo* prbInfo) const +void TrxBoard::prbImpulseResponse(ConnectedPrbInfo* prbInfo) const { - QByteArray info; - QVector vec; - info.clear(); - vec.clear(); + QByteArray info; + QVector vec; + info.clear(); + vec.clear(); - vec = this->_bCtrlMngt->getConnectedPrb(); + vec = this->_bCtrlMngt->getConnectedPrb(); - for(quint8 i = 0; i < vec.size(); i++) - { - if(vec.at(i)) - { - info = this->_bCtrlMngt->prbEepromRead(EEPROM_INFO_BYTE_BEGIN, - EEPROM_INFO_BYTE_NUMBER, - i); - } - else - { - info.append(nullptr); - } + for(quint8 i = 0; i < vec.size(); i++) + { + if(vec.at(i)) + { + info = this->_bCtrlMngt->prbEepromRead(EEPROM_IMPULSE_RESPONSE_BEGIN, + EEPROM_IMPULSE_RESPONSE_NUMBER, + i); + } + else + { + info.append(nullptr); + } - switch(i) - { - case 0: - prbInfo->prbA = info; - break; + switch(i) + { + case 0: + prbInfo->prbA = info; + break; - case 1: - prbInfo->prbB = info; - break; + case 1: + prbInfo->prbB = info; + break; - case 2: - prbInfo->prbC = info; - break; + case 2: + prbInfo->prbC = info; + break; - case 3: - prbInfo->prbD = info; - break; - } + case 3: + prbInfo->prbD = info; + break; + } info.clear(); - } + } } void TrxBoard::supervisorRbValue(SupervisorRbValue* sValue) const diff --git a/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp b/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp index 7f5ffeb..0ca581c 100644 --- a/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp +++ b/src/model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.cpp @@ -640,10 +640,12 @@ void BoardsCtrlMngt::mpsHvSet(float &hva, float &hvb) const _mpsDacs->hvaValue = 3.3f; _mpsDacs->hvbValue = 1.53f; } - -// _mpsDacs->cwdValue = 0.0f; -// _mpsDacs->hvaValue = hva; -// _mpsDacs->hvbValue = hvb; + else + { + _mpsDacs->cwdValue = 0.0f; + _mpsDacs->hvaValue = hva; + _mpsDacs->hvbValue = hvb; + } getSupervisorI2cTimeout(); setMpsDacsValue (_mpsDacs); diff --git a/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp b/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp index aac17c6..6a95d73 100644 --- a/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp +++ b/src/model/hardware/core/register/fpgaProgram/FpgaProgram.cpp @@ -30,12 +30,14 @@ void FpgaProgram::program(QByteArray& bitFileData, quint8 number) setSlaveFpgaNumber(number); -// QProgressDialog progress; -// progress.setMinimumSize(300,100); -// progress.setLabelText("Please wait..."); -// progress.setWindowTitle("Slaves FPGA Programming"); -// progress.setRange(0,bitFileData.size()); -// progress.setModal(true); +#ifdef DEVELOP_UI + QProgressDialog progress; + progress.setMinimumSize(300,100); + progress.setLabelText("Please wait..."); + progress.setWindowTitle("Slaves FPGA Programming"); + progress.setRange(0,bitFileData.size()); + progress.setModal(true); +#endif while(progByte < bitFileData.size()) { @@ -70,10 +72,11 @@ void FpgaProgram::program(QByteArray& bitFileData, quint8 number) "Timeout is happened and the programming of the slave FPGAs is failed"); } -// progress.setValue(progByte); -// if (progress.wasCanceled()) -// throw SonoException("Slaves fpga programming is canceled"); - +#ifdef DEVELOP_UI + progress.setValue(progByte); + if (progress.wasCanceled()) + throw SonoException("Slaves fpga programming is canceled"); +#endif temp.clear(); progByte += sizeof(quint32); } diff --git a/src/model/hardware/core/register/scenPlayer/ScenPlayer.cpp b/src/model/hardware/core/register/scenPlayer/ScenPlayer.cpp index 351306f..7291d7e 100644 --- a/src/model/hardware/core/register/scenPlayer/ScenPlayer.cpp +++ b/src/model/hardware/core/register/scenPlayer/ScenPlayer.cpp @@ -35,13 +35,20 @@ quint32 ScenPalyer::getErrorCount(void) const return errCnt; } -void ScenPalyer::PlayerControl::command(bool start) const +void ScenPalyer::PlayerControl::setCommand(bool start) const { quint32 strCmd = start ? 1 : 0; _playerctrl->start->setValue(strCmd); _playerctrl->update(); } +bool ScenPalyer::PlayerControl::getCommand() const +{ + _playerctrl->sync(); + auto cmdValue = _playerctrl->start->getValue(); + return (cmdValue!=0); +} + void ScenPalyer::PlayerControl::pause(bool pause) const { quint32 pusCmd = pause ? 1 : 0; diff --git a/src/model/hardware/device/SonoDevice.cpp b/src/model/hardware/device/SonoDevice.cpp index c1f5c30..608f518 100644 --- a/src/model/hardware/device/SonoDevice.cpp +++ b/src/model/hardware/device/SonoDevice.cpp @@ -42,7 +42,14 @@ int SonoDevice::getCounter() { auto temp = device.readWord(BAR_BRAM, COUNTER_REG); - return temp & COUNTER_MASK; + return temp & COUNTER_MASK; +} + +bool SonoDevice::isDmaBusy() +{ + auto temp = device.readWord(BAR_BRAM, COUNTER_REG); + + return ((temp & BUSY_MASK) != 0); } void SonoDevice::copy(int srcIndex, int dstIndex)