chenluhua1980
2026-01-10 ded981a2ac5dbb456bafce5468d7289bc45e313b
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)
{