-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Siemens PAC1600 meter #2396
Implement Siemens PAC1600 meter #2396
Conversation
@clehne Could anyone of your team do a first review of this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. My comments are mostly about general things. I haven't checked the modbus protocol in detail yet.
I would put all this into the bundle io.openems.edge.meter.siemens
and create two packages there, one for the existing meters Siemens PAC 2200,... and one for your meter.
Also, in the tools
directory, you have a script prepare-commit.sh
. Running this script before you commit takes care of some errors regarding code style.
rrd4j;version='[3.9.0,3.9.1)',\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reordering should be reverted to remain alphabetical ordering.
= Siemens Meter PAC1600 | ||
|
||
Implemented Natures: | ||
-ElectricityMeter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be consistent with other readme.adocs: There should be a whitespace after the "-".
@@ -0,0 +1,16 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<classpath> | |||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing it with other .classpath
files, I see that they don't have the <attributes>
tag, and this classpath entry is second in the list.
@@ -0,0 +1 @@ | |||
/bin_test/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also contain \bin\
and \generated\
.
// this.config = config; | ||
} | ||
|
||
@Deactivate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also have an @Override
-Annotation.
"Modbus", config.modbus_id())) { | ||
return; | ||
} | ||
// this.config = config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be removed.
@Override | ||
public MeterType getMeterType() { | ||
return this.meterType; | ||
// return this.config.type(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be removed.
immediate = true, // | ||
configurationPolicy = ConfigurationPolicy.REQUIRE // | ||
) | ||
public class MeterSiemensPAC1600Impl extends AbstractOpenemsModbusComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call this MeterSiemensPac1600Impl
, as three upper case letters in a row are a checkstyle violation. Same for Interface and Test.
m(ElectricityMeter.ChannelId.ACTIVE_POWER, new SignedDoublewordElement(57),ElementToChannelConverter.SCALE_FACTOR_MINUS_2), | ||
m(ElectricityMeter.ChannelId.REACTIVE_POWER, new SignedDoublewordElement(59),ElementToChannelConverter.SCALE_FACTOR_MINUS_2)), | ||
|
||
new FC3ReadRegistersTask(6687, Priority.HIGH, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The priority of this and the next task can be set to LOW
, as it's not necessary to read energy values all that frequently.
add /bin/ /bin_test/ /generated/
Thank you very much, Thomas, for your comments. The only thing I don't know is whether I can change the bundle with the Siemens PAC 2200 without crashing previous configurations. In principle I would think that would make sense, but the manufacturer is different. |
The only thing relevant for a configuration is the Factory-ID, i.e. |
Thank you very much, Stefan, for your information on component identification. I have put the two packages together and hope that everything fits now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work and sorry for the delay. It looks much better to me now, though I still have some remarks regarding code style.
.unit(Unit.MILLIVOLT)), | ||
|
||
REACTIVE_CONSUMPTION_ENERGY(Doc.of(OpenemsType.INTEGER) // | ||
.unit(Unit.CUMULATED_WATT_HOURS)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking the unit for these should be VOLT_AMPERE_REACTIVE_HOURS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be formatted according to coding guidelines. See here: https://openems.github.io/openems.io/openems/latest/contribute/coding-guidelines.html#_tool_support
m(MeterSiemensPac1600.ChannelId.REACTIVE_CONSUMPTION_ENERGY_L3, new UnsignedDoublewordElement(6751),ElementToChannelConverter.DIRECT_1_TO_1), | ||
m(MeterSiemensPac1600.ChannelId.REACTIVE_PRODUCTION_ENERGY_L3, new UnsignedDoublewordElement(6753),ElementToChannelConverter.DIRECT_1_TO_1))); | ||
|
||
return modbusProtocol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can make this "inline" (mark modbusProtocol
and press Shift + Alt + I if you are using eclipse), then you don't need the local variable modbusProtocol
. Your code will then simply look like this:
return new ModbusProtocol(this, // new FC3ReadRegistersTask(1, Priority.HIGH, // m(ElectricityMeter.ChannelId.VOLTAGE_L1, new UnsignedDoublewordElement(1), ElementToChannelConverter.SCALE_FACTOR_1), m(ElectricityMeter.ChannelId.VOLTAGE_L2, new UnsignedDoublewordElement(3), ElementToChannelConverter.SCALE_FACTOR_1), m(ElectricityMeter.ChannelId.VOLTAGE_L3, new UnsignedDoublewordElement(5), ElementToChannelConverter.SCALE_FACTOR_1), ...
barring formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the naming with the underscore. As of now, this is not used anywhere else in OpenEMS as far as I can see, but I don't know a better naming either at the moment. Maybe something like MeterSiemensPacX200
?
Same of course for the other related files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the name PacX200 is not good because there is also the Pac1200 and Pac5200 and these have a different Modbus protocol. Is the underscore really a problem. If not, I think calling it that is the best way to go.
Formatting of the code
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
Thanks @tsicking for reviewing the code!
Co-authored-by: JosefRick <[email protected]> Co-authored-by: Stefan Feilmeier <[email protected]> Reviewed-by: Thomas Sicking <[email protected]>
Added Meter Siemens PAC1600
I tested it on a real Siemens PAC 1665 and found no issues until now.