2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.modbus.sbc.internal;
15 import static org.openhab.core.io.transport.modbus.ModbusConstants.ValueType.*;
17 import java.math.BigDecimal;
19 import javax.measure.Unit;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.core.io.transport.modbus.ModbusConstants;
23 import org.openhab.core.io.transport.modbus.ModbusConstants.ValueType;
24 import org.openhab.core.library.unit.Units;
27 * The {@link ALD1Registers} is responsible for defining Modbus registers and their units.
29 * @author Fabian Wolter - Initial contribution
32 public enum ALD1Registers {
33 // the following register numbers are 1-based. They need to be converted before sending them on the wire.
34 TOTAL_ENERGY(0.01f, 28, UINT32, Units.KILOWATT_HOUR),
35 PARTIAL_ENERGY(0.01f, 30, UINT32, Units.KILOWATT_HOUR), // only unidirectional meters
36 FEEDING_BACK_ENERGY(0.01f, 30, UINT32, Units.KILOWATT_HOUR), // only bidirectional meters
37 VOLTAGE(1, 36, UINT16, Units.VOLT),
38 CURRENT(0.1f, 37, UINT16, Units.AMPERE),
39 ACTIVE_POWER(10, 38, INT16, Units.WATT),
40 REACTIVE_POWER(10, 39, INT16, Units.VAR),
41 POWER_FACTOR(0.01f, 40, INT16, Units.ONE);
43 private BigDecimal multiplier;
44 private int registerNumber;
45 private ModbusConstants.ValueType type;
48 private ALD1Registers(float multiplier, int registerNumber, ValueType type, Unit<?> unit) {
49 this.multiplier = new BigDecimal(multiplier);
50 this.registerNumber = registerNumber;
55 public Unit<?> getUnit() {
59 public BigDecimal getMultiplier() {
63 public int getRegisterNumber() {
64 return registerNumber;
67 public ModbusConstants.ValueType getType() {