Ejemplo n.º 1
0
        protected override void Command(RecognitionResult rr)
        {
            var d = dataCollector.Data;

            if (d == null)
            {
                SpeakAsync("Yet to received any data from iRacing");
                return;
            }

            var session = d.Telemetry.Session;;

            SpeakAsync("You are in a {0} session.".F(session.SessionType));
            TimeSpan sessionTimeSpanRemaining = TimeSpan.MaxValue;

            if (session.IsLimitedTime)
            {
                sessionTimeSpanRemaining = TimeSpan.FromSeconds(d.Telemetry.SessionTimeRemain);
                SpeakAsync("There is {0} minutes remaining in the session".F((int)sessionTimeSpanRemaining.TotalMinutes));
            }

            var r = FuelStrategy.CalculateRemainingLapsForFuel(
                fuelLevel: d.Telemetry.FuelLevel,
                averageFuelBurnPerLap: dataCollector.AverageFuelPerLap,
                averageLapTime: dataCollector.AverageLapTimeSpan);

            SpeakAsync("You will run out of fuel in about {0} laps.".F(r.EstimateLapsRemaining));
            SpeakAsync("You will run out of fuel in about {0} minutes.".F((int)r.EstimateTimeRemaining.TotalMinutes));
        }
        void Calculate()
        {
            if (dataCollector.RaceDuration.Type == RaceType.Laps)
            {
                SpeakAsync("Your race length is {0} laps".F(dataCollector.RaceDuration.Length));
            }
            else
            {
                SpeakAsync("Your race length is {0} minutes".F(dataCollector.RaceDuration.Length));
            }

            SpeakAsync("Your tank size is {0}".F(dataCollector.TankSize));

            var t = dataCollector.AverageLapTimeSpan;

            SpeakAsync("Your average fuel usage is {0:0.00} litres per lap.".F(dataCollector.AverageFuelPerLap));

            if (dataCollector.RaceDuration.Type == RaceType.Minutes)
            {
                var r = FuelStrategy.Calculate(dataCollector.RaceDuration.TotalMinutes, dataCollector.AverageFuelPerLap, dataCollector.AverageLapTimeSpan, (int)dataCollector.TankSize);

                SpeakAsync("Estimating you will do {0} laps in {1} minutes".F(r.EstimatedNumberOfRaceLaps, (int)r.RaceDuration.TotalMinutes));
                SpeakAsync("For a {0} minute race, you will need a total of {1} litres".F((int)r.RaceDuration.TotalMinutes, r.TotalFuelRequired));
                if (r.NumberOfPitStops == 0)
                {
                    SpeakAsync("You will not need to stop");
                }
                else
                {
                    SpeakAsync("You will need to stop {0}".F(ToWords(r.NumberOfPitStops)));
                }
            }
            else
            {
                var r = FuelStrategy.Calculate(dataCollector.RaceDuration.Length, dataCollector.AverageFuelPerLap, (int)dataCollector.TankSize);

                SpeakAsync("For a {0} lap race, you will need a total of {1} litres".F(dataCollector.RaceDuration.Length, r.TotalFuelRequired));
                if (r.NumberOfPitStops == 0)
                {
                    SpeakAsync("You will not need to stop");
                }
                else
                {
                    SpeakAsync("You will need to stop {0}".F(ToWords(r.NumberOfPitStops)));
                }
            }
        }
Ejemplo n.º 3
0
        protected override void Command(RecognitionResult rr)
        {
            var d = dataCollector.Data;

            if (d == null)
            {
                SpeakAsync("Yet to received any data from iRacing");
                return;
            }

            var session = d.Telemetry.Session;

            if (!session.IsRace)
            {
                SpeakAsync("You are not in a race");
                return;
            }

            if (session.IsLimitedTime)
            {
                var sessionTimeSpanRemaining = TimeSpan.FromSeconds(d.Telemetry.SessionTimeRemain);

                SpeakAsync(string.Format("There are {0} minutes remaining in this race.", (int)sessionTimeSpanRemaining.TotalMinutes));

                var r = FuelStrategy.CalculateToFinish(
                    fuelLevel: d.Telemetry.FuelLevel,
                    remainingTime: sessionTimeSpanRemaining,
                    raceDuration: dataCollector.RaceDuration.TotalMinutes,
                    averageFuelBurnPerLap: dataCollector.AverageFuelPerLap,
                    averageLapTime: dataCollector.AverageLapTimeSpan,
                    fuelTankCapacity: (int)dataCollector.TankSize);

                SpeakAsync("There are about {0} laps remaining".F(r.EstimateLapsRemaining));
                SpeakAsync("You need an additional {0} litres to finish".F(r.TotalFuelRequired));
                SpeakAsync("At your next stop, you need {0} litres".F(r.TotalFuelRequiredAtNextStop));
                if (r.PitWindowOpened)
                {
                    SpeakAsync("Your pit window is open");
                }
                else
                {
                    SpeakAsync("Your pit stop window will open in about {0} laps".F(r.LapsToPitWindow));
                }
            }

            else if (session.IsLimitedSessionLaps)
            {
                SpeakAsync(string.Format("There are {0} laps remaining", d.Telemetry.SessionLapsRemain));

                var r = FuelStrategy.CalculateToFinish(
                    fuelLevel: d.Telemetry.FuelLevel,
                    remainingLaps: d.Telemetry.SessionLapsRemain,
                    raceDuration: dataCollector.RaceDuration.TotalMinutes,
                    averageFuelBurnPerLap: dataCollector.AverageFuelPerLap,
                    averageLapTime: dataCollector.AverageLapTimeSpan,
                    fuelTankCapacity: (int)dataCollector.TankSize);

                SpeakAsync("You need an additional {0} litres to finish".F(r.TotalFuelRequired));
                SpeakAsync("At your next stop, you need {0} litres".F(r.TotalFuelRequiredAtNextStop));
                if (r.PitWindowOpened)
                {
                    SpeakAsync("Your pit window is open");
                }
                else
                {
                    SpeakAsync("Your pit stop window will open in about {0} laps".F(r.LapsToPitWindow));
                }
            }
        }