예제 #1
0
        private void CheckFtpFromAllControllers(List <Models.Signal> signals)
        {
            var startHour     = new TimeSpan(Settings.ScanDayStartHour, 0, 0);
            var endHour       = new TimeSpan(Settings.ScanDayEndHour, 0, 0);
            var analysisStart = ScanDate.Date + startHour;
            var analysisEnd   = ScanDate.Date + endHour;
            var options       = new ParallelOptions();

            options.MaxDegreeOfParallelism = Settings.MaxDegreeOfParallelism;
            MOE.Common.Models.Repositories.IApplicationEventRepository eventRepository = MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
            var events = eventRepository.GetApplicationEventsBetweenDatesByApplication(analysisStart, analysisEnd, "FTPFromAllcontrollers");

            Parallel.ForEach(signals, options, signal =>
                             //foreach(var signal in signals)
            {
                ErrorCount = (events.Where(e => e.Description.Contains(signal.SignalID)).Count());
                if (ErrorCount > 0)
                {
                    MOE.Common.Models.SPMWatchDogErrorEvent error = new MOE.Common.Models.SPMWatchDogErrorEvent();
                    Console.WriteLine("Signal " + signal.SignalID + " can not download from this signal during " + ErrorCount.ToString() + " atempts.  ");
                    error.SignalID   = signal.SignalID;
                    error.DetectorID = "0";
                    error.Phase      = 0;
                    error.Direction  = "";
                    error.TimeStamp  = ScanDate;
                    error.Message    = "FTPFromAllControllers could not download from Controller.  Number of attempts were: " + ErrorCount.ToString();
                    error.ErrorCode  = 6;
                    CannotFtpFiles.Add(error);
                }
                //}
            });
        }
예제 #2
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);
            }
        }
예제 #3
0
        private void CheckForLowDetectorHits(MOE.Common.Models.Signal signal)
        {
            List <MOE.Common.Models.Detector> detectors = signal.GetDetectorsForSignalThatSupportAMetric(6);

            //Parallel.ForEach(detectors, options, detector =>
            foreach (MOE.Common.Models.Detector detector in detectors)
            {
                try
                {
                    int      channel   = detector.DetChannel;
                    string   direction = detector.Approach.DirectionType.Description;
                    DateTime start     = new DateTime();
                    DateTime end       = new DateTime();
                    if (Settings.WeekdayOnly && ScanDate.DayOfWeek == DayOfWeek.Monday)
                    {
                        start = ScanDate.AddDays(-3).Date.AddHours(Settings.PreviousDayPMPeakStart);
                        end   = ScanDate.AddDays(-3).Date.AddHours(Settings.PreviousDayPMPeakEnd);
                    }
                    else
                    {
                        start = ScanDate.AddDays(-1).Date.AddHours(Settings.PreviousDayPMPeakStart);
                        end   = ScanDate.AddDays(-1).Date.AddHours(Settings.PreviousDayPMPeakEnd);
                    }
                    int currentVolume = detector.GetVolumeForPeriod(start, end);
                    //Compare collected hits to low hit threshold,
                    if (currentVolume < Convert.ToInt32(Settings.LowHitThreshold))
                    {
                        MOE.Common.Models.SPMWatchDogErrorEvent error = new MOE.Common.Models.SPMWatchDogErrorEvent();
                        error.SignalID   = signal.SignalID;
                        error.DetectorID = detector.DetectorID;
                        error.Phase      = detector.Approach.ProtectedPhaseNumber;
                        error.TimeStamp  = ScanDate;
                        error.Direction  = detector.Approach.DirectionType.Description;
                        error.Message    = "CH: " + channel.ToString() + " - Count: " + currentVolume.ToString();
                        error.ErrorCode  = 2;
                        if (!LowHitCountErrors.Contains(error))
                        {
                            LowHitCountErrors.Add(error);
                        }
                    }
                }

                catch (Exception ex)
                {
                    MOE.Common.Models.Repositories.IApplicationEventRepository er =
                        MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();

                    er.QuickAdd("SPMWatchDog", "Program", "CheckForLowDetectorHits",
                                MOE.Common.Models.ApplicationEvent.SeverityLevels.Medium, detector.DetectorID + "-" + ex.Message);
                }
            }
            //);
        }
예제 #4
0
 private void CheckForForceOff(MOE.Common.Business.AnalysisPhase phase, MOE.Common.Models.Signal signal)
 {
     if (phase.PercentForceOffs > Settings.PercentThreshold && phase.TerminationEvents.Where(t => t.EventCode != 7).Count() > Settings.MinPhaseTerminations)
     {
         MOE.Common.Models.SPMWatchDogErrorEvent error = new MOE.Common.Models.SPMWatchDogErrorEvent();
         error.SignalID  = signal.SignalID;
         error.Phase     = phase.PhaseNumber;
         error.TimeStamp = ScanDate;
         error.Direction = phase.Direction ?? "";
         error.Message   = "Force Offs " + Math.Round(phase.PercentForceOffs * 100, 1).ToString() + "%";
         error.ErrorCode = 4;
         if (!ForceOffErrors.Contains(error))
         {
             ForceOffErrors.Add(error);
         }
     }
 }
예제 #5
0
        private void CheckForMaxOut(MOE.Common.Business.AnalysisPhase phase,
                                    MOE.Common.Models.Signal signal)
        {
            if (phase.PercentMaxOuts > Settings.PercentThreshold && phase.TotalPhaseTerminations > Settings.MinPhaseTerminations)
            {
                MOE.Common.Models.SPMWatchDogErrorEvent error = new MOE.Common.Models.SPMWatchDogErrorEvent();
                error.SignalID  = signal.SignalID;
                error.Phase     = phase.PhaseNumber;
                error.TimeStamp = ScanDate;
                error.Direction = phase.Direction ?? "";
                error.Message   = "Max Outs " + Math.Round(phase.PercentMaxOuts * 100, 1).ToString() + "%";
                error.ErrorCode = 5;

                if (MaxOutErrors.Count == 0 || !MaxOutErrors.Contains(error))
                {
                    Console.WriteLine("Signal " + signal.SignalID + "Has MaxOut Errors");
                    MaxOutErrors.Add(error);
                }
            }
        }
예제 #6
0
 private void CheckForStuckPed(MOE.Common.Business.AnalysisPhase phase, MOE.Common.Models.Signal signal)
 {
     if (phase.PedestrianEvents.Count > Settings.MaximumPedestrianEvents)
     {
         MOE.Common.Models.SPMWatchDogErrorEvent error = new MOE.Common.Models.SPMWatchDogErrorEvent();
         error.SignalID  = signal.SignalID;
         error.Phase     = phase.PhaseNumber;
         error.TimeStamp = ScanDate;
         error.Direction = phase.Direction ?? "";
         error.Message   = phase.PedestrianEvents.Count.ToString() +
                           " Pedestrian Activations";
         error.ErrorCode = 3;
         if (!StuckPedErrors.Contains(error))
         {
             Console.WriteLine("Signal " + signal.SignalID + phase.PedestrianEvents.Count.ToString() +
                               " Pedestrian Activations");
             StuckPedErrors.Add(error);
         }
     }
 }