From e42e8364112e97d89eeaecd13f043dff42179949 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 27 五月 2025 17:19:02 +0800
Subject: [PATCH] 1.enum修改为enum class, 理顺CLoadPort各成员变量在调度中的判定作用;

---
 SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp |   85 +++++++++++++++++++++++-------------------
 1 files changed, 47 insertions(+), 38 deletions(-)

diff --git a/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp b/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
index 28a62e6..ea62463 100644
--- a/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
+++ b/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
@@ -14,7 +14,7 @@
 #define LOG_COLOR_TIME     RGB(0, 0, 255)       // 鏃堕棿鎴筹細钃濊壊
 
 // 蹇嵎鍛戒护鏄犲皠琛�
-std::map<CString, QuickCmdFieldMask> g_quickCmdMap = {
+std::map<CString, QuickCmdFieldMask> g_mapQuickCmd = {
 	{_T("SendHome"),             {false, false, false, false, false}},
 	{_T("SendTransfer"),         {true,  true,  true,  true,  true }},
 	{_T("SendMoveToGet"),        {true,  true,  true,  false, false}},
@@ -76,14 +76,14 @@
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
 	// 鍒濆鍖栧懡浠ょ粍鍚堝垪琛�
-	for (const auto& pair : g_quickCmdMap) {
+	for (const auto& pair : g_mapQuickCmd) {
 		m_comboCmdType.AddString(pair.first);
 	}
 	m_comboCmdType.SetCurSel(0);
 
 	// 鍒濆鍖栧懡浠よ緭鍏ユ帶浠�
-	if (!g_quickCmdMap.empty()) {
-		UpdateCommandInputUI(g_quickCmdMap.begin()->first);
+	if (!g_mapQuickCmd.empty()) {
+		UpdateCommandInputUI(g_mapQuickCmd.begin()->first);
 	}
 
 	// 鍒濆鍖� Arm No锛�1锛欰rm#1锛�2锛欰rm#2锛�
@@ -127,64 +127,64 @@
 
 	// 蹇嵎鍛戒护鎵ц鏄犲皠琛�
 	m_mapCmdExec = {
-		{_T("SendHome"), [this](int seq, int, int, int, int, int) {
-			return m_pEFEM->SendHome(seq);
+		{_T("SendHome"), [this](int seq, int, int, int, int, int, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendHome(seq, onWritedBlock);
 		}},
 
-		{_T("SendTransfer"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot) {
-			return m_pEFEM->SendTransfer(seq, armNo, getPos, putPos, getSlot, putSlot);
+		{_T("SendTransfer"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendTransfer(seq, armNo, getPos, putPos, getSlot, putSlot, onWritedBlock);
 		}},
 
-		{_T("SendMoveToGet"), [this](int seq, int armNo, int pos, int, int slot, int) {
-			return m_pEFEM->SendMoveToGet(seq, armNo, pos, slot);
+		{_T("SendMoveToGet"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendMoveToGet(seq, armNo, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendMoveToPut"), [this](int seq, int armNo, int, int pos, int, int slot) {
-			return m_pEFEM->SendMoveToPut(seq, armNo, pos, slot);
+		{_T("SendMoveToPut"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendMoveToPut(seq, armNo, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendGet"), [this](int seq, int armNo, int pos, int, int slot, int) {
-			return m_pEFEM->SendGet(seq, armNo, pos, slot);
+		{_T("SendGet"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendGet(seq, armNo, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendPut"), [this](int seq, int armNo, int, int pos, int, int slot) {
-			return m_pEFEM->SendPut(seq, armNo, pos, slot);
+		{_T("SendPut"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendPut(seq, armNo, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendExchange"), [this](int seq, int armNo, int pos, int, int getSlot, int putSlot) {
-			return m_pEFEM->SendExchange(seq, armNo, pos, getSlot, putSlot);
+		{_T("SendExchange"), [this](int seq, int armNo, int pos, int, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendExchange(seq, armNo, pos, getSlot, putSlot, onWritedBlock);
 		}},
 
-		{_T("SendCommandClear"), [this](int seq, int, int, int, int, int) {
-			return m_pEFEM->SendCommandClear(seq);
+		{_T("SendCommandClear"), [this](int seq, int, int, int, int, int, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendCommandClear(seq, onWritedBlock);
 		}},
 
-		{_T("SendBatchGet"), [this](int seq, int armNo, int pos, int, int slot, int) {
-			return m_pEFEM->SendBatchGet(seq, pos, slot);
+		{_T("SendBatchGet"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendBatchGet(seq, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendBatchPut"), [this](int seq, int armNo, int, int pos, int, int slot) {
-			return m_pEFEM->SendBatchPut(seq, pos, slot);
+		{_T("SendBatchPut"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendBatchPut(seq, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendMoveToGetAndHome"), [this](int seq, int armNo, int pos, int, int slot, int) {
-			return m_pEFEM->SendMoveToGetAndHome(seq, armNo, pos, slot);
+		{_T("SendMoveToGetAndHome"), [this](int seq, int armNo, int pos, int, int slot, int, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendMoveToGetAndHome(seq, armNo, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendMoveToPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot) {
-			return m_pEFEM->SendMoveToPutAndHome(seq, armNo, pos, slot);
+		{_T("SendMoveToPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendMoveToPutAndHome(seq, armNo, pos, slot, onWritedBlock);
 		}},
 
-		{_T("SendTransferAndHome"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot) {
-			return m_pEFEM->SendTransferAndHome(seq, armNo, getPos, putPos, getSlot, putSlot);
+		{_T("SendTransferAndHome"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendTransferAndHome(seq, armNo, getPos, putPos, getSlot, putSlot, onWritedBlock);
 		}},
 
-		{_T("SendGetAndPut"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot) {
-			return m_pEFEM->SendGetAndPut(seq, armNo, getPos, putPos, getSlot, putSlot);
+		{_T("SendGetAndPut"), [this](int seq, int armNo, int getPos, int putPos, int getSlot, int putSlot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendGetAndPut(seq, armNo, getPos, putPos, getSlot, putSlot, onWritedBlock);
 		}},
 
-		{_T("SendPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot) {
-			return m_pEFEM->SendPutAndHome(seq, armNo, pos, slot);
+		{_T("SendPutAndHome"), [this](int seq, int armNo, int, int pos, int, int slot, SERVO::ONWRITED onWritedBlock) {
+			return m_pEFEM->robotSendPutAndHome(seq, armNo, pos, slot, onWritedBlock);
 		}}
 	};
 
@@ -197,8 +197,9 @@
 
 void CRobotCmdTestDlg::UpdateCommandInputUI(const CString& cmdName)
 {
-	auto it = g_quickCmdMap.find(cmdName);
-	if (it == g_quickCmdMap.end()) { 
+	auto it = g_mapQuickCmd.find(cmdName);
+	if (it == g_mapQuickCmd.end()) {
+		AppendLogLineRichStyled(_T("鏈煡鐨勫懡浠ょ被鍨�"), LOG_COLOR_ERROR);
 		return;
 	}
 
@@ -274,7 +275,6 @@
 
 	long nStart = 0;
 	long nEnd = m_editLog.GetTextLength();
-	CHARRANGE cr;
 	FINDTEXTEX ft = { 0 };
 	ft.chrg.cpMin = 0;
 	ft.chrg.cpMax = nEnd;
@@ -333,7 +333,16 @@
 	// 鏌ユ壘鍑芥暟骞舵墽琛�
 	auto it = m_mapCmdExec.find(cmdName);
 	if (it != m_mapCmdExec.end() && nullptr != m_pEFEM) {
-		int ret = it->second(1, armNo, getPos, getSlot, putPos, putSlot);
+		int ret = it->second(1, armNo, getPos, getSlot, putPos, putSlot, [&](int code) -> int {
+			if (code == WOK) {
+				AppendLogLineRichStyled(_T("宸叉敹鍒癛obot鍥炲簲锛�"), LOG_COLOR_SUCCESS);
+			}
+			else {
+				AppendLogLineRichStyled(_T("鏈敹鍒癛obot鍥炲簲锛�"), LOG_COLOR_ERROR);
+			}
+
+			return 0;
+			});
 
 		CString log;
 		if (ret == 0) {

--
Gitblit v1.9.3