From 6a0f19f181b6968d86aca3885662aabedefc3a3e Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期一, 05 一月 2026 22:28:49 +0800
Subject: [PATCH] 1.DATAID修改为U2 2.Link event或unlink后保存到文件;

---
 SourceCode/Bond/Servo/CCollectionEvent.h   |    2 
 SourceCode/Bond/x64/Debug/test.ini         |   10 +++++
 SourceCode/Bond/Servo/HsmsPassive.cpp      |   73 ++++++++++++++++++++++++++----------
 SourceCode/Bond/Servo/CCollectionEvent.cpp |    4 +-
 4 files changed, 65 insertions(+), 24 deletions(-)

diff --git a/SourceCode/Bond/Servo/CCollectionEvent.cpp b/SourceCode/Bond/Servo/CCollectionEvent.cpp
index ce5d1a2..13e23b2 100644
--- a/SourceCode/Bond/Servo/CCollectionEvent.cpp
+++ b/SourceCode/Bond/Servo/CCollectionEvent.cpp
@@ -59,9 +59,9 @@
 		}
 	}
 
-	unsigned int CCollectionEvent::getFirstPortID()
+	unsigned int CCollectionEvent::getFirstReportID()
 	{
-		if (m_reports.empty()) return -1;
+		if (m_reports.empty()) return 0;
 		return m_reports.front()->getReportId();
 	}
 
diff --git a/SourceCode/Bond/Servo/CCollectionEvent.h b/SourceCode/Bond/Servo/CCollectionEvent.h
index 9bd55a9..7dfe985 100644
--- a/SourceCode/Bond/Servo/CCollectionEvent.h
+++ b/SourceCode/Bond/Servo/CCollectionEvent.h
@@ -23,7 +23,7 @@
 
 		/* 如果一个CEID只有一个Report的场景,调用此函数设置或取消 */
 		void setReport(CReport* pReport);
-		unsigned int getFirstPortID();
+		unsigned int getFirstReportID();
 		CReport* getFirstReport();
 
 	private:
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 8b56b52..e8986ca 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -153,9 +153,11 @@
 
 void CHsmsPassive::unlinkEventReport(unsigned int CEID)
 {
+	LOGI("<CHsmsPassive>unlinkEventReport enter");
 	SERVO::CCollectionEvent* pEvent = getEvent(CEID);
 	if (pEvent != nullptr) {
 		pEvent->setReport(nullptr);
+		LOGI("<CHsmsPassive>unlink Event Report.CEID=%d", CEID);
 	}
 }
 
@@ -193,7 +195,7 @@
 
 int CHsmsPassive::onRecvMsg(IMessage* pMessage)
 {
-	LOGI("onRecvMsg:%s", pMessage->toString());
+	// LOGI("onRecvMsg:%s", pMessage->toString());
 	Lock();
 	if (m_pActiveAction != nullptr &&
 		(m_pActiveAction->getSendMessage()->getHeader()->systemBytes == pMessage->getHeader()->systemBytes)) {
@@ -1199,7 +1201,7 @@
 		*/
 	};
 	auto onRecvSysMessage = [&](void* pFrom, IMessage* pMessage) -> void {
-		LOGI("<HSMS>onRecvSysMessage:sessionId:%d, sType:%d systemBytes:%d",
+		LOGI("<HSMS>[Received]sessionId:%d, sType:%d systemBytes:%d",
 		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
 		onRecvMsg(pMessage);
 		if (MSG_LINKTEST_REQ == pMessage->getHeader()->sType) {
@@ -1226,7 +1228,7 @@
 		HEADER* pHeader = pMessage->getHeader();
 		int nStream = (pHeader->stream & 0x7F);
 
-		LOGI("<HSMS>鏀跺埌娑堟伅 S%dF%d", nStream, pHeader->function);
+		LOGI("<HSMS>[Received]%s", pMessage->toString());
 		if (nStream == 1 && pHeader->function == 1) {
 			// S1F1
 			replyAreYouThere(pMessage);
@@ -1498,7 +1500,9 @@
 	ISECS2Item* pItem = pMessage->getBody();
 	pItem->setBinary((const char*)&ack, 1, pszAckName);
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]S%dF%d (SysByte=%u)", s, f, systemBytes);
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 }
 
@@ -1539,7 +1543,7 @@
 	pItem->addItem(m_strEquipmentModelType.c_str(), "MDLN");
 	pItem->addItem(m_strSoftRev.c_str(), "SOFTREV");
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]S1F2 (SysByte=%u)", pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SECS Msg SEND] %s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 
 	return 0;
@@ -1600,7 +1604,9 @@
 	pList->addItem(m_strEquipmentModelType.c_str(), "MDLN");
 	pList->addItem(m_strSoftRev.c_str(), "SOFTREV");
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]%s", pMessage->toString());
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 
 	return 0;
@@ -1638,7 +1644,9 @@
 
 MYREPLY:
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]%s", pMessage->toString());
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 
 
@@ -1687,7 +1695,9 @@
 	}
 
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]S2F14 (SysByte=%u)", pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 
 	return 0;
@@ -1783,9 +1793,10 @@
 
 	ISECS2Item* pBody = pRecv->getBody();
 	ISECS2Item* defineItem, *rptListItem, * vidListItem;
-	unsigned int dataId, rptid, vid;
+	unsigned short dataId;
+	unsigned int rptid, vid;
 
