feat: Add some error code.

This commit is contained in:
sunwen
2025-06-25 11:12:11 +08:00
parent 32196fc26c
commit 00d4852c81
5 changed files with 52 additions and 22 deletions

View File

@@ -146,25 +146,25 @@ void DeviceManager::initDevice()
mDrainageControlAction->setTimeoutInterval(WATERPROCESS_TIMEOUT); mDrainageControlAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
connect(mDrainageControlAction, &DmsAsyncAction::timeout, [this]() connect(mDrainageControlAction, &DmsAsyncAction::timeout, [this]()
{ {
this->processDrainageResult("{\"code\":-1}"); this->processDrainageResult("{\"code\":-1,\"info\":\"454\"}");
}); });
mWaterfloodAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WINJECT, this, "responseWaterflood(const QString&)", this); mWaterfloodAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WINJECT, this, "responseWaterflood(const QString&)", this);
mWaterfloodAction->setTimeoutInterval(WATERPROCESS_TIMEOUT); mWaterfloodAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
connect(mWaterfloodAction, &DmsAsyncAction::timeout, [this]() connect(mWaterfloodAction, &DmsAsyncAction::timeout, [this]()
{ {
this->processWaterfloodResult("{\"code\":-1}"); this->processWaterfloodResult("{\"code\":-1,\"info\":\"454\"}");
}); });
mWaterCleanAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WCLEAN, this, "responseWaterclean(const QString&)", this); mWaterCleanAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WCLEAN, this, "responseWaterclean(const QString&)", this);
mWaterCleanAction->setTimeoutInterval(WATERPROCESS_TIMEOUT); mWaterCleanAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
connect(mWaterCleanAction, &DmsAsyncAction::timeout, [this]() connect(mWaterCleanAction, &DmsAsyncAction::timeout, [this]()
{ {
this->processWaterCleanResult("{\"code\":-1}"); this->processWaterCleanResult("{\"code\":-1,\"info\":\"454\"}");
}); });
mWaterProcessExitAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WEXIT, this, "responseWaterProcessExit(const QString&)", this); mWaterProcessExitAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_WEXIT, this, "responseWaterProcessExit(const QString&)", this);
mWaterProcessExitAction->setTimeoutInterval(WATERPROCESS_TIMEOUT); mWaterProcessExitAction->setTimeoutInterval(WATERPROCESS_TIMEOUT);
connect(mWaterProcessExitAction, &DmsAsyncAction::timeout, [this]() connect(mWaterProcessExitAction, &DmsAsyncAction::timeout, [this]()
{ {
this->processWaterProcessExitResult("{\"code\":-1}"); this->processWaterProcessExitResult("{\"code\":-1,\"info\":\"454\"}");
}); });
mGetAutoLocatePositionAction = new DmsAsyncAction(USRV_CONTROL, ACT_CTL_MOTION_POSITION, this, "responseGetAutoLocatePosition(const QString&)", this); 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 = new DmsAsyncAction(USRV_INFOCFG, ACT_IFCFG_VERINFO, this,"responseGetSoftwareVersion(const QString&)", this);
@@ -238,11 +238,11 @@ void DeviceManager::initDevice()
mCheckInitStatusTimer = startTimer(500); mCheckInitStatusTimer = startTimer(500);
} }
void DeviceManager::initGUI(bool aIsInitSucceed) void DeviceManager::initGUI(bool aIsInitSucceed, int aCode)
{ {
if(!AppGlobalValues::DBconnected().toBool()) if(!AppGlobalValues::DBconnected().toBool())
{ {
emitErrorCallback(tr("Fail to connect to DB!Reboot device to try!")); emitErrorCallback(tr("Fail to connect to DB!Reboot device to try!") + tr("\nError: ") + QString::number(455));
emit initializeFinished(); emit initializeFinished();
return; return;
} }
@@ -275,7 +275,7 @@ void DeviceManager::initGUI(bool aIsInitSucceed)
else else
{ {
UsctStateManager::getInstance()->setState(DmsState, false); UsctStateManager::getInstance()->setState(DmsState, false);
QString msg = tr("Initialize Failed."); QString msg = tr("Initialize Failed.") + tr("\nError: ") + QString::number(aCode);
THROW_ERROR(msg); THROW_ERROR(msg);
emit initializeProgress("33"); emit initializeProgress("33");
QThread::msleep(500); QThread::msleep(500);
@@ -605,7 +605,7 @@ void DeviceManager::checkInitStatus()
killTimer(mCheckInitStatusTimer); killTimer(mCheckInitStatusTimer);
mCheckInitStatusTimer = -1; mCheckInitStatusTimer = -1;
} }
initGUI(false); initGUI(false, 454);
return; return;
} }
@@ -617,7 +617,7 @@ void DeviceManager::checkInitStatus()
killTimer(mCheckInitStatusTimer); killTimer(mCheckInitStatusTimer);
mCheckInitStatusTimer = -1; mCheckInitStatusTimer = -1;
} }
initGUI(true); initGUI(true, 0);
} }
else if(jsonObj["code"].toInt() == 2) else if(jsonObj["code"].toInt() == 2)
{ {
@@ -626,7 +626,7 @@ void DeviceManager::checkInitStatus()
killTimer(mCheckInitStatusTimer); killTimer(mCheckInitStatusTimer);
mCheckInitStatusTimer = -1; mCheckInitStatusTimer = -1;
} }
initGUI(false); initGUI(false, jsonObj["info"].toInt());
} }
} }
@@ -1217,7 +1217,7 @@ void DeviceManager::processDrainageResult(const QString& aResponse)
} }
emit startDrainageControlResult(false); emit startDrainageControlResult(false);
QString msg = tr("Open drain vavle failed."); QString msg = tr("Open drain vavle failed.") + tr("\nError: ") + jsonObj["info"].toString();
THROW_ERROR(msg); THROW_ERROR(msg);
} }
@@ -1241,7 +1241,7 @@ void DeviceManager::processWaterfloodResult(const QString &aResponse)
} }
emit startWaterfloodResult(false); emit startWaterfloodResult(false);
QString msg = tr("Water injection failed."); QString msg = tr("Water injection failed.")+ tr("\nError: ") + jsonObj["info"].toString();;
THROW_ERROR(msg); THROW_ERROR(msg);
} }
@@ -1265,7 +1265,7 @@ void DeviceManager::processWaterCleanResult(const QString &aResponse)
} }
emit startWaterCleanResult(false); emit startWaterCleanResult(false);
QString msg = tr("Cleaning startup failed."); QString msg = tr("Cleaning startup failed.") + tr("\nError: ") + jsonObj["info"].toString();
THROW_ERROR(msg); THROW_ERROR(msg);
} }
@@ -1294,10 +1294,10 @@ void DeviceManager::processWaterProcessFinishedResult(const QString &aResponse)
QJsonObject jsonObj = toJsonObject(aResponse); QJsonObject jsonObj = toJsonObject(aResponse);
if(jsonObj["code"].toInt() == 0 ) if(jsonObj["code"].toInt() == 0 )
{ {
emit waterProcessFinishedResult(true); emit waterProcessFinishedResult(true, jsonObj["info"].toString());
return; return;
} }
emit waterProcessFinishedResult(false); emit waterProcessFinishedResult(false, jsonObj["info"].toString());
} }
void DeviceManager::updateReconConnectionState(bool aIsConnected) void DeviceManager::updateReconConnectionState(bool aIsConnected)

