From 1e7d3ca649456469440d74fabfc16e191433f9b4 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 09 五月 2025 17:47:25 +0800
Subject: [PATCH] 1.实现FetchOut Job功能;

---
 SourceCode/Bond/Servo/CEquipment.cpp |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index b2e3ad3..fe9cfe6 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -2,6 +2,7 @@
 #include "CEquipment.h"
 #include "ToolUnits.h"
 #include <regex>
+#include "CArm.h"
 
 
 #define CHECK_READ_STEP_SIGNAL(addr, data, size) {							\
@@ -34,6 +35,7 @@
 		m_bVCREnable[0] = FALSE;
 		m_pCclink = nullptr;
 		m_nBaseAlarmId = 0;
+		m_pArm = nullptr;
 		InitializeCriticalSection(&m_criticalSection);
 	}
 
@@ -74,6 +76,13 @@
 	void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
 	{
 		m_pCclink = pCcLink;
+	}
+
+	void CEquipment::setArm(CEquipment* pEquipment)
+	{
+		ASSERT(pEquipment->isArm());
+		ASSERT(!this->isArm());
+		m_pArm = pEquipment;
 	}
 
 	void CEquipment::setBaseAlarmId(int nBaseId)
@@ -382,6 +391,14 @@
 			CHECK_READ_STEP_SIGNAL(STEP_ID_EQMODE_CHANGED + i, pszData, size);
 		}
 
+		// process data report
+		CHECK_READ_STEP_SIGNAL(STEP_ID_PROCESS_DATA_REPORT, pszData, size);
+
+		// 配方改变
+		CHECK_READ_STEP_SIGNAL(STEP_ID_CURRENT_RECIPE_CHANGE_REPORT, pszData, size);
+		
+		// 主配方上报
+		CHECK_READ_STEP_SIGNAL(STEP_ID_MASTER_RECIPE_LIST_REPORT, pszData, size);
 
 		// CIM Mode
 		CHECK_WRITE_STEP_SIGNAL(STEP_ID_CIMMODE_CHANGED_CMD_REPLY, pszData, size);
@@ -769,6 +786,75 @@
 		return pGlass;
 	}
 
+	int CEquipment::fetchedOut(const char* pszGlassId)
+	{
+		if (m_pArm == nullptr) {
+			return -1;
+		}
+
+		// 找到指定的glass id, 
+		Lock();
+		if (m_glassList.empty()) {
+			Unlock();
+			return -2;
+		}
+
+		CGlass* pContext = nullptr;
+		for (auto iter = m_glassList.begin(); iter != m_glassList.end(); iter++) {
+			if ((*iter)->getID().compare(pszGlassId) == 0) {
+				pContext = (*iter);
+				m_glassList.erase(iter);
+				break;
+			}
+		}
+		if (pContext == nullptr) {
+			Unlock();
+			return -3;
+		}
+
+		((CArm*)m_pArm)->tempStore(pContext);
+		pContext->release();
+		Unlock();
+
+		if (m_listener.onDataChanged != nullptr) {
+			m_listener.onDataChanged(this, 0);
+		}
+
+		return 0;
+	}
+
+	int CEquipment::storeJob(const char* pszGlassId)
+	{
+		if (m_pArm == nullptr) {
+			return -1;
+		}
+
+		CGlass* pGlass = nullptr;
+		if (((CArm*)m_pArm)->tempFetchOut(pGlass) != 0) {
+			return -2;
+		}
+
+
+		ASSERT(pGlass);
+		Lock();
+		pGlass->addPath(m_nID);
+		pGlass->addRef();					// 加入list,addRef
+		m_glassList.push_back(pGlass);
+		pGlass->release();				// tempFetchOut需要调用一次release
+		Unlock();
+
+		if (m_listener.onDataChanged != nullptr) {
+			m_listener.onDataChanged(this, 0);
+		}
+
+		return 0;
+	}
+
+	BOOL CEquipment::isGlassListEmpty()
+	{
+		return m_glassList.empty();
+	}
+
 	bool CEquipment::isAlarmStep(SERVO::CStep* pStep)
 	{
 		return CToolUnits::startsWith(pStep->getName(), STEP_ALARM_START);
@@ -938,4 +1024,32 @@
 	{
 		return m_recipesManager.decodeRecipeParameterReport(pszData, size);
 	}
+
+	int CEquipment::decodeFetchedOutJobReport(int port, const char* pszData, size_t size)
+	{
+		int index = 0;
+		short unitOrPort, unitOrPortNo, subUnitNo, subSlotNo;
+		CJobDataB jobDataB;
+		int nRet = jobDataB.unserialize(&pszData[index], size);
+		if (nRet < 0) return nRet;
+		index += nRet;
+
+		memcpy(&unitOrPort, &pszData[index], sizeof(short));
+		index += sizeof(short);
+		memcpy(&unitOrPortNo, &pszData[index], sizeof(short));
+		index += sizeof(short);
+		memcpy(&subUnitNo, &pszData[index], sizeof(short));
+		index += sizeof(short);
+		memcpy(&subSlotNo, &pszData[index], sizeof(short));
+		index += sizeof(short);
+
+		onFetchedOut(port, jobDataB.getGlassId().c_str());
+
+		return index;
+	}
+
+	int CEquipment::onFetchedOut(int port, const char* pszGlassId)
+	{
+		return fetchedOut(pszGlassId);
+	}
 }
\ No newline at end of file

--
Gitblit v1.9.3