| | |
| | | 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; |
| | |
| | | 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) |
| | |
| | | |
| | | clearAllVariabel(); |
| | | clearAllReport(); |
| | | clearAllCollectionEvent(); |
| | | |
| | | return 0; |
| | | } |