From 86742865018ecaa76c099c1b79149b4517eec075 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 18 十一月 2024 16:51:34 +0800
Subject: [PATCH] 1.继续整合主框架;

---
 Document/Gand Bond Server-Connect Function Manual.docx |    0 
 SourceCode/Bond/BondEq/BondEq.cpp                      |    1 
 SourceCode/Bond/BondEq/CBonder.cpp                     |  141 +---------------
 SourceCode/Bond/BondEq/Resource.h                      |    0 
 SourceCode/Bond/BondEq/CProjectPageComponents.cpp      |  233 +++++++++++++++++++++++++++++
 SourceCode/Bond/BondEq/CPanelProject.cpp               |   11 +
 SourceCode/Bond/BondEq/CProjectPageComponents.h        |   43 +++++
 SourceCode/Bond/BondEq/BondEq.rc                       |    0 
 SourceCode/Bond/BondEq/CPanelProject.h                 |    2 
 SourceCode/Bond/BondEq/Model.cpp                       |    4 
 SourceCode/Bond/BondEq/BondEq.vcxproj                  |    2 
 SourceCode/Bond/BondEq/Common.h                        |    7 
 12 files changed, 314 insertions(+), 130 deletions(-)

diff --git a/Document/Gand Bond Server-Connect Function Manual.docx b/Document/Gand Bond Server-Connect Function Manual.docx
new file mode 100644
index 0000000..5e3b0d3
--- /dev/null
+++ b/Document/Gand Bond Server-Connect Function Manual.docx
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEq.cpp b/SourceCode/Bond/BondEq/BondEq.cpp
index 7366fa1..6818a3d 100644
--- a/SourceCode/Bond/BondEq/BondEq.cpp
+++ b/SourceCode/Bond/BondEq/BondEq.cpp
@@ -152,6 +152,7 @@
 
 int CBondEqApp::ExitInstance()
 {
+	m_model.term();
 	BEQ_Term();
 	RX_Term();
 	MCL_Term();
diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index 85188b8..c49d5cd 100644
--- a/SourceCode/Bond/BondEq/BondEq.rc
+++ b/SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEq.vcxproj b/SourceCode/Bond/BondEq/BondEq.vcxproj
index b93d941..df383a5 100644
--- a/SourceCode/Bond/BondEq/BondEq.vcxproj
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -207,6 +207,7 @@
     <ClInclude Include="Context.h" />
     <ClInclude Include="CPanel.h" />
     <ClInclude Include="CParam.h" />
+    <ClInclude Include="CProjectPageComponents.h" />
     <ClInclude Include="CRemoteEqUnitView.h" />
     <ClInclude Include="CRemoteEqView.h" />
     <ClInclude Include="CHomeDialog.h" />
@@ -266,6 +267,7 @@
     <ClCompile Include="Context.cpp" />
     <ClCompile Include="CPanel.cpp" />
     <ClCompile Include="CParam.cpp" />
+    <ClCompile Include="CProjectPageComponents.cpp" />
     <ClCompile Include="CRemoteEqUnitView.cpp" />
     <ClCompile Include="CRemoteEqView.cpp" />
     <ClCompile Include="CHomeDialog.cpp" />
diff --git a/SourceCode/Bond/BondEq/CBonder.cpp b/SourceCode/Bond/BondEq/CBonder.cpp
index 104a6fe..33ddc29 100644
--- a/SourceCode/Bond/BondEq/CBonder.cpp
+++ b/SourceCode/Bond/BondEq/CBonder.cpp
@@ -126,20 +126,12 @@
 {
 	// 机器状态
 	CEQStateMonitor* pEQStateMonitor1 = new CEQStateMonitor();
-	pEQStateMonitor1->setName("机器状态(A单元)");
-	pEQStateMonitor1->setDescription("A单机器状态");
+	pEQStateMonitor1->setName("机器状态");
+	pEQStateMonitor1->setDescription("机器状态");
 	pEQStateMonitor1->setIndex(0);
 	pEQStateMonitor1->setBeginAddr(4463 - 4400);
 	AddComponent(pEQStateMonitor1);
 	pEQStateMonitor1->init();
-
-	CEQStateMonitor* pEQStateMonitor2 = new CEQStateMonitor();
-	pEQStateMonitor2->setName("机器状态(B单元)");
-	pEQStateMonitor2->setDescription("B单机器状态");
-	pEQStateMonitor2->setIndex(1);
-	pEQStateMonitor2->setBeginAddr(4563 - 4500);
-	AddComponent(pEQStateMonitor2);
-	pEQStateMonitor2->init();
 
 
 	// 初始化各种组件
@@ -195,69 +187,35 @@
 
 
 	CDataMonitor1* pDataMonitor1 = new CDataMonitor1();
-	pDataMonitor1->setName("数据监控(A单元)");
-	pDataMonitor1->setDescription("A单元真空、压力和温度数据");
+	pDataMonitor1->setName("数据监控");
+	pDataMonitor1->setDescription("真空、压力和温度数据");
 	pDataMonitor1->setIndex(0);
 	pDataMonitor1->setResponseAddr(4425);
 	pDataMonitor1->enableAutoSendData(bAutoSendData);
 	AddComponent(pDataMonitor1);
 	pDataMonitor1->init();
 	
-	CDataMonitor1* pDataMonitor2 = new CDataMonitor1();
-	pDataMonitor2->setName("数据监控(B单元)");
-	pDataMonitor2->setDescription("B单元真空、压力和温度数据");
-	pDataMonitor2->setIndex(1);
-	pDataMonitor2->setResponseAddr(4525);
-	pDataMonitor2->enableAutoSendData(bAutoSendData);
-	AddComponent(pDataMonitor2);
-	pDataMonitor2->init();
-	
-
 
 	CString strAlarmFile;
 	strAlarmFile.Format(_T("%s\\AlarmList.txt"), m_strWorkDir.c_str());
 	CAlarmMonitor* pAlarmMonitor1 = new CAlarmMonitor();
-	pAlarmMonitor1->setName("警告信息(A单元)");
-	pAlarmMonitor1->setDescription("警告信息监控(A单元)");
+	pAlarmMonitor1->setName("警告信息");
+	pAlarmMonitor1->setDescription("警告信息监控");
 	pAlarmMonitor1->setBeginAddr(4461 - 4400);
 	pAlarmMonitor1->setIndex(0);
 	pAlarmMonitor1->readAlarmListFromFile((LPTSTR)(LPCTSTR)strAlarmFile);
 	AddComponent(pAlarmMonitor1);
 	pAlarmMonitor1->init();
 
-	CAlarmMonitor* pAlarmMonitor2 = new CAlarmMonitor();
-	pAlarmMonitor2->setName("警告信息(B单元)");
-	pAlarmMonitor2->setDescription("警告信息监控(B单元)");
-	pAlarmMonitor2->setBeginAddr(4561 - 4500);
-	pAlarmMonitor2->setIndex(1);
-	pAlarmMonitor2->readAlarmListFromFile((LPTSTR)(LPCTSTR)strAlarmFile);
-	AddComponent(pAlarmMonitor2);
-	pAlarmMonitor2->init();
 
 	// LoadMonitor
 	CLoadMonitor* pLoadMonitor1 = new CLoadMonitor();
-	pLoadMonitor1->setName("上下料(A单元)");
-	pLoadMonitor1->setDescription("上下料信号监控(A单元)");
+	pLoadMonitor1->setName("上下料");
+	pLoadMonitor1->setDescription("上下料信号监控");
 	pLoadMonitor1->setBeginAddr(4700);
 	pLoadMonitor1->setIndex(0);
 	AddComponent(pLoadMonitor1);
 	pLoadMonitor1->init();
-
-	CLoadMonitor* pLoadMonitor2 = new CLoadMonitor();
-	pLoadMonitor2->setName("上下料(B单元)");
-	pLoadMonitor2->setDescription("上下料信号监控(B单元)");
-	pLoadMonitor2->setBeginAddr(4700);
-	pLoadMonitor2->setIndex(1);
-	AddComponent(pLoadMonitor2);
-	pLoadMonitor2->init();
-
-	CLoadMonitor* pLoadMonitor3 = new CLoadMonitor();
-	pLoadMonitor3->setName("上下料(冷却箱)");
-	pLoadMonitor3->setDescription("上下料信号监控(冷却箱)");
-	pLoadMonitor3->setBeginAddr(4700);
-	pLoadMonitor3->setIndex(2);
-	AddComponent(pLoadMonitor3);
-	pLoadMonitor3->init();
 
 
 	// BEQ与EFEM通讯
@@ -292,10 +250,7 @@
 	};
 	m_pEquipment->setEquipmentListener(equListener);
 	m_pEquipment->setVersion(m_strSoftRev.c_str());
-	m_pEquipment->addUnit(UNITA, 5);
-	m_pEquipment->addUnit(UNITB, 5);
-	BEQ::IUnit* pUnitC = m_pEquipment->addUnit(UNITC, 1);
-	pUnitC->setLayerCount(4);
+	m_pEquipment->addUnit(UNIT1, 5);
 	m_pEquipment->runOnServerMode(8192);
 
 
@@ -577,11 +532,7 @@
 BEQ::IUnit* CBonder::getUnit(int index)
 {
 	if (index == 0)
-		return m_pEquipment->getUnit(UNITA);
-	if (index == 1)
-		return m_pEquipment->getUnit(UNITB);
-	if (index == 2)
-		return m_pEquipment->getUnit(UNITC);
+		return m_pEquipment->getUnit(UNIT1);
 
 	return nullptr;
 }
@@ -798,24 +749,14 @@
 	}
 
 
