From c55e355700e462d281da22e49d22d5a81fdef183 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 03 七月 2025 15:26:08 +0800
Subject: [PATCH] 1.人工搬出后实时刷新界面,去掉小绿点;

---
 SourceCode/Bond/Servo/CEqStatusStep.cpp |   78 ++++++++++++++++++++++++++------------
 1 files changed, 53 insertions(+), 25 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEqStatusStep.cpp b/SourceCode/Bond/Servo/CEqStatusStep.cpp
index edf4572..6108c58 100644
--- a/SourceCode/Bond/Servo/CEqStatusStep.cpp
+++ b/SourceCode/Bond/Servo/CEqStatusStep.cpp
@@ -5,11 +5,11 @@
 
 
 namespace SERVO {
-	CEqStatusStep::CEqStatusStep() : CStep()
+	CEqStatusStep::CEqStatusStep() : CReadStep()
 	{
 		m_nStatusDev = 0;
 		for (int i = 0; i < STATUS_MAX; i++) {
-			m_nStatus[i] = 7;
+			m_nStatus[i] = 0;
 			m_nReasonCode[i] = 0;
 		}
 	
@@ -21,34 +21,62 @@
 
 	}
 
+	void CEqStatusStep::getAttributeVector(CAttributeVector& attrubutes)
+	{
+		CReadStep::getAttributeVector(attrubutes);
+
+		unsigned int weight = 31;
+		char szName[256];
+		for (int i = 0; i < STATUS_MAX; i++) {
+			sprintf_s(szName, 256, "Status %d", i + 1);
+			attrubutes.addAttribute(new CAttribute(szName,
+				std::to_string(m_nStatus[i]).c_str(), "", weight++));
+			sprintf_s(szName, 256, "Reason Code %d", i + 1);
+			attrubutes.addAttribute(new CAttribute(szName,
+				std::to_string(m_nReasonCode[i]).c_str(), "", weight++));
+		}
+
+		std::string strTemp;
+		attrubutes.addAttribute(new CAttribute("Status Dev",
+			("W" + CToolUnits::toHexString(m_nStatusDev, strTemp)).c_str(), "", weight++));
+	}
+
+	int CEqStatusStep::getStatus(unsigned int uint)
+	{
+		if (uint < STATUS_MAX) {
+			return m_nStatus[uint];
+		}
+
+		return -1;
+	}
 	int CEqStatusStep::onReadData()
 	{
-		CStep::onReadData();
+		CReadStep::onReadData();
 
 		char szBuffer[64];
 		int nRet = m_pCclink->ReadData2(m_station, DeviceType::W,
 			m_nStatusDev, 64, szBuffer);
-		if (0 == nRet) {
-			unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
-			if (unitId < STATUS_MAX) {
-				if (unitId == 0) {
-					m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4]);
-					m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4 + 2]);
-				}
-				else {
-					m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4]);
-					m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4 + 2]);
-				}
-
-				for (int i = 0; i < 64; i++) {
-					TRACE("bbb %d, %x\n", i, szBuffer[i]);
-				}
-				TRACE("cccc %d %d %d\n", unitId, m_nStatus[unitId], m_nReasonCode[unitId]);
-				std::string strTemp;
-				LOGI("<CEqStatusStep> Equipment Status Changed<Unit:%d, %s, ReasonCode=%d>\n",
-					unitId, getStatusDescription(unitId, strTemp).c_str(), m_nReasonCode[unitId]);
-			}
+		if (0 != nRet) {
+			return -1;
 		}
+
+		unsigned int unitId = (unsigned int)CToolUnits::toInt16(&szBuffer[0]);
+		if (unitId >= STATUS_MAX) {
+			return -2;
+		}
+
+		if (unitId == 0) {
+			m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4]);
+			m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + unitId * 4 + 2]);
+		}
+		else {
+			m_nStatus[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4]);
+			m_nReasonCode[unitId] = CToolUnits::toInt16(&szBuffer[2 + 3 * 2 + unitId * 4 + 2]);
+		}
+
+		std::string strTemp;
+		LOGI("<CEqStatusStep> Equipment Status Changed<Unit:%d, %s, ReasonCode=%d>\n",
+			unitId, getStatusDescription(unitId, strTemp).c_str(), m_nReasonCode[unitId]);
 
 
 		return 0;
@@ -56,7 +84,7 @@
 
 	int CEqStatusStep::onComplete()
 	{
-		CStep::onComplete();
+		CReadStep::onComplete();
 		LOGI("<CEqStatusStep> onComplete.");
 
 		return 0;
@@ -64,7 +92,7 @@
 
 	int CEqStatusStep::onTimeout()
 	{
-		CStep::onTimeout();
+		CReadStep::onTimeout();
 		LOGI("<CEqStatusStep> onTimeout.");
 
 		return 0;

--
Gitblit v1.9.3