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 @@ -89,7 +89,7 @@ public T setConnectableBus1(String connectableBus1) {
}

protected TerminalExt checkAndGetTerminal1() {
return new TerminalBuilder(voltageLevel.getNetworkRef(), this, null, TerminalNumber.ONE)
return new TerminalBuilder(voltageLevel.getNetworkRef(), voltageLevel.getTopologyKind(), this, null, TerminalNumber.ONE)
.setNode(node1)
.setBus(bus1)
.setConnectableBus(connectableBus1)
Expand All @@ -113,7 +113,7 @@ public T setConnectableBus2(String connectableBus2) {

protected Optional<TerminalExt> checkAndGetTerminal2() {
if (hasTwoAcTerminals()) {
return Optional.of(new TerminalBuilder(voltageLevel.getNetworkRef(), this, null, TerminalNumber.TWO)
return Optional.of(new TerminalBuilder(voltageLevel.getNetworkRef(), voltageLevel.getTopologyKind(), this, null, TerminalNumber.TWO)
.setNode(node2)
.setBus(bus2)
.setConnectableBus(connectableBus2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public T setVoltageLevel1(String voltageLevelId1) {

protected TerminalExt checkAndGetTerminal1() {
VoltageLevelExt voltageLevel = checkAndGetVoltageLevel1();
return new TerminalBuilder(voltageLevel.getNetworkRef(), this, ThreeSides.ONE, null)
return new TerminalBuilder(voltageLevel.getNetworkRef(), voltageLevel.getTopologyKind(), this, ThreeSides.ONE, null)
.setNode(node1)
.setBus(bus1)
.setConnectableBus(connectableBus1)
Expand Down Expand Up @@ -99,7 +99,7 @@ public T setVoltageLevel2(String voltageLevelId2) {

protected TerminalExt checkAndGetTerminal2() {
VoltageLevelExt voltageLevel = checkAndGetVoltageLevel2();
return new TerminalBuilder(voltageLevel.getNetworkRef(), this, ThreeSides.TWO, null)
return new TerminalBuilder(voltageLevel.getNetworkRef(), voltageLevel.getTopologyKind(), this, ThreeSides.TWO, null)
.setNode(node2)
.setBus(bus2)
.setConnectableBus(connectableBus2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected void move(TerminalExt oldTerminal, int node, String voltageLevelId) {
}

// create the new terminal and attach it to the given voltage level and to the connectable
TerminalExt terminalExt = new TerminalBuilder(voltageLevel.getNetworkRef(), this, oldTerminal.getSide(), oldTerminal.getTerminalNumber())
TerminalExt terminalExt = new TerminalBuilder(voltageLevel.getNetworkRef(), voltageLevel.getTopologyKind(), this, oldTerminal.getSide(), oldTerminal.getTerminalNumber())
.setNode(node)
.build();

Expand All @@ -169,7 +169,7 @@ protected void move(TerminalExt oldTerminal, String busId, boolean connected) {
}

// create the new terminal and attach it to the voltage level of the given bus and links it to the connectable
TerminalExt terminalExt = new TerminalBuilder(((VoltageLevelExt) bus.getVoltageLevel()).getNetworkRef(), this, oldTerminal.getSide(), oldTerminal.getTerminalNumber())
TerminalExt terminalExt = new TerminalBuilder(((VoltageLevelExt) bus.getVoltageLevel()).getNetworkRef(), bus.getVoltageLevel().getTopologyKind(), this, oldTerminal.getSide(), oldTerminal.getTerminalNumber())
.setBus(connected ? bus.getId() : null)
.setConnectableBus(bus.getId())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected Ref<NetworkImpl> getNetworkRef() {
}

protected TerminalExt checkAndGetTerminal() {
return new TerminalBuilder(getNetworkRef(), this, null, null)
return new TerminalBuilder(getNetworkRef(), voltageLevel.getTopologyKind(), this, null, null)
.setNode(node)
.setBus(bus)
.setConnectableBus(connectableBus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.powsybl.commons.ref.Ref;
import com.powsybl.iidm.network.Validable;
import com.powsybl.iidm.network.ValidationException;
import com.powsybl.iidm.network.TopologyKind;

import java.util.Objects;

Expand All @@ -29,15 +30,18 @@ class TerminalBuilder {

private final TerminalNumber terminalNumber;

private final TopologyKind topologyKind;

private Integer node;

private String bus;

private String connectableBus;

TerminalBuilder(Ref<? extends VariantManagerHolder> network, Validable validable, ThreeSides side, TerminalNumber terminalNumber) {
TerminalBuilder(Ref<? extends VariantManagerHolder> network, TopologyKind topologyKind, Validable validable, ThreeSides side, TerminalNumber terminalNumber) {
this.network = Objects.requireNonNull(network);
this.validable = Objects.requireNonNull(validable);
this.topologyKind = Objects.requireNonNull(topologyKind);
this.side = side;
this.terminalNumber = terminalNumber;
}
Expand All @@ -64,14 +68,16 @@ TerminalExt build() {
"connection node and connection bus are exclusives");
}

if (node == null) {
if (topologyKind == TopologyKind.NODE_BREAKER) {
if (node == null) {
throw new ValidationException(validable, "node is not set");
}
return new NodeTerminal(network, side, terminalNumber, node);
} else {
if (connectionBus == null) {
throw new ValidationException(validable, "connectable bus is not set");
}

return new BusTerminal(network, side, terminalNumber, connectionBus, bus != null);
} else {
return new NodeTerminal(network, side, terminalNumber, node);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected void checkParams() {

protected TerminalExt checkAndGetTerminal() {
VoltageLevelExt voltageLevel = checkAndGetVoltageLevel();
return new TerminalBuilder(voltageLevel.getNetworkRef(), this, side, null)
return new TerminalBuilder(voltageLevel.getNetworkRef(), voltageLevel.getTopologyKind(), this, side, null)
.setNode(node)
.setBus(bus)
.setConnectableBus(connectableBus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ record TopologyModelInfos(TerminalExt terminal, String connectableBusId, boolean
AbstractConnectable<?> connectable = oldTerminalExt.getConnectable();

// create the new terminal with new type
TerminalExt newTerminalExt = new TerminalBuilder(networkRef, this, oldTerminalExt.getSide(), oldTerminalExt.getTerminalNumber())
TerminalExt newTerminalExt = new TerminalBuilder(networkRef, TopologyKind.BUS_BREAKER, this, oldTerminalExt.getSide(), oldTerminalExt.getTerminalNumber())
.setBus(infos.connected ? infos.connectableBusId() : null)
.setConnectableBus(infos.connectableBusId())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void testCreationError() {
.setId("Ground")
.setEnsureIdUnicity(true);
ValidationException exception = assertThrows(ValidationException.class, groundAdderNB::add);
assertEquals("Ground 'Ground': connectable bus is not set", exception.getMessage());
assertEquals("Ground 'Ground': node is not set", exception.getMessage());
groundAdderNB = vl1.newGround()
.setNode(6)
.setEnsureIdUnicity(true);
Expand Down