LoadRoutine.cs 3.9 KB

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