private void RemoveApproachesByFilter(FilterSignal filterSignal, Models.Signal signal)
        {
            RemoveApproachesFromSignalByDirection(signal);
            RemoveDetectorsFromSignalByMovement(signal);
            var approachRepository  = ApproachRepositoryFactory.Create();
            var excludedApproachIds =
                filterSignal.FilterApproaches.Where(f => f.Exclude).Select(f => f.ApproachId).ToList();
            var excludedApproaches = approachRepository.GetApproachesByIds(excludedApproachIds);

            foreach (var excludedApproach in excludedApproaches)
            {
                var approachesToExclude = signal.Approaches.Where(a =>
                                                                  a.DirectionTypeID == excludedApproach.DirectionTypeID &&
                                                                  a.ProtectedPhaseNumber == excludedApproach.ProtectedPhaseNumber &&
                                                                  a.PermissivePhaseNumber == excludedApproach.PermissivePhaseNumber &&
                                                                  a.IsPermissivePhaseOverlap ==
                                                                  excludedApproach.IsPermissivePhaseOverlap &&
                                                                  a.IsProtectedPhaseOverlap ==
                                                                  excludedApproach.IsProtectedPhaseOverlap)
                                          .ToList();
                foreach (var approachToExclude in approachesToExclude)
                {
                    signal.Approaches.Remove(approachToExclude);
                }
                foreach (var approach in signal.Approaches)
                {
                    foreach (var filterApproach in filterSignal.FilterApproaches.Where(f => !f.Exclude))
                    {
                        RemoveDetectorsFromApproachByFilter(filterApproach, approach);
                    }
                }
            }
        }
Exemple #2
0
        private static List <RouteSignal> CreateRouteSignals(OldRoute oldRoute, Route newRoute, SPM db)
        {
            List <RouteSignal>  signals = new List <RouteSignal>();
            IApproachRepository appRepo = ApproachRepositoryFactory.Create(db);

            foreach (var detail in oldRoute.Details)
            {
                var         approach = appRepo.GetApproachByApproachID(detail.ApproachId);
                RouteSignal signal   = new RouteSignal();
                signal.Route           = newRoute;
                signal.Order           = detail.Order;
                signal.SignalId        = approach.SignalID;
                signal.PhaseDirections = CreateRoutePhaseDirections(signal, detail, approach, db);
                signals.Add(signal);
            }
            return(signals);
        }
Exemple #3
0
        public static Approach CopyApproach(int approachIDToCopy)
        {
            var approachRepository =
                ApproachRepositoryFactory.Create();
            var approachToCopy = approachRepository.GetApproachByApproachID(approachIDToCopy);
            var newApproach    = CopyApproachCommonProperties(approachToCopy, false);

            if (approachToCopy.Detectors != null)
            {
                foreach (var d in approachToCopy.Detectors)
                {
                    var
                             dForNewApproach =
                        Detector.CopyDetector(d.ID,
                                              true); //need to increase DetChannel if not copying the whole signal.
                    newApproach.Detectors.Add(dForNewApproach);
                }
                if (newApproach.Detectors.Count > 1)
                {
                    newApproach = SetDetChannelWhenMultipleDetectorsExist(newApproach);
                }
            }
            return(newApproach);
        }