From 05a65c62b97ea1bb79450cc0759e0f891fc0ccee Mon Sep 17 00:00:00 2001
From: tfarcraw <123211521@163.com>
Date: Fri, 31 Jul 2026 13:22:58 +0800
Subject: [PATCH] IO 0 OFF 1 ON
---
PLCSharpWpf/VVMs/MotionController/Controller.cs | 4 ++--
PLCSharpWpf/VVMs/MotionController/EMC.cs | 9 ++++++++-
PLCSharpWpf/VVMs/MotionController/SMC.cs | 11 ++++++++++-
PLCSharpWpf/VVMs/Workflows/Script/DO输出.spt | 2 +-
PLCSharpWpf/VVMs/Workflows/Script/设置变量值.spt | 7 ++-----
5 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/PLCSharpWpf/VVMs/MotionController/Controller.cs b/PLCSharpWpf/VVMs/MotionController/Controller.cs
index a01a919..02bf15d 100644
--- a/PLCSharpWpf/VVMs/MotionController/Controller.cs
+++ b/PLCSharpWpf/VVMs/MotionController/Controller.cs
@@ -222,7 +222,7 @@ namespace PLCSharp.VVMs.MotionController
{
if (param is DQ dq)
{
- SetDQ(dq.Number, 0);
+ SetDQ(dq.Number, 1);
}
}
@@ -234,7 +234,7 @@ namespace PLCSharp.VVMs.MotionController
{
if (param is DQ dq)
{
- SetDQ(dq.Number, 1);
+ SetDQ(dq.Number, 0);
}
}
diff --git a/PLCSharpWpf/VVMs/MotionController/EMC.cs b/PLCSharpWpf/VVMs/MotionController/EMC.cs
index f14ff89..fb28dc8 100644
--- a/PLCSharpWpf/VVMs/MotionController/EMC.cs
+++ b/PLCSharpWpf/VVMs/MotionController/EMC.cs
@@ -128,7 +128,14 @@ namespace PLCSharp.VVMs.MotionController
/// off_on
public override void SetDQ(ushort port, ushort off_on)
{
- LTDMC.dmc_write_outbit(ControllerNo, port, off_on);
+ if (off_on == 0)
+ {
+ LTDMC.dmc_write_outbit(ControllerNo, port, 1);
+ }
+ else
+ {
+ LTDMC.dmc_write_outbit(ControllerNo, port, 0);
+ }
}
///
diff --git a/PLCSharpWpf/VVMs/MotionController/SMC.cs b/PLCSharpWpf/VVMs/MotionController/SMC.cs
index 6ae8a4c..ef44226 100644
--- a/PLCSharpWpf/VVMs/MotionController/SMC.cs
+++ b/PLCSharpWpf/VVMs/MotionController/SMC.cs
@@ -1,4 +1,5 @@
using PLCSharp.Core.Tools;
+using PLCSharp.SDK.MotionControl.EMC;
using PLCSharp.SDK.MotionControl.SMC;
using System.Threading;
using static PLCSharp.VVMs.MotionController.Axis;
@@ -128,7 +129,15 @@ namespace PLCSharp.VVMs.MotionController
/// off_on
public override void SetDQ(ushort port, ushort off_on)
{
- LTSMC.smc_write_outbit(ControllerNo, port, off_on);
+
+ if (off_on == 0)
+ {
+ LTSMC.smc_write_outbit(ControllerNo, port, 1);
+ }
+ else
+ {
+ LTSMC.smc_write_outbit(ControllerNo, port, 0);
+ }
}
///
diff --git a/PLCSharpWpf/VVMs/Workflows/Script/DO输出.spt b/PLCSharpWpf/VVMs/Workflows/Script/DO输出.spt
index f0b915e..323fec3 100644
--- a/PLCSharpWpf/VVMs/Workflows/Script/DO输出.spt
+++ b/PLCSharpWpf/VVMs/Workflows/Script/DO输出.spt
@@ -1 +1 @@
-CurrController.SetDQ(Y001, 1); // 0=通, 1=断
\ No newline at end of file
+CurrController.SetDQ(Y001, 1); // 0=OFF, 1=ON
\ No newline at end of file
diff --git a/PLCSharpWpf/VVMs/Workflows/Script/设置变量值.spt b/PLCSharpWpf/VVMs/Workflows/Script/设置变量值.spt
index 03d3d56..bc0f530 100644
--- a/PLCSharpWpf/VVMs/Workflows/Script/设置变量值.spt
+++ b/PLCSharpWpf/VVMs/Workflows/Script/设置变量值.spt
@@ -1,6 +1,3 @@
//全局变量
-case 2:
- CurrVariable = globalModel.GetVariable("变量名");//如果前面已经获取,这里可以删除
- CurrVariable.Value = 100; // 设置变量值
- flow.Step++;
- break;
\ No newline at end of file
+CurrVariable.Value = 100; // 设置变量值
+
\ No newline at end of file