From 9b2d1e962bf802f75c44c1f5372fc4cf029e3f4e Mon Sep 17 00:00:00 2001
From: darker <mr.darker@163.com>
Date: 星期二, 11 二月 2025 11:11:13 +0800
Subject: [PATCH] 1. 添加SECS运行设置管理类
---
SourceCode/Bond/Servo/HsmsPassive.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 103 insertions(+), 1 deletions(-)
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 38ceda5..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);
}
@@ -64,6 +68,9 @@
void CHsmsPassive::setListener(SECSListener listener)
{
+ 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;
}
@@ -189,6 +196,12 @@
else if (nStream == 1 && pHeader->function == 13) {
replyEstablishCommunications(pMessage);
}
+ else if (nStream == 1 && pHeader->function == 15) {
+ replyOffLine(pMessage);
+ }
+ else if (nStream == 1 && pHeader->function == 17) {
+ replyOnLine(pMessage);
+ }
else if (nStream == 2 && pHeader->function == 13) {
replyEquipmentConstantRequest(pMessage);
}
@@ -200,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);
@@ -366,7 +382,44 @@
return 0;
}
-// S1F14
+// S1F15
+int CHsmsPassive::replyOffLine(IMessage* pRecv)
+{
+ if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
+ return ER_NOTSELECT;
+ }
+
+
+ // 交由上层应用来获取机器常量值
+ if (m_listener.onEQOffLine != nullptr) {
+ m_listener.onEQOffLine(this);
+ }
+
+
+ // 回复
+ replyAck(1, 16, pRecv->getHeader()->systemBytes, BYTE(0), "OFLACK");
+ return 0;
+}
+
+// S1F17
+int CHsmsPassive::replyOnLine(IMessage* pRecv)
+{
+ if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
+ return ER_NOTSELECT;
+ }
+
+
+ // 交由上层应用来获取机器常量值
+ if (m_listener.onEQOnLine != nullptr) {
+ m_listener.onEQOnLine(this);
+ }
+
+
+ // 回复
+ replyAck(1, 18, pRecv->getHeader()->systemBytes, BYTE(0), "ONLACK");
+ return 0;
+}
+
int CHsmsPassive::replyEstablishCommunications(IMessage* pRecv)
{
if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
@@ -553,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