Exemplo n.º 1
0
 public TestPlan(
     Journey journey,
     double journeysPerMinute,
     FrequencyPattern frequency)
 {
     Journey   = journey;
     Frequency = frequency;
 }
Exemplo n.º 2
0
        private int GetJourneyCountInPeriod(FrequencyPattern frequencyPattern, DateTime startTime, DateTime endTime)
        {
            int totalSeconds = Convert.ToInt32(endTime.Subtract(startTime).TotalSeconds);

            return(Convert.ToInt32(
                       Enumerable.Range(0, totalSeconds)
                       .Select(s =>
                               new FrequencyService().GetCurrentFrequencyPerMinute(frequencyPattern, s) / 60)
                       .Sum()));
        }
Exemplo n.º 3
0
        public double GetGraphFrequencyPerMinute(
            FrequencyPattern frequencyPattern,
            int timeEllapsedSeconds)
        {
            double maxX            = frequencyPattern.Points.Max(p => p.UnitsFromStart);
            double secondsPerPoint = (frequencyPattern.DurationSeconds / maxX);
            var    currentPosition = timeEllapsedSeconds / secondsPerPoint;

            return(Enumerable.Range(0, frequencyPattern.Points.Count)
                   .Select(i => frequencyPattern.Points[i])
                   .Where(p => p.UnitsFromStart <= currentPosition)
                   .OrderByDescending(p => p.UnitsFromStart)
                   .First()
                   ?.FrequencyPerMinute ?? 0);
        }
Exemplo n.º 4
0
        public double GetCurrentFrequencyPerMinute(
            FrequencyPattern frequencyPattern,
            int timeEllapsedSeconds)
        {
            switch (frequencyPattern.PatternType)
            {
            case PatternType.Constant:
                return(frequencyPattern.MaxJourneysPerMinute);

            case PatternType.Gradual:
                return(GetGradualFrequencyPerMinute(frequencyPattern, timeEllapsedSeconds));

            case PatternType.Graph:
                return(GetGraphFrequencyPerMinute(frequencyPattern, timeEllapsedSeconds));

            default:
                throw new ArgumentException("Frequency pattern not recognised");
            }
        }
Exemplo n.º 5
0
        public double GetGradualFrequencyPerMinute(
            FrequencyPattern frequencyPattern,
            int timeEllapsedSeconds)
        {
            if (timeEllapsedSeconds < frequencyPattern.RampUpSeconds)
            {
                return((frequencyPattern.MaxJourneysPerMinute / frequencyPattern.RampUpSeconds) * timeEllapsedSeconds);
            }

            var rampdownStart = frequencyPattern.DurationSeconds - frequencyPattern.RampDownSeconds;

            if (timeEllapsedSeconds > rampdownStart)
            {
                double gradient = frequencyPattern.MaxJourneysPerMinute / frequencyPattern.RampDownSeconds;
                return(frequencyPattern.MaxJourneysPerMinute - (gradient * timeEllapsedSeconds));
            }

            return(frequencyPattern.MaxJourneysPerMinute);
        }