View File

@@ -112,7 +112,7 @@ private:
void checkInitStatus(); void checkInitStatus();
bool startAutoLocate(); bool startAutoLocate();
void stopAutoLocate(); void stopAutoLocate();
void initGUI(bool aIsInitSucceed); void initGUI(bool aIsInitSucceed, int aCode);
void checkDataQuality(); void checkDataQuality();
void processScanProgress(const QString& aProgress); void processScanProgress(const QString& aProgress);
@@ -189,7 +189,7 @@ signals:
void startWaterfloodResult(bool aIsSucessful); void startWaterfloodResult(bool aIsSucessful);
void startWaterCleanResult(bool aIsSucessful); void startWaterCleanResult(bool aIsSucessful);
void exitWaterProcessResult(bool aIsSucessful); void exitWaterProcessResult(bool aIsSucessful);
void waterProcessFinishedResult(bool aIsSucessful); void waterProcessFinishedResult(bool aIsSucessful, const QString& aInfoCode);
void startAutoLocateResult(bool aIsSucessful); void startAutoLocateResult(bool aIsSucessful);
void updateAutoLocatePosition(int aX, int aY, int aZ); void updateAutoLocatePosition(int aX, int aY, int aZ);
void autolocatePositionEffective(); void autolocatePositionEffective();

