Browse Source

update safety routine

chenkui 2 days ago
parent
commit
443fa4a0dd

+ 49 - 104
PunkHPX8_RT/Devices/Safety/SafetyAllOnRoutine.cs

@@ -9,6 +9,9 @@ using PunkHPX8_RT.Modules.Transporter;
 using MECF.Framework.Common.Beckhoff.ModuleIO;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.Routine;
+using MECF.Framework.Common.Utilities;
+using System.Runtime.InteropServices;
+using PunkHPX8_RT.Devices.AXIS;
 
 namespace PunkHPX8_RT.Devices.Safety
 {
@@ -16,17 +19,22 @@ namespace PunkHPX8_RT.Devices.Safety
     {
         private enum SafetyAllOnStep
         {
-            Ready,
-            SwitchOnProcessTransporter,
-            WaitSwitchOnProcessTransporter,
-            SwitchOnLoaderTransporter,
-            WaitSwitchOnLoaderTransporter,
-            SwitchOnLoader,
-            WaitSwitchOnLoader,
-            SwitchOnPuf1,
-            WaitSwitchOnPuf1,
-            SwitchOnPuf2,
-            WaitSwitchOnPuf2,
+            VpwCell1SwitchOn,
+            WaitSwitchOnVpwCell1,
+            VpwCell2SwitchOn,
+            WaitSwitchOnVpwCell2,
+            PlatingCell1RotationSwitchOn,
+            WaitSwitchOnPlatingCell1Rotation,
+            PlatingCell2RotationSwitchOn,
+            WaitSwitchOnPlatingCell2Rotation,
+            PlatingCell3RotationSwitchOn,
+            WaitSwitchOnPlatingCell3Rotation,
+            PlatingCell4RotationSwitchOn,
+            WaitSwitchOnPlatingCell4Rotation,
+            PlatingCell12LiftSwitchOn,
+            WaitSwitchOnPlatingCell12Lift,
+            PlatingCell34LiftSwitchOn,
+            WaitSwitchOnPlatingCell34Lift,
             SwitchOnSRD1,
             WaitSwitchOnSRD1,
             SwitchOnSRD2,
@@ -35,14 +43,16 @@ namespace PunkHPX8_RT.Devices.Safety
         }
         #region 内部变量
         private SafetyDevice _device;
-        /// <summary>
-        /// SRD1
-        /// </summary>
-        private SRDEntity _srd1Entity;
-        /// <summary>
-        /// SRD2
-        /// </summary>
-        private SRDEntity _srd2Entity;
+        private JetAxisBase _vpwCell1Rotation;
+        private JetAxisBase _vpwCell2Rotation;
+        private JetAxisBase _platingCell1Rotation;
+        private JetAxisBase _platingCell2Rotation;
+        private JetAxisBase _platingCell3Rotation;
+        private JetAxisBase _platingCell4Rotation;
+        private JetAxisBase _platingCell12Lift;
+        private JetAxisBase _platingCell34Lift;
+        private JetAxisBase _srd1Rotation;
+        private JetAxisBase _srd2Rotation;
         #endregion
         /// <summary>
         /// 构造函数
@@ -65,112 +75,45 @@ namespace PunkHPX8_RT.Devices.Safety
         /// <returns></returns>
         public RState Monitor()
         {
-            Runner.Run(SafetyAllOnStep.Ready, CheckReady, _delay_1ms)
-                .RunIf(SafetyAllOnStep.SwitchOnSRD1, _srd1Entity!=null, SwitchOnSRD1, _delay_1ms)
-                .WaitWithStopCondition(SafetyAllOnStep.WaitSwitchOnSRD1, CheckSwitchOnSRD1Complete, CheckSwitchOnSRD1Error)
-                .RunIf(SafetyAllOnStep.SwitchOnSRD2, _srd2Entity!=null, SwitchOnSRD2, _delay_1ms)
-                .WaitWithStopCondition(SafetyAllOnStep.WaitSwitchOnSRD2, CheckSwitchOnSRD2Complete, CheckSwitchOnSRD2Error)
+            Runner.RunIf(SafetyAllOnStep.VpwCell1SwitchOn,ModuleHelper.IsInstalled(ModuleName.VPW1),()=>SwitchOnAxis(_vpwCell1Rotation),_delay_1ms)
+                .WaitWithStopConditionIf(SafetyAllOnStep.WaitSwitchOnVpwCell1, ModuleHelper.IsInstalled(ModuleName.VPW1),
+                    ()=>CheckSwitchOn(_vpwCell1Rotation),()=>CheckSwitchOnStopStatus(_vpwCell1Rotation))
+                .RunIf(SafetyAllOnStep.VpwCell2SwitchOn, ModuleHelper.IsInstalled(ModuleName.VPW2), () => SwitchOnAxis(_vpwCell2Rotation), _delay_1ms)
+                .WaitWithStopConditionIf(SafetyAllOnStep.WaitSwitchOnVpwCell2, ModuleHelper.IsInstalled(ModuleName.VPW2),
+                    () => CheckSwitchOn(_vpwCell2Rotation), () => CheckSwitchOnStopStatus(_vpwCell2Rotation))
                 .End(SafetyAllOnStep.End, NullFun, _delay_1ms);
 
             return Runner.Status;
         }
-
-        private bool CheckReady()
-        {
-           _srd1Entity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(ModuleName.SRD1.ToString());
-            _srd2Entity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(ModuleName.SRD2.ToString());
-            return true;
-        }
-
-        #region SRD1
-        /// <summary>
-        /// Switch on SRD1 Motors
-        /// </summary>
-        /// <returns></returns>
-        private bool SwitchOnSRD1()
-        {
-            return _srd1Entity.CheckToPostMessage<SRDState,SRDMSG>(eEvent.ERR_SRD, ModuleName.SRD1.ToString(), (int)SRDMSG.SwitchOn);
-        }
         /// <summary>
-        /// 检查SRD1 Motors switchon是否完成
+        /// 电机SwitchOn
         /// </summary>
+        /// <param name="axis"></param>
         /// <returns></returns>
-        private bool CheckSwitchOnSRD1Complete()
+        private bool SwitchOnAxis(JetAxisBase axis)
         {
-            if(_srd1Entity==null)
-            {
-                return true;
-            }
-            if (_srd1Entity.IsRotationSwitchOn && _srd1Entity.IsArmSwitchOn)
-            {
-                return true;
-            }
-            return false;
+            return axis.SwitchOn();
         }
         /// <summary>
-        /// 检查SRD1 Motors switchon是否出错
+        /// 检验电机是否上电
         /// </summary>
+        /// <param name="axis"></param>
         /// <returns></returns>
-        private bool CheckSwitchOnSRD1Error()
+        private bool CheckSwitchOn(JetAxisBase axis) 
         {
-            if (_srd1Entity == null)
-            {
-                return false;
-            }
-            if (_srd1Entity.IsError)
-            {
-                LOG.WriteLog(eEvent.ERR_SAFETY, Module, $"Switching On SRD1 Motors is failed");
-                return true;
-            }
-            return false;
+            return axis.IsSwitchOn && axis.Status == RState.End;
         }
-        #endregion
 
-        #region SRD2
         /// <summary>
-        /// Switch on SRD2 Motors
+        /// 检验电机上电是否异常
         /// </summary>
+        /// <param name="axis"></param>
         /// <returns></returns>
-        private bool SwitchOnSRD2()
+        private bool CheckSwitchOnStopStatus(JetAxisBase axis)
         {
-            return _srd2Entity.CheckToPostMessage<SRDState,SRDMSG>(eEvent.ERR_SRD, ModuleName.SRD2.ToString(), (int)SRDMSG.SwitchOn);
+            return axis.Status == RState.Failed;
         }
         /// <summary>
-        /// 检查SRD2 Motors switchon是否完成
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckSwitchOnSRD2Complete()
-        {
-            if(_srd2Entity == null)
-            {
-                return true;
-            }
-            if (_srd2Entity.IsRotationSwitchOn && _srd2Entity.IsArmSwitchOn)
-            {
-                return true;
-            }
-            return false;
-        }
-        /// <summary>
-        /// 检查SRD2 Motors switchon是否出错
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckSwitchOnSRD2Error()
-        {
-            if(_srd2Entity == null)
-            {
-                return false;
-            }
-            if (_srd2Entity.IsError)
-            {
-                LOG.WriteLog(eEvent.ERR_SAFETY, Module, $"Switching On SRD2 Motors is failed");
-                return true;
-            }
-            return false;
-        }
-        #endregion
-
-        /// <summary>
         /// 启动
         /// </summary>
         /// <param name="objs"></param>
@@ -178,6 +121,8 @@ namespace PunkHPX8_RT.Devices.Safety
         public RState Start(params object[] objs)
         {
             _device = DEVICE.GetDevice<SafetyDevice>(Module);
+            _vpwCell1Rotation = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.VPW1}.Rotation");
+            _vpwCell2Rotation = DEVICE.GetDevice<JetAxisBase>($"{ModuleName.VPW2}.Rotation");
             return Runner.Start(Module, $"Safety All On");
         }
     }

