Ejemplo n.º 1
0
        private void CheckAllSignals(List <Models.Signal> signals)
        {
            var startHour     = new TimeSpan(Settings.ScanDayStartHour, 0, 0);
            var endHour       = new TimeSpan(Settings.ScanDayEndHour, 0, 0);
            var AnalysisStart = ScanDate.Date + startHour;
            var AnalysisEnd   = ScanDate.Date + endHour;
            var options       = new ParallelOptions();

            options.MaxDegreeOfParallelism = Settings.MaxDegreeOfParallelism;

            Parallel.ForEach(signals, options, signal =>
                             //foreach(var signal in signals)
            {
                var APcollection =
                    new AnalysisPhaseCollection(signal.SignalID,
                                                AnalysisStart, AnalysisEnd, Settings.ConsecutiveCount);

                foreach (var phase in APcollection.Items)
                //Parallel.ForEach(APcollection.Items, options,phase =>
                {
                    CheckForMaxOut(phase, signal);
                    CheckForForceOff(phase, signal);
                    CheckForStuckPed(phase, signal);
                }
                // );
            });
        }
Ejemplo n.º 2
0
        protected void AddTermEventDataToChart(Chart chart, DateTime startDate,
                                               DateTime endDate, AnalysisPhaseCollection analysisPhaseCollection,
                                               string signalId, bool showVolume, bool showPlanStripes)
        {
            foreach (var phase in analysisPhaseCollection.Items)
            {
                if (phase.TerminationEvents.Count > 0)
                {
                    foreach (var TermEvent in phase.ConsecutiveGapOuts)
                    {
                        chart.Series["GapOut"].Points.AddXY(TermEvent.Timestamp, phase.PhaseNumber);
                    }

                    foreach (var TermEvent in phase.ConsecutiveMaxOut)
                    {
                        chart.Series["MaxOut"].Points.AddXY(TermEvent.Timestamp, phase.PhaseNumber);
                    }

                    foreach (var TermEvent in phase.ConsecutiveForceOff)
                    {
                        chart.Series["ForceOff"].Points.AddXY(TermEvent.Timestamp, phase.PhaseNumber);
                    }

                    foreach (var TermEvent in phase.UnknownTermination)
                    {
                        chart.Series["Unknown"].Points.AddXY(TermEvent.Timestamp, phase.PhaseNumber);
                    }

                    if (ShowPedActivity)
                    {
                        foreach (var PedEvent in phase.PedestrianEvents)
                        {
                            if (PedEvent.EventCode == 23)
                            {
                                chart.Series["Ped Walk Begin"].Points.AddXY(PedEvent.Timestamp, phase.PhaseNumber + .3);
                            }
                        }
                    }
                }
                if (showPlanStripes)
                {
                    SetSimplePlanStrips(analysisPhaseCollection.Plans, chart, startDate);
                }
                if (YAxisMax != null)
                {
                    chart.ChartAreas[0].AxisY.Maximum = YAxisMax.Value + .5;
                }
            }
        }
Ejemplo n.º 3
0
        public override List <string> CreateMetric()
        {
            base.CreateMetric();
            var location = GetSignalLocation();
            var chart    = ChartFactory.CreateDefaultChartNoX2Axis(this);

            CreateLegend();
            var analysisPhaseCollection =
                new AnalysisPhaseCollection(SignalID, StartDate,
                                            EndDate, SelectedConsecutiveCount);

            //If there are phases in the collection add the charts
            if (analysisPhaseCollection.Items.Count > 0)
            {
                chart = GetNewTermEventChart(StartDate, EndDate, SignalID, location,
                                             SelectedConsecutiveCount, analysisPhaseCollection.MaxPhaseInUse, ShowPedActivity);

                AddTermEventDataToChart(chart, StartDate, EndDate, analysisPhaseCollection, SignalID,
                                        ShowPedActivity, ShowPlanStripes);
            }

            var chartName   = CreateFileName();
            var removethese = new List <Title>();

            foreach (var t in chart.Titles)
            {
                if (t.Text == "" || t.Text == null)
                {
                    removethese.Add(t);
                }
            }
            foreach (var t in removethese)
            {
                chart.Titles.Remove(t);
            }

            //Save an image of the chart
            chart.SaveImage(MetricFileLocation + chartName, ChartImageFormat.Jpeg);

            ReturnList.Add(MetricWebPath + chartName);

            return(ReturnList);
        }
Ejemplo n.º 4
0
        private void CheckAllSignals(List <Models.Signal> signals)
        {
            var startHour     = new TimeSpan(Settings.ScanDayStartHour, 0, 0);
            var endHour       = new TimeSpan(Settings.ScanDayEndHour, 0, 0);
            var AnalysisStart = ScanDate.Date + startHour;
            var AnalysisEnd   = ScanDate.Date + endHour;
            var options       = new ParallelOptions();

            options.MaxDegreeOfParallelism = Settings.MaxDegreeOfParallelism;

            //Parallel.ForEach(signals, options, signal =>
            foreach (var signal in signals)
            {
                AnalysisPhaseCollection APcollection = null;
                try
                {
                    APcollection =
                        new AnalysisPhaseCollection(signal.SignalID,
                                                    AnalysisStart, AnalysisEnd, Settings.ConsecutiveCount);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Unable to get analysis phase for signal " + signal.SignalID);
                }

                if (APcollection != null)
                {
                    foreach (var phase in APcollection.Items)
                    //Parallel.ForEach(APcollection.Items, options,phase =>
                    {
                        try
                        {
                            CheckForMaxOut(phase, signal);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(phase.SignalID + " " + phase.PhaseNumber + " - Max Out Error " +
                                              e.Message);
                        }

                        try
                        {
                            CheckForForceOff(phase, signal);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(phase.SignalID + " " + phase.PhaseNumber + " - Force Off Error " +
                                              e.Message);
                        }

                        try
                        {
                            CheckForStuckPed(phase, signal);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(phase.SignalID + " " + phase.PhaseNumber + " - Stuck Ped Error " +
                                              e.Message);
                        }
                    }
                }

                //);
            }//);
        }
