private static List <RouteSignal> CreateRouteSignals(OldRoute oldRoute, Route newRoute, SPM db) { List <RouteSignal> signals = new List <RouteSignal>(); IApproachRepository appRepo = ApproachRepositoryFactory.Create(db); foreach (var detail in oldRoute.Details) { var approach = appRepo.GetApproachByApproachID(detail.ApproachId); RouteSignal signal = new RouteSignal(); signal.Route = newRoute; signal.Order = detail.Order; signal.SignalId = approach.SignalID; signal.PhaseDirections = CreateRoutePhaseDirections(signal, detail, approach, db); signals.Add(signal); } return(signals); }
public static List <PlanPcd> GetPcdPlans(List <CyclePcd> cycles, DateTime startDate, DateTime endDate, Approach approach, SPM db) { var planEvents = GetPlanEvents(startDate, endDate, approach.SignalID, db); var plans = new List <PlanPcd>(); for (var i = 0; i < planEvents.Count; i++) { if (planEvents.Count - 1 == i) { if (planEvents[i].Timestamp != endDate) { var planCycles = cycles .Where(c => c.StartTime >= planEvents[i].Timestamp && c.StartTime < endDate).ToList(); plans.Add(new PlanPcd(planEvents[i].Timestamp, endDate, planEvents[i].EventParam, planCycles)); } } else { if (planEvents[i].Timestamp != planEvents[i + 1].Timestamp) { var planCycles = cycles.Where(c => c.StartTime >= planEvents[i].Timestamp && c.StartTime < planEvents[i + 1].Timestamp) .ToList(); plans.Add(new PlanPcd(planEvents[i].Timestamp, planEvents[i + 1].Timestamp, planEvents[i].EventParam, planCycles)); } } } return(plans); }
public SignalsRepository() { _db = new SPM(); }
public DetectorRepository() { _db = new SPM(); }
public AgencyRepository(SPM context) { db = context; }
public DetectionTypeRepository() { _db = new SPM(); }
/// <summary> /// Default Constructor Used for PCDs /// </summary> /// <param name="cycleEvents"></param> /// <param name="detectortable"></param> /// <param name="startdate"></param> /// <param name="enddate"></param> /// <param name="signalId"></param> /// <param name="region"></param> public RLMPlanCollection(List <Controller_Event_Log> cycleEvents, DateTime startdate, DateTime enddate, double srlvSeconds, Approach approach, SPM db) { Approach = approach; SRLVSeconds = srlvSeconds; GetPlanCollection(startdate, enddate, cycleEvents, db); }
public ApproachCycleAggregationRepository() { _db = new SPM(); }
public ApproachCycleAggregationRepository(SPM context) { _db = context; }
public PriorityAggregationDatasRepository() { _db = new SPM(); }
public PriorityAggregationDatasRepository(SPM context) { _db = context; }
public void SetActionRepository(SPM context) { db = context; }
public ActionRepository(SPM context) { db = context; }
private static List <RoutePhaseDirection> CreateRoutePhaseDirections(RouteSignal signal, OldRouteDetail detail, Approach approach, SPM db) { List <RoutePhaseDirection> phaseDirecitons = new List <RoutePhaseDirection>(); RoutePhaseDirection phaseDireciton = new RoutePhaseDirection(); phaseDireciton.RouteSignal = signal; phaseDireciton.DirectionTypeId = approach.DirectionTypeID; phaseDireciton.Phase = approach.ProtectedPhaseNumber; phaseDireciton.IsOverlap = approach.IsProtectedPhaseOverlap; phaseDireciton.IsPrimaryApproach = true; phaseDirecitons.Add(phaseDireciton); return(phaseDirecitons); }
public ApproachSpeedAggregationRepository(SPM context) { _db = context; }
public PhasePedAggregationRepository() { _db = new SPM(); }
public DetectionTypeRepository(SPM context) { _db = context; }
public PhasePedAggregationRepository(SPM context) { _db = context; }
protected void AddSpeedDataToChart(Chart chart, Models.Detector detector, DateTime startDate, DateTime endDate, int binSize) { decimal totalDetectorHits = 0; decimal totalOnGreenArrivals = 0; decimal percentArrivalOnGreen = 0; Models.SPM db = new SPM(); List <Models.Speed_Events> SpeedHitsForChart = (from r in db.Speed_Events where r.timestamp > startDate && r.timestamp < endDate && r.DetectorID == detector.DetectorID select r).ToList(); MOE.Common.Models.Repositories.IControllerEventLogRepository CLR = Models.Repositories.ControllerEventLogRepositoryFactory.Create(); List <Models.Controller_Event_Log> phaseevents = CLR.GetEventsByEventCodesParam(detector.Approach.SignalID, StartDate, EndDate, new List <int>() { 0, 1, 7, 8, 9, 10, 11 }, detector.Approach.ProtectedPhaseNumber); List <Models.Controller_Event_Log> detEvents = new List <Controller_Event_Log>(); List <Models.Controller_Event_Log> preemptEvents = new List <Controller_Event_Log>(); PlanCollection Plans = new PlanCollection(phaseevents, detEvents, StartDate, EndDate, detector.Approach, preemptEvents); foreach (MOE.Common.Business.Plan plan in Plans.PlanList) { foreach (Cycle c in plan.CycleCollection) { c.FindSpeedEventsForCycle(SpeedHitsForChart); } plan.AvgSpeedBucketCollection = new AvgSpeedBucketCollection(plan.StartTime, plan.EndTime, plan.CycleCollection, binSize, detector.MinSpeedFilter ?? 5, detector.MovementDelay ?? 0); if (plan.AvgSpeedBucketCollection.Items.Count > 0) { foreach (MOE.Common.Business.AvgSpeedBucket bucket in plan.AvgSpeedBucketCollection.Items) { chart.Series["Average MPH"].Points.AddXY(bucket.StartTime, bucket.AvgSpeed); chart.Series["85th Percentile Speed"].Points.AddXY(bucket.StartTime, bucket.EightyFifth); if (ShowPlanStatistics && ShowPostedSpeed) { chart.Series["Posted Speed"].Points.AddXY(bucket.StartTime, detector.Approach.MPH); } } } } //if arrivals on green is selected add the data to the chart if (ShowPlanStatistics) { if (totalDetectorHits > 0) { percentArrivalOnGreen = (totalOnGreenArrivals / totalDetectorHits) * 100; } else { percentArrivalOnGreen = 0; } SetSpeedPlanStrips(Plans, chart, startDate, detector.MinSpeedFilter ?? 0); } }
public ApproachYellowRedActivationsAggregationRepository() { _db = new SPM(); }
///<summary> ///Removes the given SPM ///</summary> public void RemoveSPM(SPM toRemove) { this.RemoveStructure("SPM", toRemove); }
public ApproachYellowRedActivationsAggregationRepository(SPM context) { _db = context; }
public DetectorRepository(SPM context) { _db = context; }
public ApproachRepository() { _db = new SPM(); }
public void SetAgencyRepository(SPM context) { db = context; }
public ApproachRepository(SPM context) { _db = context; }
public static List <Controller_Event_Log> GetPlanEvents(DateTime startDate, DateTime endDate, string signalId, SPM db) { IControllerEventLogRepository celRepository; if (db == null) { celRepository = ControllerEventLogRepositoryFactory.Create(); } else { celRepository = ControllerEventLogRepositoryFactory.Create(db); } var planEvents = new List <Controller_Event_Log>(); var firstPlanEvent = celRepository.GetFirstEventBeforeDate(signalId, 131, startDate); if (firstPlanEvent != null) { firstPlanEvent.Timestamp = startDate; planEvents.Add(firstPlanEvent); } else { firstPlanEvent = new Controller_Event_Log { Timestamp = startDate, EventCode = 131, EventParam = 0, SignalID = signalId }; planEvents.Add(firstPlanEvent); } var tempPlanEvents = celRepository.GetSignalEventsByEventCode(signalId, startDate, endDate, 131) .OrderBy(e => e.Timestamp).ToList(); tempPlanEvents.Add(new Controller_Event_Log { SignalID = signalId, EventCode = 131, EventParam = 254, Timestamp = endDate }); for (var x = 0; x < tempPlanEvents.Count(); x++) { if (x + 2 < tempPlanEvents.Count()) { if (tempPlanEvents[x].EventParam == tempPlanEvents[x + 1].EventParam) { planEvents.Add(tempPlanEvents[x]); x++; } else { planEvents.Add(tempPlanEvents[x]); } } else { if (tempPlanEvents.Count >= 2 && tempPlanEvents.Last().EventCode == tempPlanEvents[tempPlanEvents.Count() - 2].EventCode) { planEvents.Add(tempPlanEvents[tempPlanEvents.Count() - 2]); } else { planEvents.Add(tempPlanEvents.Last()); } } } return(planEvents); }
public ApproachSpeedAggregationRepository() { _db = new SPM(); }
public SignalsRepository(SPM context) { _db = context; }
public ApproachSplitFailAggregationRepository(SPM context) { _db = context; }