From 8860b7e63527fad69f15944d340b7158edde1bed Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 19 七月 2025 16:10:39 +0800
Subject: [PATCH] 1.Define Report功能测试,EAP模拟

---
 SourceCode/Bond/Servo/HsmsPassive.h                       |   13 -
 SourceCode/Bond/EAPSimulator/CDefineReportsDlg.h          |   40 ++++
 SourceCode/Bond/EAPSimulator/CAddIDSDlg.h                 |   32 +++
 SourceCode/Bond/EAPSimulator/CHsmsActive.h                |    5 
 SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h            |    1 
 SourceCode/Bond/Servo/HsmsPassive.cpp                     |   75 ++++---
 SourceCode/Bond/EAPSimulator/CDefineReportsDlg.cpp        |  193 +++++++++++++++++++++
 SourceCode/Bond/EAPSimulator/EAPSimulator.rc              |    0 
 SourceCode/Bond/Servo/Model.cpp                           |    2 
 SourceCode/Bond/Servo/ServoDlg.cpp                        |    2 
 SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters |   12 +
 SourceCode/Bond/EAPSimulator/CHsmsActive.cpp              |   21 ++
 SourceCode/Bond/EAPSimulator/Resource.h                   |   16 +
 SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp          |    9 +
 SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj         |    4 
 SourceCode/Bond/EAPSimulator/CAddIDSDlg.cpp               |   65 +++++++
 SourceCode/Bond/Servo/CBonder.cpp                         |    2 
 17 files changed, 447 insertions(+), 45 deletions(-)

