-
Notifications
You must be signed in to change notification settings - Fork 0
get all voltage level connections #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 20 commits
98d2a6e
397e97c
884a664
732185b
46700f8
6b9b5a4
6d0e15e
01cbb74
80a13c0
7774634
0305db9
84cff31
a971d0c
1e5770b
f63c963
7e6fd6b
c966b59
c2a535e
12d9d9f
fed0ec8
34b31cc
5a615ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* 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.voltagelevel; | ||
|
||
import com.powsybl.iidm.network.ThreeSides; | ||
import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; | ||
|
||
/** | ||
* @author Etienne Lesot <etienne.lesot at rte-france.com> | ||
*/ | ||
public record FeederBayInfos(String busbarSectionId, ConnectablePositionInfos connectablePositionInfos, ThreeSides connectionSide) { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
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.FeederBayInfos; | ||
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; | ||
|
@@ -106,14 +107,52 @@ static VoltageLevelFormInfos toFormInfos(Identifiable<?> identifiable) { | |
builder.isRetrievedBusbarSections(vlTopologyInfos.isRetrievedBusbarSections()); | ||
builder.isBusbarSectionPositionFound(vlTopologyInfos.isBusbarSectionPositionFound()); | ||
builder.busBarSectionInfos(vlTopologyInfos.getBusBarSectionInfosGrouped()); | ||
builder.feederBaysInfos(getFeederBaysInfos(voltageLevel)); | ||
} | ||
|
||
builder.identifiableShortCircuit(ExtensionUtils.toIdentifiableShortCircuit(voltageLevel)); | ||
|
||
return builder.build(); | ||
} | ||
|
||
static VoltageLevelMapInfos toMapInfos(Identifiable<?> identifiable) { | ||
private static Map<String, List<FeederBayInfos>> getFeederBaysInfos(VoltageLevel voltageLevel) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something like this to be more succinct ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
Map<String, List<FeederBayInfos>> connections = new HashMap<>(); | ||
voltageLevel.getConnectableStream() | ||
.filter(connectable -> !(connectable instanceof BusbarSection)) | ||
.forEach(connectable -> { | ||
switch (connectable) { | ||
case Injection<?> injection -> connections.put(injection.getId(), List.of(new FeederBayInfos(getBusOrBusbarSection(injection.getTerminal()), | ||
toMapConnectablePosition(injection, 0), null))); | ||
case Branch<?> branch -> { | ||
List<FeederBayInfos> branchConnections = new ArrayList<>(); | ||
if (branch.getTerminal1().getVoltageLevel().getId().equals(voltageLevel.getId())) { | ||
branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal1()), toMapConnectablePosition(branch, 1), ThreeSides.ONE)); | ||
} | ||
if (branch.getTerminal2().getVoltageLevel().getId().equals(voltageLevel.getId())) { | ||
branchConnections.add(new FeederBayInfos(getBusOrBusbarSection(branch.getTerminal2()), toMapConnectablePosition(branch, 2), ThreeSides.TWO)); | ||
} | ||
connections.put(branch.getId(), branchConnections); | ||
} | ||
case ThreeWindingsTransformer threeWindingsTransformer -> { | ||
List<FeederBayInfos> threeWTConnections = new ArrayList<>(); | ||
if (threeWindingsTransformer.getLeg1().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { | ||
threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg1().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 1), ThreeSides.ONE)); | ||
} | ||
if (threeWindingsTransformer.getLeg2().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { | ||
threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg2().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 2), ThreeSides.TWO)); | ||
} | ||
if (threeWindingsTransformer.getLeg3().getTerminal().getVoltageLevel().getId().equals(voltageLevel.getId())) { | ||
threeWTConnections.add(new FeederBayInfos(getBusOrBusbarSection(threeWindingsTransformer.getLeg3().getTerminal()), toMapConnectablePosition(threeWindingsTransformer, 3), ThreeSides.THREE)); | ||
} | ||
connections.put(threeWindingsTransformer.getId(), threeWTConnections); | ||
} | ||
default -> throw new IllegalArgumentException("connectable type: " + connectable.getClass() + " not supported"); | ||
} | ||
}); | ||
return connections; | ||
} | ||
|
||
protected static VoltageLevelMapInfos toMapInfos(Identifiable<?> identifiable) { | ||
VoltageLevel voltageLevel = (VoltageLevel) identifiable; | ||
return VoltageLevelMapInfos.builder() | ||
.id(voltageLevel.getId()) | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,12 +7,14 @@ | |||||
package org.gridsuite.network.map.dto.utils; | ||||||
|
||||||
import com.powsybl.iidm.network.*; | ||||||
import com.powsybl.iidm.network.extensions.ConnectablePosition; | ||||||
import com.powsybl.math.graph.TraversalType; | ||||||
import lombok.NonNull; | ||||||
import org.gridsuite.network.map.dto.common.ReactiveCapabilityCurveMapData; | ||||||
import org.gridsuite.network.map.dto.common.TapChangerData; | ||||||
import org.gridsuite.network.map.dto.common.TapChangerStepData; | ||||||
import org.gridsuite.network.map.dto.definition.extension.BusbarSectionFinderTraverser; | ||||||
import org.springframework.lang.NonNull; | ||||||
import org.gridsuite.network.map.dto.definition.extension.ConnectablePositionInfos; | ||||||
|
||||||
import java.util.Collection; | ||||||
import java.util.List; | ||||||
|
@@ -39,6 +41,39 @@ public static void setIfNotNan(@NonNull final DoubleConsumer setter, final doubl | |||||
} | ||||||
} | ||||||
|
||||||
private static ConnectablePosition.Feeder getFeederInfos(Identifiable<?> identifiable, int index) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code should use ThreeSides
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the index we can handle injections and branches, but the ThreeSides type cannot manage that |
||||||
var connectablePosition = identifiable.getExtension(ConnectablePosition.class); | ||||||
if (connectablePosition == null) { | ||||||
return null; | ||||||
} | ||||||
|
||||||
switch (index) { | ||||||
case 0: | ||||||
return connectablePosition.getFeeder(); | ||||||
case 1: | ||||||
return connectablePosition.getFeeder1(); | ||||||
case 2: | ||||||
return connectablePosition.getFeeder2(); | ||||||
default: | ||||||
throw new IllegalArgumentException("Invalid feeder index: " + index); | ||||||
} | ||||||
} | ||||||
|
||||||
public static ConnectablePositionInfos toMapConnectablePosition(Identifiable<?> identifiable, int index) { | ||||||
|
public static ConnectablePositionInfos toMapConnectablePosition(Identifiable<?> identifiable, int index) { | |
public static ConnectablePositionInfos getConnectablePosition(Identifiable<?> identifiable, ThreeSides side) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the renaming, but not with changing int index to ThreeSides side, because we need to specify the index to retrieve the feeder
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static ConnectablePositionInfos convertFeederToConnectablePositionInfos(ConnectablePosition.Feeder feeder) { | |
public static ConnectablePositionInfos buildConnectablePositionInfos(ConnectablePosition.Feeder feeder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move those changes in another PR. So the review can be done with #288. And the changes in the tests will be reviewed with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move those changes in another PR. So the review can be done with #288. And the changes in the tests will be reviewed with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done