From b240dab80093049cfd301f6b1c1bbcac2d41bc16 Mon Sep 17 00:00:00 2001 From: Mathieu Deharbe <148252167+Mathieu-Deharbe@users.noreply.github.com> Date: Tue, 17 Sep 2024 11:25:57 +0200 Subject: [PATCH] UpdateResource in moveConnectable() (#447) Signed-off-by: Mathieu DEHARBE --- .../store/iidm/impl/TerminalBusBreakerViewImpl.java | 10 +++++++--- .../store/iidm/impl/TerminalNodeBreakerViewImpl.java | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java index fbd68971a..0608fbeda 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalBusBreakerViewImpl.java @@ -146,9 +146,13 @@ public void moveConnectable(String busId, boolean connected) { throw new PowsyblException("Trying to move connectable " + attributes.getResource().getId() + " to bus " + busId + " of voltage level " + bus.getVoltageLevel().getId() + ", which is a node breaker voltage level"); } - attributes.setConnectableBus(busId); - attributes.setBus(connected ? busId : null); - attributes.setVoltageLevelId(voltageLevel.getId()); + getAbstractIdentifiable().updateResource(res -> { + InjectionAttributes attr = attributesGetter.apply(res); + attr.setConnectableBus(busId); + attr.setBus(connected ? busId : null); + attr.setNode(null); + attr.setVoltageLevelId(voltageLevel.getId()); + }); voltageLevel.invalidateCalculatedBuses(); } } diff --git a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java index cab643335..08cb6325e 100644 --- a/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java +++ b/network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/TerminalNodeBreakerViewImpl.java @@ -70,8 +70,13 @@ public void moveConnectable(int node, String voltageLevelId) { throw new ValidationException(attributes.getResource(), "an equipment (" + terminal.getConnectable().getId() + ") is already connected to node " + node + " of voltage level " + voltageLevelId); } - attributes.setNode(node); - attributes.setVoltageLevelId(voltageLevelId); + getAbstractIdentifiable().updateResource(res -> { + InjectionAttributes attr = attributesGetter.apply(res); + attr.setConnectableBus(null); + attr.setBus(null); + attr.setNode(node); + attr.setVoltageLevelId(voltageLevelId); + }); voltageLevel.invalidateCalculatedBuses(); } }