Skip to content

Commit 8534402

Browse files
Merge pull request #861 from PowerGridModel/feature/current-sensor-skeleton
current sensor skeleton
2 parents c8865db + 4ae0b48 commit 8534402

File tree

18 files changed

+820
-0
lines changed

18 files changed

+820
-0
lines changed

code_generation/data/attribute_classes/input.json

+39
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,45 @@
494494
"description": "line drop compensation reactance"
495495
}
496496
]
497+
},
498+
{
499+
"name": "GenericCurrentSensorInput",
500+
"base": "SensorInput",
501+
"attributes": [
502+
{
503+
"data_type": "MeasuredTerminalType",
504+
"names": "measured_terminal_type",
505+
"description": "type of measured terminal"
506+
},
507+
{
508+
"data_type": "AngleMeasurementType",
509+
"names": "angle_measurement_type",
510+
"description": "type of angle measurement"
511+
},
512+
{
513+
"data_type": "double",
514+
"names": [
515+
"i_sigma",
516+
"i_angle_sigma"
517+
],
518+
"description": "sigma of error margin of current (angle) measurement"
519+
}
520+
]
521+
},
522+
{
523+
"name": "CurrentSensorInput",
524+
"base": "GenericCurrentSensorInput",
525+
"is_template": true,
526+
"attributes": [
527+
{
528+
"data_type": "RealValue<sym>",
529+
"names": [
530+
"i_measured",
531+
"i_angle_measured"
532+
],
533+
"description": "measured current and current angle"
534+
}
535+
]
497536
}
498537
]
499538
}

code_generation/data/attribute_classes/output.json

+15
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,21 @@
293293
"base": "BaseOutput",
294294
"is_template": false,
295295
"attributes": []
296+
},
297+
{
298+
"name": "CurrentSensorOutput",
299+
"base": "BaseOutput",
300+
"is_template": true,
301+
"attributes": [
302+
{
303+
"data_type": "RealValue<sym>",
304+
"names": [
305+
"i_residual",
306+
"i_angle_residual"
307+
],
308+
"description": "deviation between the measured value and calculated value"
309+
}
310+
]
296311
}
297312
]
298313
}

code_generation/data/attribute_classes/update.json

+23
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,29 @@
243243
"description": "line drop compensation reactance"
244244
}
245245
]
246+
},
247+
{
248+
"name": "CurrentSensorUpdate",
249+
"base": "BaseUpdate",
250+
"is_template": true,
251+
"attributes": [
252+
{
253+
"data_type": "double",
254+
"names": [
255+
"i_sigma",
256+
"i_angle_sigma"
257+
],
258+
"description": "sigma of error margin of current (angle) measurement"
259+
},
260+
{
261+
"data_type": "RealValue<sym>",
262+
"names": [
263+
"i_measured",
264+
"i_angle_measured"
265+
],
266+
"description": "measured current and current angle"
267+
}
268+
]
246269
}
247270
]
248271
}

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/input.hpp

+46
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,52 @@ struct TransformerTapRegulatorInput {
444444
operator RegulatorInput const&() const { return reinterpret_cast<RegulatorInput const&>(*this); }
445445
};
446446

447+
struct GenericCurrentSensorInput {
448+
ID id{na_IntID}; // ID of the object
449+
ID measured_object{na_IntID}; // ID of the measured object
450+
MeasuredTerminalType measured_terminal_type{static_cast<MeasuredTerminalType>(na_IntS)}; // type of measured terminal
451+
AngleMeasurementType angle_measurement_type{static_cast<AngleMeasurementType>(na_IntS)}; // type of angle measurement
452+
double i_sigma{nan}; // sigma of error margin of current (angle) measurement
453+
double i_angle_sigma{nan}; // sigma of error margin of current (angle) measurement
454+
455+
// implicit conversions to BaseInput
456+
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
457+
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }
458+
459+
// implicit conversions to SensorInput
460+
operator SensorInput&() { return reinterpret_cast<SensorInput&>(*this); }
461+
operator SensorInput const&() const { return reinterpret_cast<SensorInput const&>(*this); }
462+
};
463+
464+
template <symmetry_tag sym_type>
465+
struct CurrentSensorInput {
466+
using sym = sym_type;
467+
468+
ID id{na_IntID}; // ID of the object
469+
ID measured_object{na_IntID}; // ID of the measured object
470+
MeasuredTerminalType measured_terminal_type{static_cast<MeasuredTerminalType>(na_IntS)}; // type of measured terminal
471+
AngleMeasurementType angle_measurement_type{static_cast<AngleMeasurementType>(na_IntS)}; // type of angle measurement
472+
double i_sigma{nan}; // sigma of error margin of current (angle) measurement
473+
double i_angle_sigma{nan}; // sigma of error margin of current (angle) measurement
474+
RealValue<sym> i_measured{nan}; // measured current and current angle
475+
RealValue<sym> i_angle_measured{nan}; // measured current and current angle
476+
477+
// implicit conversions to BaseInput
478+
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
479+
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }
480+
481+
// implicit conversions to SensorInput
482+
operator SensorInput&() { return reinterpret_cast<SensorInput&>(*this); }
483+
operator SensorInput const&() const { return reinterpret_cast<SensorInput const&>(*this); }
484+
485+
// implicit conversions to GenericCurrentSensorInput
486+
operator GenericCurrentSensorInput&() { return reinterpret_cast<GenericCurrentSensorInput&>(*this); }
487+
operator GenericCurrentSensorInput const&() const { return reinterpret_cast<GenericCurrentSensorInput const&>(*this); }
488+
};
489+
490+
using SymCurrentSensorInput = CurrentSensorInput<symmetric_t>;
491+
using AsymCurrentSensorInput = CurrentSensorInput<asymmetric_t>;
492+
447493

