LAPTOP-SNT8I5JK\Boounion
2025-07-15 669b642758788c1ed187e7a1b862475747964c85
1.CReport列表在界面中的显示;
已修改6个文件
80 ■■■■■ 文件已修改
SourceCode/Bond/Servo/CPageReport.cpp 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CPageReport.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CReport.cpp 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/CReport.h 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.cpp 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SourceCode/Bond/Servo/HsmsPassive.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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());
    }
}
SourceCode/Bond/Servo/CPageReport.h
@@ -12,6 +12,7 @@
public:
    CPageReport(CWnd* pParent = nullptr);   // 标准构造函数
    virtual ~CPageReport();
    void loadReports();
private:
    CListCtrlEx m_listCtrl;
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;
    }
}
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;
    };
}
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;
}
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: