From 3b557ae5d4bb96062d9ab66f877ca729f7891ffa Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 21 一月 2025 14:35:59 +0800
Subject: [PATCH] 1.SECS通讯,实现S1F41,接收EAP的Command,解释出参数列表,并回复。具体指令(Stop, Abort, Pause, Resume等)需要和机器端确认相关逻辑。
---
SourceCode/Bond/Servo/HsmsPassive.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index b77ee1a..39f7e68 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -38,7 +38,11 @@
m_bCimWorking = FALSE;
m_hCimWorkEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
m_nSessionId = 1;
+ m_listener.onEQOffLine = nullptr;
+ m_listener.onEQOnLine = nullptr;
+ m_listener.onCommand = nullptr;
m_listener.onEQConstantRequest = nullptr;
+ m_listener.onEQConstantSend = nullptr;
InitializeCriticalSection(&m_criticalSection);
}
@@ -66,6 +70,7 @@
{
m_listener.onEQOffLine = listener.onEQOffLine;
m_listener.onEQOnLine = listener.onEQOnLine;
+ m_listener.onCommand = listener.onCommand;
m_listener.onEQConstantRequest = listener.onEQConstantRequest;
m_listener.onEQConstantSend = listener.onEQConstantSend;
}
@@ -208,6 +213,9 @@
}
else if (nStream == 2 && pHeader->function == 37) {
replyEanbleDisableEventReport(pMessage);
+ }
+ else if (nStream == 2 && pHeader->function == 41) {
+ replyCommand(pMessage);
}
else if (nStream == 5 && pHeader->function == 3) {
replyEanbleDisableAlarmReport(pMessage);
@@ -598,6 +606,55 @@
return 0;
}
+// S2F41
+int CHsmsPassive::replyCommand(IMessage* pRecv)
+{
+ if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
+ return ER_NOTSELECT;
+ }
+ ISECS2Item* pBody = pRecv->getBody();
+ if (pBody == nullptr || pBody->getType() != SITYPE::A) ER_PARAM_ERROR;
+
+
+
+ BOOL bCheckData = FALSE;
+ const char* pszCmdName;
+ std::vector<CommandParameter> params;
+ {
+ ISECS2Item* pItemParams, *pItemParam;
+ ISECS2Item* pItem = pRecv->getBody();
+ if (pItem->getSubItemSize() < 2) goto MYREPLY;
+ if (!pItem->getSubItemString(0, pszCmdName)) goto MYREPLY;
+ pItemParams = pItem->getSubItem(1);
+ if (pItemParams == nullptr || pItemParams->getType() != SITYPE::L) goto MYREPLY;
+ for (int i = 0; i < pItemParams->getSubItemSize(); i++) {
+ const char* pszParamName, * pszParamValue;
+ pItemParam = pItemParams->getSubItem(i);
+ if (pItemParam != nullptr
+ && pItemParam->getSubItemString(0, pszParamName)
+ && pItemParam->getSubItemString(1, pszParamValue)) {
+ CommandParameter cp;
+ strcpy_s(cp.szName, 256, pszParamName);
+ strcpy_s(cp.szValue, 256, pszParamValue);
+ params.push_back(cp);
+ }
+ }
+ bCheckData = TRUE;
+ }
+
+
+ // 回调到应用层
+ if (bCheckData) {
+ if (m_listener.onCommand != nullptr) {
+ m_listener.onCommand(this, pszCmdName, params);
+ }
+ }
+
+MYREPLY:
+ replyAck(2, 42, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
+ return 0;
+}
+
// S5F3
int CHsmsPassive::replyEanbleDisableAlarmReport(IMessage* pRecv)
{
--
Gitblit v1.9.3