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)); }
Bus b1 = vl.getBusBreakerView().getBus1(sw.getId()); Bus b2 = vl.getBusBreakerView().getBus2(sw.getId()); Bus toRemove = null;
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); } }
Bus busToKeep = vl.getBusBreakerView().getBus1(switchToRemove.getId()).equals(bus) ? vl.getBusBreakerView().getBus2(switchToRemove.getId()) : vl.getBusBreakerView().getBus1(switchToRemove.getId()); boolean reconnectBus1 = vl.getBusBreakerView().getBus1(switchToKeep.getId()) .equals(bus) ? true : false; : vl.getBusBreakerView().getBus1(switchToKeep.getId()).getId(); String bus2 = reconnectBus1 ? vl.getBusBreakerView().getBus2(switchToKeep.getId()).getId()
/** * Export IIDM coupling devices connect to Modelica coupling devices connect * @param writerMo * @param modContext * @param modelicaModelsList * @param modelicaSim * @throws IOException */ private void exportConnectCouplingDevices(Writer writerMo, ModExportContext modContext, List<String> modelicaModelsList, SimulatorInst modelicaSim) throws IOException { if ((connectCouplingList.size() != 0) && (!connectCouplingList.isEmpty())) { LOGGER.info("EXPORTING CONNECT COUPLING DEVICES " + connectCouplingList.size()); this.addRecord(writerMo, null); this.addRecord(writerMo, "// COUPLING DEVICES"); for (VoltageLevel voltageLevel : connectCouplingList) { for (Switch sw : voltageLevel.getBusBreakerView().getSwitches()) { LOGGER.info("\t Exporting coupling device connect " + sw.getId()); Bus bus1 = voltageLevel.getBusBreakerView().getBus1(sw.getId()); Bus bus2 = voltageLevel.getBusBreakerView().getBus2(sw.getId()); if (!Double.isNaN(bus1.getV()) && !Double.isNaN(bus2.getV())) { ConnectCouplingDevicesRecord couplingDeviceRecord = ModelConverter.getModelicaRecord(sw, bus1, bus2, modContext, _ddbManager, modelicaSim); this.addRecord(couplingDeviceRecord, writerMo, modContext, _ddbManager, modelicaSim); } } } } }
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 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 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())); }