From ab612c6fa43c9ae172572d187bf40da0386434d2 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 19 二月 2025 15:38:46 +0800
Subject: [PATCH] 1.增加CStep类,用于处理相似的CC-Link读取数据,回复等逻辑;

---
 SourceCode/Bond/Servo/CEquipment.cpp |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 5fe849f..33156a2 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -20,6 +20,11 @@
 
 	CEquipment::~CEquipment()
 	{
+		for (auto item : m_mapStep) {
+			delete item.second;
+		}
+		m_mapStep.clear();
+
 		DeleteCriticalSection(&m_criticalSection);
 	}
 
@@ -29,14 +34,37 @@
 		m_listener.onCimStateChanged = listener.onCimStateChanged;
 	}
 
+	CStep* CEquipment::getStep(unsigned int addr)
+	{
+		auto iter = m_mapStep.find(addr);
+		if (iter == m_mapStep.end()) return nullptr;
+		return iter->second;
+	}
+
+	int CEquipment::addStep(unsigned int addr, CStep* pStep)
+	{
+		auto iter = m_mapStep.find(addr);
+		if (iter != m_mapStep.end()) return -1;
+		m_mapStep[addr] = pStep;
+		return 0;
+	}
+
 	void CEquipment::init()
 	{
-
+		CStep* pStep = new CStep();
+		if (addStep(0x360, pStep) == 0) {
+			pStep->init();
+		}
+		else {
+			delete pStep;
+		}
 	}
 
 	void CEquipment::term()
 	{
-
+		for (auto item : m_mapStep) {
+			item.second->term();
+		}
 	}
 
 	void CEquipment::setID(int nID)
@@ -196,6 +224,27 @@
 		if (!equalBool(m_bVCREnable[0], bFlag)) {
 			m_bVCREnable[0] = bFlag;
 		}
+
+
+		// 以下根据信号做流程处理
+
+		// Equipment Mode Change Report
+		index = 0x360;
+		bFlag = isBitOn(pszData, size, ++index);
+		static int i;
+		i++;
+		if (i > 10) bFlag = TRUE;
+		if (i > 15) bFlag = FALSE;
+		if (i > 110) bFlag = TRUE;
+		if (i > 115) bFlag = FALSE;
+		//if (i == 12) bFlag = FALSE;
+		CStep* pStep = getStep(0x360);
+		if (pStep != nullptr) {
+			pStep->onSignal(bFlag);
+		}
+
+
+
 	}
 
 	BOOL CEquipment::isBitOn(const char* pszData, size_t size, int index)

--
Gitblit v1.9.3