| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | 
							- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.Routine;
 
- using CyberX8_Core;
 
- using CyberX8_RT.Devices.LinMot;
 
- using CyberX8_RT.Devices.Prewet;
 
- using MECF.Framework.Common.Alarm;
 
- using MECF.Framework.Common.Routine;
 
- namespace CyberX8_RT.Modules.Prewet
 
- {
 
-     public class PrewetKeepWetRoutine : RoutineBase, IRoutine
 
-     {
 
-         private enum KeepwetStep
 
-         {
 
-             Idle_KeepwetPrepare,
 
-             Idle_KeepwetPrepareWait,
 
-             Idle_KeepWetStart,
 
-             Idle_KeepWetScan,
 
-             Idle_KeepWetPause,
 
-             End
 
-         }
 
-         #region 内部变量
 
-         /// <summary>
 
-         /// prewet设备
 
-         /// </summary>
 
-         private PrewetDevice _prewetDevice;
 
-         /// <summary>
 
-         /// linmot axis
 
-         /// </summary>
 
-         private LinMotAxis _linMotAxis;
 
-         #endregion
 
-         /// <summary>
 
-         /// 构造函数
 
-         /// </summary>
 
-         /// <param name="module"></param>
 
-         public PrewetKeepWetRoutine(string module,LinMotAxis linMotAxis) : base(module)
 
-         {
 
-             _linMotAxis= linMotAxis;
 
-         }
 
-         /// <summary>
 
-         /// 中止
 
-         /// </summary>
 
-         public void Abort()
 
-         {
 
-             _linMotAxis.StopOperation("", null);
 
-             if (_prewetDevice != null)
 
-             {
 
-                 _prewetDevice.PumpValveClose();
 
-             }
 
-             Runner.Stop("Manual Abort");
 
-         }
 
-         /// <summary>
 
-         /// 监控
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         public RState Monitor()
 
-         {
 
-             Runner.Run(KeepwetStep.Idle_KeepwetPrepare, ResetLinmot, _delay_1ms)
 
-                 .WaitWithStopCondition(KeepwetStep.Idle_KeepwetPrepareWait, CheckResetLinmotEndStatus, CheckResetLinmotStopStatus)
 
-                 .Run(KeepwetStep.Idle_KeepWetStart, ExecuteWetScan, _delay_1s)
 
-                 .WaitWithStopCondition(KeepwetStep.Idle_KeepWetScan,CheckLinmotScanEndStatus,CheckLinmotScanStopStatus)
 
-                 .Run(KeepwetStep.Idle_KeepWetPause, KeepWetComplete, _delay_1ms)
 
-                 .End(KeepwetStep.End, NullFun, _delay_1ms);
 
-             return Runner.Status;
 
-         }
 
-         /// <summary>
 
-         /// Reset Linmot
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool ResetLinmot()
 
-         {
 
-             bool result = _linMotAxis.ResetOperation("", false);
 
-             if (!result)
 
-             {
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验Reset Linmot状态
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool CheckResetLinmotEndStatus()
 
-         {
 
-             return _linMotAxis.Status == RState.End;
 
-         }
 
-         /// <summary>
 
-         /// 检验Reset Linmot停止状态
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckResetLinmotStopStatus()
 
-         {
 
-             return _linMotAxis.Status == RState.Failed || _linMotAxis.Status == RState.Timeout;
 
-         }
 
-         /// <summary>
 
-         /// execute Keep Wet Scan
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool ExecuteWetScan()
 
-         {
 
-             bool pumpValveResult = _prewetDevice.PumpValveOpen();
 
-             if (!pumpValveResult)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_PREWET, Module, "pump valve open error");
 
-                 return false;
 
-             }
 
-             //bool pumpEnableResult = _prewetDevice.PumpEnableOperation("", null);
 
-             //bool pumpEnableResult = _prewetDevice.PumpEnable();
 
-             //if (!pumpEnableResult)
 
-             //{
 
-             //    LOG.WriteLog(eEvent.ERR_PREWET, Module, "pump enable error");
 
-             //    return false;
 
-             //}
 
-             bool result = _linMotAxis.StartPosition("", new object[] { 1 });
 
-             if (!result)
 
-             {
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 检验Linomot扫描结束状态
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckLinmotScanEndStatus()
 
-         {
 
-             return _linMotAxis.Status == RState.End;
 
-         }
 
-         /// <summary>
 
-         /// 检验Linmot Scan停止状态
 
-         /// </summary>
 
-         /// <returns></returns>
 
-         private bool CheckLinmotScanStopStatus()
 
-         {
 
-             bool result=_linMotAxis.Status==RState.Failed||_linMotAxis.Status==RState.Timeout;
 
-             if(!result)
 
-             {
 
-                 //Pressure
 
-                 if (_prewetDevice.PrewetPumpData.PumpPressureData.IsError)
 
-                 {
 
-                     _linMotAxis.StopOperation("", null);
 
-                     _prewetDevice.PumpValveClose();
 
-                     LOG.WriteLog(eEvent.ERR_PREWET, Module, $"Pump pressure {_prewetDevice.PrewetPumpData.PumpPressureData.Value} is in error");
 
-                     return true;
 
-                 }
 
-                 else if (_prewetDevice.PrewetPumpData.PumpPressureData.IsWarning)
 
-                 {
 
-                     string str = $"Pump pressure {_prewetDevice.PrewetPumpData.PumpPressureData.Value} is in warning";
 
-                     if (AlarmListManager.Instance.AddWarn(Module, "Pump Pressure", str))
 
-                     {
 
-                         LOG.WriteLog(eEvent.WARN_PREWET, Module, str);
 
-                     }
 
-                 }
 
-                 //Flow
 
-                 if (_prewetDevice.PrewetPumpData.PumpFlowData.IsError)
 
-                 {
 
-                     LOG.WriteLog(eEvent.ERR_PREWET, Module, $"Pump flow {_prewetDevice.PrewetPumpData.PumpFlowData.Value} is in error");
 
-                     _linMotAxis.StopOperation("", null);
 
-                     _prewetDevice.PumpValveClose();
 
-                     return true;
 
-                 }
 
-                 else if (_prewetDevice.PrewetPumpData.PumpFlowData.IsWarning)
 
-                 {
 
-                     string str = $"Pump flow {_prewetDevice.PrewetPumpData.PumpFlowData.Value} is in warning";
 
-                     if (AlarmListManager.Instance.AddWarn(Module, "Pump Flow", str))
 
-                     {
 
-                         LOG.WriteLog(eEvent.WARN_PREWET, Module, str);
 
-                     }
 
-                 }
 
-                 return false;
 
-             }
 
-             else
 
-             {
 
-                 _prewetDevice.PumpValveClose();
 
-                 return true;
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// Wait execute WetScan
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool WaitExecuteWetScan(object param)
 
-         {
 
-             
 
-             //linmot完成一次scan
 
-             if (_linMotAxis.Status == RState.End)
 
-             {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         /// <summary>
 
-         /// Keep wet scan完成
 
-         /// </summary>
 
-         /// <param name="param"></param>
 
-         /// <returns></returns>
 
-         private bool KeepWetComplete()
 
-         {
 
-             bool result = _prewetDevice.PumpValveClose();
 
-             if (!result)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_PREWET, Module, "pump valve close error");
 
-                 return false;
 
-             }
 
-             result = _linMotAxis.SwitchOff();
 
-             if (!result)
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_PREWET, Module, "linmot disable error");
 
-                 return false;
 
-             }
 
-             return true;
 
-         }
 
-         /// <summary>
 
-         /// 启动
 
-         /// </summary>
 
-         /// <param name="objs"></param>
 
-         /// <returns></returns>
 
-         public RState Start(params object[] objs)
 
-         {
 
-             _prewetDevice = DEVICE.GetDevice<PrewetDevice>(Module);
 
-             return Runner.Start(Module, "Start Keepwet");
 
-         }
 
-     }
 
- }
 
 
  |