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

Unit for feeder info #555

Merged
merged 6 commits into from
Sep 29, 2023
Merged

Unit for feeder info #555

merged 6 commits into from
Sep 29, 2023

Conversation

So-Fras
Copy link
Member

@So-Fras So-Fras commented Sep 28, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

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

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>
@So-Fras So-Fras requested a review from tadam50 September 28, 2023 20:36
@So-Fras So-Fras added the SLD label Sep 28, 2023
Copy link
Contributor

@tadam50 tadam50 left a 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)));
Copy link
Contributor

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

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

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

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>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@So-Fras So-Fras merged commit 909a8d0 into main Sep 29, 2023
6 checks passed
@So-Fras So-Fras deleted the unit_for_feeder_info branch September 29, 2023 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants