Add shutdown widget.
This commit is contained in:
@@ -36,6 +36,7 @@ namespace
|
||||
{
|
||||
const int PREVIEW_IMAGE_WH = 140;
|
||||
const unsigned int GET_TEMPERATURE_TIME = 60000;
|
||||
const int SHUT_DOWN_TIMEOUT = 180000;//3 minitues
|
||||
const QString DEFAULT_DMS_START_FAILED = "Dms start failed.";
|
||||
const QString RECON_TRANSFER_PATH = "/home/krad/TestStore";
|
||||
|
||||
@@ -101,7 +102,7 @@ void DeviceManager::initDevice()
|
||||
// preview
|
||||
connect(EventCenter::Default(), &EventCenter::RequestPreviewScan,this, &DeviceManager::startPreview);
|
||||
//shutdown
|
||||
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdown);
|
||||
connect(EventCenter::Default(), &EventCenter::RequestShutdown, this, &DeviceManager::shutdownDms);
|
||||
//Drainage
|
||||
connect(EventCenter::Default(), &EventCenter::RequestDrainage, this, [this](QObject* sender, QObject* detail)
|
||||
{
|
||||
@@ -126,7 +127,10 @@ void DeviceManager::initDevice()
|
||||
mGetSoftwareVersionAction = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
|
||||
mGetDeviceTemperatureAction = new DmsAsyncAction(USRV_SCAN, ACT_SCAN_TEMP, this, "responseGetDeviceTemperature(const QString&)", this);
|
||||
mStopTransferAction = new DmsAsyncAction(USRV_XFR, ACT_XFR_STOP, this, "responseStopTransfer(const QString&)", this);
|
||||
mShutDownAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_PWRDOWN, this, "responseShutDown(const QString&)", this);
|
||||
mShutDownAction->setTimeoutInterval(SHUT_DOWN_TIMEOUT);
|
||||
connect(mGetScanProgressAction, &DmsAsyncAction::timeout, this, &DeviceManager::scanTimeout);
|
||||
connect(mShutDownAction, &DmsAsyncAction::timeout, this, &DeviceManager::shutdownDmsFailed);
|
||||
|
||||
|
||||
//dmsInfoReceiverThread
|
||||
@@ -600,6 +604,10 @@ void DeviceManager::processReceiveDMSInfoResult(int aServerID, int aActionID, co
|
||||
case ACT_CTL_PUMP:
|
||||
emit responsePumpControl(aContents);
|
||||
break;
|
||||
case ACT_CTL_PWRDOWN:
|
||||
emit responseShutDown(aContents);
|
||||
processShutDownDms(aContents);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -731,14 +739,42 @@ void DeviceManager::getScanProcess()
|
||||
mGetScanProgressAction->execute();
|
||||
}
|
||||
|
||||
void DeviceManager::shutdown()
|
||||
void DeviceManager::shutdownDms()
|
||||
{
|
||||
if(mIsTransfering)
|
||||
{
|
||||
QString msg = "Data is currently being transmitted, please shut down later.";
|
||||
QString msg = tr("Data is currently being transmitted, please shut down later.");
|
||||
THROW_ERROR(msg);
|
||||
return;
|
||||
}
|
||||
QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
|
||||
|
||||
if(!mShutDownAction->execute())
|
||||
{
|
||||
QString msg = tr("Shut down failed, please push emergency button to shutdown.");
|
||||
THROW_ERROR(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
AppGlobalValues::setInProcessing(true);
|
||||
emit shutdownDmsSended();
|
||||
}
|
||||
|
||||
void DeviceManager::processShutDownDms(const QString& aResponse)
|
||||
{
|
||||
QJsonObject jsonObj = toJsonObject(aResponse);
|
||||
if(jsonObj.contains("code") && jsonObj["code"].toInt() == 0)
|
||||
{
|
||||
shutdownOperationSystem();
|
||||
return;
|
||||
}
|
||||
AppGlobalValues::setInProcessing(false);
|
||||
emit shutdownDmsFailed();
|
||||
}
|
||||
|
||||
void DeviceManager::shutdownOperationSystem()
|
||||
{
|
||||
qDebug()<< "shut down OS";
|
||||
//QProcess::startDetached("shutdown", QStringList() << "-h" << "now");
|
||||
}
|
||||
|
||||
void DeviceManager::insertEmptyScanRecord()
|
||||
|
||||
Reference in New Issue
Block a user