Fix dms timeout problem.
This commit is contained in:
@@ -209,6 +209,7 @@ private:
|
|||||||
DmsAsyncAction* mStopTransferAction = nullptr;
|
DmsAsyncAction* mStopTransferAction = nullptr;
|
||||||
DmsAsyncAction* mShutDownAction = nullptr;
|
DmsAsyncAction* mShutDownAction = nullptr;
|
||||||
|
|
||||||
|
friend class InfoReceiveWorker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -50,3 +50,8 @@ void DmsAsyncAction::setTimeoutInterval(int aMsec)
|
|||||||
{
|
{
|
||||||
mTimer->setInterval(aMsec);
|
mTimer->setInterval(aMsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DmsAsyncAction::responsed()
|
||||||
|
{
|
||||||
|
mTimer->stop();
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
bool execute();
|
bool execute();
|
||||||
void setSendData(const QString& aData);
|
void setSendData(const QString& aData);
|
||||||
void setTimeoutInterval(int aMsec);
|
void setTimeoutInterval(int aMsec);
|
||||||
|
void responsed();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void timeout();
|
void timeout();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const int TIMEOUT_MSEC = 500;
|
const int TIMEOUT_MSEC = 500;
|
||||||
@@ -20,10 +20,12 @@ DmsSyncAction::DmsSyncAction(int aServerId, int aActionId, QObject* aObject, con
|
|||||||
, mTimeoutMsec(TIMEOUT_MSEC)
|
, mTimeoutMsec(TIMEOUT_MSEC)
|
||||||
, mSendData()
|
, mSendData()
|
||||||
, mActionResult()
|
, mActionResult()
|
||||||
|
, mIsTimeout(false)
|
||||||
{
|
{
|
||||||
mTimer->setSingleShot(true);
|
mTimer->setSingleShot(true);
|
||||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
connect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
||||||
connect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
connect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
||||||
|
connect(mTimer, &QTimer::timeout, this, &DmsSyncAction::responsed);
|
||||||
connect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
connect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +33,7 @@ DmsSyncAction::~DmsSyncAction()
|
|||||||
{
|
{
|
||||||
disconnect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
disconnect(mObject, ("2" + mSignal).toStdString().c_str(), mLoop, SLOT(quit()));
|
||||||
disconnect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
disconnect(mObject, ("2" + mSignal).toStdString().c_str(), this, SLOT(saveActionResult(const QString&)));
|
||||||
|
disconnect(mTimer, &QTimer::timeout, this, &DmsSyncAction::responsed);
|
||||||
disconnect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
disconnect(mTimer, &QTimer::timeout, mLoop, &QEventLoop::quit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,10 +68,22 @@ bool DmsSyncAction::waitUntilSignalReceived()
|
|||||||
{
|
{
|
||||||
mTimer->start(mTimeoutMsec);
|
mTimer->start(mTimeoutMsec);
|
||||||
mLoop->exec();
|
mLoop->exec();
|
||||||
if(!mTimer->isActive())
|
if(mIsTimeout)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mTimer->stop();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DmsSyncAction::responsed()
|
||||||
|
{
|
||||||
|
if(mTimer->isActive())
|
||||||
|
{
|
||||||
|
mTimer->stop();
|
||||||
|
mIsTimeout = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mIsTimeout = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
|
|
||||||
DmsSyncActionResult execute();
|
DmsSyncActionResult execute();
|
||||||
void setSendData(const QString& aData);
|
void setSendData(const QString& aData);
|
||||||
|
void responsed();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void saveActionResult(const QString& aResult);
|
void saveActionResult(const QString& aResult);
|
||||||
@@ -43,6 +44,7 @@ private:
|
|||||||
int mTimeoutMsec;
|
int mTimeoutMsec;
|
||||||
QString mSendData;
|
QString mSendData;
|
||||||
QString mActionResult;
|
QString mActionResult;
|
||||||
|
bool mIsTimeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DMSSYNCACTION_H
|
#endif // DMSSYNCACTION_H
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
#include "InfoReceiveWorker.h"
|
#include "InfoReceiveWorker.h"
|
||||||
|
#include "DeviceManager.h"
|
||||||
|
#include "DmsAsyncAction.h"
|
||||||
|
#include "DmsSyncAction.h"
|
||||||
#include "dms_mq.h"
|
#include "dms_mq.h"
|
||||||
#include "daq_define.h"
|
#include "daq_define.h"
|
||||||
|
|
||||||
@@ -17,6 +20,7 @@ void InfoReceiveWorker::startListen()
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
count = dmsmq_recv(&serverID, &actionID,data);
|
count = dmsmq_recv(&serverID, &actionID,data);
|
||||||
|
responsed(serverID, actionID);
|
||||||
if(count >= 0)
|
if(count >= 0)
|
||||||
{
|
{
|
||||||
uint8_t* copyData = data;
|
uint8_t* copyData = data;
|
||||||
@@ -26,3 +30,82 @@ void InfoReceiveWorker::startListen()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InfoReceiveWorker::responsed(int aServerID, int aActionID)
|
||||||
|
{
|
||||||
|
switch(aServerID)
|
||||||
|
{
|
||||||
|
case USRV_SCAN :
|
||||||
|
switch(aActionID)
|
||||||
|
{
|
||||||
|
case ACT_SCAN_STATUS :
|
||||||
|
DeviceManager::Default()->mGetDeviceStatusAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_FULLSCAN :
|
||||||
|
DeviceManager::Default()->mFullScanAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_PREVIEW:
|
||||||
|
DeviceManager::Default()->mPreviewScanAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_TEMP :
|
||||||
|
DeviceManager::Default()->mGetDeviceTemperatureAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_PROGRESS_PASSIVE :
|
||||||
|
DeviceManager::Default()->mGetScanProgressAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_STOP :
|
||||||
|
DeviceManager::Default()->mStopScanAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_CE :
|
||||||
|
DeviceManager::Default()->mCEScanAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_CE_STATUS :
|
||||||
|
DeviceManager::Default()->mGetCEStatusAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_SCAN_SIMULATOR:
|
||||||
|
DeviceManager::Default()->mSetSimulatorModeAction->responsed();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case USRV_XFR :
|
||||||
|
switch(aActionID)
|
||||||
|
{
|
||||||
|
case ACT_XFR_START :
|
||||||
|
DeviceManager::Default()->mTransferAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_XFR_STOP :
|
||||||
|
DeviceManager::Default()->mStopTransferAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_XFR_PROGRESS_PASSIVE :
|
||||||
|
DeviceManager::Default()->mGetTransferProgressAction->responsed();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case USRV_INFOCFG:
|
||||||
|
switch(aActionID)
|
||||||
|
{
|
||||||
|
case ACT_IFCFG_VERINFO :
|
||||||
|
DeviceManager::Default()->mGetSoftwareVersionAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_IFCFG_HBCFG :
|
||||||
|
DeviceManager::Default()->mSetHeartBeatAction->responsed();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case USRV_CONTROL:
|
||||||
|
switch(aActionID)
|
||||||
|
{
|
||||||
|
case ACT_CTL_PUMP:
|
||||||
|
DeviceManager::Default()->mPumpControlAction->responsed();
|
||||||
|
break;
|
||||||
|
case ACT_CTL_PWRDOWN:
|
||||||
|
DeviceManager::Default()->mShutDownAction->responsed();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void infoReceived(int aServerID, int aActionID, const QString& aContents);
|
void infoReceived(int aServerID, int aActionID, const QString& aContents);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void responsed(int aServerID, int aActionID);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INFORECEIVEWORKER_H
|
#endif // INFORECEIVEWORKER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user