From aadd7e3ca3b81a97b53cf906d88edc7fe448c585 Mon Sep 17 00:00:00 2001 From: mehrabi Date: Sat, 18 Dec 2021 09:25:14 -0500 Subject: [PATCH] add BlockingQueuedConnection and sig-slot check --- Plx/Plx.pro | 4 - Plx/include/API/HonaAPI.h | 54 +- .../Exception/HonaAlreadyStartedException.h | 22 +- .../LowLevel/Exception/HonaBusyException.h | 18 +- .../LowLevel/Exception/HonaException.h | 18 +- Plx/include/LowLevel/HonaLowLevelAPI.h | 218 +-- Plx/include/LowLevel/HonaPacket.h | 102 +- Plx/include/LowLevel/Setting/Setting.h | 32 +- Plx/include/LowLevel/Utils/Utils.h | 63 +- Plx/include/Wrapper/PlxWrapper.h | 76 +- Plx/src/API/HonaAPI.cpp | 255 ++- Plx/src/LowLevel/HonaLowLevelAPI.cpp | 1614 ++++++++--------- Plx/src/LowLevel/HonaPacket.cpp | 48 +- Plx/src/Wrapper/PlxWrapper.cpp | 99 +- Test/MainWindow.cpp | 97 +- Test/MainWindow.h | 25 +- Test/MainWindow.ui | 10 +- Test/Test.pro | 2 + Test/main.cpp | 1 + ignore.save | 1 + 20 files changed, 1248 insertions(+), 1511 deletions(-) create mode 100644 ignore.save diff --git a/Plx/Plx.pro b/Plx/Plx.pro index 4c1d0dd..9aab6b0 100755 --- a/Plx/Plx.pro +++ b/Plx/Plx.pro @@ -41,7 +41,3 @@ INCLUDEPATH += $$PWD/../../Plxlibrary DEPENDPATH += $$PWD/../../Plxlibrary unix:!macx: PRE_TARGETDEPS += $$PWD/../../Plxlibrary/Library/libPlxApi.a -<<<<<<< HEAD -======= - ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 diff --git a/Plx/include/API/HonaAPI.h b/Plx/include/API/HonaAPI.h index 8f49e89..a4db1fb 100644 --- a/Plx/include/API/HonaAPI.h +++ b/Plx/include/API/HonaAPI.h @@ -4,42 +4,42 @@ #include #include "LowLevel/Setting/Setting.h" -#include "include/LowLevel/Exception/HonaAlreadyStartedException.h" -#include "include/LowLevel/Exception/HonaException.h" -#include "include/LowLevel/Utils/Utils.h" -#include "include/LowLevel/HonaLowLevelAPI.h" +#include "LowLevel/Exception/HonaAlreadyStartedException.h" +#include "LowLevel/Exception/HonaException.h" +#include "LowLevel/Utils/Utils.h" +#include "LowLevel/HonaLowLevelAPI.h" class HonaAPI : public QObject { - Q_OBJECT + Q_OBJECT private: - HonaLowLevelAPI _honaLowLevelAPI; + HonaLowLevelAPI _honaLowLevelAPI; public: - HonaAPI() - { - } - - ~HonaAPI() - { - } - - ApiResult isHsruStarted(); - ApiResult isHiruStarted(); - ApiResult deviceReset(); - - ApiResult setConfig(HonaSettings& settings); - ApiResult getConfig(HonaSettings& settings); - ApiResult getSwVersion(QString& swVerion); - ApiResult getDeviceId(QString& deviceId); - ApiResult hsruStart(); - ApiResult hiruStart(); - ApiResult hsruStop(); - ApiResult init(); + HonaAPI() + { + } + + ~HonaAPI() + { + } + + ApiResult isHsruStarted(); + ApiResult isHiruStarted(); + ApiResult deviceReset(); + + ApiResult setConfig(HonaSettings& settings); + ApiResult getConfig(HonaSettings& settings); + ApiResult getSwVersion(QString& swVerion); + ApiResult getDeviceId(QString& deviceId); + ApiResult hsruStart(); + ApiResult hiruStart(); + ApiResult hsruStop(); + ApiResult init(); signals: - void honaDataResult(QList honaPacketList, quint32 hsruLoss, quint32 Doa); + void honaDataResult(QList &honaPacketList, quint32 hsruLoss, quint32 Doa); }; #endif //HONAAPI_H diff --git a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h index c8352b2..32c5d19 100755 --- a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h +++ b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h @@ -7,21 +7,21 @@ class HonaAlreadyStartedException : public std::exception { private: - QString _str; + QString _str; public: - HonaAlreadyStartedException(QString str) - { - _str = str; - qDebug() << "HonaAlreadyStartedException " << str; - } + HonaAlreadyStartedException(QString str) + { + _str = str; + qDebug() << "HonaAlreadyStartedException " << str; + } - virtual const char* what() const throw() - { - qDebug() << "HonaAlreadyStartedException return " << _str; + virtual const char* what() const throw() + { + qDebug() << "HonaAlreadyStartedException return " << _str; - return _str.toStdString().c_str(); - } + return _str.toStdString().c_str(); + } }; #endif //HONAALREADYSTARTEDEXCEPTION_H diff --git a/Plx/include/LowLevel/Exception/HonaBusyException.h b/Plx/include/LowLevel/Exception/HonaBusyException.h index d466099..eb031d7 100755 --- a/Plx/include/LowLevel/Exception/HonaBusyException.h +++ b/Plx/include/LowLevel/Exception/HonaBusyException.h @@ -7,18 +7,18 @@ class HonaBusyException : public std::exception { private: - QString _str; + QString _str; public: - HonaBusyException(QString str) - { - _str = str; - } + HonaBusyException(QString str) + { + _str = str; + } - virtual const char* what() const throw() - { - return _str.toStdString().c_str(); - } + virtual const char* what() const throw() + { + return _str.toStdString().c_str(); + } }; #endif //HONABUSYEXCEPTION_H diff --git a/Plx/include/LowLevel/Exception/HonaException.h b/Plx/include/LowLevel/Exception/HonaException.h index 57f3ce1..ab5b04e 100755 --- a/Plx/include/LowLevel/Exception/HonaException.h +++ b/Plx/include/LowLevel/Exception/HonaException.h @@ -7,18 +7,18 @@ class HonaException : public std::exception { private: - QString _str; + QString _str; public: - HonaException(QString str) - { - _str = str; - } + HonaException(QString str) + { + _str = str; + } - virtual const char* what() const throw() - { - return _str.toStdString().c_str(); - } + virtual const char* what() const throw() + { + return _str.toStdString().c_str(); + } }; #endif //HONAEXCEPTION_H diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h index 801398d..6bc66ff 100755 --- a/Plx/include/LowLevel/HonaLowLevelAPI.h +++ b/Plx/include/LowLevel/HonaLowLevelAPI.h @@ -1,163 +1,137 @@ #ifndef HONALOWLEVELAPI_H #define HONALOWLEVELAPI_H #include +#include +#include + #include "LowLevel/Setting/Setting.h" #include "LowLevel/HonaPacket.h" #include "LowLevel/Setting/Setting.h" #include "HonaPacket.h" -#include "QWaitCondition" -#include "QMutex" -<<<<<<< HEAD - - -#include "include/LowLevel/HonaPacket.h" -#include "include/Wrapper/PlxWrapper.h" - -======= #include "LowLevel/Exception/HonaAlreadyStartedException.h" #include "LowLevel/Exception/HonaException.h" #include "Wrapper/PlxWrapper.h" #include "LowLevel/Utils/Utils.h" ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 class HonaLowLevelAPI : public QObject { - Q_OBJECT + Q_OBJECT private: - bool _hsruIsStarted = false; - bool _hiruIsStarted = false; - quint32 _hsruLoss; - HonaSettings _honaSetting; - QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent, _hiruReadDone0, _hiruCountDone, - _hiruUpdateAck1; - - QList honaPacketList; - QMutex _mutex; - int _threadSforValue = 0; -<<<<<<< HEAD - bool _isReaderThreadFree = false; - bool _isUpdateThreadFree = false; - QVector honaRegisterBuffer; + bool _hsruIsStarted = false; + bool _hiruIsStarted = false; + quint32 _hsruLoss; + HonaSettings _honaSetting; + QWaitCondition _hsruReadDone, _hsruUpdateAck, _hsruStopEvent, _hiruReadDone0, _hiruCountDone, + _hiruUpdateAck1; + QList honaPacketList; - PlxWrapper plxwrapper; + QMutex _mutex; + int _threadSforValue = 0; + bool _isHsruMainThreadFree = false; + bool _isHsruReaderThreadFree = false; + bool _isHsruUpdateThreadFree = false; + + bool _isHiruReaderThreadFree = false; + bool _isHiruUpdateThreadFree = false; + QVector honaRegisterBuffer; + PlxWrapper plxWrapper; - quint32 hsruLoss = 0; + static quint32 packetLenInt4; + static quint32 packetLenRes4; + static quint32 packetLenSinglePulse; static quint32 packetLenInt123C; static quint32 packetLenRes123C; static quint32 packetLenIntS; static quint32 packetLenResS; -======= - bool _isHsruMainThreadFree = false; - bool _isHsruReaderThreadFree = false; - bool _isHsruUpdateThreadFree = false; - - bool _isHiruReaderThreadFree = false; - bool _isHiruUpdateThreadFree = false; - QVector honaRegisterBuffer; - PlxWrapper plxWrapper; - - static quint32 packetLenInt4; - static quint32 packetLenRes4; - static quint32 packetLenSinglePulse; - - static quint32 packetLenInt123C; - static quint32 packetLenRes123C; - static quint32 packetLenIntS; - static quint32 packetLenResS; - - static quint32 nextInt4; - static quint32 nextRes4; - static quint32 nextSinglePulse; - - static quint32 nextInt123C; - static quint32 nextRes123C; - static quint32 nextIntS; - static quint32 nextResS; - - quint32 lastPNInt4 = 0; - quint32 lastPNRes4 = 0; - quint32 lastPNSinglePulse = 0; - - quint32 lastPNInt123C = 0; - quint32 lastPNRes123C = 0; - quint32 lastPNIntS = 0; - quint32 lastPNResS = 0; - - HonaPacket tempHonaPacketInt4; - HonaPacket tempHonaPacketRes4; - HonaPacket tempHonaPacketSinglePulse; - - HonaPacket tempHonaPacketInt123C; - HonaPacket tempHonaPacketRes123C; - HonaPacket tempHonaPacketIntS; - HonaPacket tempHonaPacketResS; ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 + + static quint32 nextInt4; + static quint32 nextRes4; + static quint32 nextSinglePulse; + + static quint32 nextInt123C; + static quint32 nextRes123C; + static quint32 nextIntS; + static quint32 nextResS; + + quint32 lastPNInt4 = 0; + quint32 lastPNRes4 = 0; + quint32 lastPNSinglePulse = 0; + + quint32 lastPNInt123C = 0; + quint32 lastPNRes123C = 0; + quint32 lastPNIntS = 0; + quint32 lastPNResS = 0; + + HonaPacket tempHonaPacketInt4; + HonaPacket tempHonaPacketRes4; + HonaPacket tempHonaPacketSinglePulse; + + HonaPacket tempHonaPacketInt123C; + HonaPacket tempHonaPacketRes123C; + HonaPacket tempHonaPacketIntS; + HonaPacket tempHonaPacketResS; public: - qulonglong toaStartBoard = 0; + qulonglong toaStartBoard = 0; - HonaLowLevelAPI(QObject* parent = nullptr); - ~HonaLowLevelAPI() - { - } + HonaLowLevelAPI(QObject* parent = nullptr); + ~HonaLowLevelAPI() + { + } - bool isHsruStarted(); - bool isHiruStarted(); - void deviceReset(); + bool isHsruStarted(); + bool isHiruStarted(); + void deviceReset(); - void setConfig(HonaSettings& settings); - HonaSettings getConfig(); - QString getSwVersion(); - QString getDeviceId(); - void hsruStart(); - void hiruStart(); - void hsruStop(); - void init(); + void setConfig(HonaSettings& settings); + HonaSettings getConfig(); + QString getSwVersion(); + QString getDeviceId(); + void hsruStart(); + void hiruStart(); + void hsruStop(); + void init(); - bool getHsruIsStarted() const; - void setHsruIsStarted(bool hsruIsStarted); + bool getHsruIsStarted() const; + void setHsruIsStarted(bool hsruIsStarted); - bool getHiruIsStarted() const; - void setHiruIsStarted(bool hiruIsStarted); + bool getHiruIsStarted() const; + void setHiruIsStarted(bool hiruIsStarted); private: - void writeSettingToRegisters(HonaSettings& settings); - void setConfig(); - void hsruMainThread(); - void hsruReadThread(); - void hsruUpdateThread(); - void hiruMainThread(); - void hiruReadThread(); - void hiruUpdateThread(); - quint32 hiruGetDOA(); - - quint32 hsruParserInt123C(const QVector& honaData, QList& honaPacketList); - quint32 hsruParserRes123C(const QVector& honaData, QList& honaPacketList); - quint32 hsruParserIntS(const QVector& honaData, QList& honaPacketList); - quint32 hsruParserResS(const QVector& honaData, QList& honaPacketList); - quint32 hsruParserInt4(const QVector& honaData, QList& honaPacketList); - quint32 hsruParserRes4(const QVector& honaData, QList& honaPacketList); - quint32 hsruParserSinglePulse(const QVector& honaData, - QList& honaPacketList); - - QVector hsruReadHonaBuffer(honaReceivers receiver); - - bool isValid(HonaPacket hp); + void writeSettingToRegisters(HonaSettings& settings); + void setConfig(); + void hsruMainThread(); + void hsruReadThread(); + void hsruUpdateThread(); + void hiruMainThread(); + void hiruReadThread(); + void hiruUpdateThread(); + quint32 hiruGetDOA(); + + quint32 hsruParserInt123C(const QVector& honaData, QList& honaPacketList); + quint32 hsruParserRes123C(const QVector& honaData, QList& honaPacketList); + quint32 hsruParserIntS(const QVector& honaData, QList& honaPacketList); + quint32 hsruParserResS(const QVector& honaData, QList& honaPacketList); + quint32 hsruParserInt4(const QVector& honaData, QList& honaPacketList); + quint32 hsruParserRes4(const QVector& honaData, QList& honaPacketList); + quint32 hsruParserSinglePulse(const QVector& honaData, + QList& honaPacketList); -public: - - void hsruReaderMethod(); QVector hsruReadHonaBuffer(honaReceivers receiver); - quint32 hsruParserInt123C(quint32 honaData,QList honaPacketList); + + bool isValid(HonaPacket hp); + +public: signals: - void lowLevelHonaData(QList honaPacketList, quint32 hsruLoss, quint32 Doa); + void lowLevelHonaData(QList &honaPacketList, quint32 hsruLoss, quint32 Doa); - //uncrustify off + //uncrustify off public slots: - //uncrustify on + //uncrustify on }; #endif //HONALOWLEVELAPI_H diff --git a/Plx/include/LowLevel/HonaPacket.h b/Plx/include/LowLevel/HonaPacket.h index 534369f..8814ad4 100755 --- a/Plx/include/LowLevel/HonaPacket.h +++ b/Plx/include/LowLevel/HonaPacket.h @@ -8,59 +8,59 @@ class HonaPacket { private: - qreal toaClock; - honaPacketType m_PacketType; - quint32 m_PacketNumber; - qulonglong m_Toa; - quint32 m_Doa; - quint32 m_Pa1; - quint32 m_Pa2; - quint32 m_Pa3; - quint32 m_Pa4; - quint32 m_Code; - qulonglong m_CodeL; - qulonglong m_CodeM; - quint8 m4Status; + qreal toaClock; + honaPacketType m_PacketType; + quint32 m_PacketNumber; + qulonglong m_Toa; + quint32 m_Doa; + quint32 m_Pa1; + quint32 m_Pa2; + quint32 m_Pa3; + quint32 m_Pa4; + quint32 m_Code; + qulonglong m_CodeL; + qulonglong m_CodeM; + quint8 m4Status; public: - HonaPacket(); - /******************************************************************/ - honaPacketType getPacketType(); - void setPacketType(honaPacketType temp); - /******************************************************************/ - quint32 getPacketNumber(); - void setPacketNumber(quint32 temp); - /******************************************************************/ - qulonglong getToa(); - void setToa(qulonglong temp); - /******************************************************************/ - quint32 getDoa(); - void setDoa(quint32 temp); - /******************************************************************/ - quint32 getPa1(); - void setPa1(quint32 temp); - /******************************************************************/ - quint32 getPa2(); - void setPa2(quint32 temp); - /******************************************************************/ - quint32 getPa3(); - void setPa3(quint32 temp); - /******************************************************************/ - quint32 getPa4(); - void setPa4(quint32 temp); - /******************************************************************/ - quint32 getCode(); - void setCode(quint32 temp); - /******************************************************************/ - quint32 getCodeL(); - void setCodeL(quint32 temp); - /******************************************************************/ - quint32 getCodeM(); - void setCodeM(quint32 temp); - /******************************************************************/ - quint8 getm4Status(); - void setm4Status(quint8 temp); - /******************************************************************/ + HonaPacket(); + /******************************************************************/ + honaPacketType getPacketType(); + void setPacketType(honaPacketType temp); + /******************************************************************/ + quint32 getPacketNumber(); + void setPacketNumber(quint32 temp); + /******************************************************************/ + qulonglong getToa(); + void setToa(qulonglong temp); + /******************************************************************/ + quint32 getDoa(); + void setDoa(quint32 temp); + /******************************************************************/ + quint32 getPa1(); + void setPa1(quint32 temp); + /******************************************************************/ + quint32 getPa2(); + void setPa2(quint32 temp); + /******************************************************************/ + quint32 getPa3(); + void setPa3(quint32 temp); + /******************************************************************/ + quint32 getPa4(); + void setPa4(quint32 temp); + /******************************************************************/ + quint32 getCode(); + void setCode(quint32 temp); + /******************************************************************/ + quint32 getCodeL(); + void setCodeL(quint32 temp); + /******************************************************************/ + quint32 getCodeM(); + void setCodeM(quint32 temp); + /******************************************************************/ + quint8 getm4Status(); + void setm4Status(quint8 temp); + /******************************************************************/ }; #endif //HONAPACKET_H diff --git a/Plx/include/LowLevel/Setting/Setting.h b/Plx/include/LowLevel/Setting/Setting.h index ac07087..4251a42 100755 --- a/Plx/include/LowLevel/Setting/Setting.h +++ b/Plx/include/LowLevel/Setting/Setting.h @@ -9,32 +9,32 @@ /***********************************************************************************************/ struct hiruSettings_t { - recorderStart recordStard; - recorderMode recordMode; - quint32 recordChannel; - quint32 threshold = 0; - quint32 timeout = 1000; - quint32 count = 5; + recorderStart recordStard; + recorderMode recordMode; + quint32 recordChannel; + quint32 threshold = 0; + quint32 timeout = 1000; + quint32 count = 5; }; /***********************************************************************************************/ struct hsruSettings_t { - bool isReal = true; - quint32 honaInt123CTHR = 128; - quint32 honaRes123CTHR = 128; - quint32 honaIntSTHR = 20; - quint32 honaResSTHR = 20; - quint32 honaSPTHR = 20; //mode4 - quint32 intM4_THR = 20; //mode4 - quint32 resM4_THR = 20; //mode4 + bool isReal = true; + quint32 honaInt123CTHR = 128; + quint32 honaRes123CTHR = 128; + quint32 honaIntSTHR = 20; + quint32 honaResSTHR = 20; + quint32 honaSPTHR = 20; + quint32 intM4_THR = 20; + quint32 resM4_THR = 20; }; /***********************************************************************************************/ struct HonaSettings { - hiruSettings_t hiruSettings; - hsruSettings_t hsruSettings; + hiruSettings_t hiruSettings; + hsruSettings_t hsruSettings; }; /***********************************************************************************************/ diff --git a/Plx/include/LowLevel/Utils/Utils.h b/Plx/include/LowLevel/Utils/Utils.h index 24bdd41..68ff736 100755 --- a/Plx/include/LowLevel/Utils/Utils.h +++ b/Plx/include/LowLevel/Utils/Utils.h @@ -1,83 +1,64 @@ #ifndef UTILS_H #define UTILS_H - #include - /*************************************************************************************************/ enum ApiResult : quint8 { - success, - alreadyStarted, - busy, - error + success, + alreadyStarted, + busy, + error }; /*************************************************************************************************/ enum drxDeviceIfChannel : quint8 { - ifChannel11, - ifChannel12 + ifChannel11, + ifChannel12 }; /*************************************************************************************************/ enum honaReceivers : quint8 { -<<<<<<< HEAD int123C, res123C, intS, resS, - int4, //Mode 4 - res4, //Mode 4 - singlePulse //Mode 4 - -======= - int123C, - res123C, - intS, - resS, - int4, //Mode 4 - res4, //Mode 4 - singlePulse //Mode 4 ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 + int4, + res4, + singlePulse }; /*************************************************************************************************/ enum recorderMode : quint8 { - signalChannel, - dualChannel + signalChannel, + dualChannel }; /*************************************************************************************************/ enum recorderStart : quint8 { - selfTestCounter = 1, - freeRunRecording = 2 + selfTestCounter = 1, + freeRunRecording = 2 }; /*************************************************************************************************/ enum honaPacketType : quint8 { - interrogationMode123C, - interrogationModeS56, - interrogationModeS112, - interrogationMode4, + interrogationMode123C, + interrogationModeS56, + interrogationModeS112, + interrogationMode4, - responseMode123C, - responseModeS56, - responseModeS112, + responseMode123C, + responseModeS56, + responseModeS112, - responseMode4, - singlePulseMode4 + responseMode4, + singlePulseMode4 }; -<<<<<<< HEAD -/*************************************************************************************************/ - -#endif // UTILS_H -======= /*************************************************************************************************/ #endif //UTILS_H ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 diff --git a/Plx/include/Wrapper/PlxWrapper.h b/Plx/include/Wrapper/PlxWrapper.h index b00f9a1..514e205 100755 --- a/Plx/include/Wrapper/PlxWrapper.h +++ b/Plx/include/Wrapper/PlxWrapper.h @@ -2,62 +2,32 @@ #define PLXWRAPPER_H #include #include "PlxPci_9054_Func.h" -<<<<<<< HEAD class PlxWrapper { public: - PlxWrapper(); - - bool deviceInit(quint32 devicekey); - bool deviceOpen(void); - bool deviceClose(void); - bool deviceReset(void); - bool deviceLoadE2pToFPGA(void); - - bool deviceReadEeprom(quint16 offset, quint32 length, QVector& data); - bool deviceWriteEeprom(quint16 offset, quint32 data); - - bool deviceReadRegister(quint32 address, QVector& data, quint32 length); - bool deviceReadRegister(quint32 address, quint32& data); - bool deviceWriteRegister(quint32 address, QVector& data); - bool deviceWriteRegister(quint32 address, quint32 data); - - bool deviceReadMemory(quint32 localAddress, QVector& data, quint32 length); - bool deviceOpenPCIChannel(void); - bool deviceClosePCIChannel(void); - bool deviceEnableInterrupt(void); - bool deviceDisableInterrupt(void); - bool deviceWaitForInterrupt(quint32 timeout); - bool deviceGetChipType(quint8 revision, quint16 chipType); -======= - -class PlxWrapper -{ -public: - PlxWrapper(); - - bool deviceInit(quint32 devicekey); - bool deviceOpen(void); - bool deviceClose(void); - bool deviceReset(void); - bool deviceLoadE2pToFPGA(void); - - bool deviceReadEeprom(quint16 offset, quint32 length, QVector& data); - bool deviceWriteEeprom(quint16 offset, quint32 data); - - bool deviceReadRegister(quint32 address, QVector& data, quint32 length); - bool deviceReadRegister(quint32 address, quint32& data); - bool deviceWriteRegister(quint32 address, QVector& data); - bool deviceWriteRegister(quint32 address, quint32 data); - - bool deviceReadMemory(quint32 localAddress, QVector& data, quint32 length); - bool deviceOpenPCIChannel(void); - bool deviceClosePCIChannel(void); - bool deviceEnableInterrupt(void); - bool deviceDisableInterrupt(void); - bool deviceWaitForInterrupt(quint32 timeout); - bool deviceGetChipType(quint8 revision, quint16 chipType); ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 + PlxWrapper(); + + bool deviceInit(quint32 devicekey); + bool deviceOpen(void); + bool deviceClose(void); + bool deviceReset(void); + bool deviceLoadE2pToFPGA(void); + + bool deviceReadEeprom(quint16 offset, quint32 length, QVector& data); + bool deviceWriteEeprom(quint16 offset, quint32 data); + + bool deviceReadRegister(quint32 address, QVector& data, quint32 length); + bool deviceReadRegister(quint32 address, quint32& data); + bool deviceWriteRegister(quint32 address, QVector& data); + bool deviceWriteRegister(quint32 address, quint32 data); + + bool deviceReadMemory(quint32 localAddress, QVector& data, quint32 length); + bool deviceOpenPCIChannel(void); + bool deviceClosePCIChannel(void); + bool deviceEnableInterrupt(void); + bool deviceDisableInterrupt(void); + bool deviceWaitForInterrupt(quint32 timeout); + bool deviceGetChipType(quint8 revision, quint16 chipType); }; #endif //PLXWRAPPER_H diff --git a/Plx/src/API/HonaAPI.cpp b/Plx/src/API/HonaAPI.cpp index 77fcc23..dbb5ca9 100644 --- a/Plx/src/API/HonaAPI.cpp +++ b/Plx/src/API/HonaAPI.cpp @@ -1,186 +1,185 @@ #include "include/API/HonaAPI.h" /*************************************************************************************************/ - ApiResult HonaAPI::isHsruStarted() { - try { - if(_honaLowLevelAPI.isHsruStarted()) - return ApiResult::success; - } - catch(HonaException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + if(_honaLowLevelAPI.isHsruStarted()) + return ApiResult::success; + } + catch(HonaException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::isHiruStarted() { - try { - if(_honaLowLevelAPI.isHiruStarted()) - return ApiResult::success; - } - catch(HonaException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + if(_honaLowLevelAPI.isHiruStarted()) + return ApiResult::success; + } + catch(HonaException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::deviceReset() { - try { - _honaLowLevelAPI.deviceReset(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - catch(HonaAlreadyStartedException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + _honaLowLevelAPI.deviceReset(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + catch(HonaAlreadyStartedException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::setConfig(HonaSettings& settings) { - try { - _honaLowLevelAPI.setConfig(settings); - } - catch(HonaException ex) - { - return ApiResult::error; - } - catch(HonaAlreadyStartedException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + _honaLowLevelAPI.setConfig(settings); + } + catch(HonaException ex) + { + return ApiResult::error; + } + catch(HonaAlreadyStartedException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::getConfig(HonaSettings& settings) { - try { - settings = _honaLowLevelAPI.getConfig(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + settings = _honaLowLevelAPI.getConfig(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::getSwVersion(QString& swVerion) { - try { - swVerion = _honaLowLevelAPI.getSwVersion(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + swVerion = _honaLowLevelAPI.getSwVersion(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::getDeviceId(QString& deviceId) { - try { - deviceId = _honaLowLevelAPI.getDeviceId(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + deviceId = _honaLowLevelAPI.getDeviceId(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::hsruStart() { - try { - _honaLowLevelAPI.hsruStart(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - catch(HonaAlreadyStartedException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + _honaLowLevelAPI.hsruStart(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + catch(HonaAlreadyStartedException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::hiruStart() { - try { - _honaLowLevelAPI.hiruStart(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - catch(HonaAlreadyStartedException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + _honaLowLevelAPI.hiruStart(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + catch(HonaAlreadyStartedException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::hsruStop() { - try { - _honaLowLevelAPI.hsruStop(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - catch(HonaAlreadyStartedException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + try { + _honaLowLevelAPI.hsruStop(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + catch(HonaAlreadyStartedException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ ApiResult HonaAPI::init() { - connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult); - - try { - _honaLowLevelAPI.init(); - } - catch(HonaException ex) - { - return ApiResult::error; - } - catch(HonaAlreadyStartedException ex) - { - return ApiResult::error; - } - - return ApiResult::success; + connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult,Qt::BlockingQueuedConnection); + + try { + _honaLowLevelAPI.init(); + } + catch(HonaException ex) + { + return ApiResult::error; + } + catch(HonaAlreadyStartedException ex) + { + return ApiResult::error; + } + + return ApiResult::success; } /*************************************************************************************************/ diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp index e0b10e5..9d0cf28 100755 --- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp +++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp @@ -1,16 +1,8 @@ #include - #include #include "include/LowLevel/HonaLowLevelAPI.h" #include "include/Wrapper/PlxWrapper.h" - -<<<<<<< HEAD -#include "qdebug.h" -#include "QTime" -#include "QtConcurrent/QtConcurrent" -======= #include - quint32 HonaLowLevelAPI::packetLenInt4; quint32 HonaLowLevelAPI::packetLenRes4; quint32 HonaLowLevelAPI::packetLenSinglePulse; @@ -28,326 +20,285 @@ quint32 HonaLowLevelAPI::nextResS; quint32 HonaLowLevelAPI::nextInt123C; quint32 HonaLowLevelAPI::nextRes123C; quint32 HonaLowLevelAPI::nextIntS; ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 bool HonaLowLevelAPI::getHsruIsStarted() const { - return _hsruIsStarted; + return _hsruIsStarted; } /*************************************************************************************************/ void HonaLowLevelAPI::setHsruIsStarted(bool hsruIsStarted) { - _hsruIsStarted = hsruIsStarted; + _hsruIsStarted = hsruIsStarted; } /*************************************************************************************************/ bool HonaLowLevelAPI::getHiruIsStarted() const { - return _hiruIsStarted; + return _hiruIsStarted; } /*************************************************************************************************/ void HonaLowLevelAPI::setHiruIsStarted(bool hiruIsStarted) { - _hiruIsStarted = hiruIsStarted; + _hiruIsStarted = hiruIsStarted; } /*************************************************************************************************/ HonaLowLevelAPI::HonaLowLevelAPI(QObject* parent) : QObject(parent) { - packetLenInt4 = 7; - packetLenRes4 = 5; - packetLenSinglePulse = 5; - packetLenInt123C = 6; - packetLenRes123C = 6; - packetLenIntS = 7; - packetLenResS = 7; + packetLenInt4 = 7; + packetLenRes4 = 5; + packetLenSinglePulse = 5; + packetLenInt123C = 6; + packetLenRes123C = 6; + packetLenIntS = 7; + packetLenResS = 7; } /*************************************************************************************************/ bool HonaLowLevelAPI::isHsruStarted() { - return getHsruIsStarted(); + return getHsruIsStarted(); } /*************************************************************************************************/ bool HonaLowLevelAPI::isHiruStarted() { - return getHiruIsStarted(); + return getHiruIsStarted(); } /*************************************************************************************************/ void HonaLowLevelAPI::deviceReset() { - if(!plxWrapper.deviceReset()) - throw HonaException("Reset Doesnt Occur"); + if(!plxWrapper.deviceReset()) + throw HonaException("Reset Doesnt Occur"); } /*************************************************************************************************/ void HonaLowLevelAPI::setConfig(HonaSettings& settings) { - if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8)) - { - throw HonaException("DeviceReadRegister Doesnt Occur"); - } - _honaSetting = settings; - writeSettingToRegisters(settings); - if(!plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer)) - { - throw HonaException("DeviceWriteRegister Doesnt Occur"); - } - - if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8)) - { - throw HonaException("DeviceReadRegister Doesnt Occur"); - } + if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8)) + { + throw HonaException("DeviceReadRegister Doesnt Occur"); + } + _honaSetting = settings; + writeSettingToRegisters(settings); + if(!plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer)) + { + throw HonaException("DeviceWriteRegister Doesnt Occur"); + } + + if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8)) + { + throw HonaException("DeviceReadRegister Doesnt Occur"); + } } /*************************************************************************************************/ HonaSettings HonaLowLevelAPI::getConfig() { - return _honaSetting; + return _honaSetting; } /*************************************************************************************************/ QString HonaLowLevelAPI::getSwVersion() { - return("94072200"); + return("94072200"); } /*************************************************************************************************/ QString HonaLowLevelAPI::getDeviceId() { - return("ssr"); + return("ssr"); } /*************************************************************************************************/ void HonaLowLevelAPI::hsruStart() { - if(HonaLowLevelAPI::isHsruStarted()) - { - throw HonaAlreadyStartedException(" alreadyStarted"); - } - else - { - setHsruIsStarted(true); - QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread); - } + if(HonaLowLevelAPI::isHsruStarted()) + { + throw HonaAlreadyStartedException(" alreadyStarted"); + } + else + { + setHsruIsStarted(true); + QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread); + } } /*************************************************************************************************/ void HonaLowLevelAPI::hiruStart() { - if(!isHiruStarted()) - throw HonaException("HiruStarted doesn't started "); - QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread); - setHiruIsStarted(true); + if(!isHiruStarted()) + throw HonaException("HiruStarted doesn't started "); + QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread); + setHiruIsStarted(true); } /*************************************************************************************************/ void HonaLowLevelAPI::hsruStop() { - if(isHiruStarted()) - setHsruIsStarted(false); - _hsruStopEvent.wakeAll(); + if(isHiruStarted()) + setHsruIsStarted(false); + _hsruStopEvent.wakeAll(); } /*************************************************************************************************/ void HonaLowLevelAPI::init() { - if(!plxWrapper.deviceInit(0X9054)) - { - throw HonaException("Init Doesn't Occur"); - } - - if(!plxWrapper.deviceOpen()) - { - throw HonaException("deviceOpen Doesn't Occur"); - } + if(!plxWrapper.deviceInit(0X9054)) + { + throw HonaException("Init Doesn't Occur"); + } + + if(!plxWrapper.deviceOpen()) + { + throw HonaException("deviceOpen Doesn't Occur"); + } } /*************************************************************************************************/ void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings) { -<<<<<<< HEAD honaRegisterBuffer.clear(); - honaRegisterBuffer.insert(0,0x00000000); + honaRegisterBuffer.insert(0, 0x00000000); /************************************************************************/ if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter) - honaRegisterBuffer.insert(0,0x80000000); + honaRegisterBuffer.insert(0, 0x80000000); else - honaRegisterBuffer.insert(0,0x7FFFFFFF); - /************************************************************************/ + honaRegisterBuffer.insert(0, 0x7FFFFFFF); + /************************************************************************/ if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12) - honaRegisterBuffer.insert(0,0x20000000); + honaRegisterBuffer.insert(0, 0x20000000); else - honaRegisterBuffer.insert(0,0xDFFFFFFF); + honaRegisterBuffer.insert(0, 0xDFFFFFFF); /************************************************************************/ if(settings.hiruSettings.recordMode == recorderMode::dualChannel) - honaRegisterBuffer.insert(0,0x10000000); + honaRegisterBuffer.insert(0, 0x10000000); else - honaRegisterBuffer.insert(0,0xEFFFFFFF); + honaRegisterBuffer.insert(0, 0xEFFFFFFF); /************************************************************************/ - honaRegisterBuffer.insert(0,(honaRegisterBuffer.at(0)+ (settings.hiruSettings.threshold & 0x00000FFF))); - - honaRegisterBuffer.insert(1,settings.hsruSettings.honaInt123CTHR); - honaRegisterBuffer.insert(2,settings.hsruSettings.honaRes123CTHR); - honaRegisterBuffer.insert(3,settings.hsruSettings.honaIntSTHR); - honaRegisterBuffer.insert(4,settings.hsruSettings.honaResSTHR); - honaRegisterBuffer.insert(5,settings.hsruSettings.honaSPTHR); - honaRegisterBuffer.insert(6,settings.hsruSettings.intM4_THR); - honaRegisterBuffer.insert(7,settings.hsruSettings.resM4_THR); -======= - honaRegisterBuffer.clear(); - honaRegisterBuffer.insert(0, 0x00000000); - /************************************************************************/ - if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter) - honaRegisterBuffer.insert(0, 0x80000000); - else - honaRegisterBuffer.insert(0, 0x7FFFFFFF); - /************************************************************************/ - if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12) - honaRegisterBuffer.insert(0, 0x20000000); - else - honaRegisterBuffer.insert(0, 0xDFFFFFFF); - /************************************************************************/ - if(settings.hiruSettings.recordMode == recorderMode::dualChannel) - honaRegisterBuffer.insert(0, 0x10000000); - else - honaRegisterBuffer.insert(0, 0xEFFFFFFF); - /************************************************************************/ - - honaRegisterBuffer.insert(0, - (honaRegisterBuffer.at(0) + - (settings.hiruSettings.threshold & 0x00000FFF))); - - honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR); - honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR); - honaRegisterBuffer.insert(3, settings.hsruSettings.honaIntSTHR); - honaRegisterBuffer.insert(4, settings.hsruSettings.honaResSTHR); - honaRegisterBuffer.insert(5, settings.hsruSettings.honaSPTHR); - honaRegisterBuffer.insert(6, settings.hsruSettings.intM4_THR); - honaRegisterBuffer.insert(7, settings.hsruSettings.resM4_THR); ->>>>>>> 64f6e7f618eb5a6f1f63a4c5f377b46f1e7bc126 + honaRegisterBuffer.insert(0, + (honaRegisterBuffer.at(0) + + (settings.hiruSettings.threshold & 0x00000FFF))); + + honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR); + honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR); + honaRegisterBuffer.insert(3, settings.hsruSettings.honaIntSTHR); + honaRegisterBuffer.insert(4, settings.hsruSettings.honaResSTHR); + honaRegisterBuffer.insert(5, settings.hsruSettings.honaSPTHR); + honaRegisterBuffer.insert(6, settings.hsruSettings.intM4_THR); + honaRegisterBuffer.insert(7, settings.hsruSettings.resM4_THR); } /*************************************************************************************************/ void HonaLowLevelAPI::setConfig() { - setConfig(_honaSetting); + setConfig(_honaSetting); } /*************************************************************************************************/ void HonaLowLevelAPI::hsruMainThread() { - //try - //{ - deviceReset(); - setConfig(); - deviceReset(); - if(!plxWrapper.deviceEnableInterrupt()) - { - throw HonaException("DeviceEnableInterrupt Doesnt Occur"); - } - - QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread); - QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread); - //} - //catch(...) - //{ - //_isHsruReaderThreadFree = true; - //_isHsruUpdateThreadFree = true; - //hsruStop(); - //} - - _mutex.lock(); - _hsruStopEvent.wait(&_mutex); - _mutex.unlock(); - _isHsruReaderThreadFree = true; - _isHsruUpdateThreadFree = true; - - if(!plxWrapper.deviceDisableInterrupt()) - { - throw HonaException("DeviceEnableInterrupt Doesnt Occur"); - } + deviceReset(); + setConfig(); + deviceReset(); + if(!plxWrapper.deviceEnableInterrupt()) + { + throw HonaException("DeviceEnableInterrupt Doesnt Occur"); + } + + QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread); + QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread); + + _mutex.lock(); + _hsruStopEvent.wait(&_mutex); + _mutex.unlock(); + _isHsruReaderThreadFree = true; + _isHsruUpdateThreadFree = true; + + if(!plxWrapper.deviceDisableInterrupt()) + { + throw HonaException("DeviceEnableInterrupt Doesnt Occur"); + } } /*************************************************************************************************/ void HonaLowLevelAPI::hsruReadThread() { - _hsruLoss = 0; - while(true) - { - if(_isHsruReaderThreadFree) - break; - - if(!plxWrapper.deviceWaitForInterrupt(1000)) - { - throw HonaException("DeviceWaitForInterrupt Doesnt Occur"); - } - honaPacketList.clear(); - _hsruLoss = 0; - if(!plxWrapper.deviceOpenPCIChannel()) - { - throw HonaException("DeviceOpenPCIChannel Doesnt Occur"); - } - - _hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C), - honaPacketList); - _hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C), - honaPacketList); - _hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList); - _hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList); - _hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList); - _hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList); - _hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse), - honaPacketList); - if(!plxWrapper.deviceClosePCIChannel()) - { - throw HonaException("DeviceClosePCIChannel Doesnt Occur"); - } - if(!plxWrapper.deviceEnableInterrupt()) - { - throw HonaException("DeviceEnableInterrupt Doesnt Occur"); - } - _mutex.lock(); - _hsruReadDone.wakeAll(); - _hsruUpdateAck.wait(&_mutex); - _mutex.unlock(); - } + _hsruLoss = 0; + while(true) + { + if(_isHsruReaderThreadFree) + break; + + if(!plxWrapper.deviceWaitForInterrupt(1000)) + { + throw HonaException("DeviceWaitForInterrupt Doesnt Occur"); + } + honaPacketList.clear(); + _hsruLoss = 0; + if(!plxWrapper.deviceOpenPCIChannel()) + { + throw HonaException("DeviceOpenPCIChannel Doesnt Occur"); + } + + _hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C), + honaPacketList); + _hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C), + honaPacketList); + _hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList); + _hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList); + _hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList); + _hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList); + _hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse), + honaPacketList); + if(!plxWrapper.deviceClosePCIChannel()) + { + throw HonaException("DeviceClosePCIChannel Doesnt Occur"); + } + if(!plxWrapper.deviceEnableInterrupt()) + { + throw HonaException("DeviceEnableInterrupt Doesnt Occur"); + } + _mutex.lock(); + _hsruReadDone.wakeAll(); + _hsruUpdateAck.wait(&_mutex); + _mutex.unlock(); + } } /*************************************************************************************************/ void HonaLowLevelAPI::hsruUpdateThread() { - while(true) - { - _mutex.lock(); - _hsruReadDone.wait(&_mutex); - _mutex.unlock(); - if(_isHsruUpdateThreadFree) - break; - quint32 Doa = 0; - Doa = hiruGetDOA(); - emit lowLevelHonaData(honaPacketList, _hsruLoss, Doa); - _hsruUpdateAck.wakeAll(); - } + while(true) + { + _mutex.lock(); + _hsruReadDone.wait(&_mutex); + _mutex.unlock(); + if(_isHsruUpdateThreadFree) + break; + quint32 Doa = 0; + Doa = hiruGetDOA(); + emit lowLevelHonaData(honaPacketList, _hsruLoss, Doa); + _hsruUpdateAck.wakeAll(); + } } /*************************************************************************************************/ void HonaLowLevelAPI::hiruMainThread() { - QtConcurrent::run(this, &HonaLowLevelAPI::hiruReadThread); - QtConcurrent::run(this, &HonaLowLevelAPI::hiruUpdateThread); - while(true) - { - _mutex.lock(); - _hsruStopEvent.wait(&_mutex); - _mutex.unlock(); - } + QtConcurrent::run(this, &HonaLowLevelAPI::hiruReadThread); + QtConcurrent::run(this, &HonaLowLevelAPI::hiruUpdateThread); + while(true) + { + _mutex.lock(); + _hsruStopEvent.wait(&_mutex); + _mutex.unlock(); + } } /*************************************************************************************************/ @@ -363,658 +314,576 @@ void HonaLowLevelAPI::hiruUpdateThread() /*************************************************************************************************/ quint32 HonaLowLevelAPI::hiruGetDOA() { - quint32 Doa = 0; - if(!plxWrapper.deviceReadRegister(0x30000004, Doa)) - { - throw HonaException("DeviceReadRegister Doesnt Occur"); - } - Doa = Doa & 0x0000FFFF; - - return Doa; + quint32 Doa = 0; + if(!plxWrapper.deviceReadRegister(0x30000004, Doa)) + { + throw HonaException("DeviceReadRegister Doesnt Occur"); + } + Doa = Doa & 0x0000FFFF; + return Doa; } /*************************************************************************************************/ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector& honaData, - QList& honaPacketList) + QList& honaPacketList) { - quint32 lossFound = 0; - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - HonaPacket tempHonaPacketInt123C; - tempHonaPacketInt123C.setPacketType(honaPacketType::interrogationMode123C); - packetLenInt123C = 6; - tempHonaPacketInt123C.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketInt123C.getPacketNumber() != - (lastPNInt123C + 1)) & (lastPNInt123C > 0)) - { - lossFound += - ((tempHonaPacketInt123C.getPacketNumber() - lastPNInt123C + 65536) % 65536 - 1); - } - lastPNInt123C = tempHonaPacketInt123C.getPacketNumber(); - if(nextInt123C > 0) - lossFound++; - nextInt123C = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextInt123C == 1)) - { - tempHonaPacketInt123C.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); - nextInt123C = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt123C == 2)) - { - tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa()) + - (static_cast(honaData[Ind] & 0x0000FFFF) << - 28)); - - tempHonaPacketInt123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextInt123C = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextInt123C == 3)) - { - tempHonaPacketInt123C.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketInt123C.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextInt123C = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextInt123C == 4)) - { - tempHonaPacketInt123C.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketInt123C.setPa2(tempHonaPacketInt123C.getPa2() + - ((honaData[Ind] & 0x000F0000) >> 4)); - tempHonaPacketInt123C.setPa3(tempHonaPacketInt123C.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 8)); - nextInt123C = 5; - } - else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt123C == 5)) - { - tempHonaPacketInt123C.setCodeM( - (static_cast(honaData[Ind] & 0x0000001F)) << 59); - tempHonaPacketInt123C.setCodeL(0); - nextInt123C = 6; - } - - if(nextInt123C == packetLenInt123C) - { - if(isValid(tempHonaPacketInt123C)) - { - tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa() / 8) + toaStartBoard); - honaPacketList.append(tempHonaPacketInt123C); - } - nextInt123C = 0; - } - } - - return lossFound; + quint32 lossFound = 0; + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) + { + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + HonaPacket tempHonaPacketInt123C; + tempHonaPacketInt123C.setPacketType(honaPacketType::interrogationMode123C); + packetLenInt123C = 6; + tempHonaPacketInt123C.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketInt123C.getPacketNumber() != + (lastPNInt123C + 1)) & (lastPNInt123C > 0)) + { + lossFound += + ((tempHonaPacketInt123C.getPacketNumber() - lastPNInt123C + 65536) % 65536 - 1); + } + lastPNInt123C = tempHonaPacketInt123C.getPacketNumber(); + if(nextInt123C > 0) + lossFound++; + nextInt123C = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextInt123C == 1)) + { + tempHonaPacketInt123C.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); + nextInt123C = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt123C == 2)) + { + tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa()) + + (static_cast(honaData[Ind] & 0x0000FFFF) << + 28)); + + tempHonaPacketInt123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextInt123C = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextInt123C == 3)) + { + tempHonaPacketInt123C.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketInt123C.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextInt123C = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextInt123C == 4)) + { + tempHonaPacketInt123C.setPa1(honaData[Ind] & 0x0000FFFF); + tempHonaPacketInt123C.setPa2(tempHonaPacketInt123C.getPa2() + + ((honaData[Ind] & 0x000F0000) >> 4)); + tempHonaPacketInt123C.setPa3(tempHonaPacketInt123C.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 8)); + nextInt123C = 5; + } + else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt123C == 5)) + { + tempHonaPacketInt123C.setCodeM( + (static_cast(honaData[Ind] & 0x0000001F)) << 59); + tempHonaPacketInt123C.setCodeL(0); + nextInt123C = 6; + } + + if(nextInt123C == packetLenInt123C) + { + if(isValid(tempHonaPacketInt123C)) + { + tempHonaPacketInt123C.setToa((tempHonaPacketInt123C.getToa() / 8) + toaStartBoard); + honaPacketList.append(tempHonaPacketInt123C); + } + nextInt123C = 0; + } + } + + return lossFound; } /*************************************************************************************************/ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector& honaData, - QList& honaPacketList) + QList& honaPacketList) { - quint32 lossFound = 0; - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - tempHonaPacketRes123C.setPacketType(honaPacketType::responseMode123C); - packetLenRes123C = 6; - tempHonaPacketRes123C.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketRes123C.getPacketNumber() != - (lastPNRes123C + 1)) & (lastPNRes123C > 0)) - { - lossFound += - ((tempHonaPacketRes123C.getPacketNumber() - lastPNRes123C + 65536) % 65536 - 1); - } - lastPNRes123C = tempHonaPacketRes123C.getPacketNumber(); - if(nextRes123C > 0) - lossFound++; - nextRes123C = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextRes123C == 1)) - { - tempHonaPacketRes123C.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); - nextRes123C = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes123C == 2)) - { - tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() + - ((static_cast(honaData[Ind] & 0x0000FFFF)) << - 28)); - tempHonaPacketRes123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextRes123C = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextRes123C == 3)) - { - tempHonaPacketRes123C.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketRes123C.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextRes123C = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextRes123C == 4)) - { - tempHonaPacketRes123C.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() + - ((honaData[Ind] & 0x000F0000) >> 4)); - tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 8)); - nextRes123C = 5; - } - else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextRes123C == 5)) - { - tempHonaPacketRes123C.setCodeM( - (static_cast(honaData[Ind] & 0x00001FFF)) << 51); - tempHonaPacketRes123C.setCodeL(0); - nextRes123C = 6; - } - - if(nextRes123C == packetLenRes123C) - { - if(isValid(tempHonaPacketRes123C)) - { - tempHonaPacketRes123C.setToa((tempHonaPacketRes123C.getToa() / 8) + toaStartBoard); - honaPacketList.append(tempHonaPacketRes123C); - } - nextRes123C = 0; - } - } - - return lossFound; + quint32 lossFound = 0; + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) + { + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + tempHonaPacketRes123C.setPacketType(honaPacketType::responseMode123C); + packetLenRes123C = 6; + tempHonaPacketRes123C.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketRes123C.getPacketNumber() != + (lastPNRes123C + 1)) & (lastPNRes123C > 0)) + { + lossFound += + ((tempHonaPacketRes123C.getPacketNumber() - lastPNRes123C + 65536) % 65536 - 1); + } + lastPNRes123C = tempHonaPacketRes123C.getPacketNumber(); + if(nextRes123C > 0) + lossFound++; + nextRes123C = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextRes123C == 1)) + { + tempHonaPacketRes123C.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); + nextRes123C = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes123C == 2)) + { + tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() + + ((static_cast(honaData[Ind] & 0x0000FFFF)) << + 28)); + tempHonaPacketRes123C.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextRes123C = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextRes123C == 3)) + { + tempHonaPacketRes123C.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketRes123C.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextRes123C = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextRes123C == 4)) + { + tempHonaPacketRes123C.setPa1(honaData[Ind] & 0x0000FFFF); + + tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() + + ((honaData[Ind] & 0x000F0000) >> 4)); + tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 8)); + nextRes123C = 5; + } + else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextRes123C == 5)) + { + tempHonaPacketRes123C.setCodeM( + (static_cast(honaData[Ind] & 0x00001FFF)) << 51); + tempHonaPacketRes123C.setCodeL(0); + + nextRes123C = 6; + } + + if(nextRes123C == packetLenRes123C) + { + if(isValid(tempHonaPacketRes123C)) + { + tempHonaPacketRes123C.setToa((tempHonaPacketRes123C.getToa() / 8) + toaStartBoard); + honaPacketList.append(tempHonaPacketRes123C); + } + nextRes123C = 0; + } + } + return lossFound; } /*************************************************************************************************/ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector& honaData, - QList& honaPacketList) + QList& honaPacketList) { - uint lossFound = 0; - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - qint32 TypeVal = (honaData[Ind] & 0x00F00000) >> 20; - if(TypeVal == 2) - { - tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS56); - packetLenIntS = 7; - } - else - { - tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS112); - packetLenIntS = 9; - } - tempHonaPacketIntS.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketIntS.getPacketNumber() != (lastPNIntS + 1)) & (lastPNIntS > 0)) - { - lossFound += - ((tempHonaPacketIntS.getPacketNumber() - lastPNIntS + 65536) % 65536 - 1); - } - lastPNIntS = tempHonaPacketIntS.getPacketNumber(); - if(nextIntS > 0) - lossFound++; - nextIntS = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextIntS == 1)) - { - tempHonaPacketIntS.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); - nextIntS = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextIntS == 2)) - { - tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() + - ((static_cast(honaData[Ind] & 0x0000FFFF)) << - 28)); - tempHonaPacketIntS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextIntS = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextIntS == 3)) - { - tempHonaPacketIntS.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketIntS.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextIntS = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextIntS == 4)) - { - tempHonaPacketIntS.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData[Ind] & 0x000F0000))); - tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 4)); - nextIntS = 5; - } - else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextIntS == 5)) - { - tempHonaPacketIntS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); - tempHonaPacketIntS.setCodeL(0); - nextIntS = 6; - } - else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextIntS == 6)) - { - tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); - tempHonaPacketIntS.setCodeL(0); - nextIntS = 7; - } - else if(((honaData[Ind] & 0xF0000000) == 0x70000000) && (nextIntS == 7)) - { - tempHonaPacketIntS.setCodeL(tempHonaPacketIntS.getCodeM()); - tempHonaPacketIntS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); - nextIntS = 8; - } - else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextIntS == 8)) - { - tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); - nextIntS = 9; - } - - if(nextIntS == packetLenIntS) - { - if(isValid(tempHonaPacketIntS)) - { - tempHonaPacketIntS.setToa((tempHonaPacketIntS.getToa() / 8) + toaStartBoard); - honaPacketList.append(tempHonaPacketIntS); - } - nextIntS = 0; - } - } - - return lossFound; + uint lossFound = 0; + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) + { + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + qint32 TypeVal = (honaData[Ind] & 0x00F00000) >> 20; + if(TypeVal == 2) + { + tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS56); + packetLenIntS = 7; + } + else + { + tempHonaPacketIntS.setPacketType(honaPacketType::interrogationModeS112); + packetLenIntS = 9; + } + tempHonaPacketIntS.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketIntS.getPacketNumber() != (lastPNIntS + 1)) & (lastPNIntS > 0)) + { + lossFound += + ((tempHonaPacketIntS.getPacketNumber() - lastPNIntS + 65536) % 65536 - 1); + } + lastPNIntS = tempHonaPacketIntS.getPacketNumber(); + if(nextIntS > 0) + lossFound++; + nextIntS = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextIntS == 1)) + { + tempHonaPacketIntS.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); + nextIntS = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextIntS == 2)) + { + tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() + + ((static_cast(honaData[Ind] & 0x0000FFFF)) << + 28)); + tempHonaPacketIntS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextIntS = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextIntS == 3)) + { + tempHonaPacketIntS.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketIntS.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextIntS = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextIntS == 4)) + { + tempHonaPacketIntS.setPa1(honaData[Ind] & 0x0000FFFF); + tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData[Ind] & 0x000F0000))); + tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 4)); + nextIntS = 5; + } + else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextIntS == 5)) + { + tempHonaPacketIntS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); + tempHonaPacketIntS.setCodeL(0); + nextIntS = 6; + } + else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextIntS == 6)) + { + tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + + (static_cast(honaData[Ind] & 0x0FFFFFFF)) << + 36); + tempHonaPacketIntS.setCodeL(0); + nextIntS = 7; + } + else if(((honaData[Ind] & 0xF0000000) == 0x70000000) && (nextIntS == 7)) + { + tempHonaPacketIntS.setCodeL(tempHonaPacketIntS.getCodeM()); + tempHonaPacketIntS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); + nextIntS = 8; + } + else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextIntS == 8)) + { + tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + + (static_cast(honaData[Ind] & 0x0FFFFFFF)) << + 36); + nextIntS = 9; + } + + if(nextIntS == packetLenIntS) + { + if(isValid(tempHonaPacketIntS)) + { + tempHonaPacketIntS.setToa((tempHonaPacketIntS.getToa() / 8) + toaStartBoard); + honaPacketList.append(tempHonaPacketIntS); + } + nextIntS = 0; + } + } + + return lossFound; } /*************************************************************************************************/ quint32 HonaLowLevelAPI::hsruParserResS(const QVector& honaData, - QList& honaPacketList) + QList& honaPacketList) { - uint lossFound = 0; - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - qint32 TypeVal = (honaData[Ind] & 0x00F00000) >> 20; - if(TypeVal == 4) - { - tempHonaPacketResS.setPacketType(honaPacketType::responseModeS56); - packetLenResS = 7; - } - else - { - tempHonaPacketResS.setPacketType(honaPacketType::responseModeS112); - packetLenResS = 9; - } - tempHonaPacketResS.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketResS.getPacketNumber() != (lastPNResS + 1)) & (lastPNResS > 0)) - { - lossFound += - ((tempHonaPacketResS.getPacketNumber() - lastPNResS + 65536) % 65536 - 1); - } - lastPNResS = tempHonaPacketResS.getPacketNumber(); - if(nextResS > 0) - lossFound++; - nextResS = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextResS == 1)) - { - tempHonaPacketResS.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); - nextResS = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextResS == 2)) - { - tempHonaPacketResS.setToa(tempHonaPacketResS.getToa() + - ((static_cast(honaData[Ind] & 0x0000FFFF)) << - 28)); - tempHonaPacketResS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextResS = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextResS == 3)) - { - tempHonaPacketResS.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketResS.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextResS = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextResS == 4)) - { - tempHonaPacketResS.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData[Ind] & 0x000F0000))); - tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 4)); - nextResS = 5; - } - else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextResS == 5)) - { - tempHonaPacketResS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); - tempHonaPacketResS.setCodeL(0); - nextResS = 6; - } - else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextResS == 6)) - { - tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); - tempHonaPacketResS.setCodeL(0); - nextResS = 7; - } - else if(((honaData[Ind] & 0xF0000000) == 0x70000000) && (nextResS == 7)) - { - tempHonaPacketResS.setCodeL(tempHonaPacketResS.getCodeM()); - tempHonaPacketResS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); - nextResS = 8; - } - else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextResS == 8)) - { - tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); - nextResS = 9; - } - if(nextResS == packetLenResS) - { - if(isValid(tempHonaPacketResS)) - { - tempHonaPacketResS.setToa((tempHonaPacketResS.getToa() / 8) + toaStartBoard); - honaPacketList.append(tempHonaPacketResS); - } - nextResS = 0; - } - } - - return lossFound; + uint lossFound = 0; + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) + { + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + qint32 TypeVal = (honaData[Ind] & 0x00F00000) >> 20; + if(TypeVal == 4) + { + tempHonaPacketResS.setPacketType(honaPacketType::responseModeS56); + packetLenResS = 7; + } + else + { + tempHonaPacketResS.setPacketType(honaPacketType::responseModeS112); + packetLenResS = 9; + } + tempHonaPacketResS.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketResS.getPacketNumber() != (lastPNResS + 1)) & (lastPNResS > 0)) + { + lossFound += + ((tempHonaPacketResS.getPacketNumber() - lastPNResS + 65536) % 65536 - 1); + } + lastPNResS = tempHonaPacketResS.getPacketNumber(); + if(nextResS > 0) + lossFound++; + nextResS = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextResS == 1)) + { + tempHonaPacketResS.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); + nextResS = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextResS == 2)) + { + tempHonaPacketResS.setToa(tempHonaPacketResS.getToa() + + ((static_cast(honaData[Ind] & 0x0000FFFF)) << + 28)); + tempHonaPacketResS.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextResS = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextResS == 3)) + { + tempHonaPacketResS.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketResS.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextResS = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextResS == 4)) + { + tempHonaPacketResS.setPa1(honaData[Ind] & 0x0000FFFF); + tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData[Ind] & 0x000F0000))); + tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 4)); + nextResS = 5; + } + else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextResS == 5)) + { + tempHonaPacketResS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); + tempHonaPacketResS.setCodeL(0); + nextResS = 6; + } + else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextResS == 6)) + { + tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + + (static_cast(honaData[Ind] & 0x0FFFFFFF)) << + 36); + tempHonaPacketResS.setCodeL(0); + nextResS = 7; + } + else if(((honaData[Ind] & 0xF0000000) == 0x70000000) && (nextResS == 7)) + { + tempHonaPacketResS.setCodeL(tempHonaPacketResS.getCodeM()); + tempHonaPacketResS.setCodeM((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 8); + nextResS = 8; + } + else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextResS == 8)) + { + tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + + (static_cast(honaData[Ind] & 0x0FFFFFFF)) << + 36); + nextResS = 9; + } + if(nextResS == packetLenResS) + { + if(isValid(tempHonaPacketResS)) + { + tempHonaPacketResS.setToa((tempHonaPacketResS.getToa() / 8) + toaStartBoard); + honaPacketList.append(tempHonaPacketResS); + } + nextResS = 0; + } + } + + return lossFound; } /*************************************************************************************************/ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector& honaData, - QList& honaPacketList) + QList& honaPacketList) { - uint lossFound = 0; - - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - tempHonaPacketInt4.setPacketType(honaPacketType::interrogationMode4); - packetLenInt4 = 7; - tempHonaPacketInt4.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0)) - { - lossFound += - ((tempHonaPacketInt4.getPacketNumber() - lastPNInt4 + 65536) % 65536 - 1); - } - lastPNInt4 = tempHonaPacketInt4.getPacketNumber(); - if(nextInt4 > 0) - lossFound++; - nextInt4 = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextInt4 == 1)) - { - tempHonaPacketInt4.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); - nextInt4 = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt4 == 2)) - { - tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() + - ((static_cast(honaData[Ind] & 0x0000FFFF)) << - 28)); - tempHonaPacketInt4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextInt4 = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextInt4 == 3)) - { - tempHonaPacketInt4.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketInt4.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextInt4 = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextInt4 == 4)) - { - tempHonaPacketInt4.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() + - ((honaData[Ind] & 0x000F0000) >> 4)); - tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 8)); - nextInt4 = 5; - } - else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt4 == 5)) - { - tempHonaPacketInt4.setCodeM(0); - tempHonaPacketInt4.setCodeL(static_cast(honaData[Ind] & 0x0FFFFFFF)); - nextInt4 = 6; - } - else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextInt4 == 6)) - { - tempHonaPacketInt4.setPa4(honaData[Ind] & 0x0000FFFF); - tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() + - ((static_cast(honaData[Ind] & 0x000F0000)) << - 12)); - tempHonaPacketInt4.setm4Status(static_cast((honaData[Ind] & 0x0F000000) >> 20)); - nextInt4 = 7; - } - - if(nextInt4 == packetLenInt4) - { - if(isValid(tempHonaPacketInt4)) - { - tempHonaPacketInt4.setToa((tempHonaPacketInt4.getToa() / 6) + toaStartBoard); - honaPacketList.append(tempHonaPacketInt4); - } - nextInt4 = 0; - } - } - - return lossFound; -} + uint lossFound = 0; -quint32 HonaLowLevelAPI::hsruParserRes4(const QVector& honaData, - QList& honaPacketList) -{ - uint lossFound = 0; - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - tempHonaPacketRes4.setPacketType(honaPacketType::responseMode4); - packetLenRes4 = 5; - tempHonaPacketRes4.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0)) - { - lossFound += - ((tempHonaPacketRes4.getPacketNumber() - lastPNRes4 + 65536) % 65536 - 1); - } - lastPNRes4 = tempHonaPacketRes4.getPacketNumber(); - if(nextRes4 > 0) - lossFound++; - nextRes4 = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextRes4 == 1)) - { - tempHonaPacketRes4.setToa((static_cast(honaData[Ind] & 0x0FFFFFFF))); - nextRes4 = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes4 == 2)) - { - tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() + - (static_cast(honaData[Ind] & 0x0000FFFF) << - 28)); - tempHonaPacketRes4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextRes4 = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextRes4 == 3)) - { - tempHonaPacketRes4.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketRes4.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextRes4 = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextRes4 == 4)) - { - tempHonaPacketRes4.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketRes4.setPa2(tempHonaPacketRes4.getPa2() + - ((honaData[Ind] & 0x000F0000) >> 4)); - tempHonaPacketRes4.setPa3(tempHonaPacketRes4.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 8)); - nextRes4 = 5; - } - - if(nextRes4 == packetLenRes4) - { - if(isValid(tempHonaPacketRes4)) - { - tempHonaPacketRes4.setToa((tempHonaPacketRes4.getToa() / 6) + toaStartBoard); - honaPacketList.append(tempHonaPacketRes4); - } - nextRes4 = 0; - } - } - - return lossFound; -} + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) + { + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + tempHonaPacketInt4.setPacketType(honaPacketType::interrogationMode4); + packetLenInt4 = 7; + tempHonaPacketInt4.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketInt4.getPacketNumber() != (lastPNInt4 + 1)) & (lastPNInt4 > 0)) + { + lossFound += + ((tempHonaPacketInt4.getPacketNumber() - lastPNInt4 + 65536) % 65536 - 1); + } + lastPNInt4 = tempHonaPacketInt4.getPacketNumber(); + if(nextInt4 > 0) + lossFound++; + nextInt4 = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextInt4 == 1)) + { + tempHonaPacketInt4.setToa(static_cast(honaData[Ind] & 0x0FFFFFFF)); + nextInt4 = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextInt4 == 2)) + { + tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() + + ((static_cast(honaData[Ind] & 0x0000FFFF)) << + 28)); + tempHonaPacketInt4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextInt4 = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextInt4 == 3)) + { + tempHonaPacketInt4.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketInt4.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextInt4 = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextInt4 == 4)) + { + tempHonaPacketInt4.setPa1(honaData[Ind] & 0x0000FFFF); + tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() + + ((honaData[Ind] & 0x000F0000) >> 4)); + tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 8)); + nextInt4 = 5; + } + else if(((honaData[Ind] & 0xF0000000) == 0x50000000) && (nextInt4 == 5)) + { + tempHonaPacketInt4.setCodeM(0); + tempHonaPacketInt4.setCodeL(static_cast(honaData[Ind] & 0x0FFFFFFF)); + nextInt4 = 6; + } + else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextInt4 == 6)) + { + tempHonaPacketInt4.setPa4(honaData[Ind] & 0x0000FFFF); + tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() + + ((static_cast(honaData[Ind] & 0x000F0000)) << 12)); + tempHonaPacketInt4.setm4Status(static_cast((honaData[Ind] & 0x0F000000) >> 20)); + nextInt4 = 7; + } -/*************************************************************************************************/ -quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector& honaData, - QList& honaPacketList) -{ - uint lossFound = 0; - for(qint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if((honaData[Ind] & 0xFF000000) == 0x0F000000) - { - tempHonaPacketSinglePulse.setPacketType(honaPacketType::singlePulseMode4); - packetLenSinglePulse = 5; - tempHonaPacketSinglePulse.setPacketNumber(honaData[Ind] & 0x0000FFFF); - if((tempHonaPacketSinglePulse.getPacketNumber() != - (lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0)) - { - lossFound += - ((tempHonaPacketSinglePulse.getPacketNumber() - lastPNSinglePulse + 65536) % - 65536 - - 1); - } - lastPNSinglePulse = tempHonaPacketSinglePulse.getPacketNumber(); - if(nextSinglePulse > 0) - lossFound++; - nextSinglePulse = 1; - } - else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1)) - { - tempHonaPacketSinglePulse.setToa(static_cast(honaData[Ind] & - 0x0FFFFFFF)); - nextSinglePulse = 2; - } - else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2)) - { - tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() + - ((static_cast(honaData[Ind] & - 0x0000FFFF)) << 28)); - tempHonaPacketSinglePulse.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); - nextSinglePulse = 3; - } - else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextSinglePulse == 3)) - { - tempHonaPacketSinglePulse.setDoa(honaData[Ind] & 0x0000FFFF); - tempHonaPacketSinglePulse.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); - nextSinglePulse = 4; - } - else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextSinglePulse == 4)) - { - tempHonaPacketSinglePulse.setPa1(honaData[Ind] & 0x0000FFFF); - tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() + - ((honaData[Ind] & 0x000F0000) >> 4)); - tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() + - ((honaData[Ind] & 0x00F00000) >> 8)); - nextSinglePulse = 5; - } - - if(nextSinglePulse == packetLenSinglePulse) - { - if(isValid(tempHonaPacketSinglePulse)) - { - tempHonaPacketSinglePulse.setToa( - (tempHonaPacketSinglePulse.getToa() / 6) + toaStartBoard); - honaPacketList.append(tempHonaPacketSinglePulse); - } - nextSinglePulse = 0; - } - } - - return lossFound; -} + if(nextInt4 == packetLenInt4) + { + if(isValid(tempHonaPacketInt4)) + { + tempHonaPacketInt4.setToa((tempHonaPacketInt4.getToa() / 6) + toaStartBoard); + honaPacketList.append(tempHonaPacketInt4); + } + nextInt4 = 0; + } + } -/*************************************************************************************************/ -QVector HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver) -{ - QVector honaData; - honaData.resize(16384); - quint32 address = 0; - - if(receiver == honaReceivers::int123C) - address = 0X50000000; - else if(receiver == honaReceivers::res123C) - address = 0X60000000; - else if(receiver == honaReceivers::intS) - address = 0X70000000; - else if(receiver == honaReceivers::resS) - address = 0X80000000; - else if(receiver == honaReceivers::int4) - address = 0X90000000; - else if(receiver == honaReceivers::res4) - address = 0XA0000000; - else if(receiver == honaReceivers::singlePulse) - address = 0XB0000000; - - else - throw HonaException("honaReceivers is Not Valid"); - - if(!plxWrapper.deviceReadMemory(address, honaData, honaData.size())) - { - throw HonaException("DeviceReadMemory Doesnt Occur"); - } - - //qDebug() << " hsruReadHonaBuffer receiver "<< receiver; - //for(auto i = 0 ; i < 10; i++) - //qDebug() << "[" << i << "] " << "0x" << QString::number(honaData[i], 16); - //qDebug() << "------------------------------------------------------------"; - return honaData; + return lossFound; } /*************************************************************************************************/ -bool HonaLowLevelAPI::isValid(HonaPacket hp) +quint32 HonaLowLevelAPI::hsruParserRes4(const QVector& honaData, + QList& honaPacketList) { - if(hp.getToa() <= 0) - return false; + uint lossFound = 0; + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) + { + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + tempHonaPacketRes4.setPacketType(honaPacketType::responseMode4); + packetLenRes4 = 5; + tempHonaPacketRes4.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketRes4.getPacketNumber() != (lastPNRes4 + 1)) & (lastPNRes4 > 0)) + { + lossFound += + ((tempHonaPacketRes4.getPacketNumber() - lastPNRes4 + 65536) % 65536 - 1); + } + lastPNRes4 = tempHonaPacketRes4.getPacketNumber(); + if(nextRes4 > 0) + lossFound++; + nextRes4 = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextRes4 == 1)) + { + tempHonaPacketRes4.setToa((static_cast(honaData[Ind] & 0x0FFFFFFF))); + nextRes4 = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextRes4 == 2)) + { + tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() + + (static_cast(honaData[Ind] & 0x0000FFFF) << + 28)); + tempHonaPacketRes4.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextRes4 = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextRes4 == 3)) + { + tempHonaPacketRes4.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketRes4.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextRes4 = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextRes4 == 4)) + { + tempHonaPacketRes4.setPa1(honaData[Ind] & 0x0000FFFF); + tempHonaPacketRes4.setPa2(tempHonaPacketRes4.getPa2() + + ((honaData[Ind] & 0x000F0000) >> 4)); + tempHonaPacketRes4.setPa3(tempHonaPacketRes4.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 8)); + nextRes4 = 5; + } - return true; + if(nextRes4 == packetLenRes4) + { + if(isValid(tempHonaPacketRes4)) + { + tempHonaPacketRes4.setToa((tempHonaPacketRes4.getToa() / 6) + toaStartBoard); + honaPacketList.append(tempHonaPacketRes4); + } + nextRes4 = 0; + } + } + + return lossFound; } /*************************************************************************************************/ -/*************************************************************************************************/ - - - - - - -void HonaLowLevelAPI::hsruReaderMethod() +quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector& honaData, + QList& honaPacketList) { - DateTime dtStartSim = DateTime.Now; - hsruLoss = 0; - while (true) + uint lossFound = 0; + for(qint32 Ind = 0; Ind < honaData.length(); Ind++) { - if (_honaSettings.hsruSettings.isReal) + if((honaData[Ind] & 0xFF000000) == 0x0F000000) + { + tempHonaPacketSinglePulse.setPacketType(honaPacketType::singlePulseMode4); + packetLenSinglePulse = 5; + tempHonaPacketSinglePulse.setPacketNumber(honaData[Ind] & 0x0000FFFF); + if((tempHonaPacketSinglePulse.getPacketNumber() != + (lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0)) + { + lossFound += + ((tempHonaPacketSinglePulse.getPacketNumber() - lastPNSinglePulse + 65536) % + 65536 - + 1); + } + lastPNSinglePulse = tempHonaPacketSinglePulse.getPacketNumber(); + if(nextSinglePulse > 0) + lossFound++; + nextSinglePulse = 1; + } + else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1)) + { + tempHonaPacketSinglePulse.setToa(static_cast(honaData[Ind] & + 0x0FFFFFFF)); + nextSinglePulse = 2; + } + else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2)) + { + tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() + + ((static_cast(honaData[Ind] & + 0x0000FFFF)) << 28)); + tempHonaPacketSinglePulse.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); + nextSinglePulse = 3; + } + else if(((honaData[Ind] & 0xF0000000) == 0x30000000) && (nextSinglePulse == 3)) { - plxwrapper.deviceWaitForInterrupt(1000); - honaPacketList.clear(); - hsruLoss = 0; - plxwrapper.deviceOpenPCIChannel(); - hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C),&honaPacketList); - hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C),&honaPacketList); - hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS),&honaPacketList); - hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS),&honaPacketList); - hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4),&honaPacketList); - hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4),&honaPacketList); - hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse),&honaPacketList); - plxwrapper.deviceClosePCIChannel(); - plxwrapper.deviceEnableInterrupt(); + tempHonaPacketSinglePulse.setDoa(honaData[Ind] & 0x0000FFFF); + tempHonaPacketSinglePulse.setPa3((honaData[Ind] & 0x0FFF0000) >> 16); + nextSinglePulse = 4; + } + else if(((honaData[Ind] & 0xF0000000) == 0x40000000) && (nextSinglePulse == 4)) + { + tempHonaPacketSinglePulse.setPa1(honaData[Ind] & 0x0000FFFF); + tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() + + ((honaData[Ind] & 0x000F0000) >> 4)); + tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() + + ((honaData[Ind] & 0x00F00000) >> 8)); + nextSinglePulse = 5; } - hsruReadDone.Set(); - hsruUpdateAck.WaitOne(); + if(nextSinglePulse == packetLenSinglePulse) + { + if(isValid(tempHonaPacketSinglePulse)) + { + tempHonaPacketSinglePulse.setToa( + (tempHonaPacketSinglePulse.getToa() / 6) + toaStartBoard); + honaPacketList.append(tempHonaPacketSinglePulse); + } + nextSinglePulse = 0; + } } + + return lossFound; } /*************************************************************************************************/ @@ -1024,105 +893,42 @@ QVector HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver) honaData.resize(16384); quint32 address = 0; - if (receiver == honaReceivers::int123C) + if(receiver == honaReceivers::int123C) address = 0X50000000; - else if (receiver == honaReceivers::res123C) + else if(receiver == honaReceivers::res123C) address = 0X60000000; - else if (receiver == honaReceivers::intS) + else if(receiver == honaReceivers::intS) address = 0X70000000; - else if (receiver == honaReceivers::resS) + else if(receiver == honaReceivers::resS) address = 0X80000000; - else if (receiver == honaReceivers::int4)// Mode4 :: added by H.H + else if(receiver == honaReceivers::int4) address = 0X90000000; - else if (receiver == honaReceivers::res4)// Mode4 :: added by H.H + else if(receiver == honaReceivers::res4) address = 0XA0000000; - else if (receiver == honaReceivers::singlePulse)// Mode4 :: added by H.H + else if(receiver == honaReceivers::singlePulse) address = 0XB0000000; - else - return false; - - plxwrapper.deviceReadMemory(address, honaData,honaData.size()); + throw HonaException("honaReceivers is Not Valid"); - //TODO for test (Debug) - WriteToFile(Receiver, honaData); + if(!plxWrapper.deviceReadMemory(address, honaData, honaData.size())) + { + throw HonaException("DeviceReadMemory Doesnt Occur"); + } + // qDebug() << " hsruReadHonaBuffer receiver "<< receiver; + // for(auto i = 0 ; i < 10; i++) + // qDebug() << "[" << i << "] " << "0x" << QString::number(honaData[i], 16); + // qDebug() << "------------------------------------------------------------"; return honaData; } -/*************************************************************************************************/ -quint32 hsruParserInt123C(QVector honaData,QList honaPacketList) +/*************************************************************************************************/ +bool HonaLowLevelAPI::isValid(HonaPacket hp) { - quint32 lossFound; - for (quint32 Ind = 0; Ind < honaData.length(); Ind++) - { - if ((honaData.at(Ind) & 0xFF000000) == 0x0F000000) - { - HonaPacket tempHonaPacketInt123C; - tempHonaPacketInt123C.setPacketType(honaPacketType.InterrogationMode123C); - packetLenInt123C = 6; - TempHonaPacketInt123C.PacketNumber = HonaData[Ind] & 0x0000FFFF; - if ((TempHonaPacketInt123C.PacketNumber != (LastPNInt123C + 1)) & (LastPNInt123C > 0)) - // & (LastPNInt123C != 65535)) - { - LossFound += ((TempHonaPacketInt123C.PacketNumber - LastPNInt123C + 65536)%65536 - 1); - } - LastPNInt123C = TempHonaPacketInt123C.PacketNumber; - if (NextInt123C > 0) - LossFound++; - NextInt123C = 1; - } - else if (((HonaData[Ind] & 0xF0000000) == 0x10000000) && (NextInt123C == 1)) - { - TempHonaPacketInt123C.TOA = (ulong) (HonaData[Ind] & 0x0FFFFFFF); - NextInt123C = 2; - } - else if (((HonaData[Ind] & 0xF0000000) == 0x20000000) && (NextInt123C == 2)) - { - TempHonaPacketInt123C.TOA += (((ulong) (HonaData[Ind] & 0x0000FFFF)) << 28); - TempHonaPacketInt123C.PA2 = ((HonaData[Ind] & 0x0FFF0000) >> 16); - NextInt123C = 3; - } - else if (((HonaData[Ind] & 0xF0000000) == 0x30000000) && (NextInt123C == 3)) - { - TempHonaPacketInt123C.DOA = (HonaData[Ind] & 0x0000FFFF); - TempHonaPacketInt123C.PA3 = ((HonaData[Ind] & 0x0FFF0000) >> 16); - NextInt123C = 4; - } - else if (((HonaData[Ind] & 0xF0000000) == 0x40000000) && (NextInt123C == 4)) - { - TempHonaPacketInt123C.PA1 = (HonaData[Ind] & 0x0000FFFF); - TempHonaPacketInt123C.PA2 += ((HonaData[Ind] & 0x000F0000) >> 4); - TempHonaPacketInt123C.PA3 += ((HonaData[Ind] & 0x00F00000) >> 8); - NextInt123C = 5; - } - else if (((HonaData[Ind] & 0xF0000000) == 0x50000000) && (NextInt123C == 5)) - { - TempHonaPacketInt123C.CodeM = ((ulong) (HonaData[Ind] & 0x0000001F)) << 59; - TempHonaPacketInt123C.CodeL = 0; - NextInt123C = 6; - } - else if (HonaData[Ind] == 0xEEEEEEEE) - { - //Console.Write("-"); - } - else - { - //Console.Write("."); - } - - if (NextInt123C == PacketLenInt123C) - { - if (Isvalid(TempHonaPacketInt123C)) - { - TempHonaPacketInt123C.TOA = (TempHonaPacketInt123C.TOA/8)/SimulationSpeed + toaStartBoard; - //toa converted to 100nsec - HonaPacketList.Add(TempHonaPacketInt123C); - } - NextInt123C = 0; - } - } - return LossFound; - + if(hp.getToa() <= 0) + return false; + return true; } + +/*************************************************************************************************/ diff --git a/Plx/src/LowLevel/HonaPacket.cpp b/Plx/src/LowLevel/HonaPacket.cpp index 5f6b5a8..dc61181 100755 --- a/Plx/src/LowLevel/HonaPacket.cpp +++ b/Plx/src/LowLevel/HonaPacket.cpp @@ -7,133 +7,133 @@ HonaPacket::HonaPacket() /*************************************************************************************************/ honaPacketType HonaPacket::getPacketType() { - return m_PacketType; + return m_PacketType; } void HonaPacket::setPacketType(honaPacketType temp) { - m_PacketType = temp; + m_PacketType = temp; } /*************************************************************************************************/ quint32 HonaPacket::getPacketNumber() { - return m_PacketNumber; + return m_PacketNumber; } void HonaPacket::setPacketNumber(quint32 temp) { - m_PacketNumber = temp; + m_PacketNumber = temp; } /*************************************************************************************************/ qulonglong HonaPacket::getToa() { - return m_Toa; + return m_Toa; } void HonaPacket::setToa(qulonglong temp) { - m_Toa = temp; + m_Toa = temp; } /*************************************************************************************************/ quint32 HonaPacket::getDoa() { - return m_Doa; + return m_Doa; } void HonaPacket::setDoa(quint32 temp) { - m_Doa = temp; + m_Doa = temp; } /*************************************************************************************************/ quint32 HonaPacket::getPa1() { - return m_Pa1; + return m_Pa1; } void HonaPacket::setPa1(quint32 temp) { - m_Pa1 = temp; + m_Pa1 = temp; } /*************************************************************************************************/ quint32 HonaPacket::getPa2() { - return m_Pa2; + return m_Pa2; } void HonaPacket::setPa2(quint32 temp) { - m_Pa2 = temp; + m_Pa2 = temp; } /*************************************************************************************************/ quint32 HonaPacket::getPa3() { - return m_Pa3; + return m_Pa3; } void HonaPacket::setPa3(quint32 temp) { - m_Pa3 = temp; + m_Pa3 = temp; } /*************************************************************************************************/ quint32 HonaPacket::getPa4() { - return m_Pa4; + return m_Pa4; } void HonaPacket::setPa4(quint32 temp) { - m_Pa4 = temp; + m_Pa4 = temp; } /*************************************************************************************************/ quint32 HonaPacket::getCode() { - return m_Code; + return m_Code; } void HonaPacket::setCode(quint32 temp) { - m_Code = temp; + m_Code = temp; } /*************************************************************************************************/ quint32 HonaPacket::getCodeL() { - return m_CodeL; + return m_CodeL; } void HonaPacket::setCodeL(quint32 temp) { - m_CodeL = temp; + m_CodeL = temp; } /*************************************************************************************************/ quint32 HonaPacket::getCodeM() { - return m_CodeM; + return m_CodeM; } void HonaPacket::setCodeM(quint32 temp) { - m_CodeM = temp; + m_CodeM = temp; } /*************************************************************************************************/ quint8 HonaPacket::getm4Status() { - return m4Status; + return m4Status; } void HonaPacket::setm4Status(quint8 temp) { - m4Status = temp; + m4Status = temp; } /*************************************************************************************************/ diff --git a/Plx/src/Wrapper/PlxWrapper.cpp b/Plx/src/Wrapper/PlxWrapper.cpp index ad98fb7..528f7cf 100755 --- a/Plx/src/Wrapper/PlxWrapper.cpp +++ b/Plx/src/Wrapper/PlxWrapper.cpp @@ -10,151 +10,150 @@ PlxWrapper::PlxWrapper() /*************************************************************************************************/ bool PlxWrapper::deviceInit(quint32 devicekey) { - return PlxPci_9054_SelDevice(devicekey); + return PlxPci_9054_SelDevice(devicekey); } /*************************************************************************************************/ bool PlxWrapper::deviceOpen() { - return PlxPci_9054_Open(); + return PlxPci_9054_Open(); } /*************************************************************************************************/ bool PlxWrapper::deviceClose() { - return PlxPci_9054_Close(); + return PlxPci_9054_Close(); } /*************************************************************************************************/ bool PlxWrapper::deviceReset() { - return PlxPci_9054_Reset(); + return PlxPci_9054_Reset(); } /*************************************************************************************************/ bool PlxWrapper::deviceLoadE2pToFPGA() { - return PlxPci_9054_LoadE2pToFPGA(); + return PlxPci_9054_LoadE2pToFPGA(); } /*************************************************************************************************/ bool PlxWrapper::deviceReadEeprom(quint16 offset, quint32 length, QVector& data) { - bool ret = true; - data.clear(); + bool ret = true; + data.clear(); - for(auto i = 0U; i < (length - 1) * 4; i += 4) - { - quint32 temp; - ret &= PlxPci_9054_ReadEep(offset + i, &temp); - data.append(temp); - } + for(auto i = 0U; i < (length - 1) * 4; i += 4) + { + quint32 temp; + ret &= PlxPci_9054_ReadEep(offset + i, &temp); + data.append(temp); + } - return ret; + return ret; } /*************************************************************************************************/ bool PlxWrapper::deviceWriteEeprom(quint16 offset, quint32 data) { - return PlxPci_9054_WriteEep(offset, data); + return PlxPci_9054_WriteEep(offset, data); } /*************************************************************************************************/ bool PlxWrapper::deviceReadRegister(quint32 address, QVector& data, quint32 length) { - bool ret = true; - data.clear(); + bool ret = true; + data.clear(); - quint32 temp[length]; - ret &= PlxPci_9054_ReadBar(address, &temp, length * 4); - if(ret == true) - { - for(auto i = 0U; i < length; i++) - { - data.append(temp[i]); - qDebug() << hex << temp[i]; - } - } + quint32 temp[length]; + ret &= PlxPci_9054_ReadBar(address, &temp, length * 4); + if(ret == true) + { + for(auto i = 0U; i < length; i++) + { + data.append(temp[i]); + } + } - return ret; + return ret; } /*************************************************************************************************/ bool PlxWrapper::deviceReadRegister(quint32 address, quint32& data) { - return PlxPci_9054_ReadBar(address, &data, 4); + return PlxPci_9054_ReadBar(address, &data, 4); } /*************************************************************************************************/ bool PlxWrapper::deviceWriteRegister(quint32 address, QVector& data) { - bool ret = true; - auto length = data.length(); - quint32 temp[length]; + bool ret = true; + auto length = data.length(); + quint32 temp[length]; - for(auto i = 0U; i < length; i++) - temp[i] = data.at(i); + for(auto i = 0U; i < length; i++) + temp[i] = data.at(i); - ret &= PlxPci_9054_WriteBar(address, &temp, length * 4); + ret &= PlxPci_9054_WriteBar(address, &temp, length * 4); - return ret; + return ret; } /*************************************************************************************************/ bool PlxWrapper::deviceWriteRegister(quint32 address, quint32 data) { - return PlxPci_9054_WriteBar(address, &data, 4); + return PlxPci_9054_WriteBar(address, &data, 4); } /*************************************************************************************************/ bool PlxWrapper::deviceReadMemory(quint32 localAddress, QVector& data, quint32 length) { - bool ret = true; - data.clear(); + bool ret = true; + data.clear(); - quint32 temp[length]; - ret &= PlxPci_9054_DMATransfer(localAddress, &temp, (quint32)(length * 4)); + quint32 temp[length]; + ret &= PlxPci_9054_DMATransfer(localAddress, &temp, (quint32)(length * 4)); - for(auto i = 0U; i < length; i++) - data.append(temp[i]); + for(auto i = 0U; i < length; i++) + data.append(temp[i]); - return ret; + return ret; } /*************************************************************************************************/ bool PlxWrapper::deviceOpenPCIChannel(void) { - return PlxPci_9054_DMAChannelOpen(); + return PlxPci_9054_DMAChannelOpen(); } /*************************************************************************************************/ bool PlxWrapper::deviceClosePCIChannel(void) { - return PlxPci_9054_DMAChannelClose(); + return PlxPci_9054_DMAChannelClose(); } /*************************************************************************************************/ bool PlxWrapper::deviceEnableInterrupt(void) { - return PlxPci_9054_EnableInterrupt(); + return PlxPci_9054_EnableInterrupt(); } /*************************************************************************************************/ bool PlxWrapper::deviceDisableInterrupt(void) { - return PlxPci_9054_DisableInterrupt(); + return PlxPci_9054_DisableInterrupt(); } /*************************************************************************************************/ bool PlxWrapper::deviceWaitForInterrupt(quint32 timeout) { - return PlxPci_9054_WaitForInterrupt(timeout); + return PlxPci_9054_WaitForInterrupt(timeout); } /*************************************************************************************************/ bool PlxWrapper::deviceGetChipType(quint8 revision, quint16 chipType) { - return PlxPci_9054_ChipTypeGet(revision, chipType); + return PlxPci_9054_ChipTypeGet(revision, chipType); } diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp index 54f24b5..6c4fadf 100755 --- a/Test/MainWindow.cpp +++ b/Test/MainWindow.cpp @@ -1,72 +1,75 @@ #include "MainWindow.h" #include "ui_MainWindow.h" -HonaAPI _honaAPI; + MainWindow::MainWindow(QWidget* parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) + : QMainWindow(parent) + , ui(new Ui::MainWindow) { - ui->setupUi(this); - connect(&_honaAPI, &HonaAPI::honaDataResult, this, &MainWindow::honaDataResultUi); + ui->setupUi(this); + connect(&_honaAPI, &HonaAPI::honaDataResult, this, &MainWindow::honaDataResultUi); } MainWindow::~MainWindow() { - delete ui; + delete ui; } /*************************************************************************************************/ -void MainWindow::honaDataResultUi(QList honaPacketList, quint32 hsruLoss, quint32 Doa) +void MainWindow::honaDataResultUi(QList &honaPacketList, quint32 hsruLoss, quint32 Doa) { - qDebug() << "honaDataResultUi inside " << honaPacketList.length(); - QString _str; - for(auto i = 0; i < honaPacketList.length(); i++) - { - _str = "[" + QString::number(i) + "] " + "0x hsruLoss" + QString::number(hsruLoss); - _str += "\n *********************************************"; - } + QString _str; + for(auto i = 0; i < honaPacketList.length(); i++) + { + _str += "\n[hsruLoss] :" + QString::number(hsruLoss, 16); + _str += "\n[getToa] :" + QString::number(honaPacketList[i].getToa(), 16); + _str += "\n[getDoa] :" + QString::number(honaPacketList[i].getDoa(), 16); + _str += "\n[getPa1] :" + QString::number(honaPacketList[i].getPa1(), 16); + _str += "\n[getPa2] :" + QString::number(honaPacketList[i].getPa2(), 16); + _str += "\n[getPa3] :" + QString::number(honaPacketList[i].getPa3(), 16); + _str += "\n[getPa4] :" + QString::number(honaPacketList[i].getPa4(), 16); + _str += "\n[getCode] :" + QString::number(honaPacketList[i].getCode(), 16); + _str += "\n[getCodeL] :" + QString::number(honaPacketList[i].getCodeL(), 16); + _str += "\n[getCodeM] :" + QString::number(honaPacketList[i].getCodeM(), 16); + } - ui->dataFromMemory->setText(_str); + ui->dataFromMemory->setText(_str); } void MainWindow::on_testPLX_clicked() { - ApiResult _resultInit = _honaAPI.init(); - //ApiResult _deviceReset = _honaAPI.deviceReset(); - //HonaSettings settings; - //ApiResult _configResult = _honaAPI.setConfig(settings); - //ApiResult isHsruStarted = _honaAPI.isHsruStarted(); - ApiResult _hsruStartResult = _honaAPI.hsruStart(); + ApiResult _resultInit = _honaAPI.init(); + ApiResult _hsruStartResult = _honaAPI.hsruStart(); - //******************************************************** - QString temp = ui->errorMonitoring->text(); - if(_resultInit == ApiResult::error) - { - ui->errorMonitoring->setText(temp + "\n" + " Error _resultInit"); - } - else if(_resultInit == ApiResult::success) - { - ui->errorMonitoring->setText(temp + "\n" + "success _resultInit"); - } - //******************************************************** + //******************************************************** + QString temp = ui->errorMonitoring->text(); + if(_resultInit == ApiResult::error) + { + ui->errorMonitoring->setText(temp + "\n" + " Error _resultInit"); + } + else if(_resultInit == ApiResult::success) + { + ui->errorMonitoring->setText(temp + "\n" + "success _resultInit"); + } + //******************************************************** - if(_hsruStartResult == ApiResult::error) - { - ui->errorMonitoring->setText(temp + "\n" + " Error _hsruStartResult"); - } - else if(_hsruStartResult == ApiResult::success) - { - ui->errorMonitoring->setText(temp + "\n" + " success _hsruStartResult"); - } - //******************************************************** + if(_hsruStartResult == ApiResult::error) + { + ui->errorMonitoring->setText(temp + "\n" + " Error _hsruStartResult"); + } + else if(_hsruStartResult == ApiResult::success) + { + ui->errorMonitoring->setText(temp + "\n" + " success _hsruStartResult"); + } + //******************************************************** } void MainWindow::on_stopHsru_clicked() { - QString temp = ui->errorMonitoring->text(); - ApiResult _hsruStop = _honaAPI.hsruStop(); - if(_hsruStop == ApiResult::error) - { - ui->errorMonitoring->setText(temp + "\n" + " success _hsruStartResult"); - } + QString temp = ui->errorMonitoring->text(); + ApiResult _hsruStop = _honaAPI.hsruStop(); + if(_hsruStop == ApiResult::error) + { + ui->errorMonitoring->setText(temp + "\n" + " success _hsruStartResult"); + } } diff --git a/Test/MainWindow.h b/Test/MainWindow.h index 9e218f4..b880172 100755 --- a/Test/MainWindow.h +++ b/Test/MainWindow.h @@ -10,29 +10,28 @@ QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; -} + } QT_END_NAMESPACE class MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT private: - Ui::MainWindow* ui; - int a; + Ui::MainWindow* ui; + HonaAPI _honaAPI; public: - MainWindow(QWidget* parent = nullptr); - ~MainWindow(); + MainWindow(QWidget* parent = nullptr); + ~MainWindow(); - //uncrustify off + //uncrustify off private slots: - void honaDataResultUi(QList honaPacketList, quint32 hsruLoss, quint32 Doa); - void on_testPLX_clicked(); - void on_stopHsru_clicked(); - //uncrustify on: -private: - //HonaAPI _honaAPI; + void honaDataResultUi(QList &honaPacketList, quint32 hsruLoss, quint32 Doa); + void on_testPLX_clicked(); + void on_stopHsru_clicked(); + //uncrustify on: + }; #endif //MAINWINDOW_H diff --git a/Test/MainWindow.ui b/Test/MainWindow.ui index a9148d8..3c00688 100755 --- a/Test/MainWindow.ui +++ b/Test/MainWindow.ui @@ -70,11 +70,17 @@ 50 - 160 + 140 451 - 261 + 301 + + Qt::ScrollBarAlwaysOn + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + diff --git a/Test/Test.pro b/Test/Test.pro index b5c986c..432718d 100755 --- a/Test/Test.pro +++ b/Test/Test.pro @@ -35,6 +35,7 @@ qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + unix:!macx: LIBS += -L$$PWD/../../Plxlibrary/Library/ -lPlxApi INCLUDEPATH += $$PWD/../../Plxlibrary/Library @@ -44,3 +45,4 @@ INCLUDEPATH += $$PWD/../../Plxlibrary DEPENDPATH += $$PWD/../../Plxlibrary unix:!macx: PRE_TARGETDEPS += $$PWD/../../Plxlibrary/Library/libPlxApi.a + diff --git a/Test/main.cpp b/Test/main.cpp index 723a9ab..a866c7e 100755 --- a/Test/main.cpp +++ b/Test/main.cpp @@ -5,6 +5,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + MainWindow w; w.show(); return a.exec(); diff --git a/ignore.save b/ignore.save new file mode 100644 index 0000000..75c107b --- /dev/null +++ b/ignore.save @@ -0,0 +1 @@ +*.pro.user