From 1f5df45b8e213de70e91a7ca54d6e2219cd967ca Mon Sep 17 00:00:00 2001
From: darker <mr.darker@163.com>
Date: 星期二, 18 二月 2025 11:07:25 +0800
Subject: [PATCH] 1. 添加获取plc心跳修改状态
---
SourceCode/Bond/Servo/Model.cpp | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index c4e39d0..f7d8571 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -57,10 +57,45 @@
});
+ SECSListener listener;
+ listener.onEQOffLine = [&](void* pFrom) -> void {
+ LOGI("远程请求OffLine");
+ };
+ listener.onEQOnLine = [&](void* pFrom) -> void {
+ LOGI("远程请求OnLine");
+ };
+ listener.onCommand = [&](void* pFrom, const char* pszName, std::vector<CommandParameter>& params) -> void {
+ LOGI("onCommand:%s", pszName);
+ for (auto& item : params) {
+ LOGI("param:%s,%s", item.szName, item.szValue);
+ }
+ };
+ 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);
+
+ SERVO::MasterListener masterListener;
+ masterListener.onEqAlive = [&](void* pMaster, SERVO::CEquipment* pEquipment, BOOL bAlive) -> void {
+ LOGI("<CModel>Equipment onAlive:%d.\n", pEquipment->getName().c_str(),
+ bAlive ? _T("ON") : _T("OFF"));
+ notifyPtr(RX_CODE_EQ_ALIVE, pEquipment);
+ };
+ m_master.setListener(masterListener);
return 0;
}
@@ -69,6 +104,8 @@
{
m_hsmsPassive.term();
CLog::GetLog()->SetOnLogCallback(nullptr);
+ m_master.term();
+
return 0;
}
--
Gitblit v1.9.3