From 4a1d72850cf1d28c3f5f99f93dcb0136089a0918 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期二, 03 十二月 2024 16:34:33 +0800
Subject: [PATCH] 1.IO页面,上一页、下一页按钮根据页号禁用或启用; 2.PLC页,修复在连接前打开闪退的问题。同进根据连接状态启用或禁用按钮组;
---
SourceCode/Bond/BondEq/CComponentPLCDlg.h | 2 ++
SourceCode/Bond/BondEq/CPLC.cpp | 2 +-
Document/PLC参考图.rar | 0
SourceCode/Bond/BondEq/BondEq.rc | 0
SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp | 8 ++++++++
SourceCode/Bond/BondEq/CComponentPLCDlg.cpp | 38 ++++++++++++++++++++++++++++++++++----
SourceCode/Bond/BondEq/BondEqDlg.cpp | 3 ++-
SourceCode/Bond/x64/Debug/Config/BondEq.db | 0
8 files changed, 47 insertions(+), 6 deletions(-)
diff --git "a/Document/PLC\345\217\202\350\200\203\345\233\276.rar" "b/Document/PLC\345\217\202\350\200\203\345\233\276.rar"
new file mode 100644
index 0000000..328c050
--- /dev/null
+++ "b/Document/PLC\345\217\202\350\200\203\345\233\276.rar"
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index 9cc7434..4bc6104 100644
--- a/SourceCode/Bond/BondEq/BondEq.rc
+++ b/SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.cpp b/SourceCode/Bond/BondEq/BondEqDlg.cpp
index 3584094..498f7af 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.cpp
+++ b/SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -760,8 +760,9 @@
CComponentPLCDlg* CBondEqDlg::CreateComponentPLCDlg(CComponent* pComponent)
{
CComponentPLCDlg* pDlg = new CComponentPLCDlg(m_pMainContainer);
- pDlg->Create(IDD_COMPONENT_PLC, 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);
diff --git a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
index f56598b..d380353 100644
--- a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
+++ b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
@@ -38,6 +38,7 @@
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BUTTON_PLC_AXIS_SETTINGS, &CComponentPLCDlg::OnBnClickedButtonAxisSetting)
ON_BN_CLICKED(IDC_BUTTON_PLC_IO, &CComponentPLCDlg::OnBnClickedButtonIO)
+ ON_WM_TIMER()
END_MESSAGE_MAP()
@@ -53,8 +54,19 @@
// onNext
pAny->addRef();
int code = pAny->getCode();
- if (RX_CODE_ALARM_EVENT == code) {
-
+ if (RX_CODE_PLC1_CONNECTTD == code) {
+ CComponent* pComponent;
+ if (pAny->getPtrValue("ptr", (void*&)pComponent)
+ && pComponent == m_pContext) {
+ EnableGroup1(TRUE);
+ }
+ }
+ else if (RX_CODE_PLC1_DISCONNECTTD == code) {
+ CComponent* pComponent;
+ if (pAny->getPtrValue("ptr", (void*&)pComponent)
+ && pComponent == m_pContext) {
+ EnableGroup1(FALSE);
+ }
}
pAny->release();
}, [&]() -> void {
@@ -72,12 +84,24 @@
BOOL CComponentPLCDlg::OnInitDialog()
{
CComponentDlg::OnInitDialog();
-
+ SetTimer(1, 200, NULL);
return TRUE; // return TRUE unless you set the focus to a control
// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
}
+void CComponentPLCDlg::OnTimer(UINT_PTR nIDEvent)
+{
+ // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
+ if (1 == nIDEvent) {
+ KillTimer(1);
+ InitRxWindows();
+ CPLC* pPLC = (CPLC*)m_pContext;
+ EnableGroup1(pPLC->isConnected());
+ }
+
+ CComponentDlg::OnTimer(nIDEvent);
+}
HBRUSH CComponentPLCDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
@@ -129,7 +153,7 @@
void CComponentPLCDlg::OnBnClickedButtonAxisSetting()
{
CAxisSettingsDlg axisDlg;
- axisDlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+ axisDlg.SetPLC((CPLC*)m_pContext);
axisDlg.SetRecipeName(_T("Default"));
axisDlg.DoModal();
}
@@ -142,3 +166,9 @@
dlg.DoModal();
}
+void CComponentPLCDlg::EnableGroup1(BOOL bEnable)
+{
+ GetDlgItem(IDC_BUTTON_PLC_AXIS_SETTINGS)->EnableWindow(bEnable);
+ GetDlgItem(IDC_BUTTON_PLC_IO)->EnableWindow(bEnable);
+}
+
diff --git a/SourceCode/Bond/BondEq/CComponentPLCDlg.h b/SourceCode/Bond/BondEq/CComponentPLCDlg.h
index 51a79e4..484fa14 100644
--- a/SourceCode/Bond/BondEq/CComponentPLCDlg.h
+++ b/SourceCode/Bond/BondEq/CComponentPLCDlg.h
@@ -15,6 +15,7 @@
private:
void InitRxWindows();
+ void EnableGroup1(BOOL bEnable);
private:
IObserver* m_pObserver;
@@ -36,4 +37,5 @@
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBnClickedButtonAxisSetting();
afx_msg void OnBnClickedButtonIO();
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
};
diff --git a/SourceCode/Bond/BondEq/CPLC.cpp b/SourceCode/Bond/BondEq/CPLC.cpp
index 7a7afcf..ba307d3 100644
--- a/SourceCode/Bond/BondEq/CPLC.cpp
+++ b/SourceCode/Bond/BondEq/CPLC.cpp
@@ -242,7 +242,7 @@
bool CPLC::isConnected()
{
- return m_pChannel->isConnected();
+ return m_pChannel != nullptr && m_pChannel->isConnected();
}
int CPLC::readWord(MC::SOFT_COMPONENT softComponent, unsigned int addr,
diff --git a/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp b/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
index f707501..dfc430a 100644
--- a/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
@@ -502,6 +502,8 @@
CreateDynamicControls();
DisplayCurrentPage();
+ GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurrentPage > 1);
+ GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurrentPage < m_nTotalPages);
SetTimer(TIMER_READ_PLC_DATA, 500, nullptr);
@@ -535,6 +537,9 @@
else {
AfxMessageBox(_T("宸茬粡鏄涓�椤碉紒"));
}
+
+ GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurrentPage > 1);
+ GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurrentPage < m_nTotalPages);
}
void CIOMonitoringDlg::OnBnClickedButtonNextPage()
@@ -547,6 +552,9 @@
else {
AfxMessageBox(_T("宸茬粡鏄渶鍚庝竴椤碉紒"));
}
+
+ GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurrentPage > 1);
+ GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurrentPage < m_nTotalPages);
}
void CIOMonitoringDlg::OnTimer(UINT_PTR nIDEvent)
diff --git a/SourceCode/Bond/x64/Debug/Config/BondEq.db b/SourceCode/Bond/x64/Debug/Config/BondEq.db
index 82fb855..8d301ed 100644
--- a/SourceCode/Bond/x64/Debug/Config/BondEq.db
+++ b/SourceCode/Bond/x64/Debug/Config/BondEq.db
Binary files differ
--
Gitblit v1.9.3