Example #1
0
        /// <summary>
        /// </summary>
        /// <param name="factory"/>
        /// <param name="hb"/>
        /// <param name="handled"/>
        public void LOCATE_FOR_RUN0(Mozart.SeePlan.Simulation.AoFactory factory, Mozart.SeePlan.Simulation.IHandlingBatch hb, ref bool handled)
        {
            var wipInitiator = ServiceLocator.Resolve <WipInitiator>();

            FabLot lot = hb.Sample as FabLot;

            string      eqpID = wipInitiator.GetLoadingEquipment(hb);
            AoEquipment aeqp  = factory.GetEquipment(eqpID);

            if (aeqp == null)
            {
                //If there is not Equipment, handle through Bucketing.
                factory.AddToBucketer(hb);
                Logger.Warn("Eqp {0} is invalid, so locate running wip to dummy bucket. check input data!", eqpID ?? "-");
            }
            else
            {
                //// Checks WIP state that is Run, but processing is completed and located in Outport.
                //bool trackOut = wipInitiator.CheckTrackOut(factory, hb);
                //if (trackOut)
                //{
                //    aeqp.AddOutBuffer(hb);
                //}
                //else
                //{
                //    aeqp.AddRun(hb);
                //}

                var eqp     = aeqp.Target as FabEqp;
                var runWips = eqp.InitRunWips;

                bool lastRunWip = runWips[runWips.Count - 1] == lot;
                if (eqp.State == ResourceState.Up && lastRunWip)
                {
                    MaskMaster.InitLocate(aeqp, hb);
                    JigMaster.InitLocate(aeqp, hb);

                    aeqp.AddRun(hb);                     //※초기Run재공은 OnTrackIn 이벤트 발생안함.
                }
                else
                {
                    DateTime tkInTime     = lot.Wip.LastTrackInTime;
                    var      procTimeInfo = aeqp.GetProcessTime(hb);
                    double   processTime  = procTimeInfo.FlowTime.TotalSeconds + (procTimeInfo.TactTime.TotalSeconds * (hb.UnitQty - 1));
                    DateTime tkOutTime    = tkInTime.AddSeconds(processTime);

                    Time delay = Time.Max((tkOutTime - aeqp.NowDT), Time.Zero);
                    if (delay > Time.Zero)
                    {
                        object[] args = new object[2] {
                            aeqp, hb
                        };
                        aeqp.AddTimeout(delay, SimHelper.OnEqpOutBuffer, args);
                        InFlowMaster.ChangeWipLocation(hb, EventType.TrackIn);

                        lot.CurrentPlan.LoadedResource = eqp;
                    }
                    else
                    {
                        aeqp.AddOutBuffer(hb);
                    }
                }
            }
        }