Exemplo n.º 1
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));
            }
        }