-	// 单元C为水冷塔,不需要写
-	if (strcmp(szUnitName, UNITC) == 0) {
-		return 0;
-	}
-
-
 	// 如果是单元A或单元B, 写物料ID和配方ID到PLC
 	CLoadMonitor* pLoadMonitor = nullptr;
-	if (strcmp(szUnitName, UNITA) == 0) {
+	if (strcmp(szUnitName, UNIT1) == 0) {
 
-		pLoadMonitor = (CLoadMonitor*)GetComponent("上下料(A单元)");
+		pLoadMonitor = (CLoadMonitor*)GetComponent("上下料");
 		return pLoadMonitor->loadReady(pszMaterielId, pszRecipeId);
 	}
-	else if (strcmp(szUnitName, UNITB) == 0) {
 
-		pLoadMonitor = (CLoadMonitor*)GetComponent("上下料(B单元)");
-		return pLoadMonitor->loadReady(pszMaterielId, pszRecipeId);
-	}
 
 	return -2;
 }
@@ -831,7 +772,7 @@
 	if (!pPLC->isConnected()) {
 		return -1;
 	}
-	if (layer <= 0 || layer > 4) {
+	if (layer <= 0 || layer > 1) {
 		return -2;
 	}
 
@@ -874,36 +815,10 @@
 
 	// 写
 	int index, nFlagAddr;
-	if (strcmp(szUnitName, UNITA) == 0) {
+	if (strcmp(szUnitName, UNIT1) == 0) {
 		index = 0;
 		nFlagAddr = 4710;
 		szBuffer[index * 2] |= 0x02;
-	}
-	else if (strcmp(szUnitName, UNITB) == 0) {
-		index = 1;
-		nFlagAddr = 4711;
-		szBuffer[index * 2] |= 0x02;
-	}
-	else if (strcmp(szUnitName, UNITC) == 0) {
-		index = 2;
-		nFlagAddr = 4712;
-		switch (layer)
-		{
-		case 1:
-			szBuffer[index * 2] |= 0x01;
-			break;
-		case 2:
-			szBuffer[index * 2] |= 0x02;
-			break;
-		case 3:
-			szBuffer[index * 2] |= 0x04;
-			break;
-		case 4:
-			szBuffer[index * 2] |= 0x08;
-			break;
-		default:
-			break;
-		}
 	}
 
 
@@ -984,36 +899,10 @@
 
 	// 写
 	int index, nFlagAddr;
-	if (strcmp(szUnitName, UNITA) == 0) {
+	if (strcmp(szUnitName, UNIT1) == 0) {
 		index = 0;
 		nFlagAddr = 4710;
 		szBuffer[index * 2 + 1] |= 0x02;
-	}
-	else if (strcmp(szUnitName, UNITB) == 0) {
-		index = 1;
-		nFlagAddr = 4711;
-		szBuffer[index * 2 + 1] |= 0x02;
-	}
-	else if (strcmp(szUnitName, UNITC) == 0) {
-		index = 2;
-		nFlagAddr = 4712;
-		switch (layer)
-		{
-		case 1:
-			szBuffer[index * 2] |= 0x20;
-			break;
-		case 2:
-			szBuffer[index * 2] |= 0x40;
-			break;
-		case 3:
-			szBuffer[index * 2] |= 0x80;
-			break;
-		case 4:
-			szBuffer[index * 2 + 1] |= 0x01;
-			break;
-		default:
-			break;
-		}
 	}
 
 
diff --git a/SourceCode/Bond/BondEq/CPanelProject.cpp b/SourceCode/Bond/BondEq/CPanelProject.cpp
index 92cf9e9..0aa4518 100644
--- a/SourceCode/Bond/BondEq/CPanelProject.cpp
+++ b/SourceCode/Bond/BondEq/CPanelProject.cpp
@@ -19,6 +19,7 @@
 	m_nPanelWidth = int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25);
 	m_pAccordionWnd = nullptr;
 	m_pPageRemoteEqs = nullptr;
+	m_pPageComponents = nullptr;
 }
 
 CPanelProject::~CPanelProject()
@@ -75,6 +76,10 @@
 	m_pPageRemoteEqs->ShowWindow(SW_SHOW);
 	m_pAccordionWnd->AddItem("杩滅▼璁惧", m_pPageRemoteEqs, 0, TRUE, TRUE);
 	
+	m_pPageComponents = new CProjectPageComponents();
+	m_pPageComponents->Create(IDD_PROJECT_PAGE_COMPONENTS, GetDlgItem(IDC_ACCORDION_WND1));
+	m_pPageComponents->ShowWindow(SW_SHOW);
+	m_pAccordionWnd->AddItem("缁勪欢鍒楄〃", m_pPageComponents, -1, TRUE, TRUE);
 
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -110,6 +115,12 @@
 		::DeleteObject(m_hbrBkgnd);
 	}
 
