Skip to content

Commit

Permalink
Update slack terminal if connectable is related.
Browse files Browse the repository at this point in the history
Signed-off-by: Bertrand Rix <[email protected]>
  • Loading branch information
obrix committed Oct 4, 2023
1 parent d00316e commit 81268bc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion java/src/main/java/com/powsybl/python/network/NetworkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.powsybl.dataframe.network.extensions.ConnectablePositionFeederData;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import com.powsybl.iidm.network.extensions.SlackTerminal;
import com.powsybl.python.commons.PyPowsyblApiHeader;

import java.util.List;
Expand Down Expand Up @@ -258,8 +259,21 @@ public static void moveConnectable(Network network, String equipmentId, String b

boolean foundTerminal = false;
for (Terminal t : b.getConnectedTerminals()) {
if (t.getConnectable().getId().equals(equipmentId)) {
Connectable<?> connectable = t.getConnectable();
if (connectable.getId().equals(equipmentId)) {
SlackTerminal slackTerminal = t.getVoltageLevel().getExtension(SlackTerminal.class);
//Terminal of the connectable was a slack terminal, mus be updated after the move...
boolean updateSlackTerminal = slackTerminal != null && slackTerminal.getTerminal().equals(t);

t.getBusBreakerView().moveConnectable(busDestination, true);

if (updateSlackTerminal) {
for (Terminal newTerminal : connectable.getTerminals()) {
if (newTerminal.getBusBreakerView().getBus().getId().equals(busDestination)) {
slackTerminal.setTerminal(newTerminal);
}
}
}
foundTerminal = true;
}
}
Expand Down

0 comments on commit 81268bc

Please sign in to comment.