LoadRoutine.cs 3.7 KB

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