UnloadWithSMIFRoutine.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. TMBase _tm;
  39. SEMFVentRoutine ventRoutine;
  40. public UnloadWithSMIFRoutine(ModuleName module,VCEModuleBase vce,ISMIF smif) : base(module)
  41. {
  42. _vce = vce;
  43. _smif = smif;
  44. switch (RtInstance.ConfigType)
  45. {
  46. case ConfigType.VenusSE:
  47. _tm = DEVICE.GetDevice<HongHuTM>("TM");
  48. break;
  49. case ConfigType.VenusDE:
  50. _tm = DEVICE.GetDevice<HongHuDETM>("TM");
  51. break;
  52. }
  53. ventRoutine = new SEMFVentRoutine(_tm, module);
  54. }
  55. public RState Start(params object[] objs)
  56. {
  57. _vcetimeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  58. _smiftimeout = SC.GetValue<int>($"{Module}.SMIF.MotionTimeout") * 1000;
  59. Reset();
  60. return Runner.Start(Module, $"{Module} Unload with SMIF");
  61. }
  62. public RState Monitor()
  63. {
  64. Runner.Run(UnloadWithSMIFStep.CloseDoor, CloseDoor, CheckDoorIsClose)
  65. .Run(UnloadWithSMIFStep.Vent, Vent, CheckVentOver)
  66. .Run(UnloadWithSMIFStep.GotoUnload, GotoUnload, CheckVceIdle, _vcetimeout)
  67. .Run(UnloadWithSMIFStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _vcetimeout)
  68. .Run(UnloadWithSMIFStep.SMIFUnload, SMIFUnload, CheckSMIFIdle, _smiftimeout)
  69. .Run(UnloadWithSMIFStep.CloseOutDoor, CloseOutDoor, CheckVceIdle, _vcetimeout)
  70. .End(UnloadWithSMIFStep.NotifyOver, NullFun, 100);
  71. return Runner.Status;
  72. }
  73. private bool CloseDoor()
  74. {
  75. OP.DoOperation("TM.SetSlitDoor", Module, false);
  76. return true;
  77. }
  78. private bool CheckDoorIsClose()
  79. {
  80. return Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed(Module);
  81. }
  82. private bool CheckVentOver()
  83. {
  84. RState ret = ventRoutine.Monitor();
  85. if (ret == RState.Failed || ret == RState.Timeout)
  86. {
  87. _vce.PostMsg(VceMSG.Error);
  88. }
  89. return ret == RState.End;
  90. }
  91. private bool Vent()
  92. {
  93. return ventRoutine.Start() == RState.Running;
  94. }
  95. private bool SMIFUnload()
  96. {
  97. _smif.Unload();
  98. return true;
  99. }
  100. private bool CheckSMIFIdle()
  101. {
  102. return true;
  103. }
  104. private bool CloseOutDoor()
  105. {
  106. return _vce.CloseDoor();
  107. }
  108. private bool OpenOutDoor()
  109. {
  110. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module) && Singleton<RouteManager>.Instance.seTM.VCEPressure(Module) >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))
  111. {
  112. return _vce.OpenDoor();
  113. }
  114. else
  115. {
  116. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");
  117. return false;
  118. }
  119. }
  120. private bool GotoUnload()
  121. {
  122. return _vce.GotoLP();
  123. }
  124. private bool CheckVceIdle()
  125. {
  126. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  127. {
  128. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  129. return false;
  130. }
  131. return _vce.Status == RState.End;
  132. }
  133. public void Abort()
  134. {
  135. }
  136. }
  137. }