From e48a55eb3cc807fa5a45cf398b6f523e96aa5312 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 15 七月 2025 15:10:31 +0800
Subject: [PATCH] 1.Variable列表显示到界面; 2.从文件中加载CReport列表;

---
 SourceCode/Bond/Servo/Servo.vcxproj         |    4 
 SourceCode/Bond/Servo/HsmsPassive.h         |   17 +
 SourceCode/Bond/Servo/CVariable.h           |    1 
 SourceCode/Bond/Servo/resource.h            |    0 
 SourceCode/Bond/Servo/HsmsPassive.cpp       |  167 ++++++++++++---
 SourceCode/Bond/Servo/Model.cpp             |    6 
 SourceCode/Bond/Servo/ServoDlg.cpp          |   15 +
 SourceCode/Bond/x64/Debug/VariableList.txt  |   60 ++--
 SourceCode/Bond/Servo/CPageVarialbles.cpp   |  133 ++++++++++++
 SourceCode/Bond/Servo/Servo.vcxproj.filters |    4 
 SourceCode/Bond/Servo/CPageVarialbles.h     |   36 +++
 SourceCode/Bond/Servo/CPageReport.h         |   33 +++
 SourceCode/Bond/Servo/CReport.h             |    1 
 SourceCode/Bond/Servo/Servo.rc              |    0 
 SourceCode/Bond/Servo/CVariable.cpp         |   22 ++
 SourceCode/Bond/Servo/CPageReport.cpp       |  115 ++++++++++
 SourceCode/Bond/x64/Debug/ReportList.txt    |   17 +
 SourceCode/Bond/Servo/CReport.cpp           |    5 
 18 files changed, 569 insertions(+), 67 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageReport.cpp b/SourceCode/Bond/Servo/CPageReport.cpp
