UnloadRoutine.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Core.Util;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.RT.Core.Equipments;
  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.VCE;
  17. using Venus_RT.Modules.TM;
  18. using Venus_RT.Modules.TM.VenusEntity;
  19. namespace Venus_RT.Modules.VCE
  20. {
  21. public class UnloadRoutine : ModuleRoutineBase, IRoutine
  22. {
  23. public enum UnloadStep
  24. {
  25. Vent,
  26. GotoUnload,
  27. OpenOutDoor,
  28. NotifyOver
  29. }
  30. VceModuleBase _vce;
  31. int _timeout;
  32. SEMFVentRoutine ventRoutine;
  33. public UnloadRoutine(ModuleName module,VceModuleBase vce) : base(module)
  34. {
  35. _vce = vce;
  36. ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuTM>("SETM"), module);
  37. }
  38. public RState Start(params object[] objs)
  39. {
  40. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  41. //if vce inner door not close cannot dot it as it will vent
  42. if (!Singleton<RouteManager>.Instance.seTM.IsVCESlitDoorClosed)
  43. {
  44. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Inner Door is open! Please close it First!");
  45. return RState.Failed;
  46. }
  47. Reset();
  48. return Runner.Start(Module,"VCE Unload Routine");
  49. }
  50. public RState Monitor()
  51. {
  52. Runner.Run(UnloadStep.Vent, Vent, CheckVentOver)
  53. .Run(UnloadStep.GotoUnload, GotoUnload, CheckVceIdle, _timeout)
  54. .Run(UnloadStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _timeout)
  55. .End(UnloadStep.NotifyOver, NullFun, 100);
  56. return Runner.Status;
  57. }
  58. private bool CheckVentOver()
  59. {
  60. RState ret = ventRoutine.Monitor();
  61. if (ret == RState.Failed || ret == RState.Timeout)
  62. {
  63. _vce.PostMsg(VceMSG.Error);
  64. }
  65. return ret == RState.End;
  66. }
  67. private bool Vent()
  68. {
  69. return ventRoutine.Start() == RState.Running;
  70. }
  71. private bool OpenOutDoor()
  72. {
  73. return _vce.OpenDoor();
  74. }
  75. private bool GotoUnload()
  76. {
  77. return _vce.GotoLP();
  78. }
  79. private bool CheckVceIdle()
  80. {
  81. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  82. {
  83. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  84. return false;
  85. }
  86. return _vce.Status == RState.End;
  87. }
  88. public void Abort()
  89. {
  90. }
  91. }
  92. }