com.powsybl.dataframe.network.adders.BusDataframeAdder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pypowsybl Show documentation
Show all versions of pypowsybl Show documentation
A C interface to powsybl, for pypowsybl implementation
The newest version!
/**
* Copyright (c) 2022, 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.PowsyblException;
import com.powsybl.dataframe.SeriesMetadata;
import com.powsybl.dataframe.update.StringSeries;
import com.powsybl.dataframe.update.UpdatingDataframe;
import com.powsybl.iidm.network.BusAdder;
import com.powsybl.iidm.network.Network;
import java.util.Collections;
import java.util.List;
import static com.powsybl.dataframe.network.adders.NetworkUtils.getVoltageLevelOrThrow;
/**
* @author Yichen TANG {@literal }
* @author Etienne Lesot {@literal }
* @author Sylvain Leclerc {@literal }
*/
public class BusDataframeAdder extends AbstractSimpleAdder {
private static final List METADATA = List.of(
SeriesMetadata.stringIndex("id"),
SeriesMetadata.strings("voltage_level_id"),
SeriesMetadata.strings("name")
);
@Override
public List> getMetadata() {
return Collections.singletonList(METADATA);
}
private static class BusSeries extends IdentifiableSeries {
private final StringSeries voltageLevels;
BusSeries(UpdatingDataframe dataframe) {
super(dataframe);
this.voltageLevels = dataframe.getStrings("voltage_level_id");
if (voltageLevels == null) {
throw new PowsyblException("voltage_level_id is missing");
}
}
void createBus(Network network, int row) {
BusAdder adder = getVoltageLevelOrThrow(network, voltageLevels.get(row))
.getBusBreakerView()
.newBus();
setIdentifiableAttributes(adder, row);
adder.add();
}
}
@Override
public void addElements(Network network, UpdatingDataframe dataframe) {
BusSeries series = new BusSeries(dataframe);
for (int row = 0; row < dataframe.getRowCount(); row++) {
series.createBus(network, row);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy