LoadRoutine.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. public LoadRoutine(ModuleName module, VCEModuleBase vce) : base(module)
  40. {
  41. _vce = vce;
  42. switch (RtInstance.ConfigType)
  43. {
  44. case ConfigType.VenusSE:
  45. _tm = DEVICE.GetDevice<HongHuTM>("TM");
  46. break;
  47. case ConfigType.VenusDE:
  48. _tm = DEVICE.GetDevice<HongHuDETM>("TM");
  49. break;
  50. }
  51. pumpRoutine = new SEMFPumpRoutine(_tm, module);
  52. _isATMMode = SC.GetValue<bool>("System.IsATMMode");
  53. }
  54. public RState Start(params object[] objs)
  55. {
  56. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") *1000;
  57. //if vce inner door not close cannot do it as it will pump
  58. if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module))
  59. {
  60. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
  61. return RState.Failed;
  62. }
  63. Reset();
  64. return Runner.Start(Module,"Vce Load Routine");
  65. }
  66. public RState Monitor()
  67. {
  68. Runner.Run(LoadStep.CloseOutDoor, CloseOutDoor, CheckVceIdle, _timeout)
  69. .Run(LoadStep.GotoLP, _vce.GotoLP, CheckVceIdle, _timeout)
  70. .Run(LoadStep.VcePumpDown, VCEPumpDown, CheckPumpOver)
  71. .Run(LoadStep.Mapping, Mapping, CheckVceIdle, 25 *1000)
  72. .Run(LoadStep.ReadMap, ReadMap, CheckVceIdle, _timeout)
  73. .Run(LoadStep.OpenInnerDoor, OpenInnerDoor, CheckInnerDoorOpen)
  74. .End(LoadStep.NotifyOver, NullFun, 100);
  75. return Runner.Status;
  76. }
  77. private bool CheckInnerDoorOpen()
  78. {
  79. return !_tm.VCESlitDoorClosed(Module);
  80. }
  81. private bool OpenInnerDoor()
  82. {
  83. return _tm.TurnSlitDoor(Module,true);
  84. }
  85. //
  86. private bool CheckPumpOver()
  87. {
  88. RState ret = pumpRoutine.Monitor();
  89. if (ret == RState.Failed || ret == RState.Timeout)
  90. {
  91. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  92. }
  93. return ret == RState.End;
  94. }
  95. private bool VCEPumpDown()
  96. {
  97. return pumpRoutine.Start() == RState.Running;
  98. }
  99. private bool ReadMap()
  100. {
  101. return _vce.ReadMap();
  102. }
  103. private bool Mapping()
  104. {
  105. return _vce.Map();
  106. }
  107. private bool CloseOutDoor()
  108. {
  109. return _vce.CloseDoor();
  110. }
  111. private bool CheckVceIdle()
  112. {
  113. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  114. {
  115. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  116. return false;
  117. }
  118. return _vce.Status == RState.End;
  119. }
  120. public void Abort()
  121. {
  122. }
  123. }
  124. }