public void GetBins15MinutesTest() { BinFactoryOptions binFactoryOptions = new BinFactoryOptions(Convert.ToDateTime("10/17/2017 12:00 AM"), Convert.ToDateTime("10/17/2017 1:00 AM"), null, null, null, null, null, BinFactoryOptions.BinSize.FifteenMinute, BinFactoryOptions.TimeOptions.StartToEnd); var binsContainers = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(binsContainers.Count == 1); Assert.IsTrue(binsContainers[0].Bins.Count == 4); }
protected AggregationByDetector(Models.Detector detector, DetectorAggregationMetricOptions options) { Detector = detector; BinsContainers = BinFactory.GetBins(options.TimeOptions); if (options.ShowEventCount) { DetectorEventCountAggregations = GetdetectorEventCountAggregations(options, detector); } LoadBins(detector, options); }
public override List <BinsContainer> GetBinsContainersByRoute(List <Models.Signal> signals) { var binsContainers = BinFactory.GetBins(TimeOptions); foreach (var signal in signals) { var eventCountAggregationBySignal = new SignalEventCountAggregationBySignal(this, signal); PopulateBinsForRoute(signals, binsContainers, eventCountAggregationBySignal); } return(binsContainers); }
public void GetBins30MinutesTest() { BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/17/2017 12:00 AM"), Convert.ToDateTime("10/17/2017 1:00 AM"), null, null, null, null, null, BinFactoryOptions.BinSize.ThirtyMinute, BinFactoryOptions.TimeOptions.StartToEnd); var bins = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(bins.First().Bins.Count == 2); }
public void GetBinsMonthTest() { BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/1/2017 12:00 AM"), Convert.ToDateTime("12/27/2017 5:00 AM"), null, null, null, null, null, BinFactoryOptions.BinSize.Month, BinFactoryOptions.TimeOptions.StartToEnd); var bins = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(bins.First().Bins.Count == 3); }
public void GetBinsYearTest() { BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/1/2016 12:00 AM"), Convert.ToDateTime("12/27/2018 5:00 AM"), null, null, null, null, null, BinFactoryOptions.BinSize.Year, BinFactoryOptions.TimeOptions.StartToEnd); var binsContainers = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(binsContainers.Count == 1); Assert.IsTrue(binsContainers.First().Bins.Count == 2); }
public void GetBinsDayTest() { BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/1/2017 12:00 AM"), Convert.ToDateTime("10/5/2017 5:00 AM"), null, null, null, null, null, BinFactoryOptions.BinSize.Day, BinFactoryOptions.TimeOptions.StartToEnd); var binsContainers = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(binsContainers.Count == 1); Assert.IsTrue(binsContainers.First().Bins.Count == 4); }
public AggregationByPhase(Models.Signal signal, int phaseNumber, PhaseAggregationMetricOptions options, AggregatedDataType dataType) { BinsContainers = BinFactory.GetBins(options.TimeOptions); PhaseNumber = phaseNumber; //if (options.ShowEventCount) //{ // ApproachEventCountAggregations = GetApproachEventCountAggregations(options, approach, true); // if (approach.PermissivePhaseNumber != null) // { // ApproachEventCountAggregations.AddRange(GetApproachEventCountAggregations(options, approach, false)); // } //} LoadBins(signal, phaseNumber, options, dataType); }
public void GetBinsDayTest() { BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/1/2017 12:00 AM"), Convert.ToDateTime("10/5/2017 5:00 AM"), null, null, null, null, new List <DayOfWeek> { DayOfWeek.Sunday, DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday, DayOfWeek.Saturday }, BinFactoryOptions.BinSize.Day, BinFactoryOptions.TimeOptions.StartToEnd); var binsContainers = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(binsContainers.Count == 1); Assert.IsTrue(binsContainers.First().Bins.Count == 4); }
public AggregationByApproach(Approach approach, ApproachAggregationMetricOptions options, DateTime startDate, DateTime endDate, bool getProtectedPhase, AggregatedDataType dataType) { BinsContainers = BinFactory.GetBins(options.TimeOptions); Approach = approach; if (options.ShowEventCount) { ApproachEventCountAggregations = GetApproachEventCountAggregations(options, approach, true); if (approach.PermissivePhaseNumber != null) { ApproachEventCountAggregations.AddRange(GetApproachEventCountAggregations(options, approach, false)); } } LoadBins(approach, options, getProtectedPhase, dataType); }
public void YearOfWednesdaysShouldReturn52Bins() { List <DayOfWeek> weekdays = new List <DayOfWeek>(); weekdays.Add(DayOfWeek.Wednesday); BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("1/1/2017 12:00 AM"), Convert.ToDateTime("12/31/2017 11:59 PM"), 0, 1, 23, 59, weekdays, BinFactoryOptions.BinSize.Year, BinFactoryOptions.TimeOptions.TimePeriod); var bins = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(bins.First().Bins.Count == 52); }
public void GetBinsHourTimePeriodMultipleDaysTest() { List <DayOfWeek> days = new List <DayOfWeek>(); days.Add(DayOfWeek.Monday); days.Add(DayOfWeek.Tuesday); days.Add(DayOfWeek.Wednesday); days.Add(DayOfWeek.Thursday); days.Add(DayOfWeek.Friday); BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/19/2017 12:00 AM"), Convert.ToDateTime("10/24/2017 1:00 AM"), 0, 0, 1, 0, days, BinFactoryOptions.BinSize.Hour, BinFactoryOptions.TimeOptions.TimePeriod); var bins = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(bins.First().Bins.Count == 4); }
public override List <BinsContainer> GetBinsContainersByRoute(List <Models.Signal> signals) { var aggregations = new ConcurrentBag <SpeedAggregationBySignal>(); Parallel.ForEach(signals, signal => { aggregations.Add(new SpeedAggregationBySignal(this, signal)); }); var binsContainers = BinFactory.GetBins(TimeOptions); foreach (var speedAggregationBySignal in aggregations) { for (var i = 0; i < binsContainers.Count; i++) { for (var binIndex = 0; binIndex < binsContainers[i].Bins.Count; binIndex++) { var bin = binsContainers[i].Bins[binIndex]; bin.Sum += speedAggregationBySignal.BinsContainers[i].Bins[binIndex].Sum; bin.Average = Convert.ToInt32(Math.Round((double)(bin.Sum / signals.Count))); } } } return(binsContainers); }
public void GetBins15MinutesTimePeriodMultipleDaysTest() { List <DayOfWeek> days = new List <DayOfWeek>(); days.Add(DayOfWeek.Monday); days.Add(DayOfWeek.Tuesday); days.Add(DayOfWeek.Wednesday); days.Add(DayOfWeek.Thursday); days.Add(DayOfWeek.Friday); BinFactoryOptions binFactoryOptions = new BinFactoryOptions( Convert.ToDateTime("10/19/2017 12:00 AM"), Convert.ToDateTime("10/24/2017 1:00 AM"), 0, 0, 1, 0, days, BinFactoryOptions.BinSize.FifteenMinute, BinFactoryOptions.TimeOptions.TimePeriod); var binsContainers = BinFactory.GetBins(binFactoryOptions); Assert.IsTrue(binsContainers.Count == 1); Assert.IsTrue(binsContainers[0].Bins.Count == 16); }
public AggregationBySignal(SignalAggregationMetricOptions options, Models.Signal signal) { BinsContainers = BinFactory.GetBins(options.TimeOptions); Signal = signal; }