diff --git a/io.openems.edge.battery.bmw/src/io/openems/edge/battery/bmw/BmwBatteryImpl.java b/io.openems.edge.battery.bmw/src/io/openems/edge/battery/bmw/BmwBatteryImpl.java index 40d79221504..5d69a22a84d 100644 --- a/io.openems.edge.battery.bmw/src/io/openems/edge/battery/bmw/BmwBatteryImpl.java +++ b/io.openems.edge.battery.bmw/src/io/openems/edge/battery/bmw/BmwBatteryImpl.java @@ -1,5 +1,11 @@ package io.openems.edge.battery.bmw; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; + import java.time.LocalDateTime; import org.osgi.service.cm.ConfigurationAdmin; @@ -27,7 +33,6 @@ import io.openems.edge.battery.bmw.enums.State; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -351,8 +356,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(BmwChannelId.HEART_BEAT, new UnsignedWordElement(1399)), // m(BmwChannelId.BMS_STATE_COMMAND, new UnsignedWordElement(1400)), // m(BmwChannelId.OPERATING_STATE_INVERTER, new UnsignedWordElement(1401)), // - m(BmwChannelId.DC_LINK_VOLTAGE, new UnsignedWordElement(1402), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(BmwChannelId.DC_LINK_VOLTAGE, new UnsignedWordElement(1402), SCALE_FACTOR_MINUS_1), // m(BmwChannelId.DC_LINK_CURRENT, new UnsignedWordElement(1403)), // m(BmwChannelId.OPERATION_MODE_REQUEST_GRANTED, new UnsignedWordElement(1404)), // m(BmwChannelId.OPERATION_MODE_REQUEST_CANCELED, new UnsignedWordElement(1405)), // @@ -375,23 +379,18 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(BmwChannelId.INFO_BITS, new UnsignedWordElement(1005)), m(BmwChannelId.MAXIMUM_OPERATING_CURRENT, new SignedWordElement(1006)), // m(BmwChannelId.MINIMUM_OPERATING_CURRENT, new SignedWordElement(1007)), // - m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, new UnsignedWordElement(1008), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(1009), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, new UnsignedWordElement(1008), SCALE_FACTOR_MINUS_1), // + m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(1009), SCALE_FACTOR_MINUS_1), // m(Battery.ChannelId.DISCHARGE_MAX_CURRENT, new SignedWordElement(1010)), // - m(Battery.ChannelId.CHARGE_MAX_CURRENT, new SignedWordElement(1011), - ElementToChannelConverter.INVERT), // + m(Battery.ChannelId.CHARGE_MAX_CURRENT, new SignedWordElement(1011), INVERT), // m(BmwChannelId.MAXIMUM_LIMIT_DYNAMIC_VOLTAGE, new UnsignedWordElement(1012), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BmwChannelId.MINIMUM_LIMIT_DYNAMIC_VOLTAGE, new UnsignedWordElement(1013), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BmwChannelId.NUMBER_OF_STRINGS_CONNECTED, new UnsignedWordElement(1014)), // m(BmwChannelId.NUMBER_OF_STRINGS_INSTALLED, new UnsignedWordElement(1015)), // - m(BmwChannelId.SOC_ALL_STRINGS, new UnsignedWordElement(1016), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Battery.ChannelId.SOC, new UnsignedWordElement(1017), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(BmwChannelId.SOC_ALL_STRINGS, new UnsignedWordElement(1016), SCALE_FACTOR_MINUS_2), // + m(Battery.ChannelId.SOC, new UnsignedWordElement(1017), SCALE_FACTOR_MINUS_2), // m(BmwChannelId.REMAINING_CHARGE_CAPACITY, new UnsignedWordElement(1018)), // m(BmwChannelId.REMAINING_DISCHARGE_CAPACITY, new UnsignedWordElement(1019)), // m(BmwChannelId.REMAINING_CHARGE_ENERGY, new UnsignedWordElement(1020)), // @@ -400,28 +399,25 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(BmwChannelId.TOTAL_ENERGY, new UnsignedWordElement(1023)), // m(BmwChannelId.NOMINAL_CAPACITY, new UnsignedWordElement(1024)), // m(Battery.ChannelId.CAPACITY, new UnsignedWordElement(1025)), // - m(Battery.ChannelId.SOH, new UnsignedWordElement(1026), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(1027), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(BmwChannelId.DC_VOLTAGE_AVERAGE, new UnsignedWordElement(1028), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), // + m(Battery.ChannelId.SOH, new UnsignedWordElement(1026), SCALE_FACTOR_MINUS_2), // + m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(1027), SCALE_FACTOR_MINUS_1), // + m(BmwChannelId.DC_VOLTAGE_AVERAGE, new UnsignedWordElement(1028), SCALE_FACTOR_MINUS_1)), // new FC4ReadInputRegistersTask(1029, Priority.HIGH, // m(new SignedWordElement(1029)) // - .m(BmwChannelId.DC_CURRENT, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // - .m(Battery.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(BmwChannelId.DC_CURRENT, SCALE_FACTOR_MINUS_1) // + .m(Battery.ChannelId.CURRENT, SCALE_FACTOR_MINUS_1) // .build()), // new FC4ReadInputRegistersTask(1030, Priority.HIGH, // m(BmwChannelId.AVERAGE_TEMPERATURE, new SignedWordElement(1030))), // new FC4ReadInputRegistersTask(1031, Priority.HIGH, // m(new SignedWordElement(1031)) // - .m(BmwChannelId.MINIMUM_TEMPERATURE, ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(BmwChannelId.MINIMUM_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, DIRECT_1_TO_1) // .build()), // new FC4ReadInputRegistersTask(1032, Priority.HIGH, // m(new SignedWordElement(1032)) // - .m(BmwChannelId.MAXIMUM_TEMPERATURE, ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(BmwChannelId.MAXIMUM_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, DIRECT_1_TO_1) // .build()), // new FC4ReadInputRegistersTask(1033, Priority.HIGH, m(Battery.ChannelId.MIN_CELL_VOLTAGE, new UnsignedWordElement(1033)), // @@ -429,21 +425,17 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(BmwChannelId.AVERAGE_CELL_VOLTAGE, new UnsignedWordElement(1035)), // // not defined by "BCS_HL-SW_Operating-Instructions_V1.0.2_under_work_ChL.pdf" m(BmwChannelId.INTERNAL_RESISTANCE, new UnsignedWordElement(1036)), - m(BmwChannelId.INSULATION_RESISTANCE, new UnsignedWordElement(1037), - ElementToChannelConverter.DIRECT_1_TO_1), // + m(BmwChannelId.INSULATION_RESISTANCE, new UnsignedWordElement(1037), DIRECT_1_TO_1), // // not defined by "BCS_HL-SW_Operating-Instructions_V1.0.2_under_work_ChL.pdf" - m(BmwChannelId.CONTAINER_TEMPERATURE, new UnsignedWordElement(1038), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + m(BmwChannelId.CONTAINER_TEMPERATURE, new UnsignedWordElement(1038), SCALE_FACTOR_MINUS_1), // not defined by "BCS_HL-SW_Operating-Instructions_V1.0.2_under_work_ChL.pdf" - m(BmwChannelId.AMBIENT_TEMPERATURE, new UnsignedWordElement(1039), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + m(BmwChannelId.AMBIENT_TEMPERATURE, new UnsignedWordElement(1039), SCALE_FACTOR_MINUS_1), // not defined by "BCS_HL-SW_Operating-Instructions_V1.0.2_under_work_ChL.pdf" - m(BmwChannelId.HUMIDITY_CONTAINER, new UnsignedWordElement(1040), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + m(BmwChannelId.HUMIDITY_CONTAINER, new UnsignedWordElement(1040), SCALE_FACTOR_MINUS_1), m(BmwChannelId.MAXIMUM_LIMIT_DYNAMIC_CURRENT_HIGH_RES, new SignedWordElement(1041), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(BmwChannelId.MINIMUM_LIMIT_DYNAMIC_CURRENT_HIGH_RES, new SignedWordElement(1042), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(BmwChannelId.FULL_CYCLE_COUNT, new UnsignedWordElement(1043)), // // not defined by "BCS_HL-SW_Operating-Instructions_V1.0.2_under_work_ChL.pdf" m(BmwChannelId.OPERATING_TIME_COUNT, new UnsignedDoublewordElement(1044)), diff --git a/io.openems.edge.battery.bydcommercial/src/io/openems/edge/battery/bydcommercial/BatteryBoxC130Impl.java b/io.openems.edge.battery.bydcommercial/src/io/openems/edge/battery/bydcommercial/BatteryBoxC130Impl.java index 17c7b90cb2d..dddd7d50eae 100644 --- a/io.openems.edge.battery.bydcommercial/src/io/openems/edge/battery/bydcommercial/BatteryBoxC130Impl.java +++ b/io.openems.edge.battery.bydcommercial/src/io/openems/edge/battery/bydcommercial/BatteryBoxC130Impl.java @@ -1,5 +1,9 @@ package io.openems.edge.battery.bydcommercial; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; @@ -30,7 +34,6 @@ import io.openems.edge.battery.protection.BatteryProtection; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.ModbusUtils; @@ -188,44 +191,38 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // new FC3ReadRegistersTask(0x2100, Priority.HIGH, // m(new UnsignedWordElement(0x2100).onUpdateCallback(this.onRegister0x2100Update)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_2) // [mV] - .m(Battery.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // [V] + .m(BatteryBoxC130.ChannelId.CLUSTER_1_VOLTAGE, SCALE_FACTOR_2) // [mV] + .m(Battery.ChannelId.VOLTAGE, SCALE_FACTOR_MINUS_1) // [V] .build(), // m(new SignedWordElement(0x2101)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_CURRENT, ElementToChannelConverter.SCALE_FACTOR_2) // [mA] - .m(Battery.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // [A] + .m(BatteryBoxC130.ChannelId.CLUSTER_1_CURRENT, SCALE_FACTOR_2) // [mA] + .m(Battery.ChannelId.CURRENT, SCALE_FACTOR_MINUS_1) // [A] .build(), // m(BatteryBoxC130.ChannelId.BATTERY_WORK_STATE, new UnsignedWordElement(0x2102)), // m(Battery.ChannelId.SOC, new UnsignedWordElement(0x2103)), // m(new UnsignedWordElement(0x2104)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_SOH, ElementToChannelConverter.DIRECT_1_TO_1) // [%] - .m(Battery.ChannelId.SOH, ElementToChannelConverter.DIRECT_1_TO_1) // [%] + .m(BatteryBoxC130.ChannelId.CLUSTER_1_SOH, DIRECT_1_TO_1) // [%] + .m(Battery.ChannelId.SOH, DIRECT_1_TO_1) // [%] .build(), // m(BatteryBoxC130.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2105)), // m(new UnsignedWordElement(0x2106)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(BatteryBoxC130.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_VOLTAGE, DIRECT_1_TO_1) // .build(), // m(BatteryBoxC130.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2107)), // m(new UnsignedWordElement(0x2108)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(BatteryBoxC130.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_VOLTAGE, DIRECT_1_TO_1) // .build(), // m(BatteryBoxC130.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x2109)), // m(new SignedWordElement(0x210A)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(BatteryBoxC130.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, SCALE_FACTOR_MINUS_1) // .build(), // m(BatteryBoxC130.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x210B)), // m(new SignedWordElement(0x210C)) // - .m(BatteryBoxC130.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(BatteryBoxC130.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, SCALE_FACTOR_MINUS_1) // .build()), // new FC3ReadRegistersTask(0x211D, Priority.HIGH, // @@ -325,9 +322,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // new FC3ReadRegistersTask(0x216C, Priority.HIGH, // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(0x216C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(0x216D), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_MINUS_1) // ), // new FC3ReadRegistersTask(0x2183, Priority.LOW, // @@ -717,10 +714,10 @@ public StartStop getStartStopTarget() { new UnsignedWordElement(0x210E))), // new FC3ReadRegistersTask(0x216E, Priority.LOW, // m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, new UnsignedWordElement(0x216E), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(0x216F), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_MINUS_1) // )); } catch (OpenemsException e) { BatteryBoxC130Impl.this.logError(BatteryBoxC130Impl.this.log, diff --git a/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/FeneconCommercialBatteryImpl.java b/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/FeneconCommercialBatteryImpl.java index afe92b65b6f..81765f6a1f5 100644 --- a/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/FeneconCommercialBatteryImpl.java +++ b/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/FeneconCommercialBatteryImpl.java @@ -1,6 +1,7 @@ package io.openems.edge.battery.fenecon.commercial; import static io.openems.common.types.OpenemsType.BOOLEAN; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; @@ -136,8 +137,7 @@ protected void deactivate() { super.deactivate(); } - private final ElementToChannelConverter ignoreZero = IgnoreZeroConverter.from(this, - ElementToChannelConverter.DIRECT_1_TO_1); + private final ElementToChannelConverter ignoreZero = IgnoreZeroConverter.from(this, DIRECT_1_TO_1); private final ElementToChannelConverter ignoreZeroAndScaleFactorMinus2 = IgnoreZeroConverter.from(this, SCALE_FACTOR_MINUS_2); diff --git a/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/IgnoreZeroConverter.java b/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/IgnoreZeroConverter.java index 2cc28ad1e73..3443cae5de7 100644 --- a/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/IgnoreZeroConverter.java +++ b/io.openems.edge.battery.fenecon.commercial/src/io/openems/edge/battery/fenecon/commercial/IgnoreZeroConverter.java @@ -1,7 +1,6 @@ package io.openems.edge.battery.fenecon.commercial; import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverterChain; /** * Before the battery is started, values are wrongly received as 'zero' via @@ -24,10 +23,10 @@ public class IgnoreZeroConverter extends ElementToChannelConverter { */ public static ElementToChannelConverter from(FeneconCommercialBatteryImpl parent, ElementToChannelConverter converter) { - if (converter == ElementToChannelConverter.DIRECT_1_TO_1) { + if (converter == DIRECT_1_TO_1) { return new IgnoreZeroConverter(parent); } - return new ElementToChannelConverterChain(new IgnoreZeroConverter(parent), converter); + return ElementToChannelConverter.chain(new IgnoreZeroConverter(parent), converter); } private IgnoreZeroConverter(FeneconCommercialBatteryImpl parent) { diff --git a/io.openems.edge.battery.fenecon.home/src/io/openems/edge/battery/fenecon/home/FeneconHomeBatteryImpl.java b/io.openems.edge.battery.fenecon.home/src/io/openems/edge/battery/fenecon/home/FeneconHomeBatteryImpl.java index 1ec679123f6..a53912cbb25 100644 --- a/io.openems.edge.battery.fenecon.home/src/io/openems/edge/battery/fenecon/home/FeneconHomeBatteryImpl.java +++ b/io.openems.edge.battery.fenecon.home/src/io/openems/edge/battery/fenecon/home/FeneconHomeBatteryImpl.java @@ -1,5 +1,7 @@ package io.openems.edge.battery.fenecon.home; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; @@ -266,34 +268,28 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // new FC3ReadRegistersTask(506, Priority.LOW, // - m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(506), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [V] - m(Battery.ChannelId.CURRENT, new SignedWordElement(507), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [A] - m(Battery.ChannelId.SOC, new UnsignedWordElement(508), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [%] - m(Battery.ChannelId.SOH, new UnsignedWordElement(509), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [%] + m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(506), SCALE_FACTOR_MINUS_1), // [V] + m(Battery.ChannelId.CURRENT, new SignedWordElement(507), SCALE_FACTOR_MINUS_1), // [A] + m(Battery.ChannelId.SOC, new UnsignedWordElement(508), SCALE_FACTOR_MINUS_1), // [%] + m(Battery.ChannelId.SOH, new UnsignedWordElement(509), SCALE_FACTOR_MINUS_1), // [%] m(Battery.ChannelId.MIN_CELL_VOLTAGE, new UnsignedWordElement(510)), // [mV] m(FeneconHomeBattery.ChannelId.ID_OF_CELL_VOLTAGE_MIN, new UnsignedWordElement(511)), // m(Battery.ChannelId.MAX_CELL_VOLTAGE, new UnsignedWordElement(512)), // [mV] m(FeneconHomeBattery.ChannelId.ID_OF_CELL_VOLTAGE_MAX, new UnsignedWordElement(513)), // - m(Battery.ChannelId.MIN_CELL_TEMPERATURE, new SignedWordElement(514), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(Battery.ChannelId.MIN_CELL_TEMPERATURE, new SignedWordElement(514), SCALE_FACTOR_MINUS_1), // m(FeneconHomeBattery.ChannelId.ID_OF_MIN_TEMPERATURE, new UnsignedWordElement(515)), // - m(Battery.ChannelId.MAX_CELL_TEMPERATURE, new SignedWordElement(516), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(Battery.ChannelId.MAX_CELL_TEMPERATURE, new SignedWordElement(516), SCALE_FACTOR_MINUS_1), // m(FeneconHomeBattery.ChannelId.ID_OF_MAX_TEMPERATURE, new UnsignedWordElement(517)), // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(518), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [A] + SCALE_FACTOR_MINUS_1), // [A] m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(519), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [A] + SCALE_FACTOR_MINUS_1), // [A] m(FeneconHomeBattery.ChannelId.MAX_DC_CHARGE_CURRENT_LIMIT_PER_BCU, new UnsignedWordElement(520), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(FeneconHomeBattery.ChannelId.MAX_DC_DISCHARGE_CURRENT_LIMIT_PER_BCU, new UnsignedWordElement(521), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(FeneconHomeBattery.ChannelId.RACK_NUMBER_OF_BATTERY_BCU, new UnsignedWordElement(522)), // m(FeneconHomeBattery.ChannelId.RACK_NUMBER_OF_CELLS_IN_SERIES_PER_MODULE, new UnsignedWordElement(523)), // @@ -643,16 +639,16 @@ private synchronized void initializeTowerModulesChannels(int numberOfTowers, int Level.WARNING))), // m(this.generateTowerChannel(tower, "_SOC", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 8), // [%] - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(this.generateTowerChannel(tower, "_SOH", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 9), // [%] - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(this.generateTowerChannel(tower, "_VOLTAGE", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 10), // [V] - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(this.generateTowerChannel(tower, "_CURRENT", OpenemsType.INTEGER), new SignedWordElement(towerOffset + 11), // [A] - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(this.generateTowerChannel(tower, "_MIN_CELL_VOLTAGE", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 12)), // [mV] m(this.generateTowerChannel(tower, "_MAX_CELL_VOLTAGE", OpenemsType.INTEGER), @@ -667,14 +663,13 @@ private synchronized void initializeTowerModulesChannels(int numberOfTowers, int m(this.generateTowerChannel(tower, "_NO_OF_CYCLES", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 18)), // m(this.generateTowerChannel(tower, "_DESIGN_CAPACITY", OpenemsType.INTEGER), - new UnsignedWordElement(towerOffset + 19), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [Ah] + new UnsignedWordElement(towerOffset + 19), SCALE_FACTOR_MINUS_1), // [Ah] m(this.generateTowerChannel(tower, "_USABLE_CAPACITY", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 20), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [Ah] + SCALE_FACTOR_MINUS_1), // [Ah] m(this.generateTowerChannel(tower, "_REMAINING_CAPACITY", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 21), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [Ah] + SCALE_FACTOR_MINUS_1), // [Ah] m(this.generateTowerChannel(tower, "_MAX_CELL_VOLTAGE_LIMIT", OpenemsType.INTEGER), new UnsignedWordElement(towerOffset + 22)), // m(this.generateTowerChannel(tower, "_MIN_CELL_VOLTAGE_LIMIT", OpenemsType.INTEGER), diff --git a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/ClusterVersionB.java b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/ClusterVersionB.java index d9d5c5c0927..335a26b1771 100644 --- a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/ClusterVersionB.java +++ b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/ClusterVersionB.java @@ -1,5 +1,7 @@ package io.openems.edge.battery.soltaro.cluster.versionb; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; @@ -563,7 +565,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(0x1044, Priority.LOW, // m(SoltaroCluster.ChannelId.CHARGE_INDICATION, new UnsignedWordElement(0x1044)), // m(Battery.ChannelId.CURRENT, new UnsignedWordElement(0x1045), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // new DummyRegisterElement(0x1046), // m(Battery.ChannelId.SOC, new UnsignedWordElement(0x1047)) // .onUpdateCallback(val -> { @@ -571,14 +573,14 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { }), // m(SoltaroCluster.ChannelId.SYSTEM_RUNNING_STATE, new UnsignedWordElement(0x1048)), // m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(0x1049), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC3ReadRegistersTask(0x104A, Priority.HIGH, // m(SoltaroCluster.ChannelId.SYSTEM_INSULATION, new UnsignedWordElement(0x104A)), // new DummyRegisterElement(0x104B, 0x104D), // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(0x104E), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(0x104F), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), // + SCALE_FACTOR_MINUS_1)), // new FC3ReadRegistersTask(0x1081, Priority.LOW, // m(new BitsWordElement(0x1081, this) // .bit(4, ClusterVersionBChannelId.MASTER_ALARM_LEVEL_2_INSULATION) // diff --git a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/SingleRack.java b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/SingleRack.java index 08c4c5cdbac..48c15ab3387 100644 --- a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/SingleRack.java +++ b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionb/SingleRack.java @@ -1,5 +1,8 @@ package io.openems.edge.battery.soltaro.cluster.versionb; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -14,7 +17,6 @@ import io.openems.edge.battery.soltaro.common.ChannelIdImpl; import io.openems.edge.battery.soltaro.common.enums.ChargeIndication; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.element.AbstractModbusElement; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; import io.openems.edge.bridge.modbus.api.element.SignedWordElement; @@ -153,10 +155,8 @@ protected Collection getTasks() { // State values tasks.add(new FC3ReadRegistersTask(this.addressOffset + 0x100, Priority.HIGH, // - this.parent.map(this.channelIds.get(KEY_VOLTAGE), this.getUnsignedWordElement(0x100), - ElementToChannelConverter.SCALE_FACTOR_2), // - this.parent.map(this.channelIds.get(KEY_CURRENT), this.getSignedWordElement(0x101), - ElementToChannelConverter.SCALE_FACTOR_2), // + this.parent.map(this.channelIds.get(KEY_VOLTAGE), this.getUnsignedWordElement(0x100), SCALE_FACTOR_2), // + this.parent.map(this.channelIds.get(KEY_CURRENT), this.getSignedWordElement(0x101), SCALE_FACTOR_2), // this.parent.map(this.channelIds.get(KEY_CHARGE_INDICATION), this.getUnsignedWordElement(0x102)), // this.parent.map(this.channelIds.get(KEY_SOC), this.getUnsignedWordElement(0x103)). // onUpdateCallback(val -> { @@ -175,13 +175,13 @@ protected Collection getTasks() { }), // this.parent.map(this.channelIds.get(KEY_MAX_CELL_TEMPERATURE_ID), this.getUnsignedWordElement(0x109)), // this.parent.map(this.channelIds.get(KEY_MAX_CELL_TEMPERATURE), this.getSignedWordElement(0x10A), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1). // + SCALE_FACTOR_MINUS_1). // onUpdateCallback(val -> { this.parent.recalculateMaxCellTemperature(); }), // this.parent.map(this.channelIds.get(KEY_MIN_CELL_TEMPERATURE_ID), this.getUnsignedWordElement(0x10B)), // this.parent.map(this.channelIds.get(KEY_MIN_CELL_TEMPERATURE), this.getSignedWordElement(0x10C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1). // + SCALE_FACTOR_MINUS_1). // onUpdateCallback(val -> { this.parent.recalculateMinCellTemperature(); }) // diff --git a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionc/ClusterVersionCImpl.java b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionc/ClusterVersionCImpl.java index e66b7897b21..cc07f022091 100644 --- a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionc/ClusterVersionCImpl.java +++ b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/cluster/versionc/ClusterVersionCImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.battery.soltaro.cluster.versionc; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.LinkedList; import java.util.Optional; import java.util.Queue; @@ -43,7 +46,6 @@ import io.openems.edge.battery.soltaro.versionc.utils.Constants; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.ModbusUtils; @@ -238,10 +240,9 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th // Single Cluster Status Registers new FC3ReadRegistersTask(r.offset + 0x100, Priority.HIGH, // m(this.createChannelId(r, RackChannel.VOLTAGE), - new UnsignedWordElement(r.offset + 0x100), - ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(r.offset + 0x100), SCALE_FACTOR_2), m(this.createChannelId(r, RackChannel.CURRENT), new SignedWordElement(r.offset + 0x101), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(this.createChannelId(r, RackChannel.CHARGE_INDICATION), new UnsignedWordElement(r.offset + 0x102)), m(this.createChannelId(r, RackChannel.SOC), new UnsignedWordElement(r.offset + 0x103)), @@ -257,23 +258,19 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.MAX_CELL_TEMPERATURE_ID), new UnsignedWordElement(r.offset + 0x109)), m(this.createChannelId(r, RackChannel.MAX_CELL_TEMPERATURE), - new SignedWordElement(r.offset + 0x10A), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + new SignedWordElement(r.offset + 0x10A), SCALE_FACTOR_MINUS_1), m(this.createChannelId(r, RackChannel.MIN_CELL_TEMPERATURE_ID), new UnsignedWordElement(r.offset + 0x10B)), m(this.createChannelId(r, RackChannel.MIN_CELL_TEMPERATURE), - new SignedWordElement(r.offset + 0x10C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + new SignedWordElement(r.offset + 0x10C), SCALE_FACTOR_MINUS_1), m(this.createChannelId(r, RackChannel.AVERAGE_VOLTAGE), new UnsignedWordElement(r.offset + 0x10D)), m(this.createChannelId(r, RackChannel.SYSTEM_INSULATION), new UnsignedWordElement(r.offset + 0x10E)), m(this.createChannelId(r, RackChannel.SYSTEM_MAX_CHARGE_CURRENT), - new UnsignedWordElement(r.offset + 0x10F), - ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(r.offset + 0x10F), SCALE_FACTOR_2), m(this.createChannelId(r, RackChannel.SYSTEM_MAX_DISCHARGE_CURRENT), - new UnsignedWordElement(r.offset + 0x110), - ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(r.offset + 0x110), SCALE_FACTOR_2), m(this.createChannelId(r, RackChannel.POSITIVE_INSULATION), new UnsignedWordElement(r.offset + 0x111)), m(this.createChannelId(r, RackChannel.NEGATIVE_INSULATION), @@ -418,25 +415,25 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.PRE_ALARM_CELL_OVER_VOLTAGE_RECOVER), new UnsignedWordElement(r.offset + 0x081)), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_OVER_VOLTAGE_ALARM), - new UnsignedWordElement(r.offset + 0x082), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x082), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_OVER_VOLTAGE_RECOVER), - new UnsignedWordElement(r.offset + 0x083), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x083), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_CHARGE_OVER_CURRENT_ALARM), - new UnsignedWordElement(r.offset + 0x084), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x084), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_CHARGE_OVER_CURRENT_RECOVER), - new UnsignedWordElement(r.offset + 0x085), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x085), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_CELL_UNDER_VOLTAGE_ALARM), new UnsignedWordElement(r.offset + 0x086)), // m(this.createChannelId(r, RackChannel.PRE_ALARM_CELL_UNDER_VOLTAGE_RECOVER), new UnsignedWordElement(r.offset + 0x087)), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_UNDER_VOLTAGE_ALARM), - new UnsignedWordElement(r.offset + 0x088), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x088), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_UNDER_VOLTAGE_RECOVER), - new UnsignedWordElement(r.offset + 0x089), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x089), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_DISCHARGE_OVER_CURRENT_ALARM), - new UnsignedWordElement(r.offset + 0x08A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x08A), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER), - new UnsignedWordElement(r.offset + 0x08B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x08B), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_CELL_OVER_TEMPERATURE_ALARM), new SignedWordElement(r.offset + 0x08C)), // m(this.createChannelId(r, RackChannel.PRE_ALARM_CELL_OVER_TEMPERATURE_RECOVER), @@ -463,9 +460,9 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.PRE_ALARM_CELL_VOLTAGE_DIFFERENCE_ALARM_RECOVER), new UnsignedWordElement(r.offset + 0x099)), // m(this.createChannelId(r, RackChannel.PRE_ALARM_TOTAL_VOLTAGE_DIFFERENCE_ALARM), - new UnsignedWordElement(r.offset + 0x09A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x09A), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_TOTAL_VOLTAGE_DIFFERENCE_ALARM_RECOVER), - new UnsignedWordElement(r.offset + 0x09B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x09B), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.PRE_ALARM_DISCHARGE_TEMPERATURE_HIGH_ALARM), new SignedWordElement(r.offset + 0x09C)), // m(this.createChannelId(r, RackChannel.PRE_ALARM_DISCHARGE_TEMPERATURE_HIGH_ALARM_RECOVER), @@ -493,25 +490,25 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.LEVEL1_CELL_OVER_VOLTAGE_RECOVER), new UnsignedWordElement(r.offset + 0x041)), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_OVER_VOLTAGE_PROTECTION), - new UnsignedWordElement(r.offset + 0x042), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x042), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_OVER_VOLTAGE_RECOVER), - new UnsignedWordElement(r.offset + 0x043), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x043), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_CHARGE_OVER_CURRENT_PROTECTION), - new UnsignedWordElement(r.offset + 0x044), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x044), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_CHARGE_OVER_CURRENT_RECOVER), - new UnsignedWordElement(r.offset + 0x045), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x045), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_CELL_UNDER_VOLTAGE_PROTECTION), new UnsignedWordElement(r.offset + 0x046)), // m(this.createChannelId(r, RackChannel.LEVEL1_CELL_UNDER_VOLTAGE_RECOVER), new UnsignedWordElement(r.offset + 0x047)), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_UNDER_VOLTAGE_PROTECTION), - new UnsignedWordElement(r.offset + 0x048), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x048), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_UNDER_VOLTAGE_RECOVER), - new UnsignedWordElement(r.offset + 0x049), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x049), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_DISCHARGE_OVER_CURRENT_PROTECTION), - new UnsignedWordElement(r.offset + 0x04A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x04A), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER), - new UnsignedWordElement(r.offset + 0x04B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x04B), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_CELL_OVER_TEMPERATURE_PROTECTION), new SignedWordElement(r.offset + 0x04C)), // m(this.createChannelId(r, RackChannel.LEVEL1_CELL_OVER_TEMPERATURE_RECOVER), @@ -538,9 +535,9 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.LEVEL1_CELL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER), new UnsignedWordElement(r.offset + 0x059)), // m(this.createChannelId(r, RackChannel.LEVEL1_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION), - new UnsignedWordElement(r.offset + 0x05A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x05A), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER), - new UnsignedWordElement(r.offset + 0x05B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x05B), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL1_DISCHARGE_TEMPERATURE_HIGH_PROTECTION), new SignedWordElement(r.offset + 0x05C)), // m(this.createChannelId(r, RackChannel.LEVEL1_DISCHARGE_TEMPERATURE_HIGH_PROTECTION_RECOVER), @@ -570,23 +567,23 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_OVER_VOLTAGE_PROTECTION), new UnsignedWordElement(r.offset + 0x402)), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_OVER_VOLTAGE_RECOVER), - new UnsignedWordElement(r.offset + 0x403), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x403), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_CHARGE_OVER_CURRENT_PROTECTION), - new UnsignedWordElement(r.offset + 0x404), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x404), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_CHARGE_OVER_CURRENT_RECOVER), - new UnsignedWordElement(r.offset + 0x405), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x405), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_CELL_UNDER_VOLTAGE_PROTECTION), new UnsignedWordElement(r.offset + 0x406)), // m(this.createChannelId(r, RackChannel.LEVEL2_CELL_UNDER_VOLTAGE_RECOVER), new UnsignedWordElement(r.offset + 0x407)), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_UNDER_VOLTAGE_PROTECTION), - new UnsignedWordElement(r.offset + 0x408), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x408), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_UNDER_VOLTAGE_RECOVER), - new UnsignedWordElement(r.offset + 0x409), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x409), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_DISCHARGE_OVER_CURRENT_PROTECTION), - new UnsignedWordElement(r.offset + 0x40A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x40A), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER), - new UnsignedWordElement(r.offset + 0x40B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x40B), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_CELL_OVER_TEMPERATURE_PROTECTION), new SignedWordElement(r.offset + 0x40C)), // m(this.createChannelId(r, RackChannel.LEVEL2_CELL_OVER_TEMPERATURE_RECOVER), @@ -613,9 +610,9 @@ private void updateRackChannels(Integer numberOfModules, TreeSet racks) th m(this.createChannelId(r, RackChannel.LEVEL2_CELL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER), new UnsignedWordElement(r.offset + 0x419)), // m(this.createChannelId(r, RackChannel.LEVEL2_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION), - new UnsignedWordElement(r.offset + 0x41A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x41A), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER), - new UnsignedWordElement(r.offset + 0x41B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(r.offset + 0x41B), SCALE_FACTOR_2), // m(this.createChannelId(r, RackChannel.LEVEL2_DISCHARGE_TEMPERATURE_HIGH_PROTECTION), new SignedWordElement(r.offset + 0x41C)), // m(this.createChannelId(r, RackChannel.LEVEL2_DISCHARGE_TEMPERATURE_HIGH_PROTECTION_RECOVER), @@ -829,18 +826,18 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(0x1044, Priority.HIGH, // m(SoltaroCluster.ChannelId.CHARGE_INDICATION, new UnsignedWordElement(0x1044)), // m(Battery.ChannelId.CURRENT, new UnsignedWordElement(0x1045), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // new DummyRegisterElement(0x1046), // m(ClusterVersionC.ChannelId.ORIGINAL_SOC, new UnsignedWordElement(0x1047)), // m(SoltaroCluster.ChannelId.SYSTEM_RUNNING_STATE, new UnsignedWordElement(0x1048)), // m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(0x1049), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(SoltaroCluster.ChannelId.SYSTEM_INSULATION, new UnsignedWordElement(0x104A)), // new DummyRegisterElement(0x104B, 0x104D), // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(0x104E), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(0x104F), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), // + SCALE_FACTOR_MINUS_1)), // new FC3ReadRegistersTask(0x1081, Priority.LOW, // m(new BitsWordElement(0x1081, this) // .bit(0, ClusterVersionC.ChannelId.MASTER_PCS_COMMUNICATION_FAILURE) // diff --git a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versiona/SingleRack.java b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versiona/SingleRack.java index 3ca25f8a5f7..7f67a803717 100644 --- a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versiona/SingleRack.java +++ b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versiona/SingleRack.java @@ -1,5 +1,7 @@ package io.openems.edge.battery.soltaro.single.versiona; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.time.LocalDateTime; import org.osgi.service.cm.ConfigurationAdmin; @@ -34,7 +36,6 @@ import io.openems.edge.battery.soltaro.common.enums.State; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -1137,13 +1138,13 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // new FC3ReadRegistersTask(0x2042, Priority.HIGH, // m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, new UnsignedWordElement(0x2042), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_MINUS_1) // ), // new FC3ReadRegistersTask(0x2046, Priority.HIGH, // m(SingleRack.ChannelId.CELL_VOLTAGE_PROTECT, new UnsignedWordElement(0x2046)), // m(SingleRack.ChannelId.CELL_VOLTAGE_RECOVER, new UnsignedWordElement(0x2047)), // m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(0x2048), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_MINUS_1) // ), // new FC6WriteRegisterTask(0x2046, // m(SingleRack.ChannelId.CELL_VOLTAGE_PROTECT, new UnsignedWordElement(0x2046)) // @@ -1153,9 +1154,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // new FC3ReadRegistersTask(0x2100, Priority.HIGH, // m(Battery.ChannelId.VOLTAGE, new UnsignedWordElement(0x2100), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(Battery.ChannelId.CURRENT, new SignedWordElement(0x2101), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(SingleRack.ChannelId.CHARGE_INDICATION, new UnsignedWordElement(0x2102)), // m(Battery.ChannelId.SOC, new UnsignedWordElement(0x2103)), // m(Battery.ChannelId.SOH, new UnsignedWordElement(0x2104)), // @@ -1164,19 +1165,17 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRack.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2107)), // m(Battery.ChannelId.MIN_CELL_VOLTAGE, new UnsignedWordElement(0x2108)), // m(SingleRack.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x2109)), // - m(Battery.ChannelId.MAX_CELL_TEMPERATURE, new SignedWordElement(0x210A), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(Battery.ChannelId.MAX_CELL_TEMPERATURE, new SignedWordElement(0x210A), SCALE_FACTOR_MINUS_1), // m(SingleRack.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x210B)), // - m(Battery.ChannelId.MIN_CELL_TEMPERATURE, new SignedWordElement(0x210C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(Battery.ChannelId.MIN_CELL_TEMPERATURE, new SignedWordElement(0x210C), SCALE_FACTOR_MINUS_1), // new DummyRegisterElement(0x210D, 0x2115), // m(SingleRack.ChannelId.SYSTEM_INSULATION, new UnsignedWordElement(0x2116)) // ), // new FC3ReadRegistersTask(0x2160, Priority.HIGH, // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(0x2160), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(0x2161), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_MINUS_1) // ), // new FC3ReadRegistersTask(0x2140, Priority.LOW, // m(new BitsWordElement(0x2140, this) // diff --git a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionb/SingleRackVersionBImpl.java b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionb/SingleRackVersionBImpl.java index b2f46580c88..6d2df9134d2 100644 --- a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionb/SingleRackVersionBImpl.java +++ b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionb/SingleRackVersionBImpl.java @@ -1,5 +1,10 @@ package io.openems.edge.battery.soltaro.single.versionb; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; @@ -38,7 +43,6 @@ import io.openems.edge.battery.soltaro.single.versionb.statemachine.StateMachine.State; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.ModbusUtils; @@ -332,66 +336,57 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(0x2082, Priority.LOW, // m(new UnsignedWordElement(0x2082)) // .m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_OVER_VOLTAGE_ALARM, - ElementToChannelConverter.SCALE_FACTOR_2) // - .m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_2) // + .m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, SCALE_FACTOR_MINUS_1) // .build(), // new DummyRegisterElement(0x2083, 0x2087), // m(new UnsignedWordElement(0x2088)) // .m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_UNDER_VOLTAGE_ALARM, - ElementToChannelConverter.SCALE_FACTOR_2) // - .m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_2) // + .m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, SCALE_FACTOR_MINUS_1) // .build()), // // Summary state new FC3ReadRegistersTask(0x2100, Priority.HIGH, // m(new UnsignedWordElement(0x2100)) // - .m(SingleRackVersionB.ChannelId.CLUSTER_1_VOLTAGE, - ElementToChannelConverter.SCALE_FACTOR_2) // - .m(Battery.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(SingleRackVersionB.ChannelId.CLUSTER_1_VOLTAGE, SCALE_FACTOR_2) // + .m(Battery.ChannelId.VOLTAGE, SCALE_FACTOR_MINUS_1) // .build(), // m(new SignedWordElement(0x2101)) // - .m(SingleRackVersionB.ChannelId.CLUSTER_1_CURRENT, - ElementToChannelConverter.SCALE_FACTOR_2) // - .m(Battery.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(SingleRackVersionB.ChannelId.CLUSTER_1_CURRENT, SCALE_FACTOR_2) // + .m(Battery.ChannelId.CURRENT, SCALE_FACTOR_MINUS_1) // .build(), // m(SingleRackVersionB.ChannelId.CHARGE_INDICATION, new UnsignedWordElement(0x2102)), m(Battery.ChannelId.SOC, new UnsignedWordElement(0x2103)), m(SingleRackVersionB.ChannelId.CLUSTER_1_SOH, new UnsignedWordElement(0x2104)), m(SingleRackVersionB.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2105)), // m(new SignedWordElement(0x2106)) // - .m(SingleRackVersionB.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(SingleRackVersionB.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_VOLTAGE, DIRECT_1_TO_1) // .build(), // m(SingleRackVersionB.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2107)), // m(new UnsignedWordElement(0x2108)) // - .m(SingleRackVersionB.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(SingleRackVersionB.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_VOLTAGE, DIRECT_1_TO_1) // .build(), // m(SingleRackVersionB.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x2109)), // m(new SignedWordElement(0x210A)) // - .m(SingleRackVersionB.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(SingleRackVersionB.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, SCALE_FACTOR_MINUS_1) // .build(), // m(SingleRackVersionB.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x210B)), // m(new SignedWordElement(0x210C)) // - .m(SingleRackVersionB.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(SingleRackVersionB.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, SCALE_FACTOR_MINUS_1) // .build(), // m(SingleRackVersionB.ChannelId.MAX_CELL_RESISTANCE_ID, new UnsignedWordElement(0x210D)), // m(SingleRackVersionB.ChannelId.MAX_CELL_RESISTANCE, new UnsignedWordElement(0x210E), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // m(SingleRackVersionB.ChannelId.MIN_CELL_RESISTANCE_ID, new UnsignedWordElement(0x210F)), // m(SingleRackVersionB.ChannelId.MIN_CELL_RESISTANCE, new UnsignedWordElement(0x2110), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // m(SingleRackVersionB.ChannelId.POSITIVE_INSULATION, new UnsignedWordElement(0x2111)), // m(SingleRackVersionB.ChannelId.NEGATIVE_INSULATION, new UnsignedWordElement(0x2112)), // m(SingleRackVersionB.ChannelId.MAIN_CONTACTOR_FLAG, new UnsignedWordElement(0x2113)), // @@ -400,7 +395,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.SYSTEM_INSULATION, new UnsignedWordElement(0x2116)), // m(SingleRackVersionB.ChannelId.CELL_VOLTAGE_DIFFERENCE, new UnsignedWordElement(0x2117)), // m(SingleRackVersionB.ChannelId.TOTAL_VOLTAGE_DIFFERENCE, new UnsignedWordElement(0x2118), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.POWER_TEMPERATURE, new UnsignedWordElement(0x2119)), // m(SingleRackVersionB.ChannelId.POWER_SUPPLY_VOLTAGE, new UnsignedWordElement(0x211A))), // @@ -476,9 +471,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.OTHER_ALARM_EQUIPMENT_FAILURE, new UnsignedWordElement(0x215B)), // new DummyRegisterElement(0x215C, 0x215F), // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(0x2160), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(0x2161), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), // + SCALE_FACTOR_MINUS_1)), // // Cluster info new FC3ReadRegistersTask(0x2180, Priority.LOW, // @@ -525,14 +520,14 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.SYSTEM_TIME_LOW, new UnsignedWordElement(0x2187)), // new DummyRegisterElement(0x2188, 0x218E), // m(SingleRackVersionB.ChannelId.LAST_TIME_CHARGE_CAPACITY_LOW_BITS, - new UnsignedWordElement(0x218F), ElementToChannelConverter.SCALE_FACTOR_1), // + new UnsignedWordElement(0x218F), SCALE_FACTOR_1), // m(SingleRackVersionB.ChannelId.LAST_TIME_CHARGE_END_TIME_HIGH_BITS, new UnsignedWordElement(0x2190)), // m(SingleRackVersionB.ChannelId.LAST_TIME_CHARGE_END_TIME_LOW_BITS, new UnsignedWordElement(0x2191)), // new DummyRegisterElement(0x2192), // m(SingleRackVersionB.ChannelId.LAST_TIME_DISCHARGE_CAPACITY_LOW_BITS, - new UnsignedWordElement(0x2193), ElementToChannelConverter.SCALE_FACTOR_1), // + new UnsignedWordElement(0x2193), SCALE_FACTOR_1), // m(SingleRackVersionB.ChannelId.LAST_TIME_DISCHARGE_END_TIME_HIGH_BITS, new UnsignedWordElement(0x2194)), // m(SingleRackVersionB.ChannelId.LAST_TIME_DISCHARGE_END_TIME_LOW_BITS, @@ -591,25 +586,25 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2041)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_OVER_VOLTAGE_PROTECTION, - new UnsignedWordElement(0x2042), ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(0x2042), SCALE_FACTOR_2), m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_OVER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2043), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2043), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x2044), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2044), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2045), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2045), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_UNDER_VOLTAGE_PROTECTION, new UnsignedWordElement(0x2046)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2047)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_UNDER_VOLTAGE_PROTECTION, - new UnsignedWordElement(0x2048), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2048), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_UNDER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2049), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2049), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x204A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x204A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x204B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x204B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_OVER_TEMPERATURE_PROTECTION, new SignedWordElement(0x204C)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_OVER_TEMPERATURE_RECOVER, @@ -639,9 +634,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, new UnsignedWordElement(0x2059)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION, - new UnsignedWordElement(0x205A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x205A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, - new UnsignedWordElement(0x205B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x205B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_PROTECTION, new SignedWordElement(0x205C)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_PROTECTION_RECOVER, @@ -662,25 +657,25 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2081)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_OVER_VOLTAGE_ALARM, - new UnsignedWordElement(0x2082), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2082), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_OVER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2083), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2083), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_ALARM, - new UnsignedWordElement(0x2084), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2084), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2085), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2085), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_UNDER_VOLTAGE_ALARM, new UnsignedWordElement(0x2086)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2087)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_UNDER_VOLTAGE_ALARM, - new UnsignedWordElement(0x2088), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2088), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_UNDER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2089), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2089), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_ALARM, - new UnsignedWordElement(0x208A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x208A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x208B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x208B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_OVER_TEMPERATURE_ALARM, new SignedWordElement(0x208C)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_OVER_TEMPERATURE_RECOVER, @@ -708,9 +703,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_VOLTAGE_DIFFERENCE_ALARM_RECOVER, new UnsignedWordElement(0x2099)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_ALARM, - new UnsignedWordElement(0x209A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x209A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_ALARM_RECOVER, - new UnsignedWordElement(0x209B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x209B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_ALARM, new SignedWordElement(0x209C)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_ALARM_RECOVER, @@ -736,25 +731,25 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2041)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_OVER_VOLTAGE_PROTECTION, - new UnsignedWordElement(0x2042), ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(0x2042), SCALE_FACTOR_2), m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_OVER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2043), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2043), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x2044), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2044), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2045), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2045), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_UNDER_VOLTAGE_PROTECTION, new UnsignedWordElement(0x2046)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2047)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_UNDER_VOLTAGE_PROTECTION, - new UnsignedWordElement(0x2048), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2048), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_UNDER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2049), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2049), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x204A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x204A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x204B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x204B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_OVER_TEMPERATURE_PROTECTION, new SignedWordElement(0x204C)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_OVER_TEMPERATURE_RECOVER, @@ -782,9 +777,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.STOP_PARAMETER_CELL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, new UnsignedWordElement(0x2059)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION, - new UnsignedWordElement(0x205A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x205A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, - new UnsignedWordElement(0x205B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x205B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_PROTECTION, new SignedWordElement(0x205C)), // m(SingleRackVersionB.ChannelId.STOP_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_PROTECTION_RECOVER, @@ -806,22 +801,22 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new UnsignedWordElement(0x2081)), // new DummyRegisterElement(0x2082), m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_OVER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2083), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2083), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_ALARM, - new UnsignedWordElement(0x2084), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2084), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2085), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2085), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_UNDER_VOLTAGE_ALARM, new UnsignedWordElement(0x2086)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2087)), // new DummyRegisterElement(0x2088), m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_UNDER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2089), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2089), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_ALARM, - new UnsignedWordElement(0x208A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x208A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x208B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x208B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_OVER_TEMPERATURE_ALARM, new SignedWordElement(0x208C)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_OVER_TEMPERATURE_RECOVER, @@ -848,9 +843,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionB.ChannelId.WARN_PARAMETER_CELL_VOLTAGE_DIFFERENCE_ALARM_RECOVER, new UnsignedWordElement(0x2099)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_ALARM, - new UnsignedWordElement(0x209A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x209A), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_TOTAL_VOLTAGE_DIFFERENCE_ALARM_RECOVER, - new UnsignedWordElement(0x209B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x209B), SCALE_FACTOR_2), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_ALARM, new SignedWordElement(0x209C)), // m(SingleRackVersionB.ChannelId.WARN_PARAMETER_DISCHARGE_TEMPERATURE_HIGH_ALARM_RECOVER, diff --git a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionc/SingleRackVersionCImpl.java b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionc/SingleRackVersionCImpl.java index b48361d02ec..9e7cc9a065f 100644 --- a/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionc/SingleRackVersionCImpl.java +++ b/io.openems.edge.battery.soltaro/src/io/openems/edge/battery/soltaro/single/versionc/SingleRackVersionCImpl.java @@ -1,5 +1,9 @@ package io.openems.edge.battery.soltaro.single.versionc; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; @@ -35,7 +39,6 @@ import io.openems.edge.battery.soltaro.versionc.utils.CellChannelFactory.Type; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.ModbusUtils; @@ -283,54 +286,46 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Single Cluster Running Status Registers new FC3ReadRegistersTask(0x2100, Priority.HIGH, // m(new UnsignedWordElement(0x2100)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_VOLTAGE, - ElementToChannelConverter.SCALE_FACTOR_2) // [mV] - .m(Battery.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // [V] + .m(SingleRackVersionC.ChannelId.CLUSTER_1_VOLTAGE, SCALE_FACTOR_2) // [mV] + .m(Battery.ChannelId.VOLTAGE, SCALE_FACTOR_MINUS_1) // [V] .build(), // m(new UnsignedWordElement(0x2101)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_CURRENT, - ElementToChannelConverter.SCALE_FACTOR_2) // [mA] - .m(Battery.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // [A] + .m(SingleRackVersionC.ChannelId.CLUSTER_1_CURRENT, SCALE_FACTOR_2) // [mA] + .m(Battery.ChannelId.CURRENT, SCALE_FACTOR_MINUS_1) // [A] .build(), // m(SingleRackVersionC.ChannelId.CHARGE_INDICATION, new UnsignedWordElement(0x2102)), m(Battery.ChannelId.SOC, new UnsignedWordElement(0x2103)), m(new UnsignedWordElement(0x2104)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_SOH, ElementToChannelConverter.DIRECT_1_TO_1) // [%] - .m(Battery.ChannelId.SOH, ElementToChannelConverter.DIRECT_1_TO_1) // [%] + .m(SingleRackVersionC.ChannelId.CLUSTER_1_SOH, DIRECT_1_TO_1) // [%] + .m(Battery.ChannelId.SOH, DIRECT_1_TO_1) // [%] .build(), // m(SingleRackVersionC.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2105)), // m(new UnsignedWordElement(0x2106)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(SingleRackVersionC.ChannelId.CLUSTER_1_MAX_CELL_VOLTAGE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_VOLTAGE, DIRECT_1_TO_1) // .build(), // m(SingleRackVersionC.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE_ID, new UnsignedWordElement(0x2107)), // m(new UnsignedWordElement(0x2108)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(SingleRackVersionC.ChannelId.CLUSTER_1_MIN_CELL_VOLTAGE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_VOLTAGE, DIRECT_1_TO_1) // .build(), // m(SingleRackVersionC.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x2109)), // m(new SignedWordElement(0x210A)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(SingleRackVersionC.ChannelId.CLUSTER_1_MAX_CELL_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MAX_CELL_TEMPERATURE, SCALE_FACTOR_MINUS_1) // .build(), // m(SingleRackVersionC.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE_ID, new UnsignedWordElement(0x210B)), // m(new SignedWordElement(0x210C)) // - .m(SingleRackVersionC.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE, - ElementToChannelConverter.DIRECT_1_TO_1) // - .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + .m(SingleRackVersionC.ChannelId.CLUSTER_1_MIN_CELL_TEMPERATURE, DIRECT_1_TO_1) // + .m(Battery.ChannelId.MIN_CELL_TEMPERATURE, SCALE_FACTOR_MINUS_1) // .build(), // m(SingleRackVersionC.ChannelId.CLUSTER_1_AVERAGE_VOLTAGE, new UnsignedWordElement(0x210D)), // m(SingleRackVersionC.ChannelId.CLUSTER_1_SYSTEM_INSULATION, new UnsignedWordElement(0x210E)), // m(BatteryProtection.ChannelId.BP_CHARGE_BMS, new UnsignedWordElement(0x210F), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(BatteryProtection.ChannelId.BP_DISCHARGE_BMS, new UnsignedWordElement(0x2110), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(SingleRackVersionC.ChannelId.POSITIVE_INSULATION, new UnsignedWordElement(0x2111)), // m(SingleRackVersionC.ChannelId.NEGATIVE_INSULATION, new UnsignedWordElement(0x2112)), // m(SingleRackVersionC.ChannelId.CLUSTER_RUN_STATE, new UnsignedWordElement(0x2113)), // @@ -466,24 +461,24 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionC.ChannelId.PRE_ALARM_CELL_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2081)), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_OVER_VOLTAGE_ALARM, new UnsignedWordElement(0x2082), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_OVER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2083), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2083), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_CHARGE_OVER_CURRENT_ALARM, - new UnsignedWordElement(0x2084), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2084), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2085), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2085), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_CELL_UNDER_VOLTAGE_ALARM, new UnsignedWordElement(0x2086)), // m(SingleRackVersionC.ChannelId.PRE_ALARM_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2087)), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_UNDER_VOLTAGE_ALARM, - new UnsignedWordElement(0x2088), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2088), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_UNDER_VOLTAGE_RECOVER, - new UnsignedWordElement(0x2089), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2089), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_DISCHARGE_OVER_CURRENT_ALARM, - new UnsignedWordElement(0x208A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x208A), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x208B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x208B), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_CELL_OVER_TEMPERATURE_ALARM, new SignedWordElement(0x208C)), // m(SingleRackVersionC.ChannelId.PRE_ALARM_CELL_OVER_TEMPERATURE_RECOVER, @@ -506,9 +501,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionC.ChannelId.PRE_ALARM_CELL_VOLTAGE_DIFFERENCE_ALARM_RECOVER, new UnsignedWordElement(0x2099)), // m(SingleRackVersionC.ChannelId.PRE_ALARM_TOTAL_VOLTAGE_DIFFERENCE_ALARM, - new UnsignedWordElement(0x209A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x209A), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_TOTAL_VOLTAGE_DIFFERENCE_ALARM_RECOVER, - new UnsignedWordElement(0x209B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x209B), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.PRE_ALARM_DISCHARGE_TEMPERATURE_HIGH_ALARM, new SignedWordElement(0x209C)), // m(SingleRackVersionC.ChannelId.PRE_ALARM_DISCHARGE_TEMPERATURE_HIGH_ALARM_RECOVER, @@ -533,24 +528,24 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new UnsignedWordElement(0x2040)), // m(SingleRackVersionC.ChannelId.LEVEL1_CELL_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2041)), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_OVER_VOLTAGE_PROTECTION, - new UnsignedWordElement(0x2042), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2042), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2043), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_CHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x2044), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2044), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2045), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2045), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_CELL_UNDER_VOLTAGE_PROTECTION, new UnsignedWordElement(0x2046)), // m(SingleRackVersionC.ChannelId.LEVEL1_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2047)), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_UNDER_VOLTAGE_PROTECTION, - new UnsignedWordElement(0x2048), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2048), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2049), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_DISCHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x204A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x204A), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x204B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x204B), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_CELL_OVER_TEMPERATURE_PROTECTION, new SignedWordElement(0x204C)), // m(SingleRackVersionC.ChannelId.LEVEL1_CELL_OVER_TEMPERATURE_RECOVER, new SignedWordElement(0x204D)), // @@ -573,9 +568,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionC.ChannelId.LEVEL1_CELL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, new UnsignedWordElement(0x2059)), // m(SingleRackVersionC.ChannelId.LEVEL1_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION, - new UnsignedWordElement(0x205A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x205A), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, - new UnsignedWordElement(0x205B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x205B), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL1_DISCHARGE_TEMPERATURE_HIGH_PROTECTION, new SignedWordElement(0x205C)), // m(SingleRackVersionC.ChannelId.LEVEL1_DISCHARGE_TEMPERATURE_HIGH_PROTECTION_RECOVER, @@ -600,30 +595,28 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new UnsignedWordElement(0x2400)), // m(SingleRackVersionC.ChannelId.LEVEL2_CELL_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2401)), // m(new UnsignedWordElement(0x2402)) // - .m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_OVER_VOLTAGE_PROTECTION, - ElementToChannelConverter.SCALE_FACTOR_2) // [mV] - .m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // [V] + .m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_OVER_VOLTAGE_PROTECTION, SCALE_FACTOR_2) // [mV] + .m(Battery.ChannelId.CHARGE_MAX_VOLTAGE, SCALE_FACTOR_MINUS_1) // [V] .build(), // m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_OVER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2403), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_CHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x2404), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2404), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_CHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x2405), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x2405), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_CELL_UNDER_VOLTAGE_PROTECTION, new UnsignedWordElement(0x2406)), // m(SingleRackVersionC.ChannelId.LEVEL2_CELL_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2407)), // m(new UnsignedWordElement(0x2408)) // - .m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_UNDER_VOLTAGE_PROTECTION, - ElementToChannelConverter.SCALE_FACTOR_2) // [mV] - .m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // [V] + .m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_UNDER_VOLTAGE_PROTECTION, SCALE_FACTOR_2) // [mV] + .m(Battery.ChannelId.DISCHARGE_MIN_VOLTAGE, SCALE_FACTOR_MINUS_1) // [V] .build(), // m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_UNDER_VOLTAGE_RECOVER, new UnsignedWordElement(0x2409), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_DISCHARGE_OVER_CURRENT_PROTECTION, - new UnsignedWordElement(0x240A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x240A), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_SYSTEM_DISCHARGE_OVER_CURRENT_RECOVER, - new UnsignedWordElement(0x240B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x240B), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_CELL_OVER_TEMPERATURE_PROTECTION, new SignedWordElement(0x240C)), // m(SingleRackVersionC.ChannelId.LEVEL2_CELL_OVER_TEMPERATURE_RECOVER, new SignedWordElement(0x240D)), // @@ -646,9 +639,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SingleRackVersionC.ChannelId.LEVEL2_CELL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, new UnsignedWordElement(0x2419)), // m(SingleRackVersionC.ChannelId.LEVEL2_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION, - new UnsignedWordElement(0x241A), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x241A), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_TOTAL_VOLTAGE_DIFFERENCE_PROTECTION_RECOVER, - new UnsignedWordElement(0x241B), ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x241B), SCALE_FACTOR_2), // m(SingleRackVersionC.ChannelId.LEVEL2_DISCHARGE_TEMPERATURE_HIGH_PROTECTION, new SignedWordElement(0x241C)), // m(SingleRackVersionC.ChannelId.LEVEL2_DISCHARGE_TEMPERATURE_HIGH_PROTECTION_RECOVER, diff --git a/io.openems.edge.batteryinverter.refu88k/src/io/openems/edge/batteryinverter/refu88k/RefuStore88kImpl.java b/io.openems.edge.batteryinverter.refu88k/src/io/openems/edge/batteryinverter/refu88k/RefuStore88kImpl.java index 4e862b38ba1..b2eeab4b6f0 100644 --- a/io.openems.edge.batteryinverter.refu88k/src/io/openems/edge/batteryinverter/refu88k/RefuStore88kImpl.java +++ b/io.openems.edge.batteryinverter.refu88k/src/io/openems/edge/batteryinverter/refu88k/RefuStore88kImpl.java @@ -1,5 +1,11 @@ package io.openems.edge.batteryinverter.refu88k; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_3; + import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; @@ -29,7 +35,6 @@ import io.openems.edge.batteryinverter.refu88k.statemachine.StateMachine.State; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -237,56 +242,56 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Reg m(RefuStore88kChannelId.ID_103, new UnsignedWordElement(SUNSPEC_103)), // 40070 m(RefuStore88kChannelId.L_103, new UnsignedWordElement(SUNSPEC_103 + 1)), // 40071 m(RefuStore88kChannelId.A, new UnsignedWordElement(SUNSPEC_103 + 2), // 40072 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.APH_A, new UnsignedWordElement(SUNSPEC_103 + 3), // 40073 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.APH_B, new UnsignedWordElement(SUNSPEC_103 + 4), // 40074 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.APH_C, new UnsignedWordElement(SUNSPEC_103 + 5), // 40075 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.A_SF, new UnsignedWordElement(SUNSPEC_103 + 6)), // 40076 m(RefuStore88kChannelId.PP_VPH_AB, new UnsignedWordElement(SUNSPEC_103 + 7), // 40077 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.PP_VPH_BC, new UnsignedWordElement(SUNSPEC_103 + 8), // 40078 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.PP_VPH_CA, new UnsignedWordElement(SUNSPEC_103 + 9), // 40079 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.PH_VPH_A, new UnsignedWordElement(SUNSPEC_103 + 10), // 40080 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.PH_VPH_B, new UnsignedWordElement(SUNSPEC_103 + 11), // 40081 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.PH_VPH_C, new UnsignedWordElement(SUNSPEC_103 + 12), // 40082 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.V_SF, new UnsignedWordElement(SUNSPEC_103 + 13)), // 40083 m(SymmetricBatteryInverter.ChannelId.ACTIVE_POWER, new SignedWordElement(SUNSPEC_103 + 14), // 40084 - ElementToChannelConverter.SCALE_FACTOR_1), // REFUStore88KChannelId.W// + SCALE_FACTOR_1), // REFUStore88KChannelId.W// m(RefuStore88kChannelId.W_SF, new SignedWordElement(SUNSPEC_103 + 15)), // 40085 m(RefuStore88kChannelId.HZ, new SignedWordElement(SUNSPEC_103 + 16), // 40086 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.HZ_SF, new SignedWordElement(SUNSPEC_103 + 17)), // 40087 m(RefuStore88kChannelId.VA, new SignedWordElement(SUNSPEC_103 + 18), // 40088 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.VA_SF, new SignedWordElement(SUNSPEC_103 + 19)), // 40089 m(SymmetricBatteryInverter.ChannelId.REACTIVE_POWER, new SignedWordElement(SUNSPEC_103 + 20), // 40090 - ElementToChannelConverter.SCALE_FACTOR_1), // REFUStore88KChannelId.VA_R + SCALE_FACTOR_1), // REFUStore88KChannelId.VA_R m(RefuStore88kChannelId.VA_R_SF, new SignedWordElement(SUNSPEC_103 + 21)), // 40091 new DummyRegisterElement(SUNSPEC_103 + 22, SUNSPEC_103 + 23), m(RefuStore88kChannelId.WH, new UnsignedDoublewordElement(SUNSPEC_103 + 24), // 40094 - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(RefuStore88kChannelId.WH_SF, new UnsignedWordElement(SUNSPEC_103 + 26)), // 40096 m(RefuStore88kChannelId.DCA, new SignedWordElement(SUNSPEC_103 + 27), // 40097 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.DCA_SF, new UnsignedWordElement(SUNSPEC_103 + 28)), // 40098 m(RefuStore88kChannelId.DCV, new UnsignedWordElement(SUNSPEC_103 + 29), // 40099 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.DCV_SF, new UnsignedWordElement(SUNSPEC_103 + 30)), // 40100 m(RefuStore88kChannelId.DCW, new SignedWordElement(SUNSPEC_103 + 31), // 40101 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.DCW_SF, new SignedWordElement(SUNSPEC_103 + 32)), // 40102 m(RefuStore88kChannelId.TMP_CAB, new SignedWordElement(SUNSPEC_103 + 33), // 40103 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(RefuStore88kChannelId.TMP_SNK, new SignedWordElement(SUNSPEC_103 + 34), // 40104 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), new DummyRegisterElement(SUNSPEC_103 + 35, SUNSPEC_103 + 36), m(RefuStore88kChannelId.TMP_SF, new UnsignedWordElement(SUNSPEC_103 + 37)), // 40107 m(RefuStore88kChannelId.ST, new UnsignedWordElement(SUNSPEC_103 + 38)), // 40108 @@ -324,34 +329,33 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Reg m(RefuStore88kChannelId.L_120, new UnsignedWordElement(SUNSPEC_120 + 1)), // 40123 m(RefuStore88kChannelId.DER_TYP, new UnsignedWordElement(SUNSPEC_120 + 2)), // 40124 m(RefuStore88kChannelId.W_RTG, new UnsignedWordElement(SUNSPEC_120 + 3), // 40125 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.W_RTG_SF, new UnsignedWordElement(SUNSPEC_120 + 4)), // 40126 m(new UnsignedWordElement(SUNSPEC_120 + 5)) - .m(SymmetricBatteryInverter.ChannelId.MAX_APPARENT_POWER, - ElementToChannelConverter.SCALE_FACTOR_1) - .m(RefuStore88kChannelId.VA_RTG, ElementToChannelConverter.SCALE_FACTOR_1).build(), + .m(SymmetricBatteryInverter.ChannelId.MAX_APPARENT_POWER, SCALE_FACTOR_1) + .m(RefuStore88kChannelId.VA_RTG, SCALE_FACTOR_1).build(), m(RefuStore88kChannelId.VA_RTG_SF, new UnsignedWordElement(SUNSPEC_120 + 6)), // 40128 m(RefuStore88kChannelId.VAR_RTG_Q1, new SignedWordElement(SUNSPEC_120 + 7), // 40129 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.VAR_RTG_Q2, new SignedWordElement(SUNSPEC_120 + 8), // 40130 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.VAR_RTG_Q3, new SignedWordElement(SUNSPEC_120 + 9), // 40131 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.VAR_RTG_Q4, new SignedWordElement(SUNSPEC_120 + 10), // 40132 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.VAR_RTG_SF, new SignedWordElement(SUNSPEC_120 + 11)), // 40133 m(RefuStore88kChannelId.A_RTG, new UnsignedWordElement(SUNSPEC_120 + 12), // 40134 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.A_RTG_SF, new SignedWordElement(SUNSPEC_120 + 13)), // 40135 m(RefuStore88kChannelId.PF_RTG_Q1, new SignedWordElement(SUNSPEC_120 + 14), // 40136 - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), + SCALE_FACTOR_MINUS_3), m(RefuStore88kChannelId.PF_RTG_Q2, new SignedWordElement(SUNSPEC_120 + 15), // 40137 - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), + SCALE_FACTOR_MINUS_3), m(RefuStore88kChannelId.PF_RTG_Q3, new SignedWordElement(SUNSPEC_120 + 16), // 40138 - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), + SCALE_FACTOR_MINUS_3), m(RefuStore88kChannelId.PF_RTG_Q4, new SignedWordElement(SUNSPEC_120 + 17), // 40139 - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), + SCALE_FACTOR_MINUS_3), m(RefuStore88kChannelId.PF_RTG_SF, new SignedWordElement(SUNSPEC_120 + 18)), // 40140 new DummyRegisterElement(SUNSPEC_120 + 19, SUNSPEC_120 + 26), m(RefuStore88kChannelId.PAD_120, new SignedWordElement(SUNSPEC_120 + 27))), // 40149 @@ -366,11 +370,11 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Reg new FC16WriteRegistersTask(SUNSPEC_121 + 2, // m(RefuStore88kChannelId.W_MAX, new UnsignedWordElement(SUNSPEC_121 + 2), // 40152 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.V_REF, new UnsignedWordElement(SUNSPEC_121 + 3), // 40153 - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_1), m(RefuStore88kChannelId.V_REF_OFS, new UnsignedWordElement(SUNSPEC_121 + 4), // 40154 - ElementToChannelConverter.SCALE_FACTOR_1)), + SCALE_FACTOR_1)), new FC3ReadRegistersTask(SUNSPEC_123, Priority.LOW, // m(RefuStore88kChannelId.ID_123, new UnsignedWordElement(SUNSPEC_123)), // 40182 @@ -387,12 +391,12 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Reg new FC16WriteRegistersTask(SUNSPEC_123 + 9, // m(RefuStore88kChannelId.W_MAX_LIM_ENA, new UnsignedWordElement(SUNSPEC_123 + 9)), // 40191 m(RefuStore88kChannelId.OUT_PF_SET, new SignedWordElement(SUNSPEC_123 + 10), // 40192 - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC16WriteRegistersTask(SUNSPEC_123 + 14, // m(RefuStore88kChannelId.OUT_PF_SET_ENA, new UnsignedWordElement(SUNSPEC_123 + 14)), // 40196 m(RefuStore88kChannelId.VAR_W_MAX_PCT, new SignedWordElement(SUNSPEC_123 + 15), // 40197 - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC16WriteRegistersTask(SUNSPEC_123 + 22, // m(RefuStore88kChannelId.VAR_PCT_ENA, new UnsignedWordElement(SUNSPEC_123 + 22))), // 40204 @@ -435,9 +439,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Reg new FC16WriteRegistersTask(SUNSPEC_64800 + 6, // m(RefuStore88kChannelId.PCS_SET_OPERATION, new SignedWordElement(SUNSPEC_64800 + 6)), // 40231 m(RefuStore88kChannelId.MAX_BAT_A_CHA, new UnsignedWordElement(SUNSPEC_64800 + 7), // 40232 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.MAX_BAT_A_DISCHA, new UnsignedWordElement(SUNSPEC_64800 + 8), // 40233 - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(RefuStore88kChannelId.MAX_A, new UnsignedWordElement(SUNSPEC_64800 + 9)), // 40234 m(RefuStore88kChannelId.MAX_A_CUR, new UnsignedWordElement(SUNSPEC_64800 + 10)), // 40235 m(RefuStore88kChannelId.MAX_BAT_A_SF, new SignedWordElement(SUNSPEC_64800 + 11)), // 40236 diff --git a/io.openems.edge.batteryinverter.sinexcel/src/io/openems/edge/batteryinverter/sinexcel/SinexcelImpl.java b/io.openems.edge.batteryinverter.sinexcel/src/io/openems/edge/batteryinverter/sinexcel/SinexcelImpl.java index 5fdf7c35b44..2fb5f0df2fd 100644 --- a/io.openems.edge.batteryinverter.sinexcel/src/io/openems/edge/batteryinverter/sinexcel/SinexcelImpl.java +++ b/io.openems.edge.batteryinverter.sinexcel/src/io/openems/edge/batteryinverter/sinexcel/SinexcelImpl.java @@ -1,5 +1,12 @@ package io.openems.edge.batteryinverter.sinexcel; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_3; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.chain; + import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; @@ -38,7 +45,6 @@ import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverterChain; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -495,89 +501,53 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), new FC3ReadRegistersTask(101, Priority.HIGH, // - m(Sinexcel.ChannelId.GRID_VOLTAGE_L1, new SignedWordElement(101), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.GRID_VOLTAGE_L2, new SignedWordElement(102), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.GRID_VOLTAGE_L3, new SignedWordElement(103), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.GRID_CURRENT_L1, new SignedWordElement(104), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.GRID_CURRENT_L2, new SignedWordElement(105), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.GRID_CURRENT_L3, new SignedWordElement(106), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.FREQUENCY, new SignedWordElement(107), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.GRID_VOLTAGE_L1, new SignedWordElement(101), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.GRID_VOLTAGE_L2, new SignedWordElement(102), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.GRID_VOLTAGE_L3, new SignedWordElement(103), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.GRID_CURRENT_L1, new SignedWordElement(104), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.GRID_CURRENT_L2, new SignedWordElement(105), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.GRID_CURRENT_L3, new SignedWordElement(106), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.FREQUENCY, new SignedWordElement(107), SCALE_FACTOR_1), // new DummyRegisterElement(108, 109), - m(Sinexcel.ChannelId.ACTIVE_POWER_L1, new SignedWordElement(110), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.ACTIVE_POWER_L2, new SignedWordElement(111), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.ACTIVE_POWER_L3, new SignedWordElement(112), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.REACTIVE_POWER_L1, new SignedWordElement(113), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.REACTIVE_POWER_L2, new SignedWordElement(114), - ElementToChannelConverter.SCALE_FACTOR_1), // fems - m(Sinexcel.ChannelId.REACTIVE_POWER_L3, new SignedWordElement(115), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.APPERENT_POWER_L1, new SignedWordElement(116), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.APPERENT_POWER_L2, new SignedWordElement(117), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.APPERENT_POWER_L3, new SignedWordElement(118), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.COS_PHI_L1, new SignedWordElement(119), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Sinexcel.ChannelId.COS_PHI_L2, new SignedWordElement(120), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Sinexcel.ChannelId.COS_PHI_L3, new SignedWordElement(121), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.ACTIVE_POWER_L1, new SignedWordElement(110), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.ACTIVE_POWER_L2, new SignedWordElement(111), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.ACTIVE_POWER_L3, new SignedWordElement(112), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.REACTIVE_POWER_L1, new SignedWordElement(113), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.REACTIVE_POWER_L2, new SignedWordElement(114), SCALE_FACTOR_1), // fems + m(Sinexcel.ChannelId.REACTIVE_POWER_L3, new SignedWordElement(115), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.APPERENT_POWER_L1, new SignedWordElement(116), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.APPERENT_POWER_L2, new SignedWordElement(117), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.APPERENT_POWER_L3, new SignedWordElement(118), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.COS_PHI_L1, new SignedWordElement(119), SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.COS_PHI_L2, new SignedWordElement(120), SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.COS_PHI_L3, new SignedWordElement(121), SCALE_FACTOR_MINUS_2), // m(SymmetricBatteryInverter.ChannelId.ACTIVE_POWER, new SignedWordElement(122), - new ElementToChannelConverterChain(ElementToChannelConverter.SCALE_FACTOR_1, - IGNORE_LESS_THAN_100)), // + chain(SCALE_FACTOR_1, IGNORE_LESS_THAN_100)), // m(SymmetricBatteryInverter.ChannelId.REACTIVE_POWER, new SignedWordElement(123), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.APPARENT_POWER, new SignedWordElement(124), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.COS_PHI, new SignedWordElement(125), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.APPARENT_POWER, new SignedWordElement(124), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.COS_PHI, new SignedWordElement(125), SCALE_FACTOR_MINUS_2), // new DummyRegisterElement(126, 131), // m(Sinexcel.ChannelId.TEMPERATURE_OF_AC_HEAT_SINK, new SignedWordElement(132)), // - m(Sinexcel.ChannelId.DC_VOLTAGE_POSITIVE, new SignedWordElement(133), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.DC_VOLTAGE_NEGATIVE, new SignedWordElement(134), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.SET_ACTIVE_POWER, new SignedWordElement(135), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.SET_REACTIVE_POWER, new SignedWordElement(136), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.SET_OFF_GRID_VOLTAGE, new SignedWordElement(137), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.SET_OFF_GRID_FREQUENCY, new SignedWordElement(138), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.DC_VOLTAGE_POSITIVE, new SignedWordElement(133), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DC_VOLTAGE_NEGATIVE, new SignedWordElement(134), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.SET_ACTIVE_POWER, new SignedWordElement(135), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.SET_REACTIVE_POWER, new SignedWordElement(136), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.SET_OFF_GRID_VOLTAGE, new SignedWordElement(137), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.SET_OFF_GRID_FREQUENCY, new SignedWordElement(138), SCALE_FACTOR_1), // new DummyRegisterElement(139, 140), - m(Sinexcel.ChannelId.DC_POWER, new SignedWordElement(141), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(Sinexcel.ChannelId.DC_VOLTAGE, new SignedWordElement(142), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.DC_CURRENT, new SignedWordElement(143), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.DC_CHARGE_ENERGY, new UnsignedDoublewordElement(144), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.DC_DISCHARGE_ENERGY, new UnsignedDoublewordElement(146), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DC_POWER, new SignedWordElement(141), SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.DC_VOLTAGE, new SignedWordElement(142), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DC_CURRENT, new SignedWordElement(143), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DC_CHARGE_ENERGY, new UnsignedDoublewordElement(144), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DC_DISCHARGE_ENERGY, new UnsignedDoublewordElement(146), SCALE_FACTOR_2), // m(Sinexcel.ChannelId.TEMPERATURE_OF_DC_DC_HEAT_SINK, new SignedWordElement(148)) // ), new FC3ReadRegistersTask(224, Priority.LOW, // - m(Sinexcel.ChannelId.DC_RELAY_REAR_END_VOLTAGE, new SignedWordElement(224), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.CHARGE_MAX_CURRENT_READ, new UnsignedWordElement(225), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(Sinexcel.ChannelId.DISCHARGE_MAX_CURRENT_READ, new UnsignedWordElement(226), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DC_RELAY_REAR_END_VOLTAGE, new SignedWordElement(224), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.CHARGE_MAX_CURRENT_READ, new UnsignedWordElement(225), SCALE_FACTOR_2), // + m(Sinexcel.ChannelId.DISCHARGE_MAX_CURRENT_READ, new UnsignedWordElement(226), SCALE_FACTOR_2), // new DummyRegisterElement(227, 299), m(Sinexcel.ChannelId.IP_ADDRESS_BLOCK_1, new UnsignedWordElement(300)), // m(Sinexcel.ChannelId.IP_ADDRESS_BLOCK_2, new UnsignedWordElement(301)), // @@ -675,22 +645,16 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(Sinexcel.ChannelId.START_UP_MODE, new UnsignedWordElement(805)), // new DummyRegisterElement(806), m(Sinexcel.ChannelId.LOCAL_ID_SETTING, new SignedWordElement(807)), // - m(Sinexcel.ChannelId.FLOAT_CHARGE_VOLTAGE, new SignedWordElement(808), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(Sinexcel.ChannelId.TOPPING_CHARGE_VOLTAGE, new SignedWordElement(809), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(Sinexcel.ChannelId.FLOAT_CHARGE_VOLTAGE, new SignedWordElement(808), SCALE_FACTOR_MINUS_1), // + m(Sinexcel.ChannelId.TOPPING_CHARGE_VOLTAGE, new SignedWordElement(809), SCALE_FACTOR_MINUS_1), // m(Sinexcel.ChannelId.CURRENT_FROM_TOPPING_CHARGING_TO_FLOAT_CHARGING, - new SignedWordElement(810), ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(Sinexcel.ChannelId.CHARGE_MAX_CURRENT, new SignedWordElement(811), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(Sinexcel.ChannelId.DISCHARGE_MAX_CURRENT, new SignedWordElement(812), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(Sinexcel.ChannelId.DISCHARGE_MIN_VOLTAGE, new SignedWordElement(813), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(Sinexcel.ChannelId.CHARGE_MAX_VOLTAGE, new SignedWordElement(814), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + new SignedWordElement(810), SCALE_FACTOR_MINUS_1), // + m(Sinexcel.ChannelId.CHARGE_MAX_CURRENT, new SignedWordElement(811), SCALE_FACTOR_MINUS_1), // + m(Sinexcel.ChannelId.DISCHARGE_MAX_CURRENT, new SignedWordElement(812), SCALE_FACTOR_MINUS_1), // + m(Sinexcel.ChannelId.DISCHARGE_MIN_VOLTAGE, new SignedWordElement(813), SCALE_FACTOR_MINUS_1), // + m(Sinexcel.ChannelId.CHARGE_MAX_VOLTAGE, new SignedWordElement(814), SCALE_FACTOR_MINUS_1), // m(Sinexcel.ChannelId.BATTERY_VOLTAGE_PROTECTION_LIMIT, new UnsignedWordElement(815), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1) // + SCALE_FACTOR_MINUS_1) // ), @@ -731,26 +695,21 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new DummyRegisterElement(873, 875), m(Sinexcel.ChannelId.SOFT_START_RAMP_RATE, new SignedWordElement(876)), // m(Sinexcel.ChannelId.POWER_RAMP_RATE, new SignedWordElement(877)), // - m(Sinexcel.ChannelId.POWER_FACTOR_SETTING, new SignedWordElement(878), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Sinexcel.ChannelId.POWER_FACTOR_P1, new SignedWordElement(879), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Sinexcel.ChannelId.POWER_FACTOR_P2, new SignedWordElement(880), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Sinexcel.ChannelId.POWER_FACTOR_P3, new SignedWordElement(881), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(Sinexcel.ChannelId.POWER_FACTOR_P4, new SignedWordElement(882), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.POWER_FACTOR_SETTING, new SignedWordElement(878), SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.POWER_FACTOR_P1, new SignedWordElement(879), SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.POWER_FACTOR_P2, new SignedWordElement(880), SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.POWER_FACTOR_P3, new SignedWordElement(881), SCALE_FACTOR_MINUS_2), // + m(Sinexcel.ChannelId.POWER_FACTOR_P4, new SignedWordElement(882), SCALE_FACTOR_MINUS_2), // m(Sinexcel.ChannelId.POWER_FACTOR_CURVE_MODE_P1, new SignedWordElement(883), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(Sinexcel.ChannelId.POWER_FACTOR_CURVE_MODE_P2, new SignedWordElement(884), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(Sinexcel.ChannelId.POWER_FACTOR_CURVE_MODE_P3, new SignedWordElement(885), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(Sinexcel.ChannelId.POWER_FACTOR_CURVE_MODE_P4, new SignedWordElement(886), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(Sinexcel.ChannelId.CONTINUOS_OVER_VOLTAGE_TRIP_THRESHOLD, new SignedWordElement(887), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(Sinexcel.ChannelId.FREQUENCY_VARIATION_RATE_TRIP_THRESHOLD, new SignedWordElement(888)), // m(Sinexcel.ChannelId.PHASE_ANGLE_ABRUPT_TRIP_THRESHOLD, new SignedWordElement(889)), // m(Sinexcel.ChannelId.GRID_RECONNECTION_VOLTAGE_UPPER_LIMIT, new SignedWordElement(890)), // @@ -761,63 +720,58 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ), new FC3ReadRegistersTask(934, Priority.LOW, // - m(Sinexcel.ChannelId.METER_ACTIVE_POWER, new SignedWordElement(934), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(Sinexcel.ChannelId.METER_ACTIVE_POWER, new SignedWordElement(934), SCALE_FACTOR_1), // new DummyRegisterElement(935, 947), m(Sinexcel.ChannelId.GRID_VOLTAGE_CALIBRATION_L1, new UnsignedWordElement(948), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.GRID_VOLTAGE_CALIBRATION_L2, new UnsignedWordElement(949), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.GRID_VOLTAGE_CALIBRATION_L3, new UnsignedWordElement(950), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INVERTER_VOLTAGE_CALIBRATION_L1, new UnsignedWordElement(951), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INVERTER_VOLTAGE_CALIBRATION_L2, new UnsignedWordElement(952), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INVERTER_VOLTAGE_CALIBRATION_L3, new UnsignedWordElement(953), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L1_PARAMETERS_1, new UnsignedWordElement(954), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L2_PARAMETERS_1, new UnsignedWordElement(955), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L3_PARAMETERS_1, new UnsignedWordElement(956), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L1_PARAMETERS_2, new UnsignedWordElement(957), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L2_PARAMETERS_2, new UnsignedWordElement(958), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L3_PARAMETERS_2, new UnsignedWordElement(959), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.OUTPUT_CURRENT_CALIBRATION_L1, new UnsignedWordElement(960), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.OUTPUT_CURRENT_CALIBRATION_L2, new UnsignedWordElement(961), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.OUTPUT_CURRENT_CALIBRATION_L3, new UnsignedWordElement(962), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.POSITIVE_BUS_VOLTAGE_CALIBRATION, new UnsignedWordElement(963), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.NEGATIVE_BUS_VOLTAGE_CALIBRATION, new UnsignedWordElement(964), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.DC_VOLTAGE_CALIBRATION, new UnsignedWordElement(965), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.DC_CURRENT_CALIBRATION, new UnsignedWordElement(966), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), // + SCALE_FACTOR_MINUS_3), // m(Sinexcel.ChannelId.DC_INDUCTOR_CURRENT_CALIBRATION, new UnsignedWordElement(967), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3) // + SCALE_FACTOR_MINUS_3) // ), new FC6WriteRegisterTask(135, // - m(Sinexcel.ChannelId.SET_ACTIVE_POWER, new SignedWordElement(135), - ElementToChannelConverter.SCALE_FACTOR_2)), + m(Sinexcel.ChannelId.SET_ACTIVE_POWER, new SignedWordElement(135), SCALE_FACTOR_2)), new FC6WriteRegisterTask(136, // - m(Sinexcel.ChannelId.SET_REACTIVE_POWER, new SignedWordElement(136), - ElementToChannelConverter.SCALE_FACTOR_2)), + m(Sinexcel.ChannelId.SET_REACTIVE_POWER, new SignedWordElement(136), SCALE_FACTOR_2)), new FC6WriteRegisterTask(137, // - m(Sinexcel.ChannelId.SET_OFF_GRID_VOLTAGE, new SignedWordElement(137), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.SET_OFF_GRID_VOLTAGE, new SignedWordElement(137), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(138, // - m(Sinexcel.ChannelId.SET_OFF_GRID_FREQUENCY, new SignedWordElement(138), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.SET_OFF_GRID_FREQUENCY, new SignedWordElement(138), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(300, // m(Sinexcel.ChannelId.IP_ADDRESS_BLOCK_1, new UnsignedWordElement(300))), new FC6WriteRegisterTask(301, // @@ -966,29 +920,23 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC6WriteRegisterTask(807, // m(Sinexcel.ChannelId.LOCAL_ID_SETTING, new SignedWordElement(807))), new FC6WriteRegisterTask(808, // - m(Sinexcel.ChannelId.FLOAT_CHARGE_VOLTAGE, new SignedWordElement(808), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.FLOAT_CHARGE_VOLTAGE, new SignedWordElement(808), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(809, // - m(Sinexcel.ChannelId.TOPPING_CHARGE_VOLTAGE, new SignedWordElement(809), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.TOPPING_CHARGE_VOLTAGE, new SignedWordElement(809), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(810, // m(Sinexcel.ChannelId.CURRENT_FROM_TOPPING_CHARGING_TO_FLOAT_CHARGING, - new SignedWordElement(810), ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + new SignedWordElement(810), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(811, // - m(Sinexcel.ChannelId.CHARGE_MAX_CURRENT, new SignedWordElement(811), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.CHARGE_MAX_CURRENT, new SignedWordElement(811), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(812, // - m(Sinexcel.ChannelId.DISCHARGE_MAX_CURRENT, new SignedWordElement(812), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.DISCHARGE_MAX_CURRENT, new SignedWordElement(812), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(813, // - m(Sinexcel.ChannelId.DISCHARGE_MIN_VOLTAGE, new SignedWordElement(813), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.DISCHARGE_MIN_VOLTAGE, new SignedWordElement(813), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(814, // - m(Sinexcel.ChannelId.CHARGE_MAX_VOLTAGE, new SignedWordElement(814), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + m(Sinexcel.ChannelId.CHARGE_MAX_VOLTAGE, new SignedWordElement(814), SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(815, // m(Sinexcel.ChannelId.BATTERY_VOLTAGE_PROTECTION_LIMIT, new UnsignedWordElement(815), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC6WriteRegisterTask(825, // m(Sinexcel.ChannelId.LEAKAGE_CURRENT_DC_COMPONENT_DETECTOR, new UnsignedWordElement(825))), // TODO Check scale factors, channel names and so on... @@ -1086,64 +1034,64 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(Sinexcel.ChannelId.METER_ACTIVE_POWER, new SignedWordElement(934))), new FC6WriteRegisterTask(948, // m(Sinexcel.ChannelId.GRID_VOLTAGE_CALIBRATION_L1, new UnsignedWordElement(948), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(949, // m(Sinexcel.ChannelId.GRID_VOLTAGE_CALIBRATION_L2, new UnsignedWordElement(949), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(950, // m(Sinexcel.ChannelId.GRID_VOLTAGE_CALIBRATION_L3, new UnsignedWordElement(950), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(951, // m(Sinexcel.ChannelId.INVERTER_VOLTAGE_CALIBRATION_L1, new UnsignedWordElement(951), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(952, // m(Sinexcel.ChannelId.INVERTER_VOLTAGE_CALIBRATION_L2, new UnsignedWordElement(952), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(953, // m(Sinexcel.ChannelId.INVERTER_VOLTAGE_CALIBRATION_L3, new UnsignedWordElement(953), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(954, // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L1_PARAMETERS_1, new UnsignedWordElement(954), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(955, // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L2_PARAMETERS_1, new UnsignedWordElement(955), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(956, // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L3_PARAMETERS_1, new UnsignedWordElement(956), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(957, // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L1_PARAMETERS_2, new UnsignedWordElement(957), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(958, // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L2_PARAMETERS_2, new UnsignedWordElement(958), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(959, // m(Sinexcel.ChannelId.INDUCTOR_CURRENT_CALIBRATION_L3_PARAMETERS_2, new UnsignedWordElement(959), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(960, // m(Sinexcel.ChannelId.OUTPUT_CURRENT_CALIBRATION_L1, new UnsignedWordElement(960), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(961, // m(Sinexcel.ChannelId.OUTPUT_CURRENT_CALIBRATION_L2, new UnsignedWordElement(961), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(962, // m(Sinexcel.ChannelId.OUTPUT_CURRENT_CALIBRATION_L3, new UnsignedWordElement(962), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(963, // m(Sinexcel.ChannelId.POSITIVE_BUS_VOLTAGE_CALIBRATION, new UnsignedWordElement(963), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(964, // m(Sinexcel.ChannelId.NEGATIVE_BUS_VOLTAGE_CALIBRATION, new UnsignedWordElement(964), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(965, // m(Sinexcel.ChannelId.DC_VOLTAGE_CALIBRATION, new UnsignedWordElement(965), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(966, // m(Sinexcel.ChannelId.DC_CURRENT_CALIBRATION, new UnsignedWordElement(966), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(967, // m(Sinexcel.ChannelId.DC_INDUCTOR_CURRENT_CALIBRATION, new UnsignedWordElement(967), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3)), + SCALE_FACTOR_MINUS_3)), new FC6WriteRegisterTask(4001, // m(Sinexcel.ChannelId.TIME_SETTING, new SignedWordElement(4001))), new FC6WriteRegisterTask(4007, // diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/AbstractOpenemsModbusComponent.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/AbstractOpenemsModbusComponent.java index 20f2e224c44..bce15d7ac13 100644 --- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/AbstractOpenemsModbusComponent.java +++ b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/AbstractOpenemsModbusComponent.java @@ -1,5 +1,7 @@ package io.openems.edge.bridge.modbus.api; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; + import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -409,7 +411,7 @@ protected final AbstractModbusElement m(BitsWordElement bitsWordElement) { */ protected final > T m(io.openems.edge.common.channel.ChannelId channelId, T element) { - return this.m(channelId, element, ElementToChannelConverter.DIRECT_1_TO_1); + return this.m(channelId, element, DIRECT_1_TO_1); } /** @@ -424,7 +426,7 @@ protected final > T m(io.openems.edge.common. */ protected final > T m(io.openems.edge.common.channel.ChannelId channelId, T element, ChannelMetaInfo channelMetaInfo) { - return this.m(channelId, element, ElementToChannelConverter.DIRECT_1_TO_1, channelMetaInfo); + return this.m(channelId, element, DIRECT_1_TO_1, channelMetaInfo); } /** diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverter.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverter.java index 238dab3a46a..b2243ae205f 100644 --- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverter.java +++ b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverter.java @@ -79,133 +79,86 @@ public class ElementToChannelConverter { // channel -> element StaticConverters.INVERT); - /** - * Sets the value to 'zero' if parameter is true; otherwise - * {@link #DIRECT_1_TO_1}. - * - *
    - *
  • true: set zero - *
  • false: apply {@link #DIRECT_1_TO_1} - *
- * - * @param setZero true to set to null - * @return the {@link ElementToChannelConverter} - */ - // CHECKSTYLE:OFF - public static ElementToChannelConverter SET_ZERO_IF_TRUE(boolean setZero) { - // CHECKSTYLE:ON - if (setZero) { - return new ElementToChannelConverter(// - // element -> channel - value -> 0, // - // channel -> element - value -> 0); - } - return DIRECT_1_TO_1; - } - - /** - * Converts depending on the given parameter. - * - *
    - *
  • true: invert value - *
  • false: keep value (1-to-1) - *
- * - * @param invert true if Converter should invert - * @return the {@link ElementToChannelConverter} - */ - // CHECKSTYLE:OFF - public static ElementToChannelConverter INVERT_IF_TRUE(boolean invert) { - // CHECKSTYLE:ON - if (invert) { - return INVERT; - } - return DIRECT_1_TO_1; - } - /** * Converts only negative values from Element to Channel and inverts them (makes * the value positive). */ - public static final ElementToChannelConverter KEEP_NEGATIVE_AND_INVERT = new ElementToChannelConverterChain(INVERT, - KEEP_POSITIVE); + public static final ElementToChannelConverter KEEP_NEGATIVE_AND_INVERT = chain(INVERT, KEEP_POSITIVE); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_1} and * CONVERT_POSITIVE. */ - public static final ElementToChannelConverter SCALE_FACTOR_1_AND_KEEP_POSITIVE = new ElementToChannelConverterChain( - SCALE_FACTOR_1, KEEP_POSITIVE); + public static final ElementToChannelConverter SCALE_FACTOR_1_AND_KEEP_POSITIVE = chain(SCALE_FACTOR_1, + KEEP_POSITIVE); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_2} and INVERT. */ - public static final ElementToChannelConverter SCALE_FACTOR_2_AND_INVERT = new ElementToChannelConverterChain( - SCALE_FACTOR_2, INVERT); + public static final ElementToChannelConverter SCALE_FACTOR_2_AND_INVERT = chain(SCALE_FACTOR_2, INVERT); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_1} and * CONVERT_NEGATIVE_AND_INVERT. */ - public static final ElementToChannelConverter SCALE_FACTOR_1_AND_KEEP_NEGATIVE_AND_INVERT = new ElementToChannelConverterChain( - SCALE_FACTOR_1, KEEP_NEGATIVE_AND_INVERT); + public static final ElementToChannelConverter SCALE_FACTOR_1_AND_KEEP_NEGATIVE_AND_INVERT = chain(SCALE_FACTOR_1, + KEEP_NEGATIVE_AND_INVERT); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_2} and * CONVERT_POSITIVE. */ - public static final ElementToChannelConverter SCALE_FACTOR_2_AND_KEEP_POSITIVE = new ElementToChannelConverterChain( - SCALE_FACTOR_2, KEEP_POSITIVE); + public static final ElementToChannelConverter SCALE_FACTOR_2_AND_KEEP_POSITIVE = chain(SCALE_FACTOR_2, + KEEP_POSITIVE); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_2} and @see * {@link ElementToChannelConverter#KEEP_NEGATIVE_AND_INVERT}. */ - public static final ElementToChannelConverter SCALE_FACTOR_2_AND_KEEP_NEGATIVE_AND_INVERT = new ElementToChannelConverterChain( - SCALE_FACTOR_2, KEEP_NEGATIVE_AND_INVERT); + public static final ElementToChannelConverter SCALE_FACTOR_2_AND_KEEP_NEGATIVE_AND_INVERT = chain(SCALE_FACTOR_2, + KEEP_NEGATIVE_AND_INVERT); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_2_AND_KEEP_NEGATIVE} * and @see {@link ElementToChannelConverter#INVERT}. */ - public static ElementToChannelConverter SCALE_FACTOR_2_AND_KEEP_NEGATIVE = new ElementToChannelConverterChain( + public static ElementToChannelConverter SCALE_FACTOR_2_AND_KEEP_NEGATIVE = chain( SCALE_FACTOR_2_AND_KEEP_NEGATIVE_AND_INVERT, INVERT); /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_1} and INVERT_IF_TRUE. * * @param invert input value for {@link #INVERT_IF_TRUE(boolean)} - * @return the {@link ElementToChannelConverterChain} + * @return the {@link ElementToChannelConverter} */ // CHECKSTYLE:OFF public static final ElementToChannelConverter SCALE_FACTOR_1_AND_INVERT_IF_TRUE(boolean invert) { // CHECKSTYLE:ON - return new ElementToChannelConverterChain(SCALE_FACTOR_1, INVERT_IF_TRUE(invert)); + return chain(SCALE_FACTOR_1, INVERT_IF_TRUE(invert)); } /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_2} and INVERT_IF_TRUE. * * @param invert input value for {@link #INVERT_IF_TRUE(boolean)} - * @return the {@link ElementToChannelConverterChain} + * @return the {@link ElementToChannelConverter} */ // CHECKSTYLE:OFF public static final ElementToChannelConverter SCALE_FACTOR_2_AND_INVERT_IF_TRUE(boolean invert) { // CHECKSTYLE:ON - return new ElementToChannelConverterChain(SCALE_FACTOR_2, INVERT_IF_TRUE(invert)); + return chain(SCALE_FACTOR_2, INVERT_IF_TRUE(invert)); } /** * Applies {@link ElementToChannelConverter#SCALE_FACTOR_3} and INVERT_IF_TRUE. * * @param invert input value for {@link #INVERT_IF_TRUE(boolean)} - * @return the {@link ElementToChannelConverterChain} + * @return the {@link ElementToChannelConverter} */ // CHECKSTYLE:OFF public static final ElementToChannelConverter SCALE_FACTOR_3_AND_INVERT_IF_TRUE(boolean invert) { // CHECKSTYLE:ON - return new ElementToChannelConverterChain(SCALE_FACTOR_3, INVERT_IF_TRUE(invert)); + return chain(SCALE_FACTOR_3, INVERT_IF_TRUE(invert)); } /** @@ -213,12 +166,12 @@ public static final ElementToChannelConverter SCALE_FACTOR_3_AND_INVERT_IF_TRUE( * INVERT_IF_TRUE. * * @param invert input value for {@link #INVERT_IF_TRUE(boolean)} - * @return the {@link ElementToChannelConverterChain} + * @return the {@link ElementToChannelConverter} */ // CHECKSTYLE:OFF public static final ElementToChannelConverter SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(boolean invert) { // CHECKSTYLE:ON - return new ElementToChannelConverterChain(SCALE_FACTOR_MINUS_1, INVERT_IF_TRUE(invert)); + return chain(SCALE_FACTOR_MINUS_1, INVERT_IF_TRUE(invert)); } private final Function elementToChannel; @@ -271,4 +224,222 @@ public Object elementToChannel(Object value) { public Object channelToElement(Object value) { return this.channelToElement.apply(value); } + + /** + * Sets the value to 'zero' if parameter is true; otherwise + * {@link #DIRECT_1_TO_1}. + * + *
    + *
  • true: set zero + *
  • false: apply {@link #DIRECT_1_TO_1} + *
+ * + * @param setZero true to set to null + * @return the {@link ElementToChannelConverter} + */ + // CHECKSTYLE:OFF + public static ElementToChannelConverter SET_ZERO_IF_TRUE(boolean setZero) { + // CHECKSTYLE:ON + if (setZero) { + return new ElementToChannelConverter(// + // element -> channel + value -> 0, // + // channel -> element + value -> 0); + } + return DIRECT_1_TO_1; + } + + /** + * Converts depending on the given parameter. + * + *
    + *
  • true: invert value + *
  • false: keep value (1-to-1) + *
+ * + * @param invert true if Converter should invert + * @return the {@link ElementToChannelConverter} + */ + // CHECKSTYLE:OFF + public static ElementToChannelConverter INVERT_IF_TRUE(boolean invert) { + // CHECKSTYLE:ON + if (invert) { + return INVERT; + } + return DIRECT_1_TO_1; + } + + /** + * Sets the chain with given {@link ElementToChannelConverter + * ElementToChannelConverters}. + * + * @param converters to be applied as chain one after the other. + * @return {@link ElementToChannelConverter} after applied all converters. + */ + public static ElementToChannelConverter chain(ElementToChannelConverter... converters) { + return new ElementToChannelConverter( + // element -> channel + value -> { + for (var converter : converters) { + value = converter.elementToChannel(value); + } + return value; + }, + // channel -> element + value -> { + for (int i = converters.length - 1; i >= 0; i--) { + value = converters[i].channelToElement(value); + } + return value; + }); + } + + /** + * Multiply the given factor with the channel value. + * + * @param factor the value to be applied to the Channel value. + * @return {@link ElementToChannelConverter} + */ + // CHECKSTYLE:OFF + public static final ElementToChannelConverter MULTIPLY(double factor) { + // CHECKSTYLE:ON + return new ElementToChannelConverter(multiplyFunction(factor), divideFunction(factor)); + } + + /** + * Divide the channel value with the given scale. + * + * @param scale the value to be applied to the Channel value. + * @return {@link ElementToChannelConverter} + */ + // CHECKSTYLE:OFF + public static final ElementToChannelConverter DIVIDE(double scale) { + // CHECKSTYLE:ON + return new ElementToChannelConverter(divideFunction(scale), multiplyFunction(scale)); + } + + /** + * Add the given value to the Channel value. + * + * @param value to add to the Channel value. + * @return {@link ElementToChannelConverter} + */ + // CHECKSTYLE:OFF + public static final ElementToChannelConverter ADD(double value) { + // CHECKSTYLE:ON + return new ElementToChannelConverter(addFunction(value), addFunction(-value)); + } + + /** + * Subtract the given value to the Channel value. + * + * @param value to subtract to the Channel value. + * @return {@link ElementToChannelConverter} + */ + // CHECKSTYLE:OFF + public static final ElementToChannelConverter SUBTRACT(double value) { + // CHECKSTYLE:ON + return ADD(-value); + } + + /** + * Multiplication function to be applied for different variable types. + * + * @param factor to multiply to the Channel value. + * @return an {@link Object} based on the variable type. + */ + private static final Function multiplyFunction(double factor) { + return value -> apply(value, // + t -> (long) (t * factor), // + t -> (long) (t * factor), // + t -> (long) (t * factor), // + t -> t * factor, // + t -> t * factor // + ); + } + + /** + * Division function to be applied for different variable types. + * + * @param scale to divide to the Channel value. + * @return an {@link Object} based on the variable type. + */ + private static final Function divideFunction(double scale) { + return value -> apply(value, // + t -> (long) (t / scale), // + t -> (long) (t / scale), // + t -> (long) (t / scale), // + t -> t / scale, // + t -> t / scale // + ); + } + + /** + * Summation function to be applied for different variable types. + * + * @param value to add to the Channel value. + * @return an {@link Object} based on the variable type. + */ + private static final Function addFunction(double value) { + return v -> apply(v, // + t -> (long) (t + value), // + t -> (long) (t + value), // + t -> (long) (t + value), // + t -> t + value, // + t -> t + value // + ); + } + + private static Object apply(// + Object value, // + Function shortFactor, // + Function integerFactor, // + Function longFactor, // + Function floatFactor, // + Function doubleFactor // + ) { + if (value == null) { + return null; + } + if (value instanceof Boolean) { + return (boolean) value; + } + if (value instanceof Short s) { + long result = shortFactor.apply(s); + if (result >= Short.MIN_VALUE && result <= Short.MAX_VALUE) { + return Short.valueOf((short) result); + } + if (result > Integer.MIN_VALUE && result < Integer.MAX_VALUE) { + return Integer.valueOf((int) result); + } else { + return Long.valueOf(result); + } + } + if (value instanceof Integer i) { + long result = integerFactor.apply(i); + if (result >= Integer.MIN_VALUE && result <= Integer.MAX_VALUE) { + return Integer.valueOf((int) result); + } + return Long.valueOf(result); + } + if (value instanceof Long l) { + return longFactor.apply(l); + } + if (value instanceof Float f) { + double result = floatFactor.apply(f); + if (result >= Float.MIN_VALUE && result <= Float.MAX_VALUE) { + return Float.valueOf((float) result); + } + return Double.valueOf(result); + } + if (value instanceof Double d) { + return doubleFactor.apply(d); + } + if (value instanceof String) { + return value; + } + throw new IllegalArgumentException( + "Type [" + value.getClass().getName() + "] not supported by OFFSET converter"); + } } diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverterChain.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverterChain.java deleted file mode 100644 index 9310addf1ff..00000000000 --- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelConverterChain.java +++ /dev/null @@ -1,13 +0,0 @@ -package io.openems.edge.bridge.modbus.api; - -public class ElementToChannelConverterChain extends ElementToChannelConverter { - - public ElementToChannelConverterChain(ElementToChannelConverter converter1, ElementToChannelConverter converter2) { - super( - // element -> channel - value -> converter2.elementToChannel(converter1.elementToChannel(value)), - // channel -> element - value -> converter1.channelToElement(converter2.channelToElement(value))); - } - -} diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelOffsetConverter.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelOffsetConverter.java deleted file mode 100644 index 4ded48ae686..00000000000 --- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelOffsetConverter.java +++ /dev/null @@ -1,81 +0,0 @@ -package io.openems.edge.bridge.modbus.api; - -import io.openems.common.types.OpenemsType; - -/** - * Converts between Element and Channel by applying an offset. - * - *

- * (channel = element + offset) - */ -public class ElementToChannelOffsetConverter extends ElementToChannelConverter { - - public ElementToChannelOffsetConverter(int offset) { - super(// - // element -> channel - value -> apply(value, offset), // - - // channel -> element - value -> apply(value, offset * -1)); - } - - private static Object apply(Object value, int offset) { - if (value == null) { - return null; - } - for (OpenemsType openemsType : OpenemsType.values()) { - // this 'for' + 'switch' is only utilized to get an alert by Eclipse IDE if a - // new OpenemsType was added. ("The enum constant [...] needs a corresponding - // case label in this enum switch on OpenemsType") - switch (openemsType) { - case BOOLEAN: - case SHORT: - case INTEGER: - case LONG: - case FLOAT: - case DOUBLE: - case STRING: - if (value instanceof Boolean) { - return (boolean) value; - } - if (value instanceof Short) { - long result = (Short) value + offset; - if (result >= Short.MIN_VALUE && result <= Short.MAX_VALUE) { - return Short.valueOf((short) result); - } - if (result > Integer.MIN_VALUE && result < Integer.MAX_VALUE) { - return Integer.valueOf((int) result); - } else { - return Long.valueOf(result); - } - } - if (value instanceof Integer) { - long result = (Integer) value + offset; - if (result >= Integer.MIN_VALUE && result <= Integer.MAX_VALUE) { - return Integer.valueOf((int) result); - } - return Long.valueOf(result); - } - if (value instanceof Long) { - return (Long) value + offset; - } - if (value instanceof Float) { - double result = (Float) value + offset; - if (result >= Float.MIN_VALUE && result <= Float.MAX_VALUE) { - return Float.valueOf((float) result); - } - return Double.valueOf(result); - } - if (value instanceof Double) { - return Double.valueOf((Double) value + offset); - } - if (value instanceof String) { - return value; - } - } - break; - } - throw new IllegalArgumentException( - "Type [" + value.getClass().getName() + "] not supported by OFFSET converter"); - } -} diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelScaleFactorConverter.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelScaleFactorConverter.java index 5c3c14264b4..0040ad059af 100644 --- a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelScaleFactorConverter.java +++ b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/ElementToChannelScaleFactorConverter.java @@ -1,7 +1,6 @@ package io.openems.edge.bridge.modbus.api; import io.openems.common.exceptions.InvalidValueException; -import io.openems.common.types.OpenemsType; import io.openems.edge.bridge.modbus.sunspec.SunSpecPoint; import io.openems.edge.common.channel.ChannelId; import io.openems.edge.common.channel.IntegerReadChannel; @@ -60,58 +59,43 @@ private static Object apply(Object value, int scaleFactor) { if (value == null) { return null; } - for (OpenemsType openemsType : OpenemsType.values()) { - // this 'for' + 'switch' is only utilized to get an alert by Eclipse IDE if a - // new OpenemsType was added. ("The enum constant [...] needs a corresponding - // case label in this enum switch on OpenemsType") - switch (openemsType) { - case BOOLEAN: - case SHORT: - case INTEGER: - case LONG: - case FLOAT: - case DOUBLE: - case STRING: - if (value instanceof Boolean) { - return (boolean) value; - } - if (value instanceof Short) { - var result = (Short) value * factor; - if (result >= Short.MIN_VALUE && result <= Short.MAX_VALUE) { - return Short.valueOf((short) result); - } - if (result > Integer.MIN_VALUE && result < Integer.MAX_VALUE) { - return Integer.valueOf((int) result); - } else { - return Double.valueOf(Math.round(result)); - } - } - if (value instanceof Integer) { - var result = (Integer) value * factor; - if (result >= Integer.MIN_VALUE && result <= Integer.MAX_VALUE) { - return Integer.valueOf((int) result); - } - return Double.valueOf(Math.round(result)); - } - if (value instanceof Long) { - var result = (Long) value * factor; - return Math.round(result); - } - if (value instanceof Float) { - var result = (Float) value * factor; - if (result >= Float.MIN_VALUE && result <= Float.MAX_VALUE) { - return Float.valueOf((float) result); - } - return Double.valueOf(result); - } - if (value instanceof Double) { - return Double.valueOf((Double) value * factor); - } - if (value instanceof String) { - return value; - } + if (value instanceof Boolean) { + return (boolean) value; + } + if (value instanceof Short) { + var result = (Short) value * factor; + if (result >= Short.MIN_VALUE && result <= Short.MAX_VALUE) { + return Short.valueOf((short) result); + } + if (result > Integer.MIN_VALUE && result < Integer.MAX_VALUE) { + return Integer.valueOf((int) result); + } else { + return Double.valueOf(Math.round(result)); } - break; + } + if (value instanceof Integer) { + var result = (Integer) value * factor; + if (result >= Integer.MIN_VALUE && result <= Integer.MAX_VALUE) { + return Integer.valueOf((int) result); + } + return Double.valueOf(Math.round(result)); + } + if (value instanceof Long) { + var result = (Long) value * factor; + return Math.round(result); + } + if (value instanceof Float) { + var result = (Float) value * factor; + if (result >= Float.MIN_VALUE && result <= Float.MAX_VALUE) { + return Float.valueOf((float) result); + } + return Double.valueOf(result); + } + if (value instanceof Double) { + return Double.valueOf((Double) value * factor); + } + if (value instanceof String) { + return value; } throw new IllegalArgumentException( "Type [" + value.getClass().getName() + "] not supported by SCALE_FACTOR converter"); diff --git a/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/api/ConversionTest.java b/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/api/ConversionTest.java index e4c7ffa96b4..15d1d3ee643 100644 --- a/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/api/ConversionTest.java +++ b/io.openems.edge.bridge.modbus/test/io/openems/edge/bridge/modbus/api/ConversionTest.java @@ -1,6 +1,10 @@ package io.openems.edge.bridge.modbus.api; import static org.junit.Assert.assertEquals; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIVIDE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.MULTIPLY; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.ADD; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SUBTRACT; import org.junit.Test; @@ -24,4 +28,40 @@ public void testShortConversions() { expected = 1; assertEquals(expected, result); } + + @Test + public void multiplyTest() { + var value = 10; + var result = MULTIPLY(2).elementToChannel(value); + assertEquals(20, result); + var result2 = MULTIPLY(2).channelToElement(result); + assertEquals(value, result2); + } + + @Test + public void divideTest() { + var value = 10; + var result = DIVIDE(2).elementToChannel(value); + assertEquals(5, result); + var result2 = DIVIDE(2).channelToElement(result); + assertEquals(value, result2); + } + + @Test + public void addTest() { + var value = 10; + var result = ADD(2).elementToChannel(value); + assertEquals(12, result); + var result2 = ADD(2).channelToElement(result); + assertEquals(value, result2); + } + + @Test + public void subtractTest() { + var value = 10; + var result = SUBTRACT(2).elementToChannel(value); + assertEquals(8, result); + var result2 = SUBTRACT(2).channelToElement(result); + assertEquals(value, result2); + } } diff --git a/io.openems.edge.ess.adstec.storaxe/src/io/openems/edge/ess/adstec/storaxe/AdstecStoraxeEssImpl.java b/io.openems.edge.ess.adstec.storaxe/src/io/openems/edge/ess/adstec/storaxe/AdstecStoraxeEssImpl.java index 589462ff131..1d52db6e3ce 100644 --- a/io.openems.edge.ess.adstec.storaxe/src/io/openems/edge/ess/adstec/storaxe/AdstecStoraxeEssImpl.java +++ b/io.openems.edge.ess.adstec.storaxe/src/io/openems/edge/ess/adstec/storaxe/AdstecStoraxeEssImpl.java @@ -1,5 +1,9 @@ package io.openems.edge.ess.adstec.storaxe; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -17,7 +21,6 @@ import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverterChain; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.SignedWordElement; @@ -88,25 +91,22 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC4ReadInputRegistersTask(1 + offset, Priority.LOW, // m(SymmetricEss.ChannelId.GRID_MODE, new UnsignedWordElement(1 + offset), GRID_MODE_CONVERTER), - m(SymmetricEss.ChannelId.ACTIVE_POWER, new SignedWordElement(2 + offset), - ElementToChannelConverter.SCALE_FACTOR_2), + m(SymmetricEss.ChannelId.ACTIVE_POWER, new SignedWordElement(2 + offset), SCALE_FACTOR_2), m(SymmetricEss.ChannelId.REACTIVE_POWER, new SignedWordElement(3 + offset), - new ElementToChannelConverterChain(ElementToChannelConverter.SCALE_FACTOR_2, - reactivePowerConverter))), + ElementToChannelConverter.chain(SCALE_FACTOR_2, reactivePowerConverter))), new FC4ReadInputRegistersTask(125 + offset, Priority.LOW, // m(SymmetricEss.ChannelId.MAX_APPARENT_POWER, new UnsignedWordElement(125 + offset), - ElementToChannelConverter.SCALE_FACTOR_2), - m(SymmetricEss.ChannelId.SOC, new UnsignedWordElement(126 + offset), - ElementToChannelConverter.DIRECT_1_TO_1)), + SCALE_FACTOR_2), + m(SymmetricEss.ChannelId.SOC, new UnsignedWordElement(126 + offset), DIRECT_1_TO_1)), new FC4ReadInputRegistersTask(134 + offset, Priority.LOW, // m(SymmetricEss.ChannelId.ACTIVE_DISCHARGE_ENERGY, new UnsignedDoublewordElement(134 + offset), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(SymmetricEss.ChannelId.ACTIVE_CHARGE_ENERGY, new UnsignedDoublewordElement(136 + offset), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(SymmetricEss.ChannelId.MIN_CELL_VOLTAGE, new UnsignedWordElement(138 + offset), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), m(SymmetricEss.ChannelId.MAX_CELL_VOLTAGE, new UnsignedWordElement(139 + offset), - ElementToChannelConverter.DIRECT_1_TO_1))); + DIRECT_1_TO_1))); } @Override diff --git a/io.openems.edge.ess.byd.container/src/io/openems/edge/ess/byd/container/EssFeneconBydContainer.java b/io.openems.edge.ess.byd.container/src/io/openems/edge/ess/byd/container/EssFeneconBydContainer.java index c170e6c4d45..2f7513f443a 100644 --- a/io.openems.edge.ess.byd.container/src/io/openems/edge/ess/byd/container/EssFeneconBydContainer.java +++ b/io.openems.edge.ess.byd.container/src/io/openems/edge/ess/byd/container/EssFeneconBydContainer.java @@ -1,5 +1,8 @@ package io.openems.edge.ess.byd.container; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -20,7 +23,6 @@ import io.openems.common.types.OpenemsType; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -591,24 +593,15 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(EssFeneconBydContainer.ChannelId.PCS_CHARGE_LIMIT_ACTIVE_POWER, new SignedWordElement(0x1007)), m(EssFeneconBydContainer.ChannelId.POSITIVE_REACTIVE_POWER_LIMIT, new UnsignedWordElement(0x1008)), m(EssFeneconBydContainer.ChannelId.NEGATIVE_REACTIVE_POWER_LIMIT, new SignedWordElement(0x1009)), - m(EssFeneconBydContainer.ChannelId.CURRENT_L1, new SignedWordElement(0x100A), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.CURRENT_L2, new SignedWordElement(0x100B), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.CURRENT_L3, new SignedWordElement(0x100C), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.VOLTAGE_L1, new UnsignedWordElement(0x100D), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.VOLTAGE_L2, new UnsignedWordElement(0x100E), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.VOLTAGE_L3, new UnsignedWordElement(0x100F), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.VOLTAGE_L12, new UnsignedWordElement(0x1010), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.VOLTAGE_L23, new UnsignedWordElement(0x1011), - ElementToChannelConverter.SCALE_FACTOR_2), - m(EssFeneconBydContainer.ChannelId.VOLTAGE_L31, new UnsignedWordElement(0x1012), - ElementToChannelConverter.SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.CURRENT_L1, new SignedWordElement(0x100A), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.CURRENT_L2, new SignedWordElement(0x100B), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.CURRENT_L3, new SignedWordElement(0x100C), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.VOLTAGE_L1, new UnsignedWordElement(0x100D), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.VOLTAGE_L2, new UnsignedWordElement(0x100E), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.VOLTAGE_L3, new UnsignedWordElement(0x100F), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.VOLTAGE_L12, new UnsignedWordElement(0x1010), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.VOLTAGE_L23, new UnsignedWordElement(0x1011), SCALE_FACTOR_2), + m(EssFeneconBydContainer.ChannelId.VOLTAGE_L31, new UnsignedWordElement(0x1012), SCALE_FACTOR_2), m(EssFeneconBydContainer.ChannelId.SYSTEM_FREQUENCY, new UnsignedWordElement(0x1013)), m(EssFeneconBydContainer.ChannelId.DC_VOLTAGE, new SignedWordElement(0x1014)), m(EssFeneconBydContainer.ChannelId.DC_CURRENT, new SignedWordElement(0x1015)), @@ -943,16 +936,12 @@ protected ModbusProtocol defineModbus2Protocol() throws OpenemsException { // RTU registers m(EssFeneconBydContainer.ChannelId.SYSTEM_WORKSTATE, new UnsignedWordElement(0x38A0)), m(EssFeneconBydContainer.ChannelId.SYSTEM_WORKMODE, new UnsignedWordElement(0x38A1)), - m(ManagedSymmetricEss.ChannelId.ALLOWED_DISCHARGE_POWER, new SignedWordElement(0x38A2), - ElementToChannelConverter.SCALE_FACTOR_3), - m(ManagedSymmetricEss.ChannelId.ALLOWED_CHARGE_POWER, new SignedWordElement(0x38A3), - ElementToChannelConverter.SCALE_FACTOR_3), + m(ManagedSymmetricEss.ChannelId.ALLOWED_DISCHARGE_POWER, new SignedWordElement(0x38A2), SCALE_FACTOR_3), + m(ManagedSymmetricEss.ChannelId.ALLOWED_CHARGE_POWER, new SignedWordElement(0x38A3), SCALE_FACTOR_3), m(EssFeneconBydContainer.ChannelId.LIMIT_INDUCTIVE_REACTIVE_POWER, new SignedWordElement(0x38A4)), m(EssFeneconBydContainer.ChannelId.LIMIT_CAPACITIVE_REACTIVE_POWER, new SignedWordElement(0x38A5)), - m(SymmetricEss.ChannelId.ACTIVE_POWER, new SignedWordElement(0x38A6), - ElementToChannelConverter.SCALE_FACTOR_2), - m(SymmetricEss.ChannelId.REACTIVE_POWER, new SignedWordElement(0x38A7), - ElementToChannelConverter.SCALE_FACTOR_2), + m(SymmetricEss.ChannelId.ACTIVE_POWER, new SignedWordElement(0x38A6), SCALE_FACTOR_2), + m(SymmetricEss.ChannelId.REACTIVE_POWER, new SignedWordElement(0x38A7), SCALE_FACTOR_2), m(SymmetricEss.ChannelId.SOC, new UnsignedWordElement(0x38A8)), m(EssFeneconBydContainer.ChannelId.CONTAINER_RUN_NUMBER, new UnsignedWordElement(0x38A9))), new FC16WriteRegistersTask(0x0500, diff --git a/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/EssFeneconCommercial40Impl.java b/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/EssFeneconCommercial40Impl.java index 887d6c271aa..ca1be1bb899 100644 --- a/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/EssFeneconCommercial40Impl.java +++ b/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/EssFeneconCommercial40Impl.java @@ -1,5 +1,7 @@ package io.openems.edge.ess.fenecon.commercial40; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; + import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -335,61 +337,50 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { .bit(14, EssFeneconCommercial40.SystemErrorChannelId.STATE_124))), new FC3ReadRegistersTask(0x0200, Priority.HIGH, // m(EssFeneconCommercial40.ChannelId.BATTERY_VOLTAGE, new SignedWordElement(0x0200), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.BATTERY_CURRENT, new SignedWordElement(0x0201), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.BATTERY_POWER, new SignedWordElement(0x0202), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // new DummyRegisterElement(0x0203, 0x0207), m(EssFeneconCommercial40.ChannelId.ORIGINAL_ACTIVE_CHARGE_ENERGY, - new UnsignedDoublewordElement(0x0208).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedDoublewordElement(0x0208).wordOrder(WordOrder.LSWMSW), SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.ORIGINAL_ACTIVE_DISCHARGE_ENERGY, - new UnsignedDoublewordElement(0x020A).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedDoublewordElement(0x020A).wordOrder(WordOrder.LSWMSW), SCALE_FACTOR_2), // new DummyRegisterElement(0x020C, 0x020F), // m(EssFeneconCommercial40.ChannelId.GRID_ACTIVE_POWER, new SignedWordElement(0x0210), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(SymmetricEss.ChannelId.REACTIVE_POWER, new SignedWordElement(0x0211), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // + m(SymmetricEss.ChannelId.REACTIVE_POWER, new SignedWordElement(0x0211), SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.APPARENT_POWER, new UnsignedWordElement(0x0212), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssFeneconCommercial40.ChannelId.CURRENT_L1, new SignedWordElement(0x0213), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssFeneconCommercial40.ChannelId.CURRENT_L2, new SignedWordElement(0x0214), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssFeneconCommercial40.ChannelId.CURRENT_L3, new SignedWordElement(0x0215), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // + m(EssFeneconCommercial40.ChannelId.CURRENT_L1, new SignedWordElement(0x0213), SCALE_FACTOR_2), // + m(EssFeneconCommercial40.ChannelId.CURRENT_L2, new SignedWordElement(0x0214), SCALE_FACTOR_2), // + m(EssFeneconCommercial40.ChannelId.CURRENT_L3, new SignedWordElement(0x0215), SCALE_FACTOR_2), // new DummyRegisterElement(0x0216, 0x218), // - m(EssFeneconCommercial40.ChannelId.VOLTAGE_L1, new UnsignedWordElement(0x0219), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssFeneconCommercial40.ChannelId.VOLTAGE_L2, new UnsignedWordElement(0x021A), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssFeneconCommercial40.ChannelId.VOLTAGE_L3, new UnsignedWordElement(0x021B), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(EssFeneconCommercial40.ChannelId.VOLTAGE_L1, new UnsignedWordElement(0x0219), SCALE_FACTOR_2), // + m(EssFeneconCommercial40.ChannelId.VOLTAGE_L2, new UnsignedWordElement(0x021A), SCALE_FACTOR_2), // + m(EssFeneconCommercial40.ChannelId.VOLTAGE_L3, new UnsignedWordElement(0x021B), SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.FREQUENCY, new UnsignedWordElement(0x021C)), // new DummyRegisterElement(0x021D, 0x0221), // m(EssFeneconCommercial40.ChannelId.INVERTER_VOLTAGE_L1, new UnsignedWordElement(0x0222), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.INVERTER_VOLTAGE_L2, new UnsignedWordElement(0x0223), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.INVERTER_VOLTAGE_L3, new UnsignedWordElement(0x0224), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.INVERTER_CURRENT_L1, new SignedWordElement(0x0225), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.INVERTER_CURRENT_L2, new SignedWordElement(0x0226), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.INVERTER_CURRENT_L3, new SignedWordElement(0x0227), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(SymmetricEss.ChannelId.ACTIVE_POWER, new SignedWordElement(0x0228), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // + m(SymmetricEss.ChannelId.ACTIVE_POWER, new SignedWordElement(0x0228), SCALE_FACTOR_2), // new DummyRegisterElement(0x0229, 0x022F), // m(EssFeneconCommercial40.ChannelId.ORIGINAL_ALLOWED_CHARGE_POWER, new SignedWordElement(0x0230), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.ORIGINAL_ALLOWED_DISCHARGE_POWER, - new UnsignedWordElement(0x0231), ElementToChannelConverter.SCALE_FACTOR_2), // - m(SymmetricEss.ChannelId.MAX_APPARENT_POWER, new UnsignedWordElement(0x0232), - ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedWordElement(0x0231), SCALE_FACTOR_2), // + m(SymmetricEss.ChannelId.MAX_APPARENT_POWER, new UnsignedWordElement(0x0232), SCALE_FACTOR_2), // new DummyRegisterElement(0x0233, 0x23F), m(EssFeneconCommercial40.ChannelId.IPM_TEMPERATURE_L1, new SignedWordElement(0x0240)), // m(EssFeneconCommercial40.ChannelId.IPM_TEMPERATURE_L2, new SignedWordElement(0x0241)), // @@ -400,9 +391,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(EssFeneconCommercial40.ChannelId.SET_WORK_STATE, new UnsignedWordElement(0x0500))), // new FC16WriteRegistersTask(0x0501, // m(EssFeneconCommercial40.ChannelId.SET_ACTIVE_POWER, new SignedWordElement(0x0501), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssFeneconCommercial40.ChannelId.SET_REACTIVE_POWER, new SignedWordElement(0x0502), - ElementToChannelConverter.SCALE_FACTOR_2)), // + SCALE_FACTOR_2)), // new FC3ReadRegistersTask(0xA000, Priority.LOW, // m(EssFeneconCommercial40.ChannelId.BMS_DCDC_WORK_STATE, new UnsignedWordElement(0xA000)), // m(EssFeneconCommercial40.ChannelId.BMS_DCDC_WORK_MODE, new UnsignedWordElement(0xA001))), // @@ -664,18 +655,18 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(EssFeneconCommercial40.ChannelId.CELL_224_VOLTAGE, new UnsignedWordElement(0x15DF))), new FC3ReadRegistersTask(0x1400, Priority.LOW, // m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_TOTAL_VOLTAGE, - new UnsignedWordElement(0x1400), ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(0x1400), SCALE_FACTOR_2), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_TOTAL_CURRENT, new SignedWordElement(0x1401), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(SymmetricEss.ChannelId.SOC, new UnsignedWordElement(0x1402)), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_SOH, new UnsignedWordElement(0x1403)), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_AVG_TEMPERATURE, new SignedWordElement(0x1404)), new DummyRegisterElement(0x1405), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_CHARGE_CURRENT_LIMIT, - new UnsignedWordElement(0x1406), ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(0x1406), SCALE_FACTOR_2), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_DISCHARGE_CURRENT_LIMIT, - new UnsignedWordElement(0x1407), ElementToChannelConverter.SCALE_FACTOR_2), + new UnsignedWordElement(0x1407), SCALE_FACTOR_2), new DummyRegisterElement(0x1408, 0x1409), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_CYCLES, new UnsignedDoublewordElement(0x140A).wordOrder(WordOrder.LSWMSW)), @@ -686,7 +677,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new UnsignedDoublewordElement(0x141A).wordOrder(WordOrder.LSWMSW)), new DummyRegisterElement(0x141C, 0x141F), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_POWER, new SignedWordElement(0x1420), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), new DummyRegisterElement(0x1421, 0x142F), m(EssFeneconCommercial40.ChannelId.BATTERY_STRING_MAX_CELL_VOLTAGE_NO, new UnsignedWordElement(0x1430)), diff --git a/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/charger/AbstractEssDcChargerFeneconCommercial40.java b/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/charger/AbstractEssDcChargerFeneconCommercial40.java index 6abb55c701c..2a0a5440b42 100644 --- a/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/charger/AbstractEssDcChargerFeneconCommercial40.java +++ b/io.openems.edge.ess.fenecon.commercial40/src/io/openems/edge/ess/fenecon/commercial40/charger/AbstractEssDcChargerFeneconCommercial40.java @@ -1,12 +1,13 @@ package io.openems.edge.ess.fenecon.commercial40.charger; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; + import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import io.openems.common.channel.AccessMode; import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -55,27 +56,27 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { var protocol = new ModbusProtocol(this, // new FC16WriteRegistersTask(0x0503, // m(EssDcChargerFeneconCommercial40.ChannelId.SET_PV_POWER_LIMIT, new UnsignedWordElement(0x0503), - ElementToChannelConverter.SCALE_FACTOR_2))); // + SCALE_FACTOR_2))); // if (this.isPV1()) { protocol.addTasks(// new FC3ReadRegistersTask(0xA130, Priority.LOW, // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_VOLTAGE, - new SignedWordElement(0xA130), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA130), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_CURRENT, - new SignedWordElement(0xA131), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA131), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_POWER, - new SignedWordElement(0xA132), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA132), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_VOLTAGE, - new SignedWordElement(0xA133), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA133), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_CURRENT, - new SignedWordElement(0xA134), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA134), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_POWER, - new SignedWordElement(0xA135), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA135), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_ENERGY, - new SignedWordElement(0xA136), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA136), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_ENERGY, - new SignedWordElement(0xA137), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA137), SCALE_FACTOR_2), // new DummyRegisterElement(0xA138, 0xA13F), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_REACTOR_TEMPERATURE, new SignedWordElement(0xA140)), // @@ -84,34 +85,33 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new DummyRegisterElement(0xA142, 0xA14F), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xA150).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xA152).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xA154).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xA156).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2)), // + SCALE_FACTOR_2)), // new FC3ReadRegistersTask(0xA730, Priority.LOW, // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_VOLTAGE, - new SignedWordElement(0xA730), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA730), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_CURRENT, - new SignedWordElement(0xA731), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA731), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_POWER, - new SignedWordElement(0xA732), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA732), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_VOLTAGE, - new SignedWordElement(0xA733), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA733), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_CURRENT, - new SignedWordElement(0xA734), ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssDcCharger.ChannelId.ACTUAL_POWER, new SignedWordElement(0xA735), - ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA734), SCALE_FACTOR_2), // + m(EssDcCharger.ChannelId.ACTUAL_POWER, new SignedWordElement(0xA735), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_ENERGY, - new SignedWordElement(0xA736), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA736), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_ENERGY, - new SignedWordElement(0xA737), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA737), SCALE_FACTOR_2), // new DummyRegisterElement(0xA738, 0xA73F), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_REACTOR_TEMPERATURE, new SignedWordElement(0xA740)), // @@ -120,36 +120,35 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new DummyRegisterElement(0xA742, 0xA74F), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xA750).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xA752).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xA754).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xA756).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2))); + SCALE_FACTOR_2))); } else { protocol.addTasks(// new FC3ReadRegistersTask(0xAA30, Priority.LOW, // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_VOLTAGE, - new SignedWordElement(0xAA30), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA30), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_CURRENT, - new SignedWordElement(0xAA31), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA31), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_POWER, - new SignedWordElement(0xAA32), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA32), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_VOLTAGE, - new SignedWordElement(0xAA33), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA33), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_CURRENT, - new SignedWordElement(0xAA34), ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssDcCharger.ChannelId.ACTUAL_POWER, new SignedWordElement(0xAA35), - ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA34), SCALE_FACTOR_2), // + m(EssDcCharger.ChannelId.ACTUAL_POWER, new SignedWordElement(0xAA35), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_ENERGY, - new SignedWordElement(0xAA36), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA36), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_ENERGY, - new SignedWordElement(0xAA37), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xAA37), SCALE_FACTOR_2), // new DummyRegisterElement(0xAA38, 0xAA3F), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_REACTOR_TEMPERATURE, new SignedWordElement(0xAA40)), // @@ -158,33 +157,33 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new DummyRegisterElement(0xAA42, 0xAA4F), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xAA50).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_INPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xAA52).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xAA54).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.PV_DCDC_OUTPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xAA56).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2)), + SCALE_FACTOR_2)), new FC3ReadRegistersTask(0xA430, Priority.LOW, // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_VOLTAGE, - new SignedWordElement(0xA430), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA430), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_CURRENT, - new SignedWordElement(0xA431), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA431), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_POWER, - new SignedWordElement(0xA432), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA432), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_VOLTAGE, - new SignedWordElement(0xA433), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA433), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_CURRENT, - new SignedWordElement(0xA434), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA434), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_POWER, - new SignedWordElement(0xA435), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA435), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_ENERGY, - new SignedWordElement(0xA436), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA436), SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_ENERGY, - new SignedWordElement(0xA437), ElementToChannelConverter.SCALE_FACTOR_2), // + new SignedWordElement(0xA437), SCALE_FACTOR_2), // new DummyRegisterElement(0xA438, 0xA43F), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_REACTOR_TEMPERATURE, new SignedWordElement(0xA440)), // @@ -193,16 +192,16 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new DummyRegisterElement(0xA442, 0xA44F), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xA450).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_INPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xA452).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_CHARGE_ENERGY, new UnsignedDoublewordElement(0xA454).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(EssDcChargerFeneconCommercial40.ChannelId.BMS_DCDC_OUTPUT_DISCHARGE_ENERGY, new UnsignedDoublewordElement(0xA456).wordOrder(WordOrder.LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2))); // + SCALE_FACTOR_2))); // } return protocol; } diff --git a/io.openems.edge.ess.mr.gridcon/src/io/openems/edge/ess/mr/gridcon/GridconPcsImpl.java b/io.openems.edge.ess.mr.gridcon/src/io/openems/edge/ess/mr/gridcon/GridconPcsImpl.java index 29943d8061f..31888008d18 100644 --- a/io.openems.edge.ess.mr.gridcon/src/io/openems/edge/ess/mr/gridcon/GridconPcsImpl.java +++ b/io.openems.edge.ess.mr.gridcon/src/io/openems/edge/ess/mr/gridcon/GridconPcsImpl.java @@ -1,5 +1,7 @@ package io.openems.edge.ess.mr.gridcon; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; + import java.nio.ByteOrder; import org.osgi.service.cm.ConfigurationAdmin; @@ -23,7 +25,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -634,8 +635,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GridConChannelId.INVERTER_1_STATUS_DC_LINK_CURRENT, new FloatDoublewordElement(33176).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.INVERTER_1_STATUS_DC_LINK_ACTIVE_POWER, - new FloatDoublewordElement(33178).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.INVERT), // + new FloatDoublewordElement(33178).wordOrder(WordOrder.LSWMSW), INVERT), // m(GridConChannelId.INVERTER_1_STATUS_DC_LINK_UTILIZATION, new FloatDoublewordElement(33180).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.INVERTER_1_STATUS_FAN_SPEED_MAX, @@ -717,8 +717,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GridConChannelId.INVERTER_2_STATUS_DC_LINK_CURRENT, new FloatDoublewordElement(33208).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.INVERTER_2_STATUS_DC_LINK_ACTIVE_POWER, - new FloatDoublewordElement(33210).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.INVERT), // + new FloatDoublewordElement(33210).wordOrder(WordOrder.LSWMSW), INVERT), // m(GridConChannelId.INVERTER_2_STATUS_DC_LINK_UTILIZATION, new FloatDoublewordElement(33212).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.INVERTER_2_STATUS_FAN_SPEED_MAX, @@ -799,8 +798,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GridConChannelId.INVERTER_3_STATUS_DC_LINK_CURRENT, new FloatDoublewordElement(33240).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.INVERTER_3_STATUS_DC_LINK_ACTIVE_POWER, - new FloatDoublewordElement(33242).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.INVERT), // + new FloatDoublewordElement(33242).wordOrder(WordOrder.LSWMSW), INVERT), // m(GridConChannelId.INVERTER_3_STATUS_DC_LINK_UTILIZATION, new FloatDoublewordElement(33244).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.INVERTER_3_STATUS_FAN_SPEED_MAX, @@ -1000,7 +998,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FloatDoublewordElement(startAddressDcDcState + 8).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.DCDC_STATUS_DC_LINK_ACTIVE_POWER, new FloatDoublewordElement(startAddressDcDcState + 10).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.INVERT), // + INVERT), // m(GridConChannelId.DCDC_STATUS_DC_LINK_UTILIZATION, new FloatDoublewordElement(startAddressDcDcState + 12).wordOrder(WordOrder.LSWMSW)), // m(GridConChannelId.DCDC_STATUS_FAN_SPEED_MAX, diff --git a/io.openems.edge.ess.sma/src/io/openems/edge/sma/sunnyisland/SunnyIslandEssImpl.java b/io.openems.edge.ess.sma/src/io/openems/edge/sma/sunnyisland/SunnyIslandEssImpl.java index 5f8c50201f3..9e727443150 100644 --- a/io.openems.edge.ess.sma/src/io/openems/edge/sma/sunnyisland/SunnyIslandEssImpl.java +++ b/io.openems.edge.ess.sma/src/io/openems/edge/sma/sunnyisland/SunnyIslandEssImpl.java @@ -1,5 +1,11 @@ package io.openems.edge.sma.sunnyisland; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -189,21 +195,17 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(AsymmetricEss.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(30779)), // m(AsymmetricEss.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(30781)), // m(SunnyIslandEss.ChannelId.GRID_VOLTAGE_L1, new SignedDoublewordElement(30783), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(SunnyIslandEss.ChannelId.GRID_VOLTAGE_L2, new SignedDoublewordElement(30785), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(SunnyIslandEss.ChannelId.GRID_VOLTAGE_L3, new SignedDoublewordElement(30787), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // new DummyRegisterElement(30789, 30802), // - m(SunnyIslandEss.ChannelId.FREQUENCY, new UnsignedDoublewordElement(30803), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(SunnyIslandEss.ChannelId.FREQUENCY, new UnsignedDoublewordElement(30803), SCALE_FACTOR_1), // new DummyRegisterElement(30805, 30806), // - m(AsymmetricEss.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(30807), - ElementToChannelConverter.INVERT), // - m(AsymmetricEss.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(30809), - ElementToChannelConverter.INVERT), // - m(AsymmetricEss.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(30811), - ElementToChannelConverter.INVERT)), // + m(AsymmetricEss.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(30807), INVERT), // + m(AsymmetricEss.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(30809), INVERT), // + m(AsymmetricEss.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(30811), INVERT)), // new FC3ReadRegistersTask(30835, Priority.LOW, // m(SunnyIslandEss.ChannelId.OPERATING_MODE_FOR_ACTIVE_POWER_LIMITATION, @@ -212,13 +214,13 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(30843, Priority.HIGH, // // BatteryAmpere 30843 m(SunnyIslandEss.ChannelId.BATTERY_CURRENT, new SignedDoublewordElement(30843), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), + SCALE_FACTOR_MINUS_3), m(SymmetricEss.ChannelId.SOC, new UnsignedDoublewordElement(30845)), // m(SunnyIslandEss.ChannelId.CURRENT_BATTERY_CAPACITY, new SignedDoublewordElement(30847)), // m(SunnyIslandEss.ChannelId.BATTERY_TEMPERATURE, new SignedDoublewordElement(30849), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(SunnyIslandEss.ChannelId.BATTERY_VOLTAGE, new UnsignedDoublewordElement(30851), // - ElementToChannelConverter.SCALE_FACTOR_1)), + SCALE_FACTOR_1)), new FC3ReadRegistersTask(30877, Priority.LOW, m(SunnyIslandEss.ChannelId.POWER_SUPPLY_STATUS, new UnsignedDoublewordElement(30877), @@ -248,15 +250,15 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(30997, Priority.LOW, m(SunnyIslandEss.ChannelId.LOWEST_MEASURED_BATTERY_TEMPERATURE, - new SignedDoublewordElement(30997), ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + new SignedDoublewordElement(30997), SCALE_FACTOR_MINUS_1), m(SunnyIslandEss.ChannelId.HIGHEST_MEASURED_BATTERY_TEMPERATURE, - new SignedDoublewordElement(30999), ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + new SignedDoublewordElement(30999), SCALE_FACTOR_MINUS_1), m(SunnyIslandEss.ChannelId.MAX_OCCURRED_BATTERY_VOLTAGE, new SignedDoublewordElement(31001), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2)), + SCALE_FACTOR_MINUS_2)), new FC3ReadRegistersTask(40189, Priority.HIGH, // m(ManagedSymmetricEss.ChannelId.ALLOWED_CHARGE_POWER, new UnsignedDoublewordElement(40189), - ElementToChannelConverter.INVERT), // + INVERT), // m(ManagedSymmetricEss.ChannelId.ALLOWED_DISCHARGE_POWER, new UnsignedDoublewordElement(40191))), // new FC16WriteRegistersTask(40149, // diff --git a/io.openems.edge.evcs.alpitronic.hypercharger/src/io/openems/edge/evcs/hypercharger/HyperchargerImpl.java b/io.openems.edge.evcs.alpitronic.hypercharger/src/io/openems/edge/evcs/hypercharger/HyperchargerImpl.java index 77f0a769473..eed863496da 100644 --- a/io.openems.edge.evcs.alpitronic.hypercharger/src/io/openems/edge/evcs/hypercharger/HyperchargerImpl.java +++ b/io.openems.edge.evcs.alpitronic.hypercharger/src/io/openems/edge/evcs/hypercharger/HyperchargerImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.evcs.hypercharger; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; + import java.util.function.Consumer; import java.util.function.IntFunction; @@ -26,7 +29,6 @@ import io.openems.common.types.OpenemsType; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.UnsignedDoublewordElement; @@ -191,9 +193,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC4ReadInputRegistersTask(this.offset.apply(0), Priority.LOW, m(Hypercharger.ChannelId.RAW_STATUS, new UnsignedWordElement(this.offset.apply(0))), m(Hypercharger.ChannelId.CHARGING_VOLTAGE, new UnsignedDoublewordElement(this.offset.apply(1)), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(Hypercharger.ChannelId.CHARGING_CURRENT, new UnsignedWordElement(this.offset.apply(3)), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), /* * TODO: Test charge power register with newer firmware versions. Register value * was always 0 with versions < 1.7.2. @@ -201,7 +203,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(Hypercharger.ChannelId.RAW_CHARGE_POWER, new UnsignedDoublewordElement(this.offset.apply(4))), m(Hypercharger.ChannelId.CHARGED_TIME, new UnsignedWordElement(this.offset.apply(6))), m(Hypercharger.ChannelId.CHARGED_ENERGY, new UnsignedWordElement(this.offset.apply(7)), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2).onUpdateCallback(e -> { + SCALE_FACTOR_MINUS_2).onUpdateCallback(e -> { if (e == null) { return; } @@ -232,7 +234,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { }), // TODO: Implement SocEvcs Nature & map SoC register m(Hypercharger.ChannelId.EV_SOC, new UnsignedWordElement(this.offset.apply(8)), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + SCALE_FACTOR_MINUS_2), m(Hypercharger.ChannelId.CONNECTOR_TYPE, new UnsignedWordElement(this.offset.apply(9))), /* @@ -247,7 +249,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(Hypercharger.ChannelId.VAR_REACTIVE_MAX, new UnsignedDoublewordElement(this.offset.apply(14))), m(Hypercharger.ChannelId.VAR_REACTIVE_MIN, new UnsignedDoublewordElement(this.offset.apply(16)), - ElementToChannelConverter.INVERT)) + INVERT)) ); diff --git a/io.openems.edge.evcs.core/readme.adoc b/io.openems.edge.evcs.core/readme.adoc index 9003f76f056..30f9b2c143d 100644 --- a/io.openems.edge.evcs.core/readme.adoc +++ b/io.openems.edge.evcs.core/readme.adoc @@ -193,7 +193,7 @@ Most mistakes: - Missing register (Unimportant register could be skipped with *new DummyRegisterElement(xxx),*) - Important tasks with Priority HIGH are blocked by other unimportant tasks with Priority HIGH - Read/Write register must be read and write in different tasks with different function codes -- Scale factor overlooked. The scale factor can be easily adjusted using, for example, ElementToChannelConverter.SCALE_FACTOR_MINUS_2 +- Scale factor overlooked. The scale factor can be easily adjusted using, for example, SCALE_FACTOR_MINUS_2 . Check if every Channel is set correctly + diff --git a/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/charger/AbstractFeneconDessCharger.java b/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/charger/AbstractFeneconDessCharger.java index f1f3d159232..cf21f3796e3 100644 --- a/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/charger/AbstractFeneconDessCharger.java +++ b/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/charger/AbstractFeneconDessCharger.java @@ -1,12 +1,13 @@ package io.openems.edge.fenecon.dess.charger; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; + import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import io.openems.common.channel.AccessMode; import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -47,8 +48,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(EssDcCharger.ChannelId.ACTUAL_POWER, new UnsignedWordElement(offset + 2)), // new DummyRegisterElement(offset + 3, offset + 4), m(FeneconDessCharger.ChannelId.ORIGINAL_ACTUAL_ENERGY, - new UnsignedDoublewordElement(offset + 5).wordOrder(WordOrder.MSWLSW), - ElementToChannelConverter.SCALE_FACTOR_2)) // + new UnsignedDoublewordElement(offset + 5).wordOrder(WordOrder.MSWLSW), SCALE_FACTOR_2)) // ); } diff --git a/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/ess/FeneconDessEssImpl.java b/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/ess/FeneconDessEssImpl.java index 54a1fd43d76..a87c90eb7f4 100644 --- a/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/ess/FeneconDessEssImpl.java +++ b/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/ess/FeneconDessEssImpl.java @@ -1,5 +1,7 @@ package io.openems.edge.fenecon.dess.ess; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import java.util.ArrayList; import java.util.List; @@ -123,11 +125,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SymmetricEss.ChannelId.SOC, new UnsignedWordElement(10143)), // new DummyRegisterElement(10144, 10150), m(FeneconDessEss.ChannelId.ORIGINAL_ACTIVE_CHARGE_ENERGY, - new UnsignedDoublewordElement(10151).wordOrder(WordOrder.MSWLSW), - ElementToChannelConverter.SCALE_FACTOR_3), // + new UnsignedDoublewordElement(10151).wordOrder(WordOrder.MSWLSW), SCALE_FACTOR_3), // m(FeneconDessEss.ChannelId.ORIGINAL_ACTIVE_DISCHARGE_ENERGY, - new UnsignedDoublewordElement(10153).wordOrder(WordOrder.MSWLSW), - ElementToChannelConverter.SCALE_FACTOR_3)), // + new UnsignedDoublewordElement(10153).wordOrder(WordOrder.MSWLSW), SCALE_FACTOR_3)), // new FC3ReadRegistersTask(11133, Priority.HIGH, // m(AsymmetricEss.ChannelId.ACTIVE_POWER_L1, new UnsignedWordElement(11133), DELTA_10000), // m(AsymmetricEss.ChannelId.REACTIVE_POWER_L1, new UnsignedWordElement(11134), DELTA_10000)), // diff --git a/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/gridmeter/FeneconDessGridMeterImpl.java b/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/gridmeter/FeneconDessGridMeterImpl.java index 0390d5b145d..1087eaffce3 100644 --- a/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/gridmeter/FeneconDessGridMeterImpl.java +++ b/io.openems.edge.fenecon.dess/src/io/openems/edge/fenecon/dess/gridmeter/FeneconDessGridMeterImpl.java @@ -1,5 +1,7 @@ package io.openems.edge.fenecon.dess.gridmeter; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -99,30 +101,22 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC3ReadRegistersTask(11109, Priority.LOW, // m(FeneconDessGridMeter.ChannelId.ORIGINAL_ACTIVE_CONSUMPTION_ENERGY, - new UnsignedDoublewordElement(11109).wordOrder(WordOrder.MSWLSW), - ElementToChannelConverter.SCALE_FACTOR_2), // + new UnsignedDoublewordElement(11109).wordOrder(WordOrder.MSWLSW), SCALE_FACTOR_2), // m(FeneconDessGridMeter.ChannelId.ORIGINAL_ACTIVE_PRODUCTION_ENERGY, - new UnsignedDoublewordElement(11111).wordOrder(WordOrder.MSWLSW), - ElementToChannelConverter.SCALE_FACTOR_2)), // + new UnsignedDoublewordElement(11111).wordOrder(WordOrder.MSWLSW), SCALE_FACTOR_2)), // new FC3ReadRegistersTask(11136, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedWordElement(11136), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(11137), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedWordElement(11136), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(11137), SCALE_FACTOR_2), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new UnsignedWordElement(11138), DELTA_10000), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new UnsignedWordElement(11139), DELTA_10000)), // new FC3ReadRegistersTask(11166, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedWordElement(11166), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(11167), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedWordElement(11166), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(11167), SCALE_FACTOR_2), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new UnsignedWordElement(11168), DELTA_10000), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new UnsignedWordElement(11169), DELTA_10000)), // new FC3ReadRegistersTask(11196, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedWordElement(11196), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(11197), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedWordElement(11196), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(11197), SCALE_FACTOR_2), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new UnsignedWordElement(11198), DELTA_10000), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new UnsignedWordElement(11199), DELTA_10000)) // ); // diff --git a/io.openems.edge.fenecon.mini/src/io/openems/edge/fenecon/mini/ess/FeneconMiniEssImpl.java b/io.openems.edge.fenecon.mini/src/io/openems/edge/fenecon/mini/ess/FeneconMiniEssImpl.java index 72d5f55a53d..eb687c1ff37 100644 --- a/io.openems.edge.fenecon.mini/src/io/openems/edge/fenecon/mini/ess/FeneconMiniEssImpl.java +++ b/io.openems.edge.fenecon.mini/src/io/openems/edge/fenecon/mini/ess/FeneconMiniEssImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.fenecon.mini.ess; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SUBTRACT; + import java.util.function.Consumer; import org.osgi.service.cm.ConfigurationAdmin; @@ -27,7 +30,6 @@ import io.openems.edge.bridge.modbus.api.BridgeModbus; import io.openems.edge.bridge.modbus.api.ChannelMetaInfoReadAndWrite; import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; -import io.openems.edge.bridge.modbus.api.ElementToChannelOffsetConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.BitsWordElement; @@ -195,11 +197,10 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { UNSIGNED_POWER_CONVERTER)), // new FC3ReadRegistersTask(3000, Priority.LOW, // m(FeneconMiniEss.ChannelId.BECU1_ALLOWED_CHARGE_CURRENT, new UnsignedWordElement(3000), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(FeneconMiniEss.ChannelId.BECU1_ALLOWED_DISCHARGE_CURRENT, new UnsignedWordElement(3001), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconMiniEss.ChannelId.BECU1_TOTAL_VOLTAGE, new UnsignedWordElement(3002), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // + m(FeneconMiniEss.ChannelId.BECU1_TOTAL_VOLTAGE, new UnsignedWordElement(3002), SCALE_FACTOR_2), // m(FeneconMiniEss.ChannelId.BECU1_TOTAL_CURRENT, new UnsignedWordElement(3003)), // m(FeneconMiniEss.ChannelId.BECU1_SOC, new UnsignedWordElement(3004)), // m(new BitsWordElement(3005, this) // @@ -264,13 +265,13 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(FeneconMiniEss.ChannelId.BECU1_MINIMUM_VOLTAGE_NO, new UnsignedWordElement(3012)), // m(FeneconMiniEss.ChannelId.BECU1_MINIMUM_VOLTAGE, new UnsignedWordElement(3013)), // m(FeneconMiniEss.ChannelId.BECU1_MAXIMUM_VOLTAGE_NO, new UnsignedWordElement(3014)), // - m(FeneconMiniEss.ChannelId.BECU1_MAXIMUM_VOLTAGE, new UnsignedWordElement(3015)), // ^ + m(FeneconMiniEss.ChannelId.BECU1_MAXIMUM_VOLTAGE, new UnsignedWordElement(3015)), // m(FeneconMiniEss.ChannelId.BECU1_MINIMUM_TEMPERATURE_NO, new UnsignedWordElement(3016)), // m(FeneconMiniEss.ChannelId.BECU1_MINIMUM_TEMPERATURE, new UnsignedWordElement(3017), - new ElementToChannelOffsetConverter(-40)), // + SUBTRACT(40)), // m(FeneconMiniEss.ChannelId.BECU1_MAXIMUM_TEMPERATURE_NO, new UnsignedWordElement(3018)), // - m(FeneconMiniEss.ChannelId.BECU1_MAXIMUM_TEMPERATURE, new UnsignedWordElement( - 3019), new ElementToChannelOffsetConverter(-40))), + m(FeneconMiniEss.ChannelId.BECU1_MAXIMUM_TEMPERATURE, new UnsignedWordElement(3019), + SUBTRACT(40))), new FC3ReadRegistersTask(3020, Priority.LOW, // m(FeneconMiniEss.ChannelId.BATTERY_VOLTAGE_SECTION_1, new UnsignedWordElement(3020)), // m(FeneconMiniEss.ChannelId.BATTERY_VOLTAGE_SECTION_2, new UnsignedWordElement(3021)), // @@ -461,11 +462,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(FeneconMiniEss.ChannelId.RTC_SECOND, new UnsignedWordElement(9019))), // new FC16WriteRegistersTask(30526, // m(FeneconMiniEss.ChannelId.GRID_MAX_CHARGE_CURRENT, new UnsignedWordElement(30526), - ElementToChannelConverter.SCALE_FACTOR_2, - new ChannelMetaInfoReadAndWrite(30126, 30526)), // + SCALE_FACTOR_2, new ChannelMetaInfoReadAndWrite(30126, 30526)), // m(FeneconMiniEss.ChannelId.GRID_MAX_DISCHARGE_CURRENT, new UnsignedWordElement(30527), - ElementToChannelConverter.SCALE_FACTOR_2, - new ChannelMetaInfoReadAndWrite(30127, 30527))), // + SCALE_FACTOR_2, new ChannelMetaInfoReadAndWrite(30127, 30527))), // new FC16WriteRegistersTask(30558, // m(FeneconMiniEss.ChannelId.SETUP_MODE, new UnsignedWordElement(30558), new ChannelMetaInfoReadAndWrite(30157, 30558))), // @@ -475,11 +474,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(30126, Priority.LOW, // m(FeneconMiniEss.ChannelId.GRID_MAX_CHARGE_CURRENT, new UnsignedWordElement(30126), - ElementToChannelConverter.SCALE_FACTOR_2, - new ChannelMetaInfoReadAndWrite(30126, 30526)), // + SCALE_FACTOR_2, new ChannelMetaInfoReadAndWrite(30126, 30526)), // m(FeneconMiniEss.ChannelId.GRID_MAX_DISCHARGE_CURRENT, new UnsignedWordElement(30127), - ElementToChannelConverter.SCALE_FACTOR_2, - new ChannelMetaInfoReadAndWrite(30127, 30527)), // + SCALE_FACTOR_2, new ChannelMetaInfoReadAndWrite(30127, 30527)), // new DummyRegisterElement(30128, 30156), // m(FeneconMiniEss.ChannelId.SETUP_MODE, new UnsignedWordElement(30157), new ChannelMetaInfoReadAndWrite(30157, 30558)), // diff --git a/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/ess/FeneconProEssImpl.java b/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/ess/FeneconProEssImpl.java index 2c4936e6773..b8b883671b5 100644 --- a/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/ess/FeneconProEssImpl.java +++ b/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/ess/FeneconProEssImpl.java @@ -1,5 +1,9 @@ package io.openems.edge.fenecon.pro.ess; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -160,10 +164,8 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return value; }, // channel -> element value -> value)), // - m(FeneconProEss.ChannelId.BATTERY_VOLTAGE, new UnsignedWordElement(110), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconProEss.ChannelId.BATTERY_CURRENT, new SignedWordElement(111), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.BATTERY_VOLTAGE, new UnsignedWordElement(110), SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.BATTERY_CURRENT, new SignedWordElement(111), SCALE_FACTOR_2), // m(FeneconProEss.ChannelId.BATTERY_POWER, new SignedWordElement(112)), // m(new BitsWordElement(113, this) // .bit(0, FeneconProEss.ChannelId.STATE_0) // @@ -175,18 +177,12 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { .bit(6, FeneconProEss.ChannelId.STATE_6)), // m(FeneconProEss.ChannelId.PCS_OPERATION_STATE, new UnsignedWordElement(114)), // new DummyRegisterElement(115, 117), // - m(FeneconProEss.ChannelId.CURRENT_L1, new SignedWordElement(118), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconProEss.ChannelId.CURRENT_L2, new SignedWordElement(119), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconProEss.ChannelId.CURRENT_L3, new SignedWordElement(120), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconProEss.ChannelId.VOLTAGE_L1, new UnsignedWordElement(121), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconProEss.ChannelId.VOLTAGE_L2, new UnsignedWordElement(122), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(FeneconProEss.ChannelId.VOLTAGE_L3, new UnsignedWordElement(123), - ElementToChannelConverter.SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.CURRENT_L1, new SignedWordElement(118), SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.CURRENT_L2, new SignedWordElement(119), SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.CURRENT_L3, new SignedWordElement(120), SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.VOLTAGE_L1, new UnsignedWordElement(121), SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.VOLTAGE_L2, new UnsignedWordElement(122), SCALE_FACTOR_2), // + m(FeneconProEss.ChannelId.VOLTAGE_L3, new UnsignedWordElement(123), SCALE_FACTOR_2), // m(AsymmetricEss.ChannelId.ACTIVE_POWER_L1, new SignedWordElement(124)), // m(AsymmetricEss.ChannelId.ACTIVE_POWER_L2, new SignedWordElement(125)), // m(AsymmetricEss.ChannelId.ACTIVE_POWER_L3, new SignedWordElement(126)), // @@ -194,16 +190,12 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(AsymmetricEss.ChannelId.REACTIVE_POWER_L2, new SignedWordElement(128)), // m(AsymmetricEss.ChannelId.REACTIVE_POWER_L3, new SignedWordElement(129)), // new DummyRegisterElement(130), // - m(FeneconProEss.ChannelId.FREQUENCY_L1, new UnsignedWordElement(131), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(FeneconProEss.ChannelId.FREQUENCY_L2, new UnsignedWordElement(132), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(FeneconProEss.ChannelId.FREQUENCY_L3, new UnsignedWordElement(133), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(FeneconProEss.ChannelId.FREQUENCY_L1, new UnsignedWordElement(131), SCALE_FACTOR_1), // + m(FeneconProEss.ChannelId.FREQUENCY_L2, new UnsignedWordElement(132), SCALE_FACTOR_1), // + m(FeneconProEss.ChannelId.FREQUENCY_L3, new UnsignedWordElement(133), SCALE_FACTOR_1), // m(FeneconProEss.ChannelId.SINGLE_PHASE_ALLOWED_APPARENT, new UnsignedWordElement(134)), // new DummyRegisterElement(135, 140), // - m(ManagedSymmetricEss.ChannelId.ALLOWED_CHARGE_POWER, new UnsignedWordElement(141), - ElementToChannelConverter.INVERT), // + m(ManagedSymmetricEss.ChannelId.ALLOWED_CHARGE_POWER, new UnsignedWordElement(141), INVERT), // m(ManagedSymmetricEss.ChannelId.ALLOWED_DISCHARGE_POWER, new UnsignedWordElement(142)), // new DummyRegisterElement(143, 149)), // new FC3ReadRegistersTask(150, Priority.LOW, // diff --git a/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/pvmeter/FeneconProPvMeter.java b/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/pvmeter/FeneconProPvMeter.java index 804e17f915f..4a23229351c 100644 --- a/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/pvmeter/FeneconProPvMeter.java +++ b/io.openems.edge.fenecon.pro/src/io/openems/edge/fenecon/pro/pvmeter/FeneconProPvMeter.java @@ -1,5 +1,8 @@ package io.openems.edge.fenecon.pro.pvmeter; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SUBTRACT; + import java.util.function.Consumer; import org.osgi.service.cm.ConfigurationAdmin; @@ -18,8 +21,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; -import io.openems.edge.bridge.modbus.api.ElementToChannelOffsetConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -61,11 +62,6 @@ public class FeneconProPvMeter extends AbstractOpenemsModbusComponent @Reference protected ConfigurationAdmin cm; - /** - * Subtracts 10.000 between Element and Channel. - */ - public static final ElementToChannelConverter MINUS_10000_CONVERTER = new ElementToChannelOffsetConverter(-10000); - public FeneconProPvMeter() { super(// OpenemsComponent.ChannelId.values(), // @@ -117,31 +113,25 @@ public String getModbusBridgeId() { protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC3ReadRegistersTask(121, Priority.LOW, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(121), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(122), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(123), - ElementToChannelConverter.SCALE_FACTOR_2)), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(121), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(122), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(123), SCALE_FACTOR_2)), // new FC3ReadRegistersTask(2035, Priority.LOW, // // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L1, new UnsignedDoublewordElement(2035), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // new DummyRegisterElement(2037, 2065), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new UnsignedWordElement(2066), - MINUS_10000_CONVERTER)), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new UnsignedWordElement(2066), SUBTRACT(10000))), // new FC3ReadRegistersTask(2135, Priority.LOW, // // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L2, new UnsignedDoublewordElement(2135), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // new DummyRegisterElement(2137, 2165), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new UnsignedWordElement(2166), - MINUS_10000_CONVERTER)), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new UnsignedWordElement(2166), SUBTRACT(10000))), // new FC3ReadRegistersTask(2235, Priority.LOW, // // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L3, new UnsignedDoublewordElement(2235), - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // new DummyRegisterElement(2237, 2265), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new UnsignedWordElement(2266), - MINUS_10000_CONVERTER))// + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new UnsignedWordElement(2266), SUBTRACT(10000)))// ); } diff --git a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/charger/AbstractGoodWeEtCharger.java b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/charger/AbstractGoodWeEtCharger.java index ff5c6dda80b..a1199930f90 100644 --- a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/charger/AbstractGoodWeEtCharger.java +++ b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/charger/AbstractGoodWeEtCharger.java @@ -1,12 +1,13 @@ package io.openems.edge.goodwe.charger; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; + import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; import io.openems.common.channel.AccessMode; import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.UnsignedDoublewordElement; @@ -46,9 +47,8 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC3ReadRegistersTask(startAddress, Priority.HIGH, // m(EssDcCharger.ChannelId.VOLTAGE, new UnsignedWordElement(startAddress), // - ElementToChannelConverter.SCALE_FACTOR_2), // - m(EssDcCharger.ChannelId.CURRENT, new UnsignedWordElement(startAddress + 1), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), // + m(EssDcCharger.ChannelId.CURRENT, new UnsignedWordElement(startAddress + 1), SCALE_FACTOR_2), m(EssDcCharger.ChannelId.ACTUAL_POWER, new UnsignedDoublewordElement(startAddress + 2)))); } diff --git a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/common/AbstractGoodWe.java b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/common/AbstractGoodWe.java index e26047e3218..24140dd8cc8 100644 --- a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/common/AbstractGoodWe.java +++ b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/common/AbstractGoodWe.java @@ -1,5 +1,10 @@ package io.openems.edge.goodwe.common; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; + import java.util.HashSet; import java.util.Set; @@ -158,15 +163,11 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(35111, Priority.LOW, // // Registers for PV1 and PV2 (35103 to 35110) are read via DC-Charger // implementation - m(GoodWe.ChannelId.V_PV3, new UnsignedWordElement(35111), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.I_PV3, new UnsignedWordElement(35112), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V_PV3, new UnsignedWordElement(35111), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.I_PV3, new UnsignedWordElement(35112), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.P_PV3, new UnsignedDoublewordElement(35113)), // - m(GoodWe.ChannelId.V_PV4, new UnsignedWordElement(35115), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.I_PV4, new UnsignedWordElement(35116), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V_PV4, new UnsignedWordElement(35115), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.I_PV4, new UnsignedWordElement(35116), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.P_PV4, new UnsignedDoublewordElement(35117)), // m(GoodWe.ChannelId.PV_MODE, new UnsignedDoublewordElement(35119)), // // Registers for Grid Smart-Meter (35121 to 35135) are read via GridMeter @@ -191,11 +192,11 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(35137, Priority.LOW, // m(GoodWe.ChannelId.TOTAL_INV_POWER, new SignedDoublewordElement(35137)), // m(GoodWe.ChannelId.AC_ACTIVE_POWER, new SignedDoublewordElement(35139), // - ElementToChannelConverter.INVERT), // + INVERT), // m(this.reactivePowerChannelId, new SignedDoublewordElement(35141), // - ElementToChannelConverter.INVERT), // + INVERT), // m(GoodWe.ChannelId.AC_APPARENT_POWER, new SignedDoublewordElement(35143), // - ElementToChannelConverter.INVERT), // + INVERT), // new DummyRegisterElement(35145, 35147), // m(GoodWe.ChannelId.LOAD_MODE_R, new UnsignedWordElement(35148)), // new DummyRegisterElement(35149, 35153), // @@ -208,25 +209,17 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.P_LOAD_T, new SignedDoublewordElement(35167)), // m(GoodWe.ChannelId.TOTAL_BACK_UP_LOAD_POWER, new SignedDoublewordElement(35169)), // m(GoodWe.ChannelId.TOTAL_LOAD_POWER, new SignedDoublewordElement(35171)), // - m(GoodWe.ChannelId.UPS_LOAD_PERCENT, new UnsignedWordElement(35173), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.AIR_TEMPERATURE, new SignedWordElement(35174), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.MODULE_TEMPERATURE, new SignedWordElement(35175), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.RADIATOR_TEMPERATURE, new SignedWordElement(35176), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.UPS_LOAD_PERCENT, new UnsignedWordElement(35173), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.AIR_TEMPERATURE, new SignedWordElement(35174), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.MODULE_TEMPERATURE, new SignedWordElement(35175), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.RADIATOR_TEMPERATURE, new SignedWordElement(35176), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.FUNCTION_BIT_VALUE, new UnsignedWordElement(35177)), // - m(GoodWe.ChannelId.BUS_VOLTAGE, new UnsignedWordElement(35178), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.NBUS_VOLTAGE, new UnsignedWordElement(35179), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), // + m(GoodWe.ChannelId.BUS_VOLTAGE, new UnsignedWordElement(35178), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.NBUS_VOLTAGE, new UnsignedWordElement(35179), SCALE_FACTOR_MINUS_1)), // new FC3ReadRegistersTask(35180, Priority.HIGH, // - m(GoodWe.ChannelId.V_BATTERY1, new UnsignedWordElement(35180), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.I_BATTERY1, new SignedWordElement(35181), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V_BATTERY1, new UnsignedWordElement(35180), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.I_BATTERY1, new SignedWordElement(35181), SCALE_FACTOR_MINUS_1), // // Required for calculation of ActivePower; wrongly documented in official // Modbus protocol v1.9 as being Unsigned. m(GoodWe.ChannelId.P_BATTERY1, new SignedDoublewordElement(35182)), @@ -274,30 +267,20 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // // The total PV production energy from installation - m(GoodWe.ChannelId.PV_E_TOTAL, new UnsignedDoublewordElement(35191), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.PV_E_DAY, new UnsignedDoublewordElement(35193), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_E_TOTAL, new UnsignedDoublewordElement(35191), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_E_DAY, new UnsignedDoublewordElement(35193), SCALE_FACTOR_MINUS_1), // new DummyRegisterElement(35195, 35196), // m(GoodWe.ChannelId.H_TOTAL, new UnsignedDoublewordElement(35197)), // - m(GoodWe.ChannelId.E_DAY_SELL, new UnsignedWordElement(35199), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_BUY, new UnsignedDoublewordElement(35200), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_DAY_BUY, new UnsignedWordElement(35202), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_LOAD, new UnsignedDoublewordElement(35203), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_LOAD_DAY, new UnsignedWordElement(35205), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DAY_SELL, new UnsignedWordElement(35199), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_BUY, new UnsignedDoublewordElement(35200), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DAY_BUY, new UnsignedWordElement(35202), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_LOAD, new UnsignedDoublewordElement(35203), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_LOAD_DAY, new UnsignedWordElement(35205), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.E_BATTERY_CHARGE, new UnsignedDoublewordElement(35206), // - ElementToChannelConverter.SCALE_FACTOR_2), // - m(GoodWe.ChannelId.E_CHARGE_DAY, new UnsignedWordElement(35208), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_BATTERY_DISCHARGE, new UnsignedDoublewordElement(35209), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(GoodWe.ChannelId.E_DISCHARGE_DAY, new UnsignedWordElement(35211), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_2), // + m(GoodWe.ChannelId.E_CHARGE_DAY, new UnsignedWordElement(35208), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_BATTERY_DISCHARGE, new UnsignedDoublewordElement(35209), SCALE_FACTOR_2), // + m(GoodWe.ChannelId.E_DISCHARGE_DAY, new UnsignedWordElement(35211), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.BATTERY_STRINGS, new UnsignedWordElement(35212)), // m(GoodWe.ChannelId.CPLD_WARNING_CODE, new UnsignedWordElement(35213)), // new DummyRegisterElement(35214, 35217), // @@ -390,21 +373,21 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // new DummyRegisterElement(35260, 35267), // m(GoodWe.ChannelId.MAX_GRID_FREQ_WITHIN_1_MINUTE, new UnsignedWordElement(35268), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.MIN_GRID_FREQ_WITHIN_1_MINUTE, new UnsignedWordElement(35269), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.MAX_GRID_VOLTAGE_WITHIN_1_MINUTE_R, new UnsignedWordElement(35270), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MIN_GRID_VOLTAGE_WITHIN_1_MINUTE_R, new UnsignedWordElement(35271), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MAX_GRID_VOLTAGE_WITHIN_1_MINUTE_S, new UnsignedWordElement(35272), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MIN_GRID_VOLTAGE_WITHIN_1_MINUTE_S, new UnsignedWordElement(35273), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MAX_GRID_VOLTAGE_WITHIN_1_MINUTE_T, new UnsignedWordElement(35274), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MIN_GRID_VOLTAGE_WITHIN_1_MINUTE_T, new UnsignedWordElement(35275), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MAX_BACKUP_POWER_WITHIN_1_MINUTE_R, new UnsignedDoublewordElement(35276)), // m(GoodWe.ChannelId.MAX_BACKUP_POWER_WITHIN_1_MINUTE_S, new UnsignedDoublewordElement(35278)), // m(GoodWe.ChannelId.MAX_BACKUP_POWER_WITHIN_1_MINUTE_T, new UnsignedDoublewordElement(35280)), // @@ -434,8 +417,7 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { ), // m(GoodWe.ChannelId.BATTERY_TYPE_INDEX, new UnsignedWordElement(37001)), // m(GoodWe.ChannelId.BMS_STATUS, new UnsignedWordElement(37002)), // - m(GoodWe.ChannelId.BMS_PACK_TEMPERATURE, new UnsignedWordElement(37003), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.BMS_PACK_TEMPERATURE, new UnsignedWordElement(37003), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.BMS_CHARGE_IMAX, new UnsignedWordElement(37004)), // m(GoodWe.ChannelId.BMS_DISCHARGE_IMAX, new UnsignedWordElement(37005)), // m(new BitsWordElement(37006, this) // @@ -485,9 +467,9 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.MAXIMUM_CELL_VOLTAGE_ID, new UnsignedWordElement(37018)), // m(GoodWe.ChannelId.MINIMUM_CELL_VOLTAGE_ID, new UnsignedWordElement(37019)), // m(GoodWe.ChannelId.MAXIMUM_CELL_TEMPERATURE, new UnsignedWordElement(37020), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MINIMUM_CELL_TEMPERATURE, new UnsignedWordElement(37021), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MAXIMUM_CELL_VOLTAGE, new UnsignedWordElement(37022)), // m(GoodWe.ChannelId.MINIMUM_CELL_VOLTAGE, new UnsignedWordElement(37023)), // m(GoodWe.ChannelId.PASS_INFORMATION_1, new UnsignedWordElement(37024)), // @@ -534,31 +516,21 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(45222, Priority.LOW, // // to read or write the accumulated energy battery discharged, of the day Not // from BMS - m(GoodWe.ChannelId.PV_E_TOTAL_2, new UnsignedDoublewordElement(45222), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.PV_E_DAY_2, new UnsignedDoublewordElement(45224), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_SELL_2, new UnsignedDoublewordElement(45226), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_E_TOTAL_2, new UnsignedDoublewordElement(45222), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_E_DAY_2, new UnsignedDoublewordElement(45224), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_SELL_2, new UnsignedDoublewordElement(45226), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.H_TOTAL_2, new UnsignedDoublewordElement(45228)), // - m(GoodWe.ChannelId.E_DAY_SELL_2, new UnsignedWordElement(45230), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_BUY_2, new UnsignedDoublewordElement(45231), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_DAY_BUY_2, new UnsignedWordElement(45233), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_LOAD_2, new UnsignedDoublewordElement(45234), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_LOAD_DAY_2, new UnsignedWordElement(45236), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DAY_SELL_2, new UnsignedWordElement(45230), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_BUY_2, new UnsignedDoublewordElement(45231), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DAY_BUY_2, new UnsignedWordElement(45233), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_LOAD_2, new UnsignedDoublewordElement(45234), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_LOAD_DAY_2, new UnsignedWordElement(45236), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.E_BATTERY_CHARGE_2, new UnsignedDoublewordElement(45237), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_CHARGE_DAY_2, new UnsignedWordElement(45239), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_CHARGE_DAY_2, new UnsignedWordElement(45239), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.E_BATTERY_DISCHARGE_2, new UnsignedDoublewordElement(45240), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_DISCHARGE_DAY_2, new UnsignedWordElement(45242), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DISCHARGE_DAY_2, new UnsignedWordElement(45242), SCALE_FACTOR_MINUS_1), // new DummyRegisterElement(45243), // // to set safety code for inverter or read the preset safety code for the // inverter @@ -567,8 +539,7 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.LVRT_HVRT, new UnsignedWordElement(45246))), // new FC3ReadRegistersTask(45250, Priority.LOW, // - m(GoodWe.ChannelId.PV_START_VOLTAGE, new UnsignedWordElement(45250), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_START_VOLTAGE, new UnsignedWordElement(45250), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.MPPT_FOR_SHADOW_ENABLE, new UnsignedWordElement(45251)), // m(GoodWe.ChannelId.BACK_UP_ENABLE, new UnsignedWordElement(45252)), // m(GoodWe.ChannelId.AUTO_START_BACKUP, new UnsignedWordElement(45253)), // @@ -604,63 +575,48 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(45352, Priority.LOW, // m(GoodWe.ChannelId.BMS_CHARGE_MAX_VOLTAGE, new UnsignedWordElement(45352), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [500*N,600*N] + SCALE_FACTOR_MINUS_1), // [500*N,600*N] m(GoodWe.ChannelId.BMS_CHARGE_MAX_CURRENT, new UnsignedWordElement(45353), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [0,1000] + SCALE_FACTOR_MINUS_1), // [0,1000] m(GoodWe.ChannelId.BMS_DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(45354), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [400*N,480*N] + SCALE_FACTOR_MINUS_1), // [400*N,480*N] m(GoodWe.ChannelId.BMS_DISCHARGE_MAX_CURRENT, new UnsignedWordElement(45355), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [0,1000] + SCALE_FACTOR_MINUS_1), // [0,1000] m(GoodWe.ChannelId.BMS_SOC_UNDER_MIN, new UnsignedWordElement(45356)), // [0,100] m(GoodWe.ChannelId.BMS_OFFLINE_DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(45357), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // ), // + SCALE_FACTOR_MINUS_1), // ), // m(GoodWe.ChannelId.BMS_OFFLINE_SOC_UNDER_MIN, new UnsignedWordElement(45358))), // // Safety new FC3ReadRegistersTask(45400, Priority.LOW, // - m(GoodWe.ChannelId.GRID_VOLT_HIGH_S1, new UnsignedWordElement(45400), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH_S1, new UnsignedWordElement(45400), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_HIGH_S1_TIME, new UnsignedWordElement(45401)), // - m(GoodWe.ChannelId.GRID_VOLT_LOW_S1, new UnsignedWordElement(45402), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW_S1, new UnsignedWordElement(45402), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_LOW_S1_TIME, new UnsignedWordElement(45403)), // - m(GoodWe.ChannelId.GRID_VOLT_HIGH_S2, new UnsignedWordElement(45404), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH_S2, new UnsignedWordElement(45404), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_HIGH_S2_TIME, new UnsignedWordElement(45405)), // - m(GoodWe.ChannelId.GRID_VOLT_LOW_S2, new UnsignedWordElement(45406), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW_S2, new UnsignedWordElement(45406), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_LOW_S2_TIME, new UnsignedWordElement(45407)), // - m(GoodWe.ChannelId.GRID_VOLT_QUALITY, new UnsignedWordElement(45408), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_FREQ_HIGH_S1, new UnsignedWordElement(45409), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_VOLT_QUALITY, new UnsignedWordElement(45408), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_FREQ_HIGH_S1, new UnsignedWordElement(45409), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_HIGH_S1_TIME, new UnsignedWordElement(45410)), // - m(GoodWe.ChannelId.GRID_FREQ_LOW_S1, new UnsignedWordElement(45411), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_LOW_S1, new UnsignedWordElement(45411), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_LOW_S1_TIME, new UnsignedWordElement(45412)), // - m(GoodWe.ChannelId.GRID_FREQ_HIGH_S2, new UnsignedWordElement(45413), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_HIGH_S2, new UnsignedWordElement(45413), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_HIGH_S2_TIME, new UnsignedWordElement(45414)), // - m(GoodWe.ChannelId.GRID_FREQ_LOW_S2, new UnsignedWordElement(45415), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_LOW_S2, new UnsignedWordElement(45415), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_LOW_S2_TIME, new UnsignedWordElement(45416)), // - m(GoodWe.ChannelId.GRID_VOLT_HIGH, new UnsignedWordElement(45417), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_VOLT_LOW, new UnsignedWordElement(45418), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_FREQ_HIGH, new UnsignedWordElement(45419), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.GRID_FREQ_LOW, new UnsignedWordElement(45420), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH, new UnsignedWordElement(45417), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW, new UnsignedWordElement(45418), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_FREQ_HIGH, new UnsignedWordElement(45419), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_LOW, new UnsignedWordElement(45420), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_RECOVER_TIME, new UnsignedWordElement(45421)), // m(GoodWe.ChannelId.GRID_VOLT_RECOVER_HIGH, new UnsignedWordElement(45422), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_VOLT_RECOVER_LOW, new UnsignedWordElement(45423), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_RECOVER_LOW, new UnsignedWordElement(45423), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_FREQ_RECOVER_HIGH, new UnsignedWordElement(45424), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.GRID_FREQ_RECOVER_LOW, new UnsignedWordElement(45425), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_RECOVER_LOW, new UnsignedWordElement(45425), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_VOLT_RECOVER_TIME, new UnsignedWordElement(45426)), // m(GoodWe.ChannelId.GRID_FREQ_RECOVER_TIME, new UnsignedWordElement(45427)), // m(GoodWe.ChannelId.POWER_RATE_LIMIT_GENERATE, new UnsignedWordElement(45428)), // @@ -671,11 +627,11 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(45428, Priority.LOW, // m(GoodWe.ChannelId.POWER_RATE_LIMIT_GENERATE, new UnsignedWordElement(45428), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.POWER_RATE_LIMIT_RECONNECT, new UnsignedWordElement(45429), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.POWER_RATE_LIMIT_REDUCTION, new UnsignedWordElement(45430), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_PROTECT, new UnsignedWordElement(45431))), // // Cos Phi Curve @@ -683,17 +639,13 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.POWER_SLOPE_ENABLE, new UnsignedWordElement(45432)), // m(GoodWe.ChannelId.ENABLE_CURVE_PU, new UnsignedWordElement(45433)), // m(GoodWe.ChannelId.A_POINT_POWER, new SignedWordElement(45434)), // - m(GoodWe.ChannelId.A_POINT_COS_PHI, new SignedWordElement(45435), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.A_POINT_COS_PHI, new SignedWordElement(45435), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.B_POINT_POWER, new SignedWordElement(45436)), // - m(GoodWe.ChannelId.B_POINT_COS_PHI, new SignedWordElement(45437), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.B_POINT_COS_PHI, new SignedWordElement(45437), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.C_POINT_POWER, new SignedWordElement(45438)), // m(GoodWe.ChannelId.C_POINT_COS_PHI, new SignedWordElement(45439)), - m(GoodWe.ChannelId.LOCK_IN_VOLTAGE, new UnsignedWordElement(45440), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.LOCK_OUT_VOLTAGE, new UnsignedWordElement(45441), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LOCK_IN_VOLTAGE, new UnsignedWordElement(45440), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LOCK_OUT_VOLTAGE, new UnsignedWordElement(45441), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.LOCK_OUT_POWER, new SignedWordElement(45442)), // // Power and frequency curve @@ -701,28 +653,20 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { .bit(0, GoodWe.ChannelId.POWER_FREQUENCY_ENABLED)// .bit(1, GoodWe.ChannelId.POWER_FREQUENCY_RESPONSE_MODE)// ), // - m(GoodWe.ChannelId.FFROZEN_DCH, new UnsignedWordElement(45444), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.FFROZEN_CH, new UnsignedWordElement(45445), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.FSTOP_DCH, new UnsignedWordElement(45446), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.FSTOP_CH, new UnsignedWordElement(45447), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FFROZEN_DCH, new UnsignedWordElement(45444), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FFROZEN_CH, new UnsignedWordElement(45445), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FSTOP_DCH, new UnsignedWordElement(45446), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FSTOP_CH, new UnsignedWordElement(45447), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.OF_RECOVERY_WAITING_TIME, new UnsignedWordElement(45448), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.RECOVERY_FREQURNCY1, new UnsignedWordElement(45449), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.RECOVERY_FREQUENCY2, new UnsignedWordElement(45450), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.RECOVERY_FREQURNCY1, new UnsignedWordElement(45449), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.RECOVERY_FREQUENCY2, new UnsignedWordElement(45450), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.OF_RECOVERY_SLOPE, new UnsignedWordElement(45451), // new ChannelMetaInfoReadAndWrite(45451, 45452)), // m(GoodWe.ChannelId.CFP_SETTINGS, new UnsignedWordElement(45452), // new ChannelMetaInfoReadAndWrite(45452, 45451)), // - m(GoodWe.ChannelId.CFP_OF_SLOPE_PERCENT, new UnsignedWordElement(45453), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.CFP_UF_SLOPE_PERCENT, new UnsignedWordElement(45454), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.CFP_OF_SLOPE_PERCENT, new UnsignedWordElement(45453), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.CFP_UF_SLOPE_PERCENT, new UnsignedWordElement(45454), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.CFP_OF_RECOVER_POWER_PERCENT, new UnsignedWordElement(45455))), // // QU Curve @@ -730,17 +674,13 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.QU_CURVE, new UnsignedWordElement(45456)), // m(GoodWe.ChannelId.LOCK_IN_POWER_QU, new SignedWordElement(45457)), // m(GoodWe.ChannelId.LOCK_OUT_POWER_QU, new SignedWordElement(45458)), // - m(GoodWe.ChannelId.V1_VOLTAGE, new UnsignedWordElement(45459), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // ), // + m(GoodWe.ChannelId.V1_VOLTAGE, new UnsignedWordElement(45459), SCALE_FACTOR_MINUS_1), // ), // m(GoodWe.ChannelId.V1_VALUE, new SignedWordElement(45460)), // - m(GoodWe.ChannelId.V2_VOLTAGE, new UnsignedWordElement(45461), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V2_VOLTAGE, new UnsignedWordElement(45461), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V2_VALUE, new SignedWordElement(45462)), // - m(GoodWe.ChannelId.V3_VOLTAGE, new UnsignedWordElement(45463), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V3_VOLTAGE, new UnsignedWordElement(45463), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V3_VALUE, new SignedWordElement(45464)), // - m(GoodWe.ChannelId.V4_VOLTAGE, new UnsignedWordElement(45465), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V4_VOLTAGE, new UnsignedWordElement(45465), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V4_VALUE, new SignedWordElement(45466)), // m(GoodWe.ChannelId.K_VALUE, new UnsignedWordElement(45467)), // m(GoodWe.ChannelId.TIME_CONSTANT, new UnsignedWordElement(45468)), // @@ -750,30 +690,19 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(45472, Priority.LOW, // m(GoodWe.ChannelId.PU_CURVE, new UnsignedWordElement(45472)), // m(GoodWe.ChannelId.POWER_CHANGE_RATE, new UnsignedWordElement(45473)), // - m(GoodWe.ChannelId.V1_VOLTAGE_PU, new UnsignedWordElement(45474), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V1_VALUE_PU, new SignedWordElement(45475), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V2_VOLTAGE_PU, new UnsignedWordElement(45476), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V2_VALUE_PU, new SignedWordElement(45477), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V3_VOLTAGE_PU, new UnsignedWordElement(45478), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V3_VALUE_PU, new SignedWordElement(45479), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V4_VOLTAGE_PU, new UnsignedWordElement(45480), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.V4_VALUE_PU, new SignedWordElement(45481), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V1_VOLTAGE_PU, new UnsignedWordElement(45474), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V1_VALUE_PU, new SignedWordElement(45475), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V2_VOLTAGE_PU, new UnsignedWordElement(45476), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V2_VALUE_PU, new SignedWordElement(45477), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V3_VOLTAGE_PU, new UnsignedWordElement(45478), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V3_VALUE_PU, new SignedWordElement(45479), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V4_VOLTAGE_PU, new UnsignedWordElement(45480), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V4_VALUE_PU, new SignedWordElement(45481), SCALE_FACTOR_MINUS_1), // // 80=Pf 0.8, 20= -0.8Pf - m(GoodWe.ChannelId.FIXED_POWER_FACTOR, new UnsignedWordElement(45482), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FIXED_POWER_FACTOR, new UnsignedWordElement(45482), SCALE_FACTOR_MINUS_2), // // Set the percentage of rated power of the inverter - m(GoodWe.ChannelId.FIXED_REACTIVE_POWER, new SignedWordElement(45483), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.FIXED_ACTIVE_POWER, new UnsignedWordElement(45484), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), // + m(GoodWe.ChannelId.FIXED_REACTIVE_POWER, new SignedWordElement(45483), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.FIXED_ACTIVE_POWER, new UnsignedWordElement(45484), SCALE_FACTOR_MINUS_1)), // new FC3ReadRegistersTask(45488, Priority.LOW, // m(GoodWe.ChannelId.AUTO_TEST_ENABLE, new UnsignedWordElement(45488)), // @@ -784,29 +713,21 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.R_PHASE_FIXED_ACTIVE_POWER, new UnsignedWordElement(45492)), // m(GoodWe.ChannelId.S_PHASE_FIXED_ACTIVE_POWER, new UnsignedWordElement(45493)), // m(GoodWe.ChannelId.T_PHASE_FIXED_ACTIVE_POWER, new UnsignedWordElement(45494)), // - m(GoodWe.ChannelId.GRID_VOLT_HIGH_S3, new UnsignedWordElement(45495), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH_S3, new UnsignedWordElement(45495), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_HIGH_S3_TIME, new UnsignedWordElement(45496)), // - m(GoodWe.ChannelId.GRID_VOLT_LOW_S3, new UnsignedWordElement(45497), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW_S3, new UnsignedWordElement(45497), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_LOW_S3_TIME, new UnsignedWordElement(45498)), // m(GoodWe.ChannelId.ZVRT_CONFIG, new UnsignedWordElement(45499)), // - m(GoodWe.ChannelId.LVRT_START_VOLT, new UnsignedWordElement(45500), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.LVRT_END_VOLT, new UnsignedWordElement(45501), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LVRT_START_VOLT, new UnsignedWordElement(45500), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LVRT_END_VOLT, new UnsignedWordElement(45501), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.LVRT_START_TRIP_TIME, new UnsignedWordElement(45502)), // m(GoodWe.ChannelId.LVRT_END_TRIP_TIME, new UnsignedWordElement(45503)), // - m(GoodWe.ChannelId.LVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45504), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.HVRT_START_VOLT, new UnsignedWordElement(45505), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.HVRT_END_VOLT, new UnsignedWordElement(45506), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45504), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.HVRT_START_VOLT, new UnsignedWordElement(45505), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.HVRT_END_VOLT, new UnsignedWordElement(45506), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.HVRT_START_TRIP_TIME, new UnsignedWordElement(45507)), // m(GoodWe.ChannelId.HVRT_END_TRIP_TIME, new UnsignedWordElement(45508)), // - m(GoodWe.ChannelId.HVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45509), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)// + m(GoodWe.ChannelId.HVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45509), SCALE_FACTOR_MINUS_1)// ), // // Additional settings for PF/PU/UF @@ -819,31 +740,27 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.D_POINT_COS_PHI, new SignedWordElement(45514)), // // Additional settings for UF Curve m(GoodWe.ChannelId.UF_RECOVERY_WAITING_TIME, new UnsignedWordElement(45515), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.UF_RECOVER_SLOPE, new UnsignedWordElement(45516)), // m(GoodWe.ChannelId.CFP_UF_RECOVER_POWER_PERCENT, new UnsignedWordElement(45517)), // - m(GoodWe.ChannelId.POWER_CHARGE_LIMIT, new UnsignedWordElement(45518), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.POWER_CHARGE_LIMIT, new UnsignedWordElement(45518), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.POWER_CHARGE_LIMIT_RECONNECT, new UnsignedWordElement(45519), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.C_EXT_UF_CHARGE_STOP, new UnsignedWordElement(45520), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.C_EXT_UF_CHARGE_STOP, new UnsignedWordElement(45520), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.C_EXT_OF_DISCHARGE_STOP, new UnsignedWordElement(45521), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.C_EXT_TWOSSTEPF_FLG, new UnsignedWordElement(45522))// ), // new FC3ReadRegistersTask(47500, Priority.LOW, // m(GoodWe.ChannelId.STOP_SOC_PROTECT, new UnsignedWordElement(47500)), // - m(GoodWe.ChannelId.BMS_FLOAT_VOLT, new UnsignedWordElement(47501), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.BMS_FLOAT_VOLT, new UnsignedWordElement(47501), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.BMS_FLOAT_CURRENT, new UnsignedWordElement(47502)), // m(GoodWe.ChannelId.BMS_FLOAT_TIME, new UnsignedWordElement(47503)), // m(GoodWe.ChannelId.BMS_TYPE_INDEX_ARM, new UnsignedWordElement(47504)), // m(GoodWe.ChannelId.MANUFACTURE_CODE, new UnsignedWordElement(47505)), // m(GoodWe.ChannelId.DC_VOLT_OUTPUT, new UnsignedWordElement(47506)), // - m(GoodWe.ChannelId.BMS_AVG_CHG_VOLT, new UnsignedWordElement(47507), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.BMS_AVG_CHG_VOLT, new UnsignedWordElement(47507), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.BMS_AVG_CHG_HOURS, new UnsignedWordElement(47508)), // m(GoodWe.ChannelId.FEED_POWER_ENABLE, new UnsignedWordElement(47509)), // m(GoodWe.ChannelId.FEED_POWER_PARA_SET, new UnsignedWordElement(47510)), // @@ -879,51 +796,41 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.RESTART, new UnsignedWordElement(45220)), // // inverter will total shutdown and wake up again m(GoodWe.ChannelId.RESET_SPS, new UnsignedWordElement(45221)), // - m(GoodWe.ChannelId.PV_E_TOTAL_2, new UnsignedDoublewordElement(45222), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_E_TOTAL_2, new UnsignedDoublewordElement(45222), SCALE_FACTOR_MINUS_1), // // to read or write the total PV production energy of the day - m(GoodWe.ChannelId.PV_E_DAY_2, new UnsignedDoublewordElement(45224), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_E_DAY_2, new UnsignedDoublewordElement(45224), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated exporting energy to grid from the // installation date - m(GoodWe.ChannelId.E_TOTAL_SELL_2, new UnsignedDoublewordElement(45226), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_SELL_2, new UnsignedDoublewordElement(45226), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated operation hours from the installation date m(GoodWe.ChannelId.H_TOTAL_2, new UnsignedDoublewordElement(45228)), // // to read or write the accumulated exporting energy to grid of the day - m(GoodWe.ChannelId.E_DAY_SELL_2, new UnsignedWordElement(45230), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DAY_SELL_2, new UnsignedWordElement(45230), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated energy imported from grid from the // installation date - m(GoodWe.ChannelId.E_TOTAL_BUY_2, new UnsignedDoublewordElement(45231), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_BUY_2, new UnsignedDoublewordElement(45231), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated energy imported from grid of the day - m(GoodWe.ChannelId.E_DAY_BUY_2, new UnsignedWordElement(45233), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DAY_BUY_2, new UnsignedWordElement(45233), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated load consumption energy from the // installation date, not include backup load. - m(GoodWe.ChannelId.E_TOTAL_LOAD_2, new UnsignedDoublewordElement(45234), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_LOAD_2, new UnsignedDoublewordElement(45234), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated load consumption energy of the day Not // include backup loads - m(GoodWe.ChannelId.E_LOAD_DAY_2, new UnsignedWordElement(45236), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_LOAD_DAY_2, new UnsignedWordElement(45236), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated energy charged to battery from the // installation date Not from BMS m(GoodWe.ChannelId.E_BATTERY_CHARGE_2, new UnsignedDoublewordElement(45237), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // // to read or write the accumulated energy charged to battery of the day Not // from BMS - m(GoodWe.ChannelId.E_CHARGE_DAY_2, new UnsignedWordElement(45239), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_CHARGE_DAY_2, new UnsignedWordElement(45239), SCALE_FACTOR_MINUS_1), // // to read or write the accumulated energy battery discharged, from the // installation date Not from BMS m(GoodWe.ChannelId.E_BATTERY_DISCHARGE_2, new UnsignedDoublewordElement(45240), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // // to read or write the accumulated energy battery discharged, of the day Not // from BMS - m(GoodWe.ChannelId.E_DISCHARGE_DAY_2, new UnsignedWordElement(45242), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_DISCHARGE_DAY_2, new UnsignedWordElement(45242), SCALE_FACTOR_MINUS_1), // new DummyRegisterElement(45243), // // to set safety code for inverter or read the preset safety code for the // inverter @@ -937,8 +844,7 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC16WriteRegistersTask(45250, // // to write or read the start up PV voltage of the inverter.Please refer to the // user manual - m(GoodWe.ChannelId.PV_START_VOLTAGE, new UnsignedWordElement(45250), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.PV_START_VOLTAGE, new UnsignedWordElement(45250), SCALE_FACTOR_MINUS_1), // // as default is deactivated, set "1" to activate "Shadow Scan" function m(GoodWe.ChannelId.MPPT_FOR_SHADOW_ENABLE, new UnsignedWordElement(45251)), // // as default is deactivated, set "1" to activate "Shadow Scan" function @@ -988,74 +894,59 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { // the real charge current of the battery will exceed 25A. new FC16WriteRegistersTask(45352, // m(GoodWe.ChannelId.BMS_CHARGE_MAX_VOLTAGE, new UnsignedWordElement(45352), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [500*N,600*N] + SCALE_FACTOR_MINUS_1), // [500*N,600*N] m(GoodWe.ChannelId.BMS_CHARGE_MAX_CURRENT, new UnsignedWordElement(45353), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [0,1000] + SCALE_FACTOR_MINUS_1), // [0,1000] m(GoodWe.ChannelId.BMS_DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(45354), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [400*N,480*N] + SCALE_FACTOR_MINUS_1), // [400*N,480*N] m(GoodWe.ChannelId.BMS_DISCHARGE_MAX_CURRENT, new UnsignedWordElement(45355), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // [0,1000] + SCALE_FACTOR_MINUS_1), // [0,1000] m(GoodWe.ChannelId.BMS_SOC_UNDER_MIN, new UnsignedWordElement(45356)), // [0,100] m(GoodWe.ChannelId.BMS_OFFLINE_DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(45357), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // ), // + SCALE_FACTOR_MINUS_1), // ), // m(GoodWe.ChannelId.BMS_OFFLINE_SOC_UNDER_MIN, new UnsignedWordElement(45358))), // // Safety Parameters new FC16WriteRegistersTask(45400, // - m(GoodWe.ChannelId.GRID_VOLT_HIGH_S1, new UnsignedWordElement(45400), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH_S1, new UnsignedWordElement(45400), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_HIGH_S1_TIME, new UnsignedWordElement(45401)), // - m(GoodWe.ChannelId.GRID_VOLT_LOW_S1, new UnsignedWordElement(45402), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW_S1, new UnsignedWordElement(45402), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_LOW_S1_TIME, new UnsignedWordElement(45403)), // - m(GoodWe.ChannelId.GRID_VOLT_HIGH_S2, new UnsignedWordElement(45404), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH_S2, new UnsignedWordElement(45404), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_HIGH_S2_TIME, new UnsignedWordElement(45405)), // - m(GoodWe.ChannelId.GRID_VOLT_LOW_S2, new UnsignedWordElement(45406), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW_S2, new UnsignedWordElement(45406), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_LOW_S2_TIME, new UnsignedWordElement(45407)), // - m(GoodWe.ChannelId.GRID_VOLT_QUALITY, new UnsignedWordElement(45408), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_FREQ_HIGH_S1, new UnsignedWordElement(45409), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_VOLT_QUALITY, new UnsignedWordElement(45408), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_FREQ_HIGH_S1, new UnsignedWordElement(45409), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_HIGH_S1_TIME, new UnsignedWordElement(45410)), // - m(GoodWe.ChannelId.GRID_FREQ_LOW_S1, new UnsignedWordElement(45411), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_LOW_S1, new UnsignedWordElement(45411), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_LOW_S1_TIME, new UnsignedWordElement(45412)), // - m(GoodWe.ChannelId.GRID_FREQ_HIGH_S2, new UnsignedWordElement(45413), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_HIGH_S2, new UnsignedWordElement(45413), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_HIGH_S2_TIME, new UnsignedWordElement(45414)), // - m(GoodWe.ChannelId.GRID_FREQ_LOW_S2, new UnsignedWordElement(45415), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_LOW_S2, new UnsignedWordElement(45415), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_FREQ_LOW_S2_TIME, new UnsignedWordElement(45416)), // // Connect voltage - m(GoodWe.ChannelId.GRID_VOLT_HIGH, new UnsignedWordElement(45417), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_VOLT_LOW, new UnsignedWordElement(45418), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_FREQ_HIGH, new UnsignedWordElement(45419), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.GRID_FREQ_LOW, new UnsignedWordElement(45420), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH, new UnsignedWordElement(45417), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW, new UnsignedWordElement(45418), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_FREQ_HIGH, new UnsignedWordElement(45419), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_LOW, new UnsignedWordElement(45420), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_RECOVER_TIME, new UnsignedWordElement(45421)), // // Reconnect voltage m(GoodWe.ChannelId.GRID_VOLT_RECOVER_HIGH, new UnsignedWordElement(45422), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.GRID_VOLT_RECOVER_LOW, new UnsignedWordElement(45423), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_RECOVER_LOW, new UnsignedWordElement(45423), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_FREQ_RECOVER_HIGH, new UnsignedWordElement(45424), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.GRID_FREQ_RECOVER_LOW, new UnsignedWordElement(45425), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.GRID_FREQ_RECOVER_LOW, new UnsignedWordElement(45425), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_VOLT_RECOVER_TIME, new UnsignedWordElement(45426)), // m(GoodWe.ChannelId.GRID_FREQ_RECOVER_TIME, new UnsignedWordElement(45427)), // // Power rate limit m(GoodWe.ChannelId.POWER_RATE_LIMIT_GENERATE, new UnsignedWordElement(45428), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.POWER_RATE_LIMIT_RECONNECT, new UnsignedWordElement(45429), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.POWER_RATE_LIMIT_REDUCTION, new UnsignedWordElement(45430), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.GRID_PROTECT, new UnsignedWordElement(45431)), // m(GoodWe.ChannelId.POWER_SLOPE_ENABLE, new UnsignedWordElement(45432))), // @@ -1063,18 +954,13 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC16WriteRegistersTask(45433, // m(GoodWe.ChannelId.ENABLE_CURVE_PU, new UnsignedWordElement(45433)), // m(GoodWe.ChannelId.A_POINT_POWER, new SignedWordElement(45434)), // - m(GoodWe.ChannelId.A_POINT_COS_PHI, new SignedWordElement(45435), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.A_POINT_COS_PHI, new SignedWordElement(45435), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.B_POINT_POWER, new SignedWordElement(45436)), // - m(GoodWe.ChannelId.B_POINT_COS_PHI, new SignedWordElement(45437), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.B_POINT_COS_PHI, new SignedWordElement(45437), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.C_POINT_POWER, new SignedWordElement(45438)), // - m(GoodWe.ChannelId.C_POINT_COS_PHI, new SignedWordElement(45439), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // ), // - m(GoodWe.ChannelId.LOCK_IN_VOLTAGE, new UnsignedWordElement(45440), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.LOCK_OUT_VOLTAGE, new UnsignedWordElement(45441), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.C_POINT_COS_PHI, new SignedWordElement(45439), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.LOCK_IN_VOLTAGE, new UnsignedWordElement(45440), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LOCK_OUT_VOLTAGE, new UnsignedWordElement(45441), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.LOCK_OUT_POWER, new SignedWordElement(45442))), // // Power and frequency curve @@ -1084,44 +970,32 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { // Power and frequency curve new FC16WriteRegistersTask(45444, // - m(GoodWe.ChannelId.FFROZEN_DCH, new UnsignedWordElement(45444), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.FFROZEN_CH, new UnsignedWordElement(45445), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.FSTOP_DCH, new UnsignedWordElement(45446), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.FSTOP_CH, new UnsignedWordElement(45447), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FFROZEN_DCH, new UnsignedWordElement(45444), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FFROZEN_CH, new UnsignedWordElement(45445), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FSTOP_DCH, new UnsignedWordElement(45446), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.FSTOP_CH, new UnsignedWordElement(45447), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.RECOVERY_WAITING_TIME, new UnsignedWordElement(45448)), // - m(GoodWe.ChannelId.RECOVERY_FREQURNCY1, new UnsignedWordElement(45449), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.RECOVERY_FREQUENCY2, new UnsignedWordElement(45450), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.RECOVERY_FREQURNCY1, new UnsignedWordElement(45449), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.RECOVERY_FREQUENCY2, new UnsignedWordElement(45450), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.CFP_SETTINGS, new UnsignedWordElement(45451), // new ChannelMetaInfoReadAndWrite(45452, 45451)), // m(GoodWe.ChannelId.OF_RECOVERY_SLOPE, new UnsignedWordElement(45452), // new ChannelMetaInfoReadAndWrite(45451, 45452)), // - m(GoodWe.ChannelId.CFP_OF_SLOPE_PERCENT, new UnsignedWordElement(45453), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.CFP_UF_SLOPE_PERCENT, new UnsignedWordElement(45454), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.CFP_OF_SLOPE_PERCENT, new UnsignedWordElement(45453), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.CFP_UF_SLOPE_PERCENT, new UnsignedWordElement(45454), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.CFP_OF_RECOVER_POWER_PERCENT, new UnsignedWordElement(45455)), // // QU Curve m(GoodWe.ChannelId.QU_CURVE, new UnsignedWordElement(45456)), // m(GoodWe.ChannelId.LOCK_IN_POWER_QU, new SignedWordElement(45457)), // m(GoodWe.ChannelId.LOCK_OUT_POWER_QU, new SignedWordElement(45458)), // - m(GoodWe.ChannelId.V1_VOLTAGE, new UnsignedWordElement(45459), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // ), // + m(GoodWe.ChannelId.V1_VOLTAGE, new UnsignedWordElement(45459), SCALE_FACTOR_MINUS_1), // ), // m(GoodWe.ChannelId.V1_VALUE, new UnsignedWordElement(45460)), // - m(GoodWe.ChannelId.V2_VOLTAGE, new UnsignedWordElement(45461), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V2_VOLTAGE, new UnsignedWordElement(45461), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V2_VALUE, new UnsignedWordElement(45462)), // - m(GoodWe.ChannelId.V3_VOLTAGE, new UnsignedWordElement(45463), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V3_VOLTAGE, new UnsignedWordElement(45463), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V3_VALUE, new UnsignedWordElement(45464)), // - m(GoodWe.ChannelId.V4_VOLTAGE, new UnsignedWordElement(45465), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V4_VOLTAGE, new UnsignedWordElement(45465), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V4_VALUE, new SignedWordElement(45466)), // m(GoodWe.ChannelId.K_VALUE, new UnsignedWordElement(45467)), // m(GoodWe.ChannelId.TIME_CONSTANT, new UnsignedWordElement(45468)), // @@ -1130,19 +1004,14 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { // PU Curve new FC16WriteRegistersTask(45472, // m(GoodWe.ChannelId.PU_CURVE, new UnsignedWordElement(45472)), // - m(GoodWe.ChannelId.POWER_CHANGE_RATE, new UnsignedWordElement(45473), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.V1_VOLTAGE_PU, new UnsignedWordElement(45474), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.POWER_CHANGE_RATE, new UnsignedWordElement(45473), SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.V1_VOLTAGE_PU, new UnsignedWordElement(45474), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V1_VALUE_PU, new SignedWordElement(45475)), // - m(GoodWe.ChannelId.V2_VOLTAGE_PU, new UnsignedWordElement(45476), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V2_VOLTAGE_PU, new UnsignedWordElement(45476), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V2_VALUE_PU, new SignedWordElement(45477)), // - m(GoodWe.ChannelId.V3_VOLTAGE_PU, new UnsignedWordElement(45478), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V3_VOLTAGE_PU, new UnsignedWordElement(45478), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V3_VALUE_PU, new SignedWordElement(45479)), // - m(GoodWe.ChannelId.V4_VOLTAGE_PU, new UnsignedWordElement(45480), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.V4_VOLTAGE_PU, new UnsignedWordElement(45480), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.V4_VALUE_PU, new SignedWordElement(45481)), // // 80=Pf 0.8, 20= -0.8Pf m(GoodWe.ChannelId.FIXED_POWER_FACTOR, new UnsignedWordElement(45482)), // [0,20]||[80,100] @@ -1159,31 +1028,23 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.T_PHASE_FIXED_ACTIVE_POWER, new UnsignedWordElement(45494)), // // only for countries where it needs 3-stage grid voltage // protection, Eg. Czech Republic - m(GoodWe.ChannelId.GRID_VOLT_HIGH_S3, new UnsignedWordElement(45495), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_HIGH_S3, new UnsignedWordElement(45495), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_HIGH_S3_TIME, new UnsignedWordElement(45496)), // - m(GoodWe.ChannelId.GRID_VOLT_LOW_S3, new UnsignedWordElement(45497), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.GRID_VOLT_LOW_S3, new UnsignedWordElement(45497), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.GRID_VOLT_LOW_S3_TIME, new UnsignedWordElement(45498)), // // For ZVRT, LVRT, HVRT m(GoodWe.ChannelId.ZVRT_CONFIG, new UnsignedWordElement(45499)), // - m(GoodWe.ChannelId.LVRT_START_VOLT, new UnsignedWordElement(45500), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.LVRT_END_VOLT, new UnsignedWordElement(45501), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LVRT_START_VOLT, new UnsignedWordElement(45500), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LVRT_END_VOLT, new UnsignedWordElement(45501), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.LVRT_START_TRIP_TIME, new UnsignedWordElement(45502)), // m(GoodWe.ChannelId.LVRT_END_TRIP_TIME, new UnsignedWordElement(45503)), // - m(GoodWe.ChannelId.LVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45504), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.HVRT_START_VOLT, new UnsignedWordElement(45505), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.HVRT_END_VOLT, new UnsignedWordElement(45506), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.LVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45504), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.HVRT_START_VOLT, new UnsignedWordElement(45505), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.HVRT_END_VOLT, new UnsignedWordElement(45506), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.HVRT_START_TRIP_TIME, new UnsignedWordElement(45507)), // m(GoodWe.ChannelId.HVRT_END_TRIP_TIME, new UnsignedWordElement(45508)), // - m(GoodWe.ChannelId.HVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45509), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)// + m(GoodWe.ChannelId.HVRT_TRIP_LIMIT_VOLT, new UnsignedWordElement(45509), SCALE_FACTOR_MINUS_1)// ), // // Additional settings for PF/PU/UF @@ -1196,17 +1057,15 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.D_POINT_COS_PHI, new SignedWordElement(45514)), // // Additional settings for UF Curve m(GoodWe.ChannelId.UF_RECOVERY_WAITING_TIME, new UnsignedWordElement(45515), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.UF_RECOVER_SLOPE, new UnsignedWordElement(45516)), // m(GoodWe.ChannelId.CFP_UF_RECOVER_POWER_PERCENT, new UnsignedWordElement(45517)), // - m(GoodWe.ChannelId.POWER_CHARGE_LIMIT, new UnsignedWordElement(45518), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.POWER_CHARGE_LIMIT, new UnsignedWordElement(45518), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.POWER_CHARGE_LIMIT_RECONNECT, new UnsignedWordElement(45519), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.C_EXT_UF_CHARGE_STOP, new UnsignedWordElement(45520), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.C_EXT_UF_CHARGE_STOP, new UnsignedWordElement(45520), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.C_EXT_OF_DISCHARGE_STOP, new UnsignedWordElement(45521), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.C_EXT_TWOSSTEPF_FLG, new UnsignedWordElement(45522))// ), // @@ -1233,21 +1092,18 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.WBMS_VERSION, new UnsignedWordElement(47900)), // m(GoodWe.ChannelId.WBMS_STRINGS, new UnsignedWordElement(47901)), // m(GoodWe.ChannelId.WBMS_CHARGE_MAX_VOLTAGE, new UnsignedWordElement(47902), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_CHARGE_MAX_CURRENT, new UnsignedWordElement(47903), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(47904), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_DISCHARGE_MAX_CURRENT, new UnsignedWordElement(47905), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.WBMS_VOLTAGE, new UnsignedWordElement(47906), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.WBMS_CURRENT, new UnsignedWordElement(47907), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.WBMS_VOLTAGE, new UnsignedWordElement(47906), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.WBMS_CURRENT, new UnsignedWordElement(47907), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_SOC, new UnsignedWordElement(47908)), // m(GoodWe.ChannelId.WBMS_SOH, new UnsignedWordElement(47909)), // - m(GoodWe.ChannelId.WBMS_TEMPERATURE, new SignedWordElement(47910), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.WBMS_TEMPERATURE, new SignedWordElement(47910), SCALE_FACTOR_MINUS_1), // /** * Warning Codes (table 8-8). * @@ -1308,20 +1164,18 @@ protected final ModbusProtocol defineModbusProtocol() throws OpenemsException { m(GoodWe.ChannelId.WBMS_VERSION, new UnsignedWordElement(47900)), // m(GoodWe.ChannelId.WBMS_STRINGS, new UnsignedWordElement(47901)), // m(GoodWe.ChannelId.WBMS_CHARGE_MAX_VOLTAGE, new UnsignedWordElement(47902), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_CHARGE_MAX_CURRENT, new UnsignedWordElement(47903), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_DISCHARGE_MIN_VOLTAGE, new UnsignedWordElement(47904), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_DISCHARGE_MAX_CURRENT, new UnsignedWordElement(47905), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.WBMS_VOLTAGE, new UnsignedWordElement(47906), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.WBMS_VOLTAGE, new UnsignedWordElement(47906), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_CURRENT, new UnsignedWordElement(47907)), // m(GoodWe.ChannelId.WBMS_SOC, new UnsignedWordElement(47908)), // m(GoodWe.ChannelId.WBMS_SOH, new UnsignedWordElement(47909)), // - m(GoodWe.ChannelId.WBMS_TEMPERATURE, new SignedWordElement(47910), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.WBMS_TEMPERATURE, new SignedWordElement(47910), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.WBMS_WARNING_CODE, new UnsignedDoublewordElement(47911)), // m(GoodWe.ChannelId.WBMS_ALARM_CODE, new UnsignedDoublewordElement(47913)), // // TODO reset to individual states @@ -1431,9 +1285,9 @@ private void handleDspVersion7(ModbusProtocol protocol) throws OpenemsException // force // charge power is 1000W from PV or Grid as well m(GoodWe.ChannelId.SOC_START_TO_FORCE_CHARGE, new UnsignedWordElement(47531), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.SOC_STOP_TO_FORCE_CHARGE, new UnsignedWordElement(47532), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // // to clear all economical mode settings (47515-47530) enter self Use Mode m(GoodWe.ChannelId.CLEAR_ALL_ECONOMIC_MODE, new UnsignedWordElement(47533)), // new DummyRegisterElement(47534, 47538), // @@ -1690,10 +1544,8 @@ private void handleDspVersion6(ModbusProtocol protocol) throws OpenemsException // Registers for Grid Smart-Meter (36005 to 36014) are read via GridMeter // implementation new DummyRegisterElement(36005, 36014), - m(GoodWe.ChannelId.E_TOTAL_SELL, new FloatDoublewordElement(36015), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_BUY_F, new FloatDoublewordElement(36017), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_SELL, new FloatDoublewordElement(36015), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_BUY_F, new FloatDoublewordElement(36017), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.METER_ACTIVE_POWER_R, new SignedDoublewordElement(36019)), // m(GoodWe.ChannelId.METER_ACTIVE_POWER_S, new SignedDoublewordElement(36021)), // m(GoodWe.ChannelId.METER_ACTIVE_POWER_T, new SignedDoublewordElement(36023)), // @@ -1712,9 +1564,8 @@ private void handleDspVersion6(ModbusProtocol protocol) throws OpenemsException // Only for AC coupled inverter. Detect Pv Meter m(GoodWe.ChannelId.METER_CT2_ACTIVE_POWER, new SignedDoublewordElement(36045)), // m(GoodWe.ChannelId.CT2_E_TOTAL_SELL, new UnsignedDoublewordElement(36047), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.CT2_E_TOTAL_BUY, new UnsignedDoublewordElement(36049), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.CT2_E_TOTAL_BUY, new UnsignedDoublewordElement(36049), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.METER_CT2_STATUS, new UnsignedWordElement(36051))) // ); @@ -1811,10 +1662,8 @@ private void handleDspVersion5(ModbusProtocol protocol) throws OpenemsException // Registers for Grid Smart-Meter (36005 to 36014) are read via GridMeter // implementation new DummyRegisterElement(36005, 36014), - m(GoodWe.ChannelId.E_TOTAL_SELL, new FloatDoublewordElement(36015), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // - m(GoodWe.ChannelId.E_TOTAL_BUY_F, new FloatDoublewordElement(36017), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_SELL, new FloatDoublewordElement(36015), SCALE_FACTOR_MINUS_1), // + m(GoodWe.ChannelId.E_TOTAL_BUY_F, new FloatDoublewordElement(36017), SCALE_FACTOR_MINUS_1), // m(GoodWe.ChannelId.METER_ACTIVE_POWER_R, new SignedDoublewordElement(36019)), // m(GoodWe.ChannelId.METER_ACTIVE_POWER_S, new SignedDoublewordElement(36021)), // m(GoodWe.ChannelId.METER_ACTIVE_POWER_T, new SignedDoublewordElement(36023)), // @@ -1833,9 +1682,8 @@ private void handleDspVersion5(ModbusProtocol protocol) throws OpenemsException // Only for AC coupled inverter. Detect Pv Meter m(GoodWe.ChannelId.METER_CT2_ACTIVE_POWER, new SignedDoublewordElement(36045)), // m(GoodWe.ChannelId.CT2_E_TOTAL_SELL, new UnsignedDoublewordElement(36047), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(GoodWe.ChannelId.CT2_E_TOTAL_BUY, new UnsignedDoublewordElement(36049), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // + m(GoodWe.ChannelId.CT2_E_TOTAL_BUY, new UnsignedDoublewordElement(36049), SCALE_FACTOR_MINUS_2), // m(GoodWe.ChannelId.METER_CT2_STATUS, new UnsignedWordElement(36051))) // ); } diff --git a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/emergencypowermeter/GoodWeEmergencyPowerMeterImpl.java b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/emergencypowermeter/GoodWeEmergencyPowerMeterImpl.java index e7a3cb6d7a1..653643db336 100644 --- a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/emergencypowermeter/GoodWeEmergencyPowerMeterImpl.java +++ b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/emergencypowermeter/GoodWeEmergencyPowerMeterImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.goodwe.emergencypowermeter; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -19,7 +22,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -103,29 +105,29 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { // Power of each backup up phase new FC3ReadRegistersTask(35145, Priority.HIGH, // m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(35145), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedWordElement(35146), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWeEmergencyPowerMeter.ChannelId.FREQUENCY_L1, new UnsignedWordElement(35147), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // new DummyRegisterElement(35148), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(35149)), // m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(35151), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedWordElement(35152), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWeEmergencyPowerMeter.ChannelId.FREQUENCY_L2, new UnsignedWordElement(35153), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // new DummyRegisterElement(35154), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(35155)), // m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(35157), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedWordElement(35158), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), // + SCALE_FACTOR_MINUS_1), // m(GoodWeEmergencyPowerMeter.ChannelId.FREQUENCY_L3, new UnsignedWordElement(35159), // - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + SCALE_FACTOR_MINUS_2), // new DummyRegisterElement(35160), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(35161)))); } diff --git a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/gridmeter/GoodWeGridMeterImpl.java b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/gridmeter/GoodWeGridMeterImpl.java index d984868acb3..39626c2c99b 100644 --- a/io.openems.edge.goodwe/src/io/openems/edge/goodwe/gridmeter/GoodWeGridMeterImpl.java +++ b/io.openems.edge.goodwe/src/io/openems/edge/goodwe/gridmeter/GoodWeGridMeterImpl.java @@ -1,5 +1,10 @@ package io.openems.edge.goodwe.gridmeter; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_2; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -124,44 +129,31 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { }))), // new FC3ReadRegistersTask(35123, Priority.LOW, // - m(GoodWeGridMeter.ChannelId.F_GRID_R, new UnsignedWordElement(35123), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // // + m(GoodWeGridMeter.ChannelId.F_GRID_R, new UnsignedWordElement(35123), SCALE_FACTOR_MINUS_2), // // new DummyRegisterElement(35124, 35127), // - m(GoodWeGridMeter.ChannelId.F_GRID_S, new UnsignedWordElement(35128), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), + m(GoodWeGridMeter.ChannelId.F_GRID_S, new UnsignedWordElement(35128), SCALE_FACTOR_MINUS_2), new DummyRegisterElement(35129, 35132), - m(GoodWeGridMeter.ChannelId.F_GRID_T, new UnsignedWordElement(35133), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // + m(GoodWeGridMeter.ChannelId.F_GRID_T, new UnsignedWordElement(35133), SCALE_FACTOR_MINUS_2), // m(GoodWeGridMeter.ChannelId.P_GRID_T, new SignedDoublewordElement(35134), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2)), // + SCALE_FACTOR_MINUS_2)), // // Active and reactive power, Power factor and frequency // Voltage, current and Grid Frequency of each phase new FC3ReadRegistersTask(36005, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedWordElement(36005), - ElementToChannelConverter.INVERT), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedWordElement(36006), - ElementToChannelConverter.INVERT), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedWordElement(36007), - ElementToChannelConverter.INVERT), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedWordElement(36005), INVERT), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedWordElement(36006), INVERT), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedWordElement(36007), INVERT), // new DummyRegisterElement(36008, 36012), // m(GoodWeGridMeter.ChannelId.METER_POWER_FACTOR, new UnsignedWordElement(36013), - ElementToChannelConverter.SCALE_FACTOR_MINUS_2), // - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedWordElement(36014), - ElementToChannelConverter.SCALE_FACTOR_1), + SCALE_FACTOR_MINUS_2), // + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedWordElement(36014), SCALE_FACTOR_1), new DummyRegisterElement(36015, 36051), - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(36052), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(36053), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(36054), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedWordElement(36055), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedWordElement(36056), - ElementToChannelConverter.SCALE_FACTOR_2), // - m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedWordElement(36057), - ElementToChannelConverter.SCALE_FACTOR_2))); // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedWordElement(36052), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedWordElement(36053), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedWordElement(36054), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedWordElement(36055), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedWordElement(36056), SCALE_FACTOR_2), // + m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedWordElement(36057), SCALE_FACTOR_2))); // } @Override diff --git a/io.openems.edge.meter.artemes.am2/src/io/openems/edge/meter/artemes/am2/MeterArtemesAM2.java b/io.openems.edge.meter.artemes.am2/src/io/openems/edge/meter/artemes/am2/MeterArtemesAM2.java index 32636390586..7963d7acae7 100644 --- a/io.openems.edge.meter.artemes.am2/src/io/openems/edge/meter/artemes/am2/MeterArtemesAM2.java +++ b/io.openems.edge.meter.artemes.am2/src/io/openems/edge/meter/artemes/am2/MeterArtemesAM2.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.artemes.am2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -16,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -98,43 +100,41 @@ public MeterType getMeterType() { @Override protected ModbusProtocol defineModbusProtocol() throws OpenemsException { - return new ModbusProtocol(this, - new FC4ReadInputRegistersTask(0x0000, Priority.HIGH, - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0x0000)), - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0x0002)), - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0x0004)), - new DummyRegisterElement(0x0006, 0x000B), - m(SymmetricMeter.ChannelId.VOLTAGE, new UnsignedDoublewordElement(0x000C)), - m(AsymmetricMeter.ChannelId.CURRENT_L1, new SignedDoublewordElement(0x000E)), - m(AsymmetricMeter.ChannelId.CURRENT_L2, new SignedDoublewordElement(0x0010)), - m(AsymmetricMeter.ChannelId.CURRENT_L3, new SignedDoublewordElement(0x0012)), - new DummyRegisterElement(0x0014, 0x0015), - m(SymmetricMeter.ChannelId.CURRENT, new SignedDoublewordElement(0x0016)), - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedQuadruplewordElement(0x0018), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedQuadruplewordElement(0x001C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedQuadruplewordElement(0X0020), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedQuadruplewordElement(0X0024), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - new DummyRegisterElement(0x0028, 0x0037), - m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedQuadruplewordElement(0x0038), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedQuadruplewordElement(0x003C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedQuadruplewordElement(0x0040), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedQuadruplewordElement(0x0044), - ElementToChannelConverter.SCALE_FACTOR_MINUS_3), - new DummyRegisterElement(0x0048, 0x0071), - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0x0072))), + return new ModbusProtocol(this, new FC4ReadInputRegistersTask(0x0000, Priority.HIGH, + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0x0000)), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0x0002)), + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0x0004)), + new DummyRegisterElement(0x0006, 0x000B), + m(SymmetricMeter.ChannelId.VOLTAGE, new UnsignedDoublewordElement(0x000C)), + m(AsymmetricMeter.ChannelId.CURRENT_L1, new SignedDoublewordElement(0x000E)), + m(AsymmetricMeter.ChannelId.CURRENT_L2, new SignedDoublewordElement(0x0010)), + m(AsymmetricMeter.ChannelId.CURRENT_L3, new SignedDoublewordElement(0x0012)), + new DummyRegisterElement(0x0014, 0x0015), + m(SymmetricMeter.ChannelId.CURRENT, new SignedDoublewordElement(0x0016)), + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedQuadruplewordElement(0x0018), + SCALE_FACTOR_MINUS_3), + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedQuadruplewordElement(0x001C), + SCALE_FACTOR_MINUS_3), + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedQuadruplewordElement(0X0020), + SCALE_FACTOR_MINUS_3), + m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedQuadruplewordElement(0X0024), SCALE_FACTOR_MINUS_3), + new DummyRegisterElement(0x0028, 0x0037), + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedQuadruplewordElement(0x0038), + SCALE_FACTOR_MINUS_3), + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedQuadruplewordElement(0x003C), + SCALE_FACTOR_MINUS_3), + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedQuadruplewordElement(0x0040), + SCALE_FACTOR_MINUS_3), + m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedQuadruplewordElement(0x0044), + SCALE_FACTOR_MINUS_3), + new DummyRegisterElement(0x0048, 0x0071), + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0x0072))), new FC4ReadInputRegistersTask(0x0418, Priority.LOW, m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedQuadruplewordElement(0x0418), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedQuadruplewordElement(0x0041C), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1))); + SCALE_FACTOR_MINUS_1))); } @Override diff --git a/io.openems.edge.meter.bcontrol.em300/src/io/openems/edge/meter/bcontrol/em300/MeterBControlEM300Impl.java b/io.openems.edge.meter.bcontrol.em300/src/io/openems/edge/meter/bcontrol/em300/MeterBControlEM300Impl.java index 16cbd7d518c..6b0f1cb2c62 100644 --- a/io.openems.edge.meter.bcontrol.em300/src/io/openems/edge/meter/bcontrol/em300/MeterBControlEM300Impl.java +++ b/io.openems.edge.meter.bcontrol.em300/src/io/openems/edge/meter/bcontrol/em300/MeterBControlEM300Impl.java @@ -1,5 +1,7 @@ package io.openems.edge.meter.bcontrol.em300; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1; + import java.util.function.Consumer; import org.osgi.service.cm.ConfigurationAdmin; @@ -18,7 +20,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.UnsignedDoublewordElement; @@ -94,26 +95,26 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { var modbusProtocol = new ModbusProtocol(this, // new FC3ReadRegistersTask(0, Priority.HIGH, // m(MeterBControlEM300.ChannelId.ACTIVE_POWER_POS, new UnsignedDoublewordElement(0), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.ACTIVE_POWER_NEG, new UnsignedDoublewordElement(2), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_POS, new UnsignedDoublewordElement(4), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_NEG, new UnsignedDoublewordElement(6), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC3ReadRegistersTask(10, Priority.LOW, m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(10))), new FC3ReadRegistersTask(40, Priority.HIGH, m(MeterBControlEM300.ChannelId.ACTIVE_POWER_L1_POS, new UnsignedDoublewordElement(40), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.ACTIVE_POWER_L1_NEG, new UnsignedDoublewordElement(42), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_L1_POS, new UnsignedDoublewordElement(44), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_L1_NEG, new UnsignedDoublewordElement(46), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC3ReadRegistersTask(60, Priority.HIGH, m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedDoublewordElement(60)), @@ -121,14 +122,14 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(80, Priority.HIGH, m(MeterBControlEM300.ChannelId.ACTIVE_POWER_L2_POS, new UnsignedDoublewordElement(80), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.ACTIVE_POWER_L2_NEG, new UnsignedDoublewordElement(82), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_L2_POS, new UnsignedDoublewordElement(84), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_L2_NEG, new UnsignedDoublewordElement(86), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC3ReadRegistersTask(100, Priority.HIGH, m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedDoublewordElement(100)), @@ -136,13 +137,13 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(120, Priority.HIGH, m(MeterBControlEM300.ChannelId.ACTIVE_POWER_L3_POS, new UnsignedDoublewordElement(120), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.ACTIVE_POWER_L3_NEG, new UnsignedDoublewordElement(122), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_L3_POS, new UnsignedDoublewordElement(124), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(MeterBControlEM300.ChannelId.REACTIVE_POWER_L3_NEG, new UnsignedDoublewordElement(126), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1)), + SCALE_FACTOR_MINUS_1)), new FC3ReadRegistersTask(140, Priority.HIGH, m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedDoublewordElement(140)), @@ -151,15 +152,15 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { if (this.config.invert()) { modbusProtocol.addTask(new FC3ReadRegistersTask(512, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedQuadruplewordElement(512), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedQuadruplewordElement(516), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1))); + SCALE_FACTOR_MINUS_1))); } else { modbusProtocol.addTask(new FC3ReadRegistersTask(512, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedQuadruplewordElement(512), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1), + SCALE_FACTOR_MINUS_1), m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedQuadruplewordElement(516), - ElementToChannelConverter.SCALE_FACTOR_MINUS_1))); + SCALE_FACTOR_MINUS_1))); } // Calculates required Channels from other existing Channels. diff --git a/io.openems.edge.meter.bgetech/src/io/openems/edge/meter/bgetech/MeterBgeTechDrt428M2Impl.java b/io.openems.edge.meter.bgetech/src/io/openems/edge/meter/bgetech/MeterBgeTechDrt428M2Impl.java index da3b59a9781..936f104217e 100644 --- a/io.openems.edge.meter.bgetech/src/io/openems/edge/meter/bgetech/MeterBgeTechDrt428M2Impl.java +++ b/io.openems.edge.meter.bgetech/src/io/openems/edge/meter/bgetech/MeterBgeTechDrt428M2Impl.java @@ -1,6 +1,8 @@ package io.openems.edge.meter.bgetech; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -17,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.FloatDoublewordElement; @@ -83,42 +84,27 @@ public MeterType getMeterType() { protected ModbusProtocol defineModbusProtocol() throws OpenemsException { ModbusProtocol modbusProtocol = new ModbusProtocol(this, new FC3ReadRegistersTask(14, Priority.HIGH, - m(new FloatDoublewordElement(14)) - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3) - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3).build(), - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(16), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(18), - ElementToChannelConverter.SCALE_FACTOR_3), // - - m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(20), - ElementToChannelConverter.SCALE_FACTOR_3), // - - m(new FloatDoublewordElement(22)) - .m(AsymmetricMeter.ChannelId.CURRENT_L1, ElementToChannelConverter.SCALE_FACTOR_3) - .m(SymmetricMeter.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_3).build(), - m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(24), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(26), - ElementToChannelConverter.SCALE_FACTOR_3), // - - m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(28), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(30), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(32), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(34), - ElementToChannelConverter.SCALE_FACTOR_3), // - - m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(36), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(38), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(40), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(42), - ElementToChannelConverter.SCALE_FACTOR_3), // + m(new FloatDoublewordElement(14)).m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3) + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3).build(), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(16), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(18), SCALE_FACTOR_3), // + + m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(20), SCALE_FACTOR_3), // + + m(new FloatDoublewordElement(22)).m(AsymmetricMeter.ChannelId.CURRENT_L1, SCALE_FACTOR_3) + .m(SymmetricMeter.ChannelId.CURRENT, SCALE_FACTOR_3).build(), + m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(24), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(26), SCALE_FACTOR_3), // + + m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(28), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(30), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(32), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(34), SCALE_FACTOR_3), // + + m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(36), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(38), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(40), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(42), SCALE_FACTOR_3), // m(MeterBgeTechDrt428M2.ChannelId.TOTAL_APPARENT_POWER, new FloatDoublewordElement(44)), m(MeterBgeTechDrt428M2.ChannelId.L1_APPARENT_POWER, new FloatDoublewordElement(46)), diff --git a/io.openems.edge.meter.carlo.gavazzi.em300/src/io/openems/edge/meter/carlo/gavazzi/em300/MeterCarloGavazziEm300Impl.java b/io.openems.edge.meter.carlo.gavazzi.em300/src/io/openems/edge/meter/carlo/gavazzi/em300/MeterCarloGavazziEm300Impl.java index 42180196e1a..aa05c6bf286 100644 --- a/io.openems.edge.meter.carlo.gavazzi.em300/src/io/openems/edge/meter/carlo/gavazzi/em300/MeterCarloGavazziEm300Impl.java +++ b/io.openems.edge.meter.carlo.gavazzi.em300/src/io/openems/edge/meter/carlo/gavazzi/em300/MeterCarloGavazziEm300Impl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.carlo.gavazzi.em300; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -15,7 +18,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -118,83 +120,71 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC4ReadInputRegistersTask(300001 - offset, Priority.LOW, // m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new SignedDoublewordElement(300001 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new SignedDoublewordElement(300003 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(AsymmetricMeter.ChannelId.VOLTAGE_L3, - new SignedDoublewordElement(300005 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2)), + new SignedDoublewordElement(300005 - offset) + .wordOrder(WordOrder.LSWMSW), + SCALE_FACTOR_2)), new FC4ReadInputRegistersTask(300013 - offset, Priority.HIGH, // m(AsymmetricMeter.ChannelId.CURRENT_L1, new SignedDoublewordElement(300013 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(AsymmetricMeter.ChannelId.CURRENT_L2, new SignedDoublewordElement(300015 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(AsymmetricMeter.ChannelId.CURRENT_L3, new SignedDoublewordElement(300017 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(300019 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(300021 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(300023 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(MeterCarloGavazziEm300.ChannelId.APPARENT_POWER_L1, new SignedDoublewordElement(300025 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(MeterCarloGavazziEm300.ChannelId.APPARENT_POWER_L2, new SignedDoublewordElement(300027 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(MeterCarloGavazziEm300.ChannelId.APPARENT_POWER_L3, new SignedDoublewordElement(300029 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(300031 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(300033 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(300035 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), new DummyRegisterElement(300037 - offset, 300040 - offset), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(300041 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(MeterCarloGavazziEm300.ChannelId.APPARENT_POWER, new SignedDoublewordElement(300043 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert())), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(300045 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter - .SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert()))), + SCALE_FACTOR_MINUS_1_AND_INVERT_IF_TRUE(this.config.invert()))), new FC4ReadInputRegistersTask(300052 - offset, Priority.LOW, // - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedWordElement(300052 - offset), - ElementToChannelConverter.SCALE_FACTOR_2), + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedWordElement(300052 - offset), SCALE_FACTOR_2), m(energyChannelId300053, new SignedDoublewordElement(300053 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2), + SCALE_FACTOR_2), new DummyRegisterElement(300055 - offset, 300078 - offset), // m(energyChannelId300079, new SignedDoublewordElement(300079 - offset).wordOrder(WordOrder.LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_2))); + SCALE_FACTOR_2))); } @Override diff --git a/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg511/MeterJanitzaUmg511Impl.java b/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg511/MeterJanitzaUmg511Impl.java index fb3a642228d..3f6a5a8c9a9 100644 --- a/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg511/MeterJanitzaUmg511Impl.java +++ b/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg511/MeterJanitzaUmg511Impl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.janitza.umg511; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -16,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -97,43 +99,40 @@ public MeterType getMeterType() { protected ModbusProtocol defineModbusProtocol() throws OpenemsException { var modbusProtocol = new ModbusProtocol(this, // new FC3ReadRegistersTask(3845, Priority.HIGH, // - m(new FloatDoublewordElement(3845)) - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3)// - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3)// + m(new FloatDoublewordElement(3845)).m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3)// + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3)// .build(), - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(3847), - ElementToChannelConverter.SCALE_FACTOR_3), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(3849), - ElementToChannelConverter.SCALE_FACTOR_3), // , // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(3847), SCALE_FACTOR_3), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(3849), SCALE_FACTOR_3), // new DummyRegisterElement(3851, 3852), m(new FloatDoublewordElement(3853)) // - .m(AsymmetricMeter.ChannelId.CURRENT_L1, ElementToChannelConverter.SCALE_FACTOR_3) // - .m(SymmetricMeter.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_3) // + .m(AsymmetricMeter.ChannelId.CURRENT_L1, SCALE_FACTOR_3) // + .m(SymmetricMeter.ChannelId.CURRENT, SCALE_FACTOR_3) // .build(), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(3855), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(3857), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(3859, 3860), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(3861), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(3863), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(3865), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // new DummyRegisterElement(3867, 3868), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(3869), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(3871), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(3873), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert))), // + INVERT_IF_TRUE(this.invert))), // new FC3ReadRegistersTask(3925, Priority.HIGH, // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(3925)), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(3927), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert))), // + INVERT_IF_TRUE(this.invert))), // new FC3ReadRegistersTask(3995, Priority.LOW, // m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(3995), // - ElementToChannelConverter.SCALE_FACTOR_3))); + SCALE_FACTOR_3))); if (this.invert) { modbusProtocol.addTask(new FC3ReadRegistersTask(19068, Priority.LOW, // diff --git a/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg604/MeterJanitzaUmg604Impl.java b/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg604/MeterJanitzaUmg604Impl.java index adbba05e0e0..a5b17e52224 100644 --- a/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg604/MeterJanitzaUmg604Impl.java +++ b/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg604/MeterJanitzaUmg604Impl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.janitza.umg604; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -16,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -97,45 +99,44 @@ public MeterType getMeterType() { protected ModbusProtocol defineModbusProtocol() throws OpenemsException { var modbusProtocol = new ModbusProtocol(this, // new FC3ReadRegistersTask(1317, Priority.HIGH, // - m(new FloatDoublewordElement(1317)) - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3)// - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3)// + m(new FloatDoublewordElement(1317)).m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3)// + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3)// .build(), m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(1319), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(1321), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(1323, 1324), // m(new FloatDoublewordElement(1325)) // - .m(AsymmetricMeter.ChannelId.CURRENT_L1, ElementToChannelConverter.SCALE_FACTOR_3) // - .m(SymmetricMeter.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_3) // + .m(AsymmetricMeter.ChannelId.CURRENT_L1, SCALE_FACTOR_3) // + .m(SymmetricMeter.ChannelId.CURRENT, SCALE_FACTOR_3) // .build(), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(1327), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(1329), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(1331, 1332), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(1333), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(1335), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(1337), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // new DummyRegisterElement(1339, 1340), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(1341), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(1343), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(1345), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // new DummyRegisterElement(1347, 1368), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(1369), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), // + INVERT_IF_TRUE(this.invert)), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(1371), // - ElementToChannelConverter.INVERT_IF_TRUE(this.invert))), // + INVERT_IF_TRUE(this.invert))), // new FC3ReadRegistersTask(1439, Priority.LOW, // m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(1439), // - ElementToChannelConverter.SCALE_FACTOR_3))); + SCALE_FACTOR_3))); if (this.invert) { modbusProtocol.addTask(new FC3ReadRegistersTask(9851, Priority.LOW, // diff --git a/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg96rme/MeterJanitzaUmg96rme.java b/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg96rme/MeterJanitzaUmg96rme.java index 1edf6599c29..f2e04c17c2c 100644 --- a/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg96rme/MeterJanitzaUmg96rme.java +++ b/io.openems.edge.meter.janitza/src/io/openems/edge/meter/janitza/umg96rme/MeterJanitzaUmg96rme.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.janitza.umg96rme; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -16,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -112,42 +114,35 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { */ var modbusProtocol = new ModbusProtocol(this, // new FC3ReadRegistersTask(800, Priority.HIGH, // - m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(800), - ElementToChannelConverter.SCALE_FACTOR_3), + m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(800), SCALE_FACTOR_3), new DummyRegisterElement(802, 807), // m(new FloatDoublewordElement(808)) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3) // - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3) // + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3) // .build(), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(810), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(812), - ElementToChannelConverter.SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(810), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(812), SCALE_FACTOR_3), new DummyRegisterElement(814, 859), // - m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(860), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(862), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(864), - ElementToChannelConverter.SCALE_FACTOR_3), - m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(866), - ElementToChannelConverter.SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(860), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(862), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(864), SCALE_FACTOR_3), + m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(866), SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(868), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(870), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(872), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(874), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(876), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(878), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(880), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(882), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)))); + INVERT_IF_TRUE(this.invert)))); if (this.invert) { modbusProtocol.addTask(new FC3ReadRegistersTask(19068, Priority.LOW, // diff --git a/io.openems.edge.meter.kdk/src/io/openems/edge/meter/kdk/puct2/MeterKdk2puctImpl.java b/io.openems.edge.meter.kdk/src/io/openems/edge/meter/kdk/puct2/MeterKdk2puctImpl.java index 1e4b5343568..878b7705026 100755 --- a/io.openems.edge.meter.kdk/src/io/openems/edge/meter/kdk/puct2/MeterKdk2puctImpl.java +++ b/io.openems.edge.meter.kdk/src/io/openems/edge/meter/kdk/puct2/MeterKdk2puctImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.kdk.puct2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE; + import java.util.function.Consumer; import org.osgi.service.cm.ConfigurationAdmin; @@ -18,7 +21,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -109,109 +111,109 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC3ReadRegistersTask(0x5002, Priority.HIGH, // m(AsymmetricMeter.ChannelId.VOLTAGE_L1, // new FloatDoublewordElement(0x5002), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.VOLTAGE_L2, // new FloatDoublewordElement(0x5004), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.VOLTAGE_L3, // new FloatDoublewordElement(0x5006), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(SymmetricMeter.ChannelId.FREQUENCY, // new FloatDoublewordElement(0x5008), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x500A, 0x500B), // m(MeterKdk2puct.ChannelId.METER_CURRENT_L1, // new FloatDoublewordElement(0x500C), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(MeterKdk2puct.ChannelId.METER_CURRENT_L2, // new FloatDoublewordElement(0x500E), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(MeterKdk2puct.ChannelId.METER_CURRENT_L3, // new FloatDoublewordElement(0x5010), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(MeterKdk2puct.ChannelId.METER_ACTIVE_POWER, // new FloatDoublewordElement(0x5012), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_ACTIVE_POWER_L1, // new FloatDoublewordElement(0x5014), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_ACTIVE_POWER_L2, // new FloatDoublewordElement(0x5016), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_ACTIVE_POWER_L3, // new FloatDoublewordElement(0x5018), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_REACTIVE_POWER, // new FloatDoublewordElement(0x501A), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_REACTIVE_POWER_L1, // new FloatDoublewordElement(0x501C), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_REACTIVE_POWER_L2, // new FloatDoublewordElement(0x501E), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())), // m(MeterKdk2puct.ChannelId.METER_REACTIVE_POWER_L3, // new FloatDoublewordElement(0x5020), - ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())) // + SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.config.invert())) // )); if (this.config.invert()) { modbusProtocol.addTask(new FC3ReadRegistersTask(0x600C, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, // new FloatDoublewordElement(0x600C), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x600E, 0x6011), // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L1, // new FloatDoublewordElement(0x6012), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L2, // new FloatDoublewordElement(0x6014), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L3, // new FloatDoublewordElement(0x6016), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, // new FloatDoublewordElement(0x6018), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x601A, 0x601D), // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L1, // new FloatDoublewordElement(0x601E), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L2, // new FloatDoublewordElement(0x6020), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L3, // new FloatDoublewordElement(0x6022), // - ElementToChannelConverter.SCALE_FACTOR_3) // + SCALE_FACTOR_3) // )); } else { modbusProtocol.addTask(new FC3ReadRegistersTask(0x600C, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, // new FloatDoublewordElement(0x600C), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x600E, 0x6011), // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L1, // new FloatDoublewordElement(0x6012), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L2, // new FloatDoublewordElement(0x6014), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L3, // new FloatDoublewordElement(0x6016), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, // new FloatDoublewordElement(0x6018), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x601A, 0x601D), // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L1, // new FloatDoublewordElement(0x601E), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L2, // new FloatDoublewordElement(0x6020), // - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L3, // new FloatDoublewordElement(0x6022), // - ElementToChannelConverter.SCALE_FACTOR_3) // + SCALE_FACTOR_3) // )); } diff --git a/io.openems.edge.meter.microcare.sdm630/src/io/openems/edge/meter/microcare/sdm630/MeterMicrocareSdm630Impl.java b/io.openems.edge.meter.microcare.sdm630/src/io/openems/edge/meter/microcare/sdm630/MeterMicrocareSdm630Impl.java index 5302ca17a6f..7d0a8542ac4 100644 --- a/io.openems.edge.meter.microcare.sdm630/src/io/openems/edge/meter/microcare/sdm630/MeterMicrocareSdm630Impl.java +++ b/io.openems.edge.meter.microcare.sdm630/src/io/openems/edge/meter/microcare/sdm630/MeterMicrocareSdm630Impl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.microcare.sdm630; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import java.nio.ByteOrder; import org.osgi.service.cm.ConfigurationAdmin; @@ -18,7 +21,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -90,90 +92,90 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { new FC4ReadInputRegistersTask(30001 - offset, Priority.HIGH, m(new FloatDoublewordElement(30001 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN)) - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3)// - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3)// + .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3)// + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3)// .build(), m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(30003 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(30005 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(30007 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(30009 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(30011 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(30013 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(30015 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(30017 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), new DummyRegisterElement(30019 - offset, 30024 - offset), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(30025 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(30027 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(30029 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), new DummyRegisterElement(30031 - offset, 30048 - offset), m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(30049 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), new DummyRegisterElement(30051 - offset, 30052 - offset), m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(30053 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), new DummyRegisterElement(30055 - offset, 30060 - offset), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(30061 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), new DummyRegisterElement(30063 - offset, 30070 - offset), m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(30071 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.DIRECT_1_TO_1), + DIRECT_1_TO_1), m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatDoublewordElement(30073 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatDoublewordElement(30075 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(MeterMicrocareSdm630.ChannelId.REACTIVE_CONSUMPTION_ENERGY, new FloatDoublewordElement(30077 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(MeterMicrocareSdm630.ChannelId.REACTIVE_PRODUCTION_ENERGY, new FloatDoublewordElement(30079 - offset).wordOrder(WordOrder.MSWLSW) .byteOrder(ByteOrder.BIG_ENDIAN), - ElementToChannelConverter.SCALE_FACTOR_3))); + SCALE_FACTOR_3))); } @Override diff --git a/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd96/MeterPqplusUmd96Impl.java b/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd96/MeterPqplusUmd96Impl.java index aa17987ed0e..1f5c7eba135 100644 --- a/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd96/MeterPqplusUmd96Impl.java +++ b/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd96/MeterPqplusUmd96Impl.java @@ -1,5 +1,7 @@ package io.openems.edge.meter.pqplus.umd96; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -15,7 +17,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -91,28 +92,24 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // // Frequency new FC3ReadRegistersTask(0x1004, Priority.LOW, // - m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(0x1004), - ElementToChannelConverter.SCALE_FACTOR_3)), + m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(0x1004), SCALE_FACTOR_3)), // Voltages new FC3ReadRegistersTask(0x1100, Priority.HIGH, // m(new FloatDoublewordElement(0x1100)) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3) // - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3) // + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3) // .build(), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(0x1102), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(0x1104), - ElementToChannelConverter.SCALE_FACTOR_3)), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(0x1102), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(0x1104), SCALE_FACTOR_3)), // Currents new FC3ReadRegistersTask(0x1200, Priority.HIGH, // - m(new FloatDoublewordElement(0x1200)) - .m(AsymmetricMeter.ChannelId.CURRENT_L1, ElementToChannelConverter.SCALE_FACTOR_3) // - .m(SymmetricMeter.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_3) // + m(new FloatDoublewordElement(0x1200)).m(AsymmetricMeter.ChannelId.CURRENT_L1, SCALE_FACTOR_3) // + .m(SymmetricMeter.ChannelId.CURRENT, SCALE_FACTOR_3) // .build(), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(0x1202), // - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(0x1204), // - ElementToChannelConverter.SCALE_FACTOR_3)), + SCALE_FACTOR_3)), // Power values new FC3ReadRegistersTask(0x1314, Priority.HIGH, // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(0x1314)), diff --git a/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd97/MeterPqplusUmd97Impl.java b/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd97/MeterPqplusUmd97Impl.java index 94fd5f78f44..ef42c1a9a43 100644 --- a/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd97/MeterPqplusUmd97Impl.java +++ b/io.openems.edge.meter.pqplus/src/io/openems/edge/meter/pqplus/umd97/MeterPqplusUmd97Impl.java @@ -1,5 +1,7 @@ package io.openems.edge.meter.pqplus.umd97; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -15,7 +17,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -89,22 +90,16 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC3ReadRegistersTask(19000, Priority.HIGH, // m(new FloatDoublewordElement(19000)) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.SCALE_FACTOR_3) // - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_3) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, SCALE_FACTOR_3) // + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_3) // .build(), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(19002), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(19004), - ElementToChannelConverter.SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(19002), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(19004), SCALE_FACTOR_3), new DummyRegisterElement(19006, 19011), // - m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(19012), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(19014), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(19016), - ElementToChannelConverter.SCALE_FACTOR_3), - m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(19018), - ElementToChannelConverter.SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(19012), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(19014), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(19016), SCALE_FACTOR_3), + m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(19018), SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(19020)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(19022)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(19024)), @@ -115,8 +110,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(19040)), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(19042)), new DummyRegisterElement(19044, 19049), // - m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(19050), - ElementToChannelConverter.SCALE_FACTOR_3))); + m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(19050), SCALE_FACTOR_3))); } @Override diff --git a/io.openems.edge.meter.schneider.acti9.smartlink/src/io/openems/edge/meter/schneider/acti9/smartlink/MeterSchneiderActi9Smartlink.java b/io.openems.edge.meter.schneider.acti9.smartlink/src/io/openems/edge/meter/schneider/acti9/smartlink/MeterSchneiderActi9Smartlink.java index b3dd297276f..82ec1fe0980 100644 --- a/io.openems.edge.meter.schneider.acti9.smartlink/src/io/openems/edge/meter/schneider/acti9/smartlink/MeterSchneiderActi9Smartlink.java +++ b/io.openems.edge.meter.schneider.acti9.smartlink/src/io/openems/edge/meter/schneider/acti9/smartlink/MeterSchneiderActi9Smartlink.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.schneider.acti9.smartlink; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -15,7 +18,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -91,33 +93,33 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC4ReadInputRegistersTask(3000 - offset, Priority.HIGH, m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(3000 - offset), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(3002 - offset), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(3004 - offset), - ElementToChannelConverter.SCALE_FACTOR_3)), + SCALE_FACTOR_3)), new FC4ReadInputRegistersTask(3028 - offset, Priority.LOW, m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new FloatDoublewordElement(3028 - offset), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(3030 - offset), - ElementToChannelConverter.SCALE_FACTOR_3), + SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(3032 - offset), - ElementToChannelConverter.SCALE_FACTOR_3)), + SCALE_FACTOR_3)), new FC4ReadInputRegistersTask(3054 - offset, Priority.HIGH, m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(3054 - offset), - ElementToChannelConverter.INVERT_IF_TRUE(this.inverted)), + INVERT_IF_TRUE(this.inverted)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(3056 - offset), - ElementToChannelConverter.INVERT_IF_TRUE(this.inverted)), + INVERT_IF_TRUE(this.inverted)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(3058 - offset), - ElementToChannelConverter.INVERT_IF_TRUE(this.inverted)), + INVERT_IF_TRUE(this.inverted)), m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(3060 - offset), - ElementToChannelConverter.INVERT_IF_TRUE(this.inverted)), + INVERT_IF_TRUE(this.inverted)), new DummyRegisterElement(3062 - offset, 3067 - offset), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(3068 - offset), - ElementToChannelConverter.INVERT_IF_TRUE(this.inverted))), + INVERT_IF_TRUE(this.inverted))), new FC4ReadInputRegistersTask(3110 - offset, Priority.LOW, m(SymmetricMeter.ChannelId.FREQUENCY, new FloatDoublewordElement(3110 - offset), - ElementToChannelConverter.SCALE_FACTOR_3)), + SCALE_FACTOR_3)), new FC4ReadInputRegistersTask(3208 - offset, Priority.LOW, m(this.inverted ? SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY : SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java index b82094d9614..4ee41b27810 100644 --- a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.siemens; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -16,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -99,40 +101,33 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { var modbusProtocol = new ModbusProtocol(this, // new FC3ReadRegistersTask(1, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new FloatDoublewordElement(1), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(3), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(5), - ElementToChannelConverter.SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new FloatDoublewordElement(1), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(3), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(5), SCALE_FACTOR_3), new DummyRegisterElement(7, 12), // - m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(13), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(15), - ElementToChannelConverter.SCALE_FACTOR_3), - m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(17), - ElementToChannelConverter.SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(13), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(15), SCALE_FACTOR_3), + m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(17), SCALE_FACTOR_3), new DummyRegisterElement(19, 24), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(25), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(27), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(29), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(31), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(33), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(35), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), new DummyRegisterElement(37, 60), // - m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(61), - ElementToChannelConverter.SCALE_FACTOR_3), + m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(61), SCALE_FACTOR_3), new DummyRegisterElement(63, 64), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(65), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + INVERT_IF_TRUE(this.invert)), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(67), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)))); + INVERT_IF_TRUE(this.invert)))); if (this.invert) { modbusProtocol.addTask(new FC3ReadRegistersTask(801, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(801)), diff --git a/io.openems.edge.meter.sma.shm20/src/io/openems/edge/meter/sma/shm20/MeterSmaShm20Impl.java b/io.openems.edge.meter.sma.shm20/src/io/openems/edge/meter/sma/shm20/MeterSmaShm20Impl.java index 01e62a19f69..9a02deeafc6 100644 --- a/io.openems.edge.meter.sma.shm20/src/io/openems/edge/meter/sma/shm20/MeterSmaShm20Impl.java +++ b/io.openems.edge.meter.sma.shm20/src/io/openems/edge/meter/sma/shm20/MeterSmaShm20Impl.java @@ -1,5 +1,7 @@ package io.openems.edge.meter.sma.shm20; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; + import java.util.function.Consumer; import org.osgi.service.cm.ConfigurationAdmin; @@ -17,7 +19,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.SignedDoublewordElement; @@ -95,12 +96,9 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(MeterSmaShm20.ChannelId.ACTIVE_CONSUMPTION_POWER, new SignedDoublewordElement(30867))), // Voltage, Power and Reactive Power new FC3ReadRegistersTask(31253, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(31253), - ElementToChannelConverter.SCALE_FACTOR_1), - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(31255), - ElementToChannelConverter.SCALE_FACTOR_1), - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(31257), - ElementToChannelConverter.SCALE_FACTOR_1), + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(31253), SCALE_FACTOR_1), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(31255), SCALE_FACTOR_1), + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(31257), SCALE_FACTOR_1), m(MeterSmaShm20.ChannelId.ACTIVE_CONSUMPTION_POWER_L1, new UnsignedDoublewordElement(31259)), m(MeterSmaShm20.ChannelId.ACTIVE_CONSUMPTION_POWER_L2, new UnsignedDoublewordElement(31261)), m(MeterSmaShm20.ChannelId.ACTIVE_CONSUMPTION_POWER_L3, new UnsignedDoublewordElement(31263)), @@ -118,8 +116,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(AsymmetricMeter.ChannelId.CURRENT_L3, new SignedDoublewordElement(31439))), // Frequency new FC3ReadRegistersTask(31447, Priority.LOW, // - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(31447), - ElementToChannelConverter.SCALE_FACTOR_1))); + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(31447), SCALE_FACTOR_1))); // Calculates required Channels from other existing Channels. this.addCalculateChannelListeners(); diff --git a/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/singlephase/SocomecMeterSinglephaseImpl.java b/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/singlephase/SocomecMeterSinglephaseImpl.java index 274f774af04..ef774368a8f 100644 --- a/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/singlephase/SocomecMeterSinglephaseImpl.java +++ b/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/singlephase/SocomecMeterSinglephaseImpl.java @@ -1,5 +1,10 @@ package io.openems.edge.meter.socomec.singlephase; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SET_ZERO_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.chain; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -17,8 +22,6 @@ import io.openems.common.channel.AccessMode; import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverterChain; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; import io.openems.edge.bridge.modbus.api.element.SignedDoublewordElement; @@ -100,96 +103,71 @@ protected void identifiedCountisE14() throws OpenemsException { this.modbusProtocol.addTask(// new FC3ReadRegistersTask(0xc558, Priority.HIGH, // m(new UnsignedDoublewordElement(0xc558)) // - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.SCALE_FACTOR_1) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new ElementToChannelConverterChain(// - ElementToChannelConverter.SCALE_FACTOR_1, // - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1))) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new ElementToChannelConverterChain(// - ElementToChannelConverter.SCALE_FACTOR_1, // - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2))) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new ElementToChannelConverterChain(// - ElementToChannelConverter.SCALE_FACTOR_1, // - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3))) // + .m(SymmetricMeter.ChannelId.VOLTAGE, SCALE_FACTOR_1) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, + chain(// + SCALE_FACTOR_1, // + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1))) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L2, chain(// + SCALE_FACTOR_1, // + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2))) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L3, chain(// + SCALE_FACTOR_1, // + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3))) // .build(), // new DummyRegisterElement(0xc55A, 0xc55D), // m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E)), // m(new UnsignedDoublewordElement(0xc560)) // - .m(SymmetricMeter.ChannelId.CURRENT, ElementToChannelConverter.SCALE_FACTOR_1) // + .m(SymmetricMeter.ChannelId.CURRENT, SCALE_FACTOR_1) // .m(AsymmetricMeter.ChannelId.CURRENT_L1, - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1)) // + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1)) // .m(AsymmetricMeter.ChannelId.CURRENT_L2, - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2)) // + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2)) // .m(AsymmetricMeter.ChannelId.CURRENT_L3, - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3)) // + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3)) // .build(), // new DummyRegisterElement(0xc562, 0xc567), // m(new SignedDoublewordElement(0xc568)) // .m(SymmetricMeter.ChannelId.ACTIVE_POWER, - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())) - .m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, // - new ElementToChannelConverterChain(// - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1))) // - .m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, // - new ElementToChannelConverterChain(// - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2))) // - .m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, // - new ElementToChannelConverterChain(// - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3))) // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())) + .m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, chain(// + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1))) // + .m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, chain(// + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2))) // + .m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, chain(// + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3))) // .build(), // m(new SignedDoublewordElement(0xc56A)) // .m(SymmetricMeter.ChannelId.REACTIVE_POWER, - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())) - .m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, // - new ElementToChannelConverterChain(// - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1))) // - .m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, // - new ElementToChannelConverterChain(// - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2))) // - .m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, // - new ElementToChannelConverterChain(// - ElementToChannelConverter - .SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), - ElementToChannelConverter - .SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3))) // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())) + .m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, chain(// + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L1))) // + .m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, chain(// + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L2))) // + .m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, chain(// + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert()), + SET_ZERO_IF_TRUE(this.config.phase() != SinglePhase.L3))) // .build())); if (this.config.invert()) { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } else { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } } diff --git a/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/threephase/SocomecMeterThreephaseImpl.java b/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/threephase/SocomecMeterThreephaseImpl.java index 47065411a3d..86aae24ab0e 100644 --- a/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/threephase/SocomecMeterThreephaseImpl.java +++ b/io.openems.edge.meter.socomec/src/io/openems/edge/meter/socomec/threephase/SocomecMeterThreephaseImpl.java @@ -1,5 +1,10 @@ package io.openems.edge.meter.socomec.threephase; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import java.util.function.Consumer; import org.osgi.service.cm.ConfigurationAdmin; @@ -19,7 +24,6 @@ import io.openems.common.channel.AccessMode; import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; import io.openems.edge.bridge.modbus.api.element.SignedDoublewordElement; @@ -95,54 +99,50 @@ public MeterType getMeterType() { protected void identifiedCountisE23_E24_E27_E28() throws OpenemsException { this.modbusProtocol.addTask(// new FC3ReadRegistersTask(0xc558, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), SCALE_FACTOR_1), // m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E)), // m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedDoublewordElement(0xc560)), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedDoublewordElement(0xc562)), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedDoublewordElement(0xc564)), // new DummyRegisterElement(0xc566, 0xc567), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(0xc568), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(0xc56A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // new DummyRegisterElement(0xc56C, 0xc56F), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(0xc570), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(0xc572), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(0xc574), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(0xc576), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(0xc578), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(0xc57A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // new DummyRegisterElement(0xC57C, 0xC587), // m(SymmetricMeter.ChannelId.CURRENT, new UnsignedDoublewordElement(0xC588)), // new DummyRegisterElement(0xC58A, 0xC58B), // - m(SymmetricMeter.ChannelId.VOLTAGE, new UnsignedDoublewordElement(0xC58C), - ElementToChannelConverter.SCALE_FACTOR_1))); // + m(SymmetricMeter.ChannelId.VOLTAGE, new UnsignedDoublewordElement(0xC58C), SCALE_FACTOR_1))); // if (this.config.invert()) { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } else { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } } @@ -151,35 +151,31 @@ protected void identifiedCountisE23_E24_E27_E28() throws OpenemsException { protected void identifiedCountisE34_E44() throws OpenemsException { this.modbusProtocol.addTask(// new FC3ReadRegistersTask(0xc558, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), SCALE_FACTOR_1), // + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E), SCALE_FACTOR_1), // m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedDoublewordElement(0xc560)), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedDoublewordElement(0xc562)), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedDoublewordElement(0xc564)), // new DummyRegisterElement(0xc566, 0xc567), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(0xc568), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(0xc56A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // new DummyRegisterElement(0xc56C, 0xc56F), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(0xc570), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(0xc572), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(0xc574), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(0xc576), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(0xc578), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(0xc57A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())))); + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())))); this.calculateSumCurrent(); this.calculateAverageVoltage(); @@ -187,18 +183,18 @@ protected void identifiedCountisE34_E44() throws OpenemsException { if (this.config.invert()) { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } else { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } } @@ -207,35 +203,31 @@ protected void identifiedCountisE34_E44() throws OpenemsException { protected void identifiedDirisA14() throws OpenemsException { this.modbusProtocol.addTask(// new FC3ReadRegistersTask(0xc558, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), SCALE_FACTOR_1), // + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E), SCALE_FACTOR_1), // m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedDoublewordElement(0xc560)), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedDoublewordElement(0xc562)), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedDoublewordElement(0xc564)), // new DummyRegisterElement(0xc566, 0xc567), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(0xc568), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(0xc56A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // new DummyRegisterElement(0xc56C, 0xc56F), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(0xc570), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(0xc572), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(0xc574), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(0xc576), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(0xc578), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(0xc57A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())))); // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())))); // this.calculateSumCurrent(); this.calculateAverageVoltage(); @@ -243,18 +235,18 @@ protected void identifiedDirisA14() throws OpenemsException { if (this.config.invert()) { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } else { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC702, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC702), - ElementToChannelConverter.SCALE_FACTOR_1), // + SCALE_FACTOR_1), // new DummyRegisterElement(0xC704, 0xC707), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC708), - ElementToChannelConverter.SCALE_FACTOR_1) // + SCALE_FACTOR_1) // )); } } @@ -263,35 +255,31 @@ protected void identifiedDirisA14() throws OpenemsException { protected void identifiedDirisA10() throws OpenemsException { this.modbusProtocol.addTask(// new FC3ReadRegistersTask(0xc558, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0xc558), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0xc55A), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0xc55C), SCALE_FACTOR_1), // + m(SymmetricMeter.ChannelId.FREQUENCY, new UnsignedDoublewordElement(0xc55E), SCALE_FACTOR_1), // m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedDoublewordElement(0xc560)), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedDoublewordElement(0xc562)), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedDoublewordElement(0xc564)), // new DummyRegisterElement(0xc566, 0xc567), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(0xc568), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(0xc56A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // new DummyRegisterElement(0xc56C, 0xc56F), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(0xc570), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(0xc572), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(0xc574), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(0xc576), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(0xc578), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(0xc57A), - ElementToChannelConverter.SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())))); // + SCALE_FACTOR_1_AND_INVERT_IF_TRUE(this.config.invert())))); // this.calculateSumCurrent(); this.calculateAverageVoltage(); @@ -299,18 +287,18 @@ protected void identifiedDirisA10() throws OpenemsException { if (this.config.invert()) { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC65C, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC65C), - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0xC65E, 0xC661), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC662), - ElementToChannelConverter.SCALE_FACTOR_3) // + SCALE_FACTOR_3) // )); } else { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0xC65C, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0xC65C), - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0xC65E, 0xC661), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0xC662), - ElementToChannelConverter.SCALE_FACTOR_3) // + SCALE_FACTOR_3) // )); } } @@ -319,34 +307,31 @@ protected void identifiedDirisA10() throws OpenemsException { protected void identifiedDirisB30() throws OpenemsException { this.modbusProtocol.addTask(// new FC3ReadRegistersTask(0x480C, Priority.HIGH, // - m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0x480C), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0x480E), - ElementToChannelConverter.SCALE_FACTOR_1), // - m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0x4810), - ElementToChannelConverter.SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(0x480C), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(0x480E), SCALE_FACTOR_1), // + m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(0x4810), SCALE_FACTOR_1), // new DummyRegisterElement(0x4812, 0x4819), // m(AsymmetricMeter.ChannelId.CURRENT_L1, new UnsignedDoublewordElement(0x481A)), // m(AsymmetricMeter.ChannelId.CURRENT_L2, new UnsignedDoublewordElement(0x481C)), // m(AsymmetricMeter.ChannelId.CURRENT_L3, new UnsignedDoublewordElement(0x481E)), // new DummyRegisterElement(0x4820, 0x482B), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(0x482C), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(0x482E), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // new DummyRegisterElement(0x4830, 0x4837), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new SignedDoublewordElement(0x4838), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new SignedDoublewordElement(0x483A), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new SignedDoublewordElement(0x483C), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new SignedDoublewordElement(0x483E), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new SignedDoublewordElement(0x4840), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new SignedDoublewordElement(0x4842), // - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())) // + INVERT_IF_TRUE(this.config.invert())) // )); this.calculateSumCurrent(); @@ -355,18 +340,18 @@ protected void identifiedDirisB30() throws OpenemsException { if (this.config.invert()) { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0x4D83, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0x4D83), - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x4D85), // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0x4D86), - ElementToChannelConverter.SCALE_FACTOR_3) // + SCALE_FACTOR_3) // )); } else { this.modbusProtocol.addTask(new FC3ReadRegistersTask(0x4D83, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new UnsignedDoublewordElement(0x4D83), - ElementToChannelConverter.SCALE_FACTOR_3), // + SCALE_FACTOR_3), // new DummyRegisterElement(0x4D85), // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new UnsignedDoublewordElement(0x4D86), - ElementToChannelConverter.SCALE_FACTOR_3) // + SCALE_FACTOR_3) // )); } } diff --git a/io.openems.edge.meter.sunspec/src/io/openems/edge/meter/sunspec/AbstractSunSpecMeter.java b/io.openems.edge.meter.sunspec/src/io/openems/edge/meter/sunspec/AbstractSunSpecMeter.java index 71ab20f08a4..4de550eb262 100644 --- a/io.openems.edge.meter.sunspec/src/io/openems/edge/meter/sunspec/AbstractSunSpecMeter.java +++ b/io.openems.edge.meter.sunspec/src/io/openems/edge/meter/sunspec/AbstractSunSpecMeter.java @@ -1,5 +1,9 @@ package io.openems.edge.meter.sunspec; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import java.util.Map; import java.util.Optional; @@ -10,7 +14,6 @@ import org.slf4j.LoggerFactory; import io.openems.common.exceptions.OpenemsException; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.sunspec.AbstractOpenemsSunSpecComponent; import io.openems.edge.bridge.modbus.sunspec.DefaultSunSpecModel; import io.openems.edge.bridge.modbus.sunspec.SunSpecModel; @@ -68,32 +71,32 @@ protected void onSunSpecInitializationCompleted() { */ this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.FREQUENCY, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.HZ, DefaultSunSpecModel.S203.HZ, DefaultSunSpecModel.S202.HZ, DefaultSunSpecModel.S201.HZ); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.ACTIVE_POWER, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.W, DefaultSunSpecModel.S203.W, DefaultSunSpecModel.S202.W, DefaultSunSpecModel.S201.W); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.REACTIVE_POWER, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.VAR, DefaultSunSpecModel.S203.VAR, DefaultSunSpecModel.S202.VAR, DefaultSunSpecModel.S201.VAR); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_EXP, DefaultSunSpecModel.S203.TOT_WH_EXP, DefaultSunSpecModel.S202.TOT_WH_EXP, DefaultSunSpecModel.S201.TOT_WH_EXP); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_IMP, DefaultSunSpecModel.S203.TOT_WH_IMP, DefaultSunSpecModel.S202.TOT_WH_IMP, DefaultSunSpecModel.S201.TOT_WH_IMP); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.VOLTAGE, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.PH_V, DefaultSunSpecModel.S203.PH_V, DefaultSunSpecModel.S202.PH_V, DefaultSunSpecModel.S201.PH_V, // DefaultSunSpecModel.S204.PH_VPH_A, DefaultSunSpecModel.S203.PH_VPH_A, DefaultSunSpecModel.S202.PH_VPH_A, @@ -104,7 +107,7 @@ protected void onSunSpecInitializationCompleted() { DefaultSunSpecModel.S201.PH_VPH_C); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.CURRENT, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.A, DefaultSunSpecModel.S203.A, DefaultSunSpecModel.S202.A, DefaultSunSpecModel.S201.A); @@ -113,92 +116,92 @@ protected void onSunSpecInitializationCompleted() { */ this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.WPH_A, DefaultSunSpecModel.S203.WPH_A, DefaultSunSpecModel.S202.WPH_A, DefaultSunSpecModel.S201.WPH_A); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.WPH_B, DefaultSunSpecModel.S203.WPH_B, DefaultSunSpecModel.S202.WPH_B, DefaultSunSpecModel.S201.WPH_B); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.WPH_C, DefaultSunSpecModel.S203.WPH_C, DefaultSunSpecModel.S202.WPH_C, DefaultSunSpecModel.S201.WPH_C); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.CURRENT_L1, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.APH_A, DefaultSunSpecModel.S203.APH_A, DefaultSunSpecModel.S202.APH_A, DefaultSunSpecModel.S201.APH_A); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.CURRENT_L2, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.APH_B, DefaultSunSpecModel.S203.APH_B, DefaultSunSpecModel.S202.APH_B, DefaultSunSpecModel.S201.APH_B); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.CURRENT_L3, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.APH_C, DefaultSunSpecModel.S203.APH_C, DefaultSunSpecModel.S202.APH_C, DefaultSunSpecModel.S201.APH_C); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.V_A_RPH_A, DefaultSunSpecModel.S203.V_A_RPH_A, DefaultSunSpecModel.S202.V_A_RPH_A, DefaultSunSpecModel.S201.V_A_RPH_A); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.V_A_RPH_B, DefaultSunSpecModel.S203.V_A_RPH_B, DefaultSunSpecModel.S202.V_A_RPH_B, DefaultSunSpecModel.S201.V_A_RPH_B); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, // - ElementToChannelConverter.INVERT, // + INVERT, // DefaultSunSpecModel.S204.V_A_RPH_C, DefaultSunSpecModel.S203.V_A_RPH_C, DefaultSunSpecModel.S202.V_A_RPH_C, DefaultSunSpecModel.S201.V_A_RPH_C); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.VOLTAGE_L1, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.PH_VPH_A, DefaultSunSpecModel.S203.PH_VPH_A, DefaultSunSpecModel.S202.PH_VPH_A, DefaultSunSpecModel.S201.PH_VPH_A); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.VOLTAGE_L2, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.PH_VPH_B, DefaultSunSpecModel.S203.PH_VPH_B, DefaultSunSpecModel.S202.PH_VPH_B, DefaultSunSpecModel.S201.PH_VPH_B); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.VOLTAGE_L3, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S204.PH_VPH_C, DefaultSunSpecModel.S203.PH_VPH_C, DefaultSunSpecModel.S202.PH_VPH_C, DefaultSunSpecModel.S201.PH_VPH_C); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L1, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_EXP_PH_A, DefaultSunSpecModel.S203.TOT_WH_EXP_PH_A, DefaultSunSpecModel.S202.TOT_WH_EXP_PH_A, DefaultSunSpecModel.S201.TOT_WH_EXP_PH_A); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L2, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_EXP_PH_B, DefaultSunSpecModel.S203.TOT_WH_EXP_PH_B, DefaultSunSpecModel.S202.TOT_WH_EXP_PH_B, DefaultSunSpecModel.S201.TOT_WH_EXP_PH_B); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L3, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_EXP_PH_C, DefaultSunSpecModel.S203.TOT_WH_EXP_PH_C, DefaultSunSpecModel.S202.TOT_WH_EXP_PH_C, DefaultSunSpecModel.S201.TOT_WH_EXP_PH_C); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L1, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_IMP_PH_A, DefaultSunSpecModel.S203.TOT_WH_IMP_PH_A, DefaultSunSpecModel.S202.TOT_WH_IMP_PH_A, DefaultSunSpecModel.S201.TOT_WH_IMP_PH_A); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L2, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_IMP_PH_B, DefaultSunSpecModel.S203.TOT_WH_IMP_PH_B, DefaultSunSpecModel.S202.TOT_WH_IMP_PH_B, DefaultSunSpecModel.S201.TOT_WH_IMP_PH_B); this.mapFirstPointToChannel(// AsymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY_L3, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S204.TOT_WH_IMP_PH_C, DefaultSunSpecModel.S203.TOT_WH_IMP_PH_C, DefaultSunSpecModel.S202.TOT_WH_IMP_PH_C, DefaultSunSpecModel.S201.TOT_WH_IMP_PH_C); } diff --git a/io.openems.edge.meter.weidmueller/src/io/openems/edge/meter/weidmueller/MeterWeidmueller525.java b/io.openems.edge.meter.weidmueller/src/io/openems/edge/meter/weidmueller/MeterWeidmueller525.java index 0901a261e0a..d0ac84ef3d7 100644 --- a/io.openems.edge.meter.weidmueller/src/io/openems/edge/meter/weidmueller/MeterWeidmueller525.java +++ b/io.openems.edge.meter.weidmueller/src/io/openems/edge/meter/weidmueller/MeterWeidmueller525.java @@ -1,5 +1,7 @@ package io.openems.edge.meter.weidmueller; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -16,7 +18,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.FloatDoublewordElement; @@ -81,8 +82,8 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { return new ModbusProtocol(this, // new FC3ReadRegistersTask(19000, Priority.HIGH, // m(new FloatDoublewordElement(19000)) // - .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, ElementToChannelConverter.DIRECT_1_TO_1) // - .m(SymmetricMeter.ChannelId.VOLTAGE, ElementToChannelConverter.DIRECT_1_TO_1) // + .m(AsymmetricMeter.ChannelId.VOLTAGE_L1, DIRECT_1_TO_1) // + .m(SymmetricMeter.ChannelId.VOLTAGE, DIRECT_1_TO_1) // .build(), // m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(19002)), // m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(19004)), // diff --git a/io.openems.edge.meter.ziehl/src/io/openems/edge/meter/ziehl/efr4001ip/MeterZiehlEfr4001IpImpl.java b/io.openems.edge.meter.ziehl/src/io/openems/edge/meter/ziehl/efr4001ip/MeterZiehlEfr4001IpImpl.java index 148c3454d21..d6bba60dc0d 100644 --- a/io.openems.edge.meter.ziehl/src/io/openems/edge/meter/ziehl/efr4001ip/MeterZiehlEfr4001IpImpl.java +++ b/io.openems.edge.meter.ziehl/src/io/openems/edge/meter/ziehl/efr4001ip/MeterZiehlEfr4001IpImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.meter.ziehl.efr4001ip; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.INVERT_IF_TRUE; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; import static io.openems.edge.bridge.modbus.api.element.WordOrder.LSWMSW; import java.util.function.Consumer; @@ -20,7 +23,6 @@ import io.openems.common.exceptions.OpenemsException; import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.DummyRegisterElement; @@ -91,15 +93,15 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(AsymmetricMeter.ChannelId.VOLTAGE_L1, // new UnsignedDoublewordElement(startingRegister) // .wordOrder(LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(AsymmetricMeter.ChannelId.VOLTAGE_L2, // new UnsignedDoublewordElement(startingRegister + 2) // 0x00B2 .wordOrder(LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(AsymmetricMeter.ChannelId.VOLTAGE_L3, // new UnsignedDoublewordElement(startingRegister + 4) // 0x00B4 .wordOrder(LSWMSW), // - ElementToChannelConverter.SCALE_FACTOR_2), // + SCALE_FACTOR_2), // m(AsymmetricMeter.ChannelId.CURRENT_L1, // new UnsignedDoublewordElement(startingRegister + 6) // 0x00B6 .wordOrder(LSWMSW)), // @@ -115,36 +117,36 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, // new SignedDoublewordElement(startingRegister + 14) // 0x00BE .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, // new SignedDoublewordElement(startingRegister + 16) // 0x00C0 .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.ACTIVE_POWER, // new SignedDoublewordElement(startingRegister + 18) // 0x00C2 .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, // new SignedDoublewordElement(startingRegister + 20) // 0x00C4 .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, // new SignedDoublewordElement(startingRegister + 22) // 0x00C6 .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, // new SignedDoublewordElement(startingRegister + 24) // 0x00C8 .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), // + INVERT_IF_TRUE(this.config.invert())), // m(SymmetricMeter.ChannelId.REACTIVE_POWER, // new SignedDoublewordElement(startingRegister + 26) // 0x00CA .wordOrder(LSWMSW), - ElementToChannelConverter.INVERT_IF_TRUE(this.config.invert())), + INVERT_IF_TRUE(this.config.invert())), new DummyRegisterElement(startingRegister + 28, startingRegister + 41), // 0x00CC, 0x00D9 m(SymmetricMeter.ChannelId.FREQUENCY, // new SignedDoublewordElement(startingRegister + 42) // 0x00DA .wordOrder(LSWMSW), - ElementToChannelConverter.SCALE_FACTOR_1))); + SCALE_FACTOR_1))); if (this.config.invert()) { modbusProtocol.addTask(new FC3ReadRegistersTask(startingRegisterFeedIn, Priority.LOW, // m(AsymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY_L1, // diff --git a/io.openems.edge.pvinverter.solarlog/src/io/openems/edge/pvinverter/solarlog/SolarLogImpl.java b/io.openems.edge.pvinverter.solarlog/src/io/openems/edge/pvinverter/solarlog/SolarLogImpl.java index 5c53b2a500d..d01c14e337e 100644 --- a/io.openems.edge.pvinverter.solarlog/src/io/openems/edge/pvinverter/solarlog/SolarLogImpl.java +++ b/io.openems.edge.pvinverter.solarlog/src/io/openems/edge/pvinverter/solarlog/SolarLogImpl.java @@ -1,5 +1,8 @@ package io.openems.edge.pvinverter.solarlog; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_2; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; @@ -22,7 +25,6 @@ import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; import io.openems.edge.bridge.modbus.api.BridgeModbus; import io.openems.edge.bridge.modbus.api.ChannelMetaInfoReadAndWrite; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.api.ModbusComponent; import io.openems.edge.bridge.modbus.api.ModbusProtocol; import io.openems.edge.bridge.modbus.api.element.SignedDoublewordElement; @@ -119,10 +121,8 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SymmetricMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(3502).wordOrder(WordOrder.LSWMSW)), m(SolarLog.ChannelId.PDC, new SignedDoublewordElement(3504).wordOrder(WordOrder.LSWMSW)), - m(SymmetricMeter.ChannelId.VOLTAGE, new SignedWordElement(3506), - ElementToChannelConverter.SCALE_FACTOR_3), - m(SolarLog.ChannelId.UDC, new SignedWordElement(3507), - ElementToChannelConverter.SCALE_FACTOR_2), + m(SymmetricMeter.ChannelId.VOLTAGE, new SignedWordElement(3506), SCALE_FACTOR_3), + m(SolarLog.ChannelId.UDC, new SignedWordElement(3507), SCALE_FACTOR_2), m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new SignedDoublewordElement(3508).wordOrder(WordOrder.LSWMSW)), m(SolarLog.ChannelId.YESTERDAY_YIELD, diff --git a/io.openems.edge.pvinverter.sunspec/src/io/openems/edge/pvinverter/sunspec/AbstractSunSpecPvInverter.java b/io.openems.edge.pvinverter.sunspec/src/io/openems/edge/pvinverter/sunspec/AbstractSunSpecPvInverter.java index 3c0919699ab..972f54a5293 100644 --- a/io.openems.edge.pvinverter.sunspec/src/io/openems/edge/pvinverter/sunspec/AbstractSunSpecPvInverter.java +++ b/io.openems.edge.pvinverter.sunspec/src/io/openems/edge/pvinverter/sunspec/AbstractSunSpecPvInverter.java @@ -1,5 +1,8 @@ package io.openems.edge.pvinverter.sunspec; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.DIRECT_1_TO_1; +import static io.openems.edge.bridge.modbus.api.ElementToChannelConverter.SCALE_FACTOR_3; + import java.util.Map; import java.util.Optional; @@ -15,7 +18,6 @@ import io.openems.common.exceptions.OpenemsError.OpenemsNamedException; import io.openems.common.exceptions.OpenemsException; -import io.openems.edge.bridge.modbus.api.ElementToChannelConverter; import io.openems.edge.bridge.modbus.sunspec.AbstractOpenemsSunSpecComponent; import io.openems.edge.bridge.modbus.sunspec.DefaultSunSpecModel; import io.openems.edge.bridge.modbus.sunspec.SunSpecModel; @@ -165,36 +167,36 @@ protected void onSunSpecInitializationCompleted() { this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.FREQUENCY, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S111.HZ, DefaultSunSpecModel.S112.HZ, DefaultSunSpecModel.S113.HZ, DefaultSunSpecModel.S101.HZ, DefaultSunSpecModel.S102.HZ, DefaultSunSpecModel.S103.HZ); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.ACTIVE_POWER, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S111.W, DefaultSunSpecModel.S112.W, DefaultSunSpecModel.S113.W, DefaultSunSpecModel.S101.W, DefaultSunSpecModel.S102.W, DefaultSunSpecModel.S103.W); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.REACTIVE_POWER, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S111.V_AR, DefaultSunSpecModel.S112.V_AR, DefaultSunSpecModel.S113.V_AR, DefaultSunSpecModel.S101.V_AR, DefaultSunSpecModel.S102.V_AR, DefaultSunSpecModel.S103.V_AR); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S111.WH, DefaultSunSpecModel.S112.WH, DefaultSunSpecModel.S113.WH, DefaultSunSpecModel.S101.WH, DefaultSunSpecModel.S102.WH, DefaultSunSpecModel.S103.WH); this.mapFirstPointToChannel(// ManagedSymmetricPvInverter.ChannelId.MAX_APPARENT_POWER, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S120.W_RTG); this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.CURRENT, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S111.A, DefaultSunSpecModel.S112.A, DefaultSunSpecModel.S113.A, DefaultSunSpecModel.S101.A, DefaultSunSpecModel.S102.A, DefaultSunSpecModel.S103.A); @@ -204,7 +206,7 @@ protected void onSunSpecInitializationCompleted() { if (!this.isSinglePhase) { this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.VOLTAGE, // - ElementToChannelConverter.SCALE_FACTOR_3, // + SCALE_FACTOR_3, // DefaultSunSpecModel.S112.PH_VPH_A, DefaultSunSpecModel.S112.PH_VPH_B, DefaultSunSpecModel.S112.PH_VPH_C, // DefaultSunSpecModel.S113.PH_VPH_A, DefaultSunSpecModel.S113.PH_VPH_B, @@ -224,24 +226,24 @@ protected void onSunSpecInitializationCompleted() { // use l1 when 'ALL' is configured and its not a tree phase inverter case L1: this.mapFirstPointToChannel(AsymmetricMeter.ChannelId.VOLTAGE_L1, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S101.PH_VPH_A, DefaultSunSpecModel.S111.PH_VPH_A); break; case L2: this.mapFirstPointToChannel(AsymmetricMeter.ChannelId.VOLTAGE_L2, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S101.PH_VPH_B, DefaultSunSpecModel.S111.PH_VPH_B); break; case L3: this.mapFirstPointToChannel(AsymmetricMeter.ChannelId.VOLTAGE_L3, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S101.PH_VPH_C, DefaultSunSpecModel.S111.PH_VPH_C); break; } this.mapFirstPointToChannel(// SymmetricMeter.ChannelId.VOLTAGE, // - ElementToChannelConverter.DIRECT_1_TO_1, // + DIRECT_1_TO_1, // DefaultSunSpecModel.S101.PH_VPH_A, DefaultSunSpecModel.S111.PH_VPH_A, // DefaultSunSpecModel.S101.PH_VPH_B, DefaultSunSpecModel.S111.PH_VPH_B, // DefaultSunSpecModel.S101.PH_VPH_C, DefaultSunSpecModel.S111.PH_VPH_C);