From d7c88780e1df54f34563d60bd7fa01011d2eef03 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期一, 26 一月 2026 23:17:17 +0800
Subject: [PATCH] 1.CSVData.cpp 里 unserialize 用了 8*2、125*2,但 serialize 只写 8 + 125 字节。 m_svRawData.insert 的 end 指针是 pszBuffer + 125*2,没有用 index 计算,可能把无效区域一起拷进去。 一旦 size 实际是 133(不是 266),就会直接越界,堆会被破坏,m_svDatas.clear() 在销毁元素时崩。
---
SourceCode/Bond/BondEq/CComponentPLCDlg.cpp | 64 ++++++++++++++++++++++++++++++--
1 files changed, 60 insertions(+), 4 deletions(-)
diff --git a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
index 6e68ab6..5ce1ae9 100644
--- a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
+++ b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
@@ -8,6 +8,8 @@
#include "Log.h"
#include "ToolUnits.h"
#include "Common.h"
+#include "AxisSettingsDlg.h"
+#include "IOMonitoringDlg.h"
// CComponentData1Dlg 瀵硅瘽妗�
@@ -34,6 +36,9 @@
ON_WM_CTLCOLOR()
ON_WM_DESTROY()
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()
@@ -49,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 {
@@ -68,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)
{
@@ -120,4 +148,32 @@
pItem = GetDlgItem(IDC_LIST_ALARM);
pItem->MoveWindow(x, y, rcClient.Width() - x - 12, rcClient.Height() - y - 12);
*/
-}
\ No newline at end of file
+}
+
+void CComponentPLCDlg::OnBnClickedButtonAxisSetting()
+{
+ std::string strName = RecipeManager::getInstance().getCurrentRecipeName();
+ if (strName.empty()) {
+ AfxMessageBox("鏈�夋嫨閰嶆柟锛�", MB_ICONERROR);
+ }
+
+ CAxisSettingsDlg axisDlg;
+ axisDlg.SetPLC((CPLC*)m_pContext);
+ axisDlg.SetRecipeName(strName.c_str());
+ axisDlg.DoModal();
+}
+
+void CComponentPLCDlg::OnBnClickedButtonIO()
+{
+ CIOMonitoringDlg dlg;
+ dlg.SetIOManager("Cavity");
+ dlg.SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+ dlg.DoModal();
+}
+
+void CComponentPLCDlg::EnableGroup1(BOOL bEnable)
+{
+ GetDlgItem(IDC_BUTTON_PLC_AXIS_SETTINGS)->EnableWindow(bEnable);
+ GetDlgItem(IDC_BUTTON_PLC_IO)->EnableWindow(bEnable);
+}
+
--
Gitblit v1.9.3