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

241 lines
7.1 KiB

#ifndef TRXBOARD_H
#define TRXBOARD_H
#include <QtConcurrent/QtConcurrent>
#include <chrono>
#include <thread>
#include <QVector>
#include <QString>
#include <QByteArray>
#include <QDebug>
#include "model/hardware/core/register/clockDistributer/ClockDistributer.h"
#include "model/hardware/core/register/boardsCtrlMngt/BoardsCtrlMngt.h"
#include "model/hardware/core/register/fpgaProgram/FpgaProgram.h"
#include "model/hardware/core/register/builtInTest/BuiltInTest.h"
#include "model/hardware/core/register/beamFormer/BeamFormer.h"
#include "model/hardware/core/register/scenPlayer/ScenPlayer.h"
#include "model/hardware/core/register/bpiFlash/BpiFlash.h"
#include "model/hardware/core/register/emulator/Emulator.h"
#include "model/hardware/core/register/misc/Misc.h"
#include "model/hardware/core/register/sram/Sram.h"
#include "model/hardware/core/register/dsp/Dsp.h"
#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"
#include "model/scenarioGenerator/core/general/Calculation.h"
#include "model/hardware/service/HardwarePacketEngine.h"
#define SLAVE_ELEMENT_SEGMENT 64U
#define TOTAL_SCEN_LUT_SRAM 5U
#define MOUNTED_SLAVE_FPGA 7U
#define CLOCK_DIVISION 0x55
#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
#define EEPROM_NO_ERROR 0x0
#define EEPROM_CRC_ERROR 0x1
class TrxBoard : public QObject
{
Q_OBJECT
private:
QVector<quint8> _swapVec;
QVector<quint32> _unsignedQntzrVec;
QList<quint32> _unsignedQntzrList;
QList<quint32>* _mcsList;
QList<quint32> _afeModuleOffset;
QList<quint32> _fpgaOffset;
QByteArray _eepromCrc;
const quint32 _offsetSlave0;
const quint32 _offsetSlave1;
const quint32 _offsetSlave2;
bool _allow;
bool _run;
qint32 _swCounter;
qint32 _hwCounter;
SonoDevice _device;
AdcVoltages* _adc;
VoltagesPg* _pg;
ClockDistributer* _clkDistributer;
BeamFormer* _beamFormerSlave0;
BeamFormer* _beamFormerSlave1;
BeamFormer* _beamFormerSlave2;
BoardsCtrlMngt* _bCtrlMngt;
FpgaProgram* _fpgaProgram;
ScenPalyer* _scenPlayer;
BpiFlash* _bpiFlash;
Afe* _afeSlave0;
Afe* _afeSlave1;
Afe* _afeSlave2;
Emulator* _emul;
Misc* _misc;
Sram* _sram;
Dsp* _dsp;
enum eScenParams : quint8
{
clear,
set
};
struct ScenHwRegister
{
///////////// BeamFormer /////////////
RxBeamformerProperties* rxBeamformer;
ProbeElementPosition* elementPosition;
PulseProperties* pulse;
quint8 pulseTypeNumber;
quint8 rxBeamFormerTypeNumber;
//////////////// DSP ////////////////
QVector<float> freqLut;
QVector<float> dtgcLut;
ReceiverConfiguration* configLut;
QVector<QVector<float> > blendWeight;
quint8 receiverConfigTypeNumber;
ScenHwRegister();
~ScenHwRegister();
};
struct ScenGenHardwareParam {
quint32 focusTypeNumber;
quint32 totalTxShotNumber;
QVector<quint8> rxBeamFormerNumber;
quint32 scenarioStartIndex;
quint32 scenarioEndIndex;
ScenHwRegister* hwRegister;
SramIndex* indexParams;
SramRx* rxParams;
SramTx* txParams;
ScenGenHardwareParam();
~ScenGenHardwareParam();
}
* scenParams;
void setScenario(ScenGenHardwareParam* scenParams);
void sramClear (eSramClear clearMode);
void setSwapVector(void);
void setRomCrc(void);
void setFpgaOffset(void);
void setAfeModuleOffset(void);
void scenParamsFilling(eScenParams cmd);
//QList<quint32> signedVector2unsignedList(QVector<qint32>& sgnVec);
void afeAdcsSync (void) const;
template<class T>
QByteArray uintLittleEndian2ByteArray(T& data) const;
template<class T>
T byteArray2UintLittleEndian(QByteArray& byte) const;
signals:
void sendFramePacket(QByteArray newPacket);
void sramBinaryCreateFlag (void);
void registerCsvCompareFlag (void);
void sramVerifyMessage(QString message);
public:
#ifndef DEVELOP_UI
HardwarePacketEngine packetEngine;
#endif
TrxBoard();
~TrxBoard();
///////////////////////////////// Initialize API //////////////////////////////
void init(void);
////////////////////////////////// Scenario API ///////////////////////////////
void setProbeDependParams(ScenPrbDepHardwareParam &prbDepParams);
void setScenario(ScenGenHardwareOutput_t &scenGenHw);
void setLineFilterCoefficient(QVector<float>& lineFilterLut);
void setStbCoefficient(QVector<quint32>& stbLut);
void setDtgcLut(QVector<float>& dtgcLut);
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<quint32> getAfeReg(eSlaveSelect sel, quint32 afeRegAddr);
////////////////////////////// Slave Programming API ///////////////////////////
void slaveFpgaProgram(const QString path);
/////////////////////////////// BeamFormer Mode API ////////////////////////////
void setBeamFormerMode(eClkMode mode) const;
///////////////////////////////// Emulator API /////////////////////////////////
void emulatorInit(EmulatorProperties* config) const;
void fillRam(QString path);
void emulatorStart(void);
void emulatorStop(void);
////////////////////////////// BoardCtrlMngt API ///////////////////////////////
quint32 deviceId(void) const;
quint32 vendorId(void) 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;
void mpsPwrOn() const;
void mpsPwrOff() const;
void mpsReset(void) const;
void mpsSetAo(float voltA, float voltB) const;
void selectProbe(eSelectProbe prbSel);
void getHealthStatus(HealthStatus* healStat) const;
//////////////////////////////// BPI Flash API /////////////////////////////////
void mcsProgram(QString path);
void mcsVerify(QString path) const;
//////////////////////////////// Miscellaneous API /////////////////////////////////
void getTrxStatus(StatusVec* status) const;
void getFpgasCodeVersion(FpgaCodeVersion* version) const;
void sramParityClear();
quint32 getFrameLostCounter(void) const;
/////////////////////////////// DMA Data Packet ////////////////////////////////////
void readData();
};
#endif //TRXBOARD_H