diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitsGroupTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitsGroupTest.java index 6c73e84fc84..0ce92d7f4b2 100644 --- a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitsGroupTest.java +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/OperationalLimitsGroupTest.java @@ -9,6 +9,9 @@ package com.powsybl.cgmes.conversion.test; import com.powsybl.cgmes.conversion.CgmesExport; +import com.powsybl.commons.datasource.ReadOnlyDataSource; +import com.powsybl.commons.datasource.ResourceDataSource; +import com.powsybl.commons.datasource.ResourceSet; import com.powsybl.commons.test.AbstractSerDeTest; import com.powsybl.iidm.network.*; import org.junit.jupiter.api.Test; @@ -104,6 +107,37 @@ void exportAllLimitsGroupTest() throws IOException { assertEquals(9, getOccurrences(exportAllLimitsGroupXml, CURRENT_LIMIT).size()); } + @Test + void limitSetsAssociatedToEquipmentsTest() { + // CGMES network: + // An OperationalLimitSet with a CurrentLimit associated to a boundary ACLineSegment (Dangling Line in IIDM). + // An OperationalLimitSet with a CurrentLimit associated to a normal ACLineSegment. + // An OperationalLimitSet with a CurrentLimit associated to a 2-windings PowerTransformer. + // An OperationalLimitSet with a CurrentLimit associated to a Switch. + ReadOnlyDataSource ds = new ResourceDataSource("CGMES input file(s)", + new ResourceSet("/issues/operational-limits/", + "limitsets_associated_to_equipments_EQ.xml", + "limitsets_associated_to_equipments_EQBD.xml")); + Network network = Network.read(ds, new Properties()); + + // OperationalLimitSet on dangling line is imported on its single extremity. + assertNotNull(network.getDanglingLine("DL")); + assertTrue(network.getDanglingLine("DL").getCurrentLimits().isPresent()); + + // OperationalLimitSet on ACLineSegment is imported on its two extremities. + assertNotNull(network.getLine("ACL")); + assertTrue(network.getLine("ACL").getCurrentLimits1().isPresent()); + assertTrue(network.getLine("ACL").getCurrentLimits2().isPresent()); + + // OperationalLimitSet on PowerTransformer is discarded. + assertNotNull(network.getTwoWindingsTransformer("PT")); + assertFalse(network.getTwoWindingsTransformer("PT").getCurrentLimits1().isPresent()); + assertFalse(network.getTwoWindingsTransformer("PT").getCurrentLimits2().isPresent()); + + // There can't be any limit associated to switches in IIDM, but check anyway that the switch has been imported. + assertNotNull(network.getSwitch("SW")); + } + private Set getOccurrences(String xml, Pattern pattern) { Set matches = new HashSet<>(); Matcher matcher = pattern.matcher(xml); diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limitsets_associated_to_equipments_EQ.xml b/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limitsets_associated_to_equipments_EQ.xml new file mode 100644 index 00000000000..b586b334711 --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limitsets_associated_to_equipments_EQ.xml @@ -0,0 +1,231 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Limitsets refering equipments + 001 + http://entsoe.eu/CIM/EquipmentCore/3/1 + http://entsoe.eu/CIM/EquipmentOperation/3/1 + powsybl.org + + + Geographical region + + + Subgeographical region + + + + Substation 1 + + + + Voltage level 1 + + + + + Node 1 + + + + Substation 2 + + + + Voltage level 2 + + + + + Node 2 + + + + Voltage level 3 + + + + + Node 3 + + + + Node 4 + + + + 0 + 0 + 0 + 0 + 1 + Dangling Line + 0.1 + 0.1 + 75 + 1 + 0.1 + + + + + Limit set + + + + Current limit + 100 + + + + + Terminal DL 1 + 1 + + + + + Terminal DL 2 + 2 + + + + + 0 + 0 + 0 + 0 + 1 + Line 12 + 0.1 + 0.1 + 75 + 1 + 0.1 + + + + + Limit set + + + + Current limit + 100 + + + + + Terminal ACL 1 + 1 + + + + + Terminal ACL 2 + 2 + + + + + PowerTransformer + + false + + + Limit set + + + + Current limit + 100 + + + + + TransformerEnd 1 + 1 + false + 0 + 0 + 0 + 0 + 0.1 + 0.1 + 1 + 1 + 0 + 110 + + + + + + TransformerEnd 2 + 2 + false + 0 + 0 + 0 + 0 + 0.1 + 0.1 + 1 + 1 + 0 + 110 + + + + + + Terminal PT 1 + 1 + + + + + Terminal PT 2 + 2 + + + + + Switch + + false + false + + + Limit set + + + + Current limit + 100 + + + + + Terminal SW 1 + 1 + + + + + Terminal SW 2 + 2 + + + + + + + PATL + + + 110 kV + 110 + + diff --git a/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limitsets_associated_to_equipments_EQBD.xml b/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limitsets_associated_to_equipments_EQBD.xml new file mode 100644 index 00000000000..3381824f48c --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/issues/operational-limits/limitsets_associated_to_equipments_EQBD.xml @@ -0,0 +1,19 @@ + + + 2021-03-01T23:00:00Z + 2021-03-02T10:22:58Z + Limitsets refering equipments + 001 + http://entsoe.eu/CIM/EquipmentBoundary/3/1 + http://entsoe.eu/CIM/EquipmentBoundaryOperation/3/1 + powsybl.org + + + Line + + + + X Node + + +