View File

@@ -271,7 +271,7 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
} }
}); });
connect(DeviceManager::Default(), &DeviceManager::waterProcessFinishedResult, [this](bool aIsSucessful) connect(DeviceManager::Default(), &DeviceManager::waterProcessFinishedResult, [this](bool aIsSucessful, const QString& aInfo)
{ {
if(!mIsWaterProcessing) if(!mIsWaterProcessing)
{ {
@@ -302,13 +302,13 @@ void ScanFormWidget::initCommandWidget(QHBoxLayout *layout)
switch (mWaterProcessMode) switch (mWaterProcessMode)
{ {
case WaterFloodMode: case WaterFloodMode:
message = tr("Waterflood failed."); message = tr("Waterflood failed.") + tr("\nError: ") + aInfo;
break; break;
case DrainageMode: case DrainageMode:
message = tr("Drainage failed."); message = tr("Drainage failed.") + tr("\nError: ") + aInfo;
break; break;
case WaterCleanMode: case WaterCleanMode:
message = tr("Clean failed."); message = tr("Clean failed.") + tr("\nError: ") + aInfo;
break; break;
} }
EventCenter::Default()->triggerEvent(GUIEvents::GUIErrorRaise, nullptr, (QObject*)&message); EventCenter::Default()->triggerEvent(GUIEvents::GUIErrorRaise, nullptr, (QObject*)&message);

View File

@@ -418,6 +418,11 @@ After lying down, click the confirm buttonto start scanning on the next side.</s
<source>Cleaning startup failed.</source> <source>Cleaning startup failed.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>
Error: </source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>DialogManager</name> <name>DialogManager</name>
@@ -1691,6 +1696,11 @@ The emergency button has been pushed. Please reset it before other operations.</
<source>Draining</source> <source>Draining</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>
Error: </source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>ScanSearchCriteriaForm</name> <name>ScanSearchCriteriaForm</name>

View File

@@ -515,6 +515,17 @@ progress:99%</source>
<source>Fail to connect to DB!Reboot device to try!</source> <source>Fail to connect to DB!Reboot device to try!</source>
<translation type="unfinished">!</translation> <translation type="unfinished">!</translation>
</message> </message>
<message>
<location filename="../device/DeviceManager.cpp" line="245"/>
<location filename="../device/DeviceManager.cpp" line="278"/>
<location filename="../device/DeviceManager.cpp" line="1220"/>
<location filename="../device/DeviceManager.cpp" line="1244"/>
<location filename="../device/DeviceManager.cpp" line="1268"/>
<source>
Error: </source>
<translation type="unfinished">
: </translation>
</message>
<message> <message>
<location filename="../device/DeviceManager.cpp" line="345"/> <location filename="../device/DeviceManager.cpp" line="345"/>
<source>Device is not ready, start scan operation failed!</source> <source>Device is not ready, start scan operation failed!</source>
@@ -2570,6 +2581,15 @@ The emergency button has been pushed. Please reset it before other operations.</
<source>Drainage finished. Please do the disinfection in next step.</source> <source>Drainage finished. Please do the disinfection in next step.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../forms/scan/ScanFormWidget.cpp" line="305"/>
<location filename="../forms/scan/ScanFormWidget.cpp" line="308"/>
<location filename="../forms/scan/ScanFormWidget.cpp" line="311"/>
<source>
Error: </source>
<translation type="unfinished">
: </translation>
</message>
<message> <message>
<location filename="../forms/scan/ScanFormWidget.cpp" line="308"/> <location filename="../forms/scan/ScanFormWidget.cpp" line="308"/>
<source>Drainage failed.</source> <source>Drainage failed.</source>
@@ -3428,7 +3448,7 @@ parameters
<location filename="../forms/select/WorklistTableModel.cpp" line="8"/> <location filename="../forms/select/WorklistTableModel.cpp" line="8"/>
<location filename="../forms/select/WorklistTableModel.cpp" line="131"/> <location filename="../forms/select/WorklistTableModel.cpp" line="131"/>
<source>Gender</source> <source>Gender</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../forms/select/WorklistTableModel.cpp" line="8"/> <location filename="../forms/select/WorklistTableModel.cpp" line="8"/>