From 2a803976ed12e59f3e082e7c08941ef5004e6ea1 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期二, 20 五月 2025 11:40:10 +0800
Subject: [PATCH] 1. 添加机器臂命令配置界面

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

diff --git a/SourceCode/Bond/Servo/CEFEM.cpp b/SourceCode/Bond/Servo/CEFEM.cpp
index 99e9b0c..3a277f3 100644
--- a/SourceCode/Bond/Servo/CEFEM.cpp
+++ b/SourceCode/Bond/Servo/CEFEM.cpp
@@ -1,5 +1,6 @@
 #include "stdafx.h"
 #include "CEFEM.h"
+#include "Log.h"
 
 
 #define ADD_EQ_CASSETTE_TRANSFER_STATE_STEP(name,ws,index,psd) {				\
@@ -56,6 +57,73 @@
 		if (index < 2) {
 			m_pArmTray[index] = pArmTray;
 		}
+	}
+
+	int CEFEM::robotCmd(ROBOT_CMD_PARAM& robotCmdParam, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EFEM_ROBOT_CMD);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+		LOGI("<CEFEM-%s>准备发送RobotCmd<%d>", m_strName.c_str(), (int)robotCmdParam.rcmd);
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx((const char*)&robotCmdParam, ROBOT_CMD_PARAM_SIZE, onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx((const char*)&robotCmdParam, ROBOT_CMD_PARAM_SIZE, [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CEFEM-%s>发送RobotCmd成功.", m_strName.c_str());
+				}
+				else {
+					LOGI("<CEFEM-%s>发送RobotCmd失败,code:%d", m_strName.c_str(), code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
+	}
+
+	int CEFEM::robotCmds(ROBOT_CMD_PARAM* robotCmdParam, unsigned int count, ONWRITED onWritedBlock/* = nullptr*/)
+	{
+		SERVO::CEqWriteStep* pStep = (SERVO::CEqWriteStep*)getStepWithName(STEP_EFEM_ROBOT_CMD);
+		if (pStep == nullptr) {
+			return -1;
+		}
+
+
+		// 平铺到内存中,如果ROBOT_CMD_PARAM不是4的整数倍,只能一个一个复制
+		std::string strLog = "准备发送RobotCmds<";
+		char szBuffer[ROBOT_CMD_PARAM_SIZE * 4];
+		for (int i = 0; i < min(4, count); i++) {
+			memcpy(&szBuffer[i * ROBOT_CMD_PARAM_SIZE], (robotCmdParam + i), ROBOT_CMD_PARAM_SIZE);
+			strLog += std::to_string((robotCmdParam + i)->rcmd);
+			strLog += ",";
+			LOGI("%d", (robotCmdParam + 1)->rcmd);
+		}
+		strLog += ">.";
+		LOGI("<CEFEM-%s>%s", m_strName.c_str(), strLog.c_str());
+
+
+		if (onWritedBlock != nullptr) {
+			pStep->writeDataEx(szBuffer, ROBOT_CMD_PARAM_SIZE * min(4, count), onWritedBlock);
+		}
+		else {
+			pStep->writeDataEx(szBuffer, ROBOT_CMD_PARAM_SIZE * min(4, count), [&](int code) -> int {
+				if (code == WOK) {
+					LOGI("<CEquipment-%s>发送RobotCmdS成功.", m_strName.c_str());
+				}
+				else {
+					LOGI("<CEquipment-%s>发送RobotCmds失败,code:%d", m_strName.c_str(), code);
+				}
+
+				return 0;
+				});
+		}
+
+		return 0;
 	}
 
 	void CEFEM::init()
@@ -364,6 +432,28 @@
 				}
 			}
 		}
+
+		{
+			// Dispatching Mode Change Command
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(STEP_EQ_DISPATCHINT_MODE_CHANGE);
+			pStep->setWriteSignalDev(0x071);
+			pStep->setDataDev(0x5c6);
+			if (addStep(STEP_ID_DISPATCHING_MODE_CHANGE_REPLY, pStep) != 0) {
+				delete pStep;
+			}
+		}
+
+		{
+			// Robot CMD
+			CEqWriteStep* pStep = new CEqWriteStep();
+			pStep->setName(STEP_EFEM_ROBOT_CMD);
+			pStep->setWriteSignalDev(0x14D);
+			pStep->setDataDev(0x90a);
+			if (addStep(STEP_ID_ROBOT_CMD_REPLY, pStep) != 0) {
+				delete pStep;
+			}
+		}
 	}
 
 	int CEFEM::onStepEvent(CStep* pStep, int code)

--
Gitblit v1.9.3