LoadPortUndockRoutine.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 LoadPortUndockRoutine : ModuleRoutineBase, IStepRoutine
  10. {
  11. enum RoutineStep
  12. {
  13. Undock,
  14. QueryStatus,
  15. End,
  16. }
  17. private int _timeout = 0;
  18. private LoadPortModule _lpModule;
  19. public LoadPortUndockRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  20. {
  21. _lpModule = lpModule;
  22. Name = "Undock";
  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.Undock, Undock, CheckDevice, _timeout * 1000)
  37. .End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000);
  38. return Runner.Status;
  39. }
  40. bool Undock()
  41. {
  42. string reason;
  43. if (!_lpModule.LPDevice.Undock(out reason))
  44. {
  45. Stop(reason);
  46. return false;
  47. }
  48. return true;
  49. }
  50. bool CheckDevice()
  51. {
  52. return !(_lpModule.LPDevice.Error || _lpModule.LPDevice.IsBusy);
  53. }
  54. bool QueryStatus()
  55. {
  56. string reason;
  57. if (!_lpModule.LPDevice.QueryState(out reason))
  58. {
  59. Stop(reason);
  60. return false;
  61. }
  62. return true;
  63. }
  64. public void Abort()
  65. {
  66. }
  67. }
  68. }