From 9ea5eea16629a2ab4473727e6b064f83f71aa46c Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期一, 13 一月 2025 09:43:58 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
index 060a46e..3da6b35 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
@@ -138,14 +138,20 @@
 				}
 			}
 			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());
+				CPLC* pPlc;
+				if (pAny->getPtrValue("ptr", (void*&)pPlc) && pPlc == theApp.m_model.getCurrentPlc()) {
+					AlarmOn(pPlc);
+					CAlarmMonitor* pComponent = (CAlarmMonitor*)pPlc->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());
+				CPLC* pPlc;
+				if (pAny->getPtrValue("ptr", (void*&)pPlc) && pPlc == theApp.m_model.getCurrentPlc()) {
+					AlarmOff(pPlc);
+					CAlarmMonitor* pComponent = (CAlarmMonitor*)pPlc->getComponent(ALARM_MONITOR);
+					m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(pComponent->isAlarming());
+				}
 			}
 			pAny->release();
 		}, [&]() -> void {
@@ -645,22 +651,22 @@
 	m_pMainContainer->Resize();
 }
 
-void CBoounionPLCDlg::AlarmOn()
+void CBoounionPLCDlg::AlarmOn(CPLC* pPlc)
 {
 	if (m_pAlarmWnd == nullptr) {
 		m_pAlarmWnd = new CAlarmPopupDlg();
-		//m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+		m_pAlarmWnd->SetPLC(pPlc);
 		m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this);
 		m_pAlarmWnd->CenterWindow();
 	}
 	m_pAlarmWnd->AlarmOn();
 }
 
-void CBoounionPLCDlg::AlarmOff()
+void CBoounionPLCDlg::AlarmOff(CPLC* pPlc)
 {
 	if (m_pAlarmWnd == nullptr) {
 		m_pAlarmWnd = new CAlarmPopupDlg();
-		//m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+		m_pAlarmWnd->SetPLC(pPlc);
 		m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this);
 		m_pAlarmWnd->CenterWindow();
 	}

--
Gitblit v1.9.3