| | |
| | | #include "Servo.h" |
| | | #include "CPageReport.h" |
| | | #include "afxdialogex.h" |
| | | #include "CReportEditDlg.h" |
| | | #include <algorithm> |
| | | |
| | | |
| | | // CPageReport å¯¹è¯æ¡ |
| | |
| | | void CPageReport::OnClickedBtn(const char* btnName) |
| | | { |
| | | ASSERT(btnName); |
| | | if (_strcmpi(btnName, "å é¤") == 0) { |
| | | if (_strcmpi(btnName, "æ°å¢") == 0) { |
| | | int rc = UX_CanExecute(L"addReports"); |
| | | if (rc != 1) { |
| | | AfxMessageBox("æä½æéä¸è¶³ï¼è¯·è系管ç人åï¼"); |
| | | return; |
| | | } |
| | | |
| | | unsigned int newId = theApp.m_model.m_hsmsPassive.getMaxReportId() + 1; |
| | | std::vector<unsigned int> initVids; |
| | | CReportEditDlg dlg(_T("æ°å¢æ¥å"), static_cast<int>(newId), initVids, this); |
| | | if (dlg.DoModal() != IDOK) return; |
| | | const auto& vids = dlg.GetSelectedVids(); |
| | | |
| | | int ret = theApp.m_model.m_hsmsPassive.addReport(static_cast<int>(newId), vids); |
| | | if (ret == 0) { |
| | | UX_RecordAction(L"addReports"); |
| | | m_listCtrl.DeleteAllItems(); |
| | | loadReports(); |
| | | if (CButton* pDel = GetBtnByName("å é¤")) pDel->EnableWindow(FALSE); |
| | | if (CButton* pEdit = GetBtnByName("ç¼è¾")) pEdit->EnableWindow(FALSE); |
| | | } |
| | | else { |
| | | AfxMessageBox(_T("æ°å¢æ¥å失败ï¼å¯è½IDé夿æä»¶åå
¥å¤±è´¥ï¼")); |
| | | } |
| | | } |
| | | else if (_strcmpi(btnName, "å é¤") == 0) { |
| | | POSITION pos = m_listCtrl.GetFirstSelectedItemPosition(); |
| | | if (pos == nullptr) return; |
| | | int nItem = m_listCtrl.GetNextSelectedItem(pos); |
| | |
| | | AfxMessageBox(_T("å 餿¥å失败")); |
| | | } |
| | | } |
| | | else if (_strcmpi(btnName, "ç¼è¾") == 0) { |
| | | POSITION pos = m_listCtrl.GetFirstSelectedItemPosition(); |
| | | if (pos == nullptr) return; |
| | | int nItem = m_listCtrl.GetNextSelectedItem(pos); |
| | | auto pRpt = reinterpret_cast<SERVO::CReport*>(m_listCtrl.GetItemData(nItem)); |
| | | if (pRpt == nullptr) return; |
| | | |
| | | int rc = UX_CanExecute(L"editReports"); |
| | | if (rc != 1) { |
| | | AfxMessageBox("æä½æéä¸è¶³ï¼è¯·è系管ç人åï¼"); |
| | | return; |
| | | } |
| | | |
| | | std::vector<unsigned int> vidsExisting = pRpt->getVids(); |
| | | CReportEditDlg dlg(_T("ç¼è¾æ¥å"), (int)pRpt->getReportId(), vidsExisting, this); |
| | | if (dlg.DoModal() != IDOK) return; |
| | | const auto& vids = dlg.GetSelectedVids(); |
| | | |
| | | int ret = theApp.m_model.m_hsmsPassive.updateReport((int)pRpt->getReportId(), vids); |
| | | if (ret == 0) { |
| | | UX_RecordAction(L"editReports"); |
| | | m_listCtrl.DeleteAllItems(); |
| | | loadReports(); |
| | | if (CButton* pDel = GetBtnByName("å é¤")) pDel->EnableWindow(FALSE); |
| | | if (CButton* pEdit = GetBtnByName("ç¼è¾")) pEdit->EnableWindow(FALSE); |
| | | } |
| | | else { |
| | | AfxMessageBox(_T("ç¼è¾æ¥å失败ï¼å¯è½æä»¶åå
¥å¤±è´¥ï¼")); |
| | | } |
| | | } |
| | | } |
| | |
| | | m_nReportId = 0; |
| | | } |
| | | |
| | | CReport::CReport(unsigned int reportId, std::vector<unsigned int>& vids) |
| | | CReport::CReport(unsigned int reportId, const std::vector<unsigned int>& vids) |
| | | { |
| | | m_nReportId = reportId; |
| | | for (auto vid : vids) { |
| | | m_vids.push_back(vid); |
| | | } |
| | | m_vids = vids; |
| | | } |
| | | |
| | | CReport::~CReport() |
| | |
| | | { |
| | | public: |
| | | CReport(); |
| | | CReport(unsigned int reportId, std::vector<unsigned int>& vids); |
| | | CReport(unsigned int reportId, const std::vector<unsigned int>& vids); |
| | | virtual ~CReport(); |
| | | |
| | | public: |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #include "stdafx.h" |
| | | #include "CReportEditDlg.h" |
| | | #include "Servo.h" |
| | | #include "resource.h" |
| | | #include <algorithm> |
| | | |
| | | IMPLEMENT_DYNAMIC(CReportEditDlg, CDialogEx) |
| | | |
| | | CReportEditDlg::CReportEditDlg(const CString& title, int rptId, const std::vector<unsigned int>& vids, CWnd* pParent) |
| | | : CDialogEx(IDD_DIALOG_REPORT_EDIT, pParent) |
| | | , m_strTitle(title) |
| | | , m_rptId(rptId) |
| | | , m_vids(vids) |
| | | { |
| | | } |
| | | |
| | | CReportEditDlg::~CReportEditDlg() |
| | | { |
| | | } |
| | | |
| | | void CReportEditDlg::DoDataExchange(CDataExchange* pDX) |
| | | { |
| | | CDialogEx::DoDataExchange(pDX); |
| | | DDX_Control(pDX, IDC_EDIT_RPT_ID, m_editId); |
| | | DDX_Control(pDX, IDC_LIST_RPT_VARS, m_listVars); |
| | | } |
| | | |
| | | BEGIN_MESSAGE_MAP(CReportEditDlg, CDialogEx) |
| | | END_MESSAGE_MAP() |
| | | |
| | | BOOL CReportEditDlg::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | SetWindowText(m_strTitle); |
| | | |
| | | CString strId; |
| | | strId.Format(_T("%d"), m_rptId); |
| | | m_editId.SetWindowText(strId); |
| | | m_editId.SetReadOnly(TRUE); |
| | | |
| | | // åå§åå表 |
| | | m_listVars.SetExtendedStyle(m_listVars.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES); |
| | | m_listVars.InsertColumn(0, _T("ID"), LVCFMT_LEFT, 60); |
| | | m_listVars.InsertColumn(1, _T("åç§°"), LVCFMT_LEFT, 140); |
| | | m_listVars.InsertColumn(2, _T("æ ¼å¼"), LVCFMT_LEFT, 80); |
| | | |
| | | auto& vars = theApp.m_model.m_hsmsPassive.getVariables(); |
| | | for (int i = 0; i < (int)vars.size(); ++i) { |
| | | auto v = vars[i]; |
| | | if (v == nullptr) continue; |
| | | int idx = m_listVars.InsertItem(m_listVars.GetItemCount(), std::to_string(v->getVarialbleId()).c_str()); |
| | | m_listVars.SetItemText(idx, 1, v->getName().c_str()); |
| | | m_listVars.SetItemText(idx, 2, SERVO::CVariable::formatToString(v->getFormat()).c_str()); |
| | | m_listVars.SetItemData(idx, (DWORD_PTR)v->getVarialbleId()); |
| | | if (std::find(m_vids.begin(), m_vids.end(), v->getVarialbleId()) != m_vids.end()) { |
| | | m_listVars.SetCheck(idx, TRUE); |
| | | } |
| | | } |
| | | |
| | | return TRUE; |
| | | } |
| | | |
| | | void CReportEditDlg::OnOK() |
| | | { |
| | | std::vector<unsigned int> selected; |
| | | int count = m_listVars.GetItemCount(); |
| | | for (int i = 0; i < count; ++i) { |
| | | if (m_listVars.GetCheck(i)) { |
| | | selected.push_back((unsigned int)m_listVars.GetItemData(i)); |
| | | } |
| | | } |
| | | if (selected.empty()) { |
| | | AfxMessageBox(_T("è³å°éæ©ä¸ä¸ªåé")); |
| | | return; |
| | | } |
| | | m_vids.swap(selected); |
| | | CDialogEx::OnOK(); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #pragma once |
| | | #include "afxdialogex.h" |
| | | |
| | | // æ¥åç¼è¾å¯¹è¯æ¡ï¼æ°å¢/ç¼è¾å
±ç¨ï¼ |
| | | class CReportEditDlg : public CDialogEx |
| | | { |
| | | DECLARE_DYNAMIC(CReportEditDlg) |
| | | |
| | | public: |
| | | CReportEditDlg(const CString& title, int rptId, const std::vector<unsigned int>& vids, CWnd* pParent = nullptr); |
| | | virtual ~CReportEditDlg(); |
| | | |
| | | int GetReportId() const { return m_rptId; } |
| | | const std::vector<unsigned int>& GetSelectedVids() const { return m_vids; } |
| | | |
| | | protected: |
| | | virtual BOOL OnInitDialog() override; |
| | | virtual void DoDataExchange(CDataExchange* pDX) override; |
| | | afx_msg void OnOK(); |
| | | |
| | | DECLARE_MESSAGE_MAP() |
| | | |
| | | private: |
| | | CString m_strTitle; |
| | | int m_rptId; |
| | | std::vector<unsigned int> m_vids; |
| | | |
| | | CEdit m_editId; |
| | | CListCtrl m_listVars; |
| | | }; |
| | |
| | | UX_DefineAction(L"delVarialbles", L"å é¤åé", L"PE"); |
| | | UX_DefineAction(L"addVarialbles", L"æ°å¢åé", L"PE"); |
| | | UX_DefineAction(L"editVarialbles", L"ç¼è¾åé", L"PE"); |
| | | UX_DefineAction(L"addReports", L"æ°å¢Report", L"PE"); |
| | | UX_DefineAction(L"editReports", L"ç¼è¾Report", L"PE"); |
| | | UX_DefineAction(L"delReports", L"å é¤Report", L"PE"); |
| | | } |
| | | // ç¡®ä¿æéå®ä¹åå¨ï¼å¹çï¼ |
| | | UX_DefineAction(L"addVarialbles", L"æ°å¢åé", L"PE"); |
| | | UX_DefineAction(L"editVarialbles", L"ç¼è¾åé", L"PE"); |
| | | UX_DefineAction(L"delVarialbles", L"å é¤åé", L"PE"); |
| | | UX_DefineAction(L"addReports", L"æ°å¢Report", L"PE"); |
| | | UX_DefineAction(L"editReports", L"ç¼è¾Report", L"PE"); |
| | | UX_DefineAction(L"delReports", L"å é¤Report", L"PE"); |
| | | } |
| | | |
| | |
| | | return m_reports; |
| | | } |
| | | |
| | | unsigned int CHsmsPassive::getMaxReportId() const |
| | | { |
| | | unsigned int maxId = 0; |
| | | for (auto item : m_reports) { |
| | | if (item && item->getReportId() > maxId) { |
| | | maxId = item->getReportId(); |
| | | } |
| | | } |
| | | return maxId; |
| | | } |
| | | |
| | | SERVO::CReport* CHsmsPassive::getReport(int rptid) |
| | | { |
| | | for (auto item : m_reports) { |
| | |
| | | return writeReportsToFile(m_strReportFilepath); |
| | | } |
| | | |
| | | int CHsmsPassive::addReport(int rptid, const std::vector<unsigned int>& vids) |
| | | { |
| | | if (getReport(rptid) != nullptr) { |
| | | return -1; |
| | | } |
| | | SERVO::CReport* pReport = new SERVO::CReport(rptid, vids); |
| | | for (auto vid : vids) { |
| | | SERVO::CVariable* pVariable = getVariable((int)vid); |
| | | if (pVariable != nullptr) { |
| | | pReport->addVariable(pVariable); |
| | | } |
| | | } |
| | | m_reports.push_back(pReport); |
| | | return writeReportsToFile(m_strReportFilepath); |
| | | } |
| | | |
| | | int CHsmsPassive::updateReport(int rptid, const std::vector<unsigned int>& vids) |
| | | { |
| | | for (auto iter = m_reports.begin(); iter != m_reports.end(); ++iter) { |
| | | if ((*iter)->getReportId() == rptid) { |
| | | delete (*iter); |
| | | SERVO::CReport* pReport = new SERVO::CReport(rptid, vids); |
| | | for (auto vid : vids) { |
| | | SERVO::CVariable* pVariable = getVariable((int)vid); |
| | | if (pVariable != nullptr) { |
| | | pReport->addVariable(pVariable); |
| | | } |
| | | } |
| | | *iter = pReport; |
| | | return writeReportsToFile(m_strReportFilepath); |
| | | } |
| | | } |
| | | return -1; |
| | | } |
| | | |
| | | void CHsmsPassive::clearAllReport() |
| | | { |
| | | for (auto item : m_reports) { |
| | |
| | | |
| | | // åæ¶ define report |
| | | bool removeReport(int rptid); |
| | | int deleteReport(int rptid); |
| | | int addReport(int rptid, const std::vector<unsigned int>& vids); |
| | | int updateReport(int rptid, const std::vector<unsigned int>& vids); |
| | | void clearAllReport(); |
| | | |
| | | // 仿件ä¸å è½½CVariableå表 |
| | |
| | | |
| | | // åå¾Reportå表 |
| | | std::vector<SERVO::CReport*>& getReports(); |
| | | unsigned int getMaxReportId() const; |
| | | |
| | | // 仿件ä¸å è½½CCollectionEventå表 |
| | | int loadCollectionEvents(const char* pszFilepath); |
| | |
| | | |
| | | // åå¾Report |
| | | SERVO::CReport* getReport(int rptid); |
| | | int deleteReport(int rptid); |
| | | |
| | | void setListener(SECSListener listener); |
| | | unsigned OnCimWork(); |
| | |
| | | PUSHBUTTON "åæ¶",IDCANCEL,130,140,50,14 |
| | | END |
| | | |
| | | |
| | | |
| | | IDD_DIALOG_REPORT_EDIT DIALOGEX 0, 0, 320, 240 |
| | | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU |
| | | CAPTION "æ¥å" |
| | | FONT 8, "MS Shell Dlg", 400, 0, 0x1 |
| | | BEGIN |
| | | LTEXT "æ¥åIDï¼",IDC_STATIC,12,12,50,8 |
| | | EDITTEXT IDC_EDIT_RPT_ID,70,10,170,14,ES_AUTOHSCROLL | ES_READONLY |
| | | LTEXT "éæ©åéï¼",IDC_STATIC_SELECT_VARS,12,32,60,8 |
| | | CONTROL "",IDC_LIST_RPT_VARS,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,12,42,296,150 |
| | | DEFPUSHBUTTON "ç¡®å®",IDOK,170,200,50,14 |
| | | PUSHBUTTON "åæ¶",IDCANCEL,230,200,50,14 |
| | | END |
| | | |
| | | IDD_PAGE_LINK_SIGNAL DIALOGEX 0, 0, 543, 239 |
| | | STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU |
| | |
| | | <ClInclude Include="CCjPage1.h" /> |
| | | <ClInclude Include="CProcessDataListDlg.h" /> |
| | | <ClInclude Include="CReport.h" /> |
| | | <ClInclude Include="CReportEditDlg.h" /> |
| | | <ClInclude Include="CRobotCmdContainerDlg.h" /> |
| | | <ClInclude Include="CRobotCmdTestDlg.h" /> |
| | | <ClInclude Include="CPagePortStatus.h" /> |
| | |
| | | <ClCompile Include="CCjPage1.cpp" /> |
| | | <ClCompile Include="CProcessDataListDlg.cpp" /> |
| | | <ClCompile Include="CReport.cpp" /> |
| | | <ClCompile Include="CReportEditDlg.cpp" /> |
| | | <ClCompile Include="CRobotCmdContainerDlg.cpp" /> |
| | | <ClCompile Include="CRobotCmdTestDlg.cpp" /> |
| | | <ClCompile Include="CPagePortStatus.cpp" /> |
| | |
| | | <ClCompile Include="CCustomCheckBox.cpp" /> |
| | | <ClCompile Include="CCollectionEvent.cpp" /> |
| | | <ClCompile Include="CReport.cpp" /> |
| | | <ClCompile Include="CReportEditDlg.cpp"> |
| | | <Filter>Source Files</Filter> |
| | | </ClCompile> |
| | | <ClCompile Include="CVariable.cpp" /> |
| | | <ClCompile Include="CPageVarialbles.cpp" /> |
| | | <ClCompile Include="CPageReport.cpp" /> |
| | |
| | | <ClInclude Include="CCustomCheckBox.h" /> |
| | | <ClInclude Include="CCollectionEvent.h" /> |
| | | <ClInclude Include="CReport.h" /> |
| | | <ClInclude Include="CReportEditDlg.h"> |
| | | <Filter>Header Files</Filter> |
| | | </ClInclude> |
| | | <ClInclude Include="CVariable.h" /> |
| | | <ClInclude Include="CPageVarialbles.h" /> |
| | | <ClInclude Include="CPageReport.h" /> |
| | |
| | | #define IDD_DIALOG_LOGIN 163 |
| | | #define IDD_DIALOG_INPUT 164 |
| | | #define IDD_DIALOG_VARIABLE_EDIT2 186 |
| | | #define IDD_DIALOG_REPORT_EDIT 187 |
| | | #define IDD_PAGE_LINK_SIGNAL 165 |
| | | #define IDD_DIALOG_SYSTEM_LOG_MANAGER 166 |
| | | #define IDD_DIALOG_RECIPE_DEVICE_BIND 167 |
| | |
| | | #define IDC_EDIT_USER_PASSWORD 1232 |
| | | #define IDC_COMBO_USER_ROLE 1233 |
| | | #define IDC_CHECK_USER_ENABLED 1234 |
| | | #define IDC_LIST_RPT_VARS 1241 |
| | | #define IDC_STATIC_SELECT_VARS 1242 |
| | | #define IDC_EDIT_VAR_ID 1235 |
| | | #define IDC_COMBO_VAR_TYPE 1236 |
| | | #define IDC_EDIT_VAR_NAME 1237 |
| | | #define IDC_EDIT_VAR_REMARK 1238 |
| | | #define IDC_EDIT_RPT_ID 1239 |
| | | #define IDC_EDIT_RPT_VIDS 1240 |
| | | #define IDC_EDIT_VAR_ID 1235 |
| | | #define IDC_COMBO_VAR_TYPE 1236 |
| | | #define IDC_EDIT_VAR_NAME 1237 |
| | |
| | | // |
| | | #ifdef APSTUDIO_INVOKED |
| | | #ifndef APSTUDIO_READONLY_SYMBOLS |
| | | #define _APS_NEXT_RESOURCE_VALUE 187 |
| | | #define _APS_NEXT_RESOURCE_VALUE 188 |
| | | #define _APS_NEXT_COMMAND_VALUE 32802 |
| | | #define _APS_NEXT_CONTROL_VALUE 1239 |
| | | #define _APS_NEXT_CONTROL_VALUE 1243 |
| | | #define _APS_NEXT_SYMED_VALUE 101 |
| | | #endif |
| | | #endif |
| | |
| | | 50008,(5010) |
| | | 50009,(5011) |
| | | 50010,(5012) |
| | | |
| | | |
| | | 50011,(5013) |