From 58b5bb07de4bcbf670db5ad79ff8b9bd7afc1e28 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期二, 17 六月 2025 11:35:47 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/Servo/CEFEM.cpp |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 099e2cd..33e6b29 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -22,6 +22,10 @@
 		m_pPort[3] = nullptr;
 		m_pAligner = nullptr;
 		m_pFliper = nullptr;
+		m_robotData.status = ROBOT_STATUS::Idle;
+		m_robotData.position = ROBOT_POSITION::Port1;
+		m_robotData.armState[0] = FALSE;
+		m_robotData.armState[1] = FALSE;
 	}
 
 	CEFEM::~CEFEM()
@@ -329,6 +333,11 @@
 		cmds[1].rcmd = static_cast<short>(SERVO::RCMD::Robot_home);
 
 		return robotCmds(cmds, 2, onWritedBlock);
+	}
+
+	RMDATA& CEFEM::getRobotMonitoringData()
+	{
+		return m_robotData;
 	}
 
 	void CEFEM::init()
@@ -692,6 +701,28 @@
 	{
 		__super::onReceiveLBData(pszData, size);
 
+		// 解释得到Robot状态
+		// 地址从(0x3500 - 0x3000)开始
+		int index = 0x500;
+		for (int i = 0; i < 6; i++) {
+			if (isBitOn(pszData, size, index + i)) {
+				m_robotData.status = (ROBOT_STATUS)i;
+				break;
+			}
+		}
+		index += 8;
+
+		for (int i = 0; i < 11; i++) {
+			if (isBitOn(pszData, size, index + i)) {
+				m_robotData.position = (ROBOT_POSITION)i;
+				break;
+			}
+		}
+		index += 16;
+		m_robotData.armState[0] = isBitOn(pszData, size, index);
+		m_robotData.armState[1] = isBitOn(pszData, size, index + 1);
+
+
 		for (unsigned int i = 0; i < 4; i++) {
 			if (m_pPort[i] != nullptr) {
 				m_pPort[i]->onReceiveLBData(pszData, size);

--
Gitblit v1.9.3