From b1cd908641be320c52fa1ce734d7dbd4b57f92f0 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Fri, 21 Jun 2024 16:45:28 +0200 Subject: [PATCH 1/8] Add specific code for decorator on busbar sections Signed-off-by: Sophie Frasnedo --- .../powsybl/sld/svg/AbstractLabelProvider.java | 4 ++++ .../powsybl/sld/svg/DefaultLabelProvider.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java index b37d996fc..cef407d7e 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java @@ -95,6 +95,10 @@ protected LabelPosition getMiddle3WTDecoratorPosition(Middle3WTNode node, Direct 0, yShift, true, 0); } + protected LabelPosition getBusDecoratorPosition() { + return new LabelPosition("BUS_DECORATOR", 35, -10, true, 0); + } + protected LabelPosition getLabelPosition(Node node, Direction direction) { double yShift = -LABEL_OFFSET; String positionName = ""; diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java index 4bbb9aeb9..8d198fadd 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java @@ -168,18 +168,22 @@ private > void addOperatingStatusDecorator(List operatingStatus = identifiable.getExtension(OperatingStatus.class); if (operatingStatus != null) { switch (operatingStatus.getStatus()) { - case PLANNED_OUTAGE -> nodeDecorators.add(getBranchStatusDecorator(node, direction, PLANNED_OUTAGE_BRANCH_NODE_DECORATOR)); - case FORCED_OUTAGE -> nodeDecorators.add(getBranchStatusDecorator(node, direction, FORCED_OUTAGE_BRANCH_NODE_DECORATOR)); + case PLANNED_OUTAGE -> nodeDecorators.add(getOperatingStatusDecorator(node, direction, PLANNED_OUTAGE_BRANCH_NODE_DECORATOR)); + case FORCED_OUTAGE -> nodeDecorators.add(getOperatingStatusDecorator(node, direction, FORCED_OUTAGE_BRANCH_NODE_DECORATOR)); case IN_OPERATION -> { /* No decorator for IN_OPERATION equipment */ } } } } } - private NodeDecorator getBranchStatusDecorator(Node node, Direction direction, String decoratorType) { - return (node instanceof Middle3WTNode middle3WTNode) ? - new NodeDecorator(decoratorType, getMiddle3WTDecoratorPosition(middle3WTNode, direction)) : - new NodeDecorator(decoratorType, getFeederDecoratorPosition(direction, decoratorType)); + private NodeDecorator getOperatingStatusDecorator(Node node, Direction direction, String decoratorType) { + if (node instanceof Middle3WTNode middle3WTNode) { + return new NodeDecorator(decoratorType, getMiddle3WTDecoratorPosition(middle3WTNode, direction)); + } else if (node instanceof BusNode) { + return new NodeDecorator(decoratorType, getBusDecoratorPosition()); + } else { + return new NodeDecorator(decoratorType, getFeederDecoratorPosition(direction, decoratorType)); + } } private List buildFeederInfos(ThreeWindingsTransformer transformer, ThreeSides side, boolean insideVoltageLevel) { From 94b915ed07db96e9268d922d54cad57e6926f707 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Fri, 21 Jun 2024 16:47:23 +0200 Subject: [PATCH 2/8] Modify test Signed-off-by: Sophie Frasnedo --- .../src/main/java/com/powsybl/diagram/test/Networks.java | 3 +++ .../test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg | 3 +++ 2 files changed, 6 insertions(+) diff --git a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java index 17b2d837d..77bbd9831 100644 --- a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java +++ b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java @@ -1205,6 +1205,9 @@ private static void createStatusExtensions(Network network) { network.getTwoWindingsTransformer("T12").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); network.getThreeWindingsTransformer(THREE_WINDING_TRANSFORMER_12_ID).newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); + if (network.getVoltageLevel("VL2").getTopologyKind() == TopologyKind.NODE_BREAKER) { + network.getBusbarSection("BBS2").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); + } } public static Network createNodeBreakerNetworkWithInternalBranches(String id, String sourceFormat) { diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg index a2602e7a1..96af0140b 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg @@ -604,6 +604,9 @@ BBS2 + + + From fe909fa39418040e07f4469ae2a2e7a63f21b0a8 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Mon, 1 Jul 2024 15:31:02 +0200 Subject: [PATCH 3/8] Fix bug for internal 2wt decorator Signed-off-by: Sophie Frasnedo --- .../com/powsybl/sld/svg/AbstractLabelProvider.java | 13 +++++++++++++ .../com/powsybl/sld/svg/DefaultLabelProvider.java | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java index cef407d7e..a543abdd0 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/AbstractLabelProvider.java @@ -11,6 +11,7 @@ import com.powsybl.sld.layout.LayoutParameters; import com.powsybl.sld.library.ComponentLibrary; import com.powsybl.sld.model.coordinate.Direction; +import com.powsybl.sld.model.coordinate.Orientation; import com.powsybl.sld.model.coordinate.Side; import com.powsybl.sld.model.graphs.VoltageLevelGraph; import com.powsybl.sld.model.nodes.*; @@ -117,6 +118,18 @@ protected LabelPosition getLabelPosition(Node node, Direction direction) { svgParameters.isLabelCentered() ? 0 : -LABEL_OFFSET, yShift, svgParameters.isLabelCentered(), (int) angle); } + protected LabelPosition getInternal2WTDecoratorPosition(Orientation orientation) { + if (orientation.isHorizontal()) { + return new LabelPosition("INTERNAL_2WT_DECORATOR", 0, -15, true, 0); + } else { + return new LabelPosition("INTERNAL_2WT_DECORATOR", 15, 0, true, 0); + } + } + + protected LabelPosition getGenericDecoratorPosition() { + return new LabelPosition("GENERIC_DECORATOR", 0, 0, true, 0); + } + protected LabelPosition getBusLabelPosition() { return new LabelPosition("NW_LABEL", -LABEL_OFFSET, -LABEL_OFFSET, false, 0); } diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java index 8d198fadd..35dac0afb 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java @@ -181,8 +181,10 @@ private NodeDecorator getOperatingStatusDecorator(Node node, Direction direction return new NodeDecorator(decoratorType, getMiddle3WTDecoratorPosition(middle3WTNode, direction)); } else if (node instanceof BusNode) { return new NodeDecorator(decoratorType, getBusDecoratorPosition()); - } else { + } else if (node instanceof FeederNode) { return new NodeDecorator(decoratorType, getFeederDecoratorPosition(direction, decoratorType)); + } else { + return new NodeDecorator(decoratorType, getInternal2WTDecoratorPosition(node.getOrientation())); } } From 4b9d26317e25cd365556a18a890336c17bfa8b26 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Mon, 1 Jul 2024 15:32:03 +0200 Subject: [PATCH 4/8] Fix test references Signed-off-by: Sophie Frasnedo --- .../src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg | 2 +- .../test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg index ac7410054..8379e0289 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusBusBreaker.svg @@ -213,7 +213,7 @@ - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg index e69893003..b821a5997 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/NodeDecoratorsBranchStatusNodeBreaker.svg @@ -228,7 +228,7 @@ - + From 8592890dce5c9f20c5efd6d2a9182407de931361 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Mon, 1 Jul 2024 15:32:58 +0200 Subject: [PATCH 5/8] Add new test for vertical internal pst Signed-off-by: Sophie Frasnedo --- .../com/powsybl/diagram/test/Networks.java | 6 + .../iidm/TestNodeDecoratorsNodeBreaker.java | 20 ++ ...icalInternalPstBranchStatusNodeBreaker.svg | 262 ++++++++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg diff --git a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java index 77bbd9831..add659c09 100644 --- a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java +++ b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java @@ -1675,6 +1675,12 @@ public static Network createNetworkWithInternalPst() { return network; } + public static Network createNetworkWithInternalPstAndBranchStatus() { + Network network = createNetworkWithInternalPst(); + network.getTwoWindingsTransformer("trf3").newExtension(OperatingStatusAdder.class).withStatus(OperatingStatus.Status.FORCED_OUTAGE).add(); + return network; + } + public static Network createNetworkWithFlatSections() { Network network = Network.create("TestSingleLineDiagramClass", "test"); Substation substation = createSubstation(network, "s", "s", Country.FR); diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java index 45fdfe5e7..2f2f4b04c 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java @@ -8,7 +8,12 @@ package com.powsybl.sld.iidm; import com.powsybl.diagram.test.Networks; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.extensions.OperatingStatus; +import com.powsybl.iidm.network.extensions.OperatingStatusAdder; import com.powsybl.sld.builders.NetworkGraphBuilder; +import com.powsybl.sld.layout.HorizontalSubstationLayoutFactory; +import com.powsybl.sld.layout.SmartVoltageLevelLayoutFactory; import com.powsybl.sld.library.ComponentSize; import com.powsybl.sld.model.coordinate.Direction; import com.powsybl.sld.model.graphs.SubstationGraph; @@ -18,6 +23,9 @@ import com.powsybl.sld.svg.DefaultLabelProvider; import com.powsybl.sld.svg.LabelPosition; import com.powsybl.sld.svg.LabelProvider; +import com.powsybl.sld.svg.styles.StyleProvidersList; +import com.powsybl.sld.svg.styles.iidm.HighlightLineStateStyleProvider; +import com.powsybl.sld.svg.styles.iidm.TopologicalStyleProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -52,6 +60,18 @@ void testBranchStatusDecorators() { toSVG(g, "/NodeDecoratorsBranchStatusNodeBreaker.svg", componentLibrary, layoutParameters, svgParameters, getDefaultDiagramLabelProvider(), getDefaultDiagramStyleProvider())); } + @Test + void testBranchStatusForVerticalInternalPst() { + Network networkInternalPst = Networks.createNetworkWithInternalPstAndBranchStatus(); + SubstationGraph g = new NetworkGraphBuilder(networkInternalPst).buildSubstationGraph("s"); + + // Run horizontal substation layout + new HorizontalSubstationLayoutFactory().create(g, new SmartVoltageLevelLayoutFactory(networkInternalPst)).run(layoutParameters); + + assertEquals(toString("/VerticalInternalPstBranchStatusNodeBreaker.svg"), + toSVG(g, "/VerticalInternalPstBranchStatusNodeBreaker.svg", componentLibrary, layoutParameters, svgParameters, new DefaultLabelProvider(networkInternalPst, componentLibrary, layoutParameters, svgParameters), new StyleProvidersList(new TopologicalStyleProvider(networkInternalPst), new HighlightLineStateStyleProvider(networkInternalPst)))); + } + @Test void testSwitchDecorators() { diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg new file mode 100644 index 000000000..097cba813 --- /dev/null +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg @@ -0,0 +1,262 @@ + + + + + + + vl1 + + + + bbs1 + + + + bbs2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + l + + + + From b9e6bced4476d00d465862dd3f9e1e92b9114e25 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Mon, 1 Jul 2024 15:35:14 +0200 Subject: [PATCH 6/8] Fix checkstyle Signed-off-by: Sophie Frasnedo --- .../com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java index 2f2f4b04c..9cf47e1c1 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/iidm/TestNodeDecoratorsNodeBreaker.java @@ -9,8 +9,6 @@ import com.powsybl.diagram.test.Networks; import com.powsybl.iidm.network.Network; -import com.powsybl.iidm.network.extensions.OperatingStatus; -import com.powsybl.iidm.network.extensions.OperatingStatusAdder; import com.powsybl.sld.builders.NetworkGraphBuilder; import com.powsybl.sld.layout.HorizontalSubstationLayoutFactory; import com.powsybl.sld.layout.SmartVoltageLevelLayoutFactory; From b6938395fc23a1390865fe6ade82498b0b6e94d4 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Tue, 2 Jul 2024 16:38:44 +0200 Subject: [PATCH 7/8] Fix style in test reference Signed-off-by: Sophie Frasnedo --- .../resources/VerticalInternalPstBranchStatusNodeBreaker.svg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg index 097cba813..13e9be67c 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/VerticalInternalPstBranchStatusNodeBreaker.svg @@ -104,6 +104,8 @@ .sld-busbar-section {stroke: var(--sld-vl-color, black); stroke-width: 3; fill: none} /* Stroke --sld-vl-color with fallback red */ .sld-wire {stroke: var(--sld-vl-color, #c80000); fill: none} +.sld-wire.sld-dangling-line {stroke-width: 2px} +.sld-wire.sld-tie-line {stroke-width: 2px} /* Stroke --sld-vl-color with fallback blue */ .sld-load {stroke: var(--sld-vl-color, blue); fill: none} .sld-battery {stroke: var(--sld-vl-color, blue); fill: none} From 063a3ef508d29df10f13de46b0f613ef80741509 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Tue, 2 Jul 2024 16:46:07 +0200 Subject: [PATCH 8/8] Use the getGenericDecoratorPositio() function for default case in getOperatingStatusDecorator(...) Signed-off-by: Sophie Frasnedo --- .../main/java/com/powsybl/sld/svg/DefaultLabelProvider.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java index 35dac0afb..7e83eb4e5 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/svg/DefaultLabelProvider.java @@ -183,8 +183,10 @@ private NodeDecorator getOperatingStatusDecorator(Node node, Direction direction return new NodeDecorator(decoratorType, getBusDecoratorPosition()); } else if (node instanceof FeederNode) { return new NodeDecorator(decoratorType, getFeederDecoratorPosition(direction, decoratorType)); - } else { + } else if (node instanceof Internal2WTNode) { return new NodeDecorator(decoratorType, getInternal2WTDecoratorPosition(node.getOrientation())); + } else { + return new NodeDecorator(decoratorType, getGenericDecoratorPosition()); } }