From ee4945bb0e32a065ce1d5d23ec6afbcba4bbcc03 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 09 九月 2025 09:33:49 +0800
Subject: [PATCH] 1.VCR转移到Aligner

---
 SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp |  198 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 157 insertions(+), 41 deletions(-)

diff --git a/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp b/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
index 804335e..e07c782 100644
--- a/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
+++ b/SourceCode/Bond/Servo/CRobotCmdTestDlg.cpp
@@ -32,6 +32,28 @@
 	{_T("SendPutAndHome"),       {true,  false, false, true,  true }}
 };
 
+std::map<CString, int> g_mapDeviceSlotCount = {
+	{_T("Port1"), 8},
+	{_T("Port2"), 8},
+	{_T("Port3"), 8},
+	{_T("Port4"), 8},
+	{_T("RB1"), 1},
+	{_T("RB2"), 1},
+	{_T("AL"), 1},
+	{_T("FLIP"), 1},
+	{_T("Bonder1-涓婁骇鍝�"), 1},
+	{_T("Bonder1-涓嬩骇鍝�"), 1},
+	{_T("Bonder2-涓婁骇鍝�"), 1},
+	{_T("Bonder2-涓嬩骇鍝�"), 1},
+	{_T("VacBakeA鑵�"), 1},
+	{_T("VacBakeB鑵�"), 1},
+	{_T("BakecCoolingA鐑樼儰"), 1},
+	{_T("BakecCoolingA鍐峰嵈"), 1},
+	{_T("BakecCoolingB鐑樼儰"), 1},
+	{_T("BakecCoolingB鍐峰嵈"), 1},
+	{_T("Measurement"), 1}
+};
+
 // CRobotCmdTestDlg 瀵硅瘽妗�
 
 IMPLEMENT_DYNAMIC(CRobotCmdTestDlg, CDialogEx)
@@ -64,8 +86,10 @@
 }
 
 BEGIN_MESSAGE_MAP(CRobotCmdTestDlg, CDialogEx)
-	ON_CBN_SELCHANGE(IDC_COMBO_CMD_TYPE, &CRobotCmdTestDlg::OnCbnSelchangeComboCmdType)
 	ON_BN_CLICKED(IDC_BUTTON_EXECUTE, &CRobotCmdTestDlg::OnBnClickedButtonExecute)
+	ON_CBN_SELCHANGE(IDC_COMBO_CMD_TYPE, &CRobotCmdTestDlg::OnSelchangeComboCmdType)
+	ON_CBN_SELCHANGE(IDC_COMBO_GET_POS, &CRobotCmdTestDlg::OnSelchangeComboGetPos)
+	ON_CBN_SELCHANGE(IDC_COMBO_PUT_POS, &CRobotCmdTestDlg::OnSelchangeComboPutPos)
 END_MESSAGE_MAP()
 
 // CRobotCmdTestDlg 娑堟伅澶勭悊绋嬪簭
@@ -81,11 +105,6 @@
 	}
 	m_comboCmdType.SetCurSel(0);
 
-	// 鍒濆鍖栧懡浠よ緭鍏ユ帶浠�
-	if (!g_mapQuickCmd.empty()) {
-		UpdateCommandInputUI(g_mapQuickCmd.begin()->first);
-	}
-
 	// 鍒濆鍖� Arm No锛�1锛欰rm#1锛�2锛欰rm#2锛�
 	m_comboArmNo.AddString(_T("1"));
 	m_comboArmNo.AddString(_T("2"));
@@ -93,19 +112,25 @@
 
 	// 绀轰緥璁惧鍚嶇О鍒楄〃
 	CStringList eqNameList;
