From bfe14e41fa5b07771d78af4511ba18d706bc23cc Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 28 七月 2025 17:07:52 +0800
Subject: [PATCH] 1.Spooling Config功能EAP模拟测试;

---
 SourceCode/Bond/Servo/PageRecipe.cpp |  145 +++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 135 insertions(+), 10 deletions(-)

diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 939ab8f..74ce16c 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -5,6 +5,8 @@
 #include "Servo.h"
 #include "afxdialogex.h"
 #include "PageRecipe.h"
+#include "MsgDlg.h"
+
 
 // CPageRecipe 瀵硅瘽妗�
 
@@ -22,7 +24,7 @@
 
 void CPageRecipe::FillDataToListCtrl(const std::vector<RecipeInfo>& vecRecipe) {
 	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
-	if (pListCtrl == nullptr || pListCtrl->m_hWnd == nullptr) {
+	if (pListCtrl == nullptr || !::IsWindow(pListCtrl->m_hWnd)) {
 		return;
 	}
 
@@ -49,6 +51,33 @@
 	m_listPPID.SetColumnWidth(nColCount - 1, LVSCW_AUTOSIZE_USEHEADER);
 }
 
+void CPageRecipe::FillRecipeListToListCtrl(SERVO::CRecipeList* pList)
+{
+	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
+	if (pListCtrl == nullptr || !::IsWindow(pListCtrl->m_hWnd)) {
+		return;
+	}
+
+	// 娓呯┖褰撳墠CListCtrl涓殑鎵�鏈夐」
+	pListCtrl->DeleteAllItems();
+	if (pList == nullptr) {
+		return;
+	}
+
+
+	// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
+	std::map<int, short>& ids = pList->getIds();
+	for (auto item : ids) {
+		int index = m_listPPID.InsertItem(m_listPPID.GetItemCount(), _T(""));
+		m_listPPID.SetItemText(index, 1, std::to_string(item.first).c_str());
+		m_listPPID.SetItemText(index, 2, std::to_string(item.second).c_str());
+	}
+
+	// 鑾峰彇鍒楁暟
+	int nColCount = m_listPPID.GetHeaderCtrl()->GetItemCount();
+	m_listPPID.SetColumnWidth(nColCount - 1, LVSCW_AUTOSIZE_USEHEADER);
+}
+
 void CPageRecipe::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
@@ -65,6 +94,8 @@
 	ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CPageRecipe::OnBnClickedButtonRefresh)
 	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_PPID, &CPageRecipe::OnLvnItemChangedListPPID)
 	ON_WM_DESTROY()
+	ON_CBN_SELCHANGE(IDC_COMBO_EQUIPMENT, &CPageRecipe::OnCbnSelchangeComboEquipment)
+	ON_WM_SHOWWINDOW()
 END_MESSAGE_MAP()
 
 
@@ -95,10 +126,11 @@
 	ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
 	pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0); // 闅愯棌鍒�
 	pListCtrl->InsertColumn(1, _T("No."), LVCFMT_LEFT, width[1]);
-	pListCtrl->InsertColumn(2, _T("PPID"), LVCFMT_LEFT, width[2]);
+	pListCtrl->InsertColumn(2, _T("PPID/Recipe ID"), LVCFMT_LEFT, width[2]);
 	pListCtrl->InsertColumn(3, _T("鎻忚堪"), LVCFMT_LEFT, width[3]);
 	pListCtrl->InsertColumn(4, _T("鍒涘缓鏃堕棿"), LVCFMT_LEFT, width[4]);
 	pListCtrl->SetColumnWidth(4, LVSCW_AUTOSIZE_USEHEADER);
+
 
 	// 鑾峰彇鎵�鏈夋暟鎹�
 	auto vecData = RecipeManager::getInstance().getAllRecipes();
