SRDRunRecipeRoutine.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.Util;
  5. using CyberX8_Core;
  6. using CyberX8_RT.Devices.AXIS;
  7. using CyberX8_RT.Devices.Facilities;
  8. using CyberX8_RT.Devices.SRD;
  9. using MECF.Framework.Common.Beckhoff.AxisProvider;
  10. using MECF.Framework.Common.RecipeCenter;
  11. using MECF.Framework.Common.Routine;
  12. namespace CyberX8_RT.Modules.SRD
  13. {
  14. public class SRDRunRecipeRoutine : RoutineBase, IRoutine
  15. {
  16. private enum SRDRunRecipeStep
  17. {
  18. CloseDoor,
  19. CheckDoorClosed,
  20. End
  21. }
  22. #region 常量
  23. #endregion
  24. #region 内部变量
  25. /// <summary>
  26. /// Rotation Axis
  27. /// </summary>
  28. private JetAxisBase _rotationAxis;
  29. /// <summary>
  30. /// SRD Common
  31. /// </summary>
  32. private SrdCommonDevice _srdCommon;
  33. /// <summary>
  34. /// Total SRD
  35. /// </summary>
  36. private TotalSRDDevice _totalSRDDevice;
  37. /// <summary>
  38. /// 另外SRD实例
  39. /// </summary>
  40. private SRDEntity _otherSrdEntity;
  41. /// <summary>
  42. /// Loader Common
  43. /// </summary>
  44. private SystemFacilities _systemFacilities;
  45. /// <summary>
  46. /// 是否正在用水
  47. /// </summary>
  48. private bool _isUsingWater;
  49. /// <summary>
  50. /// Recipe
  51. /// </summary>
  52. private SrdRecipe _srdRecipe;
  53. /// <summary>
  54. /// SRD rotation Provider对象
  55. /// </summary>
  56. private BeckhoffProviderAxis _rotationProviderAxis;
  57. #endregion
  58. #region 属性
  59. /// <summary>
  60. /// 是否正在用水
  61. /// </summary>
  62. public bool IsUsingWater { get { return _isUsingWater; } }
  63. #endregion
  64. /// <summary>
  65. /// 构造函数
  66. /// </summary>
  67. /// <param name="module"></param>
  68. public SRDRunRecipeRoutine(string module) : base(module)
  69. {
  70. }
  71. /// <summary>
  72. /// 中止
  73. /// </summary>
  74. public void Abort()
  75. {
  76. Runner.Stop("SRD Run Recipe Abort");
  77. }
  78. /// <summary>
  79. /// 监控
  80. /// </summary>
  81. /// <returns></returns>
  82. public RState Monitor()
  83. {
  84. Runner//.Run(SRDRunRecipeStep.CloseDoor, !_presenceTestFlag, CheckFacilities, _delay_1ms)
  85. .End(SRDRunRecipeStep.End, NullFun, _delay_1ms);
  86. return Runner.Status;
  87. }
  88. /// <summary>
  89. /// 启动
  90. /// </summary>
  91. /// <param name="objs"></param>
  92. /// <returns></returns>
  93. public RState Start(params object[] objs)
  94. {
  95. _srdRecipe = (SrdRecipe)objs[0];
  96. if (_srdRecipe == null)
  97. {
  98. NotifyError(eEvent.ERR_SRD, "srd recipe is null", 0);
  99. return RState.Failed;
  100. }
  101. _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
  102. if (!_rotationAxis.IsHomed)
  103. {
  104. NotifyError(eEvent.ERR_SRD, "Rotation is not homed", 0);
  105. return RState.Failed;
  106. }
  107. _srdCommon = DEVICE.GetDevice<SrdCommonDevice>($"{Module}.Common");
  108. _totalSRDDevice = DEVICE.GetDevice<TotalSRDDevice>("SRD");
  109. _systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  110. string otherSRD = Module == "SRD1" ? "SRD2" : "SRD1";
  111. _otherSrdEntity = Singleton<RouteManager>.Instance.GetModule<SRDEntity>(otherSRD);
  112. _rotationProviderAxis = BeckhoffAxisProviderManager.Instance.GetAxisProvider($"{Module}.Rotation");
  113. if (_rotationProviderAxis == null)
  114. {
  115. NotifyError(eEvent.ERR_SRD, $"{Module}.Rotation Provider is not exist", 0);
  116. return RState.Failed;
  117. }
  118. return Runner.Start(Module, "SRD Run Recipe Start");
  119. }
  120. }
  121. }