Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        private void SetDetectorActivations(SplitFailOptions options, SPM db)
        {
            var controllerEventsRepository = ControllerEventLogRepositoryFactory.Create(db);
            var phaseNumber = GetPermissivePhase ? Approach.PermissivePhaseNumber.Value : Approach.ProtectedPhaseNumber;
            var detectors   = Approach.GetAllDetectorsOfDetectionType(6);// .GetDetectorsForMetricType(12);

            foreach (var detector in detectors)
            {
                //var lastCycle = Cycles.OrderBy(c => c.StartTime).LastOrDefault();
                List <Models.Controller_Event_Log> events = controllerEventsRepository.GetEventsByEventCodesParamWithLatencyCorrection(Approach.SignalID,
                                                                                                                                       options.StartDate, options.EndDate, new List <int> {
                    81, 82
                }, detector.DetChannel, detector.LatencyCorrection);
                if (!events.Any())
                {
                    CheckForDetectorOnBeforeStart(options, controllerEventsRepository, detector);
                }
                else
                {
                    AddDetectorOnToBeginningIfNecessary(options, detector, events);
                    AddDetectorOffToEndIfNecessary(options, detector, events);
                    AddDetectorActivationsFromList(events);
                }
            }
            CombineDetectorActivations();
        }