public WeightValue NEXT_STEP_RUN_PRIORITY(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx) { if (factor.Factor == 0) { return(new WeightValue(0)); } float criteria0 = WeightHelper.GetCriteria(factor, 0, 0.5f); FabAoEquipment eqp = target as FabAoEquipment; FabLot lot = entity as FabLot; FabStep nextStep = BopHelper.GetNextMandatoryStep(lot); float score = 0f; int workingCnt = 0; int adv = 0; if (nextStep != null && nextStep.IsMandatoryStep) { bool checkProductVersion = true; var workingEqps = nextStep.StdStep.GetWorkingEqpList(lot, checkProductVersion); //checkProductVersion = false if (workingEqps == null || workingEqps.Count == 0) { checkProductVersion = false; workingEqps = nextStep.StdStep.GetWorkingEqpList(lot, checkProductVersion); } workingCnt = workingEqps == null ? 0 : workingEqps.Count; if (workingCnt > 0) { score = checkProductVersion ? 1f : criteria0; } var hasDummy = workingEqps.Find(t => t.IsDummyWait) != null; if (hasDummy) { adv = 2; score *= adv; } } string nextStepID = nextStep != null ? nextStep.StepID : Constants.NULL_ID; string desc = string.Format("[Next:{0}, Working:{1}, Adv:{2}]", nextStepID, workingCnt, adv); return(new WeightValue(score * factor.Factor, desc)); }
/// <summary> /// </summary> /// <param name="entity"/> /// <param name="now"/> /// <param name="target"/> /// <param name="factor"/> /// <param name="ctx"/> /// <returns/> public WeightValue MAX_QTIME_PRIORITY(Mozart.Simulation.Engine.ISimEntity entity, DateTime now, Mozart.Simulation.Engine.ActiveObject target, Mozart.SeePlan.DataModel.WeightFactor factor, Mozart.SeePlan.Simulation.IDispatchContext ctx) { if (factor.Factor == 0) { return(new WeightValue(0)); } FabLot lot = entity as FabLot; var currStep = lot.CurrentFabStep; //FabAoEquipment eqp = target as FabAoEquipment; //if (lot.LotID == "TH9C1396N0X" && eqp.EqpID == "THOVN200") //&& eqp.NowDT >= LcdHelper.StringToDateTime("20191128 133538")) // Console.WriteLine("B"); //if (lot.LotID == "TH9C1472N0L" && eqp.EqpID == "THOVN200") //&& eqp.NowDT >= LcdHelper.StringToDateTime("20191128 133538")) // Console.WriteLine("B"); var info = lot.QtimeInfo; if (info == null || info.HasMaxQTime() == false) { return(new WeightValue(0)); } var find = info.FindMinimumRemainTime(now); if (find == null) { return(new WeightValue(0)); } int criteria0 = Math.Max(WeightHelper.GetCriteria(factor, 0, 1), 1); int criteria1 = Math.Max(WeightHelper.GetCriteria(factor, 1, 0), 0); int criteria2 = Math.Max(WeightHelper.GetCriteria(factor, 2, 0), 0); int cutMinutes = (int)Time.FromMinutes(criteria0).TotalMinutes; Time baseSafe = Time.FromMinutes(criteria1); Time stepSafe = Time.FromMinutes(criteria2); int remainStepCount = find.RemainStepCount(currStep); Time safeTime = baseSafe + (stepSafe * remainStepCount); Time remainTime = find.RemainTime(lot, currStep, now); Time maxRemainTime = WeightHelper.GetMaxVaule_WF(ctx, Constants.WF_MAX_QTIME_PRIORITY, Time.Zero); float score = 0; if (remainTime < safeTime) { if (remainTime > 0 && maxRemainTime > 0) { float s = (int)(remainTime.TotalMinutes / cutMinutes); float m = (int)(maxRemainTime.TotalMinutes / cutMinutes); float r = m == 0 ? 0 : (float)Math.Round(s / m, 3); score = 1 - r; } } string desc = string.Format("[{0} = SAFE:{1}min, REMAIN:{2}min, MAX:{3}min])", Math.Round(score, 2), Math.Round(safeTime.TotalMinutes, 2), Math.Round(remainTime.TotalMinutes, 2), Math.Round(maxRemainTime.TotalMinutes, 2)); return(new WeightValue(score * factor.Factor, desc)); }