public override List <string> CreateMetric()
        {
            base.CreateMetric();
            List <string> returnString = new List <string>();

            MOE.Common.Business.ControllerEventLogs eventsTable = new MOE.Common.Business.ControllerEventLogs();

            eventsTable.FillforPreempt(SignalID, StartDate, EndDate);
            if (eventsTable.Events.Count > 0)
            {
                MOE.Common.Business.Preempt.PreemptServiceMetric psChart =
                    new MOE.Common.Business.Preempt.PreemptServiceMetric(this, eventsTable);
                Chart chart = psChart.chart;
                //Create the File Name

                string chartName = CreateFileName();


                //Save an image of the chart

                chart.SaveImage(MetricFileLocation + chartName, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Jpeg);
                returnString.Add(MetricWebPath + chartName);
            }


            return(returnString);
        }
        private void GetAverageSpeeds(DateTime startDate, DateTime endDate, int binSize, int minSpeedFilter,
                                      int movementDelay, int decisionPoint, string signalId, int eventData1)
        {
            MOE.Common.Business.ControllerEventLogs signaltable = new ControllerEventLogs(signalId, startDate, endDate, eventData1, new List <int> {
                1, 8, 10
            });

            AvgSpeeds = new SpeedExportAvgSpeedCollection(startDate, endDate, binSize,
                                                          minSpeedFilter, Cycles);
        }
        private void GetAverageSpeeds(DateTime startDate, DateTime endDate, int binSize, int minSpeedFilter,
                                      int movementDelay, int decisionPoint, string signalId, int phaseNumber)
        {
            var signaltable =
                new ControllerEventLogs(signalId, startDate, endDate, phaseNumber, new List <int> {
                1, 8, 10
            });

            AvgSpeeds = new SpeedExportAvgSpeedCollection(startDate, endDate, binSize,
                                                          minSpeedFilter, Cycles);
        }
        public void GetPlanCollection(DateTime startDate, DateTime endDate,
                                      List <Controller_Event_Log> cycleEvents, SPM db)
        {
            var ds =
                new ControllerEventLogs(Approach.SignalID, startDate, endDate, new List <int> {
                131
            }, db);
            var row = new Controller_Event_Log();

            row.Timestamp = startDate;
            row.SignalID  = Approach.SignalID;
            row.EventCode = 131;
            try
            {
                row.EventParam = ControllerEventLogs.GetPreviousPlan(Approach.SignalID, startDate);

                ds.Events.Insert(0, row);
            }
            catch
            {
                row.EventParam = 0;
                ds.Events.Insert(0, row);
            }
            // remove duplicate plan entries
            ds.MergeEvents(ds);
            for (var i = 0; i < ds.Events.Count(); i++)
            {
                //if this is the last plan then we want the end of the plan
                //to cooincide with the end of the graph
                if (ds.Events.Count() - 1 == i)
                {
                    if (ds.Events[i].Timestamp != endDate)
                    {
                        var plan = new RLMPlan(ds.Events[i].Timestamp, endDate, ds.Events[i].EventParam,
                                               cycleEvents, SRLVSeconds, Approach);
                        AddItem(plan);
                    }
                }
                //else we add the plan with the next plans' time stamp as the end of the plan
                else
                {
                    if (ds.Events[i].Timestamp != ds.Events[i + 1].Timestamp)
                    {
                        var plan = new RLMPlan(ds.Events[i].Timestamp,
                                               ds.Events[i + 1].Timestamp, ds.Events[i].EventParam, cycleEvents, SRLVSeconds, Approach);
                        AddItem(plan);
                    }
                }
            }
        }
Exemple #5
0
        public PlansBase(string signalID, DateTime startDate, DateTime endDate) :
            base(signalID, startDate, endDate, new List <int> {
            131
        })
        {
            //Get the plan Previous to the start date
            //if(this.Events.Count > 0)
            //{
            Models.Controller_Event_Log tempEvent = new Models.Controller_Event_Log();
            tempEvent.SignalID   = signalID;
            tempEvent.Timestamp  = startDate;
            tempEvent.EventCode  = 131;
            tempEvent.EventParam = ControllerEventLogs.GetPreviousPlan(signalID, startDate);

            this.Events.Insert(0, tempEvent);
            //}

            //Remove Duplicate Plans
            int x = -1;
            List <Models.Controller_Event_Log> temp = new List <Models.Controller_Event_Log>();

            foreach (Models.Controller_Event_Log cel in Events)
            {
                temp.Add(cel);
            }
            foreach (Models.Controller_Event_Log cel in temp)
            {
                if (x == -1)
                {
                    x = cel.EventParam;
                }
                else if (x != cel.EventParam)
                {
                    x = cel.EventParam;
                    continue;
                }
                else if (x == cel.EventParam)
                {
                    x = cel.EventParam;
                    this.Events.Remove(cel);
                    continue;
                }
            }
        }
