Refactor system page in GUI Alpha.

This commit is contained in:
sunwen
2024-04-25 14:37:38 +08:00
parent f9eb807fa3
commit 982b54b727
420 changed files with 23907 additions and 872 deletions

View File

@@ -36,6 +36,7 @@ namespace
{
const int PREVIEW_IMAGE_WH = 140;
const unsigned int GET_TEMPERATURE_TIME = 60000;
const int CHECK_RECON_CONNECTION_TIME = 30000;
const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues
const int PUMP_TIMEOUT = 3000;//3 seconds
const QString DEFAULT_DMS_START_FAILED = "Dms start failed.";
@@ -148,16 +149,19 @@ void DeviceManager::initDevice()
//dmsInfoReceiverThread
mDmsInfoReceiveThread = new QThread(this);
InfoReceiveWorker* infoReceiveWorker = new InfoReceiveWorker(nullptr);
infoReceiveWorker->moveToThread(mDmsInfoReceiveThread);
connect(mDmsInfoReceiveThread, &QThread::started, infoReceiveWorker, &InfoReceiveWorker::startListen);
connect(mDmsInfoReceiveThread, &QThread::finished, infoReceiveWorker, &InfoReceiveWorker::deleteLater);
connect(infoReceiveWorker, &InfoReceiveWorker::infoReceived, this, &DeviceManager::processReceiveDMSInfoResult);
mInfoReceiveWorker = new InfoReceiveWorker(nullptr);
mInfoReceiveWorker->moveToThread(mDmsInfoReceiveThread);
connect(mDmsInfoReceiveThread, &QThread::started, mInfoReceiveWorker, &InfoReceiveWorker::startListen);
connect(mDmsInfoReceiveThread, &QThread::finished, mInfoReceiveWorker, &InfoReceiveWorker::deleteLater);
connect(mInfoReceiveWorker, &InfoReceiveWorker::infoReceived, this, &DeviceManager::processReceiveDMSInfoResult);
mDmsInfoReceiveThread->start();
//reconHttpThread
mReconHttpThread = new QThread(this);
QTimer* reconConnectionTimer = new QTimer(this);
reconConnectionTimer->start(CHECK_RECON_CONNECTION_TIME);
ReconManager::getInstance()->moveToThread(mReconHttpThread);
connect(reconConnectionTimer, &QTimer::timeout, ReconManager::getInstance(), &ReconManager::checkReconConnection);
connect(mReconHttpThread, &QThread::finished, ReconManager::getInstance(), &ReconManager::deleteLater);
connect(this, &DeviceManager::createEmptyScanToRecon, ReconManager::getInstance(), &ReconManager::createEmptyScan);
connect(this, &DeviceManager::createScanToRecon, ReconManager::getInstance(), &ReconManager::createScan);

View File

@@ -8,6 +8,7 @@
#include <QObject>
#include <QThread>
#include "DeviceDefs.h"
#include "InfoReceiveWorker.h"
class DmsSyncAction;
class DmsAsyncAction;
@@ -27,13 +28,14 @@ public:
~DeviceManager() override
{
// mCmdSendThread->quit();
// mCmdSendThread->wait();
// mCmdSendThread->deleteLater();
mInfoReceiveWorker->exit();
mDmsInfoReceiveThread->quit();
mDmsInfoReceiveThread->wait();
mDmsInfoReceiveThread->deleteLater();
mReconHttpThread->quit();
mReconHttpThread->wait();
mReconHttpThread->deleteLater();
}
DeviceManager(const DeviceManager &) = delete;
@@ -215,6 +217,8 @@ private:
DmsAsyncAction* mShutDownAction = nullptr;
DmsAsyncAction* mPumpControlAction = nullptr;
InfoReceiveWorker* mInfoReceiveWorker = nullptr;
friend class InfoReceiveWorker;
};

View File

@@ -27,8 +27,8 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
DmsAsyncAction::~DmsAsyncAction()
{
disconnect(mTimer, &QTimer::timeout, this, &DmsAsyncAction::sendTimeoutSignal);
disconnect(mObject, ("2" + mResponseSignal).toStdString().c_str(), mTimer, SLOT(stop()));
//disconnect(mTimer, &QTimer::timeout, this, &DmsAsyncAction::sendTimeoutSignal);
//disconnect(mObject, ("2" + mResponseSignal).toStdString().c_str(), mTimer, SLOT(stop()));
}
void DmsAsyncAction::setSendData(const QString& aData)
@@ -38,7 +38,7 @@ void DmsAsyncAction::setSendData(const QString& aData)
bool DmsAsyncAction::execute()
{
mIsResponsed = false;
mIsResponsed = false;
QByteArray byteArray = mSendData.toUtf8();
uint8_t* data = reinterpret_cast<uint8_t*>(byteArray.data());
if(dmsmq_send(mServerId, mActionId, data, byteArray.size()) < 0)
@@ -51,7 +51,7 @@ bool DmsAsyncAction::execute()
void DmsAsyncAction::sendTimeoutSignal()
{
if(!mIsResponsed)
if(!mIsResponsed)
{
emit timeout();
}
@@ -64,7 +64,7 @@ void DmsAsyncAction::setTimeoutInterval(int aMsec)
void DmsAsyncAction::responsed()
{
if(mTimer->isActive())
if(mTimer->isActive())
{
mIsResponsed = true;
}

View File

@@ -30,9 +30,9 @@ DmsSyncAction::DmsSyncAction(int aServerId, int aActionId, QObject* aObject, con
DmsSyncAction::~DmsSyncAction()
{
disconnect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
disconnect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
disconnect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
//disconnect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
//disconnect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
// disconnect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
}
DmsSyncActionResult DmsSyncAction::execute()

View File

@@ -28,6 +28,11 @@ void InfoReceiveWorker::startListen()
QString myQString = QString::fromUtf8(reinterpret_cast<const char*>(copyData));
emit infoReceived(serverID, actionID, myQString);
}
if(mExitFlag)
{
break;
}
}
}
@@ -111,3 +116,10 @@ void InfoReceiveWorker::responsed(int aServerID, int aActionID)
break;
}
}
void InfoReceiveWorker::exit()
{
mExitFlag = true;
uint32_t cnt = 0;
dmsmq_send( USRV_SCAN, ACT_SCAN_STATUS, ( uint8_t* )( &cnt ), sizeof( cnt ) );
}

View File

@@ -9,6 +9,7 @@ class InfoReceiveWorker : public QObject
Q_OBJECT
public:
InfoReceiveWorker(QObject* aParent);
void exit();
public slots:
void startListen();
@@ -19,6 +20,9 @@ signals:
private:
void responsed(int aServerID, int aActionID);
private:
bool mExitFlag = false;
};
#endif // INFORECEIVEWORKER_H

View File

@@ -90,7 +90,7 @@ bool NetworkManager::isDHCP()
}
IpAddr NetworkManager::getDefaultIpAddr()
{
return IpAddr{mIpAddress, mSubNetMask};
return IpAddr{mIsDHCP, mIpAddress, mSubNetMask, mGateway};
}
QList<QStringList> NetworkManager::getIpAddrList()
{

View File

@@ -38,6 +38,7 @@ private:
bool mIsDHCP;
QString mIpAddress;
QString mSubNetMask;
QString mGateway;
};