From 922a39a04e535e745c1ef736a0ba427ae1696ef5 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 20 九月 2025 11:43:53 +0800
Subject: [PATCH] 1.修复批高度逻辑与之前的单片调度同步;

---
 SourceCode/Bond/Servo/CControlJobManagerDlg.cpp |  126 +++++++++++++++++++++++------------------
 1 files changed, 70 insertions(+), 56 deletions(-)

diff --git a/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp b/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
index 4a645ac..a791c3c 100644
--- a/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
+++ b/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
@@ -454,9 +454,13 @@
 	}
 
 
+	SERVO::CLoadPort* pPort[4];
+	pPort[0] = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT1);
+	pPort[1] = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT2);
+	pPort[2] = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT3);
+	pPort[3] = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT4);
 
-
-	int EQID[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4 };
+	bool bProcessStart[] = {false, false, false, false};
 	std::vector<SERVO::CProcessJob*> pjs;
 	for (auto item : m_pjWarps) {
 		if (!item.addToCj) continue;
@@ -470,17 +474,16 @@
 		}
 		if (!bCheck) continue;
 
-		SERVO::CLoadPort* pPort = (SERVO::CLoadPort*)master.getEquipment(EQID[item.port]);
 		SERVO::CProcessJob* pScr = (SERVO::CProcessJob*)item.pj;
 		SERVO::CProcessJob * pj = new SERVO::CProcessJob(pScr->id());
 		pj->setRecipe(SERVO::RecipeMethod::NoTuning, pScr->recipeSpec());
 
 		std::vector<SERVO::CarrierSlotInfo> carriers;
 		SERVO::CarrierSlotInfo csi;
