From acce0e17813055eae0f99eca392b3096cb0ea778 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 14 三月 2025 14:15:13 +0800
Subject: [PATCH] 1.测试写入CIM State成功。

---
 SourceCode/Bond/Servo/resource.h       |    0 
 SourceCode/Bond/Servo/CPanelMaster.h   |    2 
 SourceCode/Bond/Servo/CEquipment.cpp   |   11 +++++
 SourceCode/Bond/Servo/Servo.rc         |    0 
 SourceCode/Bond/Servo/CPanelMaster.cpp |   19 +++++++++
 SourceCode/Bond/Servo/CEquipment.h     |    1 
 SourceCode/Bond/Servo/ServoDlg.cpp     |   36 ++++++++++++++++++
 SourceCode/Bond/Servo/ServoDlg.h       |    4 ++
 8 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index c66619b..7ef517b 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -72,6 +72,17 @@
 		return iter->second;
 	}
 
+	CStep* CEquipment::getStepWithName(const char* pszName)
+	{
+		for (auto item : m_mapStep) {
+			if (item.second->getName().compare(pszName) == 0) {
+				return item.second;
+			}
+		}
+
+		return nullptr;
+	}
+
 	int CEquipment::addStep(unsigned int addr, CStep* pStep)
 	{
 		auto iter = m_mapStep.find(addr);
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 784767b..ea8078e 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -69,6 +69,7 @@
 		void getProperties(std::vector<std::pair<std::string, std::string>>& container);
 		int addStep(unsigned int addr, CStep* pStep);
 		CStep* getStep(unsigned int addr);
+		CStep* getStepWithName(const char* pszName);
 		std::map<unsigned int, CStep*>& getSteps();
 		virtual void init();
 		virtual void term();
diff --git a/SourceCode/Bond/Servo/CPanelMaster.cpp b/SourceCode/Bond/Servo/CPanelMaster.cpp
index d30a62a..b27ea82 100644
--- a/SourceCode/Bond/Servo/CPanelMaster.cpp
+++ b/SourceCode/Bond/Servo/CPanelMaster.cpp
@@ -211,3 +211,22 @@
 
 	return nLevel;
 }
+
+SERVO::CEquipment* CPanelMaster::GetActiveEquipment()
+{
+	HTREEITEM hItem = m_treeCtrl.GetSelectedItem();
+	if (hItem == nullptr) return nullptr;
+
+	int nLevel = GetTreeItemLevel(hItem);
+	if (nLevel == 2) {
+		return (SERVO::CEquipment*)m_treeCtrl.GetItemData(hItem);
+	}
+	else if (nLevel == 3) {
+		SERVO::CStep* pStep = (SERVO::CStep*)m_treeCtrl.GetItemData(hItem);
+		if (pStep != nullptr) {
+			return pStep->getEquipment();
+		}
+	}
+
+	return nullptr;
+}
diff --git a/SourceCode/Bond/Servo/CPanelMaster.h b/SourceCode/Bond/Servo/CPanelMaster.h
index bea8068..15bd2db 100644
--- a/SourceCode/Bond/Servo/CPanelMaster.h
+++ b/SourceCode/Bond/Servo/CPanelMaster.h
@@ -14,7 +14,7 @@
 	int getPanelWidth();
 	void loadEquipmentList();
 	void loadSteps(SERVO::CEquipment* pEquipment, HTREEITEM hItemEq);
-
+	SERVO::CEquipment* GetActiveEquipment();
 
 private:
 	int GetTreeItemLevel(HTREEITEM hItem);
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index e153b70..de89c3d 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 0746f9b..fbd0eff 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -128,6 +128,10 @@
 	ON_UPDATE_COMMAND_UI(ID_MENU_WND_LOG, &CServoDlg::OnUpdateMenuWndLog)
 	ON_COMMAND(ID_MENU_WND_ALARM, &CServoDlg::OnMenuWndAlarm)
 	ON_UPDATE_COMMAND_UI(ID_MENU_WND_ALARM, &CServoDlg::OnUpdateMenuWndAlarm)
+	ON_COMMAND(ID_MENU_TEST_MESSAGE_SET, &CServoDlg::OnMenuTestMessageSet)
+	ON_UPDATE_COMMAND_UI(ID_MENU_TEST_MESSAGE_SET, &CServoDlg::OnUpdateMenuTestMessageSet)
+	ON_COMMAND(ID_MENU_TEST_MESSAGE_CLEAR, &CServoDlg::OnMenuTestMessageClear)
+	ON_UPDATE_COMMAND_UI(ID_MENU_TEST_MESSAGE_CLEAR, &CServoDlg::OnUpdateMenuTestMessageClear)
 	ON_COMMAND(ID_MENU_HELP_ABOUT, &CServoDlg::OnMenuHelpAbout)
 	ON_WM_INITMENUPOPUP()
 	ON_WM_TIMER()
@@ -552,6 +556,38 @@
 	pCmdUI->Enable(TRUE);
 }
 
+void CServoDlg::OnMenuTestMessageSet()
+{
+	SERVO::CEquipment* pEquipment = m_pPanelMaster->GetActiveEquipment();
+	if (pEquipment != nullptr) {
+		SERVO::CEqCimModeChangeStep* pStep = (SERVO::CEqCimModeChangeStep*)pEquipment->getStepWithName(STEP_CIM_MODE_CHANGE);
+		if (pStep != nullptr) {
+			static int i = 0;
+			i++;
+			if(i % 2 == 1)
+				pStep->cimOn();
+			else
+				pStep->cimOff();
+			AfxMessageBox(pStep->getName().c_str());
+		}
+	}
+}
+
+void CServoDlg::OnUpdateMenuTestMessageSet(CCmdUI* pCmdUI)
+{
+	pCmdUI->Enable(m_pPanelMaster->GetActiveEquipment() != nullptr);
+}
+
+void CServoDlg::OnMenuTestMessageClear()
+{
+	AfxMessageBox("OnMenuTestMessageClear");
+}
+
+void CServoDlg::OnUpdateMenuTestMessageClear(CCmdUI* pCmdUI)
+{
+	pCmdUI->Enable(TRUE);
+}
+
 void CServoDlg::OnMenuHelpAbout()
 {
 	CAboutDlg dlgAbout;
diff --git a/SourceCode/Bond/Servo/ServoDlg.h b/SourceCode/Bond/Servo/ServoDlg.h
index 685acf1..091f0c8 100644
--- a/SourceCode/Bond/Servo/ServoDlg.h
+++ b/SourceCode/Bond/Servo/ServoDlg.h
@@ -101,6 +101,10 @@
 	afx_msg void OnUpdateMenuWndAlarm(CCmdUI* pCmdUI);
 	afx_msg void OnMenuFileExit();
 	afx_msg void OnUpdateMenuFileExit(CCmdUI* pCmdUI);
+	afx_msg void OnMenuTestMessageSet();
+	afx_msg void OnUpdateMenuTestMessageSet(CCmdUI* pCmdUI);
+	afx_msg void OnMenuTestMessageClear();
+	afx_msg void OnUpdateMenuTestMessageClear(CCmdUI* pCmdUI);
 	afx_msg void OnMenuHelpAbout();
 	afx_msg void OnTimer(UINT_PTR nIDEvent);
 	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index 7f2b3fb..8c81dc6 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3