Search in sources :

Example 1 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class I18nProviderImplTest method assertThatActivateSetsLocaleAndLocation.

@Test
public void assertThatActivateSetsLocaleAndLocation() {
    i18nProviderImpl.activate(componentContext);
    PointType location = i18nProviderImpl.getLocation();
    Locale setLocale = i18nProviderImpl.getLocale();
    assertThat(location.toString(), is(LOCATION_ZERO));
    assertThat(setLocale.getLanguage(), is(initialConfig.get(LANGUAGE)));
    assertThat(setLocale.getScript(), is(initialConfig.get(SCRIPT)));
    assertThat(setLocale.getCountry(), is(initialConfig.get(REGION)));
    assertThat(setLocale.getVariant(), is(initialConfig.get(VARIANT)));
}
Also used : Locale(java.util.Locale) PointType(org.eclipse.smarthome.core.library.types.PointType) Test(org.junit.Test)

Example 2 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class I18nProviderImplTest method assertThatConfigurationChangeWorks.

@Test
public void assertThatConfigurationChangeWorks() {
    i18nProviderImpl.activate(componentContext);
    i18nProviderImpl.modified(buildRUConfig());
    PointType location = i18nProviderImpl.getLocation();
    Locale setLocale = i18nProviderImpl.getLocale();
    assertThat(location.toString(), is(LOCATION_HAMBURG));
    assertThat(setLocale.getLanguage(), is(LANGUAGE_RU));
    assertThat(setLocale.getScript(), is(SCRIPT_RU));
    assertThat(setLocale.getCountry(), is(REGION_RU));
    assertThat(setLocale.getVariant(), is(VARIANT_RU));
}
Also used : Locale(java.util.Locale) PointType(org.eclipse.smarthome.core.library.types.PointType) Test(org.junit.Test)

Example 3 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class I18nProviderImplTest method assertThatConfigurationWasSet.

@SuppressWarnings("unchecked")
@Test
public void assertThatConfigurationWasSet() {
    i18nProviderImpl.modified((Map<String, Object>) initialConfig);
    PointType location = i18nProviderImpl.getLocation();
    Locale setLocale = i18nProviderImpl.getLocale();
    assertThat(location.toString(), is(LOCATION_ZERO));
    assertThat(setLocale.getLanguage(), is(initialConfig.get(LANGUAGE)));
    assertThat(setLocale.getScript(), is(initialConfig.get(SCRIPT)));
    assertThat(setLocale.getCountry(), is(initialConfig.get(REGION)));
    assertThat(setLocale.getVariant(), is(initialConfig.get(VARIANT)));
    assertThat(i18nProviderImpl.getTimeZone(), is(ZoneId.of(TIMEZONE_GMT9)));
}
Also used : Locale(java.util.Locale) PointType(org.eclipse.smarthome.core.library.types.PointType) Test(org.junit.Test)

Example 4 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class StateUtil method getAllStates.

public static List<State> getAllStates() {
    LinkedList<State> states = new LinkedList<>();
    DateTimeType dateTime = new DateTimeType();
    states.add(dateTime);
    DecimalType decimal = new DecimalType(23);
    states.add(decimal);
    PercentType percent = new PercentType(50);
    states.add(percent);
    HSBType hsb = new HSBType("50,75,42");
    states.add(hsb);
    states.add(OnOffType.ON);
    states.add(OnOffType.OFF);
    states.add(OpenClosedType.OPEN);
    states.add(OpenClosedType.CLOSED);
    states.add(PlayPauseType.PLAY);
    states.add(PlayPauseType.PAUSE);
    PointType point = new PointType("42.23,23.5");
    states.add(point);
    RawType raw = new RawType(new byte[0], "application/octet-stream");
    states.add(raw);
    states.add(RewindFastforwardType.REWIND);
    states.add(RewindFastforwardType.FASTFORWARD);
    StringListType stringList = new StringListType(new String[] { "foo", "bar" });
    states.add(stringList);
    StringType string = new StringType("foo");
    states.add(string);
    states.add(UnDefType.NULL);
    states.add(UnDefType.UNDEF);
    states.add(UpDownType.UP);
    states.add(UpDownType.DOWN);
    QuantityType<Temperature> quantityType = new QuantityType<Temperature>("12 °C");
    states.add(quantityType);
    return states;
}
Also used : Temperature(javax.measure.quantity.Temperature) StringType(org.eclipse.smarthome.core.library.types.StringType) PercentType(org.eclipse.smarthome.core.library.types.PercentType) LinkedList(java.util.LinkedList) DateTimeType(org.eclipse.smarthome.core.library.types.DateTimeType) QuantityType(org.eclipse.smarthome.core.library.types.QuantityType) State(org.eclipse.smarthome.core.types.State) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) PointType(org.eclipse.smarthome.core.library.types.PointType) RawType(org.eclipse.smarthome.core.library.types.RawType) HSBType(org.eclipse.smarthome.core.library.types.HSBType) StringListType(org.eclipse.smarthome.core.library.types.StringListType)

Example 5 with PointType

use of org.eclipse.smarthome.core.library.types.PointType in project smarthome by eclipse.

the class LocationItem method distanceFrom.

/**
 * Compute the distance with another Point type,
 * http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-
 * java
 *
 * @param away : the point to calculate the distance with
 * @return distance between the two points in meters
 */
public DecimalType distanceFrom(@Nullable LocationItem awayItem) {
    if (awayItem != null && awayItem.state instanceof PointType && this.state instanceof PointType) {
        PointType thisPoint = (PointType) this.state;
        PointType awayPoint = (PointType) awayItem.state;
        return thisPoint.distanceFrom(awayPoint);
    }
    return new DecimalType(-1);
}
Also used : PointType(org.eclipse.smarthome.core.library.types.PointType) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType)

Aggregations

PointType (org.eclipse.smarthome.core.library.types.PointType)12 Test (org.junit.Test)6 Locale (java.util.Locale)5 DecimalType (org.eclipse.smarthome.core.library.types.DecimalType)3 State (org.eclipse.smarthome.core.types.State)3 Mapview (org.eclipse.smarthome.model.sitemap.Mapview)2 Hashtable (java.util.Hashtable)1 LinkedList (java.util.LinkedList)1 Temperature (javax.measure.quantity.Temperature)1 DateTimeType (org.eclipse.smarthome.core.library.types.DateTimeType)1 HSBType (org.eclipse.smarthome.core.library.types.HSBType)1 PercentType (org.eclipse.smarthome.core.library.types.PercentType)1 QuantityType (org.eclipse.smarthome.core.library.types.QuantityType)1 RawType (org.eclipse.smarthome.core.library.types.RawType)1 StringListType (org.eclipse.smarthome.core.library.types.StringListType)1 StringType (org.eclipse.smarthome.core.library.types.StringType)1