From 38f2ff1e5bc6c4434875e03b8cadc8f3f4e39bf6 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 27 八月 2025 18:18:02 +0800
Subject: [PATCH] 1.修改调度逻辑,增加G0,第二类型,增加TestFlag, 用于必要时输出指定日志;

---
 SourceCode/Bond/Servo/CEquipment.cpp |   13 +++++-
 SourceCode/Bond/Servo/CMaster.cpp    |   75 +++++++++++++++++++++++++------------
 SourceCode/Bond/Servo/CMaster.h      |    2 +
 SourceCode/Bond/Servo/CEquipment.h   |    3 +
 SourceCode/Bond/Servo/ServoCommo.h   |    1 
 5 files changed, 67 insertions(+), 27 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index bfdec30..8d8582d 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -27,6 +27,7 @@
 		m_pArm = nullptr;
 		m_processState = PROCESS_STATE::Ready;
 		m_blockReadBit = { 0 };
+		m_nTestFlag = 0;
 		InitializeCriticalSection(&m_criticalSection);
 	}
 
@@ -1328,24 +1329,32 @@
 	CSlot* CEquipment::getProcessedSlot(MaterialsType putSlotType, BOOL bJobMode/* = FALSE*/)
 	{
 		for (int i = 0; i < SLOT_MAX; i++) {
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 001");
 			if (!m_slot[i].isEnable()) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 002");
 			if (m_slot[i].isLock()) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 003");
 			CGlass* pGlass = (CGlass*)m_slot[i].getContext();
 			if (!isSlotProcessed(i)) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 004");
 			if (pGlass == nullptr) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 005");
 			if (!pGlass->isScheduledForProcessing()) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 006");
 			if (bJobMode && pGlass->getProcessJob() == nullptr) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 007");
 			if(pGlass->getInspResult(m_nID, 0) == InspResult::Fail) continue;
 			int lsPath = m_slot[i].getLinkSignalPath();
 			if(!m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_INLINE]
 				|| m_bLinkSignalToUpstream[lsPath][SIGNAL_UPSTREAM_TROUBLE]
 				|| !m_bLinkSignalToUpstream[lsPath][SIGNAL_INTERLOCK]
 				|| !m_bLinkSignalToUpstream[lsPath][SIGNAL_SEND_ABLE] ) continue;
-
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 008");
 			MaterialsType glassType = pGlass->getType();
 			if (glassType == MaterialsType::G1 && putSlotType == MaterialsType::G2) continue;
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 009");
 			if (glassType == MaterialsType::G2 && putSlotType == MaterialsType::G1) continue;
-
+			if (m_nTestFlag == 1) LOGI("getProcessedSlot 00a");
 			return &m_slot[i];
 		}
 
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 27a448e..c2e93cd 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -290,6 +290,9 @@
 
 	private:
 		CEquipment* m_pArm;
+
+	public:
+		int m_nTestFlag;
 	};
 }
 
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index e574cd6..a4878d6 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -63,6 +63,7 @@
 		m_nContinuousTransferCount = 0;
 		m_nContinuousTransferStep = CTStep_Unknow;
 		m_pControlJob = nullptr;
+		m_nTestFlag = 0;
 		InitializeCriticalSection(&m_criticalSection);
 	}
 
@@ -598,23 +599,38 @@
 
 				// 此处检测优先类型和次要类型(G1或G2)
 				// 如果其中一Bonder有单个玻璃,优先取它的配对类型,否则无所谓了
-				primaryType = MaterialsType::G1;
-				secondaryType = MaterialsType::G2;
-				if ((!pBonder1->canPlaceGlassInSlot(0) && !pBonder1->canPlaceGlassInSlot(1))
-					&& (!pBonder2->canPlaceGlassInSlot(0) && !pBonder2->canPlaceGlassInSlot(1))) {
-					// 如果G1和G2都满了,那就看Aligner, 如果Aligner有玻璃为G1, 则取G2
-					CGlass* pGlass = pAligner->getGlassFromSlot(1);
-					if (pGlass != nullptr && pGlass->getType() == MaterialsType::G1) {
-						primaryType = MaterialsType::G2;
-						secondaryType = MaterialsType::G1;
-					}
-				}
-				else if ((pBonder1->canPlaceGlassInSlot(0) && !pBonder1->canPlaceGlassInSlot(1))
-					|| (pBonder2->canPlaceGlassInSlot(0) && !pBonder2->canPlaceGlassInSlot(1))) {
-					primaryType = MaterialsType::G2;
-					secondaryType = MaterialsType::G1;
-				}
+				primaryType = MaterialsType::G2;
+				secondaryType = MaterialsType::G1;
 
