periodic-call.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 /* --------------------------------------------------------------------- */
11 /* --- INCLUDE --------------------------------------------------------- */
12 /* --------------------------------------------------------------------- */
13 
14 /* --- SOT --- */
17 #include <dynamic-graph/pool.h>
18 
19 #include <algorithm>
20 #include <sot/core/debug.hh>
23 
24 using namespace std;
25 using namespace dynamicgraph;
26 using namespace dynamicgraph::sot;
27 
28 /* --------------------------------------------------------------------- */
29 /* --- CLASS ----------------------------------------------------------- */
30 /* --------------------------------------------------------------------- */
31 
32 PeriodicCall::PeriodicCall(void) : signalMap(), innerTime(0) {}
33 
34 /* --------------------------------------------------------------------- */
35 /* --------------------------------------------------------------------- */
36 /* --------------------------------------------------------------------- */
37 void PeriodicCall::addSignal(const std::string &name,
40  return;
41 }
42 
43 void PeriodicCall::addSignal(const std::string &sigpath) {
44  istringstream sigISS(sigpath);
45  SignalBase<sigtime_t> &signal =
47  addSignal(sigpath, signal);
48  return;
49 }
50 
51 void PeriodicCall::addDownsampledSignal(const std::string &name,
53  const std::size_t &downsamplingFactor) {
54  signalMap[name] = SignalToCall(&sig, downsamplingFactor);
55  return;
56 }
57 
58 void PeriodicCall::addDownsampledSignal(const std::string &sigpath,
59  const std::size_t &downsamplingFactor) {
60  istringstream sigISS(sigpath);
61  SignalBase<sigtime_t> &signal =
63  addDownsampledSignal(sigpath, signal, downsamplingFactor);
64  return;
65 }
66 
67 void PeriodicCall::rmSignal(const std::string &name) {
68  signalMap.erase(name);
69  return;
70 }
71 
72 /* --------------------------------------------------------------------- */
73 /* --------------------------------------------------------------------- */
74 /* --------------------------------------------------------------------- */
76  for (SignalMapType::iterator iter = signalMap.begin();
77  signalMap.end() != iter; ++iter) {
78  if (t % iter->second.downsamplingFactor == 0)
79  (*iter).second.signal->recompute(t);
80  }
81  return;
82 }
83 
85  runSignals(t);
86  return;
87 }
88 
89 /* --------------------------------------------------------------------- */
90 /* --------------------------------------------------------------------- */
91 /* --------------------------------------------------------------------- */
92 
93 void PeriodicCall::display(std::ostream &os) const {
94  os << " (t=" << innerTime << ")" << endl;
95 
96  os << " -> SIGNALS:" << endl;
97  for (SignalMapType::const_iterator iter = signalMap.begin();
98  signalMap.end() != iter; ++iter) {
99  os << " - " << (*iter).first << endl;
100  }
101 }
102 
103 /*
104 static std::string readLineStr( istringstream& args )
105 {
106  stringbuf* pbuf=args.rdbuf();
107  const std::streamsize size = pbuf->in_avail();
108  char * buffer = new char[ size+1 ];
109  pbuf->sgetn( buffer,size );
110 
111  buffer[size]='\0';
112  std::string res( buffer );
113  delete [] buffer;
114  return res;
115 }
116 */
117 
118 /*
119  * Local variables:
120  * c-basic-offset: 2
121  * End:
122  */
dynamicgraph::PoolStorage::getSignal
SignalBase< sigtime_t > & getSignal(std::istringstream &sigpath)
dynamicgraph
exception-factory.h
dynamicgraph::sot::PeriodicCall::SignalToCall
Definition: periodic-call.hh:39
dynamicgraph::sot::PeriodicCall::innerTime
sigtime_t innerTime
Definition: periodic-call.hh:57
dynamicgraph::sot::PeriodicCall::run
void run(const sigtime_t &t)
Definition: periodic-call.cpp:84
dynamicgraph::sot::PeriodicCall::rmSignal
void rmSignal(const std::string &name)
Definition: periodic-call.cpp:67
debug.hh
dynamicgraph::sot::PeriodicCall::addSignal
void addSignal(const std::string &name, dynamicgraph::SignalBase< sigtime_t > &sig)
Definition: periodic-call.cpp:37
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::PeriodicCall::display
void display(std::ostream &os) const
Definition: periodic-call.cpp:93
periodic-call.hh
dynamicgraph::sot::PeriodicCall::signalMap
SignalMapType signalMap
Definition: periodic-call.hh:55
dynamicgraph::PoolStorage::getInstance
static PoolStorage * getInstance()
Definition: pool.cpp:147
dynamicgraph::sot
exception-tools.hh
dynamicgraph::sot::PeriodicCall::runSignals
void runSignals(const sigtime_t &t)
Definition: periodic-call.cpp:75
t
Transform3f t
sig
Signal< dynamicgraph::Matrix, sigtime_t > sig("matrix")
all-commands.h
dynamicgraph::SignalBase< sigtime_t >
dynamicgraph::sot::PeriodicCall::addDownsampledSignal
void addDownsampledSignal(const std::string &name, dynamicgraph::SignalBase< sigtime_t > &sig, const std::size_t &downsamplingFactor)
Definition: periodic-call.cpp:51
compile.name
name
Definition: compile.py:23


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31