Exemple #6
0
        public ControllerEventLogs CombineDetectorDataByApproachAndType(DateTime startDate, DateTime endDate, MOE.Common.Models.Approach approach, bool Has_PCD, bool Has_TMC)
        {
            MOE.Common.Models.Repositories.IDetectorRepository gr = MOE.Common.Models.Repositories.DetectorRepositoryFactory.Create();

            string signalId = approach.SignalID;


            if (Has_TMC)
            {
                ApproachCountDetectors.Clear();


                ApproachCountDetectors.AddRange(RemoveExitDetectors(approach.GetDetectorsForMetricType(5)));
            }

            if (Has_PCD)
            {
                ApproachCountDetectors.Clear();
                ApproachCountDetectors.AddRange(RemoveExitDetectors(approach.GetDetectorsForMetricType(6)));
            }



            List <ControllerEventLogs> eventsList = new List <ControllerEventLogs>();

            ControllerEventLogs MergedEvents = new ControllerEventLogs(signalId, startDate, endDate);

            foreach (Models.Detector detector in ApproachCountDetectors)
            {
                List <int> li = new List <int> {
                    82
                };
                ControllerEventLogs cs = new ControllerEventLogs(signalId, startDate, endDate, detector.DetChannel, li);
                eventsList.Add(cs);
            }

            foreach (ControllerEventLogs Events in eventsList)
            {
                MergedEvents.MergeEvents(Events);
            }


            return(MergedEvents);
        }
Exemple #7
0
        public ControllerEventLogs CombineDetectorData(DateTime startDate, DateTime endDate, double offset, string signalId)
        {
            ControllerEventLogs        detectortable = new ControllerEventLogs(signalId, startDate, endDate);
            List <ControllerEventLogs> Tables        = new List <ControllerEventLogs>();

            foreach (MOE.Common.Business.Detector Detector in Items)
            {
                ControllerEventLogs TEMPdetectortable = new ControllerEventLogs(signalId, startDate, endDate, new List <int>()
                {
                    82
                });

                Tables.Add(TEMPdetectortable);
            }

            foreach (ControllerEventLogs Table in Tables)
            {
                detectortable.MergeEvents(Table);
            }


            return(detectortable);
        }
Exemple #8
0
        public ControllerEventLogs CombineDetectorData(DateTime startDate, DateTime endDate, double offset,
                                                       string signalId)
        {
            var detectortable = new ControllerEventLogs(signalId, startDate, endDate);
            var Tables        = new List <ControllerEventLogs>();

            foreach (var Detector in Items)
            {
                var TEMPdetectortable = new ControllerEventLogs(signalId, startDate, endDate, new List <int> {
                    82
                });

                Tables.Add(TEMPdetectortable);
            }

            foreach (var Table in Tables)
            {
                detectortable.MergeEvents(Table);
            }


            return(detectortable);
        }
        public override List <string> CreateMetric()
        {
            base.CreateMetric();
            List <string> returnList = new List <string>();

            MOE.Common.Business.ControllerEventLogs eventsTable = new MOE.Common.Business.ControllerEventLogs();

            eventsTable.FillforPreempt(SignalID, StartDate, EndDate);

            string location = GetSignalLocation();

            MOE.Common.Business.Preempt.PreemptRequestChart prChart =
                new MOE.Common.Business.Preempt.PreemptRequestChart(this, eventsTable);
            Chart  chart     = prChart.chart;
            string chartName = CreateFileName();


            //Save an image of the chart
            chart.SaveImage(MetricFileLocation + chartName, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Jpeg);

            returnList.Add(MetricWebPath + chartName);

            return(returnList);
        }
Exemple #10
0
        public ControllerEventLogs CombineDetectorDataByApproachAndType(DateTime startDate, DateTime endDate,
                                                                        Approach approach, bool Has_PCD, bool Has_TMC)
        {
            var gr       = DetectorRepositoryFactory.Create();
            var signalId = approach.SignalID;

            if (Has_TMC)
            {
                ApproachCountDetectors.Clear();
                ApproachCountDetectors.AddRange(RemoveExitDetectors(approach.GetDetectorsForMetricType(5)));
            }
            if (Has_PCD)
            {
                ApproachCountDetectors.Clear();
                ApproachCountDetectors.AddRange(RemoveExitDetectors(approach.GetDetectorsForMetricType(6)));
            }
            var eventsList   = new List <ControllerEventLogs>();
            var MergedEvents = new ControllerEventLogs(signalId, startDate, endDate);

            foreach (var detector in ApproachCountDetectors)
            {
                var li = new List <int> {
                    82
                };
                var cs = new ControllerEventLogs(signalId, startDate, endDate, detector.DetChannel, li);
                eventsList.Add(cs);
            }

            foreach (var Events in eventsList)
            {
                MergedEvents.MergeEvents(Events);
            }


            return(MergedEvents);
        }
