| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 | using Aitex.Core.RT.Device;using Aitex.Core.RT.Log;using Aitex.Core.RT.Routine;using Aitex.Core.RT.SCCore;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.Routine;using CyberX8_Core;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace CyberX8_RT.Devices.Loader{    public class LoaderReLeakFlowTestRoutine : RoutineBase, IRoutine    {        private enum LeakFlowTestStep        {            FirstDelay,            FlowClampOff,            VacuumOff,            LeakFlowTest,             CheckLeakFlowState,            End        }        #region 内部变量        private LoaderCommonDevice _loaderCommon;        private int _retryDelayms = 5;        private LoaderLeakFirstFlowTestRoutine _routine;        #endregion        public LoaderReLeakFlowTestRoutine(string module) : base(module)        {        }        public void Abort()        {            Runner.Stop("Manual Abort");        }        public RState Monitor()        {            Runner.Delay(LeakFlowTestStep.FirstDelay,_retryDelayms*1000)                  .Run(LeakFlowTestStep.FlowClampOff, FlowClampOff, _delay_1ms)                  .Run(LeakFlowTestStep.VacuumOff, VacuumOff, _delay_1ms)                  .Run(LeakFlowTestStep.LeakFlowTest, FlowTest, NullFun, 100)                  .WaitWithStopCondition(LeakFlowTestStep.CheckLeakFlowState,CheckFlowTestStatus,CheckFlowTestStop)                  .End(LeakFlowTestStep.End, NullFun);            return Runner.Status;         }        /// <summary>        /// Flow Clamp off        /// </summary>        /// <returns></returns>        private bool FlowClampOff()        {            return _loaderCommon.LeakFlowClampOffAction();        }        /// <summary>        /// Vacuum Off        /// </summary>        /// <returns></returns>        private bool VacuumOff()        {            return _loaderCommon.LeakVacuumOffAction();        }        /// <summary>        /// 确认结束状态        /// </summary>        /// <returns></returns>        private bool CheckEndState()        {            return _loaderCommon.Status == RState.End;        }        /// <summary>        /// Flow Test        /// </summary>        /// <returns></returns>        private bool FlowTest()        {            return _routine.Start() == RState.Running;        }        /// <summary>        /// 检验FlowTest Routine结束状态        /// </summary>        /// <returns></returns>        private bool CheckFlowTestStatus()        {            return _routine.Monitor() == RState.End;        }        /// <summary>        /// 检验FlowTest Routine 失败状态        /// </summary>        /// <returns></returns>        private bool CheckFlowTestStop()        {            RState state = _routine.Monitor();            return state == RState.Failed||state==RState.Timeout;        }        public RState Start(params object[] objs)        {            if (SC.ContainsItem($"{Module}.LeakTestRetryWait"))            {                _retryDelayms = SC.GetValue<int>($"{Module}.LeakTestRetryWait");            }            _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");            _routine = new LoaderLeakFirstFlowTestRoutine(Module);            Runner.Start(Module, "Re Leak Flow Test");            return RState.Running;        }    }}
 |