From 517c0e8eba29ff41afbbc0abb0f913914b37e4e1 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期二, 27 一月 2026 10:59:09 +0800
Subject: [PATCH] 1.SlotMap Mismatch 事件

---
 SourceCode/Bond/Servo/Model.cpp |   40 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 6882783..6cbe9c2 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -184,6 +184,7 @@
 
 int CModel::init()
 {
+	const ULONGLONG boot_model_begin = GetTickCount64();
 	CString strIniFile;
 	CString strUnitId;
 	strIniFile.Format(_T("%s\\ServoConfiguration.ini"), (LPTSTR)(LPCTSTR)m_strWorkDir);
@@ -214,6 +215,7 @@
 	CLog::GetLog()->SetLogsDir(strLogDir);
 	CLog::GetLog()->SetEquipmentId((LPTSTR)(LPCTSTR)strUnitId);
 	LOGI("\r\n\r\n~~~ Prog Start! ~~~");
+	LOGI("[BOOT][MODEL] init begin");
 
 
 	SECSListener listener;
@@ -331,11 +333,24 @@
 					return CAACK_5;
 				}
 
+				const short scanMap = pLoadPort->getScanCassetteMap();
+				const short downloadMap = pLoadPort->getDownloadCassetteMap();
 				m_hsmsPassive.withVariableLock([&] {
-					m_hsmsPassive.setVariableValue("SlotMapScan", pLoadPort->getScanCassetteMap());
-					m_hsmsPassive.setVariableValue("SlotMapDownload", pLoadPort->getDownloadCassetteMap());
-					m_hsmsPassive.requestEventReportSend_SlotMapVerificationOK();
+					m_hsmsPassive.setVariableValue("SlotMapScan", scanMap);
+					m_hsmsPassive.setVariableValue("SlotMapDownload", downloadMap);
+					if (scanMap != downloadMap) {
+						m_hsmsPassive.requestEventReportSend_SlotMapVerificationNG();
+						m_hsmsPassive.requestEventReportSend("SlotMapMismatch");
+					}
+					else {
+						m_hsmsPassive.requestEventReportSend_SlotMapVerificationOK();
+					}
 				});
+
+				if (scanMap != downloadMap) {
+					strErrorTxt = "rejected - SlotMap mismatch";
+					return CAACK_5;
+				}
 
 				// Host 纭 SlotMap 鍚庡啀寮�濮嬪姞宸�/娴佺▼
 				m_master.proceedWithCarrier(portIndex);
@@ -419,6 +434,8 @@
 	}
 	strVarialbleFile.Format(_T("%s\\HsmsPassive.cache"), (LPTSTR)(LPCTSTR)m_strWorkDir);
 	m_hsmsPassive.loadCacheFromFile(strVarialbleFile);
+	LOGI("[BOOT][MODEL] HSMS config loaded, cost=%llu ms",
+		(unsigned long long)(GetTickCount64() - boot_model_begin));
 
 
 	SERVO::MasterListener masterListener;
@@ -656,8 +673,14 @@
 
 		// Unified PortStateChange event + SV maintenance
 		if (pLoadPort != nullptr) {
+			const unsigned int portIndex = pLoadPort->getIndex() + 1;
+			char stateVid[64] = {0};
+			char modeVid[64] = {0};
+			sprintf_s(stateVid, "PortTransferState_P%u", portIndex);
+			sprintf_s(modeVid, "AccessMode_P%u", portIndex);
 			m_hsmsPassive.withVariableLock([&] {
-				m_hsmsPassive.setVariableValue("PortTransferState", (__int64)status); // maintain SVID=100
+				m_hsmsPassive.setVariableValue(stateVid, (__int64)status);
+				m_hsmsPassive.setVariableValue(modeVid, (__int64)pLoadPort->getPortMode());
 				m_hsmsPassive.setVariableValue("PortStateChangePortId", pLoadPort->getID());
 				m_hsmsPassive.setVariableValue("PortState", (__int64)status);
 				m_hsmsPassive.requestEventReportSend("PortStateChange");
@@ -667,7 +690,10 @@
 		if (status == PORT_INUSE) {
 			m_hsmsPassive.withVariableLock([&] {
 				if (pLoadPort != nullptr) {
-					m_hsmsPassive.setVariableValue("CarrierID", pLoadPort->getCassetteId().c_str());
+					const unsigned int portIndex = pLoadPort->getIndex() + 1;
+					char carrierVid[64] = {0};
+					sprintf_s(carrierVid, "CarrierID_P%u", portIndex);
+					m_hsmsPassive.setVariableValue(carrierVid, pLoadPort->getCassetteId().c_str());
 					if (prevStatus != PORT_INUSE && pLoadPort->isCompareMapsBeforeProceeding()) {
 						// TODO(Host鍗忓晢):
 						// 鏂囨。涓爣鏄庯細1-Empty锛�3-Exist锛屽洜姝ゆ垜浠彲鑳介渶瑕佸皢uint鐨刴ap杞崲涓簂ist涓婁紶 
@@ -922,6 +948,8 @@
 	char szBuffer[MAX_PATH];
 	sprintf_s(szBuffer, MAX_PATH, "%s\\AlarmList.csv", (LPTSTR)(LPCTSTR)m_strWorkDir);
 	alarmManager.readAlarmFile(szBuffer);
+	LOGI("[BOOT][MODEL] Alarm list loaded, cost=%llu ms",
+		(unsigned long long)(GetTickCount64() - boot_model_begin));
 
 
 	// Glass鏁版嵁搴�
@@ -930,6 +958,8 @@
 	GlassLogDb::Init(path);
 
 
+	LOGI("[BOOT][MODEL] init finished, total cost=%llu ms",
+		(unsigned long long)(GetTickCount64() - boot_model_begin));
 	return 0;
 }
 

--
Gitblit v1.9.3