-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from com-pas/develop
Create a new release
- Loading branch information
Showing
15 changed files
with
544 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-FileCopyrightText: 2022 Alliander N.V. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
changelog: | ||
exclude: | ||
labels: | ||
- wontfix | ||
- duplicate | ||
- invalid | ||
categories: | ||
- title: New Features | ||
labels: | ||
- enhancement | ||
- title: Bugfixes | ||
labels: | ||
- bug | ||
- title: Tooling changes | ||
labels: | ||
- tooling | ||
- title: Dependency updates | ||
labels: | ||
- dependencies | ||
- title: Other Changes | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ce/src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/AbstractGraphBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.auto.alignment.builder; | ||
|
||
import com.powsybl.sld.model.BaseGraph; | ||
import com.powsybl.sld.model.Node; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class AbstractGraphBuilder<G extends BaseGraph> { | ||
private G graph; | ||
private final Map<String, Node> path2Node; | ||
|
||
protected AbstractGraphBuilder(Map<String, Node> path2Node) { | ||
this.path2Node = path2Node; | ||
} | ||
|
||
public G getGraph() { | ||
return graph; | ||
} | ||
|
||
protected void setGraph(G graph) { | ||
this.graph = graph; | ||
} | ||
|
||
protected void addNode(String path, Node node) { | ||
path2Node.put(path, node); | ||
} | ||
|
||
protected Node getNodeByPath(String path) { | ||
return path2Node.get(path); | ||
} | ||
|
||
protected Map<String, Node> getPath2Node() { | ||
return path2Node; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
.../src/main/java/org/lfenergy/compas/scl/auto/alignment/builder/SubstationGraphBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// SPDX-FileCopyrightText: 2021 Alliander N.V. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.lfenergy.compas.scl.auto.alignment.builder; | ||
|
||
import com.powsybl.sld.model.*; | ||
import org.lfenergy.compas.scl.auto.alignment.exception.SclAutoAlignmentException; | ||
import org.lfenergy.compas.scl.auto.alignment.model.*; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.lfenergy.compas.scl.auto.alignment.exception.SclAutoAlignmentErrorCode.VOLTAGELEVEL_NOT_FOUND_ERROR_CODE; | ||
|
||
public class SubstationGraphBuilder extends AbstractGraphBuilder<SubstationGraph> { | ||
private final GenericSubstation substation; | ||
|
||
private final Map<String, VoltageLevelGraphBuilder> voltageLevelGraphBuilderMap = new HashMap<>(); | ||
|
||
public SubstationGraphBuilder(GenericSubstation substation) { | ||
this(substation, new HashMap<>()); | ||
} | ||
|
||
public SubstationGraphBuilder(GenericSubstation substation, | ||
Map<String, Node> path2Node) { | ||
super(path2Node); | ||
this.substation = substation; | ||
|
||
setGraph(SubstationGraph.create(substation.getFullName())); | ||
|
||
createSubstation(); | ||
} | ||
|
||
private void createSubstation() { | ||
substation.getVoltageLevels().forEach(this::createVoltageLevelGraph); | ||
substation.getPowerTransformers().forEach(this::createPowerTransformer); | ||
} | ||
|
||
private void createVoltageLevelGraph(GenericVoltageLevel voltageLevel) { | ||
var voltageLevelBuilder = new VoltageLevelGraphBuilder(voltageLevel, substation, getPath2Node()); | ||
getGraph().addVoltageLevel(voltageLevelBuilder.getGraph()); | ||
voltageLevelGraphBuilderMap.put(voltageLevel.getFullName(), voltageLevelBuilder); | ||
} | ||
|
||
private VoltageLevelGraphBuilder getVoltageLevelBuilder(GenericTransformerWinding transformerWinding) { | ||
var connectivityNode = transformerWinding.getTerminals().get(0).getConnectivityNode(); | ||
return substation.getVoltageLevels().stream() | ||
.map(GenericVoltageLevel::getBays) | ||
.flatMap(List::stream) | ||
.map(GenericBay::getConductingEquipments) | ||
.flatMap(List::stream) | ||
.map(GenericConductingEquipment::getTerminals) | ||
.flatMap(List::stream) | ||
.filter(terminal -> connectivityNode.equals(terminal.getConnectivityNode())) | ||
.findFirst() | ||
.map(terminal -> ((GenericConductingEquipment) terminal.getParent()).getParent().getParent()) | ||
.map(genericVoltageLevel -> voltageLevelGraphBuilderMap.get(genericVoltageLevel.getFullName())) | ||
.orElseThrow(() -> new SclAutoAlignmentException(VOLTAGELEVEL_NOT_FOUND_ERROR_CODE, "No voltage level found.")); | ||
} | ||
|
||
private void createPowerTransformer(GenericPowerTransformer powerTransformer) { | ||
if (powerTransformer.isFeeder2WT()) { | ||
var tws = powerTransformer.getTransformerWindings(); | ||
getGraph().addMultiTermNode( | ||
Middle2WTNode.create(powerTransformer.getFullName(), | ||
powerTransformer.getFullName(), | ||
getGraph(), | ||
getFeeder2WTLegNode(tws.get(0)), | ||
getFeeder2WTLegNode(tws.get(1)), | ||
getVoltageLevelBuilder(tws.get(0)).getGraph().getVoltageLevelInfos(), | ||
getVoltageLevelBuilder(tws.get(1)).getGraph().getVoltageLevelInfos(), | ||
false)); | ||
} else if (powerTransformer.isFeeder3WT()) { | ||
var tws = powerTransformer.getTransformerWindings(); | ||
getGraph().addMultiTermNode( | ||
Middle3WTNode.create(powerTransformer.getFullName(), | ||
powerTransformer.getFullName(), | ||
getGraph(), | ||
getFeeder3WTLegNode(tws.get(0)), | ||
getFeeder3WTLegNode(tws.get(1)), | ||
getFeeder3WTLegNode(tws.get(2)), | ||
getVoltageLevelBuilder(tws.get(0)).getGraph().getVoltageLevelInfos(), | ||
getVoltageLevelBuilder(tws.get(1)).getGraph().getVoltageLevelInfos(), | ||
getVoltageLevelBuilder(tws.get(2)).getGraph().getVoltageLevelInfos())); | ||
} | ||
} | ||
|
||
private Feeder2WTLegNode getFeeder2WTLegNode(GenericTransformerWinding transformerWinding) { | ||
var connectivityNode = transformerWinding.getTerminals().get(0).getConnectivityNode(); | ||
return (Feeder2WTLegNode) getNodeByPath(connectivityNode); | ||
} | ||
|
||
private Feeder3WTLegNode getFeeder3WTLegNode(GenericTransformerWinding transformerWinding) { | ||
var connectivityNode = transformerWinding.getTerminals().get(0).getConnectivityNode(); | ||
return (Feeder3WTLegNode) getNodeByPath(connectivityNode); | ||
} | ||
} |
Oops, something went wrong.