From 02d1df7b4fa1a0e686c112e7bf3c8e794ba42b82 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期四, 19 六月 2025 10:04:26 +0800
Subject: [PATCH] 1. 添加设备配方绑定

---
 SourceCode/Bond/Servo/CGlass.cpp |   69 ++++++++++++++++++++++++----------
 1 files changed, 49 insertions(+), 20 deletions(-)

diff --git a/SourceCode/Bond/Servo/CGlass.cpp b/SourceCode/Bond/Servo/CGlass.cpp
index e2b6259..dc47c5e 100644
--- a/SourceCode/Bond/Servo/CGlass.cpp
+++ b/SourceCode/Bond/Servo/CGlass.cpp
@@ -12,6 +12,11 @@
 
 	CGlass::~CGlass()
 	{
+
+	}
+
+	void CGlass::reset()
+	{
 		CPath* pPath = m_pPath;
 		while (pPath != nullptr) {
 			CPath* pTemp = pPath->getNext();
@@ -20,7 +25,7 @@
 		}
 		m_pPath = nullptr;
 
-		if (m_pBuddy != nullptr	&& m_type == MaterialsType::G1) {
+		if (m_pBuddy != nullptr) {
 			m_pBuddy->release();
 		}
 	}
@@ -61,27 +66,28 @@
 		return m_strID;
 	}
 
-	CPath* CGlass::getPathWithSiteID(unsigned int nSiteId)
-	{
-		CPath* pPath = m_pPath;
-		while (pPath != nullptr) {
-			if (nSiteId == pPath->getSiteID()) {
-				return pPath;
-			}
-			pPath = pPath->getNext();
-		}
-
-		return nullptr;
-	}
-
 	CPath* CGlass::getPath()
 	{
 		return m_pPath;
 	}
 
-	void CGlass::addPath(unsigned int nSiteId)
+	CPath* CGlass::getPathWithEq(unsigned int nEqId, unsigned int nUnit)
 	{
-		CPath* pPath = new CPath(nSiteId);
+		CPath* pTemp = m_pPath;
+		while (pTemp != nullptr) {
+			if (pTemp->getEqID() == nEqId && pTemp->getUnit() == nUnit) {
+				return pTemp;
+			}
+
+			pTemp = pTemp->getNext();
+		}
+
+		return nullptr;
+	}
+
+	void CGlass::addPath(unsigned int nEqId, unsigned int nUnit)
+	{
+		CPath* pPath = new CPath(nEqId, nUnit);
 		if (m_pPath == nullptr) {
 			m_pPath = pPath;
 		}
@@ -129,7 +135,7 @@
 			m_jobDataB.unserialize(temp, JOBDATAB_SIZE);
 			ar.Read(temp, JOBDATAS_SIZE);
 			m_jobDataS.unserialize(temp, JOBDATAS_SIZE);
-			ar >> ullPath;					// 这是m_pBuddy, 用不上
+			ar >> ullPath;	m_pBuddy = (CGlass*)ullPath;
 			ReadString(ar, m_strBuddyId);
 			Unlock();
 		}
@@ -160,9 +166,16 @@
 		if (m_pBuddy != nullptr) return FALSE;
 		if (pGlass->getType() == this->getType()) return FALSE;
 		m_pBuddy = pGlass;
-		if (m_type == MaterialsType::G1) {
-			m_pBuddy->addRef();
-		}
+		m_pBuddy->addRef();
+		m_strBuddyId = m_pBuddy->getID();
+
+		return TRUE;
+	}
+
+	BOOL CGlass::forceSetBuddy(CGlass* pGlass)
+	{
+		m_pBuddy = pGlass;
+		m_pBuddy->addRef();
 		m_strBuddyId = m_pBuddy->getID();
 
 		return TRUE;
@@ -177,4 +190,20 @@
 	{
 		return m_strBuddyId;
 	}
+
+	void CGlass::processEnd(unsigned int nEqId, unsigned int nUnit)
+	{
+		CPath* pPath = getPathWithEq(nEqId, nUnit);
+		if (pPath != nullptr) {
+			pPath->processEnd();
+		}
+	}
+
+	BOOL CGlass::isProcessed(unsigned int nEqId, unsigned int nUnit)
+	{
+		CPath* pPath = getPathWithEq(nEqId, nUnit);
+		if (pPath == nullptr) return FALSE;
+
+		return pPath->isProcessEnd();
+	}
 }

--
Gitblit v1.9.3