DPsim
Loading...
Searching...
No Matches
Attributes.cpp
1/* Copyright 2017-2022 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#include <DPsim.h>
10#include <dpsim-models/CSVReader.h>
11#include <dpsim-models/IdentifiedObject.h>
12#include <dpsim/RealTimeSimulation.h>
13#include <dpsim/Simulation.h>
14#include <dpsim/pybind/BaseComponents.h>
15#include <dpsim/pybind/Utils.h>
16
17PYBIND11_DECLARE_HOLDER_TYPE(T, CPS::AttributePointer<T>);
18
19namespace py = pybind11;
20using namespace pybind11::literals;
21
22void addAttributes(py::module_ m) {
23
24 py::class_<CPS::AttributeBase, CPS::AttributePointer<CPS::AttributeBase>>(
25 m, "Attribute")
26 .def("__str__", &CPS::AttributeBase::toString)
27 .def("__repr__", &CPS::AttributeBase::toString);
28
29 // Class bindings for the most common attribute types. Allows for the usage of the `get` and `set` methods in Python.
30
31 py::class_<CPS::Attribute<CPS::Real>,
33 CPS::AttributeBase>(m, "AttributeReal")
36 .def("derive_scaled",
37 py::overload_cast<CPS::Real>(
38 &CPS::Attribute<CPS::Real>::template deriveScaled<CPS::Real>));
39
40 py::class_<CPS::AttributeStatic<CPS::Real>,
42 CPS::Attribute<CPS::Real>>(m, "AttributeRealStat");
43 py::class_<CPS::AttributeDynamic<CPS::Real>,
45 CPS::Attribute<CPS::Real>>(m, "AttributeRealDyn")
47
48 py::class_<CPS::Attribute<CPS::Complex>,
50 CPS::AttributeBase>(m, "AttributeComplex")
53 .def("derive_real",
54 py::overload_cast<>(
56 .def("derive_imag",
57 py::overload_cast<>(
59 .def("derive_mag",
60 py::overload_cast<>(
62 .def("derive_phase",
63 py::overload_cast<>(
65 .def("derive_scaled",
66 py::overload_cast<CPS::Complex>(
68 CPS::Complex>));
69
70 py::class_<CPS::AttributeStatic<CPS::Complex>,
72 CPS::Attribute<CPS::Complex>>(m, "AttributeComplexStat");
73 py::class_<CPS::AttributeDynamic<CPS::Complex>,
75 CPS::Attribute<CPS::Complex>>(m, "AttributeComplexDyn")
77
78 py::class_<CPS::Attribute<CPS::Matrix>,
80 CPS::AttributeBase>(m, "AttributeMatrix")
83 .def("derive_coeff",
85
86 py::class_<CPS::AttributeStatic<CPS::Matrix>,
88 CPS::Attribute<CPS::Matrix>>(m, "AttributeMatrixStat");
89 py::class_<CPS::AttributeDynamic<CPS::Matrix>,
91 CPS::Attribute<CPS::Matrix>>(m, "AttributeMatrixDyn")
93
94 py::class_<CPS::Attribute<CPS::MatrixComp>,
96 CPS::AttributeBase>(m, "AttributeMatrixComp")
99 .def("derive_coeff",
101
102 py::class_<CPS::AttributeStatic<CPS::MatrixComp>,
104 CPS::Attribute<CPS::MatrixComp>>(m, "AttributeMatrixCompStat");
105 py::class_<CPS::AttributeDynamic<CPS::MatrixComp>,
107 CPS::Attribute<CPS::MatrixComp>>(m, "AttributeMatrixCompDyn")
108 .def("set_reference",
110
111 py::class_<CPS::Attribute<CPS::String>,
113 CPS::AttributeBase>(m, "AttributeString")
116
117 py::class_<CPS::AttributeStatic<CPS::String>,
119 CPS::Attribute<CPS::String>>(m, "AttributeStringStat");
120 py::class_<CPS::AttributeDynamic<CPS::String>,
122 CPS::Attribute<CPS::String>>(m, "AttributeStringDyn")
124}
virtual String toString()=0
virtual void setReference(typename Attribute< T >::Ptr reference) override
Definition Attribute.h:616
AttributePointer< Attribute< U > > deriveCoeff(typename CPS::MatrixVar< U >::Index row, typename CPS::MatrixVar< U >::Index column)
Definition Attribute.h:498
virtual void set(T value)=0
virtual T & get()=0