javax.measure.quantity.Pressure Java Examples
The following examples show how to use
javax.measure.quantity.Pressure.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroupItemOSGiTest.java From openhab-core with Eclipse Public License 2.0 | 7 votes |
@Test public void assertThatNumberGroupItemWithDifferentDimensionsCalculatesCorrectState() { NumberItem baseItem = createNumberItem("baseItem", Temperature.class, UnDefType.NULL); GroupFunctionDTO gfDTO = new GroupFunctionDTO(); gfDTO.name = "sum"; GroupFunction function = groupFunctionHelper.createGroupFunction(gfDTO, Collections.emptyList(), Temperature.class); GroupItem groupItem = new GroupItem("number", baseItem, function); groupItem.setUnitProvider(unitProvider); groupItem.setItemStateConverter(itemStateConverter); NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType<>("23 °C")); groupItem.addMember(celsius); NumberItem hectoPascal = createNumberItem("F", Pressure.class, new QuantityType<>("1010 hPa")); groupItem.addMember(hectoPascal); NumberItem percent = createNumberItem("K", Dimensionless.class, new QuantityType<>("110 %")); groupItem.addMember(percent); QuantityType<?> state = groupItem.getStateAs(QuantityType.class); assertThat(state, is(new QuantityType<>("23 °C"))); groupItem.stateUpdated(celsius, UnDefType.NULL); assertThat(groupItem.getState(), is(new QuantityType<>("23 °C"))); }
Example #2
Source File: GroupItemTest.java From smarthome with Eclipse Public License 2.0 | 6 votes |
@Test public void assertThatNumberGroupItemWithDifferentDimensionsCalculatesCorrectState() { NumberItem baseItem = createNumberItem("baseItem", Temperature.class, UnDefType.NULL); GroupFunctionDTO gfDTO = new GroupFunctionDTO(); gfDTO.name = "sum"; GroupFunction function = groupFunctionHelper.createGroupFunction(gfDTO, Collections.emptyList(), Temperature.class); GroupItem groupItem = new GroupItem("number", baseItem, function); groupItem.setUnitProvider(unitProvider); groupItem.setItemStateConverter(itemStateConverter); NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType<Temperature>("23 °C")); groupItem.addMember(celsius); NumberItem hectoPascal = createNumberItem("F", Pressure.class, new QuantityType<Pressure>("1010 hPa")); groupItem.addMember(hectoPascal); NumberItem percent = createNumberItem("K", Dimensionless.class, new QuantityType<Dimensionless>("110 %")); groupItem.addMember(percent); QuantityType<?> state = (QuantityType<?>) groupItem.getStateAs(QuantityType.class); assertThat(state, is(new QuantityType<Temperature>("23 °C"))); groupItem.stateUpdated(celsius, UnDefType.NULL); assertThat(groupItem.getState(), is(new QuantityType<Temperature>("23 °C"))); }
Example #3
Source File: QuantityTypeArithmeticGroupFunctionTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testMinFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<Pressure>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Min(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<Temperature>("23.54 °C"), state); }
Example #4
Source File: QuantityTypeArithmeticGroupFunctionTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testMaxFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<Pressure>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<Temperature>("23.54 °C"), state); }
Example #5
Source File: QuantityTypeArithmeticGroupFunctionTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testAvgFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<Temperature>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Avg(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<Temperature>("23.54 °C"), state); }
Example #6
Source File: QuantityTypeArithmeticGroupFunctionTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testSumFunctionQuantityTypeIncompatibleUnits() { items = new LinkedHashSet<Item>(); // we need an ordered set to guarantee the Unit of the first entry items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<Temperature>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<Temperature>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Sum(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<Temperature>("23.54 °C"), state); }
Example #7
Source File: I18nProviderImpl.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private void initDimensionMap() { Map<SystemOfUnits, Unit<? extends Quantity<?>>> temperatureMap = new HashMap<>(); temperatureMap.put(SIUnits.getInstance(), SIUnits.CELSIUS); temperatureMap.put(ImperialUnits.getInstance(), ImperialUnits.FAHRENHEIT); dimensionMap.put(Temperature.class, temperatureMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> pressureMap = new HashMap<>(); pressureMap.put(SIUnits.getInstance(), HECTO(SIUnits.PASCAL)); pressureMap.put(ImperialUnits.getInstance(), ImperialUnits.INCH_OF_MERCURY); dimensionMap.put(Pressure.class, pressureMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> speedMap = new HashMap<>(); speedMap.put(SIUnits.getInstance(), SIUnits.KILOMETRE_PER_HOUR); speedMap.put(ImperialUnits.getInstance(), ImperialUnits.MILES_PER_HOUR); dimensionMap.put(Speed.class, speedMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> lengthMap = new HashMap<>(); lengthMap.put(SIUnits.getInstance(), SIUnits.METRE); lengthMap.put(ImperialUnits.getInstance(), ImperialUnits.INCH); dimensionMap.put(Length.class, lengthMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> intensityMap = new HashMap<>(); intensityMap.put(SIUnits.getInstance(), SmartHomeUnits.IRRADIANCE); intensityMap.put(ImperialUnits.getInstance(), SmartHomeUnits.IRRADIANCE); dimensionMap.put(Intensity.class, intensityMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> percentMap = new HashMap<>(); percentMap.put(SIUnits.getInstance(), SmartHomeUnits.ONE); percentMap.put(ImperialUnits.getInstance(), SmartHomeUnits.ONE); dimensionMap.put(Dimensionless.class, percentMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> angleMap = new HashMap<>(); angleMap.put(SIUnits.getInstance(), SmartHomeUnits.DEGREE_ANGLE); angleMap.put(ImperialUnits.getInstance(), SmartHomeUnits.DEGREE_ANGLE); dimensionMap.put(Angle.class, angleMap); }
Example #8
Source File: BlukiiHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public void onScanRecordReceived(BluetoothScanNotification scanNotification) { final byte[] manufacturerData = scanNotification.getManufacturerData(); if (manufacturerData != null) { final BlukiiData blukiiData = decoder.decode(manufacturerData); if (blukiiData != null) { updateState(BlukiiBindingConstants.CHANNEL_ID_BATTERY, new DecimalType(blukiiData.battery)); blukiiData.environment.ifPresent(environment -> { updateState(BlukiiBindingConstants.CHANNEL_ID_TEMPERATURE, new QuantityType<Temperature>(environment.temperature, SIUnits.CELSIUS)); updateState(BlukiiBindingConstants.CHANNEL_ID_HUMIDITY, new QuantityType<Dimensionless>(environment.humidity, SmartHomeUnits.PERCENT)); updateState(BlukiiBindingConstants.CHANNEL_ID_PRESSURE, new QuantityType<Pressure>(environment.pressure, MetricPrefix.HECTO(SIUnits.PASCAL))); updateState(BlukiiBindingConstants.CHANNEL_ID_LUMINANCE, new QuantityType<Illuminance>(environment.luminance, SmartHomeUnits.LUX)); }); blukiiData.accelerometer.ifPresent(accelerometer -> { updateState(BlukiiBindingConstants.CHANNEL_ID_TILTX, new QuantityType<Angle>(accelerometer.tiltX, SmartHomeUnits.DEGREE_ANGLE)); updateState(BlukiiBindingConstants.CHANNEL_ID_TILTY, new QuantityType<Angle>(accelerometer.tiltY, SmartHomeUnits.DEGREE_ANGLE)); updateState(BlukiiBindingConstants.CHANNEL_ID_TILTZ, new QuantityType<Angle>(accelerometer.tiltZ, SmartHomeUnits.DEGREE_ANGLE)); }); blukiiData.magnetometer.ifPresent(magnetometer -> { // It isn't easy to get a heading from these values without any calibration, so we ignore those // right // now. }); } } super.onScanRecordReceived(scanNotification); }
Example #9
Source File: SmartHomeUnitsTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testPascal2mmHgConversion() { Quantity<Pressure> pascal = Quantities.getQuantity(new BigDecimal("133.322368"), SIUnits.PASCAL); assertThat(pascal.to(SmartHomeUnits.MILLIMETRE_OF_MERCURY), is(Quantities.getQuantity(new BigDecimal("1.000"), SmartHomeUnits.MILLIMETRE_OF_MERCURY))); }
Example #10
Source File: SmartHomeUnitsTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testmmHg2PascalConversion() { Quantity<Pressure> mmHg = Quantities.getQuantity(BigDecimal.ONE, SmartHomeUnits.MILLIMETRE_OF_MERCURY); assertThat(mmHg.to(SIUnits.PASCAL), is(Quantities.getQuantity(new BigDecimal("133.322368"), SIUnits.PASCAL))); assertThat(mmHg.to(HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(new BigDecimal("1.33322368"), HECTO(SIUnits.PASCAL)))); }
Example #11
Source File: SmartHomeUnitsTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testPascal2inHgConversion() { Quantity<Pressure> pascal = Quantities.getQuantity(new BigDecimal("3386.388"), SIUnits.PASCAL); assertThat(pascal.to(ImperialUnits.INCH_OF_MERCURY), is(Quantities.getQuantity(new BigDecimal("1.000"), ImperialUnits.INCH_OF_MERCURY))); }
Example #12
Source File: SmartHomeUnitsTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testinHg2PascalConversion() { Quantity<Pressure> inHg = Quantities.getQuantity(BigDecimal.ONE, ImperialUnits.INCH_OF_MERCURY); assertThat(inHg.to(SIUnits.PASCAL), is(Quantities.getQuantity(new BigDecimal("3386.388"), SIUnits.PASCAL))); assertThat(inHg.to(HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(new BigDecimal("33.86388"), HECTO(SIUnits.PASCAL)))); }
Example #13
Source File: MeteoBlueHandler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private State getStateForType(String type, BigDecimal value) { State state = new DecimalType(value); if (type.equals("Number:Temperature")) { state = new QuantityType<Temperature>(value, SIUnits.CELSIUS); } else if (type.equals("Number:Length")) { state = new QuantityType<Length>(value, MILLI(SIUnits.METRE)); } else if (type.equals("Number:Pressure")) { state = new QuantityType<Pressure>(value, HECTO(SIUnits.PASCAL)); } else if (type.equals("Number:Speed")) { state = new QuantityType<Speed>(value, SIUnits.KILOMETRE_PER_HOUR); } return state; }
Example #14
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testHectoPascal2Pascal() { Quantity<Pressure> pascal = Quantities.getQuantity(BigDecimal.valueOf(100), SIUnits.PASCAL); assertThat(pascal.to(MetricPrefix.HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(BigDecimal.ONE, MetricPrefix.HECTO(SIUnits.PASCAL)))); }
Example #15
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testPascal2mmHgConversion() { Quantity<Pressure> pascal = Quantities.getQuantity(new BigDecimal("133.322368"), SIUnits.PASCAL); assertThat(pascal.to(SmartHomeUnits.MILLIMETRE_OF_MERCURY), is(Quantities.getQuantity(BigDecimal.ONE, SmartHomeUnits.MILLIMETRE_OF_MERCURY))); }
Example #16
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testmmHg2PascalConversion() { Quantity<Pressure> mmHg = Quantities.getQuantity(BigDecimal.ONE, SmartHomeUnits.MILLIMETRE_OF_MERCURY); assertThat(mmHg.to(SIUnits.PASCAL), is(Quantities.getQuantity(new BigDecimal("133.322368"), SIUnits.PASCAL))); assertThat(mmHg.to(MetricPrefix.HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(new BigDecimal("1.33322368"), MetricPrefix.HECTO(SIUnits.PASCAL)))); }
Example #17
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testPascal2inHgConversion() { Quantity<Pressure> pascal = Quantities.getQuantity(new BigDecimal("3386.388"), SIUnits.PASCAL); assertThat(pascal.to(ImperialUnits.INCH_OF_MERCURY), is(Quantities.getQuantity(BigDecimal.ONE, ImperialUnits.INCH_OF_MERCURY))); }
Example #18
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testInHg2PascalConversion() { Quantity<Pressure> inHg = Quantities.getQuantity(BigDecimal.ONE, ImperialUnits.INCH_OF_MERCURY); assertThat(inHg.to(SIUnits.PASCAL), is(Quantities.getQuantity(new BigDecimal("3386.388"), SIUnits.PASCAL))); assertThat(inHg.to(MetricPrefix.HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(new BigDecimal("33.86388"), MetricPrefix.HECTO(SIUnits.PASCAL)))); }
Example #19
Source File: QuantityTypeArithmeticGroupFunctionTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testMinFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Min(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); }
Example #20
Source File: QuantityTypeArithmeticGroupFunctionTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testMaxFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); }
Example #21
Source File: QuantityTypeArithmeticGroupFunctionTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testAvgFunctionQuantityTypeIncompatibleUnits() { items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Avg(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); }
Example #22
Source File: QuantityTypeArithmeticGroupFunctionTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testSumFunctionQuantityTypeIncompatibleUnits() { items = new LinkedHashSet<>(); // we need an ordered set to guarantee the Unit of the first entry items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Sum(Temperature.class); State state = function.calculate(items); assertEquals(new QuantityType<>("23.54 °C"), state); }
Example #23
Source File: I18nProviderImpl.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
private void initDimensionMap() { Map<SystemOfUnits, Unit<? extends Quantity<?>>> temperatureMap = new HashMap<>(); temperatureMap.put(SIUnits.getInstance(), SIUnits.CELSIUS); temperatureMap.put(ImperialUnits.getInstance(), ImperialUnits.FAHRENHEIT); dimensionMap.put(Temperature.class, temperatureMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> pressureMap = new HashMap<>(); pressureMap.put(SIUnits.getInstance(), HECTO(SIUnits.PASCAL)); pressureMap.put(ImperialUnits.getInstance(), ImperialUnits.INCH_OF_MERCURY); dimensionMap.put(Pressure.class, pressureMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> speedMap = new HashMap<>(); speedMap.put(SIUnits.getInstance(), SIUnits.KILOMETRE_PER_HOUR); speedMap.put(ImperialUnits.getInstance(), ImperialUnits.MILES_PER_HOUR); dimensionMap.put(Speed.class, speedMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> lengthMap = new HashMap<>(); lengthMap.put(SIUnits.getInstance(), SIUnits.METRE); lengthMap.put(ImperialUnits.getInstance(), ImperialUnits.INCH); dimensionMap.put(Length.class, lengthMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> intensityMap = new HashMap<>(); intensityMap.put(SIUnits.getInstance(), SmartHomeUnits.IRRADIANCE); intensityMap.put(ImperialUnits.getInstance(), SmartHomeUnits.IRRADIANCE); dimensionMap.put(Intensity.class, intensityMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> percentMap = new HashMap<>(); percentMap.put(SIUnits.getInstance(), SmartHomeUnits.ONE); percentMap.put(ImperialUnits.getInstance(), SmartHomeUnits.ONE); dimensionMap.put(Dimensionless.class, percentMap); Map<SystemOfUnits, Unit<? extends Quantity<?>>> angleMap = new HashMap<>(); angleMap.put(SIUnits.getInstance(), SmartHomeUnits.DEGREE_ANGLE); angleMap.put(ImperialUnits.getInstance(), SmartHomeUnits.DEGREE_ANGLE); dimensionMap.put(Angle.class, angleMap); }
Example #24
Source File: EDS006x.java From smarthome with Eclipse Public License 2.0 | 4 votes |
@Override public void refresh(OwBaseBridgeHandler bridgeHandler, Boolean forcedRefresh) throws OwException { if (isConfigured) { if (enabledChannels.contains(CHANNEL_TEMPERATURE) || enabledChannels.contains(CHANNEL_HUMIDITY) || enabledChannels.contains(CHANNEL_ABSOLUTE_HUMIDITY) || enabledChannels.contains(CHANNEL_DEWPOINT)) { QuantityType<Temperature> temperature = new QuantityType<>( (DecimalType) bridgeHandler.readDecimalType(sensorId, temperatureParameter), SIUnits.CELSIUS); logger.trace("read temperature {} from {}", temperature, sensorId); if (enabledChannels.contains(CHANNEL_TEMPERATURE)) { callback.postUpdate(CHANNEL_TEMPERATURE, temperature); } if (enabledChannels.contains(CHANNEL_HUMIDITY) || enabledChannels.contains(CHANNEL_ABSOLUTE_HUMIDITY) || enabledChannels.contains(CHANNEL_DEWPOINT)) { QuantityType<Dimensionless> humidity = new QuantityType<>( (DecimalType) bridgeHandler.readDecimalType(sensorId, humidityParameter), SmartHomeUnits.PERCENT); logger.trace("read humidity {} from {}", humidity, sensorId); if (enabledChannels.contains(CHANNEL_HUMIDITY)) { callback.postUpdate(CHANNEL_HUMIDITY, humidity); } if (enabledChannels.contains(CHANNEL_ABSOLUTE_HUMIDITY)) { callback.postUpdate(CHANNEL_ABSOLUTE_HUMIDITY, Util.calculateAbsoluteHumidity(temperature, humidity)); } if (enabledChannels.contains(CHANNEL_DEWPOINT)) { callback.postUpdate(CHANNEL_DEWPOINT, Util.calculateDewpoint(temperature, humidity)); } } } if (enabledChannels.contains(CHANNEL_LIGHT)) { QuantityType<Illuminance> light = new QuantityType<>( (DecimalType) bridgeHandler.readDecimalType(sensorId, lightParameter), SmartHomeUnits.LUX); logger.trace("read light {} from {}", light, sensorId); callback.postUpdate(CHANNEL_LIGHT, light); } if (enabledChannels.contains(CHANNEL_PRESSURE)) { QuantityType<Pressure> pressure = new QuantityType<>( (DecimalType) bridgeHandler.readDecimalType(sensorId, pressureParameter), MetricPrefix.HECTO(SIUnits.PASCAL)); logger.trace("read pressure {} from {}", pressure, sensorId); callback.postUpdate(CHANNEL_PRESSURE, pressure); } } }
Example #25
Source File: WaterTankUnitTest.java From tutorials with MIT License | 4 votes |
@Test public void givenUnit_whenAlternateUnit_ThenGetAlternateUnit() { Unit<Pressure> PASCAL = NEWTON.divide(METRE.pow(2)).alternate("Pa").asType(Pressure.class); assertTrue(SimpleUnitFormat.getInstance().parse("Pa").equals(PASCAL)); }
Example #26
Source File: QuantityTypeTest.java From smarthome with Eclipse Public License 2.0 | 4 votes |
@Test public void testPressureUnits() { QuantityType<Pressure> pressure = new QuantityType<>("1013 mbar"); assertEquals("1.013 bar", pressure.toUnit("bar").toString()); assertEquals("101300 Pa", pressure.toUnit("Pa").toString()); }
Example #27
Source File: SmartHomeUnitsTest.java From smarthome with Eclipse Public License 2.0 | 4 votes |
@Test public void testBar2Pascal() { Quantity<Pressure> bar = Quantities.getQuantity(BigDecimal.valueOf(1), SmartHomeUnits.BAR); assertThat(bar.to(SIUnits.PASCAL), is(Quantities.getQuantity(100000, SIUnits.PASCAL))); }
Example #28
Source File: SmartHomeUnitsTest.java From smarthome with Eclipse Public License 2.0 | 4 votes |
@Test public void testHectoPascal2Pascal() { Quantity<Pressure> pascal = Quantities.getQuantity(BigDecimal.valueOf(100), SIUnits.PASCAL); assertThat(pascal.to(HECTO(SIUnits.PASCAL)), is(Quantities.getQuantity(BigDecimal.ONE, HECTO(SIUnits.PASCAL)))); }
Example #29
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testBar2Pascal() { Quantity<Pressure> bar = Quantities.getQuantity(BigDecimal.valueOf(1), SmartHomeUnits.BAR); assertThat(bar.to(SIUnits.PASCAL), is(Quantities.getQuantity(100000, SIUnits.PASCAL))); }
Example #30
Source File: QuantityTypeTest.java From openhab-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testPressureUnits() { QuantityType<Pressure> pressure = new QuantityType<>("1013 mbar"); assertEquals("1.013 bar", pressure.toUnit("bar").toString()); assertEquals("101300 Pa", pressure.toUnit("Pa").toString()); }