Beispiel #1
0
        public static List <CycleSplitFail> GetSplitFailCycles(SplitFailOptions options, Approach approach,
                                                               bool getPermissivePhase, SPM db)
        {
            var cycleEvents = GetCycleEvents(getPermissivePhase, options.StartDate, options.EndDate, approach, db);

            if (cycleEvents != null && cycleEvents.Count > 0 && GetEventType(cycleEvents.LastOrDefault().EventCode) !=
                RedToRedCycle.EventType.ChangeToGreen)
            {
                GetEventsToCompleteCycle(getPermissivePhase, options.EndDate, approach, cycleEvents);
            }
            var terminationEvents =
                GetTerminationEvents(getPermissivePhase, options.StartDate, options.EndDate, approach);
            var cycles = new List <CycleSplitFail>();

            for (var i = 0; i < cycleEvents.Count - 3; i++)
            {
                if (GetEventType(cycleEvents[i].EventCode) == RedToRedCycle.EventType.ChangeToGreen &&
                    GetEventType(cycleEvents[i + 1].EventCode) == RedToRedCycle.EventType.ChangeToYellow &&
                    GetEventType(cycleEvents[i + 2].EventCode) == RedToRedCycle.EventType.ChangeToRed &&
                    (GetEventType(cycleEvents[i + 3].EventCode) == RedToRedCycle.EventType.ChangeToGreen || cycleEvents[i + 3].EventCode == 66))
                {
                    var termEvent = GetTerminationEventBetweenStartAndEnd(cycleEvents[i].Timestamp,
                                                                          cycleEvents[i + 3].Timestamp, terminationEvents);
                    cycles.Add(new CycleSplitFail(cycleEvents[i].Timestamp, cycleEvents[i + 2].Timestamp,
                                                  cycleEvents[i + 1].Timestamp, cycleEvents[i + 3].Timestamp, termEvent,
                                                  options.FirstSecondsOfRed));
                    //i = i + 2;
                }
            }
            return(cycles);
        }
Beispiel #2
0
        private void SetDetectorActivations(SplitFailOptions options, SPM db)
        {
            var controllerEventsRepository = ControllerEventLogRepositoryFactory.Create(db);
            var phaseNumber = GetPermissivePhase ? Approach.PermissivePhaseNumber.Value : Approach.ProtectedPhaseNumber;
            var detectors   = Approach.GetAllDetectorsOfDetectionType(6);// .GetDetectorsForMetricType(12);

            foreach (var detector in detectors)
            {
                //var lastCycle = Cycles.OrderBy(c => c.StartTime).LastOrDefault();
                List <Models.Controller_Event_Log> events = controllerEventsRepository.GetEventsByEventCodesParamWithLatencyCorrection(Approach.SignalID,
                                                                                                                                       options.StartDate, options.EndDate, new List <int> {
                    81, 82
                }, detector.DetChannel, detector.LatencyCorrection);
                if (!events.Any())
                {
                    CheckForDetectorOnBeforeStart(options, controllerEventsRepository, detector);
                }
                else
                {
                    AddDetectorOnToBeginningIfNecessary(options, detector, events);
                    AddDetectorOffToEndIfNecessary(options, detector, events);
                    AddDetectorActivationsFromList(events);
                }
            }
            CombineDetectorActivations();
        }
