diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/shuntcompensator/ShuntCompensatorTabInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/shuntcompensator/ShuntCompensatorTabInfos.java index 85b6453b..a9d818f0 100644 --- a/src/main/java/org/gridsuite/network/map/dto/definition/shuntcompensator/ShuntCompensatorTabInfos.java +++ b/src/main/java/org/gridsuite/network/map/dto/definition/shuntcompensator/ShuntCompensatorTabInfos.java @@ -11,6 +11,7 @@ import lombok.Getter; import lombok.experimental.SuperBuilder; import org.gridsuite.network.map.dto.ElementInfosWithProperties; +import org.gridsuite.network.map.dto.definition.topology.BusInfos; import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; import org.gridsuite.network.map.dto.definition.extension.InjectionObservabilityInfos; import org.gridsuite.network.map.dto.definition.extension.MeasurementsInfos; @@ -62,4 +63,7 @@ public class ShuntCompensatorTabInfos extends ElementInfosWithProperties { @JsonInclude(JsonInclude.Include.NON_NULL) private Map voltageLevelProperties; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private BusInfos bus; } diff --git a/src/main/java/org/gridsuite/network/map/dto/definition/topology/BusInfos.java b/src/main/java/org/gridsuite/network/map/dto/definition/topology/BusInfos.java new file mode 100644 index 00000000..1d708d17 --- /dev/null +++ b/src/main/java/org/gridsuite/network/map/dto/definition/topology/BusInfos.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2026, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ +package org.gridsuite.network.map.dto.definition.topology; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Builder; +import lombok.Getter; + +/** + * @author Mathieu Deharbe + * + * Those BusInfos are used when we want to add Bus data into another mapped data, not by itself + */ +@Getter +@Builder +public class BusInfos { + @JsonInclude(JsonInclude.Include.NON_NULL) + private String id; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private Double v; +} diff --git a/src/main/java/org/gridsuite/network/map/dto/mapper/ShuntCompensatorMapper.java b/src/main/java/org/gridsuite/network/map/dto/mapper/ShuntCompensatorMapper.java index e656430c..b0d2b3c0 100644 --- a/src/main/java/org/gridsuite/network/map/dto/mapper/ShuntCompensatorMapper.java +++ b/src/main/java/org/gridsuite/network/map/dto/mapper/ShuntCompensatorMapper.java @@ -10,6 +10,7 @@ import com.powsybl.iidm.network.extensions.Measurement.Type; import org.gridsuite.network.map.dto.ElementInfos; import org.gridsuite.network.map.dto.InfoTypeParameters; +import org.gridsuite.network.map.dto.definition.topology.BusInfos; import org.gridsuite.network.map.dto.definition.shuntcompensator.ShuntCompensatorFormInfos; import org.gridsuite.network.map.dto.definition.shuntcompensator.ShuntCompensatorTabInfos; import org.gridsuite.network.map.dto.utils.ElementUtils; @@ -91,6 +92,17 @@ private static ShuntCompensatorTabInfos toTabInfos(Identifiable identifiable) .properties(getProperties(shuntCompensator)) .country(mapCountry(terminal.getVoltageLevel().getSubstation().orElse(null))); + Bus bus = terminal.getBusView().getBus(); + if (bus != null && bus.getId() != null) { + // those bus values are only applied if the bus is connected + builder.bus( + BusInfos.builder() + .id(bus.getId()) + .v(Double.isNaN(bus.getV()) ? null : bus.getV()) + .build() + ); + } + Double bPerSection = null; if (shuntCompensator.getModel() instanceof ShuntCompensatorLinearModel) { bPerSection = shuntCompensator.getModel(ShuntCompensatorLinearModel.class).getBPerSection(); diff --git a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java index 1ac69ef9..785deb49 100644 --- a/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java +++ b/src/test/java/org/gridsuite/network/map/NetworkMapControllerTest.java @@ -2732,6 +2732,7 @@ void shouldReturnBatteryTabData() throws Exception { @Test void shouldReturnShuntCompensatorTabData() throws Exception { + network.getShuntCompensator("SHUNT_VLNB").getTerminal().getBusView().getBus().setV(3.5); // to add a loadflow computed voltage succeedingTestForElementsInfos(NETWORK_UUID, null, ElementType.SHUNT_COMPENSATOR, InfoType.TAB, null, resourceToString("/shunt-compensators-tab-data.json")); succeedingTestForElementsInfos(NETWORK_UUID, VARIANT_ID, ElementType.SHUNT_COMPENSATOR, InfoType.TAB, null, resourceToString("/shunt-compensators-tab-data-in-variant.json")); } diff --git a/src/test/resources/all-data-in-variant.json b/src/test/resources/all-data-in-variant.json index 71b524cd..a3fccb6b 100644 --- a/src/test/resources/all-data-in-variant.json +++ b/src/test/resources/all-data-in-variant.json @@ -2172,6 +2172,9 @@ }, "voltageLevelProperties": { "Country": "FR" + }, + "bus": { + "id": "VLNEW2_0" } }, { @@ -2193,6 +2196,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -2249,6 +2255,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } } ], diff --git a/src/test/resources/all-data-without-optionals.json b/src/test/resources/all-data-without-optionals.json index c8f90570..d3e0c368 100644 --- a/src/test/resources/all-data-without-optionals.json +++ b/src/test/resources/all-data-without-optionals.json @@ -1948,6 +1948,9 @@ }, "voltageLevelProperties": { "Country": "FR" + }, + "bus": { + "id": "VLNEW2_0" } }, { @@ -1969,6 +1972,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -1989,6 +1995,9 @@ "measurementQ": { "value": 69.0, "validity": true + }, + "bus": { + "id": "VLGEN4_0" } }, { diff --git a/src/test/resources/all-data.json b/src/test/resources/all-data.json index 5d0bfccb..959b6c1e 100644 --- a/src/test/resources/all-data.json +++ b/src/test/resources/all-data.json @@ -2172,6 +2172,9 @@ }, "voltageLevelProperties": { "Country": "FR" + }, + "bus": { + "id": "VLNEW2_0" } }, { @@ -2193,6 +2196,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -2213,6 +2219,9 @@ "measurementQ": { "value": 69.0, "validity": true + }, + "bus": { + "id": "VLGEN4_0" } }, { diff --git a/src/test/resources/partial-all-data-in-variant.json b/src/test/resources/partial-all-data-in-variant.json index 8a87511c..0eb59693 100644 --- a/src/test/resources/partial-all-data-in-variant.json +++ b/src/test/resources/partial-all-data-in-variant.json @@ -352,6 +352,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -374,6 +377,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } } ], diff --git a/src/test/resources/partial-all-data.json b/src/test/resources/partial-all-data.json index ad6a21c3..8d88b892 100644 --- a/src/test/resources/partial-all-data.json +++ b/src/test/resources/partial-all-data.json @@ -352,6 +352,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } } ], diff --git a/src/test/resources/partial-all-map-data-no-redundant-lines.json b/src/test/resources/partial-all-map-data-no-redundant-lines.json index 9c2c115c..73ada2c3 100644 --- a/src/test/resources/partial-all-map-data-no-redundant-lines.json +++ b/src/test/resources/partial-all-map-data-no-redundant-lines.json @@ -370,6 +370,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -392,6 +395,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } } ], diff --git a/src/test/resources/shunt-compensators-tab-data-in-variant.json b/src/test/resources/shunt-compensators-tab-data-in-variant.json index 138f5fd3..bcf57197 100644 --- a/src/test/resources/shunt-compensators-tab-data-in-variant.json +++ b/src/test/resources/shunt-compensators-tab-data-in-variant.json @@ -41,6 +41,9 @@ }, "voltageLevelProperties": { "Country": "FR" + }, + "bus": { + "id": "VLNEW2_0" } }, { @@ -62,6 +65,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -118,6 +124,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } } ] \ No newline at end of file diff --git a/src/test/resources/shunt-compensators-tab-data.json b/src/test/resources/shunt-compensators-tab-data.json index 5e5eef93..52e35146 100644 --- a/src/test/resources/shunt-compensators-tab-data.json +++ b/src/test/resources/shunt-compensators-tab-data.json @@ -41,6 +41,9 @@ }, "voltageLevelProperties": { "Country": "FR" + }, + "bus": { + "id": "VLNEW2_0" } }, { @@ -62,6 +65,9 @@ "targetV": 225.0, "substationProperties": { "Country": "FR" + }, + "bus": { + "id": "VLGEN3_0" } }, { @@ -82,6 +88,10 @@ "measurementQ": { "value": 69.0, "validity": true + }, + "bus": { + "id": "VLGEN4_0", + "v": 3.5 } }, {