コード例 #1
0
        /// <summary>
        /// constructor Used for Termination chart.
        /// </summary>
        /// <param name="signalId"></param>
        /// <param name="starttime"></param>
        /// <param name="endtime"></param>
        /// <param name="consecutivecount"></param>
        public AnalysisPhaseCollection(string signalId, DateTime starttime, DateTime endtime, int consecutivecount)
        {
            MOE.Common.Models.Repositories.IControllerEventLogRepository cel = MOE.Common.Models.Repositories.ControllerEventLogRepositoryFactory.Create();



            List <Models.Controller_Event_Log> PTEDT = cel.GetSignalEventsByEventCodes(signalId, starttime, endtime, new List <int>()
            {
                1, 11, 4, 5, 6, 7, 21, 23
            });
            List <Models.Controller_Event_Log> DAPTA = cel.GetSignalEventsByEventCodes(signalId, starttime, endtime, new List <int>()
            {
                1
            });

            PTEDT.OrderByDescending(i => i.Timestamp);

            var PhasesInUse = (from r in DAPTA
                               where r.EventCode == 1
                               select r.EventParam).Distinct();



            Plans = new PlanCollection(starttime, endtime, signalId);


            foreach (int row in PhasesInUse)
            {
                //Business.AnalysisPhase aPhase = new AnalysisPhase(row.EventParam, starttime, endtime, PTEDT, consecutivecount);
                Business.AnalysisPhase aPhase = new AnalysisPhase(row, PTEDT, consecutivecount);

                Items.Add(aPhase);
            }
            OrderPhases();
            maxPhaseInUse = FindMaxPhase(Items);
        }
コード例 #2
0
ファイル: SplitMonitorOptions.cs プロジェクト: zfx1982/ATSPM
        private void AddSplitMonitorDataToChart(Chart chart, DateTime startDate,
                                                DateTime endDate, MOE.Common.Business.AnalysisPhase phase, string signalId, MOE.Common.Business.PlanCollection plans)
        {
            //Table
            if (phase.Cycles.Items.Count > 0)
            {
                plans.FillMissingSplits();
                int MaxSplitLength = 0;
                foreach (MOE.Common.Business.Plan plan in plans.PlanList)
                {
                    try
                    {
                        chart.Series["Programed Split"].Points.AddXY(plan.StartTime, plan.Splits[phase.PhaseNumber]);
                        chart.Series["Programed Split"].Points.AddXY(plan.EndTime, plan.Splits[phase.PhaseNumber]);

                        if (plan.Splits[phase.PhaseNumber] > MaxSplitLength)
                        {
                            MaxSplitLength = plan.Splits[phase.PhaseNumber];
                        }
                    }
                    catch
                    {
                        //System.Windows.MessageBox.Show(ex.ToString());
                    }
                }


                foreach (MOE.Common.Business.AnalysisPhaseCycle Cycle in phase.Cycles.Items)
                {
                    if (Cycle.TerminationEvent == 4)
                    {
                        chart.Series["GapOut"].Points.AddXY(Cycle.StartTime, Cycle.Duration.TotalSeconds);
                    }

                    if (Cycle.TerminationEvent == 5)
                    {
                        chart.Series["MaxOut"].Points.AddXY(Cycle.StartTime, Cycle.Duration.TotalSeconds);
                    }

                    if (Cycle.TerminationEvent == 6)
                    {
                        chart.Series["ForceOff"].Points.AddXY(Cycle.StartTime, Cycle.Duration.TotalSeconds);
                    }

                    if (Cycle.TerminationEvent == 0)
                    {
                        chart.Series["Unknown"].Points.AddXY(Cycle.StartTime, Cycle.Duration.TotalSeconds);
                    }

                    if (Cycle.HasPed && ShowPedActivity)
                    {
                        if (Cycle.PedDuration == 0)
                        {
                            if (Cycle.PedStartTime == DateTime.MinValue)
                            {
                                Cycle.SetPedStart(Cycle.StartTime);
                            }
                            if (Cycle.PedEndTime == DateTime.MinValue)
                            {
                                Cycle.SetPedEnd(Cycle.YellowEvent
                                                );
                            }
                        }
                        chart.Series["PedActivity"].Points.AddXY(Cycle.PedStartTime, Cycle.PedDuration);
                    }
                }
                if (MaxSplitLength > 0)
                {
                    if (MaxSplitLength >= 50)
                    {
                        chart.ChartAreas[0].AxisY.Maximum = (1.5 * MaxSplitLength);
                    }
                    else
                    {
                        chart.ChartAreas[0].AxisY.Maximum = (2.5 * MaxSplitLength);
                    }
                }
                if (YAxisMax != null)
                {
                    chart.ChartAreas[0].AxisY.Maximum = YAxisMax.Value;
                }
            }
        }
