From 00cd9a193cffb9ae1940545e367e002f560ff9f7 Mon Sep 17 00:00:00 2001 From: lhiven <236881222@qq.com> Date: Thu, 22 Feb 2024 15:09:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96IO=E6=97=B6=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E6=83=B3=E8=A6=81=E7=9A=84=E5=80=BC=E6=98=AF?= =?UTF-8?q?=E5=A4=9A=E8=AF=BB2=E6=AC=A1=EF=BC=8C=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E9=97=B4=E9=9A=9420ms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.SkyLine/Commom/Ops.cs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/Rs.SkyLine/Commom/Ops.cs b/Rs.SkyLine/Commom/Ops.cs index 7d97e8d..a7b7fb3 100644 --- a/Rs.SkyLine/Commom/Ops.cs +++ b/Rs.SkyLine/Commom/Ops.cs @@ -378,12 +378,45 @@ namespace Rs.MotionPlat.Commom public static bool IsOn(string ioName) { - return IoManager.Instance.ReadIn(ioName) == 1; + int num = 0; + short val = 0; + while (num<3) + { + val = IoManager.Instance.ReadIn(ioName); + if(val==0) + { + num++; + Thread.Sleep(20); + } + else + { + num = 0; + break; + } + } + return val == 1; } public static bool IsOff(string ioName) { - return IoManager.Instance.ReadIn(ioName) == 0; + int num = 0; + short val = 0; + while (num < 3) + { + val = IoManager.Instance.ReadIn(ioName); + if (val == 1) + { + num++; + Thread.Sleep(20); + } + else + { + num = 0; + break; + } + } + return val == 0; + //return IoManager.Instance.ReadIn(ioName) == 0; } public static bool IsOutOn(string ioName)