@Override public boolean connect() { return voltageLevel.connect(this); }
@Override public boolean disconnect() { return voltageLevel.disconnect(this); }
@Override public void setFictitious(boolean fictitious) { boolean oldValue = this.fictitious; if (oldValue != fictitious) { this.fictitious = fictitious; voltageLevel.invalidateCache(); NetworkImpl network = voltageLevel.getNetwork(); network.getListeners().notifyUpdate(this, "fictitious", oldValue, fictitious); } }
@Override protected NetworkImpl getNetwork() { return vl.getNetwork(); }
@Override public void setRetained(boolean retained) { if (voltageLevel.getTopologyKind() != TopologyKind.NODE_BREAKER) { throw new ValidationException(this, "retain status is not modifiable in a non node/breaker voltage level"); } NetworkImpl network = voltageLevel.getNetwork(); int index = network.getVariantIndex(); boolean oldValue = this.retained.get(index); if (oldValue != retained) { this.retained.set(index, retained); voltageLevel.invalidateCache(); network.getListeners().notifyUpdate(this, "retained", oldValue, retained); } }
VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(); VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(); if (voltageLevel1.getSubstation() != substation || voltageLevel2.getSubstation() != substation) { throw new ValidationException(this, "the 2 windings of the transformer shall belong to the substation '" + substation.getId() + "' ('" + voltageLevel1.getSubstation().getId() + "', '" + voltageLevel2.getSubstation().getId() + "')"); voltageLevel1.getSubstation(), r, x, g, b, ratedU1, ratedU2); voltageLevel1.attach(terminal1, true); voltageLevel2.attach(terminal2, true); voltageLevel1.attach(terminal1, false); voltageLevel2.attach(terminal2, false); getNetwork().getObjectStore().checkAndAdd(transformer); getNetwork().getListeners().notifyCreation(transformer);
@Override public void remove() { Substations.checkRemovability(this); Set<VoltageLevelExt> vls = new HashSet<>(voltageLevels); for (VoltageLevelExt vl : vls) { // Remove all branches, transformers and HVDC lines List<Connectable> connectables = Lists.newArrayList(vl.getConnectables()); for (Connectable connectable : connectables) { ConnectableType type = connectable.getType(); if (VoltageLevels.MULTIPLE_TERMINALS_CONNECTABLE_TYPES.contains(type)) { connectable.remove(); } else if (type == ConnectableType.HVDC_CONVERTER_STATION) { HvdcLine hvdcLine = getNetwork().getHvdcLine((HvdcConverterStation) connectable); if (hvdcLine != null) { hvdcLine.remove(); } } } // Then remove the voltage level (bus, switches and injections) from the network vl.remove(); } // Remove this substation from the network getNetwork().getObjectStore().remove(this); getNetwork().getListeners().notifyRemoval(this); }
@Override public int getTwoWindingsTransformerCount() { return voltageLevels.stream() .mapToInt(vl -> vl.getConnectableCount(TwoWindingsTransformer.class)) .sum(); }
@Override public Iterable<TwoWindingsTransformer> getTwoWindingsTransformers() { return FluentIterable.from(voltageLevels) .transformAndConcat(vl -> vl.getConnectables(TwoWindingsTransformer.class)) .toSet(); }
@Override public Stream<ThreeWindingsTransformer> getThreeWindingsTransformerStream() { return voltageLevels.stream().flatMap(vl -> vl.getConnectableStream(ThreeWindingsTransformer.class)).distinct(); }
@Override public Terminal getTerminal(String voltageLevelId) { Objects.requireNonNull(voltageLevelId); boolean side1 = getTerminal1().getVoltageLevel().getId().equals(voltageLevelId); boolean side2 = getTerminal2().getVoltageLevel().getId().equals(voltageLevelId); if (side1 && side2) { throw new PowsyblException("Both terminals are connected to voltage level " + voltageLevelId); } else if (side1) { return getTerminal1(); } else if (side2) { return getTerminal2(); } else { throw new PowsyblException("No terminal connected to voltage level " + voltageLevelId); } }
@Override protected NetworkImpl getNetwork() { return voltageLevel.getNetwork(); }
@Override public TieLineImpl add() { String id = checkAndGetUniqueId(); VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(); VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(); TerminalExt terminal1 = checkAndGetTerminal1(); TerminalExt terminal2 = checkAndGetTerminal2(); if (ucteXnodeCode == null) { throw new ValidationException(this, "ucteXnodeCode is not set"); } checkHalf(half1, 1); checkHalf(half2, 2); // check that the line is attachable on both side voltageLevel1.attach(terminal1, true); voltageLevel2.attach(terminal2, true); TieLineImpl line = new TieLineImpl(id, getName(), ucteXnodeCode, half1, half2); terminal1.setNum(1); terminal2.setNum(2); line.addTerminal(terminal1); line.addTerminal(terminal2); voltageLevel1.attach(terminal1, false); voltageLevel2.attach(terminal2, false); network.getObjectStore().checkAndAdd(line); return line; }
@Override public void setOpen(boolean open) { NetworkImpl network = voltageLevel.getNetwork(); int index = network.getVariantIndex(); boolean oldValue = this.open.get(index); if (oldValue != open) { this.open.set(index, open); voltageLevel.invalidateCache(); network.getListeners().notifyUpdate(this, "open", oldValue, open); } }
@Override public int getThreeWindingsTransformerCount() { return voltageLevels.stream() .mapToInt(vl -> vl.getConnectableCount(ThreeWindingsTransformer.class)) .sum(); }
@Override public Iterable<ThreeWindingsTransformer> getThreeWindingsTransformers() { return FluentIterable.from(voltageLevels) .transformAndConcat(vl -> vl.getConnectables(ThreeWindingsTransformer.class)) .toSet(); }
@Override public Stream<TwoWindingsTransformer> getTwoWindingsTransformerStream() { return voltageLevels.stream().flatMap(vl -> vl.getConnectableStream(TwoWindingsTransformer.class)).distinct(); }