Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic-graph-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guilhem Saurel
dynamic-graph-python
Commits
b1859161
Commit
b1859161
authored
11 years ago
by
Florent Lamiraux
Committed by
Florent Lamiraux florent@laas.fr
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Enhance SignalBase API
- add isPlugged and getPlugged methods, - add property getter name.
parent
8019f592
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/dynamic-graph-py.cc
+6
-0
6 additions, 0 deletions
src/dynamic-graph-py.cc
src/dynamic_graph/signal_base.py
+17
-0
17 additions, 0 deletions
src/dynamic_graph/signal_base.py
src/signal-base-py.cc
+48
-3
48 additions, 3 deletions
src/signal-base-py.cc
with
71 additions
and
3 deletions
src/dynamic-graph-py.cc
+
6
−
0
View file @
b1859161
...
@@ -40,6 +40,8 @@ namespace dynamicgraph {
...
@@ -40,6 +40,8 @@ namespace dynamicgraph {
extern
PyObject
*
setValue
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
setValue
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
recompute
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
recompute
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
unplug
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
unplug
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
isPlugged
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
getPlugged
(
PyObject
*
self
,
PyObject
*
args
);
}
}
namespace
entity
{
namespace
entity
{
extern
PyObject
*
create
(
PyObject
*
self
,
PyObject
*
args
);
extern
PyObject
*
create
(
PyObject
*
self
,
PyObject
*
args
);
...
@@ -166,6 +168,10 @@ static PyMethodDef dynamicGraphMethods[] = {
...
@@ -166,6 +168,10 @@ static PyMethodDef dynamicGraphMethods[] = {
METH_VARARGS
,
"Recompute the signal at given time"
},
METH_VARARGS
,
"Recompute the signal at given time"
},
{
"signal_base_unplug"
,
dynamicgraph
::
python
::
signalBase
::
unplug
,
{
"signal_base_unplug"
,
dynamicgraph
::
python
::
signalBase
::
unplug
,
METH_VARARGS
,
"Unplug the signal"
},
METH_VARARGS
,
"Unplug the signal"
},
{
"signal_base_isPlugged"
,
dynamicgraph
::
python
::
signalBase
::
isPlugged
,
METH_VARARGS
,
"Whether the signal is plugged"
},
{
"signal_base_getPlugged"
,
dynamicgraph
::
python
::
signalBase
::
getPlugged
,
METH_VARARGS
,
"To which signal the signal is plugged"
},
// Entity
// Entity
{
"create_entity"
,
dynamicgraph
::
python
::
entity
::
create
,
METH_VARARGS
,
{
"create_entity"
,
dynamicgraph
::
python
::
entity
::
create
,
METH_VARARGS
,
"create an Entity C++ object"
},
"create an Entity C++ object"
},
...
...
This diff is collapsed.
Click to expand it.
src/dynamic_graph/signal_base.py
+
17
−
0
View file @
b1859161
...
@@ -225,6 +225,13 @@ class SignalBase (object) :
...
@@ -225,6 +225,13 @@ class SignalBase (object) :
"""
"""
return
wrap
.
signal_base_get_name
(
self
.
obj
)
return
wrap
.
signal_base_get_name
(
self
.
obj
)
@property
def
name
(
self
)
:
"""
Get name of signal
"""
return
wrap
.
signal_base_get_name
(
self
.
obj
)
def
getClassName
(
self
):
def
getClassName
(
self
):
"""
"""
Get class name of signal
Get class name of signal
...
@@ -241,6 +248,16 @@ class SignalBase (object) :
...
@@ -241,6 +248,16 @@ class SignalBase (object) :
Unplug a PTR signal.
Unplug a PTR signal.
"""
"""
return
wrap
.
signal_base_unplug
(
self
.
obj
)
return
wrap
.
signal_base_unplug
(
self
.
obj
)
def
isPlugged
(
self
):
"""
Return whether a signal is plugged.
"""
return
wrap
.
signal_base_isPlugged
(
self
.
obj
)
def
getPlugged
(
self
):
"""
Return the plugged signal.
"""
return
SignalBase
(
obj
=
wrap
.
signal_base_getPlugged
(
self
.
obj
))
def
__str__
(
self
):
def
__str__
(
self
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
src/signal-base-py.cc
+
48
−
3
View file @
b1859161
...
@@ -319,6 +319,51 @@ namespace dynamicgraph {
...
@@ -319,6 +319,51 @@ namespace dynamicgraph {
}
CATCH_ALL_EXCEPTIONS
();
}
CATCH_ALL_EXCEPTIONS
();
return
Py_BuildValue
(
""
);
return
Py_BuildValue
(
""
);
}
}
}
}
PyObject
*
isPlugged
(
PyObject
*
,
PyObject
*
args
)
}
{
void
*
pointer
=
NULL
;
PyObject
*
object
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
object
))
return
NULL
;
if
(
!
PyCObject_Check
(
object
))
return
NULL
;
pointer
=
PyCObject_AsVoidPtr
(
object
);
SignalBase
<
int
>*
signal
=
(
SignalBase
<
int
>*
)
pointer
;
bool
plugged
=
false
;
try
{
plugged
=
signal
->
isPluged
();
}
CATCH_ALL_EXCEPTIONS
();
if
(
plugged
)
return
PyBool_FromLong
(
1
);
else
return
PyBool_FromLong
(
0
);
}
PyObject
*
getPlugged
(
PyObject
*
,
PyObject
*
args
)
{
void
*
pointer
=
NULL
;
PyObject
*
object
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O"
,
&
object
))
return
NULL
;
if
(
!
PyCObject_Check
(
object
))
return
NULL
;
pointer
=
PyCObject_AsVoidPtr
(
object
);
SignalBase
<
int
>*
signal
=
(
SignalBase
<
int
>*
)
pointer
;
SignalBase
<
int
>*
otherSignal
=
0
;
try
{
bool
plugged
=
signal
->
isPluged
();
otherSignal
=
signal
->
getPluged
();
if
(
!
plugged
||
otherSignal
==
0
)
{
std
::
string
msg
=
std
::
string
(
"Signal "
)
+
signal
->
getName
()
+
std
::
string
(
" is not plugged."
);
throw
std
::
runtime_error
(
msg
);
}
}
CATCH_ALL_EXCEPTIONS
();
// Return the pointer to the signal without destructor since the signal
// is not owned by the calling object.
return
PyCObject_FromVoidPtr
((
void
*
)
otherSignal
,
NULL
);
}
}
// namespace signalBase
}
// namespace python
}
// namespace dynamicgraph
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment