示例#1
0
        protected void AddDataToChart(Chart chart, RLMSignalPhase signalPhase,
                                      DateTime startDate, DateTime endDate, int binSize, string signalId, string region,
                                      bool showVolume, bool showAOG)
        {
            double totalDetectorHits = 0;
            var    yAxisHolder       = 0;


            foreach (var plan in signalPhase.Plans.PlanList)
            {
                if (plan.RLMCycleCollection.Count > 0)
                {
                    var dt = plan.StartTime;

                    while (dt < plan.EndTime)
                    {
                        double binTotalStops = 0;
                        //double hitCount = 0;
                        double binPercentAoR   = 0;
                        double binDetectorHits = 0;

                        var rlmCycles = from item in plan.RLMCycleCollection
                                        where item.StartTime > dt && item.EndTime < dt.AddMinutes(binSize)
                                        select item;


                        chart.Series["Percent Arrivals on Red"].Points.AddXY(dt, binPercentAoR);
                        chart.Series["Total Vehicles"].Points.AddXY(dt, binDetectorHits * (60 / binSize));
                        chart.Series["Arrivals on Red"].Points.AddXY(dt, binTotalStops * (60 / binSize));
                        dt = dt.AddMinutes(binSize);

                        if (yAxisHolder < binDetectorHits * (60 / binSize))
                        {
                            yAxisHolder = Convert.ToInt16(binDetectorHits * (60 / binSize));
                            yAxisHolder = RoundToNearest(yAxisHolder, 100);
                            chart.ChartAreas[0].AxisY.Maximum = yAxisHolder + 250;
                        }

                        if (yAxisHolder < binTotalStops * (60 / binSize))
                        {
                            yAxisHolder = Convert.ToInt16(binDetectorHits * (60 / binSize));
                            yAxisHolder = RoundToNearest(yAxisHolder, 100);
                            chart.ChartAreas[0].AxisY.Maximum = yAxisHolder + 250;
                        }
                    }
                }
            }
            totalCars = totalDetectorHits;


            chart.Titles.Add("Test");
        }
示例#2
0
文件: RLMChart.cs 项目: zfx1982/ATSPM
        private void SetChartTitle(Chart chart, RLMSignalPhase signalPhase)
        {
            //Set the chart title
            chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
            chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID, Options.StartDate, Options.EndDate));
            chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(signalPhase.Approach.ProtectedPhaseNumber, signalPhase.Approach.DirectionType.Description));
            Dictionary <string, string> statistics = new Dictionary <string, string>();

            statistics.Add("Total Violations", signalPhase.Violations.ToString() + " (" + signalPhase.PercentViolations.ToString() + "%)");
            statistics.Add("Severe Violations", signalPhase.Srlv + " (" + signalPhase.PercentSevereViolations.ToString() + "%)");
            statistics.Add("Yellow Light Occurrences", signalPhase.YellowOccurrences + " (" + signalPhase.PercentYellowOccurrences.ToString() + "%)");
            chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
        }
示例#3
0
文件: RLMChart.cs 项目: gmonk/ATSPM
        private void SetChartTitle(Chart chart, RLMSignalPhase signalPhase)
        {
            //Set the chart title
            chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
            chart.Titles.Add(
                ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID, Options.StartDate, Options.EndDate));
            chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(signalPhase.Approach, signalPhase.GetPermissivePhase));
            var statistics = new Dictionary <string, string>();

            statistics.Add("Total Violations", signalPhase.Violations + " (" + signalPhase.PercentViolations + "%)");
            statistics.Add("Severe Violations",
                           signalPhase.SevereRedLightViolations + " (" + signalPhase.PercentSevereViolations + "%)");
            statistics.Add("Yellow Light Occurrences",
                           signalPhase.YellowOccurrences + " (" + signalPhase.PercentYellowOccurrences + "%)");
            chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
        }
示例#4
0
文件: RLMChart.cs 项目: gmonk/ATSPM
        private void AddDataToChart(Chart chart, RLMSignalPhase signalPhase)
        //, DateTime startDate,
        //DateTime endDate, string signalId, bool showRlv, bool showSrlv,
        //bool showPrlv, bool showPsrlv, bool showAveTrlv, bool showYlo, bool showPylo,
        //bool showTylo)
        {
            decimal totalDetectorHits = 0;

            foreach (var plan in signalPhase.Plans.PlanList)
            {
                if (plan.RLMCycleCollection.Count > 0)
                {
                    foreach (var rlm in plan.RLMCycleCollection)
                    {
                        chart.Series["Yellow Clearance"].Points.AddXY(
                            //pcd.StartTime,
                            rlm.RedClearanceEvent,
                            rlm.RedClearanceBeginY);
                        chart.Series["Red Clearance"].Points.AddXY(
                            //pcd.StartTime,
                            rlm.RedEvent,
                            rlm.RedBeginY);
                        chart.Series["Red"].Points.AddXY(
                            //pcd.StartTime,
                            rlm.RedEndEvent,
                            rlm.RedEndY);
                        totalDetectorHits += rlm.DetectorCollection.Count;
                        foreach (var detectorPoint in rlm.DetectorCollection)
                        {
                            chart.Series["Detector Activation"].Points.AddXY(
                                //pcd.StartTime,
                                detectorPoint.TimeStamp,
                                detectorPoint.YPoint);
                        }
                    }
                }
            }
            SetPlanStrips(signalPhase.Plans.PlanList, chart);
            //, Options.StartDate,
            //    Options.ShowRedLightViolations, Options.showSrlv, showPrlv, showPsrlv, showAveTrlv, showYlo, showPylo,
            //showTylo);
        }
