@Test public void removeIsolatedSwitches() throws Exception { Network network = NetworkTest1Factory.create(); VoltageLevel vl = network.getVoltageLevel("voltageLevel1"); VoltageLevel.NodeBreakerView topo = vl.getNodeBreakerView(); assertNotNull(vl); assertNotNull(topo.getSwitch("load1Disconnector1")); assertNotNull(topo.getSwitch("load1Breaker1")); assertEquals(5, topo.getSwitchCount()); vl.getConnectable("load1", Load.class).remove(); assertNull(vl.getConnectable("load1", Load.class)); topo.removeSwitch("load1Breaker1"); assertNull(topo.getSwitch("load1Breaker1")); NodeBreakerTopology.removeIsolatedSwitches(topo); assertNull(topo.getSwitch("load1Disconnector1")); assertNull(topo.getSwitch("load1Breaker1")); assertEquals(3, topo.getSwitchCount()); }
public static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo) { Objects.requireNonNull(topo, "Node breaker topology view is null."); int[] nodes = topo.getNodes(); final TIntSet encountered = new TIntHashSet(); final Set<Switch> encounteredSwitches = new HashSet<>(); for (int n : nodes) { if (encountered.contains(n) || topo.getTerminal(n) == null) { continue; } encountered.add(n); topo.traverse(n, (n1, sw, n2) -> { encountered.add(n2); encounteredSwitches.add(sw); return topo.getTerminal(n2) == null; }); } List<Switch> toRemove = topo.getSwitchStream().filter(sw -> !encounteredSwitches.contains(sw)).collect(Collectors.toList()); for (Switch sw : toRemove) { topo.removeSwitch(sw.getId()); } }
NodeBreakerTopology { public static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo) { Objects.requireNonNull(topo, "Node breaker topology view is null."); int[] nodes = topo.getNodes(); final TIntSet encountered = new TIntHashSet(); final Set<Switch> encounteredSwitches = new HashSet<>(); for (int n : nodes) { if (encountered.contains(n) || topo.getTerminal(n) == null) { continue; } encountered.add(n); topo.traverse(n, (n1, sw, n2) -> { encountered.add(n2); encounteredSwitches.add(sw); return topo.getTerminal(n2) == null; }); } List<Switch> toRemove = topo.getSwitchStream().filter(sw -> !encounteredSwitches.contains(sw)).collect(Collectors.toList()); for (Switch sw : toRemove) { topo.removeSwitch(sw.getId()); } } }
NodeBreakerTopology { public static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo) { Objects.requireNonNull(topo, "Node breaker topology view is null."); int[] nodes = topo.getNodes(); final TIntSet encountered = new TIntHashSet(); final Set<Switch> encounteredSwitches = new HashSet<>(); for (int n : nodes) { if (encountered.contains(n) || topo.getTerminal(n) == null) { continue; } encountered.add(n); topo.traverse(n, (n1, sw, n2) -> { encountered.add(n2); encounteredSwitches.add(sw); return topo.getTerminal(n2) == null; }); } List<Switch> toRemove = topo.getSwitchStream().filter(sw -> !encounteredSwitches.contains(sw)).collect(Collectors.toList()); for (Switch sw : toRemove) { topo.removeSwitch(sw.getId()); } } private  NodeBreakerTopology(); }
NodeBreakerTopology { public static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo) { Objects.requireNonNull(topo, "Node breaker topology view is null."); int[] nodes = topo.getNodes(); final TIntSet encountered = new TIntHashSet(); final Set<Switch> encounteredSwitches = new HashSet<>(); for (int n : nodes) { if (encountered.contains(n) || topo.getTerminal(n) == null) { continue; } encountered.add(n); topo.traverse(n, (n1, sw, n2) -> { encountered.add(n2); encounteredSwitches.add(sw); return topo.getTerminal(n2) == null; }); } List<Switch> toRemove = topo.getSwitchStream().filter(sw -> !encounteredSwitches.contains(sw)).collect(Collectors.toList()); for (Switch sw : toRemove) { topo.removeSwitch(sw.getId()); } } private  NodeBreakerTopology(); static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo); static int newStandardConnection(BusbarSection bb); }
NodeBreakerTopology { public static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo) { Objects.requireNonNull(topo, "Node breaker topology view is null."); int[] nodes = topo.getNodes(); final TIntSet encountered = new TIntHashSet(); final Set<Switch> encounteredSwitches = new HashSet<>(); for (int n : nodes) { if (encountered.contains(n) || topo.getTerminal(n) == null) { continue; } encountered.add(n); topo.traverse(n, (n1, sw, n2) -> { encountered.add(n2); encounteredSwitches.add(sw); return topo.getTerminal(n2) == null; }); } List<Switch> toRemove = topo.getSwitchStream().filter(sw -> !encounteredSwitches.contains(sw)).collect(Collectors.toList()); for (Switch sw : toRemove) { topo.removeSwitch(sw.getId()); } } private  NodeBreakerTopology(); static void removeIsolatedSwitches(VoltageLevel.NodeBreakerView topo); static int newStandardConnection(BusbarSection bb);  }