From 8942dacbc2bfaf8aec6a360671de20b0fbf32273 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 26 三月 2025 13:43:32 +0800
Subject: [PATCH] 1.Equipment属性页对话框,准备用于展示Equipment数据,里面的Glass等。

---
 SourceCode/Bond/Servo/CEquipment.cpp |   66 +++++++++++++++++++++++++++++++-
 1 files changed, 63 insertions(+), 3 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index c24767e..a52da00 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -7,7 +7,7 @@
 
 	CEquipment::CEquipment() : m_nID(0), m_strName(""), m_strDescription(""), m_station(0, 255)
 	{
-		m_listener = { nullptr, nullptr };
+		m_listener = { nullptr, nullptr, nullptr };
 		m_alive = {FALSE, 0, FALSE};
 		m_bCimState = FALSE;
 		m_bUpstreamInline = FALSE;
@@ -22,6 +22,11 @@
 
 	CEquipment::~CEquipment()
 	{
+		for (auto item : m_glassList) {
+			item->release();
+		}
+		m_glassList.clear();
+
 		for (auto item : m_mapStep) {
 			delete item.second;
 		}
@@ -44,6 +49,7 @@
 	{
 		m_listener.onAlive = listener.onAlive;
 		m_listener.onCimStateChanged = listener.onCimStateChanged;
+		m_listener.onDataChanged = listener.onDataChanged;
 	}
 
 	void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
@@ -202,7 +208,7 @@
 		}
 
 		for (auto item : m_glassList) {
-			attrubutes.addAttribute(new CAttribute("Panel",
+			attrubutes.addAttribute(new CAttribute("Glass",
 				item->getID().c_str(), ""));
 		}
 	}
@@ -253,7 +259,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)
@@ -523,7 +548,12 @@
 
 
 		// 模拟取出第一张Panel,传送到下一环节
+		ULONGLONG time = CToolUnits::getTimestamp();
 		Lock();
+		if (m_glassList.empty()) {
+			Unlock();
+			return -2;
+		}
 		CGlass* pContext = m_glassList.front();
 		pContext->addRef();
 
@@ -533,8 +563,15 @@
 			LOGE("<CEquipment>对方拒绝接收Intent.");
 		}
 		else if (nRet == FLOW_ACCEPT) {
+			CPath* pPath = pContext->getPathWithSiteID(m_nID);
+			if (pPath != nullptr) {
+				pPath->setOutTime(time);
+			}
 			m_glassList.pop_front();
 			pContext->release();		// 添加到列队时addRef, 取出时release
+			if (m_listener.onDataChanged != nullptr) {
+				m_listener.onDataChanged(this, 0);
+			}
 		}
 
 		pContext->release();
@@ -551,9 +588,15 @@
 	int CEquipment::glassArrived(CGlass* pGlass)
 	{
 		Lock();
+		pGlass->addPath(m_nID);
 		pGlass->addRef();
 		m_glassList.push_back(pGlass);
 		Unlock();
+
+		if (m_listener.onDataChanged != nullptr) {
+			m_listener.onDataChanged(this, 0);
+		}
+
 		return FLOW_ACCEPT;
 	}
 
@@ -565,5 +608,22 @@
 		pGlass->addRef();
 		m_glassList.push_back(pGlass);
 		Unlock();
+
+		if (m_listener.onDataChanged != nullptr) {
+			m_listener.onDataChanged(this, 0);
+		}
+	}
+
+	CGlass* CEquipment::getFrontGlass()
+	{
+		CGlass* pGlass = nullptr;
+
+		Lock();
+		if (!m_glassList.empty()) {
+			pGlass = m_glassList.front();
+		}
+		Unlock();
+
+		return pGlass;
 	}
 }

--
Gitblit v1.9.3