From 6d140a6e6f2c24c9c7de46bb7c375ae4cbf931e7 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 10 一月 2026 10:38:26 +0800
Subject: [PATCH] 1.实现远程删除配方功能;

---
 SourceCode/Bond/EAPSimulator/CHsmsActive.cpp     |   14 +++++++
 SourceCode/Bond/EAPSimulator/Resource.h          |    6 ++-
 SourceCode/Bond/Servo/HsmsPassive.h              |    5 ++
 SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp |   32 ++++++++++++++++
 SourceCode/Bond/EAPSimulator/CHsmsActive.h       |    1 
 SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h   |    1 
 SourceCode/Bond/Servo/HsmsPassive.cpp            |   41 ++++++++++++++++++++
 SourceCode/Bond/EAPSimulator/EAPSimulator.rc     |    0 
 SourceCode/Bond/Servo/Model.cpp                  |   15 +++++++
 SourceCode/Bond/Servo/PageRecipe.cpp             |    3 +
 10 files changed, 116 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
index d4e6fe5..b06c325 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -394,6 +394,20 @@
 	return 0;
 }
 
+int CHsmsActive::hsmsDeletePPID(const std::vector<std::string>& ppids)
+{
+	IMessage* pMessage = nullptr;
+	int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 7 | REPLY, 17, ++m_nSystemByte);
+	if (nRet != 0 || pMessage == nullptr) return -1;
+	ISECS2Item* pBody = pMessage->getBody();
+	for (const auto& ppid : ppids) {
+		pBody->addItem(ppid.c_str(), "PPID");
+	}
+	m_pActive->sendMessage(pMessage);
+	HSMS_Destroy1Message(pMessage);
+	return 0;
+}
+
 int CHsmsActive::hsmsCarrierActionRequest(unsigned int DATAID, 
 	const char* pszCarrierAction, 
 	const char* pszCarrierId,
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.h b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
index 6362b6e..4566fa0 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.h
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -84,6 +84,7 @@
 
 	// 鏌ヨPPID List
 	int hsmsQueryPPIDList();
+	int hsmsDeletePPID(const std::vector<std::string>& ppids); // S7F17
 
 	// S3F17
 	// 鍗″專鍔ㄤ綔璇锋眰
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
index a5966d9..d1527d3 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
index 93dd187..0b54f77 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
@@ -91,6 +91,7 @@
 	ON_BN_CLICKED(IDC_BUTTON_TRANSMIT_SPOOLED_DATA, &CEAPSimulatorDlg::OnBnClickedButtonTransmitSpooledData)
 	ON_BN_CLICKED(IDC_BUTTON_PURGE_SPOOLED_DATA, &CEAPSimulatorDlg::OnBnClickedButtonPurgeSpooledData)
 	ON_BN_CLICKED(IDC_BUTTON_QUERY_PPID_LIST, &CEAPSimulatorDlg::OnBnClickedButtonQueryPpidList)
+	ON_BN_CLICKED(IDC_BUTTON_DELETE_PPID, &CEAPSimulatorDlg::OnBnClickedButtonDeletePpid)
 	ON_BN_CLICKED(IDC_BUTTON_PROCEED_WITH_CARRIER, &CEAPSimulatorDlg::OnBnClickedButtonProceedWithCarrier)
 	ON_BN_CLICKED(IDC_BUTTON_PROCEED_WITH_SLOTMAP, &CEAPSimulatorDlg::OnBnClickedButtonProceedWithSlotMap)
 	ON_BN_CLICKED(IDC_BUTTON_CARRIER_RELEASE, &CEAPSimulatorDlg::OnBnClickedButtonCarrierRelease)
@@ -380,6 +381,12 @@
 	GetDlgItem(IDC_BUTTON_TRANSMIT_SPOOLED_DATA)->EnableWindow(enabled);
 	GetDlgItem(IDC_BUTTON_PURGE_SPOOLED_DATA)->EnableWindow(enabled);
 	GetDlgItem(IDC_BUTTON_QUERY_PPID_LIST)->EnableWindow(enabled);	
+	if (GetDlgItem(IDC_BUTTON_DELETE_PPID) != nullptr) {
+		GetDlgItem(IDC_BUTTON_DELETE_PPID)->EnableWindow(enabled);
+	}
+	if (GetDlgItem(IDC_EDIT_DELETE_PPID) != nullptr) {
+		GetDlgItem(IDC_EDIT_DELETE_PPID)->EnableWindow(enabled);
+	}
 	GetDlgItem(IDC_BUTTON_PROCEED_WITH_CARRIER)->EnableWindow(enabled);	
 	if (GetDlgItem(IDC_BUTTON_PROCEED_WITH_SLOTMAP) != nullptr) {
 		GetDlgItem(IDC_BUTTON_PROCEED_WITH_SLOTMAP)->EnableWindow(enabled);
@@ -522,6 +529,31 @@
 	theApp.m_model.m_pHsmsActive->hsmsQueryPPIDList();
 }
 
+void CEAPSimulatorDlg::OnBnClickedButtonDeletePpid()
+{
+	CString strPPID;
+	GetDlgItemText(IDC_EDIT_DELETE_PPID, strPPID);
+	strPPID.Trim();
+	std::vector<std::string> ppids;
+	if (!strPPID.IsEmpty()) {
+		CString upper = strPPID;
+		upper.MakeUpper();
+		if (upper != _T("ALL")) {
+			int start = 0;
+			CString token = strPPID.Tokenize(_T(","), start);
+			while (!token.IsEmpty()) {
+				token.Trim();
+				if (!token.IsEmpty()) {
+					ppids.push_back(std::string((LPTSTR)(LPCTSTR)token));
+				}
+				token = strPPID.Tokenize(_T(","), start);
+			}
+		}
+	}
+	// L:0 if ppids empty -> delete all
+	theApp.m_model.m_pHsmsActive->hsmsDeletePPID(ppids);
+}
+
 static int DATAID = 1;
 void CEAPSimulatorDlg::OnBnClickedButtonProceedWithCarrier()
 {
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
index 6bfda45..547f189 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
@@ -57,6 +57,7 @@
 	afx_msg void OnBnClickedButtonTransmitSpooledData();
 	afx_msg void OnBnClickedButtonPurgeSpooledData();
 	afx_msg void OnBnClickedButtonQueryPpidList();
+	afx_msg void OnBnClickedButtonDeletePpid();
 	afx_msg void OnBnClickedButtonProceedWithCarrier();
 	afx_msg void OnBnClickedButtonProceedWithSlotMap();
 	afx_msg void OnBnClickedButtonCarrierRelease();
diff --git a/SourceCode/Bond/EAPSimulator/Resource.h b/SourceCode/Bond/EAPSimulator/Resource.h
index 21dbcc7..76d0766 100644
--- a/SourceCode/Bond/EAPSimulator/Resource.h
+++ b/SourceCode/Bond/EAPSimulator/Resource.h
@@ -65,14 +65,16 @@
 #define IDC_BUTTON_QUERY_PROCESS_STATE  1047
 #define IDC_BUTTON_QUERY_ALL_SVID       1048
 #define IDC_BUTTON_QUERY_ALL_CEID       1049
+#define IDC_EDIT_DELETE_PPID            1050
+#define IDC_BUTTON_DELETE_PPID          1051
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        143
+#define _APS_NEXT_RESOURCE_VALUE        144
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1050
+#define _APS_NEXT_CONTROL_VALUE         1052
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index d35b5b8..df773b6 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1370,6 +1370,9 @@
 		else if (nStream == 7 && pHeader->function == 19) {
 			replyQueryPPIDList(pMessage);
 		}
+		else if (nStream == 7 && pHeader->function == 17) {
+			replyDeletePPID(pMessage);
+		}
 		else if (nStream == 10 && pHeader->function == 3) {
 			replyTerminalDisplay(pMessage);
 		}
@@ -2544,6 +2547,44 @@
 	return 0;
 }
 
+// S7F17 Delete Process Program (PPID list) / S7F18
+int CHsmsPassive::replyDeletePPID(IMessage* pRecv)
+{
+	if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
+		return ER_NOTSELECT;
+	}
+
+	bool allOk = true;
+	const bool deleteAll = (pRecv->getBody() == nullptr || pRecv->getBody()->getSubItemSize() == 0);
+	std::vector<std::string> ppids;
+	ISECS2Item* pBody = pRecv->getBody();
+	const int nCount = pBody ? pBody->getSubItemSize() : 0;
+	for (int i = 0; i < nCount; ++i) {
+		const char* pszPPID = nullptr;
+		if (pBody->getSubItemString(i, pszPPID) && pszPPID != nullptr) {
+			ppids.emplace_back(pszPPID);
+		}
+		else {
+			allOk = false;
+		}
+	}
+
+	if (deleteAll || !ppids.empty()) {
+		if (m_listener.onDeletePPID != nullptr) {
+			allOk = m_listener.onDeletePPID(this, ppids);
+		}
+		else {
+			// no handler provided; treat as failure
+			allOk = false;
+			LOGW("<HSMS>DeletePPID request ignored: no onDeletePPID listener");
+		}
+	}
+
+
+	replyAck(7, 18, pRecv->getHeader()->systemBytes, allOk ? BYTE(0) : BYTE(1), "ACKC7");
+	return 0;
+}
+
 // S7F19
 int CHsmsPassive::replyQueryPPIDList(IMessage* pRecv)
 {
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 3461a77..d9e7e96 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -26,6 +26,8 @@
 #define ER_UNLINK_EVENT_REPORT	-5
 #define ER_NO_PPID_LIST			-6
 #define ER_NOT_SUPPORTED		-7
+#define ER_CREATED_MESSAGE		-8
+
 
 
 /* CAACK */
@@ -90,6 +92,7 @@
 	std::string& strErrorTxt)> CARRIERACTION;
 typedef std::function<int(void* pFrom, std::vector<SERVO::CProcessJob*>& pjs)> PRJOBMULTICREATE;
 typedef std::function<int(void* pFrom, SERVO::CControlJob& controlJob)> CONTROLJOBCREATE;
