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)));
}
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));
}
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)));
}
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;
}
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);
}
Aggregations