#endif
}
-
+#define SendEventTrace 0
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 Node " << Name()
+ << " ControlState : "
+ << Automaton()->ControlStateName( ControlState() )
+ << " Event : " << Automaton()->EventName( anEvent )
+ << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack << endl;
+#endif
_OldState = State() ;
_NextState = Automaton()->NextState( _OldState , anEvent ) ;
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() ;
- 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 0
// 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 ;
}
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;
+#endif
CreateNewThread( true ) ;
+ _OutNode->IncrCreatedThreads() ;
ThreadNo( 0 ) ;
}
if ( CreateNewThread() ) {
CreateNewThread( false ) ;
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 ) ;
}
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "executeAction has created thread " << T << endl ;
+#endif
ThreadStartedAction() ;
+#if ActionsTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
<< Name() << endl ;
+#endif
}
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
}
}
}
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 "
<< nextactionname << " " << statename << " NextState "
<< nextstatename << endl ;
+#endif
State( _NextState ) ;
switch ( _NextAction ) {
return 0 ;
}
}
+#if ActionsTrace
cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
<< nextactionname << endl ;
+#endif
return sts ;
}
return 1;
}
-
+#define SomeDataReadyTrace 0
int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
<< " to " << Name() << endl;
+#endif
unsigned int k;
int InReady = 0 ;
int res = 1;
bool SwitchFinished = false ;
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() ;
+ GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
LoopFinished = true ; // End of Loop
}
}
- if ( IsEndSwitchNode() ) {
- GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ;
+ if ( IsEndSwitchNode() && 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)
SwitchFinished = true ; // End of Switch
}
}
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
<< " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << 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 ;
+#if SomeDataReadyTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->PortState() << " " << anInPort->PortStatus() ;
+ if ( anOutPort ) {
+ cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
+ << " )" ;
+ }
+ cdebug<< endl ;
+#endif
if ( anInPort->IsGate() && anOutPort == NULL ) {
InReady += 1 ;
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyTrace
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 SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else if ( LoopFinished ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else if ( anInPort->IsGate() && SwitchFinished ) {
- anInPort->State( SUPERV::ReadyState ) ;
+ anInPort->PortState( SUPERV::ReadyState ) ;
InReady += 1 ;
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#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 ;
+//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()->Value( anAny ) ;
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else {
+#if SomeDataReadyTrace
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 ;
+#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 SomeDataReadyTrace
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 SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " GATE IS CLOSED from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
else {
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " GATE IS CLOSED from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName()
}
#endif
cdebug << endl ;
+#endif
}
}
- else if ( anOutPort->Done() ) {
+ else if ( anOutPort->PortDone() ) {
InReady += 1 ;
- anInPort->State( SUPERV::ReadyState ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
- << anInPort->PortName() << " " << anInPort->PortStatus() << " is Done from Node "
+ anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+ << anInPort->PortName() << " " << anInPort->PortStatus() << " "
+ << Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
<< anOutPort->PortStatus() << " " ;
#ifdef _DEBUG_
}
#endif
cdebug << endl ;
+#endif
// MacroNode : give immediately the value to the corresponding graph
if ( IsMacroNode() ) {
cout << "SomeDataReadyAction " << GraphMacroNode() << " " << GraphMacroNode()->Name()
cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Graph()->Name() << " --> InputOfAny "
<< InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready" << 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 SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
<< anInPort->PortName() << ") " << anInPort->PortStatus()
<< " is NOT Done from Node "
<< anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
- << anOutPort->PortStatus() << " " ;
+ << anOutPort->PortStatus() << " " << endl ;
+#endif
}
}
res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
}
+#if SomeDataReadyTrace
cdebug << pthread_self() << "/" << ThreadNo()
<< " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
+#endif
return res ;
}
+#define TraceDataReadyAction 0
int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
CreateNewThreadIf( false ) ;
-// cdebug << pthread_self() << " for " << ThreadNo()
-// << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+#if TraceDataReadyAction
+ cdebug << pthread_self() << " for " << ThreadNo()
+ << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+#endif
return 1;
}
int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " --> DataUndef_AllDataReadyAction " << Name()
-// << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
-// << IsLockedDataWait() ;
+#if TraceDataReadyAction
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " --> DataUndef_AllDataReadyAction " << Name()
+ << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
+ << IsLockedDataWait() ;
+#endif
if ( IsLockedDataWait() ) {
- cdebug << "DataUndef_AllDataReadyAction() WOULD DEAD-LOCK" << endl ;
+#if TraceDataReadyAction
+ cdebug << "DataUndef_AllDataReadyAction() " << Name() << "WOULD DEAD-LOCK" << endl ;
+#endif
return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
}
-// cdebug << endl ;
+#if TraceDataReadyAction
+ cdebug << "InNode::DataUndef_AllDataReadyAction CreateNewThread( CreateNewThreadIf() ) "
+ << CreateNewThreadIf() << endl ;
+#endif
CreateNewThread( CreateNewThreadIf() ) ;
if ( !CreateNewThread() ) {
-// cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+#if TraceDataReadyAction
+ 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 TraceDataReadyAction
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+#endif
return 1;
}
#include <CORBA.h>
+#define TraceDataReady_ExecuteAction 0
int GraphExecutor::InNode::DataReady_ExecuteAction() {
- int i;
-// cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
-// << Name() << endl;
+#if TraceDataReady_ExecuteAction
+ cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
+ << Name() << endl;
+#endif
_OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
GraphExecutor::ExecutingState ) ;
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 ) ;
CORBA::Object_ptr obj ;
// << 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 ;
+#endif
try {
myObjComponent->ping() ;
}
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() ) ;
+// 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() ) ;
+#if TraceDataReady_ExecuteAction
+ int i;
cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
cdebug << " , " << InParametersList[ i ].Name << "[kind"
<< (*InLineNode()->PythonFunction()).length() ;
}
cdebug << ")" << endl ;
+#endif
if ( IsOneOfInLineNodes() ) {
bool StsPyDynInvoke = true;
bool CopyInOut = false ;
if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
<< InLineNode()->PyFuncName()
<< "' IsInLineNode PyDynInvoke" << endl ;
+#endif
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
&InParametersList[0] , ServiceInParameter().length() ,
// if ( GetNodeInLoop()->GetOutPort()->BoolValue() &&
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() ,
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() ,
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 0
+#if TraceDataReady_ExecuteAction
switch ( InParametersList[i].Value.type()->kind() ) {
case CORBA::tk_string :
char * t;
<< InParametersList[i].Name.c_str()
<< " Value(string) " << t << endl ;
break ;
- case CORBA::tk_double :
- double d;
- InParametersList[i].Value >>= d;
+ case CORBA::tk_boolean:
+ bool b ;
+ InParametersList[i].Value >>= (CORBA::Any::to_boolean ) b;
cdebug << "ArgOut->In" << i << " : "
<< InParametersList[i].Name.c_str()
- << " Value(double) " << d << endl ;
+ << " Value(boolean) " << b << endl ;
+ break ;
+ case CORBA::tk_char:
+ unsigned char c ;
+ InParametersList[i].Value >>= (CORBA::Any::to_char ) c;
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(char) " << c << endl ;
+ break ;
+ case CORBA::tk_short:
+ short s ;
+ InParametersList[i].Value >>= s;
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(short) " << s << endl ;
break ;
case CORBA::tk_long :
long l;
<< InParametersList[i].Name.c_str()
<< " Value(long) " << l << endl ;
break ;
+ case CORBA::tk_float :
+ float f;
+ InParametersList[i].Value >>= f;
+ cdebug << "ArgOut->In" << i << " : "
+ << InParametersList[i].Name.c_str()
+ << " Value(float) " << f << 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_objref :
CORBA::Object_ptr obj ;
char * retstr ;
<< InParametersList[i].Name.c_str()
<< " Value(other) ERROR" << endl ;
}
-//#endif
+#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() ,
}
}
else {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
<< "' No MoreMethod" << endl ;
+#endif
CopyInOut = true ;
}
}
}
else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
strlen( InLineNode()->PyFuncName() ) ) {
-// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-// << InLineNode()->PyFuncName()
-// << "' IsSwitchNode PyDynInvoke" << endl ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
&InParametersList[0] , ServiceInParameter().length() ,
// else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
strlen( InLineNode()->PyFuncName() ) ) {
-// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-// << InLineNode()->PyFuncName()
-// << "' IsGOTONode PyDynInvoke" << endl ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsGOTONode PyDynInvoke" << endl ;
+#endif
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
&InParametersList[0] , ServiceInParameter().length() ,
// else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
else if ( ( IsEndSwitchNode() ) &&
InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
-// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-// << InLineNode()->PyFuncName()
-// << "' IsSwitchNode PyDynInvoke" << endl ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+#endif
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
InLineNode()->PyFuncName() ,
&InParametersList[0] , ServiceInParameter().length() ,
}
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[0] , ServiceInParameter().length() + 1 ,
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 ;
+#if TraceDataReady_ExecuteAction
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+#endif
int i ;
int argout0 = 0 ;
int argin0 = 0 ;
argin0 = 1 ; // after DoLoop
if ( IsLoopNode() ) { // More() is void
// OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
+#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)
+//JR 30.03.2005 OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
+ 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 ;
+//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() ) {
+ StsPyDynInvoke = false ;
+ }
+ else {
+ for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+ OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
+#if TraceDataReady_ExecuteAction
+ 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_boolean:
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
+ << " Value(boolean) "
+ << OutParametersList[argout0 + i].Name.c_str() << endl ;
+ break ;
+ case CORBA::tk_char:
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
+ << " Value(char) "
+ << OutParametersList[argout0 + i].Name.c_str() << endl ;
+ break ;
+ case CORBA::tk_short:
+ cdebug << "ArgOut->In" << argin0 + i << " : "
+ << InParametersList[argin0 + i].Name.c_str()
+ << " Value(short) "
+ << 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_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_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
}
-//#endif
}
}
if ( !StsPyDynInvoke ) {
else {
try {
try {
+#if TraceDataReady_ExecuteAction
cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ;
+#endif
DynInvoke( myObjComponent, "Names" ,
_OutNode->Graph()->Name() , Name() ) ;
}
// for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
if ( ComputingNode()->HasDataStream() ) {
try {
+#if TraceDataReady_ExecuteAction
cdebug << "DynInvoke -> SetProperties " << _OutNode->Graph()->Name() << " " << Name() << endl ;
+#endif
Engines::FieldsDict_var dict = new Engines::FieldsDict;
dict->length( 4 );
dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
}
}
if ( !Err && IsComputingNode() ) {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< " IsComputingNode DynInvoke" << endl ;
cdebug << ServiceInParameter().length()-1 << " input parameters and "
<< ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
IsLoading( false ) ;
DynInvoke( myObjComponent,
ServiceName() ,
&OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( !Err && IsFactoryNode() ) {
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << " !ObjInterface " << Name()
<< " IsFactoryNode DynInvoke" << endl ;
cdebug << ServiceInParameter().length() << " input parameters and "
<< ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
IsLoading( false ) ;
DynInvoke( myObjComponent,
ServiceName() ,
}
else {
GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
+#if TraceDataReady_ExecuteAction
cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
<< aMacroGraph->Graph()->Name() << " ->DoneWait()"
<< " State " << aMacroGraph->State() << endl;
+#endif
aMacroGraph->DoneWait() ;
+#if TraceDataReady_ExecuteAction
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 << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+#endif
return 1 ;
}
// 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 : {
int j ;
bool docdebug = false ;
State( GraphExecutor::DataWaitingState ) ;
+// cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
- cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
- << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+// cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
+// << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+// 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 ;
+//JR 21.02.2005 Debug Memory leak : *anAny <<= (long ) 0 ;
+ anAny <<= (long ) 0 ;
anOutPort->Value( anAny ) ;
- anInPort->State( SUPERV::WaitingState ) ;
+ anInPort->PortState( SUPERV::WaitingState ) ;
+// delete anAny ;
}
}
- else if ( anInPort->State() != SUPERV::WaitingState &&
+ else if ( anInPort->PortState() != SUPERV::WaitingState &&
!anInPort->IsDataConnected() ) {
if ( !docdebug ) {
- cdebug << ThreadNo()
- << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
+// cdebug << ThreadNo()
+// << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
docdebug = true ;
}
if ( !anInPort->IsDataStream() ) {
- anInPort->State( SUPERV::WaitingState ) ;
+ anInPort->PortState( SUPERV::WaitingState ) ;
}
}
- cdebug << " --> " << Name() << "( " << anInPort->PortName() << " ) "
- << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+// cdebug << " --> " << Name() << "( " << anInPort->PortName() << " ) "
+// << anInPort->PortStatus() << " " << anInPort->State() << endl ;
}
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 ) ;
+ }
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() ) {
- cdebug << ThreadNo()
- << " InNodeThreads::SetWaitingStates OutPort "
- << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
- << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
- << anOutPort->ChangeInPorts( j )->NodeName() << "( "
- << anOutPort->ChangeInPorts( j )->PortName() << " "
- << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
+// cdebug << ThreadNo()
+// << " InNodeThreads::SetWaitingStates OutPort "
+// << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+// << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
+// << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+// << anOutPort->ChangeInPorts( j )->PortName() << " "
+// << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
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
+// 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
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.
- cdebug << ThreadNo()
- << " InNodeThreads::SetWaitingStates Node " << Name() << " "
- << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
- << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
- << Name() << " : Restored to " << anOutPort->NodeName() << "( "
- << anOutPort->PortName() << " )" << endl ;
+// cdebug << ThreadNo()
+// << " InNodeThreads::SetWaitingStates Node " << Name() << " "
+// << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+// << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
+// << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+// << anOutPort->PortName() << " )" << endl ;
anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
}
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
}
}
+#define SuccessActionTrace 0
int GraphExecutor::InNode::Successed_SuccessAction() {
cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
int res = 1;
DoneAction() ;
if ( IsMacroNode() ) {
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done"
<< 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 ;
aLabelNode->SetWaitingStates( this ) ;
+#endif
// 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 ;
+//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->Value( anAny ) ;
- aLabelNode->GetChangeNodeInGate()->State( SUPERV::ReadyState ) ;
+ 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 ( firsttoNode == NULL &&
aLabelNode->ThreadNo() == pthread_self() ) {
firsttoNode = aLabelNode ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
<< aLabelNode->Name() << endl ;
+#endif
}
else if ( firstzeroNode == NULL &&
aLabelNode->ThreadNo() == 0 ) {
}
else {
SomeDataNodes.push_back( aLabelNode ) ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
<< aLabelNode->Name() << " " << SomeDataNodes.size()
<< endl ;
+#endif
}
}
- 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 ;
- }
- }
+// 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 ;
+// }
+// }
const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
if ( aGateInPort ) {
if ( aGateInPort->GetOutPort() ) {
+//JR 21.02.2005 Debug Memory leak : aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+//JR 30.03.2005 aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
}
if ( !aLabelNode->IsLockedDataWait() ) {
if ( firsttoNode == NULL &&
aLabelNode->ThreadNo() == pthread_self() ) {
firsttoNode = aLabelNode ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode "
<< aLabelNode->Name() << endl ;
+#endif
}
else if ( firstzeroNode == NULL &&
aLabelNode->ThreadNo() == 0 ) {
}
else {
SomeDataNodes.push_back( aLabelNode ) ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
<< aLabelNode->Name() << " " << SomeDataNodes.size()
<< endl ;
+#endif
}
}
}
}
}
+// JR 09.02.2005 : this is not a EndLoop or a GOTO :
else {
+#if SuccessActionTrace
cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
<< " with " << LinkedNodesSize() << " linked nodes :" ;
+#endif
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
if ( LinkedNodes( i )->IsDataFlowNode() ) {
linkednodesnumber -= 1 ;
}
+#if SuccessActionTrace
cdebug << " " << LinkedNodes( i )->Name() ;
+#endif
}
+#if SuccessActionTrace
cdebug << endl;
+#endif
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+// 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 may activate Nodes within Switch
+// or we may activate directly the EnSwitch
+// BUT the NotSwitchBranch(es) are NOT activated :
+ bool IgnoreForDefaultSwitch = 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 ;
}
+#endif
if ( toNode && !toNode->IsDataFlowNode() ) {
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 ) ;
}
}
}
else { // toNode is the EndLoopNode
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() ) {
+ const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
+ if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
+ IgnoreForDefaultSwitch = true ;
+ }
}
else if ( toNode && toNode->IsInLineNode() ) {
int j ;
if ( toNode && !IgnoreForEndLoop ) {
if ( toNode && toNode->IsLoopNode() ) {
GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
- toLoopInPort->State( SUPERV::ReadyState ) ;
+ toLoopInPort->PortState( 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->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->Value( anAny ) ;
+// delete anAny ;
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 ;
- }
- else if ( firstzeroNode == NULL &&
- toNode->ThreadNo() == 0 ) {
- firstzeroNode = toNode ;
+// If the DefaultPort of that SwitchNode is connected to the DefaultPort od the EndSwitchNode
+// the NotSwitchBranch(es) are NOT activated :
+// If the DefaultPort of that SwitchNode is connected to SwitchBranch(es)
+// the NotSwitchBranch(es) are NOT activated :
+ bool activatetoNode = true ;
+ if ( IgnoreForDefaultSwitch ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
+ << toNode->Name() << " among linked nodes to DefaultPort of " << Name() << 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 :
+ activatetoNode = true ;
+ break ;
+ }
}
- else {
- SomeDataNodes.push_back( toNode ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
- << toNode->Name() << " " << SomeDataNodes.size() << endl ;
+// if ( activatetoNode ) {
+// cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction found "
+// << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
+// << endl ;
+// }
+// else {
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " Successed_SuccessAction does NOT found "
+// << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
+// << endl ;
+// }
+ }
+ if ( activatetoNode ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
+#endif
+ res = toNode->SendSomeDataReady( Name() ) ;
+ if ( res ) {
+ if ( firsttoNode == NULL &&
+ toNode->ThreadNo() == pthread_self() ) {
+ firsttoNode = toNode ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction firsttoNode " << toNode->Name() << endl ;
+#endif
+ }
+ else if ( firstzeroNode == NULL &&
+ toNode->ThreadNo() == 0 ) {
+ firstzeroNode = toNode ;
+ }
+ else {
+ SomeDataNodes.push_back( toNode ) ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+ << Name() << " push "
+ << toNode->Name() << " " << SomeDataNodes.size() << endl ;
+#endif
+ }
}
}
}
}
}
+//PAL8517
+//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).
+// 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 ( IsSwitchNode() ) {
+ GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
+ 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 {
+#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
+ }
+ }
+
+// firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
+// firstzeroNode : node that has a null ThreadNo() and that have to be activated
if ( firsttoNode == NULL && firstzeroNode ) {
firsttoNode = firstzeroNode ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction firsttoNode = firstzeroNode "
+ << " Successed_SuccessAction firsttoNode = firstzeroNode " << firsttoNode->Name()
<< endl ;
+#endif
}
else if ( firsttoNode && firstzeroNode ) {
SomeDataNodes.push_back( firstzeroNode ) ;
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
<< firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
+#endif
+ firstzeroNode = NULL ;
}
else {
+#if SuccessActionTrace
cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode
<< " firstzeroNode " << firstzeroNode << endl ;
+#endif
}
while ( SomeDataNodes.size() ) {
GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
SomeDataNodes.pop_front() ;
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " Successed_SuccessAction pop "
-// << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction pop size "
+ << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+#endif
if ( aNode->State() == GraphExecutor::DataReadyState ) {
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction pop CreateNewThreadIf( true )"
+ << endl ;
+#endif
aNode->CreateNewThreadIf( true ) ;
+ _OutNode->IncrCreatedThreads() ;
aNode->UnLockDataWait() ;
res = aNode->DataUndef_AllDataReadyAction() ;
}
else {
-// cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
-// << aNode->Name() << " "
-// << Automaton()->StateName( aNode->State() ) << endl ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
+ << aNode->Name() << " "
+ << Automaton()->StateName( aNode->State() ) << endl ;
+#endif
}
}
if ( firsttoNode ) {
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " Successed_SuccessAction start firsttoNode "
-// << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction start firsttoNode "
+ << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+#endif
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 ;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " : " << firsttoNode->Name() << " "
+ << Automaton()->StateName( firsttoNode->State() )
+ << " --> DataWaitingState for Thread "
+ << firsttoNode->ThreadNo() << endl ;
+#endif
firsttoNode->State( GraphExecutor::DataWaitingState ) ;
}
-// pthread_t OldT = firsttoNode->ThreadNo() ;
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 SuccessActionTrace
+ 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() ;
- }
else {
cdebug << " ERROR " << endl ;
}
+#endif
+ if ( firsttoNode->State() == GraphExecutor::DataReadyState ) {
+ firsttoNode->UnLockDataWait() ;
+ res = firsttoNode->DataUndef_AllDataReadyAction() ;
+ }
}
else {
-// cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
-// << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
+#if SuccessActionTrace
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
+#endif
ThreadNo( 0 ) ;
}
// _OutNode->CheckAllDone() ;
// }
-// cdebug << pthread_self() << "/" << ThreadNo()
-// << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
-// << linkednodesnumber << endl;
+#if SuccessActionTrace
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
+ << linkednodesnumber << endl;
+#endif
return 1 ;
}
+#define SendSomeDataReadyTrace 0
bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
bool RetVal = false ;
if ( IsDataFlowNode() ) {
+#if SendSomeDataReadyTrace
cdebug << ThreadNo() << "InNode::SendSomeDataReady ----> " << Name()
<< " 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 SendSomeDataReadyTrace
+ cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
+ << " send SomeDataReady to " << Name() << " "
+ << Automaton()->StateName( State() )
+ << " CreateNewThreadIf() " << CreateNewThreadIf()
+ << " LockedDataWait " << IsLockedDataWait() << endl;
+#endif
#if 0
//cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
<< " send SomeDataReady to " << Name() << " "
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
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 0
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 ;
+//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->Value( anAny ) ;
+// delete anAny ;
}
if ( !anInPort->IsDataStream() &&
!anInPort->IsDataConnected() ) {
- anInPort->State( SUPERV::WaitingState ) ;
+ anInPort->PortState( 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() ;
+//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" ) ) {
try {
D.Value >>= obj ;
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 ;
}
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;
default:
cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
}
-//#endif
+#endif
OutParametersList[i] = D ;
}
}
+#define OutParametersSetTrace 0
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 ;
D.Value >>= obj ;
+#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 );
}
else if ( anOutPort->IsLoop() ) {
+#if OutParametersSetTrace
cdebug << " Loop " ;
+#endif
anOutPort->Value( 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 " ;
+#endif
anOutPort->Value( OutParametersList[i].Value );
if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
+//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 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"
<< 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 " ;
+#endif
anOutPort->Value( 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 ) {
+#if OutParametersSetTrace
cdebug << "OutParametersSet ToNodeName " << _OutNode->Graph()->Name() << " CoupledNode "
<< _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
<< endl ;
cdebug << " 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() ) ;
}
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 ;
+ anOutPort->Value() >>= obj ;
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() ;
+//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 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 ) ) {
+#if OutParametersSetTrace
+ cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort" << endl ;
+#endif
+ long l = 1;
+ OutParametersList[0].Value <<= l ;
+ aGateOutPort->Value( OutParametersList[0].Value ) ;
+ }
+ else {
+#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 InDefaultPort 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 ) ;
}
- else {
- cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
- << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
- long l = 1;
- OutParametersList[0].Value <<= l ;
- aGateOutPort->Value( OutParametersList[0].Value ) ;
+ if ( !OrSwitch || DefaultSwitch ) { // DefaultPort or DefaultSwitch
int i ;
for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
GraphBase::InPort * anInPort ;
anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
- if ( anInPort ) {
+//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
+// if ( anInPort && !anInPort->IsGate() ) {
+ if ( anInPort && anInPort->GetOutPort() ) {
+#if OutParametersSetTrace
+ cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName() << "( "
+ << anInPort->PortName() << " ) linked from " << anInPort->GetOutPort()->NodeName()
+ << "( " << anInPort->GetOutPort()->PortName() << " ) CHANGED TO linked from "
+ << GetChangeNodeOutPort( i )->NodeName() << "( "
+ << GetChangeNodeOutPort( i )->PortName() << " )" << endl ;
+#endif
anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
}
}
}
}
}
- 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 ;
}