public Approach(MOE.Common.Models.Approach approach) { SignalID = approach.SignalID; Direction = approach.DirectionType.Description; ApproachModel = approach; detectors = new DetectorCollection(approach); detectorevents = null; }
public PreemptServiceMetric(PreemptServiceMetricOptions options, ControllerEventLogs DTTB) { Options = options; ServiceChart = ChartFactory.CreateDefaultChart(options); //Set the chart properties ServiceChart.BorderSkin.SkinStyle = BorderSkinStyle.None; ServiceChart.BorderSkin.BorderColor = Color.Black; ServiceChart.BorderSkin.BorderWidth = 1; var reportTimespan = Options.EndDate - Options.StartDate; SetChartTitle(); //Create the chart legend var chartLegend = new Legend(); chartLegend.Name = "MainLegend"; chartLegend.Docking = Docking.Left; ServiceChart.Legends.Add(chartLegend); ServiceChart.ChartAreas[0].AxisY.Maximum = 10; ServiceChart.ChartAreas[0].AxisY.Minimum = 0; ServiceChart.ChartAreas[0].AxisY.Title = "Preempt Number"; ServiceChart.ChartAreas[0].AxisY.Interval = 1; ServiceChart.ChartAreas[0].AxisX2.Enabled = AxisEnabled.False; //Add the point series var PreemptSeries = new Series(); PreemptSeries.ChartType = SeriesChartType.Point; PreemptSeries.BorderDashStyle = ChartDashStyle.Dash; PreemptSeries.MarkerStyle = MarkerStyle.Diamond; PreemptSeries.Color = Color.Black; PreemptSeries.Name = "Preempt Service"; PreemptSeries.XValueType = ChartValueType.DateTime; //Add the Posts series to ensure the chart is the size of the selected timespan var posts = new Series(); posts.IsVisibleInLegend = false; posts.ChartType = SeriesChartType.Point; posts.Color = Color.White; posts.Name = "Posts"; posts.XValueType = ChartValueType.DateTime; ServiceChart.Series.Add(posts); ServiceChart.Series.Add(PreemptSeries); ServiceChart.Height = 200; AddDataToChart(ServiceChart, Options.StartDate, Options.EndDate, DTTB, Options.SignalID); var plans = PlanFactory.GetBasicPlans(Options.StartDate, Options.EndDate, Options.SignalID); SetSimplePlanStrips(plans, ServiceChart, Options.StartDate, DTTB); }
private DateTime FindNext111Event(ControllerEventLogs DTTB, int counter) { DateTime Next111Event = new DateTime(); for (int x = counter; x < DTTB.Events.Count; x++) { if (DTTB.Events[x].EventCode == 111) { Next111Event = DTTB.Events[x].Timestamp; x = DTTB.Events.Count; } } return(Next111Event); }
protected void AddDataToChart(Chart chart, ControllerEventLogs dttb) { var engine = new PreemptCycleEngine(); var cycles = engine.CreatePreemptCycle(dttb); foreach (var cycle in cycles) { if (cycle.HasDelay) { var point = new DataPoint(); point.SetValueXY(cycle.CycleStart.ToOADate(), cycle.Delay); chart.Series["Delay"].Points.Add(point); chart.Series["Time to Service"].Points.AddXY(cycle.CycleStart.ToOADate(), cycle.TimeToService); // point.AxisLabel = cycle.CycleStart.ToShortTimeString(); } else { var point = new DataPoint(); point.SetValueXY(cycle.CycleStart.ToOADate(), cycle.TimeToService); chart.Series["Delay"].Points.AddXY(cycle.CycleStart.ToOADate(), 0); chart.Series["Time to Service"].Points.Add(point); // point.AxisLabel = cycle.CycleStart.ToShortTimeString(); } chart.Series["Track Clear"].Points.AddXY(cycle.CycleStart.ToOADate(), cycle.TimeToTrackClear); chart.Series["Dwell Time"].Points.AddXY(cycle.CycleStart.ToOADate(), cycle.DwellTime); if (cycle.TimeToCallMaxOut > 0) { chart.Series["Call Max Out"].Points.AddXY(cycle.CycleStart.ToOADate(), cycle.TimeToCallMaxOut); } if (cycle.TimeToGateDown > 0) { chart.Series["Gate Down"].Points.AddXY(cycle.CycleStart.ToOADate(), cycle.TimeToGateDown); } foreach (var d in cycle.InputOn) { if (d >= cycle.CycleStart && d <= cycle.CycleEnd) { chart.Series["Input On"].Points.AddXY(cycle.CycleStart.ToOADate(), (d - cycle.CycleStart).TotalSeconds); } } foreach (var d in cycle.InputOff) { if (d >= cycle.CycleStart && d <= cycle.CycleEnd) { chart.Series["Input Off"].Points.AddXY(cycle.CycleStart.ToOADate(), (d - cycle.CycleStart).TotalSeconds); } } } }
private void CreateChart(Approach approach, ControllerEventLogs eventLogs, Signal signal) { var phaseEvents = new List <Controller_Event_Log>(); phaseEvents.AddRange(eventLogs.Events.Where(x => x.EventParam == approach.ProtectedPhaseNumber && (x.EventCode == EVENT_GREEN || x.EventCode == EVENT_RED))); var detectorsToUse = new List <Models.Detector>(); var detectionTypeStr = "Lane-By-Lane Count"; //Use only lane-by-lane count detectors if they exists, otherwise check for stop bar detectorsToUse = approach.GetAllDetectorsOfDetectionType(4); if (!detectorsToUse.Any()) { detectorsToUse = approach.GetAllDetectorsOfDetectionType(6); detectionTypeStr = "Stop Bar Presence"; //If no detectors of either type for this approach, skip it if (!detectorsToUse.Any()) { return; } } foreach (var detector in detectorsToUse) { // Check for thru, right, thru-right, and thru-left if (!IsThruDetector(detector)) { continue; } phaseEvents.AddRange(eventLogs.Events.Where(x => x.EventCode == EVENT_DET && x.EventParam == detector.DetChannel)); } if (phaseEvents.Any()) { var leftTurnChart = new LeftTurnGapAnalysisChart(this, signal, approach, phaseEvents, GetOpposingPhase(approach.ProtectedPhaseNumber), StartDate, EndDate, detectionTypeStr); var chart = leftTurnChart.Chart; var chartName = CreateFileName(); chart.SaveImage(MetricFileLocation + chartName); ReturnList.Add(MetricWebPath + chartName); } }
public override List <string> CreateMetric() { base.CreateMetric(); var returnList = new List <string>(); var eventsTable = new ControllerEventLogs(); eventsTable.FillforPreempt(SignalID, StartDate, EndDate); var psrChart = new PreemptRequestChart(this, eventsTable); var chart = psrChart.PreemptServiceRequestChart; var chartName = CreateFileName(); chart.SaveImage(MetricFileLocation + chartName, ChartImageFormat.Jpeg); returnList.Add(MetricWebPath + chartName); return(returnList); }
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); }
public PedDelaySignal(string signalID, DateTime startDate, DateTime endDate) { _SignalID = signalID; _StartDate = startDate; _EndDate = endDate; _Plans = new PlansBase(signalID, startDate, endDate); List <int> pedPhaseNumbers = ControllerEventLogs.GetPedPhases(signalID, startDate, endDate); Parallel.ForEach(pedPhaseNumbers, currentPhase => //foreach(int currentPhase in pedPhaseNumbers) { _PedPhases.Add(new PedPhase(currentPhase, signalID, startDate, endDate, _Plans)); } ); _PedPhases.Sort((x, y) => x.PhaseNumber.CompareTo(y.PhaseNumber)); }
public PedDelaySignal(string signalID, DateTime startDate, DateTime endDate) { _SignalID = signalID; _StartDate = startDate; _EndDate = endDate; _Plans = new PlansBase(signalID, startDate, endDate); var pedPhaseNumbers = ControllerEventLogs.GetPedPhases(signalID, startDate, endDate); Parallel.ForEach(pedPhaseNumbers, currentPhase => //foreach(int currentPhase in pedPhaseNumbers) { _PedPhases.Add(new PedPhase(currentPhase, signalID, startDate, endDate, _Plans)); } ); _PedPhases = _PedPhases.OrderBy(x => x.PhaseNumber).ToList(); }
public PreemptDetailChart(PreemptDetailOptions options, ControllerEventLogs dttb) { Options = options; DetailChart = ChartFactory.CreateDefaultChart(Options); var preemptNumber = 0; if (dttb.Events.Count > 0) { var r = (from e in dttb.Events where e.EventCode != 99 select e).FirstOrDefault(); preemptNumber = r.EventParam; } //var reportTimespan = Options.EndDate - Options.StartDate; AddTitleAndLegend(DetailChart, preemptNumber); AddChartArea(DetailChart); AddSeries(DetailChart); AddDataToChart(DetailChart, dttb); //var plans = PlanFactory.GetBasicPlans(Options.StartDate, Options.EndDate, Options.SignalID); //SetSimplePlanStrips(plans, Chart, Options.StartDate, Options.EndDate, dttb); }
private bool DoesTrackClearEndNormal(ControllerEventLogs DTTB, int counter) { bool foundEvent107 = false; for (int x = counter; x < DTTB.Events.Count; x++) { switch (DTTB.Events[x].EventCode) { case (107): foundEvent107 = true; x = DTTB.Events.Count; break; case (111): foundEvent107 = false; x = DTTB.Events.Count; break; } } return(foundEvent107); }
private void TestForValidRecords(ControllerEventLogs t, List <ControllerEventLogs> tables) { bool AddToTables = false; if (t.Events.Count > 0) { var hasStart = from r in t.Events where r.EventCode == 105 || r.EventCode == 111 || r.EventCode == 107 select r; if (hasStart.Count() > 0) { AddToTables = true; } } if (AddToTables) { tables.Add(t); } }
protected void AddDataToChart(Chart chart) { List <ControllerEventLogs> Tables = new List <ControllerEventLogs>(); List <DateTime> SplitFails = new List <DateTime>(); int totalFails = 0; Models.Repositories.ISignalsRepository signalRepository = Models.Repositories.SignalsRepositoryFactory.Create(); //var signal = signalRepository.GetSignalBySignalID(phase.SignalID); var ApproachDetectors = Phase.Approach.GetDetectorsForMetricType(12); //get occupancy events for each lane for the approach. if (ApproachDetectors.Count() > 0) { foreach (Models.Detector row in ApproachDetectors) { MOE.Common.Business.ControllerEventLogs TEMPdetectortable = new ControllerEventLogs(Phase.SignalID, Options.StartDate, Options.EndDate, row.DetChannel, new List <int>() { 81, 82 }); if (TEMPdetectortable.Events.Count > 0) { Tables.Add(TEMPdetectortable); } } Dictionary <string, string> statistics = new Dictionary <string, string>(); if (Tables.Count > 0) { //for (int CurCycleIndex = 0; CurCycleIndex < phase.Cycles.Count -1 ; CurCycleIndex++) //int tempCycleCounter = 0; //Parallel.ForEach(phase.Cycles, c => foreach (MOE.Common.Business.CustomReport.Cycle c in Phase.Cycles) { //tempCycleCounter++; //SplitFailDetectorActivationCollection activations = new SplitFailDetectorActivationCollection(); //for each lane //Parallel.ForEach(Tables, table => foreach (ControllerEventLogs table in Tables) { int channel = table.Events[0].EventParam; List <MOE.Common.Models.Controller_Event_Log> DetectorHitsForCycle = new List <MOE.Common.Models.Controller_Event_Log>(); //Parallel.ForEach(table.Events, e => foreach (MOE.Common.Models.Controller_Event_Log e in table.Events) { if (e.Timestamp >= c.CycleStart && e.Timestamp <= c.CycleEnd) { DetectorHitsForCycle.Add(e); } } //); if (DetectorHitsForCycle.Count > 0) { var eventsInOrder = DetectorHitsForCycle.OrderBy(r => r.Timestamp); if (eventsInOrder.Count() > 1) { for (int i = 0; i < eventsInOrder.Count() - 1; i++) { MOE.Common.Models.Controller_Event_Log current = eventsInOrder.ElementAt(i); MOE.Common.Models.Controller_Event_Log next = eventsInOrder.ElementAt(i + 1); if (current.Timestamp.Ticks == next.Timestamp.Ticks) { continue; } //If the first event is 'Off', then set 'On' to cyclestart if (i == 0 && current.EventCode == 81) { SplitFailDetectorActivation da = new SplitFailDetectorActivation(); da.DetectorOn = c.CycleStart; da.DetectorOff = current.Timestamp; c.Activations.AddActivation(da); } //This is the prefered sequence; an 'On' followed by an 'off' if (current.EventCode == 82 && next.EventCode == 81) { SplitFailDetectorActivation da = new SplitFailDetectorActivation(); da.DetectorOn = current.Timestamp; da.DetectorOff = next.Timestamp; c.Activations.AddActivation(da); continue; } //if we are at the penultimate event, and the last event is 'on', set 'off' as CycleEnd. if (i + 2 == eventsInOrder.Count() && next.EventCode == 82) { SplitFailDetectorActivation da = new SplitFailDetectorActivation(); da.DetectorOn = next.Timestamp; da.DetectorOff = c.CycleEnd; c.Activations.AddActivation(da); continue; } } } else { SplitFailDetectorActivation da = new SplitFailDetectorActivation(); MOE.Common.Models.Controller_Event_Log current = eventsInOrder.First(); switch (current.EventCode) { //if the only event is off case 81: da.DetectorOn = c.CycleStart; da.DetectorOff = current.Timestamp; c.Activations.AddActivation(da); break; //if the only event is on case 82: da.DetectorOn = current.Timestamp; da.DetectorOff = c.CycleEnd; c.Activations.AddActivation(da); break; } } } //if there are no hits in the cycle, we need to determine if the a previous detector activaition lasts the entire cycle else if (DetectorHitsForCycle.Count <= 0) { SplitFailDetectorActivation da = new SplitFailDetectorActivation(); DateTime earlierTime = c.CycleStart.AddMinutes(-30); List <int> li = new List <int> { 81, 82 }; ControllerEventLogs cs = new ControllerEventLogs(Phase.SignalID, earlierTime, c.CycleStart, channel, li); //if the last detecotr eventCodes was ON, and there is no matching off event, assume the detector was on for the whole cycle if (cs.Events.Count > 0 && cs.Events.LastOrDefault().EventCode == 82) { da.DetectorOn = c.CycleStart; da.DetectorOff = c.CycleEnd; c.Activations.AddActivation(da); } //} } } //); //end of Lane loop //merge the detectors for the different lanes for (int i = 0; i < c.Activations.Activations.Count - 1;) { SplitFailDetectorActivation current = c.Activations.Activations.ElementAt(i).Value; SplitFailDetectorActivation next = c.Activations.Activations.ElementAt(i + 1).Value; //if the next activaiton is between the previos one, remove the nextone and start again. if (next.DetectorOn >= current.DetectorOn && next.DetectorOff <= current.DetectorOff) { c.Activations.Activations.RemoveAt(i + 1); continue; } //if the next activaiton starts during the current, but ends later, atler current end time, and remove next, and start over. else if (next.DetectorOn >= current.DetectorOn && next.DetectorOn < current.DetectorOff && next.DetectorOff > current.DetectorOff) { current.DetectorOff = next.DetectorOff; c.Activations.Activations.RemoveAt(i + 1); continue; } else { i++; } } //if (c.Activations.Activations.Count > 0 && c.CycleStart > startDate && c.CycleStart < endDate) if (c.CycleStart > Options.StartDate && c.CycleStart < Options.EndDate) { double gor = c.Activations.GreenOccupancy(c) * 100; double ror = c.Activations.StartOfRedOccupancy(c, Options.FirstSecondsOfRed) * 100; if (c.TerminationEvent == MOE.Common.Business.CustomReport.Cycle.TerminationCause.GapOut) { chart.Series["GOR - GapOut"].Points.AddXY(c.CycleStart, gor); chart.Series["ROR - GapOut"].Points.AddXY(c.CycleStart, ror); } else { chart.Series["GOR - ForceOff"].Points.AddXY(c.CycleStart, gor); chart.Series["ROR - ForceOff"].Points.AddXY(c.CycleStart, ror); } if ((gor > 79 && ror > 79)) { if (Options.ShowFailLines) { chart.Series["SplitFail"].Points.AddXY(c.CycleStart, 100); } SplitFails.Add(c.CycleStart); totalFails++; } } } //); statistics.Add("Total Split Failures ", totalFails.ToString()); //end of Cycle loop //Average Loop DateTime counterTime = Options.StartDate; do { double binTotalGOR = 0; double binTotalROR = 0; var CycleBin = from cur in Phase.Cycles where cur.CycleStart >= counterTime && cur.CycleStart <= counterTime.AddMinutes(15) orderby cur.CycleStart select cur; var failsInBin = from s in SplitFails where s >= counterTime && s <= counterTime.AddMinutes(15) select s; double binFails = failsInBin.Count(); //Parallel.ForEach(CycleBin, c => foreach (MOE.Common.Business.CustomReport.Cycle c in CycleBin) { binTotalGOR += c.Activations.GreenOccupancy(c) * 100; binTotalROR += c.Activations.StartOfRedOccupancy(c, Options.FirstSecondsOfRed) * 100; } //); if (Options.ShowPercentFailLines) { if (binFails > 0 && CycleBin.Count() > 0) { double binFailPercent = (binFails / Convert.ToDouble(CycleBin.Count())); chart.Series["Percent Fails"].Points.AddXY(counterTime, Convert.ToInt32(binFailPercent * 100)); } else { chart.Series["Percent Fails"].Points.AddXY(counterTime, 0); } } if (Options.ShowAvgLines) { if (CycleBin.Count() > 0) { double avggor = binTotalGOR / CycleBin.Count(); double avgror = binTotalROR / CycleBin.Count(); chart.Series["Avg. GOR"].Points.AddXY(counterTime, avggor); chart.Series["Avg. ROR"].Points.AddXY(counterTime, avgror); } if (CycleBin.Count() == 0) { chart.Series["Avg. GOR"].Points.AddXY(counterTime, 0); chart.Series["Avg. ROR"].Points.AddXY(counterTime, 0); } } counterTime = counterTime.AddMinutes(15); } while (counterTime < Options.EndDate.AddMinutes(15)); //End Average Loop } SetChartTitle(statistics); AddPlanStrips(chart, Phase, Options.StartDate, Options.EndDate, SplitFails); } }
public void SetDetectorEvents(MOE.Common.Models.Approach approach, DateTime startdate, DateTime enddate, bool has_pcd, bool has_tmc) { detectorevents = detectors.CombineDetectorDataByApproachAndType(startdate, enddate, approach, has_pcd, has_tmc); }
public PreemptRequestChart(PreemptServiceRequestOptions options, ControllerEventLogs dttb) { Options = options; //Set the chart properties PreemptServiceRequestChart = ChartFactory.CreateDefaultChart(options); PreemptServiceRequestChart.ImageStorageMode = ImageStorageMode.UseImageLocation; ChartFactory.SetImageProperties(PreemptServiceRequestChart); PreemptServiceRequestChart.BorderSkin.SkinStyle = BorderSkinStyle.None; PreemptServiceRequestChart.BorderSkin.BorderColor = Color.Black; PreemptServiceRequestChart.BorderSkin.BorderWidth = 1; var reportTimespan = Options.EndDate - Options.StartDate; SetChartTitle(); //Create the chart legend var chartLegend = new Legend(); chartLegend.Name = "MainLegend"; chartLegend.Docking = Docking.Left; PreemptServiceRequestChart.Legends.Add(chartLegend); PreemptServiceRequestChart.ChartAreas[0].AxisY.Maximum = 10; PreemptServiceRequestChart.ChartAreas[0].AxisX2.Enabled = AxisEnabled.False; // top chart PreemptServiceRequestChart.ChartAreas[0].AxisY.Minimum = 0; PreemptServiceRequestChart.ChartAreas[0].AxisY.Title = "Preempt Number"; PreemptServiceRequestChart.ChartAreas[0].AxisY.Interval = 1; PreemptServiceRequestChart.ChartAreas[0].AxisX.Title = "Time (Hours:Minutes)"; PreemptServiceRequestChart.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Hours; PreemptServiceRequestChart.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm"; if (reportTimespan.Days <= 1) { if (reportTimespan.Hours > 1) { PreemptServiceRequestChart.ChartAreas[0].AxisX.Interval = 1; } else { PreemptServiceRequestChart.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm"; } } PreemptServiceRequestChart.ChartAreas[0].AxisX.Minimum = Options.StartDate.ToOADate(); PreemptServiceRequestChart.ChartAreas[0].AxisX.Maximum = Options.EndDate.ToOADate(); //Add the point series var PreemptSeries = new Series(); PreemptSeries.ChartType = SeriesChartType.Point; PreemptSeries.BorderDashStyle = ChartDashStyle.Dash; PreemptSeries.MarkerStyle = MarkerStyle.Diamond; PreemptSeries.Color = Color.Black; PreemptSeries.Name = "Preempt Request"; PreemptSeries.XValueType = ChartValueType.DateTime; //Add the Posts series to ensure the chart is the size of the selected timespan var posts = new Series(); posts.IsVisibleInLegend = false; posts.ChartType = SeriesChartType.Point; posts.Color = Color.White; posts.Name = "Posts"; posts.XValueType = ChartValueType.DateTime; PreemptServiceRequestChart.Series.Add(posts); PreemptServiceRequestChart.Series.Add(PreemptSeries); PreemptServiceRequestChart.Height = 200; //Add points at the start and and of the x axis to ensure //the graph covers the entire period selected by the user //whether there is data or not //chart.Series["Posts"].Points.AddXY(Options.StartDate, 0); //chart.Series["Posts"].Points.AddXY(Options.EndDate, 0); AddDataToChart(PreemptServiceRequestChart, Options.StartDate, Options.EndDate, dttb, Options.SignalID); var plans = PlanFactory.GetBasicPlans(Options.StartDate, Options.EndDate, Options.SignalID); SetSimplePlanStrips(plans, PreemptServiceRequestChart, Options.StartDate, dttb); }
protected void SetSimplePlanStrips(List <Plan> plans, Chart chart, DateTime graphStartDate, ControllerEventLogs DTTB) { var backGroundColor = 1; foreach (var plan in plans) { var stripline = new StripLine(); //Creates alternating backcolor to distinguish the plans if (backGroundColor % 2 == 0) { stripline.BackColor = Color.FromArgb(120, Color.LightGray); } else { stripline.BackColor = Color.FromArgb(120, Color.LightBlue); } //Set the stripline properties stripline.IntervalOffsetType = DateTimeIntervalType.Hours; stripline.Interval = 1; stripline.IntervalOffset = (plan.StartTime - graphStartDate).TotalHours; stripline.StripWidth = (plan.EndTime - plan.StartTime).TotalHours; stripline.StripWidthType = DateTimeIntervalType.Hours; chart.ChartAreas["ChartArea1"].AxisX.StripLines.Add(stripline); //Add a corrisponding custom label for each strip var Plannumberlabel = new CustomLabel(); Plannumberlabel.FromPosition = plan.StartTime.ToOADate(); Plannumberlabel.ToPosition = plan.EndTime.ToOADate(); switch (plan.PlanNumber) { case 254: Plannumberlabel.Text = "Free"; break; case 255: Plannumberlabel.Text = "Flash"; break; case 0: Plannumberlabel.Text = "Unknown"; break; default: Plannumberlabel.Text = "Plan " + plan.PlanNumber; break; } Plannumberlabel.LabelMark = LabelMarkStyle.LineSideMark; Plannumberlabel.ForeColor = Color.Black; Plannumberlabel.RowIndex = 6; var planPreemptsLabel = new CustomLabel(); planPreemptsLabel.FromPosition = plan.StartTime.ToOADate(); planPreemptsLabel.ToPosition = plan.EndTime.ToOADate(); var c = from Controller_Event_Log r in DTTB.Events where r.EventCode == 102 && r.Timestamp > plan.StartTime && r.Timestamp < plan.EndTime select r; var premptCount = c.Count().ToString(); planPreemptsLabel.Text = "Preempts Requested During Plan: " + premptCount; planPreemptsLabel.LabelMark = LabelMarkStyle.LineSideMark; planPreemptsLabel.ForeColor = Color.Red; planPreemptsLabel.RowIndex = 7; backGroundColor++; } }
public List <PreemptCycle> CreatePreemptCycle(ControllerEventLogs DTTB) { var CycleCollection = new List <PreemptCycle>(); PreemptCycle cycle = null; //foreach (MOE.Common.Models.Controller_Event_Log row in DTTB.Events) for (var x = 0; x < DTTB.Events.Count; x++) { //It can happen that there is no defined terminaiton event. if (x + 1 < DTTB.Events.Count) { var t = DTTB.Events[x + 1].Timestamp - DTTB.Events[x].Timestamp; if (cycle != null && t.TotalMinutes > 20 && DTTB.Events[x].EventCode != 111 && DTTB.Events[x].EventCode != 105) { EndCycle(cycle, DTTB.Events[x], CycleCollection); cycle = null; continue; } } switch (DTTB.Events[x].EventCode) { case 102: if (cycle != null) { cycle.InputOn.Add(DTTB.Events[x].Timestamp); } if (cycle == null && DTTB.Events[x].Timestamp != DTTB.Events[x + 1].Timestamp && DTTB.Events[x + 1].EventCode == 105) { cycle = StartCycle(DTTB.Events[x]); } break; case 103: if (cycle != null && cycle.GateDown == DateTime.MinValue) { cycle.GateDown = DTTB.Events[x].Timestamp; } break; case 104: if (cycle != null) { cycle.InputOff.Add(DTTB.Events[x].Timestamp); } break; case 105: ////If we run into an entry start after cycle start (event 102) if (cycle != null && cycle.HasDelay) { cycle.EntryStarted = DTTB.Events[x].Timestamp; break; } if (cycle != null) { EndCycle(cycle, DTTB.Events[x], CycleCollection); cycle = null; cycle = StartCycle(DTTB.Events[x]); break; } if (cycle == null) { cycle = StartCycle(DTTB.Events[x]); } break; case 106: if (cycle != null) { cycle.BeginTrackClearance = DTTB.Events[x].Timestamp; if (x + 1 < DTTB.Events.Count) { if (!DoesTrackClearEndNormal(DTTB, x)) { cycle.BeginDwellService = FindNext111Event(DTTB, x); } } } break; case 107: if (cycle != null) { cycle.BeginDwellService = DTTB.Events[x].Timestamp; if (x + 1 < DTTB.Events.Count) { if (!DoesTheCycleEndNormal(DTTB, x)) { cycle.BeginExitInterval = DTTB.Events[x + 1].Timestamp; EndCycle(cycle, DTTB.Events[x + 1], CycleCollection); cycle = null; } } } break; case 108: if (cycle != null) { cycle.LinkActive = DTTB.Events[x].Timestamp; } break; case 109: if (cycle != null) { cycle.LinkInactive = DTTB.Events[x].Timestamp; } break; case 110: if (cycle != null) { cycle.MaxPresenceExceeded = DTTB.Events[x].Timestamp; } break; case 111: // 111 can usually be considered "cycle complete" if (cycle != null) { cycle.BeginExitInterval = DTTB.Events[x].Timestamp; EndCycle(cycle, DTTB.Events[x], CycleCollection); cycle = null; } break; } if (x + 1 >= DTTB.Events.Count && cycle != null) { cycle.BeginExitInterval = DTTB.Events[x].Timestamp; EndCycle(cycle, DTTB.Events[x], CycleCollection); break; } } return(CycleCollection); }
public override List <string> CreateMetric() { base.CreateMetric(); var returnList = new List <string>(); var tables = new List <ControllerEventLogs>(); var preTestTables = new List <ControllerEventLogs>(); var eventsTable = new ControllerEventLogs(); eventsTable.FillforPreempt(SignalID, StartDate, EndDate); var t1 = new ControllerEventLogs(); var t2 = new ControllerEventLogs(); var t3 = new ControllerEventLogs(); var t4 = new ControllerEventLogs(); var t5 = new ControllerEventLogs(); var t6 = new ControllerEventLogs(); var t7 = new ControllerEventLogs(); var t8 = new ControllerEventLogs(); var t9 = new ControllerEventLogs(); var t10 = new ControllerEventLogs(); var t11 = new ControllerEventLogs(); var t12 = new ControllerEventLogs(); var t13 = new ControllerEventLogs(); var t14 = new ControllerEventLogs(); var t15 = new ControllerEventLogs(); var t16 = new ControllerEventLogs(); var t17 = new ControllerEventLogs(); var t18 = new ControllerEventLogs(); var t19 = new ControllerEventLogs(); var t20 = new ControllerEventLogs(); preTestTables.Add(t1); preTestTables.Add(t2); preTestTables.Add(t3); preTestTables.Add(t4); preTestTables.Add(t5); preTestTables.Add(t6); preTestTables.Add(t7); preTestTables.Add(t8); preTestTables.Add(t9); preTestTables.Add(t10); preTestTables.Add(t11); preTestTables.Add(t12); preTestTables.Add(t13); preTestTables.Add(t14); preTestTables.Add(t15); preTestTables.Add(t16); preTestTables.Add(t17); preTestTables.Add(t18); preTestTables.Add(t19); preTestTables.Add(t20); foreach (var row in eventsTable.Events) { switch (row.EventParam) { case 1: t1.Events.Add(row); break; case 2: t2.Events.Add(row); break; case 3: t3.Events.Add(row); break; case 4: t4.Events.Add(row); break; case 5: t5.Events.Add(row); break; case 6: t6.Events.Add(row); break; case 7: t7.Events.Add(row); break; case 8: t8.Events.Add(row); break; case 9: t9.Events.Add(row); break; case 10: t10.Events.Add(row); break; case 11: t11.Events.Add(row); break; case 12: t12.Events.Add(row); break; case 13: t13.Events.Add(row); break; case 14: t14.Events.Add(row); break; case 15: t15.Events.Add(row); break; case 16: t16.Events.Add(row); break; case 17: t17.Events.Add(row); break; case 18: t18.Events.Add(row); break; case 19: t19.Events.Add(row); break; case 20: t20.Events.Add(row); break; } } foreach (var t in preTestTables) { TestForValidRecords(t, tables); } foreach (var t in tables) { t.Add105Events(SignalID, StartDate, EndDate); var detailchart = new PreemptDetailChart(this, t); var chart = detailchart.DetailChart; var chartName = CreateFileName(); chart.SaveImage(MetricFileLocation + chartName, ChartImageFormat.Jpeg); returnList.Add(MetricWebPath + chartName); } return(returnList); }