UnloadRoutine.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.VCE;
  18. using Venus_RT.Modules.TM;
  19. using Venus_RT.Modules.TM.VenusEntity;
  20. namespace Venus_RT.Modules.VCE
  21. {
  22. public class UnloadRoutine : ModuleRoutineBase, IRoutine
  23. {
  24. public enum UnloadStep
  25. {
  26. CloseDoor,
  27. Vent,
  28. GotoUnload,
  29. OpenOutDoor,
  30. NotifyOver
  31. }
  32. VceModuleBase _vce;
  33. int _timeout;
  34. SEMFVentRoutine ventRoutine;
  35. public UnloadRoutine(ModuleName module, VceModuleBase vce) : base(module)
  36. {
  37. _vce = vce;
  38. ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuTM>("SETM"), module);
  39. }
  40. public RState Start(params object[] objs)
  41. {
  42. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  43. //if vce inner door not close cannot dot it as it will vent
  44. //if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed)
  45. //{
  46. // LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
  47. // return RState.Failed;
  48. //}
  49. Reset();
  50. return Runner.Start(Module, "VCE Unload Routine");
  51. }
  52. public RState Monitor()
  53. {
  54. Runner.Run(UnloadStep.CloseDoor, CloseDoor, CheckDoorIsClose)
  55. .Run(UnloadStep.Vent, Vent, CheckVentOver)
  56. .Run(UnloadStep.GotoUnload, GotoUnload, CheckVceIdle, _timeout)
  57. .Run(UnloadStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _timeout)
  58. .End(UnloadStep.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 OpenOutDoor()
  84. {
  85. return _vce.OpenDoor();
  86. }
  87. private bool GotoUnload()
  88. {
  89. return _vce.GotoLP();
  90. }
  91. private bool CheckVceIdle()
  92. {
  93. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  94. {
  95. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  96. return false;
  97. }
  98. return _vce.Status == RState.End;
  99. }
  100. public void Abort()
  101. {
  102. }
  103. }
  104. }