+	if (m_pPageComponents != nullptr) {
+		m_pPageComponents->DestroyWindow();
+		delete m_pPageComponents;
+		m_pPageComponents = nullptr;
+	}
+
 	if (m_pPageRemoteEqs != nullptr) {
 		m_pPageRemoteEqs->DestroyWindow();
 		delete m_pPageRemoteEqs;
diff --git a/SourceCode/Bond/BondEq/CPanelProject.h b/SourceCode/Bond/BondEq/CPanelProject.h
index d62a58b..3b3f7f6 100644
--- a/SourceCode/Bond/BondEq/CPanelProject.h
+++ b/SourceCode/Bond/BondEq/CPanelProject.h
@@ -1,6 +1,7 @@
 锘�#pragma once
 #include "VerticalLine.h"
 #include "CProjectPageRemoteEqs.h"
+#include "CProjectPageComponents.h"
 #include "AccordionWnd.h"
 
 
@@ -29,6 +30,7 @@
 	int m_nPanelWidth;
 	CAccordionWnd* m_pAccordionWnd;
 	CProjectPageRemoteEqs* m_pPageRemoteEqs;
+	CProjectPageComponents* m_pPageComponents;
 
 
 // 瀵硅瘽妗嗘暟鎹�
diff --git a/SourceCode/Bond/BondEq/CProjectPageComponents.cpp b/SourceCode/Bond/BondEq/CProjectPageComponents.cpp
new file mode 100644
index 0000000..9c4032c
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CProjectPageComponents.cpp
@@ -0,0 +1,233 @@
+锘�// CProjectPageComponents.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "BondEq.h"
+#include "CProjectPageComponents.h"
+#include "afxdialogex.h"
+#include "Alarm.h"
+
+
+// CProjectPageComponents 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CProjectPageComponents, CDialogEx)
+
+CProjectPageComponents::CProjectPageComponents(CWnd* pParent /*=nullptr*/)
+	: CDialogEx(IDD_PROJECT_PAGE_COMPENTS, pParent)
+{
+	m_crBkgnd = PROPAGE_BACKGROUND_COLOR;
+	m_hbrBkgnd = nullptr;
+	m_pObserver = nullptr;
+}
+
+CProjectPageComponents::~CProjectPageComponents()
+{
+}
+
+void CProjectPageComponents::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_TREE1, m_treeComponents);
+}
+
+
+BEGIN_MESSAGE_MAP(CProjectPageComponents, CDialogEx)
+	ON_WM_CTLCOLOR()
+	ON_WM_DESTROY()
+	ON_WM_SIZE()
+	ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, &CProjectPageComponents::OnTvnSelchangedTree1)
+	ON_MESSAGE(ID_MSG_TREE_CLICK_ITEM, OnTreeClickItem)
+END_MESSAGE_MAP()
+
+
+// CEQPageComponents 娑堟伅澶勭悊绋嬪簭
+
+
+void CProjectPageComponents::InitRxWindows()
+{
+	/* code */
+	// 璁㈤槄鏁版嵁
+	IRxWindows* pRxWindows = RX_GetRxWindows();
+	pRxWindows->enableLog(5);
+	if (m_pObserver == NULL) {
+		m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
+			// onNext
+			pAny->addRef();
+			int code = pAny->getCode();
+			if (RX_CODE_DATA1_MATERIAL_RECEIVED == code) {
+				CComponent* pComponent;
+				if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
+					HTREEITEM hItem = getTreeItem(pComponent);
+					if (hItem != nullptr) {
+						m_treeComponents.ShowItemBadgeDotMode(hItem);
+					}
+				}
+			}
+			else if(RX_CODE_DATA1_MATERIAL_REMOVEED == code) {
+				CComponent* pComponent;
+				if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
+					HTREEITEM hItem = getTreeItem(pComponent);
+					if (hItem != nullptr) {
+						m_treeComponents.HideItemBadge(hItem);
+					}
+				}
+			}
+			else if (RX_CODE_ALARM_EVENT == code) {
+				CComponent* pComponent = nullptr;
+				CAlarm* pAlarm = nullptr;
+				pAny->getObject("obj", (IRxObject*&)pAlarm);
+				pAny->getPtrValue("ptr", (void*&)pComponent);
+				ASSERT(pComponent);
+				ASSERT(pAlarm);
+				HTREEITEM hItem = getTreeItem(pComponent);
+				if (hItem != nullptr) {
+					if(pAlarm->getStatus() == 1)
+						m_treeComponents.ShowItemBadgeDotMode(hItem);
+					else if (pAlarm->getStatus() == 2)
+						m_treeComponents.HideItemBadge(hItem);
+				}
+			}
+			else if (RX_CODE_PLC1_CONNECTTD == code) {
+				CComponent* pComponent;
+				if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
+					HTREEITEM hItem = getTreeItem(pComponent);
+					if (hItem != nullptr) {
+						m_treeComponents.ShowItemBadgeDotMode(hItem);
+					}
+				}
+			}
+			else if (RX_CODE_PLC1_DISCONNECTTD == code) {
+				CComponent* pComponent;
+				if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
+					HTREEITEM hItem = getTreeItem(pComponent);
+					if (hItem != nullptr) {
+						m_treeComponents.HideItemBadge(hItem);
+					}
+				}
+			}
+			pAny->release();
+		}, [&]() -> void {
+			// onComplete
+		}, [&](IThrowable* pThrowable) -> void {
+			// onErrorm
+			pThrowable->printf();
+		});
+
+		theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
+			->subscribe(m_pObserver);
+	}
+}
+
+BOOL CProjectPageComponents::OnInitDialog()
+{
+	CDialogEx::OnInitDialog();
+
+	
+	// 缁勪欢鍒楄〃
+	m_treeComponents.SetBkColor(PROPAGE_BACKGROUND_COLOR);
+	m_treeComponents.SetItemHeight(50);
+
+	const std::vector<CComponent*>& components = theApp.m_model.getBonder().getComponents();
+	for (auto item : components) {
+		HTREEITEM hItemComponent = m_treeComponents.InsertItem(item->getName().c_str());
+		m_treeComponents.SetItemData(hItemComponent, (DWORD_PTR)item);
+		if (item->getClassName().compare("CAlarmMonitor") == 0) {
+			m_treeComponents.SetItemBadge(hItemComponent, TREE_BADGE2_BACKGROUND, TREE_BADGE2_FOREGROUND);
+		}
+		else {
+			m_treeComponents.SetItemBadge(hItemComponent, TREE_BADGE_BACKGROUND, TREE_BADGE_FOREGROUND);
+		}
+	}
+
+	InitRxWindows();
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+
+HBRUSH CProjectPageComponents::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+	HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+	if (nCtlColor == CTLCOLOR_STATIC) {
+		pDC->SetBkColor(m_crBkgnd);
+	}
+
+	if (m_hbrBkgnd == nullptr) {
+		m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+	}
+
+	return m_hbrBkgnd;
+}
+
+
+void CProjectPageComponents::OnDestroy()
+{
+	CDialogEx::OnDestroy();
+
+	if (m_hbrBkgnd != nullptr) {
+		::DeleteObject(m_hbrBkgnd);
+	}
+
+	ASSERT(m_pObserver != NULL);
+	m_pObserver->unsubscribe();
+	m_pObserver = NULL;
+}
+
+
+void CProjectPageComponents::OnSize(UINT nType, int cx, int cy)
+{
+	CDialogEx::OnSize(nType, cx, cy);
+	if (GetDlgItem(IDC_TREE1) == nullptr) return;
+
+	CRect rcClient;
+	CWnd* pItem;
+	GetClientRect(&rcClient);
+
+	pItem = GetDlgItem(IDC_TREE1);
+	pItem->MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
+}
+
+
+void CProjectPageComponents::OnTvnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
+{
+	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
+
+
+	HTREEITEM hItem = pNMTreeView->itemNew.hItem;
+	ASSERT(hItem);
+	CComponent* pComponent = (CComponent*)m_treeComponents.GetItemData(hItem);
+	ASSERT(pComponent);
+	// theApp.m_model.notifyPtr(RX_CODE_SELECT_COMPONENT, pComponent);
+
+
+	*pResult = 0;
+}
+
+LRESULT CProjectPageComponents::OnTreeClickItem(WPARAM wParam, LPARAM lParam)
+{
+	HTREEITEM hItem = (HTREEITEM)wParam;
+	ASSERT(hItem);
+	CComponent* pComponent = (CComponent*)m_treeComponents.GetItemData(hItem);
+	ASSERT(pComponent);
+	theApp.m_model.notifyPtr(RX_CODE_SELECT_COMPONENT, pComponent);
+
+
+	return 0;
+}
+
+HTREEITEM CProjectPageComponents::getTreeItem(CComponent* pComponent)
+{
+	HTREEITEM hItem = m_treeComponents.GetChildItem(nullptr);
+	while (hItem != nullptr) {
+		CComponent* p = (CComponent*)m_treeComponents.GetItemData(hItem);
+		if (p == pComponent) {
+			return hItem;
+		}
+
+		hItem = m_treeComponents.GetNextSiblingItem(hItem);
+	}
+
+	return nullptr;
+}
diff --git a/SourceCode/Bond/BondEq/CProjectPageComponents.h b/SourceCode/Bond/BondEq/CProjectPageComponents.h
new file mode 100644
index 0000000..4f38d5a
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CProjectPageComponents.h
@@ -0,0 +1,43 @@
+锘�#pragma once
+#include "ApredTreeCtrl.h"
+
+
+// CEQPageComponents 瀵硅瘽妗�
+
+class CProjectPageComponents : public CDialogEx
+{
+	DECLARE_DYNAMIC(CProjectPageComponents)
+
+public:
+	CProjectPageComponents(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CProjectPageComponents();
+
+
+private:
+	void InitRxWindows();
+	HTREEITEM getTreeItem(CComponent* pComponent);
+
+private:
+	COLORREF m_crBkgnd;
+	HBRUSH m_hbrBkgnd;
+	CApredTreeCtrl m_treeComponents;
+	IObserver* m_pObserver;
+
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_EQPAGE_COMPONENTS };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	virtual BOOL OnInitDialog();
+	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+	afx_msg void OnDestroy();
+	afx_msg void OnSize(UINT nType, int cx, int cy);
+	afx_msg void OnTvnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult);
+	afx_msg LRESULT OnTreeClickItem(WPARAM wParam, LPARAM lParam);
+};
diff --git a/SourceCode/Bond/BondEq/Common.h b/SourceCode/Bond/BondEq/Common.h
index 6b4757c..6cc098b 100644
--- a/SourceCode/Bond/BondEq/Common.h
+++ b/SourceCode/Bond/BondEq/Common.h
@@ -4,9 +4,7 @@
 #define MC_TIME_SEPAR				1000
 
 
