LoadPortClampRoutine.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 LoadPortClampRoutine : ModuleRoutineBase, IStepRoutine
  10. {
  11. enum RoutineStep
  12. {
  13. Clamp,
  14. QueryStatus,
  15. End,
  16. }
  17. private int _timeout = 0;
  18. private LoadPortModule _lpModule;
  19. public LoadPortClampRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  20. {
  21. _lpModule = lpModule;
  22. Name = "Clamp";
  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.Clamp, Clamp, CheckDevice, _timeout * 1000).
  37. End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000);
  38. return Runner.Status;
  39. }
  40. bool Clamp()
  41. {
  42. string reason;
  43. if (!_lpModule.LPDevice.Clamp(out reason))
  44. {
  45. Stop(reason);
  46. return false;
  47. }
  48. return true;
  49. }
  50. bool CheckDevice()
  51. {
  52. return !(_lpModule.LPDevice.IsError || _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. }