示例#5
0
        public RedLightMonitorChart(DateTime graphStartDate, DateTime graphEndDate,
                                    RLMSignalPhase signalPhase, int binSize,
                                    string location, string region, string yAxisMax, string yAxis2Max,
                                    bool showVolume, bool showPlanStatistics)
        {
            double y = 0;
            var    extendedDirection = string.Empty;
            var    movementType      = "Phase";

            if (signalPhase.Approach.IsProtectedPhaseOverlap)
            {
                movementType = "Overlap";
            }


            //Gets direction for the title
            switch (signalPhase.Approach.DirectionType.Description)
            {
            case "SB":
                extendedDirection = "Southbound";
                break;

            case "NB":
                extendedDirection = "Northbound";
                break;

            default:
                extendedDirection = signalPhase.Approach.DirectionType.Description;
                break;
            }

            //Set the chart properties
            ChartFactory.SetImageProperties(chart);
            chart.BorderSkin.SkinStyle   = BorderSkinStyle.Raised;
            chart.BorderSkin.BorderColor = Color.Black;
            chart.BorderSkin.BorderWidth = 1;


            //Set the chart title
            chart.Titles.Add(location + "Signal " + signalPhase.Approach.SignalID + " "
                             + movementType + ": " + signalPhase.Approach.ProtectedPhaseNumber +
                             " " + extendedDirection + "\n" + graphStartDate.ToString("f") +
                             " - " + graphEndDate.ToString("f"));

            //Create the chart legend
            var chartLegend = new Legend();

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);


            //Create the chart area
            var chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";
            if (double.TryParse(yAxisMax, out y))
            {
                chartArea.AxisY.Maximum = y;
            }
            else
            {
                chartArea.AxisY.Maximum = 60;
            }
            chartArea.AxisY.Minimum   = 0;
            chartArea.AxisY.Title     = "Volume (Vehicles Per Hour)";
            chartArea.AxisY.Interval  = 500;
            chartArea.AxisY2.Title    = "Percent AoR";
            chartArea.AxisY2.Maximum  = 100;
            chartArea.AxisY2.Interval = 10;
            chartArea.AxisY2.Enabled  = AxisEnabled.True;


            chartArea.AxisX.Title             = "Time (Hour of Day)";
            chartArea.AxisX.Interval          = 1;
            chartArea.AxisX.IntervalType      = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format = "HH";

            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;
            chartArea.AxisX2.IntervalType          = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelStyle.Format     = "HH";
            chartArea.AxisX2.LabelAutoFitStyle     = LabelAutoFitStyles.None;
            chartArea.AxisX2.Interval = 1;

            chart.ChartAreas.Add(chartArea);


            //Add the point series

            var AoRSeries = new Series();

            AoRSeries.ChartType       = SeriesChartType.Line;
            AoRSeries.BorderDashStyle = ChartDashStyle.Dash;
            AoRSeries.Color           = Color.Red;
            AoRSeries.Name            = "Arrivals on Red";
            AoRSeries.XValueType      = ChartValueType.DateTime;

            var TVSeries = new Series();

            TVSeries.ChartType       = SeriesChartType.Line;
            TVSeries.BorderDashStyle = ChartDashStyle.Dash;
            TVSeries.Color           = Color.Black;
            TVSeries.Name            = "Total Vehicles";
            TVSeries.XValueType      = ChartValueType.DateTime;

            var PARSeries = new Series();

            PARSeries.ChartType   = SeriesChartType.Line;
            PARSeries.Color       = Color.Red;
            PARSeries.Name        = "Percent Arrivals on Red";
            PARSeries.BorderWidth = 2;
            PARSeries.XValueType  = ChartValueType.DateTime;
            PARSeries.YAxisType   = AxisType.Secondary;


            var pointSeries = new Series();

            pointSeries.ChartType         = SeriesChartType.Point;
            pointSeries.Color             = Color.White;
            pointSeries.Name              = "Posts";
            pointSeries.XValueType        = ChartValueType.DateTime;
            pointSeries.IsVisibleInLegend = false;


            chart.Series.Add(pointSeries);
            chart.Series.Add(AoRSeries);
            chart.Series.Add(PARSeries);
            chart.Series.Add(TVSeries);


            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Posts"].Points.AddXY(graphStartDate, 0);
            chart.Series["Posts"].Points.AddXY(graphEndDate, 0);

            AddDataToChart(chart, signalPhase, graphStartDate, graphEndDate, binSize, signalPhase.Approach.SignalID,
                           region, showVolume, false);
            SetPlanStrips(signalPhase.Plans.PlanList, chart, graphStartDate, showPlanStatistics);
        }