diff --git a/SourceCode/Bond/EAPSimulator/CAddIDSDlg.cpp b/SourceCode/Bond/EAPSimulator/CAddIDSDlg.cpp
new file mode 100644
index 0000000..d11ccf3
--- /dev/null
+++ b/SourceCode/Bond/EAPSimulator/CAddIDSDlg.cpp
@@ -0,0 +1,65 @@
+锘�// CAddIDSDlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "pch.h"
+#include "EAPSimulator.h"
+#include "CAddIDSDlg.h"
+#include "afxdialogex.h"
+
+
+// CAddIDSDlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CAddIDSDlg, CDialogEx)
+
+CAddIDSDlg::CAddIDSDlg(CWnd* pParent /*=nullptr*/)
+	: CDialogEx(IDD_DIALOG_ADD_IDS, pParent)
+{
+	m_nId = 0;
+}
+
+CAddIDSDlg::~CAddIDSDlg()
+{
+}
+
+void CAddIDSDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CAddIDSDlg, CDialogEx)
+	ON_BN_CLICKED(IDOK, &CAddIDSDlg::OnBnClickedOk)
+END_MESSAGE_MAP()
+
+
+// CAddIDSDlg 娑堟伅澶勭悊绋嬪簭
+
+void CAddIDSDlg::SetTitle(const char* pszTitle)
+{
+	m_strTitle = pszTitle;
+}
+
+BOOL CAddIDSDlg::OnInitDialog()
+{
+	CDialogEx::OnInitDialog();
+
+	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+	SetWindowText(m_strTitle);
+	SetDlgItemText(IDC_GROUP_IDS, m_strTitle);
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+unsigned int CAddIDSDlg::GetId()
+{
+	return m_nId;
+}
+
+
+void CAddIDSDlg::OnBnClickedOk()
+{
+	m_nId = GetDlgItemInt(IDC_EDIT_ID);
+
+	CDialogEx::OnOK();
+}
diff --git a/SourceCode/Bond/EAPSimulator/CAddIDSDlg.h b/SourceCode/Bond/EAPSimulator/CAddIDSDlg.h
new file mode 100644
index 0000000..1bf0c8f
--- /dev/null
+++ b/SourceCode/Bond/EAPSimulator/CAddIDSDlg.h
@@ -0,0 +1,32 @@
+锘�#pragma once
+
+
+// CAddIDSDlg 瀵硅瘽妗�
+
+class CAddIDSDlg : public CDialogEx
+{
+	DECLARE_DYNAMIC(CAddIDSDlg)
+
+public:
+	CAddIDSDlg(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CAddIDSDlg();
+	void SetTitle(const char* pszTitle);
+	unsigned int GetId();
+
+private:
+	CString m_strTitle;
+	unsigned int m_nId;
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_DIALOG_ADD_IDS };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	virtual BOOL OnInitDialog();
+	afx_msg void OnBnClickedOk();
+};
diff --git a/SourceCode/Bond/EAPSimulator/CDefineReportsDlg.cpp b/SourceCode/Bond/EAPSimulator/CDefineReportsDlg.cpp
new file mode 100644
index 0000000..5ff5f39
--- /dev/null
+++ b/SourceCode/Bond/EAPSimulator/CDefineReportsDlg.cpp
@@ -0,0 +1,193 @@
+锘�// CDefineReportsDlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "pch.h"
+#include "EAPSimulator.h"
+#include "CDefineReportsDlg.h"
+#include "afxdialogex.h"
+#include "CAddIDSDlg.h"
+
+
+// CDefineReportsDlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CDefineReportsDlg, CDialogEx)
+
+CDefineReportsDlg::CDefineReportsDlg(CWnd* pParent /*=nullptr*/)
+	: CDialogEx(IDD_DIALOG_DEFINE_REPORTS, pParent)
+{
+
+}
+
+CDefineReportsDlg::~CDefineReportsDlg()
+{
+}
+
+void CDefineReportsDlg::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CDefineReportsDlg, CDialogEx)
+	ON_BN_CLICKED(IDC_BUTTON_ADD_RPTID, &CDefineReportsDlg::OnBnClickedButtonAddRptid)
+	ON_LBN_SELCHANGE(IDC_LIST1, &CDefineReportsDlg::OnLbnSelchangeList1)
+	ON_BN_CLICKED(IDC_BUTTON_DEL_REPORT, &CDefineReportsDlg::OnBnClickedButtonDelReport)
+	ON_BN_CLICKED(IDC_BUTTON_ADD_VID, &CDefineReportsDlg::OnBnClickedButtonAddVid)
+	ON_LBN_SELCHANGE(IDC_LIST2, &CDefineReportsDlg::OnLbnSelchangeList2)
+	ON_BN_CLICKED(IDC_BUTTON_DEL_VID, &CDefineReportsDlg::OnBnClickedButtonDelVid)
+	ON_BN_CLICKED(IDC_BUTTON_SEND, &CDefineReportsDlg::OnBnClickedButtonSend)
+END_MESSAGE_MAP()
+
+
+// CDefineReportsDlg 娑堟伅澶勭悊绋嬪簭
+void CDefineReportsDlg::OnBnClickedButtonAddRptid()
+{
+	CAddIDSDlg dlg;
+	dlg.SetTitle("RPTID");
+	dlg.DoModal();
+	int PRTID = dlg.GetId();
+	addReport(PRTID);
+}
+
+void CDefineReportsDlg::OnBnClickedButtonAddVid()
+{
+	CString strReportId;
+	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
+	int nSel = pListBox->GetCurSel();
+	if (nSel >= 0) {
+		pListBox->GetText(nSel, strReportId);
+		int RPTID = atoi(strReportId);
+
+		CAddIDSDlg dlg;
+		dlg.SetTitle("RPTID");
+		dlg.DoModal();
+		unsigned int VID = dlg.GetId();;
+		addVid(RPTID, VID);
+	}
+
+
+}
+
+void CDefineReportsDlg::OnLbnSelchangeList1()
+{
+	CString strReportId;
+	int RPTID = -1;
+	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
+	int nSel = pListBox->GetCurSel();
+	if (nSel >= 0) {
+		pListBox->GetText(nSel, strReportId);
+		RPTID = atoi(strReportId);
+	}
+
+	GetDlgItem(IDC_BUTTON_DEL_REPORT)->EnableWindow(nSel >= 0);
+	GetDlgItem(IDC_BUTTON_ADD_VID)->EnableWindow(nSel >= 0);
+
+	CListBox* pListBox2 = (CListBox*)GetDlgItem(IDC_LIST2);
+	pListBox2->ResetContent();
+	auto iter = m_mapReport.find(RPTID);
+	if (iter != m_mapReport.end()) {
+		auto& vids = m_mapReport[RPTID];
+		for (auto item : vids) {
+			pListBox2->AddString(std::to_string(item).c_str());
+		}
+	}
+}
+
+void CDefineReportsDlg::OnBnClickedButtonDelReport()
+{
+	CString strReportId;
+	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
+	int nSel = pListBox->GetCurSel();
+	if (nSel >= 0) {
+		pListBox->GetText(nSel, strReportId);
+		int RPTID = atoi(strReportId);
+		delReport(RPTID);
+		pListBox->DeleteString(nSel);
+		((CListBox*)GetDlgItem(IDC_LIST2))->ResetContent();
+	}
+
+	nSel = pListBox->GetCurSel();
+	GetDlgItem(IDC_BUTTON_DEL_REPORT)->EnableWindow(nSel >= 0);
+	GetDlgItem(IDC_BUTTON_ADD_VID)->EnableWindow(nSel >= 0);
+}
+
+void CDefineReportsDlg::OnLbnSelchangeList2()
+{
+	CListBox* pListBox2 = (CListBox*)GetDlgItem(IDC_LIST2);
+	int nSel = pListBox2->GetCurSel();
+	GetDlgItem(IDC_BUTTON_DEL_VID)->EnableWindow(nSel >= 0);
+}
+
+void CDefineReportsDlg::OnBnClickedButtonDelVid()
+{
+	CString strRPTID, strVID;
+	CListBox* pListBox1 = (CListBox*)GetDlgItem(IDC_LIST1);
+	CListBox* pListBox2 = (CListBox*)GetDlgItem(IDC_LIST2);
+	int nSel1 = pListBox1->GetCurSel();
+	int nSel2 = pListBox2->GetCurSel();
+	if (nSel1 >= 0 && nSel2 >= 0) {
+		pListBox1->GetText(nSel1, strRPTID);
+		pListBox2->GetText(nSel2, strVID);
+		int RPTID = atoi(strRPTID);
+		int VID = atoi(strVID);
+		delVid(RPTID, VID);
+		pListBox2->DeleteString(nSel2);
+	}
+
+	nSel2 = pListBox2->GetCurSel();
+	GetDlgItem(IDC_BUTTON_DEL_VID)->EnableWindow(nSel2 >= 0);
+}
+
+void CDefineReportsDlg::addReport(int RPTID)
+{
+	auto iter = m_mapReport.find(RPTID);
+	if (iter == m_mapReport.end()) {
+		std::vector<unsigned int> vids;
+		m_mapReport[RPTID] = vids;
+	}
+
+	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST1);
+	pListBox->AddString(std::to_string(RPTID).c_str());
+}
+
+bool CDefineReportsDlg::addVid(unsigned int RPTID, unsigned int vid)
+{
+	auto iter = m_mapReport.find(RPTID);
+	if (iter == m_mapReport.end()) {
+		return false;
+	}
+
+	auto& vids = m_mapReport[RPTID];
+	vids.push_back(vid);
+	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LIST2);
+	pListBox->AddString(std::to_string(vid).c_str());
+
+	return true;
+}
+
+void CDefineReportsDlg::delReport(int RPTID)
+{
+	auto iter = m_mapReport.find(RPTID);
+	if (iter != m_mapReport.end()) {
+		m_mapReport.erase(iter);
+	}
+}
+
+void CDefineReportsDlg::delVid(int RPTID, int VID)
+{
+	auto iter = m_mapReport.find(RPTID);
+	if (iter != m_mapReport.end()) {
+		auto& vids = iter->second;
+		for (auto iter2 = vids.begin(); iter2 != vids.end(); iter2++) {
+			if ((*iter2) == VID) {
+				vids.erase(iter2);
+				break;
+			}
+		}
+	}
+}
+
+void CDefineReportsDlg::OnBnClickedButtonSend()
+{
+	theApp.m_model.m_pHsmsActive->hsmsDefineReports(m_mapReport);
+}
diff --git a/SourceCode/Bond/EAPSimulator/CDefineReportsDlg.h b/SourceCode/Bond/EAPSimulator/CDefineReportsDlg.h
new file mode 100644
index 0000000..e37af56
--- /dev/null
+++ b/SourceCode/Bond/EAPSimulator/CDefineReportsDlg.h
@@ -0,0 +1,40 @@
+锘�#pragma once
+#include <map>
+#include <vector>
+
+// CDefineReportsDlg 瀵硅瘽妗�
+
+class CDefineReportsDlg : public CDialogEx
+{
+	DECLARE_DYNAMIC(CDefineReportsDlg)
+
+public:
+	CDefineReportsDlg(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CDefineReportsDlg();
+	void addReport(int RPTID);
+	void delReport(int RPTID);
+	bool addVid(unsigned int RPTID, unsigned int vid);
+	void delVid(int RPTID, int VID);
+
+private:
+	std::map<unsigned int, std::vector<unsigned int>> m_mapReport;
+
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_DIALOG_DEFINE_REPORTS };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	afx_msg void OnBnClickedButtonAddRptid();
+	afx_msg void OnLbnSelchangeList1();
+	afx_msg void OnBnClickedButtonDelReport();
+	afx_msg void OnBnClickedButtonAddVid();
+	afx_msg void OnLbnSelchangeList2();
+	afx_msg void OnBnClickedButtonDelVid();
+	afx_msg void OnBnClickedButtonSend();
+};
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
index e3e2286..925eb0e 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.cpp
@@ -201,6 +201,27 @@
 	return 0;
 }
 
