Beispiel #1
0
        public void LastTwoPlansAreTheSameShouldOnlyAddTheEarierEventTest()
        {
            AddDuplicatePlanEvents(DateTime.Now.AddDays(-1), DateTime.Now, "1001", _db);
            var lastplan = (from r in _db.Controller_Event_Log
                            where r.EventCode == 131
                            orderby r.Timestamp
                            select r).Last();

            var NextToLastPlan = new Controller_Event_Log();

            NextToLastPlan.Timestamp  = lastplan.Timestamp.AddMinutes(-30);
            NextToLastPlan.SignalID   = lastplan.SignalID;
            NextToLastPlan.EventCode  = lastplan.EventCode;
            NextToLastPlan.EventParam = lastplan.EventParam;

            _db.Controller_Event_Log.Add(NextToLastPlan);

            var plans = PlanFactory.GetBasicPlans(DateTime.Now.AddDays(-1), DateTime.Now, "1001");

            Assert.IsTrue(plans.Count == 13);

            bool adjDupPlans = false;

            for (int i = 0; i > plans.Count; i++)
            {
                if (plans[i].PlanNumber == plans[i + i].PlanNumber)
                {
                    adjDupPlans = true;
                }
            }

            Assert.IsFalse(adjDupPlans);
        }
Beispiel #2
0
        public void SimplePlanEventsTest()
        {
            AddEasyPlanEvents(DateTime.Now.AddDays(-1), DateTime.Now, "1001", _db);
            var plans = PlanFactory.GetBasicPlans(DateTime.Now.AddDays(-1), DateTime.Now, "1001");

            Assert.IsTrue(plans.Count == 13);
        }
Beispiel #3
0
        public TMCInfo CreateMetric()
        {
            base.CreateMetric();

            var repository =
                SignalsRepositoryFactory.Create();
            var signal = repository.GetVersionOfSignalByDate(SignalID, StartDate);

            TmcInfo = new TMCInfo();
            var plans = PlanFactory.GetBasicPlans(StartDate, EndDate, SignalID);


            var ltr       = LaneTypeRepositoryFactory.Create();
            var laneTypes = ltr.GetAllLaneTypes();

            var mtr           = MovementTypeRepositoryFactory.Create();
            var movementTypes = mtr.GetAllMovementTypes();

            var dtr        = DirectionTypeRepositoryFactory.Create();
            var directions = dtr.GetAllDirections();


            CreateLaneTypeCharts(signal, "Vehicle", laneTypes, movementTypes, directions, plans, TmcInfo);
            CreateLaneTypeCharts(signal, "Exit", laneTypes, movementTypes, directions, plans, TmcInfo);
            CreateLaneTypeCharts(signal, "Bike", laneTypes, movementTypes, directions, plans, TmcInfo);


            return(TmcInfo);
        }
Beispiel #4
0
        public PreemptServiceMetric(PreemptServiceMetricOptions options,
                                    ControllerEventLogs DTTB)
        {
            Options      = options;
            ServiceChart = ChartFactory.CreateDefaultChart(options);

            //Set the chart properties
            ServiceChart.BorderSkin.SkinStyle   = BorderSkinStyle.None;
            ServiceChart.BorderSkin.BorderColor = Color.Black;
            ServiceChart.BorderSkin.BorderWidth = 1;
            var reportTimespan = Options.EndDate - Options.StartDate;

            SetChartTitle();

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

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            ServiceChart.Legends.Add(chartLegend);
            ServiceChart.ChartAreas[0].AxisY.Maximum  = 10;
            ServiceChart.ChartAreas[0].AxisY.Minimum  = 0;
            ServiceChart.ChartAreas[0].AxisY.Title    = "Preempt Number";
            ServiceChart.ChartAreas[0].AxisY.Interval = 1;
            ServiceChart.ChartAreas[0].AxisX2.Enabled = AxisEnabled.False;

            //Add the point series
            var PreemptSeries = new Series();

            PreemptSeries.ChartType       = SeriesChartType.Point;
            PreemptSeries.BorderDashStyle = ChartDashStyle.Dash;
            PreemptSeries.MarkerStyle     = MarkerStyle.Diamond;
            PreemptSeries.Color           = Color.Black;
            PreemptSeries.Name            = "Preempt Service";
            PreemptSeries.XValueType      = ChartValueType.DateTime;

            //Add the Posts series to ensure the chart is the size of the selected timespan
            var posts = new Series();

            posts.IsVisibleInLegend = false;
            posts.ChartType         = SeriesChartType.Point;
            posts.Color             = Color.White;
            posts.Name       = "Posts";
            posts.XValueType = ChartValueType.DateTime;

            ServiceChart.Series.Add(posts);
            ServiceChart.Series.Add(PreemptSeries);
            ServiceChart.Height = 200;
            AddDataToChart(ServiceChart, Options.StartDate, Options.EndDate, DTTB, Options.SignalID);
            var plans = PlanFactory.GetBasicPlans(Options.StartDate, Options.EndDate, Options.SignalID);

            SetSimplePlanStrips(plans, ServiceChart, Options.StartDate, DTTB);
        }
