Browse Source

work on honaapilowlevel honaapi

heydari
Alireza 3 years ago
parent
commit
e806f5dca5
  1. 13
      Plx/Plx.pro
  2. 40
      Plx/include/API/HonaAPI.h
  3. 1
      Plx/include/LowLevel/HonaLowLevelAPI.h
  4. 6
      Plx/include/LowLevel/HonaPacket.h
  5. 62
      Plx/include/LowLevel/HonaPacket.h.autosave
  6. 2
      Plx/include/LowLevel/Utils/Utils.h
  7. 183
      Plx/src/API/HonaAPI.cpp
  8. 165
      Plx/src/LowLevel/HonaLowLevelAPI.cpp
  9. 2
      PlxBoard.pro
  10. 13
      Test/MainWindow.cpp
  11. 18
      Test/MainWindow.h
  12. 44
      Test/MainWindow.ui
  13. 5
      Test/Test.pro
  14. 8
      Test/main.cpp

13
Plx/Plx.pro

@ -17,12 +17,15 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \ SOURCES += \
$$files(*.cpp, true) \ \ $$files(*.cpp, true) \ \ \
src/Wrapper/PlxWrapper.cpp
HEADERS += \ HEADERS += \
$$files(*.h, true) \ $$files(*.h, true) \ \ \
INCLUDEPATH += $$PWD/include INCLUDEPATH += $$PWD/include
@ -32,3 +35,7 @@ unix {
target.path = $$[QT_INSTALL_PLUGINS]/generic target.path = $$[QT_INSTALL_PLUGINS]/generic
} }
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target

40
Plx/include/API/HonaAPI.h

@ -0,0 +1,40 @@
#ifndef HONAAPI_H
#define HONAAPI_H
#include <QObject>
#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"
class HonaAPI : public QObject
{
Q_OBJECT
private:
HonaLowLevelAPI _honaLowLevelAPI;
public:
explicit HonaAPI(QObject* parent = nullptr);
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:
//uncrustify off
public slots:
//uncrustify on
};
#endif //HONAAPI_H

1
Plx/include/LowLevel/HonaLowLevelAPI.h

@ -89,6 +89,7 @@ public:
QString getDeviceId(); QString getDeviceId();
void hsruStart(); void hsruStart();
void hiruStart(); void hiruStart();
void hsruStop();
void init(); void init();
bool getHsruIsStarted() const; bool getHsruIsStarted() const;

6
Plx/include/LowLevel/HonaPacket.h

@ -20,12 +20,13 @@ private:
quint32 m_Code; quint32 m_Code;
quint32 m_CodeL; quint32 m_CodeL;
quint32 m_CodeM; quint32 m_CodeM;
quint8 m4Status;
public: public:
HonaPacket(); HonaPacket();
/******************************************************************/ /******************************************************************/
honaPacketType getPacketType(); honaPacketType getPacketType();
void setPacketType(honaPacketType& temp); void setPacketType(honaPacketType temp);
/******************************************************************/ /******************************************************************/
quint32 getPacketNumber(); quint32 getPacketNumber();
void setPacketNumber(quint32 temp); void setPacketNumber(quint32 temp);
@ -57,6 +58,9 @@ public:
quint32 getCodeM(); quint32 getCodeM();
void setCodeM(quint32 temp); void setCodeM(quint32 temp);
/******************************************************************/ /******************************************************************/
quint8 getm4Status();
void setm4Status(quint8 temp);
/******************************************************************/
}; };
#endif //HONAPACKET_H #endif //HONAPACKET_H

62
Plx/include/LowLevel/HonaPacket.h.autosave

@ -1,62 +0,0 @@
#ifndef HONAPACKET_H
#define HONAPACKET_H
#include <QtGlobal>
#include "include/LowLevel/Utils/Utils.h"
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;
quint32 m_CodeL;
quint32 m_CodeM;
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);
/******************************************************************/
};
#endif //HONAPACKET_H

2
Plx/include/LowLevel/Utils/Utils.h

