LoadRoutine.cs 4.0 KB

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