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/CLoadPort.cpp |  165 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 105 insertions(+), 60 deletions(-)

diff --git a/SourceCode/Bond/Servo/CLoadPort.cpp b/SourceCode/Bond/Servo/CLoadPort.cpp
index d3550f0..4b86cf7 100644
--- a/SourceCode/Bond/Servo/CLoadPort.cpp
+++ b/SourceCode/Bond/Servo/CLoadPort.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+锘�#include "stdafx.h"
 #include "CLoadPort.h"
 #include "CGlassPool.h"
 #include "Servo.h"
@@ -17,6 +17,7 @@
 		m_bAutoChangeEnable = FALSE;
 		m_nNextCassetteSequenceNo = 0;
 		m_isCompareMapsBeforeProceeding = FALSE;
+		m_downloadCassetteMap = 0;
 	}
 
 	CLoadPort::~CLoadPort()
@@ -40,16 +41,16 @@
 		CEquipment::term();
 	}
 
-	// 必须要实现的虚函数,在此初始化Pin列表
+	// 蹇呴』瑕佸疄鐜扮殑铏氬嚱鏁帮紝鍦ㄦ鍒濆鍖朠in鍒楄〃
 	void CLoadPort::initPins()
 	{
-		// 加入Pin初始化代码
-		LOGI("<CLoadPort>initPins");
+		// 鍔犲叆Pin鍒濆鍖栦唬鐮�
+		LOGD("<CLoadPort>initPins");
 		addPin(SERVO::PinType::INPUT, _T("In"));
 		addPin(SERVO::PinType::OUTPUT, _T("Out"));
 	}
 
