LoadPrepareRoutine.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.Reflection;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using Venus_Core;
  16. using Venus_RT.Devices;
  17. using Venus_RT.Modules.TM.VenusEntity;
  18. namespace Venus_RT.Modules.VCE
  19. {
  20. public class LoadPrepareRoutine : ModuleRoutineBase, IRoutine
  21. {
  22. private enum LoadPrepareStep
  23. {
  24. VceGotoLP,
  25. VceOuterDoorOpen,
  26. NotifyDone
  27. }
  28. private VceModuleBase _vce;//动作驱动
  29. private int _vcetimeout;
  30. public LoadPrepareRoutine(ModuleName module, VceModuleBase vce) : base(module)
  31. {
  32. Module = module;
  33. _vce = vce;
  34. }
  35. public RState Start(params object[] objs)
  36. {
  37. //如果不是ATM 不允许执行
  38. if (!Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module))
  39. {
  40. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE is not atm cannot load prepare! Please Vent it First!");
  41. return RState.Failed;
  42. }
  43. _vcetimeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  44. Reset();
  45. return Runner.Start(Module, $"Load Prepare");
  46. }
  47. public RState Monitor()
  48. {
  49. Runner.Run(LoadPrepareStep.VceGotoLP, VceGotoLP, CheckVceStageDownDone , _vcetimeout)
  50. .Run(LoadPrepareStep.VceOuterDoorOpen, VceOuterDoorOpen, CheckVceOuterDoorOpenDone, _vcetimeout)
  51. .End(LoadPrepareStep.NotifyDone, NullFun, 100);
  52. return Runner.Status;
  53. }
  54. private bool CheckVceStageDownDone()
  55. {
  56. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  57. {
  58. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE Stage Down failed");
  59. }
  60. return _vce.Status == RState.End;
  61. }
  62. private bool CheckVceOuterDoorOpenDone()
  63. {
  64. if (_vce.Status == RState.Timeout || _vce.Status == RState.Failed)
  65. {
  66. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"VCE OuterDoor Open failed");
  67. }
  68. return _vce.Status == RState.End;
  69. }
  70. private bool VceGotoLP()
  71. {
  72. return _vce.GotoLP();
  73. }
  74. private bool VceOuterDoorOpen()
  75. {
  76. if (Singleton<RouteManager>.Instance.seTM.VCEIsATM(Module) && Singleton<RouteManager>.Instance.seTM.VCEPressure(Module) >= SC.GetValue<int>($"{Module}.OutDoorOpenPressure"))
  77. {
  78. return _vce.OpenDoor();
  79. }
  80. else
  81. {
  82. LOG.Write(eEvent.ERR_VCE_COMMON_Failed, Module, $"{Module} is not ATM or Pressure not arrive {SC.GetValue<int>($"{Module}.OutDoorOpenPressure")}");
  83. return false;
  84. }
  85. }
  86. public void Abort()
  87. {
  88. }
  89. }
  90. }