From bfe14e41fa5b07771d78af4511ba18d706bc23cc Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 28 七月 2025 17:07:52 +0800
Subject: [PATCH] 1.Spooling Config功能EAP模拟测试;
---
SourceCode/Bond/BondEq/BondEqDlg.cpp | 159 +++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 137 insertions(+), 22 deletions(-)
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.cpp b/SourceCode/Bond/BondEq/BondEqDlg.cpp
index 63256a0..cabcaf7 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.cpp
+++ b/SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -16,9 +16,8 @@
#include "UserManagerDlg.h"
#include "SystemLogManagerDlg.h"
-// test
-#include "AxisSettingsDlg.h"
-#include "IOMonitoringDlg.h"
+// 测试
+#include "RecipeListDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -74,6 +73,8 @@
m_pMainContainer = nullptr;
m_pHomeDialog = nullptr;
m_pActiveView = nullptr;
+ m_pActiveComponentDlg = nullptr;
+ m_pAlarmWnd = nullptr;
}
void CBondEqDlg::DoDataExchange(CDataExchange* pDX)
@@ -134,7 +135,36 @@
}
}
}
+ 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);
+ }
+ }
+ }
+ }
+ }
+ else if (code == RX_CODE_ALARM_ON) {
+ AlarmOn();
+ CAlarmMonitor* pComponent = (CAlarmMonitor*)theApp.m_model.getBonder().GetComponent(ALARM_MONITOR);
+ m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming());
+ }
+ else if (code == RX_CODE_ALARM_OFF) {
+ AlarmOff();
+ CAlarmMonitor* pComponent = (CAlarmMonitor*)theApp.m_model.getBonder().GetComponent(ALARM_MONITOR);
+ m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming());
+ }
pAny->release();
}, [&]() -> void {
// onComplete
@@ -205,12 +235,30 @@
return FALSE;
}
+ // 初始化报警模块
+ AlarmManager& alarmManager = AlarmManager::getInstance();
+ alarmManager.setDatabase(db.get());
+ try {
+ if (!alarmManager.initializeAlarmTable()) {
+ AfxMessageBox("初始化报警模块失败!");
+ return FALSE;
+ }
+ }
+ catch (const std::exception& ex) {
+ CString errorMsg;
+ errorMsg.Format(_T("初始化报警模块失败:%s"), CString(ex.what()));
+ AfxMessageBox(errorMsg, MB_ICONERROR);
+ return FALSE;
+ }
+
// 设置配方文件夹路径
RecipeManager& recipeManager = RecipeManager::getInstance();
- std::string strRecipePath = CToolUnits::getCurrentExePath() + _T("\\Recipe");
+ std::string strRecipePath = CToolUnits::getRecipePath();
CToolUnits::createDir(strRecipePath.c_str());
recipeManager.setRecipeFolder(strRecipePath);
-
+ if (!recipeManager.loadRecipe("Default")) {
+ AfxMessageBox("Default 配方加载失败!");
+ }
// 菜单
CMenu menu;
@@ -227,6 +275,7 @@
m_pTopToolbar->Create(IDD_TOP_TOOLBAR, this);
m_pTopToolbar->ShowWindow(SW_SHOW);
m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(FALSE);
+ m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(FALSE);
HMENU hMenu = m_pTopToolbar->GetOperatorMenu();
ASSERT(hMenu);
::EnableMenuItem(hMenu, ID_OPEATOR_SWITCH, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
@@ -255,6 +304,13 @@
// 更新登录状态
UpdateLoginStatus();
logManager.log(SystemLogManager::LogType::Info, _T("BondEq启动..."));
+
+
+ // 自动启动
+ theApp.m_model.getBonder().start();
+ m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(FALSE);
+ m_pTopToolbar->GetBtn(IDC_BUTTON_STOP)->EnableWindow(TRUE);
+ logManager.log(SystemLogManager::LogType::Operation, _T("运行..."));
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
@@ -366,8 +422,19 @@
m_pActiveView = nullptr;
}
+ if (m_pActiveComponentDlg != nullptr) {
+ m_pActiveComponentDlg->DestroyWindow();
+ delete m_pActiveComponentDlg;
+ m_pActiveComponentDlg = nullptr;
+ }
+
if (m_hbrBkgnd != nullptr) {
::DeleteObject(m_hbrBkgnd);
+ }
+
+ if (m_pAlarmWnd != nullptr) {
+ m_pAlarmWnd->DestroyWindow();
+ delete m_pAlarmWnd;
}
ASSERT(m_pObserver != NULL);
@@ -482,24 +549,11 @@
void CBondEqDlg::OnMenuFileSettings()
{
- /*
- CAxisSettingsDlg axisDlg;
- axisDlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
- axisDlg.SetRecipeName(_T("Default"));
- axisDlg.DoModal();
- */
-
- // Cavity VacuumBake AfterBake AOI
- CIOMonitoringDlg dlg;
- dlg.SetIOManager("Cavity");
- dlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+ CRecipeListDlg dlg;
dlg.DoModal();
-
- /*
- CSettingsDlg dlg;
- dlg.DoModal();
- */
+ //CSettingsDlg dlg;
+ //dlg.DoModal();
}
void CBondEqDlg::OnUpdateMenuFileSettings(CCmdUI* pCmdUI)
@@ -548,7 +602,7 @@
{
int id = (int)lParam;
if (id == VIEW_TOOL_BTN_CLOSE) {
- CloseView((CBaseView*)wParam);
+ CloseView((CComponentDlg*)wParam);
}
return 0;
@@ -566,6 +620,7 @@
return 0;
}
+ /*
CString inputText = inputDialog.GetInputText();
std::string strPass = UserManager::getInstance().getCurrentPass();
if (inputText.Compare(strPass.c_str()) != 0) {
@@ -573,17 +628,23 @@
logManager.log(SystemLogManager::LogType::Info, _T("验证时,密码错误!"));
return 0;
}
+ */
}
if (id == IDC_BUTTON_RUN) {
+ theApp.m_model.getBonder().start();
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) {
+ theApp.m_model.getBonder().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_ALARM) {
+ AlarmOn();
}
else if (id == IDC_BUTTON_SETTINGS) {
CSettingsDlg dlg;
@@ -655,6 +716,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();
}
@@ -741,3 +810,49 @@
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;
+}
+
+void CBondEqDlg::AlarmOn()
+{
+ if (m_pAlarmWnd == nullptr) {
+ m_pAlarmWnd = new CAlarmPopupDlg();
+ m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+ m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this);
+ m_pAlarmWnd->CenterWindow();
+ }
+ m_pAlarmWnd->AlarmOn();
+}
+
+void CBondEqDlg::AlarmOff()
+{
+ if (m_pAlarmWnd == nullptr) {
+ m_pAlarmWnd = new CAlarmPopupDlg();
+ m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+ m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this);
+ m_pAlarmWnd->CenterWindow();
+ }
+ m_pAlarmWnd->AlarmOff();
+}
--
Gitblit v1.9.3