#endif
}
-
+#define SendEventTrace 1
int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
_CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
- cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
- << " ControlState : "
- << Automaton()->ControlStateName( ControlState() )
- << " Event : " << Automaton()->EventName( anEvent )
- << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
+#if SendEventTrace
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " SendEvent Graph " << _OutNode->Name()
+ << " Node " << Name() << " Event : " << Automaton()->EventName( anEvent )
+ << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack
+ << " ControlState : " << Automaton()->ControlStateName( ControlState() )
+ << endl;
+#endif
_OldState = State() ;
_NextState = Automaton()->NextState( _OldState , anEvent ) ;
if ( _NextState == _OldState ) {
- cdebug << pthread_self() << "/" << ThreadNo()
- << " GraphExecutor::InNodeThreads::SendEvent SameStates "
- << _OldState << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " GraphExecutor::InNodeThreads::SendEvent SameStates ERROR _OldState/_NextState "
+ << _OldState << " Event " << Automaton()->EventName( anEvent ) << endl ;
_NextAction = GraphExecutor::VoidAction ;
+ return 0 ;
}
else {
_NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
}
+#if SendEventTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << "NextState( " << _OldState << " , "
+ << Automaton()->EventName( anEvent ) << " ) --> _NextState = " << _NextState
+ << " NextAction( " << _NextState << " , " << Automaton()->EventName( anEvent )
+ << " ) --> _NextAction = "
+ << Automaton()->ActionName( _NextAction ) << endl ;
+#endif
// State( _NextState ) ;
// if ( _OldState == GraphExecutor::SuccessedExecutingState ||
// DoneAction() ;
// }
+#if SendEventTrace
cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
<< Name() << endl << " ControlState : "
<< Automaton()->ControlStateName( ControlState() ) << endl
<< " Action : " << Automaton()->ActionName( _NextAction ) << endl
<< " CreateNewThread " << CreateNewThread() << endl
<< " _RewindStack " << _RewindStack << endl ;
-
-#if 0
- //cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
- << endl << " ControlState : "
- << Automaton()->ControlStateName( ControlState() ) << endl
- << " OldState : " << Automaton()->StateName( _OldState ) << endl
- << " Event : " << Automaton()->EventName( anEvent ) << endl
- << " NextState : " << Automaton()->StateName( _NextState ) << endl
- << " Action : " << Automaton()->ActionName( _NextAction ) << endl
- << " CreateNewThread " << CreateNewThread() << endl ;
#endif
- int sts = executeAction() ;
+ int sts = true ;
+#if ExitWhenNodeAborted
+ if ( _OutNode->IsNodeAborted() ) {
+#if SendEventTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
+ << " will exit : a node was aborted ..." << endl ;
+ State( _NextState ) ;
+#endif
+ }
+ else {
+ sts = executeAction() ;
+ }
+#else
+ sts = executeAction() ;
+#endif
- cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
- << " Event : " << Automaton()->EventName( anEvent )
- << " State : " << Automaton()->StateName( State() )
- << endl;
+#if SendEventTrace
+ cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
+ << " Event : " << Automaton()->EventName( anEvent )
+ << " State : " << Automaton()->StateName( State() )
+ << endl;
+#endif
return sts ;
}
+#define ActionsTrace 1
// ReadyAction - RunningAction - DoneAction - SuspendedAction :
// for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
void GraphExecutor::InNode::ReadyAction() {
perror("Ready pthread_mutex_lock ") ;
exit( 0 ) ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "ReadyAction pthread_cond_broadcast _ReadyWait "
<< Name() << endl ;
+#endif
if ( pthread_cond_broadcast( &_ReadyWait ) ) {
perror("Ready pthread_cond_broadcast ") ;
}
perror("Running pthread_mutex_lock ") ;
exit( 0 ) ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "RunningAction pthread_cond_broadcast _RunningWait "
<< Name() << endl ;
+#endif
// That activate the pthread_cond_wait for RunninWait
if ( pthread_cond_broadcast( &_RunningWait ) ) {
perror("Running pthread_cond_broadcast ") ;
perror("Done pthread_mutex_lock ") ;
exit( 0 ) ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "DoneAction pthread_cond_broadcast _DoneWait "
<< Name() << endl ;
+#endif
if ( pthread_cond_broadcast( &_DoneWait ) ) {
perror("Done pthread_cond_broadcast ") ;
}
perror("Suspended pthread_mutex_lock ") ;
exit( 0 ) ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "SuspendedAction pthread_cond_broadcast _SuspendedWait "
<< Name() << endl ;
+#endif
if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
perror("Suspended pthread_cond_broadcast ") ;
}
perror("SuspendAction pthread_cond_wait ") ;
}
_OutNode->ResumeThread() ;
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " SuspendAction pthread_cond_waited"
<< Automaton()->StateName( State() ) << endl ;
+#endif
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " NO SuspendAction pthread_cond_wait"
<< Automaton()->StateName( State() ) << endl ;
+#endif
}
// SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
_SuspendSync = false ;
exit( 0 ) ;
}
if ( _ResumeSync ) {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
+#endif
if ( pthread_cond_signal( &_ResumeWait ) ) {
perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
+#endif
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
+#endif
_ResumeSync = true ;
}
if ( pthread_mutex_unlock( &_MutexWait ) ) {
}
_aResumeEvent = aResumeEvent ;
if ( _SuspendSync ) {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " ResumeAction pthread_cond_signal" << endl ;
+#endif
if ( pthread_cond_signal( &_SuspendWait ) ) {
perror("ResumeAction pthread_cond_signal ") ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
+#endif
RetVal = true ;
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " NO ResumeAction pthread_cond_signal" << endl ;
+#endif
if ( pthread_self() == ThreadNo() ) {
RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
}
exit( 0 ) ;
}
if ( !_ResumeSync ) {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
<< Name() << " ResumeAction pthread_cond_wait _ResumeWait "
<< Automaton()->StateName( State() ) << endl ;
+#endif
_ResumeSync = true ;
if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
perror("ResumeAction pthread_cond_wait ") ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
<< Name() << " ResumeAction pthread_cond_waited _ResumeWait"
<< Automaton()->StateName( State() ) << endl ;
+#endif
RetVal = true ;
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
<< Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
<< Automaton()->StateName( State() ) << endl ;
+#endif
RetVal = false ;
}
_ResumeSync = false ;
exit( 0 ) ;
}
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
+#endif
return RetVal ;
}
GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
_aReStartNode = aReStartNode ;
_aReStartEvent = anEvent ;
- cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " GraphExecutor::InNodeThreads::ReStartAction from "
<< Name() << " " << Automaton()->StateName( State() ) << " to "
<< aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
<< Automaton()->StateName( aReStartNode->State() ) ;
exit( 0 ) ;
}
if ( !_ThreadStartedSync ) {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
<< endl ;
+#endif
_ThreadStartedSync = true ;
if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
perror("ThreadStarted pthread_cond_wait ") ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
<< endl ;
+#endif
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
<< endl ;
+#endif
//Debug :
_ThreadStartedSync = false ;
if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
perror("ThreadStart pthread_cond_signal ") ;
}
//Debug
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
<< endl ;
+#endif
}
if ( pthread_mutex_unlock( &_MutexWait ) ) {
perror("ThreadStarted pthread_mutex_unlock ") ;
exit( 0 ) ;
}
if ( _ThreadStartedSync ) {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
<< endl ;
+#endif
_ThreadStartedSync = false ;
if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
perror("ThreadStart pthread_cond_broadcast ") ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
<< endl ;
+#endif
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
<< endl ;
+#endif
_ThreadStartedSync = true ;
//Debug :
if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
perror("ThreadStarted pthread_cond_wait ") ;
}
//Debug
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
<< endl ;
+#endif
}
if ( pthread_mutex_unlock( &_MutexWait ) ) {
perror("ThreadStart pthread_mutex_unlock ") ;
int GraphExecutor::InNode::executeAction() {
int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ;
if ( !CreateNewThread() && oldRewindStack ) {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< " executeAction start Thread _RewindStack " << _RewindStack << " > "
<< MAXSTACKTHREADSIZE << " CreateNewThread "
- << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
- << endl;
+ << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "("
+ << Name() << ")" << endl;
+#endif
CreateNewThread( true ) ;
+ _OutNode->IncrCreatedThreads() ;
ThreadNo( 0 ) ;
}
if ( CreateNewThread() ) {
CreateNewThread( false ) ;
- if ( ThreadNo() == 0 ) {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// if ( ThreadNo() == 0 ) {
_RewindStack = 1 ;
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< " executeAction start Thread _RewindStack " << _RewindStack << " "
<< Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
<< endl;
+#endif
pthread_t T;
int pthread_sts = 1 ;
// _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
<< PTHREAD_THREADS_MAX << " pthread_create status : " ;
if ( pthread_sts == EAGAIN ) {
cdebug << "EAGAIN(" << pthread_sts << ")" << endl ;
- cdebug << "It seems to me that with gdb we are limited to 256 threads because of defunct" << endl ;
+ cdebug << _OutNode->CreatedThreads() << " was created (and exited)" << endl ;
+ cdebug << "It seems to me that with gdb we are limited to 256 threads" << endl ;
}
else {
cdebug << pthread_sts << endl ;
delete [] msg ;
pthread_exit( msg ) ;
}
- cdebug << pthread_self() << "/" << ThreadNo()
- << "executeAction has created thread " << T << endl ;
+#if ActionsTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " executeAction has created thread " << T << endl ;
+#endif
ThreadStartedAction() ;
- cdebug << pthread_self() << "/" << ThreadNo()
+#if ActionsTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
<< "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
<< Name() << endl ;
+#endif
}
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+#if 0
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< " executeAction restart Thread _RewindStack " << _RewindStack << " "
<< Automaton()->StateName( State() ) << " "
<< Automaton()->ActionName( _NextAction ) << "(" << Name()
<< ") ReStartAction ==>" << endl;
+#endif
State( GraphExecutor::SuspendedSuccessedState ) ;
if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
cdebug << pthread_self() << "/" << ThreadNo()
<< ") ERROR-DEBUG " << endl;
}
else {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
<< Automaton()->ActionName( _NextAction ) << "(" << Name()
<< ")" << endl;
+#endif
}
}
}
+#endif
else {
if ( _CurrentEvent == ExecuteEvent ) {
_RewindStack += 1 ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
<< Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
<< endl;
+#endif
return ExecuteAction() ;
}
return 1 ;
}
void GraphExecutor::InNode::coutbegin() {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin"
<< " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
+#endif
}
void GraphExecutor::InNode::coutexit() {
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
<< " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
+#endif
}
void * run_function(void *p) {
GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
int GraphExecutor::InNode::ExecuteAction() {
int sts ;
+#if ActionsTrace
const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
const char * statename = Automaton()->StateName( State() ) ;
const char * nextstatename = Automaton()->StateName( _NextState ) ;
- cdebug_in << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() << " --> ExecuteAction "
<< nextactionname << " " << statename << " NextState "
<< nextstatename << endl ;
+#endif
State( _NextState ) ;
switch ( _NextAction ) {
sts = Executing_SuccessAction() ;
break ;
}
- case GraphExecutor::Executing_ErrorAction : {
- sts = Executing_ErrorAction() ;
+ case GraphExecutor::Errored_ExecutingAction : {
+ sts = Errored_ExecutingAction() ;
break ;
}
case GraphExecutor::Successed_SuccessAction : {
return 0 ;
}
}
+#if ActionsTrace
cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
<< nextactionname << endl ;
+#endif
return sts ;
}
return 1;
}
-
+#define SomeDataReadyActionTrace 1
int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
- cdebug << pthread_self() << "/" << ThreadNo()
- << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
- << " to " << Name() << endl;
+#if SomeDataReadyActionTrace
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " DataWaiting_SomeDataReadyAction from " << DataFromNode() << endl;
+#endif
unsigned int k;
int InReady = 0 ;
int res = 1;
bool LoopBeginning = false ;
bool LoopFinished = false ;
bool SwitchFinished = false ;
+ bool SwitchDefault = false ;
+ bool DoAllDataReadyIf = true ;
if ( IsLoopNode() ) {
- GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ;
+ GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
LoopBeginning = true ; // Beginning of Loop
}
}
- if ( IsEndLoopNode() ) {
- GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ;
+ else if ( IsEndLoopNode() ) {
+ GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
LoopFinished = true ; // End of Loop
}
}
- if ( IsEndSwitchNode() ) {
- GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ;
- if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
- SwitchFinished = true ; // End of Switch
+ else if ( IsEndSwitchNode() ) {
+ if ( strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
+ GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
+//JR 09.02.2005 : SomeDataReady is NOT from the SwitchNode
+ if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
+//JR 09.02.2005 : the OutPort of the SwitchNode connected to the default port is closed ===>
+// Here after we consider that that DefaultPort is Ready (even if it's value is false) in
+// order to have the good count of InPorts Ready in the EndSwitchNode
+// SwitchFinished = true ; // End of Switch
+//JR 25.08.2005 :
+// But we do that only if the InDefaultPort of the EndSwitchNode is not connected or
+// is connected from the OutDefaultPort of the corresponding SwitchNode
+ if ( !strcmp( GOTONode()->CoupledNode()->Name() , anOutGateSwitchPort->NodeName() ) ) {
+ SwitchFinished = true ; // End of Switch
+ }
+ }
+ }
+ else {
+//JR 20.04.2005 : SomeDataReady is FROM the SwitchNode to that EndSwitchNode
+//PAL8518
+//JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
+// the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
+ GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default P
+//JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is activated :
+ if ( anOutGateSwitchPort ) {
+ if ( anOutGateSwitchPort->BoolValue() ) {
+ SwitchDefault = true ;
+ }
+//JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is NOT activated :
+// a SwitchBranch should be activated
+ else {
+ DoAllDataReadyIf = false ;
+ }
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " activated from CoupledNode " << GOTONode()->CoupledNode()->Name() << " "
+ << anOutGateSwitchPort->NodeName() << "( " << anOutGateSwitchPort->PortName()
+ << " ) to InDefault " ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutGateSwitchPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+#endif
+ }
+//JR 28.06.2005 : SomeDataReady is from the SwitchNode and the InDefault is not connected :
+// a SwitchBranch should be activated
+ else {
+ DoAllDataReadyIf = false ;
+ }
}
}
+
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
- << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
+ << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished
+ << " SwitchDefault " << SwitchDefault << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
+#endif
for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
- GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
- cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->State() << " " << anInPort->PortStatus() << endl ;
+ GraphBase::OutPort * anOutPort ;
+ if ( SwitchDefault && !anInPort->IsDataStream() ) {
+//Get or Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort
+// of the SwitchNode
+ anOutPort = anInPort->GetOutPort() ;
+ if ( anOutPort ) {
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " already setted to OutPort " << anOutPort->NodeName()
+ << "( " << anOutPort->PortName() << " )" << endl ;
+#endif
+ }
+ else {
+ anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ;
+ if ( anOutPort ) {
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " change of OutPort from "
+ << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName()
+ << " ) to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )"
+ << endl ;
+#endif
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " have NO OutPort ERROR " << endl ;
+ return 0 ;
+ }
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
+ }
+ else {
+ anOutPort = anInPort->GetOutPort() ;
+ }
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " " << anInPort->PortState() << " "
+ << anInPort->PortStatus() << " " << anInPort->Kind() ;
+ if ( anOutPort ) {
+ cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
+ << " )" ;
+ }
+ else {
+ cdebug << " without OutPort " ;
+ }
+ cdebug<< endl ;
+#endif
if ( anInPort->IsGate() && anOutPort == NULL ) {
InReady += 1 ;
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " ControlPort inactive." << endl ;
+#endif
}
-// That InPort get its value from an other node
+
+// That InPort get its value from an other node : the node of anOutPort linked to that anInPort is
+// different from the sender of SomeDataReady (DataFromNode) :
else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
- if ( anInPort->State() == SUPERV::ReadyState ) {
+ if ( anInPort->PortState() == SUPERV::ReadyState ) {
InReady += 1 ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
- << anInPort->PortName() << " Was Done from Node "
- << anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") ReadyState " ;
+ << anInPort->PortName() << " " << anInPort->PortState() << " Was Done from Node "
+ << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
+ << anOutPort->PortState() << " ) PortDone " << anOutPort->PortDone() << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
}
#endif
cdebug << endl ;
+#endif
}
else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") LoopBeginning " << LoopBeginning ;
+ << ") LoopBeginning " << LoopBeginning << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
}
#endif
cdebug << endl ;
+#endif
}
else if ( LoopFinished ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") LoopFinished" ;
+ << ") LoopFinished " << LoopFinished << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
}
#endif
cdebug << endl ;
+#endif
}
else if ( anInPort->IsGate() && SwitchFinished ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") SwitchFinished" ;
+ << ") SwitchFinished " << SwitchFinished << " " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
}
#endif
cdebug << endl ;
+#endif
}
else if ( anInPort->IsGate() &&
_OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) {
// GateOutPort of GOTONodes are always opened
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
- CORBA::Any * anAny = new CORBA::Any() ;
- *anAny <<= (long ) 1 ;
- _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->Value( anAny ) ;
+//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
+ CORBA::Any anAny = CORBA::Any() ;
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
+ anAny <<= (long ) 1 ;
+ _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->SetValue( anAny ) ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
- << ") GOTONode" ;
+ << ") GOTONode " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
}
#endif
cdebug << endl ;
+#endif
}
else {
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
- << anInPort->PortName() << " Was NOT Done from Node "
- << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << " " << Automaton()->StateName( State() ) << " DataConnected "
- << anInPort->IsDataConnected() << " LoopBeginning "
- << LoopBeginning << endl ;
+ << " " << Automaton()->StateName( State() ) << " LoopBeginning "
+ << LoopBeginning << " " << anInPort->PortName() << " DataConnected "
+ << anInPort->IsDataConnected() << " Was NOT Done from Node "
+ << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
+ << anOutPort->PortState() << " , PortDone " << anOutPort->PortDone() << ") "
+ << endl ;
+#endif
}
}
-// That InPort get its value from the sending node
+
+// That InPort get its value from the sending node (DataFromNode)
else if ( anInPort->IsGate() ) {
- const CORBA::Any * theValue = anOutPort->Value() ;
+//JR 30.03.2005 const CORBA::Any * theValue = anOutPort->Value() ;
+ const CORBA::Any theValue = anOutPort->Value() ;
long GateOpened ;
- (*theValue) >>= GateOpened ;
+//JR 30.03.2005 (*theValue) >>= GateOpened ;
+ theValue >>= GateOpened ;
if ( GateOpened != 0 ) {
InReady += 1 ;
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Gate is Opened from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else if ( LoopFinished ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " GATE IS CLOSED from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else {
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " GATE IS CLOSED from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
}
- else if ( anOutPort->Done() ) {
- InReady += 1 ;
- anInPort->State( SUPERV::ReadyState ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
- << anInPort->PortName() << " " << anInPort->PortStatus() << " is Done from Node "
+ else if ( anOutPort->PortDone() ) {
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " " << anInPort->PortStatus() << " "
+ << Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << anOutPort->PortStatus() << " " ;
+ << anOutPort->PortStatus() << " --> ReadyState " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
}
#endif
cdebug << endl ;
+#endif
+ InReady += 1 ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
// MacroNode : give immediately the value to the corresponding graph
if ( IsMacroNode() ) {
- cout << "SomeDataReadyAction " << GraphMacroNode() << " " << GraphMacroNode()->Name()
- << " coupled to " << GraphMacroNode()->CoupledNode() << endl ;
GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
- cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Graph()->Name() << " --> InputOfAny "
- << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready" << endl ;
+ cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
+ << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
+ << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
// GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
- aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
+//JR 30.03.2005 aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
+ aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
}
}
else {
+#if SomeDataReadyActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
<< anInPort->PortName() << ") " << anInPort->PortStatus()
<< " is NOT Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << anOutPort->PortStatus() << " " ;
+ << anOutPort->PortStatus() << " " << anOutPort->PortDone() << endl ;
+#endif
}
}
- if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
- res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+ if ( InReady == GetNodeInPortsSize() && DoAllDataReadyIf ) { // All Flags != 0 :
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+#if SomeDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasAllDataReady"
+ << endl ;
+#endif
+ HasAllDataReady( true ) ; // ==> Ready to execute
+ res = 1 ;
}
else { // At least one Flag == 0 :
+ HasAllDataReady( false ) ;
res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
}
- cdebug << pthread_self() << "/" << ThreadNo()
- << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
+#if SomeDataReadyActionTrace
+ cdebug_out << pthread_self() << "/" << ThreadNo() << Name()
+ << " DataWaiting_SomeDataReadyAction " << endl;
+#endif
return res ;
}
+#define NotAllDataReadyActionTrace 1
int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
- CreateNewThreadIf( false ) ;
-// cdebug << pthread_self() << " for " << ThreadNo()
-// << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// CreateNewThreadIf( false ) ;
+#if NotAllDataReadyActionTrace
+ cdebug << pthread_self() << " for " << ThreadNo()
+ << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+#endif
return 1;
}
+#define AllDataReadyActionTrace 1
int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " --> DataUndef_AllDataReadyAction " << Name()
+#if AllDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " --> DataUndef_AllDataReadyAction " << Name() << endl ;
// << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
// << IsLockedDataWait() ;
- if ( IsLockedDataWait() ) {
- cdebug << "DataUndef_AllDataReadyAction() WOULD DEAD-LOCK" << endl ;
- return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
- }
-// cdebug << endl ;
- CreateNewThread( CreateNewThreadIf() ) ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
if ( !CreateNewThread() ) {
-// cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+#if AllDataReadyActionTrace
+ cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ;
+#endif
ThreadNo( pthread_self() ) ;
}
+ else {
+ _OutNode->IncrCreatedThreads() ;
+ }
_OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
GraphExecutor::DataReadyState ) ;
ReadyAction() ;
return 0;
}
}
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+#if AllDataReadyActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+#endif
return 1;
}
#include <CORBA.h>
+#define TraceDataReady_ExecuteAction 1
int GraphExecutor::InNode::DataReady_ExecuteAction() {
- int i;
-// cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
-// << Name() << endl;
+#if TraceDataReady_ExecuteAction
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " DataReady_ExecuteAction "
+ << Name() << endl;
+#endif
_OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
GraphExecutor::ExecutingState ) ;
bool Err = false ;
+ Engines::Container_var myContainer ;
+ Engines::Component_var myObjComponent ;
+
SUPERV::GraphState PortState = SUPERV::ReadyState ;
GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
int nInParams ;
- ServicesAnyData * InParametersList ;
+ ServicesAnyData * InParametersList = NULL ;
int nOutParams ;
- ServicesAnyData * OutParametersList ;
+ ServicesAnyData * OutParametersList = NULL ;
nInParams = GetNodeInPortsSize() ;
+#if TraceDataReady_ExecuteAction
+ char * aName = Name() ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << aName
+ << " nInParams " << nInParams << " InParametersList "
+ << (void * ) InParametersList << endl ;
+#endif
InParametersList = new ServicesAnyData[nInParams];
InParametersSet( Err , nInParams , InParametersList ) ;
nOutParams = GetNodeOutPortsSize() ;
OutParametersList = new ServicesAnyData[nOutParams];
InOutParametersSet( nOutParams , OutParametersList ) ;
+#if 0
+ if ( !Err && IsComputingNode() ) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " after creation of InParametersList : nInParams " << nInParams
+ << " :" << endl;
+ int i ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " ping done "
+ << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " after creation of OutParametersList :" << endl;
+ for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
+ cdebug << "OutParametersList[" << i << "] : "
+ << OutParametersList[i].Name << " "
+ << AnyValue( OutParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
if ( !IsMacroNode() ) {
- Engines::Container_var myContainer ;
- Engines::Component_var myObjComponent ;
if ( !IsFactoryNode() ) {
-// cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
+#endif
if ( IsComputingNode() ) {
ObjInterface( true ) ;
+//JR 05.08.2005 DEBUG : that code runs with SALOME_3 (OMNIOrb4) ...
+#if OMNIORB_VERSION >= 4
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ myObjComponent = Engines::Component::_narrow( obj ) ;
+//JR 05.08.2005 DEBUG : the folowing code runs with OMNIOrb3 but gives
+// unpredictable results with SALOME_3 (OMNIOrb4) ...
+#else
CORBA::Object_ptr obj ;
InParametersList[0].Value >>= obj ;
CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
- myObjComponent = Engines::Component::_narrow( objvar ) ;
+ myObjComponent = Engines::Component::_duplicate( Engines::Component::_narrow( objvar ) ) ;
+#endif
}
else {
}
}
else if ( CORBA::is_nil( Component() ) ) {
-// ostringstream astr ;
-// astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name()
-// << " : load of component " << ComponentName() << " in container "
-// << Computer() ;
-// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
- my_strdup( ComponentName() ) ,
+//JR 17.02.2005 Memory Leak my_strdup( ComponentName() ) ,
+ ComponentName() ,
myContainer , myObjComponent ) ;
ObjInterface( false ) ;
SetContainer( myContainer ) ;
else {
myContainer = Container() ;
myObjComponent = Component() ;
-// cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
-// << endl ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
+ << endl ;
try {
myObjComponent->ping() ;
}
catch( ... ) {
- cdebug << "ping() catched" << endl ;
+ cdebug << "ping() ERROR catched" << endl ;
Err = true ;
}
+#endif
}
if ( Err || ControlState() == SUPERV::ToKillState ||
ControlState() == SUPERV::ToKillDoneState ||
ControlState() == SUPERV::ToStopState ) {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
- MESSAGE(pthread_self() << "Executor::InNode::DataReady_ExecuteAction of " << Name()
- << " ControlState " << Automaton()->ControlStateName( ControlState() )
- << " BEFORE execution ThreadNo " << ThreadNo() ) ;
+#endif
Err = true ;
}
else {
if ( ControlState() == SUPERV::ToSuspendState ) {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
+#endif
}
- if ( !Err ) {
-// ostringstream astr ;
-// astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ;
-// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
- cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
- for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
- cdebug << " , " << InParametersList[ i ].Name << "[kind"
- << InParametersList[ i ].Value.type()->kind() << "]" ;
- }
- for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
- cdebug << " , " << OutParametersList[ i ].Name << "[kind"
- << OutParametersList[ i ].Value.type()->kind() << "]" ;
- }
- if ( IsOneOfInLineNodes() ) {
- cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
- << InLineNode()->PyRunMethod() << " length "
- << (*InLineNode()->PythonFunction()).length() ;
- }
- cdebug << ")" << endl ;
+#if TraceDataReady_ExecuteAction
+ int i;
+ cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
+ for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+ cdebug << " , " << InParametersList[ i ].Name << "[kind"
+ << InParametersList[ i ].Value.type()->kind() << "]" ;
+ }
+ for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
+ cdebug << " , " << OutParametersList[ i ].Name << "[kind"
+ << OutParametersList[ i ].Value.type()->kind() << "]" ;
+ }
+ if ( IsOneOfInLineNodes() ) {
+ cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
+ << InLineNode()->PyRunMethod() << " length "
+ << (*InLineNode()->PythonFunction()).length()
+ << " InParametersList " << InParametersList
+ << " OutParametersList " << OutParametersList ;
+ }
+ cdebug << ")" << endl ;
+#endif
- if ( IsOneOfInLineNodes() ) {
- bool StsPyDynInvoke = true;
- _OutNode->PyThreadLock() ;
- SetPyCpuUsed() ;
- try {
-// if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
- bool ItIsaLoop = false ;
- bool CopyInOut = false ;
- if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
- strlen( InLineNode()->PyFuncName() ) ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsInLineNode PyDynInvoke" << endl ;
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- } }
- else if ( IsLoopNode() ) {
- ItIsaLoop = true ;
- bool CopyOutIn = false ;
-// Switch between Init() and Next()
-// if InLoop port is true and does not come from EndLoop ==> execute Init
-// if InLoop port is false or come from EndLoop ==> execute Next
-// GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
-// if ( GetNodeInLoop()->GetOutPort()->BoolValue() &&
- if ( _InitLoop ) {
- if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
- << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[1] , ServiceInParameter().length() ,
- &OutParametersList[1] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- }
- CopyOutIn = true ;
- }
- else {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
- }
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
- _InitLoop = false ;
- }
- else if ( LoopNode()->PyNextMethod() &&
- strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
- << "' " << LoopNode()->PyNextMethod() << endl ;
- StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
- LoopNode()->PyNextName() ,
- &InParametersList[1] , ServiceInParameter().length() ,
- &OutParametersList[1] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
- }
- CopyOutIn = true ;
- }
- else {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
- }
- if ( StsPyDynInvoke ) {
- if ( CopyOutIn ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
- << "' Copy of " << ServiceInParameter().length()
- << " OutParameters" << endl ;
- int i ;
-// Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
- for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
- InParametersList[i].Value = OutParametersList[i].Value ;
- InParametersList[i].Name = OutParametersList[i].Name ;
-//#if 0
- switch ( InParametersList[i].Value.type()->kind() ) {
- case CORBA::tk_string :
- char * t;
- InParametersList[i].Value >>= t ;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(string) " << t << endl ;
- break ;
- case CORBA::tk_double :
- double d;
- InParametersList[i].Value >>= d;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(double) " << d << endl ;
- break ;
- case CORBA::tk_long :
- long l;
- InParametersList[i].Value >>= l;
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(long) " << l << endl ;
- break ;
- case CORBA::tk_objref :
- CORBA::Object_ptr obj ;
- char * retstr ;
- try {
- InParametersList[i].Value >>= obj ;
- retstr = ObjectToString( obj );
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(object reference) " << retstr << endl ;
- }
- catch ( ... ) {
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(object reference) Catched ERROR" << endl ;
- }
- break ;
- default :
- cdebug << "ArgOut->In" << i << " : "
- << InParametersList[i].Name.c_str()
- << " Value(other) ERROR" << endl ;
- }
-//#endif
- }
- }
- if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
- << "' " << LoopNode()->PyMoreMethod() << endl ;
- StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
- LoopNode()->PyMoreName() ,
- &InParametersList[1] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
- }
- }
- else {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
- << "' No MoreMethod" << endl ;
- CopyInOut = true ;
- }
- }
- else {
- Err = true ;
- cdebug << ThreadNo() << " InLineNode " << Name() << " "
- << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
- << " Python Dynamic Call Error"
- << endl ;
- }
- }
- else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
- strlen( InLineNode()->PyFuncName() ) ) {
-// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-// << InLineNode()->PyFuncName()
-// << "' IsSwitchNode PyDynInvoke" << endl ;
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- }
- }
-// else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
- else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
- strlen( InLineNode()->PyFuncName() ) ) {
-// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-// << InLineNode()->PyFuncName()
-// << "' IsGOTONode PyDynInvoke" << endl ;
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
- }
- }
-// else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
- else if ( ( IsEndSwitchNode() ) &&
- InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
-// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-// << InLineNode()->PyFuncName()
-// << "' IsSwitchNode PyDynInvoke" << endl ;
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- }
- }
- else if ( ( IsEndLoopNode() ) &&
- InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsSwitchNode PyDynInvoke" << endl ;
- StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() + 1 ,
- &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
- if ( !StsPyDynInvoke ) {
- RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
- }
- }
+ if ( IsOneOfInLineNodes() ) {
+ Err = DataReady_ExecuteActionInLineNodes( InParametersList ,
+ OutParametersList ) ;
+ }
-// else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
- if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
- strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
-// This is a void Python Function : without code (No PyFuncName)
-// cdebug << ThreadNo() << " !ObjInterface " << Name()
-// << " Copy of " << ServiceInParameter().length()
-// << " OutParameters" << endl ;
- int i ;
- int argout0 = 0 ;
- int argin0 = 0 ;
- if ( IsLoopNode() || IsEndLoopNode() ) {
- argout0 = 1 ;
- argin0 = 1 ; // after DoLoop
- if ( IsLoopNode() ) { // More() is void
-// OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
- cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
- << endl ;
- GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
- OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
- }
- }
- for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
- OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
-//#if 0
- switch ( InParametersList[argin0 + i].Value.type()->kind() ) {
- case CORBA::tk_string :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(string) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_double :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(double) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- case CORBA::tk_long :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(long) "
- << OutParametersList[argout0 + i ].Name.c_str() << endl ;
- break ;
- case CORBA::tk_objref :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(object reference) "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- break ;
- default :
- cdebug << "ArgOut->In" << argin0 + i << " : "
- << InParametersList[argin0 + i].Name.c_str()
- << " Value(other) ERROR "
- << OutParametersList[argout0 + i].Name.c_str() << endl ;
- }
-//#endif
- }
- }
- if ( !StsPyDynInvoke ) {
- Err = true ;
- cdebug << ThreadNo() << " InLineNode " << Name()
- << " Python Dynamic Call Error"
- << endl ;
- }
- }
- catch( ... ) {
- Err = true ;
- cdebug << ThreadNo() << " InLineNode " << Name()
- << " Python Dynamic Call Exception catched ERROR"
- << endl ;
- }
- CpuUsed( true ) ;
- _OutNode->PyThreadUnLock() ;
- }
- else {
- try {
- try {
- cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ;
- DynInvoke( myObjComponent, "Names" ,
- _OutNode->Graph()->Name() , Name() ) ;
- }
- catch( ... ) {
- cdebug << "DynInvoke Names catched ERROR" << endl ;
- }
+ else {
+#if 0
+ if ( IsComputingNode() ) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " myObjComponent " << myObjComponent << " "
+ << ObjectToString( myObjComponent ) << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " before DynInvoke nInParams " << nInParams
+ << " :" << endl;
+ int i ;
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
+ try {
+#if TraceDataReady_ExecuteAction
+ cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
+#endif
+ DynInvoke( myObjComponent, "Names" ,
+ _OutNode->Name() , Name() ) ;
+ }
+ catch( ... ) {
+ string anErrorMessage = string( "Dynamic CORBA call to Names for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << "DynInvoke Names catched ERROR" << endl ;
+ }
// for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
- if ( ComputingNode()->HasDataStream() ) {
- try {
- cdebug << "DynInvoke -> SetProperties " << _OutNode->Graph()->Name() << " " << Name() << endl ;
- Engines::FieldsDict_var dict = new Engines::FieldsDict;
- dict->length( 4 );
- dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
+ if ( ComputingNode()->HasDataStream() ) {
+ try {
+#if TraceDataReady_ExecuteAction
+ cdebug << "DynInvoke -> SetProperties " << _OutNode->Name() << " " << Name() << endl ;
+#endif
+ Engines::FieldsDict_var dict = new Engines::FieldsDict;
+ dict->length( 4 );
+ dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
// myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
// dict[ 0 ].value <<= myContainer->getHostName() ;
- char FullyQualifiedDomainName[256]="";
- gethostname(FullyQualifiedDomainName,255);
- dict[ 0 ].value <<= FullyQualifiedDomainName ;
- dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
- dict[ 1 ].value <<= "/tmp" ;
- dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
- stringstream ofst1 ;
- ofst1 << ComputingNode()->SubStreamGraph() ;
- string cpl = string( "/tmp/" ) + string( _OutNode->Graph()->Name() ) + string( "_" ) +
- ofst1.str() + string( ".cpl" );
- dict[ 2 ].value <<= cpl.c_str() ;
- dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
- string uname = Name();
- UpperCase( uname);
- dict[ 3 ].value <<= uname.c_str() ;
-
- myObjComponent->setProperties( dict ) ;
- }
- catch( ... ) {
- cdebug << "DynInvoke setProperties catched ERROR" << endl ;
- Err = true;
- }
- }
- if ( !Err && IsComputingNode() ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsComputingNode DynInvoke" << endl ;
- cdebug << ServiceInParameter().length()-1 << " input parameters and "
- << ServiceOutParameter().length() << " output parameters" << endl ;
- IsLoading( false ) ;
- DynInvoke( myObjComponent,
- ServiceName() ,
- &InParametersList[1] , ServiceInParameter().length()-1 ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- }
- else if ( !Err && IsFactoryNode() ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsFactoryNode DynInvoke" << endl ;
- cdebug << ServiceInParameter().length() << " input parameters and "
- << ServiceOutParameter().length() << " output parameters" << endl ;
- IsLoading( false ) ;
- DynInvoke( myObjComponent,
- ServiceName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
- }
-// cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
-// << myObjComponent->CpuUsed_impl() << endl ;
+ char FullyQualifiedDomainName[256]="";
+ gethostname(FullyQualifiedDomainName,255);
+ dict[ 0 ].value <<= FullyQualifiedDomainName ;
+ dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
+ dict[ 1 ].value <<= "/tmp" ;
+ dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
+ stringstream ofst1 ;
+ ofst1 << ComputingNode()->SubStreamGraph() ;
+ string cpl = string( "/tmp/" ) + string( _OutNode->Name() ) + string( "_" ) +
+ ofst1.str() + string( ".cpl" );
+ dict[ 2 ].value <<= cpl.c_str() ;
+ dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
+ string uname = Name();
+ UpperCase( uname);
+ dict[ 3 ].value <<= uname.c_str() ;
+
+ myObjComponent->setProperties( dict ) ;
}
catch( ... ) {
- Err = true ;
+ string anErrorMessage = string( "Dynamic CORBA call to setProperties for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << "DynInvoke setProperties catched ERROR" << endl ;
+ Err = true;
+ }
+ }
+
+ try {
+ if ( !Err && IsComputingNode() ) {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " Node(Component) Dynamic Call Exception catched ERROR"
- << endl ;
+ << " IsComputingNode DynInvoke" << endl ;
+ cdebug << ServiceInParameter().length()-1 << " input parameters and "
+ << ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
+ IsLoading( false ) ;
+ DynInvoke( myObjComponent,
+ ServiceName() ,
+ &InParametersList[1] , ServiceInParameter().length()-1 ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
+#if 0
+ { cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " myObjComponent " << myObjComponent << " "
+ << ObjectToString( myObjComponent ) << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " after DynInvoke nInParams " << nInParams
+ << " :" << endl;
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
+ }
+ else if ( !Err && IsFactoryNode() ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
+ << " IsFactoryNode DynInvoke" << endl ;
+ cdebug << ServiceInParameter().length() << " input parameters and "
+ << ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
+ IsLoading( false ) ;
+ DynInvoke( myObjComponent,
+ ServiceName() ,
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
+ }
+// cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
+// << myObjComponent->CpuUsed_impl() << endl ;
+ }
+ catch( ... ) {
+ Err = true ;
+ string anErrorMessage = string( "Dynamic CORBA call for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
+ << " Node(Component) Dynamic Call Exception catched ERROR"
+ << endl ;
//Reset of _ThreadId in the Container ...
- try {
- myObjComponent->Kill_impl() ;
- }
- catch( ... ) {
- }
- }
+// try {
+// myObjComponent->Kill_impl() ;
+// }
+// catch( ... ) {
+// }
}
}
}
}
-// ostringstream astr ;
-// astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : "
-// << Automaton()->StateName( State() ) ;
-// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
-
if ( Err ) {
// if exception or something else - IsLoading( false ) may not NOT has been called
}
if ( !IsMacroNode() ) {
+//JRStep A
bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
if ( !ErrOut ) {
NewEvent = GraphExecutor::ErrorEvent ;
}
- delete [] InParametersList ;
- delete [] OutParametersList ;
- }
-
- if ( !IsMacroNode() ) {
+#if 0
+ if ( !Err && IsComputingNode() ) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " myObjComponent " << myObjComponent << " "
+ << ObjectToString( myObjComponent ) << endl ;
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " delete [] InParametersList nInParams " << nInParams
+ << " :" << endl;
+ int i ;
+ CORBA::Object * obj ;
+ InParametersList[0].Value >>= obj ;
+ Engines::Component_var theObjComponent ;
+ theObjComponent = Engines::Component::_narrow( obj ) ;
+ DynInvoke( theObjComponent , "ping" ,
+ NULL , 0 , NULL , 0 ) ;
+ for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+ cdebug << "InParametersList[" << i << "] : "
+ << InParametersList[i].Name << " "
+ << AnyValue( InParametersList[i].Value ) << endl ;
+ }
+ }
+#endif
+ try {
+ delete [] InParametersList ;
+ }
+ catch(...) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " catch ERROR of delete [] InParametersList" << endl ;
+ }
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+ << " delete [] OutParametersList :" << endl;
+ int i ;
+ for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
+ cdebug << "OutParametersList[" << i << "] : "
+ << OutParametersList[i].Name << " "
+ << AnyValue( OutParametersList[i].Value ) << endl ;
+ }
+#endif
+ try {
+ delete [] OutParametersList ;
+ }
+ catch(...) {
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+ << " catch ERROR of delete [] OutParametersList" << endl ;
+ }
SendEvent( NewEvent ) ;
}
else {
GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
+#if TraceDataReady_ExecuteAction
+ int i ;
+ for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
+ cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
+ if ( GraphBase::Base::_prof_debug ) {
+ GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+ if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
+ cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
+ }
+ cdebug << endl ;
+ }
cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
- << aMacroGraph->Graph()->Name() << " ->DoneWait()"
+ << aMacroGraph->Name() << " ->DoneWait()"
<< " State " << aMacroGraph->State() << endl;
+#endif
aMacroGraph->DoneWait() ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State "
+ << aMacroGraph->State() << endl;
+#endif
+
+//JR 29.09.2005 Debug for CEA (examples/GraphMacroNodes1) :
+// Set of value of the OutGate of the corresponding MacroNode was missing
+ CORBA::Any anAny = CORBA::Any() ;
+ anAny <<= (long ) 1 ;
+ GraphMacroNode()->GraphEditor()->Executor()->OutputOfAny( Name() , "Gate" , anAny ) ;
+#if TraceDataReady_ExecuteAction
+ cdebug << "DataReady_ExecuteAction OutputOfAny( " << Name() << " , Gate , 1 )" << endl ;
+
+ for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
+ cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
+ << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
+ if ( GraphBase::Base::_prof_debug ) {
+ GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+ if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
+ cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
+ }
+ cdebug << endl ;
+ }
cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
+#endif
if ( aMacroGraph->State() == SUPERV::DoneState ) {
PortState = SUPERV::ReadyState ;
NewState = GraphExecutor::DataReadyState ;
SendEvent( NewEvent ) ;
}
-// cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+#if TraceDataReady_ExecuteAction
+ cdebug_out << ThreadNo() << " DataReady_ExecuteAction " << Name() << endl;
+#endif
return 1 ;
}
+int GraphExecutor::InNode::DataReady_ExecuteActionInLineNodes( ServicesAnyData * InParametersList ,
+ ServicesAnyData * OutParametersList ) {
+
+#if TraceDataReady_ExecuteAction
+ cdebug_in << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionInLineNodes " << Name()
+ << " InParametersList " << InParametersList
+ << " OutParametersList " << OutParametersList << endl;
+#endif
+ bool Err = false ;
+ bool StsPyDynInvoke = true ;
+ _OutNode->PyThreadLock() ;
+ SetPyCpuUsed() ;
+ try {
+ bool ItIsaLoop = false ;
+ bool CopyInOut = false ;
+ if ( IsInLineNode() &&
+ strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsInLineNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+ else if ( IsLoopNode() ) {
+ ItIsaLoop = true ;
+ Err = DataReady_ExecuteActionLoopNodes( InParametersList ,
+ OutParametersList ,
+ CopyInOut ) ;
+ }
+ else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
+ strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+ else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
+ strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsGOTONode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
+ }
+ }
+ else if ( ( IsEndSwitchNode() ) &&
+ InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() ,
+ OutParametersList , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+ else if ( IsEndLoopNode() &&
+ InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ InParametersList , ServiceInParameter().length() + 1 ,
+ OutParametersList , ServiceOutParameter().length() + 1 ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ }
+
+ if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
+ strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
+// This is a void Python Function : without code (No PyFuncName)
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+#endif
+ int i ;
+ int argout0 = 0 ;
+ int argin0 = 0 ;
+ if ( IsLoopNode() || IsEndLoopNode() ) {
+ argout0 = 1 ;
+ argin0 = 1 ; // after DoLoop
+ if ( IsLoopNode() ) { // More() is void
+#if TraceDataReady_ExecuteAction
+ cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
+ << endl ;
+#endif
+ GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
+ OutParametersList[0].Value = anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
+ }
+ }
+//PAL8072 ==> PAL8512
+//JR 24.03.2005 : Debug : void InLine Python function : check of the number of Input Ports
+// equals the number of Output Ports was missing
+ if ( ServiceInParameter().length() != ServiceOutParameter().length() ) {
+ string anErrorMessage = string( "Inconsistent number of In<->Out parameters for the vois Python function of the node " ) +
+ string( Name() ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ StsPyDynInvoke = false ;
+ }
+ else {
+ for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+ OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
+#if TraceDataReady_ExecuteAction
+ cdebug << "ArgOut->In" << InParametersList[argin0 + i].Name.c_str()
+ << " " << AnyValue( InParametersList[argin0 + i].Value )
+ << endl ;
+#endif
+ }
+ }
+ }
+ if ( !StsPyDynInvoke ) {
+ Err = true ;
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << ThreadNo() << " InLineNode " << Name()
+ << " Python Dynamic Call Error"
+ << endl ;
+ }
+ }
+ catch( ... ) {
+ Err = true ;
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " catched." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << ThreadNo() << " InLineNode " << Name()
+ << " Python Dynamic Call Exception catched ERROR"
+ << endl ;
+ }
+ CpuUsed( true ) ;
+ _OutNode->PyThreadUnLock() ;
+#if TraceDataReady_ExecuteAction
+ cdebug_out << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionInLineNodes " << Name() << endl;
+#endif
+ return Err ;
+}
+
+int GraphExecutor::InNode::DataReady_ExecuteActionLoopNodes( ServicesAnyData * InParametersList ,
+ ServicesAnyData * OutParametersList ,
+ bool & CopyInOut ) {
+
+#if TraceDataReady_ExecuteAction
+ cdebug_in << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionLoopNodes " << Name()
+ << " InParametersList " << InParametersList
+ << " OutParametersList " << OutParametersList << endl;
+#endif
+ bool Err = false ;
+ bool StsPyDynInvoke = true ;
+ bool CopyOutIn = false ;
+// Switch between Init() and Next()
+// if InLoop port is true and does not come from EndLoop ==> execute Init
+// if InLoop port is false or come from EndLoop ==> execute Next
+ if ( _InitLoop ) {
+ if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
+ << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ InLineNode()->PyFuncName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+ }
+ CopyOutIn = true ;
+ }
+ else {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
+#endif
+ }
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
+#endif
+ _InitLoop = false ;
+ }
+ else if ( LoopNode()->PyNextMethod() &&
+ strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
+ << "' " << LoopNode()->PyNextMethod() << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
+ LoopNode()->PyNextName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ LoopNode()->PyNextName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
+ }
+ CopyOutIn = true ;
+ }
+ else {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
+#endif
+ }
+ if ( StsPyDynInvoke ) {
+ if ( CopyOutIn ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+#endif
+ int i ;
+// Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
+ for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
+ InParametersList[i].Value = OutParametersList[i].Value ;
+ InParametersList[i].Name = OutParametersList[i].Name ;
+#if TraceDataReady_ExecuteAction
+ cdebug << "ArgOut->In" << InParametersList[ i].Name.c_str()
+ << " " << AnyValue( InParametersList[ i].Value )
+ << endl ;
+#endif
+ }
+ }
+ if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' " << LoopNode()->PyMoreMethod() << endl ;
+#endif
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
+ LoopNode()->PyMoreName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
+ if ( !StsPyDynInvoke ) {
+ string anErrorMessage = string( "Dynamic Python call for node " ) +
+ string( Name() ) + " function " +
+ LoopNode()->PyMoreName() + " error." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
+ }
+ }
+ else {
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' No MoreMethod" << endl ;
+#endif
+ CopyInOut = true ;
+ }
+ }
+ else {
+ Err = true ;
+ cdebug << ThreadNo() << " InLineNode " << Name() << " "
+ << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
+ << " Python Dynamic Call Error"
+ << endl ;
+ }
+#if TraceDataReady_ExecuteAction
+ cdebug_out << pthread_self() << "/" << ThreadNo()
+ << " DataReady_ExecuteActionLoopNodes " << Name() << endl;
+#endif
+ return Err ;
+}
+
int GraphExecutor::InNode::Executing_SuspendAction() {
_OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
GraphExecutor::SuspendedExecutingState ) ;
// cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
_OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
GraphExecutor::SuccessedState ) ;
- MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name()
- << " ControlState " << Automaton()->ControlStateName( ControlState() )
- << " AFTER execution ThreadNo " << ThreadNo() ) ;
+// MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name()
+// << " ControlState " << Automaton()->ControlStateName( ControlState() )
+// << " AFTER execution ThreadNo " << ThreadNo() ) ;
SUPERV::ControlState aControl = ControlState() ;
switch ( aControl ) {
case SUPERV::VoidState : {
return 1 ;
}
-int GraphExecutor::InNode::Executing_ErrorAction() {
- cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
+int GraphExecutor::InNode::Errored_ExecutingAction() {
+ cdebug << ThreadNo() << " --> Errored_ExecutingAction " << Name() << endl;
_OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
GraphExecutor::ErroredState ) ;
+ _OutNode->NodeAborted( Name() ) ;
+
SUPERV::ControlState aControl = ControlState() ;
switch ( aControl ) {
case SUPERV::VoidState : {
}
default : {
cdebug << ThreadNo()
- << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
+ << " GraphExecutor::InNodeThreads::Errored_ExecutingAction Error Undefined Control : "
<< aControl << endl ;
return 0;
}
}
- cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
+ cdebug << ThreadNo() << " <-- Errored_ExecutingAction " << Name() << endl;
return 1 ;
}
+#define SetWaitingStatesTrace 0
// Set SUPERV::WaitingState to all InPorts
void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
int i ;
int j ;
bool docdebug = false ;
State( GraphExecutor::DataWaitingState ) ;
+#if SetWaitingStatesTrace
+ cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
+#endif
for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
+#if SetWaitingStatesTrace
cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
- << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+ << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
+#endif
+// PAL8513
// JR Debug 07.01.2005 : Close the Gates instead of open !!!
if ( anInPort->IsGate() ) { // Loop : Close the doors
GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
if ( anOutPort ) {
- CORBA::Any * anAny = new CORBA::Any() ;
+//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
+ CORBA::Any anAny = CORBA::Any() ;
// *anAny <<= (long ) 1 ;
- *anAny <<= (long ) 0 ;
- anOutPort->Value( anAny ) ;
- anInPort->State( SUPERV::WaitingState ) ;
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
+ anAny <<= (long ) 0 ;
+ anOutPort->SetValue( anAny ) ;
+ anInPort->PortState( SUPERV::WaitingState ) ;
+// delete anAny ;
}
}
- else if ( anInPort->State() != SUPERV::WaitingState &&
+ else if ( anInPort->PortState() != SUPERV::WaitingState &&
!anInPort->IsDataConnected() ) {
if ( !docdebug ) {
+#if SetWaitingStatesTrace
cdebug << ThreadNo()
<< " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
+#endif
docdebug = true ;
}
if ( !anInPort->IsDataStream() ) {
- anInPort->State( SUPERV::WaitingState ) ;
+ anInPort->PortState( SUPERV::WaitingState ) ;
}
}
- cdebug << " --> " << Name() << "( " << anInPort->PortName() << " ) "
- << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+#if SetWaitingStatesTrace
+ cdebug << " --> InPort " << Name() << "( " << anInPort->PortName() << " ) "
+ << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
+#endif
}
for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
+// PAL8514
+//JR 07.03.2005 Debug : Reset of Done flag in OutPorts !... :
+ if ( !anOutPort->IsDataStream() ) {
+ anOutPort->PortDone( false ) ;
+ anOutPort->PortState( SUPERV::WaitingState ) ;
+ }
for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
!( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
!anOutPort->IsDataStream() &&
!anOutPort->ChangeInPorts( j )->IsDataStream() &&
!anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
+#if SetWaitingStatesTrace
cdebug << ThreadNo()
<< " InNodeThreads::SetWaitingStates OutPort "
<< Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
<< anOutPort->ChangeInPorts( j )->NodeName() << "( "
<< anOutPort->ChangeInPorts( j )->PortName() << " "
<< anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
+#endif
GraphBase::ComputingNode * aToNode ;
aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
-// JR 12.01.2005 : the OutPort linked to the InPort of a EndSwitchNode was changed so final
-// values of InPorts of EndSwitchNode may be wrong
+// JR 12.01.2005 Debug : the OutPort linked to the InPort of a EndSwitchNode was changed so final
+// values of InPorts of EndSwitchNode may be wrong
+// (depending of order of linkednodes)
if ( !aToNode->IsEndSwitchNode() &&
strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
// After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
// EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
+#if SetWaitingStatesTrace
cdebug << ThreadNo()
<< " InNodeThreads::SetWaitingStates Node " << Name() << " "
<< anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
<< anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
<< Name() << " : Restored to " << anOutPort->NodeName() << "( "
<< anOutPort->PortName() << " )" << endl ;
+#endif
anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
}
+//PAL8624
+//JR 21.04.2005 Debug : the OutPort field of InPorts of EndSwitchNodes must be an OutPort
+// of a SwitchBranch or of a NOTSwitchBranch if a link exist
+// (if not there is no change)
+ else if ( !IsSwitchNode() && aToNode->IsEndSwitchNode() &&
+ strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
+#if SetWaitingStatesTrace
+ cdebug << ThreadNo()
+ << " InNodeThreads::SetWaitingStates Node " << Name() << " "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
+ << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+ }
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
if ( aNode != EndNode ) {
aNode->SetWaitingStates( EndNode ) ;
}
}
}
+#if SetWaitingStatesTrace
+ cdebug << " --> OutPort " << Name() << "( " << anOutPort->PortName() << " ) "
+ << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
+#endif
}
}
+#define SuccessActionTrace 1
+//JR Step B
int GraphExecutor::InNode::Successed_SuccessAction() {
- cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
+#if SuccessActionTrace
+ cdebug_in << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+ << endl;
+#endif
int res = 1;
- int linkednodesnumber = LinkedNodesSize() ;
- GraphExecutor::InNode *firstzeroNode = NULL ;
+//PAL8624
+//JR 15.04.2005 Debug RetroConception :
+//The behavior of firstzeroNode and firsttoNode is not reliable and must be removed
+//The real problem is :
+// 1. send "SomeDataReady" event to linked nodes of the current node
+// 2. DO NOT send "AllDataReady" event even if all data are ready in SomeDataReady Action
+// but register only that all data are ready :
+// MAJOR ENHANCEMENT OF GRAPHEXECUTOR
+// 3. activate AllDataReady Action for each node (except the first one ) which have all
+// its data ready with a creation of a new thread
+// 3. activate AllDataReady Action for the first node which have all its data
+// ready in the current thread
+//The difficult problem (that I had in the past) was to clearly identify the above behavior ==>
+// firstzeroNode, firsttoNode, createnewthreadif, loackdatawait, "would dead lock" etc...
+// because if SomeDataReady Action see that all data were ready, it called immediately
+// AllDataReady Action ==> bugs difficult to understand and to reproduce
+//And the MAJOR DEBUG is (since the first "maquette") : we may have concurrent executions
+// of "SomeDataReady" in several threads and there WAS NO MUTEX to protect that
+// concurrent actions on the same node
+// int linkednodesnumber = LinkedNodesSize() ;
+// GraphExecutor::InNode *firstzeroNode = NULL ;
GraphExecutor::InNode *firsttoNode = NULL ;
GraphExecutor::InNode *toNode ;
int i ;
DoneAction() ;
if ( IsMacroNode() ) {
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done"
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done for that MacroNode"
<< endl ;
+#endif
return 1;
}
+//JR 09.02.2005 : That complicated part of the code manages LOOPS and GOTO
if ( IsGOTONode() ||
( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
<< " SetWaitingStates " << endl ;
+#endif
const GraphBase::OutPort * aGateOutPort ;
if ( IsGOTONode() ) {
aGateOutPort = GetNodeOutGate() ;
for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
<< aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
+#endif
+ State( GraphExecutor::DataWaitingState ) ;
aLabelNode->SetWaitingStates( this ) ;
// JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
if ( anOutPort ) {
- CORBA::Any * anAny = new CORBA::Any() ;
- *anAny <<= (long ) 1 ;
- anOutPort->Value( anAny ) ;
- aLabelNode->GetChangeNodeInGate()->State( SUPERV::ReadyState ) ;
+//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
+ CORBA::Any anAny = CORBA::Any() ;
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
+ anAny <<= (long ) 1 ;
+ anOutPort->SetValue( anAny ) ;
+ aLabelNode->GetChangeNodeInGate()->PortState( SUPERV::ReadyState ) ;
+// delete anAny ;
}
for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
if ( anInPort->GetOutPort() ) {
+#if SuccessActionTrace
cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
<< anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
<< endl ;
+#endif
}
}
- for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
- GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
- if ( !aBusParamOutPort->IsGate() ) {
- GraphBase::InPort * aBusParamChangeInPort = NULL ;
- if ( aBusParamOutPort->IsLoop() ) {
+//PAL8176 ==> PAL8516
+//JR 24.03.2005 Debug : the number of OutPorts of a GOTONode and of InPorts of its linked
+// InLine node must be the same
+ if ( GetNodeOutPortsSize() != aLabelNode-> GetNodeInPortsSize() ) {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction # number of ports " << GetNodeOutPortsSize()
+ << " != " << aLabelNode-> GetNodeInPortsSize() << endl ;
+ SendEvent( GraphExecutor::ErrorEvent ) ;
+ return 0 ;
+ }
+ else {
+ for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
+ if ( !aBusParamOutPort->IsGate() ) {
+ GraphBase::InPort * aBusParamChangeInPort = NULL ;
+ if ( aBusParamOutPort->IsLoop() ) {
// For EndLoop do not copy EndLoop(DoLoop) in Loop(InLoop)
// aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
- }
- else {
- aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
- }
- if ( aBusParamChangeInPort ) {
- aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
- << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
- << aBusParamOutPort->PortName() << endl ;
+ }
+ else {
+ aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
+ }
+ if ( aBusParamChangeInPort ) {
+ aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
+ << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
+ << aBusParamOutPort->PortName() << endl ;
+#endif
+ }
+ else if ( IsGOTONode() ) {
+//PAL8176 ==> PAL8516
+//JR 24.03.2005 Debug : the names of OutPorts of a GOTONode and of InPorts of its linked
+// InLine node must be the same
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction # names of ports "
+ << aBusParamOutPort->PortName() << endl ;
+ SendEvent( GraphExecutor::ErrorEvent ) ;
+ return 0 ;
+ }
}
}
}
}
- if ( aLabelNode && !aLabelNode->IsLockedDataWait() ) {
- res = aLabelNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- aLabelNode->ThreadNo() == pthread_self() ) {
- firsttoNode = aLabelNode ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
- }
- else if ( firstzeroNode == NULL &&
- aLabelNode->ThreadNo() == 0 ) {
- firstzeroNode = aLabelNode ;
- }
- else {
- SomeDataNodes.push_back( aLabelNode ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
- << aLabelNode->Name() << " " << SomeDataNodes.size()
- << endl ;
- }
- }
-
- for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
- const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
- if ( anInPort->GetOutPort() ) {
- cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
- << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
- << endl ;
- }
- }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// THERE IS ONLY ONE NODE COUPLED TO A GOTONODE OR AN ENDLOOPNODE BUT Mutex/Lock for consistency
+ if ( aLabelNode ) {
const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
if ( aGateInPort ) {
if ( aGateInPort->GetOutPort() ) {
- aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+//JR 21.02.2005 Debug Memory leak : aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+//JR 30.03.2005 aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
+ aGateInPort->GetOutPort()->SetValue( aGateOutPort->Value() ) ;
}
- if ( !aLabelNode->IsLockedDataWait() ) {
- res = aLabelNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- aLabelNode->ThreadNo() == pthread_self() ) {
- firsttoNode = aLabelNode ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
- }
- else if ( firstzeroNode == NULL &&
- aLabelNode->ThreadNo() == 0 ) {
- firstzeroNode = aLabelNode ;
- }
- else {
- SomeDataNodes.push_back( aLabelNode ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
- << aLabelNode->Name() << " " << SomeDataNodes.size()
- << endl ;
- }
- }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ if ( !aLabelNode->SendSomeDataReady( Name() ) ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " SendSomeDataReady to " << aLabelNode->Name() << " ERROR"
+ << endl ;
+//JR 30.06.2005 :
+ SendEvent( GraphExecutor::ErrorEvent ) ;
+ return 0 ;
+ }
+ if ( aLabelNode->HasAllDataReady() ) {
+ aLabelNode->ThreadNo( pthread_self() ) ;
+ aLabelNode->CreateNewThread( false ) ;
+ aLabelNode->RewindStack( RewindStack() ) ;
+ aLabelNode->HasAllDataReady( false ) ;
+ res = aLabelNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
}
}
else {
}
}
- else {
+//JR Step B
+//==================================================
+// JR 09.02.2005 : this is not a EndLoop or a GOTO :
+//==================================================
+ else { // Not a EndLoop or a GOTO
+#if SuccessActionTrace
cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
<< " with " << LinkedNodesSize() << " linked nodes :" ;
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
- if ( LinkedNodes( i )->IsDataFlowNode() ) {
- linkednodesnumber -= 1 ;
- }
cdebug << " " << LinkedNodes( i )->Name() ;
}
cdebug << endl;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
+// we do not activate Nodes within the loop
+ bool IgnoreForEndLoop = false ;
+// If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
+// We activate directly the EnSwitch
+// BUT the NotSwitchBranch(es) are NOT activated :
+ bool IgnoreForDefaultSwitch = false ;
+ if ( IsLoopNode() ) {
+ GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
+ if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
+ IgnoreForEndLoop = true ;
+ }
+ }
+ else if ( IsSwitchNode() ) {
+ const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
+ if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
+// The DefaultOutPort of that SwitchNode is true and is connected
+ IgnoreForDefaultSwitch = true ;
+ }
+ }
+
+//Loop of LinkedNodes for SendSomeDataReady :
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
- bool IgnoreForEndLoop = false ;
GraphBase::ComputingNode * aComputingNode ;
aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction of " << Name()
- << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode << " IgnoreForEndLoop "
- << IgnoreForEndLoop ;
+ << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode
+ << " IgnoreForEndLoop " << IgnoreForEndLoop ;
if ( toNode ) {
cdebug << " " << toNode->Kind() << endl ;
}
- if ( toNode && !toNode->IsDataFlowNode() ) {
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ if ( toNode ) {
+//JR 18.05.2005 : we must lock because of concurrent SendEvent if NotAllDataReady :
+ toNode->LockDataReady() ;
if ( IsComputingNode() && toNode->IsInLineNode() ) {
GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
- toGateInPort->State( SUPERV::ReadyState ) ;
+ toGateInPort->PortState( SUPERV::ReadyState ) ;
GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
if ( GateOutPort ) {
GateOutPort->PortStatus( DataConnected );
- GateOutPort->State( SUPERV::ReadyState ) ;
- GateOutPort->Done( true ) ;
+ GateOutPort->PortState( SUPERV::ReadyState ) ;
+ GateOutPort->PortDone( true ) ;
}
}
- }
- if ( toNode && IsLoopNode() ) {
- GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
- if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
- if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
- IgnoreForEndLoop = true ;
- }
- else { // toNode is the EndLoopNode
+
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ if ( IsLoopNode() ) {
+ if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
GraphBase::InPort * toLoopInPort ;
toLoopInPort = toNode->GetChangeNodeInLoop() ;
- if ( toLoopInPort->State() != SUPERV::ReadyState ) {
- toLoopInPort->State( SUPERV::ReadyState ) ;
+ if ( toLoopInPort->PortState() != SUPERV::ReadyState ) {
+ toLoopInPort->PortState( SUPERV::ReadyState ) ;
}
}
- }
- }
- else if ( toNode && IsSwitchNode() ) {
- }
- else if ( toNode && toNode->IsInLineNode() ) {
- int j ;
- for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
- toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
- }
- }
- if ( toNode && !IgnoreForEndLoop ) {
- if ( toNode && toNode->IsLoopNode() ) {
- GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
- toLoopInPort->State( SUPERV::ReadyState ) ;
- GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
- LoopOutPort->PortStatus( DataConnected );
- LoopOutPort->State( SUPERV::ReadyState ) ;
- LoopOutPort->Done( true ) ;
- CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
- *anAny <<= (long ) 1 ;
- LoopOutPort->Value( anAny ) ;
+ }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ else if ( toNode->IsInLineNode() ) {
int j ;
for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
}
}
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << toNode->Name() << "->SendSomeDataReady( "
- << Name() << " )" << endl ;
- res = toNode->SendSomeDataReady( Name() ) ;
- if ( res ) {
- if ( firsttoNode == NULL &&
- toNode->ThreadNo() == pthread_self() ) {
- firsttoNode = toNode ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << toNode->Name() << endl ;
+
+ bool activatetoNode = true ;
+//We have to execute the loop :
+ if ( !IgnoreForEndLoop ) {
+//The loop is not finished :
+ if ( toNode->IsLoopNode() ) {
+//We enter in a new loop :
+ GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
+ toLoopInPort->PortState( SUPERV::ReadyState ) ;
+ GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
+ LoopOutPort->PortStatus( DataConnected );
+ LoopOutPort->PortState( SUPERV::ReadyState ) ;
+ LoopOutPort->PortDone( true ) ;
+//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
+ CORBA::Any anAny = CORBA::Any() ; // InitLoop
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 1 ;
+ anAny <<= (long ) 1 ;
+ LoopOutPort->SetValue( anAny ) ;
+ int j ;
+ for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
+ toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
+ }
}
- else if ( firstzeroNode == NULL &&
- toNode->ThreadNo() == 0 ) {
- firstzeroNode = toNode ;
+ }
+//The loop is finished :
+ else if ( IsLoopNode() ) {
+ if ( toNode->IsEndLoopNode() ) {
+//Not the corresponding EndLoopNode :
+ if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name()
+ << endl ;
+#endif
+ activatetoNode = false ;
+ }
+ }
+//Not a EndLoopNode :
+ else {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ;
+#endif
+ activatetoNode = false ;
+ }
+ }
+
+// If the DefaultPort of that SwitchNode is connected to the DefaultPort of the EndSwitchNode
+// the NotSwitchBranch(es) are NOT activated :
+ if ( IgnoreForDefaultSwitch ) {
+//We have to activate Default to EndSwitchNode
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
+ << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
+ << "IgnoreForDefaultSwitch" << IgnoreForDefaultSwitch << endl ;
+#endif
+ activatetoNode = false ;
+ const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
+ const GraphBase::InPort * anInPort = NULL ;
+ int j ;
+ for ( j = 0 ; j < anOutGatePort->InPortsSize() ; j++ ) {
+ anInPort = anOutGatePort->InPorts( j ) ;
+ const GraphBase::ComputingNode * aNode ;
+ aNode = _OutNode->Graph()->GetGraphNode( anInPort->NodeName() ) ;
+ if ( aNode ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction try "
+ << aNode << " " << aNode->Name() << " == " << toNode << " " << toNode->Name()
+ << endl ;
+#endif
+ }
+ if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) {
+// toNode is connected to the DefaultPort of that SwitchNode :
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction activate node " << aNode->Name() << endl ;
+#endif
+ activatetoNode = true ;
+ break ;
+ }
+ else {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ;
+#endif
+ }
+ }
+ }
+//JR 19.04.2005 Debug : Do not activate the EndSwitchNode if DefaultGate is close.
+//JR 20.04.2005 : it is false : an outport of the SwitchNode may be connected to an
+// input port of the EndSwitchNode
+ if ( activatetoNode ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
+#endif
+ if ( !toNode->SendSomeDataReady( Name() ) ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " SendSomeDataReady to " << toNode->Name() << " ERROR"
+ << endl ;
+//JR 30.06.2005 :
+ toNode->UnLockDataReady() ;
+ SendEvent( GraphExecutor::ErrorEvent ) ;
+ return 0 ;
}
+ }
+ toNode->UnLockDataReady() ;
+ }
+ } //End of Loop of LinkedNodes for SendSomeDataReady
+
+//JR 10.02.2005 : Debug at the end of execution of a SwitchNode :
+// Here after we may start execution of only one SwitchBranch or of the Default
+// But with activation of only one SwitchBranch we may activate several nodes of that SwitchBranch and
+// we may activate several nodes of NotSwitchBranch ( a NotSwitchBranch is a Branch of the Switch
+// where GatePorts of Nodes are not connected ; that Branches are always executed for each of SwitchBranch
+// BUT are not executed when Default is activated).
+ if ( IsSwitchNode() ) {
+ GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
+//The InPorts of the EndSwitchNode may be connected from that SwitchNode
+//So at first, if we activate a SwitchBranch, we have to establish the correct OutPort in the InPorts
+// of the EndSwitchNode (for the SwitchBranch and the NOTSwitchBranch[es] :
+//PAL8517
+// So the bug is that all input ports of the corresponding EndSwitchNode must have the status NOTDONE !
+// (Only if Default OutPort is closed and Default InPort is closed) :
+ if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
+ !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
+ << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
+#endif
+ int i ;
+ for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
+ GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
+//PAL8519
+//JR 08.03.2005 Debug : update of state only if not a StreamPort
+ if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
+ !anOutPort->IsDataStream() ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << anEndSwitchNode->Name() << " InPort "
+ << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
+#endif
+ anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
+ anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
+ }
else {
- SomeDataNodes.push_back( toNode ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
- << toNode->Name() << " " << SomeDataNodes.size() << endl ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << anEndSwitchNode->Name() << " InPort "
+ << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOT Changed : directly from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
+#endif
}
+ }
+ }
+ else {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " " << Kind() << " OutGate->Value " << GetNodeOutGate()->BoolValue()
+ << " NO reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
+#endif
+ }
+ }
+
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//Make the list of nodes to activate :
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+ GraphBase::ComputingNode * aComputingNode ;
+ aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+ toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
+ if ( toNode ) { // Only Not DataFlowNode :
+ toNode->LockDataReady() ; // Only ONE Node may send AllDataReadyEvent to an other node
+ if ( toNode->HasAllDataReady() ) {
+ SomeDataNodes.push_back( toNode ) ;
+ toNode->HasAllDataReady( false ) ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " push "
+ << toNode->Name() << " " << SomeDataNodes.size() << endl ;
+#endif
}
+ toNode->UnLockDataReady() ;
}
}
- }
- if ( firsttoNode == NULL && firstzeroNode ) {
- firsttoNode = firstzeroNode ;
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction firsttoNode = firstzeroNode "
- << endl ;
- }
- else if ( firsttoNode && firstzeroNode ) {
- SomeDataNodes.push_back( firstzeroNode ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
- << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
- }
- else {
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode
- << " firstzeroNode " << firstzeroNode << endl ;
- }
+// firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//Activation of nodes that have AllDataReady in a new thread except one :
+ while ( SomeDataNodes.size() > 1 ) {
+ GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
+ SomeDataNodes.pop_front() ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction pop size "
+ << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << aNode->Name()
+ << " Successed_SuccessAction poped and will start in a new thread" << endl ;
+#endif
+ aNode->CreateNewThread( true ) ;
+ _OutNode->IncrCreatedThreads() ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+ }
- while ( SomeDataNodes.size() ) {
- GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
- SomeDataNodes.pop_front() ;
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " Successed_SuccessAction pop "
-// << SomeDataNodes.size() << " " << aNode->Name() << endl ;
- if ( aNode->State() == GraphExecutor::DataReadyState ) {
- aNode->CreateNewThreadIf( true ) ;
- aNode->UnLockDataWait() ;
- res = aNode->DataUndef_AllDataReadyAction() ;
+//Activation of the last node that have AllDataReady in the same thread :
+ if ( SomeDataNodes.size() ) {
+ firsttoNode = SomeDataNodes.front() ;
+ SomeDataNodes.pop_front() ;
}
- else {
-// cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
-// << aNode->Name() << " "
-// << Automaton()->StateName( aNode->State() ) << endl ;
- }
- }
-
- if ( firsttoNode ) {
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " Successed_SuccessAction start firsttoNode "
-// << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
- firsttoNode->CreateNewThreadIf( false ) ;
- firsttoNode->RewindStack( RewindStack() ) ;
- if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
-// cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
-// << " : " << firsttoNode->Name() << " "
-// << Automaton()->StateName( firsttoNode->State() )
-// << " --> DataWaitingState for Thread "
-// << firsttoNode->ThreadNo() << endl ;
- firsttoNode->State( GraphExecutor::DataWaitingState ) ;
- }
-// pthread_t OldT = firsttoNode->ThreadNo() ;
- firsttoNode->ThreadNo( pthread_self() ) ;
+ if ( firsttoNode ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction start firsttoNode "
+ << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+#endif
+// firsttoNode->CreateNewThreadIf( false ) ;
+ firsttoNode->CreateNewThread( false ) ;
+ firsttoNode->RewindStack( RewindStack() ) ;
+ if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " : " << firsttoNode->Name() << " "
+ << Automaton()->StateName( firsttoNode->State() )
+ << " --> DataWaitingState for Thread "
+ << firsttoNode->ThreadNo() << endl ;
+#endif
+ firsttoNode->State( GraphExecutor::DataWaitingState ) ;
+ }
+ firsttoNode->ThreadNo( pthread_self() ) ;
// On continue avec le meme thread
-// cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
-// << firsttoNode->Name() << "Thread(" << OldT << "-->"
-// << firsttoNode->ThreadNo() << ")" << endl ;
- ThreadNo( 0 ) ;
-// cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
-// << " for " << firsttoNode->Name()
-// << " !firsttoNode->CreateNewThreadIf() "
-// << !firsttoNode->CreateNewThreadIf()
-// << " " << Automaton()->StateName( firsttoNode->State() ) ;
- if ( firsttoNode->State() == GraphExecutor::DataReadyState ) {
- cdebug << endl ;
- firsttoNode->UnLockDataWait() ;
- res = firsttoNode->DataUndef_AllDataReadyAction() ;
+ ThreadNo( 0 ) ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " for firsttoNode " << firsttoNode->Name()
+ << " " << Automaton()->StateName( firsttoNode->State() ) << endl ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//No creation of thread and with LockDataReady, an other node in an other thread cannot be
+// waiting for that lock ( if it was the case we could not find AllDataReady for firsttoNode
+ res = firsttoNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
}
else {
- cdebug << " ERROR " << endl ;
+#if SuccessActionTrace
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL" << endl ;
+#endif
+ ThreadNo( 0 ) ;
}
}
- else {
-// cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
-// << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
- ThreadNo( 0 ) ;
- }
-
-// if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
-// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
-// << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
-// _OutNode->CheckAllDone() ;
-// }
-
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
-// << linkednodesnumber << endl;
+#if SuccessActionTrace
+ cdebug_out << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction " << Name() << endl;
+#endif
return 1 ;
}
+#define SendSomeDataReadyTrace 1
bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
bool RetVal = false ;
if ( IsDataFlowNode() ) {
- cdebug << ThreadNo() << "InNode::SendSomeDataReady ----> " << Name()
- << " send Result to graph " << Name() << endl;
+#if SendSomeDataReadyTrace
+ cdebug_in << ThreadNo() << "InNode::SendSomeDataReady " << FromNodeName
+ << " send Result to graph " << Name() << endl;
+#endif
}
else {
-// cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
-// << " send SomeDataReady to " << Name() << " "
-// << Automaton()->StateName( State() )
-// << " CreateNewThreadIf() " << CreateNewThreadIf()
-// << " LockedDataWait " << IsLockedDataWait() << endl;
-#if 0
- //cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
- << " send SomeDataReady to " << Name() << " "
- << Automaton()->StateName( State() )
- << " CreateNewThreadIf() " << CreateNewThreadIf()
- << " LockedDataWait " << IsLockedDataWait() << endl;
+#if SendSomeDataReadyTrace
+ cdebug_in << pthread_self() << "/" << ThreadNo() << FromNodeName
+ << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
+ << Automaton()->StateName( State() ) << endl;
#endif
if ( State() == GraphExecutor::SuccessedState ||
State() == GraphExecutor::SuspendedSuccessedState ||
State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
-// cdebug << ThreadNo() << " " << FromNodeName
-// << " : " << Name() << " " << Automaton()->StateName( State() )
-// << " --> DataWaitingState for Thread "
-// << ThreadNo() << " " << endl ;
+#if SendSomeDataReadyTrace
+ cdebug << ThreadNo() << " " << FromNodeName
+ << " : " << Name() << " " << Automaton()->StateName( State() )
+ << " --> DataWaitingState for Thread "
+ << ThreadNo() << " " << endl ;
+#endif
State( GraphExecutor::DataWaitingState ) ;
}
// We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
+#if SendSomeDataReadyTrace
cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
<< FromNodeName << endl ;
+#endif
_InitLoop = true ;
}
- LockDataWait() ;
+#if SendSomeDataReadyTrace
+ cdebug << "SendEvent( SomeDataReadyEvent )" << endl ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
DataFromNode( FromNodeName ) ;
- RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
- if ( !RetVal ) {
- UnLockDataWait() ;
- }
- }
+// RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
+ RetVal = SendEvent( GraphExecutor::SomeDataReadyEvent );
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+ }
+#if SendSomeDataReadyTrace
+ cdebug_out << pthread_self() << "/" << ThreadNo() << FromNodeName
+ << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
+ << Automaton()->StateName( State() ) << " " << RetVal << endl;
+#endif
return RetVal ;
}
int GraphExecutor::InNode::Errored_ErrorAction() {
cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
<< " will pthread_exit" << endl;
+
+ _OutNode->NodeAborted( Name() ) ;
+
DoneAction() ;
return 1 ;
}
<< _OutNode->SuspendedThreads() << endl;
_OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
GraphExecutor::SuspendedErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
DoneAction() ;
GraphExecutor::InNode * aReStartNode = SuspendAction() ;
cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
// ResumeAction() ;
_OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
GraphExecutor::ResumedErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
SendEvent( ResumedErroredEvent ) ;
return 1 ;
}
KillAction() ;
_OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
GraphExecutor::KilledErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
return 1 ;
}
StopAction() ;
_OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
GraphExecutor::StoppedErroredState ) ;
+
+ _OutNode->NodeAborted( Name() ) ;
+
cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
return 1 ;
}
GraphExecutor::ReStartedState ) ;
int i ;
for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
- GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
+ GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
}
SendEvent( ExecuteEvent ) ;
cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
GraphExecutor::ReStartedState ) ;
int i ;
for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
- GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
+ GetChangeNodeInPort( i )->PortState( SUPERV::ReadyState ) ;
}
SendEvent( ExecuteEvent ) ;
cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
return 1 ;
}
+#define InParametersSetTrace 1
void GraphExecutor::InNode::InParametersSet( bool & Err ,
int nInParams ,
ServicesAnyData * InParametersList ) {
int i ;
- cdebug << ThreadNo() << " InParametersSet " << Name() << endl ;
+#if InParametersSetTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " InParametersSet " << Name() << endl ;
+#endif
for ( i = 0 ; i < nInParams ; i++ ) {
ServicesAnyData D = InParametersList[i];
GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
if ( anInPort->IsGate() && theOutPort == NULL ) {
+#if InParametersSetTrace
cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
<< anInPort->GetServicesParameter().Parametertype
<< " is inactive. " << anInPort->Kind() << endl ;
+#endif
}
- else if ( anInPort->State() == SUPERV::ReadyState ) {
+ else if ( anInPort->PortState() == SUPERV::ReadyState ) {
if ( anInPort->IsGate() ) {
- CORBA::Any * anAny = new CORBA::Any() ;
- *anAny <<= (long ) 0 ;
- theOutPort->Value( anAny ) ;
+//JR 21.02.2005 Debug Memory leak : CORBA::Any * anAny = new CORBA::Any() ;
+ CORBA::Any anAny = CORBA::Any() ;
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
+ anAny <<= (long ) 0 ;
+ theOutPort->SetValue( anAny ) ;
+// delete anAny ;
}
if ( !anInPort->IsDataStream() &&
!anInPort->IsDataConnected() ) {
- anInPort->State( SUPERV::WaitingState ) ;
- }
- D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
- cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind()
- << " " << anInPort->State() ;
- cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
- D.Value = *theOutPort->Value() ; // CORBA::Any
- string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
- const char * Type = _Type.c_str() ;
+ anInPort->PortState( SUPERV::WaitingState ) ;
+ }
+//JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
+// D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
+ D.Name = anInPort->PortName() ;
+//JR 30.03.2005 const CORBA::Any * AnyPtr = theOutPort->Value() ;
+ const CORBA::Any AnyRef = theOutPort->Value() ;
+#if InParametersSetTrace
+ cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() << " "
+ << anInPort->PortState() << " " << D.Name << " "
+ << anInPort->GetServicesParameter().Parametertype << endl ;
+#endif
+//JR 30.03.2005 D.Value = * AnyPtr ; // CORBA::Any
+ D.Value = AnyRef ; // CORBA::Any
+//JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
+// const char * Type = _Type.c_str() ;
+ const char * Type = anInPort->GetServicesParameter().Parametertype ;
switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
case CORBA::tk_string:
char * t;
D.Value >>= t;
+#if InParametersSetTrace
cdebug << t << " (string)" ;
+#endif
if ( !strcmp( Type , "string" ) ) {
}
else if ( !strcmp( Type , "boolean" ) ) {
sscanf( t , "%ld" , &d ) ;
c = (short ) d ;
D.Value <<= (CORBA::Any::from_char ) c ;
+#if InParametersSetTrace
cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
+#endif
// theOutPort->Value( D.Value ) ;
}
else if ( !strcmp( Type , "short" ) ) {
sscanf( t , "%ld" , &d ) ;
s = (short ) d ;
D.Value <<= s ;
+#if InParametersSetTrace
cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
+#endif
// theOutPort->Value( D.Value ) ;
}
else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
long l ;
sscanf( t , "%ld" , &l ) ;
D.Value <<= l ;
+#if InParametersSetTrace
cdebug << "string '" << t << " --> long " << l ;
+#endif
// theOutPort->Value( D.Value ) ;
}
else if ( !strcmp( Type , "float" ) ) {
sscanf( t , "%lf" , &d ) ;
float f = d ;
D.Value <<= f ;
+#if InParametersSetTrace
cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
<< setw(25) << setprecision(18) << f ;
+#endif
// theOutPort->Value( D.Value ) ;
}
else if ( !strcmp( Type , "double" ) ) {
double d ;
sscanf( t , "%lf" , &d ) ;
D.Value <<= d ;
+#if InParametersSetTrace
cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
+#endif
// theOutPort->Value( D.Value ) ;
}
// else if ( !strcmp( Type , "objref" ) ) {
// else {
// cdebug << " (other ERROR)" << endl ;
// }
+#if InParametersSetTrace
cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+#endif
break;
case CORBA::tk_long:
+#if InParametersSetTrace
+ cdebug << ThreadNo() << " " << Name() << " ArgIn" << i << " " << D.Name << " "
+ << anInPort->GetServicesParameter().Parametertype << " " << anInPort->Kind()
+ << " " ;
+ theOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ cdebug << endl ;
+#endif
long l;
D.Value >>= l;
+#if InParametersSetTrace
cdebug << l << " (long)" << endl ;
+#endif
if ( !strcmp( Type , "string" ) ) {
char t[40] ;
sprintf( t , "%ld" , l ) ;
// else {
// cdebug << " (other ERROR)" << endl ;
// }
+#if InParametersSetTrace
cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+#endif
break;
case CORBA::tk_double:
double d;
D.Value >>= d;
+#if InParametersSetTrace
cdebug << d << " (double)" << endl ;
+#endif
if ( !strcmp( Type , "string" ) ) {
char t[40] ;
sprintf( t , "%lf" , d ) ;
// else {
// cdebug << " (other ERROR)" << endl ;
// }
+#if InParametersSetTrace
cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+#endif
break;
case CORBA::tk_objref:
if ( !strcmp( Type , "string" ) ) {
CORBA::Object_ptr ObjRef ;
char * retstr ;
try {
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) ObjRef ;
+#else
D.Value >>= ObjRef ;
+#endif
retstr = ObjectToString( ObjRef ) ;
D.Value <<= retstr ;
// theOutPort->Value( D.Value ) ;
CORBA::Object_ptr obj ;
char * retstr ;
try {
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
D.Value >>= obj ;
+#endif
retstr = ObjectToString( obj ) ;
+#if InParametersSetTrace
cdebug << retstr << endl ;
+#endif
}
catch( ... ) {
if ( i != 0 ) {
// else {
// cdebug << " (other ERROR)" << endl ;
// }
+#if InParametersSetTrace
cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+#endif
break;
default:
cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
}
else {
cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
- << anInPort->State() << " NameState "
- << Automaton()->StateName( anInPort->State() ) << " PortName "
+ << anInPort->PortState() << " NameState "
+ << Automaton()->StateName( anInPort->PortState() ) << " PortName "
<< anInPort->PortName() << " Parametername "
<< anInPort->GetServicesParameter().Parametername << endl ;
Err = true ;
void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
ServicesAnyData * OutParametersList ) {
+#if InParametersSetTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " InOutParametersSet " << Name() << endl ;
+#endif
int i ;
for ( i = 0 ; i < nOutParams ; i++ ) {
ServicesAnyData D = OutParametersList[i] ;
- D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
- string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
- const char * Type = _Type.c_str() ;
- bool OutDone = GetChangeNodeOutPort(i)->Done() ;
- cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
- << OutDone << ") " << Type << " : " << endl ;
+//JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
+// D.Name = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametername);
+ D.Name = GetChangeNodeOutPort(i)->PortName() ;
+//JR 18.02.2005 Debug Memory leak : string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
+ const char * Type = GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype ;
+#if InParametersSetTrace
+ bool OutDone = GetChangeNodeOutPort(i)->PortDone() ;
+ cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " PortDone( " << OutDone << " ) Type : "
+ << Type << endl ;
+#endif
if ( !strcmp( Type , "string" ) ) {
- D.Value <<= (char *) NULL ;
+// D.Value <<= (char *) NULL ;
+ D.Value <<= "" ;
}
else if ( !strcmp( Type , "boolean" ) ) {
bool b = 0 ;
else {
D.Value <<= CORBA::Object::_nil() ;
}
-//#if 0
+#if InParametersSetTrace
switch (D.Value.type()->kind()) { // { string , long , double , objref }
case CORBA::tk_string:
char * t;
try {
CORBA::Object_ptr obj ;
char * retstr ;
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
D.Value >>= obj ;
+#endif
retstr = ObjectToString( obj ) ;
cdebug << ThreadNo() << retstr << endl ;
}
default:
cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
}
-//#endif
+#endif
OutParametersList[i] = D ;
}
}
+#define OutParametersSetTrace 1
bool GraphExecutor::InNode::OutParametersSet( bool Err ,
- SUPERV::GraphState NewState ,
+ SUPERV::GraphState PortState ,
int nOutParams ,
ServicesAnyData * OutParametersList ) {
bool RetVal = true ;
int i ;
GraphBase::OutPort * aGateOutPort = NULL ;
bool OrSwitch = false ;
- cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState "
- << NewState << endl ;
-// cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " << NewState << endl ;
+ bool DefaultSwitch = false ;
+#if OutParametersSetTrace
+ cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
+ << PortState << endl ;
+#endif
+// cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState " << PortState << endl ;
if ( nOutParams && !IsMacroNode() ) {
GraphBase::OutPort * anOutPort ;
for ( i = 0 ; i < nOutParams ; i++ ) {
anOutPort = GetChangeNodeOutPort(i) ;
if ( Err ) {
- anOutPort->State( NewState ) ;
- anOutPort->Done( true ) ;
+ anOutPort->PortState( PortState ) ;
+ anOutPort->PortDone( true ) ;
}
else {
- cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
<< anOutPort->PortName() << " " << anOutPort->Kind() ;
+#endif
ServicesAnyData D = OutParametersList[i] ;
switch (D.Value.type()->kind()) { // { string , long , double , objref }
case CORBA::tk_string: {
char * t;
D.Value >>= t;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << t << "(string)" << endl ;
+#endif
break;
}
case CORBA::tk_boolean: {
D.Value >>= (CORBA::Any::to_boolean ) b;
long l = (long ) b ;
D.Value <<= l ;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
+#endif
break;
}
case CORBA::tk_char: {
D.Value >>= (CORBA::Any::to_char ) c;
long l = (long ) c ;
D.Value <<= l ;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << c << "(char)" << endl ;
+#endif
break;
}
case CORBA::tk_short: {
D.Value >>= s;
long l = (long ) s ;
D.Value <<= l ;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << s << "(short)" << endl ;
+#endif
break;
}
case CORBA::tk_long: {
long l;
D.Value >>= l;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << l << "(long)" << endl ;
+#endif
break;
}
case CORBA::tk_float: {
D.Value >>= f;
double d = (double ) f ;
D.Value <<= d ;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << f << "(float)" << endl ;
+#endif
break;
}
case CORBA::tk_double: {
double d;
D.Value >>= d;
+#if OutParametersSetTrace
cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+#endif
break;
}
case CORBA::tk_objref: {
try {
CORBA::Object_ptr obj ;
- char * retstr ;
+#if OMNIORB_VERSION >= 4
+ D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
D.Value >>= obj ;
+#endif
+#if OutParametersSetTrace
+ char * retstr ;
retstr = ObjectToString( obj ) ;
cdebug << ThreadNo() << retstr << endl ;
+#endif
}
catch( ... ) {
cdebug << "ToString( object ) Catched ERROR" << endl ;
+ RetVal = false ;
}
break;
}
default: {
cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
+ RetVal = false ;
}
}
OutParametersList[i] = D ;
if ( !anOutPort->IsDataStream() ) {
if ( anOutPort->IsGate() ) {
aGateOutPort = anOutPort ;
+#if OutParametersSetTrace
cdebug << " Gate " ;
+#endif
long l = 1;
OutParametersList[i].Value <<= l;
- anOutPort->Value( OutParametersList[i].Value );
+ anOutPort->SetValue( OutParametersList[i].Value );
}
else if ( anOutPort->IsLoop() ) {
+#if OutParametersSetTrace
cdebug << " Loop " ;
- anOutPort->Value( OutParametersList[i].Value );
+#endif
+ anOutPort->SetValue( OutParametersList[i].Value );
// InLoop Port of EndLoopNode is ready :
- anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
+ anOutPort->ChangeInPorts(0)->PortState( SUPERV::ReadyState ) ;
}
else if ( anOutPort->IsSwitch() ) {
+#if OutParametersSetTrace
cdebug << " Switch " ;
- anOutPort->Value( OutParametersList[i].Value );
+#endif
+ anOutPort->SetValue( OutParametersList[i].Value );
if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
+//We have a SwitchBranch or the DefaultBranch .
+//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches (SwitchParameters) :
+//It controls that there is only one SwitchBranch activated
+//If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
+//DefaultSwitch is true if a SwitchPort is linked to the DefaultPort of the EndSwitchNode
if ( OrSwitch && anOutPort->BoolValue() ) {
- cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true ERROR"
+ string anErrorMessage = string( "More than one SwitchBranch should be activated in SwitchNode " ) +
+ string( Name() ) + string( "( " ) +
+ string( anOutPort->PortName() ) + string( " )" ) ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+ cdebug << "Executor::InNodeThreads::OutParameters more than one SwitchBranch is true ERROR"
<< endl ;
RetVal = false ;
}
- else {
- OrSwitch = OrSwitch | anOutPort->BoolValue() ;
- cdebug << "InNodeThreads::OutParameters OrSwitch = true" << endl ;
+ else if ( anOutPort->BoolValue() ) {
+//JR 09.02.2005 Debug : case of a SwitchPort linked to the DefaultPort of the EndSwitchNode :
+ if ( !strcmp( anOutPort->ChangeInPorts( 0 )->NodeName() , GOTONode()->CoupledNodeName() ) ) {
+ DefaultSwitch = anOutPort->BoolValue() ;
+ }
+ else {
+ OrSwitch = OrSwitch | anOutPort->BoolValue() ;
+ }
+#if OutParametersSetTrace
+ cdebug << "InNodeThreads::OutParameters OrSwitch " << OrSwitch << "DefaultSwitch "
+ << DefaultSwitch << endl ;
+#endif
}
}
- cdebug << "OutParametersSet OrSwitch " << OrSwitch ;
}
else {
+#if OutParametersSetTrace
cdebug << " Param " ;
- anOutPort->Value( OutParametersList[i].Value );
+#endif
+ anOutPort->SetValue( OutParametersList[i].Value );
}
- anOutPort->State( NewState ) ;
- anOutPort->Done( true ) ;
+ anOutPort->PortState( PortState ) ;
+ anOutPort->PortDone( true ) ;
}
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet OrSwitch " << OrSwitch << "DefaultSwitch "
+ << DefaultSwitch << endl ;
+#endif
int j ;
for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << "OutParametersSet " << "Out" << i << " " << Name() << " "
+ << anOutPort->PortName() << " " << anOutPort->Kind() << " --> "
+ << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+ << anOutPort->ChangeInPorts( j )->PortName() << anOutPort->ChangeInPorts( j )->Kind()
+ << " )" << endl ;
+#endif
bool fromGOTO = false ;
const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
- if ( !strcmp( ToNodeName , _OutNode->Graph()->Name() ) && _OutNode->Graph()->GraphMacroLevel() != 0 ) {
- cdebug << "OutParametersSet ToNodeName " << _OutNode->Graph()->Name() << " CoupledNode "
+ if ( !strcmp( ToNodeName , _OutNode->Name() ) &&
+ _OutNode->Graph()->GraphMacroLevel() != 0 ) {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet ToNodeName " << _OutNode->Name() << " CoupledNode "
<< _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
<< endl ;
- cdebug << " GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
+ cdebug << "OutParametersSet GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
+#endif
_OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
anOutPort->ChangeInPorts( j )->PortName() ,
- *anOutPort->Value() ) ;
+//JR 30.03.2005 *anOutPort->Value() ) ;
+ anOutPort->Value() ) ;
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet OutputOfAny( "
+ << _OutNode->Graph()->CoupledNodeName() << " , "
+ << anOutPort->ChangeInPorts( j )->PortName() << " , value )" << endl ;
+#endif
+
}
else {
GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
if ( ToNode ) {
// cout << "OutParametersSet ToNodeName " << ToNodeName << endl ;
- cdebug << "OutParametersSet ToNodeName " << ToNodeName << " " << ToNode->Name() << endl ;
+// cdebug << "OutParametersSet ToNodeName " << ToNodeName << " " << ToNode->Name() << endl ;
GraphBase::OutPort * aGOTOPort = ToNode->GetChangeNodeInGate()->GetOutPort() ;
if ( aGOTOPort ) {
fromGOTO = aGOTOPort->IsGOTO() ;
}
if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
+#if OutParametersSetTrace
cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
<< anOutPort->ChangeInPorts( j )->PortName() << ","
- << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
+ << anOutPort->ChangeInPorts( j )->Kind() << ") CHANGED from "
<< anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
<< "("
<< anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
- << ") to " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ")" << endl ;
+ << " to " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
+ << ") : Done " << anOutPort->PortDone() << " State "
+ << Automaton()->StateName( anOutPort->ChangeInPorts( j )->PortState() ) << endl ;
+#endif
anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
}
else {
+#if OutParametersSetTrace
cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
<< anOutPort->ChangeInPorts( j )->PortName() << ","
<< anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
<< anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
<< "("
<< anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
- << ") to " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ")" << endl ;
+ << " " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
+ << ") " << endl ;
+#endif
}
}
}
}
-//#if 0
- switch (anOutPort->Value()->type()->kind()) {
+#if OutParametersSetTrace
+ switch ( anOutPort->Value().type()->kind() ) {
case CORBA::tk_string:
char * t;
- (*anOutPort->Value()) >>= t;
+ (anOutPort->Value()) >>= t;
cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
break;
case CORBA::tk_boolean:
bool b ;
- (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
+ (anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
break;
case CORBA::tk_char:
unsigned char c ;
- (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
+ (anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
break;
case CORBA::tk_short:
short s;
- (*anOutPort->Value()) >>= s;
+ (anOutPort->Value()) >>= s;
cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
break;
case CORBA::tk_long:
long l;
- (*anOutPort->Value()) >>= l;
+ (anOutPort->Value()) >>= l;
cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
break;
case CORBA::tk_float:
float f;
- (*anOutPort->Value()) >>= f;
+ (anOutPort->Value()) >>= f;
cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
break;
case CORBA::tk_double:
double d;
- (*anOutPort->Value()) >>= d;
+ (anOutPort->Value()) >>= d;
cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
break;
case CORBA::tk_objref:
CORBA::Object_ptr obj ;
char * retstr ;
try {
- (*anOutPort->Value()) >>= obj ;
+//JR 02.08.2005 Debug SEGV anOutPort->Value() >>= obj ;
+ CORBA::Any anAny ;
+ anAny = anOutPort->Value() ;
+#if OMNIORB_VERSION >= 4
+ anAny >>= (CORBA::Any::to_object ) obj ;
+#else
+ anAny >>= obj ;
+#endif
retstr = ObjectToString( obj );
cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
<< retstr << endl ;
catch ( ... ) {
cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
<< "Catched ERROR" << endl ;
+ RetVal = false ;
}
break;
default:
cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
RetVal = false ;
}
-//#endif
+#endif
}
- }
- if ( aGateOutPort && IsSwitchNode() ) {
- if ( OrSwitch ) {
- cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+ } // End of : for ( i = 0 ; i < nOutParams ; i++ ) {
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << "OutParametersSet End of loop with " << nOutParams
+ << " OutParams. aGateOutPort " << (void *) aGateOutPort << " IsSwitchNode "
+ << IsSwitchNode() << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch
+ << endl ;
+#endif
+
+//In SwitchNodes :
+ if ( IsSwitchNode() && aGateOutPort ) {
+//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
+//It controls that there is only one SwitchBranch activated
+//If it's final value is false ==> activation of the Default in order to GOTO to EndSwitchNode
+//DefaultSwitch is true if a SwitchPort (SwitchBranch) is linked to the DefaultPort of the EndSwitchNode
+ if ( !OrSwitch && !DefaultSwitch ) {
+ if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) {
+//Dynamic activation of the Default OutPort :
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort"
+ << endl ;
+#endif
+ long l = 1;
+ OutParametersList[0].Value <<= l ;
+ aGateOutPort->SetValue( OutParametersList[0].Value ) ;
+ }
+ else {
+//The Default OutPort is not linked ==> error
+ string anErrorMessage = string( "DefaultPort of SwitchNode " ) +
+ string( Name() ) + " is not connected." ;
+ _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << " " << "OutGate " << Name() << " "
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR"
+ << endl ;
+#endif
+ RetVal = false ;
+ }
+ }
+//JR 07.04.2005 Debug : reset only if it is not a default switch (SwitchBranch or
+// SwitchParameter of SwitchNode connected to the DefaultInPort of
+// EndSwitchNode)
+// else {
+ else if ( !DefaultSwitch ) {
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << " " << "OutGate " << Name() << " Close of "
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NO DefaultPort"
+ << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch << endl ;
+#endif
long l = 0;
OutParametersList[0].Value <<= l ;
- aGateOutPort->Value( OutParametersList[0].Value ) ;
+ aGateOutPort->SetValue( OutParametersList[0].Value ) ;
}
- else {
- cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
- long l = 1;
- OutParametersList[0].Value <<= l ;
- aGateOutPort->Value( OutParametersList[0].Value ) ;
+ if ( RetVal ) {
+// The OutPort field of InPorts of EndSwitchNode may be updated from each OutPort of that SwitchNode :
+ GraphBase::EndOfSwitchNode * anEndSwitchNode = (GraphBase::EndOfSwitchNode * ) CoupledNode() ;
int i ;
+//PAL8518
+//JR 16.02.2005 Debug : At first Change InPorts of EndSwitchNode that have the same name as an OutPort of
+// the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
+//STEP A : InPorts of EndSwitchNode that have the same name as an OutPort of the SwitchNode
for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
- GraphBase::InPort * anInPort ;
- anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
+ GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
+ GraphBase::InPort * anInPort = NULL ;
+ anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ;
if ( anInPort ) {
- anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
- }
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) with same name " ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+ }
+ else {
+ cdebug << "NOT linked " ;
+ }
+ cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
}
+//STEP B : InPorts of EndSwitchNode directly connected from an OutPort of the SwitchNode
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
+ GraphBase::InPort * anInPort ;
+ int j ;
+ for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+ anInPort = anOutPort->ChangeInPorts( j ) ;
+//Update the OutPort field in the Inports directly connected of the EndSwitchNode :
+ if ( !strcmp( anInPort->NodeName() , anEndSwitchNode->Name() ) ) {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind()
+ << " ) directly connected " ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+ }
+ else {
+ cdebug << "NOT linked " ;
+ }
+ cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
+ }
+ }
+//STEP C : If it is not the DefaultBranch, explore the SwitchBranch and all NOTSwitchBranch[es]
+//Change recursively InPorts of EndSwitchNode linked to that Branch (or that SwitchNode)
+ if ( OrSwitch ) {
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+ GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+ if ( aNode != anEndSwitchNode && !aNode->IsGOTONode() &&
+ !aNode->IsDataFlowNode() && !aNode->IsDataStreamNode() ) {
+ const GraphBase::InPort * anInGate = aNode->GetNodeInGate() ;
+ GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
+//STEP C1 : SwitchBranch :
+ if ( anInGate->GetOutPort() ) {
+ if ( anInGate->GetOutPort()->BoolValue() ) {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " SWITCHBranch " << aNode->Name() << endl ;
+#endif
+ int j ;
+ for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
+ anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
+ }
+ }
+ }
+//STEP C2 : NOTSwitchBranch :
+ else {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " NOTSWITCHBranch " << aNode->Name() << endl ;
+#endif
+ int j ;
+ for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
+ anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
+ }
+ }
+ }
+ }
+ }
}
}
}
- cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState "
- << NewState << " RetVal " << RetVal << endl ;
+#if OutParametersSetTrace
+ cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
+ << PortState << " RetVal " << RetVal << endl ;
+#endif
return RetVal ;
}
+
+
+void GraphExecutor::InNode::SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort ,
+ const char * anEndSwitchNodeName ) {
+#if OutParametersSetTrace
+ cdebug_in << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " ) with " << anOutPort->InPortsSize() << " links." << endl ;
+#endif
+ GraphBase::InPort * anInPort ;
+ int i ;
+ for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
+ anInPort = anOutPort->ChangeInPorts( i ) ;
+ if ( !anInPort->IsDataStream() ) {
+//Update the OutPort field in the Inports of the EndSwitchNode :
+ if ( !strcmp( anInPort->NodeName() , anEndSwitchNodeName ) ) {
+#if OutParametersSetTrace
+ cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " ;
+ if ( anInPort->GetOutPort() ) {
+ cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+ }
+ else {
+ cdebug << "NOT linked ERROR " ;
+ }
+ cdebug << "CHANGED TO linked from "
+ << anOutPort->NodeName() << "( "
+ << anOutPort->PortName() << " )" << endl ;
+#endif
+ anInPort->ChangeOutPort( anOutPort ) ;
+ }
+ else {
+#if OutParametersSetTrace
+ cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
+ << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " << endl ;
+#endif
+ GraphBase::ComputingNode * aComputingNode ;
+ aComputingNode = _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
+ if ( aComputingNode && !aComputingNode->IsGOTONode() &&
+ !( IsEndLoopNode() && GOTONode()->CoupledNode() == aComputingNode ) ) {
+ GraphExecutor::InNode * aNode ;
+ aNode = (GraphExecutor::InNode * ) aComputingNode->GetInNode() ;
+ if ( aNode ) {
+ int j ;
+ for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
+ aNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNodeName ) ;
+ }
+ }
+ }
+ }
+ }
+ }
+#if OutParametersSetTrace
+ cdebug_out << "SetOutPortsOfInportsOfEndSwitch " << Name() << " OutPort " << anOutPort->PortName()
+ << endl ;
+#endif
+}
+