-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hugo KULESZA <hugo.kulesza@rte-france.com>
- Loading branch information
1 parent
6d78722
commit 7aecdea
Showing
12 changed files
with
196 additions
and
0 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
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
72 changes: 72 additions & 0 deletions
72
java/src/main/java/com/powsybl/dataframe/network/adders/GroundDataframeAdder.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,72 @@ | ||
/** | ||
* Copyright (c) 2024, 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/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.dataframe.network.adders; | ||
|
||
import com.powsybl.commons.report.ReportNode; | ||
import com.powsybl.dataframe.SeriesMetadata; | ||
import com.powsybl.dataframe.update.StringSeries; | ||
import com.powsybl.dataframe.update.UpdatingDataframe; | ||
import com.powsybl.iidm.network.*; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static com.powsybl.dataframe.network.adders.NetworkUtils.getVoltageLevelOrThrowWithBusOrBusbarSectionId; | ||
|
||
/** | ||
* @author Hugo Kulesza {@literal <hugo.kulesza@rte-france.com>} | ||
*/ | ||
public class GroundDataframeAdder extends AbstractSimpleAdder { | ||
|
||
private static final List<SeriesMetadata> METADATA = List.of( | ||
SeriesMetadata.stringIndex("id"), | ||
SeriesMetadata.strings("voltage_level_id"), | ||
SeriesMetadata.strings("bus_id"), | ||
SeriesMetadata.strings("connectable_bus_id"), | ||
SeriesMetadata.ints("node"), | ||
SeriesMetadata.strings("name") | ||
); | ||
|
||
@Override | ||
public List<List<SeriesMetadata>> getMetadata() { | ||
return List.of(METADATA); | ||
} | ||
|
||
private static class GroundSeries extends InjectionSeries { | ||
|
||
private final StringSeries voltageLevels; | ||
private final StringSeries busOrBusbarSections; | ||
|
||
GroundSeries(UpdatingDataframe dataframe) { | ||
super(dataframe); | ||
this.voltageLevels = dataframe.getStrings("voltage_level_id"); | ||
this.busOrBusbarSections = dataframe.getStrings("bus_id"); | ||
} | ||
|
||
Optional<GroundAdder> createAdder(Network network, int row, boolean throwException) { | ||
Optional<VoltageLevel> vl = getVoltageLevelOrThrowWithBusOrBusbarSectionId(network, row, voltageLevels, busOrBusbarSections, throwException); | ||
if (vl.isPresent()) { | ||
GroundAdder adder = vl.get().newGround(); | ||
setInjectionAttributes(adder, row); | ||
return Optional.of(adder); | ||
} | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public void addElements(Network network, UpdatingDataframe dataframe, AdditionStrategy addition, boolean throwException, ReportNode reportNode) { | ||
GroundSeries series = new GroundSeries(dataframe); | ||
for (int row = 0; row < dataframe.getRowCount(); row++) { | ||
Optional<GroundAdder> adder = series.createAdder(network, row, throwException); | ||
if (adder.isPresent()) { | ||
addition.add(network, dataframe, adder.get(), row, throwException, reportNode); | ||
} | ||
} | ||
} | ||
} |
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
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