Esempio n. 1
0
        /// <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);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// </summary>
 /// <param name="upWorkStep"/>
 /// <param name="context"/>
 /// <param name="handled"/>
 /// <param name="prevReturnValue"/>
 /// <returns/>
 public bool CAN_ASSIGN_MORE0(WorkStep upWorkStep, JobChangeContext context, ref bool handled, bool prevReturnValue)
 {
     try
     {
         DateTime nowDT = FindHelper.GetNowDT();
         return(false);
     }
     catch (Exception e)
     {
         WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
         return(default(bool));
     }
 }
Esempio n. 3
0
        public void ON_AFTER_RUN0(WorkAgent wagent, ref bool handled)
        {
            if (wagent.Groups == null)
            {
                return;
            }

            else
            {
                var nowDT = FindHelper.GetNowDT();
                //if (count > 1)
                //    return;

                foreach (var wg in wagent.Groups)
                {
                    foreach (var ws in wg.Steps)
                    {
                        foreach (var profile in ws.Profiles)
                        {
                            foreach (var lot in profile.Value)
                            {
                                if (ws.Key.ToString() == "S0250" && profile.Key.Target.EqpID == "WB02" && nowDT >= new DateTime(2018, 01, 12, 12, 10, 00))
                                {
                                    if (ws.Inflows.Contains(lot))
                                    {
                                        Logger.MonitorInfo("Inflow Profile -> STEP : {0}, EQP_ID : {1}, LOT_ID : {2}, IN_TIME : {3}, OUT_TIME : {4}, NowDT : {5}", ws.Key.ToString(), profile.Key.Target.EqpID, lot.Lot.LotID, lot.InTime, lot.OutTime, wagent.NowDT);
                                    }

                                    else
                                    {
                                        Logger.MonitorInfo("Profile -> STEP : {0}, EQP_ID : {1}, LOT_ID : {2}, IN_TIME : {3}, OUT_TIME : {4}, NowDT : {5}", ws.Key.ToString(), profile.Key.Target.EqpID, lot.Lot.LotID, lot.InTime, lot.OutTime, wagent.NowDT);
                                    }
                                }
                            }
                        }
                    }
                }

                count++;
            }
        }
Esempio n. 4
0
        /// <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>));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        /// <param name="weqp"/>
        /// <param name="wlot"/>
        /// <param name="handled"/>
        /// <param name="prevReturnValue"/>
        /// <returns/>
        public TimeSpan GET_TACT_TIME0(WorkEqp weqp, WorkLot wlot, ref bool handled, TimeSpan prevReturnValue)
        {
            try
            {
                MicronBEAssyWorkLot lot = wlot as MicronBEAssyWorkLot;

                double            unitQty = (wlot.Batch as MicronBEAssyBELot).UnitQtyDouble;
                MicronBEAssyBELot beLot   = wlot.Batch as MicronBEAssyBELot;

                var setupControl   = ServiceLocator.Resolve <SetupControl>();
                var processControl = ServiceLocator.Resolve <ProcessControl>();

                MicronBEAssyEqp eqp      = FindHelper.FindEquipment(weqp.Target.EqpID);
                double          tactTime = SimulationHelper.GetTactTime(beLot.LineID, lot.Step.StepID, lot.Product.ProductID, eqp);

                if (beLot.CurrentStepID != weqp.Step.Key.ToString())
                {
                    return(TimeSpan.FromSeconds(tactTime * unitQty));
                }

#if DEBUG
                //if (lot.LotID == "LOT10_3")
                //    Console.WriteLine();

                //if (FindHelper.GetNowDT().Hour == 22 && FindHelper.GetNowDT().Minute == 30)
                //    Console.WriteLine();

                var nowDt = FindHelper.GetNowDT();
                if (lot.LotID == "LOT10_9" && lot.Step.Key.ToString() == "S0300" && weqp.Target.EqpID == "DA01" && nowDt >= new DateTime(2018, 01, 26, 12, 00, 00))
                {
                    Console.WriteLine();
                }
#endif

                bool   isNeedSetup = false;
                double setupTime   = 0d;

                var 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;
                    }
                }

                double tactTimeWithSetup = setupTime + (tactTime * unitQty);
                return(TimeSpan.FromSeconds(tactTimeWithSetup));

                //return TimeSpan.FromSeconds(tactTime);
            }
            catch (Exception e)
            {
                WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
                return(default(TimeSpan));
            }
        }
Esempio n. 6
0
        /// <summary>
        /// </summary>
        /// <param name="wstep"/>
        /// <param name="wlot"/>
        /// <param name="handled"/>
        /// <param name="prevReturnValue"/>
        /// <returns/>
        public WorkLot UPDATE0(WorkStep wstep, WorkLot wlot, ref bool handled, WorkLot prevReturnValue)
        {
            try
            {
                MicronBEAssyBELot lot = wlot.Batch as MicronBEAssyBELot;

                bool isRun = JobChangeHelper.IsRun(lot);

                DateTime availableTime = FindHelper.GetNowDT();

                MicronBEAssyEqp eqp      = FindHelper.FindEquipment(lot.CurrentPlan.ResID);
                double          tactTime = SimulationHelper.GetTactTime(lot.LineID, lot.CurrentStepID, lot.Product.ProductID, eqp);

                StepTat stepTat = FindHelper.FindTAT(lot.Product.ProductID, lot.CurrentStepID, lot.LineID);

                if (isRun)
                {
#if DEBUG
                    //var nowDt = FindHelper.GetNowDT();

                    if (lot.LotID == "LOT11_1" && lot.CurrentStepID == "S0200")
                    {
                        Console.WriteLine();
                    }

                    //if (nowDt >= new DateTime(2018, 06, 12, 11, 40, 00))
                    //    Console.WriteLine();
#endif
                    double runTat = stepTat == null ? 0 : (double)stepTat.RUN_TAT;
#if DEBUG
                    if (runTat > 0)
                    {
                        Console.WriteLine();
                    }
#endif
                    availableTime = availableTime.AddSeconds(tactTime * lot.UnitQtyDouble + runTat);
                }
                else
                {
                    double waitTat = stepTat == null ? 0 : (double)stepTat.WAIT_TAT;

#if DEBUG
                    if (waitTat > 0)
                    {
                        Console.WriteLine();
                    }
#endif
                    availableTime = availableTime.AddSeconds(waitTat);
                }

                AoEquipment reservationEqp = isRun ? null : lot.ReservationEqp;

                MicronBEAssyWorkLot newWorkLot = CreateHelper.CreateWorkLot(wlot.Batch, availableTime, wstep.Key, wstep.Steps[0], reservationEqp);

                return(newWorkLot);
            }
            catch (Exception e)
            {
                WriteHelper.WriteErrorHistory(ErrorLevel.FATAL, string.Format("ErrorMessage : {0}   MethodName : {1}", e.Message, System.Reflection.MethodInfo.GetCurrentMethod().Name));
                return(default(WorkLot));
            }
        }
Esempio n. 7
0
        /// <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>));
            }
        }
Esempio n. 8
0
        /// <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));
            }
        }
Esempio n. 9
0
        /// <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();
            //}
        }