| ¶Ô±ÈÐÂÎļþ |
| | |
| | | // 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(); |
| | | } |