+ 0 - 112
PunkHPX8_RT/Devices/Safety/SafetyArmResetRoutine.cs

@@ -1,112 +0,0 @@
-using Aitex.Core.RT.Device;
-using Aitex.Core.RT.Log;
-using Aitex.Core.RT.Routine;
-using MECF.Framework.Common.Beckhoff.ModuleIO;
-using MECF.Framework.Common.Routine;
-using MECF.Framework.Common.TwinCat;
-using PunkHPX8_Core;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using MECF.Framework.Common.IOCore;
-
-namespace PunkHPX8_RT.Devices.Safety
-{
-    public class SafetyToggleRoutine : RoutineBase, IRoutine
-    {
-        private enum SafetyToggleStep
-        {
-            WriteFalse,
-            WriteTrue,
-            LastWriteFalse,
-            End
-        }
-        #region 内部变量
-        /// <summary>
-        /// do名称
-        /// </summary>
-        private string _doName = "";
-        /// <summary>
-        /// do写入数值
-        /// </summary>
-        private bool _doWriteValue = false;
-        /// <summary>
-        /// 设备
-        /// </summary>
-        private SafetyDevice _device;
-        /// <summary>
-        /// 超晨
-        /// </summary>
-        private int _timeout = 1000;
-        #endregion
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="module"></param>
-        public SafetyToggleRoutine(string module) : base(module)
-        {
-        }
-        /// <summary>
-        /// 中止
-        /// </summary>
-        public void Abort()
-        {
-            Runner.Stop($"Manual Safty {_doName} Toggle");
-        }
-        /// <summary>
-        /// 监控
-        /// </summary>
-        /// <returns></returns>
-        public RState Monitor()
-        {
-            Runner.Run(SafetyToggleStep.WriteFalse, () => { return WriteDoValue(false); }, CheckDoValue, _timeout)
-                .Run(SafetyToggleStep.WriteTrue, () => { return WriteDoValue(true); }, CheckDoValue, _timeout)
-                .Run(SafetyToggleStep.LastWriteFalse, () => { return WriteDoValue(false); }, CheckDoValue, _timeout)
-                .End(SafetyToggleStep.End, NullFun, _delay_1ms);
-            return Runner.Status;
-        }
-        /// <summary>
-        /// 写入do数值
-        /// </summary>
-        /// <param name="value"></param>
-        /// <returns></returns>
-        private bool WriteDoValue(bool value)
-        {
-            string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{_doName}");
-            _doWriteValue=value;
-            return IOModuleManager.Instance.WriteIoValue(ioName, value);
-        }
-        /// <summary>
-        /// 检验do的数值
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckDoValue()
-        {
-            PropertyInfo propertyInfo = _device.SafetyData.GetType().GetProperty(_doName);
-            if (propertyInfo != null)
-            {
-                bool doValue = (bool)propertyInfo.GetValue(_device.SafetyData);
-                return doValue==_doWriteValue;
-            }
-            else
-            {
-                LOG.WriteLog(eEvent.ERR_SAFETY, Module, $"{_doName} in not in property");
-                return false;
-            }
-        }
-        /// <summary>
-        /// 启动
-        /// </summary>
-        /// <param name="objs"></param>
-        /// <returns></returns>
-        public RState Start(params object[] objs)
-        {
-            _device = DEVICE.GetDevice<SafetyDevice>(Module);
-            _doName= objs[0].ToString();
-            return Runner.Start(Module, $"{_doName} toggle");
-        }
-    }
-}

