Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ core.iidm.modification.voltageConnectedOnLine = Voltage level ${voltageLevelId}
core.iidm.modification.voltageLevelCreated = VoltageLevel ${voltageLevelId} created
core.iidm.modification.voltageLevelNotFound = Voltage level ${voltageLevelId} is not found
core.iidm.modification.voltageLevelRemoved = Voltage level ${vlId} removed
core.iidm.modification.voltageLevelRemovingEquipmentsLeft = Voltage level ${vlId} still contains equipments and it is not removed.
core.iidm.modification.voltageLevelNotRemovedWithRemainingBranches = Voltage level ${vlId} still contains equipments including branches, it is not removed.
core.iidm.modification.voltageLevelNotRemovedWithNoBranch = Voltage level ${vlId} still contains equipments but no branch, it is not removed.
core.iidm.modification.wrongSwitchKind = Switch kinds must be DISCONNECTOR or BREAKER
core.iidm.modification.noBusbarSection = No busbar section provided.
core.iidm.modification.wrongNetwork = All busbar sections must be in the network passed to the method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ core.iidm.modification.voltageConnectedOnLine = Le poste ${voltageLevelId} conne
core.iidm.modification.voltageLevelCreated = Poste ${voltageLevelId} créé.
core.iidm.modification.voltageLevelNotFound = Poste ${voltageLevelId} introuvable.
core.iidm.modification.voltageLevelRemoved = Le poste ${vlId} a été supprimé.
core.iidm.modification.voltageLevelRemovingEquipmentsLeft = Le poste ${vlId} contient toujours des équipements, il n'est donc pas supprimé.
core.iidm.modification.voltageLevelNotRemovedWithRemainingBranches = Le poste ${vlId} contient toujours des équipements dont des quadripôles, il n'est pas supprimé.
core.iidm.modification.voltageLevelNotRemovedWithNoBranch =Le poste ${vlId} contient toujours des équipements mais aucun quadripôles, il n'est pas supprimé.
core.iidm.modification.wrongSwitchKind = Les organes de coupures doivent être de type DISCONNECTOR ou BREAKER.
core.iidm.modification.noBusbarSection = Aucune section de jeu de barres donnée
core.iidm.modification.wrongNetwork = Toutes les sections de jeu de barres doivent être dans le réseau passé en entrée.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,14 @@ static void removeVoltageLevelAndSubstation(VoltageLevel voltageLevel, ReportNod
String vlId = voltageLevel.getId();
boolean noMoreEquipments = voltageLevel.getConnectableStream().noneMatch(c -> c.getType() != IdentifiableType.BUSBAR_SECTION);
if (!noMoreEquipments) {
voltageLevelRemovingEquipmentsLeftReport(reportNode, vlId);
boolean noMoreBranch = voltageLevel.getConnectableStream().noneMatch(c -> c.getType() == IdentifiableType.LINE
|| c.getType() == IdentifiableType.TWO_WINDINGS_TRANSFORMER || c.getType() == IdentifiableType.THREE_WINDINGS_TRANSFORMER ||
c.getType() == IdentifiableType.HVDC_CONVERTER_STATION);
if (noMoreBranch) {
voltageLevelNotRemovedWithNoBranch(reportNode, vlId);
} else {
voltageLevelNotRemovedWithRemainingBranches(reportNode, vlId);
}
LOGGER.warn("Voltage level {} still contains equipments and it is not removed.", vlId);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,17 @@ public static void noConnectablePositionExtension(ReportNode reportNode, Voltage
.add();
}

public static void voltageLevelRemovingEquipmentsLeftReport(ReportNode reportNode, String vlId) {
public static void voltageLevelNotRemovedWithRemainingBranches(ReportNode reportNode, String vlId) {
reportNode.newReportNode()
.withMessageTemplate("core.iidm.modification.voltageLevelRemovingEquipmentsLeft")
.withMessageTemplate("core.iidm.modification.voltageLevelNotRemovedWithRemainingBranches")
.withUntypedValue("vlId", vlId)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
}

public static void voltageLevelNotRemovedWithNoBranch(ReportNode reportNode, String vlId) {
reportNode.newReportNode()
.withMessageTemplate("core.iidm.modification.voltageLevelNotRemovedWithNoBranch")
.withUntypedValue("vlId", vlId)
.withSeverity(TypedValue.WARN_SEVERITY)
.add();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ class RevertCreateLineOnLineTest extends AbstractModificationTest {

@Test
void revertCreateLineOnLineNbTest() throws IOException {
Network network = createNbNetworkWithBusbarSection();
Line line = network.getLine("CJ");
LineAdder adder = createLineAdder(line, network);
NetworkModification modification = new CreateLineOnLineBuilder().withBusbarSectionOrBusId(BBS).withLine(line).withLineAdder(adder).build();
modification.apply(network);
Network network = createNetworkWithLineOnLine();

VoltageLevel vl = network.newVoltageLevel().setId("VL3").setNominalV(380).setTopologyKind(TopologyKind.NODE_BREAKER).add();
vl.getNodeBreakerView().newBusbarSection().setId("bbs3").setNode(0).add();
Expand Down Expand Up @@ -167,7 +163,7 @@ void revertCreateLineOnLineNbTest() throws IOException {
.withResourceBundles(PowsyblTestReportResourceBundle.TEST_BASE_NAME, PowsyblCoreReportResourceBundle.BASE_NAME)
.withMessageTemplate("reportNodeTestRevertCreateLineOnLine")
.build();
modification = new RevertCreateLineOnLineBuilder()
NetworkModification modification = new RevertCreateLineOnLineBuilder()
.withLineToBeMerged1Id("CJ_1")
.withLineToBeMerged2Id("CJ_2")
.withLineToBeDeletedId("testLine")
Expand Down Expand Up @@ -341,25 +337,20 @@ void testHasImpact() {

@Test
void testDoesNotDeleteVoltageLevel() throws IOException {
Network network = createNbNetworkWithBusbarSection();
Line line = network.getLine("CJ");
LineAdder adder = createLineAdder(line, network);
NetworkModification modification = new CreateLineOnLineBuilder().withBusbarSectionOrBusId(BBS).withLine(line).withLineAdder(adder).build();
modification.apply(network);
Network network = createNetworkWithLineOnLine();
VoltageLevel vlTest = network.getVoltageLevel(VLTEST);
assertNotNull(vlTest.getNodeBreakerView().getSwitch("CJ_BREAKER"));
assertNotNull(vlTest.getNodeBreakerView().getSwitch("CJ_DISCONNECTOR_2_0"));
VoltageLevel vl = network.getVoltageLevel("CJ_VL");
assertNotNull(vl);

// add one element
vl.newLoad().setId("loadId").setP0(100).setQ0(50).setNode(4).add();

ReportNode reportNode = ReportNode.newRootReportNode()
.withResourceBundles(PowsyblTestReportResourceBundle.TEST_BASE_NAME, PowsyblCoreReportResourceBundle.BASE_NAME)
.withMessageTemplate("reportNodeTestRevertCreateLineOnLineKeepingTheVL")
.build();
modification = new RevertCreateLineOnLineBuilder()
NetworkModification modification = new RevertCreateLineOnLineBuilder()
.withLineToBeMerged1Id("CJ_1")
.withLineToBeMerged2Id("CJ_2")
.withLineToBeDeletedId("testLine")
Expand All @@ -375,4 +366,36 @@ void testDoesNotDeleteVoltageLevel() throws IOException {
assertNull(vlTest.getNodeBreakerView().getSwitch("CJ_DISCONNECTOR_2_0"));
testReportNode(reportNode, "/reportNode/revert-create-line-on-line-keeping-vl.txt");
}

@Test
void testDoesNotDeleteVoltageLevelWithBranches() throws IOException {
Network network = createNetworkWithLineOnLine();
VoltageLevel vl = network.getVoltageLevel("CJ_VL");
assertNotNull(vl);
// add one element
network.newLine().setId("line").setR(1).setX(1).setVoltageLevel1("CJ_VL").setVoltageLevel2(VLTEST).setNode1(4).setNode2(5).add();
ReportNode reportNode = ReportNode.newRootReportNode()
.withResourceBundles(PowsyblTestReportResourceBundle.TEST_BASE_NAME, PowsyblCoreReportResourceBundle.BASE_NAME)
.withMessageTemplate("reportNodeTestRevertCreateLineOnLineKeepingTheVL")
.build();
NetworkModification modification = new RevertCreateLineOnLineBuilder()
.withLineToBeMerged1Id("CJ_1")
.withLineToBeMerged2Id("CJ_2")
.withLineToBeDeletedId("testLine")
.withMergedLineId("CJ_NEW")
.build();
modification.apply(network, true, reportNode);
Line line = network.getLine("line");
assertNotNull(line);
testReportNode(reportNode, "/reportNode/revert-create-line-on-line-keeping-vl-with-branches.txt");
}

private Network createNetworkWithLineOnLine() {
Network network = createNbNetworkWithBusbarSection();
Line line = network.getLine("CJ");
LineAdder adder = createLineAdder(line, network);
NetworkModification modification = new CreateLineOnLineBuilder().withBusbarSectionOrBusId(BBS).withLine(line).withLineAdder(adder).build();
modification.apply(network);
return network;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
+ Testing reportNode for reverting create line on line and not removing the voltage level
Line CJ_1 removed
Line CJ_2 removed
Line testLine removed
Line CJ_NEW created
Voltage level CJ_VL still contains equipments including branches, it is not removed.
Voltage level VLTEST still contains equipments including branches, it is not removed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
Line CJ_2 removed
Line testLine removed
Line CJ_NEW created
Voltage level CJ_VL still contains equipments and it is not removed.
Voltage level CJ_VL still contains equipments but no branch, it is not removed.
Voltage level VLTEST removed
Loading