private DriverInfo CreateDriverInfo(AllPacketsComposition rawData, string driverName, int driverIndex) { var rawDriverData = rawData.PacketParticipantsData.MParticipants[driverIndex]; var rawDriverLapInfo = rawData.PacketLapData.MLapData[driverIndex]; var rawCarMotionData = rawData.PacketMotionData.MCarMotionData[driverIndex]; DriverInfo driverInfo = new DriverInfo { DriverName = driverName, CompletedLaps = rawDriverLapInfo.MCurrentLapNum - 1, CarName = string.Empty, InPits = rawDriverLapInfo.MPitStatus != 0 || rawDriverLapInfo.MDriverStatus == 0, IsPlayer = driverIndex == rawData.PacketCarTelemetryData.MHeader.MPlayerCarIndex, Position = rawDriverLapInfo.MCarPosition, PositionInClass = rawDriverLapInfo.MCarPosition, Speed = Velocity.FromKph(rawData.PacketCarTelemetryData.MCarTelemetryData[driverIndex].MSpeed), LapDistance = rawDriverLapInfo.MLapDistance >= 0 ? rawDriverLapInfo.MLapDistance : rawData.PacketSessionData.MTrackLength + rawDriverLapInfo.MLapDistance, TotalDistance = rawDriverLapInfo.MTotalDistance }; driverInfo.CarName = TranslationTable.GetCarName(rawDriverData.MTeamId); driverInfo.CarClassName = TranslationTable.GetClass(rawData.PacketSessionData.MFormula); driverInfo.CarClassId = driverInfo.CarClassName; driverInfo.FinishStatus = rawData.AdditionalData.RetiredDrivers[driverIndex] ? DriverFinishStatus.Dnf : TranslateFinishStatus(rawDriverLapInfo.MResultStatus); driverInfo.WorldPosition = new Point3D(Distance.FromMeters(rawCarMotionData.MWorldPositionX), Distance.FromMeters(rawCarMotionData.MWorldPositionY), Distance.FromMeters(rawCarMotionData.MWorldPositionZ)); driverInfo.CurrentLapValid = rawDriverLapInfo.MCurrentLapInvalid == 0 && rawDriverLapInfo.MDriverStatus != 2 && rawDriverLapInfo.MDriverStatus != 3; ComputeDistanceToPlayer(_lastPlayer, driverInfo); FillTimingInfo(driverInfo, rawDriverLapInfo, driverIndex); return(driverInfo); }
public void Create_WhenFromKph_ThenValueInMsCorrect(double value) { // Arrange Velocity _testee = Velocity.FromKph(value); // Act double inMs = _testee.InMs; // Assert Assert.That(inMs, Is.EqualTo(value / 3.6).Within(0.001)); }
private void CheckAndAdvanceStartSequence(SimulatorDataSet dataSet) { if (dataSet.PlayerInfo != null && dataSet.PlayerInfo.InPits) { _startState = StartState.Countdown; dataSet.SessionInfo.SessionType = SessionType.Na; } if (dataSet.LeaderInfo.Speed > Velocity.FromKph(2)) { _startState = StartState.Started; dataSet.SessionInfo.SessionType = SessionType.Na; } }
private void AddDrivers(int driverCount, SessionSummary sessionSummary) { for (int i = 0; i < driverCount; i++) { sessionSummary.Drivers.Add(new Driver() { CarName = "A caaaar", DriverName = "Driver " + i, TotalLaps = 20, TopSpeed = Velocity.FromKph(_random.Next(150, 250)), FinishingPosition = i + 1, Finished = _random.Next(0, 10) > 0 ? true : false, IsPlayer = i == 0 }); } }
private void CheckAndAdvanceStartSequence(SimulatorDataSet dataSet) { if (dataSet.PlayerInfo != null && dataSet.PlayerInfo.InPits) { Logger.Info("Player in pits - moving to start sequence"); _startState = StartState.Countdown; dataSet.SessionInfo.SessionType = SessionType.Na; } if (dataSet.LeaderInfo.Speed > Velocity.FromKph(2)) { Logger.Info("Player moving - moving to started"); _startState = StartState.WaitForLineCross; dataSet.SessionInfo.SessionType = SessionType.Na; } }
public WheelDiameterWizardController(IViewModelFactory viewModelFactory, IWindowService windowService, ISettingsProvider settingsProvider) { _velocityUnits = settingsProvider.DisplaySettingsViewModel.VelocityUnits; _distanceUnits = settingsProvider.DisplaySettingsViewModel.DistanceUnitsVerySmall; _viewModelFactory = viewModelFactory; _windowService = windowService; _settingsProvider = settingsProvider; _welcomeStageViewModel = viewModelFactory.Create <WelcomeStageViewModel>(); _accelerationStageViewModel = viewModelFactory.Create <AccelerationStageViewModel>(); _preparationStageViewModel = viewModelFactory.Create <PreparationStageViewModel>(); _measurementPhaseViewModel = viewModelFactory.Create <MeasurementPhaseViewModel>(); _resultsStageViewModel = viewModelFactory.Create <ResultsStageViewModel>(); _accelerationStageViewModel.VelocityUnits = Velocity.GetUnitSymbol(_velocityUnits); _accelerationStageViewModel.TargetSpeed = _velocityUnits == VelocityUnits.Mph ? 75 : Math.Round(Velocity.FromKph(120).GetValueInUnits(_velocityUnits), 0); _resultsStageViewModel.DistanceUnits = Distance.GetUnitsSymbol(_distanceUnits); _resultsStageViewModel.OkCommand = new RelayCommand(TakeResultsFromWizard); _resultsStageViewModel.CancelCommand = new RelayCommand(CancelWizard); _resultsStageViewModel.RestartCommand = new RelayCommand(RestartWizard); _measurementStopWatch = new Stopwatch(); _capturedData = new List <DriverInfo>(); }