UnloadWithSMIFRoutine.cs 4.2 KB

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