Exemple #11
0
        public void SetProgrammedSplits(string signalId)
        {
            Splits.Clear();
            var l = new List <int>();

            for (var i = 130; i <= 151; i++)
            {
                l.Add(i);
            }
            var splitsDt = new ControllerEventLogs(signalId, StartTime, StartTime.AddSeconds(2), l);

            foreach (var row in splitsDt.Events)
            {
                if (row.EventCode == 132)
                {
                    CycleLength = row.EventParam;
                }

                if (row.EventCode == 133)
                {
                    OffsetLength = row.EventParam;
                }

                if (row.EventCode == 134 && !Splits.ContainsKey(1))
                {
                    Splits.Add(1, row.EventParam);
                }
                else if (row.EventCode == 134 && row.EventParam > 0)
                {
                    Splits[1] = row.EventParam;
                }

                if (row.EventCode == 135 && !Splits.ContainsKey(2))
                {
                    Splits.Add(2, row.EventParam);
                }
                else if (row.EventCode == 135 && row.EventParam > 0)
                {
                    Splits[2] = row.EventParam;
                }

                if (row.EventCode == 136 && !Splits.ContainsKey(3))
                {
                    Splits.Add(3, row.EventParam);
                }
                else if (row.EventCode == 136 && row.EventParam > 0)
                {
                    Splits[3] = row.EventParam;
                }

                if (row.EventCode == 137 && !Splits.ContainsKey(4))
                {
                    Splits.Add(4, row.EventParam);
                }
                else if (row.EventCode == 137 && row.EventParam > 0)
                {
                    Splits[4] = row.EventParam;
                }

                if (row.EventCode == 138 && !Splits.ContainsKey(5))
                {
                    Splits.Add(5, row.EventParam);
                }
                else if (row.EventCode == 138 && row.EventParam > 0)
                {
                    Splits[5] = row.EventParam;
                }

                if (row.EventCode == 139 && !Splits.ContainsKey(6))
                {
                    Splits.Add(6, row.EventParam);
                }
                else if (row.EventCode == 139 && row.EventParam > 0)
                {
                    Splits[6] = row.EventParam;
                }

                if (row.EventCode == 140 && !Splits.ContainsKey(7))
                {
                    Splits.Add(7, row.EventParam);
                }
                else if (row.EventCode == 140 && row.EventParam > 0)
                {
                    Splits[7] = row.EventParam;
                }

                if (row.EventCode == 141 && !Splits.ContainsKey(8))
                {
                    Splits.Add(8, row.EventParam);
                }
                else if (row.EventCode == 141 && row.EventParam > 0)
                {
                    Splits[8] = row.EventParam;
                }

                if (row.EventCode == 142 && !Splits.ContainsKey(9))
                {
                    Splits.Add(9, row.EventParam);
                }
                else if (row.EventCode == 142 && row.EventParam > 0)
                {
                    Splits[9] = row.EventParam;
                }

                if (row.EventCode == 143 && !Splits.ContainsKey(10))
                {
                    Splits.Add(10, row.EventParam);
                }
                else if (row.EventCode == 143 && row.EventParam > 0)
                {
                    Splits[10] = row.EventParam;
                }

                if (row.EventCode == 144 && !Splits.ContainsKey(11))
                {
                    Splits.Add(11, row.EventParam);
                }
                else if (row.EventCode == 144 && row.EventParam > 0)
                {
                    Splits[11] = row.EventParam;
                }

                if (row.EventCode == 145 && !Splits.ContainsKey(12))
                {
                    Splits.Add(12, row.EventParam);
                }
                else if (row.EventCode == 145 && row.EventParam > 0)
                {
                    Splits[12] = row.EventParam;
                }

                if (row.EventCode == 146 && !Splits.ContainsKey(13))
                {
                    Splits.Add(13, row.EventParam);
                }
                else if (row.EventCode == 146 && row.EventParam > 0)
                {
                    Splits[13] = row.EventParam;
                }

                if (row.EventCode == 147 && !Splits.ContainsKey(14))
                {
                    Splits.Add(14, row.EventParam);
                }
                else if (row.EventCode == 147 && row.EventParam > 0)
                {
                    Splits[14] = row.EventParam;
                }

                if (row.EventCode == 148 && !Splits.ContainsKey(15))
                {
                    Splits.Add(15, row.EventParam);
                }
                else if (row.EventCode == 148 && row.EventParam > 0)
                {
                    Splits[15] = row.EventParam;
                }

                if (row.EventCode == 149 && !Splits.ContainsKey(16))
                {
                    Splits.Add(16, row.EventParam);
                }
                else if (row.EventCode == 149 && row.EventParam > 0)
                {
                    Splits[16] = row.EventParam;
                }
            }

            if (Splits.Count == 0)
            {
                for (var i = 0; i < 16; i++)
                {
                    Splits.Add(i, 0);
                }
            }
        }
