From 2d7e131c2e7f547df8d5e0d56fcea85cd49c712e Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 21 二月 2025 14:17:15 +0800
Subject: [PATCH] 1.增加Equipment Status(机器和机器单元状态)获取;

---
 SourceCode/Bond/Servo/CEquipment.cpp |   41 ++++++++++++++++++++++-------------------
 1 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index 2a592fa..d3bc8da 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -15,6 +15,7 @@
 		m_bLocalAlarm = FALSE;
 		m_bAutoRecipeChange = FALSE;
 		m_bVCREnable[0] = FALSE;
+		m_pCclink = nullptr;
 		InitializeCriticalSection(&m_criticalSection);
 	}
 
@@ -32,6 +33,11 @@
 	{
 		m_listener.onAlive = listener.onAlive;
 		m_listener.onCimStateChanged = listener.onCimStateChanged;
+	}
+
+	void CEquipment::setCcLink(CCCLinkIEControl* pCcLink)
+	{
+		m_pCclink = pCcLink;
 	}
 
 	void CEquipment::getProperties(std::vector<std::pair<std::string, std::string>>& container)
@@ -54,18 +60,15 @@
 	{
 		auto iter = m_mapStep.find(addr);
 		if (iter != m_mapStep.end()) return -1;
+		pStep->setCcLink(m_pCclink);
 		m_mapStep[addr] = pStep;
 		return 0;
 	}
 
 	void CEquipment::init()
 	{
-		CStep* pStep = new CStep();
-		if (addStep(0x360, pStep) == 0) {
-			pStep->init();
-		}
-		else {
-			delete pStep;
+		for (auto item : m_mapStep) {
+			item.second->init();
 		}
 	}
 
@@ -119,7 +122,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;
@@ -168,12 +171,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;
@@ -236,24 +240,23 @@
 
 
 		// 以下根据信号做流程处理
+		CStep* pStep;
 
 		// 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);
+		bFlag = isBitOn(pszData, size, index);
+		pStep = getStep(index);
 		if (pStep != nullptr) {
 			pStep->onSignal(bFlag);
 		}
 
-
-
+		// Equipment Status Change Report
+		index = 0x361;
+		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