@Override public ConfiguredBus getBus(String id) { return BusBreakerVoltageLevel.this.getBus(id, false); }
@Override public ConfiguredBus getConnectableBus() { return ((BusBreakerVoltageLevel) voltageLevel).getBus(getConnectableBusId(), true); }
@Override public MergedBus getConnectableBus() { ConfiguredBus bus = ((BusBreakerVoltageLevel) voltageLevel).getBus(getConnectableBusId(), true); return ((BusBreakerVoltageLevel) voltageLevel).calculatedBusTopology.getMergedBus(bus); }
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); } }
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 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 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(); }); }