@ -4,7 +4,7 @@
#include <QtCore> #include <QtCore>
/*************************************************************************************************/ /*************************************************************************************************/
enum apiResult : quint8 enum ApiResult : quint8
{ {
success, success,
alreadyStarted, alreadyStarted,

183
Plx/src/API/HonaAPI.cpp

@ -0,0 +1,183 @@
#include "include/API/HonaAPI.h"
HonaAPI::HonaAPI(QObject* parent) : QObject(parent)
{
}
/*************************************************************************************************/
ApiResult HonaAPI::isHsruStarted()
{
try {
if(_honaLowLevelAPI.isHsruStarted())
return ApiResult::success;
}
catch(HonaException ex)
{
return ApiResult::error;
}
}
/*************************************************************************************************/
ApiResult HonaAPI::isHiruStarted()
{
try {
if(_honaLowLevelAPI.isHiruStarted())
return ApiResult::success;
}
catch(HonaException ex)
{
return ApiResult::error;
}
}
/*************************************************************************************************/
ApiResult HonaAPI::deviceReset()
{
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;
}
/*************************************************************************************************/
ApiResult HonaAPI::getConfig(HonaSettings& settings)
{
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;
}
/*************************************************************************************************/
ApiResult HonaAPI::getDeviceId(QString& deviceId)
{
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;
}
/*************************************************************************************************/
ApiResult HonaAPI::hiruStart()
{
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;
}
/*************************************************************************************************/
ApiResult HonaAPI::init()
{
try {
_honaLowLevelAPI.init();
}
catch(HonaException ex)
{
return ApiResult::error;
}
catch(HonaAlreadyStartedException ex)
{
return ApiResult::error;
}
return ApiResult::success;
}
/*************************************************************************************************/

165
Plx/src/LowLevel/HonaLowLevelAPI.cpp

@ -56,17 +56,27 @@ bool HonaLowLevelAPI::isHiruStarted()
void HonaLowLevelAPI::deviceReset() void HonaLowLevelAPI::deviceReset()
{ {
if(!plxWrapper.deviceReset()) if(!plxWrapper.deviceReset())
throw HonaAlreadyStartedException("reset Doesnt Occur"); throw HonaAlreadyStartedException("Reset Doesnt Occur");
} }
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::setConfig(HonaSettings& settings) void HonaLowLevelAPI::setConfig(HonaSettings& settings)
{ {
plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8); if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
{
throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
}
_honaSetting = settings; _honaSetting = settings;
writeSettingToRegisters(settings); writeSettingToRegisters(settings);
plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer); if(!plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer))
plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8); {
throw HonaAlreadyStartedException("DeviceWriteRegister Doesnt Occur");
}
if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
{
throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
}
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -92,7 +102,7 @@ QString HonaLowLevelAPI::getDeviceId()
void HonaLowLevelAPI::hsruStart() void HonaLowLevelAPI::hsruStart()
{ {
if(!isHsruStarted()) if(!isHsruStarted())
throw HonaAlreadyStartedException("HsruStarted doesn't started "); throw HonaException("HsruStarted doesn't started ");
QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread); QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
setHsruIsStarted(true); setHsruIsStarted(true);
} }
@ -101,14 +111,26 @@ void HonaLowLevelAPI::hsruStart()
void HonaLowLevelAPI::hiruStart() void HonaLowLevelAPI::hiruStart()
{ {
if(!isHiruStarted()) if(!isHiruStarted())
throw HonaAlreadyStartedException("HiruStarted doesn't started "); throw HonaException("HiruStarted doesn't started ");
QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread); QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread);
setHiruIsStarted(true); setHiruIsStarted(true);
} }
/*************************************************************************************************/
void HonaLowLevelAPI::hsruStop()
{
if(isHiruStarted())
setHsruIsStarted(false);
_hsruStopEvent.wakeAll();
}
/*************************************************************************************************/ /*************************************************************************************************/
void HonaLowLevelAPI::init() void HonaLowLevelAPI::init()
{ {
if(!plxWrapper.deviceInit(0X9054))
{
throw HonaAlreadyStartedException("Init Doesnt Occur");
}
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -134,8 +156,8 @@ void HonaLowLevelAPI::writeSettingToRegisters(HonaSettings& settings)
/************************************************************************/ /************************************************************************/
honaRegisterBuffer.insert(0, honaRegisterBuffer.insert(0,
(honaRegisterBuffer.at(0) + (honaRegisterBuffer.at(0) +
(settings.hiruSettings.threshold & 0x00000FFF))); (settings.hiruSettings.threshold & 0x00000FFF)));
honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR); honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR);
honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR); honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR);
@ -160,7 +182,10 @@ void HonaLowLevelAPI::hsruMainThread()
deviceReset(); deviceReset();
setConfig(); setConfig();
deviceReset(); deviceReset();
plxWrapper.deviceEnableInterrupt(); if(!plxWrapper.deviceEnableInterrupt())
{
throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
}
QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread); QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread); QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
@ -169,7 +194,7 @@ void HonaLowLevelAPI::hsruMainThread()
{ {
_isHsruReaderThreadFree = true; _isHsruReaderThreadFree = true;
_isHsruUpdateThreadFree = true; _isHsruUpdateThreadFree = true;
setHiruIsStarted(false); hsruStop();
} }
_mutex.lock(); _mutex.lock();
@ -178,7 +203,10 @@ void HonaLowLevelAPI::hsruMainThread()
_isHsruReaderThreadFree = true; _isHsruReaderThreadFree = true;
_isHsruUpdateThreadFree = true; _isHsruUpdateThreadFree = true;
plxWrapper.deviceDisableInterrupt(); if(!plxWrapper.deviceDisableInterrupt())
{
throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
}
} }
/*************************************************************************************************/ /*************************************************************************************************/
@ -190,23 +218,35 @@ void HonaLowLevelAPI::hsruReadThread()
if(_isHsruReaderThreadFree) if(_isHsruReaderThreadFree)
break; break;
plxWrapper.deviceWaitForInterrupt(1000); if(!plxWrapper.deviceWaitForInterrupt(1000))
{
throw HonaAlreadyStartedException("DeviceWaitForInterrupt Doesnt Occur");
}
honaPacketList.clear(); honaPacketList.clear();
_hsruLoss = 0; _hsruLoss = 0;
plxWrapper.deviceOpenPCIChannel(); if(!plxWrapper.deviceOpenPCIChannel())
{
throw HonaAlreadyStartedException("DeviceOpenPCIChannel Doesnt Occur");
}
_hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C), _hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C),
honaPacketList); honaPacketList);
_hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C), _hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C),
honaPacketList); honaPacketList);
_hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList); _hsruLoss += hsruParserIntS(hsruReadHonaBuffer(honaReceivers::intS), honaPacketList);
_hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList); _hsruLoss += hsruParserResS(hsruReadHonaBuffer(honaReceivers::resS), honaPacketList);
_hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList); _hsruLoss += hsruParserInt4(hsruReadHonaBuffer(honaReceivers::int4), honaPacketList);
_hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList); _hsruLoss += hsruParserRes4(hsruReadHonaBuffer(honaReceivers::res4), honaPacketList);
_hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse), _hsruLoss += hsruParserSinglePulse(hsruReadHonaBuffer(honaReceivers::singlePulse),
honaPacketList); honaPacketList);
plxWrapper.deviceClosePCIChannel(); if(!plxWrapper.deviceClosePCIChannel())
plxWrapper.deviceEnableInterrupt(); {
throw HonaAlreadyStartedException("DeviceClosePCIChannel Doesnt Occur");
}
if(!plxWrapper.deviceEnableInterrupt())
{
throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
}
_mutex.lock(); _mutex.lock();
_hsruReadDone.wakeAll(); _hsruReadDone.wakeAll();
@ -242,9 +282,6 @@ void HonaLowLevelAPI::hiruMainThread()
_mutex.lock(); _mutex.lock();
_hsruStopEvent.wait(&_mutex); _hsruStopEvent.wait(&_mutex);
_mutex.unlock(); _mutex.unlock();
//_isReaderThreadFree = true;
//_isUpdateThreadFree = true;
} }
} }
@ -262,7 +299,10 @@ void HonaLowLevelAPI::hiruUpdateThread()
quint32 HonaLowLevelAPI::hiruGetDOA() quint32 HonaLowLevelAPI::hiruGetDOA()
{ {
quint32 Doa = 0; quint32 Doa = 0;
plxWrapper.deviceReadRegister(0x30000004, Doa); if(!plxWrapper.deviceReadRegister(0x30000004, Doa))
{
throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
}
Doa = Doa & 0x0000FFFF; Doa = Doa & 0x0000FFFF;
return Doa; return Doa;
@ -270,7 +310,7 @@ quint32 HonaLowLevelAPI::hiruGetDOA()
/*************************************************************************************************/ /*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
quint32 lossFound; quint32 lossFound;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++) for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -282,7 +322,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
packetLenInt123C = 6; packetLenInt123C = 6;
tempHonaPacketInt123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketInt123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
if((tempHonaPacketInt123C.getPacketNumber() != if((tempHonaPacketInt123C.getPacketNumber() !=
(lastPNInt123C + 1)) & (lastPNInt123C > 0)) (lastPNInt123C + 1)) & (lastPNInt123C > 0))
//& (LastPNInt123C != 65535)) //& (LastPNInt123C != 65535))
{ {
lossFound += lossFound +=
@ -301,7 +341,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt123C == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt123C == 2))
{ {
tempHonaPacketInt123C.setToa(((tempHonaPacketInt123C.getToa()) + tempHonaPacketInt123C.setToa(((tempHonaPacketInt123C.getToa()) +
(qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28))); (qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28)));
tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextInt123C = 3; nextInt123C = 3;
@ -350,7 +390,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
/*************************************************************************************************/ /*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
quint32 lossFound = 0; quint32 lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++) for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -361,7 +401,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
packetLenRes123C = 6; packetLenRes123C = 6;
tempHonaPacketRes123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketRes123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
if((tempHonaPacketRes123C.getPacketNumber() != if((tempHonaPacketRes123C.getPacketNumber() !=
(lastPNRes123C + 1)) & (lastPNRes123C > 0)) (lastPNRes123C + 1)) & (lastPNRes123C > 0))
//& (LastPNRes123C != 65535)) //& (LastPNRes123C != 65535))
{ {
lossFound += lossFound +=
@ -380,7 +420,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes123C == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes123C == 2))
{ {
tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() + tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() +
(((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28)); (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
tempHonaPacketRes123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketRes123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextRes123C = 3; nextRes123C = 3;
} }
@ -394,9 +434,9 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
{ {
tempHonaPacketRes123C.setPa1(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketRes123C.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() + tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() +
((honaData.at(Ind) & 0x000F0000) >> 4)); ((honaData.at(Ind) & 0x000F0000) >> 4));
tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() + tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 8)); ((honaData.at(Ind) & 0x00F00000) >> 8));
nextRes123C = 5; nextRes123C = 5;
} }
else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextRes123C == 5)) else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextRes123C == 5))
@ -430,7 +470,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
/*************************************************************************************************/ /*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
uint lossFound = 0; uint lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++) for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -468,7 +508,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextIntS == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextIntS == 2))
{ {
tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() + tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() +
(((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28)); (((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
tempHonaPacketIntS.setToa((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketIntS.setToa((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextIntS = 3; nextIntS = 3;
} }
@ -479,13 +519,13 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
nextIntS = 4; nextIntS = 4;
} }
else if(((honaData.at(static_cast<int>(Ind)) & 0xF0000000) == 0x40000000) && else if(((honaData.at(static_cast<int>(Ind)) & 0xF0000000) == 0x40000000) &&
(nextIntS == 4)) (nextIntS == 4))
{ {
tempHonaPacketIntS.setPa1(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketIntS.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData.at( tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData.at(
Ind) & 0x000F0000))); Ind) & 0x000F0000)));
tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() + tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 4)); ((honaData.at(Ind) & 0x00F00000) >> 4));
nextIntS = 5; nextIntS = 5;
} }
else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextIntS == 5)) else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextIntS == 5))
@ -497,7 +537,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextIntS == 6)) else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextIntS == 6))
{ {
tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36); ((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
tempHonaPacketIntS.setCodeL(0); tempHonaPacketIntS.setCodeL(0);
nextIntS = 7; nextIntS = 7;
} }
@ -510,7 +550,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextIntS == 8)) else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextIntS == 8))
{ {
tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36); ((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
nextIntS = 9; nextIntS = 9;
} }
else if(honaData.at(Ind) == 0xEEEEEEEE) else if(honaData.at(Ind) == 0xEEEEEEEE)
@ -538,7 +578,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
/*************************************************************************************************/ /*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
uint lossFound = 0; uint lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++) for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -576,8 +616,8 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextResS == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextResS == 2))
{ {
tempHonaPacketResS.setDoa(tempHonaPacketResS.getDoa() + tempHonaPacketResS.setDoa(tempHonaPacketResS.getDoa() +
((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) << ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
28)); 28));
tempHonaPacketResS.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketResS.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextResS = 3; nextResS = 3;
} }
@ -593,7 +633,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData.at( tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData.at(
Ind) & 0x000F0000))); Ind) & 0x000F0000)));
tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() + tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 4)); ((honaData.at(Ind) & 0x00F00000) >> 4));
nextResS = 5; nextResS = 5;
} }
else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextResS == 5)) else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextResS == 5))
@ -606,7 +646,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextResS == 6)) else if(((honaData.at(Ind) & 0xF0000000) == 0x60000000) && (nextResS == 6))
{ {
tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
(static_cast<qulonglong>(honaData.at( (static_cast<qulonglong>(honaData.at(
Ind) & 0x0FFFFFFF)) << 36); Ind) & 0x0FFFFFFF)) << 36);
tempHonaPacketResS.setCodeL(0); tempHonaPacketResS.setCodeL(0);
nextResS = 7; nextResS = 7;
@ -621,7 +661,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextResS == 8)) else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextResS == 8))
{ {
tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
(static_cast<qulonglong>(honaData.at( (static_cast<qulonglong>(honaData.at(
Ind) & 0x0FFFFFFF)) << 36); Ind) & 0x0FFFFFFF)) << 36);
nextResS = 9; nextResS = 9;
} }
@ -650,7 +690,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
/*************************************************************************************************/ /*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
uint lossFound = 0; uint lossFound = 0;
@ -679,8 +719,8 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt4 == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt4 == 2))
{ {
tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() + tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() +
((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) << ((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
28)); 28));
tempHonaPacketInt4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketInt4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextInt4 = 3; nextInt4 = 3;
} }
@ -694,9 +734,9 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
{ {
tempHonaPacketInt4.setPa1(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketInt4.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() + tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() +
((honaData.at(Ind) & 0x000F0000) >> 4)); ((honaData.at(Ind) & 0x000F0000) >> 4));
tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() + tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 8)); ((honaData.at(Ind) & 0x00F00000) >> 8));
nextInt4 = 5; nextInt4 = 5;
} }
else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt4 == 5)) else if(((honaData.at(Ind) & 0xF0000000) == 0x50000000) && (nextInt4 == 5))
@ -709,9 +749,9 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
{ {
tempHonaPacketInt4.setPa4(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketInt4.setPa4(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() + tempHonaPacketInt4.setCodeL(tempHonaPacketInt4.getCodeL() +
((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) << ((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) <<
12)); 12));
tempHonaPacketInt4.M4Status = ((byte)((honaData.at(Ind) & 0x0F000000) >> 20)); tempHonaPacketInt4.setm4Status((quint8)((honaData.at(Ind) & 0x0F000000) >> 20));
nextInt4 = 7; nextInt4 = 7;
} }
else if(honaData.at(Ind) == 0xEEEEEEEE) else if(honaData.at(Ind) == 0xEEEEEEEE)
@ -738,7 +778,7 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
} }
quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
uint lossFound = 0; uint lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++) for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -766,8 +806,8 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes4 == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes4 == 2))
{ {
tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() + tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() +
(static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) << (static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) <<
28)); 28));
tempHonaPacketRes4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketRes4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextRes4 = 3; nextRes4 = 3;
} }
@ -811,7 +851,7 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
/*************************************************************************************************/ /*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData, quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList) QList<HonaPacket> honaPacketList)
{ {
uint lossFound = 0; uint lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++) for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -822,7 +862,7 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
packetLenSinglePulse = 5; packetLenSinglePulse = 5;
tempHonaPacketSinglePulse.setPacketNumber(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketSinglePulse.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
if((tempHonaPacketSinglePulse.getPacketNumber() != if((tempHonaPacketSinglePulse.getPacketNumber() !=
(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0)) (lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
; ;
{ {
lossFound += lossFound +=
@ -838,14 +878,14 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1)) else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1))
{ {
tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData.at(Ind) & tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData.at(Ind) &
0x0FFFFFFF)); 0x0FFFFFFF));
nextSinglePulse = 2; nextSinglePulse = 2;
} }
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2)) else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2))
{ {
tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() + tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() +
((static_cast<qulonglong>(honaData.at(Ind) & ((static_cast<qulonglong>(honaData.at(Ind) &
0x0000FFFF)) << 28)); 0x0000FFFF)) << 28));
tempHonaPacketSinglePulse.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16); tempHonaPacketSinglePulse.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextSinglePulse = 3; nextSinglePulse = 3;
} }
@ -859,9 +899,9 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
{ {
tempHonaPacketSinglePulse.setPa1(honaData.at(Ind) & 0x0000FFFF); tempHonaPacketSinglePulse.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() + tempHonaPacketSinglePulse.setPa2(tempHonaPacketSinglePulse.getPa2() +
((honaData.at(Ind) & 0x000F0000) >> 4)); //NOTE: shifted by 4 ((honaData.at(Ind) & 0x000F0000) >> 4)); //NOTE: shifted by 4
tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() + tempHonaPacketSinglePulse.setPa3(tempHonaPacketSinglePulse.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 8)); //NOTE: shifted by 8 ((honaData.at(Ind) & 0x00F00000) >> 8)); //NOTE: shifted by 8
nextSinglePulse = 5; nextSinglePulse = 5;
} }
else if(honaData.at(Ind) == 0xEEEEEEEE) else if(honaData.at(Ind) == 0xEEEEEEEE)
@ -912,7 +952,10 @@ QVector<quint32> HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver)
else else
throw HonaException("honaReceivers is Not Valid"); throw HonaException("honaReceivers is Not Valid");
plxWrapper.deviceReadMemory(address, honaData, honaData.size()); if(!plxWrapper.deviceReadMemory(address, honaData, honaData.size()))
{
throw HonaAlreadyStartedException("DeviceReadMemory Doesnt Occur");
}
return honaData; return honaData;
} }

2
PlxBoard.pro

@ -1,7 +1,7 @@
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS += \ SUBDIRS += \
Plx\ Plx \
Test Test
Test.depends += Plx Test.depends += Plx

13
Test/MainWindow.cpp

@ -1,15 +1,18 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
{ {
delete ui; delete ui;
} }
void MainWindow::on_testPLX_clicked()
{
}

18
Test/MainWindow.h

@ -4,18 +4,24 @@
#include <QMainWindow> #include <QMainWindow>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; } namespace Ui { class MainWindow;
}
QT_END_NAMESPACE QT_END_NAMESPACE
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
MainWindow(QWidget *parent = nullptr); MainWindow(QWidget* parent = nullptr);
~MainWindow(); ~MainWindow();
//uncrustify off
private slots:
void on_testPLX_clicked();
//uncrustify on
private: private:
Ui::MainWindow *ui; Ui::MainWindow* ui;
}; };
#endif // MAINWINDOW_H
#endif //MAINWINDOW_H

44
Test/MainWindow.ui

@ -6,15 +6,51 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>311</width>
<height>600</height> <height>281</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<widget class="QWidget" name="centralwidget"/> <widget class="QWidget" name="centralwidget">
<widget class="QMenuBar" name="menubar"/> <widget class="QPushButton" name="testPLX">
<property name="geometry">
<rect>
<x>100</x>
<y>120</y>
<width>89</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Test PLX</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>60</x>
<y>30</y>
<width>171</width>
<height>51</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:20pt;&quot;&gt;Test PLX&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>311</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<resources/> <resources/>

5
Test/Test.pro

@ -22,14 +22,9 @@ SOURCES += \
HEADERS += \ HEADERS += \
MainWindow.h MainWindow.h
INCLUDEPATH += $$PWD/../Plx/include
FORMS += \ FORMS += \
MainWindow.ui MainWindow.ui
LIBS += -L$$OUT_PWD/../Plx/ -lPlx
PRE_TARGETDEPS += $$OUT_PWD/../Plx/libPlx.a
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin

8
Test/main.cpp

@ -4,8 +4,8 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
w.show(); w.show();
return a.exec(); return a.exec();
} }

Loading…
Cancel
Save