From 0b32b5ca45370256da5bbfa8ca43014890258997 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 10 五月 2025 15:58:45 +0800
Subject: [PATCH] 1.修复storeJob为storedJob

---
 SourceCode/Bond/Servo/CEquipment.cpp |  221 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 218 insertions(+), 3 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index aaf7662..b14e096 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)
@@ -319,7 +328,7 @@
 
 		// 以下解释和处理数据
 		BOOL bFlag;
-		int index = 0x840;
+		int index = 0x540;
 
 
 		// alive
@@ -370,7 +379,7 @@
 			m_bAutoRecipeChange = bFlag;
 		}
 
-		// AutoRecipeChange
+		// VCR Enable
 		bFlag = isBitOn(pszData, size, ++index);
 		if (!equalBool(m_bVCREnable[0], bFlag)) {
 			m_bVCREnable[0] = bFlag;
@@ -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);
@@ -415,6 +432,40 @@
 		CHECK_READ_STEP_SIGNAL(STEP_ID_RECIVE_JOB_UPS2, pszData, size);
 		CHECK_READ_STEP_SIGNAL(STEP_ID_SENT_OUT_JOB_DOWNS1, pszData, size);
 		CHECK_READ_STEP_SIGNAL(STEP_ID_SENT_OUT_JOB_DOWNS2, pszData, size);
+
+		// Store Job Report #1~15
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT1, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT2, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT3, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT4, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT5, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT6, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT7, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT8, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT9, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT10, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT11, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT12, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT13, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT14, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_STORE_JOB_REPORT15, pszData, size);
+
+		// Fetched Out Job Report #1~15
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT1, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT2, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT3, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT4, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT5, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT6, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT7, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT8, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT9, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT10, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT11, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT12, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT13, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT14, pszData, size);
+		CHECK_READ_STEP_SIGNAL(STEP_ID_FETCHED_OUT_JOB_REPORT15, pszData, size);
 
 
 		// CEqCassetteTranserStateStep
@@ -769,6 +820,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::storedJob(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);
@@ -887,11 +1007,15 @@
 		}
 
 		LOGI("<CEquipment-%s>正在请求单元<%d>主配方列表", m_strName.c_str(), unitNo);
-		pStep->writeShort(unitNo, [&](int code) -> int {
+		if (m_recipesManager.syncing() != 0) {
+			return -2;
+		}
+		pStep->writeShort(unitNo, [&, unitNo](int code) -> int {
 			if (code == WOK) {
 				LOGI("<CEquipment-%s>请求单元<%d>主配方列表成功,正在等待数据.", m_strName.c_str(), unitNo);
 			}
 			else {
+				m_recipesManager.syncFailed();
 				LOGI("<CEquipment-%s>请求单元<%d>主配方列表失败,code:%d", m_strName.c_str(), unitNo, code);
 			}
 
@@ -899,4 +1023,95 @@
 		});
 		return 0;
 	}
+
+	int CEquipment::recipeParameterRequest(short masterRecipeId, short localRecipeId, short unitNo)
+	{
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EQ_MASTER_RECIPE_LIST_REQ);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CEquipment-%s>正在请求单元<%d>主配方列表", m_strName.c_str(), unitNo);
+		if (m_recipesManager.syncing() != 0) {
+			return -2;
+		}
+		pStep->writeShort(unitNo, [&, unitNo](int code) -> int {
+			if (code == WOK) {
+				LOGI("<CEquipment-%s>请求单元<%d>主配方列表成功,正在等待数据.", m_strName.c_str(), unitNo);
+			}
+			else {
+				m_recipesManager.syncFailed();
+				LOGI("<CEquipment-%s>请求单元<%d>主配方列表失败,code:%d", m_strName.c_str(), unitNo, code);
+			}
+
+			return 0;
+			});
+		return 0;
+	}
+
+	short CEquipment::decodeRecipeListReport(const char* pszData, size_t size)
+	{
+		return m_recipesManager.decodeRecipeListReport(pszData, size);
+	}
+
+	short CEquipment::decodeRecipeParameterReport(const char* pszData, size_t size)
+	{
+		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);
+	}
+
+	int CEquipment::decodeStoredJobReport(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);
+
+		onStore(port, jobDataB.getGlassId().c_str());
+
+		return index;
+	}
+
+	int CEquipment::onStore(int port, const char* pszGlassId)
+	{
+		return storedJob(pszGlassId);
+	}
 }
\ No newline at end of file

--
Gitblit v1.9.3