public override List <string> CreateMetric() { base.CreateMetric(); //EndDate = EndDate.AddSeconds(59); var returnString = new List <string>(); var sr = SignalsRepositoryFactory.Create(); var signal = sr.GetVersionOfSignalByDate(SignalID, StartDate); var metricApproaches = signal.GetApproachesForSignalThatSupportMetric(MetricTypeID); if (metricApproaches.Count > 0) { //Parallel.ForEach(metricApproaches, approach => foreach (Approach approach in metricApproaches) { if (approach.ProtectedPhaseNumber > 0) { var splitFailPhase = new SplitFailPhase(approach, this, false); var chartName = CreateFileName(); GetChart(splitFailPhase, chartName, returnString, false, approach); } if (approach.PermissivePhaseNumber != null && approach.PermissivePhaseNumber > 0) { var splitFailPermissivePhase = new SplitFailPhase(approach, this, true); var permChartName = CreateFileName(); GetChart(splitFailPermissivePhase, permChartName, returnString, true, approach); } } } //); return(returnString); }
public void SplitFailPhaseTest() { SplitFailOptions splitFailOptions = new SplitFailOptions { StartDate = new DateTime(2017, 10, 17, 17, 0, 0), EndDate = new DateTime(2017, 10, 17, 17, 11, 1), FirstSecondsOfRed = 5, SignalID = "7185", MetricTypeID = 12, ShowAvgLines = true, ShowPercentFailLines = true, ShowFailLines = true, Y2AxisMax = null, YAxisMin = 0, Y2AxisMin = 0, YAxisMax = null }; var signalRepository = SignalsRepositoryFactory.Create(); var signal = signalRepository.GetLatestVersionOfSignalBySignalID("7185"); var approach = signal.Approaches.Where(a => a.ApproachID == 5593).FirstOrDefault(); SplitFailPhase splitFailPhase = new SplitFailPhase(approach, splitFailOptions, true); Assert.IsTrue(splitFailPhase.Cycles[4].StartTime == new DateTime(2017, 10, 17, 17, 9, 33)); Assert.IsTrue(splitFailPhase.Cycles[4].YellowEvent == new DateTime(2017, 10, 17, 17, 10, 09)); Assert.IsTrue(splitFailPhase.Cycles[4].RedEvent == new DateTime(2017, 10, 17, 17, 10, 13)); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen.Count == 2); DateTime date1 = new DateTime(2017, 10, 17, 17, 1, 59, 500); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[0].DetectorOn == date1); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[0].DetectorOff == new DateTime(2017, 10, 17, 17, 9, 43, 800)); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[0].DurationInMilliseconds == 464300); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[1].DetectorOn == new DateTime(2017, 10, 17, 17, 9, 55, 400)); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[1].DetectorOff == new DateTime(2017, 10, 17, 17, 10, 6, 300)); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringGreen[1].DurationInMilliseconds == 10900); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed.Count == 1); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed[0].DetectorOn == new DateTime(2017, 10, 17, 17, 10, 9, 200)); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed[0].DetectorOff == new DateTime(2017, 10, 17, 17, 10, 13, 300)); Assert.IsTrue(splitFailPhase.Cycles[4].ActivationsDuringRed[0].DurationInMilliseconds == 4100); Assert.IsTrue(splitFailPhase.Cycles[4].GreenOccupancyTimeInMilliseconds == 21700.0); Assert.IsTrue(splitFailPhase.Cycles[4].TotalGreenTimeMilliseconds == 36000.0); Assert.IsTrue(splitFailPhase.Cycles[4].RedOccupancyTimeInMilliseconds == 300.0); Assert.IsTrue(splitFailPhase.Cycles[4].RedOccupancyPercent == 6.0); Assert.IsTrue(splitFailPhase.Cycles[4].FirstSecondsOfRed == 5); Assert.IsTrue(Math.Round(splitFailPhase.Cycles[4].GreenOccupancyPercent) == 60.0); }
public RLMSignalPhaseCollection(DateTime startDate, DateTime endDate, string signalID, int binSize, double srlvSeconds) { var metricTypeID = 11; var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetVersionOfSignalByDate(signalID, startDate); SevereRedLightViolationsSeconds = srlvSeconds; var approachesForMetric = signal.GetApproachesForSignalThatSupportMetric(metricTypeID); //If there are phases in the database add the charts if (approachesForMetric.Any()) { foreach (var approach in approachesForMetric) { SignalPhaseList.Add(new RLMSignalPhase( startDate, endDate, binSize, SevereRedLightViolationsSeconds, approach, false)); if (approach.PermissivePhaseNumber != null && approach.PermissivePhaseNumber > 0) { SignalPhaseList.Add(new RLMSignalPhase( startDate, endDate, binSize, SevereRedLightViolationsSeconds, approach, true)); } } } }
public double GetTmcVolume(DateTime startDate, DateTime endDate, string signalId, int phase) { ISignalsRepository repository = SignalsRepositoryFactory.Create(); var signal = repository.GetVersionOfSignalByDate(signalId, startDate); List <Detector> graphDetectors = signal.GetDetectorsForSignalByPhaseNumber(phase); List <int> tmcChannels = new List <int>(); foreach (Detector gd in graphDetectors) { foreach (DetectionType dt in gd.DetectionTypes) { if (dt.DetectionTypeID == 4) { tmcChannels.Add(gd.DetChannel); } } } double count = (from cel in _db.Controller_Event_Log where cel.Timestamp >= startDate && cel.Timestamp < endDate && cel.SignalID == signalId && tmcChannels.Contains(cel.EventParam) && cel.EventCode == 82 select cel).Count(); return(count); }
public override List <string> CreateMetric() { base.CreateMetric(); var sr = SignalsRepositoryFactory.Create(); var signal = sr.GetVersionOfSignalByDate(SignalID, StartDate); var speedApproaches = signal.GetApproachesForSignalThatSupportMetric(10); if (speedApproaches.Count > 0) { foreach (var approach in speedApproaches) { var speedDets = approach.GetDetectorsForMetricType(10); foreach (var det in speedDets) { var chart = GetNewSpeedChart(det); AddSpeedDataToChart(chart, det, StartDate, EndDate, SelectedBinSize); var chartName = CreateFileName(); chart.ImageLocation = MetricFileLocation + chartName; chart.SaveImage(MetricFileLocation + chartName, ChartImageFormat.Jpeg); ReturnList.Add(MetricWebPath + chartName); } } } return(ReturnList); }
public void SetPagedList() { var repository = SignalsRepositoryFactory.Create(); //MOE.Common.Models.Repositories.SignalsRepositoryTest repository = // new MOE.Common.Models.Repositories.SignalsRepositoryTest(); var queryable = repository.GetAllEnabledSignals().AsQueryable(); if (SelectedFilterID != null) { if (SelectedFilterID == 1) { queryable = queryable.Where(q => q.SignalID.Contains(FilterCriteria)).Select(q => q); } else if (SelectedFilterID == 2) { queryable = queryable.Where(q => q.PrimaryName.ToUpper().Contains(FilterCriteria.ToUpper())) .Select(q => q); } else if (SelectedFilterID == 3) { queryable = queryable.Where(q => q.SecondaryName.ToUpper().Contains(FilterCriteria.ToUpper())) .Select(q => q); } } Signals = queryable.ToPagedList(Page, 5, OrderField, OrderDirection); }
private void GetMetricsForSignal(string signalID) { var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetLatestVersionOfSignalBySignalID(signalID); MetricsList = new List <SelectListItem>(); var availableMetrics = signal.GetAvailableMetricsVisibleToWebsite().Where(m => m.ShowOnWebsite).OrderBy(m => m.DisplayOrder); if (signal != null) { foreach (var m in availableMetrics) { if (SelectedMetricID != null && SelectedMetricID == m.MetricID) { MetricsList.Add(new SelectListItem { Value = m.MetricID.ToString(), Text = m.ChartName, Selected = true }); } else { MetricsList.Add(new SelectListItem { Value = m.MetricID.ToString(), Text = m.ChartName }); } } } }
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); }
public void Initialize() { Db.ClearTables(); Db.PopulateSignal(); Db.PopulateSignalsWithApproaches(); Db.PopulateApproachesWithDetectors(); var signals = Db.Signals; foreach (var signal in signals) { Db.PopulatePreemptAggregations(Convert.ToDateTime("1/1/2016"), Convert.ToDateTime("1/1/2018"), signal.SignalID, signal.VersionID); } ApproachRepositoryFactory.SetApproachRepository(new InMemoryApproachRepository(Db)); PreemptAggregationDatasRepositoryFactory.SetArchivedMetricsRepository( new InMemoryPreemptAggregationDatasRepository(Db)); MOE.Common.Models.Repositories.SignalsRepositoryFactory.SetSignalsRepository( new InMemorySignalsRepository(Db)); MetricTypeRepositoryFactory.SetMetricsRepository(new InMemoryMetricTypeRepository(Db)); ApplicationEventRepositoryFactory.SetApplicationEventRepository(new InMemoryApplicationEventRepository(Db)); DetectorAggregationsRepositoryFactory.SetDetectorAggregationRepository(new InMemoryDetectorAggregationsRepository(Db)); Models.Repositories.DirectionTypeRepositoryFactory.SetDirectionsRepository( new InMemoryDirectionTypeRepository()); SignalsRepository = SignalsRepositoryFactory.Create(); PreemptAggregationDatasRepositoryFactory.SetArchivedMetricsRepository(new InMemoryPreemptAggregationDatasRepository(Db)); }
public void Initialize() { Db.ClearTables(); Db.PopulateSignal(); Db.PopulateSignalsWithApproaches(); Db.PopulateApproachesWithDetectors(); var signals = Db.Signals; foreach (var signal in signals) { foreach (var approach in signal.Approaches) { Db.PopulateApproachSplitFailAggregationsWithRandomRecords(Convert.ToDateTime("1/1/2016"), Convert.ToDateTime("1/1/2018"), approach); } } ApproachSplitFailAggregationRepositoryFactory.SetApplicationEventRepository( new InMemoryApproachSplitFailAggregationRepository(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()); SignalsRepository = SignalsRepositoryFactory.Create(); }
public override List <string> CreateMetric() { base.CreateMetric(); //EndDate = EndDate.AddSeconds(59); var returnString = new List <string>(); var sr = SignalsRepositoryFactory.Create(); var signal = sr.GetVersionOfSignalByDate(SignalID, StartDate); var metricApproaches = signal.GetApproachesForSignalThatSupportMetric(MetricTypeID); if (metricApproaches.Count > 0) { List <SplitFailPhase> splitFailPhases = new List <SplitFailPhase>(); foreach (Approach approach in metricApproaches) { if (approach.PermissivePhaseNumber != null && approach.PermissivePhaseNumber > 0) { splitFailPhases.Add(new SplitFailPhase(approach, this, true)); } if (approach.ProtectedPhaseNumber > 0) { splitFailPhases.Add(new SplitFailPhase(approach, this, false)); } } splitFailPhases = splitFailPhases.OrderBy(s => s.PhaseNumberSort).ToList(); foreach (var splitFailPhase in splitFailPhases) { GetChart(splitFailPhase, returnString); } } return(returnString); }
protected void GetSignalObjects() { try { if (Signals == null) { Signals = new List <Models.Signal>(); } if (Signals.Count == 0) { var signalRepository = SignalsRepositoryFactory.Create(); foreach (var filterSignal in FilterSignals) { if (!filterSignal.Exclude) { var signals = signalRepository.GetSignalsBetweenDates(filterSignal.SignalId, StartDate, EndDate); foreach (var signal in signals) { RemoveApproachesByFilter(filterSignal, signal); signal.Approaches = signal.Approaches.OrderBy(a => a.ProtectedPhaseNumber).ToList(); } Signals.AddRange(signals); } } } } catch (Exception e) { var errorLog = ApplicationEventRepositoryFactory.Create(); errorLog.QuickAdd(Assembly.GetExecutingAssembly().GetName().ToString(), GetType().DisplayName(), e.TargetSite.ToString(), ApplicationEvent.SeverityLevels.High, e.Message); throw new Exception("Unable to apply signal filter"); } }
public SpeedExportApproachDirectionCollection(DateTime startDate, DateTime endDate, string signalID, int binSize) { var signalRepository = SignalsRepositoryFactory.Create(); var signal = signalRepository.GetLatestVersionOfSignalBySignalID(signalID); var distinctPhases = signal.GetDetectorsForSignalThatSupportAMetric(10); //If there are phases in the database add the charts if (distinctPhases.Count > 0) { foreach (var detector in distinctPhases) { //Get the phase var phase = detector.Approach.ProtectedPhaseNumber; var direction = detector.Approach.DirectionType.Description; var movementDelay = detector.MovementDelay.Value; var Decision_Point = detector.DecisionPoint.Value; var MPH = detector.Approach.MPH.Value; var approachDirection = new SpeedExportApproachDirection( startDate, endDate, signalID, phase, detector.DetectorID , direction, MPH, movementDelay, Decision_Point, binSize, detector.MinSpeedFilter.Value, detector.DistanceFromStopBar.Value); List.Add(approachDirection); } } }
public SignalPhaseCollection(DateTime startDate, DateTime endDate, string signalID, bool showVolume, int binSize, int metricTypeId) { var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetVersionOfSignalByDate(signalID, startDate); var approaches = signal.GetApproachesForSignalThatSupportMetric(metricTypeId); if (signal.Approaches != null && approaches.Count > 0) { //Parallel.ForEach(approaches, approach => foreach (Models.Approach approach in approaches) { var protectedSignalPhase = new SignalPhase(startDate, endDate, approach, showVolume, binSize, metricTypeId, false); SignalPhaseList.Add(protectedSignalPhase); if (approach.PermissivePhaseNumber.HasValue) { var permissiveSignalPhase = new SignalPhase(startDate, endDate, approach, showVolume, binSize, metricTypeId, true); SignalPhaseList.Add(permissiveSignalPhase); } }//); //TODO: Should we remove phases with no cycles? SignalPhaseList = SignalPhaseList.OrderBy(s => s.Approach.ProtectedPhaseNumber).ToList(); } }
public override List <string> CreateMetric() { base.CreateMetric(); var signalRepository = SignalsRepositoryFactory.Create(); Signal = signalRepository.GetVersionOfSignalByDate(SignalID, StartDate); MetricTypeID = 6; var chart = new Chart(); var metricApproaches = Signal.GetApproachesForSignalThatSupportMetric(MetricTypeID); if (metricApproaches.Count > 0) { foreach (var approach in metricApproaches) { var signalPhase = new SignalPhase(StartDate, EndDate, approach, ShowVolumes, SelectedBinSize, MetricTypeID, false); chart = GetNewChart(); AddDataToChart(chart, signalPhase); var chartName = CreateFileName(); chart.ImageLocation = MetricFileLocation + chartName; chart.SaveImage(MetricFileLocation + chartName, ChartImageFormat.Jpeg); ReturnList.Add(MetricWebPath + chartName); } } return(ReturnList); }
static void Main(string[] args) { IApplicationEventRepository errorRepository = ApplicationEventRepositoryFactory.Create(); SignalFtpOptions signalFtpOptions = new SignalFtpOptions( Convert.ToInt32(ConfigurationManager.AppSettings["SNMPTimeout"]), Convert.ToInt32(ConfigurationManager.AppSettings["SNMPRetry"]), Convert.ToInt32(ConfigurationManager.AppSettings["SNMPPort"]), Convert.ToBoolean(ConfigurationManager.AppSettings["DeleteFilesAfterFTP"]), ConfigurationManager.AppSettings["LocalDirectory"], Convert.ToInt32(ConfigurationManager.AppSettings["FTPConnectionTimeoutInSeconds"]), Convert.ToInt32(ConfigurationManager.AppSettings["FTPReadTimeoutInSeconds"]), Convert.ToBoolean(ConfigurationManager.AppSettings["skipCurrentLog"]), Convert.ToBoolean(ConfigurationManager.AppSettings["RenameDuplicateFiles"]), Convert.ToInt32(ConfigurationManager.AppSettings["waitBetweenFileDownloadMilliseconds"]) ); int maxThreads = Convert.ToInt32(ConfigurationManager.AppSettings["MaxThreads"]); MOE.Common.Models.SPM db = new MOE.Common.Models.SPM(); ISignalsRepository signalsRepository = SignalsRepositoryFactory.Create(db); var signals = signalsRepository.GetLatestVersionOfAllSignalsForFtp(); var options = new ParallelOptions { MaxDegreeOfParallelism = maxThreads }; Parallel.ForEach(signals.AsEnumerable(), options, signal => //foreach (var signal in signals) { try { MOE.Common.Business.SignalFtp signalFtp = new MOE.Common.Business.SignalFtp(signal, signalFtpOptions); if (!Directory.Exists(signalFtpOptions.LocalDirectory + signal.SignalID)) { Directory.CreateDirectory(signalFtpOptions.LocalDirectory + signal.SignalID); } //Get the records over FTP if (CheckIfIPAddressIsValid(signal)) { try { signalFtp.GetCurrentRecords(); } catch (AggregateException ex) { Console.WriteLine("Error At Highest Level for signal " + ex.Message); errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop", MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium, "Error At Highest Level for signal " + signal.SignalID); } } } catch (AggregateException ex) { Console.WriteLine("Error At Highest Level for signal " + ex.Message); errorRepository.QuickAdd("FTPFromAllControllers", "Main", "Main Loop", MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium, "Error At Highest Level for signal " + signal.SignalID); } } ); }
private string GetSignalLcation(string SignalID) { var sr = SignalsRepositoryFactory.Create(); var location = sr.GetSignalLocation(SignalID); return(location); }
public void TestMetric24HrVs15Min() { //5030 has 8 phases, with 6 to 8 detectors per phase. There is Stop Bar, Lane-by-Lane Count, // Lane-by-Lane with Speed Restriction, Advanced Count, Advanced Spped as the detectin types for he different // detectors. THis signals has everything and is a good one to test for everything UDOT uses for a signal. var signalId = "5030"; int metricTypeId = 6; var stringstartTime = "10/24/2018 3:30 PM"; var startTime = DateTime.Parse(stringstartTime, System.Globalization.CultureInfo.InvariantCulture); var endTime24Hrs = startTime.AddDays(1); var endTime15Mins = startTime.AddMinutes(15); var signalRepository = SignalsRepositoryFactory.Create(); var signal = signalRepository.GetVersionOfSignalByDate(signalId, startTime); var metricApproaches = signal.GetApproachesForSignalThatSupportMetric(metricTypeId); if (metricApproaches.Count > 0) { foreach (var approach in metricApproaches) { var signalPhase24Hrs = new Common.Business.SignalPhase(startTime, endTime24Hrs, approach, true, 15, metricTypeId, false); var signalPhase15Mins = new Common.Business.SignalPhase(startTime, endTime15Mins, approach, true, 15, metricTypeId, false); Assert.IsTrue(signalPhase24Hrs.Cycles.Count > signalPhase15Mins.Cycles.Count); for (int i = 0; i < signalPhase15Mins.Cycles.Count; i++) { Assert.IsTrue(signalPhase24Hrs.Cycles[i].EndTime == signalPhase15Mins.Cycles[i].EndTime); Assert.IsTrue(signalPhase24Hrs.Cycles[i].GreenEvent == signalPhase15Mins.Cycles[i].GreenEvent); Assert.IsTrue(signalPhase24Hrs.Cycles[i].GreenLineY == signalPhase15Mins.Cycles[i].GreenLineY); Assert.IsTrue(signalPhase24Hrs.Cycles[i].RedLineY == signalPhase15Mins.Cycles[i].RedLineY); Assert.IsTrue(signalPhase24Hrs.Cycles[i].StartTime == signalPhase15Mins.Cycles[i].StartTime); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalArrivalOnGreen == signalPhase15Mins.Cycles[i].TotalArrivalOnGreen); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalArrivalOnRed == signalPhase15Mins.Cycles[i].TotalArrivalOnRed); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalArrivalOnYellow == signalPhase15Mins.Cycles[i].TotalArrivalOnYellow); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalDelay == signalPhase15Mins.Cycles[i].TotalDelay); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalGreenTime == signalPhase15Mins.Cycles[i].TotalGreenTime); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalGreenTimeMilliseconds == signalPhase15Mins.Cycles[i].TotalGreenTimeMilliseconds); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalRedTime == signalPhase15Mins.Cycles[i].TotalRedTime); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalRedTimeMilliseconds == signalPhase15Mins.Cycles[i].TotalRedTimeMilliseconds); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalTime == signalPhase15Mins.Cycles[i].TotalTime); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalTimeMilliseconds == signalPhase15Mins.Cycles[i].TotalTimeMilliseconds); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalVolume == signalPhase15Mins.Cycles[i].TotalVolume); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalYellowTime == signalPhase15Mins.Cycles[i].TotalYellowTime); Assert.IsTrue(signalPhase24Hrs.Cycles[i].TotalYellowTimeMilliseconds == signalPhase15Mins.Cycles[i].TotalYellowTimeMilliseconds); Assert.IsTrue(signalPhase24Hrs.Cycles[i].YellowEvent == signalPhase15Mins.Cycles[i].YellowEvent); Assert.IsTrue(signalPhase24Hrs.Cycles[i].YellowLineY == signalPhase15Mins.Cycles[i].YellowLineY); for (int j = 0; j < signalPhase15Mins.Cycles[i].DetectorEvents.Count; j++) { Assert.IsTrue(signalPhase24Hrs.Cycles[i].DetectorEvents[j].ArrivalType == signalPhase15Mins.Cycles[i].DetectorEvents[j].ArrivalType); Assert.IsTrue(signalPhase24Hrs.Cycles[i].DetectorEvents[j].Delay == signalPhase15Mins.Cycles[i].DetectorEvents[j].Delay); Assert.IsTrue(signalPhase24Hrs.Cycles[i].DetectorEvents[j].TimeStamp == signalPhase15Mins.Cycles[i].DetectorEvents[j].TimeStamp); Assert.IsTrue(signalPhase24Hrs.Cycles[i].DetectorEvents[j].YPoint == signalPhase15Mins.Cycles[i].DetectorEvents[j].YPoint); } } } } }
public void CopyVersionTest() { var signalsRepository = SignalsRepositoryFactory.Create(); Signal signal = signalsRepository.GetLatestVersionOfSignalBySignalID("7185"); SignalsController signalsController = new SignalsController(); var actionResult = signalsController.CopyVersion(signal); Assert.IsNotNull(actionResult); }
public SignalInfoBoxViewModel(string signalID) { var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetLatestVersionOfSignalBySignalID(signalID); SetTitle(signal); SetDescription(signal); SetMetrics(signal); SignalID = signalID; }
private void GetMetricsForSignal(string signalID) { var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetLatestVersionOfSignalBySignalID(signalID); MetricsList = new List <SelectListItem>(); //var availableMetrics = signal.GetAvailableMetricsVisibleToWebsite().Where(m => m.ShowOnWebsite); var availableMetrics = signal.GetAvailableMetricsVisibleToWebsite().Where(m => m.ShowOnWebsite).OrderBy(m => m.DisplayOrder); if (signal != null) { foreach (var m in availableMetrics) { if (SelectedMetricID != null && SelectedMetricID == m.MetricID) { // Andre -- Commented out parts added to try to get this to make the Pudue Phase Tremination hte default chart. // this is for bug 894. This will select it, but not get the options showing for it. Bug 896 is higher on the list for Mark Taylor. //if (m.ChartName.Contains("Purdue Phase Termination")) //{ MetricsList.Add(new SelectListItem { Value = m.MetricID.ToString(), Text = m.ChartName, Selected = true }); //} //else //{ //MetricsList.Add(new SelectListItem //{ // Value = m.MetricID.ToString(), // Text = m.ChartName // //Selected = true //}); //} } else { //if (m.ChartName.Contains("Purdue Phase Termination")) //{ // MetricsList.Add(new SelectListItem {Value = m.MetricID.ToString(), Text = m.ChartName, Selected = true}); //} //else //{ MetricsList.Add(new SelectListItem { Value = m.MetricID.ToString(), Text = m.ChartName }); //} } } } }
private static int FindChannel(string SignalID, int Phase) { var smh = SignalsRepositoryFactory.Create(); var sig = smh.GetLatestVersionOfSignalBySignalID(SignalID); var dets = sig.GetDetectorsForSignalByPhaseNumber(Phase); if (dets.Count() > 0) { return(dets.FirstOrDefault().DetChannel); } return(0); }
/// <summary> /// Alternate Constructor for PCD type data. /// </summary> /// <param name="signalid"></param> /// <param name="approach"></param> public DetectorCollection(Approach approach) { SignalId = approach.SignalID; var repository = SignalsRepositoryFactory.Create(); var PCDDetectors = approach.GetDetectorsForMetricType(6); foreach (var row in PCDDetectors) { var Detector = new Detector(row); Items.Add(Detector); } }
//public List<SPMWatchDogErrorEvent> ErrorMessages = new List<SPMWatchDogErrorEvent>(); public void StartScan() { if (!Settings.WeekdayOnly || Settings.WeekdayOnly && ScanDate.DayOfWeek != DayOfWeek.Saturday && ScanDate.DayOfWeek != DayOfWeek.Sunday) { var watchDogErrorEventRepository = SPMWatchDogErrorEventRepositoryFactory.Create(); var signalRepository = SignalsRepositoryFactory.Create(); var signals = signalRepository.EagerLoadAllSignals(); CheckForRecords(signals); CheckAllSignals(signals); CheckSignalsWithData(); CheckApplicationEvents(signals); CreateAndSendEmail(); } }
public ActionResult AddSignal(string id) { var signalRepository = SignalsRepositoryFactory.Create(); if (!String.IsNullOrEmpty(id) && !signalRepository.Exists(id)) { DatabaseArchiveExcludedSignal databaseArchiveExcludedSignal = new DatabaseArchiveExcludedSignal(); databaseArchiveExcludedSignal.SignalId = id; databaseArchiveExcludedSignal.SignalDescription = signalRepository.GetSignalDescription(id); var excludedSignalRepository = DatabaseArchiveExcludedSignalsRepositoryFactory.Create(); excludedSignalRepository.AddToExcludedList(id); return(PartialView("EditorTemplates/DatabaseArchiveExcludedSignal", databaseArchiveExcludedSignal)); } return(Content("Unable to load signal")); }
public Signal(string signalID, DateTime startDate, DateTime endDate, List <int> eventCodes, int startOfCycle) { SignalID = signalID; StartDate = startDate; EndDate = endDate; EventCodes = eventCodes; var repository = SignalsRepositoryFactory.Create(); SignalModel = repository.GetLatestVersionOfSignalBySignalID(signalID); Detectors = SignalModel.GetDetectorsForSignal(); Plans = new PlansBase(signalID, startDate, endDate); GetPhases(startOfCycle); }
/// <summary> /// Constructor Used for Split monitor /// </summary> /// <param name="phasenumber"></param> /// <param name="signalID"></param> /// <param name="CycleEventsTable"></param> public AnalysisPhase(int phasenumber, string signalID, List <Controller_Event_Log> CycleEventsTable) { var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetLatestVersionOfSignalBySignalID(signalID); PhaseNumber = phasenumber; SignalID = signalID; IsOverlap = false; var pedEvents = FindPedEvents(CycleEventsTable, phasenumber); var phaseEvents = FindPhaseEvents(CycleEventsTable, phasenumber); Cycles = new AnalysisPhaseCycleCollection(phasenumber, SignalID, phaseEvents, pedEvents); var approach = signal.Approaches.FirstOrDefault(a => a.ProtectedPhaseNumber == phasenumber); Direction = approach != null ? approach.DirectionType.Description : "Unknown"; }
public override List <string> CreateMetric() { base.CreateMetric(); var signalsRepository = SignalsRepositoryFactory.Create(); var signal = signalsRepository.GetVersionOfSignalByDate(SignalID, StartDate); CreateLegend(); var eventLogs = new ControllerEventLogs(SignalID, StartDate, EndDate, new List <int> { EVENT_DET, EVENT_GREEN, EVENT_RED }); //Get phase + check for opposing phase before creating chart var ebPhase = signal.Approaches.FirstOrDefault(x => x.ProtectedPhaseNumber == 6); if (ebPhase != null && signal.Approaches.Any(x => x.ProtectedPhaseNumber == 2)) { CreateChart(ebPhase, eventLogs, signal); } var nbPhase = signal.Approaches.FirstOrDefault(x => x.ProtectedPhaseNumber == 8); if (nbPhase != null && signal.Approaches.Any(x => x.ProtectedPhaseNumber == 4)) { CreateChart(nbPhase, eventLogs, signal); } var wbPhase = signal.Approaches.FirstOrDefault(x => x.ProtectedPhaseNumber == 2); if (wbPhase != null && signal.Approaches.Any(x => x.ProtectedPhaseNumber == 6)) { CreateChart(wbPhase, eventLogs, signal); } var sbPhase = signal.Approaches.FirstOrDefault(x => x.ProtectedPhaseNumber == 4); if (sbPhase != null && signal.Approaches.Any(x => x.ProtectedPhaseNumber == 8)) { CreateChart(sbPhase, eventLogs, signal); } return(ReturnList); }
//Total arrival on green after adjustments //Total percent arrival on green after adjustments //Total volume after adjustments //File location of the upstream after adjustment pcd //File location of the upstream before pcd /// <summary> /// Generates PCD charts for upstream and downstream detectors based on /// a Link Pivot Link /// </summary> /// <param name="upstreamSignalId"></param> /// <param name="upstreamDirection"></param> /// <param name="downstreamSignalId"></param> /// <param name="downstreamDirection"></param> /// <param name="delta"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="maxYAxis"></param> public LinkPivotPCDDisplay(string upstreamSignalId, string upstreamDirection, string downstreamSignalId, string downstreamDirection, int delta, DateTime startDate, DateTime endDate, int maxYAxis) { var signalRepository = SignalsRepositoryFactory.Create(); var upstreamSignal = signalRepository.GetVersionOfSignalByDate(upstreamSignalId, startDate); var downstreamSignal = signalRepository.GetVersionOfSignalByDate(downstreamSignalId, startDate); var upApproachToAnalyze = GetApproachToAnalyze(upstreamSignal, upstreamDirection); var downApproachToAnalyze = GetApproachToAnalyze(downstreamSignal, downstreamDirection); if (upApproachToAnalyze != null) { GeneratePcd(upApproachToAnalyze, delta, startDate, endDate, true, maxYAxis); } if (downApproachToAnalyze != null) { GeneratePcd(downApproachToAnalyze, delta, startDate, endDate, false, maxYAxis); } }
public AdvancedSpeedDataExport(string signalId, string location, DateTime startDate, DateTime endDate, int binSize, List <string> DayOfweek) { var repository = SignalsRepositoryFactory.Create(); var signal = repository.GetLatestVersionOfSignalBySignalID(signalId); //Get the dates that match the daytype for the given period var dtList = new List <DateTime>(); var tempDate = startDate; while (tempDate <= endDate) { if (DayOfweek.Contains(tempDate.DayOfWeek.ToString())) { dtList.Add(tempDate); } tempDate = tempDate.AddDays(1); } var table = signal.GetDetectorsForSignalThatSupportAMetric(10); foreach (var row in table) { var direction = row.Approach.DirectionType.Description; Approaches.Add(direction, new List <SpeedExportAvgSpeed>()); } //Create approach direction collections for each date in the list foreach (var dt in dtList) { var dtEnd = new DateTime(dt.Year, dt.Month, dt.Day, endDate.Hour, endDate.Minute, endDate.Second); var approachDirectioncollection = new SpeedExportApproachDirectionCollection(dt, dtEnd, signalId, binSize); foreach (var sad in approachDirectioncollection.List) { foreach (var sea in sad.AvgSpeeds.Items) { Approaches[sad.Direction].Add(sea); } } } }