/** * Throw a {@link com.powsybl.commons.PowsyblException} if this substation contains at least one {@link Branch} or * one {@link ThreeWindingsTransformer} or one {@link HvdcConverterStation} linked to a voltage level outside this * substation. */ static void checkRemovability(Substation substation) { for (VoltageLevel vl : substation.getVoltageLevels()) { for (Connectable connectable : vl.getConnectables()) { if (connectable instanceof Branch) { checkRemovability(substation, (Branch) connectable); } else if (connectable instanceof ThreeWindingsTransformer) { checkRemovability(substation, (ThreeWindingsTransformer) connectable); } else if (connectable instanceof HvdcConverterStation) { checkRemovability(substation, (HvdcConverterStation) connectable); } } } }
@Override public Iterable<Substation> getSubstations(Country country, String tsoId, String... geographicalTags) { return Substations.filter(getSubstations(), country, tsoId, geographicalTags); }
private static void checkRemovability(Substation substation, Branch branch) { Substation s1 = branch.getTerminal1().getVoltageLevel().getSubstation(); Substation s2 = branch.getTerminal2().getVoltageLevel().getSubstation(); if ((s1 != substation) || (s2 != substation)) { throw createIsolationException(substation); } }
private static void checkRemovability(Substation substation, HvdcConverterStation station) { HvdcLine hvdcLine = substation.getNetwork().getHvdcLine(station); if (hvdcLine != null) { Substation s1 = hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getSubstation(); Substation s2 = hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getSubstation(); if ((s1 != substation) || (s2 != substation)) { throw createIsolationException(substation); } } }
private static void checkRemovability(Substation substation, ThreeWindingsTransformer twt) { Substation s1 = twt.getLeg1().getTerminal().getVoltageLevel().getSubstation(); Substation s2 = twt.getLeg2().getTerminal().getVoltageLevel().getSubstation(); Substation s3 = twt.getLeg3().getTerminal().getVoltageLevel().getSubstation(); if ((s1 != substation) || (s2 != substation) || (s3 != substation)) { throw createIsolationException(substation); } }
@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); }