[Edge] Implement Inepro Pro380ModCT meter#3570
[Edge] Implement Inepro Pro380ModCT meter#3570tomflorentin wants to merge 7 commits intoOpenEMS:developfrom
Conversation
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Pro380modct.java
Outdated
Show resolved
Hide resolved
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Pro380modctImpl.java
Show resolved
Hide resolved
sfeilmeier
left a comment
There was a problem hiding this comment.
Marking this PR as "waiting for changes"
| public interface Pro380modct extends ElectricityMeter, OpenemsComponent { | ||
|
|
||
| public enum ChannelId implements io.openems.edge.common.channel.ChannelId { | ||
| APPARENT_POWER_L1(Doc.of(OpenemsType.INTEGER).unit(Unit.VOLT_AMPERE)), // |
There was a problem hiding this comment.
package io.openems.edge.meter.inepro.pro380modct;
import io.openems.common.channel.Unit;
import io.openems.common.types.OpenemsType;
import io.openems.edge.common.channel.Doc;
import io.openems.edge.common.component.OpenemsComponent;
import io.openems.edge.meter.api.ElectricityMeter;
public interface Pro380modct extends ElectricityMeter, OpenemsComponent {
public enum ChannelId implements io.openems.edge.common.channel.ChannelId {
APPARENT_POWER_L1(Doc.of(OpenemsType.INTEGER)//
.unit(Unit.VOLT_AMPERE)), //
APPARENT_POWER_L2(Doc.of(OpenemsType.INTEGER)//
.unit(Unit.VOLT_AMPERE)), //
APPARENT_POWER_L3(Doc.of(OpenemsType.INTEGER)//
.unit(Unit.VOLT_AMPERE)), //
APPARENT_POWER(Doc.of(OpenemsType.INTEGER)//
.unit(Unit.VOLT_AMPERE));
private final Doc doc;
private ChannelId(Doc doc) {
this.doc = doc;
}
@Override
public Doc doc() {
return this.doc;
}
}
}|
|
||
| String webconsole_configurationFactory_nameHint() default "io.openems.edge.meter.pro380modct [{id}]"; | ||
|
|
||
| @AttributeDefinition(name = "Meter-Type", description = "What is measured by this Meter?") |
There was a problem hiding this comment.
package io.openems.edge.meter.inepro.pro380modct;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
import io.openems.common.types.MeterType;
@ObjectClassDefinition(//
name = "Meter inepro Pro380ModCT", //
description = "Implements the inepro Pro380ModCT meter.")
public @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 = "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.")
int modbusUnitId() default 1;
@AttributeDefinition(name = "Meter-Type", description = "What is measured by this Meter?")
MeterType type() default MeterType.CONSUMPTION_METERED;
@AttributeDefinition(name = "Modbus target filter", description = "This is auto-generated by 'Modbus-ID'.")
String Modbus_target() default "(enabled=true)";
String webconsole_configurationFactory_nameHint() default "io.openems.edge.meter.pro380modct [{id}]";
}
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Pro380modctImpl.java
Show resolved
Hide resolved
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Config.java
Show resolved
Hide resolved
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Pro380modctImpl.java
Show resolved
Hide resolved
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Pro380modctImpl.java
Show resolved
Hide resolved
io.openems.edge.meter.inepro/src/io/openems/edge/meter/inepro/pro380modct/Config.java
Outdated
Show resolved
Hide resolved
|
Thanks for all your comments, it helps me to learn faster. I did some code changes (locally) and will test them tomorrow on the meter, i will push the changes after. |
|
I made the changes, and tested on our meter, it works fine. All your comments were very good. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3570 +/- ##
=============================================
- Coverage 59.41% 58.63% -0.77%
Complexity 105 105
=============================================
Files 3069 3093 +24
Lines 133076 134134 +1058
Branches 9815 9884 +69
=============================================
- Hits 79049 78642 -407
- Misses 51045 52592 +1547
+ Partials 2982 2900 -82 🚀 New features to boost your workflow:
|
|
|
||
|
|
||
| public class Pro380modctImpl extends AbstractOpenemsModbusComponent | ||
| implements Pro380modct, ElectricityMeter, ModbusComponent, OpenemsComponent { |
There was a problem hiding this comment.
ModbusSlave is missing - It would still be inherited from the Interface, but Best Practice would list it here
| import io.openems.common.exceptions.OpenemsException; | ||
| import io.openems.common.types.MeterType; | ||
| import io.openems.edge.bridge.modbus.api.AbstractOpenemsModbusComponent; | ||
| import io.openems.edge.bridge.modbus.api.BridgeModbus; |
There was a problem hiding this comment.
Also please apply Ctrl+Shift+O after all for Sorting the imports
| private ConfigurationAdmin cm; | ||
|
|
||
| @Reference(policy = ReferencePolicy.STATIC, policyOption = ReferencePolicyOption.GREEDY, cardinality = ReferenceCardinality.MANDATORY) | ||
| protected void setModbus(BridgeModbus modbus) { |
There was a problem hiding this comment.
Method overrides AbstractOpenemsModbusComponent.setModbus(). The @OverRide annotation provides compile-time safety and documents intent.
| } | ||
|
|
||
| private Config config = null; | ||
| private boolean invert; |
There was a problem hiding this comment.
Creates a second source of truth. KDK accesses this.config.invert() directly. Since this.config is assigned before super.activate() calls defineModbusProtocol(), direct access is safe.
| @ObjectClassDefinition(// | ||
| name = "Meter inepro Pro380ModCT", // | ||
| description = "Implements the inepro Pro380ModCT meter.") | ||
| public @interface Config { |
There was a problem hiding this comment.
Config should be package-private - it's an internal implementation detail, not part of the public api
|
In general very good First Implementation! But please use https://github.com/OpenEMS/openems/blob/develop/io.openems.edge.meter.kdk/src/io/openems/edge/meter/kdk/puct2/MeterKdk2puctImpl.java as a Reference and check, if this implementation of the kdk2puct also works with your meter as the Register Addresses seem to be 1:1 identical? So there would not be a need to Implement this Meter as a seperate Component i guess @sfeilmeier ? @tomflorentin |
|
It looks like the Kdk2 implementation works with this meter. |
|
@tomflorentin Thank you for the effort! Instead of just closing this PR, we should make sure this information can be found in future. We could either:
|
|
I would reuse the Code 1:1 for this Meter aswell - maybe also add the SolarLog Meter if feasible in this PR aswell? |
|
Ok - so which path should we go? Full new Components for Inepro and Solar-Log and use abstract class that holds the modbus mappings? I am not sure tomflorentin can do that just yet. And it's a company repository so he cannot open the PR for write-access. |
If you want maybe you could open a new PR and we can work on it together ( @tomflorentin and me) ? :) |
|
Yes @Sn0w3y , i would be happy to help. Could you email me a better way to communicate and keep in touch please ? Thanks |
Dear OpenEMS team,
I am from VEV. We recently forked OpenEMS, and I’m proud to share our first open-source contribution.
We are beginners with OpenEMS, so please feel free to share any feedback or suggestions.
Inepro Pro380 ModCT Energy Meter
We purchased and installed this three-phase meter for our first proof of concept.
As part of this project, we developed and successfully tested its integration with OpenEMS.
Modbus table:
https://7549cdd3-cc68-4b56-9f7c-0db19b0a4c60.filesusr.com/ugd/511b90_fd5e7961835344e9addd80a2badafc97.pdf
Thanks all for your amazing work !
Looking forward to seeing you in Karlsruhe.