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/CControlJobDlg.cpp        |   10 ++++++++--
 SourceCode/Bond/Servo/ProcessJob.h              |    3 +++
 SourceCode/Bond/Servo/ProcessJob.cpp            |   13 +++++++++++++
 SourceCode/Bond/Servo/CMaster.cpp               |   25 ++++++++++++++++++++++++-
 SourceCode/Bond/Servo/CControlJobManagerDlg.cpp |    5 ++++-
 5 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/SourceCode/Bond/Servo/CControlJobDlg.cpp b/SourceCode/Bond/Servo/CControlJobDlg.cpp
index d388c2c..bfd69bb 100644
--- a/SourceCode/Bond/Servo/CControlJobDlg.cpp
+++ b/SourceCode/Bond/Servo/CControlJobDlg.cpp
@@ -107,10 +107,16 @@
     pItem->MoveWindow(rcClient.right - 12 - rcItem.Width(),
         y - rcItem.Height(),
         rcItem.Width(), rcItem.Height());
+
+
+    // 缁撴壒鎸夐挳
+    pItem = GetDlgItem(IDC_BUTTON_COMPLETION_BATH);
+    pItem->GetClientRect(&rcItem);
+    pItem->MoveWindow(12, y - rcItem.Height(),
+        rcItem.Width(), rcItem.Height());
     y -= rcItem.Height();
     y -= 12;
-
-
+   
     // 绾�
     pItem = GetDlgItem(IDC_LINE1);
     pItem->MoveWindow(12, y, rcClient.Width() - 24, 2);
diff --git a/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp b/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
index 5b19f07..4a645ac 100644
--- a/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
+++ b/SourceCode/Bond/Servo/CControlJobManagerDlg.cpp
@@ -480,7 +480,10 @@
 		csi.carrierId = pPort->getCassetteId();
 		for (int i = 0; i < 8; i++) {
 			if (item.checkSlot[i]) {
-				csi.slots.push_back(i);
+				SERVO::CGlass* pGlass = pPort->getGlassFromSlot(i+1);
+				if (pGlass != nullptr) {
+					csi.slots.push_back(i + 1);
+				}
 			}
 		}
 		carriers.push_back(csi);
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index 5572e53..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();
diff --git a/SourceCode/Bond/Servo/ProcessJob.cpp b/SourceCode/Bond/Servo/ProcessJob.cpp
index a95d78e..62872f1 100644
--- a/SourceCode/Bond/Servo/ProcessJob.cpp
+++ b/SourceCode/Bond/Servo/ProcessJob.cpp
@@ -277,6 +277,19 @@
         }
     }
 
+    bool CProcessJob::setCarrierSlotsAndContexts(std::string carrierId, std::vector<uint8_t> slots, std::vector<void*> contexts)
+    {
+        for (auto& c : m_carriers) {
+            if (c.carrierId.compare(carrierId) == 0) {
+                c.slots = std::move(slots);
+                c.contexts = std::move(contexts);
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     // --------- 核心:serialize/deserialize ---------
     void CProcessJob::serialize(std::ostream& os) const {
         // 头
diff --git a/SourceCode/Bond/Servo/ProcessJob.h b/SourceCode/Bond/Servo/ProcessJob.h
index eb20b84..6fdba9f 100644
--- a/SourceCode/Bond/Servo/ProcessJob.h
+++ b/SourceCode/Bond/Servo/ProcessJob.h
@@ -154,6 +154,9 @@
         // 追加一个载具
         void addCarrier(std::string carrierId, std::vector<uint8_t> slots);
 
+        // 设置载具slots和contexts
+        bool setCarrierSlotsAndContexts(std::string carrierId, std::vector<uint8_t> slots, std::vector<void*> contexts);
+
         // 访问器
         const std::vector<CarrierSlotInfo>& carriers() const noexcept { return m_carriers; }
         CarrierSlotInfo* getCarrier(const std::string& strId);

--
Gitblit v1.9.3