PrewetLinmotScanWetRoutine.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using MECF.Framework.Common.Routine;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.LinMot;
  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 PrewetLinmotScanWetRoutine : RoutineBase, IRoutine
  15. {
  16. private enum PrewetScanStep
  17. {
  18. Reset,
  19. WaitReset,
  20. ScanWet,
  21. WaitScanWet,
  22. End
  23. }
  24. #region 内部变量
  25. private int _totalScan;
  26. private LinMotAxis _linMotAxis;
  27. #endregion
  28. /// <summary>
  29. /// 构造函数
  30. /// </summary>
  31. /// <param name="module"></param>
  32. public PrewetLinmotScanWetRoutine(string module,LinMotAxis linMotAxis) : base(module)
  33. {
  34. _linMotAxis = linMotAxis;
  35. }
  36. /// <summary>
  37. /// 中止
  38. /// </summary>
  39. public void Abort()
  40. {
  41. Runner.Stop("Manual Abort");
  42. }
  43. /// <summary>
  44. /// 监控
  45. /// </summary>
  46. /// <returns></returns>
  47. public RState Monitor()
  48. {
  49. Runner.Run(PrewetScanStep.Reset, ResetLinmotAxis, _delay_1ms)
  50. .WaitWithStopCondition(PrewetScanStep.WaitReset, () => { return _linMotAxis.Status == RState.End; }, () => { return _linMotAxis.Status == RState.Failed; })
  51. .Run(PrewetScanStep.ScanWet, ScanWet, _delay_1ms)
  52. .WaitWithStopCondition(PrewetScanStep.WaitScanWet, () => { return _linMotAxis.Status == RState.End; }, () => { return _linMotAxis.Status == RState.Failed; })
  53. .End(PrewetScanStep.End, NullFun, _delay_1ms);
  54. return Runner.Status;
  55. }
  56. /// <summary>
  57. /// Reset Linmot
  58. /// </summary>
  59. /// <returns></returns>
  60. private bool ResetLinmotAxis()
  61. {
  62. return _linMotAxis.ResetOperation("",false);
  63. }
  64. /// <summary>
  65. /// Scan Wet
  66. /// </summary>
  67. /// <returns></returns>
  68. private bool ScanWet()
  69. {
  70. return _linMotAxis.StartPosition("", new object[] { _totalScan });
  71. }
  72. /// <summary>
  73. /// 启动
  74. /// </summary>
  75. /// <param name="objs"></param>
  76. /// <returns></returns>
  77. public RState Start(params object[] objs)
  78. {
  79. _totalScan = (int)objs[0];
  80. if(_totalScan==0)
  81. {
  82. LOG.WriteLog(eEvent.ERR_LINMOT, Module, "Total Scan is 0");
  83. return RState.Failed;
  84. }
  85. return Runner.Start(Module, "Prewet ScanWet");
  86. }
  87. }
  88. }