From 2ee440d9e85eccd73d2c3d4cbfe42cb8c1c25ec0 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 28 六月 2025 14:35:24 +0800
Subject: [PATCH] 1.在stroedJob和Fetchout Job中增加Port的校验; 2.在物料调度中增加检测物料是否已经处理完成的校验;

---
 SourceCode/Bond/Servo/CBakeCooling.h   |    3 +
 SourceCode/Bond/Servo/CEquipment.cpp   |   88 +++++++++++++++++++++++++-------------------
 SourceCode/Bond/Servo/CMaster.cpp      |   10 ++--
 SourceCode/Bond/Servo/LogEdit.cpp      |    2 
 SourceCode/Bond/Servo/CEquipment.h     |    9 ++--
 SourceCode/Bond/Servo/CBakeCooling.cpp |    7 +++
 6 files changed, 70 insertions(+), 49 deletions(-)

diff --git a/SourceCode/Bond/Servo/CBakeCooling.cpp b/SourceCode/Bond/Servo/CBakeCooling.cpp
index 5d69705..314d86f 100644
--- a/SourceCode/Bond/Servo/CBakeCooling.cpp
+++ b/SourceCode/Bond/Servo/CBakeCooling.cpp
@@ -414,4 +414,11 @@
 	{
 		return 25000;
 	}
+
+	bool CBakeCooling::isSlotProcessed(int slot)
+	{
+		CGlass* pGlass = getGlassFromSlot(slot);
+		if (pGlass == nullptr) return false;
+		return pGlass->isProcessed(m_nID, slot);
+	}
 }
diff --git a/SourceCode/Bond/Servo/CBakeCooling.h b/SourceCode/Bond/Servo/CBakeCooling.h
index 3b2a746..86edf49 100644
--- a/SourceCode/Bond/Servo/CBakeCooling.h
+++ b/SourceCode/Bond/Servo/CBakeCooling.h
@@ -22,7 +22,8 @@
         virtual void getAttributeVector(CAttributeVector& attrubutes);
         virtual int recvIntent(CPin* pPin, CIntent* pIntent);
         virtual int getIndexerOperationModeBaseValue();
-        virtual short getSlotUnit(short slot) { return slot <= 2 ? 0 : 1; };
+        virtual short getSlotUnit(short slot) { return slot % 2 == 1 ? 0 : 1; };
+        virtual bool isSlotProcessed(int slot);
 	};
 }
 
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index e565feb..c7d1cb7 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -836,7 +836,7 @@
 		return 0;
 	}
 
