From cbe70079a94966fdb2ad48be3c0c91116a719b14 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 9 Sep 2024 15:02:52 +0200 Subject: [PATCH 1/4] draft moveConnectable updateResource Signed-off-by: Mathieu DEHARBE --- .../store/iidm/impl/TerminalBusBreakerViewImpl.java | 12 +++++++++--- .../store/iidm/impl/TerminalNodeBreakerViewImpl.java | 9 +++++++-- 2 files changed, 16 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..4dbb88c16 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,15 @@ 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()); + //attributes.setConnectableBus(busId); + //attributes.setBus(connected ? busId : null); + //attributes.setVoltageLevelId(voltageLevel.getId()); + //index.updateResource(getAbstractIdentifiable().getResource(), null); + getAbstractIdentifiable().updateResource(res -> { + attributes.setConnectableBus(busId); + attributes.setBus(connected ? busId : null); + attributes.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..1207eea65 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); + //attributes.setNode(node); + //attributes.setVoltageLevelId(voltageLevelId); + //index.updateResource(getAbstractIdentifiable().getResource(), null); + getAbstractIdentifiable().updateResource(res -> { + attributes.setNode(node); + attributes.setVoltageLevelId(voltageLevelId); + }); voltageLevel.invalidateCalculatedBuses(); } } From 693822817b66afc0c9343f5d0c8d3a855e749c69 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Mon, 9 Sep 2024 15:32:54 +0200 Subject: [PATCH 2/4] corrects TU move, reaffect null Signed-off-by: Mathieu DEHARBE --- .../network/store/iidm/impl/TerminalBusBreakerViewImpl.java | 1 + .../network/store/iidm/impl/TerminalNodeBreakerViewImpl.java | 2 ++ 2 files changed, 3 insertions(+) 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 4dbb88c16..28611dcf2 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 @@ -153,6 +153,7 @@ public void moveConnectable(String busId, boolean connected) { getAbstractIdentifiable().updateResource(res -> { attributes.setConnectableBus(busId); attributes.setBus(connected ? busId : null); + attributes.setNode(null); attributes.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 1207eea65..b1fe59b4a 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 @@ -74,6 +74,8 @@ public void moveConnectable(int node, String voltageLevelId) { //attributes.setVoltageLevelId(voltageLevelId); //index.updateResource(getAbstractIdentifiable().getResource(), null); getAbstractIdentifiable().updateResource(res -> { + attributes.setConnectableBus(null); + attributes.setBus(null); attributes.setNode(node); attributes.setVoltageLevelId(voltageLevelId); }); From 42930a0a1d5fb82d4c1f625a6296746b96a0a55f Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 10 Sep 2024 11:43:55 +0200 Subject: [PATCH 3/4] use of attributesGetter Signed-off-by: Mathieu DEHARBE --- .../store/iidm/impl/TerminalBusBreakerViewImpl.java | 12 ++++-------- .../store/iidm/impl/TerminalNodeBreakerViewImpl.java | 11 ++++------- 2 files changed, 8 insertions(+), 15 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 28611dcf2..c29e41a76 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,15 +146,11 @@ 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()); - //index.updateResource(getAbstractIdentifiable().getResource(), null); getAbstractIdentifiable().updateResource(res -> { - attributes.setConnectableBus(busId); - attributes.setBus(connected ? busId : null); - attributes.setNode(null); - attributes.setVoltageLevelId(voltageLevel.getId()); + attributesGetter.apply(res).setConnectableBus(busId); + attributesGetter.apply(res).setBus(connected ? busId : null); + attributesGetter.apply(res).setNode(null); + attributesGetter.apply(res).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 b1fe59b4a..5c3bf31c9 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,14 +70,11 @@ 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); - //index.updateResource(getAbstractIdentifiable().getResource(), null); getAbstractIdentifiable().updateResource(res -> { - attributes.setConnectableBus(null); - attributes.setBus(null); - attributes.setNode(node); - attributes.setVoltageLevelId(voltageLevelId); + attributesGetter.apply(res).setConnectableBus(null); + attributesGetter.apply(res).setBus(null); + attributesGetter.apply(res).setNode(node); + attributesGetter.apply(res).setVoltageLevelId(voltageLevelId); }); voltageLevel.invalidateCalculatedBuses(); } From d40ef06b2b72d106e641276fdb94846d33b27119 Mon Sep 17 00:00:00 2001 From: Mathieu DEHARBE Date: Tue, 10 Sep 2024 13:20:25 +0200 Subject: [PATCH 4/4] introduce variable Signed-off-by: Mathieu DEHARBE --- .../store/iidm/impl/TerminalBusBreakerViewImpl.java | 9 +++++---- .../store/iidm/impl/TerminalNodeBreakerViewImpl.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 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 c29e41a76..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 @@ -147,10 +147,11 @@ public void moveConnectable(String busId, boolean connected) { + " to bus " + busId + " of voltage level " + bus.getVoltageLevel().getId() + ", which is a node breaker voltage level"); } getAbstractIdentifiable().updateResource(res -> { - attributesGetter.apply(res).setConnectableBus(busId); - attributesGetter.apply(res).setBus(connected ? busId : null); - attributesGetter.apply(res).setNode(null); - attributesGetter.apply(res).setVoltageLevelId(voltageLevel.getId()); + 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 5c3bf31c9..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 @@ -71,10 +71,11 @@ public void moveConnectable(int node, String voltageLevelId) { + ") is already connected to node " + node + " of voltage level " + voltageLevelId); } getAbstractIdentifiable().updateResource(res -> { - attributesGetter.apply(res).setConnectableBus(null); - attributesGetter.apply(res).setBus(null); - attributesGetter.apply(res).setNode(node); - attributesGetter.apply(res).setVoltageLevelId(voltageLevelId); + InjectionAttributes attr = attributesGetter.apply(res); + attr.setConnectableBus(null); + attr.setBus(null); + attr.setNode(node); + attr.setVoltageLevelId(voltageLevelId); }); voltageLevel.invalidateCalculatedBuses(); }