Beispiel #1
0
 private void SetChartTitle(string direction1, string direction2)
 {
     Chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
     Chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                          Options.SignalID, Options.StartDate, Options.EndDate));
     Chart.Titles.Add(ChartTitleFactory.GetBoldTitle(direction1 + " and " + direction2 + " Approaches"));
 }
Beispiel #2
0
        private void AddTitleAndLegend(Chart chart, int PreemptNumber)
        {
            chart.ImageStorageMode       = ImageStorageMode.UseImageLocation;
            chart.ImageType              = ChartImageType.Jpeg;
            chart.Height                 = 350;
            chart.Width                  = 1100;
            chart.BorderSkin.SkinStyle   = BorderSkinStyle.None;
            chart.BorderSkin.BorderColor = Color.Black;
            chart.BorderSkin.BorderWidth = 1;

            //Set the chart title
            chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
            chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID,
                                                                             Options.StartDate, Options.EndDate));
            if (PreemptNumber > 0)
            {
                chart.Titles.Add(ChartTitleFactory.GetBoldTitle(" Preempt Number: " + PreemptNumber.ToString()));
            }

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

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);
        }
Beispiel #3
0
 private void SetChartTitle(Dictionary <string, string> statistics)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID, Options.StartDate, Options.EndDate));
     chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(Phase.PhaseNumber, Phase.Approach.DirectionType.Description));
     chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
 }
 private void SetChartTitle(Chart chart)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(this.MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(this.SignalID, this.StartDate, this.EndDate));
     chart.Titles.Add(ChartTitleFactory.GetTitle("Currently showing Force-Offs, Max-Outs and Gap-Outs with a consecutive occurrence of " +
                                                 this.SelectedConsecutiveCount.ToString() + " or more. \n  Pedestrian events are never filtered"));
 }
Beispiel #5
0
 private void SetChartTitle(Models.LaneType laneType, Models.DirectionType direction, Models.MovementType movementType)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                          Options.SignalID, Options.StartDate, Options.EndDate));
     chart.Titles.Add(ChartTitleFactory.GetBoldTitle(direction.Description + " " +
                                                     movementType.Description + " " + laneType.Description + " Lanes"));
 }
Beispiel #6
0
 private void SetChartTitle(Dictionary <string, string> statistics)
 {
     Chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
     Chart.Titles.Add(
         ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID, Options.StartDate, Options.EndDate));
     Chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(SplitFailPhase.Approach, SplitFailPhase.GetPermissivePhase));
     Chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
 }
Beispiel #7
0
 private void SetChartTitles(Chart chart, MOE.Common.Models.Detector detector)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(this.MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                          this.SignalID, this.StartDate, this.EndDate));
     chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(detector.Approach.ProtectedPhaseNumber, detector.Approach.DirectionType.Description));
     chart.Titles.Add(ChartTitleFactory.GetTitle("Detection Type: " + detector.DetectionHardware.Name + "; Speed Accuracy +/- 2 mph" + "\n" + "Detector Distance from Stop Bar: " + detector.DistanceFromStopBar.ToString() + " feet; "
                                                 + "\n" + "Includes records over 5mph that occur between 15s after start of green to start of yellow."));
 }
 private void SetChartTitle(TimingAndActuationsOptions options)
 {
     Chart.ChartAreas[0].AxisY.Title    = "";
     Chart.ChartAreas[0].AxisY2.Enabled = AxisEnabled.False;
     Chart.ChartAreas[0].AxisY2.Title   = "";
     Chart.Titles.Add(ChartTitleFactory.GetChartName(options.MetricTypeID));
     Chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                          options.SignalID, options.StartDate, options.EndDate));
 }
Beispiel #9
0
        private void SetChartTitle(Chart chart, Approach approach, Dictionary <string, string> statistics)
        {
            var    detectorsForMetric = approach.GetDetectorsForMetricType(this.MetricTypeID);
            string message            = "\n Advanced detector located " + detectorsForMetric.FirstOrDefault().DistanceFromStopBar.ToString() + " ft. upstream of stop bar";

            chart.Titles.Add(ChartTitleFactory.GetChartName(this.MetricTypeID));
            chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRangeAndMessage(approach.SignalID, this.StartDate, this.EndDate, message));
            chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(approach.ProtectedPhaseNumber, approach.DirectionType.Description));
            chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
        }
