LoadPortReadCarrierIdRoutine.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 LoadPortReadCarrierIdRoutine : ModuleRoutineBase, IStepRoutine
  10. {
  11. enum RoutineStep
  12. {
  13. ReadCarrierId,
  14. QueryStatus,
  15. End,
  16. }
  17. private int _timeout = 0;
  18. LoadPort _lp = null;
  19. private LoadPortModule _lpModule;
  20. public LoadPortReadCarrierIdRoutine(LoadPortModule lpModule) : base(lpModule.Module)
  21. {
  22. _lpModule = lpModule;
  23. Name = "ReadCarrierId";
  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.MotionTimeout");
  33. return Runner.Start(_lpModule.Module, Name);
  34. }
  35. public RState Monitor()
  36. {
  37. Runner.Run(RoutineStep.ReadCarrierId, ReadCarrierId, CheckDevice, _timeout * 1000)
  38. .End(RoutineStep.QueryStatus, QueryStatus, CheckDevice, _timeout * 1000);
  39. return Runner.Status;
  40. }
  41. bool ReadCarrierId()
  42. {
  43. Notify($"Start read carrier id {_lpModule.LPDevice.Name}");
  44. if (!_lpModule.LPDevice.ReadRfId(out string reason))
  45. {
  46. Stop(reason);
  47. return false;
  48. }
  49. return true;
  50. }
  51. bool CheckDevice()
  52. {
  53. return !(_lpModule.LPDevice.Error || _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. }