From 5c558a6cea6040c49dfde7a7ab8f61c84d4b11fc Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 06 六月 2025 16:34:15 +0800
Subject: [PATCH] 1.当前搬送任务的人工终止操作。
---
SourceCode/Bond/Servo/CMaster.cpp | 24 ++++++++++++++++++++++++
SourceCode/Bond/Servo/CMaster.h | 1 +
SourceCode/Bond/Servo/ServoDlg.cpp | 5 +++++
SourceCode/Bond/Servo/CRobotTaskDlg.cpp | 8 +++++---
4 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index bc2a884..e65347c 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1200,4 +1200,28 @@
return pTask;
}
+ int CMaster::abortCurrentTask()
+ {
+ lock();
+ if (m_pActiveRobotTask != nullptr) {
+ m_pActiveRobotTask->abort();
+ }
+ unlock();
+
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, ROBOT_EVENT_ABORT);
+ }
+
+ lock();
+ if (m_pActiveRobotTask != nullptr) {
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
+ }
+ unlock();
+
+ // 当前任务手动中止后,停止调度,需要操作员在解决问题后,重新启动
+ stop();
+
+ return 0;
+ }
}
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 9d00447..8a879dd 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -63,6 +63,7 @@
std::list<CEquipment*>& getEquipmentList();
CEquipment* getEquipment(int id);
void setCacheFilepath(const char* pszFilepath);
+ int abortCurrentTask();
private:
inline void lock() { EnterCriticalSection(&m_criticalSection); }
diff --git a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
index b354216..cb39af5 100644
--- a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
+++ b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
@@ -194,8 +194,10 @@
void CRobotTaskDlg::OnBnClickedAbortTask()
{
- if (m_pRobotTask) {
- m_pRobotTask->abort();
- AfxMessageBox(_T("浠诲姟宸插仠姝€��"));
+ int ret = AfxMessageBox(_T("纭瑕佺粓姝㈠綋鍓嶆惉閫佷换鍔″悧?闄ら潪鍙戠敓浜嗗紓甯革紝鍚﹀垯璇蜂笉瑕佹墜鍔ㄧ粓姝换鍔★紒"), MB_OKCANCEL | MB_ICONEXCLAMATION);
+ if (ret != IDOK) {
+ return;
}
+
+ theApp.m_model.getMaster().abortCurrentTask();
}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 62e21ac..e689f1a 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -175,6 +175,7 @@
SERVO::MASTERSTATE state = theApp.m_model.getMaster().getState();
if (state == SERVO::MASTERSTATE::READY) {
m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE);
+ m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_NORMAL);
m_pMyStatusbar->setForegroundColor(RGB(0, 0, 0));
KillTimer(TIMER_ID_UPDATE_RUMTIME);
@@ -183,6 +184,7 @@
m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)strText);
}
else if (state == SERVO::MASTERSTATE::RUNNING) {
+ m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(FALSE);
m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(TRUE);
m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_RUNNING);
m_pMyStatusbar->setForegroundColor(RGB(255, 255, 255));
@@ -211,6 +213,9 @@
else if (exCode == ROBOT_EVENT_FINISH) {
m_pMyStatusbar->setCurTaskBtnText("无");
}
+ else if (exCode == ROBOT_EVENT_ABORT) {
+ m_pMyStatusbar->setCurTaskBtnText("无");
+ }
}
}
--
Gitblit v1.9.3