Beispiel #3
0
        public void SplitFailPhaseTest()
        {
            SplitFailOptions splitFailOptions = new SplitFailOptions {
                StartDate = new DateTime(2017, 10, 17, 17, 0, 0), EndDate = new DateTime(2017, 10, 17, 17, 11, 1), FirstSecondsOfRed = 5, SignalID = "7185", MetricTypeID = 12, ShowAvgLines = true, ShowPercentFailLines = true, ShowFailLines = true, Y2AxisMax = null, YAxisMin = 0, Y2AxisMin = 0, YAxisMax = null
            };
            var            signalRepository = SignalsRepositoryFactory.Create();
            var            signal           = signalRepository.GetLatestVersionOfSignalBySignalID("7185");
            var            approach         = signal.Approaches.Where(a => a.ApproachID == 5593).FirstOrDefault();
            SplitFailPhase splitFailPhase   = new SplitFailPhase(approach, splitFailOptions, true);

            Assert.IsTrue(splitFailPhase.Cycles[4].StartTime == new DateTime(2017, 10, 17, 17, 9, 33));
            Assert.IsTrue(splitFailPhase.Cycles[4].YellowEvent == new DateTime(2017, 10, 17, 17, 10, 09));
            Assert.IsTrue(splitFailPhase.Cycles[4].RedEvent == new DateTime(2017, 10, 17, 17, 10, 13));
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen.Count == 2);
            DateTime date1 = new DateTime(2017, 10, 17, 17, 1, 59, 500);

            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[0].DetectorOn == date1);
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[0].DetectorOff == new DateTime(2017, 10, 17, 17, 9, 43, 800));
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[0].DurationInMilliseconds == 464300);
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[1].DetectorOn == new DateTime(2017, 10, 17, 17, 9, 55, 400));
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[1].DetectorOff == new DateTime(2017, 10, 17, 17, 10, 6, 300));
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[1].DurationInMilliseconds == 10900);
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed.Count == 1);
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed[0].DetectorOn == new DateTime(2017, 10, 17, 17, 10, 9, 200));
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed[0].DetectorOff == new DateTime(2017, 10, 17, 17, 10, 13, 300));
            Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed[0].DurationInMilliseconds == 4100);
            Assert.IsTrue(splitFailPhase.Cycles[4].GreenOccupancyTimeInMilliseconds == 21700.0);
            Assert.IsTrue(splitFailPhase.Cycles[4].TotalGreenTimeMilliseconds == 36000.0);
            Assert.IsTrue(splitFailPhase.Cycles[4].RedOccupancyTimeInMilliseconds == 300.0);
            Assert.IsTrue(splitFailPhase.Cycles[4].RedOccupancyPercent == 6.0);
            Assert.IsTrue(splitFailPhase.Cycles[4].FirstSecondsOfRed == 5);
            Assert.IsTrue(Math.Round(splitFailPhase.Cycles[4].GreenOccupancyPercent) == 60.0);
        }
Beispiel #4
0
 public SplitFailChart(SplitFailOptions options, SplitFailPhase splitFailPhase, bool getPermissivePhase)
 {
     Options            = options;
     SplitFailPhase     = splitFailPhase;
     GetPermissivePhase = getPermissivePhase;
     Chart = ChartFactory.CreateSplitFailureChart(Options);
     AddSeries(Chart);
     AddDataToChart(Chart);
 }
Beispiel #5
0
        public static Chart CreateSplitFailureChart(SplitFailOptions options)
        {
            var chart = new Chart();

            SetImageProperties(chart);
            chart.ChartAreas.Add(CreateSplitFailChartArea(options));
            SetLegend(chart);
            return(chart);
        }
Beispiel #6
0
        private static ChartArea CreateSplitFailChartArea(SplitFailOptions options)
        {
            var chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";
            SetSplitFailYAxis(chartArea, options);
            SetUpXAxis(chartArea, options);
            SetSplitFailPassX2Axis(chartArea, options);
            return(chartArea);
        }
Beispiel #7
0
        public void CreateMetricTest()
        {
            string   signalId = "7185";
            DateTime start    = Convert.ToDateTime("10/17/2017 17:00:00");
            DateTime end      = Convert.ToDateTime("10/17/2017 18:00:00");

            SplitFailOptions sfo  = new SplitFailOptions(signalId, start, end, 12, 5, true, true, false);
            List <string>    path = sfo.CreateMetric();

            Assert.IsTrue(path.Count > 0);
        }
Beispiel #8
0
        private void SetBinStatistics(SplitFailOptions options)
        {
            var startTime = options.StartDate;

            do
            {
                var endTime = startTime.AddMinutes(15);
                var cycles  = Cycles.Where(c => c.StartTime >= startTime && c.StartTime < endTime).ToList();
                Bins.Add(new SplitFailBin(startTime, endTime, cycles));
                startTime = startTime.AddMinutes(15);
            } while (startTime < options.EndDate);
        }
Beispiel #9
0
 public SplitFailPhase(Approach approach, SplitFailOptions options, bool getPermissivePhase)
 {
     Approach           = approach;
     GetPermissivePhase = getPermissivePhase;
     Cycles             = CycleFactory.GetSplitFailCycles(options, approach, getPermissivePhase);
     SetDetectorActivations(options);
     AddDetectorActivationsToCycles();
     Plans      = PlanFactory.GetSplitFailPlans(Cycles, options, Approach);
     TotalFails = Cycles.Count(c => c.IsSplitFail);
     Statistics = new Dictionary <string, string>();
     Statistics.Add("Total Split Failures", TotalFails.ToString());
     SetBinStatistics(options);
 }
