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
SOURCES += \
$$files(*.cpp, true) \ \
src/Wrapper/PlxWrapper.cpp
$$files(*.cpp, true) \ \ \
HEADERS += \
$$files(*.h, true) \
$$files(*.h, true) \ \ \
INCLUDEPATH += $$PWD/include
@ -32,3 +35,7 @@ unix {
target.path = $$[QT_INSTALL_PLUGINS]/generic
}
!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();
void hsruStart();
void hiruStart();
void hsruStop();
void init();
bool getHsruIsStarted() const;

6
Plx/include/LowLevel/HonaPacket.h

@ -20,12 +20,13 @@ private:
quint32 m_Code;
quint32 m_CodeL;
quint32 m_CodeM;
quint8 m4Status;
public:
HonaPacket();
/******************************************************************/
honaPacketType getPacketType();
void setPacketType(honaPacketType& temp);
void setPacketType(honaPacketType temp);
/******************************************************************/
quint32 getPacketNumber();
void setPacketNumber(quint32 temp);
@ -57,6 +58,9 @@ public:
quint32 getCodeM();
void setCodeM(quint32 temp);
/******************************************************************/
quint8 getm4Status();
void setm4Status(quint8 temp);
/******************************************************************/
};
#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>
/*************************************************************************************************/
enum apiResult : quint8
enum ApiResult : quint8
{
success,
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()
{
if(!plxWrapper.deviceReset())
throw HonaAlreadyStartedException("reset Doesnt Occur");
throw HonaAlreadyStartedException("Reset Doesnt Occur");
}
/*************************************************************************************************/
void HonaLowLevelAPI::setConfig(HonaSettings& settings)
{
plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8);
if(!plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8))
{
throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
}
_honaSetting = settings;
writeSettingToRegisters(settings);
plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer);
plxWrapper.deviceReadRegister(0x10000000, honaRegisterBuffer, 8);
if(!plxWrapper.deviceWriteRegister(0x10000000, honaRegisterBuffer))
{
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()
{
if(!isHsruStarted())
throw HonaAlreadyStartedException("HsruStarted doesn't started ");
throw HonaException("HsruStarted doesn't started ");
QtConcurrent::run(this, &HonaLowLevelAPI::hsruMainThread);
setHsruIsStarted(true);
}
@ -101,14 +111,26 @@ void HonaLowLevelAPI::hsruStart()
void HonaLowLevelAPI::hiruStart()
{
if(!isHiruStarted())
throw HonaAlreadyStartedException("HiruStarted doesn't started ");
throw HonaException("HiruStarted doesn't started ");
QtConcurrent::run(this, &HonaLowLevelAPI::hiruMainThread);
setHiruIsStarted(true);
}
/*************************************************************************************************/
void HonaLowLevelAPI::hsruStop()
{
if(isHiruStarted())
setHsruIsStarted(false);
_hsruStopEvent.wakeAll();
}
/*************************************************************************************************/
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.at(0) +
(settings.hiruSettings.threshold & 0x00000FFF)));
(honaRegisterBuffer.at(0) +
(settings.hiruSettings.threshold & 0x00000FFF)));
honaRegisterBuffer.insert(1, settings.hsruSettings.honaInt123CTHR);
honaRegisterBuffer.insert(2, settings.hsruSettings.honaRes123CTHR);
@ -160,7 +182,10 @@ void HonaLowLevelAPI::hsruMainThread()
deviceReset();
setConfig();
deviceReset();
plxWrapper.deviceEnableInterrupt();
if(!plxWrapper.deviceEnableInterrupt())
{
throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
}
QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread);
QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread);
@ -169,7 +194,7 @@ void HonaLowLevelAPI::hsruMainThread()
{
_isHsruReaderThreadFree = true;
_isHsruUpdateThreadFree = true;
setHiruIsStarted(false);
hsruStop();
}
_mutex.lock();
@ -178,7 +203,10 @@ void HonaLowLevelAPI::hsruMainThread()
_isHsruReaderThreadFree = true;
_isHsruUpdateThreadFree = true;
plxWrapper.deviceDisableInterrupt();
if(!plxWrapper.deviceDisableInterrupt())
{
throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
}
}
/*************************************************************************************************/
@ -190,23 +218,35 @@ void HonaLowLevelAPI::hsruReadThread()
if(_isHsruReaderThreadFree)
break;
plxWrapper.deviceWaitForInterrupt(1000);
if(!plxWrapper.deviceWaitForInterrupt(1000))
{
throw HonaAlreadyStartedException("DeviceWaitForInterrupt Doesnt Occur");
}
honaPacketList.clear();
_hsruLoss = 0;
plxWrapper.deviceOpenPCIChannel();
if(!plxWrapper.deviceOpenPCIChannel())
{
throw HonaAlreadyStartedException("DeviceOpenPCIChannel Doesnt Occur");
}
_hsruLoss += hsruParserInt123C(hsruReadHonaBuffer(honaReceivers::int123C),
honaPacketList);
honaPacketList);
_hsruLoss += hsruParserRes123C(hsruReadHonaBuffer(honaReceivers::res123C),
honaPacketList);
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();
honaPacketList);
if(!plxWrapper.deviceClosePCIChannel())
{
throw HonaAlreadyStartedException("DeviceClosePCIChannel Doesnt Occur");
}
if(!plxWrapper.deviceEnableInterrupt())
{
throw HonaAlreadyStartedException("DeviceEnableInterrupt Doesnt Occur");
}
_mutex.lock();
_hsruReadDone.wakeAll();
@ -242,9 +282,6 @@ void HonaLowLevelAPI::hiruMainThread()
_mutex.lock();
_hsruStopEvent.wait(&_mutex);
_mutex.unlock();
//_isReaderThreadFree = true;
//_isUpdateThreadFree = true;
}
}
@ -262,7 +299,10 @@ void HonaLowLevelAPI::hiruUpdateThread()
quint32 HonaLowLevelAPI::hiruGetDOA()
{
quint32 Doa = 0;
plxWrapper.deviceReadRegister(0x30000004, Doa);
if(!plxWrapper.deviceReadRegister(0x30000004, Doa))
{
throw HonaAlreadyStartedException("DeviceReadRegister Doesnt Occur");
}
Doa = Doa & 0x0000FFFF;
return Doa;
@ -270,7 +310,7 @@ quint32 HonaLowLevelAPI::hiruGetDOA()
/*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
quint32 lossFound;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -282,7 +322,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
packetLenInt123C = 6;
tempHonaPacketInt123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
if((tempHonaPacketInt123C.getPacketNumber() !=
(lastPNInt123C + 1)) & (lastPNInt123C > 0))
(lastPNInt123C + 1)) & (lastPNInt123C > 0))
//& (LastPNInt123C != 65535))
{
lossFound +=
@ -301,7 +341,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt123C == 2))
{
tempHonaPacketInt123C.setToa(((tempHonaPacketInt123C.getToa()) +
(qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28)));
(qulonglong)((honaData.at(Ind) & 0x0000FFFF) << 28)));
tempHonaPacketInt123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextInt123C = 3;
@ -350,7 +390,7 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector<quint32>& honaData,
/*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
quint32 lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -361,7 +401,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
packetLenRes123C = 6;
tempHonaPacketRes123C.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
if((tempHonaPacketRes123C.getPacketNumber() !=
(lastPNRes123C + 1)) & (lastPNRes123C > 0))
(lastPNRes123C + 1)) & (lastPNRes123C > 0))
//& (LastPNRes123C != 65535))
{
lossFound +=
@ -380,7 +420,7 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextRes123C == 2))
{
tempHonaPacketRes123C.setToa(tempHonaPacketRes123C.getToa() +
(((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
(((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
tempHonaPacketRes123C.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextRes123C = 3;
}
@ -394,9 +434,9 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector<quint32>& honaData,
{
tempHonaPacketRes123C.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketRes123C.setPa2(tempHonaPacketRes123C.getPa2() +
((honaData.at(Ind) & 0x000F0000) >> 4));
((honaData.at(Ind) & 0x000F0000) >> 4));
tempHonaPacketRes123C.setPa3(tempHonaPacketRes123C.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 8));
((honaData.at(Ind) & 0x00F00000) >> 8));
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,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
uint lossFound = 0;
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))
{
tempHonaPacketIntS.setToa(tempHonaPacketIntS.getToa() +
(((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
(((ulong)(honaData.at(Ind) & 0x0000FFFF)) << 28));
tempHonaPacketIntS.setToa((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextIntS = 3;
}
@ -479,13 +519,13 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
nextIntS = 4;
}
else if(((honaData.at(static_cast<int>(Ind)) & 0xF0000000) == 0x40000000) &&
(nextIntS == 4))
(nextIntS == 4))
{
tempHonaPacketIntS.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketIntS.setPa2(tempHonaPacketIntS.getPa2() + ((honaData.at(
Ind) & 0x000F0000)));
tempHonaPacketIntS.setPa3(tempHonaPacketIntS.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 4));
((honaData.at(Ind) & 0x00F00000) >> 4));
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))
{
tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
tempHonaPacketIntS.setCodeL(0);
nextIntS = 7;
}
@ -510,7 +550,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextIntS == 8))
{
tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() +
((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
((ulong)(honaData.at(Ind) & 0x0FFFFFFF)) << 36);
nextIntS = 9;
}
else if(honaData.at(Ind) == 0xEEEEEEEE)
@ -538,7 +578,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector<quint32>& honaData,
/*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
uint lossFound = 0;
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))
{
tempHonaPacketResS.setDoa(tempHonaPacketResS.getDoa() +
((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
28));
((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
28));
tempHonaPacketResS.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextResS = 3;
}
@ -593,7 +633,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
tempHonaPacketResS.setPa2(tempHonaPacketResS.getPa2() + ((honaData.at(
Ind) & 0x000F0000)));
tempHonaPacketResS.setPa3(tempHonaPacketResS.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 4));
((honaData.at(Ind) & 0x00F00000) >> 4));
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))
{
tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
(static_cast<qulonglong>(honaData.at(
(static_cast<qulonglong>(honaData.at(
Ind) & 0x0FFFFFFF)) << 36);
tempHonaPacketResS.setCodeL(0);
nextResS = 7;
@ -621,7 +661,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x80000000) && (nextResS == 8))
{
tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() +
(static_cast<qulonglong>(honaData.at(
(static_cast<qulonglong>(honaData.at(
Ind) & 0x0FFFFFFF)) << 36);
nextResS = 9;
}
@ -650,7 +690,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector<quint32>& honaData,
/*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
uint lossFound = 0;
@ -679,8 +719,8 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextInt4 == 2))
{
tempHonaPacketInt4.setToa(tempHonaPacketInt4.getToa() +
((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
28));
((static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF)) <<
28));
tempHonaPacketInt4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextInt4 = 3;
}
@ -694,9 +734,9 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
{
tempHonaPacketInt4.setPa1(honaData.at(Ind) & 0x0000FFFF);
tempHonaPacketInt4.setPa2(tempHonaPacketInt4.getPa2() +
((honaData.at(Ind) & 0x000F0000) >> 4));
((honaData.at(Ind) & 0x000F0000) >> 4));
tempHonaPacketInt4.setPa3(tempHonaPacketInt4.getPa3() +
((honaData.at(Ind) & 0x00F00000) >> 8));
((honaData.at(Ind) & 0x00F00000) >> 8));
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.setCodeL(tempHonaPacketInt4.getCodeL() +
((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) <<
12));
tempHonaPacketInt4.M4Status = ((byte)((honaData.at(Ind) & 0x0F000000) >> 20));
((static_cast<qulonglong>(honaData.at(Ind) & 0x000F0000)) <<
12));
tempHonaPacketInt4.setm4Status((quint8)((honaData.at(Ind) & 0x0F000000) >> 20));
nextInt4 = 7;
}
else if(honaData.at(Ind) == 0xEEEEEEEE)
@ -738,7 +778,7 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector<quint32>& honaData,
}
quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
uint lossFound = 0;
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))
{
tempHonaPacketRes4.setToa(tempHonaPacketRes4.getToa() +
(static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) <<
28));
(static_cast<qulonglong>(honaData.at(Ind) & 0x0000FFFF) <<
28));
tempHonaPacketRes4.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextRes4 = 3;
}
@ -811,7 +851,7 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector<quint32>& honaData,
/*************************************************************************************************/
quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
QList<HonaPacket> honaPacketList)
QList<HonaPacket> honaPacketList)
{
uint lossFound = 0;
for(quint32 Ind = 0; Ind < honaData.length(); Ind++)
@ -822,7 +862,7 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
packetLenSinglePulse = 5;
tempHonaPacketSinglePulse.setPacketNumber(honaData.at(Ind) & 0x0000FFFF);
if((tempHonaPacketSinglePulse.getPacketNumber() !=
(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
(lastPNSinglePulse + 1)) & (lastPNSinglePulse > 0))
;
{
lossFound +=
@ -838,14 +878,14 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
else if(((honaData.at(Ind) & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1))
{
tempHonaPacketSinglePulse.setToa(static_cast<qulonglong>(honaData.at(Ind) &
0x0FFFFFFF));
0x0FFFFFFF));
nextSinglePulse = 2;
}
else if(((honaData.at(Ind) & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2))
{
tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() +
((static_cast<qulonglong>(honaData.at(Ind) &
0x0000FFFF)) << 28));
((static_cast<qulonglong>(honaData.at(Ind) &
0x0000FFFF)) << 28));
tempHonaPacketSinglePulse.setPa2((honaData.at(Ind) & 0x0FFF0000) >> 16);
nextSinglePulse = 3;
}
@ -859,9 +899,9 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector<quint32>& honaData,
{
tempHonaPacketSinglePulse.setPa1(honaData.at(Ind) & 0x0000FFFF);
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() +
((honaData.at(Ind) & 0x00F00000) >> 8)); //NOTE: shifted by 8
((honaData.at(Ind) & 0x00F00000) >> 8)); //NOTE: shifted by 8
nextSinglePulse = 5;
}
else if(honaData.at(Ind) == 0xEEEEEEEE)
@ -912,7 +952,10 @@ QVector<quint32> HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver)
else
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;
}

2
PlxBoard.pro

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

13
Test/MainWindow.cpp

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

18
Test/MainWindow.h

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

44
Test/MainWindow.ui

@ -6,15 +6,51 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<width>311</width>
<height>281</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget"/>
<widget class="QMenuBar" name="menubar"/>
<widget class="QWidget" name="centralwidget">
<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>
<resources/>

5
Test/Test.pro

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

8
Test/main.cpp

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

Loading…
Cancel
Save