From bf55b2f3083cbfdeb83611b2fa2dd552bf5b0775 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 03 三月 2025 16:20:00 +0800
Subject: [PATCH] 1.开始处理Step属性值; 2.增加左侧master面板;

---
 SourceCode/Bond/Servo/CEquipment.cpp |   82 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 5fe849f..afd0c0e 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -15,11 +15,18 @@
 		m_bLocalAlarm = FALSE;
 		m_bAutoRecipeChange = FALSE;
 		m_bVCREnable[0] = FALSE;
+		m_pCclink = nullptr;
+		m_nBaseAlarmId = 0;
 		InitializeCriticalSection(&m_criticalSection);
 	}
 
 	CEquipment::~CEquipment()
 	{
+		for (auto item : m_mapStep) {
+			delete item.second;
+		}
+		m_mapStep.clear();
+
 		DeleteCriticalSection(&m_criticalSection);
 	}
 
@@ -29,14 +36,64 @@
 		m_listener.onCimStateChanged = listener.onCimStateChanged;
 	}
 
+	void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
+	{
+		m_pCclink = pCcLink;
+	}
+
+	void CEquipment::setBaseAlarmId(int nBaseId)
+	{
+		m_nBaseAlarmId = nBaseId;
+	}
+
+	int CEquipment::getBaseAlarmId()
+	{
+		return m_nBaseAlarmId;
+	}
+
+	void CEquipment::getProperties(std::vector<std::pair<std::string, std::string>>& container)
+	{
+		container.clear();
+		// 示例:将一些属性添加到容器
+		container.push_back(std::make_pair("DeviceName", "ServoMotor"));
+		container.push_back(std::make_pair("SerialNumber", "123456789"));
+		container.push_back(std::make_pair("Version", "1.0"));
+	}
+
+	std::map<unsigned int, CStep*>& CEquipment::getSteps()
+	{
+		return m_mapStep;
+	}
+
+	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;
+		pStep->setEquipment(this);
+		pStep->setCcLink(m_pCclink);
+		m_mapStep[addr] = pStep;
+		return 0;
+	}
+
 	void CEquipment::init()
 	{
-
+		for (auto item : m_mapStep) {
+			item.second->init();
+		}
 	}
 
 	void CEquipment::term()
 	{
-
+		for (auto item : m_mapStep) {
+			item.second->term();
+		}
 	}
 
 	void CEquipment::setID(int nID)
@@ -82,7 +139,7 @@
 
 	void CEquipment::setReadBitBlock(unsigned int start, unsigned int end)
 	{
-		m_blockReadBit.type = (unsigned int)DeviceType::LB;;
+		m_blockReadBit.type = (unsigned int)DeviceType::B;
 		m_blockReadBit.start = start;
 		m_blockReadBit.end = end;
 		m_blockReadBit.size = (m_blockReadBit.end - m_blockReadBit.start + 1) / 8;
@@ -131,12 +188,13 @@
 
 	void CEquipment::onReceiveLBData(const char* pszData, size_t size)
 	{
+		/*
 		TRACE("%s onReceiveLBData: %d bytes\n", m_strName.c_str(), size);
 		for (unsigned int i = 0; i < size; i++) {
 			if (pszData[i] != 0)
 				TRACE("%d[%x]\n", i, pszData[i]);
 		}
-
+		*/
 
 		// 以下解释和处理数据
 		BOOL bFlag;
@@ -196,6 +254,22 @@
 		if (!equalBool(m_bVCREnable[0], bFlag)) {
 			m_bVCREnable[0] = bFlag;
 		}
+
+
+		// 以下根据信号做流程处理
+		CStep* pStep;
+
+		// Equipment Mode Change Report(0x360)
+		// Equipment Status Change Report(0x361)
+		// Equipment Alarm Change Report(0x362 ~ 0x366)
+		for (int i = 0; i < 7; i++) {
+			index = 0x360 + i;;
+			bFlag = isBitOn(pszData, size, index);
+			pStep = getStep(index);
+			if (pStep != nullptr) {
+				pStep->onSignal(bFlag);
+			}
+		}
 	}
 
 	BOOL CEquipment::isBitOn(const char* pszData, size_t size, int index)

--
Gitblit v1.9.3