Skip to content
Merged
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
39 changes: 26 additions & 13 deletions src/main/java/org/gridsuite/network/map/NetworkMapController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.gridsuite.network.map.dto.*;
import org.gridsuite.network.map.dto.AllElementsInfos;
import org.gridsuite.network.map.dto.ElementInfos;
import org.gridsuite.network.map.dto.ElementType;
import org.gridsuite.network.map.dto.InfoTypeParameters;
import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos;
import org.gridsuite.network.map.dto.definition.topology.TopologyInfos;
import org.gridsuite.network.map.services.NetworkMapService;
Expand All @@ -23,6 +26,7 @@

import java.util.*;

import static org.gridsuite.network.map.dto.utils.TopologyUtils.TopologyFilterType.*;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

/**
Expand Down Expand Up @@ -90,22 +94,31 @@ public List<ElementInfos> getVoltageLevelBusesOrBusBarSections(@Parameter(descri
return networkMapService.getVoltageLevelBusesOrBusbarSections(networkUuid, voltageLevelId, variantId);
}

@GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/switches", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Get switches description for a voltage level")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Switches description")})
public List<SwitchInfos> getVoltageLevelSwitches(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) {
return networkMapService.getVoltageLevelSwitches(networkUuid, voltageLevelId, variantId);
@GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/topology-switches", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Get switches voltage level topology description")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Network switches topology information retrieved")})
public TopologyInfos getVoltageLevelTopologySwitches(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) {
return networkMapService.getVoltageLevelTopology(networkUuid, voltageLevelId, variantId, SWITCHES);
}

@GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/topology-feeder_bays", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Get feeder bays voltage level topology description")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Network feeder bays topology information retrieved")})
public TopologyInfos getVoltageLevelTopologyFeederBays(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) {
return networkMapService.getVoltageLevelTopology(networkUuid, voltageLevelId, variantId, FEEDER_BAYS);
}

@GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/topology", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Get the voltage level topology description")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Network topology information retrieved")})
public TopologyInfos getVoltageLevelTopology(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/topology-busbar_sections", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Get busbar sections voltage level topology description")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Network busbar sections topology information retrieved")})
public TopologyInfos getVoltageLevelTopologyBusbarSections(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@Parameter(description = "Voltage level id") @PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId) {
return networkMapService.getVoltageLevelTopology(networkUuid, voltageLevelId, variantId);
return networkMapService.getVoltageLevelTopology(networkUuid, voltageLevelId, variantId, BUSBAR_SECTIONS);
}

@GetMapping(value = "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/substation-id", produces = APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2025, 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/.
*/
package org.gridsuite.network.map.dto.definition.topology;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelFormInfos;

import java.util.List;
import java.util.Map;