Beispiel #5
0
        public void DuplicatePlanEventsTest()
        {
            AddDuplicatePlanEvents(DateTime.Now.AddDays(-1), DateTime.Now, "1001", _db);
            var plans = PlanFactory.GetBasicPlans(DateTime.Now.AddDays(-1), DateTime.Now, "1001");

            Assert.IsTrue(plans.Count == 13);

            bool adjDupPlans = false;

            for (int i = 0; i > plans.Count; i++)
            {
                if (plans[i].PlanNumber == plans[i + i].PlanNumber)
                {
                    adjDupPlans = true;
                }
            }

            Assert.IsFalse(adjDupPlans);
        }
Beispiel #6
0
        public PreemptRequestChart(PreemptServiceRequestOptions options, ControllerEventLogs dttb)
        {
            Options = options;
            //Set the chart properties
            PreemptServiceRequestChart = ChartFactory.CreateDefaultChart(options);
            PreemptServiceRequestChart.ImageStorageMode = ImageStorageMode.UseImageLocation;
            ChartFactory.SetImageProperties(PreemptServiceRequestChart);
            PreemptServiceRequestChart.BorderSkin.SkinStyle   = BorderSkinStyle.None;
            PreemptServiceRequestChart.BorderSkin.BorderColor = Color.Black;
            PreemptServiceRequestChart.BorderSkin.BorderWidth = 1;
            var reportTimespan = Options.EndDate - Options.StartDate;

            SetChartTitle();

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

            chartLegend.Name    = "MainLegend";
            chartLegend.Docking = Docking.Left;
            PreemptServiceRequestChart.Legends.Add(chartLegend);
            PreemptServiceRequestChart.ChartAreas[0].AxisY.Maximum  = 10;
            PreemptServiceRequestChart.ChartAreas[0].AxisX2.Enabled = AxisEnabled.False;

            // top chart

            PreemptServiceRequestChart.ChartAreas[0].AxisY.Minimum           = 0;
            PreemptServiceRequestChart.ChartAreas[0].AxisY.Title             = "Preempt Number";
            PreemptServiceRequestChart.ChartAreas[0].AxisY.Interval          = 1;
            PreemptServiceRequestChart.ChartAreas[0].AxisX.Title             = "Time (Hours:Minutes)";
            PreemptServiceRequestChart.ChartAreas[0].AxisX.IntervalType      = DateTimeIntervalType.Hours;
            PreemptServiceRequestChart.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm";
            if (reportTimespan.Days <= 1)
            {
                if (reportTimespan.Hours > 1)
                {
                    PreemptServiceRequestChart.ChartAreas[0].AxisX.Interval = 1;
                }
                else
                {
                    PreemptServiceRequestChart.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm";
                }
            }
            PreemptServiceRequestChart.ChartAreas[0].AxisX.Minimum = Options.StartDate.ToOADate();
            PreemptServiceRequestChart.ChartAreas[0].AxisX.Maximum = Options.EndDate.ToOADate();

            //Add the point series

            var PreemptSeries = new Series();

            PreemptSeries.ChartType       = SeriesChartType.Point;
            PreemptSeries.BorderDashStyle = ChartDashStyle.Dash;
            PreemptSeries.MarkerStyle     = MarkerStyle.Diamond;
            PreemptSeries.Color           = Color.Black;
            PreemptSeries.Name            = "Preempt Request";
            PreemptSeries.XValueType      = ChartValueType.DateTime;


            //Add the Posts series to ensure the chart is the size of the selected timespan
            var posts = new Series();

            posts.IsVisibleInLegend = false;
            posts.ChartType         = SeriesChartType.Point;
            posts.Color             = Color.White;
            posts.Name       = "Posts";
            posts.XValueType = ChartValueType.DateTime;

            PreemptServiceRequestChart.Series.Add(posts);
            PreemptServiceRequestChart.Series.Add(PreemptSeries);
            PreemptServiceRequestChart.Height = 200;
            //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(Options.StartDate, 0);
            //chart.Series["Posts"].Points.AddXY(Options.EndDate, 0);

            AddDataToChart(PreemptServiceRequestChart, Options.StartDate, Options.EndDate, dttb, Options.SignalID);
            var plans = PlanFactory.GetBasicPlans(Options.StartDate, Options.EndDate, Options.SignalID);

            SetSimplePlanStrips(plans, PreemptServiceRequestChart, Options.StartDate, dttb);
        }