From d400f022161ff47f02cd0ea95a5076d0187ecd4d Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期五, 30 一月 2026 15:11:06 +0800
Subject: [PATCH] 1.接上,日志完善;

---
 SourceCode/Bond/Servo/CMaster.cpp |   64 ++++++++++++++++++++++++++++----
 1 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index f51c969..d9fb326 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -119,13 +119,6 @@
 			m_hEventDispatchThreadExit[1] = nullptr;
 		}
 
-		// 閲婃斁浜哄伐鎼嚭缂撳啿鍖洪噷鐨勭幓鐠�
-		for (auto* pGlass : m_bufGlass) {
-			if (pGlass != nullptr) {
-				pGlass->release();
-			}
-		}
-		m_bufGlass.clear();
 
 		DeleteCriticalSection(&m_criticalSection);
 	}
@@ -344,6 +337,13 @@
 		}
 		m_listEquipment.clear();
 
+		// release manual-remove buffer before glass pool is torn down
+		for (auto* pGlass : m_bufGlass) {
+			if (pGlass != nullptr) {
+				pGlass->release();
+			}
+		}
+		m_bufGlass.clear();
 
 		if (m_pCollector != nullptr) {
 			m_pCollector->stopLoop();
@@ -1930,6 +1930,16 @@
 				m_listener.onJobReceived(this, (CEquipment*)pEquipment, port, pJobDataS);
 			}
 		};
+		listener.onSentOutJob = [&](void* pEquipment, int port, CJobDataS* pJobDataS) {
+			if (m_listener.onJobSentOut != nullptr) {
+				m_listener.onJobSentOut(this, (CEquipment*)pEquipment, port, pJobDataS);
+			}
+		};
+		listener.onEqStatusChanged = [&](void* pEquipment, int unitId, int status, int reason) {
+			if (m_listener.onEqStatusChanged != nullptr) {
+				m_listener.onEqStatusChanged(this, (CEquipment*)pEquipment, unitId, status, reason);
+			}
+		};
 		pEquipment->setListener(listener);
 		pEquipment->setCcLink(&m_cclink);
 		m_listEquipment.push_back(pEquipment);
@@ -2897,7 +2907,40 @@
 
 		static int pid[] = { EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4};
 		CLoadPort* pPort = (CLoadPort*)getEquipment(pid[port]);
-		pPort->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+		if (pPort == nullptr) return -1;
+
+		short jobExistence[12] = { 0 };
+		short slotProcess = 0;
+		short jobCount = 0; // 0 = Process All Glass
+		bool anyScheduled = false;
+
+		// Prefer hardware scan map for job existence (first 16 slots).
+		const short scanMap = pPort->getScanCassetteMap();
+		if (scanMap != 0) {
+			jobExistence[0] = scanMap;
+		}
+
+		const int maxSlots = 12 * 16;
+		const int totalSlots = (SLOT_MAX < maxSlots) ? SLOT_MAX : maxSlots;
+		for (int slot = 1; slot <= totalSlots; ++slot) {
+			CGlass* pGlass = pPort->getGlassFromSlot(slot);
+			if (pGlass == nullptr) continue;
+
+			const int wordIndex = (slot - 1) / 16;
+			const int bitIndex = (slot - 1) % 16;
+			jobExistence[wordIndex] = (short)(jobExistence[wordIndex] | (1 << bitIndex));
+
+			if (slot <= 16 && pGlass->isScheduledForProcessing()) {
+				slotProcess = (short)(slotProcess | (1 << bitIndex));
+				anyScheduled = true;
+			}
+		}
+
+		if (!anyScheduled) {
+			slotProcess = jobExistence[0];
+		}
+
+		pPort->sendCassetteCtrlCmd(CCC_PROCESS_START, jobExistence, 12, slotProcess, jobCount, nullptr, nullptr);
 		return 0;
 	}
 
@@ -3485,6 +3528,11 @@
 		}
 		m_pControlJob->abort(description);
 
+		// 鍏堜笂鎶ヤ竴娆$姸鎬佸彉鍖栵紙渚夸簬 PrJobAbort 瑙﹀彂锛�
+		if (m_listener.onControlJobChanged) {
+			notifyControlJobChanged();
+		}
+
 
 		// 閲婃斁Job鐩稿叧
 		for (auto item : m_processJobs) {

--
Gitblit v1.9.3