From ba74624d44eb5bfaa45b259a985d2d64e1c51e22 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 21 六月 2025 14:32:23 +0800
Subject: [PATCH] 1.从Aligner到Fliper时,使用Arm1;

---
 SourceCode/Bond/Servo/CEFEM.cpp |  110 +++++++++++++++++++++++++++----------------------------
 1 files changed, 54 insertions(+), 56 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index a331c96..201f8b5 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -26,17 +26,30 @@
 		m_robotData.position = ROBOT_POSITION::Port1;
 		m_robotData.armState[0] = FALSE;
 		m_robotData.armState[1] = FALSE;
+		m_pActiveContext = nullptr;
 	}
 
 	CEFEM::~CEFEM()
 	{
-
+		if (m_pActiveContext != nullptr) {
+			m_pActiveContext->release();
+			m_pActiveContext = nullptr;
+		}
 	}
 
 	const char* CEFEM::getClassName()
 	{
 		static char* pszName = "CEFEM";
 		return pszName;
+	}
+
+	void CEFEM::setContext(CContext* pContext)
+	{
+		if (m_pActiveContext != nullptr) {
+			m_pActiveContext->release();
+		}
+		m_pActiveContext = pContext;
+		m_pActiveContext->addRef();
 	}
 
 	void CEFEM::setPort(unsigned int index, CLoadPort* pPort)
@@ -684,7 +697,7 @@
 			CEqReadStep* pStep = new CEqReadStep(0x6301, 108 * 2,
 				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
 					if (code == ROK && pszData != nullptr && size > 0) {
-						decodePanelDataRequest((CStep*)pFrom, pszData, size);
+						decodeFacDataReport((CStep*)pFrom, pszData, size);
 					}
 					return -1;
 				});
@@ -697,18 +710,37 @@
 		}
 
 		{
-			// Panel Data Request
-			CEqReadStep* pStep = new CEqReadStep(0x617d, 2 * 2,
+			// JOB Data Request
+			CEqReadStep* pStep = new CEqReadStep(0x0, 0,
 				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
-					if (code == ROK && pszData != nullptr && size > 0) {
-						decodePanelDataRequest((CStep*)pFrom, pszData, size);
+					if (code == ROK /* && pszData != nullptr && size > 0*/) {
+						// 由于EFEM没有发送参数到master, 我们只需要返回数据
+						// Cassette Sequence No和Job Sequence No根据上一次调试缓存而来
+						// decodeJobDataRequest((CStep*)pFrom, pszData, size);
+
+						// 获取数据后返回给EFEM
+						// Job DataS				320W
+						// ACK						1W
+						// Reserved					15W
+						short ack = (short)JobDataRequestAck::NG;		// 不存在jobData
+						char szBuffer[1024] = { 0 };
+						if (m_pActiveContext != nullptr) {
+							CJobDataS* pJobDataS = ((CGlass*)m_pActiveContext)->getJobDataS();
+							if (pJobDataS != nullptr) {
+								pJobDataS->serialize(szBuffer, 1024);
+								ack = (short)JobDataRequestAck::OK;
+							}
+						}
+						memcpy(&szBuffer[320 * 2], &ack, sizeof(short));
+						((CEqReadStep*)pFrom)->setReturnData(szBuffer, 336 * 2);
 					}
 					return -1;
 				});
 			pStep->setName(STEP_EFEM_PANEL_DATA_REQUEST);
 			pStep->setProp("Port", (void*)1);
-			pStep->setWriteSignalDev(0x15d);
-			if (addStep(STEP_ID_PANEL_DATA_REQUEST, pStep) != 0) {
+			pStep->setWriteSignalDev(0x35);
+			pStep->setReturnDev(0x5EA);
+			if (addStep(STEP_ID_JOB_DATA_REQUEST, pStep) != 0) {
 				delete pStep;
 			}
 		}
@@ -811,62 +843,28 @@
 
 	int CEFEM::onFetchedOutJob(int port, CJobDataB* pJobDataB)
 	{
-		if (port == 1) {
-			return m_pPort[0]->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 2) {
-			return m_pPort[1]->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 3) {
-			return m_pPort[2]->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 4) {
-			return m_pPort[3]->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 5) {
-			return m_pArmTray[0]->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 6) {
-			return m_pArmTray[1]->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 7) {
-			return m_pAligner->onFetchedOutJob(port, pJobDataB);
-		}
-		if (port == 8) {
-			return m_pFliper->onFetchedOutJob(port, pJobDataB);
+		// 转发到子单元设备
+		CEquipment* pEqs[] = { m_pPort[0], m_pPort[1], m_pPort[2], m_pPort[3], m_pArmTray[0], m_pArmTray[1],
+			m_pAligner, m_pFliper };
+		if (1 <= port && port <= 8) {
+			pEqs[port - 1]->onFetchedOutJob(port, pJobDataB);
 		}
 
-		return -1;
+
+		return 0;
 	}
 
 	int CEFEM::onStoredJob(int port, CJobDataB* pJobDataB)
 	{
-		if (port == 1) {
-			return m_pPort[0]->onStoredJob(port, pJobDataB);
-		}
-		if (port == 2) {
-			return m_pPort[1]->onStoredJob(port, pJobDataB);
-		}
-		if (port == 3) {
-			return m_pPort[2]->onStoredJob(port, pJobDataB);
-		}
-		if (port == 4) {
-			return m_pPort[3]->onStoredJob(port, pJobDataB);
-		}
-		if (port == 5) {
-			return m_pArmTray[0]->onStoredJob(port, pJobDataB);
-		}
-		if (port == 6) {
-			return m_pArmTray[1]->onStoredJob(port, pJobDataB);
-		}
-		if (port == 7) {
-			return m_pAligner->onStoredJob(port, pJobDataB);
-		}
-		if (port == 8) {
-			return m_pFliper->onStoredJob(port, pJobDataB);
+		// 转发到子单元设备
+		CEquipment* pEqs[] = { m_pPort[0], m_pPort[1], m_pPort[2], m_pPort[3], m_pArmTray[0], m_pArmTray[1],
+			m_pAligner, m_pFliper };
+		if (1 <= port && port <= 8) {
+			pEqs[port - 1]->onStoredJob(port, pJobDataB);
 		}
 
-		return -1;
+
+		return 0;
 	}
 
 	int CEFEM::getIndexerOperationModeBaseValue()

--
Gitblit v1.9.3