| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 | 
							- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Routine;
 
- 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 LoaderFlowTestRoutine : RoutineBase, IRoutine
 
-     {
 
-         private enum FlowTestStep
 
-         {
 
-             FirstFlowTest,
 
-             FirstFlowTestWait,
 
-             SecondFlowTest,
 
-             SecondFlowTestWait,
 
-             End,
 
-         }
 
-         #region 内部变量
 
-         private LoaderLeakFirstFlowTestRoutine _firstFlowTestRoutine;
 
-         private LoaderReLeakFlowTestRoutine _reLeakFlowTestRoutine;
 
-         private bool _isNeedReTest;
 
-         private LoaderCommonDevice _commonDevice;
 
-         #endregion
 
-         /// <summary>
 
-         /// 构造函数
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         public LoaderFlowTestRoutine(string module) : base(module)
 
-         {
 
-         }
 
-         /// <summary>
 
-         /// 中止
 
-         /// </summary>
 
-         public void Abort()
 
-         {
 
-             Runner.Stop("Manual Abort");
 
-         }
 
-         /// <summary>
 
-         /// 监控
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public RState Monitor()
 
-         {
 
-             Runner.Run(FlowTestStep.FirstFlowTest, StartFirstFlowTest, _delay_1ms)
 
-                 .WaitWithStopCondition(FlowTestStep.FirstFlowTestWait, CheckFirstTestResult, CheckFirstTestFailedResult)
 
-                 .Run(FlowTestStep.SecondFlowTest, StartSecondFlowTest, _delay_1ms)
 
-                 .WaitWithStopCondition(FlowTestStep.SecondFlowTestWait, CheckSecondTestResult, CheckSecondTestFailedResult)
 
-                 .End(FlowTestStep.End, NullFun, _delay_1ms);
 
-             return Runner.Status;
 
-         }
 
-         /// <summary>
 
-         /// 启动第一次测试
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool StartFirstFlowTest()
 
-         {
 
-             bool result = _firstFlowTestRoutine.Start()==RState.Running;
 
-             if(result)
 
-             {
 
-                 _commonDevice.CommonData.LeakStatus = "Testing";
 
-             }
 
-             else
 
-             {
 
-                 _commonDevice.CommonData.LeakStatus = "Failed";
 
-             }
 
-             return result;
 
-         }
 
-         /// <summary>
 
-         /// 检验第一次测试结果
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckFirstTestResult()
 
-         {
 
-             RState rState = _firstFlowTestRoutine.Monitor();
 
-             if (rState == RState.End)
 
-             {
 
-                 _commonDevice.CommonData.LeakStatus = "PASS";
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 if(rState==RState.Timeout)
 
-                 {
 
-                     _isNeedReTest = true;
 
-                     return true;
 
-                 }
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// 检验第一次失败测试结果
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckFirstTestFailedResult()
 
-         {
 
-             RState rState = _firstFlowTestRoutine.Monitor();
 
-             if(rState==RState.Failed)
 
-             {
 
-                 _commonDevice.CommonData.LeakStatus = "Failed";
 
-                 _commonDevice.LeakFlowClampOffAction();
 
-                 _commonDevice.LeakVacuumOffAction();
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// 启动第一次测试
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool StartSecondFlowTest()
 
-         {
 
-             if (_isNeedReTest)
 
-             {
 
-                 bool result = _reLeakFlowTestRoutine.Start() == RState.Running;
 
-                 if (!result)
 
-                 {
 
-                     _commonDevice.CommonData.LeakStatus = "Failed";
 
-                 }
 
-                 return result;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验第二次测试结果
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckSecondTestResult()
 
-         {
 
-             if (_isNeedReTest)
 
-             {
 
-                 RState rState = _reLeakFlowTestRoutine.Monitor();
 
-                 if (rState == RState.End)
 
-                 {
 
-                     _commonDevice.CommonData.LeakStatus = "PASS";
 
-                     return true;
 
-                 }
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验第二次失败测试结果
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckSecondTestFailedResult()
 
-         {
 
-             if (_isNeedReTest)
 
-             {
 
-                 RState rState = _reLeakFlowTestRoutine.Monitor();
 
-                 if (rState == RState.Failed||rState==RState.Timeout)
 
-                 {
 
-                     _commonDevice.CommonData.LeakStatus = "Failed";
 
-                     _commonDevice.LeakFlowClampOffAction();
 
-                     _commonDevice.LeakVacuumOffAction();
 
-                     return true;
 
-                 }
 
-                 return false;                
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// 启动
 
-         /// </summary>
 
-         /// <param name="objs"></param>
 
-         /// <returns></returns>
 
-         public RState Start(params object[] objs)
 
-         {
 
-             _isNeedReTest = false;
 
-             _reLeakFlowTestRoutine = new LoaderReLeakFlowTestRoutine(Module);
 
-             _firstFlowTestRoutine=new LoaderLeakFirstFlowTestRoutine(Module);
 
-             _commonDevice = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
 
-             Runner.Start(Module, "Flow Test");
 
-             return RState.Running;
 
-         }
 
-     }
 
- }
 
 
  |