namespace NucuCar.Sensors.Environment.Bmxx80.Units { /// /// Structure representing pressure /// public struct Pressure { private const double MillibarRatio = 0.01; private const double KilopascalRatio = 0.001; private const double HectopascalRatio = 0.01; private const double InchOfMercuryRatio = 0.000295301; private const double MillimeterOfMercuryRatio = 0.00750062; private double _pascal; private Pressure(double pascal) { _pascal = pascal; } /// /// The mean sea-level pressure (MSLP) is the average atmospheric pressure at mean sea level /// public static Pressure MeanSeaLevel => Pressure.FromPascal(101325); /// /// Pressure in Pa /// public double Pascal => _pascal; /// /// Pressure in mbar /// public double Millibar => MillibarRatio * _pascal; /// /// Pressure in kPa /// public double Kilopascal => KilopascalRatio * _pascal; /// /// Pressure in hPa /// public double Hectopascal => HectopascalRatio * _pascal; /// /// Pressure in inHg /// public double InchOfMercury => InchOfMercuryRatio * _pascal; /// /// Pressure in mmHg /// public double MillimeterOfMercury => MillimeterOfMercuryRatio * _pascal; /// /// Creates Pressure instance from pressure in Pa /// /// Pressure value in Pa /// Pressure instance public static Pressure FromPascal(double value) { return new Pressure(value); } /// /// Creates Pressure instance from pressure in mbar /// /// Pressure value in mbar /// Pressure instance public static Pressure FromMillibar(double value) { return new Pressure(value / MillibarRatio); } /// /// Creates Pressure instance from pressure in kPa /// /// Pressure value in kPa /// Pressure instance public static Pressure FromKilopascal(double value) { return new Pressure(value / KilopascalRatio); } /// /// Creates Pressure instance from pressure in hPa /// /// Pressure value in hPa /// Pressure instance public static Pressure FromHectopascal(double value) { return new Pressure(value / HectopascalRatio); } /// /// Creates Pressure instance from pressure in inHg /// /// Pressure value in inHg /// Pressure instance public static Pressure FromInchOfMercury(double value) { return new Pressure(value / InchOfMercuryRatio); } /// /// Creates Pressure instance from pressure in mmHg /// /// Pressure value in mmHg /// Pressure instance public static Pressure FromMillimeterOfMercury(double value) { return new Pressure(value / MillimeterOfMercuryRatio); } } }