From 0c1a279c68277f9c9b1ddb62561a128b4475ec0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20QUARTON?= Date: Tue, 14 Mar 2023 10:53:39 +0100 Subject: [PATCH] feat: add current info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hervé --- .../com/powsybl/nad/svg/SvgParameters.java | 13 +++++++- .../powsybl/sld/layout/LayoutParameters.java | 23 +++++++++++++- .../sld/svg/DefaultDiagramLabelProvider.java | 30 ++++++++++++------- .../ConvergenceLibrary/components.css | 1 + .../ConvergenceLibrary/components.json | 25 +++++++++++++++- .../FlatDesignLibrary/components.css | 1 + .../FlatDesignLibrary/components.json | 23 ++++++++++++++ 7 files changed, 102 insertions(+), 14 deletions(-) diff --git a/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgParameters.java b/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgParameters.java index 30150a36a..ce23abfc2 100644 --- a/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgParameters.java +++ b/network-area-diagram/src/main/java/com/powsybl/nad/svg/SvgParameters.java @@ -54,6 +54,7 @@ public class SvgParameters { private int angleValuePrecision = 1; private double pstArrowHeadSize = 8; private String undefinedValueSymbol = ""; + private int currentValuePrecision = 0; public enum CssLocation { INSERTED_IN_SVG, EXTERNAL_IMPORTED, EXTERNAL_NO_IMPORT @@ -105,6 +106,7 @@ public SvgParameters(SvgParameters other) { this.angleValuePrecision = other.angleValuePrecision; this.pstArrowHeadSize = other.pstArrowHeadSize; this.undefinedValueSymbol = other.undefinedValueSymbol; + this.currentValuePrecision = other.currentValuePrecision; } public Padding getDiagramPadding() { @@ -429,6 +431,15 @@ public SvgParameters setPowerValuePrecision(int powerValuePrecision) { return this; } + public int getCurrentValuePrecision() { + return currentValuePrecision; + } + + public SvgParameters setCurrentValuePrecision(int currentValuePrecision) { + this.currentValuePrecision = currentValuePrecision; + return this; + } + public int getAngleValuePrecision() { return angleValuePrecision; } @@ -439,7 +450,7 @@ public SvgParameters setAngleValuePrecision(int angleValuePrecision) { } public ValueFormatter createValueFormatter() { - return new ValueFormatter(powerValuePrecision, voltageValuePrecision, angleValuePrecision, Locale.forLanguageTag(languageTag), undefinedValueSymbol); + return new ValueFormatter(powerValuePrecision, voltageValuePrecision, currentValuePrecision, angleValuePrecision, Locale.forLanguageTag(languageTag), undefinedValueSymbol); } public double getPstArrowHeadSize() { diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/LayoutParameters.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/LayoutParameters.java index 66b29ed38..a82f7b250 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/LayoutParameters.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/LayoutParameters.java @@ -94,11 +94,14 @@ public class LayoutParameters { private int powerValuePrecision = 0; private int angleValuePrecision = 1; + private int currentValuePrecision = 0; + /** em dash unicode for undefined value */ private String undefinedValueSymbol = "\u2014"; @JsonIgnore private Map componentsSize; + private boolean displayCurrentFeederInfo; @JsonCreator public LayoutParameters() { @@ -612,8 +615,26 @@ public LayoutParameters setAngleValuePrecision(int angleValuePrecision) { return this; } + public int getCurrentValuePrecision() { + return currentValuePrecision; + } + + public LayoutParameters setCurrentValuePrecision(int currentValuePrecision) { + this.currentValuePrecision = currentValuePrecision; + return this; + } + public ValueFormatter createValueFormatter() { - return new ValueFormatter(powerValuePrecision, voltageValuePrecision, angleValuePrecision, Locale.forLanguageTag(languageTag), undefinedValueSymbol); + return new ValueFormatter(powerValuePrecision, voltageValuePrecision,currentValuePrecision, angleValuePrecision, Locale.forLanguageTag(languageTag), undefinedValueSymbol); + } + + public boolean isDisplayCurrentFeederInfo() { + return this.displayCurrentFeederInfo; + } + + public LayoutParameters setDisplayCurrentFeederInfo(boolean displayCurrentFeederInfo) { + this.displayCurrentFeederInfo = displayCurrentFeederInfo; + return this; } public enum Alignment { diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultDiagramLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultDiagramLabelProvider.java index c7168b06a..061456d42 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultDiagramLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultDiagramLabelProvider.java @@ -20,6 +20,7 @@ import java.util.stream.Collectors; import static com.powsybl.sld.library.ComponentTypeName.ARROW_ACTIVE; +import static com.powsybl.sld.library.ComponentTypeName.ARROW_CURRENT; import static com.powsybl.sld.library.ComponentTypeName.ARROW_REACTIVE; import static com.powsybl.sld.model.coordinate.Direction.BOTTOM; @@ -195,28 +196,35 @@ private NodeDecorator getBranchStatusDecorator(Node node, Direction direction, S } private List buildFeederInfos(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { - return Arrays.asList( - new DirectionalFeederInfo(ARROW_ACTIVE, transformer.getTerminal(side).getP(), valueFormatter::formatPower), - new DirectionalFeederInfo(ARROW_REACTIVE, transformer.getTerminal(side).getQ(), valueFormatter::formatPower)); + return this.buildFeederInfos(transformer.getTerminal(side)); } private List buildFeederInfos(Injection injection) { - return Arrays.asList( - new DirectionalFeederInfo(ARROW_ACTIVE, injection.getTerminal().getP(), valueFormatter::formatPower), - new DirectionalFeederInfo(ARROW_REACTIVE, injection.getTerminal().getQ(), valueFormatter::formatPower)); + return this.buildFeederInfos(injection.getTerminal()); } private List buildFeederInfos(Branch branch, Branch.Side side) { - return Arrays.asList( - new DirectionalFeederInfo(ARROW_ACTIVE, branch.getTerminal(side).getP(), valueFormatter::formatPower), - new DirectionalFeederInfo(ARROW_REACTIVE, branch.getTerminal(side).getQ(), valueFormatter::formatPower)); + return this.buildFeederInfos(branch.getTerminal(side)); } private List buildFeederInfos(HvdcLine hvdcLine, NodeSide side) { HvdcConverterStation hvdcConverterStation = side == NodeSide.ONE ? hvdcLine.getConverterStation1() : hvdcLine.getConverterStation2(); + return this.buildFeederInfos(hvdcConverterStation.getTerminal()); + } + + private List buildFeederInfos(Terminal terminal){ + if(this.layoutParameters.isDisplayCurrentFeederInfo()){ + return Arrays.asList( + new DirectionalFeederInfo(ARROW_ACTIVE, terminal.getP(), valueFormatter::formatPower), + new DirectionalFeederInfo(ARROW_REACTIVE, terminal.getQ(), valueFormatter::formatPower), + new DirectionalFeederInfo(ARROW_CURRENT, terminal.getI(), valueFormatter::formatCurrent) + ); + } + return Arrays.asList( - new DirectionalFeederInfo(ARROW_ACTIVE, hvdcConverterStation.getTerminal().getP(), valueFormatter::formatPower), - new DirectionalFeederInfo(ARROW_REACTIVE, hvdcConverterStation.getTerminal().getQ(), valueFormatter::formatPower)); + new DirectionalFeederInfo(ARROW_ACTIVE, terminal.getP(), valueFormatter::formatPower), + new DirectionalFeederInfo(ARROW_REACTIVE, terminal.getQ(), valueFormatter::formatPower) + ); } } diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css index 94536e456..27c149490 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.css @@ -37,6 +37,7 @@ .sld-grid {stroke: #003700; stroke-dasharray: 1,10} .sld-feeder-info.sld-active-power {fill:black} .sld-feeder-info.sld-reactive-power {fill:blue} +.sld-feeder-info.sld-current {fill:purple} .sld-frame {fill: var(--sld-background-color, transparent)} /* Stroke maroon for fictitious switch */ .sld-breaker.sld-fictitious {stroke: maroon} diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json index 01bfda11b..7107c60a8 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/ConvergenceLibrary/components.json @@ -393,5 +393,28 @@ "styleClass" : "sld-arrow-in" } ], "styleClass" : "sld-reactive-power" - } ] + }, { + "type": "ARROW_CURRENT", + "size": { + "width": 10.0, + "height": 10.0 + }, + "transformations": { + "LEFT": "ROTATION", + "RIGHT": "ROTATION" + }, + "subComponents": [ + { + "name": "UP", + "fileName": "arrow-up.svg", + "styleClass": "sld-arrow-out" + }, + { + "name": "DOWN", + "fileName": "arrow-down.svg", + "styleClass": "sld-arrow-in" + } + ], + "styleClass": "sld-current" + }] } \ No newline at end of file diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css index 6d8d2232a..bd7b8f465 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.css @@ -25,6 +25,7 @@ .sld-grid {stroke: #003700; stroke-dasharray: 1,10} .sld-feeder-info.sld-active-power {fill: #37474f} .sld-feeder-info.sld-reactive-power {fill: #0277bd} +.sld-feeder-info.sld-current {fill:purple} .sld-frame {fill: var(--sld-background-color, transparent)} /* fictitious switches and busbar */ .sld-breaker.sld-fictitious {stroke: maroon; stroke-width: 1.5} diff --git a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json index deea510f2..e583b09df 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json +++ b/single-line-diagram/single-line-diagram-core/src/main/resources/FlatDesignLibrary/components.json @@ -467,6 +467,29 @@ } ], "styleClass": "sld-reactive-power" + }, { + "type": "ARROW_CURRENT", + "size": { + "width": 10.0, + "height": 10.0 + }, + "transformations": { + "LEFT": "ROTATION", + "RIGHT": "ROTATION" + }, + "subComponents": [ + { + "name": "UP", + "fileName": "arrow-up.svg", + "styleClass": "sld-arrow-out" + }, + { + "name": "DOWN", + "fileName": "arrow-down.svg", + "styleClass": "sld-arrow-in" + } + ], + "styleClass": "sld-current" } ] }