tracer.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
3 // JRL, CNRS/AIST.
4 //
5 
6 #ifndef DYNAMIC_GRAPH_TRACER_H
7 #define DYNAMIC_GRAPH_TRACER_H
8 #include <dynamic-graph/entity.h>
13 
14 #include <boost/function.hpp>
15 #include <dynamic-graph/config-tracer.hh>
16 #include <list>
17 #include <mutex>
18 #include <string>
19 
20 namespace dynamicgraph {
24 class DG_TRACER_DLLAPI Tracer : public Entity {
26 
27  protected:
28  typedef std::list<const SignalBase<sigtime_t> *> SignalList;
30  std::mutex files_mtx;
31 
32  public:
33  enum TraceStyle {
34  WHEN_SAID
36  ,
37  EACH_TIME
39  ,
40  FREQUENTLY
42  };
44  static const TraceStyle TRACE_STYLE_DEFAULT = EACH_TIME;
45  double frequency;
46 
47  std::string basename;
48  std::string suffix;
49  std::string rootdir;
50  bool namesSet;
51  typedef std::list<std::ostream *> FileList;
53  typedef std::list<std::string> NameList;
55  bool play;
57 
58  public:
59  Tracer(const std::string n);
60  virtual ~Tracer() { closeFiles(); }
61 
62  void addSignalToTrace(const SignalBase<sigtime_t> &sig,
63  const std::string &filename = "");
64  void addSignalToTraceByName(const std::string &signame,
65  const std::string &filename = "");
66  void clearSignalToTrace();
67  // void parasite( SignalBase<int>& sig );
68  void openFiles(const std::string &rootdir, const std::string &basename,
69  const std::string &suffix);
70  virtual void closeFiles();
71 
72  protected:
73  virtual void openFile(const SignalBase<sigtime_t> &sig,
74  const std::string &filename);
75 
76  public:
77  void setTraceStyle(const TraceStyle &style) { traceStyle = style; }
78  TraceStyle getTraceStyle() { return traceStyle; }
79 
80  void setFrenquency(const double &frqu) { frequency = frqu; }
81  double getFrequency() { return frequency; }
82 
83  void record();
84  virtual void recordSignal(std::ostream &os, const SignalBase<sigtime_t> &sig);
85  sigtime_t &recordTrigger(sigtime_t &dummy, const sigtime_t &time);
86 
87  virtual void trace();
88  void start() { play = true; }
89  void stop() { play = false; }
90 
91  public:
92  // SignalTrigerer<int> triger;
94 
95  /* --- DISPLAY --------------------------------------------------------- */
96  DG_TRACER_DLLAPI friend std::ostream &operator<<(std::ostream &os,
97  const Tracer &t);
98 
99  /* --- PARAMS --- */
100  void display(std::ostream &os) const;
101 };
102 
103 } // end of namespace dynamicgraph
104 
105 #endif
entity.h
dynamicgraph::operator<<
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
Definition: src/dgraph/entity.cpp:174
signal-time-dependent.h
dynamicgraph::Tracer::namesSet
bool namesSet
Definition: tracer.h:50
dynamicgraph
dynamicgraph::Entity
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: include/dynamic-graph/entity.h:52
dynamicgraph::Tracer::FileList
std::list< std::ostream * > FileList
Definition: tracer.h:51
dynamicgraph::Tracer::basename
std::string basename
Definition: tracer.h:47
dynamicgraph::Tracer::stop
void stop()
Definition: tracer.h:89
dynamicgraph::Tracer::play
bool play
Definition: tracer.h:55
dynamicgraph::Tracer::files_mtx
std::mutex files_mtx
Definition: tracer.h:30
dynamicgraph::Tracer::SignalList
std::list< const SignalBase< sigtime_t > * > SignalList
Definition: tracer.h:28
dynamicgraph::Tracer::names
NameList names
Definition: tracer.h:54
dynamicgraph::Tracer::getFrequency
double getFrequency()
Definition: tracer.h:81
DYNAMIC_GRAPH_ENTITY_DECL
#define DYNAMIC_GRAPH_ENTITY_DECL()
Helper macro for entity declaration.
Definition: include/dynamic-graph/entity.h:38
dynamicgraph::Tracer::toTraceSignals
SignalList toTraceSignals
Definition: tracer.h:29
time-dependency.h
dynamicgraph::Tracer::suffix
std::string suffix
Definition: tracer.h:48
dynamicgraph::sigtime_t
int64_t sigtime_t
Definition: fwd.hh:12
signal-base.h
dynamicgraph::Tracer::rootdir
std::string rootdir
Definition: tracer.h:49
dynamicgraph::Tracer::setTraceStyle
void setTraceStyle(const TraceStyle &style)
Definition: tracer.h:77
dynamicgraph::Tracer::files
FileList files
Definition: tracer.h:52
sig
dynamicgraph::SignalArray_const< double > sig
Definition: signal-all.cpp:25
dynamicgraph::Tracer::getTraceStyle
TraceStyle getTraceStyle()
Definition: tracer.h:78
dynamicgraph::Tracer::frequency
double frequency
Definition: tracer.h:45
dynamicgraph::Tracer::NameList
std::list< std::string > NameList
Definition: tracer.h:53
dynamicgraph::SignalTimeDependent< sigtime_t, sigtime_t >
dynamicgraph::Tracer::timeStart
sigtime_t timeStart
Definition: tracer.h:56
dynamicgraph::Tracer::setFrenquency
void setFrenquency(const double &frqu)
Definition: tracer.h:80
exception-traces.h
dynamicgraph::Tracer::~Tracer
virtual ~Tracer()
Definition: tracer.h:60
dynamicgraph::Tracer::triger
SignalTimeDependent< sigtime_t, sigtime_t > triger
Definition: tracer.h:93
dynamicgraph::SignalBase< sigtime_t >
dynamicgraph::Tracer::start
void start()
Definition: tracer.h:88
dynamicgraph::Tracer::traceStyle
TraceStyle traceStyle
Definition: tracer.h:43
dynamicgraph::Tracer
Tracer plug-in main class.
Definition: tracer.h:24
dynamicgraph::Tracer::TraceStyle
TraceStyle
Definition: tracer.h:33


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Fri Aug 2 2024 08:36:38