Example #1
0
        protected void AddDataToChart(Chart chart, MOE.Common.Business.RLMSignalPhase signalPhase,
                                      DateTime startDate, DateTime endDate, int binSize, string signalId, string region,
                                      bool showVolume, bool showAOG)
        {
            double totalDetectorHits = 0;
            int    yAxisHolder       = 0;



            foreach (MOE.Common.Business.RLMPlan plan in signalPhase.Plans.PlanList)
            {
                if (plan.RLMCycleCollection.Count > 0)
                {
                    DateTime 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");
        }
Example #2
0
        private void AddDataToChart(Chart chart, MOE.Common.Business.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 (MOE.Common.Business.RLMPlan plan in signalPhase.Plans.PlanList)
            {
                if (plan.RLMCycleCollection.Count > 0)
                {
                    foreach (MOE.Common.Business.RLMCycle 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 (MOE.Common.Business.RLMDetectorDataPoint 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);
        }
Example #3
0
        public RedLightMonitorChart(DateTime graphStartDate, DateTime graphEndDate,
                                    MOE.Common.Business.RLMSignalPhase signalPhase, int binSize,
                                    string location, string region, string yAxisMax, string yAxis2Max,
                                    bool showVolume, bool showPlanStatistics)
        {
            double y = 0;
            string extendedDirection = string.Empty;
            string 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
            chart.ImageStorageMode       = ImageStorageMode.UseImageLocation;
            chart.ImageType              = ChartImageType.Jpeg;
            chart.Height                 = 450;
            chart.Width                  = 1100;
            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.ToString() + " "
                             + movementType + ": " + signalPhase.Approach.ProtectedPhaseNumber.ToString() +
                             " " + extendedDirection + "\n" + graphStartDate.ToString("f") +
                             " - " + graphEndDate.ToString("f"));

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

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


            //Create the chart area
            ChartArea 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

            Series AoRSeries = new Series();

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

            Series TVSeries = new Series();

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

            Series 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;


            Series 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);
        }