UnloadRoutine.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. if(module == ModuleName.VCE1)
  41. _tm = DEVICE.GetDevice<HongHuTM>("SETM");
  42. else
  43. _tm = DEVICE.GetDevice<HongHuDETM>("DETM");
  44. ventRoutine = new SEMFVentRoutine(_tm, module);
  45. }
  46. public RState Start(params object[] objs)
  47. {
  48. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  49. //if vce inner door not close cannot dot it as it will vent
  50. //if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed)
  51. //{
  52. // LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
  53. // return RState.Failed;
  54. //}
  55. Reset();
  56. return Runner.Start(Module, "VCE Unload Routine");
  57. }
  58. public RState Monitor()
  59. {
  60. Runner.Run(UnloadStep.GotoUnload, GotoUnload, CheckVceIdle, _timeout)
  61. .Run(UnloadStep.CloseDoor, CloseDoor, CheckDoorIsClose)
  62. .Run(UnloadStep.Vent, Vent, CheckVentOver)
  63. .Run(UnloadStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _timeout)
  64. .End(UnloadStep.NotifyOver, NullFun, 100);
  65. return Runner.Status;
  66. }
  67. private bool CloseDoor()
  68. {
  69. return _tm.TurnSlitDoor(ModuleName.VCE1, false);
  70. }
  71. private bool CheckDoorIsClose()
  72. {
  73. return Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module);
  74. }
  75. private bool CheckVentOver()
  76. {
  77. RState ret = ventRoutine.Monitor();
  78. if (ret == RState.Failed || ret == RState.Timeout)
  79. {
  80. _vce.PostMsg(VceMSG.Error);
  81. }
  82. return ret == RState.End;
  83. }
  84. private bool Vent()
  85. {
  86. return ventRoutine.Start() == RState.Running;
  87. }
  88. private bool OpenOutDoor()
  89. {
  90. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module) && Singleton<RouteManager>.Instance.seTM.VCEPressure(Module) >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))
  91. {
  92. return _vce.OpenDoor();
  93. }
  94. else
  95. {
  96. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");
  97. return false;
  98. }
  99. }
  100. private bool GotoUnload()
  101. {
  102. return _vce.GotoLP();
  103. }
  104. private bool CheckVceIdle()
  105. {
  106. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  107. {
  108. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  109. return false;
  110. }
  111. return _vce.Status == RState.End;
  112. }
  113. public void Abort()
  114. {
  115. }
  116. }
  117. }