new file mode 100644
index 0000000..d2900e3
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPageReport.cpp
@@ -0,0 +1,115 @@
+锘�// CPageReport.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "CPageReport.h"
+#include "afxdialogex.h"
+
+
+// CPageReport 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CPageReport, CHMPropertyPage)
+
+CPageReport::CPageReport(CWnd* pParent /*=nullptr*/)
+	: CHMPropertyPage(IDD_PAGE_REPORT, pParent)
+{
+
+}
+
+CPageReport::~CPageReport()
+{
+}
+
+void CPageReport::DoDataExchange(CDataExchange* pDX)
+{
+	CHMPropertyPage::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_LIST1, m_listCtrl);
+}
+
+
+BEGIN_MESSAGE_MAP(CPageReport, CHMPropertyPage)
+	ON_WM_CTLCOLOR()
+	ON_WM_DESTROY()
+	ON_WM_SIZE()
+END_MESSAGE_MAP()
+
+
+// CPageReport 娑堟伅澶勭悊绋嬪簭
+
+
+BOOL CPageReport::OnInitDialog()
+{
+	CHMPropertyPage::OnInitDialog();
+
+
+	// 璇诲嚭鍒楀
+	CString strIniFile, strItem;
+	strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	int width[8] = { 0, 218, 180, 180, 180, 180, 180, 180 };
+	for (int i = 0; i < 8; i++) {
+		strItem.Format(_T("Col_%d_Width"), i);
+		width[i] = GetPrivateProfileInt("PageReportListCtrl", strItem, width[i], strIniFile);
+	}
+
+
+	// 鎶ヨ〃鎺т欢
+	DWORD dwStyle = m_listCtrl.GetExtendedStyle();
+	dwStyle |= LVS_EX_FULLROWSELECT;
+	dwStyle |= LVS_EX_GRIDLINES;
+	m_listCtrl.SetExtendedStyle(dwStyle);
+
+	HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
+	ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
+	m_listCtrl.InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
+	m_listCtrl.InsertColumn(1, _T("RPT ID"), LVCFMT_LEFT, width[1]);
+	m_listCtrl.InsertColumn(2, _T("VID"), LVCFMT_LEFT, width[2]);
+	// loadVariables();
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+
+HBRUSH CPageReport::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+	HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
+
+	// TODO:  鍦ㄦ鏇存敼 DC 鐨勪换浣曠壒鎬�
+
+	// TODO:  濡傛灉榛樿鐨勪笉鏄墍闇�鐢荤瑪锛屽垯杩斿洖鍙︿竴涓敾绗�
+	return hbr;
+}
+
+
+void CPageReport::OnDestroy()
+{
+	CHMPropertyPage::OnDestroy();
+
+	// 淇濆瓨鍒楀
+	CString strIniFile, strItem, strTemp;
+	strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	CHeaderCtrl* pHeader = m_listCtrl.GetHeaderCtrl();
+	for (int i = 0; i < pHeader->GetItemCount(); i++) {
+		RECT rect;
+		pHeader->GetItemRect(i, &rect);
+		strItem.Format(_T("Col_%d_Width"), i);
+		strTemp.Format(_T("%d"), rect.right - rect.left);
+		WritePrivateProfileString("PageReportListCtrl", strItem, strTemp, strIniFile);
+	}
+}
+
+
+void CPageReport::OnSize(UINT nType, int cx, int cy)
+{
+	CHMPropertyPage::OnSize(nType, cx, cy);
+	if (GetDlgItem(IDC_LIST1) == nullptr) return;
+
+	CWnd* pItem;
+	CRect rcClient, rcItem;
+	GetClientRect(&rcClient);
+	m_listCtrl.MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
+}
diff --git a/SourceCode/Bond/Servo/CPageReport.h b/SourceCode/Bond/Servo/CPageReport.h
new file mode 100644
index 0000000..4bb3648
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPageReport.h
@@ -0,0 +1,33 @@
+锘�#pragma once
+#include "CHMPropertyPage.h"
+#include "ListCtrlEx.h"
+
+
+// CPageReport 瀵硅瘽妗�
+
+class CPageReport : public CHMPropertyPage
+{
+	DECLARE_DYNAMIC(CPageReport)
+
+public:
+	CPageReport(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CPageReport();
+
+private:
+	CListCtrlEx m_listCtrl;
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_PAGE_REPORT };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	virtual BOOL OnInitDialog();
+	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+	afx_msg void OnDestroy();
+	afx_msg void OnSize(UINT nType, int cx, int cy);
+};
diff --git a/SourceCode/Bond/Servo/CPageVarialbles.cpp b/SourceCode/Bond/Servo/CPageVarialbles.cpp
new file mode 100644
index 0000000..415a5dc
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPageVarialbles.cpp
@@ -0,0 +1,133 @@
+锘�// CPageVarialbles.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "CPageVarialbles.h"
+#include "afxdialogex.h"
+
+
+// CPageVarialbles 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CPageVarialbles, CHMPropertyPage)
+
+CPageVarialbles::CPageVarialbles(CWnd* pParent /*=nullptr*/)
+	: CHMPropertyPage(IDD_PAGE_VARIABLE, pParent)
+{
+
+}
+
+CPageVarialbles::~CPageVarialbles()
+{
+}
+
+void CPageVarialbles::DoDataExchange(CDataExchange* pDX)
+{
+	CHMPropertyPage::DoDataExchange(pDX);
+	DDX_Control(pDX, IDC_LIST1, m_listCtrl);
+}
+
+
+BEGIN_MESSAGE_MAP(CPageVarialbles, CHMPropertyPage)
+	ON_WM_CTLCOLOR()
+	ON_WM_DESTROY()
+	ON_WM_SIZE()
+END_MESSAGE_MAP()
+
+
+// CPageVarialbles 娑堟伅澶勭悊绋嬪簭
+
+
+BOOL CPageVarialbles::OnInitDialog()
+{
+	CHMPropertyPage::OnInitDialog();
+
+
+	// 璇诲嚭鍒楀
+	CString strIniFile, strItem;
+	strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	int width[8] = { 0, 218, 180, 180, 180, 180, 180, 180 };
+	for (int i = 0; i < 8; i++) {
+		strItem.Format(_T("Col_%d_Width"), i);
+		width[i] = GetPrivateProfileInt("PageVariableListCtrl", strItem, width[i], strIniFile);
+	}
+
+
+	// 鎶ヨ〃鎺т欢
+	DWORD dwStyle = m_listCtrl.GetExtendedStyle();
+	dwStyle |= LVS_EX_FULLROWSELECT;
+	dwStyle |= LVS_EX_GRIDLINES;
+	m_listCtrl.SetExtendedStyle(dwStyle);
+
+	HIMAGELIST imageList = ImageList_Create(24, 24, ILC_COLOR24, 1, 1);
+	ListView_SetImageList(m_listCtrl.GetSafeHwnd(), imageList, LVSIL_SMALL);
+	m_listCtrl.InsertColumn(0, _T(""), LVCFMT_RIGHT, width[0]);
+	m_listCtrl.InsertColumn(1, _T("SV ID"), LVCFMT_LEFT, width[1]);
+	m_listCtrl.InsertColumn(2, _T("SV Name"), LVCFMT_LEFT, width[2]);
+	m_listCtrl.InsertColumn(3, _T("SV Format"), LVCFMT_LEFT, width[3]);
+	m_listCtrl.InsertColumn(4, _T("SV Remark"), LVCFMT_LEFT, width[4]);
+	loadVariables();
+
+	return TRUE;  // return TRUE unless you set the focus to a control
+				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+
+HBRUSH CPageVarialbles::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+	HBRUSH hbr = CHMPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);
+
+	// TODO:  鍦ㄦ鏇存敼 DC 鐨勪换浣曠壒鎬�
+
+	// TODO:  濡傛灉榛樿鐨勪笉鏄墍闇�鐢荤瑪锛屽垯杩斿洖鍙︿竴涓敾绗�
+	return hbr;
+}
+
+
+void CPageVarialbles::OnDestroy()
+{
+	CHMPropertyPage::OnDestroy();
+
+	// 淇濆瓨鍒楀
+	CString strIniFile, strItem, strTemp;
+	strIniFile.Format(_T("%s\\configuration.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	CHeaderCtrl* pHeader = m_listCtrl.GetHeaderCtrl();
+	for (int i = 0; i < pHeader->GetItemCount(); i++) {
+		RECT rect;
+		pHeader->GetItemRect(i, &rect);
+		strItem.Format(_T("Col_%d_Width"), i);
+		strTemp.Format(_T("%d"), rect.right - rect.left);
+		WritePrivateProfileString("PageVariableListCtrl", strItem, strTemp, strIniFile);
+	}
+}
+
+
+void CPageVarialbles::OnSize(UINT nType, int cx, int cy)
+{
+	CHMPropertyPage::OnSize(nType, cx, cy);
+
+	if (GetDlgItem(IDC_LIST1) == nullptr) return;
+
+	CWnd* pItem;
+	CRect rcClient, rcItem;
+	GetClientRect(&rcClient);
+	m_listCtrl.MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
+}
+
+void CPageVarialbles::OnApply()
+{
+	__super::OnApply();
+}
+
+void CPageVarialbles::loadVariables()
+{
+	auto& variables = theApp.m_model.m_hsmsPassive.getVariables();
+	for (auto item : variables) {
+		int index = m_listCtrl.InsertItem(m_listCtrl.GetItemCount(), _T(""));
+		m_listCtrl.SetItemData(index, (DWORD_PTR)item);
+		m_listCtrl.SetItemText(index, 1, std::to_string(item->getVarialbleId()).c_str());
+		m_listCtrl.SetItemText(index, 2, item->getName().c_str());
+		m_listCtrl.SetItemText(index, 3, SERVO::CVariable::formatToString(item->getFormat()).c_str());
+		m_listCtrl.SetItemText(index, 4, item->getRemark().c_str());
+	}
+}
diff --git a/SourceCode/Bond/Servo/CPageVarialbles.h b/SourceCode/Bond/Servo/CPageVarialbles.h
new file mode 100644
index 0000000..3ccbdc0
--- /dev/null
+++ b/SourceCode/Bond/Servo/CPageVarialbles.h
@@ -0,0 +1,36 @@
+锘�#pragma once
+#include "CHMPropertyPage.h"
+#include "ListCtrlEx.h"
+
+
+// CPageVarialbles 瀵硅瘽妗�
+
+class CPageVarialbles : public CHMPropertyPage
+{
+	DECLARE_DYNAMIC(CPageVarialbles)
+
+public:
+	CPageVarialbles(CWnd* pParent = nullptr);   // 鏍囧噯鏋勯�犲嚱鏁�
+	virtual ~CPageVarialbles();
+	virtual void OnApply();
+	void loadVariables();
+
+private:
+	CListCtrlEx m_listCtrl;
+
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+	enum { IDD = IDD_PAGE_VARIABLE };
+#endif
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔
+
+	DECLARE_MESSAGE_MAP()
+public:
+	virtual BOOL OnInitDialog();
+	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+	afx_msg void OnDestroy();
+	afx_msg void OnSize(UINT nType, int cx, int cy);
+};
diff --git a/SourceCode/Bond/Servo/CReport.cpp b/SourceCode/Bond/Servo/CReport.cpp
index 387bf40..a880f2f 100644
--- a/SourceCode/Bond/Servo/CReport.cpp
+++ b/SourceCode/Bond/Servo/CReport.cpp
@@ -5,7 +5,12 @@
 namespace SERVO {
 	CReport::CReport()
 	{
+		m_nReportId = 0;
+	}
 
+	CReport::CReport(unsigned int reportId)
+	{
+		m_nReportId = reportId;
 	}
 
 	CReport::~CReport()
diff --git a/SourceCode/Bond/Servo/CReport.h b/SourceCode/Bond/Servo/CReport.h
index 711af0f..a2078e1 100644
--- a/SourceCode/Bond/Servo/CReport.h
+++ b/SourceCode/Bond/Servo/CReport.h
@@ -7,6 +7,7 @@
 	{
 	public:
 		CReport();
+		CReport(unsigned int reportId);
 		virtual ~CReport();
 
 	public:
diff --git a/SourceCode/Bond/Servo/CVariable.cpp b/SourceCode/Bond/Servo/CVariable.cpp
index a0c15f0..21ddb44 100644
--- a/SourceCode/Bond/Servo/CVariable.cpp
+++ b/SourceCode/Bond/Servo/CVariable.cpp
@@ -46,6 +46,28 @@
 		return SVFromat::U1;
 	}
 
+
+	std::string CVariable::formatToString(SVFromat format)
+	{
+		if (SVFromat::U1 == format) {
+			return "U1";
+		}
+		if (SVFromat::U2 == format) {
+			return "U1";
+		}
+		if (SVFromat::I2 == format) {
+			return "I2";
+		}
+		if (SVFromat::A50 == format) {
+			return "A50";
+		}
+		if (SVFromat::A20 == format) {
+			return "A20";
+		}
+
+		return "U1";
+	}
+
 	unsigned int CVariable::getVarialbleId()
 	{
 		return m_nVarialbeId;
diff --git a/SourceCode/Bond/Servo/CVariable.h b/SourceCode/Bond/Servo/CVariable.h
index 08e05e7..7bac823 100644
--- a/SourceCode/Bond/Servo/CVariable.h
+++ b/SourceCode/Bond/Servo/CVariable.h
@@ -21,6 +21,7 @@
 
 	public:
 		static SVFromat toFormat(const char* pszFormat);
+		static std::string formatToString(SVFromat format);
 		unsigned int getVarialbleId();
 		std::string& getName();
 		SVFromat getFormat();
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index edcb481..19b97dc 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -1,4 +1,4 @@
-#include "stdafx.h"
+锘�#include "stdafx.h"
 #include "HsmsPassive.h"
 #include "Log.h"
 #include "Model.h"
@@ -117,7 +117,7 @@
 {
 	for (auto it = m_mapReportIdToCEID.begin(); it != m_mapReportIdToCEID.end(); ) {
 		if (it->second == CEID) {
-			m_mapReportIdToCEID.erase(it++);  // 更新迭代器
+			m_mapReportIdToCEID.erase(it++);  // 鏇存柊杩唬鍣�
 		}
 		else {
 			++it;
@@ -137,7 +137,7 @@
 {
 	for (auto it = m_mapValueIdToPRTID.begin(); it != m_mapValueIdToPRTID.end(); ) {
 		if (it->second == RPTID) {
-			m_mapValueIdToPRTID.erase(it++);  // 更新迭代器
+			m_mapValueIdToPRTID.erase(it++);  // 鏇存柊杩唬鍣�
 		}
 		else {
 			++it;
@@ -157,11 +157,11 @@
 
 void CHsmsPassive::OnTimer(UINT nTimerid)
 {
-	// 所有已发送的Action自加1
+	// 鎵�鏈夊凡鍙戦�佺殑Action鑷姞1
 	Lock();
 	for (auto iter = m_listActionSent.begin(); iter != m_listActionSent.end();) {
 		if ((*iter)->incrementAndCheckTimeout()) {
-			TRACE("CHsmsPassive::超时\n");
+			TRACE("CHsmsPassive::瓒呮椂\n");
 			delete (*iter);
 			m_listActionSent.erase(iter++);
 		}
@@ -179,7 +179,7 @@
 	CHsmsAction* pAction = nullptr;
 	for (auto iter = m_listActionSent.begin(); iter != m_listActionSent.end(); iter++) {
 		if ((*iter)->getSendMessage()->getHeader()->systemBytes == pMessage->getHeader()->systemBytes) {
-			LOGI("CHsmsPassive::找到");
+			LOGI("CHsmsPassive::鎵惧埌");
 			pAction = (*iter);
 			m_listActionSent.erase(iter);
 			break;
@@ -188,7 +188,7 @@
 	Unlock();
 
 	if (pAction != nullptr) {
-		LOGI("onRecvMsg::相应处理");
+		LOGI("onRecvMsg::鐩稿簲澶勭悊");
 		delete pAction;
 	}
 
@@ -196,14 +196,14 @@
 	return 0;
 }
 
-int CHsmsPassive::loadVarialbleList(const char* pszFilepath)
+int CHsmsPassive::loadVarialbles(const char* pszFilepath)
 {
 	CStdioFile file;
 	if (!file.Open(pszFilepath, CFile::modeRead)) {
 		return -1;
 	}
 
-	std::regex pattern("^\\d+,.*");  // 匹配以数字+逗号开头的字符串
+	std::regex pattern("^\\d+,.*");  // 鍖归厤浠ユ暟瀛�+閫楀彿寮�澶寸殑瀛楃涓�
 	std::vector<SERVO::CVariable*> variables;
 	int index, last;
 	CString strLine;
@@ -228,6 +228,7 @@
 		if (index < 0) continue;
 		strFormat = strLine.Mid(last, index - last);
 		strRemark = strLine.Right(strLine.GetLength() - index - 1);
+		strRemark.Replace(_T("\\r\\n"), _T("\r\n"));
 
 		SERVO::CVariable* pVarialble = new SERVO::CVariable(
 			(LPTSTR)(LPCTSTR)strId, (LPTSTR)(LPCTSTR)strName, (LPTSTR)(LPCTSTR)strFormat, (LPTSTR)(LPCTSTR)strRemark);
@@ -246,12 +247,112 @@
 	return 0;
 }
 
+std::vector<SERVO::CVariable*>& CHsmsPassive::getVariables()
+{
+	return m_variabels;
+}
+
+SERVO::CVariable* CHsmsPassive::getVariable(int variableId)
+{
+	for (auto item : m_variabels) {
+		if (item->getVarialbleId() == variableId) {
+			return item;
+		}
+	}
+
+	return nullptr;
+}
+
 void CHsmsPassive::clearAllVariabel()
 {
 	for (auto item : m_variabels) {
 		delete item;
 	}
 	m_variabels.clear();
+}
+
+int CHsmsPassive::loadReports(const char* pszFilepath)
+{
+	CStdioFile file;
+	if (!file.Open(pszFilepath, CFile::modeRead)) {
+		return -1;
+	}
+
+	std::regex pattern("^\\d+,\\(\\d+(,\\d+)*\\).*");  // 鍖归厤浠ユ暟瀛�+閫楀彿寮�澶寸殑瀛楃涓�
+	std::vector<SERVO::CReport*> reports;
+	int index;
+	CString strLine, strVariable;
+	CString strId, strName, strFormat, strRemark;
+	while (file.ReadString(strLine)) {
+		if (!std::regex_match((LPTSTR)(LPCTSTR)strLine, pattern)) {
+			continue;
+		}
+
+		index = strLine.Find(",", 0);
+		if (index < 0) continue;
+		strId = strLine.Left(index);
+		strVariable = strLine.Right(strLine.GetLength() - index - 1);
+		strVariable.Delete(0);
+		strVariable.Delete(strVariable.GetLength() - 1);
+		auto vids = parseVidList(strVariable);
+
+
+		SERVO::CReport* pReport = new SERVO::CReport(atoi((LPTSTR)(LPCTSTR)strId));
+		for (auto vid : vids) {
+			SERVO::CVariable* pVariable = getVariable(vid);
+			if (pVariable != nullptr) {
+				pReport->addVariable(pVariable);
+			}
+		}
+
+		reports.push_back(pReport);
+	}
+	
+	if (!reports.empty()) {
+		clearAllReport();
+		for (auto item : reports) {
+			m_reports.push_back(item);
+		}
+	}
+	
+
+	file.Close();
+	return 0;
+}
+
+std::vector<SERVO::CReport*>& CHsmsPassive::getReports()
+{
+	return m_reports;
+}
+
+void CHsmsPassive::clearAllReport()
+{
+	for (auto item : m_reports) {
+		delete item;
+	}
+	m_reports.clear();
+}
+
+std::vector<int> CHsmsPassive::parseVidList(CString& strNums)
+{
+	// 1. 鍏堝幓鎺夊彲鑳藉嚭鐜扮殑绌虹櫧绗︼紙绌烘牸銆佸埗琛ㄧ绛夛級
+	strNums.Trim();
+
+	// 2锔�.
+	std::vector<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;
 }
 
 int CHsmsPassive::init(CModel* pModel, const char* pszName, unsigned int port)
@@ -264,8 +365,8 @@
 	auto onStatusChanged = [&](void* pFrom, STATE state) -> void {
 		m_pModel->notifyInt(RX_CODE_PASSIVE_STATUS_CHANGED, (int)state);
 
-		// 连上之后发S1F1
-		// 修改为不主动发送,而是响应
+		// 杩炰笂涔嬪悗鍙慡1F1
+		// 淇敼涓轰笉涓诲姩鍙戦�侊紝鑰屾槸鍝嶅簲
 		/*
 		if (STATE::SELECTED == state) {
 			m_bAreYouThereRequest = FALSE;
@@ -304,7 +405,7 @@
 		HEADER* pHeader = pMessage->getHeader();
 		int nStream = (pHeader->stream & 0x7F);
 
-		LOGI("<HSMS>收到消息 S%dF%d", nStream, pHeader->function);
+		LOGI("<HSMS>鏀跺埌娑堟伅 S%dF%d", nStream, pHeader->function);
 		if (nStream == 1 && pHeader->function == 1) {
 			// S1F1
 			replyAreYouThere(pMessage);
@@ -358,7 +459,7 @@
 	listener.funError = onError;
 	m_pPassive->setListener(listener);
 
-	// 启动工作线程
+	// 鍚姩宸ヤ綔绾跨▼
 	m_bCimWorking = TRUE;
 	m_hCimWorkThreadHandle = (HANDLE)_beginthreadex(NULL, 0, ::CimWorkThreadFunction, this,
 		0, &m_nCimWorkThrdaddr);
@@ -371,7 +472,7 @@
 
 int CHsmsPassive::term()
 {
-	// 结束线程
+	// 缁撴潫绾跨▼
 	m_bCimWorking = FALSE;
 	SetEvent(m_hCimWorkEvent);
 	if (m_hCimWorkThreadHandle != NULL) {
@@ -394,12 +495,12 @@
 {
 	while (m_bCimWorking) {
 
-		// 待退出信号或时间到
+		// 寰呴��鍑轰俊鍙锋垨鏃堕棿鍒�
 		int nRet = WaitForSingleObject(m_hCimWorkEvent, INFINITE);
 		ResetEvent(m_hCimWorkEvent);
 		if (!m_bCimWorking) break;
 
-		// 取出请求列表并进行处理
+		// 鍙栧嚭璇锋眰鍒楄〃骞惰繘琛屽鐞�
 		std::list<CHsmsAction*> list;
 		Lock();
 		list.splice(list.end(), m_listAction);
@@ -418,14 +519,14 @@
 			LOGI("<HSMS> [SEND] SysByte=%u sessionId:%d", pMessage->getHeader()->systemBytes, pMessage->getHeader()->sessionId);
 
 			if (pAction->isNeedWaitReply()) {
-				// 如果需要等待回复
+				// 濡傛灉闇�瑕佺瓑寰呭洖澶�
 				int nRet = WaitForSingleObject(pAction->getEvent(), pAction->getTimeout() * 1000);
 				if (nRet == WAIT_TIMEOUT) {
 					TRACE("Timeout...\n");
 					CContext* pContext = pAction->getContext();
 					if (pContext != NULL) {
 						//pContext->setRetCode(CRC_TIMEOUT);
-						//pContext->setRetMsg("超时");
+						//pContext->setRetMsg("瓒呮椂");
 						//pContext->setEvent();
 					}
 				}
@@ -451,7 +552,7 @@
 	return 0;
 }
 
-// 通用的reply ack函数
+// 閫氱敤鐨剅eply ack鍑芥暟
 void CHsmsPassive::replyAck(int s, int f, unsigned int systemBytes, BYTE ack, const char* pszAckName)
 {
 	IMessage* pMessage = NULL;
@@ -514,13 +615,13 @@
 	}
 
 
-	// 交由上层应用来获取机器常量值
+	// 浜ょ敱涓婂眰搴旂敤鏉ヨ幏鍙栨満鍣ㄥ父閲忓��
 	if (m_listener.onEQOffLine != nullptr) {
 		m_listener.onEQOffLine(this);
 	}
 
 
-	// 回复
+	// 鍥炲
 	replyAck(1, 16, pRecv->getHeader()->systemBytes, BYTE(0), "OFLACK");
 	return 0;
 }
@@ -533,13 +634,13 @@
 	}
 
 
-	// 交由上层应用来获取机器常量值
+	// 浜ょ敱涓婂眰搴旂敤鏉ヨ幏鍙栨満鍣ㄥ父閲忓��
 	if (m_listener.onEQOnLine != nullptr) {
 		m_listener.onEQOnLine(this);
 	}
 
 
-	// 回复
+	// 鍥炲
 	replyAck(1, 18, pRecv->getHeader()->systemBytes, BYTE(0), "ONLACK");
 	return 0;
 }
@@ -574,7 +675,7 @@
 	}
 
 
-	// 要获取的常量表表
+	// 瑕佽幏鍙栫殑甯搁噺琛ㄨ〃
 	BOOL bCheckData = FALSE;
 	std::vector<EQConstant> eqcs;
 	{
@@ -591,13 +692,13 @@
 	}
 
 
-	// 交由上层应用来获取机器常量值
+	// 浜ょ敱涓婂眰搴旂敤鏉ヨ幏鍙栨満鍣ㄥ父閲忓��
 	if (m_listener.onEQConstantRequest != nullptr) {
 		m_listener.onEQConstantRequest(this, eqcs);
 	}
 
 
-	// 回复
+	// 鍥炲
 	IMessage* pMessage = NULL;
 	HSMS_Create1Message(pMessage, m_nSessionId, 1, 14, pRecv->getHeader()->systemBytes);
 	ASSERT(pMessage);
@@ -621,7 +722,7 @@
 	}
 
 
-	// 要设置的常量表表
+	// 瑕佽缃殑甯搁噺琛ㄨ〃
 	BOOL bCheckData = FALSE;
 	std::vector<EQConstant> eqcs;
 	{
@@ -644,14 +745,14 @@
 	}
 
 
-	// 交由上层应用来保存和设置机器常量值
+	// 浜ょ敱涓婂眰搴旂敤鏉ヤ繚瀛樺拰璁剧疆鏈哄櫒甯搁噺鍊�
 	std::vector<unsigned int> ecvs;
 	if (m_listener.onEQConstantSend != nullptr) {
 		m_listener.onEQConstantSend(this, eqcs);
 	}
 
 
-	// 回复
+	// 鍥炲
 	replyAck(2, 16, pRecv->getHeader()->systemBytes, BYTE(0), "EACK");
 	return 0;
 }
@@ -666,7 +767,7 @@
 	if (pBody == nullptr || pBody->getType() != SITYPE::A) ER_PARAM_ERROR;
 	const char* pszMessage;
 	if (pBody->getString(pszMessage)) {
-		// 更新时间
+		// 鏇存柊鏃堕棿
 		SYSTEMTIME time;
 		char szBuffer[20];
 		memcpy(szBuffer, pszMessage, 16);
@@ -733,7 +834,7 @@
 
 
 MYREPLY:
-	// 检验结果是否正确
+	// 妫�楠岀粨鏋滄槸鍚︽纭�
 	for (auto item : m_mapValueIdToPRTID) {
 		LOGE("=== vid:%d, prtid:%d", item.first, item.second);
 	}
@@ -777,7 +878,7 @@
 	}
 
 
-	// 检验结果是否正确
+	// 妫�楠岀粨鏋滄槸鍚︽纭�
 	for (auto item : m_mapReportIdToCEID) {
 		LOGE("=== prtid:%d, ceid:%d", item.first, item.second);
 	}
@@ -864,7 +965,7 @@
 	}
 
 
-	// 回调到应用层
+	// 鍥炶皟鍒板簲鐢ㄥ眰
 	if (bCheckData) {
 		if (m_listener.onCommand != nullptr) {
 			m_listener.onCommand(this, pszCmdName, params);
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index f5e8383..0436b2c 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -112,8 +112,18 @@
 	void deleteAllReport();
 
 	// 从文件中加载CVariable列表
-	int loadVarialbleList(const char* pszFilepath);
+	int loadVarialbles(const char* pszFilepath);
 
+	// 取得CVariable列表
+	std::vector<SERVO::CVariable*>& getVariables();
+
+	// 取得指定Variable
+	SERVO::CVariable* getVariable(int variableId);
+
+	// 从文件中加载CReport表表
+	int loadReports(const char* pszFilepath);
+
+	std::vector<SERVO::CReport*>& getReports();
 
 	void setListener(SECSListener listener);
 	unsigned OnCimWork();
@@ -152,6 +162,8 @@
 	inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
 	int onRecvMsg(IMessage* pMessage);
 	void clearAllVariabel();
+	std::vector<int> parseVidList(CString& strNums);
+	void clearAllReport();
 
 private:
 	CModel* m_pModel;
@@ -188,5 +200,8 @@
 
 	// CVariable vector
 	std::vector<SERVO::CVariable*> m_variabels;
+
+	// CReport vector
+	std::vector<SERVO::CReport*> m_reports;
 };
 
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index 666e54c..0060ca4 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -130,9 +130,11 @@
 	m_hsmsPassive.setSoftRev((LPTSTR)(LPCTSTR)strSoftRev);
 	CString strVarialbleFile;
 	strVarialbleFile.Format(_T("%s\\VariableList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
-	m_hsmsPassive.loadVarialbleList((LPTSTR)(LPCTSTR)strVarialbleFile);
+	m_hsmsPassive.loadVarialbles((LPTSTR)(LPCTSTR)strVarialbleFile);
 	m_hsmsPassive.init(this, "APP", 7000);
-
+	strVarialbleFile.Format(_T("%s\\ReportList.txt"), (LPTSTR)(LPCTSTR)m_strWorkDir);
+	m_hsmsPassive.loadReports((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/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 211d008..2996a08 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj b/SourceCode/Bond/Servo/Servo.vcxproj
index ab9f41e..95e187b 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj
+++ b/SourceCode/Bond/Servo/Servo.vcxproj
@@ -206,6 +206,8 @@
     <ClInclude Include="ChangePasswordDlg.h" />
     <ClInclude Include="CMyStatusbar.h" />
     <ClInclude Include="CPageLinkSignal.h" />
+    <ClInclude Include="CPageReport.h" />
+    <ClInclude Include="CPageVarialbles.h" />
     <ClInclude Include="CReport.h" />
     <ClInclude Include="CRobotCmdContainerDlg.h" />
     <ClInclude Include="CRobotCmdTestDlg.h" />
@@ -351,6 +353,8 @@
     <ClCompile Include="ChangePasswordDlg.cpp" />
     <ClCompile Include="CMyStatusbar.cpp" />
     <ClCompile Include="CPageLinkSignal.cpp" />
+    <ClCompile Include="CPageReport.cpp" />
+    <ClCompile Include="CPageVarialbles.cpp" />
     <ClCompile Include="CReport.cpp" />
     <ClCompile Include="CRobotCmdContainerDlg.cpp" />
     <ClCompile Include="CRobotCmdTestDlg.cpp" />
diff --git a/SourceCode/Bond/Servo/Servo.vcxproj.filters b/SourceCode/Bond/Servo/Servo.vcxproj.filters
index da72ba1..4b6248e 100644
--- a/SourceCode/Bond/Servo/Servo.vcxproj.filters
+++ b/SourceCode/Bond/Servo/Servo.vcxproj.filters
@@ -172,6 +172,8 @@
     <ClCompile Include="CCollectionEvent.cpp" />
     <ClCompile Include="CReport.cpp" />
     <ClCompile Include="CVariable.cpp" />
+    <ClCompile Include="CPageVarialbles.cpp" />
+    <ClCompile Include="CPageReport.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="AlarmManager.h" />
@@ -349,6 +351,8 @@
     <ClInclude Include="CCollectionEvent.h" />
     <ClInclude Include="CReport.h" />
     <ClInclude Include="CVariable.h" />
+    <ClInclude Include="CPageVarialbles.h" />
+    <ClInclude Include="CPageReport.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="Servo.rc" />
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 12eed74..1b04b6b 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -22,6 +22,9 @@
 #include "UserManager.h"
 #include "SystemLogManager.h"
 #include "PortConfigurationDlg.h"
+#include "CHMPropertyDlg.h"
+#include "CPageVarialbles.h"
+#include "CPageReport.h"
 
 
 #ifdef _DEBUG
@@ -556,7 +559,17 @@
 
 void CServoDlg::OnMenuProjectVarialbleList()
 {
-	AfxMessageBox("OnMenuProjectVarialbleList");
+	CHMPropertyDlg dlg(_T("Variable|Rreport|Collection Event"), 658, 788);
+
+	CPageReport* pPage1 = new CPageReport();
+	pPage1->Create(IDD_PAGE_REPORT);
+	dlg.addPage(pPage1, "Report");
+
+	CPageVarialbles* pPage2 = new CPageVarialbles();
+	pPage2->Create(IDD_PAGE_VARIABLE);
+	dlg.addPage(pPage2, "Variable");
+
+	dlg.DoModal();
 }
 
 void CServoDlg::OnUpdateMenuProjectVarialbleList(CCmdUI* pCmdUI)
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index c4c9cde..26ca77d 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ
diff --git a/SourceCode/Bond/x64/Debug/ReportList.txt b/SourceCode/Bond/x64/Debug/ReportList.txt
new file mode 100644
index 0000000..f614e93
--- /dev/null
+++ b/SourceCode/Bond/x64/Debug/ReportList.txt
@@ -0,0 +1,17 @@
+RPTID,(VID1,VID2,...)
+300,(1,300)
+301,(1,300)
+600,(500,600,601)
+700,(500,700,701)
+10000,(200,201)
+10300,(1,10000)
+10051,(1,10000,10100,10101)
+10061,(1,10000,10100,10200)
+10062,(1,10000,10100,10201,10202)
+10071,(1,10000,10100,10203,20000)
+10072,(1,10000,10100,10203,20000,20001)
+10080,(1,10000,10100)
+20000,(1,10000,10203)
+30000,(1,30000,30001)
+31000,(1,31000,31001)
+40000,(1,10203,20000)
diff --git a/SourceCode/Bond/x64/Debug/VariableList.txt b/SourceCode/Bond/x64/Debug/VariableList.txt
index 1c92863..5bb7d38 100644
--- a/SourceCode/Bond/x64/Debug/VariableList.txt
+++ b/SourceCode/Bond/x64/Debug/VariableList.txt
@@ -1,37 +1,37 @@
 SVID,SV Name,SV Format,SV Remark
-100,PortTransferState,U1,"0=OutOfService\r\n1=TransferBlocked\r\n2=ReadyToLoad\r\n3=ReadyToUnload\r\n4=InService\r\n5=TransferReady"
-300,AccessMode,U1,"1=Manual\r\n2=Auto"
+100,PortTransferState,U1,0=OutOfService\r\n1=TransferBlocked\r\n2=ReadyToLoad\r\n3=ReadyToUnload\r\n4=InService\r\n5=TransferReady
+300,AccessMode,U1,1=Manual\r\n2=Auto
 500,Clock,A50,
-600,CurrentControlState,U1,"0:Offline:equipment\r\n1:Offline-Attempt\r\n2:Online\r\n3:Offline:host\r\n4:Online:Local\r\n5:Online:Remote"
+600,CurrentControlState,U1,0:Offline:equipment\r\n1:Offline-Attempt\r\n2:Online\r\n3:Offline:host\r\n4:Online:Local\r\n5:Online:Remote
 601,PreviousControlState,U1,
-700,CurrentProcessState,U1,"0:DOWN\r\n1:IDLE\r\n2.SETUP\r\n3.EXCUTING\r\n4.MAINTAIN\r\n5.ALARM"
+700,CurrentProcessState,U1,0:DOWN\r\n1:IDLE\r\n2.SETUP\r\n3.EXCUTING\r\n4.MAINTAIN\r\n5.ALARM
 701,PreviousProcessState,U1,
 800,EFEMPPExecName,A20,
 801,EQPPExecName,A20,
 1000,CJobSpace,U1,
-2000,RbRAxisTorque,I2,鏈哄櫒浜篟杞存壄鐭�
-2001,RbLAxisTorque,l2,鏈哄櫒浜篖杞存壄鐭�
-2002,RbZAxisTorque,l2,鏈哄櫒浜篫杞存壄鐭�
-2003,RbTHAxisTorque,l2,鏈哄櫒浜篢H杞存壄鐭�
-2004,RbXAxisTorque,l2,鏈哄櫒浜篨杞存壄鐭�
-2005,AxisX111,l2,X111鐩告満鍓嶇Щ鏍界數鏈烘壄鐭�
-2006,AxisX112,l2,X112鐩告満鍚庣Щ鏍界數鏈烘壄鐭�
-2007,AxisU113,l2,U113浜у搧鏃嬭浆鐢垫満鎵煩
-2008,AxisX114,l2,X114浜у搧宸︽暣鍒楃數鏈烘壄鐭�
-2009,AxisY121,l2,Y121浜у搧鍙虫暣鍒楃數鏈烘壄鐭�
-2010,AxisY122,l2,Y122浜у搧鍓嶆暣鍒楃數鏈烘壄鐭�
-2011,AxisY123,l2,Y123浜у搧鍚庨樀鍒楃數鏈烘壄鐭�
-2012,MainAir,U2,鎬昏繘姘斿帇鍔涘��
-2013,MainVacuum,l2,鎬荤湡绌哄帇鍔涘��
-2014,RbMainVacuum,l2,鏈哄櫒浜虹湡绌哄��
-2015,LPMainVacuum,l2,LP鐪熺┖鍊�#D265
-2016,LPMainAir,U2,LP鍘嬬┖鍊�
-2017,ALVacuum,l2,Aligner鐪熺┖鍊�
-2018,FFU1RPM,U2,FFU1杞��
-2019,FFU2RPM,U2,FFU2杞��
-2020,FFU3RPM,U2,FFU3杞��
-2021,FFU4RPM,U2,FFU4杞��
-2022,ESDValue,I2,闈欑數妫�娴嬪��
-2023,OCREnable,U2,"OCR浣胯兘锛歄:寮�鍚� 1锛氬睆钄�"
-2024,CCDEnable,U2,"CCD浣胯兘锛歄:寮�鍚� 1锛氬睆钄�"
-2025,FFUParameter,U2,FFU璁惧畾鍊�
+2000,RbRAxisTorque,I2,机器人R轴扭矩
+2001,RbLAxisTorque,l2,机器人L轴扭矩
+2002,RbZAxisTorque,l2,机器人Z轴扭矩
+2003,RbTHAxisTorque,l2,机器人TH轴扭矩
+2004,RbXAxisTorque,l2,机器人X轴扭矩
+2005,AxisX111,l2,X111相机前移栽电机扭矩
+2006,AxisX112,l2,X112相机后移栽电机扭矩
+2007,AxisU113,l2,U113产品旋转电机扭矩
+2008,AxisX114,l2,X114产品左整列电机扭矩
+2009,AxisY121,l2,Y121产品右整列电机扭矩
+2010,AxisY122,l2,Y122产品前整列电机扭矩
+2011,AxisY123,l2,Y123产品后阵列电机扭矩
+2012,MainAir,U2,总进气压力值
+2013,MainVacuum,l2,总真空压力值
+2014,RbMainVacuum,l2,机器人真空值
+2015,LPMainVacuum,l2,LP真空值#D265
+2016,LPMainAir,U2,LP压空值
+2017,ALVacuum,l2,Aligner真空值
+2018,FFU1RPM,U2,FFU1转速
+2019,FFU2RPM,U2,FFU2转速
+2020,FFU3RPM,U2,FFU3转速
+2021,FFU4RPM,U2,FFU4转速
+2022,ESDValue,I2,静电检测值
+2023,OCREnable,U2,"OCR使能:O:开启 1:屏蔽"
+2024,CCDEnable,U2,"CCD使能:O:开启 1:屏蔽"
+2025,FFUParameter,U2,FFU设定值

--
Gitblit v1.9.3