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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.gridsuite.network.map.dto.definition.extension.IdentifiableShortCircuitInfos;

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

/**
Expand Down Expand Up @@ -53,4 +54,7 @@ public class VoltageLevelFormInfos extends ElementInfosWithProperties {
@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean isRetrievedBusbarSections;

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
import lombok.Setter;
import org.gridsuite.network.map.dto.ElementInfos;
import org.gridsuite.network.map.dto.InfoTypeParameters;
import org.gridsuite.network.map.dto.definition.busbarsection.BusBarSectionFormInfos;
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelFormInfos;
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelMapInfos;
import org.gridsuite.network.map.dto.definition.voltagelevel.VoltageLevelTabInfos;
import org.gridsuite.network.map.dto.utils.ElementUtils;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

Expand Down Expand Up @@ -49,6 +48,7 @@ public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParamete
public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLevel) {
VoltageLevelTopologyInfos topologyInfos = new VoltageLevelTopologyInfos();
Map<Integer, Integer> nbSectionsPerBusbar = new HashMap<>();
List<BusBarSectionFormInfos> busbarSectionInfos = new ArrayList<>();
for (BusbarSection bbs : voltageLevel.getNodeBreakerView().getBusbarSections()) {
var extension = bbs.getExtension(BusbarSectionPosition.class);
if (extension != null) {
Expand All @@ -62,6 +62,12 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev
if (extension.getSectionIndex() > nbSectionsPerBusbar.get(extension.getBusbarIndex())) {
nbSectionsPerBusbar.put(extension.getBusbarIndex(), extension.getSectionIndex());
}
BusBarSectionFormInfos busbarSectionInfo = BusBarSectionFormInfos.builder()
.id(bbs.getId())
.vertPos(extension.getSectionIndex())
.horizPos(extension.getBusbarIndex())
.build();
busbarSectionInfos.add(busbarSectionInfo);
} else {
return new VoltageLevelTopologyInfos();
}
Expand All @@ -72,6 +78,7 @@ public static VoltageLevelTopologyInfos getTopologyInfos(VoltageLevel voltageLev

topologyInfos.setRetrievedBusbarSections(true);
topologyInfos.setSwitchKinds(Collections.nCopies(topologyInfos.getSectionCount() - 1, SwitchKind.DISCONNECTOR));
topologyInfos.setBusbarSections(busbarSectionInfos);

return topologyInfos;
}
Expand All @@ -94,6 +101,7 @@ protected static VoltageLevelFormInfos toFormInfos(Identifiable<?> identifiable)
builder.sectionCount(vlTopologyInfos.getSectionCount());
builder.switchKinds(vlTopologyInfos.getSwitchKinds());
builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections());
builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped());
}

builder.identifiableShortCircuit(toIdentifiableShortCircuit(voltageLevel));
Expand Down Expand Up @@ -132,9 +140,24 @@ protected static VoltageLevelTabInfos toTabInfos(Identifiable<?> identifiable) {
@Getter
@Setter
public static class VoltageLevelTopologyInfos {
List<BusBarSectionFormInfos> busbarSections = List.of();
boolean isRetrievedBusbarSections = false;
int busbarCount = 1;
int sectionCount = 1;
List<SwitchKind> switchKinds = List.of();

public Map<String, List<String>> getBusBarSectionInfosGrouped() {
return busbarSections.stream()
.collect(Collectors.groupingBy(
section -> String.valueOf(section.getHorizPos()),
Collectors.collectingAndThen(
Collectors.toList(),
list -> list.stream()
.sorted(Comparator.comparing(BusBarSectionFormInfos::getVertPos))
.map(BusBarSectionFormInfos::getId)
.toList()
)
));
}
}
}
8 changes: 6 additions & 2 deletions src/test/resources/substations-form-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@
"switchKinds": [
"DISCONNECTOR"
],
"isRetrievedBusbarSections": true
"isRetrievedBusbarSections": true,
"busBarSectionInfos" : {
"1" : ["NGEN4"]
}
}
]
},
Expand All @@ -125,7 +128,8 @@
"busbarCount": 1,
"sectionCount": 1,
"switchKinds": [],
"isRetrievedBusbarSections": false
"isRetrievedBusbarSections": false,
"busBarSectionInfos" : { }
}
]
}
Expand Down
5 changes: 4 additions & 1 deletion src/test/resources/voltage-level-form-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"busbarCount": 1,
"sectionCount": 2,
"switchKinds": ["DISCONNECTOR"],
"isRetrievedBusbarSections": true
"isRetrievedBusbarSections": true,
"busBarSectionInfos" : {
"1" : [ "NGEN4"]
}
}
8 changes: 6 additions & 2 deletions src/test/resources/voltage-levels-form-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
"busbarCount": 1,
"sectionCount": 2,
"switchKinds": ["DISCONNECTOR"],
"isRetrievedBusbarSections": true
"isRetrievedBusbarSections": true,
"busBarSectionInfos" : {
"1" : [ "NGEN4" ]
}
},
{
"id": "VLGEN5",
Expand All @@ -78,7 +81,8 @@
"busbarCount": 1,
"sectionCount": 1,
"switchKinds": [],
"isRetrievedBusbarSections": false
"isRetrievedBusbarSections": false,
"busBarSectionInfos" : { }
},
{
"id": "VLGEN6",
Expand Down