From 35199ad4aaa3f35ff82da77d7108a4e9f136443e Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期五, 06 十二月 2024 17:49:56 +0800
Subject: [PATCH] 1.修改配方管理模块,定位点等参数有最大值最小值 2.同步修改合并轴管理界面3.IO界面显示16个,16个为一组
---
SourceCode/Bond/BondEq/BondEqDlg.cpp | 127 ++++++++++++++++++++++++++++++++++--------
1 files changed, 103 insertions(+), 24 deletions(-)
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.cpp b/SourceCode/Bond/BondEq/BondEqDlg.cpp
index 1a8a2ec..498f7af 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.cpp
+++ b/SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -8,13 +8,13 @@
#include "afxdialogex.h"
#include "Common.h"
#include "CBonder.h"
+#include "ToolUnits.h"
#include "SettingsDlg.h"
-#include "UserManager.h"
-#include "SystemLogManager.h"
+#include "InputDialog.h"
#include "LoginDlg.h"
#include "ChangePasswordDlg.h"
-#include "InputDialog.h"
#include "UserManagerDlg.h"
+#include "SystemLogManagerDlg.h"
#ifdef _DEBUG
@@ -71,6 +71,7 @@
m_pMainContainer = nullptr;
m_pHomeDialog = nullptr;
m_pActiveView = nullptr;
+ m_pActiveComponentDlg = nullptr;
}
void CBondEqDlg::DoDataExchange(CDataExchange* pDX)
@@ -131,7 +132,26 @@
}
}
}
+ else if (RX_CODE_SELECT_COMPONENT == code) {
+ CComponent* pComponent;
+ if (pAny->getPtrValue("ptr", (void*&)pComponent)) {
+ if (pComponent->getClassName().compare("CPLC") == 0) {
+ if (m_pMainContainer != nullptr) {
+ if (m_pActiveComponentDlg != nullptr) {
+ if (m_pActiveComponentDlg->GetContext() != (void*)pComponent) {
+ m_pActiveComponentDlg->DestroyWindow();
+ delete m_pActiveComponentDlg;
+ m_pActiveComponentDlg = nullptr;
+ }
+ }
+ if (m_pActiveComponentDlg == nullptr) {
+ m_pActiveComponentDlg = CreateComponentPLCDlg(pComponent);
+ }
+ }
+ }
+ }
+ }
pAny->release();
}, [&]() -> void {
// onComplete
@@ -184,21 +204,29 @@
userManager.loadSession();
std::unique_ptr<BL::Database>& db = userManager.getDatabaseInstance();
- // 设置日志模块的数据库连接
+ // 设置运行日志模块的数据库连接
SystemLogManager& logManager = SystemLogManager::getInstance();
- logManager.setDatabase(db);
+ logManager.setDatabase(db.get());
- // 初始化日志表
- if (!logManager.initializeLogTable()) {
- AfxMessageBox("初始化系统日志表失败!");
+ // 初始化运行日志表
+ try {
+ if (!logManager.initializeLogTable()) {
+ AfxMessageBox("初始化系统日志模块失败!");
+ return FALSE;
+ }
+ }
+ catch (const std::exception& ex) {
+ CString errorMsg;
+ errorMsg.Format(_T("初始化系统日志模块失败:%s"), CString(ex.what()));
+ AfxMessageBox(errorMsg, MB_ICONERROR);
return FALSE;
}
- std::string strUsername = userManager.getCurrentUser();
- if (strUsername.empty()) {
- strUsername = "SYSTEM";
- }
- logManager.log(SystemLogManager::LogType::Info, _T("BondEq启动..."), strUsername);
+ // 设置配方文件夹路径
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ std::string strRecipePath = CToolUnits::getCurrentExePath() + _T("\\Recipe");
+ CToolUnits::createDir(strRecipePath.c_str());
+ recipeManager.setRecipeFolder(strRecipePath);
// 菜单
@@ -243,6 +271,7 @@
// 更新登录状态
UpdateLoginStatus();
+ logManager.log(SystemLogManager::LogType::Info, _T("BondEq启动..."));
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
@@ -354,6 +383,12 @@
m_pActiveView = nullptr;
}
+ if (m_pActiveComponentDlg != nullptr) {
+ m_pActiveComponentDlg->DestroyWindow();
+ delete m_pActiveComponentDlg;
+ m_pActiveComponentDlg = nullptr;
+ }
+
if (m_hbrBkgnd != nullptr) {
::DeleteObject(m_hbrBkgnd);
}
@@ -368,11 +403,7 @@
KillTimer(1);
#endif
- std::string strUsername = UserManager::getInstance().getCurrentUser();
- if (strUsername.empty()) {
- strUsername = "SYSTEM";
- }
- SystemLogManager::getInstance().log(SystemLogManager::LogType::Info, _T("BondEq关闭..."), strUsername);
+ SystemLogManager::getInstance().log(SystemLogManager::LogType::Info, _T("BondEq关闭..."));
}
void CBondEqDlg::OnSize(UINT nType, int cx, int cy)
@@ -524,7 +555,7 @@
{
int id = (int)lParam;
if (id == VIEW_TOOL_BTN_CLOSE) {
- CloseView((CBaseView*)wParam);
+ CloseView((CComponentDlg*)wParam);
}
return 0;
@@ -533,6 +564,7 @@
LRESULT CBondEqDlg::OnToolbarBtnClicked(WPARAM wParam, LPARAM lParam)
{
int id = (int)lParam;
+ SystemLogManager& logManager = SystemLogManager::getInstance();
if (id == IDC_BUTTON_RUN || id == IDC_BUTTON_STOP || id == IDC_BUTTON_SETTINGS)
{
CInputDialog inputDialog(_T("验证用户"), _T("请输入用户密码:"));
@@ -545,6 +577,7 @@
std::string strPass = UserManager::getInstance().getCurrentPass();
if (inputText.Compare(strPass.c_str()) != 0) {
AfxMessageBox(_T("密码错误!"));
+ logManager.log(SystemLogManager::LogType::Info, _T("验证时,密码错误!"));
return 0;
}
}
@@ -552,10 +585,12 @@
if (id == IDC_BUTTON_RUN) {
m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(FALSE);
m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(TRUE);
+ logManager.log(SystemLogManager::LogType::Operation, _T("运行..."));
}
else if (id == IDC_BUTTON_STOP) {
m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE);
m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
+ logManager.log(SystemLogManager::LogType::Operation, _T("停止..."));
}
else if (id == IDC_BUTTON_SETTINGS) {
CSettingsDlg dlg;
@@ -574,15 +609,23 @@
}
else if (2 == menuId) {
CUserManagerDlg dlg;
- dlg.DoModal();
+ if (dlg.DoModal()!= IDOK) {
+ logManager.log(SystemLogManager::LogType::Operation, _T("用户管理的预操作被取消!"));
+ }
}
else if (3 == menuId) {
- int ret = AfxMessageBox(_T("是否切换用户?切换用户会退出当前账号!"), MB_OK | MB_ICONEXCLAMATION);
- if (ret != MB_OK) {
+ CSystemLogManagerDlg dlg;
+ dlg.DoModal();
+ }
+ else if (4 == menuId) {
+ int ret = AfxMessageBox(_T("是否切换用户?切换用户会退出当前账号!"), MB_OKCANCEL | MB_ICONEXCLAMATION);
+ if (ret != IDOK) {
return 0;
}
+ logManager.log(SystemLogManager::LogType::Operation, _T("确认切换角色!"));
if (userManager.isLoggedIn()) {
+ logManager.log(SystemLogManager::LogType::Info, _T("退出登录!"));
userManager.logout();
}
@@ -592,11 +635,12 @@
else {
CString cstrMessage;
cstrMessage.Format(_T("是否退出用户 [%s]?"), userManager.getCurrentUser().c_str());
- int ret = AfxMessageBox(_T(cstrMessage), MB_OK | MB_ICONEXCLAMATION);
- if (ret != MB_OK) {
+ int ret = AfxMessageBox(_T(cstrMessage), MB_OKCANCEL | MB_ICONEXCLAMATION);
+ if (ret != IDOK) {
return 0;
}
+ logManager.log(SystemLogManager::LogType::Info, _T("退出登录!"));
userManager.logout();
}
@@ -618,6 +662,14 @@
pView->DestroyWindow();
delete (CBaseView*)pView;
m_pActiveView = nullptr;
+ m_pMainContainer->Resize();
+}
+
+void CBondEqDlg::CloseView(CComponentDlg* pView)
+{
+ pView->DestroyWindow();
+ delete pView;
+ m_pActiveComponentDlg = nullptr;
m_pMainContainer->Resize();
}
@@ -680,6 +732,7 @@
{
::EnableMenuItem(hMenu, ID_OPEATOR_LOGIN, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
::EnableMenuItem(hMenu, ID_OPERATOR_CHANGE_PASSWORD, MF_BYCOMMAND | MF_ENABLED);
+ ::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);
@@ -696,9 +749,35 @@
::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("未登录"));
}
}
+
+CComponentPLCDlg* CBondEqDlg::CreateComponentPLCDlg(CComponent* pComponent)
+{
+ CComponentPLCDlg* pDlg = new CComponentPLCDlg(m_pMainContainer);
+ pDlg->SetContext(pComponent);
+ pDlg->Create(IDD_COMPONENT_PLC, m_pMainContainer);
+
+
+ CString strIcon0, strIcon1, strIcon2, strIcon3;
+ strIcon0.Format(_T("%s\\Res\\small_close0.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ strIcon1.Format(_T("%s\\Res\\small_close1.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ strIcon2.Format(_T("%s\\Res\\small_close2.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ strIcon3.Format(_T("%s\\Res\\small_close3.ico"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+ pDlg->AddToolBtn(VIEW_TOOL_BTN_CLOSE,
+ (LPTSTR)(LPCTSTR)strIcon0,
+ (LPTSTR)(LPCTSTR)strIcon1,
+ (LPTSTR)(LPCTSTR)strIcon2,
+ (LPTSTR)(LPCTSTR)strIcon3, "关闭");
+ pDlg->ShowWindow(SW_SHOW);
+ pDlg->SetWindowText(pComponent->getName().c_str());
+ m_pMainContainer->Resize();
+
+ return pDlg;
+}
+
--
Gitblit v1.9.3