-	eqNameList.AddTail(_T("PORT 1"));				// 1 1 UNIT
-	eqNameList.AddTail(_T("PORT 2"));				// 2 1 UNIT
-	eqNameList.AddTail(_T("PORT 3"));				// 3 1 UNIT
-	eqNameList.AddTail(_T("PORT 4"));				// 4 1 UNIT
-	eqNameList.AddTail(_T("RB1"));					// 5 1 UNIT
-	eqNameList.AddTail(_T("RB2"));					// 6 1 UNIT
-	eqNameList.AddTail(_T("ALIGN"));				// 7 1 UNIT
-	eqNameList.AddTail(_T("FLIP"));					// 8 1 UNIT
-	eqNameList.AddTail(_T("VAC BAKE"));				// 9 2 UNIT
-	eqNameList.AddTail(_T("BONDER1"));				// 10 2 UNIT
-	eqNameList.AddTail(_T("BONDER2"));				// 11 2 UNIT
-	eqNameList.AddTail(_T("POST BAKE(COOLING)"));	// 12 4 UNIT
-	eqNameList.AddTail(_T("MEASUREMENT"));			// 13 1 UNIT
+	eqNameList.AddTail(_T("Port1")); // 1
+	eqNameList.AddTail(_T("Port2")); // 2
+	eqNameList.AddTail(_T("Port3")); // 3
+	eqNameList.AddTail(_T("Port4")); // 4
+	eqNameList.AddTail(_T("RB1"));	 // 5
+	eqNameList.AddTail(_T("RB2"));	 // 6
+	eqNameList.AddTail(_T("AL"));	 // 7
+	eqNameList.AddTail(_T("FLIP"));	 // 8
+	eqNameList.AddTail(_T("Bonder1-涓婁骇鍝�")); // 9
+	eqNameList.AddTail(_T("Bonder1-涓嬩骇鍝�")); // 10
+	eqNameList.AddTail(_T("Bonder2-涓婁骇鍝�")); // 11
+	eqNameList.AddTail(_T("Bonder2-涓嬩骇鍝�")); // 12
+	eqNameList.AddTail(_T("VacBakeA鑵�"));	  // 13
+	eqNameList.AddTail(_T("VacBakeB鑵�"));	  // 14
+	eqNameList.AddTail(_T("BakecCoolingA鐑樼儰")); // 15
+	eqNameList.AddTail(_T("BakecCoolingA鍐峰嵈")); // 16
+	eqNameList.AddTail(_T("BakecCoolingB鐑樼儰")); // 17
+	eqNameList.AddTail(_T("BakecCoolingB鍐峰嵈")); // 18
+	eqNameList.AddTail(_T("Measurement"));		 // 19
 
 	for (POSITION pos = eqNameList.GetHeadPosition(); pos != NULL;) {
 		CString item = eqNameList.GetNext(pos);
@@ -115,15 +140,16 @@
 	m_comboGetPos.SetCurSel(0);
 	m_comboPutPos.SetCurSel(0);
 
-	// 鍒濆鍖� Slot锛堥粯璁や粠 1 鍒� 25锛�
-	for (int i = 1; i < 26; ++i) {
-		CString str;
-		str.Format(_T("%d"), i);
-		m_comboGetSlot.AddString(str);
-		m_comboPutSlot.AddString(str);
+	// 鍒濆鍖� Slot
+	m_comboGetPos.SetCurSel(0);
+	m_comboPutPos.SetCurSel(0);
+	UpdateSlotList(&m_comboGetPos, &m_comboGetSlot);
+	UpdateSlotList(&m_comboPutPos, &m_comboPutSlot);
+
+	// 鍒濆鍖栧懡浠よ緭鍏ユ帶浠�
+	if (!g_mapQuickCmd.empty()) {
+		UpdateCommandInputUI(g_mapQuickCmd.begin()->first);
 	}
-	m_comboGetSlot.SetCurSel(0);
-	m_comboPutSlot.SetCurSel(0);
 
 	// 蹇嵎鍛戒护鎵ц鏄犲皠琛�
 	m_mapCmdExec = {
@@ -204,11 +230,16 @@
 	}
 
 	const QuickCmdFieldMask& mask = it->second;
-	GetDlgItem(IDC_COMBO_ARM_NO)->EnableWindow(mask.useArm);
-	GetDlgItem(IDC_COMBO_GET_POS)->EnableWindow(mask.useGetPos);
-	GetDlgItem(IDC_COMBO_GET_SLOT)->EnableWindow(mask.useGetSlot);
-	GetDlgItem(IDC_COMBO_PUT_POS)->EnableWindow(mask.usePutPos);
-	GetDlgItem(IDC_COMBO_PUT_SLOT)->EnableWindow(mask.usePutSlot);
+	m_comboArmNo.SetCurSel(0);
+	m_comboArmNo.EnableWindow(mask.useArm);
+	m_comboGetPos.SetCurSel(0);
+	m_comboGetPos.EnableWindow(mask.useGetPos);
+	m_comboGetSlot.SetCurSel(0);
+	m_comboGetSlot.EnableWindow(mask.useGetSlot);
+	m_comboPutPos.SetCurSel(0);
+	m_comboPutPos.EnableWindow(mask.usePutPos);
+	m_comboPutSlot.SetCurSel(0);
+	m_comboPutSlot.EnableWindow(mask.usePutSlot);
 }
 
 void CRobotCmdTestDlg::AppendLogLineBatchBegin()
@@ -239,6 +270,8 @@
 
 void CRobotCmdTestDlg::AppendLogLineRichStyled(const CString& content, COLORREF color /*= RGB(0, 0, 0)*/)
 {
+	if (!::IsWindow(GetSafeHwnd())) return;
+
 	// 鏃堕棿鎴�
 	CString timestamp;
 	CTime now = CTime::GetCurrentTime();
@@ -296,19 +329,73 @@
 	m_editLog.SetSel(-1, 0);
 }
 
-void CRobotCmdTestDlg::OnCbnSelchangeComboCmdType()
+void CRobotCmdTestDlg::UpdateSlotList(CComboBox* pComboDevice, CComboBox* pComboSlot)
 {
-	int nSel = m_comboCmdType.GetCurSel();
-	if (nSel < 0) {
+	if (pComboDevice == nullptr || pComboSlot == nullptr) {
 		return;
 	}
 
-	CString str;
-	m_comboCmdType.GetLBText(nSel, str);
-	UpdateCommandInputUI(str);
+	int nSelIndex = pComboDevice->GetCurSel();
+	if (nSelIndex < 0) {
+		return;
+	}
 
-	str.Format(_T("鍒囨崲褰撳墠鍛戒护绫诲瀷锛�%s"), str);
-	AppendLogLineRichStyled(str, LOG_COLOR_NORMAL);
+	CString strDeviceName;
+	pComboDevice->GetLBText(nSelIndex, strDeviceName);
+
+	int nMaxSlot = 1; // 榛樿妲戒綅鏁�
+	auto it = g_mapDeviceSlotCount.find(strDeviceName);
+	if (it != g_mapDeviceSlotCount.end()) {
+		nMaxSlot = it->second;
+	}
+	else {
+		CString strLog;
+		strLog.Format(_T("璁惧 %s 鏈畾涔夋Ы浣嶆暟锛屼娇鐢ㄩ粯璁ゅ�� 1"), strDeviceName.GetString());
+		AppendLogLineRichStyled(strLog, LOG_COLOR_WARNING);
+	}
+
+	// 娓呯┖骞舵坊鍔犳Ы鍙�
+	pComboSlot->ResetContent();
+	for (int i = 1; i <= nMaxSlot; ++i) {
+		CString str;
+		str.Format(_T("%d"), i);
+		pComboSlot->AddString(str);
+	}
+
+	pComboSlot->SetCurSel(0);
+	pComboSlot->EnableWindow(1 != nMaxSlot);
+}
+
+void CRobotCmdTestDlg::UpdateArmList(CComboBox* pComboDevice, CComboBox* pComboArm)
+{
+	if (pComboDevice == nullptr || pComboArm == nullptr) {
+		return;
+	}
+
+	int nSelIndex = pComboDevice->GetCurSel();
+	if (nSelIndex < 0) {
+		return;
+	}
+
+	CString strDeviceName;
+	pComboDevice->GetLBText(nSelIndex, strDeviceName);
+	if (IsDualArmSupported(strDeviceName)) {
+		pComboArm->EnableWindow(TRUE);
+	}
+	else {
+		pComboArm->EnableWindow(FALSE);
+	}
+
+	pComboArm->SetCurSel(0);
+}
+
+bool CRobotCmdTestDlg::IsDualArmSupported(const CString& strDeviceName)
+{
+	// 娉ㄦ剰鍖归厤瑙勫垯鏄惁鍖哄垎鈥�-涓婁骇鍝佲�濄�佲��-涓嬩骇鍝佲�濈瓑鍚庣紑
+	if (strDeviceName.Find(_T("FLIP")) >= 0) return true;
+	if (strDeviceName.Find(_T("Bonder1")) >= 0) return true;
+	if (strDeviceName.Find(_T("Bonder2")) >= 0) return true;
+	return false;
 }
 
 void CRobotCmdTestDlg::OnBnClickedButtonExecute()
@@ -333,7 +420,7 @@
 	// 鏌ユ壘鍑芥暟骞舵墽琛�
 	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 code) -> int {
+		int ret = it->second(1, armNo, getPos, putPos, getSlot, putSlot, [&](int code) -> int {
 			if (code == WOK) {
 				AppendLogLineRichStyled(_T("宸叉敹鍒癛obot鍥炲簲锛�"), LOG_COLOR_SUCCESS);
 			}
@@ -360,3 +447,32 @@
 		AppendLogLineRichStyled(log, LOG_COLOR_ERROR);
 	}
 }
+
+void CRobotCmdTestDlg::OnSelchangeComboCmdType()
+{
+	int nSel = m_comboCmdType.GetCurSel();
+	if (nSel < 0) {
+		return;
+	}
+
+	CString str;
+	m_comboCmdType.GetLBText(nSel, str);
+	UpdateCommandInputUI(str);
+
+	str.Format(_T("鍒囨崲褰撳墠鍛戒护绫诲瀷锛�%s"), str);
+	AppendLogLineRichStyled(str, LOG_COLOR_NORMAL);
+}
+
+void CRobotCmdTestDlg::OnSelchangeComboGetPos()
+{
+	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	UpdateSlotList(&m_comboGetPos, &m_comboGetSlot);
+	UpdateArmList(&m_comboGetPos, &m_comboArmNo);
+}
+
+void CRobotCmdTestDlg::OnSelchangeComboPutPos()
+{
+	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	UpdateSlotList(&m_comboPutPos, &m_comboPutSlot);
+	UpdateArmList(&m_comboPutPos, &m_comboArmNo);
+}

--
Gitblit v1.9.3