LoadPortHomeRoutine.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 LoadPortHomeRoutine : ModuleRoutineBase, IStepRoutine
  10. {
  11. enum RoutineStep
  12. {
  13. ClearError,
  14. Home,
  15. QueryStatus,
  16. End,
  17. }
  18. private int _timeout = 0;
  19. private LoadPortModule _lpModule;
  20. public LoadPortHomeRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  21. {
  22. _lpModule = lpModule;
  23. Name = "Home";
  24. }
  25. public bool Initalize()
  26. {
  27. return true;
  28. }
  29. public RState Start(params object[] objs)
  30. {
  31. Reset();
  32. _timeout = SC.GetValue<int>("EFEM.LoadPort.HomeTimeout");
  33. return Runner.Start(_lpModule.Module, Name);
  34. }
  35. public RState Monitor()
  36. {
  37. Runner.Run(RoutineStep.Home, Home, CheckDevice, _timeout * 1000)
  38. .End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000);
  39. return Runner.Status;
  40. }
  41. bool Home()
  42. {
  43. string reason;
  44. if(!_lpModule.LPDevice.Home(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. string reason;
  58. if (!_lpModule.LPDevice.QueryState(out reason))
  59. {
  60. Stop(reason);
  61. return false;
  62. }
  63. return true;
  64. }
  65. public void Abort()
  66. {
  67. }
  68. }
  69. }