feat: add recon message receive and popup function
This commit is contained in:
@@ -210,6 +210,8 @@ void DeviceManager::initDevice()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(ReconManager::getInstance(), &ReconManager::reconStateResponsed, UsctStateManager::getInstance(), &UsctStateManager::updateReconState);
|
connect(ReconManager::getInstance(), &ReconManager::reconStateResponsed, UsctStateManager::getInstance(), &UsctStateManager::updateReconState);
|
||||||
|
connect(ReconManager::getInstance(), &ReconManager::reconMessagereceived, this,&DeviceManager::processReconMessage);
|
||||||
|
|
||||||
connect(this, &DeviceManager::checkReconConnection, ReconManager::getInstance(), &ReconManager::checkReconConnection);
|
connect(this, &DeviceManager::checkReconConnection, ReconManager::getInstance(), &ReconManager::checkReconConnection);
|
||||||
connect(reconConnectionTimer, &QTimer::timeout, this, &DeviceManager::prepareCheckReconConnection);
|
connect(reconConnectionTimer, &QTimer::timeout, this, &DeviceManager::prepareCheckReconConnection);
|
||||||
connect(this, &DeviceManager::createEmptyScanToRecon, ReconManager::getInstance(), &ReconManager::createEmptyScan);
|
connect(this, &DeviceManager::createEmptyScanToRecon, ReconManager::getInstance(), &ReconManager::createEmptyScan);
|
||||||
@@ -1427,6 +1429,12 @@ void DeviceManager::prepareCheckReconConnection()
|
|||||||
emit checkReconConnection();
|
emit checkReconConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::processReconMessage(const QString &aMessage)
|
||||||
|
{
|
||||||
|
QString msg=aMessage;
|
||||||
|
EventCenter::Default()->triggerEvent(WarningMessageRaise, nullptr, (QObject*)&aMessage);
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceManager::processEmergencyButtonReset(const QString& aResponse)
|
void DeviceManager::processEmergencyButtonReset(const QString& aResponse)
|
||||||
{
|
{
|
||||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ private slots:
|
|||||||
void startCreateReconRecord();
|
void startCreateReconRecord();
|
||||||
void updateReconConnectionState(bool aIsConnected);
|
void updateReconConnectionState(bool aIsConnected);
|
||||||
void prepareCheckReconConnection();
|
void prepareCheckReconConnection();
|
||||||
|
void processReconMessage(const QString& aMessage);
|
||||||
|
|
||||||
//GUI
|
//GUI
|
||||||
void scanTimeout();
|
void scanTimeout();
|
||||||
|
|
||||||
|
|||||||
@@ -35,4 +35,11 @@ struct MPPSSetting
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ServerSideMessage
|
||||||
|
{
|
||||||
|
int ErrorCode = 0;
|
||||||
|
std::string MessageContent;
|
||||||
|
std::string MessageUUID;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // __SCAN_H__
|
#endif // __SCAN_H__
|
||||||
@@ -3,6 +3,11 @@
|
|||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "log/LogManager.h"
|
#include "log/LogManager.h"
|
||||||
|
|
||||||
|
#include "event/EventCenter.h"
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "QDebug"
|
#include "QDebug"
|
||||||
#include "json/cJSON.h"
|
#include "json/cJSON.h"
|
||||||
@@ -132,11 +137,26 @@ void ReconManager::checkReconConnection()
|
|||||||
int state = 0;
|
int state = 0;
|
||||||
if (mIsConnected)
|
if (mIsConnected)
|
||||||
{
|
{
|
||||||
cJSON* json = cJSON_Parse(response.message().data());
|
QJsonObject messageState = QJsonDocument::fromJson(response.message().data()).object();
|
||||||
cJSON* stateProperty = cJSON_GetObjectItem(json, "State");
|
|
||||||
state = stateProperty->valueint;
|
state = messageState["state"].toInt();
|
||||||
cJSON_Delete(json);
|
emit reconStateResponsed(mIsConnected, state);
|
||||||
qDebug()<<"Recon State:"<<state;
|
if (!messageState["messages"].isArray())
|
||||||
|
{
|
||||||
|
qDebug()<<"messages:"<<messageState["messages"].toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
QJsonArray messages = messageState["messages"].toArray();
|
||||||
|
|
||||||
|
for(auto item : messages)
|
||||||
|
{
|
||||||
|
struct ServerSideMessage value;
|
||||||
|
QJsonObject obj = item.toObject();
|
||||||
|
value.ErrorCode = obj["errorCode"].toInt();
|
||||||
|
QString str = obj["messageContent"].toString();
|
||||||
|
emit reconMessagereceived(str);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
emit reconStateResponsed(mIsConnected, state);
|
emit reconStateResponsed(mIsConnected, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ signals:
|
|||||||
void checkReconConnectionResponsed(bool aResult);
|
void checkReconConnectionResponsed(bool aResult);
|
||||||
void getReconVersionResponsed(const QString& aResult);
|
void getReconVersionResponsed(const QString& aResult);
|
||||||
void reconStateResponsed(bool aIsConnected, int aState);
|
void reconStateResponsed(bool aIsConnected, int aState);
|
||||||
|
void reconMessagereceived(const QString& aMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReconClient* mReconClient;
|
ReconClient* mReconClient;
|
||||||
|
|||||||
Reference in New Issue
Block a user