Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches and bugfixes from upstream pull requests #2

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
673 changes: 673 additions & 0 deletions doc/xml/images/Master-Slave-Semantics.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,349 changes: 1,349 additions & 0 deletions doc/xml/images/OperationCallvsSend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
503 changes: 503 additions & 0 deletions doc/xml/images/StateMachineFlow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
751 changes: 751 additions & 0 deletions doc/xml/images/StateMachineSteps-SleepAfterEntry.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
747 changes: 747 additions & 0 deletions doc/xml/images/StateMachineSteps-SleepAfterRun.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
<build_depend>boost</build_depend>
<build_depend>omniorb</build_depend>
<build_depend>pkg-config</build_depend>
<build_depend>log4cpp</build_depend>

<run_depend>boost</run_depend>
<run_depend>omniorb</run_depend>
<run_depend>xpath-perl</run_depend>
<run_depend>pkg-config</run_depend>
<run_depend>log4cpp</run_depend>

<export>
<build_type>cmake</build_type>
Expand Down
2 changes: 1 addition & 1 deletion rtt/PropertyBag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ namespace RTT
temp->update( (*sit) );
}
// step 3 : add result to target bag.
target.add( temp );
target.ownProperty( temp );
}
}
++it;
Expand Down
26 changes: 13 additions & 13 deletions rtt/marsh/CPFDemarshaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,38 +143,38 @@ namespace RTT
if ( type == "boolean" )
{
if ( value_string == "1" || value_string == "true")
bag_stack.top().first->add
bag_stack.top().first->ownProperty
( new Property<bool>( name, description, true ) );
else if ( value_string == "0" || value_string == "false" )
bag_stack.top().first->add
bag_stack.top().first->ownProperty
( new Property<bool>( name, description, false ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain '0' or '1', got '"+ value_string +"'.").c_str());
}
else if ( type == "char" ) {
if ( value_string.empty() )
bag_stack.top().first->add( new Property<char>( name, description, '\0' ) );
bag_stack.top().first->ownProperty( new Property<char>( name, description, '\0' ) );
else
if ( value_string.length() != 1 )
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain a single character, got '"+ value_string +"'.").c_str());
else
bag_stack.top().first->add( new Property<char>( name, description, value_string[0] ) );
bag_stack.top().first->ownProperty( new Property<char>( name, description, value_string[0] ) );
}
else if ( type == "uchar" || type == "octet" ) {
if ( value_string.length() != 1 )
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain a single unsigned character, got '"+ value_string +"'.").c_str());
else
bag_stack.top().first->add
bag_stack.top().first->ownProperty
( new Property<unsigned char>( name, description, value_string[0] ) );
}
else if ( type == "long" || type == "short")
{
int v;
if ( sscanf(value_string.c_str(), "%d", &v) == 1)
bag_stack.top().first->add( new Property<int>( name, description, v ) );
bag_stack.top().first->ownProperty( new Property<int>( name, description, v ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain an integer value, got '"+ value_string +"'.").c_str());
Expand All @@ -183,7 +183,7 @@ namespace RTT
{
unsigned int v;
if ( sscanf(value_string.c_str(), "%u", &v) == 1)
bag_stack.top().first->add( new Property<unsigned int>( name, description, v ) );
bag_stack.top().first->ownProperty( new Property<unsigned int>( name, description, v ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain an integer value, got '"+ value_string +"'.").c_str());
Expand All @@ -192,7 +192,7 @@ namespace RTT
{
long long v;
if ( sscanf(value_string.c_str(), "%lld", &v) == 1)
bag_stack.top().first->add( new Property<long long>( name, description, v ) );
bag_stack.top().first->ownProperty( new Property<long long>( name, description, v ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain an integer value, got '"+ value_string +"'.").c_str());
Expand All @@ -201,7 +201,7 @@ namespace RTT
{
unsigned long long v;
if ( sscanf(value_string.c_str(), "%llu", &v) == 1)
bag_stack.top().first->add( new Property<unsigned long long>( name, description, v ) );
bag_stack.top().first->ownProperty( new Property<unsigned long long>( name, description, v ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain an integer value, got '"+ value_string +"'.").c_str());
Expand All @@ -210,7 +210,7 @@ namespace RTT
{
double v;
if ( sscanf(value_string.c_str(), "%lf", &v) == 1 )
bag_stack.top().first->add
bag_stack.top().first->ownProperty
( new Property<double>( name, description, v ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
Expand All @@ -220,14 +220,14 @@ namespace RTT
{
float v;
if ( sscanf(value_string.c_str(), "%f", &v) == 1 )
bag_stack.top().first->add
bag_stack.top().first->ownProperty
( new Property<float>( name, description, v ) );
else
throw SAXException(std::string("Wrong value for property '"+type+"'." \
" Value should contain a float value, got '"+ value_string +"'.").c_str());
}
else if ( type == "string")
bag_stack.top().first->add
bag_stack.top().first->ownProperty
( new Property<std::string>( name, description, value_string ) );
tag_stack.pop();
value_string.clear(); // cleanup
Expand All @@ -240,7 +240,7 @@ namespace RTT
{
Property<PropertyBag>* prop = bag_stack.top().second;
bag_stack.pop();
bag_stack.top().first->add( prop );
bag_stack.top().first->ownProperty( prop );
//( new Property<PropertyBag>( pn, description, *pb ) );
//delete pb;
tag_stack.pop();
Expand Down
1 change: 1 addition & 0 deletions rtt/scripting/CallFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace RTT

~CallFunction() {
this->reset();
delete minit;
}

virtual bool execute() {
Expand Down
1 change: 1 addition & 0 deletions rtt/scripting/CmdFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace RTT

~CmdFunction() {
this->reset();
delete minit;
}

virtual SendStatus get() const {
Expand Down
30 changes: 15 additions & 15 deletions rtt/scripting/StateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,14 @@ namespace RTT {
bool StateMachine::execute()
{
TRACE_INIT();
os::MutexLock lock(execlock);

// before dealing with transitional states,
// check if we're actually running.
if (smStatus == Status::inactive || smStatus == Status::unloaded) {
smpStatus = nill;
return true;
}
os::MutexLock lock(execlock);

#ifdef ASSERT_PROPER_EXECUTION_CYCLES
// we're loaded. Do some sanity checking.
Expand Down Expand Up @@ -476,7 +477,7 @@ namespace RTT {
}
else
{
TRACE("Transition triggered from '"+ (current ? current->getName() : "null") +"' to '"+(newState ? newState->getName() : "null")+"'.");
TRACE("Transition triggered from '"+ (current ? current->getName() : "(null)") +"' to '"+(newState ? newState->getName() : "(null)")+"'.");
// reset handle and run, in case it is still set ( during error
// or when an event arrived ).
//currentRun = 0;
Expand All @@ -487,7 +488,6 @@ namespace RTT {
smStatus = Status::error;

}
next = newState;
currentTrans = transProg;

next = newState;
Expand Down Expand Up @@ -1035,14 +1035,14 @@ namespace RTT {
if ( inError() )
return false;

TRACE("executePreCheck..." );
// TRACE("executePreCheck..." );
// first try to finish the current entry program (this only happens if entry was not atomically implemented, ie yielding):
if ( currentEntry ) {
TRACE("Executing entry program of '"+ current->getName() +"'" );
TRACE("Executing entry program of '"+ (current ? current->getName() : "(null)") +"'" );
if ( this->executeProgram(currentEntry, stepping) == false )
return false;
// done.
TRACE("Finished entry program of '"+ current->getName() +"'" );
TRACE("Finished entry program of '"+ (current ? current->getName() : "(null)") +"'" );
// in stepping mode, delay 'true' one executePending().
if ( stepping ) {
currentProg = currentRun;
Expand All @@ -1052,7 +1052,7 @@ namespace RTT {

// Run is executed before the transitions.
if ( currentRun ) {
TRACE("Executing run program of '"+ current->getName() +"'" );
TRACE("Executing run program of '"+ (current ? current->getName() : "(null)") +"'" );
if ( this->executeProgram(currentRun, stepping) == false )
return true;
// done.
Expand All @@ -1068,7 +1068,7 @@ namespace RTT {
if ( inError() )
return false;

TRACE("executePostCheck..." );
// TRACE("executePostCheck..." );
// if a transition has been scheduled, proceed directly instead of doing a run:
if ( currentTrans ) {
TRACE("Executing transition program from '"+ (current ? current->getName() : "(null)") + "' to '"+ ( next ? next->getName() : "(null)")+"'" );
Expand All @@ -1090,7 +1090,7 @@ namespace RTT {

// last is exit
if ( currentExit ) {
TRACE("Executing exit program from '"+ current->getName() + "' (going to '"+ (next ? next->getName() : "(null)") +"')" );
TRACE("Executing exit program from '"+ (current ? current->getName() : "(null)") + "' (going to '"+ (next ? next->getName() : "(null)") +"')" );
if ( this->executeProgram(currentExit, stepping) == false )
return false;
// done.
Expand Down Expand Up @@ -1132,7 +1132,7 @@ namespace RTT {

// finally, execute the current Entry of the new state:
if ( currentEntry ) {
TRACE("Executing entry program of '"+ current->getName() +"'" );
TRACE("Executing entry program of '"+ (current ? current->getName() : "(null)") +"'" );
if ( this->executeProgram(currentEntry, stepping) == false )
return false;
// done.
Expand All @@ -1150,7 +1150,7 @@ namespace RTT {

// Handle is executed after the transitions failed.
if ( currentHandle ) {
TRACE("Executing handle program of '"+ current->getName() +"'" );
TRACE("Executing handle program of '"+ (current ? current->getName() : "(null)") +"'" );
if ( this->executeProgram(currentHandle, stepping) == false )
return false;
// done.
Expand Down Expand Up @@ -1233,6 +1233,7 @@ namespace RTT {
TRACE("Won't activate: already active.");
return false;
}
os::MutexLock lock(execlock);

smpStatus = nill;

Expand Down Expand Up @@ -1262,8 +1263,6 @@ namespace RTT {

// execute the entry program of the initial state.
if ( !inError() ) {
enableEvents(current);

if ( this->executePreCheck() ) {
smStatus = Status::active;
TRACE("Activated.");
Expand Down Expand Up @@ -1300,9 +1299,10 @@ namespace RTT {
currentTrans = 0;
// if we stalled, in previous deactivate
// even skip/stop exit program.
if ( next != 0 && current )
if ( next != 0 && current ) {
leaveState( current );
else {
disableEvents(current);
} else {
currentExit = 0;
currentTrans = 0;
}
Expand Down
7 changes: 4 additions & 3 deletions rtt/scripting/StateMachineService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ namespace RTT
if (instantiate) {
// Remove any remaining SendHandleAlias attributes, since they are not allowed for an instantiate...
// See SendHandleAlias::copy() for more details.
for ( ConfigurationInterface::map_t::iterator it = values.begin(); it != values.end(); ++it) {
for ( ConfigurationInterface::map_t::iterator it = values.begin(); it != values.end(); ) {
if (dynamic_cast<SendHandleAlias*>(*it)) {
values.erase(it);
it = values.begin();
it = values.erase(it);
} else {
++it;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/corba_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class CorbaTest : public OperationsFixture
pint1("pint1", "", 3), pdouble1(new Property<double>("pdouble1", "", -3.0)),
aint1(3), adouble1(-3.0), wait(0)
{
// connect DataPorts
// check operations (moved from OperationCallerComponent constructor for reuseability in corba-ipc-server)
BOOST_REQUIRE( caller->ready() );

// connect DataPorts
mi1 = new InputPort<double> ("mi");
mo1 = new OutputPort<double> ("mo");

Expand Down
16 changes: 11 additions & 5 deletions tests/operations_fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ class OperationCallerComponent : public TaskContext
opc3 = tc->provides("methods")->getOperation("m3");
opc3.setCaller( this->engine() );

BOOST_REQUIRE( opc0.ready() );
BOOST_REQUIRE( opc1.ready() );
BOOST_REQUIRE( opc2.ready() );
BOOST_REQUIRE( opc3.ready() );

// four combinations are possible:
this->addOperation("o0", &OperationCallerComponent::m0, this, OwnThread);
this->addOperation("o1", &OperationCallerComponent::m1, this, ClientThread);
Expand All @@ -71,6 +66,17 @@ class OperationCallerComponent : public TaskContext
// but do set the caller to this component.
}

bool ready() {
BOOST_REQUIRE( opc0.ready() );
BOOST_REQUIRE( opc1.ready() );
BOOST_REQUIRE( opc2.ready() );
BOOST_REQUIRE( opc3.ready() );
return opc0.ready() &&
opc1.ready() &&
opc2.ready() &&
opc3.ready();
}

// plain argument tests:
double m0(void) { return opc0(); }
double m1(int i) { return opc1(i); }
Expand Down
4 changes: 2 additions & 2 deletions tests/state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#define ORO_SIGNALLING_OPERATIONS

#include "unit.hpp"

#include <rtt-config.h>
Expand Down Expand Up @@ -847,7 +847,7 @@ BOOST_AUTO_TEST_CASE( testStateYieldbySend )
+ " do test.assert(false); }\n"
+ " transition o_event(d) select NEXT;\n"
+ " transitions {\n"
+ " select FINI\n"
+ " if test.i == 10 then select FINI\n"
+ " }\n"
+ " }\n"
+ " state NEXT {\n" // Success state.
Expand Down