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

Fix ground disconnector and ground in FlatDesignLibrary #602

Merged
merged 8 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 19 additions & 30 deletions diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java
Original file line number Diff line number Diff line change
Expand Up @@ -2259,32 +2259,34 @@ public static Network createNetworkWithManySubstations() {
return network;
}

public static Network createNetworkGroundDisconnectorOnLineNodeBreaker() {
public static Network createNetworkGroundDisconnector() {
Network network = Network.create("testCaseGroundDisconnectorOnLineNB", "test");
Substation substation = Networks.createSubstation(network, "s", "s", Country.FR);
VoltageLevel vl = Networks.createVoltageLevel(substation, "vl", "vl", TopologyKind.NODE_BREAKER, 380);
Substation substation2 = Networks.createSubstation(network, "s2", "s2", Country.FR);
VoltageLevel vl2 = Networks.createVoltageLevel(substation2, "vl2", "vl2", TopologyKind.NODE_BREAKER, 380);
Networks.createBusBarSection(vl, "bbs", "bbs", 0, 1, 1);

Networks.createBusBarSection(vl, "bbs", 0, 1, 1);

Networks.createLine(network, "line", "line", 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 2, 4, vl.getId(), vl2.getId(), "fn1", 1, ConnectablePosition.Direction.TOP, "fn2", 0, ConnectablePosition.Direction.TOP);
Networks.createSwitch(vl, "d1", "d1", SwitchKind.DISCONNECTOR, false, false, false, 0, 1);
Networks.createSwitch(vl, "b1", "b1", SwitchKind.BREAKER, false, false, false, 1, 2);
Networks.createSwitch(vl, "gd", "gd", SwitchKind.DISCONNECTOR, false, true, false, 2, 3);
Networks.createGround(vl, "ground", 3);
return network;
}
Networks.createSwitch(vl, "d1", SwitchKind.DISCONNECTOR, false, false, false, 0, 1);
Networks.createSwitch(vl, "b1", SwitchKind.BREAKER, false, false, false, 1, 2);
Networks.createSwitch(vl, "gd1", SwitchKind.DISCONNECTOR, false, true, false, 2, 3);
Networks.createGround(vl, "ground1", 3);

Networks.createLoad(vl, "load", 2, ConnectablePosition.Direction.BOTTOM, 6, 10, 0);
Networks.createSwitch(vl, "d2", SwitchKind.DISCONNECTOR, false, false, false, 0, 5);
Networks.createSwitch(vl, "b2", SwitchKind.BREAKER, false, false, false, 5, 6);
Networks.createSwitch(vl, "gd2", SwitchKind.DISCONNECTOR, false, false, false, 6, 7);
Networks.createGround(vl, "ground2", 7);

Networks.createSwitch(vl, "gd", "gd", SwitchKind.DISCONNECTOR, false, true, false, 0, 8);
Networks.createGround(vl, "ground", 8);

public static Network createNetworkGroundDisconnectorOnBusBarNodeBreaker() {
Network network = Network.create("testCaseGroundDisconnectorOnBusBarNB", "test");
Substation substation = Networks.createSubstation(network, "s", "s", Country.FR);
VoltageLevel vl = Networks.createVoltageLevel(substation, "vl", "vl", TopologyKind.NODE_BREAKER, 380);
Networks.createBusBarSection(vl, "bbs", "bbs", 0, 1, 1);
Networks.createSwitch(vl, "gd", "gd", SwitchKind.DISCONNECTOR, false, true, false, 0, 1);
Networks.createGround(vl, "ground", 1);
return network;
}

public static Network createNetworkGroundDisconnectorOnLineBusBreaker() {
public static Network createNetworkGroundsBusBreaker() {
Network network = Network.create("testCaseGroundDisconnectorOnLineBB", "test");
Substation substation = Networks.createSubstation(network, "s1", "s1", Country.FR);
VoltageLevel vl = Networks.createVoltageLevel(substation, "vl", "vl", TopologyKind.BUS_BREAKER, 380);
Expand All @@ -2300,20 +2302,7 @@ public static Network createNetworkGroundDisconnectorOnLineBusBreaker() {
.setId("b1g")
.add();
Networks.createLine(b1, b2);
Networks.createGround(b1g);
return network;
}

public static Network createNetworkGroundDisconnectorOnBusBarBusBreaker() {
Network network = Network.create("testCaseGroundDisconnectorOnBusBarBB", "test");
Substation substation = Networks.createSubstation(network, "s", "s", Country.FR);
VoltageLevel vl = Networks.createVoltageLevel(substation, "vl", "vl", TopologyKind.BUS_BREAKER, 380);
vl.getBusBreakerView().newBus()
.setId("b1")
.add();
Bus b1g = vl.getBusBreakerView().newBus()
.setId("b1g")
.add();
Networks.createGround(b1);
Networks.createGround(b1g);
return network;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.sld-svc {fill: var(--sld-vl-color, blue)}
.sld-vsc {fill: var(--sld-vl-color, blue)}
.sld-lcc {fill: var(--sld-vl-color, blue)}
.sld-ground {stroke-width: 1.5; stroke: var(--sld-vl-color, black); fill: none}
.sld-ground {stroke: var(--sld-vl-color, blue); fill: none}
.sld-node-infos {stroke: none; fill: var(--sld-vl-color, black)}
.sld-node {stroke: none; fill: black}
.sld-flash {stroke: none; fill: black}
Expand All @@ -40,5 +40,5 @@
.sld-ground-disconnection-attach {stroke: var(--sld-vl-color, #c80000); fill: none}
.sld-open .sld-ground-disconnection-ground {stroke: black; fill: none}
.sld-closed .sld-ground-disconnection-ground {stroke: var(--sld-vl-color, #c80000); fill: none}
.sld-open.sld-ground-disconnection {stroke-width: 1.5; stroke: var(--sld-vl-color, black); fill: none}
.sld-open.sld-ground-disconnection {stroke: var(--sld-vl-color, black); fill: none}
.sld-closed.sld-ground-disconnection {fill: var(--sld-vl-color, black)}
Original file line number Diff line number Diff line change
Expand Up @@ -457,21 +457,27 @@
}
]
}, {
"type" : "GROUND",
"anchorPoints" : [ {
"x" : 0.0,
"y" : -11.0,
"orientation" : "VERTICAL"
} ],
"size" : {
"width" : 20.0,
"height" : 24.0
"type": "GROUND",
"anchorPoints": [
{
"x": 0.0,
"y": 10.0,
"orientation": "VERTICAL"
}
],
"size": {
"width": 20.0,
"height": 20.0
},
"transformations" : { "LEFT":"ROTATION", "RIGHT":"ROTATION" },
"subComponents" : [ {
"name" : "GROUND",
"fileName" : "ground.svg"
} ],
"transformations": {
"DOWN": "ROTATION"
},
"subComponents": [
{
"name": "GROUND",
"fileName": "ground.svg"
}
],
"styleClass" : "sld-ground"
},
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
package com.powsybl.sld.iidm;

import com.powsybl.diagram.test.Networks;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.Network;
import com.powsybl.sld.builders.NetworkGraphBuilder;
import com.powsybl.sld.library.ComponentLibrary;
import com.powsybl.sld.library.ConvergenceComponentLibrary;
import com.powsybl.sld.library.FlatDesignLibrary;
import com.powsybl.sld.model.graphs.VoltageLevelGraph;
import com.powsybl.sld.svg.styles.iidm.TopologicalStyleProvider;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -26,10 +33,11 @@ class TestCaseGroundDisconnector extends AbstractTestCaseIidm {
public void setUp() {
}

@Test
void testGroundDisconnectorOnLineNodeBreaker() {
@ParameterizedTest(name = "{1}")
@MethodSource("provideTestData")
void test(Network network, String resourceName, ComponentLibrary componentLibrary) {
// Create network
network = Networks.createNetworkGroundDisconnectorOnLineNodeBreaker();
this.network = network;

// Build graph
graphBuilder = new NetworkGraphBuilder(network);
Expand All @@ -39,54 +47,16 @@ void testGroundDisconnectorOnLineNodeBreaker() {
voltageLevelGraphLayout(g);

// Write svg and compare to reference
assertEquals(toString("/TestCaseGroundDisconnectorOnLineNodeBreaker.svg"), toSVG(g, "/TestCaseGroundDisconnectorOnLineNodeBreaker.svg", componentLibrary, layoutParameters, svgParameters, getDefaultDiagramLabelProvider(), new TopologicalStyleProvider(network)));
}

@Test
void testGroundDisconnectorOnBusBarNodeBreaker() {
// Create network
network = Networks.createNetworkGroundDisconnectorOnBusBarNodeBreaker();

// build graph
graphBuilder = new NetworkGraphBuilder(network);
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph("vl");

// Run layout
voltageLevelGraphLayout(g);

// Write svg and compare to reference
assertEquals(toString("/TestCaseGroundDisconnectorOnBusBarNodeBreaker.svg"), toSVG(g, "/TestCaseGroundDisconnectorOnBusBarNodeBreaker.svg", componentLibrary, layoutParameters, svgParameters, getDefaultDiagramLabelProvider(), new TopologicalStyleProvider(network)));
}

@Test
void testGroundDisconnectorOnLineBusBreaker() {
// Create network
network = Networks.createNetworkGroundDisconnectorOnLineBusBreaker();

// build graph
graphBuilder = new NetworkGraphBuilder(network);
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph("vl");

// Run layout
voltageLevelGraphLayout(g);

// Write svg and compare to reference
assertEquals(toString("/TestCaseGroundDisconnectorOnLineBusBreaker.svg"), toSVG(g, "/TestCaseGroundDisconnectorOnLineBusBreaker.svg", componentLibrary, layoutParameters, svgParameters, getDefaultDiagramLabelProvider(), new TopologicalStyleProvider(network)));
assertEquals(toString(resourceName), toSVG(g, resourceName, componentLibrary, layoutParameters, svgParameters,
getDefaultDiagramLabelProvider(), new TopologicalStyleProvider(network)));
}

@Test
void testGroundDisconnectorOnBusBarBusBreaker() {
// Create network
network = Networks.createNetworkGroundDisconnectorOnBusBarBusBreaker();

// build graph
graphBuilder = new NetworkGraphBuilder(network);
VoltageLevelGraph g = graphBuilder.buildVoltageLevelGraph("vl");

// Run layout
voltageLevelGraphLayout(g);

// Write svg and compare to reference
assertEquals(toString("/TestCaseGroundDisconnectorOnBusBarBusBreaker.svg"), toSVG(g, "/TestCaseGroundDisconnectorOnBusBarBusBreaker.svg", componentLibrary, layoutParameters, svgParameters, getDefaultDiagramLabelProvider(), new TopologicalStyleProvider(network)));
private static List<Arguments> provideTestData() {
return List.of(
Arguments.of(Networks.createNetworkGroundDisconnector(), "/GroundDisconnectorsAndGround.svg", new ConvergenceComponentLibrary()),
Arguments.of(Networks.createNetworkGroundsBusBreaker(), "/GroundsBusBreaker.svg", new ConvergenceComponentLibrary()),
Arguments.of(Networks.createNetworkGroundDisconnector(), "/GroundDisconnectorsAndGroundFlat.svg", new FlatDesignLibrary()),
Arguments.of(Networks.createNetworkGroundsBusBreaker(), "/GroundsBusBreakerFlat.svg", new FlatDesignLibrary())
);
}
}
Loading