From 247a2a9a9f3d699df42a009bf124d3b536ad6b37 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 25 七月 2025 14:23:55 +0800
Subject: [PATCH] 1.Master端,Line Event Report功能修改完善,并通过EAP模拟测试OK;
---
SourceCode/Bond/Servo/CCollectionEvent.h | 3 +
SourceCode/Bond/Servo/HsmsPassive.h | 33 ++++-------
SourceCode/Bond/Servo/HsmsPassive.cpp | 77 +++++++++++++------------
SourceCode/Bond/Servo/CCollectionEvent.cpp | 16 +++++
4 files changed, 70 insertions(+), 59 deletions(-)
diff --git a/SourceCode/Bond/Servo/CCollectionEvent.cpp b/SourceCode/Bond/Servo/CCollectionEvent.cpp
index 53794c9..a0b7773 100644
--- a/SourceCode/Bond/Servo/CCollectionEvent.cpp
+++ b/SourceCode/Bond/Servo/CCollectionEvent.cpp
@@ -49,6 +49,22 @@
return TRUE;
}
+ void CCollectionEvent::setReport(CReport* pReport)
+ {
+ m_rptids.clear();
+ m_reports.clear();
+ if (pReport != nullptr) {
+ m_rptids.push_back(pReport->getReportId());
+ m_reports.push_back(pReport);
+ }
+ }
+
+ unsigned int CCollectionEvent::getPortID()
+ {
+ if (m_reports.empty()) return -1;
+ return m_reports.front()->getReportId();
+ }
+
BOOL CCollectionEvent::deleteReport(unsigned int nReportId)
{
BOOL bDelete = FALSE;
diff --git a/SourceCode/Bond/Servo/CCollectionEvent.h b/SourceCode/Bond/Servo/CCollectionEvent.h
index 55e4c1f..bfad5fb 100644
--- a/SourceCode/Bond/Servo/CCollectionEvent.h
+++ b/SourceCode/Bond/Servo/CCollectionEvent.h
@@ -21,6 +21,9 @@
BOOL deleteReport(unsigned int nReportId);
CReport* getReport(unsigned int nReportId);
+ /* 如果一个CEID只有一个Report的场景,调用此函数设置或取消 */
+ void setReport(CReport* pReport);
+ unsigned int getPortID();
private:
unsigned int m_nCEID;
std::string m_strName;
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 3f52f0e..77e607c 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/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)
@@ -967,7 +960,7 @@
else {
for (int k = 0; k < prtCount; k++) {
if (rptListItem->getSubItemU4(k, rptid)) {
- linkEventReport(rptid, ceid);
+ linkEventReport(ceid, rptid);
}
}
}
@@ -976,10 +969,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;
@@ -1193,10 +1186,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 +1208,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");
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 7dbbbf6..6b7fe92 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -15,10 +15,12 @@
#define VALUE_NAME_MAX 64
-#define ER_NOERROR 0
-#define ER_NOTSELECT -1
-#define ER_BUSY -2
-#define ER_PARAM_ERROR -3
+#define ER_NOERROR 0
+#define ER_NOTSELECT -1
+#define ER_BUSY -2
+#define ER_PARAM_ERROR -3
+#define ER_NO_EVENT -4
+#define ER_UNLINK_EVENT_REPORT -5
/*
@@ -91,16 +93,11 @@
/* 设置软件版本号 最大长度 20 bytes */
void setSoftRev(const char* pszRev);
- /* 添加Report */
- void addReport(unsigned int id, const char* pszName);
-
// 连接Report
- void linkEventReport(unsigned int RPTID, unsigned int CEID);
+ void linkEventReport(unsigned int CEID, unsigned int RPTID);
// 取消连接report
void unlinkEventReport(unsigned int CEID);
-
- unsigned int getCEID(int RPTID);
// define Report
SERVO::CReport* defineReport(unsigned int RPTID, std::vector<unsigned int>& vids);
@@ -133,7 +130,10 @@
// 取消/删除所有CollectionEvent
void clearAllCollectionEvent();
+ // 取得CCollectionEvent
+ SERVO::CCollectionEvent* getEvent(unsigned short CEID);
+ // 取得Report
SERVO::CReport* getReport(int rptid);
void setListener(SECSListener listener);
@@ -147,7 +147,7 @@
/* request开头的函数为主动发送数据的函数 */
int requestAreYouThere();
int requestAlarmReport(int ALCD, int ALID, const char* ALTX);
- int requestEventReportSend(unsigned int DATAID, unsigned int RPTID, const std::vector<std::string>& values);
+ int requestEventReportSend(unsigned int DATAID, unsigned int CEID, const std::vector<std::string>& values);
private:
void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
@@ -196,15 +196,6 @@
unsigned m_nCimWorkThrdaddr;
private:
- // RPTID to CEID
- std::map<unsigned int, unsigned int> m_mapReportIdToCEID;
-
- // RPTID to Report
- std::map<unsigned int, REPORT> m_mapReport;
-
- // VID to Report
- std::map<unsigned int, VALUE> m_mapValue;
-
// CVariable vector
std::vector<SERVO::CVariable*> m_variabels;
@@ -212,6 +203,6 @@
std::vector<SERVO::CReport*> m_reports;
// CollectionEvent vector
- std::vector<SERVO::CCollectionEvent*> m_collectionEvent;
+ std::vector<SERVO::CCollectionEvent*> m_collectionEvents;
};
--
Gitblit v1.9.3