UnloadWithSMIFRoutine.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.ModuleLibrary.VceModules;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using Venus_Core;
  15. using Venus_RT.Devices;
  16. using Venus_RT.Devices.SMIF;
  17. using Venus_RT.Devices.TM;
  18. using Venus_RT.Devices.VCE;
  19. using Venus_RT.Modules.TM.VenusEntity;
  20. namespace Venus_RT.Modules.VCE
  21. {
  22. public class UnloadWithSMIFRoutine : ModuleRoutineBase, IRoutine
  23. {
  24. public enum UnloadWithSMIFStep
  25. {
  26. CloseDoor,
  27. Vent,
  28. GotoUnload,
  29. OpenOutDoor,
  30. SMIFUnload,
  31. CloseOutDoor,
  32. NotifyOver
  33. }
  34. VCEModuleBase _vce;
  35. ISMIF _smif;
  36. int _vcetimeout;
  37. int _smiftimeout;
  38. SEMFVentRoutine ventRoutine;
  39. public UnloadWithSMIFRoutine(ModuleName module,VCEModuleBase vce,ISMIF smif) : base(module)
  40. {
  41. _vce = vce;
  42. _smif = smif;
  43. if (module == ModuleName.VCE1)
  44. ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuTM>("SETM"), module);
  45. else
  46. ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuDETM>("DETM"), module);
  47. }
  48. public RState Start(params object[] objs)
  49. {
  50. _vcetimeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  51. _smiftimeout = SC.GetValue<int>($"{Module}.SMIF.MotionTimeout") * 1000;
  52. Reset();
  53. return Runner.Start(Module, "VCE Unload with SMIF");
  54. }
  55. public RState Monitor()
  56. {
  57. Runner.Run(UnloadWithSMIFStep.CloseDoor, CloseDoor, CheckDoorIsClose)
  58. .Run(UnloadWithSMIFStep.Vent, Vent, CheckVentOver)
  59. .Run(UnloadWithSMIFStep.GotoUnload, GotoUnload, CheckVceIdle, _vcetimeout)
  60. .Run(UnloadWithSMIFStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _vcetimeout)
  61. .Run(UnloadWithSMIFStep.SMIFUnload, SMIFUnload, CheckSMIFIdle, _smiftimeout)
  62. .Run(UnloadWithSMIFStep.CloseOutDoor, CloseOutDoor, CheckVceIdle, _vcetimeout)
  63. .End(UnloadWithSMIFStep.NotifyOver, NullFun, 100);
  64. return Runner.Status;
  65. }
  66. private bool CloseDoor()
  67. {
  68. OP.DoOperation("SETM.SetSlitDoor", ModuleName.VCE1, false);
  69. return true;
  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 SMIFUnload()
  89. {
  90. _smif.Unload();
  91. return true;
  92. }
  93. private bool CheckSMIFIdle()
  94. {
  95. return true;
  96. }
  97. private bool CloseOutDoor()
  98. {
  99. return _vce.CloseDoor();
  100. }
  101. private bool OpenOutDoor()
  102. {
  103. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module) && Singleton<RouteManager>.Instance.seTM.VCEPressure(Module) >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))
  104. {
  105. return _vce.OpenDoor();
  106. }
  107. else
  108. {
  109. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");
  110. return false;
  111. }
  112. }
  113. private bool GotoUnload()
  114. {
  115. return _vce.GotoLP();
  116. }
  117. private bool CheckVceIdle()
  118. {
  119. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  120. {
  121. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  122. return false;
  123. }
  124. return _vce.Status == RState.End;
  125. }
  126. public void Abort()
  127. {
  128. }
  129. }
  130. }