From 5a020cc254164a39cfc0f0ee13dfba0bb93105f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vall=C3=A9e?= Date: Tue, 12 Sep 2023 18:26:04 +0200 Subject: [PATCH] IIDM v1.9.0: fix shunt P serialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Frédéric Vallée --- CMakeLists.txt | 2 +- extensions/entsoe/src/MergedXnodeXmlSerializer.cpp | 1 + include/powsybl/iidm/converter/xml/IidmXmlVersion.hpp | 5 +++++ src/iidm/converter/xml/IidmXmlVersion.cpp | 10 ++++++++-- src/iidm/converter/xml/ShuntCompensatorXml.cpp | 3 ++- src/iidm/extensions/SlackTerminalXmlSerializer.cpp | 1 + 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1418b5f20..401dabc34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(powsybl-iidm4cpp) set(IIDM_VERSION_MAJOR 1) -set(IIDM_VERSION_MINOR 8) +set(IIDM_VERSION_MINOR 9) set(IIDM_VERSION_PATCH 0) set(IIDM_VERSION ${IIDM_VERSION_MAJOR}.${IIDM_VERSION_MINOR}.${IIDM_VERSION_PATCH}) set(IIDM_SOVERSION ${IIDM_VERSION_MAJOR}) diff --git a/extensions/entsoe/src/MergedXnodeXmlSerializer.cpp b/extensions/entsoe/src/MergedXnodeXmlSerializer.cpp index 8d9e7ba0d..a84948adb 100644 --- a/extensions/entsoe/src/MergedXnodeXmlSerializer.cpp +++ b/extensions/entsoe/src/MergedXnodeXmlSerializer.cpp @@ -38,6 +38,7 @@ MergedXnodeXmlSerializer::MergedXnodeXmlSerializer() : .put(converter::xml::IidmXmlVersion::V1_6(), {"1.0", "1.1"}) .put(converter::xml::IidmXmlVersion::V1_7(), {"1.0", "1.1"}) .put(converter::xml::IidmXmlVersion::V1_8(), {"1.0", "1.1"}) + .put(converter::xml::IidmXmlVersion::V1_9(), {"1.0", "1.1"}) .build(), stdcxx::MapBuilder() .put("1.0", "http://www.itesla_project.eu/schema/iidm/ext/merged_xnode/1_0") diff --git a/include/powsybl/iidm/converter/xml/IidmXmlVersion.hpp b/include/powsybl/iidm/converter/xml/IidmXmlVersion.hpp index bd511a55d..b518fd994 100644 --- a/include/powsybl/iidm/converter/xml/IidmXmlVersion.hpp +++ b/include/powsybl/iidm/converter/xml/IidmXmlVersion.hpp @@ -72,6 +72,11 @@ class IidmXmlVersion { */ static const IidmXmlVersion& V1_8(); + /** + * IIDM V1.9 (http://www.powsybl.org) + */ + static const IidmXmlVersion& V1_9(); + public: /** * Return the list of all supported XIIDM versions diff --git a/src/iidm/converter/xml/IidmXmlVersion.cpp b/src/iidm/converter/xml/IidmXmlVersion.cpp index 8636d5e11..a140b05b1 100644 --- a/src/iidm/converter/xml/IidmXmlVersion.cpp +++ b/src/iidm/converter/xml/IidmXmlVersion.cpp @@ -69,14 +69,15 @@ const IidmXmlVersions& IidmXmlVersion::all() { std::cref(IidmXmlVersion::V1_5()), std::cref(IidmXmlVersion::V1_6()), std::cref(IidmXmlVersion::V1_7()), - std::cref(IidmXmlVersion::V1_8()) + std::cref(IidmXmlVersion::V1_8()), + std::cref(IidmXmlVersion::V1_9()) }}; return s_versions; } const IidmXmlVersion& IidmXmlVersion::CURRENT_IIDM_XML_VERSION() { - return V1_8(); + return V1_9(); } const IidmXmlVersion& IidmXmlVersion::fromNamespaceURI(const std::string& namespaceURI) { @@ -169,6 +170,11 @@ const IidmXmlVersion& IidmXmlVersion::V1_8() { return V1_8; } +const IidmXmlVersion& IidmXmlVersion::V1_9() { + static IidmXmlVersion V1_9("powsybl.org", {{1, 9}}); + return V1_9; +} + } // namespace xml } // namespace converter diff --git a/src/iidm/converter/xml/ShuntCompensatorXml.cpp b/src/iidm/converter/xml/ShuntCompensatorXml.cpp index 06095d972..12bacb0b4 100644 --- a/src/iidm/converter/xml/ShuntCompensatorXml.cpp +++ b/src/iidm/converter/xml/ShuntCompensatorXml.cpp @@ -170,7 +170,8 @@ void ShuntCompensatorXml::writeRootElementAttributes(const ShuntCompensator& shu IidmXmlUtil::writeDoubleAttributeFromMinimumVersion(SHUNT, TARGET_V, shuntCompensator.getTargetV(), ErrorMessage::NOT_DEFAULT_NOT_SUPPORTED, IidmXmlVersion::V1_2(), context); IidmXmlUtil::writeDoubleAttributeFromMinimumVersion(SHUNT, TARGET_DEADBAND, shuntCompensator.getTargetDeadband(), ErrorMessage::NOT_DEFAULT_NOT_SUPPORTED, IidmXmlVersion::V1_2(), context); writeNodeOrBus(shuntCompensator.getTerminal(), context); - writePQ(shuntCompensator.getTerminal(), context.getWriter()); + IidmXmlUtil::runFromMinimumVersion(IidmXmlVersion::V1_9(), context.getVersion(), [&context, &shuntCompensator]() { context.getWriter().writeOptionalAttribute(P, shuntCompensator.getTerminal().getP()); }); + context.getWriter().writeOptionalAttribute(Q, shuntCompensator.getTerminal().getQ()); } void ShuntCompensatorXml::writeSubElements(const ShuntCompensator& sc, const VoltageLevel& /*voltageLevel*/, NetworkXmlWriterContext& context) const { diff --git a/src/iidm/extensions/SlackTerminalXmlSerializer.cpp b/src/iidm/extensions/SlackTerminalXmlSerializer.cpp index 911bff597..1da9a1f71 100644 --- a/src/iidm/extensions/SlackTerminalXmlSerializer.cpp +++ b/src/iidm/extensions/SlackTerminalXmlSerializer.cpp @@ -36,6 +36,7 @@ SlackTerminalXmlSerializer::SlackTerminalXmlSerializer() : .put(converter::xml::IidmXmlVersion::V1_6(), {"1.2"}) .put(converter::xml::IidmXmlVersion::V1_7(), {"1.2"}) .put(converter::xml::IidmXmlVersion::V1_8(), {"1.2"}) + .put(converter::xml::IidmXmlVersion::V1_9(), {"1.2"}) .build(), stdcxx::MapBuilder() .put("1.0", "http://www.powsybl.org/schema/iidm/ext/slack_terminal/1_0")