UnloadRoutine.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.OperationCenter;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.RT.Core.Equipments;
  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;
  20. using Venus_RT.Modules.TM.VenusEntity;
  21. namespace Venus_RT.Modules.VCE
  22. {
  23. public class UnloadRoutine : ModuleRoutineBase, IRoutine
  24. {
  25. public enum UnloadStep
  26. {
  27. CloseDoor,
  28. Vent,
  29. GotoUnload,
  30. OpenOutDoor,
  31. NotifyOver
  32. }
  33. VCEModuleBase _vce;
  34. TMBase _tm;
  35. int _timeout;
  36. SEMFVentRoutine ventRoutine;
  37. public UnloadRoutine(ModuleName module, VCEModuleBase vce) : base(module)
  38. {
  39. _vce = vce;
  40. switch (RtInstance.ConfigType)
  41. {
  42. case ConfigType.VenusSE:
  43. _tm = DEVICE.GetDevice<HongHuTM>("TM");
  44. break;
  45. case ConfigType.VenusDE:
  46. _tm = DEVICE.GetDevice<HongHuDETM>("TM");
  47. break;
  48. }
  49. ventRoutine = new SEMFVentRoutine(_tm, module);
  50. }
  51. public RState Start(params object[] objs)
  52. {
  53. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  54. //if vce inner door not close cannot dot it as it will vent
  55. //if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed)
  56. //{
  57. // LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
  58. // return RState.Failed;
  59. //}
  60. Reset();
  61. return Runner.Start(Module, "VCE Unload Routine");
  62. }
  63. public RState Monitor()
  64. {
  65. Runner.Run(UnloadStep.GotoUnload, GotoUnload, CheckVceIdle, _timeout)
  66. .Run(UnloadStep.CloseDoor, CloseDoor, CheckDoorIsClose)
  67. .Run(UnloadStep.Vent, Vent, CheckVentOver)
  68. .Run(UnloadStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _timeout)
  69. .End(UnloadStep.NotifyOver, NullFun, 100);
  70. return Runner.Status;
  71. }
  72. private bool CloseDoor()
  73. {
  74. return _tm.TurnSlitDoor(Module, false);
  75. }
  76. private bool CheckDoorIsClose()
  77. {
  78. return Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module);
  79. }
  80. private bool CheckVentOver()
  81. {
  82. RState ret = ventRoutine.Monitor();
  83. if (ret == RState.Failed || ret == RState.Timeout)
  84. {
  85. _vce.PostMsg(VceMSG.Error);
  86. }
  87. return ret == RState.End;
  88. }
  89. private bool Vent()
  90. {
  91. return ventRoutine.Start() == RState.Running;
  92. }
  93. private bool OpenOutDoor()
  94. {
  95. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module) && Singleton<RouteManager>.Instance.seTM.VCEPressure(Module) >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))
  96. {
  97. return _vce.OpenDoor();
  98. }
  99. else
  100. {
  101. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");
  102. return false;
  103. }
  104. }
  105. private bool GotoUnload()
  106. {
  107. return _vce.GotoLP();
  108. }
  109. private bool CheckVceIdle()
  110. {
  111. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  112. {
  113. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  114. return false;
  115. }
  116. return _vce.Status == RState.End;
  117. }
  118. public void Abort()
  119. {
  120. }
  121. }
  122. }