public string GetChartComment(string SignalID, int MetricID)
        {
            MOE.Common.Models.Repositories.IMetricCommentRepository mcr = MOE.Common.Models.Repositories.MetricCommentRepositoryFactory.Create();

            MOE.Common.Models.Comment comment = mcr.GetLatestCommentForReport(SignalID, MetricID);

            if (comment != null)
            {
                return(comment.CommentText);
            }
            else
            {
                return("");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds data points to a graph with the series GreenLine, YellowLine, Redline
        /// and Points already added.
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="signalPhase"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="signalId"></param>
        private void AddDataToChart(Chart chart, MOE.Common.Business.SignalPhase signalPhase, DateTime startDate,
                                    DateTime endDate, bool showVolume, bool showArrivalOnGreen)
        {
            decimal totalDetectorHits     = 0;
            decimal totalOnGreenArrivals  = 0;
            decimal percentArrivalOnGreen = 0;

            //Add the data by plan
            foreach (MOE.Common.Business.Plan plan in signalPhase.Plans.PlanList)
            {
                //check for empty pcd collection
                if (plan.CycleCollection.Count > 0)
                {
                    foreach (MOE.Common.Business.Cycle pcd in plan.CycleCollection)
                    {
                        //add the data for the green line
                        chart.Series["Change to Green"].Points.AddXY(
                            pcd.GreenEvent,
                            pcd.GreenLineY);

                        //add the data for the yellow line
                        chart.Series["Change to Yellow"].Points.AddXY(
                            pcd.YellowEvent,
                            pcd.YellowLineY);

                        //add the data for the red line
                        chart.Series["Change to Red"].Points.AddXY(
                            pcd.EndTime,
                            pcd.RedLineY);

                        //add the detector hits to the running total
                        totalDetectorHits += pcd.DetectorCollection.Count;

                        //add the detector hits to the detector activation series
                        foreach (MOE.Common.Business.DetectorDataPoint detectorPoint in pcd.DetectorCollection)
                        {
                            chart.Series["Detector Activation"].Points.AddXY(
                                detectorPoint.TimeStamp,
                                detectorPoint.YPoint);

                            //if this is an arrival on green add it to the running total
                            if (detectorPoint.YPoint > pcd.GreenLineY && detectorPoint.YPoint < pcd.RedLineY)
                            {
                                totalOnGreenArrivals++;
                            }
                        }
                    }
                }
            }

            //add the volume data to the volume series if true
            if (showVolume)
            {
                foreach (MOE.Common.Business.Volume v in signalPhase.Volume.Items)
                {
                    chart.Series["Volume Per Hour"].Points.AddXY(v.XAxis, v.YAxis);
                }
            }

            //if arrivals on green is selected add the data to the chart
            if (showArrivalOnGreen)
            {
                if (totalDetectorHits > 0)
                {
                    percentArrivalOnGreen = (totalOnGreenArrivals / totalDetectorHits) * 100;
                }
                else
                {
                    percentArrivalOnGreen = 0;
                }
                Title title = new Title();
                title.Text = Math.Round(percentArrivalOnGreen).ToString() + "% AoG";
                title.Font = new Font(FontFamily.GenericSansSerif, 20);
                chart.Titles.Add(title);


                SetPlanStrips(signalPhase.Plans.PlanList, chart, startDate);
            }

            MOE.Common.Models.Repositories.IMetricCommentRepository mcr = MOE.Common.Models.Repositories.MetricCommentRepositoryFactory.Create();

            MOE.Common.Models.MetricComment comment = mcr.GetLatestCommentForReport(signalPhase.Approach.SignalID, MetricTypeID);

            if (comment != null)
            {
                chart.Titles.Add(comment.CommentText);
                chart.Titles[1].Docking   = Docking.Bottom;
                chart.Titles[1].ForeColor = Color.Red;
            }
        }