+int CHsmsActive::hsmsDefineReports(std::map<unsigned int, std::vector<unsigned int>>& mapReport)
+{
+	IMessage* pMessage = nullptr;
+	int nRet = HSMS_Create1Message(pMessage, m_nSessionId, 2 | REPLY, 33, ++m_nSystemByte);
+	ISECS2Item* pItem = pMessage->getBody();
+	pItem->addU4Item(1, "DATAID");
+	ISECS2Item* pItemReportList = pItem->addItem();
+	for (auto item : mapReport) {
+		ISECS2Item* pItemReport = pItemReportList->addItem();
+		pItemReport->addU4Item(item.first, "RPTID");
+		ISECS2Item* pItemVidList = pItemReport->addItem();
+		for (auto vid : item.second) {
+			pItemVidList->addU4Item(vid, "VID");
+		}
+	}
+	m_pActive->sendMessage(pMessage);
+	HSMS_Destroy1Message(pMessage);
+
+	return 0;
+}
+
 int CHsmsActive::replyAck0(IMessage* pMessage)
 {
 	return 0;
diff --git a/SourceCode/Bond/EAPSimulator/CHsmsActive.h b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
index 759426f..c8bcbeb 100644
--- a/SourceCode/Bond/EAPSimulator/CHsmsActive.h
+++ b/SourceCode/Bond/EAPSimulator/CHsmsActive.h
@@ -1,7 +1,7 @@
 #pragma once
 #include <string>
 #include <vector>
-
+#include <map>
 
 typedef std::function<void(void* pFrom, ACTIVESTATE state)> STATECHANGED;
 typedef struct _ACTIVEListener
@@ -45,6 +45,9 @@
 	// Enable/Disable Alarm Report
 	int hsmsEDAlarmReport(bool bEnable, unsigned int id);
 
+	// Define reports
+	int hsmsDefineReports(std::map<unsigned int, std::vector<unsigned int>>& mapReport);
+	
 	// 通过的reply函数
 	void replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName);
 
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
index c6cb615..f869cdd 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulator.rc
Binary files differ
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj b/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj
index a8b9b26..57d8fcc 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj
@@ -183,6 +183,8 @@
     </ResourceCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="CAddIDSDlg.h" />
