示例#1
0
        /// <summary>
        /// </summary>
        /// <param name="entity"/>
        /// <param name="now"/>
        /// <param name="target"/>
        /// <param name="factor"/>
        /// <param name="ctx"/>
        /// <returns/>
        public WeightValue SMALL_BATCH_MERGE_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));
            }

            int baseQty        = (int)factor.Criteria[0];
            int checkStepCount = (int)factor.Criteria[1];

            FabAoEquipment eqp = target as FabAoEquipment;
            FabLot         lot = entity as FabLot;

            //if (eqp.IsLastPlan(lot.CurrentShopID, lot.CurrentStepID, lot.CurrentProductID, Constants.NULL_ID, lot.OwnerType, lot.OwnerID))
            //	return new WeightValue(1 * factor.Factor, string.Format("[IsLast:Y]"));

            FabStep currentStep = lot.CurrentFabStep;
            var     currentProd = lot.FabProduct;

            FabStep prevStep = currentStep.GetPrevMainStep(lot.FabProduct, true);

            StepTat tat = null;

            if (prevStep != null)
            {
                tat = prevStep.GetTat(lot.CurrentProductID, true);
            }

            if (tat == null)
            {
                tat = currentStep.GetDefaultTAT();
            }


            var job = InFlowMaster.GetJobState(lot);

            if (job == null)
            {
                return(new WeightValue(0));
            }


            int waitQty = job.GetCurrenStepWaitWipQty(eqp, currentStep, Constants.NULL_ID, (decimal)TimeSpan.FromMinutes(tat.RunTat).TotalHours);

            if (waitQty > baseQty)
            {
                return(new WeightValue(0, string.Format("[Wait:{0}>{1}:Base]", waitQty, baseQty)));
            }

            int prevWipQty = job.GetPrevStepRunWipQty(eqp, currentStep, Constants.NULL_ID, now.AddMinutes(tat.TAT));

            if (prevWipQty > 0)
            {
                return(new WeightValue(0, string.Format("[PrevRunWip:{0}>0", prevWipQty)));
            }

            int nextWipQty = 0;

            var nextStepList = currentStep.GetNextStepList(currentProd, checkStepCount);

            foreach (FabStep next in nextStepList)
            {
                nextWipQty += job.GetStepWips(next, WipType.Total);
            }

            int runQty = job.GetStepWips(currentStep, WipType.Run);

            if (runQty + nextWipQty == 0)
            {
                return(new WeightValue(0, string.Format("[Run:{0} + NextQty:{1} = 0]", runQty, nextWipQty)));
            }

            return(new WeightValue(1 * factor.Factor, string.Format("[Run:{0} + NextQty:{1}>0]", runQty, nextWipQty)));
        }
