From e51c6d1360f9679dd8e4dd3379ce0db1886badbf Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 28 七月 2025 17:36:57 +0800
Subject: [PATCH] Merge branch 'EAPSimulator' into clh

---
 SourceCode/Bond/EAPSimulator/CLinkReportDlg.cpp |  205 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 205 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/EAPSimulator/CLinkReportDlg.cpp b/SourceCode/Bond/EAPSimulator/CLinkReportDlg.cpp
new file mode 100644
index 0000000..5655fa1
--- /dev/null
+++ b/SourceCode/Bond/EAPSimulator/CLinkReportDlg.cpp
@@ -0,0 +1,205 @@
+锘�// CLinkReportDlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "pch.h"
+#include "EAPSimulator.h"
+#include "CLinkReportDlg.h"
+#include "afxdialogex.h"
+#include <string.h>  
+#include <regex>
+#include "CLinkReportDetailDlg.h"
+
+
+// CLinkReportDlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CLinkReportDlg, CDialogEx)
+
+CLinkReportDlg::CLinkReportDlg(CWnd* pParent /*=nullptr*/)
+	: CDialogEx(IDD_DIALOG_LINK_REPORT, pParent)
+{
+
+}
+
+CLinkReportDlg::~CLinkReportDlg()
+{
+}
+
+void CLinkReportDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CLinkReportDlg, CDialogEx)
+	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CLinkReportDlg::OnListCtrlDoubleClick)
+	ON_BN_CLICKED(IDC_BUTTON_SEND, &CLinkReportDlg::OnBnClickedButtonSend)
+	ON_WM_DESTROY()
+END_MESSAGE_MAP()
+
+
+// CLinkReportDlg 娑堟伅澶勭悊绋嬪簭
+BOOL CLinkReportDlg::OnInitDialog()
+{
+	CDialogEx::OnInitDialog();
+
+	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
+	DWORD dwStyle = pListCtrl->GetExtendedStyle();
+	dwStyle |= LVS_EX_FULLROWSELECT;
+	dwStyle |= LVS_EX_GRIDLINES;
+	pListCtrl->SetExtendedStyle(dwStyle);
+	pListCtrl->ModifyStyle(0, LVS_SHOWSELALWAYS);
+
+	HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
+	ListView_SetImageList(pListCtrl->GetSafeHwnd(), imageList, LVSIL_SMALL);
+	pListCtrl->InsertColumn(0, _T(""), LVCFMT_RIGHT, 0);
+	pListCtrl->InsertColumn(1, _T("CEID"), LVCFMT_LEFT, 120);
+	pListCtrl->InsertColumn(2, _T("CD Name"), LVCFMT_LEFT, 120);
+	pListCtrl->InsertColumn(3, _T("Descriptions"), LVCFMT_LEFT, 180);
+	pListCtrl->InsertColumn(4, _T("Attached RPTID"), LVCFMT_LEFT, 120);
+	pListCtrl->SetColumnWidth(4, LVSCW_AUTOSIZE_USEHEADER);
+
+
+	CString strFile;
+	strFile.Format(_T("%s\\CollectionEventList.txt"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	loadCollectionEvents((LPTSTR)(LPCTSTR)strFile);
+
+	for (auto item : m_collectionEvents) {
+		int index = pListCtrl->InsertItem(pListCtrl->GetItemCount(), _T(""));
+		pListCtrl->SetItemData(index, (DWORD_PTR)item);
+		pListCtrl->SetItemText(index, 1, std::to_string(item->getEventId()).c_str());
+		pListCtrl->SetItemText(index, 2, item->getName().c_str());
+		pListCtrl->SetItemText(index, 3, item->getDescription().c_str());
+		pListCtrl->SetItemText(index, 4, item->getReportIdsText().c_str());
+	}
+
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+int CLinkReportDlg::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);
+		events.push_back(pEvent);
+	}
+
+	if (!events.empty()) {
+		clearAllCollectionEvent();
+		for (auto item : events) {
+			m_collectionEvents.push_back(item);
+		}
+	}
+
+
+	file.Close();
+	return 0;
+}
+
+std::vector<unsigned int> CLinkReportDlg::parseVidList(CString& strNums)
+{
+	// 1. 鍏堝幓鎺夊彲鑳藉嚭鐜扮殑绌虹櫧绗︼紙绌烘牸銆佸埗琛ㄧ绛夛級
+	strNums.Trim();
+
+	// 2锔�.
+	std::vector<unsigned int> result;
+	int i = 0;
+	CString strVid;
+	while (1) {
+		if (!AfxExtractSubString(strVid, (LPCTSTR)strNums, i, ',')) {
+			break;
+		}
+		if (!strVid.IsEmpty())                 // 闃插尽鎬ф鏌�
+			result.push_back(std::stoi((LPTSTR)(LPCTSTR)strVid));
+		i++;
+
+	}
+
+	return result;
+}
+
+void CLinkReportDlg::clearAllCollectionEvent()
+{
+	for (auto item : m_collectionEvents) {
+		delete item;
+	}
+	m_collectionEvents.clear();
+}
+
+void CLinkReportDlg::OnListCtrlDoubleClick(NMHDR* pNMHDR, LRESULT* pResult)
+{
+	LPNMITEMACTIVATE pNMItem = (LPNMITEMACTIVATE)pNMHDR;
+	int nItem = pNMItem->iItem;
+	if (nItem >= 0) {
+		CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
+		SERVO::CCollectionEvent* pEvent = (SERVO::CCollectionEvent*)pListCtrl->GetItemData(nItem);
+		CLinkReportDetailDlg dlg;
+		dlg.SetCollectionEvent(pEvent);
+		if (IDOK == dlg.DoModal()) {
+			pListCtrl->SetItemText(nItem, 4, pEvent->getReportIdsText().c_str());
+		}
+	}
+
+	*pResult = 0;
+}
+
+void CLinkReportDlg::OnBnClickedButtonSend()
+{
+	std::vector<SERVO::CCollectionEvent*> events;
+	CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST1);
+	POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
+	while (pos) {
+		int nItem = pListCtrl->GetNextSelectedItem(pos);
+		SERVO::CCollectionEvent* pEvent = (SERVO::CCollectionEvent*)pListCtrl->GetItemData(nItem);
+		events.push_back(pEvent);
+	}
+
+	std::map<unsigned int, std::vector<unsigned int>> mapEvent;
+	for (auto item : events) {
+		std::vector<unsigned int> RPTIDs = item->getReportIds();
+		mapEvent[item->getEventId()] = RPTIDs;
+	}
+
+
+	theApp.m_model.m_pHsmsActive->hsmsLinkEventReport(mapEvent);
+}
+
+void CLinkReportDlg::OnDestroy()
+{
+	CDialogEx::OnDestroy();
+	clearAllCollectionEvent();
+}

--
Gitblit v1.9.3