+    <ClInclude Include="CDefineReportsDlg.h" />
     <ClInclude Include="CEDEventReportDlg.h" />
     <ClInclude Include="CHsmsActive.h" />
     <ClInclude Include="CModel.h" />
@@ -199,6 +201,8 @@
     <ClInclude Include="targetver.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="CAddIDSDlg.cpp" />
+    <ClCompile Include="CDefineReportsDlg.cpp" />
     <ClCompile Include="CEDEventReportDlg.cpp" />
     <ClCompile Include="CHsmsActive.cpp" />
     <ClCompile Include="CModel.cpp" />
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters b/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters
index d868d86..1a45eff 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulator.vcxproj.filters
@@ -57,6 +57,12 @@
     <ClInclude Include="CEDEventReportDlg.h">
       <Filter>澶存枃浠�</Filter>
     </ClInclude>
+    <ClInclude Include="CDefineReportsDlg.h">
+      <Filter>澶存枃浠�</Filter>
+    </ClInclude>
+    <ClInclude Include="CAddIDSDlg.h">
+      <Filter>澶存枃浠�</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="EAPSimulator.cpp">
@@ -89,6 +95,12 @@
     <ClCompile Include="CEDEventReportDlg.cpp">
       <Filter>婧愭枃浠�</Filter>
     </ClCompile>
