LoadRoutine.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  8. using MECF.Framework.RT.ModuleLibrary.Commons;
  9. using MECF.Framework.RT.ModuleLibrary.VceModules;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using Venus_Core;
  16. using Venus_RT.Devices;
  17. using Venus_RT.Devices.TM;
  18. using Venus_RT.Devices.VCE;
  19. using Venus_RT.Modules.TM.VenusEntity;
  20. namespace Venus_RT.Modules.VCE
  21. {
  22. public class LoadRoutine : ModuleRoutineBase, IRoutine
  23. {
  24. private enum LoadStep
  25. {
  26. CloseOutDoor,
  27. GotoLP,
  28. VcePumpDown,
  29. Mapping,
  30. ReadMap,
  31. OpenInnerDoor,
  32. NotifyOver
  33. }
  34. VCEModuleBase _vce;
  35. TMBase _tm;
  36. int _timeout;
  37. SEMFPumpRoutine pumpRoutine;
  38. bool _isATMMode = false;
  39. bool _NeedPump = true; //判定是否需要pump以及打开内门
  40. public LoadRoutine(ModuleName module, VCEModuleBase vce) : base(module)
  41. {
  42. _vce = vce;
  43. switch (RtInstance.ConfigType)
  44. {
  45. case ConfigType.VenusSE:
  46. _tm = DEVICE.GetDevice<HongHuTM>("TM");
  47. break;
  48. case ConfigType.VenusDE:
  49. _tm = DEVICE.GetDevice<HongHuDETM>("TM");
  50. break;
  51. }
  52. pumpRoutine = new SEMFPumpRoutine(_tm, module);
  53. _isATMMode = SC.GetValue<bool>("System.IsATMMode");
  54. _NeedPump = !SC.GetValue<bool>("System.IsPumpBeforeJob");
  55. }
  56. public RState Start(params object[] objs)
  57. {
  58. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") *1000;
  59. //if vce inner door not close cannot do it as it will pump
  60. if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module))
  61. {
  62. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
  63. return RState.Failed;
  64. }
  65. Reset();
  66. return Runner.Start(Module,"Vce Load Routine");
  67. }
  68. public RState Monitor()
  69. {
  70. Runner.Run(LoadStep.CloseOutDoor, CloseOutDoor, CheckVceIdle, _timeout)
  71. .Run(LoadStep.GotoLP, _vce.GotoLP, CheckVceIdle, _timeout)
  72. .RunIf(LoadStep.VcePumpDown, _NeedPump, VCEPumpDown, CheckPumpOver)
  73. .Run(LoadStep.Mapping, Mapping, CheckVceIdle, 25 *1000)
  74. .Run(LoadStep.ReadMap, ReadMap, CheckVceIdle, _timeout)
  75. .RunIf(LoadStep.OpenInnerDoor, _NeedPump, OpenInnerDoor, CheckInnerDoorOpen)
  76. .End(LoadStep.NotifyOver, NullFun, 100);
  77. return Runner.Status;
  78. }
  79. private bool CheckInnerDoorOpen()
  80. {
  81. return !_tm.VCESlitDoorClosed(Module);
  82. }
  83. private bool OpenInnerDoor()
  84. {
  85. return _tm.TurnSlitDoor(Module,true);
  86. }
  87. //
  88. private bool CheckPumpOver()
  89. {
  90. RState ret = pumpRoutine.Monitor();
  91. if (ret == RState.Failed || ret == RState.Timeout)
  92. {
  93. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  94. }
  95. return ret == RState.End;
  96. }
  97. private bool VCEPumpDown()
  98. {
  99. return pumpRoutine.Start() == RState.Running;
  100. }
  101. private bool ReadMap()
  102. {
  103. return _vce.ReadMap();
  104. }
  105. private bool Mapping()
  106. {
  107. return _vce.Map();
  108. }
  109. private bool CloseOutDoor()
  110. {
  111. return _vce.CloseDoor();
  112. }
  113. private bool CheckVceIdle()
  114. {
  115. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  116. {
  117. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  118. return false;
  119. }
  120. return _vce.Status == RState.End;
  121. }
  122. public void Abort()
  123. {
  124. pumpRoutine.Abort();
  125. }
  126. }
  127. }