From 4897210a25e7c98ddacb1fa4ecee3e8bdd1ae98e Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 12 六月 2025 14:18:16 +0800
Subject: [PATCH] 1.手臂选择匹配问题,

---
 SourceCode/Bond/Servo/CGlass.cpp |   93 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 76 insertions(+), 17 deletions(-)

diff --git a/SourceCode/Bond/Servo/CGlass.cpp b/SourceCode/Bond/Servo/CGlass.cpp
index 410868a..e975351 100644
--- a/SourceCode/Bond/Servo/CGlass.cpp
+++ b/SourceCode/Bond/Servo/CGlass.cpp
@@ -7,9 +7,15 @@
 	{
 		m_pPath = nullptr;
 		m_type = MaterialsType::G1;
+		m_pBuddy = nullptr;
 	}
 
 	CGlass::~CGlass()
+	{
+
+	}
+
+	void CGlass::reset()
 	{
 		CPath* pPath = m_pPath;
 		while (pPath != nullptr) {
@@ -18,6 +24,10 @@
 			pPath = pTemp;
 		}
 		m_pPath = nullptr;
+
+		if (m_pBuddy != nullptr) {
+			m_pBuddy->release();
+		}
 	}
 
 	std::string& CGlass::getClassName()
@@ -56,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;
 		}
@@ -90,6 +101,7 @@
 		if (ar.IsStoring())
 		{
 			Lock();
+			ar << (int)m_type;
 			WriteString(ar, m_strID);
 			ar << (ULONGLONG)m_pPath;
 			if (m_pPath != nullptr) {
@@ -100,13 +112,19 @@
 			ar.Write(temp, JOBDATAB_SIZE);
 			m_jobDataS.serialize(temp, JOBDATAS_SIZE);
 			ar.Write(temp, JOBDATAS_SIZE);
+			ar << (ULONGLONG)m_pBuddy;
+			WriteString(ar, m_strBuddyId);
 			Unlock();
 		}
 		else
 		{
-			Lock();
-			ReadString(ar, m_strID);
 			ULONGLONG ullPath;
+			int type;
+
+			Lock();
+			ar >> type;
+			m_type = (MaterialsType)type;
+			ReadString(ar, m_strID);
 			ar >> ullPath;
 			if (ullPath != 0) {
 				m_pPath = new CPath();
@@ -117,6 +135,8 @@
 			m_jobDataB.unserialize(temp, JOBDATAB_SIZE);
 			ar.Read(temp, JOBDATAS_SIZE);
 			m_jobDataS.unserialize(temp, JOBDATAS_SIZE);
+			ar >> ullPath;					// 这是m_pBuddy, 用不上
+			ReadString(ar, m_strBuddyId);
 			Unlock();
 		}
 	}
@@ -140,4 +160,43 @@
 	{
 		return &m_jobDataS;
 	}
+
+	BOOL CGlass::setBuddy(CGlass* pGlass)
+	{
+		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_strBuddyId = m_pBuddy->getID();
+
+		return TRUE;
+	}
+
+	CGlass* CGlass::getBuddy()
+	{
+		return m_pBuddy;
+	}
+
+	std::string& CGlass::getBuddyId()
+	{
+		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