Пример #1
0
        /// <summary>
        /// Creates records for 3 cars having 2 laps
        /// </summary>
        protected virtual EventLapAverages BuildTestEvent2LapAverages()
        {
            EventLapAverages averages = new EventLapAverages();

            int carCount = 3;
            int lapCount = 2;

            for (int carIndex = 1; carIndex < carCount + 1; carIndex++)
            {
                for (int lapIndex = 1; lapIndex < lapCount + 1; lapIndex++)
                {
                    double lapTime = 10.0 - carIndex;

                    averages.AddLapTime(
                        new VehicleLapTime()
                    {
                        CarNumber     = carIndex.ToString(),
                        TrackState    = TrackState.Green,
                        VehicleStatus = VehicleStatus.OnTrack,
                        LapNumber     = lapIndex,
                        LapTime       = lapTime,
                        LapSpeed      = 100 - lapTime
                    });
                }
            }

            return(averages);
        }
Пример #2
0
 protected virtual void ReadLapTimes(NascarFeed.Models.LiveFeed.RootObject feed)
 {
     foreach (var vehicle in feed.vehicles)
     {
         _eventLapAverages.AddLapTime(new VehicleLapTime()
         {
             CarNumber     = vehicle.vehicle_number,
             LapNumber     = feed.lap_number,
             LapTime       = vehicle.last_lap_time,
             LapSpeed      = vehicle.last_lap_speed,
             VehicleStatus = (VehicleStatus)vehicle.status,
             TrackState    = (TrackState)feed.flag_state
         });
     }
 }
Пример #3
0
        /// <summary>
        /// Creates records for 2 cars having 20 laps and 1 car having 2 laps
        /// </summary>
        protected virtual EventLapAverages BuildTestEvent20And2LapAverages()
        {
            EventLapAverages averages = new EventLapAverages();

            int carCount       = 3;
            int lapCount       = 20;
            int slowLapCutoff1 = 5;
            int slowLapCutoff2 = 15;

            for (int carIndex = 1; carIndex < carCount + 1; carIndex++)
            {
                for (int lapIndex = 1; lapIndex < lapCount + 1; lapIndex++)
                {
                    if (carIndex < 3 || (carIndex >= 3 && lapIndex < 3))
                    {
                        double lapTime;

                        if (lapIndex > slowLapCutoff2)
                        {
                            lapTime = 30.0 - carIndex;
                        }
                        else if (lapIndex > slowLapCutoff1)
                        {
                            lapTime = 20.0 - carIndex;
                        }
                        else
                        {
                            lapTime = 10.0 - carIndex;
                        }

                        averages.AddLapTime(
                            new VehicleLapTime()
                        {
                            CarNumber     = carIndex.ToString(),
                            TrackState    = TrackState.Green,
                            VehicleStatus = VehicleStatus.OnTrack,
                            LapNumber     = lapIndex,
                            LapTime       = lapTime,
                            LapSpeed      = 100 - lapTime
                        });
                    }
                }
            }

            return(averages);
        }