From f23593516a6ba72e8168cd387aa654984e324703 Mon Sep 17 00:00:00 2001 From: Florian Dupuy <66690739+flo-dup@users.noreply.github.com> Date: Wed, 4 Dec 2024 14:12:53 +0100 Subject: [PATCH] CGMES 3.0: cim:Jumper support (#3235) * Add cim:Jumper support for CGMES 3.0 * Fix duplicate in groundTest * Add unit test Signed-off-by: Florian Dupuy --- .../conversion/elements/SwitchConversion.java | 2 + .../conversion/test/SwitchConversionTest.java | 37 +++++++++ .../src/test/resources/groundTest.xml | 4 - .../src/test/resources/jumperTest.xml | 78 +++++++++++++++++++ .../src/main/resources/CIM100.sparql | 34 ++++++++ 5 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java create mode 100644 cgmes/cgmes-conversion/src/test/resources/jumperTest.xml diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java index 60b3ef99b7b..4410b2c9465 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/SwitchConversion.java @@ -118,6 +118,8 @@ private SwitchKind kind() { return SwitchKind.DISCONNECTOR; } else if (type.contains("loadbreak")) { return SwitchKind.LOAD_BREAK_SWITCH; + } else if (type.contains("jumper")) { + return SwitchKind.DISCONNECTOR; } return SwitchKind.BREAKER; } diff --git a/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java new file mode 100644 index 00000000000..60812d3034d --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/java/com/powsybl/cgmes/conversion/test/SwitchConversionTest.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * SPDX-License-Identifier: MPL-2.0 + */ + +package com.powsybl.cgmes.conversion.test; + +import com.powsybl.cgmes.conversion.Conversion; +import com.powsybl.commons.test.AbstractSerDeTest; +import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.Switch; +import com.powsybl.iidm.network.SwitchKind; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * @author Florian Dupuy {@literal } + */ + +class SwitchConversionTest extends AbstractSerDeTest { + + @Test + void jumperImportTest() { + Network network = Network.read("jumperTest.xml", getClass().getResourceAsStream("/jumperTest.xml")); + + Switch aswitch = network.getSwitch("Jumper"); + assertEquals(SwitchKind.DISCONNECTOR, aswitch.getKind()); + assertEquals("Jumper", aswitch.getProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "switchType")); + assertEquals("opened jumper", aswitch.getNameOrId()); + assertTrue(aswitch.isOpen()); + assertFalse(aswitch.isRetained()); + } +} diff --git a/cgmes/cgmes-conversion/src/test/resources/groundTest.xml b/cgmes/cgmes-conversion/src/test/resources/groundTest.xml index a8a9f11d941..7cb32dda91e 100644 --- a/cgmes/cgmes-conversion/src/test/resources/groundTest.xml +++ b/cgmes/cgmes-conversion/src/test/resources/groundTest.xml @@ -92,10 +92,6 @@ 1 RK - - - AAP - diff --git a/cgmes/cgmes-conversion/src/test/resources/jumperTest.xml b/cgmes/cgmes-conversion/src/test/resources/jumperTest.xml new file mode 100644 index 00000000000..f1d0c36059e --- /dev/null +++ b/cgmes/cgmes-conversion/src/test/resources/jumperTest.xml @@ -0,0 +1,78 @@ + + + + 2023-01-01T00:00:00Z + 2023-01-01T00:00:00Z + Test Jumper import + 1 + http://iec.ch/TC57/ns/CIM/CoreEquipment-EU/3.0 + http://iec.ch/TC57/ns/CIM/Operation-EU/3.0 + http://powsybl.org + + + Region + + + + SubRegion + + + 67.5 + 67.5 + + + + Substation + + + + + VoltageLevel + + + + BBS + + + + + 1 + BBS Terminal + + + + BBS ConnectivityNode + + + Load + + + + + + 1 + Load Terminal + + + + Load ConnectivityNode + + + true + false + + opened jumper + + + + + 1 + Jumper Terminal1 + + + + + 2 + Jumper Terminal2 + + diff --git a/cgmes/cgmes-model/src/main/resources/CIM100.sparql b/cgmes/cgmes-model/src/main/resources/CIM100.sparql index cb4d0904c1b..ba668498e7a 100644 --- a/cgmes/cgmes-model/src/main/resources/CIM100.sparql +++ b/cgmes/cgmes-model/src/main/resources/CIM100.sparql @@ -141,3 +141,37 @@ WHERE { OPTIONAL {?OperationalLimit cim:VoltageLimit.value ?value } }} } + +# query: switches +SELECT * +WHERE { +{ GRAPH ?graph { + ?Switch + a ?type ; + cim:Equipment.EquipmentContainer ?EquipmentContainer . + VALUES ?type { cim:Switch cim:Breaker cim:Disconnector cim:LoadBreakSwitch cim:ProtectedSwitch cim:GroundDisconnector cim:Jumper } . + OPTIONAL { + ?Switch cim:IdentifiedObject.name ?name ; + } + OPTIONAL { + ?Switch cim:Switch.retained ?retained + } + OPTIONAL { + ?Switch cim:Switch.normalOpen ?normalOpen + } + ?Terminal1 + a cim:Terminal ; + cim:Terminal.ConductingEquipment ?Switch . + OPTIONAL { ?Terminal1 cim:ACDCTerminal.sequenceNumber ?seq1 } + ?Terminal2 + a cim:Terminal ; + cim:Terminal.ConductingEquipment ?Switch . + OPTIONAL { ?Terminal2 cim:ACDCTerminal.sequenceNumber ?seq2 } + FILTER ( bound(?seq1) && ?seq1 = "1" && bound(?seq2) && ?seq2 = "2" + || !bound(?seq1) && !bound(?seq2) && str(?Terminal1) < str(?Terminal2) ) +}} +OPTIONAL { GRAPH ?graphSSH { + ?Switch cim:Switch.open ?open +}} +} +