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

Creating an modification with wrong bus bar section now throws an exception #2516

Merged
merged 6 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -113,6 +113,18 @@ public String getNewLine2Name() {
return newLine2Name;
}

// voltageLevel.getNodeBreakerView().getBusbarSection(bbsOrBusId) is currently returning any busbarSection from the network
// even if this busbarSection is not included in the voltageLevel
// this method returns null if the busbarSectionId does not belong to the voltageLevel
private BusbarSection getBusBarSectionFromVoltageLevel(Network network, VoltageLevel voltageLevel, String busBarSectionId) {
BusbarSection bbs = network.getBusbarSection(busBarSectionId);
if (bbs == null || !voltageLevel.equals(bbs.getTerminal().getVoltageLevel())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than equal, you should use ==/!= for voltage level

return null;
}

return bbs;
}

@Override
public void apply(Network network, boolean throwException,
ComputationManager computationManager, Reporter reporter) {
Expand Down Expand Up @@ -176,7 +188,7 @@ public void apply(Network network, boolean throwException,

TopologyKind topologyKind = tappedVoltageLevel.getTopologyKind();
if (topologyKind == TopologyKind.BUS_BREAKER) {
Bus bus = network.getBusBreakerView().getBus(bbsOrBusId);
Bus bus = tappedVoltageLevel.getBusBreakerView().getBus(bbsOrBusId);
if (bus == null) {
notFoundBusInVoltageLevelReport(reporter, bbsOrBusId, tappedVoltageLevel.getId());
if (throwException) {
Expand All @@ -199,7 +211,7 @@ public void apply(Network network, boolean throwException,
newLine2Adder.setBus1(bus2.getId());
newLine2Adder.setConnectableBus1(bus2.getId());
} else if (topologyKind == TopologyKind.NODE_BREAKER) {
BusbarSection bbs = network.getBusbarSection(bbsOrBusId);
BusbarSection bbs = getBusBarSectionFromVoltageLevel(network, tappedVoltageLevel, bbsOrBusId);
miovd marked this conversation as resolved.
Show resolved Hide resolved
if (bbs == null) {
notFoundBusbarSectionInVoltageLevelReport(reporter, bbsOrBusId, tappedVoltageLevel.getId());
if (throwException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ void replaceTeePointByVoltageLevelOnLineNbTest() throws IOException {
.withNewLine2Id("NEW LINE2").build();
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError6.apply(network, true, Reporter.NO_OP)).getMessage().contains("Unable to find the tee point and the tapped voltage level from lines CJ_1, CJ_2 and LINE34"));

NetworkModification modificationWithError7 = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("CJ_1")
.withTeePointLine2("CJ_2")
.withTeePointLineToRemove("testLine")
.withBbsOrBusId("bbs3")
.withNewLine1Id("NEW LINE1")
.withNewLine2Id("NEW LINE2").build();
assertTrue(assertThrows(PowsyblException.class, () -> modificationWithError7.apply(network, true, Reporter.NO_OP)).getMessage().contains("Busbar section bbs3 is not found in voltage level VLTEST"));

modification = new ReplaceTeePointByVoltageLevelOnLineBuilder()
.withTeePointLine1("CJ_1")
.withTeePointLine2("CJ_2")
Expand Down