Exemplo n.º 1
0
        public void SetPlanEvents(DateTime startTime, DateTime endTime)
        {
            var repository =
                ControllerEventLogRepositoryFactory.Create();

            PlanEvents = repository.GetSignalEventsByEventCode(SignalID, startTime, endTime, 131);
        }
Exemplo n.º 2
0
        private void GetAllRawCycleData(DateTime optionsStartDate, DateTime optionsEndDate, bool phasedata)
        {
            CycleDataEventLogs = new List <Controller_Event_Log>();
            CycleAllEvents     = new Dictionary <string, List <Controller_Event_Log> >();
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();
            var simpleEndDate            = optionsEndDate;
            var phaseEventCodesForCycles = new List <int> {
                1, 3, 8, 9, 11
            };

            if (!phasedata)
            {
                phaseEventCodesForCycles = new List <int> {
                    61, 62, 63, 64, 65
                };
            }

            string keyLabel         = "Cycles Intervals " + PhaseNumber + " " + phasedata;
            var    extendLeftSearch = Options.ExtendVsdSearch * 60;

            CycleDataEventLogs = controllerEventLogRepository.GetEventsByEventCodesParam(Options.SignalID,
                                                                                         optionsStartDate.AddSeconds(-extendLeftSearch), simpleEndDate,
                                                                                         phaseEventCodesForCycles, PhaseNumber);
            if (CycleDataEventLogs.Count > 0)
            {
                //var minTimeStamp = CycleDataEventLogs[0].Timestamp.ToString(" hh:mm:ss ");
                //var maxTimeStamp = CycleDataEventLogs[CycleDataEventLogs.Count - 1].Timestamp.ToString(" hh:mm:ss ");
                //keyLabel = keyLabel + minTimeStamp + " -> " + maxTimeStamp;
                CycleAllEvents.Add(keyLabel, CycleDataEventLogs);
            }
        }
        private void GetAllRawCycleData(DateTime optionsStartDate, DateTime optionsEndDate, bool phasedata)
        {
            CycleDataEventLogs = new List <Controller_Event_Log>();
            CycleAllEvents     = new Dictionary <string, List <Controller_Event_Log> >();
            var extendLine = 6;
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();
            var simpleEndDate            = optionsEndDate;
            var phaseEventCodesForCycles = new List <int> {
                1, 3, 8, 9, 11
            };

            if (!phasedata)
            {
                phaseEventCodesForCycles = new List <int> {
                    61, 62, 63, 64, 65
                };
            }
            string keyLabel = "Cycles Intervals " + PhaseNumber + " " + phasedata;

            CycleDataEventLogs = controllerEventLogRepository.GetEventsByEventCodesParam(Options.SignalID,
                                                                                         optionsStartDate.AddMinutes(-extendLine), simpleEndDate.AddMinutes(extendLine),
                                                                                         phaseEventCodesForCycles, PhaseNumber);
            if (CycleDataEventLogs.Count > 0)
            {
                CycleAllEvents.Add(keyLabel, CycleDataEventLogs);
            }
        }
Exemplo n.º 4
0
        private void GetSignalPhaseData(DateTime startDate, DateTime endDate, bool usePermissivePhase, SPM db)
        {
            if (!usePermissivePhase)
            {
                PhaseNumber = Approach.ProtectedPhaseNumber;
            }
            else
            {
                PhaseNumber = Approach.PermissivePhaseNumber ?? 0;
            }
            var controllerRepository =
                ControllerEventLogRepositoryFactory.Create(db);

            TotalVolume = controllerRepository.GetTmcVolume(startDate, endDate, Approach.SignalID, PhaseNumber);
            var cycleEvents = controllerRepository.GetEventsByEventCodesParam(Approach.SignalID,
                                                                              startDate, endDate, new List <int> {
                1, 8, 9, 10, 11
            }, PhaseNumber);

            Plans = new RLMPlanCollection(cycleEvents, startDate, endDate, SevereRedLightViolationSeconds, Approach, db);
            if (Plans.PlanList.Count == 0)
            {
                Plans.AddItem(new RLMPlan(startDate, endDate, 0, cycleEvents, SevereRedLightViolationSeconds,
                                          Approach));
            }
        }
