Renamed
Select vehivle telemetry
This commit is contained in:
parent
ffae6c9a15
commit
1ac3ef7b86
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
|||||||
// Les informations générales relatives à un assembly dépendent de
|
// Les informations générales relatives à un assembly dépendent de
|
||||||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
|
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
|
||||||
// associées à un assembly.
|
// associées à un assembly.
|
||||||
[assembly: AssemblyTitle("rFactor 2 Message Center")]
|
[assembly: AssemblyTitle("rFactor 2 MiscData")]
|
||||||
[assembly: AssemblyDescription("Read Access to the rFactor 2 Message Center")]
|
[assembly: AssemblyDescription("Read Access to miscellaneous rFactor 2 Data")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Kilian Kurt Hofmann")]
|
[assembly: AssemblyCompany("Kilian Kurt Hofmann")]
|
||||||
[assembly: AssemblyProduct("rFactor 2 Message Center")]
|
[assembly: AssemblyProduct("rFactor 2 MiscData")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|||||||
4
Properties/Resources.Designer.cs
generated
4
Properties/Resources.Designer.cs
generated
@ -8,7 +8,7 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace rFactor2MessageCenter.Properties {
|
namespace rFactor2MiscData.Properties {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ namespace rFactor2MessageCenter.Properties {
|
|||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("rFactor2MessageCenter.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("rFactor2MiscData.Properties.Resources", typeof(Resources).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
<ProjectGuid>{833040C9-FE5E-4CCF-B21D-71979E049B6B}</ProjectGuid>
|
<ProjectGuid>{833040C9-FE5E-4CCF-B21D-71979E049B6B}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>rFactor2MessageCenter</RootNamespace>
|
<RootNamespace>rFactor2MiscData</RootNamespace>
|
||||||
<AssemblyName>rFactor2 Message Center</AssemblyName>
|
<AssemblyName>rFactor2 Misc Data</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
@ -78,7 +78,7 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="rFactor2MessageCenter.cs" />
|
<Compile Include="rFactor2MiscData.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.4.33103.184
|
VisualStudioVersion = 17.4.33103.184
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rFactor 2 Message Center", "rFactor 2 Message Center.csproj", "{833040C9-FE5E-4CCF-B21D-71979E049B6B}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rFactor 2 Misc Data", "rFactor 2 Misc Data.csproj", "{833040C9-FE5E-4CCF-B21D-71979E049B6B}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -1,73 +0,0 @@
|
|||||||
using GameReaderCommon;
|
|
||||||
using RfactorReader.RF2;
|
|
||||||
using SimHub.Plugins;
|
|
||||||
|
|
||||||
namespace rFactor2MessageCenter
|
|
||||||
{
|
|
||||||
[PluginDescription("Read Access to the rFactor 2 Message Center")]
|
|
||||||
[PluginAuthor("Kilian Kurt Hofmann")]
|
|
||||||
[PluginName("rFactor 2 Message Center")]
|
|
||||||
public class rFactor2MessageCenter : IPlugin, IDataPlugin
|
|
||||||
{
|
|
||||||
private const string LAST_MESSAGE = "LastMessage";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Instance of the current plugin manager
|
|
||||||
/// </summary>
|
|
||||||
public PluginManager PluginManager { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a short plugin title to show in left menu. Return null if you want to use the title as defined in PluginName attribute.
|
|
||||||
/// </summary>
|
|
||||||
public string LeftMenuTitle => null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called one time per game data update, contains all normalized game data,
|
|
||||||
/// raw data are intentionnally "hidden" under a generic object type (A plugin SHOULD NOT USE IT)
|
|
||||||
///
|
|
||||||
/// This method is on the critical path, it must execute as fast as possible and avoid throwing any error
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pluginManager"></param>
|
|
||||||
/// <param name="data">Current game data, including current and previous data frame.</param>
|
|
||||||
public void DataUpdate(PluginManager pluginManager, ref GameData data)
|
|
||||||
{
|
|
||||||
// Define the value of our property (declared in init)
|
|
||||||
if (data.GameRunning && data is GameData<WrapV2> _data)
|
|
||||||
{
|
|
||||||
StatusData<WrapV2> newData = _data.GameNewData;
|
|
||||||
string message = System.Text.Encoding.Default.GetString(newData.Raw.extended.mLastHistoryMessage);
|
|
||||||
int index = message.IndexOf('\0');
|
|
||||||
if( index >= 0)
|
|
||||||
{
|
|
||||||
message = message.Remove(index);
|
|
||||||
}
|
|
||||||
pluginManager.SetPropertyValue(LAST_MESSAGE, GetType(), message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called at plugin manager stop, close/dispose anything needed here !
|
|
||||||
/// Plugins are rebuilt at game change
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pluginManager"></param>
|
|
||||||
public void End(PluginManager pluginManager)
|
|
||||||
{
|
|
||||||
SimHub.Logging.Current.Info("Stopping plugin");
|
|
||||||
|
|
||||||
pluginManager.ClearProperties(GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called once after plugins startup
|
|
||||||
/// Plugins are rebuilt at game change
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pluginManager"></param>
|
|
||||||
public void Init(PluginManager pluginManager)
|
|
||||||
{
|
|
||||||
SimHub.Logging.Current.Info("Starting plugin");
|
|
||||||
|
|
||||||
pluginManager.AddProperty(LAST_MESSAGE, GetType(), "No Data", "Last Message Center Entry");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
114
rFactor2MiscData.cs
Normal file
114
rFactor2MiscData.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using CrewChiefV4.rFactor2_V2.rFactor2Data;
|
||||||
|
using GameReaderCommon;
|
||||||
|
using RfactorReader.RF2;
|
||||||
|
using SimHub.Plugins;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace rFactor2MiscData
|
||||||
|
{
|
||||||
|
[PluginDescription("Read Access to miscellaneous rFactor 2 Data")]
|
||||||
|
[PluginAuthor("Kilian Kurt Hofmann")]
|
||||||
|
[PluginName("rFactor 2 Misc Data")]
|
||||||
|
public class rFactor2MiscData : IPlugin, IDataPlugin
|
||||||
|
{
|
||||||
|
private const string LAST_MESSAGE = "rF2MiscData.LastMessage";
|
||||||
|
private const string VEHICLE_BASE = "rF2MiscData.Position";
|
||||||
|
private const string VEHICLE_FUEL = ".Fuel";
|
||||||
|
private const string VEHICLE_THROTTLE= ".Throttle";
|
||||||
|
private const string VEHICLE_BRAKE = ".Brake";
|
||||||
|
private const string VEHICLE_PLACE = ".Place";
|
||||||
|
private const string VEHICLE_DRIVERNAME = ".DriverName";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instance of the current plugin manager
|
||||||
|
/// </summary>
|
||||||
|
public PluginManager PluginManager { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a short plugin title to show in left menu. Return null if you want to use the title as defined in PluginName attribute.
|
||||||
|
/// </summary>
|
||||||
|
public string LeftMenuTitle => null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called one time per game data update, contains all normalized game data,
|
||||||
|
/// raw data are intentionnally "hidden" under a generic object type (A plugin SHOULD NOT USE IT)
|
||||||
|
///
|
||||||
|
/// This method is on the critical path, it must execute as fast as possible and avoid throwing any error
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pluginManager"></param>
|
||||||
|
/// <param name="data">Current game data, including current and previous data frame.</param>
|
||||||
|
public void DataUpdate(PluginManager pluginManager, ref GameData data)
|
||||||
|
{
|
||||||
|
// Define the value of our property (declared in init)
|
||||||
|
if (data.GameRunning && data is GameData<WrapV2> _data)
|
||||||
|
{
|
||||||
|
WrapV2 newData = _data.GameNewData.Raw;
|
||||||
|
|
||||||
|
// Last Message
|
||||||
|
string message = System.Text.Encoding.Default.GetString(newData.extended.mLastHistoryMessage);
|
||||||
|
int index = message.IndexOf('\0');
|
||||||
|
if( index >= 0)
|
||||||
|
{
|
||||||
|
message = message.Remove(index);
|
||||||
|
}
|
||||||
|
pluginManager.SetPropertyValue(LAST_MESSAGE, GetType(), message);
|
||||||
|
|
||||||
|
int maxVehicles = Math.Min(newData.Scoring.mVehicles.Length, newData.telemetry.mVehicles.Length);
|
||||||
|
for(int i = 0; i < maxVehicles; i++)
|
||||||
|
{
|
||||||
|
rF2VehicleTelemetry telemetry = newData.telemetry.mVehicles[i];
|
||||||
|
rF2VehicleScoring scoring = newData.Scoring.mVehicles[i];
|
||||||
|
// Vehicle Fuel
|
||||||
|
pluginManager.SetPropertyValue($"{VEHICLE_BASE}{scoring.mPlace:000}{VEHICLE_FUEL}", GetType(), telemetry.mFuel);
|
||||||
|
// Vehicle Throttle
|
||||||
|
pluginManager.SetPropertyValue($"{VEHICLE_BASE}{scoring.mPlace:000}{VEHICLE_THROTTLE}", GetType(), telemetry.mFilteredThrottle);
|
||||||
|
// Vehicle Brake
|
||||||
|
pluginManager.SetPropertyValue($"{VEHICLE_BASE}{scoring.mPlace:000}{VEHICLE_BRAKE}", GetType(), telemetry.mFilteredBrake);
|
||||||
|
// Vehicle Position
|
||||||
|
pluginManager.SetPropertyValue($"{VEHICLE_BASE}{scoring.mPlace:000}{VEHICLE_PLACE}", GetType(), scoring.mPlace);
|
||||||
|
// Vehicle Driver Name
|
||||||
|
string driverName = System.Text.Encoding.Default.GetString(scoring.mDriverName);
|
||||||
|
index = message.IndexOf('\0');
|
||||||
|
if (index >= 0)
|
||||||
|
{
|
||||||
|
message = message.Remove(index);
|
||||||
|
}
|
||||||
|
pluginManager.SetPropertyValue($"{VEHICLE_BASE}{scoring.mPlace:000}{VEHICLE_DRIVERNAME}", GetType(), driverName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called at plugin manager stop, close/dispose anything needed here !
|
||||||
|
/// Plugins are rebuilt at game change
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pluginManager"></param>
|
||||||
|
public void End(PluginManager pluginManager)
|
||||||
|
{
|
||||||
|
SimHub.Logging.Current.Info("Stopping plugin");
|
||||||
|
|
||||||
|
pluginManager.ClearProperties(GetType());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called once after plugins startup
|
||||||
|
/// Plugins are rebuilt at game change
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pluginManager"></param>
|
||||||
|
public void Init(PluginManager pluginManager)
|
||||||
|
{
|
||||||
|
SimHub.Logging.Current.Info("Starting plugin");
|
||||||
|
|
||||||
|
pluginManager.AddProperty(LAST_MESSAGE, GetType(), "No Data", "Last Message Center Entry");
|
||||||
|
for (int i = 1; i <= 104; i++)
|
||||||
|
{
|
||||||
|
pluginManager.AddProperty($"{VEHICLE_BASE}{i:000}{VEHICLE_FUEL}", GetType(), "No Data", $"Vehicle at position {i}: Fuel");
|
||||||
|
pluginManager.AddProperty($"{VEHICLE_BASE}{i:000}{VEHICLE_THROTTLE}", GetType(), "No Data", $"Vehicle at position {i}: Throttle");
|
||||||
|
pluginManager.AddProperty($"{VEHICLE_BASE}{i:000}{VEHICLE_BRAKE}", GetType(), "No Data", $"Vehicle at position {i}: Brake");
|
||||||
|
pluginManager.AddProperty($"{VEHICLE_BASE}{i:000}{VEHICLE_PLACE}", GetType(), "No Data", $"Vehicle at position {i}: Place");
|
||||||
|
pluginManager.AddProperty($"{VEHICLE_BASE}{i:000}{VEHICLE_DRIVERNAME}", GetType(), "No Data", $"Vehicle at position {i}: Driver Name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user