Esempio n. 1
0
        public void AddLapData(LapData lapData)
        {
            this.lapData.Add(lapData);

            if (CurrentLapNumber == 0)
            {
                CurrentLapNumber = lapData.CurrentLapNum;
            }
            else if (lapData.CurrentLapNum > CurrentLapNumber)
            {
                var lastLapData          = LapData.Where(l => (lapData.CurrentLapNum - 1).Equals(l.CurrentLapNum)).ToList().AsReadOnly();
                var lastCarTelemetryData = new List <CarTelemetryData>();

                foreach (var lastLap in lastLapData)
                {
                    lastCarTelemetryData.Add(CarTelemetryData.SingleOrDefault(c => c.SessionTime.Equals(lastLap.SessionTime) && c.SessionUID.Equals(lastLap.SessionUID)));
                }

                var newLapEventArgs = new NewLapEventArgs
                {
                    LastLapNumber        = lapData.CurrentLapNum - 1,
                    LastLapTime          = lapData.LastLapTime,
                    LastLapData          = lastLapData,
                    LastCarTelemetryData = lastCarTelemetryData.AsReadOnly()
                };

                OnNewLap(newLapEventArgs);

                if (CurrentLapInterval == LapIntervalThreshold)
                {
                    OnLapInterval();
                    CurrentLapInterval = 0;
                }

                CurrentLapInterval++;
            }

            CurrentLapNumber = lapData.CurrentLapNum;
        }
Esempio n. 2
0
 protected virtual void OnNewLap(NewLapEventArgs e)
 {
     NewLap?.Invoke(this, e);
 }