From 3896bd8be7e7db15e5e1b9f3c07469ad614c8a74 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 19 九月 2025 17:01:33 +0800
Subject: [PATCH] 1.结批处理; 2.Process Job修复未绑定context的问题;

---
 SourceCode/Bond/Servo/CMaster.cpp |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index ab5214c..ac0a419 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -2409,8 +2409,31 @@
 				temp.push_back(p);
 			}
 		}
-
 		m_processJobs = temp;
+
+
+		// 更新context
+		std::vector<uint8_t> newSlots;
+		std::vector<void*> newContexts;
+		for (auto pj : m_processJobs) {
+			for (auto& c : pj->carriers()) {
+				auto pPort = getPortWithCarrierId(c.carrierId);
+				if (pPort == nullptr) continue;
+
+				for (auto s : c.slots) {
+					auto pGlass = pPort->getGlassFromSlot(s);
+					if (pGlass == nullptr) continue;
+
+					newSlots.push_back(s);
+					newContexts.push_back(pGlass);
+				}
+
+				pj->setCarrierSlotsAndContexts(c.carrierId, newSlots, newContexts);
+			}
+		}
+
+
+
 		this->saveState();
 
 		return (int)m_processJobs.size();
@@ -2758,6 +2781,50 @@
 		return nullptr;
 	}
 
+
+	bool CMaster::completeControlJob(std::string description)
+	{
+		if (m_pControlJob == nullptr || m_state != SERVO::MASTERSTATE::READY) {
+			return false;
+		}
+		for (auto item : m_processJobs) {
+			item->abort(description);
+		}
+		m_pControlJob->abort(description);
+
+
+		// 释放Job相关
+		for (auto item : m_processJobs) {
+			delete item;
+		}
+		m_processJobs.clear();
+		if (m_pControlJob != nullptr) {
+			delete m_pControlJob;
+			m_pControlJob = nullptr;
+		}
+
+		saveState();
+
+		return true;
+	}
+
+	bool CMaster::canCreateControlJob()
+	{
+		return m_pControlJob == nullptr;
+	}
+
+	bool CMaster::canCompleteControlJob()
+	{
+		return m_pControlJob != nullptr && m_state == SERVO::MASTERSTATE::READY;
+	}
+
+	bool CMaster::canDeleteControlJob()
+	{
+		return m_pControlJob != nullptr 
+			&& m_pControlJob->state() == CJState::NoState
+			&& m_state == SERVO::MASTERSTATE::READY;
+	}
+
 	int CMaster::getWipGlasses(std::vector<CGlass*>& glasses)
 	{
 		for (auto eq : m_listEquipment) {

--
Gitblit v1.9.3