123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- using System;
- using System.Collections.Generic;
- using Aitex.Core.Common;
- using Aitex.Core.RT.Event;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Schedulers;
- using MECF.Framework.Common.SubstrateTrackings;
- namespace EfemDualSchedulerLib.Schedulers
- {
- public class SchedulerModule
- {
- public enum TaskType
- {
- None,
- PrepareTransfer,
- Pick,
- Place,
- Goto,
- PickAndPlace,
- PlaceAndPick,
- Preprocess,
- Process,
- PostProcess,
- IdlePurgeProcess,
- IdleCleanProcess,
- PreJobProcess,
- CompleteJobProcess,
- OpenCover,
- CloseCover,
- Load,
- Unload,
- Align,
- TransferTarget,
- PreCooling,
- Cooling,
- Heating,
- Map,
- }
- public ModuleName Module
- {
- get { return ModuleHelper.Converter(_module); }
- }
- public virtual bool IsAvailable { get; }
- public virtual bool IsOnline { get; }
- public virtual bool IsError { get; }
- private R_TRIG[] firstDetectWaferArriveTrigs = new R_TRIG[25];
- private R_TRIG[] firstDetectWaferLeaveTrigs = new R_TRIG[25];
- protected string _module;
- protected TaskType _task = TaskType.None;
- public TaskType Task => _task;
- public TaskType GetTaskType() { return _task; }
- protected ModuleName _inProcessRobot;
- public ModuleName InProcessRobot => _inProcessRobot;
- public SchedulerModule(string module)
- {
- _module = module;
- for (int i = 0; i < firstDetectWaferArriveTrigs.Length; i++)
- {
- firstDetectWaferArriveTrigs[i] = new R_TRIG();
- }
- for (int i = 0; i < firstDetectWaferLeaveTrigs.Length; i++)
- {
- firstDetectWaferLeaveTrigs[i] = new R_TRIG();
- }
- }
- protected void LogTaskStart(TaskType cmd, string message)
- {
- EV.PostInfoLog("Scheduler", $"TaskStart:{_module},{cmd},{message}");
- }
- protected void LogTaskDone(TaskType cmd, string message)
- {
- EV.PostInfoLog("Scheduler", $"TaskDone:{_module},{cmd},{message}");
- }
- public virtual void ResetTask()
- {
- _task = TaskType.None;
- }
- public bool WaitTransfer(ModuleName robot)
- {
- _task = TaskType.TransferTarget;
- _inProcessRobot = robot;
- LogTaskStart(_task, $"Note {robot} in transfer");
- return true;
- }
- public bool IsWaitTransfer(ModuleName robot)
- {
- return _task == TaskType.TransferTarget && _inProcessRobot == robot;
- }
- public bool StopWaitTransfer(ModuleName robot)
- {
- LogTaskDone(_task, $"Note {robot} transfer complete");
- _inProcessRobot = ModuleName.System;
- _task = TaskType.None;
- return true;
- }
- public WaferInfo GetWaferInfo(int slot)
- {
- return WaferManager.Instance.GetWafer(ModuleHelper.Converter(_module), slot);
- }
- public virtual bool HasWafer(int slot)
- {
- return WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(_module), slot);
- }
- public virtual bool NoWafer(int slot)
- {
- return WaferManager.Instance.CheckNoWafer(ModuleHelper.Converter(_module), slot);
- }
- public bool FirstDetectWaferArrive(int slot)
- {
- firstDetectWaferArriveTrigs[slot].CLK = HasWafer(slot);
- return firstDetectWaferArriveTrigs[slot].Q;
- }
- public bool FirstDetectWaferLeave(int slot)
- {
- firstDetectWaferLeaveTrigs[slot].CLK = NoWafer(slot);
- return firstDetectWaferLeaveTrigs[slot].Q;
- }
- /// <summary>
- /// 检查参数代表的wafer下一站是否是本模块
- /// </summary>
- /// <param name="module"> 已有wafer的Module</param>
- /// <param name="slot"> 已有wafer的Slot</param>
- /// <returns></returns>
- public virtual bool CheckWaferNextStepIsThisModule(ModuleName module, int slot)
- {
- if (!WaferManager.Instance.CheckHasWafer(module, slot))
- return false;
- WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(Module))
- return false;
- return true;
- }
- /// <summary>
- /// 检查参数代表的wafer下一站是否是本模块thisSlot
- /// </summary>
- /// <param name="module"> 已有wafer的Module</param>
- /// <param name="slot"> 已有wafer的Slot</param>
- /// <param name="thisSlot"> 本模块slot位置</param>
- /// <returns></returns>
- public virtual bool CheckWaferNextStepIsThisModuleSlot(ModuleName module, int slot, int thisSlot)
- {
- if (!WaferManager.Instance.CheckHasWafer(module, slot))
- return false;
- WaferInfo wafer = WaferManager.Instance.GetWafer(module, slot);
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(Module))
- return false;
- if (!wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter["SlotSelection"].ToString().Contains(thisSlot.ToString()))
- return false;
- return true;
- }
- /// <summary>
- /// 判断下一步的模块是否有Wafer
- /// </summary>
- /// <param name="slot"></param>
- /// <returns></returns>
- public virtual bool CheckWaferNextStepModuleNoWafer(int slot)
- {
- if (!WaferManager.Instance.CheckHasWafer(Module, slot))
- return false;
- WaferInfo wafer = WaferManager.Instance.GetWafer(Module, slot);
- if (wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null)
- return false;
- if (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
- return false;
- List<ModuleName> lstModuleName = wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules;
- if (lstModuleName.Count > 0)
- {
- for (int i = 0; i < lstModuleName.Count; i++)
- {
- if (WaferManager.Instance.CheckNoWafer(lstModuleName[i], 0))
- {
- return true;
- }
- }
- }
- return false;
- }
- public virtual bool IsReadyForPick(ModuleName robot, Hand blade, int slot)
- {
- return true;
- }
- public virtual bool IsReadyForPlace(ModuleName robot, Hand blade, int slot)
- {
- return true;
- }
- public virtual bool PrepareTransfer(ModuleName robot, EnumTransferType type, int slot)
- {
- return true;
- }
- public virtual bool PostTransfer(ModuleName robot, EnumTransferType type, int slot)
- {
- return true;
- }
- public virtual bool Process(string recipeName, bool isCleanRecipe, bool withDummyWafer)
- {
- return true;
- }
- public virtual bool Cooling(int coolingTime)
- {
- return true;
- }
- }
- }
|