chenluhua1980
2026-01-08 2be286ac19bf2bb00e27f556e8b2cc292a58bd09
SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -1,9 +1,9 @@
#include "pch.h"
#include "pch.h"
#include "CHsmsActive.h"
#include "Log.h"
static unsigned int DATAID = 1;
static unsigned short DATAID = 1;
CHsmsActive::CHsmsActive()
{
@@ -64,13 +64,17 @@
      HEADER* pHeader = pMessage->getHeader();
      int nStream = (pHeader->stream & 0x7F);
      TRACE("收到消息 S%dF%d================\n", pHeader->stream & 0x7F, pHeader->function);
      TRACE("收到消息 S%dF%d================\n", pHeader->stream & 0x7F, pHeader->function);
      TRACE("Body:%s\n", pMessage->toString());
      LOGI("onRecvDataMessage(%s).", pMessage->toString());
      if (nStream == 5 && pHeader->function == 1) {
         // S5F1
         replyAck(5, 2, pMessage->getHeader()->systemBytes, 0, _T("ACK0"));
      }
      else if (nStream == 6 && pHeader->function == 11) {
         // S5F1
         replyAck(6, 12, pMessage->getHeader()->systemBytes, 0, _T("ACK0"));
      }
   };
@@ -345,12 +349,50 @@
   return hsmsCarrierActionRequest(DATAID, "CarrierRelease", pszCarrierId, PTN);
}
int CHsmsActive::hsmsProceedWithSlotMap(unsigned int DATAID,
   const char* pszCarrierId,
   unsigned char PTN,
   const char* pszLotId,
   const std::vector<std::string>& panelIds,
   const std::vector<unsigned char>& slotMap)
{
   IMessage* pMessage = nullptr;
   int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 3 | REPLY, 17, ++m_nSystemByte);
   if (nRet != 0 || pMessage == nullptr) {
      return nRet;
   }
   pMessage->getBody()->addU4Item(DATAID, "DATAID");
   pMessage->getBody()->addItem("ProceedWithSlotMap", "CARRIERACTION");
   pMessage->getBody()->addItem(pszCarrierId, "CARRIERID");
   pMessage->getBody()->addU1Item(PTN, "PTN");
   // Extended params (currently not parsed by Servo side): { LOTID, PANELID_LIST, SLOTMAP_LIST }
   ISECS2Item* pParams = pMessage->getBody()->addItem(); // L
   pParams->addItem(pszLotId != nullptr ? pszLotId : "", "LOTID");
   ISECS2Item* pPanelList = pParams->addItem(); // L
   for (const auto& id : panelIds) {
      pPanelList->addItem(id.c_str(), "PANELID");
   }
   ISECS2Item* pSlotMapList = pParams->addItem(); // L
   for (auto v : slotMap) {
      pSlotMapList->addU1Item(v, "SLOTSTATE");
   }
   m_pActive->sendMessage(pMessage);
   HSMS_Destroy1Message(pMessage);
   return 0;
}
int CHsmsActive::hsmsPRJobMultiCreate(std::vector<SERVO::CProcessJob*>& pjs)
{
   IMessage* pMessage = nullptr;
   int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 16 | REPLY, 15, ++m_nSystemByte);
   char szMF[32] = {14};
   pMessage->getBody()->addU4Item(++DATAID, "DATAID");
   pMessage->getBody()->addU2Item(++DATAID, "DATAID");
   auto itemPjs = pMessage->getBody()->addItem();
   for (auto pj : pjs) {
      auto itemPj = itemPjs->addItem();
@@ -381,12 +423,56 @@
   return 0;
}
int CHsmsActive::hsmsCreateControlJob(const char* pszControlJobId, std::vector<std::string>& processJobIds)
{
   char szBuffer[256];
   sprintf_s(szBuffer, 256, "ControlJob:%s>", pszControlJobId);
   IMessage* pMessage = nullptr;
   int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 14 | REPLY, 9, ++m_nSystemByte);
   pMessage->getBody()->addItem(szBuffer, "OBJSPEC");
   pMessage->getBody()->addItem("ControlJob", "OBJTYPE");
   auto itemAttrs = pMessage->getBody()->addItem();
   {
      auto itemAttr = itemAttrs->addItem();
      itemAttr->addItem("Priority", "ATTRID");
      itemAttr->addU1Item(8, "ATTRDATA");
   }
   {
      auto itemAttr = itemAttrs->addItem();
      itemAttr->addItem("weight", "ATTRID");
      itemAttr->addF4Item(60.5, "ATTRDATA");
   }
   {
      auto itemAttr = itemAttrs->addItem();
      itemAttr->addItem("tel", "ATTRID");
      itemAttr->addItem("15919875007", "ATTRDATA");
   }
   {
      auto itemAttr = itemAttrs->addItem();
      itemAttr->addItem("PRJOBLIST", "ATTRID");
      auto itemProcessJobs = itemAttr->addItem();
      for (auto& item : processJobIds) {
         itemProcessJobs->addItem(item.c_str(), "");
      }
   }
   m_pActive->sendMessage(pMessage);
   HSMS_Destroy1Message(pMessage);
   return 0;
}
int CHsmsActive::replyAck0(IMessage* pMessage)
{
   return 0;
}
// 通用的reply ack函数
// 通用的reply ack函数
void CHsmsActive::replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName)
{
   IMessage* pMessage = NULL;