@Override public double getAngle() { return ((NodeTerminal) getTerminal()).getAngle(); } }
@Override public void printTopology(PrintStream out, ShortIdDictionary dict) { out.println("-------------------------------------------------------------"); out.println("Topology of " + NodeBreakerVoltageLevel.this.id); graph.print(out, terminal -> terminal != null ? terminal.getConnectable().toString() : null, null); }
@Override public double getV() { checkValidity(); if (terminals.isEmpty()) { return Double.NaN; } return terminals.get(0).getV(); }
@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); }
@Override public void detach(TerminalExt terminal) { assert terminal instanceof NodeTerminal; int node = ((NodeTerminal) terminal).getNode(); assert node >= 0 && node < graph.getMaxVertex(); assert graph.getVertexObject(node) == terminal; graph.setVertexObject(node, null); // remove the link terminal -> voltage level terminal.setVoltageLevel(null); }
TerminalExt build() { String connectionBus = getConnectionBus(); if (node != null && connectionBus != null) { throw new ValidationException(validable, "connection node and connection bus are exclusives"); } if (node == null) { if (connectionBus == null) { throw new ValidationException(validable, "connectable bus is not set"); } return new BusTerminal(network, connectionBus, bus != null); } else { return new NodeTerminal(network, node); } }
@Override public void setConnectedComponentNumber(int connectedComponentNumber) { checkValidity(); for (NodeTerminal terminal : terminals) { terminal.setConnectedComponentNumber(connectedComponentNumber); } }
@Override public BusExt setAngle(double angle) { checkValidity(); for (NodeTerminal terminal : terminals) { terminal.setAngle(angle); } return this; }
@Override public void setSynchronousComponentNumber(int componentNumber) { checkValidity(); for (NodeTerminal terminal : terminals) { terminal.setSynchronousComponentNumber(componentNumber); } }
@Override public Component getSynchronousComponent() { checkValidity(); NetworkImpl.SynchronousComponentsManager scm = voltageLevel.getNetwork().getSynchronousComponentsManager(); scm.update(); return terminals.isEmpty() ? null : scm.getComponent(terminals.get(0).getSynchronousComponentNumber()); }
@Override public Component getConnectedComponent() { checkValidity(); NetworkImpl.ConnectedComponentsManager ccm = voltageLevel.getNetwork().getConnectedComponentsManager(); ccm.update(); return terminals.isEmpty() ? null : ccm.getComponent(terminals.get(0).getConnectedComponentNumber()); }
@Override public Bus getMergedBus(String busBarId) { NodeTerminal nt = (NodeTerminal) nodeBreakerView.getBusbarSection(busBarId).getTerminal(); int node = nt.getNode(); return variants.get().calculatedBusTopology.getBus(node); } };
@Override public BusbarSection add() { String id = checkAndGetUniqueId(); TerminalExt terminal = new NodeTerminal(getNetwork().getRef(), node); BusbarSectionImpl section = new BusbarSectionImpl(id, getName()); section.addTerminal(terminal); voltageLevel.attach(terminal, false); getNetwork().getObjectStore().checkAndAdd(section); getNetwork().getListeners().notifyCreation(section); return section; }
traversedTerminals.add(terminal); int node = terminal.getNode(); List<TerminalExt> nextTerminals = new ArrayList<>();
@Override public double getV() { return ((NodeTerminal) getTerminal()).getV(); }
@Override public double getAngle() { checkValidity(); if (terminals.isEmpty()) { return Double.NaN; } return terminals.get(0).getAngle(); }
@Override public boolean connect(TerminalExt terminal) { assert terminal instanceof NodeTerminal; int node = ((NodeTerminal) terminal).getNode(); // find all paths starting from the current terminal to a busbar section that does not contain an open disconnector // paths are already sorted List<TIntArrayList> paths = graph.findAllPaths(node, NodeBreakerVoltageLevel::isBusbarSection, NodeBreakerVoltageLevel::isOpenedDisconnector); boolean connected = false; if (!paths.isEmpty()) { // the shorted path is the best, close all opened breakers of the path TIntArrayList shortestPath = paths.get(0); for (int i = 0; i < shortestPath.size(); i++) { int e = shortestPath.get(i); SwitchImpl sw = graph.getEdgeObject(e); if (sw.getKind() == SwitchKind.BREAKER && sw.isOpen()) { sw.setOpen(false); connected = true; } } } return connected; }
@Override public boolean disconnect(TerminalExt terminal) { assert terminal instanceof NodeTerminal; int node = ((NodeTerminal) terminal).getNode(); // find all paths starting from the current terminal to a busbar section that does not contain an open disconnector // (because otherwise there is nothing we can do to connected the terminal using only breakers) List<TIntArrayList> paths = graph.findAllPaths(node, NodeBreakerVoltageLevel::isBusbarSection, NodeBreakerVoltageLevel::isOpenedDisconnector); if (paths.isEmpty()) { return false; } for (TIntArrayList path : paths) { boolean pathOpen = false; for (int i = 0; i < path.size(); i++) { int e = path.get(i); SwitchImpl sw = graph.getEdgeObject(e); if (sw.getKind() == SwitchKind.BREAKER) { if (!sw.isOpen()) { sw.setOpen(true); } // just one open breaker is enough to disconnect the terminal, so we can stop pathOpen = true; break; } } if (!pathOpen) { return false; } } return true; }