+    <ClCompile Include="CDefineReportsDlg.cpp">
+      <Filter>婧愭枃浠�</Filter>
+    </ClCompile>
+    <ClCompile Include="CAddIDSDlg.cpp">
+      <Filter>婧愭枃浠�</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="EAPSimulator.rc">
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
index 6dca163..bb79178 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.cpp
@@ -11,6 +11,7 @@
 #include <regex>
 #include "CTerminalDisplayDlg.h"
 #include "CEDEventReportDlg.h"
+#include "CDefineReportsDlg.h"
 
 
 #ifdef _DEBUG
@@ -80,6 +81,7 @@
 	ON_BN_CLICKED(IDC_BUTTON_TERMINAL_DISPLAY, &CEAPSimulatorDlg::OnBnClickedButtonTerminalDisplay)
 	ON_BN_CLICKED(IDC_BUTTON_ED_EVENT_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonEdEventReport)
 	ON_BN_CLICKED(IDC_BUTTON_ED_ALARM_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonEdAlarmReport)
+	ON_BN_CLICKED(IDC_BUTTON_DEFINE_REPORT, &CEAPSimulatorDlg::OnBnClickedButtonDefineReport)
 END_MESSAGE_MAP()
 
 
@@ -261,6 +263,7 @@
 	GetDlgItem(IDC_BUTTON_TERMINAL_DISPLAY)->EnableWindow(enabled);	
 	GetDlgItem(IDC_BUTTON_ED_EVENT_REPORT)->EnableWindow(enabled);
 	GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->EnableWindow(enabled);	
+	GetDlgItem(IDC_BUTTON_DEFINE_REPORT)->EnableWindow(enabled);	
 }
 
 void CEAPSimulatorDlg::OnBnClickedButtonConnect()
@@ -310,3 +313,9 @@
 		enable == 1 ? _T("Disable Alarm Report") : _T("Enable Alarm Report"));
 	::SetProp(GetDlgItem(IDC_BUTTON_ED_ALARM_REPORT)->m_hWnd, _T("Enable"), (void*)enable);
 }
+
+void CEAPSimulatorDlg::OnBnClickedButtonDefineReport()
+{
+	CDefineReportsDlg dlg;
+	dlg.DoModal();
+}
diff --git a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
index 76fff99..6fafcec 100644
--- a/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
+++ b/SourceCode/Bond/EAPSimulator/EAPSimulatorDlg.h
@@ -51,4 +51,5 @@
 	afx_msg void OnBnClickedButtonTerminalDisplay();
 	afx_msg void OnBnClickedButtonEdEventReport();
 	afx_msg void OnBnClickedButtonEdAlarmReport();
+	afx_msg void OnBnClickedButtonDefineReport();
 };
diff --git a/SourceCode/Bond/EAPSimulator/Resource.h b/SourceCode/Bond/EAPSimulator/Resource.h
index fec8156..4a5ed28 100644
--- a/SourceCode/Bond/EAPSimulator/Resource.h
+++ b/SourceCode/Bond/EAPSimulator/Resource.h
@@ -9,6 +9,8 @@
 #define IDR_MAINFRAME                   128
 #define IDD_DIALOG_TERMINAL_DISPLAY     129
 #define IDD_DIALOG_ED_EVENT_REPORT      131
+#define IDD_DIALOG_DEFINE_REPORTS       133
+#define IDD_DIALOG_ADD_IDS              135
 #define IDC_EDIT_LOG                    1000
 #define IDC_EDIT_IP                     1001
 #define IDC_EDIT_PORT                   1002
@@ -22,17 +24,27 @@
 #define IDC_EDIT_TEXT                   1009
 #define IDC_BUTTON_ED_ALARM_REPORT      1009
 #define IDC_BUTTON_SEND                 1010
