UnloadRoutine.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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.VCE;
  18. using Venus_RT.Modules.TM;
  19. using Venus_RT.Modules.TM.VenusEntity;
  20. namespace Venus_RT.Modules.VCE
  21. {
  22. public class UnloadRoutine : ModuleRoutineBase, IRoutine
  23. {
  24. public enum UnloadStep
  25. {
  26. CloseDoor,
  27. Vent,
  28. GotoUnload,
  29. OpenOutDoor,
  30. NotifyOver
  31. }
  32. VceModuleBase _vce;
  33. HongHuTM _tm;
  34. int _timeout;
  35. SEMFVentRoutine ventRoutine;
  36. public UnloadRoutine(ModuleName module, VceModuleBase vce) : base(module)
  37. {
  38. _vce = vce;
  39. _tm = DEVICE.GetDevice<HongHuTM>("SETM");
  40. ventRoutine = new SEMFVentRoutine(_tm, module);
  41. }
  42. public RState Start(params object[] objs)
  43. {
  44. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  45. //if vce inner door not close cannot dot it as it will vent
  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 Unload Routine");
  53. }
  54. public RState Monitor()
  55. {
  56. Runner.Run(UnloadStep.CloseDoor, CloseDoor, CheckDoorIsClose)
  57. .Run(UnloadStep.Vent, Vent, CheckVentOver)
  58. .Run(UnloadStep.GotoUnload, GotoUnload, CheckVceIdle, _timeout)
  59. .Run(UnloadStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _timeout)
  60. .End(UnloadStep.NotifyOver, NullFun, 100);
  61. return Runner.Status;
  62. }
  63. private bool CloseDoor()
  64. {
  65. return _tm.TurnSlitDoor(ModuleName.VCE1, false);
  66. }
  67. private bool CheckDoorIsClose()
  68. {
  69. return Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed;
  70. }
  71. private bool CheckVentOver()
  72. {
  73. RState ret = ventRoutine.Monitor();
  74. if (ret == RState.Failed || ret == RState.Timeout)
  75. {
  76. _vce.PostMsg(VceMSG.Error);
  77. }
  78. return ret == RState.End;
  79. }
  80. private bool Vent()
  81. {
  82. return ventRoutine.Start() == RState.Running;
  83. }
  84. private bool OpenOutDoor()
  85. {
  86. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM && Singleton<RouteManager>.Instance.seTM.VCEPressure >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))
  87. {
  88. return _vce.OpenDoor();
  89. }
  90. else
  91. {
  92. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");
  93. return false;
  94. }
  95. }
  96. private bool GotoUnload()
  97. {
  98. return _vce.GotoLP();
  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. }