+ 2 - 2
PunkHPX8_RT/Devices/Safety/SafetyDevice.cs

@@ -250,7 +250,7 @@ namespace PunkHPX8_RT.Devices.Safety
         /// <summary>
         /// All Switch On Routine
         /// </summary>
-        private SafetyNewAllOnRoutine _allOnRoutine;
+        private SafetyAllOnRoutine _allOnRoutine;
         /// <summary>
         /// AllOnRoutine状态
         /// </summary>
@@ -345,7 +345,7 @@ namespace PunkHPX8_RT.Devices.Safety
         private void InitializeRoutine()
         {
             _resetRoutine = new SafetyResetRoutine(Module);
-            _allOnRoutine = new SafetyNewAllOnRoutine(Module);
+            _allOnRoutine = new SafetyAllOnRoutine(Module);
         }
         /// <summary>
         /// 初始化DATA

+ 0 - 156
PunkHPX8_RT/Devices/Safety/SafetyNewAllOnRoutine.cs

@@ -1,156 +0,0 @@
-using Aitex.Core.RT.Device;
-using Aitex.Core.RT.Log;
-using Aitex.Core.RT.Routine;
-using Aitex.Core.Util;
-using PunkHPX8_Core;
-using PunkHPX8_RT.Modules;
-using PunkHPX8_RT.Modules.SRD;
-using PunkHPX8_RT.Modules.Transporter;
-using MECF.Framework.Common.Beckhoff.ModuleIO;
-using MECF.Framework.Common.Equipment;
-using MECF.Framework.Common.Routine;
-using MECF.Framework.Common.Utilities;
-using System.Runtime.InteropServices;
-
-namespace PunkHPX8_RT.Devices.Safety
-{
-    internal class SafetyNewAllOnRoutine : RoutineBase, IRoutine
-    {
-        private enum SafetyAllOnStep
-        {
-            Ready,
-            SwitchOnProcessTransporter,
-            WaitSwitchOnProcessTransporter,
-            SwitchOnLoaderTransporter,
-            WaitSwitchOnLoaderTransporter,
-            SwitchOnLoader,
-            WaitSwitchOnLoader,
-            SwitchOnPuf1,
-            WaitSwitchOnPuf1,
-            SwitchOnPuf2,
-            WaitSwitchOnPuf2,
-            SwitchOnSRD1,
-            WaitSwitchOnSRD1,
-            SwitchOnSRD2,
-            WaitSwitchOnSRD2,
-            End
-        }
-        #region 内部变量
-        private SafetyDevice _device;
-        private SRDSwitchOnRoutine _srd1SwitchOnRoutine;
-        private SRDSwitchOnRoutine _srd2SwitchOnRoutine;
-        #endregion
-        /// <summary>
-        /// 构造函数
-        /// </summary>
-        /// <param name="module"></param>
-        public SafetyNewAllOnRoutine(string module) : base(module)
-        {
-            
-        }
-        /// <summary>
-        /// 中止
-        /// </summary>
-        public void Abort()
-        {
-            Runner.Stop($"Safety All On Abort");
-        }
-        /// <summary>
-        /// 监控
-        /// </summary>
-        /// <returns></returns>
-        public RState Monitor()
-        {
-            Runner.RunIf(SafetyAllOnStep.SwitchOnSRD1, ModuleHelper.IsInstalled(ModuleName.SRD1), SwitchOnSRD1, _delay_1ms)
-                .WaitWithStopCondition(SafetyAllOnStep.WaitSwitchOnSRD1, CheckSwitchOnSRD1Complete, CheckSwitchOnSRD1Error)
-                .RunIf(SafetyAllOnStep.SwitchOnSRD2, ModuleHelper.IsInstalled(ModuleName.SRD2), SwitchOnSRD2, _delay_1ms)
-                .WaitWithStopCondition(SafetyAllOnStep.WaitSwitchOnSRD2, CheckSwitchOnSRD2Complete, CheckSwitchOnSRD2Error)
-                .End(SafetyAllOnStep.End, NullFun, _delay_1ms);
-
-            return Runner.Status;
-        }
-
-        #region SRD1
-        /// <summary>
-        /// Switch on SRD1 Motors
-        /// </summary>
-        /// <returns></returns>
-        private bool SwitchOnSRD1()
-        {
-            return _srd1SwitchOnRoutine.Start() == RState.Running;
-        }
-        /// <summary>
-        /// 检查SRD1 Motors switchon是否完成
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckSwitchOnSRD1Complete()
-        {
-            if (!ModuleHelper.IsInstalled(ModuleName.SRD1))
-            {
-                return true;
-            }
-            return CommonFunction.CheckRoutineEndState(_srd1SwitchOnRoutine);
-        }
-        /// <summary>
-        /// 检查SRD1 Motors switchon是否出错
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckSwitchOnSRD1Error()
-        {
-            if (!ModuleHelper.IsInstalled(ModuleName.SRD1))
-            {
-                return false;
-            }
-            return CommonFunction.CheckRoutineStopState(_srd1SwitchOnRoutine);
-        }
-        #endregion
-
-        #region SRD2
-        /// <summary>
-        /// Switch on SRD2 Motors
-        /// </summary>
-        /// <returns></returns>
-        private bool SwitchOnSRD2()
-        {
-            return _srd2SwitchOnRoutine.Start()==RState.Running;
-        }
-        /// <summary>
-        /// 检查SRD2 Motors switchon是否完成
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckSwitchOnSRD2Complete()
-        {
-            if (!ModuleHelper.IsInstalled(ModuleName.SRD2))
-            {
-                return true;
-            }
-            return CommonFunction.CheckRoutineEndState(_srd2SwitchOnRoutine);
-        }
-        /// <summary>
-        /// 检查SRD2 Motors switchon是否出错
-        /// </summary>
-        /// <returns></returns>
-        private bool CheckSwitchOnSRD2Error()
-        {
-            if (!ModuleHelper.IsInstalled(ModuleName.SRD2))
-            {
-                return true;
-            }
-            return CommonFunction.CheckRoutineStopState(_srd2SwitchOnRoutine);
-        }
-        #endregion
-
-        /// <summary>
-        /// 启动
-        /// </summary>
-        /// <param name="objs"></param>
-        /// <returns></returns>
-        public RState Start(params object[] objs)
-        {
-            _srd1SwitchOnRoutine = new SRDSwitchOnRoutine(ModuleName.SRD1.ToString());
-            _srd2SwitchOnRoutine = new SRDSwitchOnRoutine(ModuleName.SRD2.ToString());
-            _device = DEVICE.GetDevice<SafetyDevice>(Module);
-            return Runner.Start(Module, $"Safety All On");
-        }
-    }
-}

