Commit 5f16b500 authored by Markus Mirz's avatar Markus Mirz
Browse files

python: fix after removing shmem


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent c5812f21
/* 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/.
*********************************************************************************/
#pragma once
#ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif
#include <cps/Config.h>
#include <cps/Definitions.h>
#include <dpsim/Interface.h>
namespace DPsim {
namespace Python {
// Thin Python wrapper around Interface
struct Interface {
PyObject_HEAD
static void addExportDesc(Interface *self, int idx, const CPS::String &type, const CPS::String &name, const CPS::String &suffix = "");
static void dealloc(Interface *self);
static int init(Interface *self, PyObject *args, PyObject *kwds);
static PyObject* newfunc(PyTypeObject *type, PyObject *args, PyObject *kwds);
static PyObject* addImport(Interface *self, PyObject *args, PyObject *kwargs);
static PyObject* addExport(Interface *self, PyObject *args, PyObject *kwargs);
static PyObject* exports(Interface *self, void *ctx);
static PyMethodDef methods[];
static PyMemberDef members[];
static PyTypeObject type;
static const char* doc;
static const char* docOpen;
static const char* docAddImport;
static const char* docAddExport;
};
}
}
......@@ -68,7 +68,7 @@ namespace Python {
// List of additional objects that aren't directly used from Simulation
// methods, but that a reference has be kept to to avoid them from being
// freed (e.g. Interfaces).
// freed.
std::vector<PyObject*> refs;
/// Function executed by the simulation thread
......@@ -85,7 +85,6 @@ namespace Python {
static void dealloc(Simulation *self);
// Methods that are actually available from Python
static PyObject* addInterface(Simulation *self, PyObject *args, PyObject *kwargs);
static PyObject* addLogger(Simulation* self, PyObject* args, PyObject *kwargs);
static PyObject* addEvent(Simulation* self, PyObject* args);
static PyObject* pause(Simulation *self, PyObject *args);
......@@ -114,7 +113,6 @@ namespace Python {
static const char *docStop;
static const char *docReset;
static const char *docStep;
static const char *docAddInterface;
static const char *docAddEvent;
static const char *docAddLogger;
static const char *docAddEventFD;
......
......@@ -23,7 +23,6 @@
#include <dpsim/Python/LoadCim.h>
#include <dpsim/Python/Logger.h>
#ifndef _MSC_VER
#include <dpsim/Python/Interface.h>
#endif
#include <cps/Components.h>
......@@ -119,10 +118,6 @@ PyMODINIT_FUNC PyInit__dpsim(void) {
return nullptr;
if (PyType_Ready(&Logger::type) < 0)
return nullptr;
#ifdef WITH_SHMEM
if (PyType_Ready(&Interface::type) < 0)
return nullptr;
#endif
m = PyModule_Create(&dpsimModule);
if (!m)
......@@ -137,10 +132,6 @@ PyMODINIT_FUNC PyInit__dpsim(void) {
PyModule_AddObject(m, "Logger", (PyObject*) &Logger::type);
Py_INCREF(&Component::type);
PyModule_AddObject(m, "Component", (PyObject*) &Component::type);
#ifdef WITH_SHMEM
Py_INCREF(&Interface::type);
PyModule_AddObject(m, "Interface", (PyObject*) &Interface::type);
#endif
Py_INCREF(&Node<CPS::Complex>::type);
PyModule_AddObject(m, "_dp_Node", (PyObject*) &Node<CPS::Complex>::type);
Py_INCREF(&Node<CPS::Real>::type);
......
......@@ -15,7 +15,6 @@
#include <dpsim/Python/Simulation.h>
#include <dpsim/Python/Logger.h>
#include <dpsim/Python/Component.h>
#include <dpsim/Python/Interface.h>
#include <dpsim/RealTimeSimulation.h>
#include <dpsim/SequentialScheduler.h>
#include <dpsim/ThreadLevelScheduler.h>
......@@ -707,7 +706,6 @@ PyGetSetDef Python::Simulation::getset[] = {
};
PyMethodDef Python::Simulation::methods[] = {
{"add_interface", (PyCFunction) Python::Simulation::addInterface, METH_VARARGS | METH_KEYWORDS, (char *) Python::Simulation::docAddInterface},
{"add_logger", (PyCFunction) Python::Simulation::addLogger, METH_VARARGS | METH_KEYWORDS, (char *) Python::Simulation::docAddLogger},
{"add_event", (PyCFunction) Python::Simulation::addEvent, METH_VARARGS, (char *) docAddEvent},
{"pause", (PyCFunction) Python::Simulation::pause, METH_NOARGS, (char *) Python::Simulation::docPause},
......
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