From 0f16bc147a30311e971d6b5f1aae7a75ee15a693 Mon Sep 17 00:00:00 2001 From: florent <florent@laas.fr> Date: Sun, 2 Jan 2011 08:14:15 +0100 Subject: [PATCH] Add recompute method in SignalBase python class. * src/dynamic-graph-py.cc, * src/dynamic_graph/signal_base.py, * src/signal-base-py.cc. --- src/dynamic-graph-py.cc | 3 +++ src/dynamic_graph/signal_base.py | 6 ++++++ src/signal-base-py.cc | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/dynamic-graph-py.cc b/src/dynamic-graph-py.cc index 11f00fa..6976c16 100644 --- a/src/dynamic-graph-py.cc +++ b/src/dynamic-graph-py.cc @@ -21,6 +21,7 @@ namespace dynamicgraph { extern PyObject* getTime(PyObject* self, PyObject* args); extern PyObject* getValue(PyObject* self, PyObject* args); extern PyObject* setValue(PyObject* self, PyObject* args); + extern PyObject* recompute(PyObject* self, PyObject* args); } namespace entity { extern PyObject* create(PyObject* self, PyObject* args); @@ -128,6 +129,8 @@ static PyMethodDef dynamicGraphMethods[] = { METH_VARARGS, "Read the value of a signal"}, {"signal_base_set_value", dynamicgraph::python::signalBase::setValue, METH_VARARGS, "Set the value of a signal"}, + {"signal_base_recompute", dynamicgraph::python::signalBase::recompute, + METH_VARARGS, "Recompute the signal at given time"}, // Entity {"create_entity", dynamicgraph::python::entity::create, METH_VARARGS, "create an Entity C++ object"}, diff --git a/src/dynamic_graph/signal_base.py b/src/dynamic_graph/signal_base.py index ccaaf1f..bbd6969 100644 --- a/src/dynamic_graph/signal_base.py +++ b/src/dynamic_graph/signal_base.py @@ -199,3 +199,9 @@ class SignalBase (object) : """ string = objectToString(val) return wrap.signal_base_set_value(self.obj, string) + + def recompute(self, time): + """ + Force signal to recompute the value at given time. + """ + return wrap.signal_base_recompute(self.obj, time) diff --git a/src/signal-base-py.cc b/src/signal-base-py.cc index 7922c2e..159ae80 100644 --- a/src/signal-base-py.cc +++ b/src/signal-base-py.cc @@ -123,6 +123,22 @@ namespace dynamicgraph { return Py_BuildValue(""); } + + PyObject* recompute(PyObject* self, PyObject* args) + { + void * pointer = NULL; + PyObject* object = NULL; + unsigned int time; + if (!PyArg_ParseTuple(args,"OI", &object, &time)) + return NULL; + if (!PyCObject_Check(object)) + return NULL; + + pointer = PyCObject_AsVoidPtr(object); + SignalBase<int>* signal = (SignalBase<int>*)pointer; + signal->recompute(time); + return Py_BuildValue(""); + } } } } -- GitLab