From 0880e23a5b3d22b4fc48f31598dc821893bb4ddd Mon Sep 17 00:00:00 2001 From: Luma Date: Thu, 11 Jan 2024 12:20:46 +0100 Subject: [PATCH] CGMES import grounds Signed-off-by: Luma --- .../powsybl/cgmes/conversion/Conversion.java | 1 + .../conversion/elements/GroundConversion.java | 32 +++++++++++++++++++ .../com/powsybl/cgmes/model/CgmesModel.java | 4 +++ .../triplestore/CgmesModelTripleStore.java | 5 +++ .../src/main/resources/CIM16.sparql | 11 +++++++ 5 files changed, 53 insertions(+) create mode 100644 cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java index bb80fcbe04a..d43b53e14d9 100644 --- a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/Conversion.java @@ -180,6 +180,7 @@ public Network convert(Reporter reporter) { convert(cgmes.busBarSections(), bbs -> new BusbarSectionConversion(bbs, context)); } + convert(cgmes.grounds(), g -> new GroundConversion(g, context)); convert(cgmes.energyConsumers(), ec -> new EnergyConsumerConversion(ec, context)); convert(cgmes.energySources(), es -> new EnergySourceConversion(es, context)); convf = eqi -> new EquivalentInjectionConversion(eqi, context); diff --git a/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java new file mode 100644 index 00000000000..182cdca67f6 --- /dev/null +++ b/cgmes/cgmes-conversion/src/main/java/com/powsybl/cgmes/conversion/elements/GroundConversion.java @@ -0,0 +1,32 @@ +/** + 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.elements; + +import com.powsybl.cgmes.conversion.Context; +import com.powsybl.iidm.network.*; +import com.powsybl.triplestore.api.PropertyBag; + +/** + * @author Luma ZamarreƱo {@literal } + */ +public class GroundConversion extends AbstractConductingEquipmentConversion { + + public GroundConversion(PropertyBag ec, Context context) { + super("Ground", ec, context); + } + + @Override + public void convert() { + GroundAdder adder = voltageLevel().newGround(); + identify(adder); + connect(adder); + Ground g = adder.add(); + addAliasesAndProperties(g); + convertedTerminals(g.getTerminal()); + } +} diff --git a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java index bcb499469eb..45f99502540 100644 --- a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java +++ b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesModel.java @@ -152,6 +152,10 @@ default PropertyBags graph() { return new PropertyBags(); } + default PropertyBags grounds() { + return new PropertyBags(); + } + CgmesDcTerminal dcTerminal(String dcTerminalId); void clear(CgmesSubset subset); diff --git a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/triplestore/CgmesModelTripleStore.java b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/triplestore/CgmesModelTripleStore.java index 370b7c8d195..483e5ab3b6e 100644 --- a/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/triplestore/CgmesModelTripleStore.java +++ b/cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/triplestore/CgmesModelTripleStore.java @@ -590,6 +590,11 @@ public PropertyBags graph() { return namedQuery("graph"); } + @Override + public PropertyBags grounds() { + return namedQuery("grounds"); + } + @Override public PropertyBags modelProfiles() { return namedQuery(MODEL_PROFILES); diff --git a/cgmes/cgmes-model/src/main/resources/CIM16.sparql b/cgmes/cgmes-model/src/main/resources/CIM16.sparql index 9c32889bb5c..d33dce62360 100644 --- a/cgmes/cgmes-model/src/main/resources/CIM16.sparql +++ b/cgmes/cgmes-model/src/main/resources/CIM16.sparql @@ -1101,6 +1101,17 @@ WHERE { }} } +# query: grounds +SELECT * +WHERE { +{ GRAPH ?graph { + ?Ground + a cim:Ground ; + cim:IdentifiedObject.name ?name . + ?Terminal cim:Terminal.ConductingEquipment ?Ground . +}} +} + # query: update DELETE { GRAPH <{0}> { ?subject ?predicate ?value }