From b0a65e9e914510a008146cf7cde96c491044ab91 Mon Sep 17 00:00:00 2001 From: Simon Fey Date: Mon, 22 Nov 2021 16:55:23 +0100 Subject: [PATCH 1/8] initial commit for Siemens PAC 3200 meter --- .../element/FloatQuadruplewordElement.java | 30 +++ io.openems.edge.meter.siemens/.classpath | 12 ++ io.openems.edge.meter.siemens/.gitignore | 2 + io.openems.edge.meter.siemens/.project | 23 +++ io.openems.edge.meter.siemens/bnd.bnd | 14 ++ io.openems.edge.meter.siemens/readme.adoc | 7 + .../io/openems/edge/meter/siemens/Config.java | 38 ++++ .../meter/siemens/SiemensPAC3200Meter.java | 178 ++++++++++++++++++ io.openems.edge.meter.siemens/test/.gitignore | 2 + 9 files changed, 306 insertions(+) create mode 100644 io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/element/FloatQuadruplewordElement.java create mode 100644 io.openems.edge.meter.siemens/.classpath create mode 100644 io.openems.edge.meter.siemens/.gitignore create mode 100644 io.openems.edge.meter.siemens/.project create mode 100644 io.openems.edge.meter.siemens/bnd.bnd create mode 100644 io.openems.edge.meter.siemens/readme.adoc create mode 100644 io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java create mode 100644 io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java create mode 100644 io.openems.edge.meter.siemens/test/.gitignore diff --git a/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/element/FloatQuadruplewordElement.java b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/element/FloatQuadruplewordElement.java new file mode 100644 index 00000000000..7fad114bc35 --- /dev/null +++ b/io.openems.edge.bridge.modbus/src/io/openems/edge/bridge/modbus/api/element/FloatQuadruplewordElement.java @@ -0,0 +1,30 @@ +package io.openems.edge.bridge.modbus.api.element; + +import io.openems.common.types.OpenemsType; + +import java.nio.ByteBuffer; + +/** + * A FloatQuadruplewordElement represents a Float value in an + * {@link AbstractQuadrupleWordElement}. + */ +public class FloatQuadruplewordElement extends AbstractQuadrupleWordElement { + + public FloatQuadruplewordElement(int address) { + super(OpenemsType.DOUBLE, address); + } + + @Override + protected FloatQuadruplewordElement self() { + return this; + } + + protected Double fromByteBuffer(ByteBuffer buff) { + return Double.valueOf(buff.getDouble()); + } + + protected ByteBuffer toByteBuffer(ByteBuffer buff, Double value) { + return buff.putDouble(value.doubleValue()); + } + +} diff --git a/io.openems.edge.meter.siemens/.classpath b/io.openems.edge.meter.siemens/.classpath new file mode 100644 index 00000000000..7a6fc254361 --- /dev/null +++ b/io.openems.edge.meter.siemens/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/io.openems.edge.meter.siemens/.gitignore b/io.openems.edge.meter.siemens/.gitignore new file mode 100644 index 00000000000..e62678f49e9 --- /dev/null +++ b/io.openems.edge.meter.siemens/.gitignore @@ -0,0 +1,2 @@ +/bin_test/ +/generated/ diff --git a/io.openems.edge.meter.siemens/.project b/io.openems.edge.meter.siemens/.project new file mode 100644 index 00000000000..9da930d2c7c --- /dev/null +++ b/io.openems.edge.meter.siemens/.project @@ -0,0 +1,23 @@ + + + io.openems.edge.meter.siemens + + + + + + org.eclipse.jdt.core.javabuilder + + + + + bndtools.core.bndbuilder + + + + + + org.eclipse.jdt.core.javanature + bndtools.core.bndnature + + diff --git a/io.openems.edge.meter.siemens/bnd.bnd b/io.openems.edge.meter.siemens/bnd.bnd new file mode 100644 index 00000000000..9721b7b3285 --- /dev/null +++ b/io.openems.edge.meter.siemens/bnd.bnd @@ -0,0 +1,14 @@ +Bundle-Name: OpenEMS Edge Meter Siemens +Bundle-Description: This implementation covers Siemens PAC3200 +Bundle-Vendor: Ernst KNOLL Feinmechanik GmbH +Bundle-License: https://opensource.org/licenses/EPL-2.0 +Bundle-Version: 1.0.0.${tstamp} + +-buildpath: \ + ${buildpath},\ + io.openems.common,\ + io.openems.edge.bridge.modbus,\ + io.openems.edge.common,\ + io.openems.edge.meter.api +-testpath: \ + ${testpath} \ No newline at end of file diff --git a/io.openems.edge.meter.siemens/readme.adoc b/io.openems.edge.meter.siemens/readme.adoc new file mode 100644 index 00000000000..db2e989ab0e --- /dev/null +++ b/io.openems.edge.meter.siemens/readme.adoc @@ -0,0 +1,7 @@ += Janitza Meters UMG 96RM-E | UMG 604 + +Implemented Natures:: +- SymmetricMeter +- AsymmetricMeter + +https://github.com/OpenEMS/openems/tree/develop/io.openems.edge.meter.janitza[Source Code icon:github[]] \ No newline at end of file diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java new file mode 100644 index 00000000000..da05c7f50b1 --- /dev/null +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java @@ -0,0 +1,38 @@ +package io.openems.edge.meter.siemens; + +import org.osgi.service.metatype.annotations.AttributeDefinition; +import org.osgi.service.metatype.annotations.ObjectClassDefinition; + +import io.openems.edge.meter.api.MeterType; + +@ObjectClassDefinition(// + name = "Siemens 3200", // + description = "Implements the Siemens 3200 power analyser.") +@interface Config { + + @AttributeDefinition(name = "Component-ID", description = "Unique ID of this Component") + String id() default "meter0"; + + @AttributeDefinition(name = "Alias", description = "Human-readable name of this Component; defaults to Component-ID") + String alias() default ""; + + @AttributeDefinition(name = "Is enabled?", description = "Is this Component enabled?") + boolean enabled() default true; + + @AttributeDefinition(name = "Meter-Type", description = "What is measured by this Meter?") + MeterType type() default MeterType.PRODUCTION; + + @AttributeDefinition(name = "Modbus-ID", description = "ID of Modbus bridge.") + String modbus_id() default "modbus0"; + + @AttributeDefinition(name = "Modbus Unit-ID", description = "The Unit-ID of the Modbus device. Defaults to '1' for Modbus/TCP.") + int modbusUnitId() default 1; + + @AttributeDefinition(name = "Invert Power", description = "Inverts all Power values, inverts current values, swaps production and consumption energy, i.e. Power is multiplied with -1.") + boolean invert() default false; + + @AttributeDefinition(name = "Modbus target filter", description = "This is auto-generated by 'Modbus-ID'.") + String Modbus_target() default "(enabled=true)"; + + String webconsole_configurationFactory_nameHint() default "Siemens 3200 [{id}]"; +} \ No newline at end of file diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java new file mode 100644 index 00000000000..93d2816c2b5 --- /dev/null +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java @@ -0,0 +1,178 @@ +package io.openems.edge.meter.siemens; + +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.component.ComponentContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.ConfigurationPolicy; +import org.osgi.service.component.annotations.Deactivate; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferenceCardinality; +import org.osgi.service.component.annotations.ReferencePolicy; +import org.osgi.service.component.annotations.ReferencePolicyOption; +import org.osgi.service.metatype.annotations.Designate; + +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.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; +import io.openems.edge.bridge.modbus.api.element.FloatDoublewordElement; +import io.openems.edge.bridge.modbus.api.element.FloatQuadruplewordElement; +import io.openems.edge.bridge.modbus.api.task.FC3ReadRegistersTask; +import io.openems.edge.common.channel.Doc; +import io.openems.edge.common.component.OpenemsComponent; +import io.openems.edge.common.modbusslave.ModbusSlave; +import io.openems.edge.common.modbusslave.ModbusSlaveTable; +import io.openems.edge.common.taskmanager.Priority; +import io.openems.edge.meter.api.AsymmetricMeter; +import io.openems.edge.meter.api.MeterType; +import io.openems.edge.meter.api.SymmetricMeter; + +/** + * Implements the Siemens PAC3200 power meter. + * + *