+typedef std::function<bool(void* pFrom, const std::vector<std::string>& ppids)> DELETEPPID;
 typedef struct _SECSListener
 {
 	SECSEQOFFLINE				onEQOffLine;
@@ -101,6 +104,7 @@
 	EDEVENTREPORT				onEnableDisableEventReport;
 	EDALARMREPORT				onEnableDisableAlarmReport;
 	QUERYPPIDLIST				onQueryPPIDList;
+	DELETEPPID					onDeletePPID;
 	CARRIERACTION				onCarrierAction;
 	PRJOBMULTICREATE			onPRJobMultiCreate;
 	CONTROLJOBCREATE			onControlJobCreate;
@@ -250,6 +254,7 @@
 	int replyEanbleDisableAlarmReport(IMessage* pRecv);
 	int replyPurgeSpooledData(IMessage* pRecv);
 	int replyQueryPPIDList(IMessage* pRecv);
+	int replyDeletePPID(IMessage* pRecv); // S7F17/S7F18
 	int replyTerminalDisplay(IMessage* pRecv);
 	int replyCreateObj(IMessage* pRecv);
 	int replyPRJobMultiCreate(IMessage* pRecv);
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 31788e7..5087821 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -190,6 +190,21 @@
 			m_master.enableEventReport(bEnable);
 		}
 	};
