Exemplo n.º 1
0
        public SignalPhaseCollection(DateTime startDate, DateTime endDate, string signalID,
                                     bool showVolume, int binSize, int metricTypeId)
        {
            var repository = SignalsRepositoryFactory.Create();
            var signal     = repository.GetVersionOfSignalByDate(signalID, startDate);
            var approaches = signal.GetApproachesForSignalThatSupportMetric(metricTypeId);

            if (signal.Approaches != null && approaches.Count > 0)
            {
                //Parallel.ForEach(approaches, approach =>
                foreach (Models.Approach approach in approaches)
                {
                    var protectedSignalPhase = new SignalPhase(startDate, endDate, approach, showVolume, binSize,
                                                               metricTypeId, false);
                    SignalPhaseList.Add(protectedSignalPhase);
                    if (approach.PermissivePhaseNumber.HasValue)
                    {
                        var permissiveSignalPhase = new SignalPhase(startDate, endDate, approach, showVolume, binSize,
                                                                    metricTypeId, true);
                        SignalPhaseList.Add(permissiveSignalPhase);
                    }
                }//);
                //TODO: Should we remove phases with no cycles?
                SignalPhaseList = SignalPhaseList.OrderBy(s => s.Approach.ProtectedPhaseNumber).ToList();
            }
        }
Exemplo n.º 2
0
        public RLMSignalPhaseCollection(DateTime startDate, DateTime endDate, string signalID,
                                        int binSize, double srlvSeconds)
        {
            var metricTypeID = 11;
            var repository   =
                SignalsRepositoryFactory.Create();
            var signal = repository.GetVersionOfSignalByDate(signalID, startDate);

            SevereRedLightViolationsSeconds = srlvSeconds;
            var approachesForMetric = signal.GetApproachesForSignalThatSupportMetric(metricTypeID);

            //If there are phases in the database add the charts
            if (approachesForMetric.Any())
            {
                foreach (var approach in approachesForMetric)
                {
                    SignalPhaseList.Add(new RLMSignalPhase(
                                            startDate, endDate, binSize, SevereRedLightViolationsSeconds, approach, false));

                    if (approach.PermissivePhaseNumber != null && approach.PermissivePhaseNumber > 0)
                    {
                        SignalPhaseList.Add(new RLMSignalPhase(
                                                startDate, endDate, binSize, SevereRedLightViolationsSeconds, approach, true));
                    }
                }
            }
        }
Exemplo n.º 3
0
        public SignalPhaseCollection(MetricOptions options, bool showVolume, int binSize)
        {
            var repository = SignalsRepositoryFactory.Create();
            var signal     = repository.GetVersionOfSignalByDate(options.SignalID, options.StartDate);
            var approaches = signal.GetApproachesForSignalThatSupportMetric(options.MetricTypeID);

            if (signal.Approaches != null && approaches.Count > 0)
            {
                //Parallel.ForEach(approaches, approach =>
                foreach (Models.Approach approach in approaches)
                {
                    if (approach.ProtectedPhaseNumber != 0)
                    {
                        var protectedSignalPhase = new SignalPhase(options.StartDate, options.EndDate, approach, showVolume, binSize, options.MetricTypeID, false);
                        SignalPhaseList.Add(protectedSignalPhase);
                    }
                }//);
                //TODO: Should we remove phases with no cycles?
                SignalPhaseList = SignalPhaseList.OrderBy(s => s.Approach.ProtectedPhaseNumber).ToList();
            }
        }