/// <summary> /// </summary> /// <param name="wstep"/> /// <param name="context"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public IEnumerable <AoEquipment> SELECT_DOWN_EQP0(WorkStep wstep, JobChangeContext context, ref bool handled, IEnumerable <AoEquipment> prevReturnValue) { MicronBEAssyWorkStep ws = wstep as MicronBEAssyWorkStep; DateTime availableDownTime = ws.AvailableDownTime; DateTime nowDt = FindHelper.GetNowDT(); if (nowDt < availableDownTime) { return(null); } else { var t = wstep.LoadedEqps.FirstOrDefault(); if (t != null) { Logger.MonitorInfo(string.Format("Down Eqp -> STEP : {0}, EQP_ID : {1}, NowDT : {2}", ws.Key.ToString(), t.Target.EqpID, DateUtility.DbToString(FindHelper.GetNowDT()))); return(new AoEquipment[] { t.Target }); } else { return(null); } } }
/// <summary> /// </summary> /// <param name="wagent"/> /// <param name="handled"/> public void INITIALIZE_AGENT0(Mozart.SeePlan.Simulation.WorkAgent wagent, ref bool handled) { try { if (wagent.Id == Constants.WorkAgentName) { wagent.AgentType = AgentType.TRADE; wagent.Interval = TimeSpan.FromMinutes(10); wagent.IsReProfiling = true; wagent.IsReleaseDownEqp = true; foreach (MicronBEAssyBatch batch in InputMart.Instance.MicronBEAssyBatch.Values) { WorkGroup group = wagent.GetGroup(batch.AoProdID); foreach (KeyValuePair <string, ICollection <MicronBEAssyBEStep> > stepInfo in batch.StepList) { foreach (MicronBEAssyBEStep step in stepInfo.Value) { MicronBEAssyWorkStep wStep = group.TryGetStep(stepInfo.Key) as MicronBEAssyWorkStep; if (wStep == null) { wStep = group.GetStep(stepInfo.Key) as MicronBEAssyWorkStep; wStep.Sequence = step.Sequence; wStep.AoProd = batch.AoProdID; } if (wStep.Steps.Contains(step) == false) { wStep.Steps.Add(step); } JobChangeInit agentInitControl = ServiceLocator.Resolve <JobChangeInit>(); agentInitControl.InitializeWorkStep(wStep); } } } } } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="weqp"/> /// <param name="wstep"/> /// <param name="list"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public List <WorkLot> DO_FILTER_LOT0(WorkEqp weqp, WorkStep wstep, List <WorkLot> list, ref bool handled, List <WorkLot> prevReturnValue) { try { #if DEBUG if (weqp.Target.EqpID == "DA03" && wstep.Key.ToString() == "S0100") { Console.WriteLine(); } #endif MicronBEAssyWorkStep ws = wstep as MicronBEAssyWorkStep; List <WorkLot> lotList = new List <WorkLot>(); foreach (MicronBEAssyWorkLot lot in list) { AssyMcpPart mcpPart = lot.Product as AssyMcpPart; if (mcpPart != null && mcpPart.IsBase == false) { continue; } MicronBEAssyBELot beLot = lot.Batch as MicronBEAssyBELot; if (lot.ReservationEqp != null && lot.ReservationEqp != weqp.Target) { continue; } lotList.Add(lot); } if (lotList.IsNullOrEmpty()) { weqp.Stop = true; } return(lotList); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(List <WorkLot>)); } }
/// <summary> /// </summary> /// <param name="hb"/> /// <param name="wgroup"/> /// <param name="wstepKey"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public Step GET_TARGET_STEP0(IHandlingBatch hb, WorkGroup wgroup, object wstepKey, ref bool handled, Step prevReturnValue) { try { MicronBEAssyWorkStep workStep = wgroup.TryGetStep(wstepKey) as MicronBEAssyWorkStep; if (workStep != null) { return(workStep.Steps.ElementAt(0)); } return(null); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(Step)); } }
/// <summary> /// </summary> /// <param name="upWorkStep"/> /// <param name="assignEqps"/> /// <param name="context"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public List <AssignEqp> DO_FILTER_ASSIGN_EQP0(WorkStep upWorkStep, List <AssignEqp> assignEqps, JobChangeContext context, ref bool handled, List <AssignEqp> prevReturnValue) { try { List <AssignEqp> list = new List <AssignEqp>(); foreach (AssignEqp eqp in assignEqps) { if (eqp.WorkStep == null || eqp.WorkStep.OperationType == OperationType.Down) { list.Add(eqp); continue; } int properEqpCount = SimulationHelper.CalculateProperEqpCount(eqp); bool canFilter = false; canFilter = SimulationHelper.CanFilterAssignEqp(eqp); if (properEqpCount < eqp.WorkStep.LoadedEqpCount && canFilter) { #if DEBUG DateTime nowDt = FindHelper.GetNowDT(); MicronBEAssyWorkStep ws = eqp.WorkStep as MicronBEAssyWorkStep; if (eqp.WorkStep.Key.ToString() == "S0250") { Console.WriteLine(); } Logger.MonitorInfo(string.Format("Filtered -> STEP : {0}, EQP_ID : {1}, NowDT : {2}, Available Down : {3}", eqp.WorkStep.Key.ToString(), eqp.Target.EqpID, DateUtility.DbToString(FindHelper.GetNowDT()), DateUtility.DbToString(ws.AvailableDownTime))); #endif list.Add(eqp); } } return(list); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(List <AssignEqp>)); } }
public static bool CanFilterAssignEqp(AssignEqp assignEqp) { MicronBEAssyWorkStep wstep = assignEqp.WorkStep as MicronBEAssyWorkStep; DateTime availableDownTime = wstep.AvailableDownTime; DateTime nowDt = FindHelper.GetNowDT(); if (nowDt < availableDownTime) { return(false); } foreach (var wip in wstep.Wips) { var lot = wip.Lot as MicronBEAssyBELot; if (lot.ReservationEqp != null && lot.ReservationEqp == assignEqp.Target) { return(false); } } return(true); }
/// <summary> /// </summary> /// <param name="step"/> /// <param name="assignedEqps"/> /// <param name="context"/> /// <param name="handled"/> public void ON_AFTER_ASSIGN_EQP0(WorkStep step, List <AssignEqp> assignedEqps, JobChangeContext context, ref bool handled) { try { Logger.MonitorInfo(string.Format("Assign Eqp -> STEP : {0}, EQP_ID : {1}, NowDT : {2}", step.Key.ToString(), assignedEqps.ElementAt(0).Target.EqpID, DateUtility.DbToString(FindHelper.GetNowDT()))); MicronBEAssyWorkStep ws = step as MicronBEAssyWorkStep; double setupTime = 0d; ws.AvailableDownTime = SimulationHelper.CalculateAvailableDownTime(step, assignedEqps.ElementAt(0), ref setupTime); Logger.MonitorInfo(string.Format("Available Down Time : {0}, Setup Time : {1}", ws.AvailableDownTime, setupTime)); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } //foreach (AssignEqp eqp in assignedEqps) //{ // eqp.Target.WakeUp(); //} }
/// <summary> /// </summary> /// <param name="wstep"/> /// <param name="handled"/> public void INITIALIZE_WORK_STEP0(WorkStep wstep, ref bool handled) { try { MicronBEAssyWorkStep ws = wstep as MicronBEAssyWorkStep; ws.UpInterval = TimeSpan.FromHours(8); ws.NewUpInterval = TimeSpan.FromHours(8); ws.DownInterval = TimeSpan.FromMinutes(30); ws.AllowedArrivalGap = TimeSpan.FromHours(1); var agentInitControl = ServiceLocator.Resolve <JobChangeInit>(); var loadables = agentInitControl.GetLoadableEqps(wstep); if (loadables != null) { loadables.ForEach(aeqp => wstep.AddLoadableEqp(aeqp)); } } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); } }
/// <summary> /// </summary> /// <param name="step"/> /// <param name="reason"/> /// <param name="context"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public float CALCULATE_PRIORITY0(WorkStep step, object reason, JobChangeContext context, ref bool handled, float prevReturnValue) { try { float priority = 0; MicronBEAssyWorkStep ws = step as MicronBEAssyWorkStep; if (step.OperationType == OperationType.Up) { priority = 1000; } priority += 100 / ws.Sequence; return(priority); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(float)); } }
public static DateTime CalculateAvailableDownTime(WorkStep wstep, AssignEqp assignEqp, ref double setupTime) { try { MicronBEAssyWorkStep ws = wstep as MicronBEAssyWorkStep; DateTime nowDt = FindHelper.GetNowDT(); DateTime availableDownTime = nowDt.AddSeconds(wstep.NewUpInterval.TotalSeconds); var wip = ws.Wips.FirstOrDefault(); if (wip == null) { return(availableDownTime); } WorkEqp weqp = null; foreach (var item in ws.LoadedEqps) { if (item.Target == assignEqp.Target) { weqp = item; break; } } var setupControl = ServiceLocator.Resolve <SetupControl>(); var processControl = ServiceLocator.Resolve <ProcessControl>(); var beLot = wip.Lot as MicronBEAssyBELot; bool isNeedSetup = false; setupTime = 0d; ICollection <WorkLot> lastWorkLots = null; if (weqp.Step != null) { lastWorkLots = weqp.Step.Profiles[weqp]; } if (lastWorkLots != null && lastWorkLots.Count != 0) { isNeedSetup = SimulationHelper.IsNeedSetupProfile(weqp, beLot); if (isNeedSetup) { setupTime = SimulationHelper.GetSetupTimeProfile(weqp, beLot).TotalSeconds; } } else { bool _handled = false; isNeedSetup = processControl.IS_NEED_SETUP0(weqp.Target, beLot, ref _handled, false); if (isNeedSetup) { setupTime = setupControl.GET_SETUP_TIME0(weqp.Target, beLot, ref _handled, default(Mozart.Simulation.Engine.Time)).TotalSeconds; } } availableDownTime = availableDownTime.AddSeconds(setupTime); return(availableDownTime); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(DateTime)); } }
/// <summary> /// </summary> /// <param name="wstep"/> /// <param name="wlot"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public IEnumerable <WorkLot> ADVANCE0(WorkStep wstep, WorkLot wlot, ref bool handled, IEnumerable <WorkLot> prevReturnValue) { try { var nowDt = FindHelper.GetNowDT(); #if DEBUG if (nowDt >= new DateTime(2018, 01, 26, 07, 00, 00)) { Console.WriteLine(); } if (wstep.Key.ToString() == "S0250" && wlot.Lot.LotID == "LOT10_1") { Console.WriteLine(); } if (wlot.Lot.LotID == "LOT11_1") { Console.WriteLine(); } #endif if (wlot.OutTime > FindHelper.GetNowDT().AddHours(10)) { return(null); } #if DEBUG //if (wstep.Key.ToString() == "S0100") // Console.WriteLine(); #endif List <WorkLot> list = new List <WorkLot>(); MicronBEAssyWorkLot currentWLot = wlot as MicronBEAssyWorkLot; MicronBEAssyBEStep currentStep = wstep.Steps[0] as MicronBEAssyBEStep; string stepKey = JobChangeHelper.GetStepKey(currentWLot.Product, currentStep.GetDefaultNextStep() as MicronBEAssyBEStep, false); //string stepKey = currentStep.GetDefaultNextStep().StepID; if (stepKey != null) { MicronBEAssyWorkStep nextWorkStep = wstep.Group.TryGetStep(stepKey) as MicronBEAssyWorkStep; if (nextWorkStep != null) { MicronBEAssyWorkLot newWorkLot = CreateHelper.CreateWorkLot(wlot.Batch, wlot.OutTime, nextWorkStep.Key, nextWorkStep.Steps.ElementAt(0), null); newWorkLot.LotID = currentWLot.LotID; newWorkLot.Product = currentWLot.Product; newWorkLot.UnitQty = currentWLot.UnitQty; //if (currentWLot.Product is AssyMcpPart) //{ // MicronBEAssyBEStep workTargetStep = wstep.Steps[0] as MicronBEAssyBEStep; // if (workTargetStep.StepAction != null && workTargetStep.StepAction.FWTractIn == StepActionInfo.MCP) // { // AssyMcpPart mcpPart = currentWLot.Product as AssyMcpPart; // if (mcpPart.SequenceResolved != (wstep as MicronBEAssyWorkStep).Sequence) // newWorkLot.Product = mcpPart.Next == null ? mcpPart.OutProduct as Product : mcpPart.Next as Product; // } //} if (newWorkLot.Product != null) { list.Add(newWorkLot); } } } return(list); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(IEnumerable <WorkLot>)); } }
/// <summary> /// </summary> /// <param name="step"/> /// <param name="context"/> /// <param name="reason"/> /// <param name="handled"/> /// <param name="prevReturnValue"/> /// <returns/> public OperationType CLASSIFY_OPERATION_TYPE0(WorkStep step, JobChangeContext context, out object reason, ref bool handled, OperationType prevReturnValue) { try { reason = string.Empty; OperationType oType = OperationType.Keep; MicronBEAssyWorkStep ws = step as MicronBEAssyWorkStep; DateTime nowDT = FindHelper.GetNowDT(); #if DEBUG if (step.Key.ToString() == "S0250" && nowDT >= new DateTime(2018, 06, 12, 12, 10, 00)) { Console.WriteLine(); } #endif if (ws.LoadedEqps.Count > 1) { DateTime runDownTime = JobChangeHelper.GetMinRunDownTime(ws); if (runDownTime.Subtract(nowDT).TotalSeconds < ws.DownInterval.TotalSeconds) { return(OperationType.Down); } } if (ws.LoadedEqps.Count == 1) { if (ws.ProfileAssignWips.Count <= 0) { return(OperationType.Down); } } if (ws.Wips.Count > 0) { AoEquipment selectEqp = null; DateTime minNextInTime = DateTime.MaxValue; foreach (AoEquipment aeqp in ws.LoadableEqps) { if (ws.LoadedEqpIDs.Contains(aeqp.EqpID)) { continue; } //DateTime nextInTime = (DateTime)SimulationHelper.GetNextInTime(aeqp, false); DateTime nextInTime = (DateTime)aeqp.GetNextInTime(false); if (selectEqp == null || minNextInTime > nextInTime) { selectEqp = aeqp; minNextInTime = nextInTime; } } if (selectEqp != null) { if (step.Key.ToString() == "S0300" && nowDT >= new DateTime(2018, 01, 26, 07, 30, 00)) { Console.WriteLine(); } if (step.Key.ToString() == "S0300" && nowDT >= new DateTime(2018, 01, 26, 11, 00, 00)) { Console.WriteLine(); } ws.AddLoadedEqp(selectEqp); ws.Group.CalculateProfile(ws); //SimulationHelper.CalculateProfile(ws.Group, ws); DateTime runDownTime = JobChangeHelper.GetMinRunDownTime(ws); ws.RemoveLoadedEqp(selectEqp); ws.Group.CalculateProfile(ws); //SimulationHelper.CalculateProfile(ws.Group, ws); var setupControl = ServiceLocator.Resolve <SetupControl>(); var processControl = ServiceLocator.Resolve <ProcessControl>(); bool isNeedSetup = false; var setupTime = 0d; var wip = ws.Wips.FirstOrDefault(); if (wip != null) { var beLot = wip.Lot as MicronBEAssyBELot; bool _handled = false; isNeedSetup = processControl.IS_NEED_SETUP0(selectEqp, beLot, ref _handled, false); if (isNeedSetup) { setupTime = setupControl.GET_SETUP_TIME0(selectEqp, beLot, ref _handled, default(Mozart.Simulation.Engine.Time)).TotalSeconds; } } if (runDownTime > nowDT.AddSeconds(ws.NewUpInterval.TotalSeconds + setupTime)) { #if DEBUG if (step.Key.ToString() == "S0250" && nowDT >= new DateTime(2018, 06, 12, 12, 10, 00)) { Console.WriteLine(); } #endif oType = OperationType.Up; } else { oType = OperationType.Keep; } } } return(oType); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); reason = string.Empty; return(default(OperationType)); } }
public static DateTime GetMinRunDownTime(MicronBEAssyWorkStep ws) { try { Dictionary <WorkEqp, DateTime> minRunTime = new Dictionary <WorkEqp, DateTime>(); foreach (WorkEqp eqp in ws.LoadedEqps) { DateTime minDownTime = (DateTime)eqp.Target.GetNextInTime(false); ICollection <WorkLot> profileList; if (ws.Profiles.TryGetValue(eqp, out profileList)) { foreach (WorkLot lot in profileList) { if (minDownTime < lot.InTime) { if (minRunTime.ContainsKey(eqp) == false) { minRunTime.Add(eqp, minDownTime); } else { minRunTime[eqp] = minDownTime; } break; } else { if (minRunTime.ContainsKey(eqp) == false) { minRunTime.Add(eqp, (DateTime)lot.OutTime); } else { minRunTime[eqp] = (DateTime)lot.OutTime; } minDownTime = (DateTime)lot.OutTime; } } } else { minRunTime.Add(eqp, minDownTime); } } DateTime minTime = DateTime.MaxValue; foreach (DateTime time in minRunTime.Values) { if (minTime > time) { minTime = time; } } return(minTime); } catch (Exception e) { WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0} MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name)); return(default(DateTime)); } }