From 258d9d2d72bbf199cd86fd3e7bd824e1f117bab8 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 29 五月 2025 17:49:46 +0800
Subject: [PATCH] 1.放片物流控制和模拟测试;

---
 SourceCode/Bond/Servo/CEquipment.cpp |   49 ++++++++++++++++++++++++++++++++-----------------
 1 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index d9fb8e9..7cb8a5b 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -27,7 +27,7 @@
 
 	CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
 	{
-		m_listener = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
+		m_listener = { };
 		m_alive = { FALSE, 0, FALSE };
 		m_bCimState = FALSE;
 		m_bUpstreamInline = FALSE;
@@ -71,12 +71,7 @@
 
 	void CEquipment::setListener(EquipmentListener listener)
 	{
-		m_listener.onAlive = listener.onAlive;
-		m_listener.onCimStateChanged = listener.onCimStateChanged;
-		m_listener.onAlarm = listener.onAlarm;
-		m_listener.onDataChanged = listener.onDataChanged;
-		m_listener.onVcrEventReport = listener.onVcrEventReport;
-		m_listener.onPreFethedOutJob = listener.onPreFethedOutJob;
+		m_listener = listener;
 	}
 
 	void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
@@ -761,9 +756,8 @@
 		return 0;
 	}
 
-	int CEquipment::storedJob(CJobDataB* pJobDataB)
+	int CEquipment::storedJob(CJobDataB* pJobDataB, short& putSlot)
 	{
-		/*
 		if (m_pArm == nullptr) {
 			return -1;
 		}
@@ -777,13 +771,13 @@
 		ASSERT(pGlass);
 		Lock();
 		pGlass->addPath(m_nID);
-		pGlass->addRef();					// 加入list,addRef
-		m_glassList.push_back(pGlass);
+		m_slot[putSlot - 1].setContext(pGlass);
 		pGlass->release();				// tempFetchOut需要调用一次release
 		Unlock();
 
 
 		// 如果此玻璃已经贴合,贴合的玻璃也要从加入到列表中
+		/*
 		CGlass* pBuddy = pGlass->getBuddy();
 		if (pBuddy != nullptr) {
 			Lock();
@@ -792,12 +786,12 @@
 			m_glassList.push_back(pBuddy);
 			Unlock();
 		}
-
+		*/
 
 		if (m_listener.onDataChanged != nullptr) {
 			m_listener.onDataChanged(this, EDCC_STORED_JOB);
 		}
-		*/
+		
 		return 0;
 	}
 
@@ -1105,6 +1099,15 @@
 		return nullptr;
 	}
 
+	BOOL CEquipment::canPlaceGlassInSlot(const short slotIndex)
+	{
+		if (slotIndex >= SLOT_MAX) return FALSE;
+		if (!m_slot[slotIndex].isEnable()) return FALSE;
+		if (m_slot[slotIndex].getContext() != nullptr) return FALSE;
+
+		return TRUE;
+	}
+
 	short CEquipment::decodeRecipeListReport(const char* pszData, size_t size)
 	{
 		return m_recipesManager.decodeRecipeListReport(pszData, size);
@@ -1324,7 +1327,7 @@
 		return 0;
 	}
 
-	int CEquipment::onPreStoredJob(int port, CJobDataB* pJobDataB)
+	int CEquipment::onPreStoredJob(int port, CJobDataB* pJobDataB, short& putSlot)
 	{
 		LOGI("<CEquipment-%s>onPreStoredJob:port:%d|GlassId:%s",
 			m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
@@ -1336,7 +1339,7 @@
 			return FALSE;
 		}
 
-		// 当前不能有任何玻璃,且当前准备进的片是G2
+		// 如果没有可用位置,报错
 		Lock();
 		CSlot* pSlot = getAvailableSlotForGlass((MaterialsType)pJobDataS->getMaterialsType());
 		if (pSlot == nullptr) {
@@ -1346,6 +1349,17 @@
 		}
 		Unlock();
 
+
+		if (m_listener.onPreStoredJob != nullptr) {
+			if (!m_listener.onPreStoredJob(this, pJobDataB, putSlot)) {
+				return FALSE;
+			}
+
+			if(!canPlaceGlassInSlot(putSlot - 1)) {
+				return FALSE;
+			}
+		}
+
 		return TRUE;
 	}
 
@@ -1354,10 +1368,11 @@
 		LOGI("<CEquipment-%s>onStore:port:%d|GlassId:%s",
 			m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
 
-		BOOL bCheck = onPreStoredJob(port, pJobDataB);
+		short putSlot = 0;
+		BOOL bCheck = onPreStoredJob(port, pJobDataB, putSlot);
 		if (bCheck) {
 			addJobDataB(pJobDataB);
-			return storedJob(pJobDataB);
+			return storedJob(pJobDataB, putSlot);
 		}
 
 		// 数据异常,处理或显示

--
Gitblit v1.9.3