1
0
mirror of https://github.com/DarthAffe/OBD.NET.git synced 2025-12-12 16:58:30 +00:00

Compare commits

...

17 Commits

Author SHA1 Message Date
19f84465ed Bumped version number 2022-06-06 14:14:39 +02:00
869366085a
Update README.md 2022-06-06 14:12:55 +02:00
d66b812f5e
Merge pull request #29 from julian-baumann/feature/reunion
Move to System.IO.Ports, combine projects into a single NuGet package
2022-06-06 14:11:52 +02:00
191f7a984e Small Fix to ExampleClient 2022-06-06 14:08:09 +02:00
8a91f74cc6 Removed Universal-Project 2022-06-06 14:06:56 +02:00
1d6fc3b264 Fixed project-file 2022-06-06 14:02:50 +02:00
48754831fa Fixed some namespaces 2022-06-06 14:00:46 +02:00
0d7dc3756b Improved SerialConnection async-implementations 2022-06-05 20:12:25 +02:00
1f6c3eaedf Implemented fake async-methods on SerialConnection 2022-06-05 20:06:16 +02:00
2136aaf0ca Readded EnhanvedSerialPort for .NET-Framework support 2022-05-21 13:35:11 +02:00
163f5eb3a3 Fixed uses of nullable reference types 2022-05-02 21:59:20 +02:00
18b0fec0f2 Applied code-style 2022-05-02 21:22:49 +02:00
Julian Baumann
09d23dbaa9 Updated README.md 2022-03-30 19:14:06 +02:00
Julian Baumann
c824f5ffe3 Added unix solution file, which excludes the UWP project 2022-03-30 18:10:11 +02:00
Julian Windows
086a670855 Readded UWP bluetooth implementation 2022-03-30 08:59:54 -07:00
Julian Baumann
24b18a6708 Removed intelli folder 2022-03-30 17:02:11 +02:00
Julian Baumann
1624349483 Moved to the System.IO.Ports implementation, refactored C# 10, combined OBD.NET.Desktop with OBD.NET.Common 2022-03-30 17:01:08 +02:00
316 changed files with 5150 additions and 5659 deletions

2
.gitignore vendored
View File

@ -234,3 +234,5 @@ _Pvt_Extensions
# FAKE - F# Make
.fake/
.DS_Store
OBD.NET/.idea

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net4.8</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\OBD.NET\OBD.NET.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,82 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OBD.NET.Communication;
using OBD.NET.Devices;
using OBD.NET.Extensions;
using OBD.NET.Logging;
using OBD.NET.OBDData;
namespace ConsoleClient;
public class Program
{
public static void Main(string[] args)
{
//if (args.Length < 1)
//{
// Console.WriteLine("Parameter ComPort needed.");
// IEnumerable<string> availablePorts = SerialConnection.GetAvailablePorts();
// Console.WriteLine("\nAvailable ports:");
// foreach (string port in availablePorts)
// Console.WriteLine(port);
// return;
//}
string comPort = args[0];
using SerialConnection connection = new(comPort);
using ELM327 dev = new(connection, new OBDConsoleLogger(OBDLogLevel.Debug));
dev.SubscribeDataReceived<EngineRPM>((_, data) => Console.WriteLine("EngineRPM: " + data.Data.Rpm));
dev.SubscribeDataReceived<VehicleSpeed>((_, data) => Console.WriteLine("VehicleSpeed: " + data.Data));
dev.SubscribeDataReceived<IOBDData>((_, data) => Console.WriteLine($"PID {data.Data.PID.ToHexString()}: {data.Data}"));
dev.Initialize();
dev.RequestData<FuelType>();
for (int i = 0; i < 5; i++)
{
dev.RequestData<EngineRPM>();
dev.RequestData<VehicleSpeed>();
Thread.Sleep(1000);
}
Console.ReadLine();
//Async example
// MainAsync(comPort).Wait();
//Console.ReadLine();
}
/// <summary>
/// Async example using new RequestDataAsync
/// </summary>
/// <param name="comPort">The COM port.</param>
/// <returns></returns>
public static async Task MainAsync(string comPort)
{
using SerialConnection connection = new(comPort);
using ELM327 dev = new(connection, new OBDConsoleLogger(OBDLogLevel.Debug));
await dev.InitializeAsync();
EngineRPM? engineRpm = await dev.RequestDataAsync<EngineRPM>();
Console.WriteLine("Data: " + (engineRpm?.Rpm.ToString() ?? "-"));
engineRpm = await dev.RequestDataAsync<EngineRPM>();
Console.WriteLine("Data: " + (engineRpm?.Rpm.ToString() ?? "-"));
VehicleSpeed? vehicleSpeed = await dev.RequestDataAsync<VehicleSpeed>();
Console.WriteLine("Data: " + (vehicleSpeed?.Speed.ToString() ?? "-"));
engineRpm = await dev.RequestDataAsync<EngineRPM>();
Console.WriteLine("Data: " + (engineRpm?.Rpm.ToString() ?? "-"));
}
}

View File

@ -1,57 +0,0 @@
namespace OBD.NET.Common.Commands
{
public class ATCommand
{
#region Commands
// ReSharper disable InconsistentNaming
//TODO DarthAffe 26.06.2016: Implement all commands
public static readonly ATCommand RepeatLastCommand = new ATCommand("\r");
public static readonly ATCommand ResetDevice = new ATCommand("ATZ");
public static readonly ATCommand ReadVoltage = new ATCommand("ATRV");
public static readonly ATCommand EchoOn = new ATCommand("ATE1", "^OK$");
public static readonly ATCommand EchoOff = new ATCommand("ATE0", "^OK$");
public static readonly ATCommand HeadersOn = new ATCommand("ATH1", "^OK$");
public static readonly ATCommand HeadersOff = new ATCommand("ATH0", "^OK$");
public static readonly ATCommand PrintSpacesOn = new ATCommand("ATS1", "^OK$");
public static readonly ATCommand PrintSpacesOff = new ATCommand("ATS0", "^OK$");
public static readonly ATCommand LinefeedsOn = new ATCommand("ATL1", "^OK$");
public static readonly ATCommand LinefeedsOff = new ATCommand("ATL0", "^OK$");
public static readonly ATCommand SetProtocolAuto = new ATCommand("ATSP0", "^OK$");
public static readonly ATCommand PrintVersion = new ATCommand("ATI", "^ELM327.*");
public static readonly ATCommand CloseProtocol = new ATCommand("ATPC");
// ReSharper restore InconsistentNaming
#endregion
#region Properties & Fields
public string Command { get; }
public string ExpectedResult { get; }
#endregion
#region Constructors
private ATCommand(string command, string expectedResult = null)
{
this.Command = command;
this.ExpectedResult = expectedResult;
}
#endregion
#region Methods
public override string ToString() => Command;
#endregion
#region Operators
public static implicit operator string(ATCommand command) => command.ToString();
#endregion
}
}

View File

