-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IdentifiableShortCircuitXmlSerializer
Signed-off-by: Sébastien LAIGRE <[email protected]>
- Loading branch information
Showing
7 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...sions/iidm/include/powsybl/iidm/extensions/iidm/IdentifiableShortCircuitXmlSerializer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) 2022, 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/. | ||
*/ | ||
|
||
#ifndef POWSYBL_IIDM4CPP_IDENTIFIABLESHORTCIRCUITXMLSERIALIZER_HPP | ||
#define POWSYBL_IIDM4CPP_IDENTIFIABLESHORTCIRCUITXMLSERIALIZER_HPP | ||
|
||
#include <powsybl/iidm/converter/xml/AbstractExtensionXmlSerializer.hpp> | ||
|
||
namespace powsybl { | ||
|
||
namespace iidm { | ||
|
||
namespace extensions { | ||
|
||
namespace iidm { | ||
|
||
class IdentifiableShortCircuitXmlSerializer : public converter::xml::AbstractExtensionXmlSerializer { | ||
public: // ExtensionXmlSerializer | ||
Extension& read(Extendable& extendable, converter::xml::NetworkXmlReaderContext& context) const override; | ||
|
||
void write(const Extension& extension, converter::xml::NetworkXmlWriterContext& context) const override; | ||
|
||
public: | ||
IdentifiableShortCircuitXmlSerializer(); | ||
|
||
~IdentifiableShortCircuitXmlSerializer() noexcept override = default; | ||
}; | ||
|
||
} // namespace iidm | ||
|
||
} // namespace extensions | ||
|
||
} // namespace iidm | ||
|
||
} // namespace powsybl | ||
|
||
#endif // POWSYBL_IIDM4CPP_IDENTIFIABLESHORTCIRCUITXMLSERIALIZER_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<iidm:network xmlns:iidm="http://www.powsybl.org/schema/iidm/1_6" xmlns:isc="http://www.powsybl.org/schema/iidm/ext/identifiable_short_circuit/1_0" id="sim1" caseDate="2016-12-07T11:18:52.881000+01:00" forecastDistance="0" sourceFormat="test"> | ||
<iidm:substation id="P1" country="FR" tso="RTE" geographicalTags="A"> | ||
<iidm:voltageLevel id="VLGEN" nominalV="24" topologyKind="BUS_BREAKER"> | ||
<iidm:busBreakerTopology> | ||
<iidm:bus id="NGEN"/> | ||
</iidm:busBreakerTopology> | ||
<iidm:generator id="GEN" energySource="OTHER" minP="-9999.9899999999998" maxP="9999.9899999999998" voltageRegulatorOn="true" targetP="607" targetV="24.5" targetQ="301" bus="NGEN" connectableBus="NGEN"> | ||
<iidm:minMaxReactiveLimits minQ="-9999.9899999999998" maxQ="9999.9899999999998"/> | ||
</iidm:generator> | ||
</iidm:voltageLevel> | ||
<iidm:voltageLevel id="VLHV1" nominalV="380" topologyKind="BUS_BREAKER"> | ||
<iidm:busBreakerTopology> | ||
<iidm:bus id="NHV1"/> | ||
</iidm:busBreakerTopology> | ||
</iidm:voltageLevel> | ||
<iidm:twoWindingsTransformer id="NGEN_NHV1" r="0.26658461538461536" x="11.104492831516762" g="0" b="0" ratedU1="24" ratedU2="400" bus1="NGEN" connectableBus1="NGEN" voltageLevelId1="VLGEN" bus2="NHV1" connectableBus2="NHV1" voltageLevelId2="VLHV1"/> | ||
</iidm:substation> | ||
<iidm:substation id="P2" country="FR" tso="RTE" geographicalTags="B"> | ||
<iidm:voltageLevel id="VLHV2" nominalV="380" topologyKind="BUS_BREAKER"> | ||
<iidm:busBreakerTopology> | ||
<iidm:bus id="NHV2"/> | ||
</iidm:busBreakerTopology> | ||
</iidm:voltageLevel> | ||
<iidm:voltageLevel id="VLLOAD" nominalV="150" topologyKind="BUS_BREAKER"> | ||
<iidm:busBreakerTopology> | ||
<iidm:bus id="NLOAD"/> | ||
</iidm:busBreakerTopology> | ||
<iidm:load id="LOAD" loadType="UNDEFINED" p0="600" q0="200" bus="NLOAD" connectableBus="NLOAD"/> | ||
</iidm:voltageLevel> | ||
<iidm:twoWindingsTransformer id="NHV2_NLOAD" r="0.047249999999999993" x="4.0497243656204551" g="0" b="0" ratedU1="400" ratedU2="158" bus1="NHV2" connectableBus1="NHV2" voltageLevelId1="VLHV2" bus2="NLOAD" connectableBus2="NLOAD" voltageLevelId2="VLLOAD"> | ||
<iidm:ratioTapChanger lowTapPosition="0" tapPosition="1" targetDeadband="0" loadTapChangingCapabilities="true" regulating="true" targetV="158"> | ||
<iidm:terminalRef id="NHV2_NLOAD" side="TWO"/> | ||
<iidm:step r="0" x="0" g="0" b="0" rho="0.85056666666666658"/> | ||
<iidm:step r="0" x="0" g="0" b="0" rho="1.0006666666666666"/> | ||
<iidm:step r="0" x="0" g="0" b="0" rho="1.1507666666666665"/> | ||
</iidm:ratioTapChanger> | ||
</iidm:twoWindingsTransformer> | ||
</iidm:substation> | ||
<iidm:line id="NHV1_NHV2_1" r="3" x="33" g1="0" b1="0.000193" g2="0" b2="0.000193" bus1="NHV1" connectableBus1="NHV1" voltageLevelId1="VLHV1" bus2="NHV2" connectableBus2="NHV2" voltageLevelId2="VLHV2"/> | ||
<iidm:line id="NHV1_NHV2_2" r="3" x="33" g1="0" b1="0.000193" g2="0" b2="0.000193" bus1="NHV1" connectableBus1="NHV1" voltageLevelId1="VLHV1" bus2="NHV2" connectableBus2="NHV2" voltageLevelId2="VLHV2"/> | ||
<iidm:extension id="VLHV1"> | ||
<isc:identifiableShortCircuit ipMax="1500" ipMin="500"/> | ||
</iidm:extension> | ||
</iidm:network> |
59 changes: 59 additions & 0 deletions
59
extensions/iidm/src/IdentifiableShortCircuitXmlSerializer.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2022, 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/. | ||
*/ | ||
|
||
#include <powsybl/iidm/extensions/iidm/IdentifiableShortCircuitXmlSerializer.hpp> | ||
|
||
#include <powsybl/AssertionError.hpp> | ||
#include <powsybl/iidm/Identifiable.hpp> | ||
#include <powsybl/iidm/converter/xml/NetworkXmlReaderContext.hpp> | ||
#include <powsybl/iidm/converter/xml/NetworkXmlWriterContext.hpp> | ||
#include <powsybl/iidm/extensions/iidm/Constants.hpp> | ||
#include <powsybl/iidm/extensions/iidm/IdentifiableShortCircuit.hpp> | ||
#include <powsybl/iidm/extensions/iidm/IdentifiableShortCircuitAdder.hpp> | ||
#include <powsybl/stdcxx/demangle.hpp> | ||
#include <powsybl/stdcxx/math.hpp> | ||
#include <powsybl/xml/XmlStreamReader.hpp> | ||
#include <powsybl/xml/XmlStreamWriter.hpp> | ||
|
||
namespace powsybl { | ||
|
||
namespace iidm { | ||
|
||
namespace extensions { | ||
|
||
namespace iidm { | ||
|
||
IdentifiableShortCircuitXmlSerializer::IdentifiableShortCircuitXmlSerializer() : | ||
AbstractExtensionXmlSerializer("identifiableShortCircuit", "network", "isc", "http://www.powsybl.org/schema/iidm/ext/identifiable_short_circuit/1_0") { | ||
} | ||
|
||
Extension& IdentifiableShortCircuitXmlSerializer::read(Extendable& extendable, converter::xml::NetworkXmlReaderContext& context) const { | ||
if (!stdcxx::isInstanceOf<Identifiable>(extendable)) { | ||
throw AssertionError(stdcxx::format("Unexpected extendable type: %1% (%2% expected)", stdcxx::demangle(extendable), stdcxx::demangle<Identifiable>())); | ||
} | ||
const auto& ipMax = context.getReader().getAttributeValue<double>(IP_MAX); | ||
const auto& ipMin = context.getReader().getOptionalAttributeValue(IP_MIN, stdcxx::nan()); | ||
extendable.newExtension<IdentifiableShortCircuitAdder>() | ||
.withIpMax(ipMax) | ||
.withIpMin(ipMin) | ||
.add(); | ||
return extendable.getExtension<IdentifiableShortCircuit>(); | ||
} | ||
|
||
void IdentifiableShortCircuitXmlSerializer::write(const Extension& extension, converter::xml::NetworkXmlWriterContext& context) const { | ||
const auto& isc = safeCast<IdentifiableShortCircuit>(extension); | ||
context.getWriter().writeAttribute(IP_MAX, isc.getIpMax()); | ||
context.getWriter().writeAttribute(IP_MIN, isc.getIpMin()); | ||
} | ||
|
||
} // namespace iidm | ||
|
||
} // namespace extensions | ||
|
||
} // namespace iidm | ||
|
||
} // namespace powsybl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters