From 8860b7e63527fad69f15944d340b7158edde1bed Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 19 七月 2025 16:10:39 +0800
Subject: [PATCH] 1.Define Report功能测试,EAP模拟

---
 SourceCode/Bond/Servo/HsmsPassive.cpp |   75 ++++++++++++++++++++++---------------
 1 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 20334e8..3f52f0e 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -133,26 +133,19 @@
 	return 0;
 }
 
-void CHsmsPassive::deleteReport(unsigned int RPTID)
+SERVO::CReport* CHsmsPassive::defineReport(unsigned int RPTID, std::vector<unsigned int>& vids)
 {
-	for (auto it = m_mapValueIdToPRTID.begin(); it != m_mapValueIdToPRTID.end(); ) {
-		if (it->second == RPTID) {
-			m_mapValueIdToPRTID.erase(it++);  // 鏇存柊杩唬鍣�
-		}
-		else {
-			++it;
+	// 娣诲姞瀹氫箟report
+	SERVO::CReport* pReport = new SERVO::CReport(RPTID, vids);
+	for (auto vid : vids) {
+		SERVO::CVariable* pVariable = getVariable(vid);
+		if (pVariable != nullptr) {
+			pReport->addVariable(pVariable);
 		}
 	}
-}
+	m_reports.push_back(pReport);
 
-void CHsmsPassive::deleteAllReport()
-{
-	m_mapValueIdToPRTID.clear();
-}
-
-void CHsmsPassive::defineReport(unsigned int VID, unsigned int RPTID)
-{
-	m_mapValueIdToPRTID[VID] = RPTID;
+	return pReport;
 }
 
 void CHsmsPassive::OnTimer(UINT nTimerid)
@@ -333,6 +326,19 @@
 	}
 
 	return nullptr;
+}
+
+bool CHsmsPassive::removeReport(int rptid)
+{
+	for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) {
+		if ((*iter)->getReportId() == rptid) {
+			delete (*iter);
+			m_reports.erase(iter);
+			return true;
+		}
+	}
+
+	return false;
 }
 
 void CHsmsPassive::clearAllReport()
@@ -889,40 +895,47 @@
 	ISECS2Item* pBody = pRecv->getBody();
 	ISECS2Item* defineItem, *rptListItem, * vidListItem;
 	unsigned int dataId, rptid, vid;
+
 	if (!pBody->getSubItemU4(0, dataId)) goto MYREPLY;
 	rptListItem = pBody->getSubItem(1);
 	if (rptListItem == nullptr) goto MYREPLY;
 	if (rptListItem->getSubItemSize() == 0) {
-		deleteAllReport();
+		clearAllReport();
 		goto MYREPLY;
 	}
+
 	for (int i = 0; i < rptListItem->getSubItemSize(); i++) {
 		defineItem = rptListItem->getSubItem(i);
 		if (defineItem == nullptr) continue;
+
+		std::vector<unsigned int> vids;
+		SERVO::CReport* pReport = nullptr;
 		vidListItem = defineItem->getSubItem(1);
 		if (defineItem->getSubItemU4(0, rptid)
 			&& vidListItem != nullptr) {
-			int vidCount = vidListItem->getSubItemSize();
-			if (vidCount == 0) {
-				deleteReport(rptid);
-			}
-			else {
-				for (int k = 0; k < vidCount; k++) {
-					if (vidListItem->getSubItemU4(k, vid)) {
-						defineReport(vid, rptid);
-					}
+			for (int k = 0; k < vidListItem->getSubItemSize(); k++) {
+				if (vidListItem->getSubItemU4(k, vid)) {
+					vids.push_back(vid);
 				}
+			}
+		}
+
+		removeReport(rptid);
+		if (!vids.empty()) {
+			pReport = defineReport(rptid, vids);
+		}
+
+		// 妫�楠岀粨鏋滄槸鍚︽纭�
+		if (pReport != nullptr) {
+			auto variables = pReport->getVariables();
+			for (auto item : variables) {
+				LOGE("=== prtid:%d, vid:%d", rptid, item->getVarialbleId());
 			}
 		}
 	}
 
 
 MYREPLY:
-	// 妫�楠岀粨鏋滄槸鍚︽纭�
-	for (auto item : m_mapValueIdToPRTID) {
-		LOGE("=== vid:%d, prtid:%d", item.first, item.second);
-	}
-
 	replyAck(2, 34, pRecv->getHeader()->systemBytes, BYTE(0), "DRACK");
 	return 0;
 }

--
Gitblit v1.9.3