From 7dd62e306b4d44c3a1ebe29d70b355052d2e7617 Mon Sep 17 00:00:00 2001 From: Mansard <nmansard@laas.fr> Date: Wed, 2 Feb 2011 13:15:27 +0100 Subject: [PATCH] Added new-style command for the two entities. --- include/dynamic-graph/tracer.h | 2 ++ src/traces/tracer-real-time.cpp | 19 +++++++++++ src/traces/tracer.cpp | 56 +++++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/include/dynamic-graph/tracer.h b/include/dynamic-graph/tracer.h index a56d627b..486526f7 100644 --- a/include/dynamic-graph/tracer.h +++ b/include/dynamic-graph/tracer.h @@ -98,6 +98,8 @@ namespace dynamicgraph int& recordTrigger( int& dummy, const int& time ); virtual void trace (); + void start() { play = true ; } + void stop() { play = false; } public: //SignalTrigerer<int> triger; diff --git a/src/traces/tracer-real-time.cpp b/src/traces/tracer-real-time.cpp index a71ed467..b1681576 100644 --- a/src/traces/tracer-real-time.cpp +++ b/src/traces/tracer-real-time.cpp @@ -30,6 +30,7 @@ #include <dynamic-graph/debug.h> #include <dynamic-graph/pool.h> #include <dynamic-graph/factory.h> +#include <dynamic-graph/all-commands.h> using namespace std; using namespace dynamicgraph; @@ -116,6 +117,24 @@ TracerRealTime::TracerRealTime( const std::string n ) ,bufferSize( BUFFER_SIZE_DEFAULT ) { dgDEBUGINOUT(15); + + /* --- Commands --- */ + { + using namespace dynamicgraph::command; + std::string doc + = docCommandVoid0("Trash the current content of the buffers, without saving it."); + addCommand("empty", + makeCommandVoid0(*this,&TracerRealTime::emptyBuffers,doc )); + + addCommand("getBufferSize", + makeDirectGetter(*this,&bufferSize, + docDirectGetter("bufferSize","int"))); + addCommand("setBufferSize", + makeDirectSetter(*this,&bufferSize, + docDirectSetter("bufferSize","int"))); + } // using namespace command + + dgDEBUGOUT(15); } /* --------------------------------------------------------------------- */ diff --git a/src/traces/tracer.cpp b/src/traces/tracer.cpp index 23dfa18c..c4cb373b 100644 --- a/src/traces/tracer.cpp +++ b/src/traces/tracer.cpp @@ -27,6 +27,7 @@ #include <dynamic-graph/debug.h> #include <dynamic-graph/pool.h> #include <dynamic-graph/factory.h> +#include <dynamic-graph/all-commands.h> #include <boost/bind.hpp> using namespace std; @@ -56,6 +57,57 @@ Tracer::Tracer( const std::string n ) "Tracer("+n+")::triger" ) { signalRegistration( triger ); + + + /* --- Commands --- */ + { + using namespace dynamicgraph::command; + std::string doc; + + doc = docCommandVoid2("Add a new signal to trace.", + "string (signal name)","string (filename, empty for default"); + addCommand("add", + makeCommandVoid2(*this,&Tracer::addSignalToTraceByName,doc )); + + doc = docCommandVoid0("Remove all signals. If necessary, close open files."); + addCommand("clear", + makeCommandVoid0(*this,&Tracer::clearSignalToTrace,doc )); + + doc = docCommandVoid3("Gives the args for file opening, and " + "if signals have been set, open the corresponding files.", + "string (dirname)","string (prefix)","string (suffix)"); + addCommand("open", + makeCommandVoid3(*this,&Tracer::openFiles,doc )); + + doc = docCommandVoid0("Close all the open files."); + addCommand("close", + makeCommandVoid0(*this,&Tracer::closeFiles,doc )); + + doc = docCommandVoid0("If necessary, dump " + "(can be done automatically for some traces type)."); + addCommand("dump", + makeCommandVoid0(*this,&Tracer::trace,doc )); + + doc = docCommandVoid0("Start the tracing process."); + addCommand("start", + makeCommandVoid0(*this,&Tracer::start,doc )); + + doc = docCommandVoid0("Stop temporarily the tracing process."); + addCommand("stop", + makeCommandVoid0(*this,&Tracer::stop,doc )); + + + doc = docCommandVoid0("Stop temporarily the tracing process."); + addCommand("stop", + makeCommandVoid0(*this,&Tracer::stop,doc )); + + addCommand("getTimeStart", + makeDirectGetter(*this,&timeStart, + docDirectGetter("timeStart","int"))); + addCommand("setTimeStart", + makeDirectSetter(*this,&timeStart, + docDirectSetter("timeStart","int"))); + } // using namespace command } /* --------------------------------------------------------------------- */ @@ -93,11 +145,11 @@ addSignalToTraceByName( const string& signame, void Tracer:: clearSignalToTrace () { + closeFiles (); toTraceSignals.clear (); triger.clearDependencies (); } - // void Tracer:: // parasite( SignalBase<int>& sig ) // { @@ -314,8 +366,6 @@ commandLine( const std::string& cmdLine { os << "timeStart = " << timeStart << std::endl; } else { cmdArgs >> timeStart; } } - - else //sotTaskAbstract:: Entity::commandLine( cmdLine,cmdArgs,os ); -- GitLab