Skip to content

Commit

Permalink
Add configuration similar to the one in AbstractMainConnectedComponen…
Browse files Browse the repository at this point in the history
…tWithSwitchTest, with buses in bus breaker view between retained switches and with no equipments.

Signed-off-by: Franck LECUYER <[email protected]>
  • Loading branch information
FranckLecuyer committed Oct 3, 2024
1 parent 2130e8f commit 0d58627
Showing 1 changed file with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
Expand All @@ -27,13 +28,14 @@
public class VoltageLevelSetVTest {
@Test
public void testWithMultipleBusInBusBreakerAndBusView() {
Network network = Network.create("test_mcc", "test");

VoltageLevelImpl vl1 = createNodeBreaker(network);
VoltageLevelImpl vl2 = createBusBreaker(network);

testSetVMultipleBusAcrossViews(vl1, NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS, NBVL_BUSVIEWBUS_TO_BUSBREAKERVIEWBUS);
testSetVMultipleBusAcrossViews(vl2, BBVL_CONFIGUREDBUS_TO_BUSVIEWBUS, BBVL_BUSVIEWBUS_TO_CONFIGUREDBUS);
testSetVMultipleBusAcrossViews(() -> {
Network network = Network.create("test_mcc", "test");
return createNodeBreaker(network);
}, NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS, NBVL_BUSVIEWBUS_TO_BUSBREAKERVIEWBUS);
testSetVMultipleBusAcrossViews(() -> {
Network network = Network.create("test_mcc", "test");
return createBusBreaker(network);
}, BBVL_CONFIGUREDBUS_TO_BUSVIEWBUS, BBVL_BUSVIEWBUS_TO_CONFIGUREDBUS);
}

private static final Map<String, String> NBVL_BUSBREAKERVIEWBUS_TO_BUSVIEWBUS = new TreeMap<>(Map.of(
Expand Down Expand Up @@ -260,22 +262,17 @@ private static VoltageLevelImpl createBusBreaker(Network network) {
return (VoltageLevelImpl) vl2;
}

private void testSetVMultipleBusAcrossViews(VoltageLevelImpl vl, Map<String, String> busBreakerViewBusToBusViewBus, Map<String, List<String>> busViewBusToBusBreakerViewBus) {
private void testSetVMultipleBusAcrossViews(Supplier<VoltageLevel> supplier, Map<String, String> busBreakerViewBusToBusViewBus, Map<String, List<String>> busViewBusToBusBreakerViewBus) {

VoltageLevel vl = supplier.get();
for (Map.Entry<String, String > entry : busBreakerViewBusToBusViewBus.entrySet()) {
String busbreakerviewbusid = entry.getKey();
String busviewbusid = entry.getValue();


// should we replace with new network for each test ??
vl.invalidateCalculatedBuses(); // but this keeps previous v values
// TODO this forces a computation of all busviews
// need to test when views are not initialized
for (Bus bbvb : vl.getBusBreakerView().getBuses()) {
System.out.println("Bus dans bus breaker view : " + bbvb.getId());
bbvb.setV(Double.NaN);
}
for (Bus bvb : vl.getBusView().getBuses()) {
System.out.println("Bus dans bus view : " + bvb.getId());
bvb.setV(Double.NaN);
}

Expand All @@ -298,14 +295,11 @@ private void testSetVMultipleBusAcrossViews(VoltageLevelImpl vl, Map<String, Str
}
}

vl = supplier.get();
for (Map.Entry<String, List<String> > entry : busViewBusToBusBreakerViewBus.entrySet()) {
String busviewbusid = entry.getKey();
List<String> busbreakerviewbusids = entry.getValue();

// should we replace with new network for each test ??
vl.invalidateCalculatedBuses(); // but this keeps previous v values
// TODO this forces a computation of all busviews
// need to test when views are not initialized
for (Bus bbvb : vl.getBusBreakerView().getBuses()) {
bbvb.setV(Double.NaN);
}
Expand Down

0 comments on commit 0d58627

Please sign in to comment.