LoadPortDockRoutine.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 LoadPortDockRoutine : ModuleRoutineBase, IStepRoutine
  10. {
  11. enum RoutineStep
  12. {
  13. Dock,
  14. QueryStatus,
  15. End,
  16. }
  17. private int _timeout = 0;
  18. private LoadPortModule _lpModule;
  19. public LoadPortDockRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  20. {
  21. _lpModule = lpModule;
  22. Name = "Dock";
  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.Dock, Dock, CheckDevice, _timeout * 1000)
  37. .End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000);
  38. return Runner.Status;
  39. }
  40. bool Dock()
  41. {
  42. string reason;
  43. if (!_lpModule.LPDevice.Dock(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. }