From ded981a2ac5dbb456bafce5468d7289bc45e313b Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 10 一月 2026 21:07:48 +0800
Subject: [PATCH] 1.S7F5查询PPID
---
SourceCode/Bond/Servo/HsmsPassive.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index df773b6..301cf6a 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -3,6 +3,7 @@
#include "Log.h"
#include "Model.h"
#include "Common.h"
+#include "RecipeManager.h"
#include <time.h>
#include <iostream>
#include <time.h>
@@ -11,6 +12,7 @@
#include <algorithm>
#include <set>
#include <regex>
+#include <sstream>
// ControlState values (keep in sync with Model::ControlState / VariableList.txt)
static constexpr uint8_t kControlStateOnlineRemote = 5;
@@ -587,8 +589,8 @@
Lock();
int maxId = 0;
for (auto v : m_variabels) {
- if (v != nullptr && v->getVarialbleId() > maxId) {
- maxId = v->getVarialbleId();
+ if (v != nullptr && static_cast<int>(v->getVarialbleId()) > maxId) {
+ maxId = static_cast<int>(v->getVarialbleId());
}
}
outId = maxId + 1;
@@ -1373,6 +1375,9 @@
else if (nStream == 7 && pHeader->function == 17) {
replyDeletePPID(pMessage);
}
+ else if (nStream == 7 && pHeader->function == 5) {
+ replyProcessProgramRequest(pMessage);
+ }
else if (nStream == 10 && pHeader->function == 3) {
replyTerminalDisplay(pMessage);
}
@@ -1412,7 +1417,12 @@
return -1;
}
- int nBufSize = file.GetLength();
+ ULONGLONG len = file.GetLength();
+ if (len > INT_MAX) {
+ file.Close();
+ return -1;
+ }
+ int nBufSize = static_cast<int>(len);
char* pszBuffer = new char[nBufSize];
file.Read(pszBuffer, nBufSize);
file.Close();
@@ -2585,6 +2595,48 @@
return 0;
}
+// S7F5 Process Program Request -> reply S7F6 with PPID + PPBODY
+int CHsmsPassive::replyProcessProgramRequest(IMessage* pRecv)
+{
+ if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
+ return ER_NOTSELECT;
+ }
+ ISECS2Item* pBody = pRecv->getBody();
+ const char* pszPPID = nullptr;
+ if (pBody == nullptr || !pBody->getString(pszPPID) || pszPPID == nullptr) {
+ return ER_PARAM_ERROR;
+ }
+ std::string ppid(pszPPID);
+ std::string ppbody;
+ // 绠�鍗曡仛鍚堬細浠� RecipeManager 鍙栬澶囬厤鏂癸紝鎷兼垚鏂囨湰
+ auto recipeInfo = RecipeManager::getInstance().getRecipeByPPID(ppid);
+ if (!recipeInfo.strPPID.empty()) {
+ for (const auto& dev : recipeInfo.vecDeviceList) {
+ if (!ppbody.empty()) ppbody.append("\n");
+ ppbody.append(dev.strDeviceName);
+ ppbody.append(",");
+ ppbody.append(std::to_string(dev.nRecipeID));
+ ppbody.append(",");
+ ppbody.append(dev.strRecipeName);
+ // 闄勫姞鍙傛暟澶у皬淇℃伅锛堢洰鍓嶇己灏戝叿浣撳弬鏁板垪琛級
+ ppbody.append(",paramsSize=");
+ ppbody.append(std::to_string(dev.paramsRawData.size()));
+ }
+ }
+
+ IMessage* pMessage = nullptr;
+ if (HSMS_Create1Message(pMessage, m_nSessionId, 7, 6, pRecv->getHeader()->systemBytes) != 0 || pMessage == nullptr) {
+ return ER_CREATED_MESSAGE;
+ }
+ ISECS2Item* pRspBody = pMessage->getBody(); // top-level L:2
+ pRspBody->addItem(ppid.c_str(), "PPID");
+ pRspBody->addItem(ppbody.c_str(), "PPBODY");
+ m_pPassive->sendMessage(pMessage);
+ LogSecsMessageBrief("<HSMS>[SEND]", pMessage);
+ HSMS_Destroy1Message(pMessage);
+ return 0;
+}
+
// S7F19
int CHsmsPassive::replyQueryPPIDList(IMessage* pRecv)
{
--
Gitblit v1.9.3