From 162434948377976502137d0b1f8a83ef5b4b44e3 Mon Sep 17 00:00:00 2001 From: Julian Baumann Date: Wed, 30 Mar 2022 17:01:08 +0200 Subject: [PATCH] Moved to the `System.IO.Ports` implementation, refactored C# 10, combined `OBD.NET.Desktop` with `OBD.NET.Common` --- .gitignore | 2 + OBD.NET/ConsoleClient/ConsoleClient.csproj | 14 + OBD.NET/ConsoleClient/Program.cs | 83 +++++ OBD.NET/OBD.NET.Common/Commands/ATCommand.cs | 57 ---- OBD.NET/OBD.NET.Common/Commands/STCommand.cs | 49 --- .../EventArgs/DataReceivedEventArgs.cs | 37 --- .../Communication/ISerialConnection.cs | 58 ---- OBD.NET/OBD.NET.Common/DataTypes/Count.cs | 23 -- OBD.NET/OBD.NET.Common/DataTypes/Degree.cs | 29 -- .../OBD.NET.Common/DataTypes/DegreeCelsius.cs | 29 -- .../OBD.NET.Common/DataTypes/GenericData.cs | 52 ---- .../OBD.NET.Common/DataTypes/GramPerSec.cs | 23 -- OBD.NET/OBD.NET.Common/DataTypes/Kilometre.cs | 23 -- .../DataTypes/KilometrePerHour.cs | 23 -- .../OBD.NET.Common/DataTypes/Kilopascal.cs | 29 -- .../OBD.NET.Common/DataTypes/LitresPerHour.cs | 23 -- .../OBD.NET.Common/DataTypes/Milliampere.cs | 23 -- OBD.NET/OBD.NET.Common/DataTypes/Minute.cs | 31 -- .../OBD.NET.Common/DataTypes/NewtonMetre.cs | 23 -- OBD.NET/OBD.NET.Common/DataTypes/Pascal.cs | 31 -- OBD.NET/OBD.NET.Common/DataTypes/Percent.cs | 23 -- OBD.NET/OBD.NET.Common/DataTypes/Ratio.cs | 23 -- .../DataTypes/RevolutionsPerMinute.cs | 23 -- OBD.NET/OBD.NET.Common/DataTypes/Second.cs | 29 -- OBD.NET/OBD.NET.Common/DataTypes/Volt.cs | 23 -- OBD.NET/OBD.NET.Common/Devices/Command.cs | 27 -- .../OBD.NET.Common/Devices/CommandResult.cs | 23 -- OBD.NET/OBD.NET.Common/Devices/ELM327.cs | 288 ------------------ OBD.NET/OBD.NET.Common/Devices/STN1170.cs | 27 -- .../OBD.NET.Common/Devices/SerialDevice.cs | 254 --------------- OBD.NET/OBD.NET.Common/Enums/Mode.cs | 19 -- .../Events/EventArgs/DataReceivedEventArgs.cs | 25 -- .../EventArgs/RawDataReceivedEventArgs.cs | 24 -- .../Events/GenericDataEventManager.cs | 23 -- .../Events/IDataEventManager.cs | 10 - .../Exceptions/SerialException.cs | 23 -- .../Exceptions/UnexpectedResultException.cs | 39 --- .../OBD.NET.Common/Extensions/HexExtension.cs | 24 -- OBD.NET/OBD.NET.Common/Logging/IOBDLogger.cs | 7 - .../OBD.NET.Common/Logging/OBDDebugLogger.cs | 40 --- OBD.NET/OBD.NET.Common/Logging/OBDLogLevel.cs | 10 - OBD.NET/OBD.NET.Common/OBD.NET.Common.csproj | 50 --- .../OBDData/00-1F/AuxiliaryInputStatus.cs | 25 -- .../OBDData/00-1F/CalculatedEngineLoad.cs | 27 -- .../00-1F/CommandedSecondaryAirStatus.cs | 44 --- .../OBDData/00-1F/EngineCoolantTemperature.cs | 27 -- .../OBD.NET.Common/OBDData/00-1F/EngineRPM.cs | 27 -- .../OBDData/00-1F/FuelPressure.cs | 27 -- .../OBDData/00-1F/FuelSystemStatus.cs | 46 --- .../OBDData/00-1F/IntakeAirTemperature.cs | 27 -- .../00-1F/IntakeManifoldAbsolutePressure.cs | 27 -- .../OBDData/00-1F/LongTermFuelTrimBank1.cs | 27 -- .../OBDData/00-1F/LongTermFuelTrimBank2.cs | 27 -- .../OBDData/00-1F/MAFAirFlowRate.cs | 27 -- .../OBDData/00-1F/OBDStandards.cs | 62 ---- .../OBDData/00-1F/OxygenSensor1FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor2FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor3FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor4FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor5FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor6FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor7FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensor8FuelTrim.cs | 29 -- .../OBDData/00-1F/OxygenSensorPresent.cs | 34 --- .../OBDData/00-1F/OxygenSensorsPresent2.cs | 34 --- .../OBDData/00-1F/PidsSupported01_20.cs | 19 -- .../OBDData/00-1F/RunTimeSinceEngineStart.cs | 27 -- .../OBDData/00-1F/ShortTermFuelTrimBank1.cs | 27 -- .../OBDData/00-1F/ShortTermFuelTrimBank2.cs | 27 -- .../OBDData/00-1F/ThrottlePosition.cs | 27 -- .../OBDData/00-1F/TimingAdvance.cs | 27 -- .../OBDData/00-1F/VehicleSpeed.cs | 27 -- .../20-3F/AbsoluteBarometricPressure.cs | 27 -- .../20-3F/CatalystTemperatureBank1Sensor1.cs | 27 -- .../20-3F/CatalystTemperatureBank1Sensor2.cs | 27 -- .../20-3F/CatalystTemperatureBank2Sensor1.cs | 27 -- .../20-3F/CatalystTemperatureBank2Sensor2.cs | 27 -- .../OBDData/20-3F/CommandedEGR.cs | 27 -- .../20-3F/CommandedEvaporativePurge.cs | 27 -- .../DistanceTraveledSinceCodesCleared.cs | 27 -- .../20-3F/DistanceTraveledWithMILOn.cs | 27 -- .../OBD.NET.Common/OBDData/20-3F/EGRError.cs | 27 -- .../OBDData/20-3F/EvapSystemVaporPressure.cs | 27 -- .../OBDData/20-3F/FuelRailGaugePressure.cs | 27 -- .../OBDData/20-3F/FuelRailPressure.cs | 27 -- .../OBDData/20-3F/FuelTankLevelInput.cs | 27 -- .../OBDData/20-3F/OxygenSensor1FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor1FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor2FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor2FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor3FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor3FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor4FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor4FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor5FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor5FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor6FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor6FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor7FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor7FuelAir2.cs | 28 -- .../OBDData/20-3F/OxygenSensor8FuelAir.cs | 28 -- .../OBDData/20-3F/OxygenSensor8FuelAir2.cs | 28 -- .../OBDData/20-3F/PidsSupported21_40.cs | 19 -- .../OBDData/20-3F/WarmUpsSinceCodesCleared.cs | 27 -- .../40-5F/AbsoluteEvapSystemVaporPressure.cs | 27 -- .../OBDData/40-5F/AbsoluteLoadValue.cs | 27 -- .../40-5F/AbsoluteThrottlePositionB.cs | 27 -- .../40-5F/AbsoluteThrottlePositionC.cs | 27 -- .../40-5F/AcceleratorPedalPositionD.cs | 27 -- .../40-5F/AcceleratorPedalPositionE.cs | 27 -- .../40-5F/AcceleratorPedalPositionF.cs | 27 -- .../OBDData/40-5F/AmbientAirTemperature.cs | 27 -- .../40-5F/CommandedThrottleActuator.cs | 27 -- .../OBDData/40-5F/ControlModuleVoltage.cs | 27 -- .../OBDData/40-5F/EngineFuelRate.cs | 27 -- .../OBDData/40-5F/EngineOilTemperature.cs | 27 -- .../OBDData/40-5F/EthanolFuel.cs | 27 -- .../OBDData/40-5F/EvapSystemVaporPressure2.cs | 27 -- .../40-5F/FuelAirCommandedEquivalenceRatio.cs | 27 -- .../OBDData/40-5F/FuelInjectionTiming.cs | 27 -- .../OBDData/40-5F/FuelRailAbsolutePressure.cs | 27 -- .../OBD.NET.Common/OBDData/40-5F/FuelType.cs | 57 ---- .../40-5F/HybridBatteryPackRemainingLife.cs | 27 -- ...LongTermSecondaryOxygenSensorTrimBank13.cs | 28 -- ...LongTermSecondaryOxygenSensorTrimBank24.cs | 28 -- .../40-5F/MaximumValueForAirFlowRate.cs | 27 -- .../OBDData/40-5F/MaximumValues.cs | 30 -- .../40-5F/MonitorStatusThisDriveCycle.cs | 56 ---- .../OBDData/40-5F/PidsSupported41_60.cs | 19 -- .../40-5F/RelativeAcceleratorPedalPosition.cs | 27 -- .../OBDData/40-5F/RelativeThrottlePosition.cs | 27 -- ...hortTermSecondaryOxygenSensorTrimBank13.cs | 28 -- ...hortTermSecondaryOxygenSensorTrimBank24.cs | 28 -- .../OBDData/40-5F/TimeRunWithMILOn.cs | 27 -- .../40-5F/TimeSinceTroubleCodesCleared.cs | 27 -- .../60-7F/ActualEnginePercentTorque.cs | 27 -- .../60-7F/DriversDemandEnginePercentTorque.cs | 27 -- .../60-7F/EngineCoolantTemperatureSensor.cs | 29 -- .../OBDData/60-7F/EnginePercentTorqueData.cs | 31 -- .../OBDData/60-7F/EngineReferenceTorque.cs | 27 -- .../60-7F/IntakeAirTemperatureSensor.cs | 33 -- .../OBDData/60-7F/PidsSupported61_80.cs | 19 -- .../OBDData/80-9F/PidsSupported81_A0.cs | 19 -- .../OBDData/A0-BF/PidsSupportedA1_C0.cs | 19 -- .../OBD.NET.Common/OBDData/AbstractOBDData.cs | 74 ----- .../OBDData/AbstractPidsSupported.cs | 34 --- .../OBDData/C0-DF/PidsSupportedC1_E0.cs | 19 -- OBD.NET/OBD.NET.Common/OBDData/IOBDData.cs | 9 - .../Util/AsyncManulResetEvent.cs | 54 ---- OBD.NET/OBD.NET.ConsoleClient/App.config | 6 - .../OBD.NET.ConsoleClient.csproj | 63 ---- OBD.NET/OBD.NET.ConsoleClient/Program.cs | 72 ----- .../Properties/AssemblyInfo.cs | 35 --- .../Communication/EnhancedSerialPort.cs | 171 ----------- .../Communication/SerialConnection.cs | 74 ----- .../Logging/ODBConsoleLogger.cs | 39 --- .../OBD.NET.Desktop/OBD.NET.Desktop.csproj | 62 ---- .../BluetoothSerialConnection.cs | 170 ----------- .../OBD.NET.Universal.csproj | 138 --------- .../OBD.NET.Universal.nuspec | 15 - .../Properties/AssemblyInfo.cs | 29 -- .../Properties/OBD.NET.Universal.rd.xml | 33 -- OBD.NET/OBD.NET.sln | 92 +----- .../.idea/.idea.OBD.NET/.idea/workspace.xml | 212 +++++++++++++ OBD.NET/OBD.NET/Commands/ATCommand.cs | 56 ++++ OBD.NET/OBD.NET/Commands/STCommand.cs | 48 +++ .../EventArgs/DataReceivedEventArgs.cs | 36 +++ .../Communication/ISerialConnection.cs | 55 ++++ .../OBD.NET/Communication/SerialConnection.cs | 71 +++++ OBD.NET/OBD.NET/DataTypes/Count.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Degree.cs | 28 ++ OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs | 28 ++ OBD.NET/OBD.NET/DataTypes/GenericData.cs | 49 +++ OBD.NET/OBD.NET/DataTypes/GramPerSec.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Kilometre.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Kilopascal.cs | 28 ++ OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Milliampere.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Minute.cs | 30 ++ OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Pascal.cs | 30 ++ OBD.NET/OBD.NET/DataTypes/Percent.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Ratio.cs | 22 ++ .../OBD.NET/DataTypes/RevolutionsPerMinute.cs | 22 ++ OBD.NET/OBD.NET/DataTypes/Second.cs | 28 ++ OBD.NET/OBD.NET/DataTypes/Volt.cs | 22 ++ OBD.NET/OBD.NET/Devices/Command.cs | 26 ++ OBD.NET/OBD.NET/Devices/CommandResult.cs | 22 ++ OBD.NET/OBD.NET/Devices/ELM327.cs | 283 +++++++++++++++++ OBD.NET/OBD.NET/Devices/STN1170.cs | 26 ++ OBD.NET/OBD.NET/Devices/SerialDevice.cs | 250 +++++++++++++++ OBD.NET/OBD.NET/Enums/Mode.cs | 18 ++ .../Events/EventArgs/DataReceivedEventArgs.cs | 23 ++ .../EventArgs/RawDataReceivedEventArgs.cs | 21 ++ .../OBD.NET/Events/GenericDataEventManager.cs | 21 ++ OBD.NET/OBD.NET/Events/IDataEventManager.cs | 8 + OBD.NET/OBD.NET/Exceptions/SerialException.cs | 20 ++ .../Exceptions/UnexpectedResultException.cs | 36 +++ OBD.NET/OBD.NET/Extensions/HexExtension.cs | 20 ++ OBD.NET/OBD.NET/Logging/IOBDLogger.cs | 6 + OBD.NET/OBD.NET/Logging/OBDConsoleLogger.cs | 35 +++ OBD.NET/OBD.NET/Logging/OBDDebugLogger.cs | 38 +++ OBD.NET/OBD.NET/Logging/OBDLogLevel.cs | 9 + OBD.NET/OBD.NET/OBD.NET.csproj | 53 ++++ .../OBDData/00-1F/AuxiliaryInputStatus.cs | 24 ++ .../OBDData/00-1F/CalculatedEngineLoad.cs | 26 ++ .../00-1F/CommandedSecondaryAirStatus.cs | 41 +++ .../OBDData/00-1F/EngineCoolantTemperature.cs | 26 ++ OBD.NET/OBD.NET/OBDData/00-1F/EngineRPM.cs | 26 ++ OBD.NET/OBD.NET/OBDData/00-1F/FuelPressure.cs | 26 ++ .../OBD.NET/OBDData/00-1F/FuelSystemStatus.cs | 43 +++ .../OBDData/00-1F/IntakeAirTemperature.cs | 26 ++ .../00-1F/IntakeManifoldAbsolutePressure.cs | 26 ++ .../OBDData/00-1F/LongTermFuelTrimBank1.cs | 26 ++ .../OBDData/00-1F/LongTermFuelTrimBank2.cs | 26 ++ .../OBD.NET/OBDData/00-1F/MAFAirFlowRate.cs | 26 ++ OBD.NET/OBD.NET/OBDData/00-1F/OBDStandards.cs | 61 ++++ .../OBDData/00-1F/OxygenSensor1FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor2FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor3FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor4FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor5FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor6FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor7FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensor8FuelTrim.cs | 28 ++ .../OBDData/00-1F/OxygenSensorPresent.cs | 31 ++ .../OBDData/00-1F/OxygenSensorsPresent2.cs | 31 ++ .../OBDData/00-1F/PidsSupported01_20.cs | 18 ++ .../OBDData/00-1F/RunTimeSinceEngineStart.cs | 26 ++ .../OBDData/00-1F/ShortTermFuelTrimBank1.cs | 26 ++ .../OBDData/00-1F/ShortTermFuelTrimBank2.cs | 26 ++ .../OBD.NET/OBDData/00-1F/ThrottlePosition.cs | 26 ++ .../OBD.NET/OBDData/00-1F/TimingAdvance.cs | 26 ++ OBD.NET/OBD.NET/OBDData/00-1F/VehicleSpeed.cs | 26 ++ .../20-3F/AbsoluteBarometricPressure.cs | 26 ++ .../20-3F/CatalystTemperatureBank1Sensor1.cs | 26 ++ .../20-3F/CatalystTemperatureBank1Sensor2.cs | 26 ++ .../20-3F/CatalystTemperatureBank2Sensor1.cs | 26 ++ .../20-3F/CatalystTemperatureBank2Sensor2.cs | 26 ++ OBD.NET/OBD.NET/OBDData/20-3F/CommandedEGR.cs | 26 ++ .../20-3F/CommandedEvaporativePurge.cs | 26 ++ .../DistanceTraveledSinceCodesCleared.cs | 26 ++ .../20-3F/DistanceTraveledWithMILOn.cs | 26 ++ OBD.NET/OBD.NET/OBDData/20-3F/EGRError.cs | 26 ++ .../OBDData/20-3F/EvapSystemVaporPressure.cs | 26 ++ .../OBDData/20-3F/FuelRailGaugePressure.cs | 26 ++ .../OBD.NET/OBDData/20-3F/FuelRailPressure.cs | 26 ++ .../OBDData/20-3F/FuelTankLevelInput.cs | 26 ++ .../OBDData/20-3F/OxygenSensor1FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor1FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor2FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor2FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor3FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor3FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor4FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor4FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor5FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor5FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor6FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor6FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor7FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor7FuelAir2.cs | 27 ++ .../OBDData/20-3F/OxygenSensor8FuelAir.cs | 27 ++ .../OBDData/20-3F/OxygenSensor8FuelAir2.cs | 27 ++ .../OBDData/20-3F/PidsSupported21_40.cs | 18 ++ .../OBDData/20-3F/WarmUpsSinceCodesCleared.cs | 26 ++ .../40-5F/AbsoluteEvapSystemVaporPressure.cs | 26 ++ .../OBDData/40-5F/AbsoluteLoadValue.cs | 26 ++ .../40-5F/AbsoluteThrottlePositionB.cs | 26 ++ .../40-5F/AbsoluteThrottlePositionC.cs | 26 ++ .../40-5F/AcceleratorPedalPositionD.cs | 26 ++ .../40-5F/AcceleratorPedalPositionE.cs | 26 ++ .../40-5F/AcceleratorPedalPositionF.cs | 26 ++ .../OBDData/40-5F/AmbientAirTemperature.cs | 26 ++ .../40-5F/CommandedThrottleActuator.cs | 26 ++ .../OBDData/40-5F/ControlModuleVoltage.cs | 26 ++ .../OBD.NET/OBDData/40-5F/EngineFuelRate.cs | 26 ++ .../OBDData/40-5F/EngineOilTemperature.cs | 26 ++ OBD.NET/OBD.NET/OBDData/40-5F/EthanolFuel.cs | 26 ++ .../OBDData/40-5F/EvapSystemVaporPressure2.cs | 26 ++ .../40-5F/FuelAirCommandedEquivalenceRatio.cs | 26 ++ .../OBDData/40-5F/FuelInjectionTiming.cs | 26 ++ .../OBDData/40-5F/FuelRailAbsolutePressure.cs | 26 ++ OBD.NET/OBD.NET/OBDData/40-5F/FuelType.cs | 56 ++++ .../40-5F/HybridBatteryPackRemainingLife.cs | 26 ++ ...LongTermSecondaryOxygenSensorTrimBank13.cs | 27 ++ ...LongTermSecondaryOxygenSensorTrimBank24.cs | 27 ++ .../40-5F/MaximumValueForAirFlowRate.cs | 26 ++ .../OBD.NET/OBDData/40-5F/MaximumValues.cs | 29 ++ .../40-5F/MonitorStatusThisDriveCycle.cs | 55 ++++ .../OBDData/40-5F/PidsSupported41_60.cs | 18 ++ .../40-5F/RelativeAcceleratorPedalPosition.cs | 26 ++ .../OBDData/40-5F/RelativeThrottlePosition.cs | 26 ++ ...hortTermSecondaryOxygenSensorTrimBank13.cs | 27 ++ ...hortTermSecondaryOxygenSensorTrimBank24.cs | 27 ++ .../OBD.NET/OBDData/40-5F/TimeRunWithMILOn.cs | 26 ++ .../40-5F/TimeSinceTroubleCodesCleared.cs | 26 ++ .../60-7F/ActualEnginePercentTorque.cs | 26 ++ .../60-7F/DriversDemandEnginePercentTorque.cs | 26 ++ .../60-7F/EngineCoolantTemperatureSensor.cs | 28 ++ .../OBDData/60-7F/EnginePercentTorqueData.cs | 30 ++ .../OBDData/60-7F/EngineReferenceTorque.cs | 26 ++ .../60-7F/IntakeAirTemperatureSensor.cs | 32 ++ .../OBDData/60-7F/PidsSupported61_80.cs | 18 ++ .../OBDData/80-9F/PidsSupported81_A0.cs | 18 ++ .../OBDData/A0-BF/PidsSupportedA1_C0.cs | 18 ++ OBD.NET/OBD.NET/OBDData/AbstractOBDData.cs | 72 +++++ .../OBD.NET/OBDData/AbstractPidsSupported.cs | 32 ++ .../OBDData/C0-DF/PidsSupportedC1_E0.cs | 18 ++ OBD.NET/OBD.NET/OBDData/IOBDData.cs | 8 + OBD.NET/OBD.NET/Util/AsyncManulResetEvent.cs | 50 +++ 312 files changed, 4934 insertions(+), 5675 deletions(-) create mode 100644 OBD.NET/ConsoleClient/ConsoleClient.csproj create mode 100644 OBD.NET/ConsoleClient/Program.cs delete mode 100644 OBD.NET/OBD.NET.Common/Commands/ATCommand.cs delete mode 100644 OBD.NET/OBD.NET.Common/Commands/STCommand.cs delete mode 100644 OBD.NET/OBD.NET.Common/Communication/EventArgs/DataReceivedEventArgs.cs delete mode 100644 OBD.NET/OBD.NET.Common/Communication/ISerialConnection.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Count.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Degree.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/DegreeCelsius.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/GenericData.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/GramPerSec.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Kilometre.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/KilometrePerHour.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Kilopascal.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/LitresPerHour.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Milliampere.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Minute.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/NewtonMetre.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Pascal.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Percent.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Ratio.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/RevolutionsPerMinute.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Second.cs delete mode 100644 OBD.NET/OBD.NET.Common/DataTypes/Volt.cs delete mode 100644 OBD.NET/OBD.NET.Common/Devices/Command.cs delete mode 100644 OBD.NET/OBD.NET.Common/Devices/CommandResult.cs delete mode 100644 OBD.NET/OBD.NET.Common/Devices/ELM327.cs delete mode 100644 OBD.NET/OBD.NET.Common/Devices/STN1170.cs delete mode 100644 OBD.NET/OBD.NET.Common/Devices/SerialDevice.cs delete mode 100644 OBD.NET/OBD.NET.Common/Enums/Mode.cs delete mode 100644 OBD.NET/OBD.NET.Common/Events/EventArgs/DataReceivedEventArgs.cs delete mode 100644 OBD.NET/OBD.NET.Common/Events/EventArgs/RawDataReceivedEventArgs.cs delete mode 100644 OBD.NET/OBD.NET.Common/Events/GenericDataEventManager.cs delete mode 100644 OBD.NET/OBD.NET.Common/Events/IDataEventManager.cs delete mode 100644 OBD.NET/OBD.NET.Common/Exceptions/SerialException.cs delete mode 100644 OBD.NET/OBD.NET.Common/Exceptions/UnexpectedResultException.cs delete mode 100644 OBD.NET/OBD.NET.Common/Extensions/HexExtension.cs delete mode 100644 OBD.NET/OBD.NET.Common/Logging/IOBDLogger.cs delete mode 100644 OBD.NET/OBD.NET.Common/Logging/OBDDebugLogger.cs delete mode 100644 OBD.NET/OBD.NET.Common/Logging/OBDLogLevel.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBD.NET.Common.csproj delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/AuxiliaryInputStatus.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/CalculatedEngineLoad.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/CommandedSecondaryAirStatus.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineCoolantTemperature.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineRPM.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelPressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelSystemStatus.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeAirTemperature.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank1.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/MAFAirFlowRate.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OBDStandards.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor1FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor2FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor3FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor4FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor5FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor6FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor7FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor8FuelTrim.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorPresent.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorsPresent2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/PidsSupported01_20.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/RunTimeSinceEngineStart.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank1.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/ThrottlePosition.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/TimingAdvance.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/00-1F/VehicleSpeed.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/AbsoluteBarometricPressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEGR.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEvaporativePurge.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledWithMILOn.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/EGRError.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/EvapSystemVaporPressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailGaugePressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailPressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelTankLevelInput.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/PidsSupported21_40.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/20-3F/WarmUpsSinceCodesCleared.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteLoadValue.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionB.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionC.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionD.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionE.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionF.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/AmbientAirTemperature.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/CommandedThrottleActuator.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/ControlModuleVoltage.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineFuelRate.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineOilTemperature.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/EthanolFuel.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/EvapSystemVaporPressure2.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelInjectionTiming.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelRailAbsolutePressure.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelType.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/HybridBatteryPackRemainingLife.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValueForAirFlowRate.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValues.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/MonitorStatusThisDriveCycle.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/PidsSupported41_60.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeThrottlePosition.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeRunWithMILOn.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/ActualEnginePercentTorque.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/DriversDemandEnginePercentTorque.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineCoolantTemperatureSensor.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/EnginePercentTorqueData.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineReferenceTorque.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/IntakeAirTemperatureSensor.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/60-7F/PidsSupported61_80.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/80-9F/PidsSupported81_A0.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/A0-BF/PidsSupportedA1_C0.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/AbstractOBDData.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/AbstractPidsSupported.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/C0-DF/PidsSupportedC1_E0.cs delete mode 100644 OBD.NET/OBD.NET.Common/OBDData/IOBDData.cs delete mode 100644 OBD.NET/OBD.NET.Common/Util/AsyncManulResetEvent.cs delete mode 100644 OBD.NET/OBD.NET.ConsoleClient/App.config delete mode 100644 OBD.NET/OBD.NET.ConsoleClient/OBD.NET.ConsoleClient.csproj delete mode 100644 OBD.NET/OBD.NET.ConsoleClient/Program.cs delete mode 100644 OBD.NET/OBD.NET.ConsoleClient/Properties/AssemblyInfo.cs delete mode 100644 OBD.NET/OBD.NET.Desktop/Communication/EnhancedSerialPort.cs delete mode 100644 OBD.NET/OBD.NET.Desktop/Communication/SerialConnection.cs delete mode 100644 OBD.NET/OBD.NET.Desktop/Logging/ODBConsoleLogger.cs delete mode 100644 OBD.NET/OBD.NET.Desktop/OBD.NET.Desktop.csproj delete mode 100644 OBD.NET/OBD.NET.Universal/Communication/BluetoothSerialConnection.cs delete mode 100644 OBD.NET/OBD.NET.Universal/OBD.NET.Universal.csproj delete mode 100644 OBD.NET/OBD.NET.Universal/OBD.NET.Universal.nuspec delete mode 100644 OBD.NET/OBD.NET.Universal/Properties/AssemblyInfo.cs delete mode 100644 OBD.NET/OBD.NET.Universal/Properties/OBD.NET.Universal.rd.xml create mode 100644 OBD.NET/OBD.NET/.idea/.idea.OBD.NET/.idea/workspace.xml create mode 100644 OBD.NET/OBD.NET/Commands/ATCommand.cs create mode 100644 OBD.NET/OBD.NET/Commands/STCommand.cs create mode 100644 OBD.NET/OBD.NET/Communication/EventArgs/DataReceivedEventArgs.cs create mode 100644 OBD.NET/OBD.NET/Communication/ISerialConnection.cs create mode 100644 OBD.NET/OBD.NET/Communication/SerialConnection.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Count.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Degree.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/GenericData.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/GramPerSec.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Kilometre.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Kilopascal.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Milliampere.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Minute.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Pascal.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Percent.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Ratio.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/RevolutionsPerMinute.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Second.cs create mode 100644 OBD.NET/OBD.NET/DataTypes/Volt.cs create mode 100644 OBD.NET/OBD.NET/Devices/Command.cs create mode 100644 OBD.NET/OBD.NET/Devices/CommandResult.cs create mode 100644 OBD.NET/OBD.NET/Devices/ELM327.cs create mode 100644 OBD.NET/OBD.NET/Devices/STN1170.cs create mode 100644 OBD.NET/OBD.NET/Devices/SerialDevice.cs create mode 100644 OBD.NET/OBD.NET/Enums/Mode.cs create mode 100644 OBD.NET/OBD.NET/Events/EventArgs/DataReceivedEventArgs.cs create mode 100644 OBD.NET/OBD.NET/Events/EventArgs/RawDataReceivedEventArgs.cs create mode 100644 OBD.NET/OBD.NET/Events/GenericDataEventManager.cs create mode 100644 OBD.NET/OBD.NET/Events/IDataEventManager.cs create mode 100644 OBD.NET/OBD.NET/Exceptions/SerialException.cs create mode 100644 OBD.NET/OBD.NET/Exceptions/UnexpectedResultException.cs create mode 100644 OBD.NET/OBD.NET/Extensions/HexExtension.cs create mode 100644 OBD.NET/OBD.NET/Logging/IOBDLogger.cs create mode 100644 OBD.NET/OBD.NET/Logging/OBDConsoleLogger.cs create mode 100644 OBD.NET/OBD.NET/Logging/OBDDebugLogger.cs create mode 100644 OBD.NET/OBD.NET/Logging/OBDLogLevel.cs create mode 100644 OBD.NET/OBD.NET/OBD.NET.csproj create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/AuxiliaryInputStatus.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/CalculatedEngineLoad.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/CommandedSecondaryAirStatus.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/EngineCoolantTemperature.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/EngineRPM.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/FuelPressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/FuelSystemStatus.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/IntakeAirTemperature.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank1.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/MAFAirFlowRate.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OBDStandards.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor1FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor2FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor3FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor4FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor5FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor6FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor7FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor8FuelTrim.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorPresent.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorsPresent2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/PidsSupported01_20.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/RunTimeSinceEngineStart.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank1.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/ThrottlePosition.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/TimingAdvance.cs create mode 100644 OBD.NET/OBD.NET/OBDData/00-1F/VehicleSpeed.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/AbsoluteBarometricPressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/CommandedEGR.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/CommandedEvaporativePurge.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledWithMILOn.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/EGRError.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/EvapSystemVaporPressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/FuelRailGaugePressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/FuelRailPressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/FuelTankLevelInput.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/PidsSupported21_40.cs create mode 100644 OBD.NET/OBD.NET/OBDData/20-3F/WarmUpsSinceCodesCleared.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteLoadValue.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionB.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionC.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionD.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionE.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionF.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/AmbientAirTemperature.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/CommandedThrottleActuator.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/ControlModuleVoltage.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/EngineFuelRate.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/EngineOilTemperature.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/EthanolFuel.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/EvapSystemVaporPressure2.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/FuelInjectionTiming.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/FuelRailAbsolutePressure.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/FuelType.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/HybridBatteryPackRemainingLife.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/MaximumValueForAirFlowRate.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/MaximumValues.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/MonitorStatusThisDriveCycle.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/PidsSupported41_60.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/RelativeThrottlePosition.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/TimeRunWithMILOn.cs create mode 100644 OBD.NET/OBD.NET/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/ActualEnginePercentTorque.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/DriversDemandEnginePercentTorque.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/EngineCoolantTemperatureSensor.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/EnginePercentTorqueData.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/EngineReferenceTorque.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/IntakeAirTemperatureSensor.cs create mode 100644 OBD.NET/OBD.NET/OBDData/60-7F/PidsSupported61_80.cs create mode 100644 OBD.NET/OBD.NET/OBDData/80-9F/PidsSupported81_A0.cs create mode 100644 OBD.NET/OBD.NET/OBDData/A0-BF/PidsSupportedA1_C0.cs create mode 100644 OBD.NET/OBD.NET/OBDData/AbstractOBDData.cs create mode 100644 OBD.NET/OBD.NET/OBDData/AbstractPidsSupported.cs create mode 100644 OBD.NET/OBD.NET/OBDData/C0-DF/PidsSupportedC1_E0.cs create mode 100644 OBD.NET/OBD.NET/OBDData/IOBDData.cs create mode 100644 OBD.NET/OBD.NET/Util/AsyncManulResetEvent.cs diff --git a/.gitignore b/.gitignore index 94420dc..5aa37d5 100644 --- a/.gitignore +++ b/.gitignore @@ -234,3 +234,5 @@ _Pvt_Extensions # FAKE - F# Make .fake/ +.DS_Store +OBD.NET/.idea diff --git a/OBD.NET/ConsoleClient/ConsoleClient.csproj b/OBD.NET/ConsoleClient/ConsoleClient.csproj new file mode 100644 index 0000000..ed1d504 --- /dev/null +++ b/OBD.NET/ConsoleClient/ConsoleClient.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/OBD.NET/ConsoleClient/Program.cs b/OBD.NET/ConsoleClient/Program.cs new file mode 100644 index 0000000..937e945 --- /dev/null +++ b/OBD.NET/ConsoleClient/Program.cs @@ -0,0 +1,83 @@ +using OBD.NET.Communication; +using OBD.NET.Devices; +using OBD.NET.Extensions; +using OBD.NET.Logging; +using OBD.NET.OBDData; +using OBD.NET.OBDData._00_1F; +using OBD.NET.OBDData._40_5F; + +namespace ConsoleClient; + +public class Program +{ + public static void Main(string[] args) + { + if (args.Length < 1) + { + Console.WriteLine("Parameter ComPort needed."); + + IEnumerable availablePorts = SerialConnection.GetAvailablePorts(); + + Console.WriteLine("\nAvailable ports:"); + + foreach (string port in availablePorts) + { + Console.WriteLine(port); + } + + return; + } + + string comPort = args[0]; + + using SerialConnection connection = new SerialConnection(comPort); + using ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug)); + + dev.SubscribeDataReceived((sender, data) => Console.WriteLine("EngineRPM: " + data.Data.Rpm)); + dev.SubscribeDataReceived((sender, data) => Console.WriteLine("VehicleSpeed: " + data.Data)); + + dev.SubscribeDataReceived((sender, data) => Console.WriteLine($"PID {data.Data.PID.ToHexString()}: {data.Data}")); + + dev.Initialize(); + dev.RequestData(); + + for (int i = 0; i < 5; i++) + { + dev.RequestData(); + dev.RequestData(); + Thread.Sleep(1000); + } + + Console.ReadLine(); + + //Async example + // MainAsync(comPort).Wait(); + + //Console.ReadLine(); + } + + /// + /// Async example using new RequestDataAsync + /// + /// The COM port. + /// + public static async Task MainAsync(string comPort) + { + using SerialConnection connection = new SerialConnection(comPort); + using ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug)); + + dev.Initialize(); + + EngineRPM engineRpm = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + engineRpm.Rpm); + + engineRpm = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + engineRpm.Rpm); + + VehicleSpeed vehicleSpeed = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + vehicleSpeed.Speed); + + engineRpm = await dev.RequestDataAsync(); + Console.WriteLine("Data: " + engineRpm.Rpm); + } +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET.Common/Commands/ATCommand.cs b/OBD.NET/OBD.NET.Common/Commands/ATCommand.cs deleted file mode 100644 index 04c6a45..0000000 --- a/OBD.NET/OBD.NET.Common/Commands/ATCommand.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Commands/STCommand.cs b/OBD.NET/OBD.NET.Common/Commands/STCommand.cs deleted file mode 100644 index 818ceeb..0000000 --- a/OBD.NET/OBD.NET.Common/Commands/STCommand.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Communication/EventArgs/DataReceivedEventArgs.cs b/OBD.NET/OBD.NET.Common/Communication/EventArgs/DataReceivedEventArgs.cs deleted file mode 100644 index 07231b3..0000000 --- a/OBD.NET/OBD.NET.Common/Communication/EventArgs/DataReceivedEventArgs.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace OBD.NET.Common.Communication.EventArgs -{ - /// - /// Event args for receiving serial data - /// - public class DataReceivedEventArgs : System.EventArgs - { - #region Properties & Fields - - /// - /// Count of valid data bytes in the buffer - /// - public int Count { get; } - - /// - /// Data buffer holding the bytes - /// - public byte[] Data { get; } - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of the class. - /// - /// The count. - /// The data. - public DataReceivedEventArgs(int count, byte[] data) - { - this.Count = count; - this.Data = data; - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/Communication/ISerialConnection.cs b/OBD.NET/OBD.NET.Common/Communication/ISerialConnection.cs deleted file mode 100644 index 0fec8a8..0000000 --- a/OBD.NET/OBD.NET.Common/Communication/ISerialConnection.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Threading.Tasks; -using OBD.NET.Common.Communication.EventArgs; - -namespace OBD.NET.Common.Communication -{ - /// - /// Serial connection interface - /// - /// - public interface ISerialConnection : IDisposable - { - /// - /// Gets a value indicating whether this instance is open. - /// - /// - /// true if this instance is open; otherwise, false. - /// - bool IsOpen { get; } - - /// - /// Gets a value indicating whether this instance uses asynchronous IO - /// - /// - /// Has to be set to true if asynchronous IO is supported. - /// If true async methods have to be implemented - /// - bool IsAsync { get; } - - /// - /// Occurs when a full line was received - /// - event EventHandler DataReceived; - - /// - /// Connects the serial port. - /// - void Connect(); - - /// - /// Connects the serial port asynchronous - /// - /// - Task ConnectAsync(); - - /// - /// Writes the specified data to the serial connection - /// - /// The data. - void Write(byte[] data); - - /// - /// Writes the specified data to the serial connection asynchronous - /// - /// The data. - Task WriteAsync(byte[] data); - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Count.cs b/OBD.NET/OBD.NET.Common/DataTypes/Count.cs deleted file mode 100644 index d8e6675..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Count.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Degree.cs b/OBD.NET/OBD.NET.Common/DataTypes/Degree.cs deleted file mode 100644 index 1d982f7..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Degree.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/DegreeCelsius.cs b/OBD.NET/OBD.NET.Common/DataTypes/DegreeCelsius.cs deleted file mode 100644 index cc39dd9..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/DegreeCelsius.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/GenericData.cs b/OBD.NET/OBD.NET.Common/DataTypes/GenericData.cs deleted file mode 100644 index 3db09e3..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/GenericData.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/GramPerSec.cs b/OBD.NET/OBD.NET.Common/DataTypes/GramPerSec.cs deleted file mode 100644 index 76ccd5f..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/GramPerSec.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Kilometre.cs b/OBD.NET/OBD.NET.Common/DataTypes/Kilometre.cs deleted file mode 100644 index 9368e76..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Kilometre.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/KilometrePerHour.cs b/OBD.NET/OBD.NET.Common/DataTypes/KilometrePerHour.cs deleted file mode 100644 index d265720..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/KilometrePerHour.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Kilopascal.cs b/OBD.NET/OBD.NET.Common/DataTypes/Kilopascal.cs deleted file mode 100644 index 73b7c28..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Kilopascal.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/LitresPerHour.cs b/OBD.NET/OBD.NET.Common/DataTypes/LitresPerHour.cs deleted file mode 100644 index 232bc29..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/LitresPerHour.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Milliampere.cs b/OBD.NET/OBD.NET.Common/DataTypes/Milliampere.cs deleted file mode 100644 index 5a3d176..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Milliampere.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Minute.cs b/OBD.NET/OBD.NET.Common/DataTypes/Minute.cs deleted file mode 100644 index 104ec73..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Minute.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/NewtonMetre.cs b/OBD.NET/OBD.NET.Common/DataTypes/NewtonMetre.cs deleted file mode 100644 index 25651be..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/NewtonMetre.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Pascal.cs b/OBD.NET/OBD.NET.Common/DataTypes/Pascal.cs deleted file mode 100644 index f81f42b..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Pascal.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Percent.cs b/OBD.NET/OBD.NET.Common/DataTypes/Percent.cs deleted file mode 100644 index 55541cc..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Percent.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Ratio.cs b/OBD.NET/OBD.NET.Common/DataTypes/Ratio.cs deleted file mode 100644 index cf871f5..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Ratio.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/RevolutionsPerMinute.cs b/OBD.NET/OBD.NET.Common/DataTypes/RevolutionsPerMinute.cs deleted file mode 100644 index 3162590..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/RevolutionsPerMinute.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Second.cs b/OBD.NET/OBD.NET.Common/DataTypes/Second.cs deleted file mode 100644 index 3072a2c..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Second.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/DataTypes/Volt.cs b/OBD.NET/OBD.NET.Common/DataTypes/Volt.cs deleted file mode 100644 index 3d372b3..0000000 --- a/OBD.NET/OBD.NET.Common/DataTypes/Volt.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Devices/Command.cs b/OBD.NET/OBD.NET.Common/Devices/Command.cs deleted file mode 100644 index 4a6d766..0000000 --- a/OBD.NET/OBD.NET.Common/Devices/Command.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace OBD.NET.Common.Devices -{ - /// - /// Class used for queued command - /// - 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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Devices/CommandResult.cs b/OBD.NET/OBD.NET.Common/Devices/CommandResult.cs deleted file mode 100644 index 3c30514..0000000 --- a/OBD.NET/OBD.NET.Common/Devices/CommandResult.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Devices/ELM327.cs b/OBD.NET/OBD.NET.Common/Devices/ELM327.cs deleted file mode 100644 index 87e5c3f..0000000 --- a/OBD.NET/OBD.NET.Common/Devices/ELM327.cs +++ /dev/null @@ -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 DataReceivedEventHandlers = new Dictionary(); - - protected static Dictionary PidCache { get; } = new Dictionary(); - protected static Dictionary DataTypeCache { get; } = new Dictionary(); - - 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(object sender, DataReceivedEventArgs 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; - } - } - - /// - /// Sends the AT command. - /// - /// The command. - public virtual void SendCommand(ATCommand command) => SendCommand(command.Command); - - /// - /// Requests the data and calls the handler - /// - /// - public virtual void RequestData() - where T : class, IOBDData, new() - { - Logger?.WriteLine("Requesting Type " + typeof(T).Name + " ...", OBDLogLevel.Debug); - - byte pid = ResolvePid(); - RequestData(pid); - } - - /// - /// Request data based on a pid - /// - /// The pid of the requested data - public virtual void RequestData(byte pid) - { - Logger?.WriteLine("Requesting PID " + pid.ToString("X2") + " ...", OBDLogLevel.Debug); - SendCommand(((byte)Mode).ToString("X2") + pid.ToString("X2")); - } - - /// - /// Requests the data asynchronous and return the data when available - /// - /// - /// - public virtual async Task RequestDataAsync() - where T : class, IOBDData, new() - { - Logger?.WriteLine("Requesting Type " + typeof(T).Name + " ...", OBDLogLevel.Debug); - byte pid = ResolvePid(); - return await RequestDataAsync(pid) as T; - } - - /// - /// Requests the data asynchronous and return the data when available - /// - /// - /// - public virtual async Task RequestDataAsync(Type type) - { - Logger?.WriteLine("Requesting Type " + type.Name + " ...", OBDLogLevel.Debug); - byte pid = ResolvePid(type); - return await RequestDataAsync(pid) as IOBDData; - } - - /// - /// Request data based on a pid - /// - /// The pid of the requested data - public virtual async Task 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() - 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() - 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; - } - - /// - /// YOU SHOULDN'T NEED THIS METHOD! - /// - /// You should only use this method if you're requesting data by pid instead of the -method. - /// - /// Initializes the PID-Cache with all IOBDData-Types contained in OBD.NET. - /// You can add additional ones with . - /// - 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(DataReceivedEventHandler eventHandler) where T : IOBDData - { - if (!DataReceivedEventHandlers.TryGetValue(typeof(T), out IDataEventManager eventManager)) - DataReceivedEventHandlers.Add(typeof(T), (eventManager = new GenericDataEventManager())); - - ((GenericDataEventManager)eventManager).DataReceived += eventHandler; - } - - public void UnsubscribeDataReceived(DataReceivedEventHandler eventHandler) where T : IOBDData - { - if (DataReceivedEventHandlers.TryGetValue(typeof(T), out IDataEventManager eventManager)) - ((GenericDataEventManager)eventManager).DataReceived -= eventHandler; - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/Devices/STN1170.cs b/OBD.NET/OBD.NET.Common/Devices/STN1170.cs deleted file mode 100644 index 44c6c3e..0000000 --- a/OBD.NET/OBD.NET.Common/Devices/STN1170.cs +++ /dev/null @@ -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 - - /// - /// Sends the ST command. - /// - /// The command. - public virtual void SendCommand(STCommand command) => SendCommand(command.Command); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/Devices/SerialDevice.cs b/OBD.NET/OBD.NET.Common/Devices/SerialDevice.cs deleted file mode 100644 index e4623f2..0000000 --- a/OBD.NET/OBD.NET.Common/Devices/SerialDevice.cs +++ /dev/null @@ -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 -{ - /// - /// Base class used for communicating with the device - /// - public abstract class SerialDevice : IDisposable - { - #region Properties & Fields - - private readonly BlockingCollection _commandQueue = new BlockingCollection(); - 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 - - /// - /// Initializes a new instance of the class. - /// - /// connection. - /// terminator used for terminating the command message - /// logger instance - 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 - - /// - /// Initializes the device - /// - public virtual void Initialize() - { - Connection.Connect(); - CheckConnectionAndStartWorker(); - } - - /// - /// Initializes the device - /// - public virtual async Task InitializeAsync() - { - await Connection.ConnectAsync(); - CheckConnectionAndStartWorker(); - } - - /// - /// Checks the connection and starts background worker which is sending the commands - /// - /// Failed to open Serial-Connection. - 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); - } - - - /// - /// Sends the command. - /// - /// command string - /// Not connected - 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; - } - - /// - /// Prepares the command - /// - /// - /// - 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; - } - - /// - /// Called when data is received from the serial device - /// - /// The sender. - /// The instance containing the event data. - 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; - } - } - } - - /// - /// Signals a final message - /// - private void FinishLine() - { - string line = _lineBuffer.ToString().Trim(); - _lineBuffer.Clear(); - - if (string.IsNullOrWhiteSpace(line)) return; - Logger?.WriteLine("Response: '" + line + "'", OBDLogLevel.Verbose); - - InternalProcessMessage(line); - } - - /// - /// Process message and sets the result - /// - /// The message. - private void InternalProcessMessage(string message) - { - object data = ProcessMessage(message); - CurrentCommand.CommandResult.Result = data; - } - - /// - /// Processes the message. - /// - /// message received - /// result data - protected abstract object ProcessMessage(string message); - - /// - /// Worker method for sending commands - /// - 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()); - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public virtual void Dispose() - { - _commandQueue.CompleteAdding(); - _commandCancellationToken?.Cancel(); - _commandWorkerTask?.Wait(); - Connection?.Dispose(); - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/Enums/Mode.cs b/OBD.NET/OBD.NET.Common/Enums/Mode.cs deleted file mode 100644 index 9126eb6..0000000 --- a/OBD.NET/OBD.NET.Common/Enums/Mode.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.Enums -{ - /// - /// https://en.wikipedia.org/wiki/OBD-II_PIDs#Modes - /// - 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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Events/EventArgs/DataReceivedEventArgs.cs b/OBD.NET/OBD.NET.Common/Events/EventArgs/DataReceivedEventArgs.cs deleted file mode 100644 index 557ce18..0000000 --- a/OBD.NET/OBD.NET.Common/Events/EventArgs/DataReceivedEventArgs.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using OBD.NET.Common.OBDData; - -namespace OBD.NET.Common.Events.EventArgs -{ - public class DataReceivedEventArgs 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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Events/EventArgs/RawDataReceivedEventArgs.cs b/OBD.NET/OBD.NET.Common/Events/EventArgs/RawDataReceivedEventArgs.cs deleted file mode 100644 index 680bff6..0000000 --- a/OBD.NET/OBD.NET.Common/Events/EventArgs/RawDataReceivedEventArgs.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Events/GenericDataEventManager.cs b/OBD.NET/OBD.NET.Common/Events/GenericDataEventManager.cs deleted file mode 100644 index 39ad47b..0000000 --- a/OBD.NET/OBD.NET.Common/Events/GenericDataEventManager.cs +++ /dev/null @@ -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 : IDataEventManager - where T : IOBDData - { - #region Events - - internal event ELM327.DataReceivedEventHandler DataReceived; - - #endregion - - #region Methods - - public void RaiseEvent(object sender, IOBDData data, DateTime timestamp) => DataReceived?.Invoke(sender, new DataReceivedEventArgs((T)data, timestamp)); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/Events/IDataEventManager.cs b/OBD.NET/OBD.NET.Common/Events/IDataEventManager.cs deleted file mode 100644 index a15963e..0000000 --- a/OBD.NET/OBD.NET.Common/Events/IDataEventManager.cs +++ /dev/null @@ -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); - } -} diff --git a/OBD.NET/OBD.NET.Common/Exceptions/SerialException.cs b/OBD.NET/OBD.NET.Common/Exceptions/SerialException.cs deleted file mode 100644 index 3fd1d64..0000000 --- a/OBD.NET/OBD.NET.Common/Exceptions/SerialException.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Exceptions/UnexpectedResultException.cs b/OBD.NET/OBD.NET.Common/Exceptions/UnexpectedResultException.cs deleted file mode 100644 index d3f18d3..0000000 --- a/OBD.NET/OBD.NET.Common/Exceptions/UnexpectedResultException.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Extensions/HexExtension.cs b/OBD.NET/OBD.NET.Common/Extensions/HexExtension.cs deleted file mode 100644 index fa20476..0000000 --- a/OBD.NET/OBD.NET.Common/Extensions/HexExtension.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Logging/IOBDLogger.cs b/OBD.NET/OBD.NET.Common/Logging/IOBDLogger.cs deleted file mode 100644 index c0b3021..0000000 --- a/OBD.NET/OBD.NET.Common/Logging/IOBDLogger.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace OBD.NET.Common.Logging -{ - public interface IOBDLogger - { - void WriteLine(string text, OBDLogLevel level); - } -} diff --git a/OBD.NET/OBD.NET.Common/Logging/OBDDebugLogger.cs b/OBD.NET/OBD.NET.Common/Logging/OBDDebugLogger.cs deleted file mode 100644 index 14cc316..0000000 --- a/OBD.NET/OBD.NET.Common/Logging/OBDDebugLogger.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Diagnostics; - -namespace OBD.NET.Common.Logging -{ - /// - /// Simple debug logger - /// - /// - 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 - } -} diff --git a/OBD.NET/OBD.NET.Common/Logging/OBDLogLevel.cs b/OBD.NET/OBD.NET.Common/Logging/OBDLogLevel.cs deleted file mode 100644 index 65b118a..0000000 --- a/OBD.NET/OBD.NET.Common/Logging/OBDLogLevel.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace OBD.NET.Common.Logging -{ - public enum OBDLogLevel - { - None, - Error, - Verbose, - Debug - } -} diff --git a/OBD.NET/OBD.NET.Common/OBD.NET.Common.csproj b/OBD.NET/OBD.NET.Common/OBD.NET.Common.csproj deleted file mode 100644 index 1e746f1..0000000 --- a/OBD.NET/OBD.NET.Common/OBD.NET.Common.csproj +++ /dev/null @@ -1,50 +0,0 @@ - - - - net5.0;net6.0;netstandard1.4 - Darth Affe / Roman Lumetsberger - - - OBD.NET - C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter - 1.2.0 - - True - Github - https://github.com/DarthAffe/OBD.NET - https://github.com/DarthAffe/OBD.NET - GPL-2.0-only - - ..\bin\ - true - True - True - snupkg - - - - NET5_0;NETFULL - - - - NET6_0;NETFULL - - - - NETCORE;NETSTANDARD;NETSTANDARD1_4 - - - - $(DefineConstants);TRACE;DEBUG - true - full - false - - - - portable - true - $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE - - - \ No newline at end of file diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/AuxiliaryInputStatus.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/AuxiliaryInputStatus.cs deleted file mode 100644 index 8966ce3..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/AuxiliaryInputStatus.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/CalculatedEngineLoad.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/CalculatedEngineLoad.cs deleted file mode 100644 index f9f0040..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/CalculatedEngineLoad.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/CommandedSecondaryAirStatus.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/CommandedSecondaryAirStatus.cs deleted file mode 100644 index 594d989..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/CommandedSecondaryAirStatus.cs +++ /dev/null @@ -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 - - /// - /// https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_12 - /// - [Flags] - public enum CommandedSecondaryAirStatusValue - { - Missing = 0, - Upstream = 1 << 0, - DownstreamOfCatalyticConverter = 1 << 1, - FromTheOutsideAtmosphereOrOff = 1 << 2, - PumpCommandedOnForDiagnostics = 1 << 3 - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineCoolantTemperature.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineCoolantTemperature.cs deleted file mode 100644 index 19ed723..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineCoolantTemperature.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineRPM.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineRPM.cs deleted file mode 100644 index 6d6f001..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/EngineRPM.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelPressure.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelPressure.cs deleted file mode 100644 index bc9df51..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelPressure.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelSystemStatus.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelSystemStatus.cs deleted file mode 100644 index 47cb0a2..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/FuelSystemStatus.cs +++ /dev/null @@ -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 - - /// - /// https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_03 - /// - [Flags] - public enum FuelSystemStatusValue - { - Missing = 0, - OpenLoopDueToInsufficientEngineTemperature = 1 << 0, - ClosedLoopUsingOxygenSensorFeedbackToDetermineFuelMix = 1 << 1, - OpenLoopDueToEngineLoadOrFuelCutDueToDeceleration = 1 << 2, - OpenLoopDueToSystemFailure = 1 << 3, - ClosedLoopUsingAtLeastOneOxygenSensorButThereIsAFaultInTheFeedbackSystem = 1 << 4 - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeAirTemperature.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeAirTemperature.cs deleted file mode 100644 index 4c1be46..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeAirTemperature.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs deleted file mode 100644 index 5b1661c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank1.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank1.cs deleted file mode 100644 index 78a75fa..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank1.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank2.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank2.cs deleted file mode 100644 index 7ae0a99..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/LongTermFuelTrimBank2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/MAFAirFlowRate.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/MAFAirFlowRate.cs deleted file mode 100644 index 7b786f0..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/MAFAirFlowRate.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OBDStandards.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OBDStandards.cs deleted file mode 100644 index 9003267..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OBDStandards.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor1FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor1FuelTrim.cs deleted file mode 100644 index 84ac8d6..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor1FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor2FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor2FuelTrim.cs deleted file mode 100644 index 7cd0b9c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor2FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor3FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor3FuelTrim.cs deleted file mode 100644 index 0ef6b01..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor3FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor4FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor4FuelTrim.cs deleted file mode 100644 index 5698294..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor4FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor5FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor5FuelTrim.cs deleted file mode 100644 index b06cb85..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor5FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor6FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor6FuelTrim.cs deleted file mode 100644 index 8eb94da..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor6FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor7FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor7FuelTrim.cs deleted file mode 100644 index 4f6b331..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor7FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor8FuelTrim.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor8FuelTrim.cs deleted file mode 100644 index b6f81a3..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensor8FuelTrim.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorPresent.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorPresent.cs deleted file mode 100644 index 2040f0f..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorPresent.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorsPresent2.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorsPresent2.cs deleted file mode 100644 index 7384396..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/OxygenSensorsPresent2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/PidsSupported01_20.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/PidsSupported01_20.cs deleted file mode 100644 index 18794e2..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/PidsSupported01_20.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/RunTimeSinceEngineStart.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/RunTimeSinceEngineStart.cs deleted file mode 100644 index 672397c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/RunTimeSinceEngineStart.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank1.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank1.cs deleted file mode 100644 index 762bbca..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank1.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank2.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank2.cs deleted file mode 100644 index 93bdb47..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/ShortTermFuelTrimBank2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/ThrottlePosition.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/ThrottlePosition.cs deleted file mode 100644 index b91e42c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/ThrottlePosition.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/TimingAdvance.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/TimingAdvance.cs deleted file mode 100644 index 3251cf4..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/TimingAdvance.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/00-1F/VehicleSpeed.cs b/OBD.NET/OBD.NET.Common/OBDData/00-1F/VehicleSpeed.cs deleted file mode 100644 index 810fc14..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/00-1F/VehicleSpeed.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/AbsoluteBarometricPressure.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/AbsoluteBarometricPressure.cs deleted file mode 100644 index 17c2ae2..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/AbsoluteBarometricPressure.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs deleted file mode 100644 index cdc6742..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs deleted file mode 100644 index da9c025..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs deleted file mode 100644 index 9be01e6..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs deleted file mode 100644 index ab2b52c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEGR.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEGR.cs deleted file mode 100644 index 91b25df..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEGR.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEvaporativePurge.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEvaporativePurge.cs deleted file mode 100644 index 9c46126..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/CommandedEvaporativePurge.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs deleted file mode 100644 index 0dc89ed..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledWithMILOn.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledWithMILOn.cs deleted file mode 100644 index 78b6b6b..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/DistanceTraveledWithMILOn.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/EGRError.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/EGRError.cs deleted file mode 100644 index 48650ea..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/EGRError.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/EvapSystemVaporPressure.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/EvapSystemVaporPressure.cs deleted file mode 100644 index 8e27f14..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/EvapSystemVaporPressure.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailGaugePressure.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailGaugePressure.cs deleted file mode 100644 index 1f1f55b..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailGaugePressure.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailPressure.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailPressure.cs deleted file mode 100644 index 94a5f78..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelRailPressure.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelTankLevelInput.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelTankLevelInput.cs deleted file mode 100644 index d3d3e10..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/FuelTankLevelInput.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir.cs deleted file mode 100644 index ca35572..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir2.cs deleted file mode 100644 index 7ed9763..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor1FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir.cs deleted file mode 100644 index 5c7db30..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir2.cs deleted file mode 100644 index a90d71b..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor2FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir.cs deleted file mode 100644 index 71f912f..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir2.cs deleted file mode 100644 index 89c8f6e..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor3FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir.cs deleted file mode 100644 index 480c3b1..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir2.cs deleted file mode 100644 index 30ed5cc..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor4FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir.cs deleted file mode 100644 index fbca3ff..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir2.cs deleted file mode 100644 index e18c858..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor5FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir.cs deleted file mode 100644 index 7863808..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir2.cs deleted file mode 100644 index 597a485..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor6FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir.cs deleted file mode 100644 index ee68813..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir2.cs deleted file mode 100644 index 753e7d8..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor7FuelAir2.cs +++ /dev/null @@ -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 - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir.cs deleted file mode 100644 index 05d845b..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir.cs +++ /dev/null @@ -1,28 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class OxygenSensor8FuelAir : 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 OxygenSensor8FuelAir() - : base(0x2B, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => FuelAirEquivalenceRatio.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir2.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir2.cs deleted file mode 100644 index 23871d5..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/OxygenSensor8FuelAir2.cs +++ /dev/null @@ -1,28 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class OxygenSensor8FuelAir2 : 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 OxygenSensor8FuelAir2() - : base(0x3B, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => FuelAirEquivalenceRatio.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/PidsSupported21_40.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/PidsSupported21_40.cs deleted file mode 100644 index cc72b10..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/PidsSupported21_40.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class PidsSupported21_40 : AbstractPidsSupported - { - #region Constructors - - public PidsSupported21_40() - : base(0x20, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Join(",", SupportedPids); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/20-3F/WarmUpsSinceCodesCleared.cs b/OBD.NET/OBD.NET.Common/OBDData/20-3F/WarmUpsSinceCodesCleared.cs deleted file mode 100644 index 2f02ab7..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/20-3F/WarmUpsSinceCodesCleared.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class WarmUpsSinceCodesCleared : AbstractOBDData - { - #region Properties & Fields - - public Count WarmUps => new Count(A, 0, 255); - - #endregion - - #region Constructors - - public WarmUpsSinceCodesCleared() - : base(0x30, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => WarmUps.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs deleted file mode 100644 index 42ea3d5..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AbsoluteEvapSystemVaporPressure : AbstractOBDData - { - #region Properties & Fields - - public Kilopascal Pressure => new Kilopascal(((256 * A) + B) / 200.0, 0, 327.675); - - #endregion - - #region Constructors - - public AbsoluteEvapSystemVaporPressure() - : base(0x53, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Pressure.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteLoadValue.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteLoadValue.cs deleted file mode 100644 index a3b08b1..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteLoadValue.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AbsoluteLoadValue : AbstractOBDData - { - #region Properties & Fields - - public Percent Load => new Percent(((256 * A) + B) / 2.55, 0, 25700); - - #endregion - - #region Constructors - - public AbsoluteLoadValue() - : base(0x43, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Load.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionB.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionB.cs deleted file mode 100644 index 3ab6fd9..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionB.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AbsoluteThrottlePositionB : AbstractOBDData - { - #region Properties & Fields - - public Percent Position => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public AbsoluteThrottlePositionB() - : base(0x47, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Position.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionC.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionC.cs deleted file mode 100644 index bdaee63..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AbsoluteThrottlePositionC.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AbsoluteThrottlePositionC : AbstractOBDData - { - #region Properties & Fields - - public Percent Position => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public AbsoluteThrottlePositionC() - : base(0x48, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Position.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionD.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionD.cs deleted file mode 100644 index ddfc453..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionD.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AcceleratorPedalPositionD : AbstractOBDData - { - #region Properties & Fields - - public Percent Position => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public AcceleratorPedalPositionD() - : base(0x49, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Position.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionE.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionE.cs deleted file mode 100644 index 78f9450..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionE.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AcceleratorPedalPositionE : AbstractOBDData - { - #region Properties & Fields - - public Percent Position => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public AcceleratorPedalPositionE() - : base(0x4A, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Position.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionF.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionF.cs deleted file mode 100644 index 129055b..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AcceleratorPedalPositionF.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AcceleratorPedalPositionF : AbstractOBDData - { - #region Properties & Fields - - public Percent Position => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public AcceleratorPedalPositionF() - : base(0x4B, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Position.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AmbientAirTemperature.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/AmbientAirTemperature.cs deleted file mode 100644 index c3825e2..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/AmbientAirTemperature.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class AmbientAirTemperature : AbstractOBDData - { - #region Properties & Fields - - public DegreeCelsius Temperature => new DegreeCelsius(A - 40, -40, 215); - - #endregion - - #region Constructors - - public AmbientAirTemperature() - : base(0x46, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Temperature.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/CommandedThrottleActuator.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/CommandedThrottleActuator.cs deleted file mode 100644 index bf11754..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/CommandedThrottleActuator.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class CommandedThrottleActuator : AbstractOBDData - { - #region Properties & Fields - - public Percent Value => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public CommandedThrottleActuator() - : base(0x4C, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Value.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/ControlModuleVoltage.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/ControlModuleVoltage.cs deleted file mode 100644 index 0822f4b..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/ControlModuleVoltage.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class ControlModuleVoltage : AbstractOBDData - { - #region Properties & Fields - - public Volt Voltage => new Volt(((256 * A) + B) / 1000.0, 0, 65.535); - - #endregion - - #region Constructors - - public ControlModuleVoltage() - : base(0x42, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Voltage.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineFuelRate.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineFuelRate.cs deleted file mode 100644 index 5145805..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineFuelRate.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EngineFuelRate : AbstractOBDData - { - #region Properties & Fields - - public LitresPerHour FuelRate => new LitresPerHour(((256 * A) + B) / 20.0, 0, 3212.75); - - #endregion - - #region Constructors - - public EngineFuelRate() - : base(0x5E, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => FuelRate.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineOilTemperature.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineOilTemperature.cs deleted file mode 100644 index aab6641..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EngineOilTemperature.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EngineOilTemperature : AbstractOBDData - { - #region Properties & Fields - - public DegreeCelsius Temperature => new DegreeCelsius(A - 40, -40, 210); - - #endregion - - #region Constructors - - public EngineOilTemperature() - : base(0x5C, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Temperature.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EthanolFuel.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/EthanolFuel.cs deleted file mode 100644 index 6dfbf3e..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EthanolFuel.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EthanolFuel : AbstractOBDData - { - #region Properties & Fields - - public Percent Value => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public EthanolFuel() - : base(0x52, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Value.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EvapSystemVaporPressure2.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/EvapSystemVaporPressure2.cs deleted file mode 100644 index 9c362ef..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/EvapSystemVaporPressure2.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EvapSystemVaporPressure2 : AbstractOBDData - { - #region Properties & Fields - - public Pascal Pressure => new Pascal(((A * 256) + B) - 32767, -32767, 32768); - - #endregion - - #region Constructors - - public EvapSystemVaporPressure2() - : base(0x54, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Pressure.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs deleted file mode 100644 index 0046eb1..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class FuelAirCommandedEquivalenceRatio : AbstractOBDData - { - #region Properties & Fields - - public Ratio Ratio => new Ratio((2.0 / 65536.0) * ((256 * A) + B), 0, 2.0 - double.Epsilon); - - #endregion - - #region Constructors - - public FuelAirCommandedEquivalenceRatio() - : base(0x44, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Ratio.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelInjectionTiming.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelInjectionTiming.cs deleted file mode 100644 index 765b795..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelInjectionTiming.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class FuelInjectionTiming : AbstractOBDData - { - #region Properties & Fields - - public Degree Timing => new Degree((((256 * A) + B) / 128.0) - 210, -210, 301.992); - - #endregion - - #region Constructors - - public FuelInjectionTiming() - : base(0x5D, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Timing.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelRailAbsolutePressure.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelRailAbsolutePressure.cs deleted file mode 100644 index 500896d..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelRailAbsolutePressure.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class FuelRailAbsolutePressure : AbstractOBDData - { - #region Properties & Fields - - public Kilopascal Pressure => new Kilopascal(10 * ((256 * A) + B), 0, 655350); - - #endregion - - #region Constructors - - public FuelRailAbsolutePressure() - : base(0x59, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Pressure.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelType.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelType.cs deleted file mode 100644 index ab221e9..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/FuelType.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class FuelType : AbstractOBDData - { - #region Properties & Fields - - public FuelTypeValue Type => (FuelTypeValue)A; - - #endregion - - #region Constructors - - public FuelType() - : base(0x51, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Type.ToString(); - - #endregion - - #region Enum - - public enum FuelTypeValue - { - NotAvailable = 0, - Gasoline = 1, - Methanol = 2, - Ethanol = 3, - Diesel = 4, - LPG = 5, - CNG = 6, - Propane = 7, - Electric = 8, - BifuelGasoline = 9, - BifuelMethanol = 10, - BifuelEthanol = 11, - BifuelLPG = 12, - BifuelCNG = 13, - BifuelPropane = 14, - BifuelElectricity = 15, - BifuelElectricAndCombustionEngine = 16, - HybridGasoline = 17, - HybridEthanol = 18, - HybridDiesel = 19, - HybridElectric = 20, - HybridElectricAndCombustionEngine = 21, - HybridRegenerative = 22, - BifuelDiesel = 23 - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/HybridBatteryPackRemainingLife.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/HybridBatteryPackRemainingLife.cs deleted file mode 100644 index 37bcccd..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/HybridBatteryPackRemainingLife.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class HybridBatteryPackRemainingLife : AbstractOBDData - { - #region Properties & Fields - - public Percent RemainingLife => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public HybridBatteryPackRemainingLife() - : base(0x5B, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => RemainingLife.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs deleted file mode 100644 index b61ecaa..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs +++ /dev/null @@ -1,28 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class LongtTermSecondaryOxygenSensorTrimBank13 : AbstractOBDData - { - #region Properties & Fields - - public Percent Bank1 => new Percent((A / 1.28) - 100, -100, 99.2); - public Percent Bank3 => new Percent((B / 1.28) - 100, -100, 99.2); - - #endregion - - #region Constructors - - public LongtTermSecondaryOxygenSensorTrimBank13() - : base(0x56, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Bank1.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs deleted file mode 100644 index e9e2657..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs +++ /dev/null @@ -1,28 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class LongTermSecondaryOxygenSensorTrimBank24 : AbstractOBDData - { - #region Properties & Fields - - public Percent Bank2 => new Percent((A / 1.28) - 100, -100, 99.2); - public Percent Bank4 => new Percent((B / 1.28) - 100, -100, 99.2); - - #endregion - - #region Constructors - - public LongTermSecondaryOxygenSensorTrimBank24() - : base(0x58, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Bank2.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValueForAirFlowRate.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValueForAirFlowRate.cs deleted file mode 100644 index b4cbb53..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValueForAirFlowRate.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class MaximumValueForAirFlowRate : AbstractOBDData - { - #region Properties & Fields - - public GramPerSec Value => new GramPerSec(A * 10, 0, 2550); - - #endregion - - #region Constructors - - public MaximumValueForAirFlowRate() - : base(0x50, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => Value.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValues.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValues.cs deleted file mode 100644 index 5cca8d2..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/MaximumValues.cs +++ /dev/null @@ -1,30 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class MaximumValues : AbstractOBDData - { - #region Properties & Fields - - public Ratio FuelAirEquivalenceRatio => new Ratio(A, 0, 255); - public Volt OxygenSensorVoltage => new Volt(B, 0, 255); - public Milliampere OxygenSensorCurrent => new Milliampere(C, 0, 255); - public Kilopascal IntakeManifoldAbsolutePressure => new Kilopascal(D * 10, 0, 2550); - - #endregion - - #region Constructors - - public MaximumValues() - : base(0x4F, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => FuelAirEquivalenceRatio.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/MonitorStatusThisDriveCycle.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/MonitorStatusThisDriveCycle.cs deleted file mode 100644 index 562a7e2..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/MonitorStatusThisDriveCycle.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class MonitorStatusThisDriveCycle : AbstractOBDData - { - #region Properties & Fields - - public bool IsComponentsTestAvailable => (B & (1 << 3)) != 0; - public bool IsComponentsTestComplete => (B & (1 << 7)) == 0; - - public bool IsFuelSystemTestAvailable => (B & (1 << 1)) != 0; - public bool IsFuelSystemTestComplete => (B & (1 << 5)) == 0; - - public bool IsMisfireTestAvailable => (B & (1 << 0)) != 0; - public bool IsMisfireTestComplete => (B & (1 << 4)) == 0; - - public bool IsEGRSystemTestAvailable => (C & (1 << 7)) != 0; - public bool IsEGRSystemTestComplete => (D & (1 << 7)) == 0; - - public bool IsOxygenSensorHeaterTestAvailable => (C & (1 << 6)) != 0; - public bool IsOxygenSensorHeaterTestComplete => (D & (1 << 6)) == 0; - - public bool IsOxygenSensorTestAvailable => (C & (1 << 5)) != 0; - public bool IsOxygenSensorTestComplete => (D & (1 << 5)) == 0; - - public bool IsACRefrigerantTestAvailable => (C & (1 << 4)) != 0; - public bool IsACRefrigerantTestComplete => (D & (1 << 4)) == 0; - - public bool IsSecondaryAirSystemTestAvailable => (C & (1 << 3)) != 0; - public bool IsSecondaryAirSystemTestComplete => (D & (1 << 3)) == 0; - - public bool IsEvaporativeSystemTestAvailable => (C & (1 << 2)) != 0; - public bool IsEvaporativeSystemTestComplete => (D & (1 << 2)) == 0; - - public bool IsHeatedCatalystTestAvailable => (C & (1 << 1)) != 0; - public bool IsHeatedCatalystTestComplete => (D & (1 << 1)) == 0; - - public bool IsCatalystAvailable => (C & (1 << 0)) != 0; - public bool IsCatalystComplete => (D & (1 << 0)) == 0; - - #endregion - - #region Constructors - - public MonitorStatusThisDriveCycle() - : base(0x41, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Empty; - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/PidsSupported41_60.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/PidsSupported41_60.cs deleted file mode 100644 index 9f935a9..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/PidsSupported41_60.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class PidsSupported41_60 : AbstractPidsSupported - { - #region Constructors - - public PidsSupported41_60() - : base(0x40, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Join(",", SupportedPids); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs deleted file mode 100644 index 3901296..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class RelativeAcceleratorPedalPosition : AbstractOBDData - { - #region Properties & Fields - - public Percent PedalPosition => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public RelativeAcceleratorPedalPosition() - : base(0x5A, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => PedalPosition.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeThrottlePosition.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeThrottlePosition.cs deleted file mode 100644 index 25d2142..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/RelativeThrottlePosition.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class RelativeThrottlePosition : AbstractOBDData - { - #region Properties & Fields - - public Percent Position => new Percent(A / 2.55, 0, 100); - - #endregion - - #region Constructors - - public RelativeThrottlePosition() - : base(0x45, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Position.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs deleted file mode 100644 index d6d3e4a..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs +++ /dev/null @@ -1,28 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class ShortTermSecondaryOxygenSensorTrimBank13 : AbstractOBDData - { - #region Properties & Fields - - public Percent Bank1 => new Percent((A / 1.28) - 100, -100, 99.2); - public Percent Bank3 => new Percent((B / 1.28) - 100, -100, 99.2); - - #endregion - - #region Constructors - - public ShortTermSecondaryOxygenSensorTrimBank13() - : base(0x55, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Bank1.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs deleted file mode 100644 index bff7c4d..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs +++ /dev/null @@ -1,28 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class ShortTermSecondaryOxygenSensorTrimBank24 : AbstractOBDData - { - #region Properties & Fields - - public Percent Bank2 => new Percent((A / 1.28) - 100, -100, 99.2); - public Percent Bank4 => new Percent((B / 1.28) - 100, -100, 99.2); - - #endregion - - #region Constructors - - public ShortTermSecondaryOxygenSensorTrimBank24() - : base(0x57, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Bank2.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeRunWithMILOn.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeRunWithMILOn.cs deleted file mode 100644 index 9934bbf..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeRunWithMILOn.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class TimeRunWithMILOn : AbstractOBDData - { - #region Properties & Fields - - public Minute Time => new Minute((256 * A) + B, 0, 65535); - - #endregion - - #region Constructors - - public TimeRunWithMILOn() - : base(0x4D, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Time.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs b/OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs deleted file mode 100644 index 81c80e6..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class TimeSinceTroubleCodesCleared : AbstractOBDData - { - #region Properties & Fields - - public Minute Time => new Minute((256 * A) + B, 0, 65535); - - #endregion - - #region Constructors - - public TimeSinceTroubleCodesCleared() - : base(0x4E, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Time.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/ActualEnginePercentTorque.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/ActualEnginePercentTorque.cs deleted file mode 100644 index 95b6267..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/ActualEnginePercentTorque.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class ActualEnginePercentTorque : AbstractOBDData - { - #region Properties & Fields - - public Percent Torque => new Percent(A - 125, -125, 125); - - #endregion - - #region Constructors - - public ActualEnginePercentTorque() - : base(0x62, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Torque.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/DriversDemandEnginePercentTorque.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/DriversDemandEnginePercentTorque.cs deleted file mode 100644 index bff8f3c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/DriversDemandEnginePercentTorque.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class DriversDemandEnginePercentTorque : AbstractOBDData - { - #region Properties & Fields - - public Percent Torque => new Percent(A - 125, -125, 125); - - #endregion - - #region Constructors - - public DriversDemandEnginePercentTorque() - : base(0x61, 1) - { } - - #endregion - - #region Methods - - public override string ToString() => Torque.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineCoolantTemperatureSensor.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineCoolantTemperatureSensor.cs deleted file mode 100644 index 0dc335c..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineCoolantTemperatureSensor.cs +++ /dev/null @@ -1,29 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EngineCoolantTemperatureSensor : AbstractOBDData - { - #region Properties & Fields - - public int SensorsSupported => A; - public DegreeCelsius Sensor1 => new DegreeCelsius(B - 40, -40, 215); - public DegreeCelsius Sensor2 => new DegreeCelsius(C - 40, -40, 215); - - #endregion - - #region Constructors - - public EngineCoolantTemperatureSensor() - : base(0x67, 3) - { } - - #endregion - - #region Methods - - public override string ToString() => Sensor1.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/EnginePercentTorqueData.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/EnginePercentTorqueData.cs deleted file mode 100644 index 73f751d..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/EnginePercentTorqueData.cs +++ /dev/null @@ -1,31 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EnginePercentTorqueData : AbstractOBDData - { - #region Properties & Fields - - public Percent Idle => new Percent(A - 125, -125, 125); - public Percent EnginePoint1 => new Percent(B - 125, -125, 125); - public Percent EnginePoint2 => new Percent(C - 125, -125, 125); - public Percent EnginePoint3 => new Percent(D - 125, -125, 125); - public Percent EnginePoint4 => new Percent(E - 125, -125, 125); - - #endregion - - #region Constructors - - public EnginePercentTorqueData() - : base(0x64, 5) - { } - - #endregion - - #region Methods - - public override string ToString() => Idle.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineReferenceTorque.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineReferenceTorque.cs deleted file mode 100644 index 71d3204..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/EngineReferenceTorque.cs +++ /dev/null @@ -1,27 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class EngineReferenceTorque : AbstractOBDData - { - #region Properties & Fields - - public NewtonMetre Torque => new NewtonMetre((256 * A) + B, 0, 65535); - - #endregion - - #region Constructors - - public EngineReferenceTorque() - : base(0x63, 2) - { } - - #endregion - - #region Methods - - public override string ToString() => Torque.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/IntakeAirTemperatureSensor.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/IntakeAirTemperatureSensor.cs deleted file mode 100644 index 795fdfc..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/IntakeAirTemperatureSensor.cs +++ /dev/null @@ -1,33 +0,0 @@ -using OBD.NET.Common.DataTypes; - -namespace OBD.NET.Common.OBDData -{ - public class IntakeAirTemperatureSensor : AbstractOBDData - { - #region Properties & Fields - - public int SensorsSupported => A; - public DegreeCelsius Bank1Sensor1 => new DegreeCelsius(B - 40, -40, 215); - public DegreeCelsius Bank1Sensor2 => new DegreeCelsius(C - 40, -40, 215); - public DegreeCelsius Bank1Sensor3 => new DegreeCelsius(D - 40, -40, 215); - public DegreeCelsius Bank2Sensor1 => new DegreeCelsius(E - 40, -40, 215); - public DegreeCelsius Bank2Sensor2 => new DegreeCelsius(RawData[5] - 40, -40, 215); - public DegreeCelsius Bank2Sensor3 => new DegreeCelsius(RawData[6] - 40, -40, 215); - - #endregion - - #region Constructors - - public IntakeAirTemperatureSensor() - : base(0x68, 7) - { } - - #endregion - - #region Methods - - public override string ToString() => Bank1Sensor1.ToString(); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/60-7F/PidsSupported61_80.cs b/OBD.NET/OBD.NET.Common/OBDData/60-7F/PidsSupported61_80.cs deleted file mode 100644 index a946df4..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/60-7F/PidsSupported61_80.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class PidsSupported61_80 : AbstractPidsSupported - { - #region Constructors - - public PidsSupported61_80() - : base(0x60, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Join(",", SupportedPids); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/80-9F/PidsSupported81_A0.cs b/OBD.NET/OBD.NET.Common/OBDData/80-9F/PidsSupported81_A0.cs deleted file mode 100644 index cb5c658..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/80-9F/PidsSupported81_A0.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class PidsSupported81_A0 : AbstractPidsSupported - { - #region Constructors - - public PidsSupported81_A0() - : base(0x80, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Join(",", SupportedPids); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/A0-BF/PidsSupportedA1_C0.cs b/OBD.NET/OBD.NET.Common/OBDData/A0-BF/PidsSupportedA1_C0.cs deleted file mode 100644 index 03dbbed..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/A0-BF/PidsSupportedA1_C0.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class PidsSupportedA1_C0 : AbstractPidsSupported - { - #region Constructors - - public PidsSupportedA1_C0() - : base(0xA0, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Join(",", SupportedPids); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/AbstractOBDData.cs b/OBD.NET/OBD.NET.Common/OBDData/AbstractOBDData.cs deleted file mode 100644 index 6fc3abd..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/AbstractOBDData.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using OBD.NET.Common.Extensions; - -namespace OBD.NET.Common.OBDData -{ - public abstract class AbstractOBDData : IOBDData - { - #region Properties & Fields - - public byte PID { get; } - private readonly int _length; - - private byte[] _rawData; - public byte[] RawData - { - get => _rawData; - set - { - if (value.Length != _length) - throw new ArgumentException("The provided raw-data is not valid", nameof(value)); - - _rawData = value; - } - } - - public bool IsValid => RawData.Length == _length; - - protected byte A => RawData.Length > 0 ? RawData[0] : default(byte); - protected byte B => RawData.Length > 1 ? RawData[1] : default(byte); - protected byte C => RawData.Length > 2 ? RawData[2] : default(byte); - protected byte D => RawData.Length > 3 ? RawData[3] : default(byte); - protected byte E => RawData.Length > 4 ? RawData[4] : default(byte); - - #endregion - - #region Constructors - - protected AbstractOBDData(byte pid, int length) - { - this.PID = pid; - this._length = length; - } - - protected AbstractOBDData(byte pid, int length, byte[] rawData) - : this(pid, length) - { - this.RawData = rawData; - } - - #endregion - - #region Methods - - public void Load(string data) - { - try - { - if (((data.Length % 2) != 0) || ((data.Length / 2) < _length)) - throw new ArgumentException("The provided data is not valid", nameof(data)); - - _rawData = new byte[_length]; - for (int i = 0; i < _length; ++i) - _rawData[i] = (byte)((data[i << 1].GetHexVal() << 4) + (data[(i << 1) + 1].GetHexVal())); - } - catch - { - _rawData = new byte[0]; - throw; - } - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/AbstractPidsSupported.cs b/OBD.NET/OBD.NET.Common/OBDData/AbstractPidsSupported.cs deleted file mode 100644 index 9ecd36a..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/AbstractPidsSupported.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Collections; -using System.Collections.Generic; - -namespace OBD.NET.Common.OBDData -{ - public abstract class AbstractPidsSupported : AbstractOBDData - { - #region Properties & Fields - - public int[] SupportedPids - { - get - { - List supportedPids = new List(); - BitArray bitArray = new BitArray(new[] { D, C, B, A }); - - for (int i = 0x01; i <= 0x20; i++) - if (bitArray.Get(bitArray.Length - i)) - supportedPids.Add(PID + i); - - return supportedPids.ToArray(); - } - } - - #endregion - - #region Constructors - - public AbstractPidsSupported(byte pid, int length) : base(pid, length) - { } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/C0-DF/PidsSupportedC1_E0.cs b/OBD.NET/OBD.NET.Common/OBDData/C0-DF/PidsSupportedC1_E0.cs deleted file mode 100644 index 0e92608..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/C0-DF/PidsSupportedC1_E0.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public class PidsSupportedC1_E0 : AbstractPidsSupported - { - #region Constructors - - public PidsSupportedC1_E0() - : base(0xC0, 4) - { } - - #endregion - - #region Methods - - public override string ToString() => string.Join(",", SupportedPids); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Common/OBDData/IOBDData.cs b/OBD.NET/OBD.NET.Common/OBDData/IOBDData.cs deleted file mode 100644 index 2d2a10d..0000000 --- a/OBD.NET/OBD.NET.Common/OBDData/IOBDData.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace OBD.NET.Common.OBDData -{ - public interface IOBDData - { - byte PID { get; } - - void Load(string data); - } -} diff --git a/OBD.NET/OBD.NET.Common/Util/AsyncManulResetEvent.cs b/OBD.NET/OBD.NET.Common/Util/AsyncManulResetEvent.cs deleted file mode 100644 index acbf9e9..0000000 --- a/OBD.NET/OBD.NET.Common/Util/AsyncManulResetEvent.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace OBD.NET.Common.Util -{ - /// - /// Notifies one or more waiting awaiters that an event has occurred - /// - public class AsyncManualResetEvent - { - #region Properties & Fields - - private volatile TaskCompletionSource _tcs = new TaskCompletionSource(); - - #endregion - - #region Methods - - /// - /// Waits the async. - /// - /// - public Task WaitAsync() => _tcs.Task; - - //public void Set() { m_tcs.TrySetResult(true); } - /// - /// Sets the state of the event to signaled, allowing one or more waiting awaiters to proceed. - /// - public void Set() - { - TaskCompletionSource tcs = _tcs; - Task.Factory.StartNew(s => ((TaskCompletionSource)s).TrySetResult(true), - tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default); - - tcs.Task.Wait(); - } - - /// - /// Sets the state of the event to nonsignaled, causing awaiters to block. - /// - public void Reset() - { - while (true) - { - TaskCompletionSource tcs = _tcs; - if (!tcs.Task.IsCompleted || - (Interlocked.CompareExchange(ref _tcs, new TaskCompletionSource(), tcs) == tcs)) - return; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/OBD.NET/OBD.NET.ConsoleClient/App.config b/OBD.NET/OBD.NET.ConsoleClient/App.config deleted file mode 100644 index bae5d6d..0000000 --- a/OBD.NET/OBD.NET.ConsoleClient/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/OBD.NET/OBD.NET.ConsoleClient/OBD.NET.ConsoleClient.csproj b/OBD.NET/OBD.NET.ConsoleClient/OBD.NET.ConsoleClient.csproj deleted file mode 100644 index 6c8adc4..0000000 --- a/OBD.NET/OBD.NET.ConsoleClient/OBD.NET.ConsoleClient.csproj +++ /dev/null @@ -1,63 +0,0 @@ - - - - - Debug - AnyCPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC} - Exe - ODB.NET.ConsoleClient - ODB.NET.ConsoleClient - v4.6.1 - 512 - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31} - OBD.NET.Common - - - {14CB98E1-95DE-4923-8896-FDF5171AA49E} - OBD.NET.Desktop - - - - \ No newline at end of file diff --git a/OBD.NET/OBD.NET.ConsoleClient/Program.cs b/OBD.NET/OBD.NET.ConsoleClient/Program.cs deleted file mode 100644 index a76b93a..0000000 --- a/OBD.NET/OBD.NET.ConsoleClient/Program.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Threading; -using System.Threading.Tasks; -using OBD.NET.Common.Devices; -using OBD.NET.Common.Extensions; -using OBD.NET.Common.Logging; -using OBD.NET.Common.OBDData; -using OBD.NET.Desktop.Communication; -using OBD.NET.Desktop.Logging; - -namespace OBD.NET.ConsoleClient -{ - public class Program - { - public static void Main(string[] args) - { - if (args.Length < 1) - { - Console.WriteLine("Parameter ComPort needed."); - return; - } - - string comPort = args[0]; - - using (SerialConnection connection = new SerialConnection(comPort)) - using (ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug))) - { - dev.SubscribeDataReceived((sender, data) => Console.WriteLine("EngineRPM: " + data.Data.Rpm)); - dev.SubscribeDataReceived((sender, data) => Console.WriteLine("VehicleSpeed: " + data.Data.Speed)); - - dev.SubscribeDataReceived((sender, data) => Console.WriteLine($"PID {data.Data.PID.ToHexString()}: {data.Data}")); - - dev.Initialize(); - dev.RequestData(); - for (int i = 0; i < 5; i++) - { - dev.RequestData(); - dev.RequestData(); - Thread.Sleep(1000); - } - } - Console.ReadLine(); - - //Async example - //MainAsync(comPort).Wait(); - - //Console.ReadLine(); - } - - /// - /// Async example using new RequestDataAsync - /// - /// The COM port. - /// - public static async Task MainAsync(string comPort) - { - using (SerialConnection connection = new SerialConnection(comPort)) - using (ELM327 dev = new ELM327(connection, new OBDConsoleLogger(OBDLogLevel.Debug))) - { - dev.Initialize(); - EngineRPM data = await dev.RequestDataAsync(); - Console.WriteLine("Data: " + data.Rpm); - data = await dev.RequestDataAsync(); - Console.WriteLine("Data: " + data.Rpm); - VehicleSpeed data2 = await dev.RequestDataAsync(); - Console.WriteLine("Data: " + data2.Speed); - data = await dev.RequestDataAsync(); - Console.WriteLine("Data: " + data.Rpm); - } - } - } -} diff --git a/OBD.NET/OBD.NET.ConsoleClient/Properties/AssemblyInfo.cs b/OBD.NET/OBD.NET.ConsoleClient/Properties/AssemblyInfo.cs deleted file mode 100644 index 8cabffc..0000000 --- a/OBD.NET/OBD.NET.ConsoleClient/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OBD.NET.ConsoleClient")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OBD.NET.ConsoleClient")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8f8ec5d5-94bd-47cf-9714-ca8c0198bddc")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OBD.NET/OBD.NET.Desktop/Communication/EnhancedSerialPort.cs b/OBD.NET/OBD.NET.Desktop/Communication/EnhancedSerialPort.cs deleted file mode 100644 index af5dc8a..0000000 --- a/OBD.NET/OBD.NET.Desktop/Communication/EnhancedSerialPort.cs +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2013 Antanas Veiverys www.veiverys.com -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.ComponentModel; -using System.IO; -using System.IO.Ports; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Threading; - -// Source: http://antanas.veiverys.com/mono-serialport-datareceived-event-workaround-using-a-derived-class/ -namespace OBD.NET.Desktop.Communication -{ - [DesignerCategory("Code")] - public class EnhancedSerialPort : SerialPort - { - #region Properties & Fields - - // private member access via reflection - private int _fd; - private FieldInfo _disposedFieldInfo; - private object _dataReceived; - private Thread _thread; - - #endregion - - #region DLLImports - - [DllImport("MonoPosixHelper", SetLastError = true)] - private static extern bool poll_serial(int fd, out int error, int timeout); - - [DllImport("libc")] - private static extern IntPtr strerror(int errnum); - - #endregion - - #region Constructors - - public EnhancedSerialPort() - : base() - { } - - public EnhancedSerialPort(IContainer container) - : base(container) - { } - - public EnhancedSerialPort(string portName) - : base(portName) - { } - - public EnhancedSerialPort(string portName, int baudRate) - : base(portName, baudRate) - { } - - public EnhancedSerialPort(string portName, int baudRate, Parity parity) - : base(portName, baudRate, parity) - { } - - public EnhancedSerialPort(string portName, int baudRate, Parity parity, int dataBits) - : base(portName, baudRate, parity, dataBits) - { } - - public EnhancedSerialPort(string portName, int baudRate, Parity parity, int dataBits, StopBits stopBits) - : base(portName, baudRate, parity, dataBits, stopBits) - { } - - #endregion - - #region Methods - - public new void Open() - { - base.Open(); - - if (!IsWindows) - { - FieldInfo fieldInfo = BaseStream.GetType().GetField("fd", BindingFlags.Instance | BindingFlags.NonPublic); - if (fieldInfo == null) throw new NotSupportedException("Unable to initialize SerialPort - 'fd'-field is missing."); - _fd = (int)fieldInfo.GetValue(BaseStream); - - _disposedFieldInfo = BaseStream.GetType().GetField("disposed", BindingFlags.Instance | BindingFlags.NonPublic); - if (_disposedFieldInfo == null) throw new NotSupportedException("Unable to initialize SerialPort - 'disposed'-field is missing."); - - fieldInfo = typeof(SerialPort).GetField("data_received", BindingFlags.Instance | BindingFlags.NonPublic); - if (fieldInfo == null) throw new NotSupportedException("Unable to initialize SerialPort - 'data_received'-field is missing."); - _dataReceived = fieldInfo.GetValue(this); - - _thread = new Thread(EventThreadFunction); - _thread.Start(); - } - } - - private static bool IsWindows - { - get - { - PlatformID id = Environment.OSVersion.Platform; - return (id == PlatformID.Win32Windows) || (id == PlatformID.Win32NT); // WinCE not supported - } - } - - private void EventThreadFunction() - { - do - { - try - { - Stream stream = BaseStream; - if (stream == null) - return; - - if (Poll(stream, ReadTimeout)) - OnDataReceived(null); - } - catch - { - return; - } - } while (IsOpen); - } - - private void OnDataReceived(SerialDataReceivedEventArgs args) - { - SerialDataReceivedEventHandler handler = Events[_dataReceived] as SerialDataReceivedEventHandler; - handler?.Invoke(this, args); - } - - private bool Poll(Stream stream, int timeout) - { - CheckDisposed(stream); - if (IsOpen == false) - throw new Exception("port is closed"); - int error; - - bool pollResult = poll_serial(_fd, out error, ReadTimeout); - if (error == -1) - ThrowIOException(); - - return pollResult; - } - - private static void ThrowIOException() - { - int errnum = Marshal.GetLastWin32Error(); - string errorMessage = Marshal.PtrToStringAnsi(strerror(errnum)); - - throw new IOException(errorMessage); - } - - private void CheckDisposed(Stream stream) - { - bool disposed = (bool)_disposedFieldInfo.GetValue(stream); - if (disposed) - throw new ObjectDisposedException(stream.GetType().FullName); - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Desktop/Communication/SerialConnection.cs b/OBD.NET/OBD.NET.Desktop/Communication/SerialConnection.cs deleted file mode 100644 index 2cb622d..0000000 --- a/OBD.NET/OBD.NET.Desktop/Communication/SerialConnection.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using OBD.NET.Common.Communication.EventArgs; -using System.IO.Ports; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using OBD.NET.Common.Communication; - -namespace OBD.NET.Desktop.Communication -{ - public class SerialConnection : ISerialConnection - { - #region Properties & Fields - - private readonly EnhancedSerialPort _serialPort; - private readonly int _timeout; - - public bool IsOpen => _serialPort?.IsOpen ?? false; - public bool IsAsync => false; - - private readonly byte[] _readBuffer = new byte[1024]; - private readonly StringBuilder _lineBuffer = new StringBuilder(); - - private readonly AutoResetEvent _hasPrompt = new AutoResetEvent(true); - - #endregion - - #region Events - - public event EventHandler DataReceived; - - #endregion - - #region Constructors - - public SerialConnection(string port, int baudRate = 38400, Parity parity = Parity.None, StopBits stopBits = StopBits.One, - Handshake handshake = Handshake.None, int timeout = 5000) - { - this._timeout = timeout; - - _serialPort = new EnhancedSerialPort(port, baudRate, parity) - { - StopBits = stopBits, - Handshake = handshake, - ReadTimeout = timeout, - WriteTimeout = timeout - }; - - _serialPort.DataReceived += SerialPortOnDataReceived; - } - - #endregion - - #region Methods - - public void Connect() => _serialPort.Open(); - - private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs) - { - int count = _serialPort.Read(_readBuffer, 0, _serialPort.BytesToRead); - DataReceived?.Invoke(this, new DataReceivedEventArgs(count, _readBuffer)); - } - - public void Dispose() => _serialPort?.Dispose(); - - public Task ConnectAsync() => throw new NotSupportedException("Asynchronous operations not supported"); - - public Task WriteAsync(byte[] data) => throw new NotSupportedException("Asynchronous operations not supported"); - - public void Write(byte[] data) => _serialPort.Write(data, 0, data.Length); - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Desktop/Logging/ODBConsoleLogger.cs b/OBD.NET/OBD.NET.Desktop/Logging/ODBConsoleLogger.cs deleted file mode 100644 index 9f630d1..0000000 --- a/OBD.NET/OBD.NET.Desktop/Logging/ODBConsoleLogger.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using OBD.NET.Common.Logging; - -namespace OBD.NET.Desktop.Logging -{ - /// - /// Simple console logger - /// - /// - public class OBDConsoleLogger : IOBDLogger - { - #region Properties & Fields - - public OBDLogLevel LogLevel { get; set; } - - #endregion - - #region Constructors - - public OBDConsoleLogger(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) - Console.WriteLine($"{DateTime.Now:G} - {level} - {text}"); - } - - #endregion - } -} diff --git a/OBD.NET/OBD.NET.Desktop/OBD.NET.Desktop.csproj b/OBD.NET/OBD.NET.Desktop/OBD.NET.Desktop.csproj deleted file mode 100644 index 379ca60..0000000 --- a/OBD.NET/OBD.NET.Desktop/OBD.NET.Desktop.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net5.0;net6.0;net461 - Darth Affe / Roman Lumetsberger - - - OBD.NET - C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter - 1.2.0 - - True - Github - https://github.com/DarthAffe/OBD.NET - https://github.com/DarthAffe/OBD.NET - GPL-2.0-only - - ..\bin\ - true - True - True - snupkg - - - - NET5_0;NETFULL - - - - NET6_0;NETFULL - - - - NET461;NETFULL - - - - $(DefineConstants);TRACE;DEBUG - true - full - false - - - - portable - true - $(NoWarn);CS1591;CS1572;CS1573 - $(DefineConstants);RELEASE - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OBD.NET/OBD.NET.Universal/Communication/BluetoothSerialConnection.cs b/OBD.NET/OBD.NET.Universal/Communication/BluetoothSerialConnection.cs deleted file mode 100644 index dbb7401..0000000 --- a/OBD.NET/OBD.NET.Universal/Communication/BluetoothSerialConnection.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System; -using System.Runtime.InteropServices.WindowsRuntime; -using System.Threading; -using System.Threading.Tasks; -using OBD.NET.Common.Communication.EventArgs; -using Windows.Devices.Bluetooth.Rfcomm; -using Windows.Networking.Sockets; -using Windows.Storage.Streams; -using System.Linq; - -namespace OBD.NET.Communication -{ - /// - /// Bluetooth OBD serial implementation - /// - /// - public class BluetoothSerialConnection : ISerialConnection - { - - private StreamSocket _socket; - private DataWriter _writer; - - private readonly byte[] _readBuffer = new byte[1024]; - - private CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); - private Task _readerTask; - - private string device; - - /// - /// Initializes a new instance of the class. - /// - public BluetoothSerialConnection() - { - device = null; - } - - /// - /// Initializes a new instance of the class. - /// - /// Name of the device. - /// The logger. - public BluetoothSerialConnection(string deviceName) - { - device = deviceName; - } - - - /// - /// Gets a value indicating whether this instance is open. - /// - /// - /// true if this instance is open; otherwise, false. - /// - public bool IsOpen { get; private set; } - - /// - /// Gets a value indicating whether this instance uses asynchronous IO - /// - /// - /// Has to be set to true if asynchronous IO is supported. - /// If true async methods have to be implemented - /// - public bool IsAsync => true; - - /// - /// Occurs when a full line was received - /// - public event EventHandler DataReceived; - - /// - /// Connects the serial port. - /// - /// Synchronous operations not supported - public void Connect() - { - throw new NotSupportedException("Synchronous operations not supported on UWP platform"); - } - - /// - /// Connects the serial port asynchronously - /// - /// - public async Task ConnectAsync() - { - var services = await Windows.Devices.Enumeration.DeviceInformation - .FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort)); - - //use first serial service - if (services.Count > 0) - { - var id = services[0].Id; - - //use predefined device from constructor - if (!string.IsNullOrWhiteSpace(device)) - { - id = services.Where(x => x.Name.Equals(device, StringComparison.OrdinalIgnoreCase)) - .Select(x => x.Id).FirstOrDefault(); - - if (id == null) - { - throw new InvalidOperationException($"Device {device} not found"); - } - } - - // Initialize the target Bluetooth device - var service = await RfcommDeviceService.FromIdAsync(id); - - // Check that the service meets this App's minimum requirement - - _socket = new StreamSocket(); - await _socket.ConnectAsync(service.ConnectionHostName, - service.ConnectionServiceName); - _writer = new DataWriter(_socket.OutputStream); - _readerTask = StartReader(); - IsOpen = true; - } - } - - /// - /// Writes the specified text to the serial connection - /// - /// The text. - /// Synchronous operations not supported - public void Write(byte[] data) - { - throw new NotImplementedException("Synchronous operations not supported on UWP platform"); - } - - /// - /// Writes the specified text to the serial connection asynchronously - /// - /// The text. - /// - public async Task WriteAsync(byte[] data) - { - _writer.WriteBytes(data); - await _writer.StoreAsync(); - await _writer.FlushAsync(); - } - - private Task StartReader() - { - return Task.Factory.StartNew(async () => - { - - var buffer = _readBuffer.AsBuffer(); - while (!_cancellationTokenSource.IsCancellationRequested) - { - var readData = await _socket.InputStream.ReadAsync(buffer, buffer.Capacity, InputStreamOptions.Partial); - SerialPortOnDataReceived(readData); - } - }, _cancellationTokenSource.Token); - } - - private void SerialPortOnDataReceived(IBuffer buffer) - { - DataReceived?.Invoke(this, new DataReceivedEventArgs((int)buffer.Length, _readBuffer)); - } - - - public void Dispose() - { - _cancellationTokenSource?.Cancel(); - _readerTask?.Wait(); - _socket?.Dispose(); - } - - } -} diff --git a/OBD.NET/OBD.NET.Universal/OBD.NET.Universal.csproj b/OBD.NET/OBD.NET.Universal/OBD.NET.Universal.csproj deleted file mode 100644 index df7f9f0..0000000 --- a/OBD.NET/OBD.NET.Universal/OBD.NET.Universal.csproj +++ /dev/null @@ -1,138 +0,0 @@ - - - - - Debug - AnyCPU - {E0EAFF82-C514-4827-8F49-F1928EBA8E73} - Library - Properties - OBD.NET.Universal - OBD.NET.Universal - en-US - UAP - 10.0.15063.0 - 10.0.10586.0 - 14 - 512 - {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - prompt - 4 - - - x86 - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x86 - false - prompt - - - x86 - bin\x86\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x86 - false - prompt - - - ARM - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - ARM - false - prompt - - - ARM - bin\ARM\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - ARM - false - prompt - - - x64 - true - bin\x64\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x64 - false - prompt - - - x64 - bin\x64\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x64 - false - prompt - - - PackageReference - - - - - - - - - 5.2.4 - - - - - {d985b70e-cdf3-4cf1-ab5d-8d19c7fe7b31} - OBD.NET.Common - - - - - - - 14.0 - - - - \ No newline at end of file diff --git a/OBD.NET/OBD.NET.Universal/OBD.NET.Universal.nuspec b/OBD.NET/OBD.NET.Universal/OBD.NET.Universal.nuspec deleted file mode 100644 index 5fcc230..0000000 --- a/OBD.NET/OBD.NET.Universal/OBD.NET.Universal.nuspec +++ /dev/null @@ -1,15 +0,0 @@ - - - - $id$ - $version$ - $title$ - $author$ - $author$ - https://github.com/romanlum/OBD.NET - false - $description$ - Initial release. - Copyright 2017 - - \ No newline at end of file diff --git a/OBD.NET/OBD.NET.Universal/Properties/AssemblyInfo.cs b/OBD.NET/OBD.NET.Universal/Properties/AssemblyInfo.cs deleted file mode 100644 index 483f8d8..0000000 --- a/OBD.NET/OBD.NET.Universal/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OBD.NET.Universal")] -[assembly: AssemblyDescription("C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter on UWP")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Roman Lumetsberger")] -[assembly: AssemblyProduct("OBD.NET")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/OBD.NET/OBD.NET.Universal/Properties/OBD.NET.Universal.rd.xml b/OBD.NET/OBD.NET.Universal/Properties/OBD.NET.Universal.rd.xml deleted file mode 100644 index 874b02e..0000000 --- a/OBD.NET/OBD.NET.Universal/Properties/OBD.NET.Universal.rd.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - diff --git a/OBD.NET/OBD.NET.sln b/OBD.NET/OBD.NET.sln index 6e8a543..0d1d446 100644 --- a/OBD.NET/OBD.NET.sln +++ b/OBD.NET/OBD.NET.sln @@ -1,94 +1,22 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OBD.NET.Common", "OBD.NET.Common\OBD.NET.Common.csproj", "{D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OBD.NET", "OBD.NET\OBD.NET.csproj", "{F60052E8-1201-4A5A-ADD7-6367C5424F74}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OBD.NET.Desktop", "OBD.NET.Desktop\OBD.NET.Desktop.csproj", "{14CB98E1-95DE-4923-8896-FDF5171AA49E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OBD.NET.Universal", "OBD.NET.Universal\OBD.NET.Universal.csproj", "{E0EAFF82-C514-4827-8F49-F1928EBA8E73}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OBD.NET.ConsoleClient", "OBD.NET.ConsoleClient\OBD.NET.ConsoleClient.csproj", "{8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleClient", "ConsoleClient\ConsoleClient.csproj", "{8AC58110-3925-481F-9D85-4B809D7D18B9}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|ARM.ActiveCfg = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|ARM.Build.0 = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|x64.ActiveCfg = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|x64.Build.0 = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|x86.ActiveCfg = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Debug|x86.Build.0 = Debug|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|Any CPU.Build.0 = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|ARM.ActiveCfg = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|ARM.Build.0 = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|x64.ActiveCfg = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|x64.Build.0 = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|x86.ActiveCfg = Release|Any CPU - {D985B70E-CDF3-4CF1-AB5D-8D19C7FE7B31}.Release|x86.Build.0 = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|ARM.ActiveCfg = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|ARM.Build.0 = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|x64.ActiveCfg = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|x64.Build.0 = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|x86.ActiveCfg = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Debug|x86.Build.0 = Debug|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|Any CPU.Build.0 = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|ARM.ActiveCfg = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|ARM.Build.0 = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|x64.ActiveCfg = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|x64.Build.0 = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|x86.ActiveCfg = Release|Any CPU - {14CB98E1-95DE-4923-8896-FDF5171AA49E}.Release|x86.Build.0 = Release|Any CPU - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|ARM.ActiveCfg = Debug|ARM - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|ARM.Build.0 = Debug|ARM - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x64.ActiveCfg = Debug|x64 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x64.Build.0 = Debug|x64 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x86.ActiveCfg = Debug|x86 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Debug|x86.Build.0 = Debug|x86 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|Any CPU.Build.0 = Release|Any CPU - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|ARM.ActiveCfg = Release|ARM - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|ARM.Build.0 = Release|ARM - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x64.ActiveCfg = Release|x64 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x64.Build.0 = Release|x64 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x86.ActiveCfg = Release|x86 - {E0EAFF82-C514-4827-8F49-F1928EBA8E73}.Release|x86.Build.0 = Release|x86 - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|ARM.ActiveCfg = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|ARM.Build.0 = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|x64.ActiveCfg = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|x64.Build.0 = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|x86.ActiveCfg = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Debug|x86.Build.0 = Debug|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|Any CPU.Build.0 = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|ARM.ActiveCfg = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|ARM.Build.0 = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|x64.ActiveCfg = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|x64.Build.0 = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|x86.ActiveCfg = Release|Any CPU - {8F8EC5D5-94BD-47CF-9714-CA8C0198BDDC}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE + {F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F60052E8-1201-4A5A-ADD7-6367C5424F74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F60052E8-1201-4A5A-ADD7-6367C5424F74}.Release|Any CPU.Build.0 = Release|Any CPU + {8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8AC58110-3925-481F-9D85-4B809D7D18B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8AC58110-3925-481F-9D85-4B809D7D18B9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/OBD.NET/OBD.NET/.idea/.idea.OBD.NET/.idea/workspace.xml b/OBD.NET/OBD.NET/.idea/.idea.OBD.NET/.idea/workspace.xml new file mode 100644 index 0000000..8c1d66d --- /dev/null +++ b/OBD.NET/OBD.NET/.idea/.idea.OBD.NET/.idea/workspace.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1648650452176 + + + + + + + + + + + \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Commands/ATCommand.cs b/OBD.NET/OBD.NET/Commands/ATCommand.cs new file mode 100644 index 0000000..fd85542 --- /dev/null +++ b/OBD.NET/OBD.NET/Commands/ATCommand.cs @@ -0,0 +1,56 @@ +namespace OBD.NET.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) + { + Command = command; + ExpectedResult = expectedResult; + } + + #endregion + + #region Methods + + public override string ToString() => Command; + + #endregion + + #region Operators + + public static implicit operator string(ATCommand command) => command.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Commands/STCommand.cs b/OBD.NET/OBD.NET/Commands/STCommand.cs new file mode 100644 index 0000000..316436f --- /dev/null +++ b/OBD.NET/OBD.NET/Commands/STCommand.cs @@ -0,0 +1,48 @@ +namespace OBD.NET.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) + { + Command = command; + } + + #endregion + + #region Methods + + public override string ToString() => Command; + + #endregion + + #region Operators + + public static implicit operator string(STCommand command) => command.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Communication/EventArgs/DataReceivedEventArgs.cs b/OBD.NET/OBD.NET/Communication/EventArgs/DataReceivedEventArgs.cs new file mode 100644 index 0000000..f38483a --- /dev/null +++ b/OBD.NET/OBD.NET/Communication/EventArgs/DataReceivedEventArgs.cs @@ -0,0 +1,36 @@ +namespace OBD.NET.Communication.EventArgs; + +/// +/// Event args for receiving serial data +/// +public class DataReceivedEventArgs : System.EventArgs +{ + #region Properties & Fields + + /// + /// Count of valid data bytes in the buffer + /// + public int Count { get; } + + /// + /// Data buffer holding the bytes + /// + public byte[] Data { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + /// The count. + /// The data. + public DataReceivedEventArgs(int count, byte[] data) + { + Count = count; + Data = data; + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Communication/ISerialConnection.cs b/OBD.NET/OBD.NET/Communication/ISerialConnection.cs new file mode 100644 index 0000000..0f509b5 --- /dev/null +++ b/OBD.NET/OBD.NET/Communication/ISerialConnection.cs @@ -0,0 +1,55 @@ +using OBD.NET.Communication.EventArgs; + +namespace OBD.NET.Communication; + +/// +/// Serial connection interface +/// +/// +public interface ISerialConnection : IDisposable +{ + /// + /// Gets a value indicating whether this instance is open. + /// + /// + /// true if this instance is open; otherwise, false. + /// + bool IsOpen { get; } + + /// + /// Gets a value indicating whether this instance uses asynchronous IO + /// + /// + /// Has to be set to true if asynchronous IO is supported. + /// If true async methods have to be implemented + /// + bool IsAsync { get; } + + /// + /// Occurs when a full line was received + /// + event EventHandler DataReceived; + + /// + /// Connects the serial port. + /// + void Connect(); + + /// + /// Connects the serial port asynchronous + /// + /// + Task ConnectAsync(); + + /// + /// Writes the specified data to the serial connection + /// + /// The data. + void Write(byte[] data); + + /// + /// Writes the specified data to the serial connection asynchronous + /// + /// The data. + Task WriteAsync(byte[] data); +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Communication/SerialConnection.cs b/OBD.NET/OBD.NET/Communication/SerialConnection.cs new file mode 100644 index 0000000..833d70c --- /dev/null +++ b/OBD.NET/OBD.NET/Communication/SerialConnection.cs @@ -0,0 +1,71 @@ +using System.IO.Ports; +using System.Text; +using OBD.NET.Communication.EventArgs; + +namespace OBD.NET.Communication; + +public class SerialConnection : ISerialConnection +{ + #region Properties & Fields + + private readonly SerialPort _serialPort; + + public bool IsOpen => _serialPort?.IsOpen ?? false; + public bool IsAsync => false; + + private readonly byte[] _readBuffer = new byte[1024]; + private readonly StringBuilder _lineBuffer = new StringBuilder(); + + private readonly AutoResetEvent _hasPrompt = new AutoResetEvent(true); + + #endregion + + #region Events + + public event EventHandler DataReceived = delegate { }; + + #endregion + + #region Constructors + + public SerialConnection(string port, int baudRate = 38400, Parity parity = Parity.None, StopBits stopBits = StopBits.One, + Handshake handshake = Handshake.None, int timeout = 5000) + { + _serialPort = new SerialPort(port, baudRate, parity) + { + StopBits = stopBits, + Handshake = handshake, + ReadTimeout = timeout, + WriteTimeout = timeout + }; + + _serialPort.DataReceived += SerialPortOnDataReceived; + } + + #endregion + + #region Methods + + public static IEnumerable GetAvailablePorts() + { + return SerialPort.GetPortNames(); + } + + public void Connect() => _serialPort.Open(); + + private void SerialPortOnDataReceived(object sender, SerialDataReceivedEventArgs serialDataReceivedEventArgs) + { + int count = _serialPort.Read(_readBuffer, 0, _serialPort.BytesToRead); + DataReceived?.Invoke(this, new DataReceivedEventArgs(count, _readBuffer)); + } + + public void Dispose() => _serialPort?.Dispose(); + + public Task ConnectAsync() => throw new NotSupportedException("Asynchronous operations not supported"); + + public Task WriteAsync(byte[] data) => throw new NotSupportedException("Asynchronous operations not supported"); + + public void Write(byte[] data) => _serialPort.Write(data, 0, data.Length); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Count.cs b/OBD.NET/OBD.NET/DataTypes/Count.cs new file mode 100644 index 0000000..0d0a9c9 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Count.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Degree.cs b/OBD.NET/OBD.NET/DataTypes/Degree.cs new file mode 100644 index 0000000..826d82d --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Degree.cs @@ -0,0 +1,28 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs b/OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs new file mode 100644 index 0000000..23abf7c --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs @@ -0,0 +1,28 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/GenericData.cs b/OBD.NET/OBD.NET/DataTypes/GenericData.cs new file mode 100644 index 0000000..d178c22 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/GenericData.cs @@ -0,0 +1,49 @@ +namespace OBD.NET.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) + { + Value = value; + MinValue = minValue; + MaxValue = maxValue; + IsFloatingPointValue = true; + } + + protected GenericData(int value, int minValue, int maxValue) + { + Value = value; + MinValue = minValue; + MaxValue = maxValue; + 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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/GramPerSec.cs b/OBD.NET/OBD.NET/DataTypes/GramPerSec.cs new file mode 100644 index 0000000..c2b9173 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/GramPerSec.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Kilometre.cs b/OBD.NET/OBD.NET/DataTypes/Kilometre.cs new file mode 100644 index 0000000..d208d8a --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Kilometre.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs b/OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs new file mode 100644 index 0000000..d022d30 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Kilopascal.cs b/OBD.NET/OBD.NET/DataTypes/Kilopascal.cs new file mode 100644 index 0000000..335d866 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Kilopascal.cs @@ -0,0 +1,28 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs b/OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs new file mode 100644 index 0000000..a28cebe --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Milliampere.cs b/OBD.NET/OBD.NET/DataTypes/Milliampere.cs new file mode 100644 index 0000000..c589676 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Milliampere.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Minute.cs b/OBD.NET/OBD.NET/DataTypes/Minute.cs new file mode 100644 index 0000000..d8e2096 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Minute.cs @@ -0,0 +1,30 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs b/OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs new file mode 100644 index 0000000..a38d82b --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Pascal.cs b/OBD.NET/OBD.NET/DataTypes/Pascal.cs new file mode 100644 index 0000000..2f6db6f --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Pascal.cs @@ -0,0 +1,30 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Percent.cs b/OBD.NET/OBD.NET/DataTypes/Percent.cs new file mode 100644 index 0000000..7f6e6dd --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Percent.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Ratio.cs b/OBD.NET/OBD.NET/DataTypes/Ratio.cs new file mode 100644 index 0000000..3e3d079 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Ratio.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/RevolutionsPerMinute.cs b/OBD.NET/OBD.NET/DataTypes/RevolutionsPerMinute.cs new file mode 100644 index 0000000..9d28499 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/RevolutionsPerMinute.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Second.cs b/OBD.NET/OBD.NET/DataTypes/Second.cs new file mode 100644 index 0000000..96ca906 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Second.cs @@ -0,0 +1,28 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/DataTypes/Volt.cs b/OBD.NET/OBD.NET/DataTypes/Volt.cs new file mode 100644 index 0000000..875ca17 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Volt.cs @@ -0,0 +1,22 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Devices/Command.cs b/OBD.NET/OBD.NET/Devices/Command.cs new file mode 100644 index 0000000..d69850e --- /dev/null +++ b/OBD.NET/OBD.NET/Devices/Command.cs @@ -0,0 +1,26 @@ +namespace OBD.NET.Devices; + +/// +/// Class used for queued command +/// +public class QueuedCommand +{ + #region Properties & Fields + + public string CommandText { get; private set; } + + public CommandResult CommandResult { get; } + + #endregion + + #region Constructors + + public QueuedCommand(string commandText) + { + CommandText = commandText; + + CommandResult = new CommandResult(); + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Devices/CommandResult.cs b/OBD.NET/OBD.NET/Devices/CommandResult.cs new file mode 100644 index 0000000..c32b60b --- /dev/null +++ b/OBD.NET/OBD.NET/Devices/CommandResult.cs @@ -0,0 +1,22 @@ +using OBD.NET.Util; + +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Devices/ELM327.cs b/OBD.NET/OBD.NET/Devices/ELM327.cs new file mode 100644 index 0000000..59ab1d2 --- /dev/null +++ b/OBD.NET/OBD.NET/Devices/ELM327.cs @@ -0,0 +1,283 @@ +using System.Reflection; +using OBD.NET.Commands; +using OBD.NET.Communication; +using OBD.NET.Enums; +using OBD.NET.Events; +using OBD.NET.Events.EventArgs; +using OBD.NET.Extensions; +using OBD.NET.Logging; +using OBD.NET.OBDData; + +namespace OBD.NET.Devices; + +public class ELM327 : SerialDevice +{ + #region Properties & Fields + + protected readonly Dictionary DataReceivedEventHandlers = new Dictionary(); + + protected static Dictionary PidCache { get; } = new Dictionary(); + protected static Dictionary DataTypeCache { get; } = new Dictionary(); + + 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(object sender, DataReceivedEventArgs 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; + } + } + + /// + /// Sends the AT command. + /// + /// The command. + public virtual void SendCommand(ATCommand command) => SendCommand(command.Command); + + /// + /// Requests the data and calls the handler + /// + /// + public virtual void RequestData() + where T : class, IOBDData, new() + { + Logger?.WriteLine("Requesting Type " + typeof(T).Name + " ...", OBDLogLevel.Debug); + + byte pid = ResolvePid(); + RequestData(pid); + } + + /// + /// Request data based on a pid + /// + /// The pid of the requested data + public virtual void RequestData(byte pid) + { + Logger?.WriteLine("Requesting PID " + pid.ToString("X2") + " ...", OBDLogLevel.Debug); + SendCommand(((byte)Mode).ToString("X2") + pid.ToString("X2")); + } + + /// + /// Requests the data asynchronous and return the data when available + /// + /// + /// + public virtual async Task RequestDataAsync() + where T : class, IOBDData, new() + { + Logger?.WriteLine("Requesting Type " + typeof(T).Name + " ...", OBDLogLevel.Debug); + byte pid = ResolvePid(); + return await RequestDataAsync(pid) as T; + } + + /// + /// Requests the data asynchronous and return the data when available + /// + /// + /// + public virtual async Task RequestDataAsync(Type type) + { + Logger?.WriteLine("Requesting Type " + type.Name + " ...", OBDLogLevel.Debug); + byte pid = ResolvePid(type); + return await RequestDataAsync(pid) as IOBDData; + } + + /// + /// Request data based on a pid + /// + /// The pid of the requested data + public virtual async Task 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() + 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() + 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; + } + + /// + /// YOU SHOULDN'T NEED THIS METHOD! + /// + /// You should only use this method if you're requesting data by pid instead of the -method. + /// + /// Initializes the PID-Cache with all IOBDData-Types contained in OBD.NET. + /// You can add additional ones with . + /// + 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(DataReceivedEventHandler eventHandler) where T : IOBDData + { + if (!DataReceivedEventHandlers.TryGetValue(typeof(T), out IDataEventManager eventManager)) + DataReceivedEventHandlers.Add(typeof(T), (eventManager = new GenericDataEventManager())); + + ((GenericDataEventManager)eventManager).DataReceived += eventHandler; + } + + public void UnsubscribeDataReceived(DataReceivedEventHandler eventHandler) where T : IOBDData + { + if (DataReceivedEventHandlers.TryGetValue(typeof(T), out IDataEventManager eventManager)) + ((GenericDataEventManager)eventManager).DataReceived -= eventHandler; + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Devices/STN1170.cs b/OBD.NET/OBD.NET/Devices/STN1170.cs new file mode 100644 index 0000000..4328a01 --- /dev/null +++ b/OBD.NET/OBD.NET/Devices/STN1170.cs @@ -0,0 +1,26 @@ +using OBD.NET.Commands; +using OBD.NET.Communication; +using OBD.NET.Logging; + +namespace OBD.NET.Devices; + +public class STN1170 : ELM327 // Fully compatible device +{ + #region Constructors + + public STN1170(ISerialConnection connection, IOBDLogger logger = null) + : base(connection, logger) + { } + + #endregion + + #region Methods + + /// + /// Sends the ST command. + /// + /// The command. + public virtual void SendCommand(STCommand command) => SendCommand(command.Command); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Devices/SerialDevice.cs b/OBD.NET/OBD.NET/Devices/SerialDevice.cs new file mode 100644 index 0000000..80568c5 --- /dev/null +++ b/OBD.NET/OBD.NET/Devices/SerialDevice.cs @@ -0,0 +1,250 @@ +using System.Collections.Concurrent; +using System.Text; +using OBD.NET.Communication; +using OBD.NET.Communication.EventArgs; +using OBD.NET.Exceptions; +using OBD.NET.Logging; + +namespace OBD.NET.Devices; + +/// +/// Base class used for communicating with the device +/// +public abstract class SerialDevice : IDisposable +{ + #region Properties & Fields + + private readonly BlockingCollection _commandQueue = new BlockingCollection(); + 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 + + /// + /// Initializes a new instance of the class. + /// + /// connection. + /// terminator used for terminating the command message + /// logger instance + protected SerialDevice(ISerialConnection connection, char terminator = '\r', IOBDLogger logger = null) + { + Connection = connection; + Terminator = terminator; + Logger = logger; + + connection.DataReceived += OnDataReceived; + } + + #endregion + + #region Methods + + /// + /// Initializes the device + /// + public virtual void Initialize() + { + Connection.Connect(); + CheckConnectionAndStartWorker(); + } + + /// + /// Initializes the device + /// + public virtual async Task InitializeAsync() + { + await Connection.ConnectAsync(); + CheckConnectionAndStartWorker(); + } + + /// + /// Checks the connection and starts background worker which is sending the commands + /// + /// Failed to open Serial-Connection. + 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); + } + + + /// + /// Sends the command. + /// + /// command string + /// Not connected + 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; + } + + /// + /// Prepares the command + /// + /// + /// + 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; + } + + /// + /// Called when data is received from the serial device + /// + /// The sender. + /// The instance containing the event data. + 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; + } + } + } + + /// + /// Signals a final message + /// + private void FinishLine() + { + string line = _lineBuffer.ToString().Trim(); + _lineBuffer.Clear(); + + if (string.IsNullOrWhiteSpace(line)) return; + Logger?.WriteLine("Response: '" + line + "'", OBDLogLevel.Verbose); + + InternalProcessMessage(line); + } + + /// + /// Process message and sets the result + /// + /// The message. + private void InternalProcessMessage(string message) + { + object data = ProcessMessage(message); + CurrentCommand.CommandResult.Result = data; + } + + /// + /// Processes the message. + /// + /// message received + /// result data + protected abstract object ProcessMessage(string message); + + /// + /// Worker method for sending commands + /// + 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()); + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public virtual void Dispose() + { + _commandQueue.CompleteAdding(); + _commandCancellationToken?.Cancel(); + _commandWorkerTask?.Wait(); + Connection?.Dispose(); + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Enums/Mode.cs b/OBD.NET/OBD.NET/Enums/Mode.cs new file mode 100644 index 0000000..a9e225a --- /dev/null +++ b/OBD.NET/OBD.NET/Enums/Mode.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.Enums; + +/// +/// https://en.wikipedia.org/wiki/OBD-II_PIDs#Modes +/// +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Events/EventArgs/DataReceivedEventArgs.cs b/OBD.NET/OBD.NET/Events/EventArgs/DataReceivedEventArgs.cs new file mode 100644 index 0000000..fd1342f --- /dev/null +++ b/OBD.NET/OBD.NET/Events/EventArgs/DataReceivedEventArgs.cs @@ -0,0 +1,23 @@ +using OBD.NET.OBDData; + +namespace OBD.NET.Events.EventArgs; + +public class DataReceivedEventArgs where T : IOBDData +{ + #region Properties & Fields + + public T Data { get; } + public DateTime Timestamp { get; } + + #endregion + + #region Constructors + + public DataReceivedEventArgs(T data, DateTime timestamp) + { + Data = data; + Timestamp = timestamp; + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Events/EventArgs/RawDataReceivedEventArgs.cs b/OBD.NET/OBD.NET/Events/EventArgs/RawDataReceivedEventArgs.cs new file mode 100644 index 0000000..f247a60 --- /dev/null +++ b/OBD.NET/OBD.NET/Events/EventArgs/RawDataReceivedEventArgs.cs @@ -0,0 +1,21 @@ +namespace OBD.NET.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) + { + Data = data; + Timestamp = timestamp; + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Events/GenericDataEventManager.cs b/OBD.NET/OBD.NET/Events/GenericDataEventManager.cs new file mode 100644 index 0000000..a304e8e --- /dev/null +++ b/OBD.NET/OBD.NET/Events/GenericDataEventManager.cs @@ -0,0 +1,21 @@ +using OBD.NET.Devices; +using OBD.NET.Events.EventArgs; +using OBD.NET.OBDData; + +namespace OBD.NET.Events; + +public class GenericDataEventManager : IDataEventManager + where T : IOBDData +{ + #region Events + + internal event ELM327.DataReceivedEventHandler DataReceived; + + #endregion + + #region Methods + + public void RaiseEvent(object sender, IOBDData data, DateTime timestamp) => DataReceived?.Invoke(sender, new DataReceivedEventArgs((T)data, timestamp)); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Events/IDataEventManager.cs b/OBD.NET/OBD.NET/Events/IDataEventManager.cs new file mode 100644 index 0000000..e2e150e --- /dev/null +++ b/OBD.NET/OBD.NET/Events/IDataEventManager.cs @@ -0,0 +1,8 @@ +using OBD.NET.OBDData; + +namespace OBD.NET.Events; + +public interface IDataEventManager +{ + void RaiseEvent(object sender, IOBDData data, DateTime timestamp); +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Exceptions/SerialException.cs b/OBD.NET/OBD.NET/Exceptions/SerialException.cs new file mode 100644 index 0000000..29a8a34 --- /dev/null +++ b/OBD.NET/OBD.NET/Exceptions/SerialException.cs @@ -0,0 +1,20 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Exceptions/UnexpectedResultException.cs b/OBD.NET/OBD.NET/Exceptions/UnexpectedResultException.cs new file mode 100644 index 0000000..86e1e4e --- /dev/null +++ b/OBD.NET/OBD.NET/Exceptions/UnexpectedResultException.cs @@ -0,0 +1,36 @@ +namespace OBD.NET.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) + { + Result = result; + ExpectedResult = expectedResult; + } + + public UnexpectedResultException(string message, string result, string expectedResult) + : base(message) + { + Result = result; + ExpectedResult = expectedResult; + } + + public UnexpectedResultException(string message, Exception innerException, string result, string expectedResult) + : base(message, innerException) + { + Result = result; + ExpectedResult = expectedResult; + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Extensions/HexExtension.cs b/OBD.NET/OBD.NET/Extensions/HexExtension.cs new file mode 100644 index 0000000..12930fa --- /dev/null +++ b/OBD.NET/OBD.NET/Extensions/HexExtension.cs @@ -0,0 +1,20 @@ +namespace OBD.NET.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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Logging/IOBDLogger.cs b/OBD.NET/OBD.NET/Logging/IOBDLogger.cs new file mode 100644 index 0000000..ae59920 --- /dev/null +++ b/OBD.NET/OBD.NET/Logging/IOBDLogger.cs @@ -0,0 +1,6 @@ +namespace OBD.NET.Logging; + +public interface IOBDLogger +{ + void WriteLine(string text, OBDLogLevel level); +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Logging/OBDConsoleLogger.cs b/OBD.NET/OBD.NET/Logging/OBDConsoleLogger.cs new file mode 100644 index 0000000..b272a39 --- /dev/null +++ b/OBD.NET/OBD.NET/Logging/OBDConsoleLogger.cs @@ -0,0 +1,35 @@ +namespace OBD.NET.Logging; + +/// +/// Simple console logger +/// +/// +public class OBDConsoleLogger : IOBDLogger +{ + #region Properties & Fields + + public OBDLogLevel LogLevel { get; set; } + + #endregion + + #region Constructors + + public OBDConsoleLogger(OBDLogLevel level = OBDLogLevel.None) + { + LogLevel = level; + } + + #endregion + + #region Methods + + public void WriteLine(string text, OBDLogLevel level) + { + if (LogLevel == OBDLogLevel.None) return; + + if ((int)level <= (int)LogLevel) + Console.WriteLine($"{DateTime.Now:G} - {level} - {text}"); + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Logging/OBDDebugLogger.cs b/OBD.NET/OBD.NET/Logging/OBDDebugLogger.cs new file mode 100644 index 0000000..28f7757 --- /dev/null +++ b/OBD.NET/OBD.NET/Logging/OBDDebugLogger.cs @@ -0,0 +1,38 @@ +using System.Diagnostics; + +namespace OBD.NET.Logging; + +/// +/// Simple debug logger +/// +/// +public class OBDDebugLogger : IOBDLogger +{ + + #region Properties & Fields + + public OBDLogLevel LogLevel { get; set; } + + #endregion + + #region Constructors + + public OBDDebugLogger(OBDLogLevel level = OBDLogLevel.None) + { + 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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Logging/OBDLogLevel.cs b/OBD.NET/OBD.NET/Logging/OBDLogLevel.cs new file mode 100644 index 0000000..97d437a --- /dev/null +++ b/OBD.NET/OBD.NET/Logging/OBDLogLevel.cs @@ -0,0 +1,9 @@ +namespace OBD.NET.Logging; + +public enum OBDLogLevel +{ + None, + Error, + Verbose, + Debug +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBD.NET.csproj b/OBD.NET/OBD.NET/OBD.NET.csproj new file mode 100644 index 0000000..a35313e --- /dev/null +++ b/OBD.NET/OBD.NET/OBD.NET.csproj @@ -0,0 +1,53 @@ + + + + enable + enable + net6.0;net5.0;netstandard2.0 + 10 + + Darth Affe / Roman Lumetsberger + - + OBD.NET + C#-Library to read/write data from/to a car through an ELM327-/STN1170-Adapter + 1.2.0 + + True + Github + https://github.com/DarthAffe/OBD.NET + https://github.com/DarthAffe/OBD.NET + GPL-2.0-only + + ..\bin\ + true + True + True + snupkg + OBD.NET + OBD.NET + OBD.NET + + + + $(DefineConstants);TRACE;DEBUG + true + full + false + + + + portable + true + $(NoWarn);CS1591;CS1572;CS1573 + $(DefineConstants);RELEASE + + + + + + + + + + + diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/AuxiliaryInputStatus.cs b/OBD.NET/OBD.NET/OBDData/00-1F/AuxiliaryInputStatus.cs new file mode 100644 index 0000000..ceec4f9 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/AuxiliaryInputStatus.cs @@ -0,0 +1,24 @@ +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/CalculatedEngineLoad.cs b/OBD.NET/OBD.NET/OBDData/00-1F/CalculatedEngineLoad.cs new file mode 100644 index 0000000..d21fa95 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/CalculatedEngineLoad.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/CommandedSecondaryAirStatus.cs b/OBD.NET/OBD.NET/OBDData/00-1F/CommandedSecondaryAirStatus.cs new file mode 100644 index 0000000..27aecbc --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/CommandedSecondaryAirStatus.cs @@ -0,0 +1,41 @@ +namespace OBD.NET.OBDData._00_1F; + +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 + + /// + /// https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_12 + /// + [Flags] + public enum CommandedSecondaryAirStatusValue + { + Missing = 0, + Upstream = 1 << 0, + DownstreamOfCatalyticConverter = 1 << 1, + FromTheOutsideAtmosphereOrOff = 1 << 2, + PumpCommandedOnForDiagnostics = 1 << 3 + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/EngineCoolantTemperature.cs b/OBD.NET/OBD.NET/OBDData/00-1F/EngineCoolantTemperature.cs new file mode 100644 index 0000000..761d378 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/EngineCoolantTemperature.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/EngineRPM.cs b/OBD.NET/OBD.NET/OBDData/00-1F/EngineRPM.cs new file mode 100644 index 0000000..d330378 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/EngineRPM.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/FuelPressure.cs b/OBD.NET/OBD.NET/OBDData/00-1F/FuelPressure.cs new file mode 100644 index 0000000..0138704 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/FuelPressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/FuelSystemStatus.cs b/OBD.NET/OBD.NET/OBDData/00-1F/FuelSystemStatus.cs new file mode 100644 index 0000000..a90fd69 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/FuelSystemStatus.cs @@ -0,0 +1,43 @@ +namespace OBD.NET.OBDData._00_1F; + +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 + + /// + /// https://en.wikipedia.org/wiki/OBD-II_PIDs#Mode_1_PID_03 + /// + [Flags] + public enum FuelSystemStatusValue + { + Missing = 0, + OpenLoopDueToInsufficientEngineTemperature = 1 << 0, + ClosedLoopUsingOxygenSensorFeedbackToDetermineFuelMix = 1 << 1, + OpenLoopDueToEngineLoadOrFuelCutDueToDeceleration = 1 << 2, + OpenLoopDueToSystemFailure = 1 << 3, + ClosedLoopUsingAtLeastOneOxygenSensorButThereIsAFaultInTheFeedbackSystem = 1 << 4 + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/IntakeAirTemperature.cs b/OBD.NET/OBD.NET/OBDData/00-1F/IntakeAirTemperature.cs new file mode 100644 index 0000000..a4f07d5 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/IntakeAirTemperature.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs b/OBD.NET/OBD.NET/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs new file mode 100644 index 0000000..302dae9 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/IntakeManifoldAbsolutePressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank1.cs b/OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank1.cs new file mode 100644 index 0000000..dc86935 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank1.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank2.cs b/OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank2.cs new file mode 100644 index 0000000..fc2ddf4 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/LongTermFuelTrimBank2.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/MAFAirFlowRate.cs b/OBD.NET/OBD.NET/OBDData/00-1F/MAFAirFlowRate.cs new file mode 100644 index 0000000..36d7e60 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/MAFAirFlowRate.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OBDStandards.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OBDStandards.cs new file mode 100644 index 0000000..dd73cb3 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OBDStandards.cs @@ -0,0 +1,61 @@ +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor1FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor1FuelTrim.cs new file mode 100644 index 0000000..ff63a39 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor1FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor2FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor2FuelTrim.cs new file mode 100644 index 0000000..f91e751 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor2FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor3FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor3FuelTrim.cs new file mode 100644 index 0000000..213e82e --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor3FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor4FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor4FuelTrim.cs new file mode 100644 index 0000000..cac590d --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor4FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor5FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor5FuelTrim.cs new file mode 100644 index 0000000..45e10cb --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor5FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor6FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor6FuelTrim.cs new file mode 100644 index 0000000..312615a --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor6FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor7FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor7FuelTrim.cs new file mode 100644 index 0000000..822a5fe --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor7FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor8FuelTrim.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor8FuelTrim.cs new file mode 100644 index 0000000..b5b1698 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensor8FuelTrim.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorPresent.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorPresent.cs new file mode 100644 index 0000000..c40276f --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorPresent.cs @@ -0,0 +1,31 @@ +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorsPresent2.cs b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorsPresent2.cs new file mode 100644 index 0000000..52ad864 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/OxygenSensorsPresent2.cs @@ -0,0 +1,31 @@ +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/PidsSupported01_20.cs b/OBD.NET/OBD.NET/OBDData/00-1F/PidsSupported01_20.cs new file mode 100644 index 0000000..fb15836 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/PidsSupported01_20.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData._00_1F; + +public class PidsSupported01_20 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupported01_20() + : base(0x00, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/RunTimeSinceEngineStart.cs b/OBD.NET/OBD.NET/OBDData/00-1F/RunTimeSinceEngineStart.cs new file mode 100644 index 0000000..e489569 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/RunTimeSinceEngineStart.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank1.cs b/OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank1.cs new file mode 100644 index 0000000..5201723 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank1.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank2.cs b/OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank2.cs new file mode 100644 index 0000000..ee2f840 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/ShortTermFuelTrimBank2.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/ThrottlePosition.cs b/OBD.NET/OBD.NET/OBDData/00-1F/ThrottlePosition.cs new file mode 100644 index 0000000..fd4e498 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/ThrottlePosition.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/TimingAdvance.cs b/OBD.NET/OBD.NET/OBDData/00-1F/TimingAdvance.cs new file mode 100644 index 0000000..38bb518 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/TimingAdvance.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/00-1F/VehicleSpeed.cs b/OBD.NET/OBD.NET/OBDData/00-1F/VehicleSpeed.cs new file mode 100644 index 0000000..b205d92 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/00-1F/VehicleSpeed.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._00_1F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/AbsoluteBarometricPressure.cs b/OBD.NET/OBD.NET/OBDData/20-3F/AbsoluteBarometricPressure.cs new file mode 100644 index 0000000..eba09fd --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/AbsoluteBarometricPressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs new file mode 100644 index 0000000..133b883 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor1.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs new file mode 100644 index 0000000..9b7b38a --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank1Sensor2.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs new file mode 100644 index 0000000..6b95b2d --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor1.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs new file mode 100644 index 0000000..b0f64ee --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/CatalystTemperatureBank2Sensor2.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/CommandedEGR.cs b/OBD.NET/OBD.NET/OBDData/20-3F/CommandedEGR.cs new file mode 100644 index 0000000..351f50a --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/CommandedEGR.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/CommandedEvaporativePurge.cs b/OBD.NET/OBD.NET/OBDData/20-3F/CommandedEvaporativePurge.cs new file mode 100644 index 0000000..bf2f365 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/CommandedEvaporativePurge.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs b/OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs new file mode 100644 index 0000000..9610312 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledSinceCodesCleared.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledWithMILOn.cs b/OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledWithMILOn.cs new file mode 100644 index 0000000..58dc766 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/DistanceTraveledWithMILOn.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/EGRError.cs b/OBD.NET/OBD.NET/OBDData/20-3F/EGRError.cs new file mode 100644 index 0000000..bad9131 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/EGRError.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/EvapSystemVaporPressure.cs b/OBD.NET/OBD.NET/OBDData/20-3F/EvapSystemVaporPressure.cs new file mode 100644 index 0000000..5f5c239 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/EvapSystemVaporPressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/FuelRailGaugePressure.cs b/OBD.NET/OBD.NET/OBDData/20-3F/FuelRailGaugePressure.cs new file mode 100644 index 0000000..5cf6b19 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/FuelRailGaugePressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/FuelRailPressure.cs b/OBD.NET/OBD.NET/OBDData/20-3F/FuelRailPressure.cs new file mode 100644 index 0000000..3daea9e --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/FuelRailPressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/FuelTankLevelInput.cs b/OBD.NET/OBD.NET/OBDData/20-3F/FuelTankLevelInput.cs new file mode 100644 index 0000000..42f14b4 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/FuelTankLevelInput.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir.cs new file mode 100644 index 0000000..b2440c4 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir2.cs new file mode 100644 index 0000000..3df8d4c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor1FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir.cs new file mode 100644 index 0000000..9ea432d --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir2.cs new file mode 100644 index 0000000..301977e --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor2FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir.cs new file mode 100644 index 0000000..c014c6c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir2.cs new file mode 100644 index 0000000..3872fed --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor3FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir.cs new file mode 100644 index 0000000..01e54d8 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir2.cs new file mode 100644 index 0000000..acb091e --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor4FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir.cs new file mode 100644 index 0000000..3f8268d --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir2.cs new file mode 100644 index 0000000..3c31f5a --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor5FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir.cs new file mode 100644 index 0000000..785864b --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir2.cs new file mode 100644 index 0000000..ead6b4d --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor6FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir.cs new file mode 100644 index 0000000..519dc72 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir2.cs new file mode 100644 index 0000000..abc0df2 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor7FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +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 +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir.cs new file mode 100644 index 0000000..c91fda4 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +public class OxygenSensor8FuelAir : 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 OxygenSensor8FuelAir() + : base(0x2B, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => FuelAirEquivalenceRatio.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir2.cs b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir2.cs new file mode 100644 index 0000000..4d7bbae --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/OxygenSensor8FuelAir2.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +public class OxygenSensor8FuelAir2 : 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 OxygenSensor8FuelAir2() + : base(0x3B, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => FuelAirEquivalenceRatio.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/PidsSupported21_40.cs b/OBD.NET/OBD.NET/OBDData/20-3F/PidsSupported21_40.cs new file mode 100644 index 0000000..70ad556 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/PidsSupported21_40.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData._20_3F; + +public class PidsSupported21_40 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupported21_40() + : base(0x20, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/20-3F/WarmUpsSinceCodesCleared.cs b/OBD.NET/OBD.NET/OBDData/20-3F/WarmUpsSinceCodesCleared.cs new file mode 100644 index 0000000..db5eab8 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/20-3F/WarmUpsSinceCodesCleared.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._20_3F; + +public class WarmUpsSinceCodesCleared : AbstractOBDData +{ + #region Properties & Fields + + public Count WarmUps => new Count(A, 0, 255); + + #endregion + + #region Constructors + + public WarmUpsSinceCodesCleared() + : base(0x30, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => WarmUps.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs new file mode 100644 index 0000000..c979eea --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteEvapSystemVaporPressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AbsoluteEvapSystemVaporPressure : AbstractOBDData +{ + #region Properties & Fields + + public Kilopascal Pressure => new Kilopascal(((256 * A) + B) / 200.0, 0, 327.675); + + #endregion + + #region Constructors + + public AbsoluteEvapSystemVaporPressure() + : base(0x53, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Pressure.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteLoadValue.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteLoadValue.cs new file mode 100644 index 0000000..eee203c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteLoadValue.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AbsoluteLoadValue : AbstractOBDData +{ + #region Properties & Fields + + public Percent Load => new Percent(((256 * A) + B) / 2.55, 0, 25700); + + #endregion + + #region Constructors + + public AbsoluteLoadValue() + : base(0x43, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Load.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionB.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionB.cs new file mode 100644 index 0000000..0b89d0b --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionB.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AbsoluteThrottlePositionB : AbstractOBDData +{ + #region Properties & Fields + + public Percent Position => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public AbsoluteThrottlePositionB() + : base(0x47, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Position.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionC.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionC.cs new file mode 100644 index 0000000..1fa373c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AbsoluteThrottlePositionC.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AbsoluteThrottlePositionC : AbstractOBDData +{ + #region Properties & Fields + + public Percent Position => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public AbsoluteThrottlePositionC() + : base(0x48, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Position.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionD.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionD.cs new file mode 100644 index 0000000..991b98f --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionD.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AcceleratorPedalPositionD : AbstractOBDData +{ + #region Properties & Fields + + public Percent Position => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public AcceleratorPedalPositionD() + : base(0x49, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Position.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionE.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionE.cs new file mode 100644 index 0000000..775d337 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionE.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AcceleratorPedalPositionE : AbstractOBDData +{ + #region Properties & Fields + + public Percent Position => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public AcceleratorPedalPositionE() + : base(0x4A, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Position.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionF.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionF.cs new file mode 100644 index 0000000..a1cb496 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AcceleratorPedalPositionF.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AcceleratorPedalPositionF : AbstractOBDData +{ + #region Properties & Fields + + public Percent Position => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public AcceleratorPedalPositionF() + : base(0x4B, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Position.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/AmbientAirTemperature.cs b/OBD.NET/OBD.NET/OBDData/40-5F/AmbientAirTemperature.cs new file mode 100644 index 0000000..ac73f3b --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/AmbientAirTemperature.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class AmbientAirTemperature : AbstractOBDData +{ + #region Properties & Fields + + public DegreeCelsius Temperature => new DegreeCelsius(A - 40, -40, 215); + + #endregion + + #region Constructors + + public AmbientAirTemperature() + : base(0x46, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Temperature.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/CommandedThrottleActuator.cs b/OBD.NET/OBD.NET/OBDData/40-5F/CommandedThrottleActuator.cs new file mode 100644 index 0000000..54a789c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/CommandedThrottleActuator.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class CommandedThrottleActuator : AbstractOBDData +{ + #region Properties & Fields + + public Percent Value => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public CommandedThrottleActuator() + : base(0x4C, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Value.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/ControlModuleVoltage.cs b/OBD.NET/OBD.NET/OBDData/40-5F/ControlModuleVoltage.cs new file mode 100644 index 0000000..45efd41 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/ControlModuleVoltage.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class ControlModuleVoltage : AbstractOBDData +{ + #region Properties & Fields + + public Volt Voltage => new Volt(((256 * A) + B) / 1000.0, 0, 65.535); + + #endregion + + #region Constructors + + public ControlModuleVoltage() + : base(0x42, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Voltage.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/EngineFuelRate.cs b/OBD.NET/OBD.NET/OBDData/40-5F/EngineFuelRate.cs new file mode 100644 index 0000000..4217efa --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/EngineFuelRate.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class EngineFuelRate : AbstractOBDData +{ + #region Properties & Fields + + public LitresPerHour FuelRate => new LitresPerHour(((256 * A) + B) / 20.0, 0, 3212.75); + + #endregion + + #region Constructors + + public EngineFuelRate() + : base(0x5E, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => FuelRate.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/EngineOilTemperature.cs b/OBD.NET/OBD.NET/OBDData/40-5F/EngineOilTemperature.cs new file mode 100644 index 0000000..0014012 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/EngineOilTemperature.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class EngineOilTemperature : AbstractOBDData +{ + #region Properties & Fields + + public DegreeCelsius Temperature => new DegreeCelsius(A - 40, -40, 210); + + #endregion + + #region Constructors + + public EngineOilTemperature() + : base(0x5C, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Temperature.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/EthanolFuel.cs b/OBD.NET/OBD.NET/OBDData/40-5F/EthanolFuel.cs new file mode 100644 index 0000000..bf16992 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/EthanolFuel.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class EthanolFuel : AbstractOBDData +{ + #region Properties & Fields + + public Percent Value => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public EthanolFuel() + : base(0x52, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Value.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/EvapSystemVaporPressure2.cs b/OBD.NET/OBD.NET/OBDData/40-5F/EvapSystemVaporPressure2.cs new file mode 100644 index 0000000..cdf4ed0 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/EvapSystemVaporPressure2.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class EvapSystemVaporPressure2 : AbstractOBDData +{ + #region Properties & Fields + + public Pascal Pressure => new Pascal(((A * 256) + B) - 32767, -32767, 32768); + + #endregion + + #region Constructors + + public EvapSystemVaporPressure2() + : base(0x54, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Pressure.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs b/OBD.NET/OBD.NET/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs new file mode 100644 index 0000000..a07a36c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/FuelAirCommandedEquivalenceRatio.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class FuelAirCommandedEquivalenceRatio : AbstractOBDData +{ + #region Properties & Fields + + public Ratio Ratio => new Ratio((2.0 / 65536.0) * ((256 * A) + B), 0, 2.0 - double.Epsilon); + + #endregion + + #region Constructors + + public FuelAirCommandedEquivalenceRatio() + : base(0x44, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Ratio.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/FuelInjectionTiming.cs b/OBD.NET/OBD.NET/OBDData/40-5F/FuelInjectionTiming.cs new file mode 100644 index 0000000..c8e25cc --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/FuelInjectionTiming.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class FuelInjectionTiming : AbstractOBDData +{ + #region Properties & Fields + + public Degree Timing => new Degree((((256 * A) + B) / 128.0) - 210, -210, 301.992); + + #endregion + + #region Constructors + + public FuelInjectionTiming() + : base(0x5D, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Timing.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/FuelRailAbsolutePressure.cs b/OBD.NET/OBD.NET/OBDData/40-5F/FuelRailAbsolutePressure.cs new file mode 100644 index 0000000..d329769 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/FuelRailAbsolutePressure.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class FuelRailAbsolutePressure : AbstractOBDData +{ + #region Properties & Fields + + public Kilopascal Pressure => new Kilopascal(10 * ((256 * A) + B), 0, 655350); + + #endregion + + #region Constructors + + public FuelRailAbsolutePressure() + : base(0x59, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Pressure.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/FuelType.cs b/OBD.NET/OBD.NET/OBDData/40-5F/FuelType.cs new file mode 100644 index 0000000..b5e7d21 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/FuelType.cs @@ -0,0 +1,56 @@ +namespace OBD.NET.OBDData._40_5F; + +public class FuelType : AbstractOBDData +{ + #region Properties & Fields + + public FuelTypeValue Type => (FuelTypeValue)A; + + #endregion + + #region Constructors + + public FuelType() + : base(0x51, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Type.ToString(); + + #endregion + + #region Enum + + public enum FuelTypeValue + { + NotAvailable = 0, + Gasoline = 1, + Methanol = 2, + Ethanol = 3, + Diesel = 4, + LPG = 5, + CNG = 6, + Propane = 7, + Electric = 8, + BifuelGasoline = 9, + BifuelMethanol = 10, + BifuelEthanol = 11, + BifuelLPG = 12, + BifuelCNG = 13, + BifuelPropane = 14, + BifuelElectricity = 15, + BifuelElectricAndCombustionEngine = 16, + HybridGasoline = 17, + HybridEthanol = 18, + HybridDiesel = 19, + HybridElectric = 20, + HybridElectricAndCombustionEngine = 21, + HybridRegenerative = 22, + BifuelDiesel = 23 + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/HybridBatteryPackRemainingLife.cs b/OBD.NET/OBD.NET/OBDData/40-5F/HybridBatteryPackRemainingLife.cs new file mode 100644 index 0000000..ac0ab83 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/HybridBatteryPackRemainingLife.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class HybridBatteryPackRemainingLife : AbstractOBDData +{ + #region Properties & Fields + + public Percent RemainingLife => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public HybridBatteryPackRemainingLife() + : base(0x5B, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => RemainingLife.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs b/OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs new file mode 100644 index 0000000..0d48b03 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank13.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class LongtTermSecondaryOxygenSensorTrimBank13 : AbstractOBDData +{ + #region Properties & Fields + + public Percent Bank1 => new Percent((A / 1.28) - 100, -100, 99.2); + public Percent Bank3 => new Percent((B / 1.28) - 100, -100, 99.2); + + #endregion + + #region Constructors + + public LongtTermSecondaryOxygenSensorTrimBank13() + : base(0x56, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Bank1.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs b/OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs new file mode 100644 index 0000000..0cf88f7 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/LongTermSecondaryOxygenSensorTrimBank24.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class LongTermSecondaryOxygenSensorTrimBank24 : AbstractOBDData +{ + #region Properties & Fields + + public Percent Bank2 => new Percent((A / 1.28) - 100, -100, 99.2); + public Percent Bank4 => new Percent((B / 1.28) - 100, -100, 99.2); + + #endregion + + #region Constructors + + public LongTermSecondaryOxygenSensorTrimBank24() + : base(0x58, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Bank2.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/MaximumValueForAirFlowRate.cs b/OBD.NET/OBD.NET/OBDData/40-5F/MaximumValueForAirFlowRate.cs new file mode 100644 index 0000000..ab23996 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/MaximumValueForAirFlowRate.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class MaximumValueForAirFlowRate : AbstractOBDData +{ + #region Properties & Fields + + public GramPerSec Value => new GramPerSec(A * 10, 0, 2550); + + #endregion + + #region Constructors + + public MaximumValueForAirFlowRate() + : base(0x50, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => Value.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/MaximumValues.cs b/OBD.NET/OBD.NET/OBDData/40-5F/MaximumValues.cs new file mode 100644 index 0000000..8295d54 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/MaximumValues.cs @@ -0,0 +1,29 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class MaximumValues : AbstractOBDData +{ + #region Properties & Fields + + public Ratio FuelAirEquivalenceRatio => new Ratio(A, 0, 255); + public Volt OxygenSensorVoltage => new Volt(B, 0, 255); + public Milliampere OxygenSensorCurrent => new Milliampere(C, 0, 255); + public Kilopascal IntakeManifoldAbsolutePressure => new Kilopascal(D * 10, 0, 2550); + + #endregion + + #region Constructors + + public MaximumValues() + : base(0x4F, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => FuelAirEquivalenceRatio.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/MonitorStatusThisDriveCycle.cs b/OBD.NET/OBD.NET/OBDData/40-5F/MonitorStatusThisDriveCycle.cs new file mode 100644 index 0000000..3d8890a --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/MonitorStatusThisDriveCycle.cs @@ -0,0 +1,55 @@ +namespace OBD.NET.OBDData._40_5F; + +public class MonitorStatusThisDriveCycle : AbstractOBDData +{ + #region Properties & Fields + + public bool IsComponentsTestAvailable => (B & (1 << 3)) != 0; + public bool IsComponentsTestComplete => (B & (1 << 7)) == 0; + + public bool IsFuelSystemTestAvailable => (B & (1 << 1)) != 0; + public bool IsFuelSystemTestComplete => (B & (1 << 5)) == 0; + + public bool IsMisfireTestAvailable => (B & (1 << 0)) != 0; + public bool IsMisfireTestComplete => (B & (1 << 4)) == 0; + + public bool IsEGRSystemTestAvailable => (C & (1 << 7)) != 0; + public bool IsEGRSystemTestComplete => (D & (1 << 7)) == 0; + + public bool IsOxygenSensorHeaterTestAvailable => (C & (1 << 6)) != 0; + public bool IsOxygenSensorHeaterTestComplete => (D & (1 << 6)) == 0; + + public bool IsOxygenSensorTestAvailable => (C & (1 << 5)) != 0; + public bool IsOxygenSensorTestComplete => (D & (1 << 5)) == 0; + + public bool IsACRefrigerantTestAvailable => (C & (1 << 4)) != 0; + public bool IsACRefrigerantTestComplete => (D & (1 << 4)) == 0; + + public bool IsSecondaryAirSystemTestAvailable => (C & (1 << 3)) != 0; + public bool IsSecondaryAirSystemTestComplete => (D & (1 << 3)) == 0; + + public bool IsEvaporativeSystemTestAvailable => (C & (1 << 2)) != 0; + public bool IsEvaporativeSystemTestComplete => (D & (1 << 2)) == 0; + + public bool IsHeatedCatalystTestAvailable => (C & (1 << 1)) != 0; + public bool IsHeatedCatalystTestComplete => (D & (1 << 1)) == 0; + + public bool IsCatalystAvailable => (C & (1 << 0)) != 0; + public bool IsCatalystComplete => (D & (1 << 0)) == 0; + + #endregion + + #region Constructors + + public MonitorStatusThisDriveCycle() + : base(0x41, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Empty; + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/PidsSupported41_60.cs b/OBD.NET/OBD.NET/OBDData/40-5F/PidsSupported41_60.cs new file mode 100644 index 0000000..13f1228 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/PidsSupported41_60.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData._40_5F; + +public class PidsSupported41_60 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupported41_60() + : base(0x40, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs b/OBD.NET/OBD.NET/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs new file mode 100644 index 0000000..0d59ace --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/RelativeAcceleratorPedalPosition.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class RelativeAcceleratorPedalPosition : AbstractOBDData +{ + #region Properties & Fields + + public Percent PedalPosition => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public RelativeAcceleratorPedalPosition() + : base(0x5A, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => PedalPosition.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/RelativeThrottlePosition.cs b/OBD.NET/OBD.NET/OBDData/40-5F/RelativeThrottlePosition.cs new file mode 100644 index 0000000..7facdf6 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/RelativeThrottlePosition.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class RelativeThrottlePosition : AbstractOBDData +{ + #region Properties & Fields + + public Percent Position => new Percent(A / 2.55, 0, 100); + + #endregion + + #region Constructors + + public RelativeThrottlePosition() + : base(0x45, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Position.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs b/OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs new file mode 100644 index 0000000..0aa7775 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank13.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class ShortTermSecondaryOxygenSensorTrimBank13 : AbstractOBDData +{ + #region Properties & Fields + + public Percent Bank1 => new Percent((A / 1.28) - 100, -100, 99.2); + public Percent Bank3 => new Percent((B / 1.28) - 100, -100, 99.2); + + #endregion + + #region Constructors + + public ShortTermSecondaryOxygenSensorTrimBank13() + : base(0x55, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Bank1.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs b/OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs new file mode 100644 index 0000000..93f0571 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/ShortTermSecondaryOxygenSensorTrimBank24.cs @@ -0,0 +1,27 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class ShortTermSecondaryOxygenSensorTrimBank24 : AbstractOBDData +{ + #region Properties & Fields + + public Percent Bank2 => new Percent((A / 1.28) - 100, -100, 99.2); + public Percent Bank4 => new Percent((B / 1.28) - 100, -100, 99.2); + + #endregion + + #region Constructors + + public ShortTermSecondaryOxygenSensorTrimBank24() + : base(0x57, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Bank2.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/TimeRunWithMILOn.cs b/OBD.NET/OBD.NET/OBDData/40-5F/TimeRunWithMILOn.cs new file mode 100644 index 0000000..7213b50 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/TimeRunWithMILOn.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class TimeRunWithMILOn : AbstractOBDData +{ + #region Properties & Fields + + public Minute Time => new Minute((256 * A) + B, 0, 65535); + + #endregion + + #region Constructors + + public TimeRunWithMILOn() + : base(0x4D, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Time.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs b/OBD.NET/OBD.NET/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs new file mode 100644 index 0000000..54af431 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/40-5F/TimeSinceTroubleCodesCleared.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._40_5F; + +public class TimeSinceTroubleCodesCleared : AbstractOBDData +{ + #region Properties & Fields + + public Minute Time => new Minute((256 * A) + B, 0, 65535); + + #endregion + + #region Constructors + + public TimeSinceTroubleCodesCleared() + : base(0x4E, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Time.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/ActualEnginePercentTorque.cs b/OBD.NET/OBD.NET/OBDData/60-7F/ActualEnginePercentTorque.cs new file mode 100644 index 0000000..7d57d8c --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/ActualEnginePercentTorque.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._60_7F; + +public class ActualEnginePercentTorque : AbstractOBDData +{ + #region Properties & Fields + + public Percent Torque => new Percent(A - 125, -125, 125); + + #endregion + + #region Constructors + + public ActualEnginePercentTorque() + : base(0x62, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Torque.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/DriversDemandEnginePercentTorque.cs b/OBD.NET/OBD.NET/OBDData/60-7F/DriversDemandEnginePercentTorque.cs new file mode 100644 index 0000000..3137581 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/DriversDemandEnginePercentTorque.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._60_7F; + +public class DriversDemandEnginePercentTorque : AbstractOBDData +{ + #region Properties & Fields + + public Percent Torque => new Percent(A - 125, -125, 125); + + #endregion + + #region Constructors + + public DriversDemandEnginePercentTorque() + : base(0x61, 1) + { } + + #endregion + + #region Methods + + public override string ToString() => Torque.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/EngineCoolantTemperatureSensor.cs b/OBD.NET/OBD.NET/OBDData/60-7F/EngineCoolantTemperatureSensor.cs new file mode 100644 index 0000000..fcf0ed3 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/EngineCoolantTemperatureSensor.cs @@ -0,0 +1,28 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._60_7F; + +public class EngineCoolantTemperatureSensor : AbstractOBDData +{ + #region Properties & Fields + + public int SensorsSupported => A; + public DegreeCelsius Sensor1 => new DegreeCelsius(B - 40, -40, 215); + public DegreeCelsius Sensor2 => new DegreeCelsius(C - 40, -40, 215); + + #endregion + + #region Constructors + + public EngineCoolantTemperatureSensor() + : base(0x67, 3) + { } + + #endregion + + #region Methods + + public override string ToString() => Sensor1.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/EnginePercentTorqueData.cs b/OBD.NET/OBD.NET/OBDData/60-7F/EnginePercentTorqueData.cs new file mode 100644 index 0000000..b697adc --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/EnginePercentTorqueData.cs @@ -0,0 +1,30 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._60_7F; + +public class EnginePercentTorqueData : AbstractOBDData +{ + #region Properties & Fields + + public Percent Idle => new Percent(A - 125, -125, 125); + public Percent EnginePoint1 => new Percent(B - 125, -125, 125); + public Percent EnginePoint2 => new Percent(C - 125, -125, 125); + public Percent EnginePoint3 => new Percent(D - 125, -125, 125); + public Percent EnginePoint4 => new Percent(E - 125, -125, 125); + + #endregion + + #region Constructors + + public EnginePercentTorqueData() + : base(0x64, 5) + { } + + #endregion + + #region Methods + + public override string ToString() => Idle.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/EngineReferenceTorque.cs b/OBD.NET/OBD.NET/OBDData/60-7F/EngineReferenceTorque.cs new file mode 100644 index 0000000..8c1212b --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/EngineReferenceTorque.cs @@ -0,0 +1,26 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._60_7F; + +public class EngineReferenceTorque : AbstractOBDData +{ + #region Properties & Fields + + public NewtonMetre Torque => new NewtonMetre((256 * A) + B, 0, 65535); + + #endregion + + #region Constructors + + public EngineReferenceTorque() + : base(0x63, 2) + { } + + #endregion + + #region Methods + + public override string ToString() => Torque.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/IntakeAirTemperatureSensor.cs b/OBD.NET/OBD.NET/OBDData/60-7F/IntakeAirTemperatureSensor.cs new file mode 100644 index 0000000..6f9c81a --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/IntakeAirTemperatureSensor.cs @@ -0,0 +1,32 @@ +using OBD.NET.DataTypes; + +namespace OBD.NET.OBDData._60_7F; + +public class IntakeAirTemperatureSensor : AbstractOBDData +{ + #region Properties & Fields + + public int SensorsSupported => A; + public DegreeCelsius Bank1Sensor1 => new DegreeCelsius(B - 40, -40, 215); + public DegreeCelsius Bank1Sensor2 => new DegreeCelsius(C - 40, -40, 215); + public DegreeCelsius Bank1Sensor3 => new DegreeCelsius(D - 40, -40, 215); + public DegreeCelsius Bank2Sensor1 => new DegreeCelsius(E - 40, -40, 215); + public DegreeCelsius Bank2Sensor2 => new DegreeCelsius(RawData[5] - 40, -40, 215); + public DegreeCelsius Bank2Sensor3 => new DegreeCelsius(RawData[6] - 40, -40, 215); + + #endregion + + #region Constructors + + public IntakeAirTemperatureSensor() + : base(0x68, 7) + { } + + #endregion + + #region Methods + + public override string ToString() => Bank1Sensor1.ToString(); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/60-7F/PidsSupported61_80.cs b/OBD.NET/OBD.NET/OBDData/60-7F/PidsSupported61_80.cs new file mode 100644 index 0000000..b59c8b1 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/60-7F/PidsSupported61_80.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData._60_7F; + +public class PidsSupported61_80 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupported61_80() + : base(0x60, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/80-9F/PidsSupported81_A0.cs b/OBD.NET/OBD.NET/OBDData/80-9F/PidsSupported81_A0.cs new file mode 100644 index 0000000..49fc8a3 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/80-9F/PidsSupported81_A0.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData._80_9F; + +public class PidsSupported81_A0 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupported81_A0() + : base(0x80, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/A0-BF/PidsSupportedA1_C0.cs b/OBD.NET/OBD.NET/OBDData/A0-BF/PidsSupportedA1_C0.cs new file mode 100644 index 0000000..7e0525d --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/A0-BF/PidsSupportedA1_C0.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData.A0_BF; + +public class PidsSupportedA1_C0 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupportedA1_C0() + : base(0xA0, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/AbstractOBDData.cs b/OBD.NET/OBD.NET/OBDData/AbstractOBDData.cs new file mode 100644 index 0000000..35b5064 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/AbstractOBDData.cs @@ -0,0 +1,72 @@ +using OBD.NET.Extensions; + +namespace OBD.NET.OBDData; + +public abstract class AbstractOBDData : IOBDData +{ + #region Properties & Fields + + public byte PID { get; } + private readonly int _length; + + private byte[] _rawData; + public byte[] RawData + { + get => _rawData; + set + { + if (value.Length != _length) + throw new ArgumentException("The provided raw-data is not valid", nameof(value)); + + _rawData = value; + } + } + + public bool IsValid => RawData.Length == _length; + + protected byte A => RawData.Length > 0 ? RawData[0] : default(byte); + protected byte B => RawData.Length > 1 ? RawData[1] : default(byte); + protected byte C => RawData.Length > 2 ? RawData[2] : default(byte); + protected byte D => RawData.Length > 3 ? RawData[3] : default(byte); + protected byte E => RawData.Length > 4 ? RawData[4] : default(byte); + + #endregion + + #region Constructors + + protected AbstractOBDData(byte pid, int length) + { + PID = pid; + _length = length; + } + + protected AbstractOBDData(byte pid, int length, byte[] rawData) + : this(pid, length) + { + RawData = rawData; + } + + #endregion + + #region Methods + + public void Load(string data) + { + try + { + if (((data.Length % 2) != 0) || ((data.Length / 2) < _length)) + throw new ArgumentException("The provided data is not valid", nameof(data)); + + _rawData = new byte[_length]; + for (int i = 0; i < _length; ++i) + _rawData[i] = (byte)((data[i << 1].GetHexVal() << 4) + (data[(i << 1) + 1].GetHexVal())); + } + catch + { + _rawData = new byte[0]; + throw; + } + } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/AbstractPidsSupported.cs b/OBD.NET/OBD.NET/OBDData/AbstractPidsSupported.cs new file mode 100644 index 0000000..379feba --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/AbstractPidsSupported.cs @@ -0,0 +1,32 @@ +using System.Collections; + +namespace OBD.NET.OBDData; + +public abstract class AbstractPidsSupported : AbstractOBDData +{ + #region Properties & Fields + + public int[] SupportedPids + { + get + { + List supportedPids = new List(); + BitArray bitArray = new BitArray(new[] { D, C, B, A }); + + for (int i = 0x01; i <= 0x20; i++) + if (bitArray.Get(bitArray.Length - i)) + supportedPids.Add(PID + i); + + return supportedPids.ToArray(); + } + } + + #endregion + + #region Constructors + + public AbstractPidsSupported(byte pid, int length) : base(pid, length) + { } + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/C0-DF/PidsSupportedC1_E0.cs b/OBD.NET/OBD.NET/OBDData/C0-DF/PidsSupportedC1_E0.cs new file mode 100644 index 0000000..f5d7e04 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/C0-DF/PidsSupportedC1_E0.cs @@ -0,0 +1,18 @@ +namespace OBD.NET.OBDData.C0_DF; + +public class PidsSupportedC1_E0 : AbstractPidsSupported +{ + #region Constructors + + public PidsSupportedC1_E0() + : base(0xC0, 4) + { } + + #endregion + + #region Methods + + public override string ToString() => string.Join(",", SupportedPids); + + #endregion +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/OBDData/IOBDData.cs b/OBD.NET/OBD.NET/OBDData/IOBDData.cs new file mode 100644 index 0000000..8186090 --- /dev/null +++ b/OBD.NET/OBD.NET/OBDData/IOBDData.cs @@ -0,0 +1,8 @@ +namespace OBD.NET.OBDData; + +public interface IOBDData +{ + byte PID { get; } + + void Load(string data); +} \ No newline at end of file diff --git a/OBD.NET/OBD.NET/Util/AsyncManulResetEvent.cs b/OBD.NET/OBD.NET/Util/AsyncManulResetEvent.cs new file mode 100644 index 0000000..a00b249 --- /dev/null +++ b/OBD.NET/OBD.NET/Util/AsyncManulResetEvent.cs @@ -0,0 +1,50 @@ +namespace OBD.NET.Util; + +/// +/// Notifies one or more waiting awaiters that an event has occurred +/// +public class AsyncManualResetEvent +{ + #region Properties & Fields + + private volatile TaskCompletionSource _tcs = new TaskCompletionSource(); + + #endregion + + #region Methods + + /// + /// Waits the async. + /// + /// + public Task WaitAsync() => _tcs.Task; + + //public void Set() { m_tcs.TrySetResult(true); } + /// + /// Sets the state of the event to signaled, allowing one or more waiting awaiters to proceed. + /// + public void Set() + { + TaskCompletionSource tcs = _tcs; + Task.Factory.StartNew(s => ((TaskCompletionSource)s).TrySetResult(true), + tcs, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default); + + tcs.Task.Wait(); + } + + /// + /// Sets the state of the event to nonsignaled, causing awaiters to block. + /// + public void Reset() + { + while (true) + { + TaskCompletionSource tcs = _tcs; + if (!tcs.Task.IsCompleted || + (Interlocked.CompareExchange(ref _tcs, new TaskCompletionSource(), tcs) == tcs)) + return; + } + } + + #endregion +} \ No newline at end of file