+ 28 - 2
PunkHPX8_RT/Devices/Safety/SafetyResetRoutine.cs

@@ -33,6 +33,14 @@ namespace PunkHPX8_RT.Devices.Safety
             PlatingCell34Sto1EstopDelay,
             PlatingCell34Sto2EstopRestart,
             PlatingCell34Sto2EstopDelay,
+            Res12StoEstopRestart,
+            Res12StoEstopDelay,
+            Res34StoEstopRestart,
+            Res34StoEstopDelay,
+            VpwStoEstopRestart,
+            VpwStoEstopDelay,
+            SrdStoEstopRestart,
+            SrdStoEstopDelay,
             SlsRestart,
             End
         }
@@ -46,6 +54,10 @@ namespace PunkHPX8_RT.Devices.Safety
         private SafetyToggleRoutine _platingCell12Sto2EstopRestart;
         private SafetyToggleRoutine _platingCell34Sto1EstopRestart;
         private SafetyToggleRoutine _platingCell34Sto2EstopRestart;
+        private SafetyToggleRoutine _res12StoEstopRestart;
+        private SafetyToggleRoutine _res34StoEstopRestart;
+        private SafetyToggleRoutine _vpwStoEstopRestart;
+        private SafetyToggleRoutine _srdStoEstopRestart;
         private SafetyDevice _device;
         #endregion
         /// <summary>
