private void checkTerminal(TerminalExt terminal) { if (!(terminal instanceof NodeTerminal)) { throw new ValidationException(terminal.getConnectable(), "voltage level " + NodeBreakerVoltageLevel.this.id + " has a node/breaker topology" + ", a node connection should be specified instead of a bus connection"); } }
@Override public void printTopology(PrintStream out, ShortIdDictionary dict) { out.println("-------------------------------------------------------------"); out.println("Topology of " + BusBreakerVoltageLevel.this.id); Function<ConfiguredBus, String> vertexToString = bus -> { StringBuilder builder = new StringBuilder(); builder.append(bus.getId()) .append(" ["); for (Iterator<TerminalExt> it = bus.getConnectedTerminals().iterator(); it.hasNext(); ) { TerminalExt terminal = it.next(); builder.append(dict != null ? dict.getShortId(terminal.getConnectable().getId()) : terminal.getConnectable().getId()); if (it.hasNext()) { builder.append(", "); } } builder.append("]"); return builder.toString(); }; Function<SwitchImpl, String> edgeToString = aSwitch -> { StringBuilder builder = new StringBuilder(); builder.append("id=").append(aSwitch.getId()) .append(" status=").append(aSwitch.isOpen() ? "open" : "closed"); return builder.toString(); }; graph.print(out, vertexToString, edgeToString); }
private void checkTerminal(TerminalExt terminal) { if (!(terminal instanceof BusTerminal)) { throw new ValidationException(terminal.getConnectable(), "voltage level " + BusBreakerVoltageLevel.this.id + " has a bus/breaker topology" + ", a bus connection should be specified instead of a node connection"); } // check connectable buses exist String connectableBusId = ((BusTerminal) terminal).getConnectableBusId(); if (connectableBusId != null) { getBus(connectableBusId, true); } }
protected boolean isBusValid(Set<ConfiguredBus> busSet) { int feederCount = 0; int branchCount = 0; for (TerminalExt terminal : FluentIterable.from(busSet).transformAndConcat(ConfiguredBus::getConnectedTerminals)) { AbstractConnectable connectable = terminal.getConnectable(); switch (connectable.getType()) { case LINE: case TWO_WINDINGS_TRANSFORMER: case THREE_WINDINGS_TRANSFORMER: case HVDC_CONVERTER_STATION: branchCount++; feederCount++; break; case DANGLING_LINE: case LOAD: case GENERATOR: case SHUNT_COMPENSATOR: case STATIC_VAR_COMPENSATOR: feederCount++; break; case BUSBAR_SECTION: // must not happend in a bus/breaker topology default: throw new AssertionError(); } } return Networks.isBusValid(branchCount); }
.append(" [label=\"").append(label).append("\"]\n"); for (TerminalExt terminal : bus.getTerminals()) { AbstractConnectable connectable = terminal.getConnectable(); label = connectable.getType().toString() + "\\n" + connectable.getId(); writer.append(" ").append(connectable.getId()) AbstractConnectable connectable = terminal.getConnectable(); writer.append(" ").append(bus.getId()) .append(" -- ").append(connectable.getId())
AbstractConnectable connectable = terminal.getConnectable(); switch (connectable.getType()) { case BUSBAR_SECTION:
AbstractConnectable connectable = terminal.getConnectable(); switch (connectable.getType()) { case BUSBAR_SECTION:
private void exportBuses(Graph g, Multimap<String, Integer> busToNodes, Map<Integer, Node> intToNode) { String[] colors = Colors.generateColorScale(busToNodes.asMap().keySet().size()); int i = 0; for (String key : busToNodes.asMap().keySet()) { Graph newBus = new Graph().id("\"" + key + "\""); newBus.attr(LABEL_ATTRIBUTE, key); for (int nodeInt : busToNodes.get(key)) { Node node = intToNode.get(nodeInt); TerminalExt terminal = graph.getVertexObject(nodeInt); if (terminal != null) { AbstractConnectable connectable = terminal.getConnectable(); String label = nodeInt + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); node.attr(LABEL_ATTRIBUTE, label); } node.attr("style", "filled").attr("color", colors[i]); newBus.node(node); } g.subGraph(newBus); i++; } }
TerminalExt terminal = graph.getVertexObject(node); if (terminal != null) { AbstractConnectable connectable = terminal.getConnectable(); switch (connectable.getType()) { case LINE:
protected static void addNextTerminals(TerminalExt otherTerminal, List<TerminalExt> nextTerminals) { Objects.requireNonNull(otherTerminal); Objects.requireNonNull(nextTerminals); Connectable otherConnectable = otherTerminal.getConnectable(); if (otherConnectable instanceof Branch) { Branch branch = (Branch) otherConnectable; if (branch.getTerminal1() == otherTerminal) { nextTerminals.add((TerminalExt) branch.getTerminal2()); } else if (branch.getTerminal2() == otherTerminal) { nextTerminals.add((TerminalExt) branch.getTerminal1()); } else { throw new AssertionError(); } } else if (otherConnectable instanceof ThreeWindingsTransformer) { ThreeWindingsTransformer ttc = (ThreeWindingsTransformer) otherConnectable; if (ttc.getLeg1().getTerminal() == otherTerminal) { nextTerminals.add((TerminalExt) ttc.getLeg2().getTerminal()); nextTerminals.add((TerminalExt) ttc.getLeg3().getTerminal()); } else if (ttc.getLeg2().getTerminal() == otherTerminal) { nextTerminals.add((TerminalExt) ttc.getLeg1().getTerminal()); nextTerminals.add((TerminalExt) ttc.getLeg3().getTerminal()); } else if (ttc.getLeg3().getTerminal() == otherTerminal) { nextTerminals.add((TerminalExt) ttc.getLeg1().getTerminal()); nextTerminals.add((TerminalExt) ttc.getLeg2().getTerminal()); } else { throw new AssertionError(); } } }
public void exportTopology(OutputStream os) { Graph g = new Graph().id("\"" + NodeBreakerVoltageLevel.this.id + "\""); Map<Integer, Node> intToNode = new HashMap<>(); Multimap<String, Integer> busToNodes = ArrayListMultimap.create(); for (int n = 0; n < graph.getVertexCount(); n++) { Node node = new Node().id(Integer.toString(n)); intToNode.put(n, node); Bus bus = getCalculatedBusBreakerTopology().getBus(n); if (bus != null) { busToNodes.put(bus.getId(), n); } else { TerminalExt terminal = graph.getVertexObject(n); if (terminal != null) { AbstractConnectable connectable = terminal.getConnectable(); String label = n + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); node.attr(LABEL_ATTRIBUTE, label); g.node(node); } } } exportBuses(g, busToNodes, intToNode); exportEdges(g, intToNode); g.writeTo(os); }
@Override public void attach(TerminalExt terminal, boolean test) { checkTerminal(terminal); if (test) { return; } int node = ((NodeTerminal) terminal).getNode(); if (graph.getVertexObject(node) != null) { throw new ValidationException(terminal.getConnectable(), "an equipment (" + graph.getVertexObject(node).getConnectable().getId() + ") is already connected to node " + node + " of voltage level " + NodeBreakerVoltageLevel.this.id); } // create the link terminal <-> voltage level terminal.setVoltageLevel(NodeBreakerVoltageLevel.this); // create the link terminal <-> graph vertex graph.setVertexObject(node, (NodeTerminal) terminal); }
AbstractConnectable connectable = ((TerminalExt) terminal).getConnectable(); switch (connectable.getType()) { case BUSBAR_SECTION: