9 #include <dpsim/pybind/Utils.h>
11 CPS::Matrix zeroMatrix(
int dim) {
return CPS::Matrix::Zero(dim, dim); }
14 std::stringstream output;
15 output << std::setiosflags(std::ios::left);
16 output <<
"Attribute list for object with name " << obj.name() <<
":"
18 output << std::setw(30) <<
"name" << std::setw(20) <<
"type" << std::setw(15)
19 <<
"size" << std::setw(30) <<
"value" << std::endl;
20 output << std::setw(95) << std::setfill(
'-') <<
"" << std::setfill(
' ')
22 for (
auto attr : obj.attributes()) {
23 std::string name = attr.first;
28 attr.second.getPtr())) {
30 value = std::to_string(tryReal->get());
32 }
else if (
auto tryComplex =
34 attr.second.getPtr())) {
36 value = std::to_string(abs(tryComplex->get())) +
"<" +
37 std::to_string(arg(tryComplex->get()));
39 }
else if (
auto tryMatrixReal =
41 attr.second.getPtr())) {
44 size = std::to_string(tryMatrixReal->get().rows()) +
"x" +
45 std::to_string(tryMatrixReal->get().cols());
46 }
else if (
auto tryMatrixComp =
48 attr.second.getPtr())) {
49 type =
"MatrixComplex";
51 size = std::to_string(tryMatrixComp->get().rows()) +
"x" +
52 std::to_string(tryMatrixComp->get().cols());
53 }
else if (
auto tryString =
55 attr.second.getPtr())) {
57 value =
"\"" + tryString->get() +
"\"";
64 output << std::setw(30) << name << std::setw(20) << type << std::setw(15)
65 << size << std::setw(30) << value << std::endl;
71 py::print(getAttributeList(obj));
78 py::print(
"Attribute " + attrName +
" on object " + obj.name() +
79 " has type Real and value " + std::to_string(tryReal->get()));
80 }
else if (
auto tryComplex =
83 std::string value = std::to_string(abs(tryComplex->get())) +
"<" +
84 std::to_string(arg(tryComplex->get()));
85 py::print(
"Attribute " + attrName +
" on object " + obj.name() +
86 " has type Complex and value " + value);
87 }
else if (
auto tryMatrixReal =
90 std::string size = std::to_string(tryMatrixReal->get().rows()) +
"x" +
91 std::to_string(tryMatrixReal->get().cols());
92 py::print(
"Attribute " + attrName +
" on object " + obj.name() +
93 " has type MatrixReal (size " + size +
") and value:");
94 py::print(py::cast(tryMatrixReal->get()));
95 }
else if (
auto tryMatrixComp =
98 std::string size = std::to_string(tryMatrixComp->get().rows()) +
"x" +
99 std::to_string(tryMatrixComp->get().cols());
100 py::print(
"Attribute " + attrName +
" on object " + obj.name() +
101 " has type MatrixComplex (size " + size +
") and value:");
102 py::print(py::cast(tryMatrixComp->get()));
103 }
else if (
auto tryString =
106 py::print(
"Attribute " + attrName +
" on object " + obj.name() +
107 " has type String and value \"" + tryString->get() +
"\"");
109 py::print(
"Could not determine type of attribute " + attrName);
AttributeBase::Ptr attribute(const String &name) const
Return pointer to an attribute.