Browse Source

remove Qblockingconnection add Q_MetaType

mehrabi
mehrabi 3 years ago
parent
commit
61fac75a1c
  1. 2
      Plx/include/API/HonaAPI.h
  2. 2
      Plx/include/LowLevel/HonaLowLevelAPI.h
  3. 5
      Plx/include/LowLevel/HonaPacket.h
  4. 42
      Plx/src/API/HonaAPI.cpp
  5. 8
      Plx/src/LowLevel/HonaLowLevelAPI.cpp
  6. 1
      Plx/src/LowLevel/HonaPacket.cpp
  7. 2
      Test/MainWindow.cpp
  8. 2
      Test/MainWindow.h
  9. 3
      Test/main.cpp

2
Plx/include/API/HonaAPI.h

@ -37,7 +37,7 @@ public:
ApiResult init();
signals:
void honaDataResult(QList<HonaPacket> &honaPacketList, quint32 hsruLoss, quint32 Doa);
void honaDataResult(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa);
};

2
Plx/include/LowLevel/HonaLowLevelAPI.h

@ -119,7 +119,7 @@ private:
public:
signals:
void lowLevelHonaData(QList<HonaPacket> &honaPacketList, quint32 hsruLoss, quint32 Doa);
void lowLevelHonaData(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa);
//uncrustify off
public slots:

5
Plx/include/LowLevel/HonaPacket.h

@ -2,6 +2,8 @@
#define HONAPACKET_H
#include <QtGlobal>
#include <QMetaType>
#include "LowLevel/Utils/Utils.h"
@ -63,4 +65,7 @@ public:
/******************************************************************/
};
Q_DECLARE_METATYPE(HonaPacket);
Q_DECLARE_METATYPE(QList<HonaPacket>);
#endif //HONAPACKET_H

42
Plx/src/API/HonaAPI.cpp

@ -11,6 +11,7 @@ ApiResult HonaAPI::deviceReset()
{
return ApiResult::error;
}
return ApiResult::success;
}
@ -25,20 +26,14 @@ ApiResult HonaAPI::setConfig(HonaSettings& settings)
{
return ApiResult::error;
}
return ApiResult::success;
}
/*************************************************************************************************/
ApiResult HonaAPI::getConfig(HonaSettings& settings)
{
try
{
settings = _honaLowLevelAPI.getConfig();
}
catch(HonaException ex)
{
return ApiResult::error;
}
settings = _honaLowLevelAPI.getConfig();
return ApiResult::success;
}
@ -46,14 +41,7 @@ ApiResult HonaAPI::getConfig(HonaSettings& settings)
/*************************************************************************************************/
ApiResult HonaAPI::getSwVersion(QString& swVerion)
{
try
{
swVerion = _honaLowLevelAPI.getSwVersion();
}
catch(HonaException ex)
{
return ApiResult::error;
}
swVerion = _honaLowLevelAPI.getSwVersion();
return ApiResult::success;
}
@ -61,14 +49,7 @@ ApiResult HonaAPI::getSwVersion(QString& swVerion)
/*************************************************************************************************/
ApiResult HonaAPI::getDeviceId(QString& deviceId)
{
try
{
deviceId = _honaLowLevelAPI.getDeviceId();
}
catch(HonaException ex)
{
return ApiResult::error;
}
deviceId = _honaLowLevelAPI.getDeviceId();
return ApiResult::success;
}
@ -114,21 +95,15 @@ ApiResult HonaAPI::hiruStart()
/*************************************************************************************************/
ApiResult HonaAPI::hsruStop()
{
try
{
_honaLowLevelAPI.hsruStop();
}
catch(HonaException ex)
{
return ApiResult::error;
}
_honaLowLevelAPI.hsruStop();
return ApiResult::success;
}
/*************************************************************************************************/
ApiResult HonaAPI::init()
{
connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult,Qt::BlockingQueuedConnection);
connect(&_honaLowLevelAPI, &HonaLowLevelAPI::lowLevelHonaData, this, &HonaAPI::honaDataResult);
try
{
@ -138,6 +113,7 @@ ApiResult HonaAPI::init()
{
return ApiResult::error;
}
return ApiResult::success;
}

8
Plx/src/LowLevel/HonaLowLevelAPI.cpp

@ -24,6 +24,9 @@ quint32 HonaLowLevelAPI::nextInt123C;
quint32 HonaLowLevelAPI::nextRes123C;
quint32 HonaLowLevelAPI::nextIntS;
#define PLX_ID 0x9054
/*************************************************************************************************/
HonaLowLevelAPI::HonaLowLevelAPI(QObject* parent) : QObject(parent)
{
@ -115,14 +118,15 @@ void HonaLowLevelAPI::hiruStart()
void HonaLowLevelAPI::hsruStop()
{
if(_hsruIsStarted)
_hsruIsStarted =false;
_hsruIsStarted = false;
_hsruStopEvent.wakeAll();
}
/*************************************************************************************************/
void HonaLowLevelAPI::init()
{
if(!plxWrapper.deviceInit(0X9054))
if(!plxWrapper.deviceInit(PLX_ID))
{
throw HonaException();
}

1
Plx/src/LowLevel/HonaPacket.cpp

@ -136,4 +136,3 @@ void HonaPacket::setm4Status(quint8 temp)
m4Status = temp;
}
/*************************************************************************************************/

2
Test/MainWindow.cpp

@ -17,7 +17,7 @@ MainWindow::~MainWindow()
}
/*************************************************************************************************/
void MainWindow::honaDataResultUi(QList<HonaPacket> &honaPacketList, quint32 hsruLoss, quint32 Doa)
void MainWindow::honaDataResultUi(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa)
{
QString _str;
for(auto i = 0; i < honaPacketList.length(); i++)

2
Test/MainWindow.h

@ -27,7 +27,7 @@ public:
//uncrustify off
private slots:
void honaDataResultUi(QList<HonaPacket> &honaPacketList, quint32 hsruLoss, quint32 Doa);
void honaDataResultUi(QList<HonaPacket> honaPacketList, quint32 hsruLoss, quint32 Doa);
void on_testPLX_clicked();
void on_stopHsru_clicked();
//uncrustify on:

3
Test/main.cpp

@ -1,10 +1,13 @@
#include "MainWindow.h"
#include <QApplication>
#include <LowLevel/HonaPacket.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qRegisterMetaType<HonaPacket>();
qRegisterMetaType<QList<HonaPacket>>();
MainWindow w;
w.show();

Loading…
Cancel
Save