mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 19:55:48 +01:00
Add new Imperial Pressure unit psi (#2758)
Signed-off-by: James Melville <jamesmelville@gmail.com>
This commit is contained in:
parent
92679aa6fd
commit
b594d0a8b7
@ -49,6 +49,9 @@ public final class ImperialUnits extends CustomUnits {
|
||||
public static final Unit<Pressure> INCH_OF_MERCURY = addUnit(new TransformedUnit<>("inHg", Units.PASCAL,
|
||||
MultiplyConverter.ofRational(BigInteger.valueOf(3386388), BigInteger.valueOf(1000))));
|
||||
|
||||
public static final Unit<Pressure> POUND_FORCE_SQUARE_INCH = addUnit(new TransformedUnit<>("psi", Units.PASCAL,
|
||||
MultiplyConverter.ofRational(BigInteger.valueOf(6894757), BigInteger.valueOf(1000))));
|
||||
|
||||
public static final Unit<Temperature> FAHRENHEIT = addUnit(
|
||||
new TransformedUnit<>("°F", Units.KELVIN, MultiplyConverter
|
||||
.ofRational(BigInteger.valueOf(5), BigInteger.valueOf(9)).concatenate(new AddConverter(459.67))));
|
||||
@ -104,6 +107,7 @@ public final class ImperialUnits extends CustomUnits {
|
||||
SimpleUnitFormat.getInstance().label(LEAGUE, LEAGUE.getSymbol());
|
||||
SimpleUnitFormat.getInstance().label(GALLON_LIQUID_US, GALLON_LIQUID_US.getSymbol());
|
||||
SimpleUnitFormat.getInstance().label(GALLON_PER_MINUTE, "gal/min");
|
||||
SimpleUnitFormat.getInstance().label(POUND_FORCE_SQUARE_INCH, POUND_FORCE_SQUARE_INCH.getSymbol());
|
||||
}
|
||||
|
||||
private ImperialUnits() {
|
||||
|
@ -75,6 +75,14 @@ public class UnitsTest {
|
||||
isQuantityEquals(Quantities.getQuantity(BigDecimal.ONE, ImperialUnits.INCH_OF_MERCURY)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPascal2psiConversion() {
|
||||
Quantity<Pressure> pascal = Quantities.getQuantity(new BigDecimal("6894.757"), SIUnits.PASCAL);
|
||||
|
||||
assertThat(pascal.to(ImperialUnits.POUND_FORCE_SQUARE_INCH),
|
||||
isQuantityEquals(Quantities.getQuantity(BigDecimal.ONE, ImperialUnits.POUND_FORCE_SQUARE_INCH)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testmmHg2PascalConversion() {
|
||||
Quantity<Pressure> mmHg = Quantities.getQuantity(BigDecimal.ONE, Units.MILLIMETRE_OF_MERCURY);
|
||||
|
Loading…
Reference in New Issue
Block a user