CopyDetector(int ID, bool increaseChannel) //still need to add this detector to the collection of its associated Approach { var detectorRepository = DetectorRepositoryFactory.Create(); var detectorToCopy = detectorRepository.GetDetectorByID(ID); var newGD = new Detector(); var dtr = DetectionTypeRepositoryFactory.Create(); newGD.AllDetectionTypes = dtr.GetAllDetectionTypesNoBasic(); newGD.DateAdded = DateTime.Now; newGD.DetectionTypeIDs = new List <int>(); newGD.DetectionTypes = new List <DetectionType>(); foreach (var dt in detectorToCopy.DetectionTypes) { newGD.DetectionTypeIDs.Add(dt.DetectionTypeID); } newGD.DistanceFromStopBar = detectorToCopy.DistanceFromStopBar; newGD.LaneNumber = detectorToCopy.LaneNumber; newGD.MinSpeedFilter = detectorToCopy.MinSpeedFilter; newGD.MovementTypeID = detectorToCopy.MovementTypeID; newGD.LaneTypeID = detectorToCopy.LaneTypeID; newGD.DecisionPoint = detectorToCopy.DecisionPoint; newGD.MovementDelay = detectorToCopy.MovementDelay; newGD.DetectionHardwareID = detectorToCopy.DetectionHardwareID; newGD.MovementDelay = detectorToCopy.MovementDelay; newGD.DetectorComments = new List <DetectorComment>(); if (increaseChannel) { newGD.DetChannel = detectorRepository.GetMaximumDetectorChannel(detectorToCopy.Approach.VersionID) + 1; } else //when copying signals, signalID changes, and DetChannel should be kept the same. { newGD.DetChannel = detectorToCopy.DetChannel; } if (newGD.DetChannel < 10) { newGD.DetectorID = detectorToCopy.Approach.SignalID + "0" + newGD.DetChannel; } else { newGD.DetectorID = detectorToCopy.Approach.SignalID + newGD.DetChannel; } return(newGD); }
public List <Detector> GetDetectorsForSignalThatSupportAMetricByPhaseNumber(int metricTypeId, int phaseNumber) { var gdr = DetectorRepositoryFactory.Create(); var detectors = new List <Detector>(); foreach (var d in GetDetectorsForSignal()) { if (gdr.CheckReportAvialbilityByDetector(d, metricTypeId) && (d.Approach.ProtectedPhaseNumber == phaseNumber || d.Approach.PermissivePhaseNumber == phaseNumber)) { detectors.Add(d); } } return(detectors); }
public List <Detector> GetDetectorsForSignalThatSupportAMetric(int MetricTypeID) { var gdr = DetectorRepositoryFactory.Create(); var detectors = new List <Detector>(); foreach (var d in GetDetectorsForSignal()) { if (gdr.CheckReportAvialbility(d.DetectorID, MetricTypeID)) { detectors.Add(d); } } return(detectors); }
public List <Detector> GetDetectorsForSignalThatSupportAMetricByApproachDirection(int MetricTypeID, string Direction) { var gdr = DetectorRepositoryFactory.Create(); var detectors = new List <Detector>(); foreach (var d in GetDetectorsForSignal()) { if (gdr.CheckReportAvialbility(d.DetectorID, MetricTypeID) && d.Approach.DirectionType.Description == Direction) { detectors.Add(d); } } return(detectors); }
public ConfigurationRecord(Models.Detector gd) { var gdr = DetectorRepositoryFactory.Create(); var dcr = DetectorCommentRepositoryFactory.Create(); var comment = ""; var c = dcr.GetMostRecentDetectorCommentByDetectorID(gd.ID); if (c != null) { comment = c.CommentText; } Comment = comment; DecisionPoint = gd.DecisionPoint.ToString(); DetectorChannel = gd.DetChannel.ToString(); DetectorID = gd.DetectorID; Direction = gd.Approach.DirectionType.Abbreviation; DistanceFromStopBar = gd.DistanceFromStopBar.ToString(); Enabled = gd.Approach.Signal.Enabled.ToString(); MinSpeedFilter = gd.MinSpeedFilter.ToString(); MovementDelay = gd.MovementDelay.ToString(); MPH = gd.Approach.MPH.ToString(); Overlap = gd.Approach.IsProtectedPhaseOverlap.ToString(); PermissivePhaseNumber = gd.Approach.PermissivePhaseNumber.ToString(); ProtectedPhaseNumber = gd.Approach.ProtectedPhaseNumber.ToString(); DetectionHardware = gd.DetectionHardware.Name; LatencyCorrection = gd.LatencyCorrection.ToString(); if (gd.LaneType != null) { LaneType = gd.LaneType.Description; } if (gd.LaneNumber != null) { LaneNumber = gd.LaneNumber.ToString(); } if (gd.MovementType != null) { MovementType = gd.MovementType.Description; } foreach (var dt in gd.DetectionTypes) { DetectionTypes += dt.Description + "<br/>"; } }
public bool CheckReportAvailabilityForSignal(int MetricTypeID) { var gdr = DetectorRepositoryFactory.Create(); var detectors = new List <Detector>(); foreach (var d in GetDetectorsForSignal()) { if (gdr.CheckReportAvialbility(d.DetectorID, MetricTypeID)) { detectors.Add(d); } } if (detectors.Count > 0) { return(true); } return(false); }
public void Initialize() { db.ClearTables(); XmlToListImporter.LoadControllerEventLog("7185_10_17_2017.xml", db); XmlToListImporter.LoadSignals("signals.xml", db); XmlToListImporter.LoadApproaches("approachesfor7185.xml", db); XmlToListImporter.LoadDetectors("detectorsFor7185.xml", db); XmlToListImporter.AddDetectionTypesToDetectors ("DetectorTypesforDetectorsFor7185.xml", db); XmlToListImporter.AddDetectionTypesToMetricTypes("mtdt.xml", db); MOE.Common.Models.Repositories.SignalsRepositoryFactory.SetSignalsRepository( new InMemorySignalsRepository(db)); MetricTypeRepositoryFactory.SetMetricsRepository(new InMemoryMetricTypeRepository(db)); ApplicationEventRepositoryFactory.SetApplicationEventRepository( new InMemoryApplicationEventRepository(db)); Models.Repositories.DirectionTypeRepositoryFactory.SetDirectionsRepository( new InMemoryDirectionTypeRepository()); ApproachRepositoryFactory.SetApproachRepository(new InMemoryApproachRepository(db)); ControllerEventLogRepositoryFactory.SetRepository(new InMemoryControllerEventLogRepository(db)); DetectorRepositoryFactory.SetDetectorRepository(new InMemoryDetectorRepository(db)); }
private static void RemoveDetectorsFromApproachByFilter(FilterApproach filterApproach, Approach approach) { var detectorRepository = DetectorRepositoryFactory.Create(); var excludedDetectorIds = filterApproach.FilterDetectors.Where(f => f.Exclude).Select(f => f.Id).ToList(); var excludedDetectors = detectorRepository.GetDetectorsByIds(excludedDetectorIds); foreach (var excludedDetector in excludedDetectors) { var detectorsToExclude = approach.Detectors.Where(d => d.LaneNumber == excludedDetector.LaneNumber && d.LaneTypeID == excludedDetector.LaneTypeID && d.MovementTypeID == excludedDetector.MovementTypeID && d.DetectionHardwareID == excludedDetector.DetectionHardwareID && d.DetChannel == excludedDetector.DetChannel ).ToList(); foreach (var detectorToExclude in detectorsToExclude) { approach.Detectors.Remove(detectorToExclude); } } }
public static void InitializeTestDataFor7185Feb012018(InMemoryMOEDatabase db) { db.ClearTables(); XmlToListImporter.LoadControllerEventLog("7185Events02_01_2018.Xml", db); XmlToListImporter.LoadSignals("signals.xml", db); XmlToListImporter.LoadApproaches("approachesfor7185.xml", db); XmlToListImporter.LoadDetectors("detectorsFor7185.xml", db); XmlToListImporter.AddDetectionTypesToDetectors ("DetectorTypesforDetectorsFor7185.xml", db); XmlToListImporter.AddDetectionTypesToMetricTypes("mtdt.xml", db); MOE.Common.Models.Repositories.SignalsRepositoryFactory.SetSignalsRepository( new InMemorySignalsRepository(db)); MetricTypeRepositoryFactory.SetMetricsRepository(new InMemoryMetricTypeRepository(db)); ApplicationEventRepositoryFactory.SetApplicationEventRepository( new InMemoryApplicationEventRepository(db)); DirectionTypeRepositoryFactory.SetDirectionsRepository( new InMemoryDirectionTypeRepository()); SpeedEventRepositoryFactory.SetSignalsRepository(new InMemorySpeedEventRepository(db)); ApproachRepositoryFactory.SetApproachRepository(new InMemoryApproachRepository(db)); ControllerEventLogRepositoryFactory.SetRepository(new InMemoryControllerEventLogRepository(db)); DetectorRepositoryFactory.SetDetectorRepository(new InMemoryDetectorRepository(db)); XmlToListImporter.LoadSpeedEvents("7185speed.xml", db); }
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); }