+
+				if (!pBonder1->canPlaceGlassInSlot(0) && pBonder1->canPlaceGlassInSlot(1)) {
+					// 如果Bonder1有G2了,则取G1
+					primaryType = MaterialsType::G1;
+					secondaryType = MaterialsType::G0;
+				}
+				else if (!pBonder2->canPlaceGlassInSlot(0) && pBonder2->canPlaceGlassInSlot(1)) {
+					// 如果Bonder2有G2了,则取G1
+					primaryType = MaterialsType::G1;
+					secondaryType = MaterialsType::G0;
+				}
+				else if (!pFliper->canPlaceGlassInSlot(0)) {
+					primaryType = MaterialsType::G1;
+					secondaryType = MaterialsType::G0;
+				}
+				else if (pBonder1->canPlaceGlassInSlot(0)) {
+					// 如果Bonder1没有G2, 则先G2
+					primaryType = MaterialsType::G2;
+					secondaryType = MaterialsType::G0;
+				}
+				else if (pBonder2->canPlaceGlassInSlot(0)) {
+					// 如果Bonder2没有G2, 则先G2
+					primaryType = MaterialsType::G2;
+					secondaryType = MaterialsType::G0;
+				}
+				else {
+					primaryType = MaterialsType::G2;
+					secondaryType = MaterialsType::G0;
+				}
 
 				// Measurement -> LoadPort
 				if (rmd.armState[0] || rmd.armState[1]) {
@@ -674,24 +690,29 @@
 
 				// Fliper(G2) -> Bonder
 				auto pSrcSlot = pVacuumBake->getProcessedSlot(primaryType);
-				if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder1->hasBondClass()) {
-					m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, primaryType, secondaryType, 2);
+				//LOGI("<Master>pSrcSlot = %x, primaryType:%d", pSrcSlot, primaryType);
+				if (pSrcSlot != nullptr && !rmd.armState[1]
+					&& pBonder1->canPlaceGlassInSlot(0)
+					&& !pBonder1->hasBondClass()) {
+					m_pActiveRobotTask = createTransferTask(pFliper, pBonder1, MaterialsType::G2, MaterialsType::G0, 2);
 					CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
 				}
-				if (pSrcSlot != nullptr && !rmd.armState[1] && !pBonder2->hasBondClass()) {
-					m_pActiveRobotTask = createTransferTask(pFliper, pBonder2, primaryType, secondaryType, 2);
+				if (pSrcSlot != nullptr && !rmd.armState[1] 
+					&& pBonder2->canPlaceGlassInSlot(0)
+					&& !pBonder2->hasBondClass()) {
+					m_pActiveRobotTask = createTransferTask(pFliper, pBonder2, MaterialsType::G2, MaterialsType::G0, 2);
 					CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
 				}
 
 
 				// VacuumBake(G1) -> Bonder
 				if (!rmd.armState[0] && !pBonder1->hasBondClass()) {
-					m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, primaryType, secondaryType);
+					m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder1, MaterialsType::G1, MaterialsType::G0);
 					CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
 				}
 
 				if (!rmd.armState[0] && !pBonder2->hasBondClass()) {
-					m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, primaryType, secondaryType);
+					m_pActiveRobotTask = createTransferTask(pVacuumBake, pBonder2, MaterialsType::G1, MaterialsType::G0);
 					CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
 				}
 
@@ -704,8 +725,11 @@
 				}
 
 				if (!rmd.armState[0]) {
+					// m_nTestFlag = 1;
+					if (m_nTestFlag == 1) LOGI("createTransferTask 004df %d, %d", primaryType, secondaryType);
 					m_pActiveRobotTask = createTransferTask(pAligner, pVacuumBake, primaryType, secondaryType);
 					CHECK_RUN_ACTIVE_ROBOT_TASK(m_pActiveRobotTask);
+					m_nTestFlag = 0;
 				}
 
 
@@ -1929,16 +1953,17 @@
 		if (!pSrcEq->IsEnabled()) { 
 			return nullptr;
 		}
-
 		CRobotTask* pTask = nullptr;
 		CSlot* pSrcSlot, * pTarSlot;
+		pSrcEq->m_nTestFlag = m_nTestFlag;
 		pTarSlot = pTarEq->getAvailableSlotForGlass(primaryType);
 		pSrcSlot = pSrcEq->getProcessedSlot(primaryType, bJobMode);
-		if (pSrcSlot == nullptr || nullptr == pTarSlot) {
+		if (m_nTestFlag == 1) LOGI("createTransferTask 003 %x, %x", pTarSlot, pSrcSlot);
+		if (pSrcSlot == nullptr || nullptr == pTarSlot && secondaryType != SERVO::MaterialsType::G0) {
 			pTarSlot = pTarEq->getAvailableSlotForGlass(secondaryType);
 			pSrcSlot = pSrcEq->getProcessedSlot(secondaryType, bJobMode);
 		}
-
+		if (m_nTestFlag == 1) LOGI("createTransferTask 004 %x, %x", pTarSlot, pSrcSlot);
 
 		if (pSrcSlot != nullptr && nullptr != pTarSlot) {
 			pTask = new CRobotTask();
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 1e52477..cae98db 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -231,6 +231,8 @@
         SERVO::CControlJob* m_pControlJob;
         std::vector<SERVO::CProcessJob*> m_processJobs;
         std::string m_strStatePath;
+
+        int m_nTestFlag;
     };
 }
 
diff --git a/SourceCode/Bond/Servo/ServoCommo.h b/SourceCode/Bond/Servo/ServoCommo.h
index dea7370..8c4c7ea 100644
--- a/SourceCode/Bond/Servo/ServoCommo.h
+++ b/SourceCode/Bond/Servo/ServoCommo.h
@@ -73,6 +73,7 @@
 	};
 
 	enum class MaterialsType {
+		G0 = 0,
 		G1 = 1,
 		G2 = 2,
 		G1G2 = 3

--
Gitblit v1.9.3