From 789af4f4a7baee07bd6c2c03588afcb19555343b Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期三, 16 七月 2025 14:00:32 +0800
Subject: [PATCH] 1.CollectionEvent列表从文件加载,界面上显示;
---
SourceCode/Bond/Servo/HsmsPassive.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 1 deletions(-)
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index a40a131..20334e8 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -282,7 +282,7 @@
std::vector<SERVO::CReport*> reports;
int index;
CString strLine, strVariable;
- CString strId, strName, strFormat, strRemark;
+ CString strId;
while (file.ReadString(strLine)) {
if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
continue;
@@ -324,12 +324,95 @@
return m_reports;
}
+SERVO::CReport* CHsmsPassive::getReport(int rptid)
+{
+ for (auto item : m_reports) {
+ if (item->getReportId() == rptid) {
+ return item;
+ }
+ }
+
+ return nullptr;
+}
+
void CHsmsPassive::clearAllReport()
{
for (auto item : m_reports) {
delete item;
}
m_reports.clear();
+}
+
+int CHsmsPassive::loadCollectionEvents(const char* pszFilepath)
+{
+ CStdioFile file;
+ if (!file.Open(pszFilepath, CFile::modeRead)) {
+ return -1;
+ }
+
+ std::regex pattern("^\\d+,[^,]*,[^,]*,\\(\\d+(,\\d+)*\\).*"); // 鍖归厤浠ユ暟瀛�+閫楀彿寮�澶寸殑瀛楃涓�
+ std::vector<SERVO::CCollectionEvent*> events;
+ int index, last;
+ CString strLine, strRPTIDs;
+ CString strId, strName, strDescription;
+ while (file.ReadString(strLine)) {
+ if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
+ continue;
+ }
+
+ last = 0;
+ index = strLine.Find(",", last);
+ if (index < 0) continue;
+ strId = strLine.Left(index);
+ last = index + 1;
+
+ index = strLine.Find(",", last);
+ if (index < 0) continue;
+ strName = strLine.Mid(last, index - last);
+ last = index + 1;
+
+ index = strLine.Find(",", last);
+ if (index < 0) continue;
+ strDescription = strLine.Mid(last, index - last);
+ strRPTIDs = strLine.Right(strLine.GetLength() - index - 1);
+ strRPTIDs.Delete(0);
+ strRPTIDs.Delete(strRPTIDs.GetLength() - 1);
+ auto prtids = parseVidList(strRPTIDs);
+
+ SERVO::CCollectionEvent* pEvent = new SERVO::CCollectionEvent(
+ atoi(strId), (LPTSTR)(LPCTSTR)strName, (LPTSTR)(LPCTSTR)strDescription, prtids);
+ for (auto rptid : prtids) {
+ SERVO::CReport* pReport = getReport(rptid);
+ if (pReport != nullptr) {
+ pEvent->addReport(pReport);
+ }
+ }
+ events.push_back(pEvent);
+ }
+
+ if (!events.empty()) {
+ clearAllCollectionEvent();
+ for (auto item : events) {
+ m_collectionEvent.push_back(item);
+ }
+ }
+
+
+ file.Close();
+ return 0;
+}
+
+std::vector<SERVO::CCollectionEvent*>& CHsmsPassive::getCollectionEvents()
+{
+ return m_collectionEvent;
+}
+
+void CHsmsPassive::clearAllCollectionEvent()
+{
+ for (auto item : m_collectionEvent) {
+ delete item;
+ }
+ m_collectionEvent.clear();
}
std::vector<unsigned int> CHsmsPassive::parseVidList(CString& strNums)
@@ -487,6 +570,7 @@
clearAllVariabel();
clearAllReport();
+ clearAllCollectionEvent();
return 0;
}
--
Gitblit v1.9.3