diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java index ce61377b7..98510e9e8 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java @@ -77,6 +77,7 @@ import org.openhab.core.library.dimension.ElectricConductivity; import org.openhab.core.library.dimension.EmissionIntensity; import org.openhab.core.library.dimension.EnergyPrice; import org.openhab.core.library.dimension.Intensity; +import org.openhab.core.library.dimension.RadiantExposure; import org.openhab.core.library.dimension.RadiationSpecificActivity; import org.openhab.core.library.dimension.VolumetricFlowRate; import org.openhab.core.library.types.PointType; @@ -429,6 +430,7 @@ public class I18nProviderImpl addDefaultUnit(dimensionMap, RadiationDoseAbsorbed.class, Units.GRAY); addDefaultUnit(dimensionMap, RadiationDoseEffective.class, Units.SIEVERT); addDefaultUnit(dimensionMap, RadiationSpecificActivity.class, Units.BECQUEREL_PER_CUBIC_METRE); + addDefaultUnit(dimensionMap, RadiantExposure.class, Units.JOULE_PER_SQUARE_METRE); addDefaultUnit(dimensionMap, Radioactivity.class, Units.BECQUEREL); addDefaultUnit(dimensionMap, SolidAngle.class, Units.STERADIAN); addDefaultUnit(dimensionMap, Speed.class, SIUnits.KILOMETRE_PER_HOUR, ImperialUnits.MILES_PER_HOUR); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/dimension/RadiantExposure.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/dimension/RadiantExposure.java new file mode 100644 index 000000000..d0ef542a4 --- /dev/null +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/dimension/RadiantExposure.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.core.library.dimension; + +import javax.measure.Quantity; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link RadiantExposure} defines the dimension for Radiant Exposure + * https://en.wikipedia.org/wiki/Radiant_exposure + * + * @author Gaël L'hopital - Initial contribution + */ +@NonNullByDefault +public interface RadiantExposure extends Quantity { +} diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/ImperialUnits.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/ImperialUnits.java index 7fa660b57..1ed5614ee 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/ImperialUnits.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/ImperialUnits.java @@ -25,6 +25,7 @@ import javax.measure.quantity.Volume; import javax.measure.spi.SystemOfUnits; import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.core.library.dimension.Density; import org.openhab.core.library.dimension.VolumetricFlowRate; import tech.units.indriya.format.SimpleUnitFormat; @@ -48,6 +49,8 @@ public final class ImperialUnits extends CustomUnits { public static final Unit POUND = addUnit(new TransformedUnit<>("lb", Units.GRAM, MultiplyConverter.ofRational(BigInteger.valueOf(45359237), BigInteger.valueOf(100000)))); + public static final Unit GRAIN = addUnit( + new TransformedUnit<>("gr", Units.GRAM, MultiplyConverter.of(0.06479891))); /** Additionally defined units to be used in openHAB **/ public static final Unit INCH_OF_MERCURY = addUnit(new TransformedUnit<>("inHg", Units.PASCAL, MultiplyConverter.ofRational(BigInteger.valueOf(3386388), BigInteger.valueOf(1000)))); @@ -94,6 +97,8 @@ public final class ImperialUnits extends CustomUnits { public static final Unit GALLON_PER_MINUTE = addUnit( new ProductUnit<>(GALLON_LIQUID_US.divide(tech.units.indriya.unit.Units.MINUTE))); + public static final Unit GRAIN_PER_CUBICFOOT = addUnit(new ProductUnit<>(GRAIN.divide(CUBIC_FOOT))); + /* * Add unit symbols for imperial units. */ @@ -111,6 +116,7 @@ public final class ImperialUnits extends CustomUnits { 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()); + SimpleUnitFormat.getInstance().label(GRAIN, GRAIN.getSymbol()); } private ImperialUnits() { diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java index f3e220fb1..f36b25d1b 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java @@ -57,6 +57,7 @@ import org.openhab.core.library.dimension.Density; import org.openhab.core.library.dimension.ElectricConductivity; import org.openhab.core.library.dimension.EmissionIntensity; import org.openhab.core.library.dimension.Intensity; +import org.openhab.core.library.dimension.RadiantExposure; import org.openhab.core.library.dimension.RadiationSpecificActivity; import org.openhab.core.library.dimension.VolumetricFlowRate; @@ -91,13 +92,15 @@ public final class Units extends CustomUnits { public static final Unit MOLE = addUnit(tech.units.indriya.unit.Units.MOLE); public static final Unit LITRE = addUnit(tech.units.indriya.unit.Units.LITRE); @SuppressWarnings("unchecked") - public static final Unit DEUTSCHE_HAERTE = addUnit(new TransformedUnit<>("°dH", - (Unit) MetricPrefix.MILLI(Units.MOLE).divide(Units.LITRE), MultiplyConverter.of(5.6))); + public static final Unit DEUTSCHE_HAERTE = addUnit((Unit) new TransformedUnit<>("°dH", + MetricPrefix.MILLI(Units.MOLE).divide(Units.LITRE), MultiplyConverter.of(0.17833))); public static final Unit DEGREE_ANGLE = addUnit(NonSI.DEGREE_ANGLE); public static final Unit RADIAN = addUnit(tech.units.indriya.unit.Units.RADIAN); public static final Unit DOBSON_UNIT = addUnit( new ProductUnit<>(MetricPrefix.MILLI(tech.units.indriya.unit.Units.MOLE).multiply(0.4462) .divide(tech.units.indriya.unit.Units.SQUARE_METRE))); + public static final Unit KILOGRAM_PER_SQUARE_METRE = addUnit(new ProductUnit<>( + tech.units.indriya.unit.Units.KILOGRAM.divide(tech.units.indriya.unit.Units.SQUARE_METRE))); public static final Unit KATAL = addUnit(tech.units.indriya.unit.Units.KATAL); public static final Unit KILOGRAM_PER_CUBICMETRE = addUnit(new ProductUnit<>( tech.units.indriya.unit.Units.KILOGRAM.divide(tech.units.indriya.unit.Units.CUBIC_METRE))); @@ -187,6 +190,10 @@ public final class Units extends CustomUnits { new TransformedUnit<>("kn", tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR, MultiplyConverter.ofRational(BigInteger.valueOf(1852), BigInteger.valueOf(1000)))); public static final Unit STERADIAN = addUnit(tech.units.indriya.unit.Units.STERADIAN); + public static final Unit WATT_HOUR_PER_SQUARE_METRE = addUnit( + new ProductUnit<>(WATT_HOUR.divide(tech.units.indriya.unit.Units.SQUARE_METRE))); + public static final Unit JOULE_PER_SQUARE_METRE = addUnit( + new ProductUnit<>(JOULE.divide(tech.units.indriya.unit.Units.SQUARE_METRE))); public static final Unit KELVIN = addUnit(tech.units.indriya.unit.Units.KELVIN); public static final Unit MIRED = addUnit(MetricPrefix.MEGA(tech.units.indriya.unit.Units.KELVIN).inverse()); public static final Unit