Beispiel #10
0
 private void SetChartTitle(LaneType laneType, DirectionType direction, MovementType movementType)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                          Options.SignalID, Options.StartDate, Options.EndDate));
     chart.Titles.Add(ChartTitleFactory.GetBoldTitle(direction.Description + " " +
                                                     movementType.Description + " " + laneType.Description +
                                                     " Lanes"));
     if (movementType.MovementTypeID == 2 || movementType.MovementTypeID == 3)
     {
         chart.ChartAreas[0].AxisY.Maximum = Options.Y2AxisMax.Value;
     }
 }
Beispiel #11
0
        private void SetChartTitle(Chart chart, SignalPhase signalPhase, Dictionary <string, string> statistics)
        {
            var detectorsForMetric = signalPhase.Approach.GetDetectorsForMetricType(MetricTypeID);
            var message            = "\n Advanced detector located " + detectorsForMetric.FirstOrDefault().DistanceFromStopBar +
                                     " ft. upstream of stop bar";

            chart.Titles.Add(ChartTitleFactory.GetChartName(MetricTypeID));
            chart.Titles.Add(
                ChartTitleFactory.GetSignalLocationAndDateRangeAndMessage(signalPhase.Approach.SignalID, StartDate, EndDate,
                                                                          message));
            chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(signalPhase.Approach, signalPhase.GetPermissivePhase));
            chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
        }
Beispiel #12
0
 private void SetChartTitles(Chart chart, Models.Detector detector)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                          SignalID, StartDate, EndDate));
     chart.Titles.Add(ChartTitleFactory.GetPhaseAndPhaseDescriptions(detector.Approach, false));
     chart.Titles.Add(ChartTitleFactory.GetTitle("Detection Type: " + detector.DetectionHardware.Name +
                                                 "; Speed Accuracy +/- 2 mph" + "\n" +
                                                 "Detector Distance from Stop Bar: " +
                                                 detector.DistanceFromStopBar + " feet; "
                                                 + "\n" +
                                                 "Includes records over 5mph that occur between 15s after start of green to start of yellow."));
 }
Beispiel #13
0
        private void SetChartTitle(Chart chart, PedPhase pp, PedDelayOptions options)
        {
            chart.Titles.Add(ChartTitleFactory.GetChartName(options.MetricTypeID));
            chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(
                                 options.SignalID, options.StartDate, options.EndDate));
            chart.Titles.Add(ChartTitleFactory.GetPhase(pp.PhaseNumber));
            var statistics = new Dictionary <string, string>();

            statistics.Add("Ped Actuations(PA)", pp.PedActuations.ToString());
            statistics.Add("Min Delay", DateTime.Today.AddMinutes(pp.MinDelay / 60).ToString("mm:ss"));
            statistics.Add("Max Delay", DateTime.Today.AddMinutes(pp.MaxDelay / 60).ToString("mm:ss"));
            statistics.Add("Average Delay(AD)", DateTime.Today.AddMinutes(pp.AverageDelay / 60).ToString("mm:ss"));
            chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
        }
Beispiel #14
0
 private void AddDetectionTypeTitle(ApproachVolume approachVolume)
 {
     if (approachVolume.Detectors.Count > 0)
     {
         Models.Detector d = approachVolume.Detectors.FirstOrDefault();
         if (d.DistanceFromStopBar != null && d.DistanceFromStopBar > 0)
         {
             Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " located " + d.DistanceFromStopBar +
                                                         "ft. upstream of the stop bar"));
         }
         else
         {
             Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " at stop bar"));
         }
     }
 }
Beispiel #15
0
        //public static void SetSimplePlanStrips(List<Plan> plans, Chart chart, DateTime startDate, ControllerEventLogs eventLog)
        //{
        //    int backGroundColor = 1;
        //    foreach (Plan plan in plans)
        //    {
        //        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 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++;

        //    }
        //}

        private void AddTitleAndLegend(Chart chart, int preemptNumber)
        {
            ChartFactory.SetImageProperties(chart);
            chart.BorderSkin.SkinStyle   = BorderSkinStyle.None;
            chart.BorderSkin.BorderColor = Color.Black;
            chart.BorderSkin.BorderWidth = 1;

            //Set the chart title
            chart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
            chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID,
                                                                             Options.StartDate, Options.EndDate));
            if (preemptNumber > 0)
            {
                chart.Titles.Add(ChartTitleFactory.GetBoldTitle(" Preempt Number: " + preemptNumber));
            }

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

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            chart.Legends.Add(chartLegend);
        }
