TMMapRoutine.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using MECF.Framework.Common.Equipment;
  5. namespace JetMainframe.TMs
  6. {
  7. public class TMMapRoutine : ModuleRoutineBase, IStepRoutine
  8. {
  9. enum RoutineStep
  10. {
  11. CheckTargetEnableMap,
  12. Map,
  13. End,
  14. }
  15. private int _mapTimeout;
  16. private ModuleName _target;
  17. private int _thicknessIndex;
  18. //private Hand _hand;
  19. //private bool _autoHand;
  20. private TMModule _tmModule;
  21. public TMMapRoutine(TMModule tmModule) : base(ModuleName.TM.ToString())
  22. {
  23. Name = "Map";
  24. _tmModule = tmModule;
  25. }
  26. public RState Start(params object[] objs)
  27. {
  28. _mapTimeout = SC.GetValue<int>("TM.MapTimeout");
  29. Reset();
  30. _thicknessIndex = 0;
  31. Notify($"Start map {_target}");
  32. return Runner.Start(ModuleName.TM.ToString(), Name);
  33. }
  34. public void Init(ModuleName source)
  35. {
  36. //_autoHand = true;
  37. _target = source;
  38. }
  39. public void Abort()
  40. {
  41. Notify($"Abort map {_target}");
  42. }
  43. public RState Monitor()
  44. {
  45. Runner.Wait(RoutineStep.CheckTargetEnableMap, CheckTargetEnableMap)
  46. .Run(RoutineStep.Map, Map, CheckMap, _mapTimeout * 1000)
  47. .End(RoutineStep.End, NullFun, _delay_1s);
  48. if (Runner.Status == RState.End)
  49. Notify($"Complete map {_target}");
  50. return Runner.Status;
  51. }
  52. bool CheckTargetEnableMap()
  53. {
  54. Notify($"Check {_target} enable map");
  55. if (!ModuleHelper.IsLoadPort(_target))
  56. {
  57. Stop($"Can not map {_target}, only LP supported");
  58. return false;
  59. }
  60. //LoadPortModuleBase lp = EquipmentManager.Modules[target] as LoadPortModuleBase;
  61. //if (!lp.CheckReadyForMap(ModuleName.EfemRobot, Hand.Blade1, out string reason))
  62. //{
  63. // Stop(reason);
  64. // return false;
  65. //}
  66. return true;
  67. }
  68. bool Map()
  69. {
  70. //ModuleName target, int thicknessIndex
  71. Notify($"Robot start map {_target}");
  72. //string reason;
  73. //if (!_efemModule.RobotDevice.Map(_target, _thicknessIndex, out reason))
  74. //{
  75. // Stop(reason);
  76. // return false;
  77. //}
  78. return true;
  79. }
  80. bool CheckMap()
  81. {
  82. return !_tmModule.RobotDevice.IsError && _tmModule.RobotDevice.IsIdle;
  83. }
  84. }
  85. }