+	listener.onDeletePPID = [&](void* pFrom, const std::vector<std::string>& ppids) -> bool {
+		(void)pFrom;
+		bool allOk = true;
+		std::vector<std::string> targets = ppids;
+		if (targets.empty()) {
+			// L:0 => delete all PPIDs
+			targets = RecipeManager::getInstance().getAllPPID();
+		}
+		for (auto& ppid : targets) {
+			bool ok = RecipeManager::getInstance().deleteRecipeByPPID(ppid);
+			allOk = allOk && ok;
+			LOGI("<CModel>DeletePPID: %s, result=%s", ppid.c_str(), ok ? "OK" : "FAIL");
+		}
+		return allOk;
+	};
 	listener.onEnableDisableAlarmReport = [&](void* pFrom, bool bEnable, unsigned int id) -> void {
 		LOGI("onEnableDisableAlarmReport bEnable:%s, id:%d", bEnable ? _T("YES") : _T("NO"), id);
 		if (id == 0) {
diff --git a/SourceCode/Bond/Servo/PageRecipe.cpp b/SourceCode/Bond/Servo/PageRecipe.cpp
index 3965041..841a96f 100644
--- a/SourceCode/Bond/Servo/PageRecipe.cpp
+++ b/SourceCode/Bond/Servo/PageRecipe.cpp
@@ -138,9 +138,12 @@
 	// 閬嶅巻鏁版嵁骞舵彃鍏ュ埌CListCtrl涓�
 	for (int i = 0; i < static_cast<int>(vecRecipe.size()); ++i) {
 		const RecipeInfo& recipe = vecRecipe[i];
+		// 鍘熺▼搴忚姹侾PID鏈夊瓙閰嶆柟锛屽厛娉ㄩ噴
+		/*
 		if (recipe.vecDeviceList.empty() || recipe.vecDeviceList.size() > 6){
 			continue;
 		}
+		*/
 
 		m_listPPID.InsertItem(i, _T("")); // 绗�0鍒楃┖鐧�
 

--
Gitblit v1.9.3