From fd1333fbf52e00ff8f0b0d51ec0d707a66cc9141 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 16 六月 2025 11:20:16 +0800
Subject: [PATCH] 1.Robot状态和位置的监控,其中两个arm状态(是否有料),也作为调度的依据。

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

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 86cd158..3474d3e 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -331,6 +331,11 @@
 		return robotCmds(cmds, 2, onWritedBlock);
 	}
 
+	RMDATA& CEFEM::getRobotMonitoringData()
+	{
+		return m_robotData;
+	}
+
 	void CEFEM::init()
 	{
 		CEquipment::init();
@@ -643,6 +648,23 @@
 				delete pStep;
 			}
 		}
+
+		{
+			// FAC Data Report
+			CEqReadStep* pStep = new CEqReadStep(0x6301, 108 * 2,
+				[&](void* pFrom, int code, const char* pszData, size_t size) -> int {
+					if (code == ROK && pszData != nullptr && size > 0) {
+						decodePanelDataReport((CStep*)pFrom, pszData, size);
+					}
+					return -1;
+				});
+			pStep->setName(STEP_EQ_FAC_DATA_REPORT);
+			pStep->setProp("Port", (void*)1);
+			pStep->setWriteSignalDev(0x04d);
+			if (addStep(STEP_ID_FAC_DATA_REPORT, pStep) != 0) {
+				delete pStep;
+			}
+		}
 	}
 
 	// 必须要实现的虚函数,在此初始化Slot信息
@@ -675,6 +697,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