Beispiel #16
0
        protected void AddDataToChart(Chart chart, List <MOE.Common.Business.ApproachVolume.Approach> approachDirectionCollection, DateTime startDate,
                                      DateTime endDate, string signalId, string direction1, string direction2, ApproachVolumeOptions options, bool useAdvance)
        {
            int      D1vol  = 0;
            int      D2vol  = 0;
            DateTime D1time = new DateTime();
            DateTime D2time = new DateTime();
            SortedDictionary <DateTime, int> D1volumes = new SortedDictionary <DateTime, int>();
            SortedDictionary <DateTime, int> D2volumes = new SortedDictionary <DateTime, int>();


            List <MOE.Common.Business.ApproachVolume.Approach> FilteredApproaches = (from r in approachDirectionCollection
                                                                                     where
                                                                                     r.Direction == direction1 || r.Direction == direction2
                                                                                     select r).ToList();


            foreach (MOE.Common.Business.ApproachVolume.Approach approachDirection in FilteredApproaches)
            {
                if (useAdvance)
                {
                    approachDirection.SetDetectorEvents(approachDirection.ApproachModel, startDate, endDate, true, false);
                }
                else
                {
                    approachDirection.SetDetectorEvents(approachDirection.ApproachModel, startDate, endDate, false, true);
                }

                approachDirection.SetVolume(startDate, endDate, options.SelectedBinSize);
            }

            if (FilteredApproaches.Count > 0)
            {
                MOE.Common.Models.Detector d = FilteredApproaches[0].Detectors.ApproachCountDetectors[0];


                if (d.DistanceFromStopBar != null && d.DistanceFromStopBar > 0)
                {
                    Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " located " + d.DistanceFromStopBar.ToString() + "ft. upstream of the stop bar"));
                }
                else
                {
                    Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " at stop bar"));
                }
            }



            foreach (MOE.Common.Business.ApproachVolume.Approach approachDirection in FilteredApproaches)
            {
                if (approachDirection.Volume.Items.Count > 0)
                {
                    foreach (MOE.Common.Business.Volume v in approachDirection.Volume.Items)
                    {
                        //add Direction1 volumes
                        if (approachDirection.Direction == direction1)
                        {
                            //Add the volumes and times to a collection so we can use them later
                            if (!D1volumes.ContainsKey(v.XAxis))
                            {
                                D1volumes.Add(v.XAxis, v.YAxis);
                                D1TotalVolume = (D1TotalVolume + v.DetectorCount);
                            }
                        }



                        //add Direction2 volumes
                        if (approachDirection.Direction == direction2)
                        {
                            //Add the volumes and times to a collection so we can use them later
                            if (!D2volumes.ContainsKey(v.XAxis))
                            {
                                D2volumes.Add(v.XAxis, v.YAxis);
                                D2TotalVolume = (D2TotalVolume + v.DetectorCount);
                            }
                        }
                    }
                }

                if (options.ShowSBEBVolume)
                {
                    foreach (KeyValuePair <DateTime, int> vol in D1volumes)
                    {
                        //This is the Thicker Solid Red line
                        chart.Series[0].Points.AddXY(vol.Key, vol.Value);
                    }
                }


                if (options.ShowNBWBVolume)
                {
                    foreach (KeyValuePair <DateTime, int> vol in D2volumes)
                    {
                        //This is the Thicker Solid Blue line
                        chart.Series[1].Points.AddXY(vol.Key, vol.Value);
                        CheckAndCorrectConsecutiveXValues(chart.Series[1].Points);
                    }
                }

                //add ratios


                //Match the times in the dir1 colleciton to the dir2 collection so we can get a ratio
                //of the values collected at the same point in time.
                foreach (KeyValuePair <DateTime, int> volRow in D1volumes)
                {
                    D2vol = (from k in D2volumes
                             where DateTime.Compare(k.Key, volRow.Key) == 0
                             select k.Value).FirstOrDefault();

                    D1vol  = volRow.Value;
                    D1time = volRow.Key;

                    if (D1vol > 0 && D2vol > 0)
                    {
                        //ratio the values
                        double D1DFactor = Convert.ToDouble(D1vol) / ((Convert.ToDouble(D2vol) + Convert.ToDouble(D1vol)));

                        if (options.ShowDirectionalSplits)
                        {
                            //plot the ratio and time on the secondary Y axis
                            //This is the Thin Dashed Red line
                            chart.Series[2].Points.AddXY(D1time, D1DFactor);
                        }
                    }
                }

                CheckAndCorrectConsecutiveXValues(chart.Series[2].Points);

                //Match the times in the dir2 colleciton to the dir1 collection so we can get a ratio
                //of the values collected at the same point in time.
                foreach (KeyValuePair <DateTime, int> volRow in D2volumes)
                {
                    D1vol = (from k in D1volumes
                             where DateTime.Compare(k.Key, volRow.Key) == 0
                             select k.Value).FirstOrDefault();

                    D2vol  = volRow.Value;
                    D2time = volRow.Key;

                    if (D2vol > 0 && D1vol > 0)
                    {
                        //ratio the values
                        double D2DFactor = Convert.ToDouble(D2vol) / ((Convert.ToDouble(D2vol) + Convert.ToDouble(D1vol)));

                        //plot the ratio and time on the secondary Y axis
                        if (options.ShowDirectionalSplits)
                        {
                            //This is the Thin Dashed Blue line
                            chart.Series[3].Points.AddXY(D2time, D2DFactor);
                        }
                    }
                }
            }

            foreach (Series s in chart.Series)
            {
                List <DataPoint> temppoints = CheckAndCorrectConsecutiveXValues(s.Points);

                s.Points.Clear();

                foreach (DataPoint d in temppoints)
                {
                    s.Points.Add(d);
                }
            }



            if (D1volumes.Count > 0 && D2volumes.Count > 0)
            {
                Table = CreateVolumeMetricsTable(direction1, direction2, D1TotalVolume, D2TotalVolume, D1volumes, D2volumes, options);
            }
        }