Beispiel #10
0
        public void SplitFailChartSplitFailChartTest()
        {
            string   signalId         = "6311".ToString();
            DateTime startTime        = global::System.Convert.ToDateTime("01/01/2014 2:00 AM");
            DateTime endTime          = global::System.Convert.ToDateTime("1/1/2014 2:00 PM");
            int      metricId         = 12;
            int      firstSecondOfRed = 23;

            SplitFailOptions options = new SplitFailOptions(signalId, startTime, endTime, metricId, firstSecondOfRed, false, false, false);


            global::Microsoft.VisualStudio.TestTools.UnitTesting.Assert.Fail();
        }
Beispiel #11
0
 private static void SetSplitFailYAxis(ChartArea chartArea, SplitFailOptions options)
 {
     if (options.YAxisMax != null)
     {
         chartArea.AxisY.Maximum = options.YAxisMax.Value;
     }
     else
     {
         chartArea.AxisY.Maximum = 100;
     }
     chartArea.AxisY.Title    = "Occupancy Ratio (percent)";
     chartArea.AxisY.Minimum  = 0;
     chartArea.AxisY.Interval = 10;
 }
Beispiel #12
0
 private static void AddDetectorOffToEndIfNecessary(SplitFailOptions options, Models.Detector detector,
                                                    List <Controller_Event_Log> events)
 {
     if (events.LastOrDefault()?.EventCode == 82)
     {
         events.Insert(events.Count, new Controller_Event_Log
         {
             Timestamp  = options.EndDate,
             EventCode  = 81,
             EventParam = detector.DetChannel,
             SignalID   = options.SignalID
         });
     }
 }
Beispiel #13
0
 private static void AddDetectorOnToBeginningIfNecessary(SplitFailOptions options, Models.Detector detector,
                                                         List <Controller_Event_Log> events)
 {
     if (events.FirstOrDefault()?.EventCode == 81)
     {
         events.Insert(0, new Controller_Event_Log
         {
             Timestamp  = options.StartDate,
             EventCode  = 82,
             EventParam = detector.DetChannel,
             SignalID   = options.SignalID
         });
     }
 }
Beispiel #14
0
        public SplitFailPhase(Approach approach, SplitFailOptions options, bool getPermissivePhase)
        {
            Approach           = approach;
            GetPermissivePhase = getPermissivePhase;
            PhaseNumberSort    = getPermissivePhase ? approach.PermissivePhaseNumber.Value.ToString() + "-1": approach.ProtectedPhaseNumber.ToString() + "-2";

            using (var db = new SPM())
            {
                Cycles = CycleFactory.GetSplitFailCycles(options, approach, getPermissivePhase, db);
                SetDetectorActivations(options, db);
                AddDetectorActivationsToCycles();
                Plans = PlanFactory.GetSplitFailPlans(Cycles, options, Approach, db);
            }
            TotalFails = Cycles.Count(c => c.IsSplitFail);
            Statistics = new Dictionary <string, string>();
            Statistics.Add("Total Split Failures", TotalFails.ToString());
            SetBinStatistics(options);
        }
Beispiel #15
0
        private void CheckForDetectorOnBeforeStart(SplitFailOptions options,
                                                   IControllerEventLogRepository controllerEventsRepository, Models.Detector detector)
        {
            var eventOnBeforeStart = controllerEventsRepository.GetFirstEventBeforeDateByEventCodeAndParameter(
                options.SignalID,
                detector.DetChannel, 81, options.StartDate);
            var eventOffBeforeStart = controllerEventsRepository.GetFirstEventBeforeDateByEventCodeAndParameter(
                options.SignalID,
                detector.DetChannel, 82, options.StartDate);

            if (eventOnBeforeStart != null && eventOffBeforeStart == null)
            {
                _detectorActivations.Add(new SplitFailDetectorActivation
                {
                    DetectorOn  = options.StartDate,
                    DetectorOff = options.EndDate
                });
            }
        }
