From 8de338246a5c70210077ce1162e926cef5f39c70 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期二, 25 三月 2025 17:09:16 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/Servo/CEquipment.cpp |   62 ++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index ad4a356..393191b 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -22,6 +22,11 @@
 
 	CEquipment::~CEquipment()
 	{
+		for (auto item : m_glassList) {
+			item->release();
+		}
+		m_glassList.clear();
+
 		for (auto item : m_mapStep) {
 			delete item.second;
 		}
@@ -201,8 +206,8 @@
 				std::to_string((int)item->getType()).c_str(), ""));
 		}
 
-		for (auto item : m_panelList) {
-			attrubutes.addAttribute(new CAttribute("Panel",
+		for (auto item : m_glassList) {
+			attrubutes.addAttribute(new CAttribute("Glass",
 				item->getID().c_str(), ""));
 		}
 	}
@@ -253,7 +258,26 @@
 
 	void CEquipment::serialize(CArchive& ar)
 	{
-
+		if (ar.IsStoring()) {
+			Lock();
+			int count = (int)m_glassList.size();
+			ar << count;
+			for (auto item : m_glassList) {
+				item->serialize(ar);
+			}
+			Unlock();
+		}
+		else {
+			Lock();
+			int count;
+			ar >> count;
+			for (int i = 0; i < count; i++) {
+				CGlass* pGlass = new CGlass();
+				pGlass->serialize(ar);
+				addGlassToList(pGlass);
+			}
+			Unlock();
+		}
 	}
 
 	void CEquipment::onReceiveLBData(const char* pszData, size_t size)
@@ -492,12 +516,12 @@
 
 		// 物料
 		if (code == FLOW_MOVE_MATERIAL) {
-			CPanel* pPanel = (CPanel*)pIntent->getContext();
-			ASSERT(pPanel);
-			if (!glassWillArrive(pPanel)) {
+			CGlass* pGlass = (CGlass*)pIntent->getContext();
+			ASSERT(pGlass);
+			if (!glassWillArrive(pGlass)) {
 				return FLOW_REJECT;
 			}
-			return glassArrived(pPanel);
+			return glassArrived(pGlass);
 		}
 
 
@@ -524,7 +548,11 @@
 
 		// 模拟取出第一张Panel,传送到下一环节
 		Lock();
-		CPanel* pContext = m_panelList.front();
+		if (m_glassList.empty()) {
+			Unlock();
+			return -2;
+		}
+		CGlass* pContext = m_glassList.front();
 		pContext->addRef();
 
 		CIntent intent(FLOW_MOVE_MATERIAL, "", pContext);
@@ -533,7 +561,7 @@
 			LOGE("<CEquipment>对方拒绝接收Intent.");
 		}
 		else if (nRet == FLOW_ACCEPT) {
-			m_panelList.pop_front();
+			m_glassList.pop_front();
 			pContext->release();		// 添加到列队时addRef, 取出时release
 		}
 
@@ -543,27 +571,27 @@
 		return 0;
 	}
 
-	BOOL CEquipment::glassWillArrive(CPanel* pPanel)
+	BOOL CEquipment::glassWillArrive(CGlass* pGlass)
 	{
 		return TRUE;
 	}
 
-	int CEquipment::glassArrived(CPanel* pPanel)
+	int CEquipment::glassArrived(CGlass* pGlass)
 	{
 		Lock();
-		pPanel->addRef();
-		m_panelList.push_back(pPanel);
+		pGlass->addRef();
+		m_glassList.push_back(pGlass);
 		Unlock();
 		return FLOW_ACCEPT;
 	}
 
-	void CEquipment::addPanelToList(CPanel* pPanel)
+	void CEquipment::addGlassToList(CGlass* pGlass)
 	{
-		ASSERT(pPanel);
+		ASSERT(pGlass);
 
 		Lock();
-		pPanel->addRef();
-		m_panelList.push_back(pPanel);
+		pGlass->addRef();
+		m_glassList.push_back(pGlass);
 		Unlock();
 	}
 }

--
Gitblit v1.9.3