using Aitex.Core.Common; using Aitex.Core.RT.Event; using Aitex.Core.UI.Control; using Aitex.Core.Util; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Jobs; using MECF.Framework.Common.SubstrateTrackings; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; namespace Venus_RT.Modules { public interface ISchedulerFACallback { void JobCreated(ControlJobInfo cj, ProcessJobInfo pj); void JobCreateFailed(string module, string lotID, string jobID, string sequenceID); void JobStarted(ControlJobInfo cj, ProcessJobInfo pj); void JobStopped(ControlJobInfo cj, ProcessJobInfo pj); void JobPaused(ControlJobInfo cj, ProcessJobInfo pj); void JobResumed(ControlJobInfo cj, ProcessJobInfo pj); void JobAborted(ControlJobInfo cj, ProcessJobInfo pj); void JobFinished(ControlJobInfo cj, ProcessJobInfo pj); void JobFailed(ControlJobInfo cj, ProcessJobInfo pj); void JobWaferStart(ControlJobInfo cj, int slotID); void JobWaferEnd(ControlJobInfo cj, int slotID); } 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 PortSequenceSelectFailed = "PortPPSelectFailed"; private const string PortJobWaferStart = "PortJobWaferStart"; private const string PortJobWaferEnd = "PortJobWaferEnd"; private Dictionary PortId = new Dictionary() { {ModuleName.LP1, "1"}, {ModuleName.LP2, "2"}, {ModuleName.LP3, "3"}, {ModuleName.VCE1, "1"}, {ModuleName.VCEA, "1"}, {ModuleName.VCEB, "2"}, }; 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)); } public void JobCreated(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortSequenceSelected, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name } }); } public void JobCreateFailed(string module, string lotID, string jobID, string sequenceID) { ModuleName moduleName = ModuleHelper.Converter(module); EV.Notify(PortSequenceSelectFailed, new SerializableDictionary() { {DVIDName.LotID, lotID}, {DVIDName.JobID, jobID}, {DVIDName.PortID, PortId[moduleName] }, {DVIDName.SequenceID, sequenceID } }); } public void JobStarted(ControlJobInfo cj,ProcessJobInfo pj) { ModuleName module= ModuleHelper.Converter(cj.Module); EV.Notify(PortJobStarted, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name } }); } public void JobStopped(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobStopped, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name } }); } public void JobPaused(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobPaused, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name } }); } public void JobResumed(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobResumed, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name } }); } public void JobAborted(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobAborted, new SerializableDictionary() { {DVIDName.LotID, cj.LotName}, {DVIDName.JobID, cj.Name}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, "" } }); } public void JobFinished(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); int count = pj.SlotWafers.Count; EV.Notify(PortJobFinished, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name }, {DVIDName.ProcessedWaferCount, count.ToString() }, }); } public void JobFailed(ControlJobInfo cj, ProcessJobInfo pj) { ModuleName module = ModuleHelper.Converter(cj.Module); EV.Notify(PortJobFailed, new SerializableDictionary() { {DVIDName.LotID, pj.LotName}, {DVIDName.JobID, pj.ControlJobName}, {DVIDName.PortID, PortId[module] }, {DVIDName.SequenceID, pj.Sequence.Name } }); } public void JobWaferStart(ControlJobInfo cj, int slotID) { ModuleName module = ModuleHelper.Converter(cj.Module); WaferInfo waferInfo = WaferManager.Instance.GetWafer(module, slotID); if (waferInfo != null) { EV.Notify(PortJobWaferStart, new SerializableDictionary() { {DVIDName.LotID, cj.LotName}, {DVIDName.JobID, cj.Name}, {DVIDName.PortID, PortId[module] }, {DVIDName.SlotID, (slotID+1).ToString() }, {DVIDName.CarrierID, waferInfo.OriginCarrierID==null?"":waferInfo.OriginCarrierID}, {DVIDName.SequenceID,waferInfo.SequenceName } }); } } public void JobWaferEnd(ControlJobInfo cj, int slotID) { ModuleName module = ModuleHelper.Converter(cj.Module); WaferInfo wafer = WaferManager.Instance.GetWafer(module, slotID); if (wafer != null) { EV.Notify(PortJobWaferEnd, new SerializableDictionary() { {DVIDName.LotID, cj.LotName}, {DVIDName.JobID, cj.Name}, {DVIDName.PortID, PortId[module] }, {DVIDName.SlotID, (slotID+1).ToString() }, {DVIDName.CarrierID, wafer.OriginCarrierID==null?"":wafer.OriginCarrierID}, {DVIDName.WaferProcessResult, (wafer.ProcessState == EnumWaferProcessStatus.Failed ? 0:1).ToString()}, {DVIDName.SequenceID,wafer.SequenceName } }); } } } }