-		csi.carrierId = pPort->getCassetteId();
+		csi.carrierId = pPort[item.port]->getCassetteId();
 		for (int i = 0; i < 8; i++) {
 			if (item.checkSlot[i]) {
-				SERVO::CGlass* pGlass = pPort->getGlassFromSlot(i+1);
+				SERVO::CGlass* pGlass = pPort[item.port]->getGlassFromSlot(i+1);
 				if (pGlass != nullptr) {
 					csi.slots.push_back(i + 1);
 				}
@@ -489,6 +492,7 @@
 		carriers.push_back(csi);
 		pj->setCarriers(carriers);
 		pjs.push_back(pj);
+		bProcessStart[item.port] = true;
 
 		m_pControlJob->addPJ(pScr->id());
 	}
@@ -502,6 +506,15 @@
 	m_pControlJob->setPJs(pjs);
 	m_pControlJob->clearIssues();
 	int nRet = master.setProcessJobs(pjs);
+
+	// 娌℃湁闂鐨刾j瑕侀噴鏀�
+	for (auto pj : pjs) {
+		if (!pj->issues().empty()) {
+			delete pj;
+		}
+	}
+	pjs.clear();
+
 	if (nRet <= 0) {
 		std::string msg("鍚屾Process Job澶辫触!");
 		for (auto pj : pjs) {
@@ -524,7 +537,6 @@
 		return;
 	}
 
-
 	nRet = master.setControlJob(*m_pControlJob);
 	if (nRet != 0) {
 		std::string msg("鍚屾ControlJob澶辫触!");
@@ -544,63 +556,65 @@
 	}
 
 
-	// 鍋囪鎴愬姛锛岃鍒ゆ柇锛屽悓姝ュ埌slot鐨刧lass涓紝绫诲瀷绛�
-	if (true) {
-		auto& master = theApp.m_model.getMaster();
-		int EQID[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4 };
-		for (int p = 0; p < 4; p++) {
-			SERVO::CLoadPort* pPort = (SERVO::CLoadPort*)master.getEquipment(EQID[p]);
-			for (int i = 0; i < SLOT_MAX; ++i) {
-				SERVO::CSlot* pSlot = pPort->getSlot(i);
-				if (!pSlot) {
-					continue;
-				}
+	// 鎴愬姛锛岃鍒ゆ柇锛屽悓姝ュ埌slot鐨刧lass涓紝绫诲瀷绛�
+	for (int p = 0; p < 4; p++) {
+		for (int i = 0; i < SLOT_MAX; ++i) {
+			SERVO::CSlot* pSlot = pPort[p]->getSlot(i);
+			if (!pSlot) {
+				continue;
+			}
 
-				// 璁剧疆 Panel ID 鍜屽嬀閫夋
-				SERVO::CProcessJob* pj = (SERVO::CProcessJob*)m_pjWarps[p].pj;
-				int nRecipeID = RecipeManager::getInstance().getIdByPPID(pj->recipeSpec());
-				RecipeInfo stRecipeInfo = RecipeManager::getInstance().getRecipeByPPID(pj->recipeSpec());
-				std::vector<DeviceRecipe> vecRecipeInfo = stRecipeInfo.vecDeviceList;
-				SERVO::CGlass* pGlass = dynamic_cast<SERVO::CGlass*>(pSlot->getContext());
+			// 璁剧疆 Panel ID 鍜屽嬀閫夋
+			SERVO::CProcessJob* pj = (SERVO::CProcessJob*)m_pjWarps[p].pj;
+			int nRecipeID = RecipeManager::getInstance().getIdByPPID(pj->recipeSpec());
+			RecipeInfo stRecipeInfo = RecipeManager::getInstance().getRecipeByPPID(pj->recipeSpec());
+			std::vector<DeviceRecipe> vecRecipeInfo = stRecipeInfo.vecDeviceList;
+			SERVO::CGlass* pGlass = dynamic_cast<SERVO::CGlass*>(pSlot->getContext());
+			SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
+			if (pGlass != nullptr && pJobDataS != nullptr) {
+				pGlass->setScheduledForProcessing(m_pjWarps[p].checkSlot[i]);
+				pGlass->setType(static_cast<SERVO::MaterialsType>(m_pjWarps[p].material[i]));
+
 				SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
-				if (pGlass != nullptr && pJobDataS != nullptr) {
-					pGlass->setScheduledForProcessing(m_pjWarps[p].checkSlot[i]);
-					pGlass->setType(static_cast<SERVO::MaterialsType>(m_pjWarps[p].material[i]));
+				pJobDataS->setLotId("LotID1");
+				pJobDataS->setProductId("ProductId1");
+				pJobDataS->setOperationId("OPerationId");
+				pJobDataS->setMaterialsType(m_pjWarps[p].material[i]);
+				pJobDataS->setMasterRecipe(nRecipeID);
 
-					SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
-					pJobDataS->setLotId("LotID1");
-					pJobDataS->setProductId("ProductId1");
-					pJobDataS->setOperationId("OPerationId");
-					pJobDataS->setMaterialsType(m_pjWarps[p].material[i]);
-					pJobDataS->setMasterRecipe(nRecipeID);
-
-					for (const auto& info : vecRecipeInfo) {
-						const std::string& name = info.strDeviceName;
-						short nRecipeID = (short)info.nRecipeID;
-
-						if (name == EQ_NAME_EFEM) {
-							pJobDataS->setDeviceRecipeId(0, nRecipeID);
-						}
-						else if (name == EQ_NAME_BONDER1) {
-							pJobDataS->setDeviceRecipeId(1, nRecipeID);
-						}
-						else if (name == EQ_NAME_BONDER2) {
-							pJobDataS->setDeviceRecipeId(2, nRecipeID);
-						}
-						else if (name == EQ_NAME_BAKE_COOLING) {
-							pJobDataS->setDeviceRecipeId(3, nRecipeID);
-						}
-						else if (name == EQ_NAME_VACUUMBAKE) {
-							pJobDataS->setDeviceRecipeId(4, nRecipeID);
-						}
-						else if (name == EQ_NAME_MEASUREMENT) {
-							pJobDataS->setDeviceRecipeId(5, nRecipeID);
-						}
+				for (const auto& info : vecRecipeInfo) {
+					const std::string& name = info.strDeviceName;
+					short nRecipeID = (short)info.nRecipeID;
+				
+					if (name == EQ_NAME_EFEM) {
+						pJobDataS->setDeviceRecipeId(0, nRecipeID);
+					}
+					else if (name == EQ_NAME_BONDER1) {
+						pJobDataS->setDeviceRecipeId(1, nRecipeID);
+					}
+					else if (name == EQ_NAME_BONDER2) {
+						pJobDataS->setDeviceRecipeId(2, nRecipeID);
+					}
+					else if (name == EQ_NAME_BAKE_COOLING) {
+						pJobDataS->setDeviceRecipeId(3, nRecipeID);
+					}
+					else if (name == EQ_NAME_VACUUMBAKE) {
+						pJobDataS->setDeviceRecipeId(4, nRecipeID);
+					}
+					else if (name == EQ_NAME_MEASUREMENT) {
+						pJobDataS->setDeviceRecipeId(5, nRecipeID);
 					}
 				}
 			}
 		}
 	}
 
-	AfxMessageBox("鏂偣妫�鏌ヤ竴涓嬫暟鎹�");
+
+	// process start
+	for (int p = 0; p < 4; p++) {
+		if (bProcessStart[p]) {
+			pPort[p]->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+			Sleep(100);
+		}
+	}
 }

--
Gitblit v1.9.3