UnloadRoutine.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.Core.Equipments;
  7. using MECF.Framework.RT.ModuleLibrary.VceModules;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using Venus_Core;
  14. using Venus_RT.Devices;
  15. using Venus_RT.Devices.VCE;
  16. using Venus_RT.Modules.TM;
  17. using Venus_RT.Modules.TM.VenusEntity;
  18. namespace Venus_RT.Modules.VCE
  19. {
  20. public class UnloadRoutine : ModuleRoutineBase, IRoutine
  21. {
  22. public enum UnloadStep
  23. {
  24. Vent,
  25. GotoUnload,
  26. OpenOutDoor,
  27. NotifyOver
  28. }
  29. VceModuleBase _vce;
  30. int _timeout;
  31. SEMFVentRoutine ventRoutine;
  32. public UnloadRoutine(ModuleName module,VceModuleBase vce) : base(module)
  33. {
  34. _vce = vce;
  35. ventRoutine = new SEMFVentRoutine(DEVICE.GetDevice<HongHuTM>("SETM"), module);
  36. }
  37. public RState Start(params object[] objs)
  38. {
  39. _timeout = SC.GetValue<int>($"{Module}.MotionTimeout") * 1000;
  40. Reset();
  41. return Runner.Start(Module,"VCE Unload Routine");
  42. }
  43. public RState Monitor()
  44. {
  45. Runner.Run(UnloadStep.Vent, Vent, CheckVentOver)
  46. .Run(UnloadStep.GotoUnload, GotoUnload, CheckVceIdle, _timeout)
  47. .Run(UnloadStep.OpenOutDoor, OpenOutDoor, CheckVceIdle, _timeout)
  48. .End(UnloadStep.NotifyOver, NullFun, 100);
  49. return Runner.Status;
  50. }
  51. private bool CheckVentOver()
  52. {
  53. RState ret = ventRoutine.Monitor();
  54. if (ret == RState.Failed || ret == RState.Timeout)
  55. {
  56. _vce.PostMsg(VceMSG.Error);
  57. }
  58. return ret == RState.End;
  59. }
  60. private bool Vent()
  61. {
  62. return ventRoutine.Start() == RState.Running;
  63. }
  64. private bool OpenOutDoor()
  65. {
  66. return _vce.OpenDoor();
  67. }
  68. private bool GotoUnload()
  69. {
  70. return _vce.GotoLP();
  71. }
  72. private bool CheckVceIdle()
  73. {
  74. if (_vce.Status == RState.Failed || _vce.Status == RState.Timeout)
  75. {
  76. Singleton<RouteManager>.Instance.GetVCE(Module).PostMsg(VceMSG.Error);
  77. return false;
  78. }
  79. return _vce.Status == RState.End;
  80. }
  81. public void Abort()
  82. {
  83. }
  84. }
  85. }