-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from PowerGridModel/feature/vnf-skeleton
Feature/vnf skeleton
- Loading branch information
Showing
23 changed files
with
305 additions
and
10 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
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
[submodule "power-grid-model"] | ||
path = power-grid-model | ||
[submodule "deps/power-grid-model"] | ||
path = deps/power-grid-model | ||
url = [email protected]:PowerGridModel/power-grid-model.git | ||
branch = main |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
add_subdirectory("power-grid-model") | ||
|
Submodule power-grid-model
added at
a05b88
Submodule power-grid-model
deleted from
560323
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
128 changes: 128 additions & 0 deletions
128
...id_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.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,128 @@ | ||
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
#ifndef POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP | ||
#define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_HPP | ||
|
||
#include <power_grid_model/auxiliary/dataset.hpp> | ||
#include <power_grid_model/common/exception.hpp> | ||
|
||
#include <iostream> | ||
|
||
class PgmVnfConverter { | ||
public: | ||
PgmVnfConverter(char* buffer = nullptr, power_grid_model::WritableDataset* data = nullptr); | ||
|
||
// Public member functions | ||
void parse_vnf_file(); | ||
power_grid_model::ConstDataset const* convert_input(power_grid_model::ConstDataset const* dataset); | ||
|
||
private: | ||
// Private attributes | ||
char* f_file_buffer; | ||
power_grid_model::WritableDataset* | ||
deserialized_data; // this type because it is generated by a deserializer type structure | ||
|
||
// Private setters/getters | ||
void set_file_buffer(char* file_buffer); | ||
|
||
void set_deserialized_data(power_grid_model::WritableDataset* deserialized_data); | ||
|
||
char* get_file_buffer(); | ||
|
||
power_grid_model::WritableDataset* get_deserialized_data(); | ||
|
||
// Private member functions | ||
void convert_node_input(); | ||
void convert_line_input(); | ||
void convert_sources_input(); | ||
void convert_sym_loads_input(); | ||
void convert_shunts_input(); | ||
void convert_transformer_input(); | ||
void convert_sym_gens_input(); | ||
void convert_links_input(); | ||
}; | ||
|
||
inline PgmVnfConverter::PgmVnfConverter(char* buffer, power_grid_model::WritableDataset* data) | ||
: f_file_buffer(buffer), deserialized_data(data) { | ||
using namespace std::string_literals; | ||
using power_grid_model::ExperimentalFeature; | ||
throw ExperimentalFeature{"PGM_VNF_converter", ExperimentalFeature::TypeValuePair{.name = "PGM_VNF_conversion", | ||
.value = std::to_string(1)}}; | ||
} | ||
|
||
inline void PgmVnfConverter::parse_vnf_file() { | ||
// the function should use a deserializer type structure | ||
// will be implemented later | ||
} | ||
|
||
inline power_grid_model::ConstDataset const* | ||
PgmVnfConverter::convert_input(power_grid_model::ConstDataset const* /*dataset*/) { | ||
convert_node_input(); | ||
convert_line_input(); | ||
convert_sources_input(); | ||
convert_sym_loads_input(); | ||
convert_shunts_input(); | ||
convert_transformer_input(); | ||
convert_sym_gens_input(); | ||
convert_links_input(); | ||
|
||
// then return the buffer | ||
// return pgm_input_data; | ||
// for now. | ||
power_grid_model::ConstDataset* fake_data = nullptr; | ||
return fake_data; | ||
} | ||
|
||
inline void PgmVnfConverter::set_file_buffer(char* file_buffer) { this->f_file_buffer = file_buffer; } | ||
|
||
inline void PgmVnfConverter::set_deserialized_data(power_grid_model::WritableDataset* data) { | ||
this->deserialized_data = data; | ||
} | ||
|
||
inline char* PgmVnfConverter::get_file_buffer() { return this->f_file_buffer; } | ||
|
||
inline power_grid_model::WritableDataset* PgmVnfConverter::get_deserialized_data() { return this->deserialized_data; } | ||
|
||
inline void PgmVnfConverter::convert_node_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_line_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_sources_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_sym_loads_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_shunts_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_transformer_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_sym_gens_input() { | ||
// Implementation | ||
} | ||
|
||
inline void PgmVnfConverter::convert_links_input() { | ||
// Implementation | ||
} | ||
|
||
inline void parse_vnf_file_wrapper(PgmVnfConverter* obj) { obj->parse_vnf_file(); } | ||
|
||
inline power_grid_model::ConstDataset const* convert_input_wrapper(PgmVnfConverter* obj, | ||
power_grid_model::ConstDataset const* dataset) { | ||
return obj->convert_input(dataset); | ||
} | ||
|
||
#endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_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
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
44 changes: 44 additions & 0 deletions
44
...e_c/power_grid_model_io_native_c/include/power_grid_model_io_native_c/vnf_pgm_converter.h
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,44 @@ | ||
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
#ifndef POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_H | ||
#define POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_H | ||
|
||
#include "basics.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Create the PGM_VNF_converter | ||
* @param handle | ||
* @param file_buffer A pointer to the null-terminated C string. | ||
* @return The pointer to a PGM_VNF_converter instance. The instance must be freed by | ||
* PGM_VNF_delete_Converter | ||
*/ | ||
PGM_IO_API PGM_IO_VnfConverter* PGM_VNF_create_converter(PGM_IO_Handle* handle, char* file_buffer); | ||
|
||
/** | ||
* @brief Retrieve the transformed input data from .vnf format to PGM format | ||
* @param handle | ||
* @param converter_ptr A pointer to a PGM_VNF_converter instace. | ||
* @param dataset A pointer to the const dataset supplied by the user. | ||
* @return The pointer to the const dataset instance supplied by the user which has been filled in. | ||
*/ | ||
PGM_IO_API PGM_IO_ConstDataset const* PGM_VNF_get_input_data(PGM_IO_Handle* handle, PGM_IO_VnfConverter* converter_ptr, | ||
PGM_IO_ConstDataset const* dataset); | ||
|
||
/** | ||
* @brief Destroy the converter and free up the memory that was dedicated to it. | ||
* @param converter_ptr A pointer to a PGM_VNF_converter instance. | ||
*/ | ||
PGM_IO_API void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // POWER_GRID_MODEL_IO_NATIVE_C_VNF_PGM_CONVERTER_H |
35 changes: 35 additions & 0 deletions
35
power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.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,35 @@ | ||
// SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#define PGM_IO_DLL_EXPORTS | ||
|
||
#include <power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp> | ||
|
||
#include "handle.hpp" | ||
#include <power_grid_model_io_native_c/basics.h> | ||
#include <power_grid_model_io_native_c/vnf_pgm_converter.h> | ||
|
||
#include <power_grid_model/auxiliary/dataset.hpp> | ||
|
||
using power_grid_model::ConstDataset; | ||
|
||
// TODO(Laurynas-Jagutis) add call_with_catch for these functions | ||
PGM_IO_VnfConverter* PGM_VNF_create_converter(const PGM_IO_Handle* /*handle*/, char* file_buffer) { | ||
auto* converter = new PgmVnfConverter(file_buffer); | ||
parse_vnf_file_wrapper(converter); | ||
return reinterpret_cast<PGM_IO_VnfConverter*>(converter); | ||
} | ||
|
||
PGM_IO_ConstDataset const* PGM_VNF_get_input_data(const PGM_IO_Handle* /*handle*/, PGM_IO_VnfConverter* converter_ptr, | ||
PGM_IO_ConstDataset const* dataset) { | ||
auto* converter = reinterpret_cast<PgmVnfConverter*>(converter_ptr); | ||
auto const* data = reinterpret_cast<ConstDataset const*>(dataset); | ||
convert_input_wrapper(converter, data); | ||
return reinterpret_cast<PGM_IO_ConstDataset const*>(data); | ||
} | ||
|
||
void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr) { | ||
auto* converter = reinterpret_cast<PgmVnfConverter*>(converter_ptr); | ||
delete converter; | ||
} |
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
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
Oops, something went wrong.