@@ -60,6 +72,10 @@ namespace PunkHPX8_RT.Devices.Safety
             _platingCell12Sto2EstopRestart=new SafetyToggleRoutine(module);
             _platingCell34Sto1EstopRestart= new SafetyToggleRoutine(module);    
             _platingCell34Sto2EstopRestart = new SafetyToggleRoutine(module);
+            _res12StoEstopRestart=new SafetyToggleRoutine(module);
+            _res34StoEstopRestart=new SafetyToggleRoutine(module);
+            _vpwStoEstopRestart = new SafetyToggleRoutine(module);
+            _srdStoEstopRestart=new SafetyToggleRoutine (module);
         }
 
         /// <summary>
@@ -96,8 +112,18 @@ namespace PunkHPX8_RT.Devices.Safety
                 .Run(SafetyResetStep.PlatingCell34Sto2EstopDelay, () => { return _platingCell34Sto1EstopRestart.Start("PlatingCell34Sto2EstopRestart") == RState.Running; },
                 () => { return CheckRoutineStatus(_platingCell34Sto2EstopRestart); }, _delay_1s)
                 .Delay(SafetyResetStep.PlatingCell34Sto1EstopDelay, 100)//100 delay
-                .Run(SafetyResetStep.SlsRestart, () => { return _slsRestart.Start("SlsRestart") == RState.Running; },
-                () => { return CheckRoutineStatus(_slsRestart); }, _delay_1s)
+                .Run(SafetyResetStep.Res12StoEstopDelay, () => { return _res12StoEstopRestart.Start("Res12StoEstopRestart") == RState.Running; },
+                () => { return CheckRoutineStatus(_res12StoEstopRestart); }, _delay_1s)
+                .Delay(SafetyResetStep.Res12StoEstopDelay, 100)//100 delay
+                .Run(SafetyResetStep.Res34StoEstopDelay, () => { return _res34StoEstopRestart.Start("Res34StoEstopRestart") == RState.Running; },
+                () => { return CheckRoutineStatus(_res34StoEstopRestart); }, _delay_1s)
+                .Delay(SafetyResetStep.Res34StoEstopDelay, 100)//100 delay
+                .Run(SafetyResetStep.VpwStoEstopRestart, () => { return _vpwStoEstopRestart.Start("VpwStoEstopRestart") == RState.Running; },
+                () => { return CheckRoutineStatus(_vpwStoEstopRestart); }, _delay_1s)
+                .Delay(SafetyResetStep.VpwStoEstopDelay, 100)//100 delay
+                .Run(SafetyResetStep.SrdStoEstopRestart, () => { return _srdStoEstopRestart.Start("SrdStoEstopRestart") == RState.Running; },
+                () => { return CheckRoutineStatus(_srdStoEstopRestart); }, _delay_1s)
+                .Delay(SafetyResetStep.SrdStoEstopRestart, 100)//100 delay
                 .End(SafetyResetStep.End, NullFun, _delay_1ms);
             return Runner.Status;
         }

