Commit 9fa73b38 authored by Markus Mirz's avatar Markus Mirz
Browse files

pybind: move villas code to separate module


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent a8592752
......@@ -210,7 +210,9 @@ endif(BUILD_EXAMPLES)
if(WITH_PYBIND)
set(PYBIND11_CPP_STANDARD -std=c++11)
pybind11_add_module(dpsimpy Source/pybind/main.cpp)
pybind11_add_module(dpsimpyvillas Source/pybind/dpsim-villas.cpp)
target_link_libraries(dpsimpy PRIVATE dpsim)
target_link_libraries(dpsimpyvillas PRIVATE dpsim)
endif()
include(cmake/GetGridData.cmake)
......
......@@ -3,6 +3,7 @@ import urllib.request
import glob
import dpsimpy
import dpsimpyvillas
from multiprocessing import Process, Queue
......@@ -110,7 +111,7 @@ def dpsim():
logger = dpsimpy.Logger(name)
sim.add_logger(logger)
intf = dpsimpy.InterfaceShmem()
intf = dpsimpyvillas.InterfaceShmem()
sim.add_interface(intf)
obj_list = system.list_idobjects()
......
/* Copyright 2017-2020 Institute for Automation of Complex Power Systems,
* EONERC, RWTH Aachen University
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*********************************************************************************/
#include <pybind11/pybind11.h>
#include <pybind11/complex.h>
#include <pybind11/stl.h>
#include <dpsim/InterfaceShmem.h>
namespace py = pybind11;
PYBIND11_MODULE(dpsimpyvillas, m) {
py::object interface = (py::object) py::module_::import("dpsimpy").attr("Interface");
py::class_<DPsim::InterfaceShmem>(m, "InterfaceShmem", interface)
.def(py::init<const CPS::String&, const CPS::String&>(), py::arg("shmwrite") = "/dpsim-villas", py::arg("shmread") = "/villas-dpsim");
}
\ No newline at end of file
......@@ -16,8 +16,6 @@
#include <cps/CIM/Reader.h>
#include <DPsim.h>
#include <dpsim/InterfaceShmem.h>
#include <cps/CSVReader.h>
namespace py = pybind11;
......@@ -90,9 +88,6 @@ PYBIND11_MODULE(dpsimpy, m) {
py::class_<DPsim::Interface>(m, "Interface");
py::class_<DPsim::InterfaceShmem, DPsim::Interface>(m, "InterfaceShmem")
.def(py::init<const CPS::String&, const CPS::String&>(), py::arg("shmwrite") = "/dpsim-villas", py::arg("shmread") = "/villas-dpsim");
py::class_<DPsim::DataLogger, std::shared_ptr<DPsim::DataLogger>>(m, "Logger")
.def(py::init<std::string>())
.def("log_attribute", (void (DPsim::DataLogger::*)(const CPS::String &, const CPS::String &, CPS::IdentifiedObject::Ptr)) &DPsim::DataLogger::addAttribute);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment