@Override protected VoltageLevel.BusBreakerView.SwitchAdder createAdder(VoltageLevel vl) { return vl.getBusBreakerView().newSwitch(); }
@Override protected BusAdder createAdder(VoltageLevel vl) { return vl.getBusBreakerView().newBus(); }
@Override public int getSwitchCount() { return getVoltageLevelStream().mapToInt(vl -> vl.getBusBreakerView().getSwitchCount()).sum(); }
@Override public Stream<Bus> getBusStream() { return getVoltageLevelStream().flatMap(vl -> vl.getBusBreakerView().getBusStream()); }
@Override public Stream<Switch> getSwitchStream() { return getVoltageLevelStream().flatMap(vl -> vl.getBusBreakerView().getSwitchStream()); }
public static Bus getBus1(VoltageLevel vl, String switchId, EurostagEchExportConfig config) { if (config.isNoSwitch()) { throw new AssertionError("Should not happen"); } else { return vl.getBusBreakerView().getBus1(switchId); } }
public static Bus getBus2(VoltageLevel vl, String switchId, EurostagEchExportConfig config) { if (config.isNoSwitch()) { throw new AssertionError("Should not happen"); } else { return vl.getBusBreakerView().getBus2(switchId); } }
public static Iterable<Switch> getSwitches(VoltageLevel vl, EurostagEchExportConfig config) { if (config.isNoSwitch()) { return Collections.emptyList(); } else { return vl.getBusBreakerView().getSwitches(); } }
private Map<String, List<String>> getBusSwitchMap(VoltageLevel vl) { return vl.getBusBreakerView().getSwitchStream().flatMap(s -> Stream.of( Maps.immutableEntry(vl.getBusBreakerView().getBus1(s.getId()).getId(), s.getId()), Maps.immutableEntry(vl.getBusBreakerView().getBus2(s.getId()).getId(), s.getId()))) .collect(Collectors.toMap(a -> a.getKey(), a -> new ArrayList<>(Collections.singletonList(a.getValue())), (o, n) -> { o.addAll(n); return o; }, HashMap::new)); }
@Override public Iterable<Bus> getBuses() { return FluentIterable.from(getVoltageLevels()) .transformAndConcat(vl -> vl.getBusBreakerView().getBuses()); }
@Override public Iterable<Switch> getSwitches() { return FluentIterable.from(getVoltageLevels()) .transformAndConcat(vl -> vl.getBusBreakerView().getSwitches()); }
public static Iterable<Bus> getBuses(VoltageLevel vl, EurostagEchExportConfig config) { if (config.isNoSwitch()) { return vl.getBusView().getBuses(); } else { return vl.getBusBreakerView().getBuses(); } }
private boolean compareSwitchToRemove(VoltageLevel vl, Bus bus, Switch s1, Switch s2) { if (s1.isFictitious()) { return true; } if (s2.isFictitious()) { return false; } if (s1.getKind() != s2.getKind()) { return s1.getKind() == SwitchKind.BREAKER; } Bus b1 = vl.getBusBreakerView().getBus1(s1.getId()).equals(bus) ? vl.getBusBreakerView().getBus2(s1.getId()) : vl.getBusBreakerView().getBus1(s1.getId()); Bus b2 = vl.getBusBreakerView().getBus1(s2.getId()).equals(bus) ? vl.getBusBreakerView().getBus2(s2.getId()) : vl.getBusBreakerView().getBus1(s2.getId()); if (b1.getAngle() != b2.getAngle()) { return b1.getAngle() < b2.getAngle(); } return s1.getId().compareTo(s2.getId()) < 0; }
private static void updateBus(XMLStreamReader reader, VoltageLevel[] vl) { String id = reader.getAttributeValue(null, "id"); double v = XmlUtil.readDoubleAttribute(reader, "v"); double angle = XmlUtil.readDoubleAttribute(reader, "angle"); Bus b = vl[0].getBusBreakerView().getBus(id); if (b == null) { b = vl[0].getBusView().getBus(id); } b.setV(v > 0 ? v : Double.NaN).setAngle(angle); }
private void writeBusBreakerTopology(VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException { context.getWriter().writeStartElement(IIDM_URI, BUS_BREAKER_TOPOLOGY_ELEMENT_NAME); for (Bus b : vl.getBusBreakerView().getBuses()) { if (!context.getFilter().test(b)) { continue; } BusXml.INSTANCE.write(b, null, context); } for (Switch sw : vl.getBusBreakerView().getSwitches()) { Bus b1 = vl.getBusBreakerView().getBus1(context.getAnonymizer().anonymizeString(sw.getId())); Bus b2 = vl.getBusBreakerView().getBus2(context.getAnonymizer().anonymizeString(sw.getId())); if (!context.getFilter().test(b1) || !context.getFilter().test(b2)) { continue; } BusBreakerViewSwitchXml.INSTANCE.write(sw, vl, context); } context.getWriter().writeEndElement(); }
@Override public void modify(Network network, ComputationManager computationManager) { VoltageLevel vl = network.getVoltageLevel(voltageLevelId); if (vl == null) { throw new PowsyblException("Voltage level '" + voltageLevelId + "' not found"); } Switch s = vl.getBusBreakerView().getSwitch(breakerId); if (s == null) { throw new PowsyblException("Breaker '" + breakerId + "' not found"); } s.setOpen(false); }
@Override public void modify(Network network, ComputationManager computationManager) { VoltageLevel vl = network.getVoltageLevel(voltageLevelId); if (vl == null) { throw new PowsyblException("Voltage level '" + voltageLevelId + "' not found"); } Switch s = vl.getBusBreakerView().getSwitch(breakerId); if (s == null) { throw new PowsyblException("Breaker '" + breakerId + "' not found"); } s.setOpen(true); }
private boolean removeSwitchandBus(VoltageLevel vl, Switch s, Bus toRemove, Bus toKeep) { List<Terminal> terminals = getTerminals(toRemove); if (terminals.size() <= 1) { terminals.forEach(t -> { boolean reconnect = false; if (t.isConnected()) { t.disconnect(); reconnect = true; } t.getBusBreakerView().setConnectableBus(toKeep.getId()); if (!s.isOpen() && reconnect) { t.connect(); } }); vl.getBusBreakerView().removeSwitch(s.getId()); vl.getBusBreakerView().removeBus(toRemove.getId()); return true; } return false; }
@Override protected void writeRootElementAttributes(Switch s, VoltageLevel vl, NetworkXmlWriterContext context) throws XMLStreamException { super.writeRootElementAttributes(s, vl, context); VoltageLevel.BusBreakerView v = vl.getBusBreakerView(); Bus bus1 = v.getBus1(s.getId()); Bus bus2 = v.getBus2(s.getId()); context.getWriter().writeAttribute("bus1", context.getAnonymizer().anonymizeString(bus1.getId())); context.getWriter().writeAttribute("bus2", context.getAnonymizer().anonymizeString(bus2.getId())); }
private void createBus(VoltageLevel voltageLevel) { Bus bus = voltageLevel.getBusBreakerView().newBus() .setId(context.namingStrategy().getId("Bus", id)) .setName(context.namingStrategy().getName("Bus", name)) .add(); double v = p.asDouble("v"); double angle = p.asDouble("angle"); if (valid(v, angle)) { bus.setV(v); bus.setAngle(angle); } else { String reason = String.format( "v = %f, angle = %f. Substation, Voltage level = %s %s", v, angle, voltageLevel.getSubstation().getName(), voltageLevel.getName()); context.invalid("SvVoltage", reason); } }