diff --git a/code_generation/data/attribute_classes/output.json b/code_generation/data/attribute_classes/output.json index 3fd789e6d..b8c310850 100644 --- a/code_generation/data/attribute_classes/output.json +++ b/code_generation/data/attribute_classes/output.json @@ -293,6 +293,21 @@ "base": "BaseOutput", "is_template": false, "attributes": [] + }, + { + "name": "CurrentSensorOutput", + "base": "BaseOutput", + "is_template": true, + "attributes": [ + { + "data_type": "RealValue", + "names": [ + "i_residual", + "i_angle_residual" + ], + "description": "deviation between the measured value and calculated value" + } + ] } ] } \ No newline at end of file diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/output.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/output.hpp index 3d4b62e96..186ec3b56 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/output.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/output.hpp @@ -247,6 +247,20 @@ struct get_attributes_list { }; }; +template +struct get_attributes_list> { + using sym = sym_type; + + static constexpr std::array value{ + // all attributes including base class + + meta_data_gen::get_meta_attribute<&CurrentSensorOutput::id>(offsetof(CurrentSensorOutput, id), "id"), + meta_data_gen::get_meta_attribute<&CurrentSensorOutput::energized>(offsetof(CurrentSensorOutput, energized), "energized"), + meta_data_gen::get_meta_attribute<&CurrentSensorOutput::i_residual>(offsetof(CurrentSensorOutput, i_residual), "i_residual"), + meta_data_gen::get_meta_attribute<&CurrentSensorOutput::i_angle_residual>(offsetof(CurrentSensorOutput, i_angle_residual), "i_angle_residual"), + }; +}; + diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/output.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/output.hpp index 54de1fa69..1fae40845 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/output.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/output.hpp @@ -245,6 +245,23 @@ struct RegulatorShortCircuitOutput { operator BaseOutput const&() const { return reinterpret_cast(*this); } }; +template +struct CurrentSensorOutput { + using sym = sym_type; + + ID id{na_IntID}; // ID of the object + IntS energized{na_IntS}; // whether the object is energized + RealValue i_residual{nan}; // deviation between the measured value and calculated value + RealValue i_angle_residual{nan}; // deviation between the measured value and calculated value + + // implicit conversions to BaseOutput + operator BaseOutput&() { return reinterpret_cast(*this); } + operator BaseOutput const&() const { return reinterpret_cast(*this); } +}; + +using SymCurrentSensorOutput = CurrentSensorOutput; +using AsymCurrentSensorOutput = CurrentSensorOutput; + } // namespace power_grid_model diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/static_asserts/output.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/static_asserts/output.hpp index 54a5d5f55..9de483618 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/static_asserts/output.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/static_asserts/output.hpp @@ -295,6 +295,39 @@ static_assert(std::same_as +static_assert(std::is_standard_layout_v>); +// static asserts for conversion of CurrentSensorOutput to BaseOutput +static_assert(std::alignment_of_v> >= std::alignment_of_v); +static_assert(std::same_as::id), decltype(BaseOutput::id)>); +static_assert(std::same_as::energized), decltype(BaseOutput::energized)>); +static_assert(offsetof(CurrentSensorOutput, id) == offsetof(BaseOutput, id)); +static_assert(offsetof(CurrentSensorOutput, energized) == offsetof(BaseOutput, energized)); +// static asserts for CurrentSensorOutput +static_assert(std::is_standard_layout_v>); +// static asserts for conversion of CurrentSensorOutput to BaseOutput +static_assert(std::alignment_of_v> >= std::alignment_of_v); +static_assert(std::same_as::id), decltype(BaseOutput::id)>); +static_assert(std::same_as::energized), decltype(BaseOutput::energized)>); +static_assert(offsetof(CurrentSensorOutput, id) == offsetof(BaseOutput, id)); +static_assert(offsetof(CurrentSensorOutput, energized) == offsetof(BaseOutput, energized)); +// static asserts for SymCurrentSensorOutput +static_assert(std::is_standard_layout_v); +// static asserts for conversion of SymCurrentSensorOutput to BaseOutput +static_assert(std::alignment_of_v >= std::alignment_of_v); +static_assert(std::same_as); +static_assert(std::same_as); +static_assert(offsetof(SymCurrentSensorOutput, id) == offsetof(BaseOutput, id)); +static_assert(offsetof(SymCurrentSensorOutput, energized) == offsetof(BaseOutput, energized)); +// static asserts for AsymCurrentSensorOutput +static_assert(std::is_standard_layout_v); +// static asserts for conversion of AsymCurrentSensorOutput to BaseOutput +static_assert(std::alignment_of_v >= std::alignment_of_v); +static_assert(std::same_as); +static_assert(std::same_as); +static_assert(offsetof(AsymCurrentSensorOutput, id) == offsetof(BaseOutput, id)); +static_assert(offsetof(AsymCurrentSensorOutput, energized) == offsetof(BaseOutput, energized)); + } // namespace power_grid_model::test