From 34d188c6c16149c42efa51a0aeeac765c4deda5f Mon Sep 17 00:00:00 2001 From: mehrabi Date: Sat, 18 Dec 2021 02:49:33 -0500 Subject: [PATCH] delete Test2 folder --- .gitignore | 0 Plx/Plx.pro | 19 +- Plx/include/API/.gitKeep | 0 Plx/include/LowLevel/Exception/.gitKeep | 0 .../Exception/HonaAlreadyStartedException.h | 0 .../LowLevel/Exception/HonaBusyException.h | 0 .../LowLevel/Exception/HonaException.h | 0 Plx/include/LowLevel/HonaLowLevelAPI.h | 21 +- Plx/include/LowLevel/HonaPacket.h | 0 Plx/include/LowLevel/Setting/.gitKeep | 0 Plx/include/LowLevel/Setting/Setting.h | 0 Plx/include/LowLevel/Utils/.gitKeep | 0 Plx/include/LowLevel/Utils/Utils.h | 9 +- Plx/include/Wrapper/.gitKeep | 0 Plx/include/Wrapper/PlxWrapper.h | 45 ++-- Plx/src/API/.gitKeep | 0 Plx/src/LowLevel/.gitKeep | 0 Plx/src/LowLevel/HonaLowLevelAPI.cpp | 200 +++++++++++++++--- Plx/src/LowLevel/HonaPacket.cpp | 0 Plx/src/LowLevel/Setting/.gitKeep | 0 Plx/src/LowLevel/Utils/.gitKeep | 0 Plx/src/Wrapper/.gitKeep | 0 Plx/src/Wrapper/PlxWrapper.cpp | 0 PlxBoard.pro | 0 Test/MainWindow.cpp | 0 Test/MainWindow.h | 0 Test/MainWindow.ui | 0 Test/Test.pro | 0 Test/main.cpp | 0 29 files changed, 231 insertions(+), 63 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 Plx/Plx.pro mode change 100644 => 100755 Plx/include/API/.gitKeep mode change 100644 => 100755 Plx/include/LowLevel/Exception/.gitKeep mode change 100644 => 100755 Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h mode change 100644 => 100755 Plx/include/LowLevel/Exception/HonaBusyException.h mode change 100644 => 100755 Plx/include/LowLevel/Exception/HonaException.h mode change 100644 => 100755 Plx/include/LowLevel/HonaLowLevelAPI.h mode change 100644 => 100755 Plx/include/LowLevel/HonaPacket.h mode change 100644 => 100755 Plx/include/LowLevel/Setting/.gitKeep mode change 100644 => 100755 Plx/include/LowLevel/Setting/Setting.h mode change 100644 => 100755 Plx/include/LowLevel/Utils/.gitKeep mode change 100644 => 100755 Plx/include/LowLevel/Utils/Utils.h mode change 100644 => 100755 Plx/include/Wrapper/.gitKeep mode change 100644 => 100755 Plx/src/API/.gitKeep mode change 100644 => 100755 Plx/src/LowLevel/.gitKeep mode change 100644 => 100755 Plx/src/LowLevel/HonaLowLevelAPI.cpp mode change 100644 => 100755 Plx/src/LowLevel/HonaPacket.cpp mode change 100644 => 100755 Plx/src/LowLevel/Setting/.gitKeep mode change 100644 => 100755 Plx/src/LowLevel/Utils/.gitKeep mode change 100644 => 100755 Plx/src/Wrapper/.gitKeep mode change 100644 => 100755 Plx/src/Wrapper/PlxWrapper.cpp mode change 100644 => 100755 PlxBoard.pro mode change 100644 => 100755 Test/MainWindow.cpp mode change 100644 => 100755 Test/MainWindow.h mode change 100644 => 100755 Test/MainWindow.ui mode change 100644 => 100755 Test/Test.pro mode change 100644 => 100755 Test/main.cpp diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Plx/Plx.pro b/Plx/Plx.pro old mode 100644 new mode 100755 index 82f08e8..9aab6b0 --- a/Plx/Plx.pro +++ b/Plx/Plx.pro @@ -17,18 +17,27 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ - $$files(*.cpp, true) \ \ - src/Wrapper/PlxWrapper.cpp - + $$files(*.cpp, true) HEADERS += \ - $$files(*.h, true) \ + $$files(*.h, true) INCLUDEPATH += $$PWD/include - # Default rules for deployment. unix { target.path = $$[QT_INSTALL_PLUGINS]/generic } !isEmpty(target.path): INSTALLS += target + + + +unix:!macx: LIBS += -L$$PWD/../../Plxlibrary/Library/ -lPlxApi + +INCLUDEPATH += $$PWD/../../Plxlibrary/Library +DEPENDPATH += $$PWD/../../Plxlibrary/Library + +INCLUDEPATH += $$PWD/../../Plxlibrary +DEPENDPATH += $$PWD/../../Plxlibrary + +unix:!macx: PRE_TARGETDEPS += $$PWD/../../Plxlibrary/Library/libPlxApi.a diff --git a/Plx/include/API/.gitKeep b/Plx/include/API/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Exception/.gitKeep b/Plx/include/LowLevel/Exception/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h b/Plx/include/LowLevel/Exception/HonaAlreadyStartedException.h old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Exception/HonaBusyException.h b/Plx/include/LowLevel/Exception/HonaBusyException.h old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Exception/HonaException.h b/Plx/include/LowLevel/Exception/HonaException.h old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h old mode 100644 new mode 100755 index 85aa18a..69b4cd9 --- a/Plx/include/LowLevel/HonaLowLevelAPI.h +++ b/Plx/include/LowLevel/HonaLowLevelAPI.h @@ -9,7 +9,11 @@ #include "HonaPacket.h" #include "QWaitCondition" #include "QMutex" -#include "include/LowLevel/Exception/HonaAlreadyStartedException.h" + + +#include "include/LowLevel/HonaPacket.h" +#include "include/Wrapper/PlxWrapper.h" + class HonaLowLevelAPI : public QObject { @@ -24,7 +28,16 @@ private: int _threadSforValue = 0; bool _isReaderThreadFree = false; bool _isUpdateThreadFree = false; - quint32 honaRegisterBuffer[8]; + QVector honaRegisterBuffer; + QList honaPacketList; + PlxWrapper plxwrapper; + + quint32 hsruLoss = 0; + + static quint32 packetLenInt123C; + static quint32 packetLenRes123C; + static quint32 packetLenIntS; + static quint32 packetLenResS; public: explicit HonaLowLevelAPI(QObject* parent = nullptr); @@ -55,6 +68,10 @@ private: void hsruUpdateThread(); int hiruGetDOA(); + void hsruReaderMethod(); + QVector hsruReadHonaBuffer(honaReceivers receiver); + quint32 hsruParserInt123C(quint32 honaData,QList honaPacketList); + signals: void signalToTop(QList honaPacketList, int i, int j); //uncrustify off diff --git a/Plx/include/LowLevel/HonaPacket.h b/Plx/include/LowLevel/HonaPacket.h old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Setting/.gitKeep b/Plx/include/LowLevel/Setting/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Setting/Setting.h b/Plx/include/LowLevel/Setting/Setting.h old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Utils/.gitKeep b/Plx/include/LowLevel/Utils/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/include/LowLevel/Utils/Utils.h b/Plx/include/LowLevel/Utils/Utils.h old mode 100644 new mode 100755 index 2eb3411..07a69e0 --- a/Plx/include/LowLevel/Utils/Utils.h +++ b/Plx/include/LowLevel/Utils/Utils.h @@ -2,6 +2,7 @@ #define UTILS_H #include + /*************************************************************************************************/ enum apiResult : quint8 { @@ -21,11 +22,13 @@ enum drxDeviceIfChannel : quint8 enum honaReceivers : quint8 { int123C, + res123C, intS, resS, int4, //Mode 4 res4, //Mode 4 - signalPulse //Mode 4 + singlePulse //Mode 4 + }; /*************************************************************************************************/ enum recorderMode : quint8 @@ -58,8 +61,4 @@ enum honaPacketType : quint8 }; /*************************************************************************************************/ - - - - #endif // UTILS_H diff --git a/Plx/include/Wrapper/.gitKeep b/Plx/include/Wrapper/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/include/Wrapper/PlxWrapper.h b/Plx/include/Wrapper/PlxWrapper.h index 9286ead..f333c4e 100755 --- a/Plx/include/Wrapper/PlxWrapper.h +++ b/Plx/include/Wrapper/PlxWrapper.h @@ -1,34 +1,33 @@ #ifndef PLXWRAPPER_H #define PLXWRAPPER_H - #include -#include "../../plxlib/plxinc/PlxPci_9054_Func.h" - +#include "PlxPci_9054_Func.h" class PlxWrapper { public: - PlxWrapper(); + PlxWrapper(); - bool deviceInit(quint32 devicekey); - bool deviceOpen(void); - bool deviceClose(void); - bool deviceReset(void); - bool deviceLoadE2pToFPGA(void); + 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 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 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); + 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 + +#endif //PLXWRAPPER_H diff --git a/Plx/src/API/.gitKeep b/Plx/src/API/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/src/LowLevel/.gitKeep b/Plx/src/LowLevel/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp old mode 100644 new mode 100755 index a176796..b5561c9 --- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp +++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp @@ -5,7 +5,6 @@ #include "qdebug.h" #include "QTime" #include "QtConcurrent/QtConcurrent" -PlxWrapper plx; bool HonaLowLevelAPI::getHsruIsStarted() const { @@ -126,33 +125,34 @@ void HonaLowLevelAPI::init() /*************************************************************************************************/ void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings) { - honaRegisterBuffer[0] = 0x00000000; - /************************************************************************/ - if(settings.hiruSettings.recordStard == recorderStart::selfTestCounter) - honaRegisterBuffer[0] = 0x80000000; - else - honaRegisterBuffer[0] = 0x7FFFFFFF; - /************************************************************************/ - if(settings.hiruSettings.recordChannel == drxDeviceIfChannel::ifChannel12) - honaRegisterBuffer[0] = 0x20000000; - else - honaRegisterBuffer[0] = 0xDFFFFFFF; - /************************************************************************/ - if(settings.hiruSettings.recordMode == recorderMode::dualChannel) - honaRegisterBuffer[0] = 0x10000000; - else - honaRegisterBuffer[0] = 0xEFFFFFFF; - /************************************************************************/ - - honaRegisterBuffer[0] += (settings.hiruSettings.threshold & 0x00000FFF); - - honaRegisterBuffer[1] = settings.hsruSettings.honaInt123CTHR; - honaRegisterBuffer[2] = settings.hsruSettings.honaRes123CTHR; - honaRegisterBuffer[3] = settings.hsruSettings.honaIntSTHR; - honaRegisterBuffer[4] = settings.hsruSettings.honaResSTHR; - honaRegisterBuffer[5] = settings.hsruSettings.honaSPTHR; - honaRegisterBuffer[6] = settings.hsruSettings.intM4_THR; - honaRegisterBuffer[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); } /*************************************************************************************************/ @@ -210,3 +210,147 @@ int HonaLowLevelAPI::hiruGetDOA() } /*************************************************************************************************/ +/*************************************************************************************************/ + + + + + + +void HonaLowLevelAPI::hsruReaderMethod() +{ + DateTime dtStartSim = DateTime.Now; + hsruLoss = 0; + while (true) + { + if (_honaSettings.hsruSettings.isReal) + { + 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(); + } + + hsruReadDone.Set(); + hsruUpdateAck.WaitOne(); + } +} + +/*************************************************************************************************/ +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)// Mode4 :: added by H.H + address = 0X90000000; + else if (receiver == honaReceivers::res4)// Mode4 :: added by H.H + address = 0XA0000000; + else if (receiver == honaReceivers::singlePulse)// Mode4 :: added by H.H + address = 0XB0000000; + + else + return false; + + plxwrapper.deviceReadMemory(address, honaData,honaData.size()); + + //TODO for test (Debug) + WriteToFile(Receiver, honaData); + + return honaData; +} +/*************************************************************************************************/ + +quint32 hsruParserInt123C(QVector honaData,QList honaPacketList) +{ + 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; + + +} diff --git a/Plx/src/LowLevel/HonaPacket.cpp b/Plx/src/LowLevel/HonaPacket.cpp old mode 100644 new mode 100755 diff --git a/Plx/src/LowLevel/Setting/.gitKeep b/Plx/src/LowLevel/Setting/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/src/LowLevel/Utils/.gitKeep b/Plx/src/LowLevel/Utils/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/src/Wrapper/.gitKeep b/Plx/src/Wrapper/.gitKeep old mode 100644 new mode 100755 diff --git a/Plx/src/Wrapper/PlxWrapper.cpp b/Plx/src/Wrapper/PlxWrapper.cpp old mode 100644 new mode 100755 diff --git a/PlxBoard.pro b/PlxBoard.pro old mode 100644 new mode 100755 diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp old mode 100644 new mode 100755 diff --git a/Test/MainWindow.h b/Test/MainWindow.h old mode 100644 new mode 100755 diff --git a/Test/MainWindow.ui b/Test/MainWindow.ui old mode 100644 new mode 100755 diff --git a/Test/Test.pro b/Test/Test.pro old mode 100644 new mode 100755 diff --git a/Test/main.cpp b/Test/main.cpp old mode 100644 new mode 100755