From 1efb832676e8ad27e7a495dba6ffc19479e0c76f Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 04 九月 2025 15:51:33 +0800
Subject: [PATCH] 1.机器配方参数的获取;

---
 SourceCode/Bond/Servo/PageRecipe.cpp |   68 ++++++++++++++++++++++++++++------
 1 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 3cadbe0..891f274 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -160,8 +160,9 @@
 	m_listPPID.SetColumnWidth(nColCount - 1, LVSCW_AUTOSIZE_USEHEADER);
 }
 
-void CPageRecipe::FillRecipeListToListCtrl(SERVO::CRecipeList* pList)
+void CPageRecipe::FillRecipeListToListCtrl(SERVO::CEquipment* pEq)
 {
+	SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
 	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_PPID);
 	if (pListCtrl == nullptr || !::IsWindow(pListCtrl->m_hWnd)) {
 		return;
@@ -169,16 +170,23 @@
 
 	// 娓呯┖褰撳墠CListCtrl涓殑鎵�鏈夐」
 	pListCtrl->DeleteAllItems();
-	if (pList == nullptr) {
+	if (pRecipeList == nullptr) {
 		return;
 	}
 
 	// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
-	std::map<int, short>& ids = pList->getIds();
+	std::map<int, short>& ids = pRecipeList->getIds();
+	auto rawDatas = pRecipeList->getParamsRawData();
 	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());
+
+		auto iter = rawDatas.find(item.second);
+		if (iter != rawDatas.end()) {
+			std::string strDescription;
+			pEq->parsingParams((const char*)iter->second.data(), iter->second.size(), strDescription);
+		}
 	}
 
 	// 鑾峰彇鍒楁暟
@@ -338,8 +346,12 @@
 					pEq[i] == nullptr ? _T("Master") : pEq[i]->getName().c_str());
 				pComboBox->SetItemDataPtr(i, pEq[i]);
 
+				// 璇诲彇鍥炴潵
+				char szBuffer[_MAX_PATH];
 				if (pEq[i]) {
-					pEq[i]->masterRecipeListRequest(0, nullptr);
+					sprintf_s(szBuffer, _MAX_PATH, "%s\\Recipe\\EQ%d_Unit0.recipelist", (LPTSTR)(LPCTSTR)theApp.m_strAppDir, pEq[i]->getID());
+					std::string strFilepath(szBuffer);
+					pEq[i]->readRecipeList(0, strFilepath);
 				}
 			}
 			pComboBox->SetCurSel(0);
@@ -531,8 +543,7 @@
 	}
 	else {
 		InitListCtrlHeaderForDevice();
-		SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
-		FillRecipeListToListCtrl(pRecipeList);
+		FillRecipeListToListCtrl(pEq);
 	}
 }
 
@@ -548,6 +559,12 @@
 	SERVO::CEquipment* pEq = (SERVO::CEquipment*)pMsgDlg->GetDataEx();
 	HANDLE hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
 	int nStep = 0;
+
+	// 鍑嗗閰嶆柟璺緞
+	char szBuffer[_MAX_PATH];
+	sprintf_s(szBuffer, _MAX_PATH, "%s\\Recipe\\EQ%d_Unit0.recipelist", (LPTSTR)(LPCTSTR)theApp.m_strAppDir, pEq->getID());
+	std::string strFilepath(szBuffer);
+
 	pEq->masterRecipeListRequest(0, [&, pEq, pMsgDlg, hEvent](int status) -> void {
 		Sleep(300);
 		if (status == SS_FAILED || status == SS_TIMEOUT) {
@@ -572,6 +589,7 @@
 	});
 	::WaitForSingleObject(hEvent, INFINITE);
 	if (nStep != 1) {
+		pEq->saveRecipeList(0, strFilepath);
 		pMsgDlg->SetIcon(MSG_BOX_SUCCEED);
 		pMsgDlg->SetMarquee(FALSE, 0);
 		pMsgDlg->SetCompleteCode(-1);
@@ -587,17 +605,18 @@
 		auto& ids = pRecipeList->getIds();
 		pMsgDlg->SetTitle(_T("姝e湪鑾峰彇鍙傛暟"));
 		for (auto item : ids) {
+			int recipeId = item.second;
 			CString strMsg;
 			strMsg.Format(_T("姝e湪鑾峰彇閰嶆柟 %d 鍙傛暟..."), item.second);
 			pMsgDlg->SetMessage((LPTSTR)(LPCTSTR)strMsg);
-			pEq->recipeParameterRequest(0, item.second, 0, [&, pEq, pMsgDlg](int status) -> void {
+			pEq->recipeParameterRequest(0, recipeId, 0, [&, pEq, pMsgDlg, recipeId, hEvent](int status) -> void {
 				Sleep(500);
 				if (status == SS_FAILED || status == SS_TIMEOUT) {
 					CString strMsg;
-					strMsg.Format(status == SS_FAILED ? _T("鑾峰彇閰嶆柟 %d 鍙傛暟澶辫触锛�") : _T("鑾峰彇閰嶆柟 %d 鍙傛暟瓒呮椂锛�"), item.second);
+					strMsg.Format(status == SS_FAILED ? _T("鑾峰彇閰嶆柟 %d 鍙傛暟澶辫触锛�") : _T("鑾峰彇閰嶆柟 %d 鍙傛暟瓒呮椂锛�"), recipeId);
 					pMsgDlg->SetMessage((LPTSTR)(LPCTSTR)strMsg);
 
-					Sleep(300);
+					Sleep(30);
 					SetEvent(hEvent);
 				}
 				else if (status == SS_PARAMS_COMPLETE) {
@@ -605,7 +624,7 @@
 					strMsg.Format(_T("鑾峰彇閰嶆柟 %d 鍙傛暟瀹屾垚锛�"), item.second);
 					pMsgDlg->SetMessage((LPTSTR)(LPCTSTR)strMsg);
 
-					Sleep(300);
+					Sleep(30);
 					SetEvent(hEvent);
 				}
 				});
@@ -613,6 +632,8 @@
 			ResetEvent(hEvent);
 		}
 		
+		
+		pEq->saveRecipeList(0, strFilepath);
 		pMsgDlg->SetIcon(MSG_BOX_SUCCEED);
 		pMsgDlg->SetTitle(_T("鎿嶄綔瀹屾垚"));
 		pMsgDlg->SetCompleteCode(0);
@@ -620,10 +641,33 @@
 		pMsgDlg->DelayClose(3000);
 	};
 
-	SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
-	FillRecipeListToListCtrl(pRecipeList);
+	FillRecipeListToListCtrl(pEq);
 	CloseHandle(hEvent);
 
 
+
+	// 鍦ㄦ鎵撳嵃閰嶆柟鍙傛暟浠ヤ究鏍稿鏁版嵁
+	SERVO::CRecipeList* pRecipeList = pEq->getRecipeList(0);
+	ASSERT(pRecipeList);
+	auto rawDatas = pRecipeList->getParamsRawData();
+	for (auto item : rawDatas) {
+		TRACE("================= 閰嶆柟 %d\n", item.first);
+
+		std::vector<CParam> params;
+		pEq->parsingParams((const char*)item.second.data(), item.second.size(), params);
+		for (auto p : params) {
+			if (p.getValueType() == PVT_INT) {
+				TRACE("%s: %d\n", p.getName().c_str(), p.getIntValue());
+			}
+			else if (p.getValueType() == PVT_DOUBLE) {
+				TRACE("%s: %f\n", p.getName().c_str(), p.getDoubleValue());
+			}
+		}
+
+	}
+
+
+
+
 	return 0;
 }

--
Gitblit v1.9.3