Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jonenst committed Dec 4, 2024
1 parent c0ec6d7 commit 6a5cec7
Showing 1 changed file with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,20 @@ private void getVAndAngleFromConfiguredBus(NetworkObjectIndex index,
ConnectedSetResult<T> connectedSet,
AtomicDouble v,
AtomicDouble angle) {
AtomicReference<ConfiguredBusImpl> foundConfiguredBus = new AtomicReference<>();
index.getConfiguredBuses(voltageLevelResource.getId()).forEach(bus -> {
if (foundConfiguredBus.get() == null) {
ConfiguredBusImpl configuredBus = (ConfiguredBusImpl) bus;
configuredBus.getAllTerminals().stream()
.filter(Terminal::isConnected)
.forEach(t -> {
if (foundConfiguredBus.get() == null) {
connectedSet.getConnectedVertices().stream().filter(vertex ->
vertex.getId().equals(t.getConnectable().getId())
).findFirst().ifPresent(vertex -> foundConfiguredBus.set(configuredBus));
// Search with early return for a first configured bus with a connected terminal matching a vertex in the connectedSet of this bus
for (Bus bus: index.getConfiguredBuses(voltageLevelResource.getId())) {
ConfiguredBusImpl configuredBus = (ConfiguredBusImpl) bus;
for (Terminal t: configuredBus.getAllTerminals()) {
if (t.isConnected()) {
for (Vertex vertex: connectedSet.getConnectedVertices()) {
if (vertex.getId().equals(t.getConnectable().getId())) {
v.set(configuredBus.getResource().getAttributes().getV());
angle.set(configuredBus.getResource().getAttributes().getAngle());
return;
}
});
}
}
}
});
if (foundConfiguredBus.get() != null) {
v.set(foundConfiguredBus.get().getResource().getAttributes().getV());
angle.set(foundConfiguredBus.get().getResource().getAttributes().getAngle());
}
}

Expand All @@ -394,11 +390,14 @@ private void getVAndAngleFromOtherView(NetworkObjectIndex index,
AtomicDouble v,
AtomicDouble angle,
boolean isBusView) {
// TODO Some day we may decide to start preserving values in nodebreaker topology after invalidating the views,
// so we could remove this check for isCalculatedBusesValid. Here it controls preserving
// the value accross the other view, we have it to be consistent with preserving values
// from the same view (currently not preserved)
if (voltageLevelResource.getAttributes().getTopologyKind() == TopologyKind.NODE_BREAKER && voltageLevelResource.getAttributes().isCalculatedBusesValid()) {
if (voltageLevelResource.getAttributes().getTopologyKind() == TopologyKind.NODE_BREAKER) {
if (!voltageLevelResource.getAttributes().isCalculatedBusesValid()) {
// TODO Some day we may decide to start preserving values in nodebreaker topology after invalidating the views,
// so we could remove this check for isCalculatedBusesValid. Here it controls preserving
// the value accross the other view, we have it to be consistent with preserving values
// from the same view (currently not preserved)
return;
}
List<CalculatedBusAttributes> calculatedBusAttributes = isBusView ? voltageLevelResource.getAttributes().getCalculatedBusesForBusBreakerView() : voltageLevelResource.getAttributes().getCalculatedBusesForBusView();
if (!CollectionUtils.isEmpty(calculatedBusAttributes)) {
Map<Integer, Integer> nodesToCalculatedBuses = isBusView ? voltageLevelResource.getAttributes().getNodeToCalculatedBusForBusBreakerView() : voltageLevelResource.getAttributes().getNodeToCalculatedBusForBusView();
Expand Down

0 comments on commit 6a5cec7

Please sign in to comment.