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<int> *> SignalList;
29  SignalList toTraceSignals;
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;
52  FileList files;
53  typedef std::list<std::string> NameList;
54  NameList names;
55  bool play;
56  int timeStart;
57 
58  public:
59  Tracer(const std::string n);
60  virtual ~Tracer() { closeFiles(); }
61 
62  void addSignalToTrace(const SignalBase<int> &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<int> &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<int> &sig);
85  int &recordTrigger(int &dummy, const int &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
NameList names
Definition: tracer.h:54
std::string rootdir
Definition: tracer.h:49
SignalTimeDependent< int, int > triger
Definition: tracer.h:93
double getFrequency()
Definition: tracer.h:81
std::string basename
Definition: tracer.h:47
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
void setTraceStyle(const TraceStyle &style)
Definition: tracer.h:77
TraceStyle traceStyle
Definition: tracer.h:43
dynamicgraph::SignalArray_const< double > sig
Definition: signal-all.cpp:25
TraceStyle getTraceStyle()
Definition: tracer.h:78
DYNAMIC_GRAPH_DLLAPI std::ostream & operator<<(std::ostream &os, const dynamicgraph::Entity &ent)
void setFrenquency(const double &frqu)
Definition: tracer.h:80
std::list< std::string > NameList
Definition: tracer.h:53
#define DYNAMIC_GRAPH_ENTITY_DECL()
Helper macro for entity declaration.
FileList files
Definition: tracer.h:52
Tracer plug-in main class.
Definition: tracer.h:24
SignalList toTraceSignals
Definition: tracer.h:29
std::string suffix
Definition: tracer.h:48
std::mutex files_mtx
Definition: tracer.h:30
std::list< std::ostream * > FileList
Definition: tracer.h:51
double frequency
Definition: tracer.h:45
std::list< const SignalBase< int > * > SignalList
Definition: tracer.h:28
virtual ~Tracer()
Definition: tracer.h:60


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03