Beispiel #17
0
        private void AddDataToChart(DateTime startDate, DateTime endDate, Models.DirectionType direction,
                                    List <Models.Detector> detectorsByDirection, Models.LaneType laneType, Models.MovementType movementType,
                                    MOE.Common.Business.WCFServiceLibrary.TMCOptions options, MOE.Common.Business.TMC.TMCInfo tmcInfo)
        {
            SortedDictionary <DateTime, int> MovementTotals = new SortedDictionary <DateTime, int>();
            SortedDictionary <string, int>   laneTotals     = new SortedDictionary <string, int>();
            int binSizeMultiplier = 60 / options.SelectedBinSize;
            int totalVolume       = 0;
            List <MOE.Common.Models.Detector> tmcDetectors = new List <Models.Detector>();

            FindLaneDetectors(tmcDetectors, movementType, detectorsByDirection, laneType);
            int laneCount = tmcDetectors.Count();

            for (int ln = 1; ln < 5; ln++)
            {
                Models.Detector detector = (from r in tmcDetectors
                                            where r.LaneNumber == ln
                                            select r).FirstOrDefault();
                if (detector != null)
                {
                    if (laneCount > 0 && detector.MovementTypeID != 4 && detector.MovementTypeID != 5)
                    {
                        MOE.Common.Business.Detector d = new MOE.Common.Business.Detector(detector, startDate, endDate,
                                                                                          options.SelectedBinSize);
                        foreach (MOE.Common.Business.Volume volume in d.Volumes.Items)
                        {
                            if (options.ShowDataTable)
                            {
                                MOE.Common.Business.TMC.TMCData tmcd = new TMC.TMCData();
                                tmcd.Direction = detector.Approach.DirectionType.Description;
                                tmcd.LaneType  = detector.LaneType.Description;
                                if (!options.ShowLaneVolumes)
                                {
                                    tmcd.MovementType = tmcd.Direction;
                                }
                                else
                                {
                                    tmcd.MovementType = detector.MovementType.Abbreviation;
                                }
                                //tmcd.DetectorID = detector.DetectorID;
                                tmcd.Timestamp = volume.XAxis.AddMinutes(options.SelectedBinSize * -1);
                                tmcd.Count     = volume.YAxis / binSizeMultiplier;
                                tmcInfo.tmcData.Add(tmcd);
                            }
                            if (options.ShowLaneVolumes)
                            {
                                chart.Series["Lane " + ln.ToString()].Points.AddXY(volume.XAxis, volume.YAxis);
                            }
                            //One of the calculations requires total volume by lane.  This if statment keeps a
                            //running total of that volume and stores it in a dictonary with the lane number.
                            if (laneTotals.ContainsKey("L" + ln))
                            {
                                laneTotals["L" + ln] += volume.YAxis;
                            }
                            else
                            {
                                laneTotals.Add("L" + ln, volume.YAxis);
                            }
                            //we need ot track the total number of cars (volume) for this movement.
                            //this uses a time/int dictionary.  The volume record for a given time is contibuted to by each lane.
                            //Then the movement total can be plotted on the graph
                            if (MovementTotals.ContainsKey(volume.XAxis))
                            {
                                MovementTotals[volume.XAxis] += volume.YAxis;
                            }
                            else
                            {
                                MovementTotals.Add(volume.XAxis, volume.YAxis);
                            }
                        }
                    }
                }
            }

            if (movementType.MovementTypeID == 1)
            {
                List <Models.Detector> thruTurnLanes = (from r in detectorsByDirection
                                                        where r.MovementTypeID == 4 ||
                                                        r.MovementTypeID == 5
                                                        select r).ToList();
                foreach (Models.Detector detector in thruTurnLanes)
                {
                    MOE.Common.Business.Detector d = new MOE.Common.Business.Detector(detector, startDate, endDate, options.SelectedBinSize);
                    foreach (MOE.Common.Business.Volume volume in d.Volumes.Items)
                    {
                        if (detector.MovementType.Abbreviation == "TL")
                        {
                            {
                                if (options.ShowLaneVolumes)
                                {
                                    if (options.ShowDataTable)
                                    {
                                        MOE.Common.Business.TMC.TMCData tmcd = new TMC.TMCData();
                                        tmcd.Direction = detector.Approach.DirectionType.Description;
                                        tmcd.LaneType  = detector.LaneType.Description;
                                        if (!options.ShowLaneVolumes)
                                        {
                                            tmcd.MovementType = tmcd.Direction;
                                        }
                                        else
                                        {
                                            tmcd.MovementType = detector.MovementType.Abbreviation;
                                        }
                                        //tmcd.DetectorID = detector.DetectorID;
                                        tmcd.Timestamp = volume.XAxis.AddMinutes(options.SelectedBinSize * -1);
                                        tmcd.Count     = volume.YAxis / binSizeMultiplier;
                                        tmcInfo.tmcData.Add(tmcd);
                                    }
                                    chart.Series["Thru Left"].Points.AddXY(volume.XAxis, volume.YAxis);
                                }
                            }
                            if (laneTotals.ContainsKey("TL"))
                            {
                                laneTotals["TL"] += volume.YAxis;
                            }
                            else
                            {
                                laneTotals.Add("TL", volume.YAxis);
                            }
                        }
                        if (detector.MovementType.Abbreviation == "TR")
                        {
                            if (options.ShowLaneVolumes)
                            {
                                if (options.ShowDataTable)
                                {
                                    MOE.Common.Business.TMC.TMCData tmcd = new TMC.TMCData();
                                    tmcd.Direction = detector.Approach.DirectionType.Description;
                                    tmcd.LaneType  = detector.LaneType.Description;
                                    if (!options.ShowLaneVolumes)
                                    {
                                        tmcd.MovementType = tmcd.Direction;
                                    }
                                    else
                                    {
                                        tmcd.MovementType = detector.MovementType.Abbreviation;
                                    }
                                    //tmcd.DetectorID = detector.DetectorID;
                                    tmcd.Timestamp = volume.XAxis.AddMinutes(options.SelectedBinSize * -1);
                                    tmcd.Count     = volume.YAxis / binSizeMultiplier;
                                    tmcInfo.tmcData.Add(tmcd);
                                }
                                chart.Series["Thru Right"].Points.AddXY(volume.XAxis, volume.YAxis);
                            }
                        }
                        if (laneTotals.ContainsKey("TR"))
                        {
                            laneTotals["TR"] += volume.YAxis;
                        }
                        else
                        {
                            laneTotals.Add("TR", volume.YAxis);
                        }
                        if (MovementTotals.ContainsKey(volume.XAxis))
                        {
                            MovementTotals[volume.XAxis] += volume.YAxis;
                        }
                        else
                        {
                            MovementTotals.Add(volume.XAxis, volume.YAxis);
                        }
                    }
                }
            }
            int binMultiplier = 60 / options.SelectedBinSize;

            //get the total volume for the approach
            foreach (KeyValuePair <DateTime, int> totals in MovementTotals)
            {
                if (options.ShowTotalVolumes)
                {
                    chart.Series["Total Volume"].Points.AddXY(totals.Key, totals.Value);
                }
                totalVolume += (totals.Value);
            }

            int highLaneVolume = 0;

            if (laneTotals.Values.Count > 0)
            {
                highLaneVolume = laneTotals.Values.Max();
            }


            KeyValuePair <DateTime, int> peakHourValue = findPeakHour(MovementTotals, binMultiplier);
            int      PHV               = peakHourValue.Value;
            DateTime peakHour          = peakHourValue.Key;
            int      PeakHourMAXVolume = 0;

            string fluPlaceholder = "";

            if (laneCount > 0 && highLaneVolume > 0)
            {
                double fLU = Convert.ToDouble(totalVolume) / (Convert.ToDouble(laneCount) * Convert.ToDouble(highLaneVolume));
                fluPlaceholder = SetSigFigs(fLU, 2).ToString();
            }
            else
            {
                fluPlaceholder = "Not Available";
            }



            for (int i = 0; i < binMultiplier; i++)
            {
                if (MovementTotals.ContainsKey(peakHour.AddMinutes(i * options.SelectedBinSize)))
                {
                    if (PeakHourMAXVolume < (MovementTotals[peakHour.AddMinutes(i * options.SelectedBinSize)]))
                    {
                        PeakHourMAXVolume = MovementTotals[peakHour.AddMinutes(i * options.SelectedBinSize)];
                    }
                }
            }

            string PHFPlaceholder = FindPHF(PHV, PeakHourMAXVolume, binMultiplier);


            string peakHourString = peakHour.ToShortTimeString() + " - " + peakHour.AddHours(1).ToShortTimeString();
            Dictionary <string, string> statistics = new Dictionary <string, string>();

            statistics.Add("Total Volume", (totalVolume / binMultiplier).ToString());
            statistics.Add("Peak Hour", peakHourString);
            statistics.Add("Peak Hour Volume", (PHV / binMultiplier).ToString() + " VPH");
            statistics.Add("PHF", PHFPlaceholder);
            statistics.Add("fLU", fluPlaceholder);
            chart.Titles.Add(ChartTitleFactory.GetStatistics(statistics));
            SetSeriesVisibility(laneCount, options.ShowLaneVolumes);
        }
