using Aitex.Sorter.Common; using SicRT.Modules.Schedulers; using SicModules.EFEMs; using SicRT.Equipments.Systems; namespace SicRT.Scheduler { public class SchedulerTrayRobot : SchedulerModule { public override bool IsAvailable { get { return _trayRobot.IsIdle && _trayRobot.IsOnline && CheckTaskDone(); } } public override bool IsOnline { get { return _trayRobot.IsOnline; } } public override bool IsError { get { return _trayRobot.IsError; } } public ModuleName? Target { get; private set; } private TrayRobotModule _trayRobot = null; private Hand _taskHand; public SchedulerTrayRobot() : base(ModuleName.TrayRobot.ToString()) { _trayRobot = Singleton.Instance.Modules[ModuleName.TrayRobot] as TrayRobotModule; } public bool IsReadyForPick(Hand blade) { return WaferManager.Instance.CheckNoWafer(ModuleName.TrayRobot, (int)blade); } public bool IsReadyForPlace(Hand blade) { return WaferManager.Instance.CheckHasWafer(ModuleName.TrayRobot, (int)blade); } public bool Pick(ModuleName target, int slot, Hand hand) { if (_trayRobot.PickTray(target, hand, slot)) { Target = target; _task = TaskType.Pick; _taskHand = hand; LogTaskStart(_task, $"{target}.{slot + 1}=>{Module}.{hand}"); } return true; } public bool Place(ModuleName target, int slot, Hand hand) { if (_trayRobot.PlaceTray(target, hand, slot)) { Target = target; _task = TaskType.Place; _taskHand = hand; LogTaskStart(_task, $"{Module}.{hand}=>{target}.{slot + 1}"); } return true; } public bool Map(ModuleName target) { if (_trayRobot.MapTray(target)) { _task = TaskType.Map; LogTaskStart(_task, $"{Module}.TrayRobot Map"); } return true; } public bool Monitor() { return true; } public bool CheckTaskDone() { var taskSucceed = false; switch (_task) { case TaskType.None: taskSucceed = true; break; case TaskType.Pick: taskSucceed = WaferManager.Instance.CheckHasTray(ModuleName.TrayRobot, (int)_taskHand); break; case TaskType.Place: taskSucceed = WaferManager.Instance.CheckNoTray(ModuleName.TrayRobot, (int)_taskHand); break; } return SuperCheckTaskDone(taskSucceed, _trayRobot.IsIdle | _trayRobot.IsError); } } }