Beispiel #16
0
        private static void SetSplitFailXAxis(ChartArea chartArea, SplitFailOptions options)
        {
            var reportTimespan = options.EndDate - options.StartDate;

            chartArea.AxisX.Title             = "Time (Hour of Day)";
            chartArea.AxisX.IntervalType      = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format = "HH";
            chartArea.AxisX.Minimum           = options.StartDate.ToOADate();
            chartArea.AxisX.Maximum           = options.EndDate.ToOADate();
            if (reportTimespan.Days < 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    chartArea.AxisX.Interval = 1;
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Format = "HH:mm";
                }
            }
        }
Beispiel #17
0
        private static void SetSplitFailX2Axis(ChartArea chartArea, SplitFailOptions options)
        {
            var reportTimespan = options.EndDate - options.StartDate;

            chartArea.AxisX2.LabelStyle.Format = "HH";
            if (reportTimespan.Days < 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    chartArea.AxisX2.Interval = 1;
                }
                else
                {
                    chartArea.AxisX2.LabelStyle.Format = "HH:mm";
                }
            }
            chartArea.AxisX2.Minimum = options.StartDate.ToOADate();
            chartArea.AxisX2.Maximum = options.EndDate.ToOADate();
            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;
            chartArea.AxisX2.IntervalType          = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelAutoFitStyle     = LabelAutoFitStyles.None;
        }
Beispiel #18
0
        public void SplitFailDataAggregationTest()
        {
            var startTime = new DateTime(2014, 1, 1);
            var endTime   = new DateTime(2014, 1, 1, 0, 15, 0);
            var splitFailAggregateRepository = MOE.Common.Models.Repositories.ApproachSplitFailAggregationRepositoryFactory.Create();
            var splitFails = splitFailAggregateRepository.GetApproachSplitFailsAggregationByApproachIdAndDateRange(4971,
                                                                                                                   startTime, endTime, true);

            var signalRepository = SignalsRepositoryFactory.Create();
            var signal           = signalRepository.GetLatestVersionOfSignalBySignalID("5078");
            var approach         = signal.Approaches.Where(s => s.ApproachID == 4971).FirstOrDefault();

            var splitFailOptions = new SplitFailOptions
            {
                FirstSecondsOfRed = 5,
                StartDate         = startTime,
                EndDate           = endTime,
                MetricTypeID      = 12
            };
            var splitFailPhase = new SplitFailPhase(approach, splitFailOptions, true);

            Assert.IsTrue(splitFails.FirstOrDefault().SplitFailures == splitFailPhase.TotalFails);
        }
