javax.measure.quantity.Power Java Examples

The following examples show how to use javax.measure.quantity.Power. 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: UnitUtilsTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGetDimensionName() {
    assertThat(UnitUtils.getDimensionName(SIUnits.CELSIUS), is(Temperature.class.getSimpleName()));
    assertThat(UnitUtils.getDimensionName(SmartHomeUnits.KILOWATT_HOUR), is(Energy.class.getSimpleName()));
    assertThat(UnitUtils.getDimensionName(SmartHomeUnits.WATT), is(Power.class.getSimpleName()));
    assertThat(UnitUtils.getDimensionName(MetricPrefix.MEGA(SmartHomeUnits.KILOWATT_HOUR)),
            is(Energy.class.getSimpleName()));

    Unit<?> unit = UnitUtils.parseUnit("°F");
    assertNotNull(unit);
    assertThat(UnitUtils.getDimensionName(unit), is(Temperature.class.getSimpleName()));
    unit = UnitUtils.parseUnit("m");
    assertNotNull(unit);
    assertThat(UnitUtils.getDimensionName(unit), is(Length.class.getSimpleName()));
}
 
Example #2
Source File: QuantityTypeArithmeticGroupFunctionTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSumFunctionQuantityTypeWithGroups() {
    items.add(createNumberItem("TestItem1", Power.class, new QuantityType<>("5 W")));
    items.add(createGroupItem("TestGroup1", Power.class, new QuantityType<>("5 W")));

    function = new QuantityTypeArithmeticGroupFunction.Sum(Power.class);
    State state = function.calculate(items);

    assertEquals(new QuantityType<>("10 W"), state);
}
 
Example #3
Source File: SmartHomeUnitsTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testKVarUnitSymbol() {
    assertThat(SmartHomeUnits.KILOVAR.toString(), is("kvar"));
    assertThat(SmartHomeUnits.KILOVAR_HOUR.toString(), is("kvarh"));

    Quantity<Power> kvar = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VAR));
    assertThat(kvar.getUnit().toString(), is("kvar"));

    Quantity<Energy> kvarh = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VAR_HOUR));
    assertThat(kvarh.getUnit().toString(), is("kvarh"));
}
 
Example #4
Source File: SmartHomeUnitsTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testVoltAmpereUnitSymbol() {
    assertThat(SmartHomeUnits.VOLT_AMPERE.toString(), is("VA"));
    assertThat(SmartHomeUnits.VOLT_AMPERE.getSymbol(), is("VA"));
    assertThat(SmartHomeUnits.VOLT_AMPERE_HOUR.toString(), is("VAh"));

    Quantity<Power> kVA = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VOLT_AMPERE));
    assertThat(kVA.getUnit().toString(), is("kVA"));

    Quantity<Energy> kVAh = Quantities.getQuantity(BigDecimal.TEN,
            MetricPrefix.KILO(SmartHomeUnits.VOLT_AMPERE_HOUR));
    assertThat(kVAh.getUnit().toString(), is("kVAh"));
}
 
Example #5
Source File: UnitsTest.java    From uom-systems with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testKiloIsAThousand() {
	// TODO Need to find the org.hamcrest assertion libs
	Quantity<Power> w2000 = Quantities.getQuantity(2000, WATT);
	Quantity<Power> kW2 = Quantities.getQuantity(2, KILO(WATT));
	// assertThat(w2000, is(kW2));
}
 
Example #6
Source File: UnitUtilsTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testGetDimensionName() {
    assertThat(UnitUtils.getDimensionName(SIUnits.CELSIUS), is(Temperature.class.getSimpleName()));
    assertThat(UnitUtils.getDimensionName(SmartHomeUnits.KILOWATT_HOUR), is(Energy.class.getSimpleName()));
    assertThat(UnitUtils.getDimensionName(SmartHomeUnits.WATT), is(Power.class.getSimpleName()));
    assertThat(UnitUtils.getDimensionName(MetricPrefix.MEGA(SmartHomeUnits.KILOWATT_HOUR)),
            is(Energy.class.getSimpleName()));

    Unit<?> unit = UnitUtils.parseUnit("°F");
    assertNotNull(unit);
    assertThat(UnitUtils.getDimensionName(unit), is(Temperature.class.getSimpleName()));
    unit = UnitUtils.parseUnit("m");
    assertNotNull(unit);
    assertThat(UnitUtils.getDimensionName(unit), is(Length.class.getSimpleName()));
}
 
Example #7
Source File: QuantityTypeArithmeticGroupFunctionTest.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSumFunctionQuantityTypeWithGroups() {
    items.add(createNumberItem("TestItem1", Power.class, new QuantityType<Power>("5 W")));
    items.add(createGroupItem("TestGroup1", Power.class, new QuantityType<Power>("5 W")));

    function = new QuantityTypeArithmeticGroupFunction.Sum(Power.class);
    State state = function.calculate(items);

    assertEquals(new QuantityType<Power>("10 W"), state);
}