From 6c373f004d79b28c735bbee2bd391bd412270535 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期五, 09 一月 2026 15:58:51 +0800
Subject: [PATCH] 完成统一 PortStateChange 事件与变量维护

---
 SourceCode/Bond/x64/Debug/CollectionEventList.txt |    1 +
 SourceCode/Bond/Servo/Model.cpp                   |   13 ++++++++++++-
 SourceCode/Bond/x64/Debug/ReportList.txt          |    1 +
 3 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index ad932b1..3f03a3d 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -490,8 +490,19 @@
 		const int eqId = (pEquipment != nullptr) ? pEquipment->getID() : 0;
 		const short prevStatus = s_prevPortStatus[eqId];
 		s_prevPortStatus[eqId] = status;
+		SERVO::CLoadPort* pLoadPort = dynamic_cast<SERVO::CLoadPort*>(pEquipment);
+
+		// Unified PortStateChange event + SV maintenance
+		if (pLoadPort != nullptr) {
+			m_hsmsPassive.withVariableLock([&] {
+				m_hsmsPassive.setVariableValue("PortTransferState", (__int64)status); // maintain SVID=100
+				m_hsmsPassive.setVariableValue("PortStateChangePortId", pLoadPort->getID());
+				m_hsmsPassive.setVariableValue("PortState", (__int64)status);
+				m_hsmsPassive.requestEventReportSend("PortStateChange");
+			});
+		}
+
 		if (status == PORT_INUSE) {
-			SERVO::CLoadPort* pLoadPort = dynamic_cast<SERVO::CLoadPort*>(pEquipment);
 			m_hsmsPassive.withVariableLock([&] {
 				if (pLoadPort != nullptr) {
 					m_hsmsPassive.setVariableValue("CarrierID", pLoadPort->getCassetteId().c_str());
diff --git a/SourceCode/Bond/x64/Debug/CollectionEventList.txt b/SourceCode/Bond/x64/Debug/CollectionEventList.txt
index b6d56b1..c8c031f 100644
--- a/SourceCode/Bond/x64/Debug/CollectionEventList.txt
+++ b/SourceCode/Bond/x64/Debug/CollectionEventList.txt
@@ -56,6 +56,7 @@
 50010,Port_Blocked,,(50010)
 50011,OCR_PanelID_Read_OK,鎵爜浜嬩欢涓婃姤,(50012)
 50012,Port_Ready_To_Release,,(50013)
+50020,PortStateChange,,(50020)
 12000,UnitStart,,(12000)
 12001,UnitStateChange,,(12001)
 12002,UnitEnd,,(12002)
diff --git a/SourceCode/Bond/x64/Debug/ReportList.txt b/SourceCode/Bond/x64/Debug/ReportList.txt
index f6741f3..cfc1f94 100644
--- a/SourceCode/Bond/x64/Debug/ReportList.txt
+++ b/SourceCode/Bond/x64/Debug/ReportList.txt
@@ -31,6 +31,7 @@
 50012,(5014)
 50013,(5015)
 50014,(5016)
+50020,(500,5020,5021)
 10015,(5018,5019)
 10016,(5018,5019)
 10017,(500,5018)

--
Gitblit v1.9.3