+ * https://cache.industry.siemens.com/dl/files/150/26504150/att_906558/v1/A5E01168664B-04_EN-US_122016_201612221316360495.pdf + */ +@Designate(ocd = Config.class, factory = true) +@Component( + name = "Meter.Siemens.PAC3200", + immediate = true, + configurationPolicy = ConfigurationPolicy.REQUIRE) +public class SiemensPAC3200Meter extends AbstractOpenemsModbusComponent + implements SymmetricMeter, AsymmetricMeter, ModbusComponent, OpenemsComponent, ModbusSlave { + + private MeterType meterType = MeterType.PRODUCTION; + + /* + * Invert power values + */ + private boolean invert = false; + + @Reference + protected ConfigurationAdmin cm; + + public SiemensPAC3200Meter() { + super(// + OpenemsComponent.ChannelId.values(), // + ModbusComponent.ChannelId.values(), // + SymmetricMeter.ChannelId.values(), // + AsymmetricMeter.ChannelId.values(), // + ChannelId.values() // + ); + } + + @Reference(policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.MANDATORY) + protected void setModbus(BridgeModbus modbus) { + super.setModbus(modbus); + } + + @Activate + void activate(ComponentContext context, Config config) throws OpenemsException { + this.meterType = config.type(); + this.invert = config.invert(); + + if (super.activate(context, config.id(), config.alias(), config.enabled(), config.modbusUnitId(), this.cm, + "Modbus", config.modbus_id())) { + return; + } + } + + @Deactivate + protected void deactivate() { + super.deactivate(); + } + + public enum ChannelId implements io.openems.edge.common.channel.ChannelId { + ; + private final Doc doc; + + private ChannelId(Doc doc) { + this.doc = doc; + } + + public Doc doc() { + return this.doc; + } + } + + @Override + public MeterType getMeterType() { + return this.meterType; + } + + @Override + protected ModbusProtocol defineModbusProtocol() throws OpenemsException { + + ModbusProtocol 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), + new DummyRegisterElement(7, 12), // + m(AsymmetricMeter.ChannelId.CURRENT_L1, new FloatDoublewordElement(13), + ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.CURRENT_L2, new FloatDoublewordElement(15), + ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.CURRENT_L3, new FloatDoublewordElement(17), + ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.invert)), + new DummyRegisterElement(19, 24), // + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L1, new FloatDoublewordElement(25), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L2, new FloatDoublewordElement(27), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.ACTIVE_POWER_L3, new FloatDoublewordElement(29), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L1, new FloatDoublewordElement(31), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L2, new FloatDoublewordElement(33), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + m(AsymmetricMeter.ChannelId.REACTIVE_POWER_L3, new FloatDoublewordElement(35), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + new DummyRegisterElement(37, 60), // + m(SymmetricMeter.ChannelId.CURRENT, new FloatDoublewordElement(61), + ElementToChannelConverter.SCALE_FACTOR_3_AND_INVERT_IF_TRUE(this.invert)), + new DummyRegisterElement(63, 64), // + m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(65), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), + m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(67), + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)) + )); + if (this.invert) { + modbusProtocol.addTask(new FC3ReadRegistersTask(801, Priority.LOW, // + m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatQuadruplewordElement(801)), + new DummyRegisterElement(805, 808), // + m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(809)))); + } else { + modbusProtocol.addTask(new FC3ReadRegistersTask(801, Priority.LOW, // + m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(801)), + new DummyRegisterElement(805, 808), // + m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatQuadruplewordElement(809)))); + } + + return modbusProtocol; + } + + @Override + public String debugLog() { + return "L:" + this.getActivePower().asString(); + } + + @Override + public ModbusSlaveTable getModbusSlaveTable(AccessMode accessMode) { + return new ModbusSlaveTable(// + OpenemsComponent.getModbusSlaveNatureTable(accessMode), // + SymmetricMeter.getModbusSlaveNatureTable(accessMode), // + AsymmetricMeter.getModbusSlaveNatureTable(accessMode) // + ); + } +} + + diff --git a/io.openems.edge.meter.siemens/test/.gitignore b/io.openems.edge.meter.siemens/test/.gitignore new file mode 100644 index 00000000000..e62678f49e9 --- /dev/null +++ b/io.openems.edge.meter.siemens/test/.gitignore @@ -0,0 +1,2 @@ +/bin_test/ +/generated/ From f324d486178b9f12734e913dd87135158751e1b9 Mon Sep 17 00:00:00 2001 From: Simon Fey Date: Mon, 6 Dec 2021 09:32:00 +0100 Subject: [PATCH 2/8] fixed import/export invert for siemens historic energy values. --- .../openems/edge/meter/siemens/SiemensPAC3200Meter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java index 93d2816c2b5..6c86608fb7d 100644 --- a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java @@ -147,14 +147,14 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { )); if (this.invert) { modbusProtocol.addTask(new FC3ReadRegistersTask(801, Priority.LOW, // - m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatQuadruplewordElement(801)), + m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(801)), new DummyRegisterElement(805, 808), // - m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(809)))); + m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatQuadruplewordElement(809)))); } else { modbusProtocol.addTask(new FC3ReadRegistersTask(801, Priority.LOW, // - m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(801)), + m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatQuadruplewordElement(801)), new DummyRegisterElement(805, 808), // - m(SymmetricMeter.ChannelId.ACTIVE_PRODUCTION_ENERGY, new FloatQuadruplewordElement(809)))); + m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(809)))); } return modbusProtocol; From 6eb40206482f318f786e1d48d2b7b52b128f77fe Mon Sep 17 00:00:00 2001 From: Simon Fey Date: Mon, 6 Dec 2021 10:07:58 +0100 Subject: [PATCH 3/8] verified compatibility with PAC2200 and PAC4200 --- io.openems.edge.meter.siemens/bnd.bnd | 2 +- .../src/io/openems/edge/meter/siemens/Config.java | 6 +++--- .../{SiemensPAC3200Meter.java => SiemensPACMeter.java} | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) rename io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/{SiemensPAC3200Meter.java => SiemensPACMeter.java} (97%) diff --git a/io.openems.edge.meter.siemens/bnd.bnd b/io.openems.edge.meter.siemens/bnd.bnd index 9721b7b3285..05d9bc3c30f 100644 --- a/io.openems.edge.meter.siemens/bnd.bnd +++ b/io.openems.edge.meter.siemens/bnd.bnd @@ -1,5 +1,5 @@ Bundle-Name: OpenEMS Edge Meter Siemens -Bundle-Description: This implementation covers Siemens PAC3200 +Bundle-Description: This implementation covers Siemens PAC2200/3200/4200 Bundle-Vendor: Ernst KNOLL Feinmechanik GmbH Bundle-License: https://opensource.org/licenses/EPL-2.0 Bundle-Version: 1.0.0.${tstamp} diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java index da05c7f50b1..c57f99c9f3b 100644 --- a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java @@ -6,8 +6,8 @@ import io.openems.edge.meter.api.MeterType; @ObjectClassDefinition(// - name = "Siemens 3200", // - description = "Implements the Siemens 3200 power analyser.") + name = "Siemens PAC 2200 3200 4200", // + description = "Implements the Siemens PAC 2200/3200/4200 power analyser.") @interface Config { @AttributeDefinition(name = "Component-ID", description = "Unique ID of this Component") @@ -34,5 +34,5 @@ @AttributeDefinition(name = "Modbus target filter", description = "This is auto-generated by 'Modbus-ID'.") String Modbus_target() default "(enabled=true)"; - String webconsole_configurationFactory_nameHint() default "Siemens 3200 [{id}]"; + String webconsole_configurationFactory_nameHint() default "Siemens PAC 2200/3200/4200 [{id}]"; } \ No newline at end of file diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPACMeter.java similarity index 97% rename from io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java rename to io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPACMeter.java index 6c86608fb7d..41117a50323 100644 --- a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPAC3200Meter.java +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPACMeter.java @@ -33,17 +33,17 @@ import io.openems.edge.meter.api.SymmetricMeter; /** - * Implements the Siemens PAC3200 power meter. + * Implements the Siemens PAC2200/3200/4200 power meter. * *

