_Valid = false ;
_Executable = false ;
_Done = false ;
+ _NodeAborted = false ;
_Threads = 0 ;
_ControlState = SUPERV::VoidState ;
_State = GraphExecutor::UnKnownState ;
const char *DataFlowName ,
const char * DebugFileName ,
const SUPERV::KindOfNode aKindOfNode ) {
-// Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
Set_prof_debug( ORB , DebugFileName ) ;
- cdebug_in << "GraphExecutor::OutNode::OutNode(" << DataFlowName << " , " << aKindOfNode << ")" << endl;
+ cdebug_in << "GraphExecutor::OutNode::OutNode(" << DataFlowName << " , " << DebugFileName
+ << " , " << aKindOfNode << ")" << endl;
if ( aKindOfNode == SUPERV::DataFlowGraph ) {
_StreamGraph = NULL ;
-// _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;
_Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
_prof_debug , _fdebug ) ;
}
else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
-// _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;;
_StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
_prof_debug , _fdebug ) ;
_Graph = _StreamGraph ;
_Valid = false ;
_Executable = false ;
_Done = false ;
+ _NodeAborted = false ;
_Threads = 0 ;
_ControlState = SUPERV::VoidState ;
_State = GraphExecutor::UnKnownState ;
const char * DataFlowComputer ,
const char * DataFlowComment ,
const char * DebugFileName ) {
-// Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
-// DataFlowInterfaceName , DataFlowName , DataFlowkind ,
-// DataFlowFirstCreation , DataFlowLastModification ,
-// DataFlowEditorRelease , DataFlowAuthor ,
-// DataFlowComputer , DataFlowComment , DebugFileName ) {
Set_prof_debug( ORB , DebugFileName ) ;
- cdebug_in << "GraphExecutor::OutNode::OutNode(" << DataFlowName << " , " << DataFlowkind << ")" << endl;
+ cdebug_in << "GraphExecutor::OutNode::OutNode(" << DataFlowComponentName << " , "
+ << DataFlowInterfaceName << " , " << DataFlowName << " , " << DataFlowkind << ")"
+ << " , ... , " << DebugFileName << ")" << endl;
if ( DataFlowkind == SUPERV::DataFlowGraph ) {
_StreamGraph = NULL ;
_Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
_Valid = false ;
_Executable = false ;
_Done = false ;
+ _NodeAborted = false ;
_Threads = 0 ;
_ControlState = SUPERV::VoidState ;
_State = GraphExecutor::UnKnownState ;
if ( RetVal ) {
IsValid() ;
RetVal = LoadDatas( (*aDataFlow).Datas ) ;
- IsExecutable() ;
+// IsExecutable() ;
if ( !RetVal) {
cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error."
<< endl ;
else {
cdebug << "GraphExecutor::OutNode::LoadDataFlow ServiceName Error." << endl ;
}
- cdebug_out << "GraphExecutor::OutNode::LoadDataFlow " << Graph()->Name() << " RetVal "
+ cdebug_out << "GraphExecutor::OutNode::LoadDataFlow " << Name() << " RetVal "
<< RetVal << endl ;
return RetVal ;
}
int i ;
for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
GraphBase::SLink aLink = aListOfDatas[ i ] ;
- if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) )
+ if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) )
RetVal = Graph()->AddInputData( aLink.ToNodeName.c_str() ,
aLink.ToServiceParameterName.c_str() ,
aLink.aLinkValue ) ;
-// else if ( !strcmp( aLink.ToNodeName.c_str() , Graph()->Name() ) ) {
+// else if ( !strcmp( aLink.ToNodeName.c_str() , Name() ) ) {
// RetVal = Graph()->AddOutputData( aLink.FromNodeName.c_str() ,
// aLink.FromServiceParameterName.c_str() ) ;
// Graph()->AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
// }
else {
cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName
- << " and " << aLink.ToNodeName << " differents from " << Graph()->Name()
+ << " and " << aLink.ToNodeName << " differents from " << Name()
<< endl ;
RetVal = false ;
}
bool GraphExecutor::OutNode::Valid() {
cdebug_in << "GraphExecutor::OutNode::Valid" << endl;
-
+ bool RetVal = true ;
+ Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
if ( _Valid )
return true ;
if ( !Graph()->CreateService() ) {
cdebug_out << "This DataFlow has invalid type(s)." << endl ;
- return false ;
+ RetVal = false ;
}
int SubStreamGraphsNumber = 0 ;
if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
cdebug_out << "This DataFlow is not valid." << endl ;
- return false ;
+ RetVal = false ;
}
if ( Graph()->IsDataStreamNode() ) {
StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
if ( !Graph()->ValidLoops() ) {
cdebug_out << "This DataFlow have not valid Loops." << endl ;
- return false ;
+ RetVal = false ;
}
if ( !Graph()->ValidSwitchs() ) {
cdebug_out << "This DataFlow have not valid Switchs." << endl ;
- return false ;
+ RetVal = false ;
}
// CreateService() ;
Graph()->ComputingNodes() ;
-
- _Valid = true ;
+ if ( RetVal ) {
+ _Valid = true ;
+ }
- cdebug_out << "GraphExecutor::OutNode::Valid " << _Valid << endl;
- return _Valid ;
+ cdebug_out << "GraphExecutor::OutNode::Valid " << _Valid << " RetVal " << RetVal << endl;
+ return RetVal ;
}
-
bool GraphExecutor::OutNode::Executable() {
-
cdebug_in << "GraphExecutor::OutNode::Executable" << endl;
- if ( !IsValid() )
- return false ;
+ bool RetVal = true ;
+ if ( !IsValid() ) {
+ RetVal = false ;
+ }
- if ( Graph()->DataServerNodes() )
- _Executable = true ;
+ if ( Graph()->DataServerNodes() ) {
+ if ( RetVal ) {
+ _Executable = true ;
+ }
+ }
else {
cdebug << "This DataFlow is not executable." << endl ;
_Executable = false ;
+ RetVal = false ;
}
cdebug_out << "GraphExecutor::OutNode::Executable " << _Executable << endl;
Done( true ) ;
cdebug_out << "GraphExecutor::OutNode::Run InitPythonFunctions ERROR "
<< anInNode->Name() << endl ;
- return false ;
+ RetVal = false ;
}
}
}
*/
if ( Graph()->GraphMacroLevel() != 0 ) {
cdebug << "GraphExecutor::OutNode::Run Execution starting GraphExecutor::Action_DataOk_RunService Node "
- << Graph()->Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
+ << Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
GraphExecutor::DataUndefState ) ;
}
else {
cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
- << Graph()->Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
+ << Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
PushEvent( NULL , GraphExecutor::ReadyEvent ,
GraphExecutor::DataReadyState ) ;
State( GraphExecutor::DataReadyState ) ;
// PushEvent( anInNode , GraphExecutor::ReadyEvent ,
// GraphExecutor::DataReadyState ) ;
// We say that we have to create a thread for that HeadNode 'anInNode'
- anInNode->CreateNewThread( true ) ;
- IncrCreatedThreads() ;
- anInNode->DataFromNode( Graph()->Name() ) ;
+ if ( !anInNode->IsMacroNode() ) {
+ anInNode->CreateNewThread( true ) ;
+ IncrCreatedThreads() ;
+ }
+ anInNode->DataFromNode( Name() ) ;
// AndSuspend == true <==> Start()
if ( AndSuspend ) {
anInNode->State( GraphExecutor::DataWaitingState ) ;
cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
return false ;
}
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ anInNode->CreateNewThread( true ) ;
+ IncrCreatedThreads() ;
+ if ( anInNode->HasAllDataReady() ) {
+ if ( !anInNode->SendEvent( GraphExecutor::AllDataReadyEvent ) ) { // ==> Ready to execute
+ cdebug << "GraphExecutor::OutNode::Run SendEvent(AllDataReadyEvent) ERROR "
+ << " Node " << anInNode->Name() << endl ;
+ cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
+ return false ;
+ }
+ }
+ else {
+ State( GraphExecutor::ErroredState ) ;
+ Done( true ) ;
+ cdebug << "GraphExecutor::OutNode::Run HasAllDataReady " << anInNode->HasAllDataReady()
+ << " Node " << anInNode->Name() << endl ;
+ cdebug_out << "GraphExecutor::OutNode::Run HasAllDataReady ERROR" << endl ;
+ return false ;
+ }
cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWait"
<< endl ;
// ==> We wait for RunningState
};
}
// ostringstream astr ;
-// astr << "Graph " << Graph()->Name() << " is running" ;
+// astr << "Graph " << Name() << " is running" ;
// Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
RetVal = true ;
}
//JR 24.03.2005 debug : State and done flags were missing
State( GraphExecutor::ErroredState ) ;
Done( true ) ;
+//JR 17.06.2005 debug call to executed was missing ===>
+// _GraphExecutingNumber field of FiniteStateMachine was not decremented ===>
+// register of python functions was de-activated ==>
+// two graphs execution with two different python functions with the same name
+// give aborted state for the second one
+//Example : GraphLoopSwitchOfSwitchNOTValid, GraphLoopSwitchs and GraphLoopSwitchsBranches
+ if ( IsDone() ) {
+ cdebug << " ==> theAutomaton->Executed() " << endl ;
+ theAutomaton->Executed() ;
+ }
+ else {
+ cdebug << " NO theAutomaton->Executed() " << endl ;
+ }
cdebug_out << "GraphExecutor::OutNode::Run Not Executable ERROR " << endl ;
return false ;
}
- cdebug_out << pthread_self() << "GraphExecutor::OutNode::Run " << Graph()->Name()
+ cdebug_out << pthread_self() << "GraphExecutor::OutNode::Run " << Name()
<< " State " << theAutomaton->StateName( State() ) << " GraphMacroLevel "
<< Graph()->GraphMacroLevel() << " RetVal " << RetVal << endl ;
return RetVal ;
if ( InNodeState != GraphExecutor::SuccessedState &&
InNodeState != GraphExecutor::ErroredState &&
InNodeState != GraphExecutor::DataWaitingState ) {
- AllDone = false ;
+ if ( !IsNodeAborted() ) {
+ AllDone = false ;
+ }
}
if ( InNodeState != GraphExecutor::SuccessedState &&
InNodeState != GraphExecutor::DataWaitingState &&
aState == SUPERV::SuspendDoneState ||
aState == SUPERV::SuspendErroredState ||
aState == SUPERV::SuspendState ) {
- alivenodes += 1 ;
+ if ( !IsNodeAborted() ) {
+ alivenodes += 1 ;
+ }
}
aNode->SuspendedAction() ;
aNode->DoneAction() ;
Done( true ) ;
_JustStarted = false ;
}
- cdebug << Graph()->Name() << " alivenodes " << alivenodes << " OutNodeState " << OutNodeState
+ cdebug << Name() << " alivenodes " << alivenodes << " OutNodeState " << OutNodeState
<< endl ;
PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
OutNodeState ) ;
}
if ( IsDone() ) {
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+ MESSAGE( Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
<< EventQSize() ) ;
MESSAGE("================================================================================") ;
cdebug << "================================================================================" << endl ;
- cdebug << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+ cdebug << Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
<< EventQSize() << endl ;
cdebug << "================================================================================" << endl ;
Graph()->GraphEditor()->Editing();
}
cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << IsDone() << " this " << this << " "
- << Graph()->Name() << " GraphAutomatonState "
+ << Name() << " GraphAutomatonState "
<< theAutomaton->StateName( AutomatonState() )
<< " State " << State() << " Threads " << _Threads << " SuspendedThreads "
<< _SuspendedThreads << " EventQSize " << EventQSize() << endl ;
}
if ( _Threads == 0 && _SuspendedThreads == 0 ) {
CheckAllDone() ;
+ cdebug << pthread_self() << " ExitThread( " << ThreadNumber << " ) " << _Threads
+ << " running threads " << _SuspendedThreads << " suspended threads IsDone() "
+ << IsDone() ;
if ( IsDone() ) {
+ cdebug << " ==> theAutomaton->Executed() " << endl ;
theAutomaton->Executed() ;
}
+ else {
+ cdebug << " NO theAutomaton->Executed() " << endl ;
+ }
}
}
void GraphExecutor::OutNode::JoinedWait() {
perror("PushEvent pthread_mutex_lock ") ;
exit( 0 ) ;
}
- char* aNodeName = aNode ? aNode->Name() : Graph()->Name() ;
+ char* aNodeName = aNode ? aNode->Name() : Name() ;
_EventNodes.push_back( aNodeName ) ;
_Events.push_back( anEvent ) ;
_States.push_back( aState ) ;
// << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ;
}
else {
-// cdebug << "PushEvent " << Graph()->Name() ;
+// cdebug << "PushEvent " << Name() ;
// cdebug << " " << theAutomaton->EventName( anEvent ) << " "
// << theAutomaton->StateName( aState ) ;
}
aState != SUPERV::RunningState &&
aState != SUPERV::SuspendDoneState &&
aState != SUPERV::SuspendErroredState ) {
- NodeName = Graph()->Name() ;
- while ( sts && !strcmp( NodeName , Graph()->Name() ) ) {
+ NodeName = Name() ;
+ while ( sts && !strcmp( NodeName , Name() ) ) {
sts = EventWait( aNodeName , anEvent , aState ) ;
NodeName = *aNodeName ;
}
void GraphExecutor::OutNode::SendSomeDataReady( const char * aNodeName ) {
cdebug_in << "GraphExecutor::OutNode::SendSomeDataReady " << aNodeName << "->SendSomeDataReady( "
- << Graph()->Name() << " )" << endl;
+ << Name() << " )" << endl;
int sts ;
- sts = ((GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( aNodeName )->GetInNode())->SendSomeDataReady( Graph()->Name() ) ;
+ sts = ((GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( aNodeName )->GetInNode())->SendSomeDataReady( Name() ) ;
cdebug_out << "GraphExecutor::OutNode::SendSomeDataReady sts " << sts << endl ;
}
void GraphExecutor::OutNode::State(GraphExecutor::AutomatonState aState ) {
-// cdebug << "GraphExecutor::OutNode::State " << Graph()->Name() << " "
+// cdebug << "GraphExecutor::OutNode::State " << Name() << " "
// << theAutomaton->StateName( AutomatonGraphState( _State ) ) << " ---> "
// << theAutomaton->StateName( AutomatonGraphState( aState ) ) << endl ;
_State = aState ;
if ( RetVal ) {
State( GraphExecutor::SuspendedState ) ;
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS SUSPENDED" ) ;
+ MESSAGE( Name() << " IS SUSPENDED" ) ;
MESSAGE("================================================================================") ;
}
else {
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ;
+ MESSAGE( Name() << " IS NOT SUSPENDED" ) ;
MESSAGE("================================================================================") ;
}
for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
}
}
else {
- cdebug << Graph()->Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ;
+ cdebug << Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ;
}
if ( RetVal ) {
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS RESUMED" ) ;
+ MESSAGE( Name() << " IS RESUMED" ) ;
MESSAGE("================================================================================") ;
}
else {
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ;
+ MESSAGE( Name() << " IS NOT RESUMED" ) ;
MESSAGE("================================================================================") ;
}
int i ;
if ( RetVal ) {
State( GraphExecutor::KilledState ) ;
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS KILLED" << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+ MESSAGE( Name() << " IS KILLED" << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
<< EventQSize() ) ;
MESSAGE("================================================================================") ;
}
else {
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ;
+ MESSAGE( Name() << " IS NOT KILLED" ) ;
MESSAGE("================================================================================") ;
}
for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
if ( RetVal ) {
MESSAGE("================================================================================") ;
- MESSAGE( Graph()->Name() << " IS STOPPED" ) ;
+ MESSAGE( Name() << " IS STOPPED" ) ;
MESSAGE("================================================================================") ;
}
return RetVal ;
}
bool GraphExecutor::OutNode::DoneWait() {
- cdebug_in << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name() << endl;
+ cdebug_in << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Name() << endl;
bool aret ;
if ( pthread_mutex_lock( &_MutexWait ) ) {
perror("pthread_mutex_lock _DoneWait") ;
}
aret = IsDone() ;
while ( !aret && !IsSuspended() && IsRunning() ) {
- cdebug << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name()
+ cdebug << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Name()
<< " DoneWait pthread_cond_wait _EventWait " << &_EventWait << endl;
pthread_cond_wait( &_EventWait , &_MutexWait );
aret = IsDone() ;
- cdebug << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name()
+ cdebug << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Name()
<< " DoneWait pthread_cond_waited _EventWaited " << &_EventWait << " : "<< aret << endl;
}
if ( pthread_mutex_unlock( &_MutexWait ) ) {
perror("pthread_mutex_lock _DoneWait") ;
exit( 0 ) ;
}
- cdebug_out << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name()
+ cdebug_out << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Name()
<< " " << State() << " : " << aret << endl ;
return aret ;
}