Beispiel #18
0
        private void SetSplitMonitorStatistics(List <PlanSplitMonitor> plans, AnalysisPhase phase, Chart chart)
        {
            //find the phase Cycles that occure during the plan.
            foreach (var plan in plans)
            {
                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;
                        }


                        var skipLabel = ChartTitleFactory.GetCustomLabelForTitle(
                            $"{SkipPercent:0.0%} Skips", plan.StartTime.ToOADate(),
                            plan.EndTime.ToOADate(), 1, Color.Black);

                        //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;
                    }


                    var 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;
                    }


                    var 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;
                    }


                    var 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 (var Cycle in Cycles)
                    {
                        runningTotal = runningTotal + Cycle.Duration.TotalSeconds;
                    }

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


                    var 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;
                        var    Percentile       = Convert.ToDouble(SelectedPercentileSplit) / 100;
                        var    setCount         = Cycles.Count();


                        var PercentilIndex = Percentile * setCount;
                        if (PercentilIndex % 1 == 0)
                        {
                            percentileResult = Cycles.ElementAt(Convert.ToInt16(PercentilIndex) - 1).Duration
                                               .TotalSeconds;
                        }
                        else
                        {
                            var 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);

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

                        var 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);
                    }
                }
            }
        }
Beispiel #19
0
 private void SetChartTitle(Chart chart, int phase)
 {
     chart.Titles.Add(ChartTitleFactory.GetChartName(this.MetricTypeID));
     chart.Titles.Add(ChartTitleFactory.GetSignalLocationAndDateRange(this.SignalID, this.StartDate, this.EndDate));
     chart.Titles.Add(ChartTitleFactory.GetPhase(phase));
 }
Beispiel #20
0
 private void SetChartTitle()
 {
     PreemptServiceRequestChart.Titles.Add(ChartTitleFactory.GetChartName(Options.MetricTypeID));
     PreemptServiceRequestChart.Titles.Add(
         ChartTitleFactory.GetSignalLocationAndDateRange(Options.SignalID, Options.StartDate, Options.EndDate));
 }