DPsim
Utils.h
1 /* Copyright 2017-2021 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 #pragma once
9 
10 #include <DPsim.h>
11 #include <iomanip>
12 #include <pybind11/eigen.h>
13 #include <pybind11/functional.h>
14 #include <pybind11/pybind11.h>
15 #include <pybind11/stl.h>
16 
17 namespace py = pybind11;
18 
19 template <typename T>
20 py::cpp_function createAttributeSetter(const std::string name) {
21  return [name](CPS::IdentifiedObject &object, T &value) {
22  object.attributeTyped<T>(name)->set(value);
23  };
24 }
25 
26 template <typename T>
27 py::cpp_function createAttributeGetter(const std::string name) {
28  return [name](CPS::IdentifiedObject &object) {
29  return object.attributeTyped<T>(name)->get();
30  };
31 }
32 
33 CPS::Matrix zeroMatrix(int dim);
34 
35 std::string getAttributeList(CPS::IdentifiedObject &obj);
36 void printAttributes(CPS::IdentifiedObject &obj);
37 void printAttribute(CPS::IdentifiedObject &obj, std::string attr);