Beispiel #19
0
        //public static List<Plan> GetSplitMonitorlans(List<Models.Controller_Event_Log> cycleEvents,
        //    List<Models.Controller_Event_Log> detectorEvents, DateTime startdate,
        //    DateTime enddate, Models.Approach approach, List<Models.Controller_Event_Log> preemptEvents)
        //{
        //    return new List<Plan>();
        //}

        //public PlanCollection(DateTime startdate,
        //    DateTime enddate, string signalId)
        //{
        //    GetSimplePlanCollection(startdate, enddate, signalId);
        //}

        //public void GetPlanCollection(DateTime startDate, DateTime endDate,
        //    List<Models.Controller_Event_Log> cycleEvents,
        //    List<Models.Controller_Event_Log> detectorEvents,
        //    List<Models.Controller_Event_Log> preemptEvents)
        //{
        //    MOE.Common.Business.PlansBase ds = new PlansBase(Approach.SignalID, startDate, endDate);

        //    for (int i = 0; i < ds.Events.Count; i++)
        //    {
        //        //if this is the last plan then we want the end of the plan
        //        //to cooincide with the end of the graph
        //        if (ds.Events.Count - 1 == i)
        //        {
        //            if (ds.Events[i].Timestamp != endDate)
        //            {
        //                //Plan plan = new Plan(ds.Events[i].Timestamp, endDate, ds.Events[i].EventParam,
        //                //    cycleEvents, detectorEvents, preemptEvents, Approach);
        //                //this.AddItem(plan);
        //            }
        //        }
        //        //else we add the plan with the next plans' time stamp as the end of the plan
        //        else
        //        {
        //            if (ds.Events[i].Timestamp != ds.Events[i + 1].Timestamp)
        //            {
        //                //Plan plan = new Plan(ds.Events[i].Timestamp, ds.Events[i + 1].Timestamp,
        //                //    ds.Events[i].EventParam, cycleEvents, detectorEvents, preemptEvents, Approach);
        //                //this.AddItem(plan);
        //            }

        //        }
        //    }
        //}

        //public void LinkPivotAddDetectorData(List<Models.Controller_Event_Log> detectorEvents)
        //{

        //    foreach (Plan plan in this.PlanList)
        //    {
        //        plan.LinkPivotAddDetectorData(detectorEvents);
        //    }
        //}

        //public void GetSimplePlanCollection(DateTime startDate, DateTime endDate, string signalId)
        //{

        //    MOE.Common.Business.PlansBase ds = new PlansBase(signalId, startDate, endDate);


        //    for (int i = 0; i < ds.Events.Count; i++)
        //    {
        //        //if this is the last plan then we want the end of the plan
        //        //to cooincide with the end of the graph
        //        if (ds.Events.Count - 1 == i)
        //        {
        //            if (ds.Events[i].Timestamp != endDate)
        //            {
        //                Plan plan = new Plan(ds.Events[i].Timestamp, endDate, ds.Events[i].EventParam);
        //                this.AddItem(plan);
        //            }
        //        }
        //        //else we add the plan with the next plans' time stamp as the end of the plan
        //        else
        //        {
        //            if (ds.Events[i].Timestamp != ds.Events[i + 1].Timestamp)
        //            {
        //                Plan plan = new Plan(ds.Events[i].Timestamp, ds.Events[i + 1].Timestamp, ds.Events[i].EventParam);
        //                this.AddItem(plan);
        //            }

        //        }
        //    }
        //}

        //public void FillMissingSplits()
        //{
        //    int highestSplit = 0;
        //    foreach (Business.Plan plan in PlanList)
        //    {
        //        int testSplit = plan.FindHighestRecordedSplitPhase();
        //        if (highestSplit < testSplit)
        //        {
        //            highestSplit = testSplit;
        //        }
        //    }

        //    foreach (Business.Plan plan in PlanList)
        //    {
        //        plan.FillMissingSplits(highestSplit);
        //    }
        //}
        //public void AddItem(Plan item)
        //{
        //    this.PlanList.Add(item);
        //}

        //public static void SetSimplePlanStrips(PlanCollection PlanCollection, Chart Chart, DateTime StartDate, ControllerEventLogs EventLog)
        //{
        //    int backGroundColor = 1;
        //    foreach (MOE.Common.Business.Plan plan in PlanCollection.PlanList)
        //    {
        //        StripLine stripline = new StripLine();
        //        //Creates alternating backcolor to distinguish the plans
        //        if (backGroundColor % 2 == 0)
        //        {
        //            stripline.BackColor = Color.FromArgb(120, Color.LightGray);
        //        }
        //        else
        //        {
        //            stripline.BackColor = Color.FromArgb(120, Color.LightBlue);
        //        }

        //        //Set the stripline properties
        //        stripline.IntervalOffsetType = DateTimeIntervalType.Hours;
        //        stripline.Interval = 1;
        //        stripline.IntervalOffset = (plan.StartTime - StartDate).TotalHours;
        //        stripline.StripWidth = (plan.EndTime - plan.StartTime).TotalHours;
        //        stripline.StripWidthType = DateTimeIntervalType.Hours;

        //        Chart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripline);

        //        //Add a corrisponding custom label for each strip
        //        CustomLabel Plannumberlabel = new CustomLabel();
        //        Plannumberlabel.FromPosition = plan.StartTime.ToOADate();
        //        Plannumberlabel.ToPosition = plan.EndTime.ToOADate();
        //        switch (plan.PlanNumber)
        //        {
        //            case 254:
        //                Plannumberlabel.Text = "Free";
        //                break;
        //            case 255:
        //                Plannumberlabel.Text = "Flash";
        //                break;
        //            case 0:
        //                Plannumberlabel.Text = "Unknown";
        //                break;
        //            default:
        //                Plannumberlabel.Text = "Plan " + plan.PlanNumber.ToString();

        //                break;
        //        }
        //        Plannumberlabel.LabelMark = LabelMarkStyle.LineSideMark;
        //        Plannumberlabel.ForeColor = Color.Black;
        //        Plannumberlabel.RowIndex = 6;


        //        Chart.ChartAreas[0].AxisX2.CustomLabels.Add(Plannumberlabel);

        //        CustomLabel planPreemptsLabel = new CustomLabel();
        //        planPreemptsLabel.FromPosition = plan.StartTime.ToOADate();
        //        planPreemptsLabel.ToPosition = plan.EndTime.ToOADate();

        //        var c = from MOE.Common.Models.Controller_Event_Log r in EventLog.Events
        //                where r.EventCode == 107 && r.Timestamp > plan.StartTime && r.Timestamp < plan.EndTime
        //                select r;


        //        string premptCount = c.Count().ToString();
        //        planPreemptsLabel.Text = "Preempts Serviced During Plan: " + premptCount;
        //        planPreemptsLabel.LabelMark = LabelMarkStyle.LineSideMark;
        //        planPreemptsLabel.ForeColor = Color.Red;
        //        planPreemptsLabel.RowIndex = 7;

        //        Chart.ChartAreas[0].AxisX2.CustomLabels.Add(planPreemptsLabel);

        //        backGroundColor++;

        //    }
        //}

        //public static void SetSimplePlanStrips(MOE.Common.Business.PlanCollection planCollection, Chart chart, DateTime graphStartDate)
        //{
        //    int backGroundColor = 1;
        //    foreach (MOE.Common.Business.Plan plan in planCollection.PlanList)
        //    {
        //        StripLine stripline = new StripLine();
        //        //Creates alternating backcolor to distinguish the plans
        //        if (backGroundColor % 2 == 0)
        //        {
        //            stripline.BackColor = Color.FromArgb(120, Color.LightGray);
        //        }
        //        else
        //        {
        //            stripline.BackColor = Color.FromArgb(120, Color.LightBlue);
        //        }

        //        //Set the stripline properties
        //        stripline.IntervalOffsetType = DateTimeIntervalType.Hours;
        //        stripline.Interval = 1;
        //        stripline.IntervalOffset = (plan.StartTime - graphStartDate).TotalHours;
        //        stripline.StripWidth = (plan.EndTime - plan.StartTime).TotalHours;
        //        stripline.StripWidthType = DateTimeIntervalType.Hours;

        //        chart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripline);

        //        //Add a corrisponding custom label for each strip
        //        CustomLabel Plannumberlabel = new CustomLabel();
        //        Plannumberlabel.FromPosition = plan.StartTime.ToOADate();
        //        Plannumberlabel.ToPosition = plan.EndTime.ToOADate();
        //        switch (plan.PlanNumber)
        //        {
        //            case 254:
        //                Plannumberlabel.Text = "Free";
        //                break;
        //            case 255:
        //                Plannumberlabel.Text = "Flash";
        //                break;
        //            case 0:
        //                Plannumberlabel.Text = "Unknown";
        //                break;
        //            default:
        //                Plannumberlabel.Text = "Plan " + plan.PlanNumber.ToString();

        //                break;
        //        }
        //        Plannumberlabel.LabelMark = LabelMarkStyle.LineSideMark;
        //        Plannumberlabel.ForeColor = Color.Black;
        //        Plannumberlabel.RowIndex = 6;


        //        chart.ChartAreas["ChartArea1"].AxisX2.CustomLabels.Add(Plannumberlabel);


        //        backGroundColor++;

        //    }


        //}
        public static List <PlanSplitFail> GetSplitFailPlans(List <CycleSplitFail> cycles, SplitFailOptions options,
                                                             Approach approach)
        {
            var planEvents = GetPlanEvents(options.StartDate, options.EndDate, approach.SignalID);
            var plans      = new List <PlanSplitFail>();

            for (var i = 0; i < planEvents.Count; i++)
            {
                if (planEvents.Count - 1 == i)
                {
                    if (planEvents[i].Timestamp != options.EndDate)
                    {
                        var planCycles = cycles.Where(c =>
                                                      c.StartTime >= planEvents[i].Timestamp && c.StartTime < options.EndDate).ToList();
                        plans.Add(new PlanSplitFail(planEvents[i].Timestamp, options.EndDate, planEvents[i].EventParam,
                                                    planCycles));
                    }
                }
                else
                {
                    if (planEvents[i].Timestamp != planEvents[i + 1].Timestamp)
                    {
                        var planCycles = cycles.Where(c =>
                                                      c.StartTime >= planEvents[i].Timestamp && c.StartTime < planEvents[i + 1].Timestamp)
                                         .ToList();
                        plans.Add(new PlanSplitFail(planEvents[i].Timestamp, planEvents[i + 1].Timestamp,
                                                    planEvents[i].EventParam, planCycles));
                    }
                }
            }
            return(plans);
        }