From 6a9862bbbc752d18f32c20ef62de4195364f2052 Mon Sep 17 00:00:00 2001
From: tfarcraw <123211521@163.com>
Date: Fri, 16 Oct 2026 03:56:48 +0800
Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=20IO=20=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E9=9D=A2=E6=9D=BF=EF=BC=9ASmcIO/EmcIO=20=E2=86=92=20=E9=80=9A?=
=?UTF-8?q?=E7=94=A8=20ControllerIO?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 删除 Config/SmcIO 与 Config/EmcIO(两面板仅 ON/OFF 按钮和列宽不同,ON/OFF 调的 DQON/DQOFF 两种 SDK 都支持,非板卡差异)
- 新增 Config/ControllerIO(保留 ON/OFF 手动输出按钮,两种板卡通用)
- ControllersModel: Config 命令去掉 switch(Type) 分支,Type≠Undefined 时直接创建 ControllerIO
- Controller: 连接循环补 SDK==null 保护;XAML 按钮改名 配置→配置IO
---
.../Config/{EmcIO.xaml => ControllerIO.xaml} | 4 +-
.../{EmcIO.xaml.cs => ControllerIO.xaml.cs} | 12 +--
.../VVMs/MotionController/Config/SmcIO.xaml | 101 ------------------
.../MotionController/Config/SmcIO.xaml.cs | 25 -----
.../VVMs/MotionController/Controller.cs | 5 +
.../VVMs/MotionController/Controllers.xaml | 2 +-
.../VVMs/MotionController/ControllersModel.cs | 18 +---
7 files changed, 18 insertions(+), 149 deletions(-)
rename PLCSharpWpf/VVMs/MotionController/Config/{EmcIO.xaml => ControllerIO.xaml} (98%)
rename PLCSharpWpf/VVMs/MotionController/Config/{EmcIO.xaml.cs => ControllerIO.xaml.cs} (66%)
delete mode 100644 PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml
delete mode 100644 PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml.cs
diff --git a/PLCSharpWpf/VVMs/MotionController/Config/EmcIO.xaml b/PLCSharpWpf/VVMs/MotionController/Config/ControllerIO.xaml
similarity index 98%
rename from PLCSharpWpf/VVMs/MotionController/Config/EmcIO.xaml
rename to PLCSharpWpf/VVMs/MotionController/Config/ControllerIO.xaml
index a001d50..2fd53cc 100644
--- a/PLCSharpWpf/VVMs/MotionController/Config/EmcIO.xaml
+++ b/PLCSharpWpf/VVMs/MotionController/Config/ControllerIO.xaml
@@ -1,4 +1,4 @@
-
-
\ No newline at end of file
+
diff --git a/PLCSharpWpf/VVMs/MotionController/Config/EmcIO.xaml.cs b/PLCSharpWpf/VVMs/MotionController/Config/ControllerIO.xaml.cs
similarity index 66%
rename from PLCSharpWpf/VVMs/MotionController/Config/EmcIO.xaml.cs
rename to PLCSharpWpf/VVMs/MotionController/Config/ControllerIO.xaml.cs
index 3667f9d..f3548fb 100644
--- a/PLCSharpWpf/VVMs/MotionController/Config/EmcIO.xaml.cs
+++ b/PLCSharpWpf/VVMs/MotionController/Config/ControllerIO.xaml.cs
@@ -1,17 +1,17 @@
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
namespace PLCSharp.VVMs.MotionController.Config
{
///
- /// SmcIO.xaml 的交互逻辑
+ /// ControllerIO.xaml 的交互逻辑(通用IO面板,SMC/EMC 板卡通用)
///
- public partial class EmcIO : UserControl
+ public partial class ControllerIO : UserControl
{
///
- /// EmcIO
+ /// ControllerIO
///
- public EmcIO()
+ public ControllerIO()
{
InitializeComponent();
}
@@ -22,4 +22,4 @@ namespace PLCSharp.VVMs.MotionController.Config
dataGrid.CommitEdit(DataGridEditingUnit.Row, true);
}
}
-}
\ No newline at end of file
+}
diff --git a/PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml b/PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml
deleted file mode 100644
index 673d3ca..0000000
--- a/PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml.cs b/PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml.cs
deleted file mode 100644
index e2189ed..0000000
--- a/PLCSharpWpf/VVMs/MotionController/Config/SmcIO.xaml.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Windows;
-using System.Windows.Controls;
-
-namespace PLCSharp.VVMs.MotionController.Config
-{
- ///
- /// SmcIO.xaml 的交互逻辑
- ///
- public partial class SmcIO : UserControl
- {
- ///
- /// SmcIO
- ///
- public SmcIO()
- {
- InitializeComponent();
- }
-
- private void DataGrid_Unloaded(object sender, RoutedEventArgs e)
- {
- var dataGrid = sender as DataGrid;
- dataGrid.CommitEdit(DataGridEditingUnit.Row, true);
- }
- }
-}
\ No newline at end of file
diff --git a/PLCSharpWpf/VVMs/MotionController/Controller.cs b/PLCSharpWpf/VVMs/MotionController/Controller.cs
index f023970..b83bee6 100644
--- a/PLCSharpWpf/VVMs/MotionController/Controller.cs
+++ b/PLCSharpWpf/VVMs/MotionController/Controller.cs
@@ -162,9 +162,14 @@ namespace PLCSharp.VVMs.MotionController
{
Thread.Sleep(1000);
Online = NetTool.PingIP(IP);
+ if (SDK == null)
+ {
+ continue;
+ }
if (Online)
{
+
Connected = SDK.Init(ControllerNo, IP);
if (Connected)
{
diff --git a/PLCSharpWpf/VVMs/MotionController/Controllers.xaml b/PLCSharpWpf/VVMs/MotionController/Controllers.xaml
index 9678bd7..f515472 100644
--- a/PLCSharpWpf/VVMs/MotionController/Controllers.xaml
+++ b/PLCSharpWpf/VVMs/MotionController/Controllers.xaml
@@ -77,7 +77,7 @@
-
+
diff --git a/PLCSharpWpf/VVMs/MotionController/ControllersModel.cs b/PLCSharpWpf/VVMs/MotionController/ControllersModel.cs
index 1594901..45b15fc 100644
--- a/PLCSharpWpf/VVMs/MotionController/ControllersModel.cs
+++ b/PLCSharpWpf/VVMs/MotionController/ControllersModel.cs
@@ -486,26 +486,16 @@ namespace PLCSharp.VVMs.MotionController
}
_DatasContext.Save();
Controller.Prompt = "";
+ ExecuteControllerManage("config");
break;
case "Config":
ControllerConfig = null;
- switch (_Controller.Type)
+ if (_Controller.Type != ControllerType.Undefined)
{
- case ControllerType.SMC304:
- ControllerConfig = new SmcIO();
- break;
-
- case ControllerType.EMC_E3064_A08:
- ControllerConfig = new EmcIO();
- break;
-
- default:
-
- break;
- }
- if (ControllerConfig != null)
+ ControllerConfig = new ControllerIO();
ControllerConfig.DataContext = this;
+ }
break;
}
}