Exemplo n.º 5
0
        public static List <Controller_Event_Log> GetPlanEvents(DateTime startDate, DateTime endDate, string signalId)
        {
            var db             = new SPM();
            var celRepository  = ControllerEventLogRepositoryFactory.Create(db);
            var planEvents     = new List <Controller_Event_Log>();
            var firstPlanEvent = celRepository.GetFirstEventBeforeDate(signalId, 131, startDate);

            if (firstPlanEvent != null)
            {
                firstPlanEvent.Timestamp = startDate;
                planEvents.Add(firstPlanEvent);
            }
            else
            {
                firstPlanEvent = new Controller_Event_Log
                {
                    Timestamp  = startDate,
                    EventCode  = 131,
                    EventParam = 0,
                    SignalID   = signalId
                };
                planEvents.Add(firstPlanEvent);
            }
            var tempPlanEvents = celRepository.GetSignalEventsByEventCode(signalId, startDate, endDate, 131)
                                 .OrderBy(e => e.Timestamp).ToList();

            tempPlanEvents.Add(new Controller_Event_Log {
                SignalID = signalId, EventCode = 131, EventParam = 254, Timestamp = endDate
            });

            for (var x = 0; x < tempPlanEvents.Count(); x++)
            {
                if (x + 2 < tempPlanEvents.Count())
                {
                    if (tempPlanEvents[x].EventParam == tempPlanEvents[x + 1].EventParam)
                    {
                        planEvents.Add(tempPlanEvents[x]);
                        x++;
                    }
                    else
                    {
                        planEvents.Add(tempPlanEvents[x]);
                    }
                }
                else
                {
                    if (tempPlanEvents.Count >= 2 && tempPlanEvents.Last().EventCode ==
                        tempPlanEvents[tempPlanEvents.Count() - 2].EventCode)
                    {
                        planEvents.Add(tempPlanEvents[tempPlanEvents.Count() - 2]);
                    }
                    else
                    {
                        planEvents.Add(tempPlanEvents.Last());
                    }
                }
            }

            return(planEvents);
        }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        private void CheckSignalRecordCount(DateTime dateToCheck, Models.Signal signal)
        {
            var controllerEventLogRepository =
                ControllerEventLogRepositoryFactory.Create();

            if (controllerEventLogRepository.GetRecordCount(signal.SignalID, dateToCheck.AddDays(-1), dateToCheck) >
                Settings.MinimumRecords)
            {
                Console.WriteLine("Signal " + signal.SignalID + " Has Current records");
                SignalsWithRecords.Add(signal);
            }
            else
            {
                Console.WriteLine("Signal " + signal.SignalID + " Does Not Have Current records");
                SignalsNoRecords.Add(signal);
                MOE.Common.Models.SPMWatchDogErrorEvent error = new MOE.Common.Models.SPMWatchDogErrorEvent();
                error.SignalID   = signal.SignalID;
                error.DetectorID = "0";
                error.Phase      = 0;
                error.Direction  = "";
                error.TimeStamp  = ScanDate;
                error.Message    = "Missing Records - IP: " + signal.IPAddress;
                error.ErrorCode  = 1;
                MissingRecords.Add(error);
            }
        }
Exemplo n.º 8
0
        private static List <Controller_Event_Log> GetDetailedCycleEvents(bool getPermissivePhase, DateTime startDate,
                                                                          DateTime endDate, Approach approach)
        {
            var celRepository = ControllerEventLogRepositoryFactory.Create();
            List <Controller_Event_Log> cycleEvents;


            if (getPermissivePhase)
            {
                var cycleEventNumbers = approach.IsPermissivePhaseOverlap
                    ? new List <int> {
                    61, 63, 64, 66
                }
                    : new List <int> {
                    1, 3, 8, 9, 11
                };
                cycleEvents = celRepository.GetEventsByEventCodesParam(approach.SignalID, startDate,
                                                                       endDate, cycleEventNumbers, approach.PermissivePhaseNumber.Value);
            }
            else
            {
                var cycleEventNumbers = approach.IsProtectedPhaseOverlap
                    ? new List <int> {
                    61, 63, 64, 66
                }
                    : new List <int> {
                    1, 3, 8, 9, 11
                };
                cycleEvents = celRepository.GetEventsByEventCodesParam(approach.SignalID, startDate,
                                                                       endDate, cycleEventNumbers, approach.ProtectedPhaseNumber);
            }
            return(cycleEvents);
        }
