PrepareToTransferRoutine.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using MECF.Framework.Common.Routine;
  4. using CyberX8_Core;
  5. using CyberX8_RT.Devices.LinMot;
  6. using CyberX8_RT.Devices.Prewet;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace CyberX8_RT.Modules.Prewet
  13. {
  14. public class PrepareToTransferRoutine : RoutineBase, IRoutine
  15. {
  16. private enum PrepareToTransferStep
  17. {
  18. PumpValveOff,
  19. LinmotDisable,
  20. End
  21. }
  22. #region 内部变量
  23. private LinMotAxis _linmotAxis;
  24. private PrewetDevice _prewetDevice;
  25. private int _timeout = 5000;
  26. private bool _isNeedStopLinmot;
  27. #endregion
  28. /// <summary>
  29. /// 构造函数
  30. /// </summary>
  31. /// <param name="module"></param>
  32. public PrepareToTransferRoutine(string module,LinMotAxis linMotAxis) : base(module)
  33. {
  34. _linmotAxis = linMotAxis;
  35. }
  36. public void Abort()
  37. {
  38. Runner.Stop("Manual Abort");
  39. }
  40. /// <summary>
  41. /// 监控
  42. /// </summary>
  43. /// <returns></returns>
  44. /// <exception cref="NotImplementedException"></exception>
  45. public RState Monitor()
  46. {
  47. Runner.Run(PrepareToTransferStep.PumpValveOff, () => { return _prewetDevice.PumpValveClose(); }, () => { return !_prewetDevice.PrewetPumpData.PumpValve && !_prewetDevice.PrewetPumpData.PumpEnable; }, _timeout)
  48. .RunIf(PrepareToTransferStep.LinmotDisable,_isNeedStopLinmot,() => { return _linmotAxis.SwitchOff(); }, () => { return _linmotAxis.IsDisabled; }, _delay_2s)
  49. .End(PrepareToTransferStep.End, NullFun, _delay_1ms);
  50. return Runner.Status;
  51. }
  52. /// <summary>
  53. /// 启动
  54. /// </summary>
  55. /// <param name="objs"></param>
  56. /// <returns></returns>
  57. /// <exception cref="NotImplementedException"></exception>
  58. public RState Start(params object[] objs)
  59. {
  60. _prewetDevice = DEVICE.GetDevice<PrewetDevice>(Module);
  61. _isNeedStopLinmot = objs.Length > 0 ? ((bool)objs[0]) : true;
  62. return Runner.Start(Module, "PrepareToTransfer");
  63. }
  64. }
  65. }