Change pump action to AsyncAion from SyncAction.
This commit is contained in:
@@ -17,6 +17,7 @@ DmsAsyncAction::DmsAsyncAction(int aServerId, int aActionId, QObject* aObject, c
|
||||
, mResponseSignal(aResponseSignal)
|
||||
, mSendData()
|
||||
, mIsResponsed(false)
|
||||
, mIsRunning(false)
|
||||
{
|
||||
mTimer->setSingleShot(true);
|
||||
mTimer->setInterval(TIMEOUT_MSEC);
|
||||
@@ -30,9 +31,14 @@ DmsAsyncAction::~DmsAsyncAction()
|
||||
disconnect(mObject, ("2" + mResponseSignal).toStdString().c_str(), mTimer, SLOT(stop()));
|
||||
}
|
||||
|
||||
void DmsAsyncAction::setSendData(const QString& aData)
|
||||
{
|
||||
mSendData = 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)
|
||||
@@ -45,7 +51,7 @@ bool DmsAsyncAction::execute()
|
||||
|
||||
void DmsAsyncAction::sendTimeoutSignal()
|
||||
{
|
||||
if(!mIsResponsed)
|
||||
if(!mIsResponsed)
|
||||
{
|
||||
emit timeout();
|
||||
}
|
||||
@@ -58,7 +64,7 @@ void DmsAsyncAction::setTimeoutInterval(int aMsec)
|
||||
|
||||
void DmsAsyncAction::responsed()
|
||||
{
|
||||
if(mTimer->isActive())
|
||||
if(mTimer->isActive())
|
||||
{
|
||||
mIsResponsed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user