| | |
| | | #include "CRobotCmdContainerDlg.h" |
| | | #include "CRobotCmdTestDlg.h" |
| | | #include "LoginDlg.h" |
| | | #include "LoginDlg2.h" |
| | | #include "ChangePasswordDlg.h" |
| | | #include "UserManagerDlg.h" |
| | | #include "SystemLogManagerDlg.h" |
| | |
| | | #include "InputDialog.h" |
| | | #include "ClientListDlg.h" |
| | | #include "CControlJobManagerDlg.h" |
| | | #include "CUserManager2.h" |
| | | #include "CUserManager2Dlg.h" |
| | | #include "CUserXLogDlg.h" |
| | | |
| | | |
| | | #ifdef _DEBUG |
| | |
| | | #define TIMER_ID_UPDATE_RUMTIME 2 |
| | | |
| | | /* Test */ |
| | | #define TIMER_ID_TEST 3 |
| | | #define TIMER_ID_LOGIN 3 |
| | | |
| | | |
| | | // 用于应用程序“关于”菜单项的 CAboutDlg 对话框 |
| | |
| | | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); |
| | | m_crBkgnd = APPDLG_BACKGROUND_COLOR; |
| | | m_hbrBkgnd = nullptr; |
| | | m_nLeftPanelType = 2; |
| | | m_pTerminalDisplayDlg = nullptr; |
| | | m_pObserver = nullptr; |
| | | m_pPanelMaster = nullptr; |
| | | m_pPanelProduction = nullptr; |
| | | m_pPanelEquipment = nullptr; |
| | | m_pPanelAttributes = nullptr; |
| | | m_pPageGraph1 = nullptr; |
| | |
| | | ON_UPDATE_COMMAND_UI(ID_MENU_TEST_MESSAGE_CLEAR, &CServoDlg::OnUpdateMenuTestMessageClear) |
| | | ON_COMMAND(ID_MENU_TOOLS_CLIENT_LIST, &CServoDlg::OnMenuToolsClientList) |
| | | ON_UPDATE_COMMAND_UI(ID_MENU_TOOLS_CLIENT_LIST, &CServoDlg::OnUpdateMenuToolsClientList) |
| | | ON_COMMAND(ID_MENU_WND_TEST_PANEL, &CServoDlg::OnMenuWndTestPanel) |
| | | ON_UPDATE_COMMAND_UI(ID_MENU_WND_TEST_PANEL, &CServoDlg::OnUpdateMenuWndTestPanel) |
| | | ON_COMMAND(ID_MENU_WND_PRO_PANEL, &CServoDlg::OnMenuWndProPanel) |
| | | ON_UPDATE_COMMAND_UI(ID_MENU_WND_PRO_PANEL, &CServoDlg::OnUpdateMenuWndProPanel) |
| | | ON_COMMAND(ID_MENU_HELP_ABOUT, &CServoDlg::OnMenuHelpAbout) |
| | | ON_WM_INITMENUPOPUP() |
| | | ON_WM_TIMER() |
| | |
| | | else if (RX_CODE_MASTER_STATE_CHANGED == code) { |
| | | SERVO::MASTERSTATE state = theApp.m_model.getMaster().getState(); |
| | | if (state == SERVO::MASTERSTATE::READY) { |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE); |
| | | m_pTopToolbar ->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE); |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_RUN_BATCH)->EnableWindow(TRUE); |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_RUN_CT)->EnableWindow(TRUE); |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE); |
| | |
| | | |
| | | if (STATE::NOT_CONNECTED == state) { |
| | | m_pMyStatusbar->setCimBtnText("Disconnected"); |
| | | //m_labelPassiveState.setBackground(DISCONNECTED_BACKGROUND); |
| | | //m_labelPassiveState.setForeground(DISCONNECTED_FOREGROUND, TRUE); |
| | | m_pMyStatusbar->setCimBtnColors( |
| | | CIM_STATUS_BK_DISCONNECTED, CIM_STATUS_BK_DISCONNECTED, RGB(0, 0, 0)); |
| | | } |
| | | else if (STATE::NOT_SELECTED == state) { |
| | | m_pMyStatusbar->setCimBtnText("Not Selected"); |
| | | //m_labelPassiveState.setBackground(NOT_SELECTED_BACKGROUND); |
| | | //m_labelPassiveState.setForeground(NOT_SELECTED_FOREGROUND, TRUE); |
| | | m_pMyStatusbar->setCimBtnColors( |
| | | CIM_STATUS_BK_DISCONNECTED, CIM_STATUS_BK_DISCONNECTED, RGB(0, 0, 0)); |
| | | } |
| | | else if (STATE::SELECTED == state) { |
| | | m_pMyStatusbar->setCimBtnText("Selected"); |
| | | //m_labelPassiveState.setBackground(SELECTED_BACKGROUND); |
| | | //m_labelPassiveState.setForeground(SELECTED_FOREGROUND, TRUE); |
| | | m_pMyStatusbar->setCimBtnColors( |
| | | CIM_STATUS_BK_SELECTED, CIM_STATUS_BK_SELECTED, RGB(0, 0, 0)); |
| | | } |
| | | } |
| | | pAny->release(); |
| | |
| | | |
| | | // model init |
| | | theApp.m_model.init(); |
| | | SetTimer(TIMER_ID_TEST, 1000, nullptr); |
| | | SetTimer(TIMER_ID_LOGIN, 1500, nullptr); |
| | | |
| | | // 菜单 |
| | | CMenu menu; |
| | |
| | | m_pTab->SetBkgndColor(RGB(222, 222, 222)); |
| | | ShowChildPage(0); |
| | | |
| | | // 读取面板宽 |
| | | CString strIniFile; |
| | | strIniFile.Format(_T("%s\\%s.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, (LPTSTR)(LPCTSTR)theApp.m_strAppFile); |
| | | int nPanelWidth = GetPrivateProfileInt(_T("App"), _T("MasterPanelWidth"), |
| | | int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25), (LPTSTR)(LPCTSTR)strIniFile); |
| | | |
| | | m_pPanelMaster = new CPanelMaster(); |
| | | m_pPanelMaster->setPanelWidth(nPanelWidth); |
| | | m_pPanelMaster->Create(IDD_PANEL_MASTER, this); |
| | | m_pPanelMaster->ShowWindow(SW_SHOW); |
| | | m_pPanelProduction = new CPanelProduction(); |
| | | m_pPanelProduction->setPanelWidth(nPanelWidth); |
| | | m_pPanelProduction->Create(IDD_PANEL_PRODUCTION, this); |
| | | SetLeftPanelType(m_nLeftPanelType, false); |
| | | m_pPanelEquipment = new CPanelEquipment(); |
| | | m_pPanelEquipment->Create(IDD_PANEL_EQUIPMENT, this); |
| | | m_pPanelAttributes = new CPanelAttributes(); |
| | |
| | | pPage3->Create(IDD_PAGE_VARIABLE); |
| | | dlg.addPage(pPage3, "Variable"); |
| | | |
| | | CPageDataVarialbles* pPage4 = new CPageDataVarialbles(); |
| | | pPage4->Create(IDD_PAGE_VARIABLE); |
| | | dlg.addPage(pPage4, "DataVariable"); |
| | | |
| | | dlg.DoModal(); |
| | | } |
| | | |
| | |
| | | void CServoDlg::OnUpdateMenuToolsClientList(CCmdUI* pCmdUI) |
| | | { |
| | | pCmdUI->Enable(TRUE); |
| | | } |
| | | |
| | | void CServoDlg::OnMenuWndTestPanel() |
| | | { |
| | | SetLeftPanelType(1); |
| | | } |
| | | |
| | | void CServoDlg::OnUpdateMenuWndTestPanel(CCmdUI* pCmdUI) |
| | | { |
| | | pCmdUI->Enable(TRUE); |
| | | pCmdUI->SetCheck(m_nLeftPanelType == 1); |
| | | } |
| | | |
| | | void CServoDlg::OnMenuWndProPanel() |
| | | { |
| | | SetLeftPanelType(2); |
| | | } |
| | | |
| | | void CServoDlg::OnUpdateMenuWndProPanel(CCmdUI* pCmdUI) |
| | | { |
| | | pCmdUI->Enable(TRUE); |
| | | pCmdUI->SetCheck(m_nLeftPanelType == 2); |
| | | } |
| | | |
| | | void CServoDlg::OnMenuHelpAbout() |
| | |
| | | m_pPanelMaster->DestroyWindow(); |
| | | delete m_pPanelMaster; |
| | | m_pPanelMaster = nullptr; |
| | | } |
| | | |
| | | if (m_pPanelProduction != nullptr) { |
| | | m_pPanelProduction->DestroyWindow(); |
| | | delete m_pPanelProduction; |
| | | m_pPanelProduction = nullptr; |
| | | } |
| | | |
| | | if (m_pPanelEquipment != nullptr) { |
| | |
| | | |
| | | |
| | | int nPanelWidth = 0; |
| | | if (m_pPanelMaster != nullptr) { |
| | | if (m_pPanelMaster != nullptr && ::IsWindow(m_pPanelMaster->GetSafeHwnd()) |
| | | && m_pPanelMaster->IsWindowVisible()) { |
| | | nPanelWidth = m_pPanelMaster->getPanelWidth(); |
| | | m_pPanelMaster->MoveWindow(x, y, nPanelWidth, y2 - y); |
| | | x += nPanelWidth; |
| | | } |
| | | |
| | | if (m_pPanelProduction != nullptr && m_pPanelProduction->IsWindowVisible()) { |
| | | nPanelWidth = m_pPanelProduction->getPanelWidth(); |
| | | m_pPanelProduction->MoveWindow(x, y, nPanelWidth, y2 - y); |
| | | x += nPanelWidth; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | m_pMyStatusbar->MoveWindow(0, y2, rcClient.Width(), STATUSBAR_HEIGHT); |
| | | } |
| | | |
| | | void CServoDlg::SetLeftPanelType(int type, bool resize) |
| | | { |
| | | if (type != 1 && type != 2) { |
| | | type = 1; |
| | | } |
| | | |
| | | m_nLeftPanelType = type; |
| | | if (m_pPanelMaster != nullptr) { |
| | | m_pPanelMaster->ShowWindow(SW_HIDE); |
| | | } |
| | | if (m_pPanelProduction != nullptr) { |
| | | m_pPanelProduction->ShowWindow(SW_HIDE); |
| | | } |
| | | if (type == 1 && m_pPanelMaster != nullptr) { |
| | | m_pPanelMaster->ShowWindow(SW_SHOW); |
| | | } |
| | | else if (type == 2 && m_pPanelProduction != nullptr) { |
| | | m_pPanelProduction->ShowWindow(SW_SHOW); |
| | | } |
| | | |
| | | if (resize && ::IsWindow(m_hWnd)) { |
| | | Resize(); |
| | | DrawMenuBar(); |
| | | } |
| | | } |
| | | |
| | | void CServoDlg::OnClose() |
| | |
| | | m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)strText); |
| | | } |
| | | |
| | | else if(TIMER_ID_TEST == nIDEvent){ |
| | | static __int64 tttt = 0; |
| | | tttt++; |
| | | theApp.m_model.m_hsmsPassive.setVariableValue("CJobSpace", tttt % 10); |
| | | theApp.m_model.m_hsmsPassive.setVariableValue("PJobSpace", tttt % 5); |
| | | else if(TIMER_ID_LOGIN == nIDEvent){ |
| | | KillTimer(TIMER_ID_LOGIN); |
| | | if (!CUserManager2::getInstance().isLoggedIn()) { |
| | | CLoginDlg2 dlg; |
| | | if (dlg.DoModal() != IDOK) { |
| | | PostMessage(WM_CLOSE); |
| | | } |
| | | else { |
| | | bool bRet = CUserManager2::getInstance().login((LPTSTR)(LPCTSTR)dlg.m_strUsername, |
| | | (LPTSTR)(LPCTSTR)dlg.m_strPassword); |
| | | if (!bRet) { |
| | | AfxMessageBox("登录失败,请检查用户名或密码是否正确!"); |
| | | PostMessage(WM_CLOSE); |
| | | } |
| | | UpdateLoginStatus(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | LRESULT CServoDlg::OnPanelResize(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | int width = (int)wParam; |
| | | // m_pPanel->SetPanelWidth(width); |
| | | |
| | | if (m_pPanelMaster != nullptr) { |
| | | m_pPanelMaster->setPanelWidth(width); |
| | | } |
| | | if (m_pPanelProduction != nullptr) { |
| | | m_pPanelProduction->setPanelWidth(width); |
| | | } |
| | | |
| | | CString strIniFile, strValue; |
| | | strIniFile.Format(_T("%s\\%s.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, (LPTSTR)(LPCTSTR)theApp.m_strAppFile); |
| | | strValue.Format(_T("%d"), width); |
| | | WritePrivateProfileString(_T("App"), _T("MasterPanelWidth"), |
| | | (LPTSTR)(LPCTSTR)strValue, (LPTSTR)(LPCTSTR)strIniFile); |
| | | |
| | | Resize(); |
| | | |
| | | return 0; |
| | |
| | | void CServoDlg::UpdateLoginStatus() |
| | | { |
| | | HMENU hMenu = m_pTopToolbar->GetOperatorMenu(); |
| | | UserManager& userManager = UserManager::getInstance(); |
| | | if (userManager.isLoggedIn()) |
| | | { |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | ::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_ENABLED); |
| | | CUserManager2& userManager = CUserManager2::getInstance(); |
| | | if (userManager.isLoggedIn()) { |
| | | ::EnableMenuItem(hMenu, ID_OPERATOR_SYSTEM_LOG, MF_BYCOMMAND | MF_ENABLED); |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_ENABLED); |
| | | ::EnableMenuItem(hMenu, ID_OPERATOR_LOGOUT, MF_BYCOMMAND | MF_ENABLED); |
| | | |
| | | if (userManager.getCurrentUserRole() == UserRole::SuperAdmin) { |
| | | if (userManager.IsAdminCurrent()) { |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_ENABLED); |
| | | } |
| | | else { |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | } |
| | | |
| | | m_pTopToolbar->SetOperatorBtnText(userManager.getCurrentUser().c_str()); |
| | | m_pTopToolbar->SetOperatorBtnText(userManager.getCurrentUserName().c_str()); |
| | | } |
| | | else { |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_ENABLED); |
| | | ::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_USER_MANAGER, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | ::EnableMenuItem(hMenu, ID_OPERATOR_SYSTEM_LOG, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | ::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | ::EnableMenuItem(hMenu, ID_OPERATOR_LOGOUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); |
| | | |
| | | m_pTopToolbar->SetOperatorBtnText(_T("未登录")); |
| | | } |
| | | } |
| | |
| | | LRESULT CServoDlg::OnToolbarBtnClicked(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | int id = (int)lParam; |
| | | if (id == IDC_BUTTON_RUN || id == IDC_BUTTON_STOP) { |
| | | UserRole emRole = UserManager::getInstance().getCurrentUserRole(); |
| | | if (emRole != UserRole::SuperAdmin) { |
| | | AfxMessageBox(_T("当前用户并非管理员!!!")); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | if (id == IDC_BUTTON_RUN) { |
| | | int rc = UX_CanExecute(L"start"); |
| | | if (rc != 1) { |
| | | AfxMessageBox("操作权限不足,请联系管理人员!"); |
| | | return 0; |
| | | } |
| | | UX_RecordAction(L"start"); |
| | | |
| | | if (theApp.m_model.getMaster().getState() == SERVO::MASTERSTATE::MSERROR) { |
| | | AfxMessageBox("当前有机台发生错误,不能启动,请确认解决问题后再尝试重新启动!"); |
| | | } |
| | |
| | | } |
| | | } |
| | | else if (id == IDC_BUTTON_STOP) { |
| | | int rc = UX_CanExecute(L"stop"); |
| | | if (rc != 1) { |
| | | AfxMessageBox("操作权限不足,请联系管理人员!"); |
| | | return 0; |
| | | } |
| | | UX_RecordAction(L"stop"); |
| | | |
| | | if (theApp.m_model.getMaster().stop() == 0) { |
| | | m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE); |
| | | } |
| | |
| | | } |
| | | else if (id == IDC_BUTTON_OPERATOR) { |
| | | int menuId = (int)wParam; |
| | | if (menuId == 0) { |
| | | CUserManager2Dlg dlg; |
| | | dlg.DoModal(); |
| | | } |
| | | else if (menuId == 1) { |
| | | CUserXLogDlg dlg; |
| | | dlg.DoModal(); |
| | | } |
| | | else if (menuId == 2) { |
| | | CLoginDlg2 dlg; |
| | | if (dlg.DoModal() == IDOK) { |
| | | bool bRet = CUserManager2::getInstance().login((LPTSTR)(LPCTSTR)dlg.m_strUsername, |
| | | (LPTSTR)(LPCTSTR)dlg.m_strPassword); |
| | | if (!bRet) { |
| | | AfxMessageBox("登录失败,请检查用户名或密码是否正确!"); |
| | | } |
| | | UpdateLoginStatus(); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | SystemLogManager& logManager = SystemLogManager::getInstance(); |
| | | UserManager& userManager = UserManager::getInstance(); |
| | | if (menuId == 0) { |
| | |
| | | } |
| | | |
| | | UpdateLoginStatus(); |
| | | */ |
| | | } |
| | | |
| | | return 0; |
| | |
| | | } |
| | | |
| | | return strText; |
| | | } |
| | | } |