From 52e82dcdc401782b58ed50bc14ae270b143370a9 Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期六, 11 一月 2025 08:35:52 +0800
Subject: [PATCH] 1.添加轴设定和细部设定

---
 SourceCode/Bond/BoounionPLC/IOMonitoringDlg.cpp |   43 +++++++++++++++++++++++++------------------
 1 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/SourceCode/Bond/BoounionPLC/IOMonitoringDlg.cpp b/SourceCode/Bond/BoounionPLC/IOMonitoringDlg.cpp
index 5bc1d1c..734f047 100644
--- a/SourceCode/Bond/BoounionPLC/IOMonitoringDlg.cpp
+++ b/SourceCode/Bond/BoounionPLC/IOMonitoringDlg.cpp
@@ -27,6 +27,22 @@
 	m_nTotalPages = 1;
 	m_nRowsPerPage = 16;
 	m_nCols = 6;
+
+	CPLC* pPLC = theApp.m_model.getCurrentPlc();
+	if (pPLC != nullptr) {
+		m_pPLC = pPLC;
+
+		// 鍔犺浇鏁版嵁
+		IOManager manager;
+		manager.LoadFromFile(pPLC->getName());
+		manager.GetMachineData(m_displayData);
+
+		// 璁$畻椤垫暟
+		m_nCurrentPage = 1;
+		m_nTotalPages = ((int)m_displayData.size() + m_nRowsPerPage - 1) / m_nRowsPerPage;
+	} else {
+		m_pPLC = nullptr;
+	}
 }
 
 CIOMonitoringDlg::~CIOMonitoringDlg()
@@ -46,24 +62,6 @@
 {
 	CDialogEx::DoDataExchange(pDX);
 	DDX_Control(pDX, IDC_STATIC_PAGE_NUMBER, m_staticPageNum);
-}
-
-void CIOMonitoringDlg::SetIOManager(const std::string& machineName)
-{
-	// 鍔犺浇鏁版嵁
-	IOManager manager;
-	manager.LoadFromFile(machineName);
-	manager.GetMachineData(m_displayData);
-
-	// 璁$畻椤垫暟
-	m_nCurrentPage = 1;
-	m_nTotalPages = ((int)m_displayData.size() + m_nRowsPerPage - 1) / m_nRowsPerPage;
-}
-
-void CIOMonitoringDlg::SetPLC(CPLC* pPLC)
-{
-	ASSERT(pPLC);
-	m_pPLC = pPLC;
 }
 
 CFont* CIOMonitoringDlg::GetOrCreateFont(int nFontSize)
@@ -568,6 +566,15 @@
 	CDialogEx::OnInitDialog();
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+	if (m_pPLC == nullptr || !m_pPLC->isConnected()) {
+		AfxMessageBox(_T("PLC 鏈繛鎺ワ紒"));
+		return FALSE;
+	}
+
+	CString strTitle;
+	strTitle.Format(_T("IO鐩戞帶椤甸潰(PLC: %s)"), m_pPLC->getName().c_str());
+	SetWindowText(strTitle);
+
 	CRect screenRect, dlgRect, clientRect;
 	SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
 

--
Gitblit v1.9.3