LoadRoutine.cs 3.6 KB

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