示例#6
0
文件: RLMChart.cs 项目: zfx1982/ATSPM
        public Chart GetChart(RLMSignalPhase signalPhase, WCFServiceLibrary.YellowAndRedOptions options)
        {
            Options = options;
            Chart    chart          = new Chart();
            TimeSpan reportTimespan = Options.EndDate - Options.StartDate;


            //Set the chart properties
            chart.ImageType        = ChartImageType.Jpeg;
            chart.Height           = 700;
            chart.Width            = 1100;
            chart.ImageStorageMode = ImageStorageMode.UseImageLocation;
            SetChartTitle(chart, signalPhase);

            //Create the chart legend
            Legend chartLegend = new Legend();

            chartLegend.Name = "MainLegend";
            chart.Legends.Add(chartLegend);


            //Create the chart area
            ChartArea chartArea = new ChartArea();

            chartArea.Name = "ChartArea1";
            if (Options.YAxisMax != null)
            {
                chartArea.AxisY.Maximum = Options.YAxisMax.Value;
            }
            chartArea.AxisY.Minimum = 0;
            chartArea.AxisY.Title   = "Yellow Red Time (Seconds) ";
            chartArea.AxisY.MinorTickMark.Enabled = true;
            chartArea.AxisY.MajorTickMark.Enabled = true;
            chartArea.AxisY.MajorGrid.Interval    = 5;
            chartArea.AxisY.MinorGrid.Interval    = 1;
            chartArea.AxisX.Title              = "Time (Hour of Day)";
            chartArea.AxisX.IntervalType       = DateTimeIntervalType.Hours;
            chartArea.AxisX.LabelStyle.Format  = "HH";
            chartArea.AxisX2.LabelStyle.Format = "HH";
            chartArea.AxisX.MajorGrid.Enabled  = true;
            if (reportTimespan.Days < 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    chartArea.AxisX2.Interval = 1;
                    chartArea.AxisX.Interval  = 1;
                }
                else
                {
                    chartArea.AxisX.LabelStyle.Format  = "HH:mm";
                    chartArea.AxisX2.LabelStyle.Format = "HH:mm";
                }
            }
            //chartArea.AxisX.Minimum = 0;

            chartArea.AxisX2.Enabled = AxisEnabled.True;
            chartArea.AxisX2.MajorTickMark.Enabled = true;

            chartArea.AxisX2.IntervalType      = DateTimeIntervalType.Hours;
            chartArea.AxisX2.LabelAutoFitStyle = LabelAutoFitStyles.None;
            //chartArea.AxisX.Minimum = 0;

            chart.ChartAreas.Add(chartArea);

            Color yelowish   = Color.FromArgb(245, 237, 127);
            Color blueish    = Color.FromArgb(128, 10, 117, 182);
            Color greenish   = Color.FromArgb(64, 177, 14);
            Color tanish     = Color.FromArgb(220, 138, 78);
            Color whiteish   = Color.FromArgb(243, 240, 235);
            Color redish     = Color.FromArgb(128, 255, 0, 0);
            Color darkRedish = Color.FromArgb(196, 222, 2, 2);
            //Color redish = Color.FromArgb(163, 60, 62);

            //Add the red series
            Series redSeries = new Series();

            redSeries.ChartType = SeriesChartType.Area;
            redSeries.Color     = redish;
            //redSeries.BackGradientStyle = GradientStyle.VerticalCenter;
            redSeries.Name       = "Red";
            redSeries.XValueType = ChartValueType.DateTime;

            chart.Series.Add(redSeries);

            //Add the yellow series
            Series redClearanceSeries = new Series();

            redClearanceSeries.ChartType  = SeriesChartType.Area;
            redClearanceSeries.Color      = darkRedish;
            redClearanceSeries.Name       = "Red Clearance";
            redClearanceSeries.XValueType = ChartValueType.DateTime;
            chart.Series.Add(redClearanceSeries);

            //Add the green series
            Series yellowClearanceSeries = new Series();

            yellowClearanceSeries.ChartType = SeriesChartType.Area;
            yellowClearanceSeries.Color     = yelowish;
            //yellowClearanceSeries.BackGradientStyle = GradientStyle.DiagonalLeft;
            yellowClearanceSeries.BackSecondaryColor = yelowish;
            yellowClearanceSeries.Name       = "Yellow Clearance";
            yellowClearanceSeries.XValueType = ChartValueType.DateTime;
            chart.Series.Add(yellowClearanceSeries);

            //Add the point series
            Series pointSeries = new Series();

            pointSeries.ChartType  = SeriesChartType.Point;
            pointSeries.Color      = Color.Black;
            pointSeries.Name       = "Detector Activation";
            pointSeries.XValueType = ChartValueType.DateTime;
            pointSeries.MarkerSize = 3;
            chart.Series.Add(pointSeries);



            //Add points at the start and and of the x axis to ensure
            //the graph covers the entire period selected by the user
            //whether there is data or not
            chart.Series["Detector Activation"].Points.AddXY(Options.StartDate, 0);
            chart.Series["Detector Activation"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(chart, signalPhase);
            return(chart);
        }