UcteImporter implements Importer { @Override public Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters) { try { String ext = findExtension(dataSource, true); try (BufferedReader reader = new BufferedReader(new InputStreamReader(dataSource.newInputStream(null, ext)))) { Stopwatch stopwatch = Stopwatch.createStarted(); UcteNetworkExt ucteNetwork = new UcteNetworkExt(new UcteReader().read(reader), LINE_MIN_Z); String fileName = dataSource.getBaseName(); EntsoeFileName ucteFileName = EntsoeFileName.parse(fileName); Network network = networkFactory.createNetwork(fileName, "UCTE"); network.setCaseDate(ucteFileName.getDate()); network.setForecastDistance(ucteFileName.getForecastDistance()); createBuses(ucteNetwork, network); createLines(ucteNetwork, network); createTransformers(ucteNetwork, network, ucteFileName); mergeXnodeDanglingLines(ucteNetwork, network); stopwatch.stop(); LOGGER.debug("UCTE import done in {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS)); return network; } } catch (IOException e) { throw new UncheckedIOException(e); } }  @Override String getFormat(); @Override String getComment(); @Override boolean exists(ReadOnlyDataSource dataSource); @Override void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource); @Override Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters);  }
@Test public void trimIssueTest() { ReadOnlyDataSource dataSource = new ResourceDataSource("importIssue", new ResourceSet("/", "importIssue.uct")); new UcteImporter().importData(dataSource, null); }
@Test public void countryAssociationIssueTest() { ReadOnlyDataSource dataSource = new ResourceDataSource("countryIssue", new ResourceSet("/", "countryIssue.uct")); Network network = new UcteImporter().importData(dataSource, null); assertEquals(Country.ES, network.getSubstation("EHORTA").getCountry().orElse(null)); assertEquals(1, network.getSubstation("EHORTA").getVoltageLevelStream().count()); assertEquals(Country.BE, network.getSubstation("BHORTA").getCountry().orElse(null)); assertEquals(1, network.getSubstation("BHORTA").getVoltageLevelStream().count()); }
@Test public void germanTsosImport() throws Exception { ReadOnlyDataSource dataSource = new ResourceDataSource("germanTsos", new ResourceSet("/", "germanTsos.uct")); Network network = new UcteImporter().importData(dataSource, null); EntsoeArea ext = network.getSubstation("D4NEUR").getExtension(EntsoeArea.class); assertNotNull(ext); assertEquals(EntsoeGeographicalCode.D4, ext.getCode()); ext = network.getSubstation("BAVLGM").getExtension(EntsoeArea.class); assertNull(ext); ext = network.getSubstation("DJA_KA").getExtension(EntsoeArea.class); assertNull(ext); ext = network.getSubstation("DEA_KA").getExtension(EntsoeArea.class); assertNull(ext); }
@Test public void elementNameTest() { ReadOnlyDataSource dataSource = new ResourceDataSource("elementName", new ResourceSet("/", "elementName.uct")); Network network = new UcteImporter().importData(dataSource, null); assertEquals("Test Line", network.getLine("F_SU1_12 F_SU2_11 1").getProperty("elementName")); assertEquals("Test DL", network.getDanglingLine("XG__F_21 F_SU1_21 1").getProperty("elementName")); assertEquals("Test Coupler", network.getSwitch("F_SU1_12 F_SU1_11 1").getProperty("elementName")); assertEquals("Test 2WT 1", network.getBranch("F_SU1_11 F_SU1_21 1").getProperty("elementName")); assertEquals("Test 2WT 2", network.getBranch("B_SU1_11 B_SU1_21 1").getProperty("elementName")); TieLine tieLine1 = (TieLine) network.getLineStream().filter(Line::isTieLine) .filter(line -> { TieLine tl = (TieLine) line; return tl.getHalf1().getId().equals("XB__F_11 B_SU1_11 1") || tl.getHalf2().getId().equals("XB__F_11 B_SU1_11 1"); }).findAny().get(); String expectedElementName1 = tieLine1.getHalf1().getId().equals("XB__F_11 B_SU1_11 1") ? "Test TL 1/2" : "Test TL 1/1"; String expectedElementName2 = tieLine1.getHalf2().getId().equals("XB__F_11 B_SU1_11 1") ? "Test TL 1/2" : "Test TL 1/1"; assertEquals(expectedElementName1, tieLine1.getProperty("elementName_1")); assertEquals(expectedElementName2, tieLine1.getProperty("elementName_2")); TieLine tieLine2 = (TieLine) network.getLineStream().filter(Line::isTieLine) .filter(line -> { TieLine tl = (TieLine) line; return tl.getHalf1().getId().equals("XB__F_21 B_SU1_21 1") || tl.getHalf2().getId().equals("XB__F_21 B_SU1_21 1"); }).findAny().get(); expectedElementName1 = tieLine2.getHalf1().getId().equals("XB__F_21 B_SU1_21 1") ? "Test TL 2/2" : "Test TL 2/1"; expectedElementName2 = tieLine2.getHalf2().getId().equals("XB__F_21 B_SU1_21 1") ? "Test TL 2/2" : "Test TL 2/1"; assertEquals(expectedElementName1, tieLine2.getProperty("elementName_1")); assertEquals(expectedElementName2, tieLine2.getProperty("elementName_2")); }
@Test public void xnodeMergingIssueTest() { ReadOnlyDataSource dataSource = new ResourceDataSource("mergedXnodeIssue", new ResourceSet("/", "mergedXnodeIssue.uct")); Network network = new UcteImporter().importData(dataSource, null); assertEquals(2, network.getVoltageLevelCount()); assertEquals(1, network.getDanglingLineCount()); assertEquals(1, network.getLineCount()); Line l = network.getLineStream().findFirst().orElseThrow(AssertionError::new); assertEquals("ESNODE11 XXNODE11 1 + FRNODE11 XXNODE11 1", l.getId()); MergedXnode mergedXnode = l.getExtension(MergedXnode.class); assertNotNull(mergedXnode); assertNotNull(l.getCurrentLimits1()); assertNotNull(l.getCurrentLimits2()); }
@Test public void lineAndTransformerSameId() { ReadOnlyDataSource dataSource = new ResourceDataSource("sameId", new ResourceSet("/", "sameId.uct")); Network network = new UcteImporter().importData(dataSource, null); assertEquals(0, network.getLineCount()); assertEquals(1, network.getTwoWindingsTransformerCount()); assertEquals(1, network.getSwitchStream().count()); }
@Test public void testCouplerToXnodeImport() { ReadOnlyDataSource dataSource = new ResourceDataSource("couplerToXnodeExample", new ResourceSet("/", "couplerToXnodeExample.uct")); Network network = new UcteImporter().importData(dataSource, null); assertEquals(1, network.getBusBreakerView().getBusStream().count()); }
@Test public void testEmptyLastCharacterOfLineImport() { ResourceDataSource dataSource = new ResourceDataSource("lastCharacterIssue", new ResourceSet("/", "lastCharacterIssue.uct")); Network network = new UcteImporter().importData(dataSource, null); assertEquals(2, network.getBusBreakerView().getBusStream().count()); }
@Test public void testImportLinesDifferentNominalvoltage() { ResourceDataSource dataSource = new ResourceDataSource("differentLinesVoltage", new ResourceSet("/", "differentLinesVoltage.uct")); exceptionRule.expect(IllegalArgumentException.class); exceptionRule.expectMessage("with two different nominal voltages"); new UcteImporter().importData(dataSource, null); }
@Test public void testVoltageRegulatingXnode() { ResourceDataSource dataSource = new ResourceDataSource("frVoltageRegulatingXnode", new ResourceSet("/", "frVoltageRegulatingXnode.uct")); Network network = new UcteImporter().importData(dataSource, null); DanglingLine dl = network.getDanglingLine("FFFFFF13 XXXXXX14 1"); assertEquals(true, dl.getGeneration().isVoltageRegulationOn()); assertEquals(409.08, dl.getGeneration().getTargetV(), 0.01); assertEquals(1.0, dl.getGeneration().getTargetP(), 0.01); assertEquals(2.0, dl.getGeneration().getMaxP(), 0.01); assertEquals(-2.0, dl.getGeneration().getMinP(), 0.01); assertEquals(1.0, dl.getGeneration().getReactiveLimits().getMaxQ(dl.getGeneration().getTargetP()), 0.01); assertEquals(-1.0, dl.getGeneration().getReactiveLimits().getMinQ(dl.getGeneration().getTargetP()), 0.01); }