@Override public void traverse(int node, Traverser traverser) { throw createNotSupportedBusBreakerTopologyException(); } };
@Override public void exportTopology(String filename) throws IOException { try (OutputStream writer = new FileOutputStream(filename)) { exportTopology(writer); } }
@Override public ConfiguredBus getBus(String id) { return BusBreakerVoltageLevel.this.getBus(id, false); }
@Override public void attach(final TerminalExt terminal, boolean test) { checkTerminal(terminal); if (test) { return; } // create the link terminal -> voltage level terminal.setVoltageLevel(this); // create the link bus -> terminal String connectableBusId = ((BusTerminal) terminal).getConnectableBusId(); final ConfiguredBus connectableBus = getBus(connectableBusId, true); getNetwork().getVariantManager().forEachVariant(() -> { connectableBus.addTerminal((BusTerminal) terminal); // invalidate connected components invalidateCache(); }); }
@Override public void detach(final TerminalExt terminal) { assert terminal instanceof BusTerminal; // remove the link terminal -> voltage level terminal.setVoltageLevel(null); // remove the link bus -> terminal String connectableBusId = ((BusTerminal) terminal).getConnectableBusId(); final ConfiguredBus connectableBus = getBus(connectableBusId, true); getNetwork().getVariantManager().forEachVariant(() -> { connectableBus.removeTerminal((BusTerminal) terminal); ((BusTerminal) terminal).setConnectableBusId(null); invalidateCache(); }); }
@Override protected NetworkImpl getNetwork() { return voltageLevel.getNetwork(); }
private void addSwitch(SwitchImpl aSwitch, String busId1, String busId2) { int v1 = getVertex(busId1, true); int v2 = getVertex(busId2, true); getNetwork().getObjectStore().checkAndAdd(aSwitch); int e = graph.addEdge(v1, v2, aSwitch); switches.put(aSwitch.getId(), e); }
traversedTerminals.add(terminal); addNextTerminals(terminal, nextTerminals); int v = getVertex(terminal.getConnectableBusId(), true); ConfiguredBus bus = graph.getVertexObject(v); bus.getTerminals().stream() .filter(t -> t != terminal) .filter(t -> traverser.traverse(t, t.isConnected())) .forEach(t -> addNextTerminals(t, nextTerminals)); traversedTerminals.add(otherTerminal); addNextTerminals(otherTerminal, nextTerminals); return TraverseResult.CONTINUE;
private void removeBus(String busId) { ConfiguredBus bus = getBus(busId, true); if (bus.getTerminalCount() > 0) { throw new ValidationException(this, "Cannot remove bus " + bus.getId() + " because of connectable equipments"); } // TODO improve check efficency for (Map.Entry<String, Integer> entry : switches.entrySet()) { String switchId = entry.getKey(); int e = entry.getValue(); int v1 = graph.getEdgeVertex1(e); int v2 = graph.getEdgeVertex2(e); ConfiguredBus b1 = graph.getVertexObject(v1); ConfiguredBus b2 = graph.getVertexObject(v2); if (bus == b1 || bus == b2) { throw new PowsyblException("Cannot remove bus '" + bus.getId() + "' because switch '" + switchId + "' is connected to it"); } } getNetwork().getObjectStore().remove(bus); int v = buses.remove(bus.getId()); graph.removeVertex(v); }
@Override public Iterable<Switch> getSwitches() { return getBusBreakerView().getSwitches(); }
private SwitchImpl getSwitch(String switchId, boolean throwException) { Integer e = getEdge(switchId, throwException); if (e != null) { SwitchImpl aSwitch = graph.getEdgeObject(e); if (!aSwitch.getId().equals(switchId)) { throw new AssertionError("Invalid switch id (expected: " + switchId + ", actual: " + aSwitch.getId() + ")"); } return aSwitch; } return null; }
@Override public ConfiguredBus add() { String id = checkAndGetUniqueId(); ConfiguredBusImpl bus = new ConfiguredBusImpl(id, voltageLevel); voltageLevel.addBus(bus); getNetwork().getListeners().notifyCreation(bus); return bus; }
@Override public VoltageLevel add() { String id = checkAndGetUniqueId(); // TODO : ckeck that there are not another voltage level with same base voltage ValidationUtil.checkNominalV(this, nominalV); ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit); ValidationUtil.checkTopologyKind(this, topologyKind); VoltageLevelExt voltageLevel; switch (topologyKind) { case NODE_BREAKER: voltageLevel = new NodeBreakerVoltageLevel(id, getName(), substation, nominalV, lowVoltageLimit, highVoltageLimit); break; case BUS_BREAKER: voltageLevel = new BusBreakerVoltageLevel(id, getName(), substation, nominalV, lowVoltageLimit, highVoltageLimit); break; default: throw new AssertionError(); } getNetwork().getObjectStore().checkAndAdd(voltageLevel); substation.addVoltageLevel(voltageLevel); getNetwork().getListeners().notifyCreation(voltageLevel); return voltageLevel; }
@Override protected NetworkImpl getNetwork() { return BusBreakerVoltageLevel.this.getNetwork(); }
@Override public int getSwitchCount() { return getBusBreakerView().getSwitchCount(); }
@Override public Terminal getTerminal(int node) { throw createNotSupportedBusBreakerTopologyException(); }
@Override public void invalidateCache() { calculatedBusTopology.invalidateCache(); getNetwork().getConnectedComponentsManager().invalidate(); getNetwork().getSynchronousComponentsManager().invalidate(); }
@Override public ConfiguredBus getConnectableBus() { return ((BusBreakerVoltageLevel) voltageLevel).getBus(getConnectableBusId(), true); }
@Override public int getInternalConnectionCount() { throw createNotSupportedBusBreakerTopologyException(); }
private void removeAllSwitches() { for (SwitchImpl s : graph.getEdgesObject()) { getNetwork().getObjectStore().remove(s); } graph.removeAllEdges(); switches.clear(); }