private void AddPlayerCarInfo(ref CarStatusData rawCarStatusData, ref CarTelemetryData rawCarTelemetryData, SimulatorDataSet simData) { CarInfo playerCar = simData.PlayerInfo.CarInfo; playerCar.CarDamageInformation.Bodywork.MediumDamageThreshold = 0.1; playerCar.CarDamageInformation.Engine.HeavyDamageThreshold = 0.9; playerCar.CarDamageInformation.Transmission.HeavyDamageThreshold = 0.75; playerCar.CarDamageInformation.Engine.MediumDamageThreshold = 0.75; playerCar.CarDamageInformation.Transmission.MediumDamageThreshold = 0.9; /*playerCar.CarDamageInformation.Suspension.Damage = rawCarStatusData.MTyresDamage.Max(x => x) / 100.0;*/ playerCar.CarDamageInformation.Bodywork.Damage = Math.Max(rawCarStatusData.MRearWingDamage, Math.Max(rawCarStatusData.MFrontLeftWingDamage, rawCarStatusData.MFrontRightWingDamage)) / 100.0; playerCar.CarDamageInformation.Engine.Damage = rawCarStatusData.MEngineDamage / 100.0; playerCar.CarDamageInformation.Transmission.Damage = rawCarStatusData.MGearBoxDamage / 100.0; playerCar.SpeedLimiterEngaged = rawCarStatusData.MPitLimiterStatus == 1; /*playerCar.WorldOrientation = new Orientation() * { * Roll = Angle.GetFromRadians(rawCarStatusData.CarOrientation.Roll), * Pitch = Angle.GetFromRadians(rawCarStatusData.CarOrientation.Pitch), * Yaw = Angle.GetFromRadians(-rawCarStatusData.CarOrientation.Yaw), * };*/ FillDrsData(ref rawCarStatusData, ref rawCarTelemetryData, playerCar); FillBoostData(ref rawCarStatusData, playerCar); }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); base.LoadBytes(BAM.NextBytes(24)); //Load header int t = 0; List <CarTelemetryData> TelDatas = new List <CarTelemetryData>(); for (t = 1; t <= 22; t++) { TelDatas.Add(CarTelemetryData.Create(BAM.NextBytes(58))); } FieldTelemetryData = TelDatas.ToArray(); //Button status ButtonStatus = BitConverter.ToInt32(BAM.NextBytes(4), 0); //MFD Panel Index MfdPanelIndex = BAM.NextByte(); //Secndary player mfd panel index SecondaryPlayerMfdPanelIndex = BAM.NextByte(); //Suggested gear SuggestedGear = BAM.NextByte(); }
protected void NotifyData(CarTelemetryData data) { foreach (var observer in _carTelemetryObservers) { observer.OnNext(data); } }
private static IPacket CarTelemetry(PacketHeader packetHeader, BinaryReader reader) { var packetCarTelemetryData = new PacketCarTelemetryData(packetHeader); for (int i = 0; i < MaxNumberOfCarsOnTrack; i++) { var carTelemData = new CarTelemetryData(); carTelemData.SessionUID = packetHeader.SessionUID; carTelemData.SessionTime = packetHeader.SessionTime; carTelemData.Speed = reader.ReadUInt16(); carTelemData.Throttle = reader.ReadSingle(); carTelemData.Steer = reader.ReadSingle(); carTelemData.Brake = reader.ReadSingle(); carTelemData.Clutch = reader.ReadByte(); carTelemData.Gear = reader.ReadSByte(); carTelemData.EngineRPM = reader.ReadUInt16(); carTelemData.Drs = (DRS)reader.ReadByte(); carTelemData.RevLightsPercent = reader.ReadByte(); for (int j = 0; j < NumberOfTyres; j++) { carTelemData.BrakesTemperature[j] = reader.ReadUInt16(); } for (int j = 0; j < NumberOfTyres; j++) { carTelemData.TyresSurfaceTemperature[j] = reader.ReadByte(); } for (int j = 0; j < NumberOfTyres; j++) { carTelemData.TyresInnerTemperature[j] = reader.ReadByte(); } carTelemData.EngineTemperature = reader.ReadUInt16(); for (int j = 0; j < NumberOfTyres; j++) { carTelemData.TyresPressure[j] = reader.ReadSingle(); } for (int j = 0; j < NumberOfTyres; j++) { carTelemData.SurfaceType[j] = (SurfaceTypes)reader.ReadByte(); } packetCarTelemetryData.CarTelemetryData[i] = carTelemData; } packetCarTelemetryData.ButtonStatus = reader.ReadUInt32(); packetCarTelemetryData.MfdPanelIndex = reader.ReadByte(); packetCarTelemetryData.MfdPanelIndexSecondaryPlayer = reader.ReadByte(); packetCarTelemetryData.SuggestedGear = reader.ReadSByte(); return(packetCarTelemetryData); }
private static void AddPedalInfo(ref CarTelemetryData rawData, SimulatorDataSet simData) { simData.InputInfo.ThrottlePedalPosition = rawData.MThrottle; simData.InputInfo.BrakePedalPosition = rawData.MBrake; simData.InputInfo.ClutchPedalPosition = rawData.MClutch / 100.0; simData.InputInfo.SteeringInput = rawData.MSteer; simData.InputInfo.WheelAngle = 180 * rawData.MSteer; simData.InputInfo.WheelAngleFilled = true; }
public CarTelemetryData Read(Span <byte> input, PacketHeader packetHeader) { var output = new CarTelemetryData { Header = packetHeader }; for (var i = 0; i < 20; i++) { output.CarTelemetries[i] = ReadCarTelemetry(input); } return(output); }
public override void LoadBytes(byte[] bytes) { ByteArrayManager BAM = new ByteArrayManager(bytes); base.LoadBytes(BAM.NextBytes(23)); //Load header int t = 0; List <CarTelemetryData> TelDatas = new List <CarTelemetryData>(); for (t = 1; t <= 20; t++) { TelDatas.Add(CarTelemetryData.Create(BAM.NextBytes(66))); } FieldTelemetryData = TelDatas.ToArray(); //I skipped the field "ButtonStatus". Doesn't seem needed. }
private static void AddBrakesInfo(ref CarTelemetryData data, SimulatorDataSet simData) { simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.BrakeTemperature.ActualQuantity = Temperature.FromCelsius(data.MBrakesTemperature[TyreIndices.FrontLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.BrakeTemperature.IdealQuantityWindow = Temperature.FromCelsius(200); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.BrakeTemperature.IdealQuantity = Temperature.FromCelsius(600); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.BrakeTemperature.ActualQuantity = Temperature.FromCelsius(data.MBrakesTemperature[TyreIndices.FrontRight]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.BrakeTemperature.IdealQuantityWindow = Temperature.FromCelsius(200); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.BrakeTemperature.IdealQuantity = Temperature.FromCelsius(600); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.BrakeTemperature.ActualQuantity = Temperature.FromCelsius(data.MBrakesTemperature[TyreIndices.RearLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.BrakeTemperature.IdealQuantityWindow = Temperature.FromCelsius(200); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.BrakeTemperature.IdealQuantity = Temperature.FromCelsius(600); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.BrakeTemperature.ActualQuantity = Temperature.FromCelsius(data.MBrakesTemperature[TyreIndices.RearRight]); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.BrakeTemperature.IdealQuantityWindow = Temperature.FromCelsius(200); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.BrakeTemperature.IdealQuantity = Temperature.FromCelsius(600); }
private void FillPlayerCarInfo(ref CarTelemetryData rawTelemetryData, SimulatorDataSet simData) { simData.PlayerInfo.CarInfo.EngineRpm = rawTelemetryData.MEngineRpm; switch (rawTelemetryData.MGear) { case 0: simData.PlayerInfo.CarInfo.CurrentGear = "N"; break; case -1: simData.PlayerInfo.CarInfo.CurrentGear = "R"; break; case -2: simData.PlayerInfo.CarInfo.CurrentGear = string.Empty; break; default: simData.PlayerInfo.CarInfo.CurrentGear = rawTelemetryData.MGear.ToString(); break; } }
private static void FillDrsData(ref CarStatusData carStatusData, ref CarTelemetryData rawCarTelemetryData, CarInfo playerCar) { DrsSystem drsSystem = playerCar.DrsSystem; drsSystem.DrsActivationLeft = -1; if (rawCarTelemetryData.MDrs == 1) { drsSystem.DrsStatus = DrsStatus.InUse; return; } switch ((int)carStatusData.MDrsAllowed) { case -1: case 0: drsSystem.DrsStatus = DrsStatus.NotEquipped; return; case 1: drsSystem.DrsStatus = DrsStatus.Available; break; } }
private static void AddEngineTemperatures(ref CarTelemetryData data, SimulatorDataSet simData) { simData.PlayerInfo.CarInfo.OilSystemInfo.OptimalOilTemperature.ActualQuantity = Temperature.FromCelsius(data.MEngineTemperature); simData.PlayerInfo.CarInfo.WaterSystemInfo.OptimalWaterTemperature = simData.PlayerInfo.CarInfo.OilSystemInfo.OptimalOilTemperature; }
private static void AddTyresInfo(ref CarTelemetryData rawTelemetryData, ref CarStatusData rawCarStatusData, ref PacketMotionData rawMotionData, SimulatorDataSet simData) { simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.TyrePressure.ActualQuantity = Pressure.FromPsi(rawTelemetryData.MTyresPressure[TyreIndices.FrontLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.TyrePressure.ActualQuantity = Pressure.FromPsi(rawTelemetryData.MTyresPressure[TyreIndices.FrontRight]); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.TyrePressure.ActualQuantity = Pressure.FromPsi(rawTelemetryData.MTyresPressure[TyreIndices.RearLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.TyrePressure.ActualQuantity = Pressure.FromPsi(rawTelemetryData.MTyresPressure[TyreIndices.RearRight]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.TyreWear.ActualWear = rawCarStatusData.MTyresWear[TyreIndices.FrontLeft] / 100.0; simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.TyreWear.ActualWear = rawCarStatusData.MTyresWear[TyreIndices.FrontRight] / 100.0; simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.TyreWear.ActualWear = rawCarStatusData.MTyresWear[TyreIndices.RearLeft] / 100.0; simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.TyreWear.ActualWear = rawCarStatusData.MTyresWear[TyreIndices.RearRight] / 100.0; simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.Rps = rawMotionData.MWheelSpeed[TyreIndices.FrontLeft]; simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.Rps = rawMotionData.MWheelSpeed[TyreIndices.FrontRight]; simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.Rps = rawMotionData.MWheelSpeed[TyreIndices.RearLeft]; simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.Rps = rawMotionData.MWheelSpeed[TyreIndices.RearRight]; simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.SuspensionTravel = Distance.FromCentimeters(rawMotionData.MSuspensionPosition[TyreIndices.FrontLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.SuspensionTravel = Distance.FromCentimeters(rawMotionData.MSuspensionPosition[TyreIndices.FrontRight]); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.SuspensionTravel = Distance.FromCentimeters(rawMotionData.MSuspensionPosition[TyreIndices.RearLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.SuspensionTravel = Distance.FromCentimeters(rawMotionData.MSuspensionPosition[TyreIndices.RearRight]); /*simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.SuspensionVelocity = Velocity.FromMs(rawMotionData.MSuspensionVelocity[TyreIndices.FrontLeft]); * simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.SuspensionVelocity = Velocity.FromMs(rawMotionData.MSuspensionVelocity[TyreIndices.FrontRight]); * simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.SuspensionVelocity = Velocity.FromMs(rawMotionData.MSuspensionVelocity[TyreIndices.RearLeft]); * simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.SuspensionVelocity = Velocity.FromMs(rawMotionData.MSuspensionVelocity[TyreIndices.RearRight]);*/ // Front Left Tyre Temps simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.CenterTyreTemp.IdealQuantity = Temperature.FromCelsius(85); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.CenterTyreTemp.IdealQuantityWindow = Temperature.FromCelsius(20); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.LeftTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.FrontLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.RightTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.FrontLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.CenterTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.FrontLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontLeft.TyreCoreTemperature.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresInnerTemperature[TyreIndices.FrontLeft]); // Front Right Tyre Temps simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.CenterTyreTemp.IdealQuantity = Temperature.FromCelsius(85); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.CenterTyreTemp.IdealQuantityWindow = Temperature.FromCelsius(20); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.LeftTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.FrontRight]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.RightTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.FrontRight]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.CenterTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.FrontRight]); simData.PlayerInfo.CarInfo.WheelsInfo.FrontRight.TyreCoreTemperature.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresInnerTemperature[TyreIndices.FrontRight]); // Rear Left Tyre Temps simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.CenterTyreTemp.IdealQuantity = Temperature.FromCelsius(85); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.CenterTyreTemp.IdealQuantityWindow = Temperature.FromCelsius(20); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.LeftTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.RearLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.RightTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.RearLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.CenterTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.RearLeft]); simData.PlayerInfo.CarInfo.WheelsInfo.RearLeft.TyreCoreTemperature.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresInnerTemperature[TyreIndices.RearLeft]); // Rear Right Tyre Temps simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.CenterTyreTemp.IdealQuantity = Temperature.FromCelsius(85); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.CenterTyreTemp.IdealQuantityWindow = Temperature.FromCelsius(20); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.LeftTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.RearRight]); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.RightTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.RearRight]); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.CenterTyreTemp.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresSurfaceTemperature[TyreIndices.RearRight]); simData.PlayerInfo.CarInfo.WheelsInfo.RearRight.TyreCoreTemperature.ActualQuantity = Temperature.FromCelsius(rawTelemetryData.MTyresInnerTemperature[TyreIndices.RearRight]); // Fuel System simData.PlayerInfo.CarInfo.FuelSystemInfo.FuelCapacity = Volume.FromLiters(rawCarStatusData.MFuelCapacity); simData.PlayerInfo.CarInfo.FuelSystemInfo.FuelRemaining = Volume.FromLiters(rawCarStatusData.MFuelInTank); }
public PacketCarTelemetryData(int a) { m_header = new PacketHeader(); m_carTelemetryData = new CarTelemetryData[20]; m_buttonStatus = 0; }
public static CarTelemetryData Create(byte[] bytes) { CarTelemetryData ReturnInstance = new CarTelemetryData(); ByteArrayManager BAM = new ByteArrayManager(bytes); //Get speed ReturnInstance.SpeedKph = BitConverter.ToUInt16(BAM.NextBytes(2), 0); double MPH = ReturnInstance.SpeedKph * 0.621371; ReturnInstance.SpeedMph = (ushort)MPH; //Get throttle ReturnInstance.Throttle = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get steer ReturnInstance.Steer = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get brake ReturnInstance.Brake = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get clutch ReturnInstance.Clutch = BAM.NextByte(); //Get gear ReturnInstance.Gear = (sbyte)BAM.NextByte(); //Get engine RMP ReturnInstance.EngineRpm = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Drs on or not byte nb = BAM.NextByte(); if (nb == 0) { ReturnInstance.DrsActive = false; } else if (nb == 1) { ReturnInstance.DrsActive = true; } //Get engine rev lights percentage ReturnInstance.RevLightsPercentage = BAM.NextByte(); //get brake temperature ReturnInstance.BrakeTemperature = new WheelDataArray(); ReturnInstance.BrakeTemperature.RearLeft = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BrakeTemperature.RearRight = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BrakeTemperature.FrontLeft = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); ReturnInstance.BrakeTemperature.FrontRight = (float)BitConverter.ToUInt16(BAM.NextBytes(2), 0); //get tyre surface temperature ReturnInstance.TyreSurfaceTemperature = new WheelDataArray(); ReturnInstance.TyreSurfaceTemperature.RearLeft = (float)BAM.NextByte(); ReturnInstance.TyreSurfaceTemperature.RearRight = (float)BAM.NextByte(); ReturnInstance.TyreSurfaceTemperature.FrontLeft = (float)BAM.NextByte(); ReturnInstance.TyreSurfaceTemperature.FrontRight = (float)BAM.NextByte(); //get tyre Inner Temperature ReturnInstance.TyreInnerTemperature = new WheelDataArray(); ReturnInstance.TyreInnerTemperature.RearLeft = (float)BAM.NextByte(); ReturnInstance.TyreInnerTemperature.RearRight = (float)BAM.NextByte(); ReturnInstance.TyreInnerTemperature.FrontLeft = (float)BAM.NextByte(); ReturnInstance.TyreInnerTemperature.FrontRight = (float)BAM.NextByte(); //Get engine temperature ReturnInstance.EngineTemperature = BitConverter.ToUInt16(BAM.NextBytes(2), 0); //Get tyre pressure ReturnInstance.TyrePressure = new WheelDataArray(); ReturnInstance.TyrePressure.RearLeft = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TyrePressure.RearRight = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TyrePressure.FrontLeft = BitConverter.ToSingle(BAM.NextBytes(4), 0); ReturnInstance.TyrePressure.FrontRight = BitConverter.ToSingle(BAM.NextBytes(4), 0); //Get surface type ReturnInstance.SurfaceType_RearLeft = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); ReturnInstance.SurfaceType_RearRight = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); ReturnInstance.SurfaceType_FrontLeft = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); ReturnInstance.SurfaceType_FrontRight = CodemastersToolkit.GetSurfaceTypeFromSurfaceTypeId(BAM.NextByte()); return(ReturnInstance); }
public PacketCarTelemetryData(PacketHeader packetHeader) { Header = packetHeader; CarTelemetryData = new CarTelemetryData[Decode.MaxNumberOfCarsOnTrack]; }
void F1Manager_CarTelemetryReceived(object sender, PacketReceivedEventArgs <PacketCarTelemetryData> e) { ctd = e.Packet.GetPlayerLapData(); Debug.Log("telemetry packet"); }