SchedulerCarrierRobot.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.Util;
  4. using Aitex.Sorter.Common;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.SubstrateTrackings;
  7. using FurnaceRT.Equipments.CarrierRobots;
  8. using FurnaceRT.Equipments.Systems;
  9. using MECF.Framework.Common.Jobs;
  10. namespace FurnaceRT.Equipments.Schedulers
  11. {
  12. public class SchedulerCarrierRobot : SchedulerModule
  13. {
  14. public override bool IsAvailable
  15. {
  16. get { return _carrierRobot.IsReady && _carrierRobot.IsOnline && CheckTaskDone(); }
  17. }
  18. public override bool IsOnline
  19. {
  20. get { return _carrierRobot.IsOnline; }
  21. }
  22. public override bool IsError
  23. {
  24. get { return _carrierRobot.IsError; }
  25. }
  26. private CarrierRobotModule _carrierRobot = null;
  27. private CarrierPara _carrierPara = null;
  28. private Hand _hand;
  29. private ModuleName _source1;
  30. private ModuleName _source2;
  31. private int _sourceSlot1;
  32. private int _sourceSlot2;
  33. private ModuleName _destination1;
  34. private ModuleName _destination2;
  35. private int _destinationSlot1;
  36. private int _destinationSlot2;
  37. public ModuleName PreviousTarget { get; set; }
  38. public SchedulerCarrierRobot() : base(ModuleName.CarrierRobot.ToString())
  39. {
  40. _carrierRobot = Singleton<EquipmentManager>.Instance.Modules[ModuleName.CarrierRobot] as CarrierRobotModule;
  41. PreviousTarget = ModuleName.System;
  42. }
  43. public override void ResetTask()
  44. {
  45. base.ResetTask();
  46. PreviousTarget = ModuleName.System;
  47. }
  48. public bool IsReadyForPick(Hand blade)
  49. {
  50. return CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, (int)blade);
  51. }
  52. public bool IsReadyForPlace(Hand blade)
  53. {
  54. return CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, (int)blade);
  55. }
  56. public bool Pick(ModuleName source, int slot, Hand hand)
  57. {
  58. _task = TaskType.Pick;
  59. _hand = hand;
  60. if (!_carrierRobot.Pick(source, hand, slot, out string reason))
  61. {
  62. LOG.Write(reason);
  63. }
  64. PreviousTarget = source;
  65. LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}");
  66. return true;
  67. }
  68. public bool Place(ModuleName destination, int slot, Hand hand)
  69. {
  70. _task = TaskType.Place;
  71. _hand = hand;
  72. if (!_carrierRobot.Place(destination, hand, slot, out string reason))
  73. {
  74. LOG.Write(reason);
  75. }
  76. PreviousTarget = destination;
  77. LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}");
  78. return true;
  79. }
  80. public bool Goto(ModuleName destination, int slot, Hand hand, bool isPickReady)
  81. {
  82. _task = TaskType.Goto;
  83. _hand = hand;
  84. if (!_carrierRobot.Goto(destination, hand, slot, isPickReady, out string reason))
  85. {
  86. LOG.Write(reason);
  87. }
  88. PreviousTarget = destination;
  89. LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}");
  90. return true;
  91. }
  92. public bool Load(ModuleName source, int slot, Hand hand, ModuleName destinationStocker,
  93. CarrierType carrierType, string reservedCarrierId, CarrierPara carrierPara)
  94. {
  95. _task = TaskType.Load;
  96. _hand = hand;
  97. if (!_carrierRobot.Load(source, hand, slot, destinationStocker, carrierType, reservedCarrierId, out string reason))
  98. {
  99. LOG.Write(reason);
  100. }
  101. _carrierPara = carrierPara;
  102. PreviousTarget = source;
  103. LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}");
  104. return true;
  105. }
  106. public bool Unload(ModuleName destination, int slot, Hand hand, CarrierPara carrierPara)
  107. {
  108. _task = TaskType.Unload;
  109. _hand = hand;
  110. if (!_carrierRobot.Unload(destination, hand, slot, out string reason))
  111. {
  112. LOG.Write(reason);
  113. }
  114. _carrierPara = carrierPara;
  115. PreviousTarget = destination;
  116. LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}");
  117. return true;
  118. }
  119. public bool CheckTaskDone()
  120. {
  121. bool ret = false;
  122. switch (_task)
  123. {
  124. case TaskType.None:
  125. ret = true;
  126. break;
  127. case TaskType.Map:
  128. ret = _carrierRobot.IsReady;
  129. break;
  130. case TaskType.Goto:
  131. ret = _carrierRobot.IsReady;
  132. break;
  133. case TaskType.Load:
  134. ret = CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0);
  135. if (ret && _carrierPara != null)
  136. {
  137. _carrierPara.IsLoaded = true;
  138. }
  139. break;
  140. case TaskType.Unload:
  141. ret = CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0);
  142. if (ret && _carrierPara != null)
  143. {
  144. _carrierPara.IsUnloaded = true;
  145. }
  146. break;
  147. case TaskType.Pick:
  148. ret = CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0);
  149. break;
  150. case TaskType.Place:
  151. ret = CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0);
  152. break;
  153. }
  154. if (ret && _task != TaskType.None)
  155. {
  156. LogTaskDone(_task, "");
  157. _task = TaskType.None;
  158. }
  159. return ret;
  160. }
  161. }
  162. }