From 669b642758788c1ed187e7a1b862475747964c85 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 15 七月 2025 15:45:10 +0800
Subject: [PATCH] 1.CReport列表在界面中的显示;
---
SourceCode/Bond/Servo/HsmsPassive.h | 2
SourceCode/Bond/Servo/HsmsPassive.cpp | 8 ++--
SourceCode/Bond/Servo/CPageReport.h | 1
SourceCode/Bond/Servo/CReport.h | 6 ++
SourceCode/Bond/Servo/CPageReport.cpp | 13 ++++++
SourceCode/Bond/Servo/CReport.cpp | 50 ++++++++++++++++++++++++
6 files changed, 72 insertions(+), 8 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPageReport.cpp b/SourceCode/Bond/Servo/CPageReport.cpp
index d2900e3..94f55b8 100644
--- a/SourceCode/Bond/Servo/CPageReport.cpp
+++ b/SourceCode/Bond/Servo/CPageReport.cpp
@@ -64,7 +64,7 @@
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();
+ loadReports();
return TRUE; // return TRUE unless you set the focus to a control
// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -113,3 +113,14 @@
GetClientRect(&rcClient);
m_listCtrl.MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
}
+
+void CPageReport::loadReports()
+{
+ auto& reports = theApp.m_model.m_hsmsPassive.getReports();
+ for (auto item : reports) {
+ 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->getReportId()).c_str());
+ m_listCtrl.SetItemText(index, 2, item->getVariablesIdsText().c_str());
+ }
+}
diff --git a/SourceCode/Bond/Servo/CPageReport.h b/SourceCode/Bond/Servo/CPageReport.h
index 4bb3648..716ac0b 100644
--- a/SourceCode/Bond/Servo/CPageReport.h
+++ b/SourceCode/Bond/Servo/CPageReport.h
@@ -12,6 +12,7 @@
public:
CPageReport(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
virtual ~CPageReport();
+ void loadReports();
private:
CListCtrlEx m_listCtrl;
diff --git a/SourceCode/Bond/Servo/CReport.cpp b/SourceCode/Bond/Servo/CReport.cpp
index a880f2f..49f2fd0 100644
--- a/SourceCode/Bond/Servo/CReport.cpp
+++ b/SourceCode/Bond/Servo/CReport.cpp
@@ -8,9 +8,12 @@
m_nReportId = 0;
}
- CReport::CReport(unsigned int reportId)
+ CReport::CReport(unsigned int reportId, std::vector<unsigned int>& vids)
{
m_nReportId = reportId;
+ for (auto vid : vids) {
+ m_vids.push_back(vid);
+ }
}
CReport::~CReport()
@@ -58,4 +61,49 @@
return nullptr;
}
+
+ std::vector<CVariable*>& CReport::getVariables()
+ {
+ return m_variabels;
+ }
+
+ std::string CReport::getVariablesIdsText()
+ {
+ std::string strResult, strName;
+ for (int i = 0; i < m_vids.size(); i++) {
+ strResult += std::to_string(m_vids[i]);
+ strResult += "(";
+ strResult += (getVariableName(m_vids[i], strName) ?
+ strName : _T("null"));
+ strResult += ")";
+ if (i != m_vids.size() - 1) {
+ strResult += ",";
+ }
+ }
+
+ /*
+ for (int i = 0; i < m_variabels.size(); i++) {
+ strResult += std::to_string(m_variabels[i]->getVarialbleId());
+ strResult += "(";
+ strResult += m_variabels[i]->getName();
+ strResult += ")";
+ if (i != m_variabels.size() - 1) {
+ strResult += ",";
+ }
+ }
+ */
+ return strResult;
+ }
+
+ bool CReport::getVariableName(unsigned int vid, std::string& strName)
+ {
+ for (auto item : m_variabels) {
+ if (item->getVarialbleId() == vid) {
+ strName = item->getName();
+ return true;
+ }
+ }
+
+ return false;
+ }
}
diff --git a/SourceCode/Bond/Servo/CReport.h b/SourceCode/Bond/Servo/CReport.h
index a2078e1..191d539 100644
--- a/SourceCode/Bond/Servo/CReport.h
+++ b/SourceCode/Bond/Servo/CReport.h
@@ -7,7 +7,7 @@
{
public:
CReport();
- CReport(unsigned int reportId);
+ CReport(unsigned int reportId, std::vector<unsigned int>& vids);
virtual ~CReport();
public:
@@ -15,9 +15,13 @@
BOOL addVariable(CVariable* pVariable);
BOOL deleteVarialble(unsigned int nVarialbleId);
CVariable* getVariable(unsigned int nVarialbleId);
+ std::vector<CVariable*>& getVariables();
+ std::string getVariablesIdsText();
+ bool getVariableName(unsigned int vid, std::string& strName);
private:
unsigned int m_nReportId;
+ std::vector<unsigned int> m_vids;
std::vector<CVariable*> m_variabels;
};
}
diff --git a/SourceCode/Bond/Servo/HsmsPassive.cpp b/SourceCode/Bond/Servo/HsmsPassive.cpp
index 19b97dc..a40a131 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.cpp
+++ b/SourceCode/Bond/Servo/HsmsPassive.cpp
@@ -296,8 +296,7 @@
strVariable.Delete(strVariable.GetLength() - 1);
auto vids = parseVidList(strVariable);
-
- SERVO::CReport* pReport = new SERVO::CReport(atoi((LPTSTR)(LPCTSTR)strId));
+ SERVO::CReport* pReport = new SERVO::CReport(atoi((LPTSTR)(LPCTSTR)strId), vids);
for (auto vid : vids) {
SERVO::CVariable* pVariable = getVariable(vid);
if (pVariable != nullptr) {
@@ -333,13 +332,13 @@
m_reports.clear();
}
-std::vector<int> CHsmsPassive::parseVidList(CString& strNums)
+std::vector<unsigned int> CHsmsPassive::parseVidList(CString& strNums)
{
// 1. 鍏堝幓鎺夊彲鑳藉嚭鐜扮殑绌虹櫧绗︼紙绌烘牸銆佸埗琛ㄧ绛夛級
strNums.Trim();
// 2锔�.
- std::vector<int> result;
+ std::vector<unsigned int> result;
int i = 0;
CString strVid;
while (1) {
@@ -487,6 +486,7 @@
}
clearAllVariabel();
+ clearAllReport();
return 0;
}
diff --git a/SourceCode/Bond/Servo/HsmsPassive.h b/SourceCode/Bond/Servo/HsmsPassive.h
index 0436b2c..7549e7c 100644
--- a/SourceCode/Bond/Servo/HsmsPassive.h
+++ b/SourceCode/Bond/Servo/HsmsPassive.h
@@ -162,7 +162,7 @@
inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
int onRecvMsg(IMessage* pMessage);
void clearAllVariabel();
- std::vector<int> parseVidList(CString& strNums);
+ std::vector<unsigned int> parseVidList(CString& strNums);
void clearAllReport();
private:
--
Gitblit v1.9.3