From 62a56d6003638a7c0a477cc549d1811e6b17a4a4 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 03 七月 2025 11:06:34 +0800
Subject: [PATCH] 1.增加下载的map和efem扫描的map的比较,如果不一致,则Cassette Process Cancel 并抛出到应用层。一致则Cassette Process Start。

---
 SourceCode/Bond/Servo/CLoadPort.h   |    1 +
 SourceCode/Bond/Servo/CMaster.cpp   |    4 ++++
 SourceCode/Bond/Servo/CEquipment.h  |    2 ++
 SourceCode/Bond/Servo/CLoadPort.cpp |   31 ++++++++++++++++++++++++++++---
 4 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 465354d..3fec1cc 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -54,6 +54,7 @@
 	typedef std::function<BOOL(void* pEiuipment, int port, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
 	typedef std::function<BOOL(void* pEiuipment, int port, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
 	typedef std::function<void(void* pEiuipment, PROCESS_STATE state)> ONPROCESSSTATE;
+	typedef std::function<void(void* pEiuipment, short scanMap, short downMap)> ONMAPMISMATCH;
 	typedef struct _EquipmentListener
 	{
 		ONALIVE				onAlive;
@@ -64,6 +65,7 @@
 		ONPREFETCHEDOUTJOB	onPreFethedOutJob;
 		ONPRESTOREDJOB		onPreStoredJob;
 		ONPROCESSSTATE		onProcessStateChanged;
+		ONMAPMISMATCH		onMapMismatch;
 	} EquipmentListener;
 
 
diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index f6afed4..ee5a8d1 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -884,8 +884,22 @@
 		if (nRet < 0) return nRet;
 		m_portStatusReport.copyEx(portStatusReport);
 
+
+		// 当port状态为InUse, 比较map
 		if (m_portStatusReport.getPortStatus() == PORT_INUSE) {
-			this->sendCassetteCtrlCmd(5, nullptr, 0, 0, 0, nullptr, nullptr);
+			short scanMap = m_portStatusReport.getJobExistenceSlot();
+			short downMap = getCassetteMap();
+			if (scanMap == downMap) {
+				this->sendCassetteCtrlCmd(5, nullptr, 0, 0, 0, nullptr, nullptr);
+			}
+			else {
+				this->sendCassetteCtrlCmd(10, nullptr, 0, 0, 0, nullptr, nullptr);
+
+				// 抛出到应用层做提示
+				if (m_listener.onMapMismatch != nullptr) {
+					m_listener.onMapMismatch(this, scanMap, downMap);
+				}
+			}
 		}
 
 
@@ -1112,6 +1126,18 @@
 		m_bAutoChangeEnable = bEnable;
 	}
 
+	short CLoadPort::getCassetteMap()
+	{
+		short map = 0;
+		for (int i = 0; i < SLOT_MAX; i++) {
+			if (!m_slot[i].isEnable()) continue;
+			if (m_slot[i].getContext() == nullptr) continue;
+			map |= (1 << i);
+		}
+
+		return map;
+	}
+
 	/*
 	 * 生成测试用的玻璃列表
 	 */
@@ -1127,14 +1153,13 @@
 
 
 		char szBuffer[64];
-		for (int i = 0; i < 1; i++) {
+		for (int i = 0; i < SLOT_MAX; i++) {
 			if (!m_slot[i].isEnable()) continue;
 
 			CJobDataS js;
 			js.setCassetteSequenceNo(getNextCassetteSequenceNo());
 			js.setJobSequenceNo(m_slot[i].getNo());
 			sprintf_s(szBuffer, 64, "%05d%05d", js.getCassetteSequenceNo(), js.getJobSequenceNo());
-			//js.setGlass1Id(szBuffer);
 			js.setJobType(1);
 			js.setMaterialsType((int)type);
 
diff --git a/SourceCode/Bond/Servo/CLoadPort.h b/SourceCode/Bond/Servo/CLoadPort.h
index daf5516..b8279c2 100644
--- a/SourceCode/Bond/Servo/CLoadPort.h
+++ b/SourceCode/Bond/Servo/CLoadPort.h
@@ -37,6 +37,7 @@
 		void localSetCessetteType(CassetteType type);
 		void localSetTransferMode(TransferMode mode);
 		void localAutoChangeEnable(BOOL bEnable);
+		short getCassetteMap();
 
 	public:
 		short getNextCassetteSequenceNo();
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 6fd1c50..752192c 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -1012,6 +1012,10 @@
 		listener.onProcessStateChanged = [&](void* pEquipment, PROCESS_STATE state) -> void {
 			LOGI("<Master>onProcessStateChanged<%d>", (int)state);
 		};
+		listener.onMapMismatch = [&](void* pEquipment, short scanMap, short downMap) {
+			LOGE("<Master-%s>Port InUse, map(%d!=%d)不一致,请检查。",
+				((CEquipment*)pEquipment)->getName().c_str(), scanMap, downMap);
+		};
 		pEquipment->setListener(listener);
 		pEquipment->setCcLink(&m_cclink);
 		m_listEquipment.push_back(pEquipment);

--
Gitblit v1.9.3