From bfc9e3dec34e108e2b4c3d0bfe19c5c16914fdff Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期一, 23 六月 2025 13:46:30 +0800
Subject: [PATCH] 1. 配方管理类添加关键字查询(PPID和描述)

---
 SourceCode/Bond/Servo/CEFEM.cpp |  119 +++++++++++++++++++++++++++++------------------------------
 1 files changed, 59 insertions(+), 60 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 4ef727c..8a0e9cc 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)
@@ -698,21 +711,28 @@
 
 		{
 			// JOB Data Request
-			CEqReadStep* pStep = new CEqReadStep(0x617d, 2 * 2,
+			CEqReadStep* pStep = new CEqReadStep(0x0, 0,
 				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
-					if (code == ROK && pszData != nullptr && size > 0) {
-						decodeJobDataRequest((CStep*)pFrom, pszData, size);
+					if (code == ROK /* && pszData != nullptr && size > 0*/) {
+						// 由于EFEM没有发送参数到master, 我们只需要返回数据
+						// Cassette Sequence No和Job Sequence No根据上一次调试缓存而来
+						// decodeJobDataRequest((CStep*)pFrom, pszData, size);
 
-						// efme, 获取数据后返回
-						// Cassette Sequence No		1W
-						// Job Sequence No			1W
-						// Job DataS				256W
+						// 获取数据后返回给EFEM
+						// Job DataS				320W
+						// ACK						1W
+						// Reserved					15W
+						short ack = (short)JobDataRequestAck::NG;		// 不存在jobData
 						char szBuffer[1024] = { 0 };
-						CJobDataS* pJobDataS = m_pPort[3]->getJobDataSWithCassette(4001, 1);
-						if (pJobDataS != nullptr) {
-							int size = pJobDataS->serialize(szBuffer, 1024);
-							((CEqReadStep*)pFrom)->setReturnData(szBuffer, size);
+						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;
 				});
@@ -823,66 +843,45 @@
 
 	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()
 	{
 		return 10000;
 	}
+
+	void CEFEM::printDebugString001()
+	{
+		for (int i = 0; i < 8; i++) {
+			LOGI("<CEquipment-%s>%d, Signal:%s, %s, %s, %s",
+				m_strName.c_str(), i,
+				m_bLinkSignal[i][SIGNAL_UPSTREAM_INLINE] ? "ON" : "OFF",
+				m_bLinkSignal[i][SIGNAL_UPSTREAM_TROUBLE] ? "ON" : "OFF",
+				m_bLinkSignal[i][SIGNAL_INTERLOCK] ? "ON" : "OFF",
+				m_bLinkSignal[i][SIGNAL_SEND_ABLE] ? "ON" : "OFF"
+			);
+		}
+	}
 }

--
Gitblit v1.9.3