Skip to content

Commit

Permalink
Merge pull request #861 from PowerGridModel/feature/current-sensor-sk…
Browse files Browse the repository at this point in the history
…eleton

current sensor skeleton
  • Loading branch information
petersalemink95 authored Jan 9, 2025
2 parents c8865db + 4ae0b48 commit 8534402
Show file tree
Hide file tree
Showing 18 changed files with 820 additions and 0 deletions.
39 changes: 39 additions & 0 deletions code_generation/data/attribute_classes/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,45 @@
"description": "line drop compensation reactance"
}
]
},
{
"name": "GenericCurrentSensorInput",
"base": "SensorInput",
"attributes": [
{
"data_type": "MeasuredTerminalType",
"names": "measured_terminal_type",
"description": "type of measured terminal"
},
{
"data_type": "AngleMeasurementType",
"names": "angle_measurement_type",
"description": "type of angle measurement"
},
{
"data_type": "double",
"names": [
"i_sigma",
"i_angle_sigma"
],
"description": "sigma of error margin of current (angle) measurement"
}
]
},
{
"name": "CurrentSensorInput",
"base": "GenericCurrentSensorInput",
"is_template": true,
"attributes": [
{
"data_type": "RealValue<sym>",
"names": [
"i_measured",
"i_angle_measured"
],
"description": "measured current and current angle"
}
]
}
]
}
15 changes: 15 additions & 0 deletions code_generation/data/attribute_classes/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@
"base": "BaseOutput",
"is_template": false,
"attributes": []
},
{
"name": "CurrentSensorOutput",
"base": "BaseOutput",
"is_template": true,
"attributes": [
{
"data_type": "RealValue<sym>",
"names": [
"i_residual",
"i_angle_residual"
],
"description": "deviation between the measured value and calculated value"
}
]
}
]
}
23 changes: 23 additions & 0 deletions code_generation/data/attribute_classes/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,29 @@
"description": "line drop compensation reactance"
}
]
},
{
"name": "CurrentSensorUpdate",
"base": "BaseUpdate",
"is_template": true,
"attributes": [
{
"data_type": "double",
"names": [
"i_sigma",
"i_angle_sigma"
],
"description": "sigma of error margin of current (angle) measurement"
},
{
"data_type": "RealValue<sym>",
"names": [
"i_measured",
"i_angle_measured"
],
"description": "measured current and current angle"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,52 @@ struct TransformerTapRegulatorInput {
operator RegulatorInput const&() const { return reinterpret_cast<RegulatorInput const&>(*this); }
};

struct GenericCurrentSensorInput {
ID id{na_IntID}; // ID of the object
ID measured_object{na_IntID}; // ID of the measured object
MeasuredTerminalType measured_terminal_type{static_cast<MeasuredTerminalType>(na_IntS)}; // type of measured terminal
AngleMeasurementType angle_measurement_type{static_cast<AngleMeasurementType>(na_IntS)}; // type of angle measurement
double i_sigma{nan}; // sigma of error margin of current (angle) measurement
double i_angle_sigma{nan}; // sigma of error margin of current (angle) measurement

// implicit conversions to BaseInput
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }

// implicit conversions to SensorInput
operator SensorInput&() { return reinterpret_cast<SensorInput&>(*this); }
operator SensorInput const&() const { return reinterpret_cast<SensorInput const&>(*this); }
};

template <symmetry_tag sym_type>
struct CurrentSensorInput {
using sym = sym_type;

ID id{na_IntID}; // ID of the object
ID measured_object{na_IntID}; // ID of the measured object
MeasuredTerminalType measured_terminal_type{static_cast<MeasuredTerminalType>(na_IntS)}; // type of measured terminal
AngleMeasurementType angle_measurement_type{static_cast<AngleMeasurementType>(na_IntS)}; // type of angle measurement
double i_sigma{nan}; // sigma of error margin of current (angle) measurement
double i_angle_sigma{nan}; // sigma of error margin of current (angle) measurement
RealValue<sym> i_measured{nan}; // measured current and current angle
RealValue<sym> i_angle_measured{nan}; // measured current and current angle

// implicit conversions to BaseInput
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }

// implicit conversions to SensorInput
operator SensorInput&() { return reinterpret_cast<SensorInput&>(*this); }
operator SensorInput const&() const { return reinterpret_cast<SensorInput const&>(*this); }

// implicit conversions to GenericCurrentSensorInput
operator GenericCurrentSensorInput&() { return reinterpret_cast<GenericCurrentSensorInput&>(*this); }
operator GenericCurrentSensorInput const&() const { return reinterpret_cast<GenericCurrentSensorInput const&>(*this); }
};

using SymCurrentSensorInput = CurrentSensorInput<symmetric_t>;
using AsymCurrentSensorInput = CurrentSensorInput<asymmetric_t>;



} // namespace power_grid_model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,38 @@ struct get_attributes_list<TransformerTapRegulatorInput> {
};
};

