#include "model/hardware/core/TrxBoard.h" template 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); in.setByteOrder(QDataStream::LittleEndian); in >> data; return data; } void TrxBoard::readData() { _swCounter = _device.getCounter(); while(_run) { auto cnt = _device.getCounter(); if(cnt == 0) { _hwCounter = 0; std::this_thread::sleep_for(std::chrono::milliseconds(3)); continue; } else if(cnt != _hwCounter) { _hwCounter++; if(_hwCounter > HW_BUFFER_NUM) { _hwCounter = 1; } _device.copy(_hwCounter - 1, _swCounter); auto temp = QByteArray::fromRawData(_device.getBufferPtr(_swCounter), BUFFER_SIZE); #ifdef DEVELOP_UI emit sendFramePacket(temp); #else packetEngine.newData(temp); #endif _swCounter++; if(_swCounter >= SW_BUFFER_NUM) { _swCounter = 0; } } } } void TrxBoard::sramClear(eSramClear clearMode) { quint32 num(0); if(clearMode == all) { 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); } } } void TrxBoard::scenParamsFilling(TrxBoard::eScenParams cmd) { static quint8 scenParams = 0; scenParams = cmd ? (scenParams + cmd) : (cmd); if(scenParams >= TOTAL_SCEN_LUT_SRAM) { scenParams = TOTAL_SCEN_LUT_SRAM; _allow = true; } else { _allow = false; } } void TrxBoard::afeAdcsSync() const { quint32 syncErr(0); this->_bCtrlMngt->timerShot(20); while(!(this->_bCtrlMngt->checkTimeout())); this->_misc->setSyncMode(adcSyncMode); this->_misc->setManualSync(true); this->_misc->setManualSync(false); this->_misc->setManualSync(bfSyncMode); this->_bCtrlMngt->timerShot(1); while(!((this->_afeSlave0->getAfeSyncDone()) && (this->_afeSlave1->getAfeSyncDone()) && (this->_afeSlave2->getAfeSyncDone()))) { if(this->_bCtrlMngt->checkTimeout()) { throw SonoException( "The timeout of the afe adcs sync is happend without receiving of sync done."); } } this->_bCtrlMngt->timerStop(); syncErr = this->_afeSlave0->getAfeSyncError(); syncErr += this->_afeSlave1->getAfeSyncError(); syncErr += this->_afeSlave2->getAfeSyncError(); if(syncErr != 0) { throw SonoException("The error of the afe adcs sync is happend."); } } void TrxBoard::waitForCaptureDone(Debug *_dbg) const { // Timeout to receive adc capture done. this->_bCtrlMngt->timerShot(1000); while (!(_dbg->getCapDone())) { if(this->_bCtrlMngt->checkTimeout()) throw SonoException("Failure to receive adc capture done."); } this->_bCtrlMngt->timerStop(); } void TrxBoard::adcCaptureStop(Debug *_dbg) const { _dbg->adcCaptureCmd(captureStop); } void TrxBoard::adcCaptureStart(Debug *_dbg) const { _dbg->adcCaptureCmd(captureStart); } void TrxBoard::adcLogTransferRoutine(Debug *_dbg, quint8 chNumPerFpga) { bool adcSamplerReady (false); bool adcSamplerError (false); // Adc logger start according to selected afe channel. _dbg->adcLoggerTransferCmd(loggerStop); _dbg->adcLoggerChannelNum(chNumPerFpga); _dbg->adcLoggerTransferCmd(loggerStart); // Timeout to receive adc log transfer done. this->_bCtrlMngt->timerShot(20); while (!(_dbg->getTransferDone())) { if(this->_bCtrlMngt->checkTimeout()) throw SonoException("Failure to receive adc log transfer done."); } this->_bCtrlMngt->timerStop(); // Timeout to receive adc sampler done. this->_bCtrlMngt->timerShot(20); while (!adcSamplerReady && !adcSamplerError) { adcSamplerReady = this->_misc->getAdcSamplerBramReady(); adcSamplerError = this->_misc->getAdcSamplerError(); if(this->_bCtrlMngt->checkTimeout()) throw SonoException("Failure to receive adc sampler done."); } this->_bCtrlMngt->timerStop(); if (adcSamplerError) throw SonoException("The adc sampler error is occured."); // Adc logger stop _dbg->adcLoggerTransferCmd(loggerStop); } void TrxBoard::debuggerMode(Debug* _dbg, DebugMode& debug, DebugMode& debugRb, QString slaveN) const { _dbg->setDebuggerMode(debug); _dbg->getDebuggerMode(debugRb); if ((debugRb.txBfTestModeEn != debug.txBfTestModeEn ) || (debugRb.txBfTestModeCfg != debug.txBfTestModeCfg )) throw ("The debugger mode register configuration of " + slaveN + " is corrupted."); } void TrxBoard::setSwapVector() { _swapVec.clear(); _swapVec << 0 << 113 << 98 << 19 << 4 << 117 << 102 << 23 << 8 << 121 << 106 << 27 << 12 << 125 << 110 << 31 << 16 << 1 << 114 << 99 << 20 << 5 << 118 << 103 << 24 << 9 << 122 << 107 << 28 << 13 << 126 << 111 << 96 << 17 << 2 << 115 << 100 << 21 << 6 << 119 << 104 << 25 << 10 << 123 << 108 << 29 << 14 << 127 << 112 << 97 << 18 << 3 << 116 << 101 << 22 << 7 << 120 << 105 << 26 << 11 << 124 << 109 << 30 << 15 << 32 << 145 << 130 << 51 << 36 << 149 << 134 << 55 << 40 << 153 << 138 << 59 << 44 << 157 << 142 << 63 << 48 << 33 << 146 << 131 << 52 << 37 << 150 << 135 << 56 << 41 << 154 << 139 << 60 << 45 << 158 << 143 << 128 << 49 << 34 << 147 << 132 << 53 << 38 << 151 << 136 << 57 << 42 << 155 << 140 << 61 << 46 << 159 << 144 << 129 << 50 << 35 << 148 << 133 << 54 << 39 << 152 << 137 << 58 << 43 << 156 << 141 << 62 << 47 << 64 << 177 << 162 << 83 << 68 << 181 << 166 << 87 << 72 << 185 << 170 << 91 << 76 << 189 << 174 << 95 << 80 << 65 << 178 << 163 << 84 << 69 << 182 << 167 << 88 << 73 << 186 << 171 << 92 << 77 << 190 << 175 << 160 << 81 << 66 << 179 << 164 << 85 << 70 << 183 << 168 << 89 << 74 << 187 << 172 << 93 << 78 << 191 << 176 << 161 << 82 << 67 << 180 << 165 << 86 << 71 << 184 << 169 << 90 << 75 << 188 << 173 << 94 << 79; } 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(); _afeModuleOffset << 0x1000 << 0x2000 << 0x4000 << 0x8000; } void TrxBoard::setFpgaOffset() { _fpgaOffset.clear(); _fpgaOffset << 0x100000 << 0x200000 << 0x300000; } //QList TrxBoard::signedVector2unsignedList (QVector& sgnVec) //{ //_unsignedQntzrList.clear(); //// std::list _usgnList (sgnVec.begin(), sgnVec.end()); //// _unsignedQntzrList.fromStdList(_usgnList); //foreach (auto i, sgnVec) //{ //_unsignedQntzrList.push_back(static_cast(i)); //} //return _unsignedQntzrList; //} TrxBoard::TrxBoard() : _offsetSlave0(0), _offsetSlave1(0x400000), _offsetSlave2(0x800000) { _beamFormerSlave0 = new BeamFormer(&_device, _offsetSlave0); _beamFormerSlave1 = new BeamFormer(&_device, _offsetSlave1); _beamFormerSlave2 = new BeamFormer(&_device, _offsetSlave2); _debugSlave0 = new Debug(&_device, _offsetSlave0); _debugSlave1 = new Debug(&_device, _offsetSlave1); _debugSlave2 = new Debug(&_device, _offsetSlave2); _clkDistributer = new ClockDistributer(&_device); _afeSlave0 = new Afe(&_device, _offsetSlave0); _afeSlave1 = new Afe(&_device, _offsetSlave1); _afeSlave2 = new Afe(&_device, _offsetSlave2); _bCtrlMngt = new BoardsCtrlMngt(&_device); _builtInTest = new BuiltInTest(&_device); _fpgaProgram = new FpgaProgram(&_device); _scenPlayer = new ScenPalyer(&_device); _bpiFlash = new BpiFlash(&_device); _emul = new Emulator(&_device); _misc = new Misc(&_device); _sram = new Sram(&_device); _dsp = new Dsp(&_device); _adc = new AdcVoltages; _pg = new VoltagesPg; _tachoRpm = new FanRpm; _coreVolt = new criticalComponentVoltages; _coreTemp = new criticalComponentTemperature; _scenParams = new ScenGenHardwareParam; _allow = false; _run = false; setSwapVector(); setRomCrc(); setFpgaOffset(); setAfeModuleOffset(); } TrxBoard::ScenHwRegister::ScenHwRegister() { configLut = new ReceiverConfiguration; elementPosition = new ProbeElementPosition; rxBeamformer = new RxBeamformerProperties; pulse = new PulseProperties; } TrxBoard::ScenGenHardwareParam::ScenGenHardwareParam() { hwRegister = new ScenHwRegister; indexParams = new SramIndex; rxParams = new SramRx; txParams = new SramTx; } TrxBoard::~TrxBoard() { delete _beamFormerSlave0; delete _beamFormerSlave1; delete _beamFormerSlave2; delete _clkDistributer; delete _debugSlave0; delete _debugSlave1; delete _debugSlave2; delete _fpgaProgram; delete _builtInTest; delete _scenPlayer; delete _afeSlave0; delete _afeSlave1; delete _afeSlave2; delete _bCtrlMngt; delete _bpiFlash; delete _emul; delete _misc; delete _sram; delete _dsp; delete _adc; delete _pg; delete _tachoRpm; delete _coreVolt; delete _coreTemp; delete _scenParams; } TrxBoard::ScenHwRegister::~ScenHwRegister() { delete configLut; delete rxBeamformer; delete elementPosition; delete pulse; } TrxBoard::ScenGenHardwareParam::~ScenGenHardwareParam() { delete hwRegister; delete indexParams; delete rxParams; delete txParams; } void TrxBoard::init() { this->_device.init(); this->_bCtrlMngt->prbCtrlInit(); sramClear(all); } void TrxBoard::fpgaProgram(const QString path) const { if(MOUNTED_SLAVE_FPGA <= 0 || MOUNTED_SLAVE_FPGA >= 8) { throw SonoException("Wrong mounted slave fpga is selected"); } QByteArray bitFileData; QFile bitFile(path); bitFileData.clear(); if(bitFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!bitFile.open(QIODevice::ReadOnly)) { throw SonoException("Couldn't open bit file programming"); } bitFileData = bitFile.readAll(); bitFile.close(); this->_fpgaProgram->program(bitFileData, MOUNTED_SLAVE_FPGA); } void TrxBoard::setProbeDependParams(ScenPrbDepHardwareParam& prbDepParams) { /////////////////////////// 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); if(prbDepParams.prbDepParams.lpfScaleCoeff.size() != LPF_SCALE_MAX) { throw SonoException("Lpf scale coefficient is out of range"); } this->_dsp->lpfScaleCoefficient(prbDepParams.prbDepParams.lpfScaleCoeff); /////////////////////////// AFE setting /////////////////////////// setAfeConfig (prbDepParams.afeCfg); setAfePwr(afePwrdnEnable); } 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; 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"); } if(_scenParams->scenarioEndIndex != (_scenParams->totalTxShotNumber - 1)) { throw SonoException( "The scenario end index must be equal to the total tx shot number minus one"); } _scenParams->hwRegister->blendWeight = scenGenHw.hwRegister.blendWeight; if(_scenParams->hwRegister->blendWeight.size() != BLENDWEIGHT_LUT_MAX) { 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) { _scenParams->hwRegister->pulse->halfPeriod.append(i.halfPeriod); _scenParams->hwRegister->pulse->startPhase.append(i.startPhase); _scenParams->hwRegister->pulse->halfCycleNo.append(i.halfCycleNo); _scenParams->hwRegister->pulse->pulseVoltSel.append(i.pulseVoltSel); _scenParams->hwRegister->pulse->dampingPulseWidth.append(i.dampingPulseWidth); } _scenParams->hwRegister->rxBeamformer->clear(); foreach(auto j, scenGenHw.hwRegister.rxBeamFormerProps) { _scenParams->hwRegister->rxBeamformer->lag.append(j.lag); _scenParams->hwRegister->rxBeamformer->mla.append(j.mla); _scenParams->hwRegister->rxBeamformer->apodization.append(j.apodizationSel); } _scenParams->hwRegister->configLut->clear(); foreach(auto k, scenGenHw.hwRegister.receiverConfigProps) { _scenParams->hwRegister->configLut->mla.append(k.mla); _scenParams->hwRegister->configLut->stb.append(k.stb); _scenParams->hwRegister->configLut->absEn.append(k.absEn); _scenParams->hwRegister->configLut->ddcEn.append(k.ddcn); _scenParams->hwRegister->configLut->dpeEn.append(k.dpeEn); _scenParams->hwRegister->configLut->stbEn.append(k.stbEn); _scenParams->hwRegister->configLut->wmfEn.append(k.wmfEn); _scenParams->hwRegister->configLut->lpfSel.append(k.lpfSel); _scenParams->hwRegister->configLut->aTgcSel.append(k.aTgcSel); _scenParams->hwRegister->configLut->focusNo.append(k.focusNo); _scenParams->hwRegister->configLut->lineMode.append(k.lineMode); _scenParams->hwRegister->configLut->ncoFreqSel.append(k.ncoFreqSel); _scenParams->hwRegister->configLut->dcCancelerEn.append(k.dcCancelEn); _scenParams->hwRegister->configLut->lineFilterEn.append(k.lineFilterEn); _scenParams->hwRegister->configLut->subtractFilterEn.append(k.subtractFilterEn); } _scenParams->indexParams->dLineNum = scenGenHw.indexParams.dLineNum; _scenParams->indexParams->frameType = scenGenHw.frameType; _scenParams->indexParams->dEnsembleNum = scenGenHw.indexParams.dEnsembleNum; _scenParams->indexParams->lastLineInFrame = scenGenHw.indexParams.lastLineInFrame; _scenParams->indexParams->firstLineInFrame = scenGenHw.indexParams.firstLineInFrame; _scenParams->indexParams->shotPropertiesIndex = scenGenHw.indexParams.shotPropertiesIndex; _scenParams->indexParams->pulsePropertiesIndex = scenGenHw.indexParams.pulsePropertiesIndex; _scenParams->indexParams->receiverConfigurationIndex = scenGenHw.indexParams.receiverConfigurationIndex; _scenParams->txParams->maxDelayQ = scenGenHw.txParams.maxDelayQ; _scenParams->txParams->txFocusXPos = scenGenHw.txParams.txFocusXPos; _scenParams->txParams->txFocusYPos = scenGenHw.txParams.txFocusYPos; _scenParams->txParams->txFocusZPos = scenGenHw.txParams.txFocusZPos; _scenParams->txParams->pulseInterval = scenGenHw.pulseInterval; _scenParams->txParams->txActiveElementNumber = scenGenHw.txParams.txActiveElementNumber; _scenParams->txParams->txStartActiveElementNumber = scenGenHw.txParams.txStartActiveElementNumber; _scenParams->rxParams->phiCos = scenGenHw.rxParams.phiCos; _scenParams->rxParams->phiSin = scenGenHw.rxParams.phiSin; _scenParams->rxParams->thetaCos = scenGenHw.rxParams.thetaCos; _scenParams->rxParams->thetaSin = scenGenHw.rxParams.thetaSin; _scenParams->rxParams->r0Position = scenGenHw.rxParams.r0Position; _scenParams->rxParams->interceptXPos = scenGenHw.rxParams.interceptXPos; _scenParams->rxParams->interceptYPos = scenGenHw.rxParams.interceptYPos; _scenParams->rxParams->interceptZPos = scenGenHw.rxParams.interceptZPos; _scenParams->rxParams->rxR0MaxDelayQ = scenGenHw.rxParams.rxR0MaxDelayQ; _scenParams->rxParams->rxR0MinDelayQ = scenGenHw.rxParams.rxR0MinDelayQ; _scenParams->rxParams->txR0MinDelayQ = scenGenHw.rxParams.txR0MinDelayQ; _scenParams->rxParams->rxFocusPointNumber = scenGenHw.rxParams.rxFocusPointNumber; _scenParams->rxParams->rxActiveElementStep = scenGenHw.rxParams.rxActiveElementStep; _scenParams->rxParams->rxR0ActiveElementNumber = scenGenHw.rxParams.rxR0ActiveElementNumber; _scenParams->rxParams->interceptPointFiringTime = scenGenHw.rxParams.interceptPointFiringTime; _scenParams->rxParams->rxR0CenterActiveElementNumber = scenGenHw.rxParams.rxR0CenterActiveElementNumber; this->setScenario(_scenParams); } void TrxBoard::setScenario (ScenGenHardwareParam* _scenParams) { ///////////////////////////////// BeamFormer setting /////////////////////////////// QList > elementPosition; QList x; QList y; QList z; //_signedQntzrVec.clear(); _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->elementPosition->xPosition, 1, 18, 0, 0, true, true, true); QList xPosQ = _unsignedQntzrVec.toList(); //QList xPosQ = signedVector2unsignedList(_signedQntzrVec); _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->elementPosition->yPosition, 1, 18, 0, 0, true, true, true); QList yPosQ = _unsignedQntzrVec.toList(); _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->elementPosition->zPosition, 0, 17, 0, 0, true, true, true); QList zPosQ = _unsignedQntzrVec.toList(); for(quint8 i = 0; i < 3; i++) { for(quint8 j = 0; j < SLAVE_ELEMENT_SEGMENT; j++) { x.append(xPosQ.at(_swapVec.at(j + i * SLAVE_ELEMENT_SEGMENT))); y.append(yPosQ.at(_swapVec.at(j + i * SLAVE_ELEMENT_SEGMENT))); z.append(zPosQ.at(_swapVec.at(j + i * SLAVE_ELEMENT_SEGMENT))); } elementPosition.append(x); elementPosition.append(y); elementPosition.append(z); switch(i) { case 0: this->_beamFormerSlave0->probeElementPosition(elementPosition); break; case 1: this->_beamFormerSlave1->probeElementPosition(elementPosition); break; case 2: this->_beamFormerSlave2->probeElementPosition(elementPosition); break; } x.clear(); y.clear(); z.clear(); elementPosition.clear(); } scenParamsFilling(set); this->_beamFormerSlave0->rxBeamformerProperties(_scenParams->hwRegister->rxBeamFormerTypeNumber, _scenParams->hwRegister->rxBeamformer); this->_beamFormerSlave1->rxBeamformerProperties(_scenParams->hwRegister->rxBeamFormerTypeNumber, _scenParams->hwRegister->rxBeamformer); this->_beamFormerSlave2->rxBeamformerProperties(_scenParams->hwRegister->rxBeamFormerTypeNumber, _scenParams->hwRegister->rxBeamformer); scenParamsFilling(set); this->_beamFormerSlave0->pulseProperties(_scenParams->hwRegister->pulseTypeNumber, _scenParams->hwRegister->pulse); this->_beamFormerSlave1->pulseProperties(_scenParams->hwRegister->pulseTypeNumber, _scenParams->hwRegister->pulse); this->_beamFormerSlave2->pulseProperties(_scenParams->hwRegister->pulseTypeNumber, _scenParams->hwRegister->pulse); scenParamsFilling(set); ////this->_beamFormerSlave0->afeLut(_scenParams->hwRegister->afe); ////this->_beamFormerSlave1->afeLut(_scenParams->hwRegister->afe); ////this->_beamFormerSlave2->afeLut(_scenParams->hwRegister->afe); ////scenParamsFilling(set); ///////////////////////////////// DSP setting /////////////////////////////// this->_dsp->receiverConfigurationLut(_scenParams->hwRegister->receiverConfigTypeNumber, _scenParams->hwRegister->configLut); _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->freqLut, 0, 24, 0, 0, true); QList freqLutQ = _unsignedQntzrVec.toList(); this->_dsp->frequencyLut(freqLutQ); _unsignedQntzrVec = Calculation::qntzr(_scenParams->hwRegister->dtgcLut, 0, 12, 8, 0, true, false); QList dtgcLutQ = _unsignedQntzrVec.toList(); this->_dsp->dtgcLut(dtgcLutQ); QList temp; QList > blendWeightQ; //_signedQntzrVec.clear(); foreach(auto vec, _scenParams->hwRegister->blendWeight) { temp.clear(); _unsignedQntzrVec = Calculation::qntzr(vec, 0, 9, 8, 0, true, false, true); temp = _unsignedQntzrVec.toList(); blendWeightQ.push_back(temp); } this->_dsp->blendWeight(blendWeightQ); ///////////////////////////////// Sram setting /////////////////////////////// this->_sram->setSramIndex(_scenParams->totalTxShotNumber, _scenParams->indexParams); this->_sram->setSramTx(_scenParams->focusTypeNumber, _scenParams->txParams); this->_sram->setSramRx(_scenParams->rxBeamFormerNumber, _scenParams->focusTypeNumber, _scenParams->rxParams); scenParamsFilling(set); ////////////////////////////// Scen Index setting //////////////////////////// this->_scenPlayer->setStartIndex(_scenParams->scenarioStartIndex); this->_scenPlayer->setEndIndex(_scenParams->scenarioEndIndex); } void TrxBoard::setLineFilterCoefficient(QVector& lineFilterLut) { if(lineFilterLut.size() != LINE_FILTER_LUT_MAX) { 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); } 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); } void TrxBoard::setAtgcMode(eAtgcMode mode, quint16 value) const { this->_dsp->atgcMode(mode, value); } 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::setFramesMetaData(const QByteArray& metaData) const { QList data; QByteArray temp; qint32 num(0); while(num < metaData.size()) { for(quint8 j = 0; j < sizeof(quint64); j++) { temp.append(metaData[j + num]); } data.push_back(byteArray2UintLittleEndian(temp)); temp.clear(); num += sizeof(quint64); } this->_sram->setSramMetaData(data); } void TrxBoard::setBiteDacData(const QByteArray &iData, const QByteArray &qData) const { this->_builtInTest->biteDacEnable(BITE_INTERVAL, false); this->_builtInTest->biteDacMemoryWrite(iData, qData); } void TrxBoard::biteScenPlayerStart() { setDebuggerMode(pulserTr, true); setAdgCfg(adgIQ); setTxDacEnable(BITE_INTERVAL, true); this->scenPlayerStart(true); } void TrxBoard::biteScenPlayerStop() { this->scenPlayerStop(true); setTxDacEnable(BITE_INTERVAL, false); setAdgCfg(adgGnd); setDebuggerMode(pulserHz, true); setDebuggerMode(pulserHz, false); } 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; quint32 offset(0); afeRegValue.clear(); switch(sel) { case slave0: this->_afeSlave0->setReadRegEnable(true); this->_bCtrlMngt->timerShot(1); while(!(this->_bCtrlMngt->checkTimeout())); for(quint8 i = 0; i < _afeModuleOffset.size(); i++) { offset = (_fpgaOffset.at(slave0) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); } this->_afeSlave0->setReadRegEnable(false); break; case slave1: this->_afeSlave1->setReadRegEnable(true); this->_bCtrlMngt->timerShot(1); while(!(this->_bCtrlMngt->checkTimeout())); for(quint8 i = 0; i < _afeModuleOffset.size(); i++) { offset = (_fpgaOffset.at(slave1) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); } this->_afeSlave1->setReadRegEnable(false); break; case slave2: this->_afeSlave2->setReadRegEnable(true); this->_bCtrlMngt->timerShot(1); while(!(this->_bCtrlMngt->checkTimeout())); for(quint8 i = 0; i < _afeModuleOffset.size(); i++) { offset = (_fpgaOffset.at(slave2) + _afeModuleOffset.at(i) + afeRegAddr) * 4; afeRegValue.push_back(this->_device.device.readWord(BAR_REG, offset)); } this->_afeSlave2->setReadRegEnable(false); break; } return afeRegValue; } void TrxBoard::setAdgCfg(eBiteDacOutput adg) const { this->_builtInTest->biteAdgCfg(adg); } void TrxBoard::setTxDacEnable(quint8 biteInterval, bool cmd) const { this->_builtInTest->biteDacEnable(biteInterval, cmd); } void TrxBoard::slaveFpgaProgram(const QString path) { scenParamsFilling(clear); fpgaProgram (path); #ifndef DEVELOP_UI afeAdcsSync(); #endif } void TrxBoard::setBeamFormerMode(eClkMode mode) const { this->_clkDistributer->clockMode(CLOCK_DIVISION, mode); } /* set afeHvPwrOn true when unfreeze happen */ void TrxBoard::scenPlayerStart(bool afeHvPwrOn) { if(_allow) { _run = false; this->_beamFormerSlave0->regValid(true); this->_beamFormerSlave1->regValid(true); this->_beamFormerSlave2->regValid(true); this->_misc->setGtSendMode(bfMode); this->_misc->setSyncMode(bfSyncMode); this->_emul->setEmulatorDis(); this->_device.resetCounter(); this->_device.startDma(); if(afeHvPwrOn) { this->_afeSlave0->setAfeGblPwr(afePwrdnDisable); this->_afeSlave1->setAfeGblPwr(afePwrdnDisable); this->_afeSlave2->setAfeGblPwr(afePwrdnDisable); this->_bCtrlMngt->timerShot(20); //uncrustify off while(!(this->_bCtrlMngt->checkTimeout())); //uncrustify on #ifdef MPS_BOARD this->_bCtrlMngt->mpsDacsOn(); #endif } this->_scenPlayer->control.setCommand(true); _run = true; QtConcurrent::run(this, &TrxBoard::readData); } else { throw SonoException("Total scenario luts and sram parameters are not written compeletely"); } } /* set afeHvPwrOff true when freeze happen */ void TrxBoard::scenPlayerStop(bool afeHvPwrOff) { _run = false; this->_device.stopDma(); this->_scenPlayer->control.setCommand(false); if(afeHvPwrOff) { this->_afeSlave0->setAfeGblPwr(afePwrdnEnable); this->_afeSlave1->setAfeGblPwr(afePwrdnEnable); this->_afeSlave2->setAfeGblPwr(afePwrdnEnable); #ifdef MPS_BOARD this->_bCtrlMngt->mpsDacsOff(); #endif this->_bCtrlMngt->timerShot(20); //uncrustify off while(!(this->_bCtrlMngt->checkTimeout())); //uncrustify on } } //void TrxBoard::scenPlayerPause(bool pause) const //{ //this->_scenPlayer->control.pause(pause); //} void TrxBoard::emulatorInit(EmulatorProperties* config) const { this->_emul->setTransferMode(config->emulOption, config->emulMode, config->transferLength); this->_emul->setRamOffsetAddress(config->ramBufAddress); this->_emul->setTransferRate(config->transferRate); } void TrxBoard::fillRam(QString path) { if(this->_scenPlayer->control.getCommand()) { scenPlayerStop(true); } emulatorStop(); QFile emulFile(path); QByteArray sramData; QByteArray temp; qint32 num(0); sramData.clear(); temp.clear(); if(emulFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!emulFile.open(QIODevice::ReadOnly)) { throw SonoException("Couldn't open frame file to emulator test"); } sramData = emulFile.readAll(); emulFile.close(); while(num < sramData.size()) { for(quint8 j = 0; j < sizeof(quint64); j++) { temp.append(sramData[j + num]); } this->_device.device.writeLong(BAR_SRAM, static_cast(num), byteArray2UintLittleEndian(temp)); temp.clear(); num += sizeof(quint64); } } void TrxBoard::emulatorStart() { _run = false; this->_scenPlayer->control.setCommand(false); this->_emul->setEmulatorEn(); this->_device.resetCounter(); this->_device.startDma(); _run = true; QtConcurrent::run(this, &TrxBoard::readData); } void TrxBoard::emulatorStop() { _run = false; this->_device.stopDma(); this->_emul->setEmulatorDis(); } quint32 TrxBoard::deviceId() const { auto pid = this->_bCtrlMngt->getPid(); return pid; } quint32 TrxBoard::vendorId() const { auto vid = this->_bCtrlMngt->getVid(); return vid; } void TrxBoard::trxState(EepromStatus& romStatus) const { QByteArray id; QByteArray crcChk; romStatus.ConnectionMode = connected; 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; } } void TrxBoard::mpsState(EepromStatus& romStatus) const { QByteArray id; QByteArray crcChk; 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; } } void TrxBoard::prbCtrlState(EepromStatus& romStatus) const { QByteArray id; QByteArray crcChk; 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; } } void TrxBoard::selectedPrbState(EepromStatus& romStatus, eSelectProbe prbSel) const { 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"); } 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::prbState(PrbCase* prb) const { QVector vec; QByteArray id; QByteArray crcChk; vec = this->_bCtrlMngt->getConnectedPrb(); for(quint8 i(0); i < vec.size(); i++) { switch(i) { 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: 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: 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: 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(); } } QString TrxBoard::trxInfo() const { 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) + ")"); } QString TrxBoard::mpsInfo() const { return QString(this->_bCtrlMngt->mpsEepromRead(EEPROM_INFO_BEGIN, EEPROM_INFO_NUMBER)); } QString TrxBoard::prbCtrlInfo() const { return QString(this->_bCtrlMngt->prbCtrlEepromRead(EEPROM_INFO_BEGIN, EEPROM_INFO_NUMBER)); } QByteArray TrxBoard::selectedPrbImpulseResponse(quint8 prbSel) const { return this->_bCtrlMngt->prbEepromRead(EEPROM_IMPULSE_RESPONSE_BEGIN, EEPROM_IMPULSE_RESPONSE_NUMBER, prbSel); } void TrxBoard::prbImpulseResponse(ConnectedPrbInfo* prbInfo) const { QByteArray info; QVector vec; info.clear(); vec.clear(); vec = this->_bCtrlMngt->getConnectedPrb(); 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; case 1: prbInfo->prbB = info; break; case 2: prbInfo->prbC = info; break; case 3: prbInfo->prbD = info; break; } info.clear(); } } void TrxBoard::supervisorRbValue(SupervisorRbValue* sValue) const { this->_bCtrlMngt->getSupervisorValue(sValue); } void TrxBoard::mpsFaultStatus(MpsFaultStatus* faultStatus) const { this->_bCtrlMngt->getMpsFault(faultStatus); } void TrxBoard::mpsPwrOn() const { this->_bCtrlMngt->mpsInit(); } void TrxBoard::mpsPwrOff() const { this->_bCtrlMngt->mpsDeInit(); } void TrxBoard::mpsReset() const { this->_bCtrlMngt->setMpsReset(); } void TrxBoard::mpsSetAo(float voltA, float voltB) const { this->_bCtrlMngt->mpsHvSet(voltA, voltB); } void TrxBoard::selectProbe(eSelectProbe prbSel) { if(this->_scenPlayer->control.getCommand()) { scenPlayerStop(true); } this->_bCtrlMngt->setProbeSelect(prbSel); } void TrxBoard::getHealthStatus(HealthStatus* healStat) const { this->_bCtrlMngt->getFanRpm(_tachoRpm); this->_bCtrlMngt->getTrxVoltagesPg(_pg); this->_bCtrlMngt->getFpgaTemp(_coreTemp); this->_bCtrlMngt->getTrxBoardVoltages(_adc, _pg); this->_bCtrlMngt->getFpgaVccInt(_coreVolt->vccInt); this->_bCtrlMngt->getFpgaVccAux(_coreVolt->vccAux); this->_bCtrlMngt->getFpgaVccBram(_coreVolt->vccBram); healStat->voltsPg = _pg; healStat->adcMon = _adc; healStat->fanRpm = _tachoRpm; healStat->fpgaCoreVoltages = _coreVolt; healStat->fpgaCoreTemperature = _coreTemp; healStat->systemTemperature = this->_bCtrlMngt->getTrxTempSensor(); } void TrxBoard::mcsProgram(QString path) { QFile mcsFile(path); if(mcsFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!mcsFile.open(QIODevice::ReadOnly)) { throw SonoException("Couldn't open mcs file programming"); } QByteArray mcsFileData = mcsFile.readAll(); this->_bpiFlash->writeMcs(mcsFileData); mcsFileData.clear(); mcsFile.close(); scenParamsFilling(clear); } void TrxBoard::mcsVerify(QString path) const { QList mcsList; QFile mcsFile(path + ".bin"); if(mcsFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!mcsFile.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't open mcs file programming"); } QTextStream save(&mcsFile); mcsList = this->_bpiFlash->readMcs(); for(auto i = 0; i < MCS_FILE_SIZE; i++) { save << (mcsList).at(i); } mcsFile.flush(); mcsFile.close(); } void TrxBoard::getTrxStatus(StatusVec* status) const { this->_misc->getStatusVector(status); } void TrxBoard::getFpgasCodeVersion(FpgaCodeVersion* version) const { this->_misc->getFpgaVersion(version); } void TrxBoard::sramParityClear() { quint64 val; val = this->_device.device.readLong(BAR_SRAM, 0); this->_device.device.writeLong(BAR_SRAM, 0, val); } quint32 TrxBoard::getFrameLostCounter() const { return (this->_misc->getFrameLostCount()); } void TrxBoard::adcCaptureConfig(captureConfig &capCfg) const { // ADC capture config this->_debugSlave0->adcLoggerConfig(capCfg); this->_debugSlave1->adcLoggerConfig(capCfg); this->_debugSlave2->adcLoggerConfig(capCfg); } void TrxBoard::adcCaptureStart(void) const { // ADC capture reset this->_debugSlave0->adcLoggerRst(true); this->_debugSlave1->adcLoggerRst(true); this->_debugSlave2->adcLoggerRst(true); this->_debugSlave0->adcLoggerRst(false); this->_debugSlave1->adcLoggerRst(false); this->_debugSlave2->adcLoggerRst(false); // ADC capture start adcCaptureStart(_debugSlave0); adcCaptureStart(_debugSlave1); adcCaptureStart(_debugSlave2); } void TrxBoard::setCaptureManualSync(void) const { this->_misc->setSyncMode(otherAdcLogMode); this->_misc->setManualSync(true); this->_misc->setManualSync(false); this->_misc->setSyncMode(bfSyncMode); } void TrxBoard::adcCaptureDone(void) const { waitForCaptureDone(_debugSlave0); waitForCaptureDone(_debugSlave1); waitForCaptureDone(_debugSlave2); adcCaptureStop(_debugSlave0); adcCaptureStop(_debugSlave1); adcCaptureStop(_debugSlave2); } void TrxBoard::adcLoggerStart(const QString path, const QString fileName) { quint8 fpgaSel(0); quint8 chNumPerFpga(0); QTime t = QTime::currentTime(); QString logPath = path + "/" + fileName + "_adcLog" + QString("_%1_%2_%3.csv") .arg(t.hour()) .arg(t.minute()) .arg(t.second()); QFile logFile(logPath); QTextStream log(&logFile); if(logFile.fileName().isEmpty()) { throw SonoException("No file is selected"); } if(!logFile.open(QIODevice::WriteOnly)) { throw SonoException("Couldn't open file for logging"); } log << "SYNC Offset(ns): "; log << this->_debugSlave0->getCapSyncOffset() * 5 << ", "; log << this->_debugSlave1->getCapSyncOffset() * 5 << ", "; log << this->_debugSlave2->getCapSyncOffset() * 5 << endl; log << "ADC Sample Latancy(ns): "; log << this->_afeSlave0->getAdcLatency() * 2.5f << ", "; log << this->_afeSlave1->getAdcLatency() * 2.5f << ", "; log << this->_afeSlave2->getAdcLatency() * 2.5f << endl; log << "ADC Sample Logger Offset(sample): "; log << this->_debugSlave0->getCaptureSampleNo() << ", "; log << this->_debugSlave1->getCaptureSampleNo() << ", "; log << this->_debugSlave2->getCaptureSampleNo() << endl; // Set gt to adc mode. this->_misc->setGtSendMode(adcMode); // Stop adc log transfer. this->_debugSlave0->adcLoggerTransferCmd(loggerStop); this->_debugSlave1->adcLoggerTransferCmd(loggerStop); this->_debugSlave2->adcLoggerTransferCmd(loggerStop); for (quint8 chNum = 0; chNum < TOTAL_AFE_CHANNEL_NUM; chNum++) { fpgaSel = chNum / AFE_CHANNEL_NUM_PER_SLAVE; chNumPerFpga = chNum % AFE_CHANNEL_NUM_PER_SLAVE; // ADC sampler start according to selected fpga. this->_misc->setAdcSamplerCmd(samplerStop); this->_misc->setAdcSamplerFpgaSel(fpgaSel); this->_misc->setAdcSamplerCmd(samplerStart); switch (fpgaSel) { case 0: this->adcLogTransferRoutine (_debugSlave0, chNumPerFpga); break; case 1: this->adcLogTransferRoutine (_debugSlave1, chNumPerFpga); break; case 2: this->adcLogTransferRoutine (_debugSlave2, chNumPerFpga); break; } // Read adc data bram. QList adcDataList = this->_misc->getAdcDataBram(); foreach (auto data, adcDataList) { log << data << ','; } log << endl; // ADC sampler stop. this->_misc->setAdcSamplerCmd(samplerStop); } logFile.flush(); logFile.close(); // Set gt to beamformer mode. this->_misc->setGtSendMode(bfMode); } void TrxBoard::setDebuggerMode(eDebugMode bfMode, bool enable) { DebugMode debug; DebugMode debugRb; debug.rxBfDbgModeEn = false; debug.rxBfSimDataGenModeEn = false; debug.txBfTestModeEn = enable; debug.txBfTestModeCfg = bfMode; this->debuggerMode(_debugSlave0, debug, debugRb, "slave0"); this->debuggerMode(_debugSlave1, debug, debugRb, "slave1"); this->debuggerMode(_debugSlave2, debug, debugRb, "slave2"); } void TrxBoard::setAfeConfig(AfeConfig& afeCfg) const { this->_afeSlave0->setAfeParams(afeCfg); this->_afeSlave1->setAfeParams(afeCfg); this->_afeSlave2->setAfeParams(afeCfg); } void TrxBoard::setAfePwr(eAfePwrdnMode pwrMode) const { this->_afeSlave0->setAfeGblPwr(pwrMode); this->_afeSlave1->setAfeGblPwr(pwrMode); this->_afeSlave2->setAfeGblPwr(pwrMode); }