From 12072ee6dff9bbbfb6048603afc24d6361329f67 Mon Sep 17 00:00:00 2001 From: lhiven <236881222@qq.com> Date: Tue, 15 Aug 2023 08:30:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E8=BF=90=E5=8A=A8?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=92=8CIO=E6=93=8D=E4=BD=9C=E7=9A=84?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E6=8E=A7=E5=88=B6=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.MotionPlat/Commom/Ops.cs | 161 ++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 Rs.MotionPlat/Commom/Ops.cs diff --git a/Rs.MotionPlat/Commom/Ops.cs b/Rs.MotionPlat/Commom/Ops.cs new file mode 100644 index 0000000..e4bba09 --- /dev/null +++ b/Rs.MotionPlat/Commom/Ops.cs @@ -0,0 +1,161 @@ +using Rs.Camera; +using Rs.Framework; +using Rs.Motion.GugaoEcat; +using Rs.Motion.GugaoPulse; +using Rs.Motion; +using Rs.MotionPlat.Flow; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Rs.Motion.Base; + +namespace Rs.MotionPlat.Commom +{ + public class Ops + { + public static void Init() + { + #region 初始化固高卡 + ErrorCode errCode = GugaoPulseCardManager.Instance.Init(); + if (errCode > ErrorCode.Ok) + { + MessageQueue.Instance.Warn("Gugao motion card load fail"); + } + else + { + + } + #endregion + + #region 初始化ztm卡 + errCode = ZtmCardManager.Instance.Init(); + if (errCode > ErrorCode.Ok) + { + MessageQueue.Instance.Warn("ZTM motion card load fail"); + } + else + { + MessageQueue.Instance.Insert("ZTM motion card load ok"); + } + #endregion + #region 初始化IO + IoManager.Instance.Init(); + #endregion + + #region 链接相机 + //链接相机 + ECameraErrorCode ceCode = HikCamera.Instance.Init(); + if (ceCode > ECameraErrorCode.Ok) + { + MessageQueue.Instance.Warn(ceCode.ToString()); + } + else + { + MessageQueue.Instance.Insert("Camera load ok!"); + + int ret = HikCamera.Instance.SetReverseX("upCamera", EDir.Y, true); + ret += HikCamera.Instance.SetReverseX("upCamera", EDir.X, true); + if (ret != 0) + { + MessageQueue.Instance.Warn("Camera init error"); + } + ret = 0; + ret = HikCamera.Instance.SetReverseX("downCamera", EDir.X, true); + ret += HikCamera.Instance.SetReverseX("downCamera", EDir.Y, false); + if (ret != 0) + { + MessageQueue.Instance.Warn("Camera init error"); + } + + ret = HikCamera.Instance.StartGrab("upCamera"); + if (ret != 0) + { + MessageQueue.Instance.Warn("Camera init error"); + } + ret = HikCamera.Instance.StartGrab("downCamera"); + if (ret != 0) + { + MessageQueue.Instance.Warn("Camera init error"); + } + } + #endregion + + SafeControl.Instance.Init(); + NozzleManager.Init(); + TestCenter.Instance.Init(); + MachineManage.Instance.InitializeState = EInitializeState.Initialized; + } + + public static bool IsStop(params string[] axies) + { + foreach (var axisname in axies) + { + if (!IsStop(AxisControl.GetAxis(axisname))) + return false; + } + return false; + } + public static bool IsStop(params IAxis[] axies) + { + foreach (var axis in axies) + { + axis.IsStop(out bool bStop); + if (!bStop) + return false; + } + return true; + } + + public static bool IsHomed(params string[] axies) + { + foreach (var axisname in axies) + { + if (!IsHomed(AxisControl.GetAxis(axisname))) + return false; + } + return false; + } + + public static bool IsHomed(params IAxis[] axies) + { + foreach (var axis in axies) + { + if (axis.HomeStatus != EHomeStatus.Finished) + return false; + } + return true; + } + + public static void On(string ioName) + { + IoManager.Instance.WriteOut(ioName, 1); + } + + public static void Off(string ioName) + { + IoManager.Instance.WriteOut(ioName, 0); + } + + public static bool IsOn(string ioName) + { + return IoManager.Instance.ReadIn(ioName) == 1; + } + + public static bool IsOff(string ioName) + { + return IoManager.Instance.ReadIn(ioName) == 0; + } + + public static bool IsOutOn(string ioName) + { + return IoManager.Instance.ReadOut(ioName) == 1; + } + + public static bool IsOutOff(string ioName) + { + return IoManager.Instance.ReadOut(ioName) == 0; + } + } +}