LAPTOP-SNT8I5JK\Boounion
2025-07-28 bfe14e41fa5b07771d78af4511ba18d706bc23cc
SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -98,39 +98,21 @@
}
void CHsmsPassive::addReport(unsigned int id, const char* pszName)
void CHsmsPassive::linkEventReport(unsigned int CEID, unsigned int RPTID)
{
   Lock();
   REPORT report;
   report.id = id;
   strcpy_s(report.szName, REPORT_NAME_MAX, pszName);
   m_mapReport[id] = report;
   Unlock();
}
void CHsmsPassive::linkEventReport(unsigned int RPTID, unsigned int CEID)
{
   m_mapReportIdToCEID[RPTID] = CEID;
   SERVO::CCollectionEvent* pEvent = getEvent(CEID);
   SERVO::CReport* pReport = getReport(RPTID);
   if (pEvent != nullptr) {
      pEvent->setReport(pReport);
   }
}
void CHsmsPassive::unlinkEventReport(unsigned int CEID)
{
   for (auto it = m_mapReportIdToCEID.begin(); it != m_mapReportIdToCEID.end(); ) {
      if (it->second == CEID) {
         m_mapReportIdToCEID.erase(it++);  // 更新迭代器
      }
      else {
         ++it;
      }
   SERVO::CCollectionEvent* pEvent = getEvent(CEID);
   if (pEvent != nullptr) {
      pEvent->setReport(nullptr);
   }
}
unsigned int CHsmsPassive::getCEID(int RPTID)
{
   auto iter = m_mapReportIdToCEID.find(RPTID);
   if (iter != m_mapReportIdToCEID.end()) return iter->second;
   return 0;
}
SERVO::CReport* CHsmsPassive::defineReport(unsigned int RPTID, std::vector<unsigned int>& vids)
@@ -399,7 +381,7 @@
   if (!events.empty()) {
      clearAllCollectionEvent();
      for (auto item : events) {
         m_collectionEvent.push_back(item);
         m_collectionEvents.push_back(item);
      }
   }
@@ -410,15 +392,26 @@
std::vector<SERVO::CCollectionEvent*>& CHsmsPassive::getCollectionEvents()
{
   return m_collectionEvent;
   return m_collectionEvents;
}
void CHsmsPassive::clearAllCollectionEvent()
{
   for (auto item : m_collectionEvent) {
   for (auto item : m_collectionEvents) {
      delete item;
   }
   m_collectionEvent.clear();
   m_collectionEvents.clear();
}
SERVO::CCollectionEvent* CHsmsPassive::getEvent(unsigned short CEID)
{
   for (auto item : m_collectionEvents) {
      if (item->getEventId() == CEID) {
         return item;
      }
   }
   return nullptr;
}
std::vector<unsigned int> CHsmsPassive::parseVidList(CString& strNums)
@@ -527,6 +520,9 @@
      }
      else if (nStream == 2 && pHeader->function == 41) {
         replyCommand(pMessage);
      }
      else if (nStream == 2 && pHeader->function == 43) {
         replyConfigureSpooling(pMessage);
      }
      else if (nStream == 5 && pHeader->function == 3) {
         replyEanbleDisableAlarmReport(pMessage);
@@ -967,7 +963,7 @@
         else {
            for (int k = 0; k < prtCount; k++) {
               if (rptListItem->getSubItemU4(k, rptid)) {
                  linkEventReport(rptid, ceid);
                  linkEventReport(ceid, rptid);
               }
            }
         }
@@ -976,10 +972,10 @@
   // 检验结果是否正确
   for (auto item : m_mapReportIdToCEID) {
      LOGE("=== prtid:%d, ceid:%d", item.first, item.second);
   for (auto item : m_collectionEvents) {
      LOGE("=== ceid:%d, prtid:%d", item->getEventId(), item->getPortID());
   }
MYREPLY:
   replyAck(2, 36, pRecv->getHeader()->systemBytes, BYTE(0), "LRACK");
   return 0;
@@ -1069,6 +1065,51 @@
      }
   }
MYREPLY:
   replyAck(2, 42, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
   return 0;
}
// S2F43
int CHsmsPassive::replyConfigureSpooling(IMessage* pRecv)
{
   if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
      return ER_NOTSELECT;
   }
   ISECS2Item* pBody = pRecv->getBody();
   if (pBody == nullptr || pBody->getType() != SITYPE::L) ER_PARAM_ERROR;
   // 清空所有
   if (pBody->getSubItemSize() == 0) {
      m_spoolingConfig.clear();
      goto MYREPLY;
   }
   // 依次配置Stream
   for (int i = 0; i < pBody->getSubItemSize(); i++) {
      ISECS2Item* pStreamItem = pBody->getSubItem(i);
      ASSERT(pStreamItem);
      unsigned char STRID, FCNID;
      pStreamItem->getSubItemU1(0, STRID);
      ISECS2Item* pFcnItemList = pStreamItem->getSubItem(1);
      if (pFcnItemList->getSubItemSize() == 0) {
         m_spoolingConfig[STRID].clear();
      }
      else {
         for (int j = 0; j < pFcnItemList->getSubItemSize(); j++) {
            pFcnItemList->getSubItemU1(j, FCNID);
            m_spoolingConfig[STRID].insert(FCNID);
         }
      }
   }
   // 打印验证结果
   for (auto s : m_spoolingConfig) {
      LOGI("====> stream:%d", s.first);
      for (auto f : s.second) {
         LOGI("function:%d", f);
      }
   }
MYREPLY:
   replyAck(2, 42, pRecv->getHeader()->systemBytes, BYTE(0), "ERACK");
   return 0;
@@ -1193,10 +1234,18 @@
}
// S6F11
int CHsmsPassive::requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector<std::string>& values)
int CHsmsPassive::requestEventReportSend(unsigned int DATAID, unsigned int CEID, const std::vector<std::string>& values)
{
   if (m_pPassive == NULL || STATE::SELECTED != m_pPassive->getState()) {
      return ER_NOTSELECT;
   }
   SERVO::CCollectionEvent* pEvent = getEvent(CEID);
   if (pEvent == nullptr) {
      return ER_NO_EVENT;
   }
   if (pEvent == nullptr) {
      return ER_UNLINK_EVENT_REPORT;
   }
   Lock();
@@ -1207,10 +1256,10 @@
   ASSERT(pMessage);
   ISECS2Item* pItem = pMessage->getBody();
   pItem->addU4Item(DATAID, "DATAID");
   pItem->addU4Item(getCEID(RPTID), "CEID");
   pItem->addU4Item(CEID, "CEID");
   ISECS2Item* pItemList1 = pItem->addItem();
   ISECS2Item* pItemList2 = pItemList1->addItem();
   pItemList2->addU4Item(RPTID, "RPTID");
   pItemList2->addU4Item(pEvent->getPortID(), "RPTID");
   ISECS2Item* pItemList3 = pItemList2->addItem();
   for (auto item : values) {
      pItemList3->addItem(item.c_str(), "V");