@@ -139,10 +171,10 @@
 
 	// 鎸夐挳绔栫洿鎺掑垪鍦ㄥ彸渚�
 	CWnd* buttons[] = {
-		GetDlgItem(IDC_BUTTON_MODIFY),
+		GetDlgItem(IDC_BUTTON_REFRESH),
 		GetDlgItem(IDC_BUTTON_DELETE),
 		GetDlgItem(IDC_BUTTON_DELETE_ALL),
-		GetDlgItem(IDC_BUTTON_REFRESH)
+		GetDlgItem(IDC_BUTTON_MODIFY)
 	};
 
 	for (auto pBtn : buttons) {
@@ -272,9 +304,42 @@
 
 void CPageRecipe::OnBnClickedButtonRefresh()
 {
-	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
-	auto vecData = RecipeManager::getInstance().getAllRecipes();
-	FillDataToListCtrl(vecData);
+	CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+	int nSel = pComboBox->GetCurSel();
+	SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nSel);
+
+	if (pEq == nullptr) {
+		// 鑾峰彇master閰嶆柟(鏈湴)
+		auto vecData = RecipeManager::getInstance().getAllRecipes();
+		FillDataToListCtrl(vecData);
+	}
+	else {
+		// enable port
+		CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鑾峰彇閰嶆柟...");
+		pEq->masterRecipeListRequest(0, [&](int status) -> void {
+			if (status == SS_FAILED) {
+				CString strMsg;
+				strMsg.Format(_T("鑾峰彇閰嶆柟澶辫触锛�"));
+				msgDlg.DelayClose(3000);
+				msgDlg.SetIcon(MSG_BOX_ERROR);
+				msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+				msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+				msgDlg.SetMarquee(FALSE, 0);
+				msgDlg.SetCompleteCode(-1);
+			}
+			else if (status == SS_COMPLETE) {
+				CString strMsg;
+				strMsg.Format(_T("鑾峰彇閰嶆柟瀹屾垚锛�"));
+				msgDlg.DelayClose(3000);
+				msgDlg.SetIcon(MSG_BOX_SUCCEED);
+				msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+				msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+				msgDlg.SetMarquee(FALSE, 0);
+				msgDlg.SetCompleteCode(0);
+			}
+			});
+		msgDlg.DoModal();
+	}
 }
 
 void CPageRecipe::OnLvnItemChangedListPPID(NMHDR* pNMHDR, LRESULT* pResult)
@@ -282,11 +347,41 @@
 	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
 	*pResult = 0;
 
+	CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+	int nEqSel = pComboBox->GetCurSel();
 	int selectedCount = ListView_GetSelectedCount(m_listPPID.GetSafeHwnd());
-	GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(selectedCount > 0);
-	GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(selectedCount > 0);
-	GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(selectedCount > 0);
+
+	GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(nEqSel == 0 && selectedCount > 0);
+	GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(nEqSel == 0 && selectedCount > 0);
+	GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(nEqSel == 0 && selectedCount > 0);
 }
+
+void CPageRecipe::OnCbnSelchangeComboEquipment()
+{
+	CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+	int nEqSel = pComboBox->GetCurSel();
+	int selectedCount = ListView_GetSelectedCount(m_listPPID.GetSafeHwnd());
+
+	GetDlgItem(IDC_BUTTON_MODIFY)->EnableWindow(nEqSel == 0 && selectedCount > 0);
+	GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(nEqSel == 0 && selectedCount > 0);
+	GetDlgItem(IDC_BUTTON_DELETE_ALL)->EnableWindow(nEqSel == 0 && selectedCount > 0);
+	GetDlgItem(IDC_EDIT_KEYWORD)->EnableWindow(nEqSel == 0);
+	GetDlgItem(IDC_BUTTON_SEARCH)->EnableWindow(nEqSel == 0);
+
+	SERVO::CEquipment* pEq = (SERVO::CEquipment*)pComboBox->GetItemDataPtr(nEqSel);
+	if (pEq == nullptr) {
+		auto vecData = RecipeManager::getInstance().getAllRecipes();
+		FillDataToListCtrl(vecData);
+	}
+	else {
+		SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
+		FillRecipeListToListCtrl(pRecipeList);
+	}
+	
+
+
+}
+
 
 void CPageRecipe::OnDestroy()
 {
@@ -304,3 +399,33 @@
 		WritePrivateProfileString("PageRecipeListCtrl", strItem, strTemp, strIniFile);
 	}
 }
+
+
+void CPageRecipe::OnShowWindow(BOOL bShow, UINT nStatus)
+{
+	CDialogEx::OnShowWindow(bShow, nStatus);
+
+	if (bShow) {
+		CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+		if (pComboBox->GetCount() == 0) {
+			SERVO::CMaster& master = theApp.m_model.getMaster();
+			SERVO::CEquipment* pEq[] = {
+				nullptr,
+				master.getEquipment(EQ_ID_EFEM),
+				master.getEquipment(EQ_ID_Bonder1),
+				master.getEquipment(EQ_ID_Bonder2),
+				master.getEquipment(EQ_ID_BAKE_COOLING),
+				master.getEquipment(EQ_ID_VACUUMBAKE),
+				master.getEquipment(EQ_ID_MEASUREMENT),
+			};
+
+			CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_EQUIPMENT);
+			for (int i = 0; i < sizeof(pEq) / sizeof(pEq[0]); i++) {
+				pComboBox->InsertString(i,
+					pEq[i] == nullptr ? _T("Master") : pEq[i]->getName().c_str());
+				pComboBox->SetItemDataPtr(i, pEq[i]);
+			}
+			pComboBox->SetCurSel(0);
+		}
+	}
+}

--
Gitblit v1.9.3