From d755eba8943d42bb01e582d44ce579a4167f99c0 Mon Sep 17 00:00:00 2001 From: lhiven <236881222@qq.com> Date: Tue, 2 Apr 2024 09:48:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BA=E9=AB=98=E6=80=BB?= =?UTF-8?q?=E7=BA=BF=E5=8D=A1=E7=9A=84IO=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.Motion/GugaoEcat/ECatIOCard.cs | 11 ++++++++++- Rs.Motion/IoManager.cs | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Rs.Motion/GugaoEcat/ECatIOCard.cs b/Rs.Motion/GugaoEcat/ECatIOCard.cs index f7c02de..9cc01c6 100644 --- a/Rs.Motion/GugaoEcat/ECatIOCard.cs +++ b/Rs.Motion/GugaoEcat/ECatIOCard.cs @@ -1,4 +1,6 @@ -using Rs.Motion.Base; +using Rs.Framework; +using Rs.Motion.Base; +using Rs.Motion.GugaoPulse; using System; using System.Collections.Generic; using System.Linq; @@ -44,6 +46,13 @@ namespace Rs.Motion.GugaoEcat io.Name = "In" + i + "_" + slaveNo; DIn.Add(io); } + + + } + public override void Save() + { + string filename = $"config/motion/io/gugao_ecat{CardID}.xml"; + XmlSerializerHelper.Instance.Serialize(filename, this); } } } diff --git a/Rs.Motion/IoManager.cs b/Rs.Motion/IoManager.cs index 6179ebf..44a5e91 100644 --- a/Rs.Motion/IoManager.cs +++ b/Rs.Motion/IoManager.cs @@ -206,7 +206,16 @@ namespace Rs.Motion ECatIO eio = (ECatIO)io; apiResult = mc_ecat.GTN_EcatIOBitReadOutput(eio.Core, eio.SlaveNo, eio.Offset, eio.Index, out byte pValue); if (apiResult == 0) - return pValue; + { + if (io.IsReverse) + { + return (short)((~pValue) & 0x01); + } + else + { + return pValue; + } + } } else { @@ -215,7 +224,15 @@ namespace Rs.Motion if (apiResult == 0) { byte pValue = (byte)(~(value >> eio.Index) & 0x01); - return pValue; + if(io.IsReverse) + { + return (short)((~pValue) & 0x01); + } + else + { + return pValue; + } + } } }