From 42fc5f4f82dca4c50a4250c2b3e48c1aeda3c943 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期二, 01 四月 2025 17:50:35 +0800
Subject: [PATCH] 1. master初始化以后状态图的控件与设备绑定

---
 SourceCode/Bond/Servo/CPageGraph1.h   |    1 +
 SourceCode/Bond/Servo/ServoDlg.cpp    |    7 +++++--
 SourceCode/Bond/Servo/CPageGraph1.cpp |   41 ++++++++++++++++++++++++++++++++---------
 3 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageGraph1.cpp b/SourceCode/Bond/Servo/CPageGraph1.cpp
index be12698..d288ba5 100644
--- a/SourceCode/Bond/Servo/CPageGraph1.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph1.cpp
@@ -193,13 +193,6 @@
 	m_pGraph->SetBoxText(INDICATE_MEASUREMENT, "13", "Measurement");
 
 
-	// 缁戝畾鏁版嵁
-	{
-		SERVO::CEquipment* pEquipment = theApp.m_model.m_master.getEquipment(EQ_ID_EFEM);
-		m_pGraph->SetIndicateBoxData(INDICATE_ROBOT_ARM1, pEquipment);
-	}
-
-
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
 }
@@ -382,15 +375,45 @@
 	Invalidate();
 }
 
+void CPageGraph1::BindEquipmentToGraph()
+{
+	struct EquipmentBindInfo
+	{
+		int nEquipmentID;
+		int nIndicateID;
+	};
+
+	static const EquipmentBindInfo EQUIPMENT_BIND_LIST[] = {
+		{ EQ_ID_EFEM,           INDICATE_ROBOT_ARM1 },
+		{ EQ_ID_EFEM,           INDICATE_ROBOT_ARM2 },
+		{ EQ_ID_Bonder1,        INDICATE_BONDER1 },
+		{ EQ_ID_Bonder2,        INDICATE_BONDER2 },
+		{ EQ_ID_LOADPORT1,      INDICATE_LPORT1 },
+		{ EQ_ID_LOADPORT2,      INDICATE_LPORT2 },
+		{ EQ_ID_LOADPORT3,      INDICATE_LPORT3 },
+		{ EQ_ID_LOADPORT4,      INDICATE_LPORT4 },
+		{ EQ_ID_FLIPER,         INDICATE_FLIPER },
+		{ EQ_ID_VACUUMBAKE,     INDICATE_VACUUM_BAKE },
+		{ EQ_ID_ALIGNER,        INDICATE_ALIGNER },
+		{ EQ_ID_BAKE_COOLING,   INDICATE_BAKE_COOLING }
+	};
+
+	for (const auto& stBindInfo : EQUIPMENT_BIND_LIST)
+	{
+		SERVO::CEquipment* pEquipment = theApp.m_model.m_master.getEquipment(stBindInfo.nEquipmentID);
+		m_pGraph->SetIndicateBoxData(stBindInfo.nIndicateID, pEquipment);
+	}
+}
+
 void CPageGraph1::OnGraphItemClicked(NMHDR* pNMHDR, LRESULT* pResult)
 {
 	BYSERVOGRAPH_NMHDR* pGraphNmhdr = reinterpret_cast<BYSERVOGRAPH_NMHDR*>(pNMHDR);
 	CString s; s.Format(_T("OnGraphItemClicked %d"), pGraphNmhdr->dwData);
 	SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)m_pGraph->GetIndicateBoxData(pGraphNmhdr->dwData);
 	if (pEquipment != nullptr) {
-		AfxMessageBox(pEquipment->getName().c_str());
+		//AfxMessageBox(pEquipment->getName().c_str());
+		theApp.m_model.notifyPtr(RX_CODE_SELECT_EQUIPMENT, pEquipment);
 	}
-
 
 	*pResult = 0;
 }
diff --git a/SourceCode/Bond/Servo/CPageGraph1.h b/SourceCode/Bond/Servo/CPageGraph1.h
index 405af87..edef11a 100644
--- a/SourceCode/Bond/Servo/CPageGraph1.h
+++ b/SourceCode/Bond/Servo/CPageGraph1.h
@@ -24,6 +24,7 @@
 	void UpdateDeviceStatus(int id, DeviceStatus status);
 	void UpdateRobotPosition(float percentage);
 	void RotateRobot(float angleInDegrees);
+	void BindEquipmentToGraph();
 
 private:
 	IObserver* m_pObserver;
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 28bbd95..8babfd8 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -224,12 +224,12 @@
 	SetMenu(&menu);
 
 
-
 	// Tab
 	m_pPageGraph1 = new CPageGraph1();
 	m_pPageGraph1->Create(IDD_PAGE_GRAPH1, this);
 	m_pPageGraph2 = new CPageGraph2();
 	m_pPageGraph2->Create(IDD_PAGE_GRAPH2, this);
+
 
 	CHmTab* m_pTab = CHmTab::Hook(GetDlgItem(IDC_TAB1)->m_hWnd);
 	m_pTab->SetPaddingLeft(20);
@@ -249,7 +249,6 @@
 	m_pPanelAttributes = new CPanelAttributes();
 	m_pPanelAttributes->Create(IDD_PANEL_ATTRIBUTES, this);
 	
-
 
 	// 调整初始窗口位置
 	CRect rcWnd;
@@ -275,6 +274,10 @@
 	theApp.m_model.m_master.init();
 
 
+	// 初始化master以后需要控件绑定数据
+	m_pPageGraph1->BindEquipmentToGraph();
+
+
 	return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
 }
 

--
Gitblit v1.9.3