From 87872a58600c4660223da81474b6cfc61897d202 Mon Sep 17 00:00:00 2001
From: Thomas Moulard <thomas.moulard@gmail.com>
Date: Fri, 30 Sep 2011 15:04:03 +0200
Subject: [PATCH] Add tools.py file containing addTrace.

---
 src/CMakeLists.txt         |  1 +
 src/dynamic_graph/tools.py | 27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 src/dynamic_graph/tools.py

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3cf2f97..1938343 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -111,6 +111,7 @@ SET (PYTHON_SOURCES
     dynamic_graph/signal_base.py
     dynamic_graph/matlab.py
     dynamic_graph/script_shortcuts.py
+    dynamic_graph/tools.py
 )
 
 SET (PYTHON_SOURCES_FULLPATH "")
diff --git a/src/dynamic_graph/tools.py b/src/dynamic_graph/tools.py
new file mode 100644
index 0000000..1b47058
--- /dev/null
+++ b/src/dynamic_graph/tools.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Copyright 2011, Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST
+#
+# This file is part of dynamic-graph.
+# dynamic-graph is free software: you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation, either version 3 of
+# the License, or (at your option) any later version.
+#
+# dynamic-graph is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Lesser Public License for more details.  You should have
+# received a copy of the GNU Lesser General Public License along with
+# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import print_function
+
+def addTrace(robot, trace, entityName, signalName, autoRecompute = True):
+    """
+    Add a signal to a tracer and recompute it automatically if necessary.
+    """
+    signal = '{0}.{1}'.format(entityName, signalName)
+    filename = '{0}-{1}'.format(entityName, signalName)
+    trace.add(signal, filename)
+    if autoRecompute:
+        robot.device.after.addSignal(signal)
-- 
GitLab