From 83922105a8e09cd8c1fbb5833e370518513121f7 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 14 三月 2025 10:15:29 +0800
Subject: [PATCH] 1.Equipment在面板中显示机器信息(Alive, Name, CIM State, Upstream, Downstream等)

---
 SourceCode/Bond/Servo/CEquipment.cpp      |   33 ++++++++++++++++
 SourceCode/Bond/Servo/Servo.rc            |    0 
 SourceCode/Bond/Servo/CEFEM.cpp           |    5 ++
 SourceCode/Bond/Servo/CEFEM.h             |    1 
 SourceCode/Bond/Servo/CPanelEquipment.h   |    2 +
 SourceCode/Bond/Servo/CEquipment.h        |    1 
 SourceCode/Bond/Servo/ServoDlg.cpp        |    2 
 SourceCode/Bond/Servo/CPanelEquipment.cpp |   29 ++++++++++++++
 8 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 665aa25..eff68be 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -37,4 +37,9 @@
 	{
 		CEquipment::serialize(ar);
 	}
+
+	void CEFEM::getAttributeVector(CAttributeVector& attrubutes)
+	{
+		__super::getAttributeVector(attrubutes);
+	}
 }
diff --git a/SourceCode/Bond/Servo/CEFEM.h b/SourceCode/Bond/Servo/CEFEM.h
index 7a7be7e..b77770e 100644
--- a/SourceCode/Bond/Servo/CEFEM.h
+++ b/SourceCode/Bond/Servo/CEFEM.h
@@ -15,6 +15,7 @@
         virtual void term();
         virtual void onTimer(UINT nTimerid);
         virtual void serialize(CArchive& ar);
+        virtual void getAttributeVector(CAttributeVector& attrubutes);
     };
 }
 
diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 3fa85bb..c66619b 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -137,6 +137,39 @@
 		return m_station;
 	}
 
+	void CEquipment::getAttributeVector(CAttributeVector& attrubutes)
+	{
+		attrubutes.clear();
+		attrubutes.addAttribute(new CAttribute("Network",
+			std::to_string(m_station.nNetNo).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Station",
+			std::to_string(m_station.nStNo).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("ID",
+			std::to_string(m_nID).c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Name",
+			m_strName.c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Description",
+			m_strDescription.c_str(), ""));
+		attrubutes.addAttribute(new CAttribute("Alive",
+			this->isAlive() ? _T("TRUE") : _T("FALSE"), ""));
+		attrubutes.addAttribute(new CAttribute("CIM State",
+			m_bCimState ? _T("ON") : _T("OFF"), ""));
+		attrubutes.addAttribute(new CAttribute("Upstream",
+			m_bUpstreamInline ? _T("Inline") : _T("Offline"), ""));
+		attrubutes.addAttribute(new CAttribute("Downstream",
+			m_bDownstreamInline ? _T("Inline") : _T("Offline"), ""));
+		attrubutes.addAttribute(new CAttribute("Local Alarm",
+			m_bLocalAlarm ? _T("TRUE") : _T("FALSE"), ""));
+		attrubutes.addAttribute(new CAttribute("Auto Recipe Change",
+			m_bAutoRecipeChange ? _T("TRUE") : _T("FALSE"), ""));
+		char szTemp[256];
+		for (int i = 0; i < VCR_MAX; i++) {
+			sprintf_s(szTemp, 256, "VCR-%d", i + 1);
+			attrubutes.addAttribute(new CAttribute(szTemp,
+				m_bVCREnable[i] ? _T("Enable") : _T("Disable"), ""));
+		}
+	}
+
 	void CEquipment::setReadBitBlock(unsigned int start, unsigned int end)
 	{
 		m_blockReadBit.type = (unsigned int)DeviceType::B;
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index c8bccd9..784767b 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -61,6 +61,7 @@
 		std::string& getDescription();
 		void setStation(int network, int station);
 		const StationIdentifier& getStation();
+		virtual void getAttributeVector(CAttributeVector& attrubutes);
 		void setReadBitBlock(unsigned int start, unsigned int end);
 		MemoryBlock& getReadBitBlock();
 		void setWriteBitBlock(unsigned int start, unsigned int end);
diff --git a/SourceCode/Bond/Servo/CPanelEquipment.cpp b/SourceCode/Bond/Servo/CPanelEquipment.cpp
index 533e77f..490babd 100644
--- a/SourceCode/Bond/Servo/CPanelEquipment.cpp
+++ b/SourceCode/Bond/Servo/CPanelEquipment.cpp
@@ -29,6 +29,7 @@
 void CPanelEquipment::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_MFCPROPERTYGRID1, m_gridCtrl);
 }
 
 
