From f5fa7d2058fec2342c3e3e3955089b8f9f9a630f Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期五, 10 一月 2025 15:02:15 +0800
Subject: [PATCH] 1. 添加IO模块
---
SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp | 35 +++++++++++++++++++++++++++++------
1 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
index 3ff6a0f..d7a9b20 100644
--- a/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
+++ b/SourceCode/Bond/BoounionPLC/BoounionPLCDlg.cpp
@@ -8,8 +8,12 @@
#include "afxdialogex.h"
#include "Common.h"
#include "PlcView.h"
-#include "AlarmMonitor.h"
#include "Log.h"
+#include "InputDialog.h"
+#include "IOManager.h"
+
+// 测试
+#include "IOMonitoringDlg.h"
#ifdef _DEBUG
@@ -487,10 +491,22 @@
{
int id = (int)lParam;
if (id == IDC_BUTTON_ADD) {
- static int i = 0;
- char szName[256];
- sprintf_s(szName, 256, "PLC%d", ++i);
- theApp.m_model.addPlc(szName, "192.168.1.188", 1001);
+ CInputDialog inputDialog(_T("新建设备"), _T("请输入设备名称:"));
+ if (inputDialog.DoModal() != IDOK) {
+ AfxMessageBox(_T("取消验证!"));
+ return 0;
+ }
+
+ CString strName;
+ strName = inputDialog.GetInputText();
+ if (!strName.IsEmpty()) {
+ theApp.m_model.addPlc((LPTSTR)(LPCTSTR)strName, "192.168.1.188", 1001);
+
+ // 新建IO文件
+ IOManager io;
+ io.DefaultMachineData();
+ io.SaveToFile((LPTSTR)(LPCTSTR)strName);
+ }
}
else if (id == IDC_BUTTON_DELETE) {
CPLC* pPlc = theApp.m_model.getCurrentPlc();
@@ -499,7 +515,14 @@
}
}
else if (id == IDC_BUTTON_SETTINGS) {
-
+ // 测试 IO模块
+ CPLC* pPLC = theApp.m_model.getCurrentPlc();
+ if (pPLC != nullptr) {
+ CIOMonitoringDlg dlg;
+ dlg.SetPLC(pPLC);
+ dlg.SetIOManager(pPLC->getName());
+ dlg.DoModal();
+ }
}
else if (id == IDC_BUTTON_OPERATOR) {
/*
--
Gitblit v1.9.3