+#define IDC_BUTTON_DEFINE_REPORT        1010
 #define IDC_RADIO_ENABLE                1012
 #define IDC_RADIO_DISABLE               1013
 #define IDC_EDIT_CEID                   1014
+#define IDC_LIST1                       1015
+#define IDC_LIST2                       1016
+#define IDC_BUTTON_ADD_RPTID            1017
+#define IDC_BUTTON_DEL_REPORT           1018
+#define IDC_BUTTON_ADD_VID              1019
+#define IDC_BUTTON_DEL_VID              1020
+#define IDC_GROUP_IDS                   1021
+#define IDC_EDIT_ID                     1022
+#define IDC_BUTTON1                     1023
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        133
+#define _APS_NEXT_RESOURCE_VALUE        137
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1015
+#define _APS_NEXT_CONTROL_VALUE         1024
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
diff --git a/SourceCode/Bond/Servo/CBonder.cpp b/SourceCode/Bond/Servo/CBonder.cpp
index 98e2164..78d003e 100644
--- a/SourceCode/Bond/Servo/CBonder.cpp
+++ b/SourceCode/Bond/Servo/CBonder.cpp
@@ -420,6 +420,7 @@
 		CEquipment::onTimer(nTimerid);
 
 		// test	 
+		/*
 		static int i[2] = { 0, 0 };
 		i[m_nIndex]++;
 		if (m_nIndex == 0 && i[m_nIndex] % 20 == 0) {
@@ -430,6 +431,7 @@
 					1);
 			}
 		}
+		*/
 	}
 
 	void CBonder::serialize(CArchive& ar)
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 20334e8..3f52f0e 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -133,26 +133,19 @@
 	return 0;
 }
 
-void CHsmsPassive::deleteReport(unsigned int RPTID)
+SERVO::CReport* CHsmsPassive::defineReport(unsigned int RPTID, std::vector<unsigned int>& vids)
 {
-	for (auto it = m_mapValueIdToPRTID.begin(); it != m_mapValueIdToPRTID.end(); ) {
-		if (it->second == RPTID) {
-			m_mapValueIdToPRTID.erase(it++);  // 鏇存柊杩唬鍣�
-		}
-		else {
-			++it;
+	// 娣诲姞瀹氫箟report
+	SERVO::CReport* pReport = new SERVO::CReport(RPTID, vids);
+	for (auto vid : vids) {
+		SERVO::CVariable* pVariable = getVariable(vid);
+		if (pVariable != nullptr) {
+			pReport->addVariable(pVariable);
 		}
 	}
-}
+	m_reports.push_back(pReport);
 
-void CHsmsPassive::deleteAllReport()
-{
-	m_mapValueIdToPRTID.clear();
-}
-
-void CHsmsPassive::defineReport(unsigned int VID, unsigned int RPTID)
-{
-	m_mapValueIdToPRTID[VID] = RPTID;
+	return pReport;
 }
 
 void CHsmsPassive::OnTimer(UINT nTimerid)
@@ -333,6 +326,19 @@
 	}
 
 	return nullptr;
+}
+
+bool CHsmsPassive::removeReport(int rptid)
+{
+	for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) {
+		if ((*iter)->getReportId() == rptid) {
+			delete (*iter);
+			m_reports.erase(iter);
+			return true;
+		}
+	}
+
+	return false;
 }
 
 void CHsmsPassive::clearAllReport()
@@ -889,40 +895,47 @@
 	ISECS2Item* pBody = pRecv->getBody();
 	ISECS2Item* defineItem, *rptListItem, * vidListItem;
 	unsigned int dataId, rptid, vid;
+
 	if (!pBody->getSubItemU4(0, dataId)) goto MYREPLY;
 	rptListItem = pBody->getSubItem(1);
 	if (rptListItem == nullptr) goto MYREPLY;
 	if (rptListItem->getSubItemSize() == 0) {
-		deleteAllReport();
+		clearAllReport();
 		goto MYREPLY;
 	}
