public DetectorSpeed(Models.Detector detector, DateTime startDate, DateTime endDate, int binSize, bool getPermissivePhase) { StartDate = startDate; EndDate = endDate; Cycles = CycleFactory.GetSpeedCycles(startDate, endDate, getPermissivePhase, detector); TotalDetectorHits = Cycles.Sum(c => c.SpeedEvents.Count); Plans = PlanFactory.GetSpeedPlans(Cycles, startDate, endDate, detector.Approach); var movementDelay = 0; if (detector.MovementDelay != null) { movementDelay = detector.MovementDelay.Value; } AvgSpeedBucketCollection = new AvgSpeedBucketCollection(startDate, endDate, binSize, movementDelay, Cycles); }