From 217f07665553605caa3f3339321d04bd2c3e8256 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 15 五月 2025 17:18:58 +0800
Subject: [PATCH] 1.Bonder 处理ProcessDataReport, 并将G1与G2绑定一起。

---
 SourceCode/Bond/Servo/CEquipment.cpp |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index cea483e..c4b51a7 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -311,13 +311,28 @@
 			Unlock();
 		}
 		else {
-			Lock();
+			// addGlassToList前不需要上锁,因其内部有锁
 			int count;
 			ar >> count;
 			for (int i = 0; i < count; i++) {
 				CGlass* pGlass = new CGlass();
 				pGlass->serialize(ar);
 				addGlassToList(pGlass);
+			}
+			
+			// 梳理各玻璃之间的绑定关系
+			Lock();
+			std::list<CGlass*> list = m_glassList;
+			for (auto item : list) {
+				std::string& strBuddyId = item->getBuddyId();
+				if (!strBuddyId.empty()) {
+					for (auto item2 : m_glassList) {
+						if (strBuddyId.compare(item2->getID()) == 0) {
+							item->setBuddy(item2);
+							TRACE("绑定关系: %s <- %s\n", item->getID().c_str(), item2->getID().c_str());
+						}
+					}
+				}
 			}
 			Unlock();
 		}
@@ -786,6 +801,21 @@
 		}
 	}
 
+	CGlass* CEquipment::getGlassFromList(const char* pszId)
+	{
+		CGlass* pGlass = nullptr;
+		Lock();
+		for (auto item : m_glassList) {
+			if (item->getID().compare(pszId) == 0) {
+				pGlass = item;
+				break;
+			}
+		}
+		Unlock();
+
+		return pGlass;
+	}
+
 	BOOL CEquipment::removeClass(CGlass* pGlass)
 	{
 		Lock();

--
Gitblit v1.9.3