/**
* @author Rehili Ghazwa <ghazwa.rehili at rte-france.com>
*/
@SuperBuilder
@Getter
@Setter
public class BusBarSectionsInfos extends VoltageLevelFormInfos {

@JsonInclude(JsonInclude.Include.NON_NULL)
Boolean isBusbarSectionPositionFound;

@JsonInclude(JsonInclude.Include.NON_NULL)
Map<String, List<String>> busBarSections;
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* 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/.
*/
package org.gridsuite.network.map.dto;
package org.gridsuite.network.map.dto.definition.topology;

import lombok.Getter;
import lombok.experimental.SuperBuilder;
import org.gridsuite.network.map.dto.ElementInfos;

/**
* @author Rehili Ghazwa <ghazwa.rehili at rte-france.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
package org.gridsuite.network.map.dto.definition.topology;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.powsybl.iidm.network.SwitchKind;
import com.powsybl.iidm.network.TopologyKind;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.util.List;
Expand All @@ -20,28 +19,15 @@
*/
@SuperBuilder
@Getter
@Setter
public class TopologyInfos {
@JsonInclude(JsonInclude.Include.NON_NULL)
private TopologyKind topologyKind;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer busbarCount;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer sectionCount;
private BusBarSectionsInfos busBarSectionsInfos;

@JsonInclude(JsonInclude.Include.NON_NULL)
private List<SwitchKind> switchKinds;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean isSymmetrical;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean isBusbarSectionPositionExtensionFound;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Map<String, List<String>> busBarSectionsInfos;
private Map<String, List<FeederBayInfos>> feederBaysInfos;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Map<String, List<FeederBayInfos>> feederBaysInfos;
private List<SwitchInfos> switchesInfos;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,40 @@
package org.gridsuite.network.map.dto.definition.voltagelevel;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.powsybl.iidm.network.SwitchKind;
import com.powsybl.iidm.network.TopologyKind;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.gridsuite.network.map.dto.ElementInfosWithProperties;
import org.gridsuite.network.map.dto.definition.extension.IdentifiableShortCircuitInfos;

import java.util.List;
import java.util.Optional;

/**
* @author Slimane Amar <slimane.amar at rte-france.com>
*/
@SuperBuilder
@Getter
@Setter
public class VoltageLevelFormInfos extends ElementInfosWithProperties {

@JsonInclude(JsonInclude.Include.NON_NULL)
private TopologyKind topologyKind;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer busbarCount;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer sectionCount;

@JsonInclude(JsonInclude.Include.NON_NULL)
private List<SwitchKind> switchKinds;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean isSymmetrical;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String substationId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
*/
package org.gridsuite.network.map.dto.mapper;

import com.powsybl.iidm.network.Identifiable;
import com.powsybl.iidm.network.Substation;
import com.powsybl.iidm.network.VoltageLevel;
import com.powsybl.iidm.network.*;
import com.powsybl.iidm.network.extensions.BusbarSectionPosition;
import org.gridsuite.network.map.dto.ElementInfos;
import org.gridsuite.network.map.dto.InfoTypeParameters;
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelFormInfos;
Expand All @@ -17,6 +16,11 @@
import org.gridsuite.network.map.dto.utils.ElementUtils;
import org.gridsuite.network.map.dto.utils.ExtensionUtils;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import static com.powsybl.iidm.network.TopologyKind.NODE_BREAKER;
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

/**
Expand All @@ -38,7 +42,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete

static VoltageLevelFormInfos toFormInfos(Identifiable<?> identifiable) {
VoltageLevel voltageLevel = (VoltageLevel) identifiable;
return VoltageLevelFormInfos.builder()
VoltageLevelFormInfos voltageLevelFormInfos = VoltageLevelFormInfos.builder()
.name(voltageLevel.getOptionalName().orElse(null))
.id(voltageLevel.getId())
.topologyKind(voltageLevel.getTopologyKind())
Expand All @@ -49,6 +53,14 @@ static VoltageLevelFormInfos toFormInfos(Identifiable<?> identifiable) {
.properties(getProperties(voltageLevel))
.identifiableShortCircuit(ExtensionUtils.toIdentifiableShortCircuit(voltageLevel))
.build();
if (voltageLevel.getTopologyKind().equals(TopologyKind.NODE_BREAKER)) {
VoltageLevelFormInfos busBarSectionsInfos = getVoltageLevelBusBarSectionsInfos(voltageLevel);
voltageLevelFormInfos.setBusbarCount(busBarSectionsInfos.getBusbarCount());
voltageLevelFormInfos.setSectionCount(busBarSectionsInfos.getSectionCount());
voltageLevelFormInfos.setSwitchKinds(busBarSectionsInfos.getSwitchKinds());
voltageLevelFormInfos.setIsSymmetrical(busBarSectionsInfos.getIsSymmetrical());
}
return voltageLevelFormInfos;
}

static VoltageLevelMapInfos toMapInfos(Identifiable<?> identifiable) {
Expand Down Expand Up @@ -78,4 +90,47 @@ static VoltageLevelTabInfos toTabInfos(Identifiable<?> identifiable) {

return builder.build();
}

public static VoltageLevelFormInfos getVoltageLevelBusBarSectionsInfos(VoltageLevel voltageLevel) {
Map<Integer, Integer> nbSectionsPerBusbar = new HashMap<>();
int maxBusbarIndex = 1;
int maxSectionIndex = 1;
for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) {
var extension = bbs.getExtension(BusbarSectionPosition.class);
if (extension == null) {
return VoltageLevelFormInfos.builder()
.busbarCount(1)
.sectionCount(1)
.topologyKind(NODE_BREAKER)
.switchKinds(Collections.emptyList())
.isSymmetrical(false)
.build();
}
int busbarIndex = extension.getBusbarIndex();
int sectionIndex = extension.getSectionIndex();
maxBusbarIndex = Math.max(maxBusbarIndex, busbarIndex);
maxSectionIndex = Math.max(maxSectionIndex, sectionIndex);
nbSectionsPerBusbar.merge(busbarIndex, 1, Integer::sum);
}

boolean isSymmetrical = maxBusbarIndex == 1 ||
nbSectionsPerBusbar.values().stream().distinct().count() == 1
&& nbSectionsPerBusbar.values().stream().findFirst().orElse(0).equals(maxSectionIndex);

if (isSymmetrical) {
return VoltageLevelFormInfos.builder()
.busbarCount(maxBusbarIndex)
.sectionCount(maxSectionIndex)
.switchKinds(Collections.nCopies(maxSectionIndex - 1, SwitchKind.DISCONNECTOR))
.isSymmetrical(true)
.build();
}
return VoltageLevelFormInfos.builder()
.busbarCount(1)
.sectionCount(1)
.topologyKind(NODE_BREAKER)
.switchKinds(Collections.emptyList())
.isSymmetrical(false)
.build();
}
}
Loading