@ -1,49 +0,0 @@
namespace OBD.NET.Common.Commands
{
public class STCommand
{
#region Values
// ReSharper disable InconsistentNaming
//TODO DarthAffe 19.03.2017: Implement all commands
internal static readonly STCommand AddPassFilter = new STCommand("STFAP");
internal static readonly STCommand AddBlockFilter = new STCommand("STFAB");
internal static readonly STCommand AddFlowControlFilter = new STCommand("STFAFC");
internal static readonly STCommand ClearPassFilters = new STCommand("STFCP");
internal static readonly STCommand ClearBlockFilters = new STCommand("STFCB");
internal static readonly STCommand ClearFlowControlFilters = new STCommand("STFCFC");
internal static readonly STCommand Monitor = new STCommand("STM");
internal static readonly STCommand MonitorAll = new STCommand("STMA");
// ReSharper restore InconsistentNaming
#endregion
#region Properties & Fields
public string Command { get; }
#endregion
#region Constructors
protected STCommand(string command)
{
this.Command = command;
}
#endregion
#region Methods
public override string ToString() => Command;
#endregion
#region Operators
public static implicit operator string(STCommand command) => command.ToString();
#endregion
}
}

View File

@ -1,37 +0,0 @@
namespace OBD.NET.Common.Communication.EventArgs
{
/// <summary>
/// Event args for receiving serial data
/// </summary>
public class DataReceivedEventArgs : System.EventArgs
{
#region Properties & Fields
/// <summary>
/// Count of valid data bytes in the buffer
/// </summary>
public int Count { get; }
/// <summary>
/// Data buffer holding the bytes
/// </summary>
public byte[] Data { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="DataReceivedEventArgs"/> class.
/// </summary>
/// <param name="count">The count.</param>
/// <param name="data">The data.</param>
public DataReceivedEventArgs(int count, byte[] data)
{
this.Count = count;
this.Data = data;
}
#endregion
}
}

View File

@ -1,58 +0,0 @@
using System;
using System.Threading.Tasks;
using OBD.NET.Common.Communication.EventArgs;
namespace OBD.NET.Common.Communication
{
/// <summary>
/// Serial connection interface
/// </summary>
/// <seealso cref="System.IDisposable" />
public interface ISerialConnection : IDisposable
{
/// <summary>
/// Gets a value indicating whether this instance is open.
/// </summary>
/// <value>
/// <c>true</c> if this instance is open; otherwise, <c>false</c>.
/// </value>
bool IsOpen { get; }
/// <summary>
/// Gets a value indicating whether this instance uses asynchronous IO
/// </summary>
/// <remarks>
/// Has to be set to true if asynchronous IO is supported.
/// If true async methods have to be implemented
/// </remarks>
bool IsAsync { get; }
/// <summary>
/// Occurs when a full line was received
/// </summary>
event EventHandler<DataReceivedEventArgs> DataReceived;
/// <summary>
/// Connects the serial port.
/// </summary>
void Connect();
/// <summary>
/// Connects the serial port asynchronous
/// </summary>
/// <returns></returns>
Task ConnectAsync();
/// <summary>
/// Writes the specified data to the serial connection
/// </summary>
/// <param name="data">The data.</param>
void Write(byte[] data);
/// <summary>
/// Writes the specified data to the serial connection asynchronous
/// </summary>
/// <param name="data">The data.</param>
Task WriteAsync(byte[] data);
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Count : GenericData
{
#region Properties & Fields
protected override string Unit => null;
#endregion
#region Constructors
public Count(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Count(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,29 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Degree : GenericData
{
#region Properties & Fields
protected override string Unit => "°";
#endregion
#region Constructors
public Degree(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Degree(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
#region Methods
public override string ToString() => (IsFloatingPointValue ? Value.ToString("0.00") : Value.ToString()) + (Unit ?? string.Empty);
#endregion
}
}

View File

@ -1,29 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class DegreeCelsius : GenericData
{
#region Properties & Fields
protected override string Unit => "°C";
#endregion
#region Constructors
public DegreeCelsius(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public DegreeCelsius(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
#region Methods
public override string ToString() => (IsFloatingPointValue ? Value.ToString("0.00") : Value.ToString()) + (Unit ?? string.Empty);
#endregion
}
}

View File

@ -1,52 +0,0 @@
using System;
namespace OBD.NET.Common.DataTypes
{
public abstract class GenericData
{
#region Properties & Fields
public double Value { get; }
public double MinValue { get; }
public double MaxValue { get; }
public bool IsFloatingPointValue { get; }
protected abstract string Unit { get; }
#endregion
#region Constructors
protected GenericData(double value, double minValue, double maxValue)
{
this.Value = value;
this.MinValue = minValue;
this.MaxValue = maxValue;
this.IsFloatingPointValue = true;
}
protected GenericData(int value, int minValue, int maxValue)
{
this.Value = value;
this.MinValue = minValue;
this.MaxValue = maxValue;
this.IsFloatingPointValue = false;
}
#endregion
#region Operators
public static implicit operator double(GenericData p) => p.Value;
public static implicit operator int(GenericData p) => (int)Math.Round(p.Value);
#endregion
#region Methods
public override string ToString() => (IsFloatingPointValue ? Value.ToString("0.00") : Value.ToString()) + (Unit == null ? string.Empty : (" " + Unit));
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class GramPerSec : GenericData
{
#region Properties & Fields
protected override string Unit => "g/s";
#endregion
#region Constructors
public GramPerSec(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public GramPerSec(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Kilometre : GenericData
{
#region Properties & Fields
protected override string Unit => "km";
#endregion
#region Constructors
public Kilometre(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Kilometre(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class KilometrePerHour : GenericData
{
#region Properties & Fields
protected override string Unit => "km/h";
#endregion
#region Constructors
public KilometrePerHour(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public KilometrePerHour(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,29 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Kilopascal : GenericData
{
#region Properties & Fields
protected override string Unit => "kPa";
#endregion
#region Constructors
public Kilopascal(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Kilopascal(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
#region Operators
public static explicit operator Pascal(Kilopascal pa) => new Pascal(pa.Value / 1000.0, pa.MinValue / 1000.0, pa.MaxValue / 1000.0);
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class LitresPerHour : GenericData
{
#region Properties & Fields
protected override string Unit => "l/h";
#endregion
#region Constructors
public LitresPerHour(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public LitresPerHour(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Milliampere : GenericData
{
#region Properties & Fields
protected override string Unit => "mA";
#endregion
#region Constructors
public Milliampere(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Milliampere(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,31 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Minute : GenericData
{
#region Properties & Fields
protected override string Unit => "min";
#endregion
#region Constructors
public Minute(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Minute(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
#region Operators
public static explicit operator Second(Minute m) => m.IsFloatingPointValue
? new Second(m.Value * 60, m.MinValue * 60, m.MaxValue * 60)
: new Second((int)(m.Value * 60), (int)(m.MinValue * 60), (int)(m.MaxValue * 60));
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class NewtonMetre : GenericData
{
#region Properties & Fields
protected override string Unit => "N";
#endregion
#region Constructors
public NewtonMetre(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public NewtonMetre(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,31 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Pascal : GenericData
{
#region Properties & Fields
protected override string Unit => "Pa";
#endregion
#region Constructors
public Pascal(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Pascal(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
#region Operators
public static explicit operator Kilopascal(Pascal pa) => pa.IsFloatingPointValue
? new Kilopascal(pa.Value * 1000, pa.MinValue * 1000, pa.MaxValue * 1000)
: new Kilopascal((int)(pa.Value * 1000), (int)(pa.MinValue * 1000), (int)(pa.MaxValue * 1000));
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Percent : GenericData
{
#region Properties & Fields
protected override string Unit => "%";
#endregion
#region Constructors
public Percent(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Percent(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Ratio : GenericData
{
#region Properties & Fields
protected override string Unit => null;
#endregion
#region Constructors
public Ratio(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Ratio(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class RevolutionsPerMinute : GenericData
{
#region Properties & Fields
protected override string Unit => "rpm";
#endregion
#region Constructors
public RevolutionsPerMinute(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public RevolutionsPerMinute(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,29 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Second : GenericData
{
#region Properties & Fields
protected override string Unit => "s";
#endregion
#region Constructors
public Second(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Second(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
#region Operators
public static explicit operator Minute(Second s) => new Minute(s.Value / 60.0, s.MinValue / 60.0, s.MaxValue / 60.0);
#endregion
}
}

View File

@ -1,23 +0,0 @@
namespace OBD.NET.Common.DataTypes
{
public class Volt : GenericData
{
#region Properties & Fields
protected override string Unit => "V";
#endregion
#region Constructors
public Volt(double value, double minValue, double maxValue)
: base(value, minValue, maxValue)
{ }
public Volt(int value, int minValue, int maxValue)
: base(value, minValue, maxValue)
{ }
#endregion
}
}

View File

@ -1,27 +0,0 @@
namespace OBD.NET.Common.Devices
{
/// <summary>
/// Class used for queued command
/// </summary>
public class QueuedCommand
{
#region Properties & Fields
public string CommandText { get; private set; }
public CommandResult CommandResult { get; }
#endregion
#region Constructors
public QueuedCommand(string commandText)
{
this.CommandText = commandText;
CommandResult = new CommandResult();
}
#endregion
}
}

View File

@ -1,23 +0,0 @@
using OBD.NET.Common.Util;
namespace OBD.NET.Common.Devices
{
public class CommandResult
{
#region Properties & Fields
public object Result { get; set; }
public AsyncManualResetEvent WaitHandle { get; }
#endregion
#region Constructors
public CommandResult()
{
WaitHandle = new AsyncManualResetEvent();
}
#endregion
}
}

View File

@ -1,288 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using OBD.NET.Common.Commands;
using OBD.NET.Common.Communication;
using OBD.NET.Common.Enums;
using OBD.NET.Common.Events;
using OBD.NET.Common.Events.EventArgs;
using OBD.NET.Common.Extensions;
using OBD.NET.Common.Logging;
using OBD.NET.Common.OBDData;
namespace OBD.NET.Common.Devices
{
public class ELM327 : SerialDevice
{
#region Properties & Fields
protected readonly Dictionary<Type, IDataEventManager> DataReceivedEventHandlers = new Dictionary<Type, IDataEventManager>();
protected static Dictionary<Type, byte> PidCache { get; } = new Dictionary<Type, byte>();
protected static Dictionary<byte, Type> DataTypeCache { get; } = new Dictionary<byte, Type>();
protected Mode Mode { get; set; } = Mode.ShowCurrentData; //TODO DarthAffe 26.06.2016: Implement different modes
protected string MessageChunk { get; set; }
#endregion
#region Events
public delegate void DataReceivedEventHandler<T>(object sender, DataReceivedEventArgs<T> args) where T : IOBDData;
public delegate void RawDataReceivedEventHandler(object sender, RawDataReceivedEventArgs args);
public event RawDataReceivedEventHandler RawDataReceived;
#endregion
#region Constructors
public ELM327(ISerialConnection connection, IOBDLogger logger = null)
: base(connection, logger: logger)
{ }
#endregion
#region Methods
public override async Task InitializeAsync()
{
await base.InitializeAsync();
InternalInitialize();
}
public override void Initialize()
{
base.Initialize();
InternalInitialize();
}
private void InternalInitialize()
{
Logger?.WriteLine("Initializing ...", OBDLogLevel.Debug);
try
{
Logger?.WriteLine("Resetting Device ...", OBDLogLevel.Debug);
SendCommand(ATCommand.ResetDevice);
Logger?.WriteLine("Turning Echo Off ...", OBDLogLevel.Debug);
SendCommand(ATCommand.EchoOff);
Logger?.WriteLine("Turning Linefeeds Off ...", OBDLogLevel.Debug);
SendCommand(ATCommand.LinefeedsOff);
Logger?.WriteLine("Turning Headers Off ...", OBDLogLevel.Debug);
SendCommand(ATCommand.HeadersOff);
Logger?.WriteLine("Turning Spaced Off ...", OBDLogLevel.Debug);
SendCommand(ATCommand.PrintSpacesOff);
Logger?.WriteLine("Setting the Protocol to 'Auto' ...", OBDLogLevel.Debug);
SendCommand(ATCommand.SetProtocolAuto);
WaitQueue();
}
// DarthAffe 21.02.2017: This seems to happen sometimes, i don't know why - just retry.
catch
{
Logger?.WriteLine("Failed to initialize the device!", OBDLogLevel.Error);
throw;
}
}
/// <summary>
/// Sends the AT command.
/// </summary>
/// <param name="command">The command.</param>
public virtual void SendCommand(ATCommand command) => SendCommand(command.Command);
/// <summary>
/// Requests the data and calls the handler
/// </summary>
/// <typeparam name="T"></typeparam>
public virtual void RequestData<T>()
where T : class, IOBDData, new()
{
Logger?.WriteLine("Requesting Type " + typeof(T).Name + " ...", OBDLogLevel.Debug);
byte pid = ResolvePid<T>();
RequestData(pid);
}
/// <summary>
/// Request data based on a pid
/// </summary>
/// <param name="pid">The pid of the requested data</param>
public virtual void RequestData(byte pid)
{
Logger?.WriteLine("Requesting PID " + pid.ToString("X2") + " ...", OBDLogLevel.Debug);
SendCommand(((byte)Mode).ToString("X2") + pid.ToString("X2"));
}
/// <summary>
/// Requests the data asynchronous and return the data when available
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public virtual async Task<T> RequestDataAsync<T>()
where T : class, IOBDData, new()
{
Logger?.WriteLine("Requesting Type " + typeof(T).Name + " ...", OBDLogLevel.Debug);
byte pid = ResolvePid<T>();
return await RequestDataAsync(pid) as T;
}
/// <summary>
/// Requests the data asynchronous and return the data when available
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public virtual async Task<IOBDData> RequestDataAsync(Type type)
{
Logger?.WriteLine("Requesting Type " + type.Name + " ...", OBDLogLevel.Debug);
byte pid = ResolvePid(type);
return await RequestDataAsync(pid) as IOBDData;
}
/// <summary>
/// Request data based on a pid
/// </summary>
/// <param name="pid">The pid of the requested data</param>
public virtual async Task<object> RequestDataAsync(byte pid)
{
Logger?.WriteLine("Requesting PID " + pid.ToString("X2") + " ...", OBDLogLevel.Debug);
CommandResult result = SendCommand(((byte)Mode).ToString("X2") + pid.ToString("X2"));
await result.WaitHandle.WaitAsync();
return result.Result;
}
protected override object ProcessMessage(string message)
{
if (message == null) return null;
DateTime timestamp = DateTime.Now;
RawDataReceived?.Invoke(this, new RawDataReceivedEventArgs(message, timestamp));
if (message.Length > 4)
{
// DarthAffe 15.08.2020: Splitted messages are prefixed with 0: (first chunk) and 1: (second chunk)
// DarthAffe 15.08.2020: They also seem to be always preceded by a '009'-message, but since that's to short to be processed it should be safe to ignore.
// DarthAffe 15.08.2020: Since that behavior isn't really documented (at least I wasn't able to find it) that's all trial and error and might not work for all pids with long results.
if (message[1] == ':')
{
if (message[0] == '0')
MessageChunk = message.Substring(2, message.Length - 2);
else if (message[0] == '1')
{
string fullMessage = MessageChunk + message.Substring(2, message.Length - 2);
MessageChunk = null;
return ProcessMessage(fullMessage);
}
}
else if (message[0] == '4')
{
byte mode = (byte)message[1].GetHexVal();
if (mode == (byte)Mode)
{
byte pid = (byte)message.Substring(2, 2).GetHexVal();
if (DataTypeCache.TryGetValue(pid, out Type dataType))
{
IOBDData obdData = (IOBDData)Activator.CreateInstance(dataType);
obdData.Load(message.Substring(4, message.Length - 4));
if (DataReceivedEventHandlers.TryGetValue(dataType, out IDataEventManager dataEventManager))
dataEventManager.RaiseEvent(this, obdData, timestamp);
if (DataReceivedEventHandlers.TryGetValue(typeof(IOBDData), out IDataEventManager genericDataEventManager))
genericDataEventManager.RaiseEvent(this, obdData, timestamp);
return obdData;
}
}
}
}
return null;
}
protected virtual byte ResolvePid<T>()
where T : class, IOBDData, new()
=> ResolvePid(typeof(T));
protected virtual byte ResolvePid(Type type)
{
if (!PidCache.TryGetValue(type, out byte pid))
pid = AddToPidCache(type);
return pid;
}
public virtual byte AddToPidCache<T>()
where T : class, IOBDData, new() => AddToPidCache(typeof(T));
protected virtual byte AddToPidCache(Type obdDataType)
{
IOBDData data = (IOBDData)Activator.CreateInstance(obdDataType);
if (data == null) throw new ArgumentException("Has to implement IOBDData", nameof(obdDataType));
byte pid = data.PID;
PidCache.Add(obdDataType, pid);
DataTypeCache.Add(pid, obdDataType);
return pid;
}
/// <summary>
/// YOU SHOULDN'T NEED THIS METHOD!
///
/// You should only use this method if you're requesting data by pid instead of the <see cref="RequestData{T}"/>-method.
///
/// Initializes the PID-Cache with all IOBDData-Types contained in OBD.NET.
/// You can add additional ones with <see cref="AddToPidCache{T}"/>.
/// </summary>
public virtual void InitializePidCache()
{
TypeInfo iobdDataInfo = typeof(IOBDData).GetTypeInfo();
foreach (TypeInfo obdDataType in iobdDataInfo.Assembly.DefinedTypes.Where(t => t.IsClass && !t.IsAbstract && iobdDataInfo.IsAssignableFrom(t)))
AddToPidCache(obdDataType.AsType());
}
public override void Dispose() => Dispose(true);
public void Dispose(bool sendCloseProtocol)
{
try
{
if (sendCloseProtocol)
SendCommand(ATCommand.CloseProtocol);
}
catch { /* Well at least we tried ... */ }
DataReceivedEventHandlers.Clear();
base.Dispose();
}
public void SubscribeDataReceived<T>(DataReceivedEventHandler<T> eventHandler) where T : IOBDData
{
if (!DataReceivedEventHandlers.TryGetValue(typeof(T), out IDataEventManager eventManager))
DataReceivedEventHandlers.Add(typeof(T), (eventManager = new GenericDataEventManager<T>()));
((GenericDataEventManager<T>)eventManager).DataReceived += eventHandler;
}
public void UnsubscribeDataReceived<T>(DataReceivedEventHandler<T> eventHandler) where T : IOBDData
{
if (DataReceivedEventHandlers.TryGetValue(typeof(T), out IDataEventManager eventManager))
((GenericDataEventManager<T>)eventManager).DataReceived -= eventHandler;
}
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.Commands;
using OBD.NET.Common.Communication;
using OBD.NET.Common.Logging;
namespace OBD.NET.Common.Devices
{
public class STN1170 : ELM327 // Fully compatible device
{
#region Constructors
public STN1170(ISerialConnection connection, IOBDLogger logger = null)
: base(connection, logger)
{ }
#endregion
#region Methods
/// <summary>
/// Sends the ST command.
/// </summary>
/// <param name="command">The command.</param>
public virtual void SendCommand(STCommand command) => SendCommand(command.Command);
#endregion
}
}

View File

@ -1,254 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OBD.NET.Common.Communication;
using OBD.NET.Common.Communication.EventArgs;
using OBD.NET.Common.Exceptions;
using OBD.NET.Common.Logging;
namespace OBD.NET.Common.Devices
{
/// <summary>
/// Base class used for communicating with the device
/// </summary>
public abstract class SerialDevice : IDisposable
{
#region Properties & Fields
private readonly BlockingCollection<QueuedCommand> _commandQueue = new BlockingCollection<QueuedCommand>();
private readonly StringBuilder _lineBuffer = new StringBuilder();
private readonly AutoResetEvent _commandFinishedEvent = new AutoResetEvent(false);
private Task _commandWorkerTask;
private CancellationTokenSource _commandCancellationToken;
private volatile int _queueSize = 0;
private readonly ManualResetEvent _queueEmptyEvent = new ManualResetEvent(true);
public int QueueSize => _queueSize;
protected QueuedCommand CurrentCommand;
protected IOBDLogger Logger { get; }
protected ISerialConnection Connection { get; }
protected char Terminator { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="SerialDevice"/> class.
/// </summary>
/// <param name="connection">connection.</param>
/// <param name="terminator">terminator used for terminating the command message</param>
/// <param name="logger">logger instance</param>
protected SerialDevice(ISerialConnection connection, char terminator = '\r', IOBDLogger logger = null)
{
this.Connection = connection;
this.Terminator = terminator;
this.Logger = logger;
connection.DataReceived += OnDataReceived;
}
#endregion
#region Methods
/// <summary>
/// Initializes the device
/// </summary>
public virtual void Initialize()
{
Connection.Connect();
CheckConnectionAndStartWorker();
}
/// <summary>
/// Initializes the device
/// </summary>
public virtual async Task InitializeAsync()
{
await Connection.ConnectAsync();
CheckConnectionAndStartWorker();
}
/// <summary>
/// Checks the connection and starts background worker which is sending the commands
/// </summary>
/// <exception cref="SerialException">Failed to open Serial-Connection.</exception>
private void CheckConnectionAndStartWorker()
{
if (!Connection.IsOpen)
{
Logger?.WriteLine("Failed to open Serial-Connection.", OBDLogLevel.Error);
throw new SerialException("Failed to open Serial-Connection.");
}
Logger?.WriteLine("Opened Serial-Connection!", OBDLogLevel.Debug);
_commandCancellationToken = new CancellationTokenSource();
_commandWorkerTask = Task.Factory.StartNew(CommandWorker);
}
/// <summary>
/// Sends the command.
/// </summary>
/// <param name="command">command string</param>
/// <exception cref="System.InvalidOperationException">Not connected</exception>
protected virtual CommandResult SendCommand(string command)
{
if (!Connection.IsOpen)
throw new InvalidOperationException("Not connected");
command = PrepareCommand(command);
Logger?.WriteLine("Queuing Command: '" + command.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
QueuedCommand cmd = new QueuedCommand(command);
_queueEmptyEvent.Reset();
_queueSize++;
_commandQueue.Add(cmd);
return cmd.CommandResult;
}
/// <summary>
/// Prepares the command
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
protected virtual string PrepareCommand(string command)
{
if (command == null) throw new ArgumentNullException(nameof(command));
if (!command.EndsWith(Terminator.ToString(), StringComparison.Ordinal))
command += Terminator;
return command;
}
/// <summary>
/// Called when data is received from the serial device
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="DataReceivedEventArgs"/> instance containing the event data.</param>
private void OnDataReceived(object sender, DataReceivedEventArgs e)
{
for (int i = 0; i < e.Count; i++)
{
char c = (char)e.Data[i];
switch (c)
{
case '\r':
FinishLine();
break;
case '>':
CurrentCommand.CommandResult.WaitHandle.Set();
_commandFinishedEvent.Set();
break;
case '\n':
case (char)0x00:
break; // ignore
default:
_lineBuffer.Append(c);
break;
}
}
}
/// <summary>
/// Signals a final message
/// </summary>
private void FinishLine()
{
string line = _lineBuffer.ToString().Trim();
_lineBuffer.Clear();
if (string.IsNullOrWhiteSpace(line)) return;
Logger?.WriteLine("Response: '" + line + "'", OBDLogLevel.Verbose);
InternalProcessMessage(line);
}
/// <summary>
/// Process message and sets the result
/// </summary>
/// <param name="message">The message.</param>
private void InternalProcessMessage(string message)
{
object data = ProcessMessage(message);
CurrentCommand.CommandResult.Result = data;
}
/// <summary>
/// Processes the message.
/// </summary>
/// <param name="message">message received</param>
/// <returns>result data</returns>
protected abstract object ProcessMessage(string message);
/// <summary>
/// Worker method for sending commands
/// </summary>
private async void CommandWorker()
{
CancellationToken cancellationToken = _commandCancellationToken.Token;
while (!_commandCancellationToken.IsCancellationRequested)
{
CurrentCommand = null;
if (_queueSize == 0)
_queueEmptyEvent.Set();
try
{
if (_commandQueue.TryTake(out CurrentCommand, 10, cancellationToken))
{
_queueSize--;
Logger?.WriteLine("Writing Command: '" + CurrentCommand.CommandText.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
if (Connection.IsAsync)
await Connection.WriteAsync(Encoding.ASCII.GetBytes(CurrentCommand.CommandText));
else
Connection.Write(Encoding.ASCII.GetBytes(CurrentCommand.CommandText));
// wait for command to finish or command canceled
while (!_commandFinishedEvent.WaitOne(50))
cancellationToken.ThrowIfCancellationRequested();
}
}
catch (OperationCanceledException)
{
CurrentCommand?.CommandResult.WaitHandle.Set();
}
}
foreach (QueuedCommand cmd in _commandQueue)
cmd.CommandResult.WaitHandle.Set();
}
public void WaitQueue() => _queueEmptyEvent.WaitOne();
public async Task WaitQueueAsync() => await Task.Run(() => WaitQueue());
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public virtual void Dispose()
{
_commandQueue.CompleteAdding();
_commandCancellationToken?.Cancel();
_commandWorkerTask?.Wait();
Connection?.Dispose();
}
#endregion
}
}

View File

@ -1,19 +0,0 @@
namespace OBD.NET.Common.Enums
{
/// <summary>
/// https://en.wikipedia.org/wiki/OBD-II_PIDs#Modes
/// </summary>
public enum Mode
{
ShowCurrentData = 0x01,
ShowFreezeFrameData = 0x02,
ShowStoredDiagnosticTroubleCodes = 0x03,
ClearDiagnosticTroubleCodesAndStoredValues = 0x04,
TestResults_OxygenSensorMonitoring = 0x05,
TestResults_OtherComponentMonitoring = 0x06,
ShowPendingDiagnosticTroubleCodes = 0x07,
ControlOperationOfOnboardComponent = 0x08,
RequestVehicleInformation = 0x09,
PermanentDiagnosticTroubleCodes = 0x0A
}
}

View File

@ -1,25 +0,0 @@
using System;
using OBD.NET.Common.OBDData;
namespace OBD.NET.Common.Events.EventArgs
{
public class DataReceivedEventArgs<T> where T : IOBDData
{
#region Properties & Fields
public T Data { get; }
public DateTime Timestamp { get; }
#endregion
#region Constructors
public DataReceivedEventArgs(T data, DateTime timestamp)
{
this.Data = data;
this.Timestamp = timestamp;
}
#endregion
}
}

View File

@ -1,24 +0,0 @@
using System;
namespace OBD.NET.Common.Events.EventArgs
{
public class RawDataReceivedEventArgs
{
#region Properties & Fields
public string Data { get; }
public DateTime Timestamp { get; }
#endregion
#region Constructors
public RawDataReceivedEventArgs(string data, DateTime timestamp)
{
this.Data = data;
this.Timestamp = timestamp;
}
#endregion
}
}

View File

@ -1,23 +0,0 @@
using System;
using OBD.NET.Common.Devices;
using OBD.NET.Common.Events.EventArgs;
using OBD.NET.Common.OBDData;
namespace OBD.NET.Common.Events
{
public class GenericDataEventManager<T> : IDataEventManager
where T : IOBDData
{
#region Events
internal event ELM327.DataReceivedEventHandler<T> DataReceived;
#endregion
#region Methods
public void RaiseEvent(object sender, IOBDData data, DateTime timestamp) => DataReceived?.Invoke(sender, new DataReceivedEventArgs<T>((T)data, timestamp));
#endregion
}
}

View File

@ -1,10 +0,0 @@
using System;
using OBD.NET.Common.OBDData;
namespace OBD.NET.Common.Events
{
public interface IDataEventManager
{
void RaiseEvent(object sender, IOBDData data, DateTime timestamp);
}
}

View File

@ -1,23 +0,0 @@
using System;
namespace OBD.NET.Common.Exceptions
{
public class SerialException : Exception
{
#region Constructors
public SerialException()
{ }
public SerialException(string message)
: base(message)
{ }
public SerialException(string message, Exception innerException)
: base(message, innerException)
{ }
#endregion
}
}

View File

@ -1,39 +0,0 @@
using System;
namespace OBD.NET.Common.Exceptions
{
public class UnexpectedResultException : Exception
{
#region Properties & Fields
public string Result { get; }
public string ExpectedResult { get; }
#endregion
#region Constructors
public UnexpectedResultException(string result, string expectedResult)
: this($"Unexpected result '{result}'. Expected was '{expectedResult}'", result, expectedResult)
{
this.Result = result;
this.ExpectedResult = expectedResult;
}
public UnexpectedResultException(string message, string result, string expectedResult)
: base(message)
{
this.Result = result;
this.ExpectedResult = expectedResult;
}
public UnexpectedResultException(string message, Exception innerException, string result, string expectedResult)
: base(message, innerException)
{
this.Result = result;
this.ExpectedResult = expectedResult;
}
#endregion
}
}

View File

@ -1,24 +0,0 @@
using System;
using System.Linq;
namespace OBD.NET.Common.Extensions
{
public static class HexExtension
{
#region Methods
public static int GetHexVal(this char hex) => hex - (hex < 58 ? 48 : (hex < 97 ? 55 : 87));
public static int GetHexVal(this string hex)
{
if ((hex.Length % 2) == 1)
throw new ArgumentException("The binary key cannot have an odd number of digits");
return hex.Aggregate(0, (current, c) => (current << 4) + (GetHexVal(c)));
}
public static string ToHexString(this byte b) => ToHexString(new[] { b });
public static string ToHexString(this byte[] bytes) => BitConverter.ToString(bytes).Replace("-", string.Empty);
#endregion
}
}

View File

@ -1,7 +0,0 @@
namespace OBD.NET.Common.Logging
{
public interface IOBDLogger
{
void WriteLine(string text, OBDLogLevel level);
}
}

View File

@ -1,40 +0,0 @@
using System;
using System.Diagnostics;
namespace OBD.NET.Common.Logging
{
/// <summary>
/// Simple debug logger
/// </summary>
/// <seealso cref="IOBDLogger" />
public class OBDDebugLogger : IOBDLogger
{
#region Properties & Fields
public OBDLogLevel LogLevel { get; set; }
#endregion
#region Constructors
public OBDDebugLogger(OBDLogLevel level = OBDLogLevel.None)
{
this.LogLevel = level;
}
#endregion
#region Methods
public void WriteLine(string text, OBDLogLevel level)
{
if (LogLevel == OBDLogLevel.None) return;
if ((int)level <= (int)LogLevel)
Debug.WriteLine($"{DateTime.Now:G} - {level} - {text}");
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace OBD.NET.Common.Logging
{
public enum OBDLogLevel
{
None,
Error,
Verbose,
Debug
}
}

View File

@ -1,50 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;net6.0;netstandard1.4</TargetFrameworks>
<Authors>Darth Affe / Roman Lumetsberger</Authors>
<Company>-</Company>
<Product>OBD.NET</Product>
<Description>C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter</Description>
<Version>1.2.0</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<RepositoryType>Github</RepositoryType>
<RepositoryUrl>https://github.com/DarthAffe/OBD.NET</RepositoryUrl>
<PackageProjectUrl>https://github.com/DarthAffe/OBD.NET</PackageProjectUrl>
<PackageLicenseExpression>GPL-2.0-only</PackageLicenseExpression>
<OutputPath>..\bin\</OutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IncludeSource>True</IncludeSource>
<IncludeSymbols>True</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
<DefineConstants>NET5_0;NETFULL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<DefineConstants>NET6_0;NETFULL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.4'">
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD1_4</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugType>portable</DebugType>
<Optimize>true</Optimize>
<NoWarn>$(NoWarn);CS1591;CS1572;CS1573</NoWarn>
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
</Project>

View File

@ -1,25 +0,0 @@
namespace OBD.NET.Common.OBDData
{
public class AuxiliaryInputStatus : AbstractOBDData
{
#region Properties & Fields
public bool PowerTakeOffStatus => (A & (1 << 0)) != 0;
#endregion
#region Constructors
public AuxiliaryInputStatus()
: base(0x1E, 1)
{ }
#endregion
#region Methods
public override string ToString() => PowerTakeOffStatus.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CalculatedEngineLoad : AbstractOBDData
{
#region Properties & Fields
public Percent Load => new Percent(A / 2.55, 0, 100);
#endregion
#region Constructors
public CalculatedEngineLoad()
: base(0x04, 1)
{ }
#endregion
#region Methods
public override string ToString() => Load.ToString();
#endregion
}
}

View File

@ -1,44 +0,0 @@
using System;
namespace OBD.NET.Common.OBDData
{
public class CommandedSecondaryAirStatus : AbstractOBDData
{
#region Properties & Fields
public CommandedSecondaryAirStatusValue Status => (CommandedSecondaryAirStatusValue)A;
#endregion
#region Constructors
public CommandedSecondaryAirStatus()
: base(0x12, 1)
{ }
#endregion
#region Methods
public override string ToString() => Status.ToString();
#endregion
#region Enum
/// <summary>
/// https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_12
/// </summary>
[Flags]
public enum CommandedSecondaryAirStatusValue
{
Missing = 0,
Upstream = 1 << 0,
DownstreamOfCatalyticConverter = 1 << 1,
FromTheOutsideAtmosphereOrOff = 1 << 2,
PumpCommandedOnForDiagnostics = 1 << 3
}
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class EngineCoolantTemperature : AbstractOBDData
{
#region Properties & Fields
public DegreeCelsius Temperature => new DegreeCelsius(A - 40, -40, 215);
#endregion
#region Constructors
public EngineCoolantTemperature()
: base(0x05, 1)
{ }
#endregion
#region Methods
public override string ToString() => Temperature.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class EngineRPM : AbstractOBDData
{
#region Properties & Fields
public RevolutionsPerMinute Rpm => new RevolutionsPerMinute(((256 * A) + B) / 4.0, 0, 16383.75);
#endregion
#region Constructors
public EngineRPM()
: base(0x0C, 2)
{ }
#endregion
#region Methods
public override string ToString() => Rpm.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class FuelPressure : AbstractOBDData
{
#region Properties & Fields
public Kilopascal Pressure => new Kilopascal(3 * A, 0, 765);
#endregion
#region Constructors
public FuelPressure()
: base(0x0A, 1)
{ }
#endregion
#region Methods
public override string ToString() => Pressure.ToString();
#endregion
}
}

View File

@ -1,46 +0,0 @@
using System;
namespace OBD.NET.Common.OBDData
{
public class FuelSystemStatus : AbstractOBDData
{
#region Properties & Fields
public FuelSystemStatusValue StatusSystem1 => (FuelSystemStatusValue)A;
public FuelSystemStatusValue StatusSystem2 => (FuelSystemStatusValue)B;
#endregion
#region Constructors
public FuelSystemStatus()
: base(0x03, 2)
{ }
#endregion
#region Methods
public override string ToString() => StatusSystem1.ToString();
#endregion
#region Enums
/// <summary>
/// https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_03
/// </summary>
[Flags]
public enum FuelSystemStatusValue
{
Missing = 0,
OpenLoopDueToInsufficientEngineTemperature = 1 << 0,
ClosedLoopUsingOxygenSensorFeedbackToDetermineFuelMix = 1 << 1,
OpenLoopDueToEngineLoadOrFuelCutDueToDeceleration = 1 << 2,
OpenLoopDueToSystemFailure = 1 << 3,
ClosedLoopUsingAtLeastOneOxygenSensorButThereIsAFaultInTheFeedbackSystem = 1 << 4
}
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class IntakeAirTemperature : AbstractOBDData
{
#region Properties & Fields
public DegreeCelsius Temperature => new DegreeCelsius(A - 40, -40, 215);
#endregion
#region Constructors
public IntakeAirTemperature()
: base(0x0F, 1)
{ }
#endregion
#region Methods
public override string ToString() => Temperature.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class IntakeManifoldAbsolutePressure : AbstractOBDData
{
#region Properties & Fields
public Kilopascal Pressure => new Kilopascal(A, 0, 255);
#endregion
#region Constructors
public IntakeManifoldAbsolutePressure()
: base(0x0B, 1)
{ }
#endregion
#region Methods
public override string ToString() => Pressure.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class LongTermFuelTrimBank1 : AbstractOBDData
{
#region Properties & Fields
public Percent Trim => new Percent((A / 1.28) - 100, -100, 99.2);
#endregion
#region Constructors
public LongTermFuelTrimBank1()
: base(0x07, 1)
{ }
#endregion
#region Methods
public override string ToString() => Trim.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class LongTermFuelTrimBank2 : AbstractOBDData
{
#region Properties & Fields
public Percent Trim => new Percent((A / 1.28) - 100, -100, 99.2);
#endregion
#region Constructors
public LongTermFuelTrimBank2()
: base(0x09, 1)
{ }
#endregion
#region Methods
public override string ToString() => Trim.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class MAFAirFlowRate : AbstractOBDData
{
#region Properties & Fields
public GramPerSec Rate => new GramPerSec(((256 * A) + B) / 100.0, 0, 655.35);
#endregion
#region Constructors
public MAFAirFlowRate()
: base(0x10, 2)
{ }
#endregion
#region Methods
public override string ToString() => Rate.ToString();
#endregion
}
}

View File

@ -1,62 +0,0 @@
namespace OBD.NET.Common.OBDData
{
public class OBDStandards : AbstractOBDData
{
#region Properties & Fields
public OBDStandard Standard => (OBDStandard)A;
#endregion
#region Constructors
public OBDStandards()
: base(0x1C, 1)
{ }
#endregion
#region Enum
public enum OBDStandard
{
Missing = 0,
OBDII = 1,
OBD = 2,
OBD_OBDII = 3,
OBDI = 4,
NotOBDCompliant = 5,
EOBD = 6,
EOBD_OBDII = 7,
EOBD_OBD = 8,
EOBD_OBD_OBDII = 9,
JOBD = 10,
JOBD_OBDII = 11,
JOBD_EOBD = 12,
JOBD_EOBD_OBDII = 13,
EMD = 17,
EMDPlus = 18,
HDOBDC = 19,
HDOBD = 20,
WWHOBD = 21,
HDEOBDI = 23,
HDEOBDIN = 24,
HDEOBDII = 25,
HDEOBDIIN = 26,
OBDBr1 = 28,
OBDBr2 = 29,
KOBD = 30,
IOBDI = 31,
IOBDII = 32,
HDEOBDIV = 33
}
#endregion
#region Methods
public override string ToString() => Standard.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor1FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor1FuelTrim()
: base(0x14, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor2FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor2FuelTrim()
: base(0x15, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor3FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor3FuelTrim()
: base(0x16, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor4FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor4FuelTrim()
: base(0x17, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor5FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor5FuelTrim()
: base(0x18, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor6FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor6FuelTrim()
: base(0x19, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor7FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor7FuelTrim()
: base(0x1A, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,29 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor8FuelTrim : AbstractOBDData
{
#region Properties & Fields
public Volt Voltage => new Volt(A / 200.0, 0, 1.275);
public Percent ShortTermFuelTrim => new Percent((B / 1.28) - 100, -100, 99.2);
public bool IsSensorUsed => B != 0xFF;
#endregion
#region Constructors
public OxygenSensor8FuelTrim()
: base(0x1B, 2)
{ }
#endregion
#region Methods
public override string ToString() => ShortTermFuelTrim.ToString();
#endregion
}
}

View File

@ -1,34 +0,0 @@
using System;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensorPresent : AbstractOBDData
{
#region Properties & Fields
public bool IsSensor1Present => (A & (1 << 0)) != 0;
public bool IsSensor2Present => (A & (1 << 1)) != 0;
public bool IsSensor3Present => (A & (1 << 2)) != 0;
public bool IsSensor4Present => (A & (1 << 3)) != 0;
public bool IsSensor5Present => (A & (1 << 4)) != 0;
public bool IsSensor6Present => (A & (1 << 5)) != 0;
public bool IsSensor7Present => (A & (1 << 6)) != 0;
public bool IsSensor8Present => (A & (1 << 7)) != 0;
#endregion
#region Constructors
public OxygenSensorPresent()
: base(0x13, 1)
{ }
#endregion
#region Methods
public override string ToString() => Convert.ToString(A, 2);
#endregion
}
}

View File

@ -1,34 +0,0 @@
using System;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensorPresent2 : AbstractOBDData
{
#region Properties & Fields
public bool IsSensor1Present => (A & (1 << 0)) != 0;
public bool IsSensor2Present => (A & (1 << 1)) != 0;
public bool IsSensor3Present => (A & (1 << 2)) != 0;
public bool IsSensor4Present => (A & (1 << 3)) != 0;
public bool IsSensor5Present => (A & (1 << 4)) != 0;
public bool IsSensor6Present => (A & (1 << 5)) != 0;
public bool IsSensor7Present => (A & (1 << 6)) != 0;
public bool IsSensor8Present => (A & (1 << 7)) != 0;
#endregion
#region Constructors
public OxygenSensorPresent2()
: base(0x1D, 1)
{ }
#endregion
#region Methods
public override string ToString() => Convert.ToString(A, 2);
#endregion
}
}

View File

@ -1,19 +0,0 @@
namespace OBD.NET.Common.OBDData
{
public class PidsSupported01_20 : AbstractPidsSupported
{
#region Constructors
public PidsSupported01_20()
: base(0x00, 4)
{ }
#endregion
#region Methods
public override string ToString() => string.Join(",", SupportedPids);
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class RunTimeSinceEngineStart : AbstractOBDData
{
#region Properties & Fields
public Second Runtime => new Second((256 * A) + B, 0, 65535);
#endregion
#region Constructors
public RunTimeSinceEngineStart()
: base(0x1F, 2)
{ }
#endregion
#region Methods
public override string ToString() => Runtime.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class ShortTermFuelTrimBank1 : AbstractOBDData
{
#region Properties & Fields
public Percent Trim => new Percent((A / 1.28) - 100, -100, 99.2);
#endregion
#region Constructors
public ShortTermFuelTrimBank1()
: base(0x06, 1)
{ }
#endregion
#region Methods
public override string ToString() => Trim.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class ShortTermFuelTrimBank2 : AbstractOBDData
{
#region Properties & Fields
public Percent Trim => new Percent((A / 1.28) - 100, -100, 99.2);
#endregion
#region Constructors
public ShortTermFuelTrimBank2()
: base(0x08, 1)
{ }
#endregion
#region Methods
public override string ToString() => Trim.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class ThrottlePosition : AbstractOBDData
{
#region Properties & Fields
public Percent Position => new Percent(A / 2.55, 0, 100);
#endregion
#region Constructors
public ThrottlePosition()
: base(0x11, 1)
{ }
#endregion
#region Methods
public override string ToString() => Position.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class TimingAdvance : AbstractOBDData
{
#region Properties & Fields
public Degree Timing => new Degree((A / 2.0) - 64, -64, 63.5);
#endregion
#region Constructors
public TimingAdvance()
: base(0x0E, 1)
{ }
#endregion
#region Methods
public override string ToString() => Timing.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class VehicleSpeed : AbstractOBDData
{
#region Properties & Fields
public KilometrePerHour Speed => new KilometrePerHour(A, 0, 255);
#endregion
#region Constructors
public VehicleSpeed()
: base(0x0D, 1)
{ }
#endregion
#region Methods
public override string ToString() => Speed.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class AbsoluteBarometricPressure : AbstractOBDData
{
#region Properties & Fields
public Kilopascal Pressure => new Kilopascal(A, 0, 255);
#endregion
#region Constructors
public AbsoluteBarometricPressure()
: base(0x33, 1)
{ }
#endregion
#region Methods
public override string ToString() => Pressure.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CatalystTemperatureBank1Sensor1 : AbstractOBDData
{
#region Properties & Fields
public DegreeCelsius Temperature => new DegreeCelsius((((256 * A) + B) / 10.0) - 40, -40, 6513.5);
#endregion
#region Constructors
public CatalystTemperatureBank1Sensor1()
: base(0x3C, 2)
{ }
#endregion
#region Methods
public override string ToString() => Temperature.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CatalystTemperatureBank1Sensor2 : AbstractOBDData
{
#region Properties & Fields
public DegreeCelsius Temperature => new DegreeCelsius((((256 * A) + B) / 10.0) - 40, -40, 6513.5);
#endregion
#region Constructors
public CatalystTemperatureBank1Sensor2()
: base(0x3D, 2)
{ }
#endregion
#region Methods
public override string ToString() => Temperature.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CatalystTemperatureBank2Sensor1 : AbstractOBDData
{
#region Properties & Fields
public DegreeCelsius Temperature => new DegreeCelsius((((256 * A) + B) / 10.0) - 40, -40, 6513.5);
#endregion
#region Constructors
public CatalystTemperatureBank2Sensor1()
: base(0x3E, 2)
{ }
#endregion
#region Methods
public override string ToString() => Temperature.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CatalystTemperatureBank2Sensor2 : AbstractOBDData
{
#region Properties & Fields
public DegreeCelsius Temperature => new DegreeCelsius((((256 * A) + B) / 10.0) - 40, -40, 6513.5);
#endregion
#region Constructors
public CatalystTemperatureBank2Sensor2()
: base(0x3F, 2)
{ }
#endregion
#region Methods
public override string ToString() => Temperature.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CommandedEGR : AbstractOBDData
{
#region Properties & Fields
public Percent EGR => new Percent(A / 2.55, 0, 100);
#endregion
#region Constructors
public CommandedEGR()
: base(0x2C, 1)
{ }
#endregion
#region Methods
public override string ToString() => EGR.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class CommandedEvaporativePurge : AbstractOBDData
{
#region Properties & Fields
public Percent Purge => new Percent(A / 2.55, 0, 100);
#endregion
#region Constructors
public CommandedEvaporativePurge()
: base(0x2E, 1)
{ }
#endregion
#region Methods
public override string ToString() => Purge.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class DistanceTraveledSinceCodesCleared : AbstractOBDData
{
#region Properties & Fields
public Kilometre Distance => new Kilometre((256 * A) + B, 0, 65535);
#endregion
#region Constructors
public DistanceTraveledSinceCodesCleared()
: base(0x31, 2)
{ }
#endregion
#region Methods
public override string ToString() => Distance.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class DistanceTraveledWithMILOn : AbstractOBDData
{
#region Properties & Fields
public Kilometre Distance => new Kilometre((256 * A) + B, 0, 65535);
#endregion
#region Constructors
public DistanceTraveledWithMILOn()
: base(0x21, 2)
{ }
#endregion
#region Methods
public override string ToString() => Distance.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class EGRError : AbstractOBDData
{
#region Properties & Fields
public Percent Error => new Percent((A / 1.28) - 100, -100, 99.2);
#endregion
#region Constructors
public EGRError()
: base(0x2D, 1)
{ }
#endregion
#region Methods
public override string ToString() => Error.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class EvapSystemVaporPressure : AbstractOBDData
{
#region Properties & Fields
public Pascal Pressure => new Pascal(((256 * A) + B) / 4.0, -8192, 8191.75);
#endregion
#region Constructors
public EvapSystemVaporPressure()
: base(0x32, 2)
{ }
#endregion
#region Methods
public override string ToString() => Pressure.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class FuelRailGaugePressure : AbstractOBDData
{
#region Properties & Fields
public Kilopascal Pressure => new Kilopascal(10 * ((256 * A) + B), 0, 655350);
#endregion
#region Constructors
public FuelRailGaugePressure()
: base(0x23, 2)
{ }
#endregion
#region Methods
public override string ToString() => Pressure.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class FuelRailPressure : AbstractOBDData
{
#region Properties & Fields
public Kilopascal Pressure => new Kilopascal(0.079 * ((256 * A) + B), 0, 5177.265);
#endregion
#region Constructors
public FuelRailPressure()
: base(0x22, 2)
{ }
#endregion
#region Methods
public override string ToString() => Pressure.ToString();
#endregion
}
}

View File

@ -1,27 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class FuelTankLevelInput : AbstractOBDData
{
#region Properties & Fields
public Percent Level => new Percent(A / 2.55, 0, 100);
#endregion
#region Constructors
public FuelTankLevelInput()
: base(0x2F, 1)
{ }
#endregion
#region Methods
public override string ToString() => Level.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor1FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor1FuelAir()
: base(0x24, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor1FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor1FuelAir2()
: base(0x34, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor2FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor2FuelAir()
: base(0x25, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor2FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor2FuelAir2()
: base(0x35, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor3FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor3FuelAir()
: base(0x26, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor3FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor3FuelAir2()
: base(0x36, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor4FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor4FuelAir()
: base(0x27, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor4FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor4FuelAir2()
: base(0x37, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor5FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor5FuelAir()
: base(0x28, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor5FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor5FuelAir2()
: base(0x38, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor6FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor6FuelAir()
: base(0x29, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor6FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor6FuelAir2()
: base(0x39, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor7FuelAir : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Volt Voltage => new Volt((80 / 25536.0) * ((256 * C) + D), 0, 8 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor7FuelAir()
: base(0x2A, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

View File

@ -1,28 +0,0 @@
using OBD.NET.Common.DataTypes;
namespace OBD.NET.Common.OBDData
{
public class OxygenSensor7FuelAir2 : AbstractOBDData
{
#region Properties & Fields
public Ratio FuelAirEquivalenceRatio => new Ratio((2.0 / 25536.0) * ((256 * A) + B), 0, 2 - double.Epsilon);
public Milliampere Current => new Milliampere((C + (D / 256.0)) - 128, -128, 128 - double.Epsilon);
#endregion
#region Constructors
public OxygenSensor7FuelAir2()
: base(0x3A, 4)
{ }
#endregion
#region Methods
public override string ToString() => FuelAirEquivalenceRatio.ToString();
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show More