@@ -56,6 +57,32 @@
 
 	if (::IsWindow(m_hWnd)) {
 		SetDlgItemText(IDC_LABEL_TITLE, m_pEquipment->getName().c_str());
+	}
+}
+
+void CPanelEquipment::loadDataFromEquipment(SERVO::CEquipment* pEquipment)
+{
+	m_pEquipment = pEquipment;
+	ASSERT(m_pEquipment);
+
+
+	// 鍏堟竻绌烘墍鏈�
+	m_gridCtrl.RemoveAll();
+
+
+	// 鍔犺浇鏁版嵁
+	SetDlgItemText(IDC_LABEL_TITLE, pEquipment->getName().c_str());
+	SERVO::CAttributeVector attrubutes;
+	pEquipment->getAttributeVector(attrubutes);
+	unsigned int nSize = attrubutes.size();
+	for (unsigned int i = 0; i < nSize; i++) {
+		SERVO::CAttribute* pAttribute = attrubutes.getAttribute(i);
+		CMFCPropertyGridProperty* pProperty = new CMFCPropertyGridProperty(
+			pAttribute->getName().c_str(),
+			pAttribute->getValue().c_str(),
+			pAttribute->getDescription().c_str());
+		pProperty->AllowEdit(FALSE);
+		m_gridCtrl.AddProperty(pProperty);
 	}
 }
 
@@ -145,6 +172,8 @@
 	pItem->MoveWindow(5, y, x2 - 5, rcItem.Height());
 	y += rcItem.Height();
 	y += 8;
+
+	GetDlgItem(IDC_MFCPROPERTYGRID1)->MoveWindow(5, y, rcClient.Width() - 13, rcClient.Height() - 3 - y);
 }
 
 #define EQUIPMENT_PANEL_MIN_WIDTH		88
diff --git a/SourceCode/Bond/Servo/CPanelEquipment.h b/SourceCode/Bond/Servo/CPanelEquipment.h
index 460e858..9aa3580 100644
--- a/SourceCode/Bond/Servo/CPanelEquipment.h
+++ b/SourceCode/Bond/Servo/CPanelEquipment.h
@@ -14,11 +14,13 @@
 	virtual ~CPanelEquipment();
 	int getPanelWidth();
 	void SetEquipment(SERVO::CEquipment* pEquipment);
+	void loadDataFromEquipment(SERVO::CEquipment* pEquipment);
 
 private:
 	COLORREF m_crBkgnd;
 	HBRUSH m_hbrBkgnd;
 	int m_nPanelWidth;
+	CMFCPropertyGridCtrl m_gridCtrl;
 	CBlButton m_btnClose;
 	SERVO::CEquipment* m_pEquipment;
 
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index f5404a1..e153b70 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index fae7e5a..0746f9b 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -179,7 +179,7 @@
 					ASSERT(pEquipment);
 					ASSERT(m_pPanelEquipment);
 					ASSERT(m_pPanelAttributes);
-					m_pPanelEquipment->SetEquipment(pEquipment);
+					m_pPanelEquipment->loadDataFromEquipment(pEquipment);
 					m_pPanelAttributes->ShowWindow(SW_HIDE);
 					if (!m_pPanelEquipment->IsWindowVisible()) {
 						m_pPanelEquipment->ShowWindow(SW_SHOW);

--
Gitblit v1.9.3