-	if (!pBody->getSubItemU4(0, dataId)) goto MYREPLY;
+	if (!pBody->getSubItemU2(0, dataId)) goto MYREPLY;
 	rptListItem = pBody->getSubItem(1);
 	if (rptListItem == nullptr) goto MYREPLY;
 	if (rptListItem->getSubItemSize() == 0) {
@@ -1839,8 +1850,10 @@
 
 	ISECS2Item* pBody = pRecv->getBody();
 	ISECS2Item* linkItem, *ceidListItem, *rptListItem;
-	unsigned int dataId, ceid, rptid;
-	if (!pBody->getSubItemU4(0, dataId)) goto MYREPLY;
+	unsigned short dataId;
+	unsigned int ceid, rptid;
+	bool bChanged = false;
+	if (!pBody->getSubItemU2(0, dataId)) goto MYREPLY;
 	ceidListItem = pBody->getSubItem(1);
 	if (ceidListItem == nullptr) goto MYREPLY;
 	for (int i = 0; i < ceidListItem->getSubItemSize(); i++) {
@@ -1852,21 +1865,31 @@
 			int prtCount = rptListItem->getSubItemSize();
 			if (prtCount == 0) {
 				unlinkEventReport(ceid);
+				bChanged = true;
 			}
 			else {
 				for (int k = 0; k < prtCount; k++) {
 					if (rptListItem->getSubItemU4(k, rptid)) {
 						linkEventReport(ceid, rptid);
+						bChanged = true;
 					}
 				}
 			}
 		}
 	}
 
+	// 鎸佷箙鍖栧埌 CollectionEventList.txt锛堜究浜庝笅娆″惎鍔ㄤ粛淇濇寔 Link/Unlink 缁撴灉锛�
+	if (bChanged && !m_strCollectionEventFilepath.empty()) {
+		writeCollectionEventsToFile(m_strCollectionEventFilepath);
+	}
 
 	// 妫�楠岀粨鏋滄槸鍚︽纭�
 	for (auto item : m_collectionEvents) {
-		LOGE("=== ceid:%d, prtid:%d", item->getEventId(), item->getFirstPortID());
+		unsigned int reportId = item->getFirstReportID();
+		if(reportId != 0)
+			LOGI("=== ceid:%d, prtid:%d", item->getEventId(), reportId);
+		else 
+			LOGI("=== ceid:%d, prtid:--", item->getEventId());
 	}
 	
 MYREPLY:
@@ -2029,10 +2052,10 @@
 	ISECS2Item* pBody = pRecv->getBody();
 	if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR;
 
-	unsigned int DATAID;
+	unsigned short DATAID;
 	unsigned char PTN;
 	const char* pszCarrierAction, *pszCarrierId;
-	pBody->getSubItemU4(0, DATAID);
+	pBody->getSubItemU2(0, DATAID);
 	pBody->getSubItemString(1, pszCarrierAction);
 	pBody->getSubItemString(2, pszCarrierId);
 	pBody->getSubItemU1(3, PTN);
@@ -2053,7 +2076,9 @@
 	pErrItem->addU4Item(ERRCODE, "ERRCODE");
 	pErrItem->addItem(strError.c_str(), "ERRTEXT");
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]S3F18 (SysByte=%u)", pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 	
 	return 0;
@@ -2154,7 +2179,9 @@
 	}
 
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]S7F20 (SysByte=%u)", pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 
 	return 0;
@@ -2318,7 +2345,9 @@
 MYREPLY:
 	pReplyItemAck->setU1(bCreateOk ? 0 : 1, "OBJACK");
 	m_pPassive->sendMessage(pReply);
-	LOGI("<HSMS>[SECS Msg SEND]S14F10 (SysByte=%u)", pReply->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pReply->getHeader()->sessionId, pReply->getHeader()->sType, pReply->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pReply->toString());
 	HSMS_Destroy1Message(pReply);
 
 
@@ -2337,7 +2366,7 @@
 
 	// 瑙i噴鏁版嵁锛屽緱鍒癈ProcessJob
 	ISECS2Item* pItemPjs, * pItemPj,* pItemCarriers, * pItemCarrier, *pItemSlots, *pItemRecipes;
-	unsigned int DATAID;
+	unsigned short DATAID;
 	const char* pszPrjobid, *pszMF, *pszCarrierId, *pszRecipeName;
 	std::string strCarrierId;
 	unsigned int len;
@@ -2345,7 +2374,7 @@
 	std::vector<unsigned char> slots;
 	std::vector<SERVO::CProcessJob*> pjs;
 
-	if (!pBody->getSubItemU4(0, DATAID)) return ER_PARAM_ERROR;
+	if (!pBody->getSubItemU2(0, DATAID)) return ER_PARAM_ERROR;
 	pItemPjs = pBody->getSubItem(1);
 	if (pItemPjs == nullptr) return ER_PARAM_ERROR;
 	for (int i = 0; i < pItemPjs->getSubItemSize(); i++) {
@@ -2417,7 +2446,9 @@
 		}
 	}
 	m_pPassive->sendMessage(pMessage);
-	LOGI("<HSMS>[SECS Msg SEND]S16F16 (SysByte=%u)", pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]sessionId:%d, sType:%d systemBytes:%d",
+		pMessage->getHeader()->sessionId, pMessage->getHeader()->sType, pMessage->getHeader()->systemBytes);
+	LOGI("<HSMS>[SEND]%s", pMessage->toString());
 	HSMS_Destroy1Message(pMessage);
 
 
diff --git a/SourceCode/Bond/x64/Debug/test.ini b/SourceCode/Bond/x64/Debug/test.ini
new file mode 100644
index 0000000..bf28634
--- /dev/null
+++ b/SourceCode/Bond/x64/Debug/test.ini
@@ -0,0 +1,10 @@
+[SimEap]
+; Enable/disable simulator (1=on, 0=off)
+Enabled=1
+
+; Step interval in milliseconds
+IntervalMs=2000
+
+; Run a single step once. Change Step value to trigger again.
+; 0 means do nothing.
+Step=1

--
Gitblit v1.9.3