@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); }
@Override public Bus getMergedBus(String busBarId) { NodeTerminal nt = (NodeTerminal) nodeBreakerView.getBusbarSection(busBarId).getTerminal(); int node = nt.getNode(); return variants.get().calculatedBusTopology.getBus(node); } };
traversedTerminals.add(terminal); int node = terminal.getNode(); List<TerminalExt> nextTerminals = new ArrayList<>();
@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; }
@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); }