From ccbda3e4f7ed430843fbc0190e8ee0d0f0e3a721 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 21 一月 2025 11:06:16 +0800
Subject: [PATCH] 1.SECS实现Off-Line和On-Line消息处理回调应用层,如何切换状态需待和机器端确定。

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

diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index c4e39d0..d9cf032 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -57,6 +57,27 @@
 	});
 
 
+	SECSListener listener;
+	listener.onEQOffLine = [&](void* pFrom) -> void {
+		LOGI("远程请求OffLine");
+	};
+	listener.onEQOnLine = [&](void* pFrom) -> void {
+		LOGI("远程请求OnLine");
+	};
+	listener.onEQConstantRequest = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
+		// 在此填充常量值,目前仅是加1后返回
+		for (auto& item : eqcs) {
+			sprintf_s(item.szValue, 256, "Test%d", item.id+1);
+		}
+	};
+	listener.onEQConstantSend = [&](void* pFrom, std::vector<EQConstant>& eqcs) -> void {
+		// 在此保存和设置机器常量值
+		for (auto& item : eqcs) {
+			LOGI("onEQConstantRequest: %d, %s", item.id, item.szValue);
+		}
+	};
+
+	m_hsmsPassive.setListener(listener);
 	m_hsmsPassive.setEquipmentModelType((LPTSTR)(LPCTSTR)strModeType);
 	m_hsmsPassive.setSoftRev((LPTSTR)(LPCTSTR)strSoftRev);
 	m_hsmsPassive.init(this, "APP", 7000);

--
Gitblit v1.9.3