-#define UNITA			_T("UNITA")
-#define UNITB			_T("UNITB")
-#define UNITC			_T("C")
+#define UNIT1			_T("UNIT1")
 
 
 /* Context Ret code */
@@ -32,7 +30,8 @@
 #define RX_CODE_ALARM_EVENT				1012
 #define RX_CODE_EQSTATE_EVENT			1013
 #define RX_CODE_EFEM_STATUS_CHANGED		1014
-#define RX_CODE_EQ_STATE_CHANGED	1015
+#define RX_CODE_EQ_STATE_CHANGED		1015
+#define RX_CODE_SELECT_COMPONENT		1016
 
 /* 广播代码 */
 #define BC_CODE_DATA1_MATERIAL_RECEIVED	5000
diff --git a/SourceCode/Bond/BondEq/Model.cpp b/SourceCode/Bond/BondEq/Model.cpp
index b50691f..8c088d2 100644
--- a/SourceCode/Bond/BondEq/Model.cpp
+++ b/SourceCode/Bond/BondEq/Model.cpp
@@ -177,6 +177,10 @@
 
 int CModel::term()
 {
+	m_bonder.save();
+	m_bonder.term();
+	m_sqlite.term();
+
 	CLog::GetLog()->SetOnLogCallback(nullptr);
 	return 0;
 }
diff --git a/SourceCode/Bond/BondEq/Resource.h b/SourceCode/Bond/BondEq/Resource.h
index 7433bc4..06da07b 100644
--- a/SourceCode/Bond/BondEq/Resource.h
+++ b/SourceCode/Bond/BondEq/Resource.h
Binary files differ

--
Gitblit v1.9.3