-	// 必须要实现的虚函数,在此初始化Slot信息
+	// 蹇呴』瑕佸疄鐜扮殑铏氬嚱鏁帮紝鍦ㄦ鍒濆鍖朣lot淇℃伅
 	void CLoadPort::initSlots()
 	{
 		for (int i = 0; i < SLOT_MAX; i++) {
@@ -350,20 +351,48 @@
 	{
 		CEquipment::onTimer(nTimerid);
 
-		// 模拟测试
+
+		// 浠庨厤缃鍑虹殑enable锛屽垵濮嬪寲鏃跺啓缁檈fem
+		static int i_enable[4] = { 0 };
+		if ((++i_enable[m_nIndex]) == 20 + m_nIndex) {
+			eablePort(m_bEnable, [&](int code) -> int {
+				LOGI("<LoadPort-%d>eablePort:code=%d", m_nIndex, code);
+				return 0;
+				});
+		}
+
+
+
+		// 妯℃嫙娴嬭瘯
 		/*
 		if (m_nIndex == 0) {
 			static int ii = 0;
 			ii++;
 			if (ii == 50) {
 				char szBuffer[64] = {0};
-				CStep* pStep = getStepWithName(STEP_EQ_PORT1_INUSE);
+				CStep* pStep = getStepWithName(STEP_EQ_PORT1_BLOCKED);
 				CPortStatusReport portStatusReport;
-				portStatusReport.setPortStatus(PORT_INUSE);
+				portStatusReport.setPortStatus(PORT_BLOCKED);
 				portStatusReport.setJobExistenceSlot(0xf);
-				portStatusReport.setCassetteId("CID1984113");
+				portStatusReport.setCassetteId("CID1001");
 				int nRet = portStatusReport.serialize(szBuffer, 64);
 				decodePortStatusReport(pStep, szBuffer, 64);
+				LOGI("<CLoadPort>Port1杞藉叆妯℃嫙鏁版嵁锛� id:CID1001 map: 0xf");
+			}
+		}
+		if (m_nIndex == 1) {
+			static int ii = 0;
+			ii++;
+			if (ii == 55) {
+				char szBuffer[64] = { 0 };
+				CStep* pStep = getStepWithName(STEP_EQ_PORT2_BLOCKED);
+				CPortStatusReport portStatusReport;
+				portStatusReport.setPortStatus(PORT_BLOCKED);
+				portStatusReport.setJobExistenceSlot(0xff );
+				portStatusReport.setCassetteId("CID1004");
+				int nRet = portStatusReport.serialize(szBuffer, 64);
+				decodePortStatusReport(pStep, szBuffer, 64);
+				LOGI("<CLoadPort>Port2杞藉叆妯℃嫙鏁版嵁锛� id:CID1004 map: 0xff");
 			}
 		}
 		*/
@@ -378,7 +407,6 @@
 			m_portStatusReport.serialize(ar);
 		}
 		else {
-			int temp;
 			ar >> m_nIndex;
 			m_portStatusReport.serialize(ar);
 		}
@@ -464,9 +492,25 @@
 		return (m_nIndex + 1) * 1000 + m_nNextCassetteSequenceNo;
 	}
 
+	int CLoadPort::getPortCassetteSnSeed()
+	{
+		return m_nNextCassetteSequenceNo;
+	}
+
+	void CLoadPort::setPortCassetteSnSeed(int seed)
+	{
+		m_nNextCassetteSequenceNo = seed;
+		if (m_nNextCassetteSequenceNo >= 1000) {
+			m_nNextCassetteSequenceNo = 0;
+		}
+	}
+
 	void CLoadPort::setIndex(unsigned int index)
 	{
 		m_nIndex = index;
+
+		std::string id = "Port" + std::to_string(index + 1);
+		m_portStatusReport.setCassetteId(id.c_str());
 	}
 
 	unsigned int CLoadPort::getIndex()
@@ -517,6 +561,11 @@
 	std::string& CLoadPort::getCassetteId()
 	{
 		return m_portStatusReport.getCassetteId();
+	}
+
+	void CLoadPort::simulateSetCassetteId(const char* pszCarrierId)
+	{
+		m_portStatusReport.setCassetteId(pszCarrierId);
 	}
 
 	int CLoadPort::getLoadingCassetteType()
@@ -893,27 +942,15 @@
 		m_portStatusReport.copyEx(portStatusReport);
 
 
-		// 当port状态为InUse, 比较map
+		// 褰損ort鐘舵�佷负InUse, 姣旇緝map
 		if (m_portStatusReport.getPortStatus() == PORT_INUSE) {
-			if (m_isCompareMapsBeforeProceeding) {
-				short scanMap = getScanCassetteMap();
-				short downloadMap = getDownloadCassetteMap();
-				if (scanMap == downloadMap) {
-					generateGlassList(scanMap);
-					this->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
-				}
-				else {
-					this->sendCassetteCtrlCmd(CCC_PROCESS_CANCEL, nullptr, 0, 0, 0, nullptr, nullptr);
+			// 鐢熸垚鐜荤拑鍒楄〃锛氭潵鑷� EFEM 鎵弿鍒扮殑 map
+			generateGlassList(getScanCassetteMap());
 
-					// 抛出到应用层做提示
-					if (m_listener.onMapMismatch != nullptr) {
-						m_listener.onMapMismatch(this, scanMap, downloadMap);
-					}
-				}
-			}
-			else {
-				// 抛出到应用层做选择要加工的片子
-				generateGlassList(getScanCassetteMap());
+			// CompareMapsBeforeProceeding锛氫笉鍦ㄦ澶勮嚜鍔� Start/Cancel锛屾敼涓虹瓑寰� Host 鍐崇瓥锛圥roceedWithCarrier/ProceedWithSlotMap/CarrierRelease锛�
+			// Host 鍐崇瓥鍏ュ彛锛歋3F17 CarrierAction -> listener.onCarrierAction -> CMaster::proceedWithCarrier()/carrierRelease()
+			if (m_isCompareMapsBeforeProceeding) {
+				// 杩欓噷浠呯瓑寰咃紝鍏蜂綋涓婃姤鐢变笂灞傚湪 PORT_INUSE 浜嬩欢涓Е鍙戯紙S6F11 CheckSlotMap锛�
 			}
 		}
 		if (m_listener.onPortStatusChanged != nullptr) {
@@ -922,7 +959,7 @@
 		}
 
 
-		// 缓存Attribute,用于调试时显示信息
+		// 缂撳瓨Attribute锛岀敤浜庤皟璇曟椂鏄剧ず淇℃伅
 		unsigned int weight = 201;
 		CAttributeVector& attrubutes = pStep->attributeVector();
 		m_portStatusReport.getAttributeVector(attrubutes, weight);
@@ -947,17 +984,17 @@
 			return -1;
 		}
 
-		LOGI("<CLoadPort-%d>准备设置Port type<%d>", m_nIndex, (int)type);
+		LOGI("<CLoadPort-%d>鍑嗗璁剧疆Port type<%d>", m_nIndex, (int)type);
 		short value = (short)type;
 		pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
 			// test
 			code = WOK;
 			if (code == WOK) {
 				m_portType = type;
-				LOGI("<CLoadPort-%d>设置Port type成功.", m_nIndex);
+				LOGI("<CLoadPort-%d>璁剧疆Port type鎴愬姛.", m_nIndex);
 			}
 			else {
-				LOGI("<CLoadPort-%d>设置Port type失败,code:%d", m_nIndex, code);
+				LOGE("<CLoadPort-%d>璁剧疆Port type澶辫触锛宑ode:%d", m_nIndex, code);
 			}
 			if (onWritedBlock != nullptr) {
 				return onWritedBlock(code);
@@ -977,17 +1014,17 @@
 			return -1;
 		}
 
-		LOGI("<CLoadPort-%d>准备%s Port", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+		LOGI("<CLoadPort-%d>鍑嗗%s Port", m_nIndex, bEnable ? _T("鍚敤") : _T("绂佺敤"));
 		short value = bEnable ? 1 : 2;
 		pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
 			// test
 			code = WOK;
 			if (code == WOK) {
 				m_bEnable = bEnable;
-				LOGI("<CLoadPort-%d>%s Port成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+				LOGI("<CLoadPort-%d>%s Port鎴愬姛.", m_nIndex, bEnable ? _T("鍚敤") : _T("绂佺敤"));
 			}
 			else {
-				LOGI("<CLoadPort-%d>%s  Port失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
+				LOGE("<CLoadPort-%d>%s  Port澶辫触锛宑ode:%d", m_nIndex, bEnable ? _T("鍚敤") : _T("绂佺敤"), code);
 			}
 			if (onWritedBlock != nullptr) {
 				return onWritedBlock(code);
@@ -1006,17 +1043,17 @@
 			return -1;
 		}
 
-		LOGI("<CLoadPort-%d>准备设置Port mode<%d>", m_nIndex, (int)mode);
+		LOGI("<CLoadPort-%d>鍑嗗璁剧疆Port mode<%d>", m_nIndex, (int)mode);
 		short value = (short)mode;
 		pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
 			// test
 			code = WOK;
 			if (code == WOK) {
 				m_portMode = mode;
-				LOGI("<CLoadPort-%d>设置Port mode成功.", m_nIndex);
+				LOGI("<CLoadPort-%d>璁剧疆Port mode鎴愬姛.", m_nIndex);
 			}
 			else {
-				LOGI("<CLoadPort-%d>设置Port mode失败,code:%d", m_nIndex, code);
+				LOGE("<CLoadPort-%d>璁剧疆Port mode澶辫触锛宑ode:%d", m_nIndex, code);
 			}
 			if (onWritedBlock != nullptr) {
 				return onWritedBlock(code);
@@ -1036,16 +1073,16 @@
 			return -1;
 		}
 
-		LOGI("<CLoadPort-%d>准备设置Cassette Type<%d>", m_nIndex, (int)type);
+		LOGI("<CLoadPort-%d>鍑嗗璁剧疆Cassette Type<%d>", m_nIndex, (int)type);
 		short value = (short)type;
 		pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
 			// test
 			code = WOK;
 			if (code == WOK) {
-				LOGI("<CLoadPort-%d>设置Cassette Type成功.", m_nIndex);
+				LOGI("<CLoadPort-%d>璁剧疆Cassette Type鎴愬姛.", m_nIndex);
 			}
 			else {
-				LOGI("<CLoadPort-%d>设置Cassette Type失败,code:%d", m_nIndex, code);
+				LOGE("<CLoadPort-%d>璁剧疆Cassette Type澶辫触锛宑ode:%d", m_nIndex, code);
 			}
 			if (onWritedBlock != nullptr) {
 				return onWritedBlock(code);
@@ -1064,17 +1101,17 @@
 			return -1;
 		}
 
-		LOGI("<CLoadPort-%d>准备设置Transfer mode<%d>", m_nIndex, (int)mode);
+		LOGI("<CLoadPort-%d>鍑嗗璁剧疆Transfer mode<%d>", m_nIndex, (int)mode);
 		short value = (short)mode;
 		pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
 			// test
 			code = WOK;
 			if (code == WOK) {
 				m_transferMode = mode;
-				LOGI("<CLoadPort-%d>设置Transfer mode成功.", m_nIndex + 1);
+				LOGI("<CLoadPort-%d>璁剧疆Transfer mode鎴愬姛.", m_nIndex + 1);
 			}
 			else {
-				LOGI("<CLoadPort-%d>设置Transfer mode失败,code:%d", m_nIndex + 1, code);
+				LOGE("<CLoadPort-%d>璁剧疆Transfer mode澶辫触锛宑ode:%d", m_nIndex + 1, code);
 			}
 			if (onWritedBlock != nullptr) {
 				return onWritedBlock(code);
@@ -1093,17 +1130,17 @@
 			return -1;
 		}
 
-		LOGI("<CLoadPort-%d>准备%s Auto Change", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+		LOGI("<CLoadPort-%d>鍑嗗%s Auto Change", m_nIndex, bEnable ? _T("鍚敤") : _T("绂佺敤"));
 		short value = bEnable ? 1 : 2;
 		pStep->writeDataEx((const char*)&value, sizeof(short), [&, onWritedBlock](int code) -> int {
 			// test
 			code = WOK;
 			if (code == WOK) {
 				m_bAutoChangeEnable = bEnable;
-				LOGI("<CLoadPort-%d>%s Auto Change成功.", m_nIndex, bEnable ? _T("启用") : _T("禁用"));
+				LOGI("<CLoadPort-%d>%s Auto Change鎴愬姛.", m_nIndex, bEnable ? _T("鍚敤") : _T("绂佺敤"));
 			}
 			else {
-				LOGI("<CLoadPort-%d>%s  Auto Change失败,code:%d", m_nIndex, bEnable ? _T("启用") : _T("禁用"), code);
+				LOGE("<CLoadPort-%d>%s  Auto Change澶辫触锛宑ode:%d", m_nIndex, bEnable ? _T("鍚敤") : _T("绂佺敤"), code);
 			}
 			if (onWritedBlock != nullptr) {
 				return onWritedBlock(code);
@@ -1151,17 +1188,20 @@
 
 	short CLoadPort::getDownloadCassetteMap()
 	{
-		// 暂时未实现此功能
-		short map = 0;
-		return map;
+		return m_downloadCassetteMap;
+	}
+
+	void CLoadPort::setDownloadCassetteMap(short map)
+	{
+		m_downloadCassetteMap = map;
 	}
 
 	/*
-	 * 生成测试用的玻璃列表
+	 * 鐢熸垚娴嬭瘯鐢ㄧ殑鐜荤拑鍒楄〃
 	 */
 	int CLoadPort::testGenerateGlassList(MaterialsType type)
 	{
-		// 如果非空就不生成了
+		// 濡傛灉闈炵┖灏变笉鐢熸垚浜�
 		Lock();
 		if (hasGlass()) {
 			Unlock();
@@ -1183,7 +1223,7 @@
 
 			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
 			pGlass->setOriginPort(m_nIndex, i);
-			pGlass->addPath(m_nID, 0);
+			pGlass->addPath(m_nID, 0, i + 1);
 			pGlass->processEnd(m_nID, 0);
 			pGlass->setID(szBuffer);
 			pGlass->setType(type);
@@ -1195,11 +1235,11 @@
 	}
 
 	/*
-	 * 根据efem扫描到的map,生成玻璃列表
+	 * 鏍规嵁efem鎵弿鍒扮殑map锛岀敓鎴愮幓鐠冨垪琛�
 	 */
 	int CLoadPort::generateGlassList(short map)
 	{
-		// 先释放较早前的数据
+		// 鍏堥噴鏀捐緝鏃╁墠鐨勬暟鎹�
 		Lock();
 		for (int i = 0; i < SLOT_MAX; i++) {
 			m_slot[i].setContext(nullptr);
@@ -1207,11 +1247,11 @@
 		Unlock();
 
 
-		// 根据map生成新的
+		// 鏍规嵁map鐢熸垚鏂扮殑
 		char szBuffer[64];
 		for (int i = 0; i < SLOT_MAX; i++) {
 			if (!m_slot[i].isEnable()) continue;
-			if (!(map >> i) & 1) continue;
+			if (((map >> i) & 1) == 0) continue;
 
 			CJobDataS js;
 			js.setCassetteSequenceNo(getNextCassetteSequenceNo());
@@ -1223,7 +1263,7 @@
 			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
 			pGlass->setOriginPort(m_nIndex, i);
 			pGlass->setScheduledForProcessing(i % 2 == 1);
-			pGlass->addPath(m_nID, 0);
+			pGlass->addPath(m_nID, 0, i + 1);
 			pGlass->processEnd(m_nID, 0);
 			pGlass->setID(szBuffer);
 			pGlass->setType(m_cassetteType);
@@ -1263,7 +1303,7 @@
 
 			CGlass* pGlass = theApp.m_model.m_glassPool.allocaGlass();
 			pGlass->setOriginPort(m_nIndex, nSlotIndex);
-			pGlass->addPath(m_nID, 0);
+			pGlass->addPath(m_nID, 0, slot.nSlotID);
 			pGlass->processEnd(m_nID, 0);
 			pGlass->setID(szBuffer);
 			pGlass->setType(static_cast<SERVO::MaterialsType>(config.nMaterialType));
@@ -1279,4 +1319,9 @@
 	{
 		m_isCompareMapsBeforeProceeding = bCompare;
 	}
+
+	BOOL CLoadPort::isCompareMapsBeforeProceeding() const
+	{
+		return m_isCompareMapsBeforeProceeding;
+	}
 }

--
Gitblit v1.9.3