448494

449495
} // namespace power_grid_model

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/input.hpp

+32
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,38 @@ struct get_attributes_list<TransformerTapRegulatorInput> {
396396
};
397397
};
398398

399+
template<>
400+
struct get_attributes_list<GenericCurrentSensorInput> {
401+
static constexpr std::array<MetaAttribute, 6> value{
402+
// all attributes including base class
403+
404+
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::id>(offsetof(GenericCurrentSensorInput, id), "id"),
405+
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::measured_object>(offsetof(GenericCurrentSensorInput, measured_object), "measured_object"),
406+
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::measured_terminal_type>(offsetof(GenericCurrentSensorInput, measured_terminal_type), "measured_terminal_type"),
407+
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::angle_measurement_type>(offsetof(GenericCurrentSensorInput, angle_measurement_type), "angle_measurement_type"),
408+
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::i_sigma>(offsetof(GenericCurrentSensorInput, i_sigma), "i_sigma"),
409+
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::i_angle_sigma>(offsetof(GenericCurrentSensorInput, i_angle_sigma), "i_angle_sigma"),
410+
};
411+
};
412+
413+
template <symmetry_tag sym_type>
414+
struct get_attributes_list<CurrentSensorInput<sym_type>> {
415+
using sym = sym_type;
416+
417+
static constexpr std::array<MetaAttribute, 8> value{
418+
// all attributes including base class
419+
420+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::id>(offsetof(CurrentSensorInput<sym>, id), "id"),
421+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::measured_object>(offsetof(CurrentSensorInput<sym>, measured_object), "measured_object"),
422+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::measured_terminal_type>(offsetof(CurrentSensorInput<sym>, measured_terminal_type), "measured_terminal_type"),
423+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::angle_measurement_type>(offsetof(CurrentSensorInput<sym>, angle_measurement_type), "angle_measurement_type"),
424+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_sigma>(offsetof(CurrentSensorInput<sym>, i_sigma), "i_sigma"),
425+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_angle_sigma>(offsetof(CurrentSensorInput<sym>, i_angle_sigma), "i_angle_sigma"),
426+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_measured>(offsetof(CurrentSensorInput<sym>, i_measured), "i_measured"),
427+
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_angle_measured>(offsetof(CurrentSensorInput<sym>, i_angle_measured), "i_angle_measured"),
428+
};
429+
};
430+
399431

400432

401433

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/output.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ struct get_attributes_list<RegulatorShortCircuitOutput> {
247247
};
248248
};
249249

250+
template <symmetry_tag sym_type>
251+
struct get_attributes_list<CurrentSensorOutput<sym_type>> {
252+
using sym = sym_type;
253+
254+
static constexpr std::array<MetaAttribute, 4> value{
255+
// all attributes including base class
256+
257+
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::id>(offsetof(CurrentSensorOutput<sym>, id), "id"),
258+
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::energized>(offsetof(CurrentSensorOutput<sym>, energized), "energized"),
259+
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::i_residual>(offsetof(CurrentSensorOutput<sym>, i_residual), "i_residual"),
260+
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::i_angle_residual>(offsetof(CurrentSensorOutput<sym>, i_angle_residual), "i_angle_residual"),
261+
};
262+
};
263+
250264

251265

252266

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/meta_gen/update.hpp

+15
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,21 @@ struct get_attributes_list<TransformerTapRegulatorUpdate> {
197197
};
198198
};
199199

200+
template <symmetry_tag sym_type>
201+
struct get_attributes_list<CurrentSensorUpdate<sym_type>> {
202+
using sym = sym_type;
203+
204+
static constexpr std::array<MetaAttribute, 5> value{
205+
// all attributes including base class
206+
207+
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::id>(offsetof(CurrentSensorUpdate<sym>, id), "id"),
208+
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_sigma>(offsetof(CurrentSensorUpdate<sym>, i_sigma), "i_sigma"),
209+
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_angle_sigma>(offsetof(CurrentSensorUpdate<sym>, i_angle_sigma), "i_angle_sigma"),
210+
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_measured>(offsetof(CurrentSensorUpdate<sym>, i_measured), "i_measured"),
211+
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_angle_measured>(offsetof(CurrentSensorUpdate<sym>, i_angle_measured), "i_angle_measured"),
212+
};
213+
};
214+
200215

201216

202217

power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/output.hpp

+17
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ struct RegulatorShortCircuitOutput {
245245
operator BaseOutput const&() const { return reinterpret_cast<BaseOutput const&>(*this); }
246246
};
247247

248+
template <symmetry_tag sym_type>
249+
struct CurrentSensorOutput {
250+
using sym = sym_type;
251+
252+
ID id{na_IntID}; // ID of the object
253+
IntS energized{na_IntS}; // whether the object is energized
254+
RealValue<sym> i_residual{nan}; // deviation between the measured value and calculated value
255+
RealValue<sym> i_angle_residual{nan}; // deviation between the measured value and calculated value
256+
257+
// implicit conversions to BaseOutput
258+
operator BaseOutput&() { return reinterpret_cast<BaseOutput&>(*this); }
259+
operator BaseOutput const&() const { return reinterpret_cast<BaseOutput const&>(*this); }
260+
};
261+
262+
using SymCurrentSensorOutput = CurrentSensorOutput<symmetric_t>;
263+
using AsymCurrentSensorOutput = CurrentSensorOutput<asymmetric_t>;
264+
248265

249266

250267
} // namespace power_grid_model

0 commit comments

Comments
 (0)