feat: Add water process in GUI.
This commit is contained in:
@@ -40,7 +40,7 @@ namespace
|
||||
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 int WATERPROCESS_TIMEOUT = 3000;//3 seconds
|
||||
const int GETDMSVERSION_TIMEOUT = 5000;
|
||||
const int EFFECTIVE_POSITION_RADIUS = 125;
|
||||
const int EFFECTIVE_POSITION_Z_START = 150;
|
||||
@@ -113,10 +113,10 @@ void DeviceManager::initDevice()
|
||||
//shutdown
|
||||
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdownDms);
|
||||
//Drainage
|
||||
connect(EventCenter::Default(), &EventCenter::RequestDrainage, this, [this](QObject* sender, QObject* detail)
|
||||
{
|
||||
controlDrainage(*(QString*)detail);
|
||||
});
|
||||
connect(EventCenter::Default(), &EventCenter::RequestDrainage, this, &DeviceManager::startDrainage);
|
||||
connect(EventCenter::Default(), &EventCenter::RequestWaterflood, this, &DeviceManager::startWaterflood);
|
||||
connect(EventCenter::Default(), &EventCenter::RequestWaterClean, this, &DeviceManager::startWaterClean);
|
||||
connect(EventCenter::Default(), &EventCenter::RequestWaterModeExit, this, &DeviceManager::exitWaterProcess);
|
||||
//AutoLocate
|
||||
connect(EventCenter::Default(), &EventCenter::StartScanProcess, this, &DeviceManager::startScanProcess);
|
||||
connect(EventCenter::Default(), &EventCenter::StopScanProcess, this, &DeviceManager::stopScanProcess);
|
||||
@@ -140,8 +140,30 @@ void DeviceManager::initDevice()
|
||||
mGetDeviceTemperatureAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_TEMP, this, "responseGetDeviceTemperature(const QString&)", this);
|
||||
mShutDownAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PWRDOWN, this, "responseShutDown(const QString&)", this);
|
||||
mShutDownAction->setTimeoutInterval(SHUT_DOWN_TIMEOUT);
|
||||
mPumpControlAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PUMP, this, "responsePumpControl(const QString&)", this);
|
||||
mPumpControlAction->setTimeoutInterval(PUMP_TIMEOUT);
|
||||
mDrainageControlAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WDRAIN, this, "responseDrainageControl(const QString&)", this);
|
||||
mDrainageControlAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
|
||||
connect(mDrainageControlAction, &DmsAsyncAction::timeout, [this]()
|
||||
{
|
||||
this->processDrainageResult("{\"code\":-1}");
|
||||
});
|
||||
mWaterfloodAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WINJECT, this, "responseWaterflood(const QString&)", this);
|
||||
mWaterfloodAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
|
||||
connect(mWaterfloodAction, &DmsAsyncAction::timeout, [this]()
|
||||
{
|
||||
this->processWaterfloodResult("{\"code\":-1}");
|
||||
});
|
||||
mWaterCleanAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WCLEAN, this, "responseWaterclean(const QString&)", this);
|
||||
mWaterCleanAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
|
||||
connect(mWaterCleanAction, &DmsAsyncAction::timeout, [this]()
|
||||
{
|
||||
this->processWaterCleanResult("{\"code\":-1}");
|
||||
});
|
||||
mWaterProcessExitAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WEXIT, this, "responseWaterProcessExit", this);
|
||||
mWaterProcessExitAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
|
||||
connect(mWaterProcessExitAction, &DmsAsyncAction::timeout, [this]()
|
||||
{
|
||||
this->processWaterProcessExitResult("{\"code\":-1}");
|
||||
});
|
||||
mGetAutoLocatePositionAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_MOTION_POSITION, this, "responseGetAutoLocatePosition(const QString&)", this);
|
||||
mGetSoftwareVersionAction = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
|
||||
mGetSoftwareVersionAction->setTimeoutInterval(GETDMSVERSION_TIMEOUT);
|
||||
@@ -150,10 +172,6 @@ void DeviceManager::initDevice()
|
||||
{
|
||||
emit getDmsVersionResponsed("DMS Version Fetch Error");
|
||||
});
|
||||
connect(mPumpControlAction, &DmsAsyncAction::timeout, [this]()
|
||||
{
|
||||
this->processPumpResult("{\"code\":-1}");
|
||||
});
|
||||
connect(mGetScanProgressAction, &DmsAsyncAction::timeout, this, &DeviceManager::scanTimeout);
|
||||
connect(mShutDownAction, &DmsAsyncAction::timeout, this, &DeviceManager::shutdownDmsFailed);
|
||||
connect(mGetAutoLocatePositionAction, &DmsAsyncAction::timeout, [this]()
|
||||
@@ -728,9 +746,24 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
|
||||
case USRV_CONTROL:
|
||||
switch(aActionID)
|
||||
{
|
||||
case ACT_CTL_PUMP:
|
||||
emit responsePumpControl(aContents);
|
||||
processPumpResult(aContents);
|
||||
case ACT_CTL_WDRAIN:
|
||||
emit responseDrainageControl(aContents);
|
||||
processDrainageResult(aContents);
|
||||
break;
|
||||
case ACT_CTL_WINJECT:
|
||||
emit responseWaterflood(aContents);
|
||||
processWaterfloodResult(aContents);
|
||||
break;
|
||||
case ACT_CTL_WCLEAN:
|
||||
emit responseWaterclean(aContents);
|
||||
processWaterCleanResult(aContents);
|
||||
break;
|
||||
case ACT_CTL_WEXIT:
|
||||
emit responseWaterProcessExit(aContents);
|
||||
processWaterProcessExitResult(aContents);
|
||||
break;
|
||||
case ACT_CTL_WRESPOSE:
|
||||
processWaterProcessFinishedResult(aContents);
|
||||
break;
|
||||
case ACT_CTL_PWRDOWN:
|
||||
emit responseShutDown(aContents);
|
||||
@@ -1125,31 +1158,109 @@ bool DeviceManager::getCEStatus()
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManager::controlDrainage(const QString& aCode)
|
||||
void DeviceManager::startDrainage()
|
||||
{
|
||||
mPumpControlAction->setSendData(QString("{\"valve\":%1}").arg(aCode));
|
||||
if(!mPumpControlAction->execute())
|
||||
if(!mDrainageControlAction->execute())
|
||||
{
|
||||
emit startPumpControlResult(false);
|
||||
emit startDrainageControlResult(false);
|
||||
QString msg = tr("Open pump failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::processPumpResult(const QString& aResponse)
|
||||
void DeviceManager::processDrainageResult(const QString& aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit startPumpControlResult(true);
|
||||
emit startDrainageControlResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
emit startPumpControlResult(false);
|
||||
emit startDrainageControlResult(false);
|
||||
QString msg = tr("Open pump failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
|
||||
void DeviceManager::startWaterflood()
|
||||
{
|
||||
if(!mWaterfloodAction->execute())
|
||||
{
|
||||
emit startWaterfloodResult(false);
|
||||
QString msg = tr("Water injection failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::processWaterfloodResult(const QString &aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit startWaterfloodResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
emit startWaterfloodResult(false);
|
||||
QString msg = tr("Water injection failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
|
||||
void DeviceManager::startWaterClean()
|
||||
{
|
||||
if(!mWaterCleanAction->execute())
|
||||
{
|
||||
emit startWaterCleanResult(false);
|
||||
QString msg = tr("Cleaning failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::processWaterCleanResult(const QString &aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit startWaterCleanResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
emit startWaterCleanResult(false);
|
||||
QString msg = tr("Cleaning failed.");
|
||||
THROW_ERROR(msg);
|
||||
}
|
||||
|
||||
void DeviceManager::exitWaterProcess()
|
||||
{
|
||||
if(!mWaterProcessExitAction->execute())
|
||||
{
|
||||
emit exitWaterProcessResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::processWaterProcessExitResult(const QString &aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit exitWaterProcessResult(true);
|
||||
return;
|
||||
}
|
||||
|
||||
emit exitWaterProcessResult(false);
|
||||
}
|
||||
|
||||
void DeviceManager::processWaterProcessFinishedResult(const QString &aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj["code"].toInt() == 0 )
|
||||
{
|
||||
emit waterProcessFinishedResult(true);
|
||||
return;
|
||||
}
|
||||
emit waterProcessFinishedResult(false);
|
||||
}
|
||||
|
||||
void DeviceManager::updateReconConnectionState(bool aIsConnected)
|
||||
{
|
||||
EventCenter::Default()->triggerEvent(ReconConnectionUpdated, nullptr, (QObject*)&aIsConnected);
|
||||
|
||||
@@ -104,7 +104,10 @@ private:
|
||||
bool getCEStatus();
|
||||
bool startCEScan();
|
||||
void initEmptyScanMeasurementID();
|
||||
void controlDrainage(const QString& aCode);
|
||||
void startDrainage();
|
||||
void startWaterflood();
|
||||
void startWaterClean();
|
||||
void exitWaterProcess();
|
||||
void checkInitStatus();
|
||||
bool startAutoLocate();
|
||||
void stopAutoLocate();
|
||||
@@ -120,7 +123,11 @@ private:
|
||||
void processPreviewData(const QString& aPreviewData);
|
||||
void processDeviceTemperature(const QString& aResponseTemperature);
|
||||
void processShutDownDms(const QString& aResponse);
|
||||
void processPumpResult(const QString& aResponse);
|
||||
void processDrainageResult(const QString& aResponse);
|
||||
void processWaterfloodResult(const QString& aResponse);
|
||||
void processWaterCleanResult(const QString& aResponse);
|
||||
void processWaterProcessExitResult(const QString& aResponse);
|
||||
void processWaterProcessFinishedResult(const QString& aResponse);
|
||||
void processGetSoftwareVersion(const QString& aResponse);
|
||||
void processEmergencyButtonReset(const QString& aResponse);
|
||||
|
||||
@@ -152,7 +159,10 @@ signals:
|
||||
void responsePreviewScan(const QString& aResponse);
|
||||
void responseGetSoftwareVersion(const QString& aSoftwareVersion);
|
||||
void responseGetCEStatus(const QString& aProgress);
|
||||
void responsePumpControl(const QString& aResponse);
|
||||
void responseDrainageControl(const QString& aResponse);
|
||||
void responseWaterflood(const QString& aResponse);
|
||||
void responseWaterclean(const QString& aResponse);
|
||||
void responseWaterProcessExit(const QString& aResponse);
|
||||
void responseSetSimulatorMode(const QString& aResponse);
|
||||
void responseSetHeartBeat(const QString& aResponese);
|
||||
void responseShutDown(const QString& aResponse);
|
||||
@@ -172,7 +182,11 @@ signals:
|
||||
void initializeFinished();
|
||||
void initializeProgress(const QString& aProgress);
|
||||
void startPreviewScanResult(bool aIsSucessful);
|
||||
void startPumpControlResult(bool aIsSucessful);
|
||||
void startDrainageControlResult(bool aIsSucessful);
|
||||
void startWaterfloodResult(bool aIsSucessful);
|
||||
void startWaterCleanResult(bool aIsSucessful);
|
||||
void exitWaterProcessResult(bool aIsSucessful);
|
||||
void waterProcessFinishedResult(bool aIsSucessful);
|
||||
void startAutoLocateResult(bool aIsSucessful);
|
||||
void updateAutoLocatePosition(int aX, int aY, int aZ);
|
||||
void autolocatePositionEffective();
|
||||
@@ -222,7 +236,10 @@ private:
|
||||
DmsAsyncAction* mGetDeviceTemperatureAction = nullptr;
|
||||
DmsAsyncAction* mGetScanProgressAction = nullptr;
|
||||
DmsAsyncAction* mShutDownAction = nullptr;
|
||||
DmsAsyncAction* mPumpControlAction = nullptr;
|
||||
DmsAsyncAction* mDrainageControlAction = nullptr;
|
||||
DmsAsyncAction* mWaterfloodAction = nullptr;
|
||||
DmsAsyncAction* mWaterCleanAction = nullptr;
|
||||
DmsAsyncAction* mWaterProcessExitAction = nullptr;
|
||||
DmsAsyncAction* mGetAutoLocatePositionAction = nullptr;
|
||||
DmsAsyncAction* mGetSoftwareVersionAction = nullptr;
|
||||
DmsAsyncAction* mEmergencyResetAction = nullptr;
|
||||
|
||||
@@ -54,6 +54,7 @@ void DmsAsyncAction::sendTimeoutSignal()
|
||||
{
|
||||
if(!mIsResponsed)
|
||||
{
|
||||
LOG_SYS_OPERATION(QString("GUI -> DMS : %1-%2, Time out.").arg(mServerId).arg(mActionId));
|
||||
emit timeout();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +93,17 @@ void InfoReceiveWorker::responsed(int aServerID, int aActionID)
|
||||
case USRV_CONTROL:
|
||||
switch(aActionID)
|
||||
{
|
||||
case ACT_CTL_PUMP:
|
||||
DeviceManager::Default()->mPumpControlAction->responsed();
|
||||
case ACT_CTL_WDRAIN:
|
||||
DeviceManager::Default()->mDrainageControlAction->responsed();
|
||||
break;
|
||||
case ACT_CTL_WINJECT:
|
||||
DeviceManager::Default()->mWaterfloodAction->responsed();
|
||||
break;
|
||||
case ACT_CTL_WCLEAN:
|
||||
DeviceManager::Default()->mWaterCleanAction->responsed();
|
||||
break;
|
||||
case ACT_CTL_WEXIT:
|
||||
DeviceManager::Default()->mWaterProcessExitAction->responsed();
|
||||
break;
|
||||
case ACT_CTL_PWRDOWN:
|
||||
DeviceManager::Default()->mShutDownAction->responsed();
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
|
||||
//-------------------- 定义服务和动作 ---------------------------
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
USRV_NONE = 0,
|
||||
USRV_SCAN, //扫查服务
|
||||
USRV_XFR, //数据传输服务
|
||||
@@ -17,7 +18,8 @@ enum{
|
||||
};
|
||||
|
||||
//扫查服务动作
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_SCAN_NONE = 0,
|
||||
ACT_SCAN_RESP, //上报扫查状态(错误码,结束等)
|
||||
ACT_SCAN_PREVIEW, //预扫
|
||||
@@ -40,7 +42,8 @@ enum{
|
||||
};
|
||||
|
||||
//数据传输服务
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_XFR_NONE = 0,
|
||||
ACT_XFR_RESP, //上报传输状态(错误码,结束等)
|
||||
ACT_XFR_START, //启动传输(含SRC和DST参数)
|
||||
@@ -52,7 +55,8 @@ enum{
|
||||
};
|
||||
|
||||
//信息与配置服务
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_IFCFG_NONE = 0,
|
||||
ACT_IFCFG_RESP, //默认的配置回复
|
||||
ACT_IFCFG_VERINFO, //GUI发给设备为请求数据,设备上报数据内容(软硬件版本,系统信息等一系列信息。)
|
||||
@@ -67,7 +71,8 @@ enum{
|
||||
//杂类控制和调试服务
|
||||
//配置成不透传模式,则XX_RESP永远不会上传数据,有错误也是通过LOG发回来。
|
||||
//如果配置成透传,则所有结果都从XX_RESP再上报一次。XX_RESP的另外一个作用就是打包和判定是否需要上传。
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_CTL_NONE = 0,
|
||||
ACT_CTL_MOTOR_CFG, //电机配置(0不透传,1透传)
|
||||
ACT_CTL_MOTOR_CMD, //下发电机控制命令
|
||||
@@ -91,22 +96,29 @@ enum{
|
||||
ACT_CTL_MOTION_STOP, //停止自动定位功能
|
||||
ACT_CTL_MOTION_POSITION, //查询自动定位状态(位置)
|
||||
ACT_CTL_EMG_RESET, //复位急停按钮
|
||||
ACT_CTL_DRIVER, //驱动控制(加载卸载驱动)
|
||||
ACT_CTL_WINJECT = 40, //注水
|
||||
ACT_CTL_WDRAIN, //排水
|
||||
ACT_CTL_WCLEAN, //清洁消毒
|
||||
ACT_CTL_WRESPOSE, //动作结束反馈
|
||||
ACT_CTL_WEXIT, //状态强制退出(都恢复到初始状态)
|
||||
ACT_CTL_WSETERR, //模拟设置错误码
|
||||
ACT_CTL_DRIVER = 100, //驱动控制(加载卸载驱动)
|
||||
ACT_CTL_EXIT, //退出程序和守护进程
|
||||
|
||||
};
|
||||
|
||||
//设备升级
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_FMW_NONE = 0,
|
||||
ACT_FMW_RESP, //上报升级结果
|
||||
ACT_FMW_RESP, //上报升级结果
|
||||
ACT_FMW_CFG, //固件升级配置(json格式)
|
||||
ACT_FMW_LOAD, //下载固件到设备
|
||||
ACT_FMW_START, //启动固件升级
|
||||
};
|
||||
|
||||
//日志和报警服务
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_LOGALM_NONE = 0,
|
||||
ACT_LOGALM_RPT, //ACT_LOGALM_RPT改成报警,即少数用户需要感知的消息在这里呈现。
|
||||
ACT_LOGALM_CFG, //日志配置(调整日志等级)
|
||||
@@ -114,13 +126,15 @@ enum{
|
||||
};
|
||||
|
||||
//心跳服务
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_HB_NONE = 0,
|
||||
ACT_HB_BEAT, //心跳包
|
||||
};
|
||||
|
||||
//网络服务
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_NET_NONE = 0,
|
||||
ACT_NET_LOCAL, //向LocalSocket发送数据
|
||||
ACT_NET_REMOTE, //想远程GUI发送数据
|
||||
@@ -132,7 +146,8 @@ enum{
|
||||
};
|
||||
|
||||
//调试诊断服务
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
ACT_DIG_NONE = 0,
|
||||
ACT_DIG_SYNC, //同步状态(板卡以及其他)
|
||||
ACT_DIG_STOP, //停止当前诊断操作
|
||||
@@ -146,4 +161,4 @@ enum{
|
||||
ACT_DIG_SIMULATOR, //模拟功能配置
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user