UnloadWithSMIFRoutine.cs 4.4 KB

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