+
 	for (int i = 0; i < rptListItem->getSubItemSize(); i++) {
 		defineItem = rptListItem->getSubItem(i);
 		if (defineItem == nullptr) continue;
+
+		std::vector<unsigned int> vids;
+		SERVO::CReport* pReport = nullptr;
 		vidListItem = defineItem->getSubItem(1);
 		if (defineItem->getSubItemU4(0, rptid)
 			&& vidListItem != nullptr) {
-			int vidCount = vidListItem->getSubItemSize();
-			if (vidCount == 0) {
-				deleteReport(rptid);
-			}
-			else {
-				for (int k = 0; k < vidCount; k++) {
-					if (vidListItem->getSubItemU4(k, vid)) {
-						defineReport(vid, rptid);
-					}
+			for (int k = 0; k < vidListItem->getSubItemSize(); k++) {
+				if (vidListItem->getSubItemU4(k, vid)) {
+					vids.push_back(vid);
 				}
+			}
+		}
+
+		removeReport(rptid);
+		if (!vids.empty()) {
+			pReport = defineReport(rptid, vids);
+		}
+
+		// 妫�楠岀粨鏋滄槸鍚︽纭�
+		if (pReport != nullptr) {
+			auto variables = pReport->getVariables();
+			for (auto item : variables) {
+				LOGE("=== prtid:%d, vid:%d", rptid, item->getVarialbleId());
 			}
 		}
 	}
 
 
 MYREPLY:
-	// 妫�楠岀粨鏋滄槸鍚︽纭�
-	for (auto item : m_mapValueIdToPRTID) {
-		LOGE("=== vid:%d, prtid:%d", item.first, item.second);
-	}
-
 	replyAck(2, 34, pRecv->getHeader()->systemBytes, BYTE(0), "DRACK");
 	return 0;
 }
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 742c7fc..7dbbbf6 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -103,10 +103,11 @@
 	unsigned int getCEID(int RPTID);
 
 	// define Report
-	void defineReport(unsigned int VID, unsigned int RPTID);
+	SERVO::CReport* defineReport(unsigned int RPTID, std::vector<unsigned int>& vids);
 
 	// 取消 define report
-	void deleteReport(unsigned int RPTID);
+	bool removeReport(int rptid);
+	void clearAllReport();
 
 	// 从文件中加载CVariable列表
 	int loadVarialbles(const char* pszFilepath);
@@ -120,9 +121,6 @@
 	// 从文件中加载CReport列表
 	int loadReports(const char* pszFilepath);
 
-	// 取消/删除所有 define report
-	void deleteAllReport();
-
 	// 取得Report列表
 	std::vector<SERVO::CReport*>& getReports();
 
@@ -134,6 +132,7 @@
 
 	// 取消/删除所有CollectionEvent
 	void clearAllCollectionEvent();
+
 
 	SERVO::CReport* getReport(int rptid);
 
@@ -175,7 +174,6 @@
 	int onRecvMsg(IMessage* pMessage);
 	void clearAllVariabel();
 	std::vector<unsigned int> parseVidList(CString& strNums);
-	void clearAllReport();
 
 private:
 	CModel* m_pModel;
@@ -203,9 +201,6 @@
 	
 	// RPTID to Report
 	std::map<unsigned int, REPORT> m_mapReport;
-
-	// VID to RPTID
-	std::map<unsigned int, unsigned int> m_mapValueIdToPRTID;
 
 	// VID to Report
 	std::map<unsigned int, VALUE> m_mapValue;
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 7544937..77ab4c7 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -136,7 +136,7 @@
 	m_hsmsPassive.loadReports((LPTSTR)(LPCTSTR)strVarialbleFile);
 	strVarialbleFile.Format(_T("%s\\CollectionEventList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
 	m_hsmsPassive.loadCollectionEvents((LPTSTR)(LPCTSTR)strVarialbleFile);
-	m_hsmsPassive.init(this, "APP", 7000);
+
 
 	SERVO::MasterListener masterListener;
 	masterListener.onMasterStateChanged = [&](void* pMaster, SERVO::MASTERSTATE state) -> void {
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index b37b0f8..709eade 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -560,7 +560,7 @@
 
 void CServoDlg::OnMenuProjectVarialbleList()
 {
-	CHMPropertyDlg dlg(_T("Variable|Rreport|Collection Event"), 658, 788);
+	CHMPropertyDlg dlg(_T("Variable | Rreport | Collection Event"), 658, 788);
 
 	CPageCollectionEvent* pPage1 = new CPageCollectionEvent();
 	pPage1->Create(IDD_PAGE_COLLECTION_EVENT);

--
Gitblit v1.9.3