From 5ee30b85c394e60b5ac4169a8093a8089345189a Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 20 六月 2025 14:02:29 +0800
Subject: [PATCH] 1.任务的回撤实现,在任务详情上增加"回撤"按钮
---
SourceCode/Bond/Servo/CRobotTask.h | 1
SourceCode/Bond/Servo/resource.h | 0
SourceCode/Bond/Servo/CRobotTask.cpp | 5 ++
SourceCode/Bond/Servo/CMaster.cpp | 44 +++++++++++++++++++++
SourceCode/Bond/Servo/CRobotTaskDlg.h | 2 +
SourceCode/Bond/Servo/CMaster.h | 1
SourceCode/Bond/Servo/Model.cpp | 5 +-
SourceCode/Bond/Servo/ServoCommo.h | 1
SourceCode/Bond/Servo/ServoDlg.cpp | 3 +
SourceCode/Bond/Servo/CRobotTaskDlg.cpp | 40 +++++++++++++++----
SourceCode/Bond/Servo/Common.h | 3 +
11 files changed, 92 insertions(+), 13 deletions(-)
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 7349b9b..76ec313 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -879,11 +879,22 @@
LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
}
}
+
+ // 是否回撤
+ else if (m_pActiveRobotTask->isRestoring() &&
+ m_pActiveRobotTask->getSrcPosition() == p->getID()) {
+ CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getSrcSlot());
+ if (pGlass == nullptr) {
+ bOk = TRUE;
+ slot = m_pActiveRobotTask->getSrcSlot();
+ LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
+ }
+ }
}
unlock();
if (!bOk) {
- LOGE("<CMaster>onPreFethedOutJob, 数据校验失败.");
+ LOGE("<CMaster>onPreStoredJob, 数据校验失败.");
}
return bOk;
@@ -932,6 +943,25 @@
}
delete m_pActiveRobotTask;
m_pActiveRobotTask = nullptr;
+ }
+
+ else if (m_pActiveRobotTask != nullptr
+ && m_pActiveRobotTask->isRestoring()
+ && m_pActiveRobotTask->getSrcPosition() == p->getID()) {
+ m_pActiveRobotTask->stored();
+ m_pActiveRobotTask->restored();
+ LOGI("回撤完成...");
+ // 完成此条搬送任务,但要把数据和消息上抛应用层
+ unlock();
+
+
+ lock();
+ if (m_listener.onRobotTaskEvent != nullptr) {
+ m_listener.onRobotTaskEvent(this, m_pActiveRobotTask, ROBOT_EVENT_RESTORE);
+ }
+ delete m_pActiveRobotTask;
+ m_pActiveRobotTask = nullptr;
+ stop();
}
unlock();
}
@@ -1462,6 +1492,18 @@
return 0;
}
+ int CMaster::restoreCurrentTask()
+ {
+ lock();
+ if (m_pActiveRobotTask != nullptr) {
+ m_pActiveRobotTask->restore();
+ }
+ unlock();
+
+
+ return 0;
+ }
+
void CMaster::setPortType(unsigned int index, BOOL enable, int type, int mode,
int cassetteType, int transferMode, BOOL autoChangeEnable)
{
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 28e2f5f..4ff2252 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -66,6 +66,7 @@
CEquipment* getEquipment(int id);
void setCacheFilepath(const char* pszFilepath);
int abortCurrentTask();
+ int restoreCurrentTask();
void setPortType(unsigned int index, BOOL enable, int type, int mode,
int cassetteType, int transferMode, BOOL autoChangeEnable);
diff --git a/SourceCode/Bond/Servo/CRobotTask.cpp b/SourceCode/Bond/Servo/CRobotTask.cpp
index 5b4fbab..9a598d7 100644
--- a/SourceCode/Bond/Servo/CRobotTask.cpp
+++ b/SourceCode/Bond/Servo/CRobotTask.cpp
@@ -290,6 +290,11 @@
m_state = ROBOT_TASK_STATE::Completed;
}
+ void CRobotTask::restored()
+ {
+ m_state = ROBOT_TASK_STATE::Restored;
+ }
+
void CRobotTask::error()
{
m_state = ROBOT_TASK_STATE::Error;
diff --git a/SourceCode/Bond/Servo/CRobotTask.h b/SourceCode/Bond/Servo/CRobotTask.h
index 990e106..5b417a0 100644
--- a/SourceCode/Bond/Servo/CRobotTask.h
+++ b/SourceCode/Bond/Servo/CRobotTask.h
@@ -38,6 +38,7 @@
void pick();
void place();
void restore();
+ void restored();
void completed();
void error();
void abort();
diff --git a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
index ab90d5b..58b6010 100644
--- a/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
+++ b/SourceCode/Bond/Servo/CRobotTaskDlg.cpp
@@ -33,6 +33,7 @@
ON_WM_SIZE()
ON_WM_ACTIVATE()
ON_BN_CLICKED(IDC_BUTTON_ABORT_TASK, &CRobotTaskDlg::OnBnClickedAbortTask)
+ ON_BN_CLICKED(IDC_BUTTON_RESTORE, &CRobotTaskDlg::OnBnClickedRestore)
END_MESSAGE_MAP()
@@ -51,7 +52,10 @@
if (m_btnAbortTask.m_hWnd) {
m_btnAbortTask.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE);
}
-
+ if (m_btnRestore.m_hWnd) {
+ m_btnRestore.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE);
+ }
+
if (m_pRobotTask != nullptr) {
using namespace SERVO;
@@ -97,14 +101,16 @@
CDialogEx::OnInitDialog();
// TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
- // 鍒涘缓鈥滃仠姝换鍔♀�濇寜閽�
+ // 鍒涘缓鈥滃仠姝换鍔♀�濇寜閽拰鈥滄挙鍥炩�濇寜閽�
m_btnAbortTask.Create(_T("鍋滄浠诲姟"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_ABORT_TASK);
+ m_btnRestore.Create(_T("鎾ゅ洖"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_RESTORE);
// 鍔ㄦ�佹寜閽垱寤哄悗璁剧疆瀛椾綋
if (m_fontButton.GetSafeHandle() == nullptr) {
m_fontButton.CreatePointFont(110, _T("寰蒋闆呴粦")); // 鎴� "Segoe UI"
}
m_btnAbortTask.SetFont(&m_fontButton);
+ m_btnRestore.SetFont(&m_fontButton);
// 璁剧疆 LABEL 鎺т欢鐨勫瓧浣�
if (m_fontDetail.GetSafeHandle() == nullptr) {
@@ -180,15 +186,21 @@
}
// 璁剧疆鈥滃仠姝换鍔♀�濇寜閽綅缃紙鍙充笅瑙掞級
+ const int nBtnWidth = 100;
+ const int nBtnHeight = 28;
+ const int nMargin = 12;
+ const int nMargin2 = 8;
+ const int x = rcClient.right - nBtnWidth - nMargin;
+ int y = rcClient.bottom - nMargin;
if (m_btnAbortTask.m_hWnd != nullptr) {
- const int nBtnWidth = 100;
- const int nBtnHeight = 28;
- const int nMargin = 12;
+ m_btnAbortTask.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight);
+ y -= nBtnHeight;
+ y -= nMargin2;
+ }
- const int nPosX = rcClient.right - nBtnWidth - nMargin;
- const int nPosY = rcClient.bottom - nBtnHeight - nMargin;
-
- m_btnAbortTask.MoveWindow(nPosX, nPosY, nBtnWidth, nBtnHeight);
+ // 璁剧疆鈥滃仠姝换鍔♀�濇寜閽綅缃紙鍙充笅瑙掞級
+ if (m_btnRestore.m_hWnd != nullptr) {
+ m_btnRestore.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight);
}
}
@@ -200,4 +212,14 @@
}
theApp.m_model.getMaster().abortCurrentTask();
+}
+
+void CRobotTaskDlg::OnBnClickedRestore()
+{
+ int ret = AfxMessageBox(_T("鐗╂枡灏嗕細琚惉杩愬洖鍘熶綅缃紝纭瑕佸洖鎾ゅ綋鍓嶄换鍔″悧锛熼櫎闈炲彂鐢熶簡寮傚父锛屽惁鍒欒涓嶈鍥炴挙浠诲姟锛�"), MB_OKCANCEL | MB_ICONEXCLAMATION);
+ if (ret != IDOK) {
+ return;
+ }
+
+ theApp.m_model.getMaster().restoreCurrentTask();
}
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/CRobotTaskDlg.h b/SourceCode/Bond/Servo/CRobotTaskDlg.h
index 9226dcb..3ab967c 100644
--- a/SourceCode/Bond/Servo/CRobotTaskDlg.h
+++ b/SourceCode/Bond/Servo/CRobotTaskDlg.h
@@ -22,6 +22,7 @@
private:
SERVO::CRobotTask* m_pRobotTask;
CButton m_btnAbortTask;
+ CButton m_btnRestore;
CFont m_fontButton;
CFont m_fontDetail;
@@ -42,4 +43,5 @@
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnBnClickedAbortTask();
+ afx_msg void OnBnClickedRestore();
};
diff --git a/SourceCode/Bond/Servo/Common.h b/SourceCode/Bond/Servo/Common.h
index 5dd53a1..dc805c2 100644
--- a/SourceCode/Bond/Servo/Common.h
+++ b/SourceCode/Bond/Servo/Common.h
@@ -494,4 +494,5 @@
#define ROBOT_EVENT_CREATE 0 // 新任务创建
#define ROBOT_EVENT_FINISH 1 // 正常完成
#define ROBOT_EVENT_ERROR 2 // 出现错误
-#define ROBOT_EVENT_ABORT 3 // 人为中止
\ No newline at end of file
+#define ROBOT_EVENT_ABORT 3 // 人为中止
+#define ROBOT_EVENT_RESTORE 4 // 回撤
\ No newline at end of file
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 27056bd..78ba03f 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -203,11 +203,12 @@
break;
case ROBOT_EVENT_ERROR:
LOGE("<CModel>onRobotTaskEvent: 任务错误(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
- pTask->error();
break;
case ROBOT_EVENT_ABORT:
LOGE("<CModel>onRobotTaskEvent: 任务停止(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
- pTask->abort();
+ break;
+ case ROBOT_EVENT_RESTORE:
+ LOGE("<CModel>onRobotTaskEvent: 任务回撤(%s, ClassID=%s).", strDesc.c_str(), strClassID.c_str());
break;
default:
LOGE("<CModel>onRobotTaskEvent: 未知事件 code=%d, 任务=%s", code, strDesc.c_str());
diff --git a/SourceCode/Bond/Servo/ServoCommo.h b/SourceCode/Bond/Servo/ServoCommo.h
index 0b58600..e09831a 100644
--- a/SourceCode/Bond/Servo/ServoCommo.h
+++ b/SourceCode/Bond/Servo/ServoCommo.h
@@ -121,6 +121,7 @@
Restoring,
Error,
Abort,
+ Restored,
Completed
};
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index bc56882..bf9c874 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -235,6 +235,9 @@
else if (exCode == ROBOT_EVENT_ABORT) {
m_pMyStatusbar->setCurTaskBtnText("无");
}
+ else if (exCode == ROBOT_EVENT_RESTORE) {
+ m_pMyStatusbar->setCurTaskBtnText("无");
+ }
}
}
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 5804523..e2b5983 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
--
Gitblit v1.9.3