From fbaf623bc561c3e5a37acad4c46ea3e5a9aaf12f Mon Sep 17 00:00:00 2001 From: Fabian Wolter Date: Wed, 23 Dec 2020 16:32:17 +0100 Subject: [PATCH] Add ability for TCP bridge. Apply moving of modbus transport to core. Apply renaming of Units. Remove feature file. Signed-off-by: Fabian Wolter --- .../org.openhab.binding.modbus.sbc/pom.xml | 6 ----- .../src/main/feature/feature.xml | 25 ------------------- .../modbus/sbc/internal/ALD1Handler.java | 10 ++++---- .../modbus/sbc/internal/ALD1Registers.java | 24 +++++++++--------- .../resources/OH-INF/thing/thing-types.xml | 1 + 5 files changed, 18 insertions(+), 48 deletions(-) delete mode 100644 bundles/org.openhab.binding.modbus.sbc/src/main/feature/feature.xml diff --git a/bundles/org.openhab.binding.modbus.sbc/pom.xml b/bundles/org.openhab.binding.modbus.sbc/pom.xml index 7c9311b36a9c7..377e28c5fe550 100644 --- a/bundles/org.openhab.binding.modbus.sbc/pom.xml +++ b/bundles/org.openhab.binding.modbus.sbc/pom.xml @@ -15,12 +15,6 @@ openHAB Add-ons :: Bundles :: Modbus SBC Binding - - org.openhab.addons.bundles - org.openhab.io.transport.modbus - ${project.version} - provided - org.openhab.addons.bundles org.openhab.binding.modbus diff --git a/bundles/org.openhab.binding.modbus.sbc/src/main/feature/feature.xml b/bundles/org.openhab.binding.modbus.sbc/src/main/feature/feature.xml deleted file mode 100644 index ee679d62dca63..0000000000000 --- a/bundles/org.openhab.binding.modbus.sbc/src/main/feature/feature.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - file:${basedirRoot}/bundles/org.openhab.io.transport.modbus/target/feature/feature.xml - - - openhab-runtime-base - openhab-transport-modbus - mvn:org.openhab.addons.bundles/org.openhab.binding.modbus/${project.version} - mvn:org.openhab.addons.bundles/org.openhab.binding.modbus.sbc/${project.version} - - diff --git a/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Handler.java b/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Handler.java index 84429845bb2a9..d6b819256145e 100644 --- a/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Handler.java +++ b/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Handler.java @@ -15,6 +15,11 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.modbus.handler.BaseModbusThingHandler; +import org.openhab.core.io.transport.modbus.AsyncModbusFailure; +import org.openhab.core.io.transport.modbus.AsyncModbusReadResult; +import org.openhab.core.io.transport.modbus.ModbusBitUtilities; +import org.openhab.core.io.transport.modbus.ModbusReadFunctionCode; +import org.openhab.core.io.transport.modbus.ModbusReadRequestBlueprint; import org.openhab.core.library.types.QuantityType; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -22,11 +27,6 @@ import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; -import org.openhab.io.transport.modbus.AsyncModbusFailure; -import org.openhab.io.transport.modbus.AsyncModbusReadResult; -import org.openhab.io.transport.modbus.ModbusBitUtilities; -import org.openhab.io.transport.modbus.ModbusReadFunctionCode; -import org.openhab.io.transport.modbus.ModbusReadRequestBlueprint; /** * The {@link ALD1Handler} is responsible for handling commands, which are diff --git a/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Registers.java b/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Registers.java index 6793623446116..d5fa1236f0b9f 100644 --- a/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Registers.java +++ b/bundles/org.openhab.binding.modbus.sbc/src/main/java/org/openhab/binding/modbus/sbc/internal/ALD1Registers.java @@ -12,16 +12,16 @@ */ package org.openhab.binding.modbus.sbc.internal; -import static org.openhab.io.transport.modbus.ModbusConstants.ValueType.*; +import static org.openhab.core.io.transport.modbus.ModbusConstants.ValueType.*; import java.math.BigDecimal; import javax.measure.Unit; import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.library.unit.SmartHomeUnits; -import org.openhab.io.transport.modbus.ModbusConstants; -import org.openhab.io.transport.modbus.ModbusConstants.ValueType; +import org.openhab.core.io.transport.modbus.ModbusConstants; +import org.openhab.core.io.transport.modbus.ModbusConstants.ValueType; +import org.openhab.core.library.unit.Units; /** * The {@link ALD1Registers} is responsible for defining Modbus registers and their units. @@ -31,14 +31,14 @@ @NonNullByDefault public enum ALD1Registers { // the following register numbers are 1-based. They need to be converted before sending them on the wire. - TOTAL_ENERGY(0.01f, 28, UINT32, SmartHomeUnits.KILOWATT_HOUR), - PARTIAL_ENERGY(0.01f, 30, UINT32, SmartHomeUnits.KILOWATT_HOUR), // only unidirectional meters - FEEDING_BACK_ENERGY(0.01f, 30, UINT32, SmartHomeUnits.KILOWATT_HOUR), // only bidirectional meters - VOLTAGE(1, 36, UINT16, SmartHomeUnits.VOLT), - CURRENT(0.1f, 37, UINT16, SmartHomeUnits.AMPERE), - ACTIVE_POWER(10, 38, INT16, SmartHomeUnits.WATT), - REACTIVE_POWER(10, 39, INT16, SmartHomeUnits.VAR), - POWER_FACTOR(0.01f, 40, UINT16, SmartHomeUnits.ONE); + TOTAL_ENERGY(0.01f, 28, UINT32, Units.KILOWATT_HOUR), + PARTIAL_ENERGY(0.01f, 30, UINT32, Units.KILOWATT_HOUR), // only unidirectional meters + FEEDING_BACK_ENERGY(0.01f, 30, UINT32, Units.KILOWATT_HOUR), // only bidirectional meters + VOLTAGE(1, 36, UINT16, Units.VOLT), + CURRENT(0.1f, 37, UINT16, Units.AMPERE), + ACTIVE_POWER(10, 38, INT16, Units.WATT), + REACTIVE_POWER(10, 39, INT16, Units.VAR), + POWER_FACTOR(0.01f, 40, UINT16, Units.ONE); private BigDecimal multiplier; private int registerNumber; diff --git a/bundles/org.openhab.binding.modbus.sbc/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.modbus.sbc/src/main/resources/OH-INF/thing/thing-types.xml index 012f5f80644f3..faaee9d636fcf 100644 --- a/bundles/org.openhab.binding.modbus.sbc/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.modbus.sbc/src/main/resources/OH-INF/thing/thing-types.xml @@ -28,6 +28,7 @@ +