Exemple #12
0
        public override List <string> CreateMetric()
        {
            base.CreateMetric();


            List <string> returnList = new List <string>();
            List <MOE.Common.Business.ControllerEventLogs> tables        = new List <MOE.Common.Business.ControllerEventLogs>();
            List <MOE.Common.Business.ControllerEventLogs> preTestTables = new List <MOE.Common.Business.ControllerEventLogs>();

            MOE.Common.Business.ControllerEventLogs eventsTable = new MOE.Common.Business.ControllerEventLogs();
            eventsTable.FillforPreempt(SignalID, StartDate, EndDate);

            MOE.Common.Business.ControllerEventLogs t1  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t2  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t3  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t4  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t5  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t6  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t7  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t8  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t9  = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t10 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t11 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t12 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t13 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t14 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t15 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t16 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t17 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t18 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t19 = new MOE.Common.Business.ControllerEventLogs();
            MOE.Common.Business.ControllerEventLogs t20 = new MOE.Common.Business.ControllerEventLogs();


            preTestTables.Add(t1);
            preTestTables.Add(t2);
            preTestTables.Add(t3);
            preTestTables.Add(t4);
            preTestTables.Add(t5);
            preTestTables.Add(t6);
            preTestTables.Add(t7);
            preTestTables.Add(t8);
            preTestTables.Add(t9);
            preTestTables.Add(t10);
            preTestTables.Add(t11);
            preTestTables.Add(t12);
            preTestTables.Add(t13);
            preTestTables.Add(t14);
            preTestTables.Add(t15);
            preTestTables.Add(t16);
            preTestTables.Add(t17);
            preTestTables.Add(t18);
            preTestTables.Add(t19);
            preTestTables.Add(t20);



            foreach (MOE.Common.Models.Controller_Event_Log row in eventsTable.Events)
            {
                switch (row.EventParam)
                {
                case 1:
                    t1.Events.Add(row);
                    break;

                case 2:
                    t2.Events.Add(row);
                    break;

                case 3:
                    t3.Events.Add(row);
                    break;

                case 4:
                    t4.Events.Add(row);
                    break;

                case 5:
                    t5.Events.Add(row);
                    break;

                case 6:
                    t6.Events.Add(row);
                    break;

                case 7:
                    t7.Events.Add(row);
                    break;

                case 8:
                    t8.Events.Add(row);
                    break;

                case 9:
                    t9.Events.Add(row);
                    break;

                case 10:
                    t10.Events.Add(row);
                    break;

                case 11:
                    t11.Events.Add(row);
                    break;

                case 12:
                    t12.Events.Add(row);
                    break;

                case 13:
                    t13.Events.Add(row);
                    break;

                case 14:
                    t14.Events.Add(row);
                    break;

                case 15:
                    t15.Events.Add(row);
                    break;

                case 16:
                    t16.Events.Add(row);
                    break;

                case 17:
                    t17.Events.Add(row);
                    break;

                case 18:
                    t18.Events.Add(row);
                    break;

                case 19:
                    t19.Events.Add(row);
                    break;

                case 20:
                    t20.Events.Add(row);
                    break;
                }
            }

            foreach (MOE.Common.Business.ControllerEventLogs t in preTestTables)
            {
                TestForValidRecords(t, tables);
            }

            foreach (MOE.Common.Business.ControllerEventLogs t in tables)
            {
                t.Add105Events(SignalID, StartDate, EndDate);

                MOE.Common.Business.Preempt.PreemptDetailChart detailchart =
                    new MOE.Common.Business.Preempt.PreemptDetailChart(this, t);
                Chart  chart     = detailchart.chart;
                string chartName = CreateFileName();
                chart.SaveImage(MetricFileLocation + chartName, System.Web.UI.DataVisualization.Charting.ChartImageFormat.Jpeg);
                returnList.Add(MetricWebPath + chartName);
            }
            return(returnList);
        }
Exemple #13
0
        public static void SetSimplePlanStrips(PlanCollection PlanCollection, Chart Chart, DateTime StartDate, ControllerEventLogs EventLog)
        {
            int backGroundColor = 1;

            foreach (MOE.Common.Business.Plan plan in PlanCollection.PlanList)
            {
                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 MOE.Common.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++;
            }
        }