Skip to content

Commit

Permalink
scripting: provide property to disable the zero period warning.
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Soetens <[email protected]>
  • Loading branch information
wixiw authored and Peter Soetens committed May 17, 2011
1 parent e013a1f commit 1ba99df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
21 changes: 17 additions & 4 deletions rtt/scripting/ScriptingService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ namespace RTT {
{
this->doc("Orocos Scripting service. Use this service in order to load or query programs or state machines.");
this->createInterface();
ZeroPeriodWarning = true;
this->addProperty("ZeroPeriodWarning",ZeroPeriodWarning)
.doc("If this is set to false, the warning log when loading a program or a state machine into a Component"
" with a null period will not be printed. Be sure you have something else triggering periodically"
" your Component activity unless your script may not work.");
}

ScriptingService::~ScriptingService()
Expand Down Expand Up @@ -189,8 +194,12 @@ namespace RTT {
if (this->recursiveCheckLoadStateMachine( sc ) == false)
return false; // throws load_exception

if ( getOwner()->getPeriod() == 0 ) {
log(Warning) << "Loading StateMachine "<< sc->getName() << " in a TaskContext with getPeriod() == 0. Use setPeriod(period) in order to setup execution of scripts." <<endlog();
if ( getOwner()->getPeriod() == 0 && ZeroPeriodWarning) {
log(Warning) << "Loading StateMachine "<< sc->getName()
<< " in a TaskContext with getPeriod() == 0."
<< " Use setPeriod(period) in order to setup execution of scripts."
<< " If you know what you are doing, you may disable this warning using scripting.ZeroPeriodWarning=false"
<<endlog();
}

this->recursiveLoadStateMachine( sc );
Expand Down Expand Up @@ -353,8 +362,12 @@ namespace RTT {
log(Error) << "Could not load Program "<< pi->getName() << " in ScriptingService: name already in use."<<endlog();
return false;
}
if ( getOwner()->getPeriod() == 0 ) {
log(Warning) << "Loading program " << pi->getName() << " in a TaskContext with getPeriod() == 0. Use setPeriod(period) in order to setup execution of scripts." <<endlog();
if ( getOwner()->getPeriod() == 0 && ZeroPeriodWarning ) {
log(Warning) << "Loading program " << pi->getName()
<< " in a TaskContext with getPeriod() == 0."
<< " Use setPeriod(period) in order to setup execution of scripts."
<< " If you know what you are doing, you may disable this warning using scripting.ZeroPeriodWarning=false"
<< endlog();
}
programs[pi->getName()] = pi;
pi->reset();
Expand Down
10 changes: 10 additions & 0 deletions rtt/scripting/ScriptingService.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,16 @@ namespace RTT
ProgMap programs;
typedef ProgMap::const_iterator ProgMapIt;

/** This is a property of the Scripting service
* It is true by default
* If this is set to false, the warning log when loading a program or a state machine
* into a Component with a null period will not be printed.
*
* Be sure you have something else triggering periodically your Component activity unless
* your script may not work.
*/
bool ZeroPeriodWarning;

};
}}

Expand Down

0 comments on commit 1ba99df

Please sign in to comment.