using Aitex.Core.Common; using Aitex.Core.RT.Log; using Aitex.Core.Util; using Aitex.Sorter.Common; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.SubstrateTrackings; using FurnaceRT.Equipments.CarrierRobots; using FurnaceRT.Equipments.Systems; using MECF.Framework.Common.Jobs; namespace FurnaceRT.Equipments.Schedulers { public class SchedulerCarrierRobot : SchedulerModule { public override bool IsAvailable { get { return _carrierRobot.IsReady && _carrierRobot.IsOnline && CheckTaskDone(); } } public override bool IsOnline { get { return _carrierRobot.IsOnline; } } public override bool IsError { get { return _carrierRobot.IsError; } } private CarrierRobotModule _carrierRobot = null; private CarrierPara _carrierPara = null; private Hand _hand; private ModuleName _source1; private ModuleName _source2; private int _sourceSlot1; private int _sourceSlot2; private ModuleName _destination1; private ModuleName _destination2; private int _destinationSlot1; private int _destinationSlot2; public ModuleName PreviousTarget { get; set; } public SchedulerCarrierRobot() : base(ModuleName.CarrierRobot.ToString()) { _carrierRobot = Singleton.Instance.Modules[ModuleName.CarrierRobot] as CarrierRobotModule; PreviousTarget = ModuleName.System; } public override void ResetTask() { base.ResetTask(); PreviousTarget = ModuleName.System; } public bool IsReadyForPick(Hand blade) { return CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, (int)blade); } public bool IsReadyForPlace(Hand blade) { return CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, (int)blade); } public bool Pick(ModuleName source, int slot, Hand hand) { _task = TaskType.Pick; _hand = hand; if (!_carrierRobot.Pick(source, hand, slot, out string reason)) { LOG.Write(reason); } PreviousTarget = source; LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}"); return true; } public bool Place(ModuleName destination, int slot, Hand hand) { _task = TaskType.Place; _hand = hand; if (!_carrierRobot.Place(destination, hand, slot, out string reason)) { LOG.Write(reason); } PreviousTarget = destination; LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}"); return true; } public bool Goto(ModuleName destination, int slot, Hand hand, bool isPickReady) { _task = TaskType.Goto; _hand = hand; if (!_carrierRobot.Goto(destination, hand, slot, isPickReady, out string reason)) { LOG.Write(reason); } PreviousTarget = destination; LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}"); return true; } public bool Load(ModuleName source, int slot, Hand hand, ModuleName destinationStocker, CarrierType carrierType, string reservedCarrierId, CarrierPara carrierPara) { _task = TaskType.Load; _hand = hand; if (!_carrierRobot.Load(source, hand, slot, destinationStocker, carrierType, reservedCarrierId, out string reason)) { LOG.Write(reason); } _carrierPara = carrierPara; PreviousTarget = source; LogTaskStart(_task, $"{source}.{slot + 1}=>{Module}.{hand}"); return true; } public bool Unload(ModuleName destination, int slot, Hand hand, CarrierPara carrierPara) { _task = TaskType.Unload; _hand = hand; if (!_carrierRobot.Unload(destination, hand, slot, out string reason)) { LOG.Write(reason); } _carrierPara = carrierPara; PreviousTarget = destination; LogTaskStart(_task, $"{Module}.{hand}=>{destination}.{slot + 1}"); return true; } public bool CheckTaskDone() { bool ret = false; switch (_task) { case TaskType.None: ret = true; break; case TaskType.Map: ret = _carrierRobot.IsReady; break; case TaskType.Goto: ret = _carrierRobot.IsReady; break; case TaskType.Load: ret = CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0); if (ret && _carrierPara != null) { _carrierPara.IsLoaded = true; } break; case TaskType.Unload: ret = CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0); if (ret && _carrierPara != null) { _carrierPara.IsUnloaded = true; } break; case TaskType.Pick: ret = CarrierManager.Instance.CheckHasCarrier(ModuleName.CarrierRobot, 0); break; case TaskType.Place: ret = CarrierManager.Instance.CheckNoCarrier(ModuleName.CarrierRobot, 0); break; } if (ret && _task != TaskType.None) { LogTaskDone(_task, ""); _task = TaskType.None; } return ret; } } }