コード例 #3
0
ファイル: SplitMonitorOptions.cs プロジェクト: zfx1982/ATSPM
        private void SetSplitMonitorStatistics(MOE.Common.Business.PlanCollection plans, MOE.Common.Business.AnalysisPhase phase, Chart chart)
        {
            //find the phase Cycles that occure during the plan.


            foreach (MOE.Common.Business.Plan plan in plans.PlanList)
            {
                var Cycles = from cycle in phase.Cycles.Items
                             where cycle.StartTime > plan.StartTime && cycle.EndTime < plan.EndTime
                             orderby cycle.Duration
                             select cycle;

                // find % Skips
                if (ShowPercentSkip)
                {
                    if (plan.CycleCount > 0)
                    {
                        double CycleCount    = plan.CycleCount;
                        double SkippedPhases = (plan.CycleCount - Cycles.Count());
                        double SkipPercent   = 0;
                        if (CycleCount > 0)
                        {
                            SkipPercent = SkippedPhases / CycleCount;
                        }


                        CustomLabel skipLabel = new CustomLabel();
                        skipLabel.FromPosition = plan.StartTime.ToOADate();
                        skipLabel.ToPosition   = plan.EndTime.ToOADate();
                        skipLabel.Text         = string.Format("{0:0.0%} Skips", SkipPercent);
                        skipLabel.LabelMark    = LabelMarkStyle.LineSideMark;
                        skipLabel.ForeColor    = Color.Black;
                        skipLabel.RowIndex     = 1;
                        chart.ChartAreas[0].AxisX2.CustomLabels.Add(skipLabel);
                    }
                }

                // find % GapOuts
                if (ShowPercentGapOuts)
                {
                    var GapOuts = from cycle in Cycles
                                  where cycle.TerminationEvent == 4
                                  select cycle;

                    double CycleCount = plan.CycleCount;
                    double gapouts    = GapOuts.Count();
                    double GapPercent = 0;
                    if (CycleCount > 0)
                    {
                        GapPercent = gapouts / CycleCount;
                    }


                    CustomLabel gapLabel = new CustomLabel();
                    gapLabel.FromPosition = plan.StartTime.ToOADate();
                    gapLabel.ToPosition   = plan.EndTime.ToOADate();
                    gapLabel.Text         = string.Format("{0:0.0%} GapOuts", GapPercent);
                    gapLabel.LabelMark    = LabelMarkStyle.LineSideMark;
                    gapLabel.ForeColor    = Color.OliveDrab;
                    gapLabel.RowIndex     = 2;
                    chart.ChartAreas[0].AxisX2.CustomLabels.Add(gapLabel);
                }

                //Set Max Out
                if (ShowPercentMaxOutForceOff && plan.PlanNumber == 254)
                {
                    var MaxOuts = from cycle in Cycles
                                  where cycle.TerminationEvent == 5
                                  select cycle;

                    double CycleCount = plan.CycleCount;
                    double maxouts    = MaxOuts.Count();
                    double MaxPercent = 0;
                    if (CycleCount > 0)
                    {
                        MaxPercent = maxouts / CycleCount;
                    }


                    CustomLabel maxLabel = new CustomLabel();
                    maxLabel.FromPosition = plan.StartTime.ToOADate();
                    maxLabel.ToPosition   = plan.EndTime.ToOADate();
                    maxLabel.Text         = string.Format("{0:0.0%} MaxOuts", MaxPercent);
                    maxLabel.LabelMark    = LabelMarkStyle.LineSideMark;
                    maxLabel.ForeColor    = Color.Red;
                    maxLabel.RowIndex     = 3;
                    chart.ChartAreas[0].AxisX2.CustomLabels.Add(maxLabel);
                }

                // Set Force Off
                if (ShowPercentMaxOutForceOff && plan.PlanNumber != 254
                    )
                {
                    var ForceOffs = from cycle in Cycles
                                    where cycle.TerminationEvent == 6
                                    select cycle;

                    double CycleCount   = plan.CycleCount;
                    double forceoffs    = ForceOffs.Count();
                    double ForcePercent = 0;
                    if (CycleCount > 0)
                    {
                        ForcePercent = forceoffs / CycleCount;
                    }


                    CustomLabel forceLabel = new CustomLabel();
                    forceLabel.FromPosition = plan.StartTime.ToOADate();
                    forceLabel.ToPosition   = plan.EndTime.ToOADate();
                    forceLabel.Text         = string.Format("{0:0.0%} ForceOffs", ForcePercent);
                    forceLabel.LabelMark    = LabelMarkStyle.LineSideMark;
                    forceLabel.ForeColor    = Color.MediumBlue;
                    forceLabel.RowIndex     = 3;
                    chart.ChartAreas[0].AxisX2.CustomLabels.Add(forceLabel);
                }

                //Average Split
                if (ShowAverageSplit)
                {
                    double runningTotal  = 0;
                    double averageSplits = 0;
                    foreach (MOE.Common.Business.AnalysisPhaseCycle Cycle in Cycles)
                    {
                        runningTotal = runningTotal + Cycle.Duration.TotalSeconds;
                    }

                    if (Cycles.Count() > 0)
                    {
                        averageSplits = runningTotal / Cycles.Count();
                    }



                    CustomLabel avgLabel = new CustomLabel();
                    avgLabel.FromPosition = plan.StartTime.ToOADate();
                    avgLabel.ToPosition   = plan.EndTime.ToOADate();
                    avgLabel.Text         = string.Format("{0: 0.0} Avg. Split", averageSplits);
                    avgLabel.LabelMark    = LabelMarkStyle.LineSideMark;
                    avgLabel.ForeColor    = Color.Black;
                    avgLabel.RowIndex     = 4;
                    chart.ChartAreas[0].AxisX2.CustomLabels.Add(avgLabel);

                    //Percentile Split
                    if (SelectedPercentileSplit != null && (Cycles.Count() > 2))
                    {
                        Double percentileResult = 0;
                        Double Percentile       = (Convert.ToDouble(SelectedPercentileSplit) / 100);
                        int    setCount         = Cycles.Count();



                        Double PercentilIndex = Percentile * setCount;
                        if (PercentilIndex % 1 == 0)
                        {
                            percentileResult = Cycles.ElementAt((Convert.ToInt16(PercentilIndex) - 1)).Duration.TotalSeconds;
                        }
                        else
                        {
                            double indexMod = (PercentilIndex % 1);
                            //subtracting .5 leaves just the integer after the convert.
                            //There was probably another way to do that, but this is easy.
                            int indexInt = Convert.ToInt16(PercentilIndex - .5);

                            Double step1    = Cycles.ElementAt((Convert.ToInt16(indexInt) - 1)).Duration.TotalSeconds;
                            Double step2    = Cycles.ElementAt((Convert.ToInt16(indexInt))).Duration.TotalSeconds;
                            Double stepDiff = (step2 - step1);
                            Double step3    = (stepDiff * indexMod);
                            percentileResult = (step1 + step3);
                        }

                        CustomLabel percentileLabel = new CustomLabel();
                        percentileLabel.FromPosition = plan.StartTime.ToOADate();
                        percentileLabel.ToPosition   = plan.EndTime.ToOADate();
                        percentileLabel.Text         = string.Format("{0: 0.0} - {1} Percentile Split", percentileResult, Convert.ToDouble(SelectedPercentileSplit));
                        percentileLabel.LabelMark    = LabelMarkStyle.LineSideMark;
                        percentileLabel.ForeColor    = Color.Purple;
                        percentileLabel.RowIndex     = 5;
                        chart.ChartAreas[0].AxisX2.CustomLabels.Add(percentileLabel);
                    }
                }
            }
        }