New timer for device information query in DeviceManager
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include "DeviceManager.h"
|
#include "DeviceManager.h"
|
||||||
#include "../event/EventCenter.h"
|
#include "../event/EventCenter.h"
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QTimerEvent>
|
||||||
|
|
||||||
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ std::string getJsonFromPatInf(QObject* obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::initDevice() {
|
void DeviceManager::initDevice() {
|
||||||
|
deviceInfTimerID = startTimer(1000);
|
||||||
// empty scan
|
// empty scan
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestEmptyScan,[=](QObject* sender, QObject* detail){
|
connect(EventCenter::Default(),&EventCenter::RequestEmptyScan,[=](QObject* sender, QObject* detail){
|
||||||
std::string json= getJsonFromPatInf(detail);
|
std::string json= getJsonFromPatInf(detail);
|
||||||
@@ -74,6 +76,8 @@ void DeviceManager::initDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::timerEvent(QTimerEvent *event) {
|
void DeviceManager::timerEvent(QTimerEvent *event) {
|
||||||
|
if (event->timerId() !=deviceInfTimerID)
|
||||||
|
{
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
if (inf.status==SCANING)
|
if (inf.status==SCANING)
|
||||||
{
|
{
|
||||||
@@ -109,6 +113,10 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
|
|||||||
}
|
}
|
||||||
killTimer(timerID);
|
killTimer(timerID);
|
||||||
}
|
}
|
||||||
|
} else{
|
||||||
|
QString temp = QString(GetDeviceInf(MEAN_TEMPERATURE));
|
||||||
|
TRIGGER_EVENT(GUIEvents::ResponseDeviceTemperature, nullptr, (QObject*)&temp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::processScan(const char *json) {
|
void DeviceManager::processScan(const char *json) {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void processScan(const char * json);
|
void processScan(const char * json);
|
||||||
int timerID = -1;
|
int timerID = -1;
|
||||||
|
int deviceInfTimerID = -1;
|
||||||
int lastStatus=-1;
|
int lastStatus=-1;
|
||||||
bool previewing = false;
|
bool previewing = false;
|
||||||
bool errorOccured = false;
|
bool errorOccured = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user