Skip to content
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

Merged
merged 18 commits into from
Jan 2, 2024

Conversation

JosefRick
Copy link
Contributor

Added Meter Siemens PAC1600

I tested it on a real Siemens PAC 1665 and found no issues until now.

@sfeilmeier
Copy link
Contributor

@clehne Could anyone of your team do a first review of this?

Copy link
Contributor

@tsicking tsicking left a 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.

io.openems.edge.application/EdgeApp.bndrun Outdated Show resolved Hide resolved
rrd4j;version='[3.9.0,3.9.1)',\
Copy link
Contributor

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
Copy link
Contributor

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">
Copy link
Contributor

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/
Copy link
Contributor

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
Copy link
Contributor

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;
Copy link
Contributor

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();
Copy link
Contributor

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
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link

Code Coverage

@sfeilmeier sfeilmeier changed the title Feature/meter siemens pac1600 Implement Siemens PAC1600 meter Nov 20, 2023
@JosefRick
Copy link
Contributor Author

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.

@sfeilmeier
Copy link
Contributor

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. Meter.Siemens for the other implementation. As long as you don't touch that or use exactly the same for your implementation, there is no problem. It does not matter, if the Bundle of the Component changes - so no problem here from my side.

@JosefRick
Copy link
Contributor Author

Thank you very much, Stefan, for your information on component identification. I have put the two packages together and hope that everything fits now.

Copy link
Contributor

@tsicking tsicking left a 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)),
Copy link
Contributor

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

Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link

github-actions bot commented Jan 2, 2024

Code Coverage

1 similar comment
Copy link

github-actions bot commented Jan 2, 2024

Code Coverage

Copy link
Contributor

@sfeilmeier sfeilmeier left a 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!

@sfeilmeier sfeilmeier merged commit 0dba9a2 into OpenEMS:develop Jan 2, 2024
2 checks passed
ebram-tw pushed a commit to terawatt-infrastructure/openems that referenced this pull request Jan 12, 2024
Co-authored-by: JosefRick <[email protected]>
Co-authored-by: Stefan Feilmeier <[email protected]>
Reviewed-by: Thomas Sicking <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants