From 92fdb79195e4d3d4256014cb66b07e6ab0292da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Laigre?= Date: Tue, 21 Jul 2020 18:30:09 +0200 Subject: [PATCH] [IIDM V1.2] Add getNameOrId() and getOptionalName() into Identifiable (#124) (#142) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sébastien LAIGRE Signed-off-by: Mathieu BAGUE --- include/powsybl/iidm/Identifiable.hpp | 4 ++- src/iidm/BusBreakerVoltageLevelTopology.cpp | 2 +- src/iidm/Identifiable.cpp | 6 +++- ...deBreakerVoltageLevelBusNamingStrategy.cpp | 4 +-- .../converter/xml/AbstractIdentifiableXml.hxx | 5 +-- test/iidm/BatteryTest.cpp | 2 +- test/iidm/BusBreakerVoltageLevelTest.cpp | 10 +++--- test/iidm/DanglingLineTest.cpp | 8 +---- test/iidm/GeneratorTest.cpp | 3 +- test/iidm/HvdcLineTest.cpp | 9 ++--- test/iidm/LccConverterStationTest.cpp | 3 +- test/iidm/LineTest.cpp | 3 +- test/iidm/LoadTest.cpp | 2 +- test/iidm/NetworkTest.cpp | 2 +- test/iidm/NodeBreakerVoltageLevelTest.cpp | 15 ++++---- test/iidm/ShuntCompensatorTest.cpp | 8 +---- test/iidm/StaticVarCompensatorTest.cpp | 2 +- test/iidm/SubstationTest.cpp | 2 +- test/iidm/ThreeWindingsTransformerTest.cpp | 2 +- test/iidm/TieLineTest.cpp | 2 +- test/iidm/TwoWindingsTransformerTest.cpp | 2 +- test/iidm/VoltageLevelTest.cpp | 2 +- test/iidm/VscConverterStationTest.cpp | 11 ++---- test/network/EurostagFactoryTest.cpp | 35 +++++++++++-------- 24 files changed, 68 insertions(+), 76 deletions(-) diff --git a/include/powsybl/iidm/Identifiable.hpp b/include/powsybl/iidm/Identifiable.hpp index 802013bb8..1c0dcb94a 100644 --- a/include/powsybl/iidm/Identifiable.hpp +++ b/include/powsybl/iidm/Identifiable.hpp @@ -39,12 +39,14 @@ class Identifiable : public virtual Validable, public Extendable { const std::string& getId() const; - const std::string& getName() const; + const std::string& getNameOrId() const; virtual const Network& getNetwork() const = 0; virtual Network& getNetwork() = 0; + const std::string& getOptionalName() const; + bool hasProperty() const; bool hasProperty(const std::string& key) const; diff --git a/src/iidm/BusBreakerVoltageLevelTopology.cpp b/src/iidm/BusBreakerVoltageLevelTopology.cpp index 4031b318a..5583477b3 100644 --- a/src/iidm/BusBreakerVoltageLevelTopology.cpp +++ b/src/iidm/BusBreakerVoltageLevelTopology.cpp @@ -29,7 +29,7 @@ CalculatedBusTopology::CalculatedBusTopology(BusBreakerVoltageLevel& voltageLeve std::unique_ptr CalculatedBusTopology::createMergedBus(unsigned long busCount, const MergedBus::BusSet& busSet) const { const std::string& mergedBusId = stdcxx::format("%1%_%2%", m_voltageLevel.getId(), busCount); - const std::string& mergedBusName = m_voltageLevel.getName().empty() ? "" : stdcxx::format("%1%_%2%", m_voltageLevel.getName(), busCount); + const std::string& mergedBusName = m_voltageLevel.getOptionalName().empty() ? "" : stdcxx::format("%1%_%2%", m_voltageLevel.getOptionalName(), busCount); return stdcxx::make_unique(mergedBusId, mergedBusName, busSet); } diff --git a/src/iidm/Identifiable.cpp b/src/iidm/Identifiable.cpp index fb7447893..6613487c6 100644 --- a/src/iidm/Identifiable.cpp +++ b/src/iidm/Identifiable.cpp @@ -44,10 +44,14 @@ std::string Identifiable::getMessageHeader() const { return getTypeDescription() + " '" + m_id + "': "; } -const std::string& Identifiable::getName() const { +const std::string& Identifiable::getNameOrId() const { return m_name.empty() ? m_id : m_name; } +const std::string& Identifiable::getOptionalName() const { + return m_name; +} + const std::string& Identifiable::getProperty(const std::string& key) const { return m_properties.get(key); } diff --git a/src/iidm/NodeBreakerVoltageLevelBusNamingStrategy.cpp b/src/iidm/NodeBreakerVoltageLevelBusNamingStrategy.cpp index 0c4d3a116..1dd7de6db 100644 --- a/src/iidm/NodeBreakerVoltageLevelBusNamingStrategy.cpp +++ b/src/iidm/NodeBreakerVoltageLevelBusNamingStrategy.cpp @@ -27,9 +27,9 @@ std::string BusNamingStrategy::getId(const std::vector& nodes) { } std::string BusNamingStrategy::getName(const std::vector& nodes) { - if (!m_voltageLevel.getName().empty()) { + if (!m_voltageLevel.getOptionalName().empty()) { const auto& iter = std::min_element(nodes.cbegin(), nodes.cend()); - return stdcxx::format("%1%_%2%", m_voltageLevel.getName(), *iter); + return stdcxx::format("%1%_%2%", m_voltageLevel.getOptionalName(), *iter); } return ""; diff --git a/src/iidm/converter/xml/AbstractIdentifiableXml.hxx b/src/iidm/converter/xml/AbstractIdentifiableXml.hxx index cdc1d601f..6a41aebe9 100644 --- a/src/iidm/converter/xml/AbstractIdentifiableXml.hxx +++ b/src/iidm/converter/xml/AbstractIdentifiableXml.hxx @@ -50,8 +50,9 @@ void AbstractIdentifiableXml::write(const Added& identifia context.getWriter().writeStartElement(context.getVersion().getPrefix(), getRootElementName()); context.getWriter().writeAttribute(ID, context.getAnonymizer().anonymizeString(identifiable.getId())); - if (identifiable.getId() != identifiable.getName()) { - context.getWriter().writeAttribute(NAME, context.getAnonymizer().anonymizeString(identifiable.getName())); + const auto& name = identifiable.getOptionalName(); + if (!name.empty()) { + context.getWriter().writeAttribute(NAME, context.getAnonymizer().anonymizeString(name)); } writeRootElementAttributes(identifiable, parent, context); diff --git a/test/iidm/BatteryTest.cpp b/test/iidm/BatteryTest.cpp index 94d43e774..f9765015c 100644 --- a/test/iidm/BatteryTest.cpp +++ b/test/iidm/BatteryTest.cpp @@ -109,7 +109,7 @@ BOOST_AUTO_TEST_CASE(constructor) { const Battery& battery = network.getBattery("BAT1"); BOOST_CHECK_EQUAL("BAT1", battery.getId()); - BOOST_CHECK_EQUAL("BAT1_NAME", battery.getName()); + BOOST_CHECK_EQUAL("BAT1_NAME", battery.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::BATTERY, battery.getType()); std::ostringstream oss; oss << battery.getType(); diff --git a/test/iidm/BusBreakerVoltageLevelTest.cpp b/test/iidm/BusBreakerVoltageLevelTest.cpp index c684df47f..dccfab0cd 100644 --- a/test/iidm/BusBreakerVoltageLevelTest.cpp +++ b/test/iidm/BusBreakerVoltageLevelTest.cpp @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(BusTest) { const auto& cBus = bus; BOOST_CHECK_EQUAL("BUS", bus.getId()); - BOOST_CHECK_EQUAL("BUS_NAME", bus.getName()); + BOOST_CHECK_EQUAL("BUS_NAME", bus.getOptionalName()); BOOST_TEST(stdcxx::areSame(voltageLevel, bus.getVoltageLevel())); BOOST_TEST(stdcxx::areSame(voltageLevel, cBus.getVoltageLevel())); BOOST_CHECK_EQUAL(0UL, bus.getConnectedTerminalCount()); @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(SwitchTest) { swAdder.setBus2("BUS2"); Switch& aSwitch = swAdder.add(); BOOST_CHECK_EQUAL("SW", aSwitch.getId()); - BOOST_CHECK_EQUAL("SW_NAME", aSwitch.getName()); + BOOST_CHECK_EQUAL("SW_NAME", aSwitch.getOptionalName()); BOOST_TEST(stdcxx::areSame(voltageLevel, aSwitch.getVoltageLevel())); BOOST_TEST(!aSwitch.isFictitious()); BOOST_TEST(!aSwitch.isOpen()); @@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(CalculatedBusTopologyTest) { stdcxx::Reference mergedBus2 = vl.getBusView().getMergedBus("BUS2"); BOOST_TEST(stdcxx::areSame(mergedBus1.get(), mergedBus2.get())); BOOST_CHECK_EQUAL("VL_0", mergedBus1.get().getId()); - BOOST_CHECK_EQUAL("VL_0", mergedBus1.get().getName()); + BOOST_CHECK(mergedBus1.get().getOptionalName().empty()); sw.setOpen(true); VoltageLevel& vlTest = vl; @@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(TerminalTest) { busBreakerView.setConnectableBus("BUS1"); const auto& configuredBus = busBreakerView.getBus().get(); BOOST_CHECK_EQUAL("BUS1", configuredBus.getId()); - BOOST_CHECK_EQUAL("BUS1_NAME", configuredBus.getName()); + BOOST_CHECK_EQUAL("BUS1_NAME", configuredBus.getOptionalName()); const auto& cConfiguredBus = cBusBreakerView.getBus().get(); BOOST_TEST(stdcxx::areSame(configuredBus, cConfiguredBus)); @@ -479,7 +479,7 @@ BOOST_AUTO_TEST_CASE(TerminalTest) { POWSYBL_ASSERT_REF_TRUE(cTerminal.getBusView().getBus()); const auto& mergedBus = terminal.getBusView().getBus().get(); BOOST_CHECK_EQUAL("VL_0", mergedBus.getId()); - BOOST_CHECK_EQUAL("VL_0", mergedBus.getName()); + BOOST_CHECK(mergedBus.getOptionalName().empty()); POWSYBL_ASSERT_THROW(terminal.getNodeBreakerView(), AssertionError, "Not implemented"); POWSYBL_ASSERT_THROW(cTerminal.getNodeBreakerView(), AssertionError, "Not implemented"); diff --git a/test/iidm/DanglingLineTest.cpp b/test/iidm/DanglingLineTest.cpp index b0393b97d..c8ab8d8c8 100644 --- a/test/iidm/DanglingLineTest.cpp +++ b/test/iidm/DanglingLineTest.cpp @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(constructor) { const DanglingLine& danglingLine = network.getDanglingLine("DL1"); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); + BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::DANGLING_LINE, danglingLine.getType()); std::ostringstream oss; oss << danglingLine.getType(); @@ -160,7 +160,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s1"); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); BOOST_CHECK_CLOSE(1.0, danglingLine.getB(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(2.0, danglingLine.getG(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(3.0, danglingLine.getP0(), std::numeric_limits::epsilon()); @@ -171,7 +170,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { danglingLine.setB(100.0).setG(200.0).setP0(300.0).setQ0(400).setR(500.0).setX(600.0); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); BOOST_CHECK_CLOSE(100.0, danglingLine.getB(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(200.0, danglingLine.getG(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(300.0, danglingLine.getP0(), std::numeric_limits::epsilon()); @@ -182,7 +180,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s2"); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); BOOST_CHECK_CLOSE(100.0, danglingLine.getB(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(200.0, danglingLine.getG(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(3.0, danglingLine.getP0(), std::numeric_limits::epsilon()); @@ -192,7 +189,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { danglingLine.setB(150.0).setG(250.0).setP0(350.0).setQ0(450).setR(550.0).setX(650.0); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); BOOST_CHECK_CLOSE(150.0, danglingLine.getB(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(250.0, danglingLine.getG(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(350.0, danglingLine.getP0(), std::numeric_limits::epsilon()); @@ -202,7 +198,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant(VariantManager::getInitialVariantId()); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); BOOST_CHECK_CLOSE(150.0, danglingLine.getB(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(250.0, danglingLine.getG(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(3.0, danglingLine.getP0(), std::numeric_limits::epsilon()); @@ -216,7 +211,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().cloneVariant("s2", "s3"); network.getVariantManager().setWorkingVariant("s3"); BOOST_CHECK_EQUAL("DL1", danglingLine.getId()); - BOOST_CHECK_EQUAL("DL1_NAME", danglingLine.getName()); BOOST_CHECK_CLOSE(150.0, danglingLine.getB(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(250.0, danglingLine.getG(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(350.0, danglingLine.getP0(), std::numeric_limits::epsilon()); diff --git a/test/iidm/GeneratorTest.cpp b/test/iidm/GeneratorTest.cpp index 3593b2c46..a6ccf67a3 100644 --- a/test/iidm/GeneratorTest.cpp +++ b/test/iidm/GeneratorTest.cpp @@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(integrity) { Generator& gen = network.getGenerator("GEN1"); BOOST_CHECK_EQUAL("GEN1", gen.getId()); - BOOST_CHECK_EQUAL("GEN1_NAME", gen.getName()); + BOOST_CHECK_EQUAL("GEN1_NAME", gen.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::GENERATOR, gen.getType()); std::ostringstream oss; oss << gen.getType(); @@ -298,7 +298,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s1"); BOOST_CHECK_EQUAL("GEN1", gen.getId()); - BOOST_CHECK_EQUAL("GEN1_NAME", gen.getName()); BOOST_CHECK_CLOSE(45, gen.getActivePowerSetpoint(), std::numeric_limits::epsilon()); POWSYBL_ASSERT_ENUM_EQ(EnergySource::WIND, gen.getEnergySource()); BOOST_CHECK_CLOSE(50.0, gen.getMaxP(), std::numeric_limits::epsilon()); diff --git a/test/iidm/HvdcLineTest.cpp b/test/iidm/HvdcLineTest.cpp index ae99a1e5b..04c31097f 100644 --- a/test/iidm/HvdcLineTest.cpp +++ b/test/iidm/HvdcLineTest.cpp @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(constructor) { const HvdcLine& hvdc = network.getHvdcLine("HVDC1"); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); + BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getOptionalName()); BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); @@ -246,7 +246,7 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s1"); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); + BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getOptionalName()); BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); @@ -257,7 +257,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { hvdc.setActivePowerSetpoint(100.0).setR(200.0).setMaxP(300.0).setConvertersMode(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER).setNominalVoltage(400.0); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); BOOST_CHECK_CLOSE(100.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); @@ -268,7 +267,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s2"); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); @@ -279,7 +277,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { hvdc.setActivePowerSetpoint(150.0).setR(250.0).setMaxP(350.0).setConvertersMode(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER).setNominalVoltage(450.0); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); BOOST_CHECK_CLOSE(150.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); @@ -290,7 +287,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant(VariantManager::getInitialVariantId()); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); BOOST_CHECK_CLOSE(11.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_RECTIFIER_SIDE_2_INVERTER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); @@ -305,7 +301,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().cloneVariant("s2", "s3"); network.getVariantManager().setWorkingVariant("s3"); BOOST_CHECK_EQUAL("HVDC1", hvdc.getId()); - BOOST_CHECK_EQUAL("HVDC1_NAME", hvdc.getName()); BOOST_CHECK_CLOSE(150.0, hvdc.getActivePowerSetpoint(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(HvdcLine::ConvertersMode::SIDE_1_INVERTER_SIDE_2_RECTIFIER, hvdc.getConvertersMode()); BOOST_CHECK_EQUAL("LCC1", hvdc.getConverterStation1().get().getId()); diff --git a/test/iidm/LccConverterStationTest.cpp b/test/iidm/LccConverterStationTest.cpp index 7f6b13afa..7a8a2387c 100644 --- a/test/iidm/LccConverterStationTest.cpp +++ b/test/iidm/LccConverterStationTest.cpp @@ -57,8 +57,7 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_TEST(stdcxx::areSame(lcc, hvdc)); BOOST_CHECK_EQUAL("LCC1", lcc.getId()); BOOST_CHECK_EQUAL(lcc.getId(), hvdc.getId()); - BOOST_CHECK_EQUAL("LCC1_NAME", lcc.getName()); - BOOST_CHECK_EQUAL(lcc.getName(), hvdc.getName()); + BOOST_CHECK_EQUAL("LCC1_NAME", lcc.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::HVDC_CONVERTER_STATION, lcc.getType()); std::ostringstream oss; oss << lcc.getType(); diff --git a/test/iidm/LineTest.cpp b/test/iidm/LineTest.cpp index cc54f139a..7fb3aa130 100644 --- a/test/iidm/LineTest.cpp +++ b/test/iidm/LineTest.cpp @@ -120,7 +120,8 @@ BOOST_AUTO_TEST_CASE(constructor) { const Line& line = network.getLine("VL1_VL3"); BOOST_CHECK_EQUAL("VL1_VL3", line.getId()); - BOOST_CHECK_EQUAL("VL1_VL3", line.getName()); + BOOST_CHECK(line.getOptionalName().empty()); + BOOST_CHECK_EQUAL("VL1_VL3", line.getNameOrId()); BOOST_CHECK_EQUAL(ConnectableType::LINE, line.getType()); std::ostringstream oss; oss << line.getType(); diff --git a/test/iidm/LoadTest.cpp b/test/iidm/LoadTest.cpp index 0c14fa706..96f28f464 100644 --- a/test/iidm/LoadTest.cpp +++ b/test/iidm/LoadTest.cpp @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(constructor) { Load& load = network.getLoad("LOAD1"); BOOST_CHECK_EQUAL("LOAD1", load.getId()); - BOOST_CHECK_EQUAL("LOAD1_NAME", load.getName()); + BOOST_CHECK_EQUAL("LOAD1_NAME", load.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::LOAD, load.getType()); std::ostringstream oss; oss << load.getType(); diff --git a/test/iidm/NetworkTest.cpp b/test/iidm/NetworkTest.cpp index 8bb46c727..9357d2197 100644 --- a/test/iidm/NetworkTest.cpp +++ b/test/iidm/NetworkTest.cpp @@ -317,7 +317,7 @@ BOOST_AUTO_TEST_CASE(constructor) { Network network("id", "sourceFormat"); BOOST_CHECK_EQUAL("id", network.getId()); - BOOST_CHECK_EQUAL("id", network.getName()); + BOOST_CHECK_EQUAL("id", network.getOptionalName()); BOOST_CHECK_EQUAL("sourceFormat", network.getSourceFormat()); BOOST_CHECK_EQUAL(0, network.getForecastDistance()); diff --git a/test/iidm/NodeBreakerVoltageLevelTest.cpp b/test/iidm/NodeBreakerVoltageLevelTest.cpp index 07de4f055..b78735d7c 100644 --- a/test/iidm/NodeBreakerVoltageLevelTest.cpp +++ b/test/iidm/NodeBreakerVoltageLevelTest.cpp @@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(busbarSection) { .add(); BOOST_CHECK_EQUAL("BBS", bbs.getId()); - BOOST_CHECK_EQUAL("BBS_NAME", bbs.getName()); + BOOST_CHECK_EQUAL("BBS_NAME", bbs.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::BUSBAR_SECTION, bbs.getType()); std::ostringstream oss; oss << bbs.getType(); @@ -245,7 +245,7 @@ BOOST_AUTO_TEST_CASE(switches) { .add(); BOOST_CHECK_EQUAL("BK", breaker.getId()); - BOOST_CHECK_EQUAL("BK_NAME", breaker.getName()); + BOOST_CHECK_EQUAL("BK_NAME", breaker.getOptionalName()); POWSYBL_ASSERT_ENUM_EQ(SwitchKind::BREAKER, breaker.getKind()); BOOST_TEST(!breaker.isOpen()); BOOST_TEST(breaker.isRetained()); @@ -531,7 +531,8 @@ BOOST_AUTO_TEST_CASE(calculatedBusBreakerTopology) { auto& testBus = busBreakerView.getBus("VL_0").get(); const auto& cTestBus = testBus; BOOST_CHECK_EQUAL("VL_0", testBus.getId()); - BOOST_CHECK_EQUAL("VL_0", testBus.getName()); + BOOST_CHECK(testBus.getOptionalName().empty()); + BOOST_CHECK_EQUAL("VL_0", testBus.getNameOrId()); BOOST_CHECK_CLOSE(7.7, testBus.setAngle(7.7).setV(8.8).getAngle(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(8.8, testBus.getV(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(2UL, testBus.getConnectedTerminalCount()); @@ -685,7 +686,7 @@ BOOST_AUTO_TEST_CASE(CalculatedBusTopology) { POWSYBL_ASSERT_REF_TRUE(cBusView.getMergedBus("BBS")); const auto& calculatedBus = busView.getBus("VL_0").get(); BOOST_CHECK_EQUAL("VL_0", calculatedBus.getId()); - BOOST_CHECK_EQUAL("VL_0", calculatedBus.getName()); + BOOST_CHECK(calculatedBus.getOptionalName().empty()); sw.setOpen(true); BOOST_CHECK_EQUAL(2UL, boost::size(busView.getBuses())); @@ -986,7 +987,8 @@ BOOST_AUTO_TEST_CASE(TerminalTest) { BOOST_TEST(stdcxx::areSame(cBusBreakerView.getBus().get(), cBusBreakerView.getConnectableBus().get())); const auto& calculatedBus = busBreakerView.getBus().get(); BOOST_CHECK_EQUAL("VL_0", calculatedBus.getId()); - BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getName()); + BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getOptionalName()); + BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getNameOrId()); POWSYBL_ASSERT_THROW(busBreakerView.setConnectableBus("BUS1"), AssertionError, "Not implemented"); @@ -998,7 +1000,8 @@ BOOST_AUTO_TEST_CASE(TerminalTest) { BOOST_TEST(stdcxx::areSame(cBusView.getBus().get(), cBusView.getConnectableBus().get())); const auto& calculatedBus2 = busView.getBus().get(); BOOST_CHECK_EQUAL("VL_0", calculatedBus2.getId()); - BOOST_CHECK_EQUAL("VL_name_0", calculatedBus2.getName()); + BOOST_CHECK_EQUAL("VL_name_0", calculatedBus2.getOptionalName()); + BOOST_CHECK_EQUAL("VL_name_0", calculatedBus.getNameOrId()); BOOST_TEST(stdcxx::areSame(terminal.getNodeBreakerView(), cTerminal.getNodeBreakerView())); BOOST_CHECK_EQUAL(2UL, terminal.getNodeBreakerView().getNode()); diff --git a/test/iidm/ShuntCompensatorTest.cpp b/test/iidm/ShuntCompensatorTest.cpp index e47fc77ff..df0908d1c 100644 --- a/test/iidm/ShuntCompensatorTest.cpp +++ b/test/iidm/ShuntCompensatorTest.cpp @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(constructor) { ShuntCompensator& shunt = network.getShuntCompensator("SHUNT1"); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); + BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::SHUNT_COMPENSATOR, shunt.getType()); std::ostringstream oss; oss << shunt.getType(); @@ -248,7 +248,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s1"); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); BOOST_CHECK_CLOSE(12.0, shunt.getbPerSection(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(2UL, shunt.getCurrentSectionCount()); BOOST_CHECK_EQUAL(3UL, shunt.getMaximumSectionCount()); @@ -257,7 +256,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { shunt.setbPerSection(100.0).setMaximumSectionCount(300UL).setCurrentSectionCount(200UL); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); BOOST_CHECK_CLOSE(100.0, shunt.getbPerSection(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(200UL, shunt.getCurrentSectionCount()); BOOST_CHECK_EQUAL(300UL, shunt.getMaximumSectionCount()); @@ -266,7 +264,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s2"); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); BOOST_CHECK_CLOSE(100.0, shunt.getbPerSection(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(2UL, shunt.getCurrentSectionCount()); BOOST_CHECK_EQUAL(300UL, shunt.getMaximumSectionCount()); @@ -275,7 +272,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { shunt.setbPerSection(150.0).setMaximumSectionCount(350UL).setCurrentSectionCount(250UL); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); BOOST_CHECK_CLOSE(150.0, shunt.getbPerSection(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(250UL, shunt.getCurrentSectionCount()); BOOST_CHECK_EQUAL(350UL, shunt.getMaximumSectionCount()); @@ -284,7 +280,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant(VariantManager::getInitialVariantId()); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); BOOST_CHECK_CLOSE(150.0, shunt.getbPerSection(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(2UL, shunt.getCurrentSectionCount()); BOOST_CHECK_EQUAL(350UL, shunt.getMaximumSectionCount()); @@ -297,7 +292,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().cloneVariant("s2", "s3"); network.getVariantManager().setWorkingVariant("s3"); BOOST_CHECK_EQUAL("SHUNT1", shunt.getId()); - BOOST_CHECK_EQUAL("SHUNT1_NAME", shunt.getName()); BOOST_CHECK_CLOSE(150.0, shunt.getbPerSection(), std::numeric_limits::epsilon()); BOOST_CHECK_EQUAL(250UL, shunt.getCurrentSectionCount()); BOOST_CHECK_EQUAL(350UL, shunt.getMaximumSectionCount()); diff --git a/test/iidm/StaticVarCompensatorTest.cpp b/test/iidm/StaticVarCompensatorTest.cpp index 9dae1685b..a58f2815a 100644 --- a/test/iidm/StaticVarCompensatorTest.cpp +++ b/test/iidm/StaticVarCompensatorTest.cpp @@ -183,7 +183,7 @@ BOOST_AUTO_TEST_CASE(constructor) { const StaticVarCompensator& svc = network.getStaticVarCompensator("SVC1"); BOOST_CHECK_EQUAL("SVC1", svc.getId()); - BOOST_CHECK_EQUAL("SVC1_NAME", svc.getName()); + BOOST_CHECK_EQUAL("SVC1_NAME", svc.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::STATIC_VAR_COMPENSATOR, svc.getType()); std::ostringstream oss; oss << svc.getType(); diff --git a/test/iidm/SubstationTest.cpp b/test/iidm/SubstationTest.cpp index 3703b0823..41fae4bf8 100644 --- a/test/iidm/SubstationTest.cpp +++ b/test/iidm/SubstationTest.cpp @@ -156,7 +156,7 @@ BOOST_AUTO_TEST_CASE(constructor) { const Substation& substation = network.getSubstation("S1"); BOOST_CHECK_EQUAL("S1", substation.getId()); - BOOST_CHECK_EQUAL("S1_NAME", substation.getName()); + BOOST_CHECK_EQUAL("S1_NAME", substation.getOptionalName()); POWSYBL_ASSERT_ENUM_EQ(Country::FR, *substation.getCountry()); BOOST_CHECK_EQUAL("TSO", substation.getTso()); } diff --git a/test/iidm/ThreeWindingsTransformerTest.cpp b/test/iidm/ThreeWindingsTransformerTest.cpp index 222a28a9b..8b73de539 100644 --- a/test/iidm/ThreeWindingsTransformerTest.cpp +++ b/test/iidm/ThreeWindingsTransformerTest.cpp @@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_TEST(stdcxx::areSame(cTransformer, transformer)); BOOST_CHECK_EQUAL("3WT_VL1_VL2_VL3", transformer.getId()); - BOOST_CHECK_EQUAL("3WT_VL1_VL2_VL3_NAME", transformer.getName()); + BOOST_CHECK_EQUAL("3WT_VL1_VL2_VL3_NAME", transformer.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::THREE_WINDINGS_TRANSFORMER, transformer.getType()); std::ostringstream oss; oss << transformer.getType(); diff --git a/test/iidm/TieLineTest.cpp b/test/iidm/TieLineTest.cpp index 2607e27f1..a24cabe97 100644 --- a/test/iidm/TieLineTest.cpp +++ b/test/iidm/TieLineTest.cpp @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(constructor) { const TieLine& tieLine = dynamic_cast(network.getLine("TL_VL1_VL3")); BOOST_CHECK_EQUAL("TL_VL1_VL3", tieLine.getId()); - BOOST_CHECK_EQUAL("TL_VL1_VL3", tieLine.getName()); + BOOST_CHECK(tieLine.getOptionalName().empty()); BOOST_CHECK_EQUAL(ConnectableType::LINE, tieLine.getType()); std::ostringstream oss; oss << tieLine.getType(); diff --git a/test/iidm/TwoWindingsTransformerTest.cpp b/test/iidm/TwoWindingsTransformerTest.cpp index 353108617..50ca00020 100644 --- a/test/iidm/TwoWindingsTransformerTest.cpp +++ b/test/iidm/TwoWindingsTransformerTest.cpp @@ -228,7 +228,7 @@ BOOST_AUTO_TEST_CASE(constructor) { TwoWindingsTransformer& transformer = network.getTwoWindingsTransformer("2WT_VL1_VL2"); BOOST_CHECK_EQUAL("2WT_VL1_VL2", transformer.getId()); - BOOST_CHECK_EQUAL("2WT_VL1_VL2", transformer.getName()); + BOOST_CHECK(transformer.getOptionalName().empty()); BOOST_CHECK_EQUAL(ConnectableType::TWO_WINDINGS_TRANSFORMER, transformer.getType()); std::ostringstream oss; oss << transformer.getType(); diff --git a/test/iidm/VoltageLevelTest.cpp b/test/iidm/VoltageLevelTest.cpp index 5df96b7e9..4994d3bb9 100644 --- a/test/iidm/VoltageLevelTest.cpp +++ b/test/iidm/VoltageLevelTest.cpp @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(constructor) { VoltageLevel& vl1 = network.getVoltageLevel("VL1"); BOOST_CHECK_EQUAL("VL1", vl1.getId()); - BOOST_CHECK_EQUAL("VL1_NAME", vl1.getName()); + BOOST_CHECK_EQUAL("VL1_NAME", vl1.getOptionalName()); BOOST_CHECK_EQUAL(TopologyKind::BUS_BREAKER, vl1.getTopologyKind()); BOOST_CHECK_CLOSE(340, vl1.getLowVoltageLimit(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(420, vl1.getHighVoltageLimit(), std::numeric_limits::epsilon()); diff --git a/test/iidm/VscConverterStationTest.cpp b/test/iidm/VscConverterStationTest.cpp index e412ce353..1e7d45765 100644 --- a/test/iidm/VscConverterStationTest.cpp +++ b/test/iidm/VscConverterStationTest.cpp @@ -70,8 +70,8 @@ BOOST_AUTO_TEST_CASE(constructor) { BOOST_TEST(stdcxx::areSame(vsc, hvdc)); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); BOOST_CHECK_EQUAL(vsc.getId(), hvdc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); - BOOST_CHECK_EQUAL(vsc.getName(), hvdc.getName()); + BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getOptionalName()); + BOOST_CHECK_EQUAL(vsc.getOptionalName(), hvdc.getOptionalName()); BOOST_CHECK_EQUAL(ConnectableType::HVDC_CONVERTER_STATION, vsc.getType()); std::ostringstream oss; oss << vsc.getType(); @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s1"); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); + BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getOptionalName()); POWSYBL_ASSERT_ENUM_EQ(HvdcConverterStation::HvdcType::VSC, vsc.getHvdcType()); BOOST_CHECK_CLOSE(3.0, vsc.getLossFactor(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(4.0, vsc.getVoltageSetpoint(), std::numeric_limits::epsilon()); @@ -143,7 +143,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { vsc.setLossFactor(100.0).setVoltageSetpoint(200.0).setReactivePowerSetpoint(300.0).setVoltageRegulatorOn(false); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); POWSYBL_ASSERT_ENUM_EQ(HvdcConverterStation::HvdcType::VSC, vsc.getHvdcType()); BOOST_CHECK_CLOSE(100.0, vsc.getLossFactor(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(200.0, vsc.getVoltageSetpoint(), std::numeric_limits::epsilon()); @@ -152,7 +151,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant("s2"); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); POWSYBL_ASSERT_ENUM_EQ(HvdcConverterStation::HvdcType::VSC, vsc.getHvdcType()); BOOST_CHECK_CLOSE(100.0, vsc.getLossFactor(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(4.0, vsc.getVoltageSetpoint(), std::numeric_limits::epsilon()); @@ -161,7 +159,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { vsc.setLossFactor(150.0).setVoltageSetpoint(250.0).setReactivePowerSetpoint(350.0).setVoltageRegulatorOn(false); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); POWSYBL_ASSERT_ENUM_EQ(HvdcConverterStation::HvdcType::VSC, vsc.getHvdcType()); BOOST_CHECK_CLOSE(150.0, vsc.getLossFactor(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(250.0, vsc.getVoltageSetpoint(), std::numeric_limits::epsilon()); @@ -170,7 +167,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().setWorkingVariant(VariantManager::getInitialVariantId()); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); POWSYBL_ASSERT_ENUM_EQ(HvdcConverterStation::HvdcType::VSC, vsc.getHvdcType()); BOOST_CHECK_CLOSE(150.0, vsc.getLossFactor(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(4.0, vsc.getVoltageSetpoint(), std::numeric_limits::epsilon()); @@ -183,7 +179,6 @@ BOOST_AUTO_TEST_CASE(multivariant) { network.getVariantManager().cloneVariant("s2", "s3"); network.getVariantManager().setWorkingVariant("s3"); BOOST_CHECK_EQUAL("VSC1", vsc.getId()); - BOOST_CHECK_EQUAL("VSC1_NAME", vsc.getName()); POWSYBL_ASSERT_ENUM_EQ(HvdcConverterStation::HvdcType::VSC, vsc.getHvdcType()); BOOST_CHECK_CLOSE(150.0, vsc.getLossFactor(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(250.0, vsc.getVoltageSetpoint(), std::numeric_limits::epsilon()); diff --git a/test/network/EurostagFactoryTest.cpp b/test/network/EurostagFactoryTest.cpp index db90ea03a..c84604d33 100644 --- a/test/network/EurostagFactoryTest.cpp +++ b/test/network/EurostagFactoryTest.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE(EurostagFactoryTestSuite) BOOST_AUTO_TEST_CASE(createTutorial1NetworkTest) { const iidm::Network& network = EurostagFactory::createTutorial1Network(); BOOST_CHECK_EQUAL("sim1", network.getId()); - BOOST_CHECK_EQUAL("sim1", network.getName()); + BOOST_CHECK_EQUAL("sim1", network.getOptionalName()); BOOST_CHECK_EQUAL("test", network.getSourceFormat()); BOOST_CHECK_EQUAL(0, network.getForecastDistance()); @@ -127,7 +127,8 @@ BOOST_AUTO_TEST_CASE(createTutorial1NetworkTest) { BOOST_TEST(std::isnan(nload.getV())); const auto& line1 = network.getLine("NHV1_NHV2_1"); - BOOST_CHECK_EQUAL("NHV1_NHV2_1", line1.getName()); + BOOST_CHECK(line1.getOptionalName().empty()); + BOOST_CHECK_EQUAL("NHV1_NHV2_1", line1.getNameOrId()); BOOST_TEST(!line1.isTieLine()); BOOST_CHECK_CLOSE(3.0, line1.getR(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(33.0, line1.getX(), std::numeric_limits::epsilon()); @@ -142,7 +143,8 @@ BOOST_AUTO_TEST_CASE(createTutorial1NetworkTest) { BOOST_TEST(!line1.isOverloaded()); const auto& line2 = network.getLine("NHV1_NHV2_2"); - BOOST_CHECK_EQUAL("NHV1_NHV2_2", line2.getName()); + BOOST_CHECK(line2.getOptionalName().empty()); + BOOST_CHECK_EQUAL("NHV1_NHV2_2", line2.getNameOrId()); BOOST_TEST(!line2.isTieLine()); BOOST_CHECK_CLOSE(3.0, line2.getR(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(33.0, line2.getX(), std::numeric_limits::epsilon()); @@ -157,7 +159,8 @@ BOOST_AUTO_TEST_CASE(createTutorial1NetworkTest) { BOOST_TEST(!line2.isOverloaded()); const auto& transfo1 = network.getTwoWindingsTransformer("NGEN_NHV1"); - BOOST_CHECK_EQUAL("NGEN_NHV1", transfo1.getName()); + BOOST_CHECK(transfo1.getOptionalName().empty()); + BOOST_CHECK_EQUAL("NGEN_NHV1", transfo1.getNameOrId()); BOOST_CHECK_CLOSE(24.0, transfo1.getRatedU1(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(400.0, transfo1.getRatedU2(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(0.24 / 1300.0 * (380.0 * 380.0 / 100.0), transfo1.getR(), std::numeric_limits::epsilon()); @@ -173,7 +176,8 @@ BOOST_AUTO_TEST_CASE(createTutorial1NetworkTest) { BOOST_TEST(!transfo1.isOverloaded()); const auto& transfo2 = network.getTwoWindingsTransformer("NHV2_NLOAD"); - BOOST_CHECK_EQUAL("NHV2_NLOAD", transfo2.getName()); + BOOST_CHECK(transfo2.getOptionalName().empty()); + BOOST_CHECK_EQUAL("NHV2_NLOAD", transfo2.getNameOrId()); BOOST_CHECK_CLOSE(400.0, transfo2.getRatedU1(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(158.0, transfo2.getRatedU2(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(0.21 / 1000 * (150.0 * 150.0 / 100.0), transfo2.getR(), std::numeric_limits::epsilon()); @@ -217,13 +221,15 @@ BOOST_AUTO_TEST_CASE(createTutorial1NetworkTest) { BOOST_CHECK_CLOSE(0.0, step.getB(), std::numeric_limits::epsilon()); const auto& load = network.getLoad("LOAD"); - BOOST_CHECK_EQUAL("LOAD", load.getName()); + BOOST_CHECK(load.getOptionalName().empty()); + BOOST_CHECK_EQUAL("LOAD", load.getNameOrId()); BOOST_CHECK_EQUAL(iidm::LoadType::UNDEFINED, load.getLoadType()); BOOST_CHECK_CLOSE(600.0, load.getP0(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(200.0, load.getQ0(), std::numeric_limits::epsilon()); const auto& gen = network.getGenerator("GEN"); - BOOST_CHECK_EQUAL("GEN", gen.getName()); + BOOST_CHECK(gen.getOptionalName().empty()); + BOOST_CHECK_EQUAL("GEN", gen.getNameOrId()); POWSYBL_ASSERT_ENUM_EQ(iidm::EnergySource::OTHER, gen.getEnergySource()); BOOST_TEST(std::isnan(gen.getRatedS())); BOOST_CHECK_CLOSE(-9999.99, gen.getMinP(), std::numeric_limits::epsilon()); @@ -248,7 +254,6 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { const iidm::Network& network = EurostagFactory::createWithCurrentLimits(); BOOST_CHECK_EQUAL("sim1", network.getId()); - BOOST_CHECK_EQUAL("sim1", network.getName()); BOOST_CHECK_EQUAL("test", network.getSourceFormat()); BOOST_CHECK_EQUAL(0, network.getForecastDistance()); BOOST_CHECK_EQUAL("2018-01-01T11:00:00+01:00", network.getCaseDate().toString()); @@ -341,7 +346,7 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { BOOST_TEST(std::isnan(nload.getV())); const auto& line1 = network.getLine("NHV1_NHV2_1"); - BOOST_CHECK_EQUAL("NHV1_NHV2_1", line1.getName()); + BOOST_CHECK(line1.getOptionalName().empty()); BOOST_TEST(!line1.isTieLine()); BOOST_CHECK_CLOSE(3.0, line1.getR(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(33.0, line1.getX(), std::numeric_limits::epsilon()); @@ -374,7 +379,7 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { BOOST_TEST(!tempLimit.isFictitious()); const auto& line2 = network.getLine("NHV1_NHV2_2"); - BOOST_CHECK_EQUAL("NHV1_NHV2_2", line2.getName()); + BOOST_CHECK(line2.getOptionalName().empty()); BOOST_TEST(!line2.isTieLine()); BOOST_CHECK_CLOSE(3.0, line2.getR(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(33.0, line2.getX(), std::numeric_limits::epsilon()); @@ -402,7 +407,7 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { BOOST_CHECK_EQUAL(0, line2CurLimit2.getTemporaryLimits().size()); const auto& transfo1 = network.getTwoWindingsTransformer("NGEN_NHV1"); - BOOST_CHECK_EQUAL("NGEN_NHV1", transfo1.getName()); + BOOST_CHECK(transfo1.getOptionalName().empty()); BOOST_CHECK_CLOSE(24.0, transfo1.getRatedU1(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(400.0, transfo1.getRatedU2(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(0.24 / 1300.0 * (380.0 * 380.0 / 100.0), transfo1.getR(), std::numeric_limits::epsilon()); @@ -418,7 +423,7 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { BOOST_TEST(!transfo1.isOverloaded()); const auto& transfo2 = network.getTwoWindingsTransformer("NHV2_NLOAD"); - BOOST_CHECK_EQUAL("NHV2_NLOAD", transfo2.getName()); + BOOST_CHECK(transfo2.getOptionalName().empty()); BOOST_CHECK_CLOSE(400.0, transfo2.getRatedU1(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(158.0, transfo2.getRatedU2(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(0.21 / 1000 * (150.0 * 150.0 / 100.0), transfo2.getR(), std::numeric_limits::epsilon()); @@ -462,13 +467,13 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { BOOST_CHECK_CLOSE(0.0, step.getB(), std::numeric_limits::epsilon()); const auto& load = network.getLoad("LOAD"); - BOOST_CHECK_EQUAL("LOAD", load.getName()); + BOOST_CHECK(load.getOptionalName().empty()); BOOST_CHECK_EQUAL(iidm::LoadType::UNDEFINED, load.getLoadType()); BOOST_CHECK_CLOSE(600.0, load.getP0(), std::numeric_limits::epsilon()); BOOST_CHECK_CLOSE(200.0, load.getQ0(), std::numeric_limits::epsilon()); const auto& gen = network.getGenerator("GEN"); - BOOST_CHECK_EQUAL("GEN", gen.getName()); + BOOST_CHECK(gen.getOptionalName().empty()); POWSYBL_ASSERT_ENUM_EQ(iidm::EnergySource::OTHER, gen.getEnergySource()); BOOST_TEST(std::isnan(gen.getRatedS())); BOOST_CHECK_CLOSE(-9999.99, gen.getMinP(), std::numeric_limits::epsilon()); @@ -489,7 +494,7 @@ BOOST_AUTO_TEST_CASE(createWithCurrentLimitsTest) { BOOST_CHECK_CLOSE(9999.99, limits.getMaxQ(0), std::numeric_limits::epsilon()); const auto& gen2 = network.getGenerator("GEN2"); - BOOST_CHECK_EQUAL("GEN2", gen2.getName()); + BOOST_CHECK(gen2.getOptionalName().empty()); POWSYBL_ASSERT_ENUM_EQ(iidm::EnergySource::OTHER, gen2.getEnergySource()); BOOST_TEST(std::isnan(gen2.getRatedS())); BOOST_CHECK_CLOSE(-9999.99, gen2.getMinP(), std::numeric_limits::epsilon());