diff --git a/src/dynamic-graph-py.cc b/src/dynamic-graph-py.cc index 11f00fac638f72405dec57672260e33eb4cf2280..6976c16adc0aee2a4275fcdc46e635f15543c9e6 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 ccaaf1fe5ba0281f60c844c6eface234970a0c0c..bbd69697503bb9dc2ff37679b962a40b62f17f0e 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 7922c2efe33134d649ec68c4c381550ad9dfe1a0..159ae805cb32e13d3a884ed5562aa8388c0c849e 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(""); + } } } }