Ejemplo n.º 5
0
        public override List <string> CreateMetric()
        {
            base.CreateMetric();
            var analysisPhaseCollection = new AnalysisPhaseCollection(SignalID, StartDate, EndDate);

            //If there are phases in the collection add the charts
            if (analysisPhaseCollection.Items.Count > 0)
            {
                foreach (var plan in analysisPhaseCollection.Plans)
                {
                    plan.SetProgrammedSplits(SignalID);
                    plan.SetHighCycleCount(analysisPhaseCollection);
                }

                //If there are phases in the collection add the charts


                //dummy chart to create a legend for the entire split monitor page.
                var dummychart = new Chart();
                var chartarea1 = new ChartArea();
                ChartFactory.SetImageProperties(dummychart);
                dummychart.BorderlineDashStyle = ChartDashStyle.Dot;

                dummychart.Height = 100;

                var PedActivity    = new Series();
                var GapoutSeries   = new Series();
                var MaxOutSeries   = new Series();
                var ForceOffSeries = new Series();
                var ProgramedSplit = new Series();
                var UnknownSeries  = new Series();

                PedActivity.Name    = "Ped Activity";
                GapoutSeries.Name   = "Gap Out";
                MaxOutSeries.Name   = "Max Out";
                ForceOffSeries.Name = "Force Off";
                ProgramedSplit.Name = "Programmed Split";
                UnknownSeries.Name  = "Unknown Termination Cause";


                PedActivity.MarkerStyle        = MarkerStyle.Cross;
                GapoutSeries.MarkerStyle       = MarkerStyle.Circle;
                MaxOutSeries.MarkerStyle       = MarkerStyle.Circle;
                ForceOffSeries.MarkerStyle     = MarkerStyle.Circle;
                ProgramedSplit.BorderDashStyle = ChartDashStyle.Solid;
                UnknownSeries.MarkerStyle      = MarkerStyle.Circle;

                GapoutSeries.Color   = Color.OliveDrab;
                PedActivity.Color    = Color.DarkGoldenrod;
                MaxOutSeries.Color   = Color.Red;
                ForceOffSeries.Color = Color.MediumBlue;
                ProgramedSplit.Color = Color.OrangeRed;
                UnknownSeries.Color  = Color.Black;

                dummychart.Series.Add(ProgramedSplit);
                dummychart.Series.Add(GapoutSeries);
                dummychart.Series.Add(MaxOutSeries);
                dummychart.Series.Add(ForceOffSeries);
                dummychart.Series.Add(UnknownSeries);
                dummychart.Series.Add(PedActivity);

                dummychart.ChartAreas.Add(chartarea1);

                var dummychartLegend = new Legend();
                dummychartLegend.Name = "DummyLegend";

                dummychartLegend.IsDockedInsideChartArea = true;

                dummychartLegend.Title     = "Chart Legend";
                dummychartLegend.Docking   = Docking.Bottom;
                dummychartLegend.Alignment = StringAlignment.Center;
                dummychart.Legends.Add(dummychartLegend);
                var removethese = new List <Title>();

                foreach (var t in dummychart.Titles)
                {
                    if (string.IsNullOrEmpty(t.Text))
                    {
                        removethese.Add(t);
                    }
                }
                foreach (var t in removethese)
                {
                    dummychart.Titles.Remove(t);
                }


                var dummyChartFileName = CreateFileName();
                dummychart.SaveImage(MetricFileLocation + dummyChartFileName);
                ReturnList.Add(MetricWebPath + dummyChartFileName);

                if (analysisPhaseCollection.Items.Count > 0)
                {
                    var phasesInOrder = (analysisPhaseCollection.Items.Select(r => r)).OrderBy(r => r.PhaseNumber);
                    foreach (var phase in phasesInOrder)
                    {
                        var chart = GetNewSplitMonitorChart(StartDate, EndDate,
                                                            phase.PhaseNumber);
                        AddSplitMonitorDataToChart(chart, phase, analysisPhaseCollection.Plans);
                        if (ShowPlanStripes)
                        {
                            SetSimplePlanStrips(analysisPhaseCollection.Plans, chart, StartDate);
                            SetSplitMonitorStatistics(analysisPhaseCollection.Plans, phase, chart);
                        }
                        var chartFileName = CreateFileName();
                        removethese = new List <Title>();

                        foreach (var t in chart.Titles)
                        {
                            if (string.IsNullOrEmpty(t.Text))
                            {
                                removethese.Add(t);
                            }
                        }
                        foreach (var t in removethese)
                        {
                            chart.Titles.Remove(t);
                        }
                        chart.SaveImage(MetricFileLocation + chartFileName);
                        ReturnList.Add(MetricWebPath + chartFileName);
                    }
                }
            }
            return(ReturnList);
        }