@@ -62,7 +62,7 @@ setPyInterpreter( dynamicgraph::python::Interpreter* ptr )
62
62
void PeriodicCall::
63
63
addSignal ( const std::string &name, SignalBase<int >& sig )
64
64
{
65
- signalMap[ name ] = &sig;
65
+ signalMap[ name ] = SignalToCall ( &sig) ;
66
66
return ;
67
67
}
68
68
@@ -75,6 +75,22 @@ addSignal( const std::string& sigpath )
75
75
return ;
76
76
}
77
77
78
+ void PeriodicCall::
79
+ addDownsampledSignal ( const std::string &name, SignalBase<int >& sig, const unsigned int & downsamplingFactor )
80
+ {
81
+ signalMap[ name ] = SignalToCall (&sig,downsamplingFactor);
82
+ return ;
83
+ }
84
+
85
+ void PeriodicCall::
86
+ addDownsampledSignal ( const std::string& sigpath, const unsigned int & downsamplingFactor )
87
+ {
88
+ istringstream sigISS ( sigpath );
89
+ SignalBase<int >& signal = ::dynamicgraph::PoolStorage::getInstance ()->getSignal ( sigISS );
90
+ addDownsampledSignal ( sigpath,signal,downsamplingFactor );
91
+ return ;
92
+ }
93
+
78
94
void PeriodicCall::
79
95
rmSignal ( const std::string &name )
80
96
{
@@ -111,7 +127,8 @@ runSignals( const int& t )
111
127
for ( SignalMapType::iterator iter = signalMap.begin ();
112
128
signalMap.end ()!=iter; ++iter )
113
129
{
114
- (*iter).second ->recompute ( t );
130
+ if (t%iter->second .downsamplingFactor == 0 )
131
+ (*iter).second .signal ->recompute ( t );
115
132
}
116
133
return ;
117
134
}
@@ -240,6 +257,8 @@ void PeriodicCall::addSpecificCommands(Entity& ent,
240
257
boost::function< void ( const std::string& ) >
241
258
addSignal = boost::bind ( &PeriodicCall::addSignal, this ,_1 ),
242
259
rmSignal = boost::bind ( &PeriodicCall::rmSignal, this ,_1 );
260
+ boost::function< void ( const std::string&, const unsigned int & ) >
261
+ addDownsampledSignal = boost::bind ( &PeriodicCall::addDownsampledSignal, this ,_1,_2);
243
262
boost::function< void ( void ) >
244
263
clear = boost::bind ( &PeriodicCall::clear, this );
245
264
boost::function< void ( std::ostream& ) >
@@ -249,6 +268,11 @@ void PeriodicCall::addSpecificCommands(Entity& ent,
249
268
makeCommandVoid1 (ent,addSignal,
250
269
docCommandVoid1 (" Add the signal to the refresh list" ,
251
270
" string (sig name)" )));
271
+ ADD_COMMAND (" addDownsampledSignal" ,
272
+ makeCommandVoid2 (ent,addDownsampledSignal,
273
+ docCommandVoid2 (" Add the signal to the refresh list" ,
274
+ " string (sig name)" ,
275
+ " unsigned int (downsampling factor, 1 means every time, 2 means every other time, etc..." )));
252
276
ADD_COMMAND (" rmSignal" ,
253
277
makeCommandVoid1 (ent,rmSignal,
254
278
docCommandVoid1 (" Remove the signal to the refresh list" ,
0 commit comments