diff --git a/OBD.NET/OBD.NET/DataTypes/Count.cs b/OBD.NET/OBD.NET/DataTypes/Count.cs new file mode 100644 index 0000000..75b70c6 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Count.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Count : GenericData + { + #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/DataTypes/Degree.cs b/OBD.NET/OBD.NET/DataTypes/Degree.cs new file mode 100644 index 0000000..a5de766 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Degree.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Degree : GenericData + { + #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 + } +} diff --git a/OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs b/OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs new file mode 100644 index 0000000..bed3565 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/DegreeCelsius.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class DegreeCelsius : GenericData + { + #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 + } +} diff --git a/OBD.NET/OBD.NET/DataTypes/GenericData.cs b/OBD.NET/OBD.NET/DataTypes/GenericData.cs new file mode 100644 index 0000000..3a7f764 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/GenericData.cs @@ -0,0 +1,50 @@ +using System; + +namespace OBD.NET.DataTypes +{ + public class GenericData + { + #region Properties & Fields + + public double Value { get; } + public double MinValue { get; } + public double MaxValue { get; } + public bool IsFloatingPointValue { get; } + + #endregion + + #region Constructors + + public GenericData(double value, double minValue, double maxValue) + { + this.Value = value; + this.MinValue = minValue; + this.MaxValue = maxValue; + this.IsFloatingPointValue = true; + } + + public 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) + { + return p.Value; + } + + public static implicit operator int(GenericData p) + { + return (int)Math.Round(p.Value); + } + + #endregion + } +} diff --git a/OBD.NET/OBD.NET/DataTypes/GramPerSec.cs b/OBD.NET/OBD.NET/DataTypes/GramPerSec.cs new file mode 100644 index 0000000..37e3661 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/GramPerSec.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class GramPerSec : GenericData + { + #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/DataTypes/Kilometre.cs b/OBD.NET/OBD.NET/DataTypes/Kilometre.cs new file mode 100644 index 0000000..1683853 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Kilometre.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Kilometre : GenericData + { + #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/DataTypes/KilometrePerHour.cs b/OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs new file mode 100644 index 0000000..5941a2f --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/KilometrePerHour.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class KilometrePerHour : GenericData + { + #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/DataTypes/Kilopascal.cs b/OBD.NET/OBD.NET/DataTypes/Kilopascal.cs new file mode 100644 index 0000000..dccf052 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Kilopascal.cs @@ -0,0 +1,26 @@ +namespace OBD.NET.DataTypes +{ + public class Kilopascal : GenericData + { + #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) + { + return new Pascal(pa.Value / 1000.0, pa.MinValue / 1000.0, pa.MaxValue / 1000.0); + } + + #endregion + } +} diff --git a/OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs b/OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs new file mode 100644 index 0000000..3af5b13 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/LitresPerHour.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class LitresPerHour : GenericData + { + #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/DataTypes/Milliampere.cs b/OBD.NET/OBD.NET/DataTypes/Milliampere.cs new file mode 100644 index 0000000..0c93be2 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Milliampere.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Milliampere : GenericData + { + #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/DataTypes/Minute.cs b/OBD.NET/OBD.NET/DataTypes/Minute.cs new file mode 100644 index 0000000..cebbc8c --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Minute.cs @@ -0,0 +1,28 @@ +namespace OBD.NET.DataTypes +{ + public class Minute : GenericData + { + #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) + { + return 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/DataTypes/NewtonMetre.cs b/OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs new file mode 100644 index 0000000..680bc53 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/NewtonMetre.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class NewtonMetre : GenericData + { + #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/DataTypes/Pascal.cs b/OBD.NET/OBD.NET/DataTypes/Pascal.cs new file mode 100644 index 0000000..c37095f --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Pascal.cs @@ -0,0 +1,28 @@ +namespace OBD.NET.DataTypes +{ + public class Pascal : GenericData + { + #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) + { + return 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/DataTypes/Percent.cs b/OBD.NET/OBD.NET/DataTypes/Percent.cs new file mode 100644 index 0000000..6c07298 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Percent.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Percent : GenericData + { + #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/DataTypes/Ratio.cs b/OBD.NET/OBD.NET/DataTypes/Ratio.cs new file mode 100644 index 0000000..9e85317 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Ratio.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Ratio : GenericData + { + #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/DataTypes/RevolutionsPerMinute.cs b/OBD.NET/OBD.NET/DataTypes/RevolutionsPerMinute.cs new file mode 100644 index 0000000..561d6a1 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/RevolutionsPerMinute.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class RevolutionsPerMinute : GenericData + { + #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/DataTypes/Second.cs b/OBD.NET/OBD.NET/DataTypes/Second.cs new file mode 100644 index 0000000..ec15a44 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Second.cs @@ -0,0 +1,26 @@ +namespace OBD.NET.DataTypes +{ + public class Second : GenericData + { + #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) + { + return new Minute(s.Value / 60.0, s.MinValue / 60.0, s.MaxValue / 60.0); + } + + #endregion + } +} diff --git a/OBD.NET/OBD.NET/DataTypes/Volt.cs b/OBD.NET/OBD.NET/DataTypes/Volt.cs new file mode 100644 index 0000000..7669cf8 --- /dev/null +++ b/OBD.NET/OBD.NET/DataTypes/Volt.cs @@ -0,0 +1,17 @@ +namespace OBD.NET.DataTypes +{ + public class Volt : GenericData + { + #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/OBD.NET.csproj b/OBD.NET/OBD.NET/OBD.NET.csproj index b4a8c47..0a9f742 100644 --- a/OBD.NET/OBD.NET/OBD.NET.csproj +++ b/OBD.NET/OBD.NET/OBD.NET.csproj @@ -45,113 +45,131 @@ + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +