Skip to content

Commit

Permalink
remove old python log_attribute methods
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Schroeder <[email protected]>
  • Loading branch information
JTS22 committed Jul 25, 2023
1 parent 7d4d5f4 commit 5cc87e3
Show file tree
Hide file tree
Showing 52 changed files with 840 additions and 548 deletions.
10 changes: 1 addition & 9 deletions dpsim/src/pybind/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,7 @@ PYBIND11_MODULE(dpsimpy, m) {
.def_static("get_log_dir", &CPS::Logger::logDir)
.def("log_attribute", py::overload_cast<const CPS::String&, CPS::AttributeBase::Ptr, CPS::UInt, CPS::UInt>(&DPsim::DataLogger::logAttribute), "name"_a, "attr"_a, "max_cols"_a = 0, "max_rows"_a = 0)
/// Compatibility method. Might be removed later when the python examples have been fully adapted.
.def("log_attribute", py::overload_cast<const std::vector<CPS::String>&, CPS::AttributeBase::Ptr>(&DPsim::DataLogger::logAttribute), "names"_a, "attr"_a)
/// Compatibility method. Might be removed later when the python examples have been fully adapted.
.def("log_attribute", [](DPsim::DataLogger &logger, const CPS::String &name, const CPS::String &attr, const CPS::IdentifiedObject &comp, CPS::UInt rowsMax, CPS::UInt colsMax) {
logger.logAttribute(name, comp.attribute(attr), rowsMax, colsMax);
}, "name"_a, "attr"_a, "comp"_a, "rows_max"_a = 0, "cols_max"_a = 0)
/// Compatibility method. Might be removed later when the python examples have been fully adapted.;
.def("log_attribute", [](DPsim::DataLogger &logger, const std::vector<CPS::String> &names, const CPS::String &attr, const CPS::IdentifiedObject &comp) {
logger.logAttribute(names, comp.attribute(attr));
});
.def("log_attribute", py::overload_cast<const std::vector<CPS::String>&, CPS::AttributeBase::Ptr>(&DPsim::DataLogger::logAttribute), "names"_a, "attr"_a);

py::class_<CPS::IdentifiedObject, std::shared_ptr<CPS::IdentifiedObject>>(m, "IdentifiedObject")
.def("name", &CPS::IdentifiedObject::name)
Expand Down
18 changes: 9 additions & 9 deletions examples/Notebooks/Circuits/CS_R2CL print_attributes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@
"\n",
"# Logging\n",
"logger = dpsimpy.Logger(name)\n",
"logger.log_attribute('n1.v', 'v', n1)\n",
"logger.log_attribute('n2.v', 'v', n2)\n",
"logger.log_attribute('cs.i_intf', 'i_intf', cs)\n",
"logger.log_attribute('c_1.i_intf', 'i_intf', c1)\n",
"logger.log_attribute('n1.v', n1.attr('v'))\n",
"logger.log_attribute('n2.v', n2.attr('v'))\n",
"logger.log_attribute('cs.i_intf', cs.attr('i_intf'))\n",
"logger.log_attribute('c_1.i_intf', c1.attr('i_intf'))\n",
"\n",
"sim = dpsimpy.Simulation(name)\n",
"sim.set_domain(dpsimpy.Domain.EMT)\n",
Expand Down Expand Up @@ -198,10 +198,10 @@
"\n",
"# Logging\n",
"logger = dpsimpy.Logger(name)\n",
"logger.log_attribute('n1.v', 'v', n1)\n",
"logger.log_attribute('n2.v', 'v', n2)\n",
"logger.log_attribute('cs.i_intf', 'i_intf', cs)\n",
"logger.log_attribute('c_1.i_intf', 'i_intf', c1)\n",
"logger.log_attribute('n1.v', n1.attr('v'))\n",
"logger.log_attribute('n2.v', n2.attr('v'))\n",
"logger.log_attribute('cs.i_intf', cs.attr('i_intf'))\n",
"logger.log_attribute('c_1.i_intf', c1.attr('i_intf'))\n",
"\n",
"sim = dpsimpy.Simulation(name)\n",
"sim.set_system(system)\n",
Expand Down Expand Up @@ -288,4 +288,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
16 changes: 8 additions & 8 deletions examples/Notebooks/Circuits/CS_R2CL.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@
"\n",
"# Logging\n",
"logger = dpsimpy.Logger(name)\n",
"logger.log_attribute('n1.v', 'v', n1)\n",
"logger.log_attribute('n2.v', 'v', n2)\n",
"logger.log_attribute('cs.i_intf', 'i_intf', cs)\n",
"logger.log_attribute('c_1.i_intf', 'i_intf', c1)\n",
"logger.log_attribute('n1.v', n1.attr('v'))\n",
"logger.log_attribute('n2.v', n2.attr('v'))\n",
"logger.log_attribute('cs.i_intf', cs.attr('i_intf'))\n",
"logger.log_attribute('c_1.i_intf', c1.attr('i_intf'))\n",
"\n",
"sim = dpsimpy.Simulation(name)\n",
"sim.set_domain(dpsimpy.Domain.EMT)\n",
Expand Down Expand Up @@ -178,10 +178,10 @@
"\n",
"# Logging\n",
"logger = dpsimpy.Logger(name)\n",
"logger.log_attribute('n1.v', 'v', n1)\n",
"logger.log_attribute('n2.v', 'v', n2)\n",
"logger.log_attribute('cs.i_intf', 'i_intf', cs)\n",
"logger.log_attribute('c_1.i_intf', 'i_intf', c1)\n",
"logger.log_attribute('n1.v', n1.attr('v'))\n",
"logger.log_attribute('n2.v', n2.attr('v'))\n",
"logger.log_attribute('cs.i_intf', cs.attr('i_intf'))\n",
"logger.log_attribute('c_1.i_intf', c1.attr('i_intf'))\n",
"\n",
"sim = dpsimpy.Simulation(name)\n",
"sim.set_system(system)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,7 @@
"### Define system topology\n",
"system_pf = dpsimpy.SystemTopology(frequency, [n1_pf, n2_pf], [gen_pf, pi_line_pf, extnet_pf])\n",
"\n",
"# Logging\n",
"logger_pf = dpsimpy.Logger(sim_name_pf)\n",
"logger_pf.log_attribute('n1.v', 'v', n1_pf)\n",
"logger_pf.log_attribute('n2.v', 'v', n2_pf)\n",
"logger_pf.log_attribute('p_inj', 'p_inj', extnet_pf)\n",
"logger_pf.log_attribute('q_inj', 'q_inj', extnet_pf)\n",
"\n",
"\n",
"sim_pf = dpsimpy.Simulation(sim_name_pf, dpsimpy.LogLevel.debug)\n",
"sim_pf.set_system(system_pf)\n",
Expand All @@ -197,7 +192,13 @@
"sim_pf.set_solver_component_behaviour(dpsimpy.SolverBehaviour.Initialization)\n",
"sim_pf.set_time_step(0.1)\n",
"sim_pf.set_final_time(0.5)\n",
"sim_pf.add_logger(logger_pf)\n",
"\n",
"# Logging\n",
"sim_pf.log_attribute('n1.v', n1_pf.attr('v'))\n",
"sim_pf.log_attribute('n2.v', n2_pf.attr('v'))\n",
"sim_pf.log_attribute('p_inj', extnet_pf.attr('p_inj'))\n",
"sim_pf.log_attribute('q_inj', extnet_pf.attr('q_inj'))\n",
"\n",
"sim_pf.run()"
]
},
Expand Down Expand Up @@ -296,7 +297,7 @@
"\n",
" ### Logging\n",
" logger = dpsimpy.Logger(name)\n",
" logger.log_attribute('Te', 'Te', gen)\n",
" logger.log_attribute('Te', gen.attr('Te'))\n",
"\n",
" \n",
" ### Simulation\n",
Expand Down
Loading

0 comments on commit 5cc87e3

Please sign in to comment.