+ 14 - 11
PunkHPX8_RT/Devices/Safety/SafetyToggleRoutine.cs

@@ -15,12 +15,14 @@ using MECF.Framework.Common.IOCore;
 
 namespace PunkHPX8_RT.Devices.Safety
 {
-    public class SafetyArmResetRoutine : RoutineBase, IRoutine
+    public class SafetyToggleRoutine : RoutineBase, IRoutine
     {
+
         private enum SafetyToggleStep
         {
             WriteFalse,
             WriteTrue,
+            LastWriteFalse,
             End
         }
         #region 内部变量
@@ -29,9 +31,9 @@ namespace PunkHPX8_RT.Devices.Safety
         /// </summary>
         private string _doName = "";
         /// <summary>
-        /// 写入数值
+        /// do写入数值
         /// </summary>
-        private double _doWriteValue = 0;
+        private bool _doWriteValue = false;
         /// <summary>
         /// 设备
         /// </summary>
@@ -45,7 +47,7 @@ namespace PunkHPX8_RT.Devices.Safety
         /// 构造函数
         /// </summary>
         /// <param name="module"></param>
-        public SafetyArmResetRoutine(string module) : base(module)
+        public SafetyToggleRoutine(string module) : base(module)
         {
         }
         /// <summary>
@@ -61,8 +63,9 @@ namespace PunkHPX8_RT.Devices.Safety
         /// <returns></returns>
         public RState Monitor()
         {
-            Runner.Run(SafetyToggleStep.WriteFalse, () => { return WriteDoValue(0); }, CheckDoValue, _timeout)
-                .Run(SafetyToggleStep.WriteTrue, () => { return WriteDoValue(1); }, CheckDoValue, _timeout)
+            Runner.Run(SafetyToggleStep.WriteFalse, () => { return WriteDoValue(false); }, CheckDoValue, _timeout)
+                .Run(SafetyToggleStep.WriteTrue, () => { return WriteDoValue(true); }, CheckDoValue, _timeout)
+                .Run(SafetyToggleStep.LastWriteFalse, () => { return WriteDoValue(false); }, CheckDoValue, _timeout)
                 .End(SafetyToggleStep.End, NullFun, _delay_1ms);
             return Runner.Status;
         }
@@ -71,11 +74,11 @@ namespace PunkHPX8_RT.Devices.Safety
         /// </summary>
         /// <param name="value"></param>
         /// <returns></returns>
-        private bool WriteDoValue(double value)
+        private bool WriteDoValue(bool value)
         {
             string ioName = BeckhoffModuleIOManager.Instance.GetIoNameByInnerModuleName($"{Module}.{_doName}");
             _doWriteValue = value;
-            return IOModuleManager.Instance.WriteIoValue(ioName, value);
+            return BeckhoffIOManager.Instance.WriteIoValue(ioName, value);
         }
         /// <summary>
         /// 检验do的数值
@@ -86,8 +89,8 @@ namespace PunkHPX8_RT.Devices.Safety
             PropertyInfo propertyInfo = _device.SafetyData.GetType().GetProperty(_doName);
             if (propertyInfo != null)
             {
-                double doValue = (double)propertyInfo.GetValue(_device.SafetyData);
-                return doValue==_doWriteValue;
+                bool doValue = (bool)propertyInfo.GetValue(_device.SafetyData);
+                return doValue == _doWriteValue;
             }
             else
             {
@@ -103,7 +106,7 @@ namespace PunkHPX8_RT.Devices.Safety
         public RState Start(params object[] objs)
         {
             _device = DEVICE.GetDevice<SafetyDevice>(Module);
-            _doName= objs[0].ToString();
+            _doName = objs[0].ToString();
             return Runner.Start(Module, $"{_doName} toggle");
         }
     }

+ 0 - 2
PunkHPX8_RT/PunkHPX8_RT.csproj

@@ -237,9 +237,7 @@
     <Compile Include="Devices\Reservoir\DMReservoirDevice.cs" />
     <Compile Include="Devices\Reservoir\HSReservoirDevice.cs" />
     <Compile Include="Devices\Reservoir\ReservoirDevice.cs" />
-    <Compile Include="Devices\Safety\SafetyNewAllOnRoutine.cs" />
     <Compile Include="Devices\Safety\SafetyAllOnRoutine.cs" />
-    <Compile Include="Devices\Safety\SafetyArmResetRoutine.cs" />
     <Compile Include="Devices\SRD\SrdCommonChuckATMRoutine.cs" />
     <Compile Include="Devices\SRD\SrdCommonFlipperRoutine.cs" />
     <Compile Include="Devices\SRD\SrdCommonLiftUpRoutine.cs" />