コード例 #1
0
ファイル: CalculateDuration.cs プロジェクト: farmwang/ABIPLC
        public static EqpSpanDuration Get30MKPI(string tagid)
        {
            EqpSpanDuration data = new EqpSpanDuration();

            try
            {
                data.TagID = tagid;
                SpanStatus span   = DTRecord.GetSpanTimeStatus(tagid, -30);
                bool       ISDown = true;
                if (span != null)
                {
                    if (span.Status == "Operating" || span.Status == "Lack" || span.Status == "Tailback")
                    {
                        data.Run = span.Duration;
                        ISDown   = false;
                    }
                    else
                    {
                        data.Down = span.Duration;
                    }
                }

                if (ISDown)
                {
                    data.Down = data.Down + DTRecord.GetDownTime(tagid, -30);
                    data.Run  = 30 - data.Down;
                }
                else
                {
                    data.Down = DTRecord.GetDownTime(tagid, -30);
                    data.Run  = 30 - data.Down;
                }

                data.KPI = data.Run / 30;
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
                data = null;
            }

            return(data);
        }
コード例 #2
0
ファイル: EqpKPI.cs プロジェクト: farmwang/ABIPLC
        public static void SetKPI()
        {
            EqpSpanDuration kpi = null;

            foreach (var P in Dic)
            {
                kpi = CalculateDuration.Get2MKPI(P.Key);
                if (kpi != null)
                {
                    P.Value.M2.Ex   = false;
                    P.Value.M2.Down = kpi.Down;
                    P.Value.M2.Run  = kpi.Run;
                    P.Value.M2.KPI  = kpi.KPI;
                }
                else
                {
                    P.Value.M2.Ex = true;
                }

                kpi = CalculateDuration.Get5MKPI(P.Key);
                if (kpi != null)
                {
                    P.Value.M5.Ex   = false;
                    P.Value.M5.Down = kpi.Down;
                    P.Value.M5.Run  = kpi.Run;
                    P.Value.M5.KPI  = kpi.KPI;
                }
                else
                {
                    P.Value.M5.Ex = true;
                }

                kpi = CalculateDuration.Get10MKPI(P.Key);
                if (kpi != null)
                {
                    P.Value.M10.Ex   = false;
                    P.Value.M10.Down = kpi.Down;
                    P.Value.M10.Run  = kpi.Run;
                    P.Value.M10.KPI  = kpi.KPI;
                }
                else
                {
                    P.Value.M10.Ex = true;
                }


                kpi = CalculateDuration.Get15MKPI(P.Key);
                if (kpi != null)
                {
                    P.Value.M15.Ex   = false;
                    P.Value.M15.Down = kpi.Down;
                    P.Value.M15.Run  = kpi.Run;
                    P.Value.M15.KPI  = kpi.KPI;
                }
                else
                {
                    P.Value.M15.Ex = true;
                }



                kpi = CalculateDuration.Get30MKPI(P.Key);
                if (kpi != null)
                {
                    P.Value.M30.Ex   = false;
                    P.Value.M30.Down = kpi.Down;
                    P.Value.M30.Run  = kpi.Run;
                    P.Value.M30.KPI  = kpi.KPI;
                }
                else
                {
                    P.Value.M30.Ex = true;
                }

                //kpi = CalculateDuration.Get60MKPI(P.Key);
                //if (kpi != null)
                //{
                //    P.Value.M60.Ex = false;
                //    P.Value.M60.Down = kpi.Down;
                //    P.Value.M60.Run = kpi.Run;
                //    P.Value.M60.KPI = kpi.KPI;
                //}
                //else
                //{
                //    P.Value.M60.Ex = true;
                //}

                CKPI[P.Key] = P.Value.M2.KPI * 0.2 + P.Value.M5.KPI * 0.2 + P.Value.M10.KPI * 0.2 + P.Value.M15.KPI * 0.2 + P.Value.M30.KPI * 0.2;
            }
        }