Exemplo n.º 9
0
        public int GetVolumeForPeriod(DateTime StartDate, DateTime EndDate)
        {
            var repository =
                ControllerEventLogRepositoryFactory.Create();

            return(repository.GetDetectorActivationCount(Approach.SignalID, StartDate, EndDate, DetChannel));
        }
        private void GetPedestrianEvents()
        {
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();

            PedestrianEvents = controllerEventLogRepository.GetEventsByEventCodesParam(Options.SignalID,
                                                                                       Options.StartDate, Options.EndDate, new List <int> {
                89, 90
            }, PhaseNumber);
        }
Exemplo n.º 11
0
        public List <Controller_Event_Log> GetDetectorOnEvents(DateTime startTime, DateTime endTime)
        {
            var repository =
                ControllerEventLogRepositoryFactory.Create();

            return(repository.GetEventsByEventCodesParam(Approach.SignalID, startTime,
                                                         endTime, new List <int> {
                82
            }, DetChannel));
        }
Exemplo n.º 12
0
        private void GetPedestrianEvents()
        {
            var extendStartTime = Options.ExtendVsdSearch * 60.0;
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();

            PedestrianEvents = controllerEventLogRepository.GetEventsByEventCodesParam(Options.SignalID,
                                                                                       Options.StartDate.AddSeconds(-extendStartTime), Options.EndDate,
                                                                                       new List <int> {
                89, 90
            }, PhaseNumber);
        }
Exemplo n.º 13
0
        public RLMPlan(DateTime start, DateTime end, int planNumber,
                       List <Controller_Event_Log> cycleEvents,
                       double srlvSeconds, Approach approach)
        {
            Approach        = approach;
            startTime       = start;
            endTime         = end;
            this.planNumber = planNumber;
            var usePermissivePhase = false;
            var db = new SPM();
            var l  = new List <int> {
                1, 8, 9, 10, 11
            };
            List <Controller_Event_Log> permEvents = null;

            if (Approach.PermissivePhaseNumber != null)
            {
                usePermissivePhase = true;
                var cveRepository =
                    ControllerEventLogRepositoryFactory.Create();
                permEvents = cveRepository.GetEventsByEventCodesParam(Approach.SignalID,
                                                                      start, end, l, Approach.ProtectedPhaseNumber);
                foreach (var row in cycleEvents)
                {
                    if (row.Timestamp >= start && row.Timestamp <= end &&
                        GetEventType(row.EventCode) == RLMCycle.EventType.BeginYellowClearance)
                    {
                        foreach (var permRow in permEvents)
                        {
                            if (GetEventType(permRow.EventCode) == RLMCycle.EventType.BeginYellowClearance)
                            {
                                if (row.Timestamp == permRow.Timestamp)
                                {
                                    usePermissivePhase = false;
                                }
                            }
                        }
                    }
                }
            }
            SRLVSeconds = srlvSeconds;
            startTime   = start;
            endTime     = end;
            if (usePermissivePhase)
            {
                GetRedCycle(start, end, permEvents);
            }
            else
            {
                GetRedCycle(start, end, cycleEvents);
            }
        }
