コード例 #1
0
ファイル: SplitFailChart.cs プロジェクト: zfx1982/ATSPM
 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));
 }
コード例 #2
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));
 }
コード例 #3
0
ファイル: PCDOptions.cs プロジェクト: zfx1982/ATSPM
        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));
        }
コード例 #4
0
ファイル: PCDOptions.cs プロジェクト: gmonk/ATSPM
        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));
        }
コード例 #5
0
ファイル: PEDDelayChart.cs プロジェクト: gmonk/ATSPM
        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));
        }
コード例 #6
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);
        }