-	int CEquipment::fetchedOutJob(CJobDataB* pJobDataB)
+	int CEquipment::fetchedOutJob(int port, CJobDataB* pJobDataB)
 	{
 		if (m_pArm == nullptr) {
 			return -1;
@@ -844,24 +844,17 @@
 
 		// 找到指定的glass id, 
 		Lock();
-		CGlass* pContext = nullptr;
-		for (int i = 0; i < SLOT_MAX; i++) {
-			CGlass* pGlass = (CGlass*)m_slot[i].getContext();
-			if (pGlass != nullptr && compareJobData(pJobDataB, pGlass->getJobDataS())) {
-				pContext = pGlass;
-				if (pGlass != nullptr) pGlass->addRef();
-				m_slot[i].setContext(nullptr);
-				break;
-			}
-		}
-		if (pContext == nullptr) {
+		CGlass* pGlass = (CGlass*)m_slot[port - 1].getContext();
+		if (pGlass == nullptr && !compareJobData(pJobDataB, pGlass->getJobDataS())) {
 			Unlock();
 			return -3;
 		}
 
+		if (pGlass != nullptr) pGlass->addRef();
+		m_slot[port - 1].setContext(nullptr);
 
-		((CArm*)m_pArm)->tempStore(pContext);
-		pContext->release();
+		((CArm*)m_pArm)->tempStore(pGlass);
+		pGlass->release();
 		Unlock();
 
 
@@ -876,7 +869,7 @@
 		return 0;
 	}
 
-	int CEquipment::storedJob(CJobDataB* pJobDataB, short putSlot)
+	int CEquipment::storedJob(int port, CJobDataB* pJobDataB)
 	{
 		if (m_pArm == nullptr) {
 			return -1;
@@ -890,8 +883,8 @@
 
 		ASSERT(pGlass);
 		Lock();
-		pGlass->addPath(m_nID, getSlotUnit(putSlot));
-		m_slot[putSlot - 1].setContext(pGlass);
+		pGlass->addPath(m_nID, port);
+		m_slot[port - 1].setContext(pGlass);
 		pGlass->release();				// tempFetchOut需要调用一次release
 		Unlock();
 
@@ -1304,6 +1297,7 @@
 			if (!m_slot[i].isEnable()) continue;
 			if (m_slot[i].isLock()) continue;
 			CGlass* pGlass = (CGlass*)m_slot[i].getContext();
+			if (!isSlotProcessed(i+1)) continue;
 			if (pGlass == nullptr) continue;
 			int lsPath = m_slot[i].getLinkSignalPath();
 			if(!m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_INLINE]
@@ -1330,6 +1324,7 @@
 					if (m_slot[i].isLock()) continue;
 					CGlass* pGlass = (CGlass*)m_slot[i].getContext();
 					if (pGlass == nullptr) continue;
+					if (!isSlotProcessed(i+1)) continue;
 					int lsPath = m_slot[i].getLinkSignalPath();
 					if (!m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_INLINE]
 						|| m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
@@ -1434,6 +1429,17 @@
 	int CEquipment::onReceivedJob(int port, CJobDataS* pJobDataS)
 	{
 		LOGI("<CEquipment-%s>onReceivedJob.", m_strName.c_str());
+
+		// 可以在此更新JobDataS数据了
+		CGlass* pGlass = getGlassFromSlot(port);
+		if (pGlass == nullptr) {
+			LOGE("<CEquipment-%s>onSentOutJob,没有找到对应的Glass(CassetteSequenceNo:%d, JobSequenceNo:%d, ID=%s),请检查数据,注意风险。",
+				m_strName.c_str(), pJobDataS->getCassetteSequenceNo(), pJobDataS->getJobSequenceNo(),
+				pJobDataS->getGlass1Id().c_str());
+			return -1;
+		}
+		pGlass->updateJobDataS(pJobDataS);
+
 		return 0;
 	}
 
@@ -1455,17 +1461,6 @@
 	int CEquipment::onSentOutJob(int port, CJobDataS* pJobDataS)
 	{
 		LOGI("<CEquipment-%s>onSentOutJob.", m_strName.c_str());
-
-
-		// 可以在此更新JobDataS数据了
-		CGlass* pGlass = getGlass(pJobDataS->getGlass1Id().c_str());
-		if (pGlass == nullptr) {
-			LOGE("<CEquipment-%s>onSentOutJob,没有找到对应的Glass(CassetteSequenceNo:%d, JobSequenceNo:%d, ID=%s),请检查数据,注意风险。",
-				m_strName.c_str(), pJobDataS->getCassetteSequenceNo(), pJobDataS->getJobSequenceNo(),
-				pJobDataS->getGlass1Id().c_str());
-			return -1;
-		}
-		pGlass->updateJobDataS(pJobDataS);
 
 		return 0;
 	}
@@ -1517,7 +1512,7 @@
 		LOGI("<CEquipment-%s>onPreFetchedOutJob:port:%d|GlassId:%s",
 			m_strName.c_str(), port, pJobDataB->getGlassId().c_str());
 		if (m_listener.onPreFethedOutJob != nullptr) {
-			return m_listener.onPreFethedOutJob(this, pJobDataB);
+			return m_listener.onPreFethedOutJob(this, port, pJobDataB);
 		}
 
 		return TRUE;
@@ -1530,7 +1525,7 @@
 
 		BOOL bCheck = onPreFetchedOutJob(port, pJobDataB);
 		if (bCheck) {
-			return fetchedOutJob(pJobDataB);
+			return fetchedOutJob(port, pJobDataB);
 		}
 
 		// 数据异常,处理或显示
@@ -1678,7 +1673,9 @@
 
 	int CEquipment::decodeJobProcessStartReport(CStep* pStep, const char* pszData, size_t size)
 	{
-		LOGI("<CEquipment-%s>decodeJobProcessStartReport", getName().c_str());
+		int port = (int)(__int64)pStep->getProp("Port");
+		LOGI("<CEquipment-%s>decodeJobProcessStartReport, port:%d", getName().c_str(), port);
+
 		short cassetteNo, jobSequenceNo, unitNo, subUnitNo, slotNo;
 		int year, month, day, hour, minute, second;
 
@@ -1744,7 +1741,8 @@
 
 	int CEquipment::decodeJobProcessEndReport(CStep* pStep, const char* pszData, size_t size)
 	{
-		LOGI("<CEquipment-%s>decodeJobProcessEndReport", getName().c_str());
+		int port = (int)(__int64)pStep->getProp("Port");
+		LOGI("<CEquipment-%s>decodeJobProcessEndReport, port:%d", getName().c_str(), port);
 
 		short cassetteNo, jobSequenceNo, unitNo, subUnitNo, slotNo;
 		int year, month, day, hour, minute, second;
@@ -1789,6 +1787,19 @@
 		if (m_processState != PROCESS_STATE::Complete) {
 			setProcessState(PROCESS_STATE::Complete);
 		}
+		CGlass* pGlass = getGlassFromSlot(port);
+		if (pGlass == nullptr) {
+			LOGE("<CEquipment-%s>decodeJobProcessEndReport, 找不到对应glass", getName().c_str());
+		}
+		else {
+			pGlass->processEnd(m_nID, port);
+			if (m_processState != PROCESS_STATE::Complete) {
+				setProcessState(PROCESS_STATE::Complete);
+			}
+		}
+
+
+
 
 		// 缓存Attribute,用于调试时显示信息
 		unsigned int weight = 201;
@@ -1833,17 +1844,18 @@
 
 		// 如果没有可用位置,报错
 		Lock();
-		CSlot* pSlot = getAvailableSlotForGlassExcludeSignal((MaterialsType)pJobDataS->getMaterialsType());
-		if (pSlot == nullptr) {
+		CSlot* pSlot = getSlot(port - 1);
+		ASSERT(pSlot);
+		if (pSlot->getContext() != nullptr) {
 			Unlock();
-			LOGE("<CEquipemnt-%s>onPreFetchedOutJob,找不到匹配的Slot,不能进料,请注意风险!", m_strName.c_str());
+			LOGE("<CEquipemnt-%s>onPreStoredJob,指定slot(port:%d)有料,请注意风险!", m_strName.c_str(), port);
 			return FALSE;
 		}
 		Unlock();
 
 
 		if (m_listener.onPreStoredJob != nullptr) {
-			if (!m_listener.onPreStoredJob(this, pJobDataB, putSlot)) {
+			if (!m_listener.onPreStoredJob(this, port, pJobDataB, putSlot)) {
 				return FALSE;
 			}
 
@@ -1862,8 +1874,8 @@
 
 		short putSlot = 0;
 		BOOL bCheck = onPreStoredJob(port, pJobDataB, putSlot);
-		if (bCheck) {
-			return storedJob(pJobDataB, putSlot);
+		if (bCheck && port == putSlot) {
+			return storedJob(port, pJobDataB);
 		}
 
 		// 数据异常,处理或显示
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index c2e880b..e1a6901 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -51,8 +51,8 @@
 	typedef std::function<void(void* pEiuipment, int code)> ONDATACHANGED;
 	typedef std::function<void(void* pEiuipment, int state, int alarmId, int unitId, int level)> ONALARM;
 	typedef std::function<void(void* pEiuipment, void* pReport)> ONVCREVENTREPORT;
-	typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
-	typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
+	typedef std::function<BOOL(void* pEiuipment, int port, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
+	typedef std::function<BOOL(void* pEiuipment, int port, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
 	typedef std::function<void(void* pEiuipment, PROCESS_STATE state)> ONPROCESSSTATE;
 	typedef struct _EquipmentListener
 	{
@@ -116,8 +116,8 @@
 		std::vector<CPin*>& CEquipment::getOutputPins();
 		CRecipeList* getRecipeList(int unitNo);
 		virtual int recvIntent(CPin* pPin, CIntent* pIntent);
-		virtual int fetchedOutJob(CJobDataB* pJobDataB);
-		virtual int storedJob(CJobDataB* pJobDataB, short putSlot);
+		virtual int fetchedOutJob(int port, CJobDataB* pJobDataB);
+		virtual int storedJob(int port, CJobDataB* pJobDataB);
 		virtual int onReceivedJob(int port, CJobDataS* pJobDataS);
 		virtual int onSentOutJob(int port, CJobDataS* pJobDataS);
 		virtual BOOL onPreFetchedOutJob(int port, CJobDataB* pJobDataB);
@@ -129,6 +129,7 @@
 		virtual int onReceiveAble();
 		virtual int onProcessStateChanged(PROCESS_STATE state);
 		virtual int getIndexerOperationModeBaseValue();
+		virtual bool isSlotProcessed(int slot) { return true; };
 		bool isAlarmStep(SERVO::CStep* pStep);
 		bool isVcrEventStep(SERVO::CStep* pStep);
 		bool isCassetteTransferStateStep(SERVO::CStep* pStep);
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 4eac116..602cdf2 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -825,7 +825,7 @@
 				m_listener.onEqVcrEventReport(this, p, p2);
 			}
 		};
-		listener.onPreFethedOutJob = [&](void* pEquipment, CJobDataB* pJobDataB) -> BOOL {
+		listener.onPreFethedOutJob = [&](void* pEquipment, int port, CJobDataB* pJobDataB) -> BOOL {
 			CEquipment* p = (CEquipment*)pEquipment;
 
 
@@ -835,7 +835,7 @@
 			if (m_pActiveRobotTask != nullptr) {
 				if (m_pActiveRobotTask->getSrcPosition() == p->getID()) {
 					CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getSrcSlot());
-					if (pGlass != nullptr) {
+					if (pGlass != nullptr && port == m_pActiveRobotTask->getSrcSlot()) {
 						CJobDataS* pJobDataS = pGlass->getJobDataS();
 						if (pJobDataS != nullptr
 							&& pJobDataS->getCassetteSequenceNo() == pJobDataB->getCassetteSequenceNo()
@@ -858,7 +858,7 @@
 			return bOk;
 
 		};
-		listener.onPreStoredJob = [&](void* pEquipment, CJobDataB* pJobDataB, short& slot) -> BOOL {
+		listener.onPreStoredJob = [&](void* pEquipment, int port, CJobDataB* pJobDataB, short& slot) -> BOOL {
 			CEquipment* p = (CEquipment*)pEquipment;
 
 
@@ -879,7 +879,7 @@
 				else if (m_pActiveRobotTask->isPlacing() &&
 					m_pActiveRobotTask->getTarPosition() == p->getID()) {
 					CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getTarSlot());
-					if (pGlass == nullptr) {
+					if (pGlass == nullptr && m_pActiveRobotTask->getTarSlot() == port) {
 						bOk = TRUE;
 						slot = m_pActiveRobotTask->getTarSlot();
 						LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
@@ -890,7 +890,7 @@
 				else if (m_pActiveRobotTask->isRestoring() &&
 					m_pActiveRobotTask->getSrcPosition() == p->getID()) {
 					CGlass* pGlass = p->getGlassFromSlot(m_pActiveRobotTask->getSrcSlot());
-					if (pGlass == nullptr) {
+					if (pGlass == nullptr && m_pActiveRobotTask->getSrcSlot() == port) {
 						bOk = TRUE;
 						slot = m_pActiveRobotTask->getSrcSlot();
 						LOGI("<CMaster>onPreFethedOutJob, 已校验数据一致性.");
diff --git a/SourceCode/Bond/Servo/LogEdit.cpp b/SourceCode/Bond/Servo/LogEdit.cpp
index 1b08345..6330dc4 100644
--- a/SourceCode/Bond/Servo/LogEdit.cpp
+++ b/SourceCode/Bond/Servo/LogEdit.cpp
@@ -97,7 +97,7 @@
 
     int endPos = GetWindowTextLength();
     SetSel(endPos, endPos);
-    ReplaceSel(lpszText);
+    ReplaceSel(pszText);
 
     if (m_bAutoScroll && !hasSelection) {
         LineScroll(GetLineCount());

--
Gitblit v1.9.3