-
Notifications
You must be signed in to change notification settings - Fork 13
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
Unit for feeder info #555
Unit for feeder info #555
Conversation
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
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.
Fix code smell & add missing constructor
@@ -220,10 +220,10 @@ private List<FeederInfo> buildFeederInfos(HvdcLine hvdcLine, NodeSide side) { | |||
|
|||
private List<FeederInfo> buildFeederInfos(Terminal terminal) { | |||
List<FeederInfo> feederInfoList = new ArrayList<>(); | |||
feederInfoList.add(new DirectionalFeederInfo(ARROW_ACTIVE, terminal.getP(), valueFormatter::formatPower)); | |||
feederInfoList.add(new DirectionalFeederInfo(ARROW_REACTIVE, terminal.getQ(), valueFormatter::formatPower)); | |||
feederInfoList.add(new DirectionalFeederInfo(ARROW_ACTIVE, terminal.getP(), svgParameters.getActivePowerUnit(), (value, unit) -> valueFormatter.formatPower(value, unit))); |
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.
Replace this lambda with method reference 'valueFormatter::formatPower'.
feederInfoList.add(new DirectionalFeederInfo(ARROW_ACTIVE, terminal.getP(), valueFormatter::formatPower)); | ||
feederInfoList.add(new DirectionalFeederInfo(ARROW_REACTIVE, terminal.getQ(), valueFormatter::formatPower)); | ||
feederInfoList.add(new DirectionalFeederInfo(ARROW_ACTIVE, terminal.getP(), svgParameters.getActivePowerUnit(), (value, unit) -> valueFormatter.formatPower(value, unit))); | ||
feederInfoList.add(new DirectionalFeederInfo(ARROW_REACTIVE, terminal.getQ(), svgParameters.getReactivePowerUnit(), (value, unit) -> valueFormatter.formatPower(value, unit))); |
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.
Replace this lambda with method reference 'valueFormatter::formatPower'.
if (this.svgParameters.isDisplayCurrentFeederInfo()) { | ||
feederInfoList.add(new DirectionalFeederInfo(ARROW_CURRENT, terminal.getI(), valueFormatter::formatCurrent)); | ||
feederInfoList.add(new DirectionalFeederInfo(ARROW_CURRENT, terminal.getI(), svgParameters.getCurrentUnit(), (value, unit) -> valueFormatter.formatCurrent(value, unit))); |
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.
Replace this lambda with method reference 'valueFormatter::formatCurrent'.
@@ -42,6 +43,12 @@ public DirectionalFeederInfo(String componentType, double value, DoubleFunction< | |||
this.value = value; | |||
} | |||
|
|||
public DirectionalFeederInfo(String componentType, double value, String unit, BiFunction<Double, String, String> formatter) { |
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.
Missing String userDefinedId
parameter
Add a new constructor as following :
public DirectionalFeederInfo(String componentType, double value, String unit, BiFunction<Double, String, String> formatter, String userDefinedId) {
super(componentType, null, formatter.apply(value, unit), userDefinedId);
this.arrowDirection = Objects.requireNonNull(getArrowDirection(value));
this.value = value;
}
And change current constructor as following:
public DirectionalFeederInfo(String componentType, double value, String unit, BiFunction<Double, String, String> formatter) {
this(componentType, value, unit, formatter, null);
}
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Signed-off-by: Sophie Frasnedo <sophie.frasnedo@rte-france.com>
Kudos, SonarCloud Quality Gate passed! |
Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
Feature
What is the current behavior?
While there were existing functions in the ValueFormatter to take into account units for feeder info, it was not possible to customize the diagram: no units were displayed.
What is the new behavior (if this is a feature change)?
The aim is to allow users to choose a unit for feeder info. The setters for single-line diagram feeder info units will be in the SvgParameters class.
The default value for each unit would be an empty String so as not to change the current behaviour.
Does this PR introduce a breaking change or deprecate an API?
No