LoadPortCloseDoorRoutine.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
  7. namespace JetEfemLib.LPs
  8. {
  9. class LoadPortCloseDoorRoutine : ModuleRoutineBase, IStepRoutine
  10. {
  11. enum RoutineStep
  12. {
  13. CloseDoor,
  14. QueryStatus,
  15. End,
  16. }
  17. private int _timeout = 0;
  18. private LoadPortModule _lpModule;
  19. public LoadPortCloseDoorRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  20. {
  21. _lpModule = lpModule;
  22. Name = "CloseDoor";
  23. }
  24. public bool Initalize()
  25. {
  26. return true;
  27. }
  28. public RState Start(params object[] objs)
  29. {
  30. Reset();
  31. _timeout = SC.GetValue<int>("EFEM.LoadPort.MotionTimeout");
  32. return Runner.Start(_lpModule.Module, Name);
  33. }
  34. public RState Monitor()
  35. {
  36. Runner.Run(RoutineStep.CloseDoor, CloseDoor, CheckDevice, _timeout * 1000)
  37. .End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000);
  38. return Runner.Status;
  39. }
  40. bool CloseDoor()
  41. {
  42. Notify($"Start Close Door {_lpModule.LPDevice.Name}");
  43. string reason;
  44. if (!_lpModule.LPDevice.CloseDoor(out reason))
  45. {
  46. Stop(reason);
  47. return false;
  48. }
  49. return true;
  50. }
  51. bool CheckDevice()
  52. {
  53. return !(_lpModule.LPDevice.IsError || _lpModule.LPDevice.IsBusy);
  54. }
  55. bool QueryStatus()
  56. {
  57. Notify($"Start query status {_lpModule.LPDevice.Name}");
  58. string reason;
  59. if (!_lpModule.LPDevice.QueryState(out reason))
  60. {
  61. Stop(reason);
  62. return false;
  63. }
  64. return true;
  65. }
  66. public void Abort()
  67. {
  68. }
  69. }
  70. }