using System.Collections.Generic; using Aitex.Core.Common; using Aitex.Core.RT.Event; using Aitex.Core.RT.OperationCenter; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.FAServices; using MECF.Framework.Common.Jobs; using MECF.Framework.Common.SubstrateTrackings; namespace EfemDualSchedulerLib.Schedulers { public class SchedulerFACallback : ISchedulerFACallback { private const string PortJobStarted = "PortJobStarted"; private const string PortJobStopped = "PortJobStopped"; private const string PortJobPaused = "PortJobPaused"; private const string PortJobResumed = "PortJobResumed"; private const string PortJobAborted = "PortJobAborted"; private const string PortJobFinished = "PortJobFinished"; private const string PortJobFailed = "PortJobFailed"; private const string PortSequenceSelected = "PortPPSelected"; private const string PortJobWaitingForStart = "PortJobWaitingForStart"; private const string PortSequenceSelectFailed = "PortPPSelectFailed"; private const string PortJobWaferStart = "PortJobWaferStart"; private const string PortJobWaferEnd = "PortJobWaferEnd"; private const string E94ControlJobStateChanged = "E94ControlJobStateChanged"; //private const string Port1JobStarted = "Port1JobStarted"; //private const string Port1JobStopped = "Port1JobStopped"; //private const string Port1JobPaused = "Port1JobPaused"; //private const string Port1JobResumed = "Port1JobResumed"; //private const string Port1JobAborted = "Port1JobAborted"; //private const string Port1JobFinished = "Port1JobFinished"; //private const string Port1JobFailed = "Port1JobFailed"; //private const string Port1SequenceSelected = "Port1SequenceSelected"; //private const string Port1SequenceSelectFailed = "Port1SequenceSelectFailed"; //private const string Port1JobWaferStart = "Port1JobWaferStart"; //private const string Port1JobWaferEnd = "Port1JobWaferEnd"; //private const string Port2JobStarted = "Port2JobStarted"; //private const string Port2JobStopped = "Port2JobStopped"; //private const string Port2JobPaused = "Port2JobPaused"; //private const string Port2JobResumed = "Port2JobResumed"; //private const string Port2JobAborted = "Port2JobAborted"; //private const string Port2JobFinished = "Port2JobFinished"; //private const string Port2JobFailed = "Port2JobFailed"; //private const string Port2SequenceSelected = "Port2SequenceSelected"; //private const string Port2SequenceSelectFailed = "Port2SequenceSelectFailed"; //private const string Port2JobWaferStart = "Port2JobWaferStart"; //private const string Port2JobWaferEnd = "Port2JobWaferEnd"; //private Dictionary PortJobWaferStart = new Dictionary() //{ // {ModuleName.LP1, Port1JobWaferStart}, // {ModuleName.LP2, Port2JobWaferStart}, //}; //private Dictionary PortJobWaferEnd = new Dictionary() //{ // {ModuleName.LP1, Port1JobWaferEnd}, // {ModuleName.LP2, Port2JobWaferEnd}, //}; //private Dictionary PortJobStarted = new Dictionary() //{ // {ModuleName.LP1, Port1JobStarted}, // {ModuleName.LP2, Port2JobStarted}, //}; //private Dictionary PortJobStopped = new Dictionary() //{ // {ModuleName.LP1, Port1JobStopped}, // {ModuleName.LP2, Port2JobStopped}, //}; //private Dictionary PortJobPaused = new Dictionary() //{ // {ModuleName.LP1, Port1JobPaused}, // {ModuleName.LP2, Port2JobPaused}, //}; //private Dictionary PortJobResumed = new Dictionary() //{ // {ModuleName.LP1, Port1JobResumed}, // {ModuleName.LP2, Port2JobResumed}, //}; //private Dictionary PortJobAborted = new Dictionary() //{ // {ModuleName.LP1, Port1JobAborted}, // {ModuleName.LP2, Port2JobAborted}, //}; //private Dictionary PortJobFinished = new Dictionary() //{ // {ModuleName.LP1, Port1JobFinished}, // {ModuleName.LP2, Port2JobFinished}, //}; //private Dictionary PortJobFailed = new Dictionary() //{ // {ModuleName.LP1, Port1JobFailed}, // {ModuleName.LP2, Port2JobFailed}, //}; //private Dictionary PortSequenceSelected = new Dictionary() //{ // {ModuleName.LP1, Port1SequenceSelected}, // {ModuleName.LP2, Port2SequenceSelected}, //}; //private Dictionary PortSequenceSelectFailed = new Dictionary() //{ // {ModuleName.LP1, Port1SequenceSelectFailed}, // {ModuleName.LP2, Port2SequenceSelectFailed}, //}; private Dictionary PortId = new Dictionary() { {ModuleName.LP1, "1"}, {ModuleName.LP2, "2"}, {ModuleName.LP3, "3"}, }; public SchedulerFACallback() { EV.Subscribe(new EventItem("Event", PortJobStarted, PortJobStarted)); EV.Subscribe(new EventItem("Event", PortJobStopped, PortJobStopped)); EV.Subscribe(new EventItem("Event", PortJobPaused, PortJobPaused)); EV.Subscribe(new EventItem("Event", PortJobResumed, PortJobResumed)); EV.Subscribe(new EventItem("Event", PortJobAborted, PortJobAborted)); EV.Subscribe(new EventItem("Event", PortJobFinished, PortJobFinished)); EV.Subscribe(new EventItem("Event", PortJobFailed, PortJobFailed)); EV.Subscribe(new EventItem("Event", PortSequenceSelected, PortSequenceSelected)); EV.Subscribe(new EventItem("Event", PortSequenceSelectFailed, PortSequenceSelectFailed)); EV.Subscribe(new EventItem("Event", PortJobWaferStart, PortJobWaferStart)); EV.Subscribe(new EventItem("Event", PortJobWaferEnd, PortJobWaferEnd)); EV.Subscribe(new EventItem("Event", PortJobWaitingForStart, PortJobWaitingForStart)); //EV.Subscribe(new EventItem("Event", Port1JobStarted, Port1JobStarted)); //EV.Subscribe(new EventItem("Event", Port1JobStopped, Port1JobStopped)); //EV.Subscribe(new EventItem("Event", Port1JobPaused, Port1JobPaused)); //EV.Subscribe(new EventItem("Event", Port1JobResumed, Port1JobResumed)); //EV.Subscribe(new EventItem("Event", Port1JobAborted, Port1JobAborted)); //EV.Subscribe(new EventItem("Event", Port1JobFinished, Port1JobFinished)); //EV.Subscribe(new EventItem("Event", Port1JobFailed, Port1JobFailed)); //EV.Subscribe(new EventItem("Event", Port1SequenceSelected, Port1SequenceSelected)); //EV.Subscribe(new EventItem("Event", Port1SequenceSelectFailed, Port1SequenceSelectFailed)); //EV.Subscribe(new EventItem("Event", Port1JobWaferStart, Port1JobWaferStart)); //EV.Subscribe(new EventItem("Event", Port1JobWaferEnd, Port1JobWaferEnd)); //EV.Subscribe(new EventItem("Event", Port2JobStarted, Port2JobStarted)); //EV.Subscribe(new EventItem("Event", Port2JobStopped, Port2JobStopped)); //EV.Subscribe(new EventItem("Event", Port2JobPaused, Port2JobPaused)); //EV.Subscribe(new EventItem("Event", Port2JobResumed, Port2JobResumed)); //EV.Subscribe(new EventItem("Event", Port2JobAborted, Port2JobAborted)); //EV.Subscribe(new EventItem("Event", Port2JobFinished, Port2JobFinished)); //EV.Subscribe(new EventItem("Event", Port2JobFailed, Port2JobFailed)); //EV.Subscribe(new EventItem("Event", Port2SequenceSelected, Port2SequenceSelected)); //EV.Subscribe(new EventItem("Event", Port2SequenceSelectFailed, Port2SequenceSelectFailed)); //EV.Subscribe(new EventItem("Event", Port2JobWaferStart, Port2JobWaferStart)); //EV.Subscribe(new EventItem("Event", Port2JobWaferEnd, Port2JobWaferEnd)); } public void JobCreated(ControlJobInfo cj, ProcessJobInfo pj) { if (!string.IsNullOrEmpty(cj.Module)) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortSequenceSelected, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); } else { EV.Notify(PortSequenceSelected, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, "" }, {DataVariables.SequenceID, pj.Sequence.Name } }); } //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobCreateFailed(string module, string lotID, string jobID, string sequenceID) { ModuleName moduleName = ModuleHelper.Converter(module); EV.Notify(PortSequenceSelectFailed, new SerializableDictionary() { {DataVariables.LotID, lotID}, {DataVariables.JobID, jobID}, {DataVariables.PortID, PortId[moduleName] }, {DataVariables.SequenceID, sequenceID } }); } public void JobStarted(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobStarted, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobWaitingForStart(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobWaitingForStart, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); //OP.DoOperation(E94ControlJobStateChanged,cj.Name, EnumControlJobState.WaitingForStart); } public void JobStopped(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobStopped, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobPaused(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobPaused, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobResumed(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobResumed, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobAborted(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobAborted, new SerializableDictionary() { {DataVariables.LotID, cj.LotName}, {DataVariables.JobID, cj.Name}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, "" } }); //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobFinished(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); int count = pj.SlotWafers.Count; EV.Notify(PortJobFinished, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name }, {DataVariables.ProcessedWaferCount, count.ToString() }, }); //OP.DoOperation(E94ControlJobStateChanged, cj.Name, cj.State); } public void JobFailed(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobFailed, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[module] }, {DataVariables.SequenceID, pj.Sequence.Name } }); } public void JobWaferStart(ProcessJobInfo pj, string loadPortName, int slotID) { var loadPort = ModuleHelper.Converter(loadPortName); EV.Notify(PortJobWaferStart, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[loadPort] }, {DataVariables.SlotID, (slotID+1).ToString() }, {DataVariables.SequenceID, pj.Sequence != null ? pj.Sequence.Name:string.Empty } }); } public void JobWaferEnd(ProcessJobInfo pj, string loadPortName, int slotID) { var loadPort = ModuleHelper.Converter(loadPortName); WaferInfo wafer = WaferManager.Instance.GetWafer(loadPort, slotID); EV.Notify(PortJobWaferEnd, new SerializableDictionary() { {DataVariables.LotID, pj.LotName}, {DataVariables.JobID, pj.ControlJobName}, {DataVariables.PortID, PortId[loadPort] }, {DataVariables.SlotID, (slotID+1).ToString() }, {DataVariables.WaferProcessResult, (wafer.ProcessState==EnumWaferProcessStatus.Failed ? 0:1).ToString()}, {DataVariables.SequenceID, pj.Sequence != null ? pj.Sequence.Name:string.Empty } }); } } }