LoadRoutine.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Core.Util;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
  7. using MECF.Framework.RT.ModuleLibrary.Commons;
  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.VenusEntity;
  18. namespace Venus_RT.Modules.VCE
  19. {
  20. public class LoadRoutine : ModuleRoutineBase, IRoutine
  21. {
  22. public enum LoadStep
  23. {
  24. CloseOutDoor,
  25. Mapping,
  26. ReadMap,
  27. PumpDown,
  28. OpenInnerDoor,
  29. NotifyOver
  30. }
  31. VceModuleBase _vce;
  32. HongHuTM _tm;
  33. int _timeout;
  34. SEMFPumpRoutine pumpRoutine;
  35. public LoadRoutine(ModuleName module, VceModuleBase vce) : base(module)
  36. {
  37. _vce = vce;
  38. pumpRoutine = new SEMFPumpRoutine(DEVICE.GetDevice<HongHuTM>("SETM"),module);
  39. }
  40. public RState Start(params object[] objs)
  41. {
  42. _tm = DEVICE.GetDevice<HongHuTM>("SETM");
  43. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") *1000;
  44. Reset();
  45. return Runner.Start(Module,"Vce Load Routine");
  46. }
  47. public RState Monitor()
  48. {
  49. Runner.Run(LoadStep.CloseOutDoor, CloseOutDoor, CheckVceIdle, _timeout)
  50. .Run(LoadStep.Mapping, Mapping, CheckVceIdle, 25 *1000)
  51. .Run(LoadStep.ReadMap, ReadMap, CheckVceIdle, _timeout)
  52. .Run(LoadStep.PumpDown, PumpDown, CheckPumpOver)
  53. .Run(LoadStep.OpenInnerDoor, OpenInnerDoor, CheckInnerDoorOpen)
  54. .End(LoadStep.NotifyOver, NullFun, 100);
  55. return Runner.Status;
  56. }
  57. private bool CheckInnerDoorOpen()
  58. {
  59. return !_tm.VCESlitDoorClosed;
  60. }
  61. private bool OpenInnerDoor()
  62. {
  63. return _tm.TurnSlitDoor(Module,true);
  64. }
  65. //
  66. private bool CheckPumpOver()
  67. {
  68. RState ret = pumpRoutine.Monitor();
  69. if (ret == RState.Failed || ret == RState.Timeout)
  70. {
  71. _vce.PostMsg(VceMSG.Error);
  72. }
  73. return ret == RState.End;
  74. }
  75. private bool PumpDown()
  76. {
  77. return pumpRoutine.Start() == RState.Running;
  78. }
  79. private bool ReadMap()
  80. {
  81. return _vce.ReadMap();
  82. }
  83. private bool Mapping()
  84. {
  85. return _vce.Map();
  86. }
  87. private bool CloseOutDoor()
  88. {
  89. return _vce.CloseDoor();
  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. }