* https://cache.industry.siemens.com/dl/files/150/26504150/att_906558/v1/A5E01168664B-04_EN-US_122016_201612221316360495.pdf */ @Designate(ocd = Config.class, factory = true) @Component( - name = "Meter.Siemens.PAC3200", + name = "Meter.Siemens.PAC.2200.3200.4200", immediate = true, configurationPolicy = ConfigurationPolicy.REQUIRE) -public class SiemensPAC3200Meter extends AbstractOpenemsModbusComponent +public class SiemensPACMeter extends AbstractOpenemsModbusComponent implements SymmetricMeter, AsymmetricMeter, ModbusComponent, OpenemsComponent, ModbusSlave { private MeterType meterType = MeterType.PRODUCTION; @@ -56,7 +56,7 @@ public class SiemensPAC3200Meter extends AbstractOpenemsModbusComponent @Reference protected ConfigurationAdmin cm; - public SiemensPAC3200Meter() { + public SiemensPACMeter() { super(// OpenemsComponent.ChannelId.values(), // ModbusComponent.ChannelId.values(), // From d22a64370284334c77c2765516a3a25d7b1aa591 Mon Sep 17 00:00:00 2001 From: Simon Fey Date: Mon, 6 Dec 2021 10:08:48 +0100 Subject: [PATCH 4/8] Added Siemens PAC Meters to runbundles. --- io.openems.edge.application/EdgeApp.bndrun | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/io.openems.edge.application/EdgeApp.bndrun b/io.openems.edge.application/EdgeApp.bndrun index 8a8fe54c59a..ad786707c97 100644 --- a/io.openems.edge.application/EdgeApp.bndrun +++ b/io.openems.edge.application/EdgeApp.bndrun @@ -151,7 +151,7 @@ bnd.identity;id='io.openems.edge.timeofusetariff.awattar',\ bnd.identity;id='io.openems.edge.timeofusetariff.corrently',\ bnd.identity;id='io.openems.edge.timeofusetariff.tibber',\ - + bnd.identity;id='io.openems.edge.meter.siemens';version=latest -runbundles: \ Java-WebSocket;version='[1.5.2,1.5.3)',\ com.fazecast.jSerialComm;version='[2.5.1,2.5.2)',\ @@ -327,4 +327,5 @@ org.ops4j.pax.logging.pax-logging-log4j1;version='[2.0.10,2.0.11)',\ org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.2.0,1.2.1)',\ - rrd4j;version='[3.8.0,3.8.1)' \ No newline at end of file + rrd4j;version='[3.8.0,3.8.1)',\ + io.openems.edge.meter.siemens;version=snapshot \ No newline at end of file From 771c4b7402890a78f3a50c40ca4d400439a62dcb Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Tue, 7 Dec 2021 22:18:04 +0100 Subject: [PATCH 5/8] Sort EdgeApp.bndrun (automated via tools/prepare-commit.sh) --- io.openems.edge.application/EdgeApp.bndrun | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/io.openems.edge.application/EdgeApp.bndrun b/io.openems.edge.application/EdgeApp.bndrun index ad786707c97..c7d42607afc 100644 --- a/io.openems.edge.application/EdgeApp.bndrun +++ b/io.openems.edge.application/EdgeApp.bndrun @@ -127,6 +127,7 @@ bnd.identity;id='io.openems.edge.meter.microcare.sdm630',\ bnd.identity;id='io.openems.edge.meter.pqplus',\ bnd.identity;id='io.openems.edge.meter.schneider.acti9.smartlink',\ + bnd.identity;id='io.openems.edge.meter.siemens',\ bnd.identity;id='io.openems.edge.meter.sma.shm20',\ bnd.identity;id='io.openems.edge.meter.socomec',\ bnd.identity;id='io.openems.edge.meter.sunspec',\ @@ -268,6 +269,7 @@ io.openems.edge.meter.microcare.sdm630;version=snapshot,\ io.openems.edge.meter.pqplus;version=snapshot,\ io.openems.edge.meter.schneider.acti9.smartlink;version=snapshot,\ + io.openems.edge.meter.siemens;version=snapshot,\ io.openems.edge.meter.sma.shm20;version=snapshot,\ io.openems.edge.meter.socomec;version=snapshot,\ io.openems.edge.meter.sunspec;version=snapshot,\ @@ -327,5 +329,4 @@ org.ops4j.pax.logging.pax-logging-log4j1;version='[2.0.10,2.0.11)',\ org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.2.0,1.2.1)',\ - rrd4j;version='[3.8.0,3.8.1)',\ - io.openems.edge.meter.siemens;version=snapshot \ No newline at end of file + rrd4j;version='[3.8.0,3.8.1)' \ No newline at end of file From 6dbbac3cf40c912536fd451828f1e646198041e0 Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Tue, 7 Dec 2021 23:19:50 +0100 Subject: [PATCH 6/8] Update classpath to Java 11 --- io.openems.edge.meter.siemens/.classpath | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.openems.edge.meter.siemens/.classpath b/io.openems.edge.meter.siemens/.classpath index 7a6fc254361..43d68895d03 100644 --- a/io.openems.edge.meter.siemens/.classpath +++ b/io.openems.edge.meter.siemens/.classpath @@ -1,7 +1,7 @@ - + From 2f5e90f20a0ec8bb0f37ec075ebb9ead33e78c4e Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Tue, 7 Dec 2021 23:35:15 +0100 Subject: [PATCH 7/8] Remove duplicated line --- io.openems.edge.application/EdgeApp.bndrun | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io.openems.edge.application/EdgeApp.bndrun b/io.openems.edge.application/EdgeApp.bndrun index 5bbab4821c5..44677ed3645 100644 --- a/io.openems.edge.application/EdgeApp.bndrun +++ b/io.openems.edge.application/EdgeApp.bndrun @@ -152,7 +152,7 @@ bnd.identity;id='io.openems.edge.timeofusetariff.awattar',\ bnd.identity;id='io.openems.edge.timeofusetariff.corrently',\ bnd.identity;id='io.openems.edge.timeofusetariff.tibber',\ - bnd.identity;id='io.openems.edge.meter.siemens';version=latest + -runbundles: \ Java-WebSocket;version='[1.5.2,1.5.3)',\ com.fazecast.jSerialComm;version='[2.5.1,2.5.2)',\ @@ -329,4 +329,4 @@ org.ops4j.pax.logging.pax-logging-log4j1;version='[2.0.10,2.0.11)',\ org.osgi.util.function;version='[1.2.0,1.2.1)',\ org.osgi.util.promise;version='[1.2.0,1.2.1)',\ - rrd4j;version='[3.8.0,3.8.1)' \ No newline at end of file + rrd4j;version='[3.8.0,3.8.1)' From e9fc567fbf4bbffb0bb82184c59a26bfb18cd92d Mon Sep 17 00:00:00 2001 From: Stefan Feilmeier Date: Wed, 22 Dec 2021 14:46:23 +0100 Subject: [PATCH 8/8] Review + apply best practices - split interface and impl - fix readme - align name/nameHint in Config (so that it shows up nicely in Apache Felix WebConsole) - simplify meter Component Name (otherwise it would cause too many subfolders in Apache Felix Configuration Admin directory) --- io.openems.edge.meter.siemens/bnd.bnd | 3 +- io.openems.edge.meter.siemens/readme.adoc | 7 ++-- .../io/openems/edge/meter/siemens/Config.java | 2 +- .../edge/meter/siemens/SiemensPacMeter.java | 25 ++++++++++++ ...PACMeter.java => SiemensPacMeterImpl.java} | 38 ++++++------------- 5 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeter.java rename io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/{SiemensPACMeter.java => SiemensPacMeterImpl.java} (90%) diff --git a/io.openems.edge.meter.siemens/bnd.bnd b/io.openems.edge.meter.siemens/bnd.bnd index 05d9bc3c30f..c1f7888d4eb 100644 --- a/io.openems.edge.meter.siemens/bnd.bnd +++ b/io.openems.edge.meter.siemens/bnd.bnd @@ -9,6 +9,7 @@ Bundle-Version: 1.0.0.${tstamp} io.openems.common,\ io.openems.edge.bridge.modbus,\ io.openems.edge.common,\ - io.openems.edge.meter.api + io.openems.edge.meter.api,\ + -testpath: \ ${testpath} \ No newline at end of file diff --git a/io.openems.edge.meter.siemens/readme.adoc b/io.openems.edge.meter.siemens/readme.adoc index db2e989ab0e..3e007c7a5eb 100644 --- a/io.openems.edge.meter.siemens/readme.adoc +++ b/io.openems.edge.meter.siemens/readme.adoc @@ -1,7 +1,8 @@ -= Janitza Meters UMG 96RM-E | UMG 604 += Siemens Meters PAC2200 / 3200 / 4200 + +Implemented Natures -Implemented Natures:: - SymmetricMeter - AsymmetricMeter -https://github.com/OpenEMS/openems/tree/develop/io.openems.edge.meter.janitza[Source Code icon:github[]] \ No newline at end of file +https://github.com/OpenEMS/openems/tree/develop/io.openems.edge.meter.siemens[Source Code icon:github[]] \ No newline at end of file diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java index c57f99c9f3b..9b9da55218e 100644 --- a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/Config.java @@ -6,7 +6,7 @@ import io.openems.edge.meter.api.MeterType; @ObjectClassDefinition(// - name = "Siemens PAC 2200 3200 4200", // + name = "Siemens PAC 2200/3200/4200", // description = "Implements the Siemens PAC 2200/3200/4200 power analyser.") @interface Config { diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeter.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeter.java new file mode 100644 index 00000000000..3b16dd279a7 --- /dev/null +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeter.java @@ -0,0 +1,25 @@ +package io.openems.edge.meter.siemens; + +import io.openems.edge.bridge.modbus.api.ModbusComponent; +import io.openems.edge.common.channel.Doc; +import io.openems.edge.common.component.OpenemsComponent; +import io.openems.edge.common.modbusslave.ModbusSlave; +import io.openems.edge.meter.api.AsymmetricMeter; +import io.openems.edge.meter.api.SymmetricMeter; + +public interface SiemensPacMeter + extends SymmetricMeter, AsymmetricMeter, ModbusComponent, OpenemsComponent, ModbusSlave { + + public enum ChannelId implements io.openems.edge.common.channel.ChannelId { + ; + private final Doc doc; + + private ChannelId(Doc doc) { + this.doc = doc; + } + + public Doc doc() { + return this.doc; + } + } +} diff --git a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPACMeter.java b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java similarity index 90% rename from io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPACMeter.java rename to io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java index 41117a50323..0244371b199 100644 --- a/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPACMeter.java +++ b/io.openems.edge.meter.siemens/src/io/openems/edge/meter/siemens/SiemensPacMeterImpl.java @@ -23,7 +23,6 @@ import io.openems.edge.bridge.modbus.api.element.FloatDoublewordElement; import io.openems.edge.bridge.modbus.api.element.FloatQuadruplewordElement; import io.openems.edge.bridge.modbus.api.task.FC3ReadRegistersTask; -import io.openems.edge.common.channel.Doc; import io.openems.edge.common.component.OpenemsComponent; import io.openems.edge.common.modbusslave.ModbusSlave; import io.openems.edge.common.modbusslave.ModbusSlaveTable; @@ -39,12 +38,13 @@ * https://cache.industry.siemens.com/dl/files/150/26504150/att_906558/v1/A5E01168664B-04_EN-US_122016_201612221316360495.pdf */ @Designate(ocd = Config.class, factory = true) -@Component( - name = "Meter.Siemens.PAC.2200.3200.4200", - immediate = true, - configurationPolicy = ConfigurationPolicy.REQUIRE) -public class SiemensPACMeter extends AbstractOpenemsModbusComponent - implements SymmetricMeter, AsymmetricMeter, ModbusComponent, OpenemsComponent, ModbusSlave { +@Component(// + name = "Meter.Siemens", // + immediate = true, // + configurationPolicy = ConfigurationPolicy.REQUIRE // +) +public class SiemensPacMeterImpl extends AbstractOpenemsModbusComponent + implements SiemensPacMeter, SymmetricMeter, AsymmetricMeter, ModbusComponent, OpenemsComponent, ModbusSlave { private MeterType meterType = MeterType.PRODUCTION; @@ -56,13 +56,13 @@ public class SiemensPACMeter extends AbstractOpenemsModbusComponent @Reference protected ConfigurationAdmin cm; - public SiemensPACMeter() { + public SiemensPacMeterImpl() { super(// OpenemsComponent.ChannelId.values(), // ModbusComponent.ChannelId.values(), // SymmetricMeter.ChannelId.values(), // AsymmetricMeter.ChannelId.values(), // - ChannelId.values() // + SiemensPacMeter.ChannelId.values() // ); } @@ -87,19 +87,6 @@ protected void deactivate() { super.deactivate(); } - public enum ChannelId implements io.openems.edge.common.channel.ChannelId { - ; - private final Doc doc; - - private ChannelId(Doc doc) { - this.doc = doc; - } - - public Doc doc() { - return this.doc; - } - } - @Override public MeterType getMeterType() { return this.meterType; @@ -112,7 +99,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { 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), + m(AsymmetricMeter.ChannelId.VOLTAGE_L2, new FloatDoublewordElement(3), ElementToChannelConverter.SCALE_FACTOR_3), m(AsymmetricMeter.ChannelId.VOLTAGE_L3, new FloatDoublewordElement(5), ElementToChannelConverter.SCALE_FACTOR_3), @@ -143,8 +130,7 @@ protected ModbusProtocol defineModbusProtocol() throws OpenemsException { m(SymmetricMeter.ChannelId.ACTIVE_POWER, new FloatDoublewordElement(65), ElementToChannelConverter.INVERT_IF_TRUE(this.invert)), m(SymmetricMeter.ChannelId.REACTIVE_POWER, new FloatDoublewordElement(67), - ElementToChannelConverter.INVERT_IF_TRUE(this.invert)) - )); + ElementToChannelConverter.INVERT_IF_TRUE(this.invert)))); if (this.invert) { modbusProtocol.addTask(new FC3ReadRegistersTask(801, Priority.LOW, // m(SymmetricMeter.ChannelId.ACTIVE_CONSUMPTION_ENERGY, new FloatQuadruplewordElement(801)), @@ -174,5 +160,3 @@ public ModbusSlaveTable getModbusSlaveTable(AccessMode accessMode) { ); } } - -