diff --git a/src/solver/systemParser/CMakeLists.txt b/src/solver/systemParser/CMakeLists.txt index 38cbdec163..a89664fe2d 100644 --- a/src/solver/systemParser/CMakeLists.txt +++ b/src/solver/systemParser/CMakeLists.txt @@ -2,6 +2,7 @@ find_package(yaml-cpp REQUIRED) set(SOURCES parser.cpp + converter.cpp encoders.hxx include/antares/solver/systemParser/parser.h include/antares/solver/systemParser/system.h @@ -19,6 +20,8 @@ target_include_directories(systemParser # Link dependencies (if any) target_link_libraries(systemParser + PUBLIC + Antares::antares-study-system-model PRIVATE yaml-cpp ) diff --git a/src/solver/systemParser/converter.cpp b/src/solver/systemParser/converter.cpp new file mode 100644 index 0000000000..86b0cbb70d --- /dev/null +++ b/src/solver/systemParser/converter.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2007-2024, RTE (https://www.rte-france.com) + * See AUTHORS.txt + * SPDX-License-Identifier: MPL-2.0 + * This file is part of Antares-Simulator, + * Adequacy and Performance assessment for interconnected energy networks. + * + * Antares_Simulator is free software: you can redistribute it and/or modify + * it under the terms of the Mozilla Public Licence 2.0 as published by + * the Mozilla Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Antares_Simulator is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Mozilla Public Licence 2.0 for more details. + * + * You should have received a copy of the Mozilla Public Licence 2.0 + * along with Antares_Simulator. If not, see . + */ + +#include "antares/solver/systemParser/system.h" +#include "antares/study/system-model/system.h" + +using namespace Antares::Study; + +namespace Antares::Solver::SystemConverter +{ + +static SystemModel::Component createComponent(const SystemParser::Component& c) +{ + SystemModel::ModelBuilder model_builder; + auto model = model_builder.withId(c.model).build(); + SystemModel::ComponentBuilder component_builder; + + /* std::map parameters; */ + /* for (const auto& p : c.parameters) */ + /* { */ + /* parameters.try_emplace(p.id, p.value); */ + /* } */ + + auto component = component_builder.withId(c.id) + .withModel(&model) + .withScenarioGroupId(c.scenarioGroup) + /* .withParameterValues(parameters) */ + .build(); + return component; +} + +SystemModel::System convert(const SystemParser::System& parserSystem) +{ + std::vector components; + for (const auto& c: parserSystem.components) + { + components.push_back(createComponent(c)); + } + + SystemModel::SystemBuilder builder; + return builder.withId(parserSystem.id).withComponents(components).build(); +} + +} // namespace Antares::Solver::SystemConverter