| | |
| | | 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 |
| | |
| | | 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()); |
| | | } |
| | | } |
| | |
| | | public: |
| | | CPageReport(CWnd* pParent = nullptr); // 标准构造函数 |
| | | virtual ~CPageReport(); |
| | | void loadReports(); |
| | | |
| | | private: |
| | | CListCtrlEx m_listCtrl; |
| | |
| | | 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() |
| | |
| | | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | { |
| | | public: |
| | | CReport(); |
| | | CReport(unsigned int reportId); |
| | | CReport(unsigned int reportId, std::vector<unsigned int>& vids); |
| | | virtual ~CReport(); |
| | | |
| | | public: |
| | |
| | | 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; |
| | | }; |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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) { |
| | |
| | | } |
| | | |
| | | clearAllVariabel(); |
| | | clearAllReport(); |
| | | |
| | | return 0; |
| | | } |
| | |
| | | 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: |