22 #include <boost/bind.hpp> 34 Tracer::Tracer(
const std::string n)
37 traceStyle(TRACE_STYLE_DEFAULT),
48 "Tracer(" + n +
")::triger") {
56 doc =
docCommandVoid2(
"Add a new signal to trace.",
"string (signal name)",
57 "string (filename, empty for default");
67 "Gives the args for file opening, and " 68 "if signals have been set, open the corresponding files.",
69 "string (dirname)",
"string (prefix)",
"string (suffix)");
77 "(can be done automatically for some traces type).");
100 const string &filename) {
106 names.push_back(filename);
112 const string &filename) {
114 istringstream iss(signame);
137 const std::string &basename_,
138 const std::string &suffix_) {
140 std::basic_string<char>::size_type n = rootdir_.length();
150 NameList::const_iterator iterName =
names.begin();
152 dgDEBUG(15) <<
"Open <" << (*iter)->getName() <<
"> in <" << *iterName
153 <<
">." << std::endl;
166 if (givenname.length()) {
174 dgDEBUG(5) <<
"Sig <" << sig.
getName() <<
">: new file " << filename << endl;
175 std::ofstream *newfile =
new std::ofstream(filename.c_str());
176 files.push_back(newfile);
182 std::lock_guard<std::mutex> files_lock(
files_mtx);
184 for (FileList::iterator iter =
files.begin();
files.end() != iter; ++iter) {
185 std::ostream *filePtr = *iter;
207 std::unique_lock<std::mutex> files_lock(
files_mtx, std::try_to_lock);
208 if (!files_lock.owns_lock()) {
216 " (file=%d != %d=sig).",
files.size(),
220 FileList::iterator iterFile =
files.begin();
224 dgDEBUG(45) <<
"Try..." << endl;
242 os << exc << std::endl;
244 os <<
"Unknown error occurred while reading signal." << std::endl;
251 dgDEBUGIN(15) <<
" time=" << time << endl;
264 os << CLASS_NAME <<
" " <<
name <<
" [mode=" << (
play ?
"play" :
"pause")
266 <<
" - Dep list: " << endl;
269 os <<
" -> " << (*iter)->getName() << endl;
virtual void trace(std::ostream &) const
SignalTimeDependent< int, int > triger
std::string docDirectGetter(const std::string &name, const std::string &type)
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
DirectGetter< E, T > * makeDirectGetter(E &entity, T *ptr, const std::string &docString)
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
virtual void openFile(const SignalBase< int > &sig, const std::string &filename)
#define dgDEBUGOUT(level)
void signalRegistration(const SignalArray< int > &signals)
void openFiles(const std::string &rootdir, const std::string &basename, const std::string &suffix)
void addSignalToTraceByName(const std::string &signame, const std::string &filename="")
#define dgDEBUGINOUT(level)
dynamicgraph::SignalArray_const< double > sig
int & recordTrigger(int &dummy, const int &time)
std::string docCommandVoid0(const std::string &doc)
std::string docCommandVoid3(const std::string &doc, const std::string &type1, const std::string &type2, const std::string &type3)
const std::string & getName() const
void clearSignalToTrace()
virtual void closeFiles()
CommandVoid3< E, T1, T2, T3 > * makeCommandVoid3(E &entity, typename CommandVoid3< E, T1, T2, T3 >::function_t function, const std::string &docString)
void display(std::ostream &os) const
Display information on the entity inside the output stream os.
virtual void addDependency(const SignalBase< Time > &signal)
std::string shortName() const
static PoolStorage * getInstance()
Get unique instance of the class.
Abstract root class for all dynamic-graph exceptions.
void dgDEBUGF(const int, const char *,...)
Tracer plug-in main class.
void addSignalToTrace(const SignalBase< int > &sig, const std::string &filename="")
DYNAMIC_GRAPH_DLLAPI SignalArray< int > sotNOSIGNAL
SignalList toTraceSignals
std::string docCommandVoid2(const std::string &doc, const std::string &type1, const std::string &type2)
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(Tracer, "Tracer")
Exceptions raised when an error related to traces happen.
SignalBase< int > & getSignal(std::istringstream &sigpath)
Get a signal by name.
void addCommand(const std::string &name, command::Command *command)
Add a command to Entity.
virtual const Time & getTime() const
virtual void recordSignal(std::ostream &os, const SignalBase< int > &sig)
virtual void clearDependencies()
std::string docDirectSetter(const std::string &name, const std::string &type)
DG_TRACER_DLLAPI friend std::ostream & operator<<(std::ostream &os, const Tracer &t)
#define dgDEBUGIN(level)
VP_DEBUG.
DirectSetter< E, T > * makeDirectSetter(E &entity, T *ptr, const std::string &docString)
CommandVoid2< E, T1, T2 > * makeCommandVoid2(E &entity, boost::function< void(const T1 &, const T2 &)> function, const std::string &docString)