template<>
struct get_attributes_list<GenericCurrentSensorInput> {
static constexpr std::array<MetaAttribute, 6> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::id>(offsetof(GenericCurrentSensorInput, id), "id"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::measured_object>(offsetof(GenericCurrentSensorInput, measured_object), "measured_object"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::measured_terminal_type>(offsetof(GenericCurrentSensorInput, measured_terminal_type), "measured_terminal_type"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::angle_measurement_type>(offsetof(GenericCurrentSensorInput, angle_measurement_type), "angle_measurement_type"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::i_sigma>(offsetof(GenericCurrentSensorInput, i_sigma), "i_sigma"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::i_angle_sigma>(offsetof(GenericCurrentSensorInput, i_angle_sigma), "i_angle_sigma"),
};
};

template <symmetry_tag sym_type>
struct get_attributes_list<CurrentSensorInput<sym_type>> {
using sym = sym_type;

static constexpr std::array<MetaAttribute, 8> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::id>(offsetof(CurrentSensorInput<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::measured_object>(offsetof(CurrentSensorInput<sym>, measured_object), "measured_object"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::measured_terminal_type>(offsetof(CurrentSensorInput<sym>, measured_terminal_type), "measured_terminal_type"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::angle_measurement_type>(offsetof(CurrentSensorInput<sym>, angle_measurement_type), "angle_measurement_type"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_sigma>(offsetof(CurrentSensorInput<sym>, i_sigma), "i_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_angle_sigma>(offsetof(CurrentSensorInput<sym>, i_angle_sigma), "i_angle_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_measured>(offsetof(CurrentSensorInput<sym>, i_measured), "i_measured"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_angle_measured>(offsetof(CurrentSensorInput<sym>, i_angle_measured), "i_angle_measured"),
};
};




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ struct get_attributes_list<RegulatorShortCircuitOutput> {
};
};

template <symmetry_tag sym_type>
struct get_attributes_list<CurrentSensorOutput<sym_type>> {
using sym = sym_type;

static constexpr std::array<MetaAttribute, 4> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::id>(offsetof(CurrentSensorOutput<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::energized>(offsetof(CurrentSensorOutput<sym>, energized), "energized"),
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::i_residual>(offsetof(CurrentSensorOutput<sym>, i_residual), "i_residual"),
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::i_angle_residual>(offsetof(CurrentSensorOutput<sym>, i_angle_residual), "i_angle_residual"),
};
};




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ struct get_attributes_list<TransformerTapRegulatorUpdate> {
};
};

template <symmetry_tag sym_type>
struct get_attributes_list<CurrentSensorUpdate<sym_type>> {
using sym = sym_type;

static constexpr std::array<MetaAttribute, 5> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::id>(offsetof(CurrentSensorUpdate<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_sigma>(offsetof(CurrentSensorUpdate<sym>, i_sigma), "i_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_angle_sigma>(offsetof(CurrentSensorUpdate<sym>, i_angle_sigma), "i_angle_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_measured>(offsetof(CurrentSensorUpdate<sym>, i_measured), "i_measured"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_angle_measured>(offsetof(CurrentSensorUpdate<sym>, i_angle_measured), "i_angle_measured"),
};
};




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@ struct RegulatorShortCircuitOutput {
operator BaseOutput const&() const { return reinterpret_cast<BaseOutput const&>(*this); }
};

template <symmetry_tag sym_type>
struct CurrentSensorOutput {
using sym = sym_type;

ID id{na_IntID}; // ID of the object
IntS energized{na_IntS}; // whether the object is energized
RealValue<sym> i_residual{nan}; // deviation between the measured value and calculated value
RealValue<sym> i_angle_residual{nan}; // deviation between the measured value and calculated value

// implicit conversions to BaseOutput
operator BaseOutput&() { return reinterpret_cast<BaseOutput&>(*this); }
operator BaseOutput const&() const { return reinterpret_cast<BaseOutput const&>(*this); }
};

using SymCurrentSensorOutput = CurrentSensorOutput<symmetric_t>;
using AsymCurrentSensorOutput = CurrentSensorOutput<asymmetric_t>;



} // namespace power_grid_model
Expand Down
Loading

0 comments on commit 8534402

Please sign in to comment.