Exemplo n.º 14
0
        private static List <Controller_Event_Log> GetTerminationEvents(bool getPermissivePhase, DateTime startDate,
                                                                        DateTime endDate,
                                                                        Approach approach)
        {
            var celRepository = ControllerEventLogRepositoryFactory.Create();
            var cycleEvents   = celRepository.GetEventsByEventCodesParam(approach.SignalID, startDate,
                                                                         endDate, new List <int> {
                4, 5, 6
            },
                                                                         getPermissivePhase ? approach.PermissivePhaseNumber.Value : approach.ProtectedPhaseNumber);

            return(cycleEvents);
        }
        private void GetAdvancePresenceEvents()
        {
            AdvancePresenceEvents = new Dictionary <string, List <Controller_Event_Log> >();
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();
            var localSortedDetectors         = Approach.Detectors.OrderByDescending(d => d.MovementType.DisplayOrder)
                                               .ThenByDescending(l => l.LaneNumber).ToList();

            foreach (var detector in localSortedDetectors)
            {
                if (detector.DetectionTypes.Any(d => d.DetectionTypeID == 7))
                {
                    var advancePresence = controllerEventLogRepository.GetEventsByEventCodesParam(Approach.SignalID,
                                                                                                  Options.StartDate, Options.EndDate, new List <int> {
                        81, 82
                    }, detector.DetChannel);
                    var laneNumber = "";
                    if (detector.LaneNumber != null)
                    {
                        laneNumber = detector.LaneNumber.Value.ToString();
                    }
                    if (advancePresence.Count > 0)
                    {
                        AdvancePresenceEvents.Add("Advanced Presence, " + detector.MovementType.Abbreviation + " " +
                                                  laneNumber + ", ch " + detector.DetChannel, advancePresence);
                    }
                    else if (AdvancePresenceEvents.Count == 0 && Options.ShowAllLanesInfo)
                    {
                        var forceEventsForAllLanes = new List <Controller_Event_Log>();
                        var tempEvent1             = new Controller_Event_Log()
                        {
                            SignalID   = Options.SignalID,
                            EventCode  = 82,
                            EventParam = detector.DetChannel,
                            Timestamp  = Options.StartDate.AddSeconds(-10)
                        };
                        forceEventsForAllLanes.Add(tempEvent1);
                        var tempEvent2 = new Controller_Event_Log()
                        {
                            SignalID   = Options.SignalID,
                            EventCode  = 81,
                            EventParam = detector.DetChannel,
                            Timestamp  = Options.StartDate.AddSeconds(-9)
                        };
                        forceEventsForAllLanes.Add(tempEvent2);
                        AdvancePresenceEvents.Add("Advanced Presence, ch " + detector.DetChannel + " " +
                                                  detector.MovementType.Abbreviation + " " +
                                                  laneNumber, forceEventsForAllLanes);
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void GetDetectorEvents(int metricTypeId)
        {
            var celRepository = ControllerEventLogRepositoryFactory.Create();

            DetectorEvents = new List <Controller_Event_Log>();
            var detectorsForMetric = Approach.GetDetectorsForMetricType(metricTypeId);

            foreach (var d in detectorsForMetric)
            {
                DetectorEvents.AddRange(celRepository.GetEventsByEventCodesParamWithOffsetAndLatencyCorrection(Approach.SignalID, StartDate,
                                                                                                               EndDate, new List <int> {
                    82
                }, d.DetChannel, d.GetOffset(), d.LatencyCorrection));
            }
        }
Exemplo n.º 17
0
        /// <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(Models.Detector detector, DateTime startDate, DateTime endDate, int binsize)
        {
            DetID    = detector.DetectorID;
            Channel  = detector.DetChannel;
            Approach = detector.Approach;
            SignalID = detector.Approach.SignalID;
            LaneType = detector.LaneType;
            var celRepository =
                ControllerEventLogRepositoryFactory.Create();
            var detectorEvents = new List <Controller_Event_Log>();

            detectorEvents.AddRange(celRepository.GetEventsByEventCodesParam(detector.Approach.SignalID, startDate,
                                                                             endDate, new List <int> {
                82
            }, Channel));

            Volumes = new VolumeCollection(startDate, endDate, detectorEvents, binsize);
        }
Exemplo n.º 18
0
        private void GetSignalOverlapData(DateTime startDate, DateTime endDate, bool showVolume, int binSize, SPM db)
        {
            var redLightTimeStamp = DateTime.MinValue;
            var li = new List <int> {
                62, 63, 64
            };
            var controllerRepository =
                ControllerEventLogRepositoryFactory.Create();
            var cycleEvents = controllerRepository.GetEventsByEventCodesParam(Approach.SignalID,
                                                                              startDate, endDate, li, Approach.ProtectedPhaseNumber);

            Plans = new RLMPlanCollection(cycleEvents, startDate, endDate, SevereRedLightViolationSeconds, Approach, db);
            if (Plans.PlanList.Count == 0)
            {
                Plans.AddItem(new RLMPlan(startDate, endDate, 0, cycleEvents, SevereRedLightViolationSeconds,
                                          Approach));
            }
        }
Exemplo n.º 19
0
        private static List <Controller_Event_Log> GetCycleEvents(bool getPermissivePhase, DateTime startDate,
                                                                  DateTime endDate, Approach approach, SPM db)
        {
            IControllerEventLogRepository celRepository;

            if (db != null)
            {
                celRepository = ControllerEventLogRepositoryFactory.Create(db);
            }
            else
            {
                celRepository = ControllerEventLogRepositoryFactory.Create();
            }
            List <Controller_Event_Log> cycleEvents;

            if (getPermissivePhase)
            {
                var cycleEventNumbers = approach.IsPermissivePhaseOverlap
                    ? new List <int> {
                    61, 63, 64, 66
                }
                    : new List <int> {
                    1, 8, 9
                };
                cycleEvents = celRepository.GetEventsByEventCodesParam(approach.SignalID, startDate,
                                                                       endDate, cycleEventNumbers, approach.PermissivePhaseNumber.Value);

                //cycleEvents = celRepository.GetEventsByEventCodesParam(approach.SignalID, startDate,
                //    endDate, new List<int>() {1, 8, 9}, approach.PermissivePhaseNumber.Value);
            }
            else
            {
                var cycleEventNumbers = approach.IsProtectedPhaseOverlap
                    ? new List <int> {
                    61, 63, 64, 66
                }
                    : new List <int> {
                    1, 8, 9
                };
                cycleEvents = celRepository.GetEventsByEventCodesParam(approach.SignalID, startDate,
                                                                       endDate, cycleEventNumbers, approach.ProtectedPhaseNumber);
            }
            return(cycleEvents);
        }
Exemplo n.º 20
0
        public void GetPedestrianIntervals(bool phaseOrOverlap)
        {
            var extendStartSearch = Options.ExtendStartStopSearch * 60.0;
            var overlapCodes      = new List <int> {
                67, 68, 69
            };

            if (phaseOrOverlap)
            {
                overlapCodes = new List <int> {
                    21, 22, 23
                };
            }
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();

            PedestrianIntervals = controllerEventLogRepository.GetEventsByEventCodesParam(Options.SignalID,
                                                                                          Options.StartDate.AddSeconds(-extendStartSearch), Options.EndDate.AddSeconds(extendStartSearch),
                                                                                          overlapCodes, PhaseNumber);
        }
        public void GetPedestrianIntervals(bool phaseOrOverlap)
        {
            var overlapCodes = new List <int> {
                67, 68, 69
            };

            if (phaseOrOverlap)
            {
                overlapCodes = new List <int> {
                    21, 22, 23
                };
            }
            var expandTimeLine = 6;
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();

            PedestrianIntervals = controllerEventLogRepository.GetEventsByEventCodesParam(Options.SignalID,
                                                                                          Options.StartDate.AddMinutes(-expandTimeLine), Options.EndDate.AddMinutes(expandTimeLine), overlapCodes,
                                                                                          PhaseNumber);
        }
Exemplo n.º 22
0
        public RLMSignalPhase(DateTime startDate, DateTime endDate, int binSize, double severeRedLightViolatinsSeconds,
                              Approach approach, bool usePermissivePhase)
        {
            SevereRedLightViolationSeconds = severeRedLightViolatinsSeconds;
            Approach           = approach;
            GetPermissivePhase = usePermissivePhase;
            var controllerRepository =
                ControllerEventLogRepositoryFactory.Create();

            if (!Approach.IsProtectedPhaseOverlap)
            {
                GetSignalPhaseData(startDate, endDate, usePermissivePhase);
            }
            else
            {
                TotalVolume = controllerRepository.GetTmcVolume(startDate, endDate, Approach.SignalID,
                                                                Approach.ProtectedPhaseNumber);
                GetSignalOverlapData(startDate, endDate, _showVolume, binSize);
            }
        }
Exemplo n.º 23
0
        public AnalysisPhaseCollection(string signalId, DateTime startTime, DateTime endTime)
        {
            var cel   = ControllerEventLogRepositoryFactory.Create();
            var ptedt = cel.GetSignalEventsByEventCodes(signalId, startTime, endTime,
                                                        new List <int> {
                1, 11, 4, 5, 6, 7, 21, 23
            });
            var dapta = cel.GetSignalEventsByEventCodes(signalId, startTime, endTime, new List <int> {
                1
            });
            var phasesInUse = dapta.Where(d => d.EventCode == 1).Select(d => d.EventParam).Distinct();

            Plans = PlanFactory.GetSplitMonitorPlans(startTime, endTime, signalId);
            foreach (var row in phasesInUse)
            {
                var aPhase = new AnalysisPhase(row, signalId, ptedt);
                Items.Add(aPhase);
            }
            OrderPhases();
        }
Exemplo n.º 24
0
        private static void GetEventsToCompleteCycle(bool getPermissivePhase, DateTime endDate, Approach approach,
                                                     List <Controller_Event_Log> cycleEvents)
        {
            var celRepository = ControllerEventLogRepositoryFactory.Create();

            if (getPermissivePhase)
            {
                var cycleEventNumbers = approach.IsPermissivePhaseOverlap
                    ? new List <int> {
                    61, 63, 64, 66
                }
                    : new List <int> {
                    1, 8, 9
                };
                var eventsAfterEndDate = celRepository.GetTopEventsAfterDateByEventCodesParam(approach.SignalID,
                                                                                              endDate, cycleEventNumbers, approach.PermissivePhaseNumber.Value, 3);
                if (eventsAfterEndDate != null)
                {
                    cycleEvents.AddRange(eventsAfterEndDate);
                }
            }
            else
            {
                var cycleEventNumbers = approach.IsProtectedPhaseOverlap
                    ? new List <int> {
                    61, 63, 64, 66
                }
                    : new List <int> {
                    1, 8, 9
                };
                var eventsAfterEndDate = celRepository.GetTopEventsAfterDateByEventCodesParam(approach.SignalID,
                                                                                              endDate, cycleEventNumbers, approach.ProtectedPhaseNumber, 3);
                if (eventsAfterEndDate != null)
                {
                    cycleEvents.AddRange(eventsAfterEndDate);
                }
            }
        }
Exemplo n.º 25
0
Arquivo: Phase.cs Projeto: gmonk/ATSPM
        public Phase(Approach approach,
                     DateTime startDate, DateTime endDate, List <int> eventCodes, int StartofCycleEvent, bool UsePermissivePhase)
        {
            startDate = startDate.AddMinutes(-1);
            endDate   = endDate.AddMinutes(+1);
            Approach  = approach;
            StartDate = startDate;
            EndDate   = endDate;
            if (!UsePermissivePhase)
            {
                PhaseNumber = Approach.ProtectedPhaseNumber;
            }
            else
            {
                PhaseNumber = Approach.PermissivePhaseNumber ?? 0;
            }
            IsOverlap = false;
            SignalID  = Approach.Signal.SignalID;
            var cer = ControllerEventLogRepositoryFactory.Create();

            Events = cer.GetEventsByEventCodesParam(SignalID, startDate, endDate, eventCodes, PhaseNumber);
            GetCycles(StartofCycleEvent);
        }
Exemplo n.º 26
0
        public AnalysisPhaseCollection(string signalId, DateTime startTime, DateTime endTime, int consecutivecount)
        {
            SignalId = signalId;
            var cel   = ControllerEventLogRepositoryFactory.Create();
            var ptedt = cel.GetSignalEventsByEventCodes(SignalId, startTime, endTime,
                                                        new List <int> {
                1, 11, 4, 5, 6, 7, 21, 23
            });
            var dapta = cel.GetSignalEventsByEventCodes(SignalId, startTime, endTime, new List <int> {
                1
            });

            ptedt = ptedt.OrderByDescending(i => i.Timestamp).ToList();
            var phasesInUse = dapta.Where(r => r.EventCode == 1).Select(r => r.EventParam).Distinct();

            Plans = PlanFactory.GetSplitMonitorPlans(startTime, endTime, SignalId);
            foreach (var row in phasesInUse)
            {
                var aPhase = new AnalysisPhase(row, ptedt, consecutivecount);
                Items.Add(aPhase);
            }
            OrderPhases();
            MaxPhaseInUse = FindMaxPhase(Items);
        }
Exemplo n.º 27
0
        private void GetAdvancePresenceEvents()
        {
            var extendBothStartStopSearch = Options.ExtendStartStopSearch * 60.0;

            AdvancePresenceEvents = new Dictionary <string, List <Controller_Event_Log> >();
            var controllerEventLogRepository = ControllerEventLogRepositoryFactory.Create();
            var localSortedDetectors         = Approach.Detectors.OrderByDescending(d => d.MovementType.DisplayOrder)
                                               .ThenByDescending(l => l.LaneNumber).ToList();

            //Parallel.ForEach(localSortedDetectors, detector =>
            foreach (var detector in localSortedDetectors)
            {
                if (detector.DetectionTypes.Any(d => d.DetectionTypeID == 7))
                {
                    var advancePresence = controllerEventLogRepository.GetEventsByEventCodesParam(Approach.SignalID,
                                                                                                  Options.StartDate.AddSeconds(-extendBothStartStopSearch),
                                                                                                  Options.EndDate.AddSeconds(extendBothStartStopSearch),
                                                                                                  new List <int> {
                        81, 82
                    }, detector.DetChannel);
                    var laneNumber = "";
                    if (detector.LaneNumber != null)
                    {
                        laneNumber = detector.LaneNumber.Value.ToString();
                    }

                    if (advancePresence.Count > 0)
                    {
                        //var minTimeStamp = advancePresence[0].Timestamp.ToString(" hh:mm:ss ");
                        //var maxTimeStamp = advancePresence[advancePresence.Count - 1].Timestamp.ToString(" hh:mm:ss ");
                        var keyLabel = "Advanced Presence, " +
                                       detector.MovementType.Abbreviation + " " + laneNumber + ", ch " +
                                       detector.DetChannel;
                        //+ minTimeStamp + " -> " + maxTimeStamp;
                        AdvancePresenceEvents.Add(keyLabel, advancePresence);
                        //AdvancePresenceEvents.Add("Advanced Presence, " + detector.MovementType.Abbreviation + " " +
                        //                          laneNumber + ", ch " + detector.DetChannel, advancePresence);
                    }
                    else if (AdvancePresenceEvents.Count == 0 && Options.ShowAllLanesInfo)
                    {
                        var forceEventsForAllLanes = new List <Controller_Event_Log>();
                        var tempEvent1             = new Controller_Event_Log()
                        {
                            SignalID   = Options.SignalID,
                            EventCode  = 82,
                            EventParam = detector.DetChannel,
                            Timestamp  = Options.StartDate.AddSeconds(-10)
                        };
                        forceEventsForAllLanes.Add(tempEvent1);
                        var tempEvent2 = new Controller_Event_Log()
                        {
                            SignalID   = Options.SignalID,
                            EventCode  = 81,
                            EventParam = detector.DetChannel,
                            Timestamp  = Options.StartDate.AddSeconds(-9)
                        };
                        forceEventsForAllLanes.Add(tempEvent2);
                        AdvancePresenceEvents.Add("Advanced Presence, ch " + detector.DetChannel + " " +
                                                  detector.MovementType.Abbreviation + " " +
                                                  laneNumber, forceEventsForAllLanes);
                    }
                }
            }
            //});
        }