/// <summary> /// alternate construtcor used for PCDs /// </summary> /// <param name="detid"></param> /// <param name="signalid"></param> /// <param name="channelid"></param> /// <param name="laneid"></param> /// <param name="approachdirection"></param> public Detector(MOE.Common.Models.Detector detector) { detID = detector.DetectorID; channel = detector.DetChannel; Approach = detector.Approach; DetectorModel = detector; }
public GraphDetectorModelHelper(MOE.Common.Models.Detector Detector) { Phase = Detector.Lane.ProtectedPhaseNumber; Direction = Detector.Lane.Approach.DirectionType.Description; //TODO:ConfigChange //MovementDelay = Detector.Lane.Approach.Movement_Delay.Value; //DecisionPoint = Detector.Lane.Approach.Decision_Point.Value; MPH = Detector.Lane.Approach.MPH.Value; IsOverlap = Detector.Lane.IsProtectedPhaseOverlap; SignalID = Detector.Lane.Approach.SignalID; LaneType = Detector.Lane.LaneGroupType.Description; LaneTypeAbbr = Detector.Lane.LaneGroupType.Abbreviation; }
public ConfigurationRecord(MOE.Common.Models.Detector gd) { MOE.Common.Models.Repositories.IDetectorRepository gdr = MOE.Common.Models.Repositories.DetectorRepositoryFactory.Create(); MOE.Common.Models.Repositories.IDetectorCommentRepository dcr = MOE.Common.Models.Repositories.DetectorCommentRepositoryFactory.Create(); string comment = ""; Models.DetectorComment c = dcr.GetMostRecentDetectorCommentByDetectorID(gd.ID); if (c != null) { comment = c.CommentText; } this.Comment = comment; this.DecisionPoint = gd.DecisionPoint.ToString(); this.DetectorChannel = gd.DetChannel.ToString(); this.DetectorID = gd.DetectorID; this.Direction = gd.Approach.DirectionType.Abbreviation; this.DistanceFromStopBar = gd.DistanceFromStopBar.ToString(); this.Enabled = gd.Approach.Signal.Enabled.ToString(); this.MinSpeedFilter = gd.MinSpeedFilter.ToString(); this.MovementDelay = gd.MovementDelay.ToString(); this.MPH = gd.Approach.MPH.ToString(); this.Overlap = gd.Approach.IsProtectedPhaseOverlap.ToString(); this.PermissivePhaseNumber = gd.Approach.PermissivePhaseNumber.ToString(); this.ProtectedPhaseNumber = gd.Approach.ProtectedPhaseNumber.ToString(); this.DetectionHardware = gd.DetectionHardware.Name; if (gd.LaneType != null) { this.LaneType = gd.LaneType.Description; } if (gd.LaneNumber != null) { this.LaneNumber = gd.LaneNumber.ToString(); } if (gd.MovementType != null) { this.MovementType = gd.MovementType.Description; } foreach (MOE.Common.Models.DetectionType dt in gd.DetectionTypes) { this.DetectionTypes += dt.Description + "<br/>"; } }
/// <summary> /// Default constructor for the Detector class use in the Turning Movement Count Charts /// </summary> /// <param name="detid"></param> /// <param name="signalid"></param> /// <param name="channelid"></param> /// <param name="laneid"></param> /// <param name="approachdirection"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="binsize"></param> public Detector(MOE.Common.Models.Detector detector, DateTime startDate, DateTime endDate, int binsize) { detID = detector.DetectorID; channel = detector.DetChannel; Approach = detector.Approach; signal = detector.Approach.SignalID; LaneType = detector.LaneType; MOE.Common.Models.Repositories.IControllerEventLogRepository celRepository = MOE.Common.Models.Repositories.ControllerEventLogRepositoryFactory.Create(); List <Models.Controller_Event_Log> detectorEvents = new List <Models.Controller_Event_Log>(); detectorEvents.AddRange(celRepository.GetEventsByEventCodesParam(detector.Approach.SignalID, startDate, endDate, new List <int> { 82 }, channel)); volumes = new VolumeCollection(startDate, endDate, detectorEvents, binsize); }
public bool CheckReportAvialbility(string detectorID, int metricID) { MOE.Common.Models.Detector gd = db.Detectors .Where(g => g.DetectorID == detectorID) .FirstOrDefault(); bool result = false; if (gd != null) { foreach (DetectionType dt in gd.DetectionTypes) { foreach (Models.MetricType m in dt.MetricTypes) { if (m.MetricID == metricID) { result = true; } } } } return(result); }
/// <summary> /// /// </summary> /// <param name="signalId"></param> /// <param name="direction"></param> /// <param name="delta"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <param name="upstream"></param> /// <param name="maxYAxis"></param> private void GeneratePCD(Models.Approach approach, int delta, DateTime startDate, DateTime endDate, bool upstream, int maxYAxis) { MOE.Common.Models.Repositories.ISignalsRepository repository = MOE.Common.Models.Repositories.SignalsRepositoryFactory.Create(); //var signal = repository.GetSignalBySignalID(approach.SignalId); //Create a location string to show the combined cross strees string location = string.Empty; if (approach.Signal != null) { location = approach.Signal.PrimaryName + " " + approach.Signal.SecondaryName; } string chartName = string.Empty; //MOE.Common.Data.LinkPivotTableAdapters.Graph_DetectorsTableAdapter gdAdapter = // new Data.LinkPivotTableAdapters.Graph_DetectorsTableAdapter(); //find the upstream approach if (!String.IsNullOrEmpty(approach.DirectionType.Description)) { //Find PCD detector for this appraoch MOE.Common.Models.Detector gd = approach.Signal.GetDetectorsForSignalThatSupportAMetricByApproachDirection( 6, approach.DirectionType.Description).FirstOrDefault(); //Check for null value if (gd != null) { //Instantiate a signal phase object SignalPhase sp = new MOE.Common.Business.SignalPhase( startDate, endDate, approach, false, 15, 13); //Check the direction of the Link Pivot if (upstream) { //Create a chart for the upstream detector before adjustments upstreamBeforePCDPath = CreateChart(sp, startDate, endDate, location, "before", ConfigurationManager.AppSettings["ImageLocation"], maxYAxis, "UpstreamBefore"); //Add the total arrival on green before adjustments to the running total existingTotalAOG += sp.TotalArrivalOnGreen; //Add the volume from the signal phase to the running total existingVolume += sp.TotalVolume; //Re run the signal phase by the optimized delta change to get the adjusted pcd sp.LinkPivotAddSeconds(delta * -1); //Create a chart for the upstream detector after adjustments upstreamAfterPCDPath = CreateChart(sp, startDate, endDate, location, "after", ConfigurationManager.AppSettings["ImageLocation"], maxYAxis, "UpstreamAfter"); //Add the total arrival on green after adjustments to the running total predictedTotalAOG += sp.TotalArrivalOnGreen; //Add the volume from the signal phase to the running total predictedVolume += sp.TotalVolume; } else { //Create a chart for downstream detector before adjustments downstreamBeforePCDPath = CreateChart(sp, startDate, endDate, location, "before", ConfigurationManager.AppSettings["ImageLocation"], maxYAxis, "DownstreamBefore"); //Add the arrivals on green to the total arrivals on green running total existingTotalAOG += sp.TotalArrivalOnGreen; //Add the volume before adjustments to the running total volume existingVolume += sp.TotalVolume; //Re run the signal phase by the optimized delta change to get the adjusted pcd sp.LinkPivotAddSeconds(delta); //Create a pcd chart for downstream after adjustments downstreamAfterPCDPath = CreateChart(sp, startDate, endDate, location, "after", ConfigurationManager.AppSettings["ImageLocation"], maxYAxis, "DownstreamAfter"); //Add the total arrivals on green to the running total predictedTotalAOG += sp.TotalArrivalOnGreen; //Add the total volume to the running total after adjustments predictedVolume += sp.TotalVolume; } } } }
protected void AddDataToChart(Chart chart, List <MOE.Common.Business.ApproachVolume.Approach> approachDirectionCollection, DateTime startDate, DateTime endDate, string signalId, string direction1, string direction2, ApproachVolumeOptions options, bool useAdvance) { int D1vol = 0; int D2vol = 0; DateTime D1time = new DateTime(); DateTime D2time = new DateTime(); SortedDictionary <DateTime, int> D1volumes = new SortedDictionary <DateTime, int>(); SortedDictionary <DateTime, int> D2volumes = new SortedDictionary <DateTime, int>(); List <MOE.Common.Business.ApproachVolume.Approach> FilteredApproaches = (from r in approachDirectionCollection where r.Direction == direction1 || r.Direction == direction2 select r).ToList(); foreach (MOE.Common.Business.ApproachVolume.Approach approachDirection in FilteredApproaches) { if (useAdvance) { approachDirection.SetDetectorEvents(approachDirection.ApproachModel, startDate, endDate, true, false); } else { approachDirection.SetDetectorEvents(approachDirection.ApproachModel, startDate, endDate, false, true); } approachDirection.SetVolume(startDate, endDate, options.SelectedBinSize); } if (FilteredApproaches.Count > 0) { MOE.Common.Models.Detector d = FilteredApproaches[0].Detectors.ApproachCountDetectors[0]; if (d.DistanceFromStopBar != null && d.DistanceFromStopBar > 0) { Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " located " + d.DistanceFromStopBar.ToString() + "ft. upstream of the stop bar")); } else { Chart.Titles.Add(ChartTitleFactory.GetTitle(d.DetectionHardware.Name + " at stop bar")); } } foreach (MOE.Common.Business.ApproachVolume.Approach approachDirection in FilteredApproaches) { if (approachDirection.Volume.Items.Count > 0) { foreach (MOE.Common.Business.Volume v in approachDirection.Volume.Items) { //add Direction1 volumes if (approachDirection.Direction == direction1) { //Add the volumes and times to a collection so we can use them later if (!D1volumes.ContainsKey(v.XAxis)) { D1volumes.Add(v.XAxis, v.YAxis); D1TotalVolume = (D1TotalVolume + v.DetectorCount); } } //add Direction2 volumes if (approachDirection.Direction == direction2) { //Add the volumes and times to a collection so we can use them later if (!D2volumes.ContainsKey(v.XAxis)) { D2volumes.Add(v.XAxis, v.YAxis); D2TotalVolume = (D2TotalVolume + v.DetectorCount); } } } } if (options.ShowSBEBVolume) { foreach (KeyValuePair <DateTime, int> vol in D1volumes) { //This is the Thicker Solid Red line chart.Series[0].Points.AddXY(vol.Key, vol.Value); } } if (options.ShowNBWBVolume) { foreach (KeyValuePair <DateTime, int> vol in D2volumes) { //This is the Thicker Solid Blue line chart.Series[1].Points.AddXY(vol.Key, vol.Value); CheckAndCorrectConsecutiveXValues(chart.Series[1].Points); } } //add ratios //Match the times in the dir1 colleciton to the dir2 collection so we can get a ratio //of the values collected at the same point in time. foreach (KeyValuePair <DateTime, int> volRow in D1volumes) { D2vol = (from k in D2volumes where DateTime.Compare(k.Key, volRow.Key) == 0 select k.Value).FirstOrDefault(); D1vol = volRow.Value; D1time = volRow.Key; if (D1vol > 0 && D2vol > 0) { //ratio the values double D1DFactor = Convert.ToDouble(D1vol) / ((Convert.ToDouble(D2vol) + Convert.ToDouble(D1vol))); if (options.ShowDirectionalSplits) { //plot the ratio and time on the secondary Y axis //This is the Thin Dashed Red line chart.Series[2].Points.AddXY(D1time, D1DFactor); } } } CheckAndCorrectConsecutiveXValues(chart.Series[2].Points); //Match the times in the dir2 colleciton to the dir1 collection so we can get a ratio //of the values collected at the same point in time. foreach (KeyValuePair <DateTime, int> volRow in D2volumes) { D1vol = (from k in D1volumes where DateTime.Compare(k.Key, volRow.Key) == 0 select k.Value).FirstOrDefault(); D2vol = volRow.Value; D2time = volRow.Key; if (D2vol > 0 && D1vol > 0) { //ratio the values double D2DFactor = Convert.ToDouble(D2vol) / ((Convert.ToDouble(D2vol) + Convert.ToDouble(D1vol))); //plot the ratio and time on the secondary Y axis if (options.ShowDirectionalSplits) { //This is the Thin Dashed Blue line chart.Series[3].Points.AddXY(D2time, D2DFactor); } } } } foreach (Series s in chart.Series) { List <DataPoint> temppoints = CheckAndCorrectConsecutiveXValues(s.Points); s.Points.Clear(); foreach (DataPoint d in temppoints) { s.Points.Add(d); } } if (D1volumes.Count > 0 && D2volumes.Count > 0) { Table = CreateVolumeMetricsTable(direction1, direction2, D1TotalVolume, D2TotalVolume, D1volumes, D2volumes, options); } }