示例#2
0
        /// <summary>
        /// </summary>
        /// <param name="entity"/>
        /// <param name="now"/>
        /// <param name="target"/>
        /// <param name="factor"/>
        /// <param name="ctx"/>
        /// <returns/>
        public WeightValue NEXT_STEP_CONTINUOUS_PRODUCTION_PRIORITY(Mozart.Simulation.Engine.ISimEntity entity, DateTime now, Mozart.Simulation.Engine.ActiveObject target, Mozart.SeePlan.DataModel.WeightFactor factor, Mozart.SeePlan.Simulation.IDispatchContext ctx)
        {
            FabAoEquipment eqp = target as FabAoEquipment;

            WeightFactor wf;

            WeightHelper.TryGetEqpWeightFactor(eqp, Constants.WF_NEXT_STEP_CONTINUOUS_PRODUCTION_PRIORITY, out wf);

            FabLot lot = entity as FabLot;

            string desc           = string.Empty;
            float  score          = 0;
            int    checkStepCount = (int)wf.Criteria[0];
            int    minLimitQty    = (int)wf.Criteria[1];
            int    maxLimitQty    = (int)wf.Criteria[2];

            var currentStep = lot.CurrentFabStep;
            var currentProd = lot.FabProduct;

            FabStep nextPhotoStep = currentStep.GetNextPhotoNearByMe(currentProd, checkStepCount, out int idx);

            if (nextPhotoStep == null)
            {
                score = 0f;
            }
            else
            {
                var job = InFlowMaster.GetJobState(lot);

                if (job == null)
                {
                    return(new WeightValue(0));
                }

                int nextPhlWipQty = job.GetStepWips(nextPhotoStep, WipType.Total);

                if (nextPhlWipQty <= maxLimitQty && nextPhlWipQty > minLimitQty)
                {
                    bool checkProductVersion = false;

                    var     workingEqps     = currentStep.StdStep.GetWorkingEqpList(lot, checkProductVersion);
                    int     workingCnt      = workingEqps == null ? 0 : workingEqps.Count;
                    Decimal curStepTactTime = TimeHelper.GetAvgTactTimeForEqps(currentStep, currentProd, workingEqps);

                    var     targetWorkingEqps     = nextPhotoStep.StdStep.GetWorkingEqpList(lot, checkProductVersion);
                    int     targetWorkingCnt      = targetWorkingEqps == null ? 0 : targetWorkingEqps.Count;
                    Decimal nextPhotoStepTactTime = TimeHelper.GetAvgTactTimeForEqps(nextPhotoStep, currentProd, targetWorkingEqps);

                    if ((workingCnt / curStepTactTime) < (targetWorkingCnt / nextPhotoStepTactTime))
                    {
                        score = 1f;
                    }

                    desc = string.Format("[Working:{0}, Next_Photo:{1}]", workingCnt, targetWorkingCnt);
                }
                else if (nextPhlWipQty <= minLimitQty)
                {
                    float s = idx;
                    float m = checkStepCount;
                    float r = m == 0 ? 0 : (float)Math.Round(s / m, 3);

                    score = 1 - r;
                    int adv = 2;
                    score *= adv;

                    desc = string.Format("[NextPhotoStepWipQty:{0}, Adv:{1}]", nextPhlWipQty, adv);
                }
            }

            return(new WeightValue(score * wf.Factor, desc));
        }
示例#3
0
        public WeightValue SMALL_LOT(ISimEntity entity, DateTime now, ActiveObject target, WeightFactor factor, IDispatchContext ctx)
        {
            if (factor.Factor == 0)
            {
                return(new WeightValue(0));
            }

            FabAoEquipment eqp = target as FabAoEquipment;
            FabLot         lot = entity as FabLot;

            int smallSize = (int)factor.Criteria[0];

            if (smallSize == 0)
            {
                return(new WeightValue(0));
            }

            int stepCount = (int)factor.Criteria[1];

            if (stepCount == 0)
            {
                return(new WeightValue(0));
            }

            var job = InFlowMaster.GetJobState(lot);

            if (job == null)
            {
                return(new WeightValue(0));
            }

            int    currentUnitQty = lot.UnitQty;
            string shopID         = lot.CurrentShopID;
            string productID      = lot.CurrentProductID;
            string productVer     = lot.CurrentProductVersion;

            bool isLastPlan = ResHelper.IsLastPlan(eqp, lot);

            float score = 0f;

            if (isLastPlan)
            {
                score = 1f;
            }

            FabStep step     = lot.CurrentFabStep;
            string  stepType = step.StepType;

            int cnt     = 0;
            int runQty  = 0;
            int waitQty = 0;
            int total   = 0;

            while (cnt < stepCount)
            {
                List <FabStep> preSteps = step.GetPrevSteps(productID);

                List <FabLot> runWips  = job.GetPrevStepWipList(step, WipType.Run, productVer);
                List <FabLot> waitWips = job.GetPrevStepWipList(step, WipType.Wait, productVer);

                if (runWips.Count <= 0 && waitWips.Count <= 0)
                {
                    cnt++;
                    continue;
                }

                int prevRunQty = runWips.Sum(x => x.UnitQty);
                int preWaitQty = waitWips.Sum(x => x.UnitQty);

                runQty  += prevRunQty;
                waitQty += preWaitQty;
                total   += runQty + waitQty;

                foreach (FabStep prevStep in preSteps)
                {
                    if (prevStep.StepType == "MAIN")
                    {
                        step = prevStep;
                    }

                    if (step == null)
                    {
                        continue;
                    }
                }

                cnt++;
            }

            int compareQty = currentUnitQty + total;

            string desc = string.Format("[SmallSize:{0}, CompareQty:{1}, IsLast:{2}]", smallSize, compareQty, isLastPlan);

            if (compareQty > smallSize)
            {
                score = 1f;
            }

            return(new WeightValue(score * factor.Factor, desc));
        }