Salome HOME
MacroNodes and omniORB4 porting and state of nodes when an other node has aborted
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_InNodeThreads.cxx
index 70deb4eda87f36ad181dd85a2a8306ab0790afb0..7ff605e1421b7f46e2cab2b2b2dbb5221c6dba96 100644 (file)
@@ -33,49 +33,82 @@ using namespace std;
 #include <unistd.h>
 #include <stdio.h>
 
+#if defined __GNUC__
+  #if __GNUC__ == 2
+    #define __GNUC_2__
+  #endif
+#endif
+
+#if defined __GNUC_2__
+// _CS_gbo_040604 include explicite pour l'utilisation de
+// std::transform dans UpperCase
+#include <cctype> // for toupper
+#include <algorithm> // for transform
+#endif
+
 #include "Python.h"
 
 #include "OpUtil.hxx"
 
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(SALOME_Component)
-//#include "SALOME_NamingService.hxx"
 #include "SALOME_LifeCycleCORBA.hxx"
 
-//#include "DataFlowExecutor_InNode.hxx"
+#include "DataFlowExecutor_DataFlow.hxx"
+#include "DataFlowEditor_DataFlow.hxx"   // GraphEditor package must be built BEFORE
 
-#include "DataFlowExecutor_OutNode.hxx"
 
-//static char *containerName = "FactoryServer" ;
+static void UpperCase(std::string& rstr)
+{
+#if defined __GNUC_2__
+  // _CS_gbo_040604 towupper n'existe pas. Utilisation de toupper. Par
+  // ailleurs, include explicite de cctype et algorithm pour toupper
+  // et transform respectivement. 
+  std::transform(rstr.begin(), rstr.end(), rstr.begin(),toupper);
+#else
+  std::transform(rstr.begin(), rstr.end(), rstr.begin(),towupper);
+#endif
+}
 
-int GraphExecutor::InNode::SendEvent(
-                   const GraphExecutor::NodeEvent anEvent ) {  
+#define SendEventTrace 1
+int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {  
 
   _CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
-  cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node "  << Name() 
-         << " ControlState : "
-         << Automaton()->ControlStateName( ControlState() )
-        << " Event : " << Automaton()->EventName( anEvent )
-        << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack  << endl;
+#if SendEventTrace
+  cdebug_in << pthread_self() << "/" << ThreadNo() << " SendEvent Graph " << _OutNode->Name()
+            << " Node " << Name() << " Event : " << Automaton()->EventName( anEvent )
+           << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack
+            << " ControlState : " << Automaton()->ControlStateName( ControlState() )
+            << endl;
+#endif
 
   _OldState = State() ;
   _NextState = Automaton()->NextState( _OldState , anEvent ) ;
   if ( _NextState == _OldState ) {
-    cdebug << pthread_self() << "/" << ThreadNo()
-           << " GraphExecutor::InNodeThreads::SendEvent SameStates "
-           << _OldState << endl ;
+    cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+           << " GraphExecutor::InNodeThreads::SendEvent SameStates ERROR _OldState/_NextState "
+           << _OldState << " Event " << Automaton()->EventName( anEvent ) << endl ;
     _NextAction = GraphExecutor::VoidAction ;
+    return 0 ;
   }
   else {
     _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
   }
+#if SendEventTrace
+  cdebug << pthread_self() << "/" << ThreadNo() << "NextState( " << _OldState << " , "
+         << Automaton()->EventName( anEvent ) << " ) --> _NextState = " << _NextState
+         << " NextAction( " << _NextState << " , " << Automaton()->EventName( anEvent )
+         << " ) --> _NextAction = "
+         << Automaton()->ActionName( _NextAction ) << endl ;
+#endif
 
 //  State( _NextState ) ;
-//  if ( _OldState == SUPERV::SuccessedExecutingState ||
-//       _OldState == SUPERV::ErroredExecutingState ) {
+//  if ( _OldState == GraphExecutor::SuccessedExecutingState ||
+//       _OldState == GraphExecutor::ErroredExecutingState ) {
 //    DoneAction() ;
 //  }
 
+#if SendEventTrace
   cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
          << Name() << endl << " ControlState : "
          << Automaton()->ControlStateName( ControlState() ) << endl
@@ -85,29 +118,36 @@ int GraphExecutor::InNode::SendEvent(
          << " 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;
+  int sts = true ;
+#if ExitWhenNodeAborted
+  if ( _OutNode->IsNodeAborted() ) {
+#if SendEventTrace
+    cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
+           << " will exit : a node was aborted ..." << endl ;
+    State( _NextState ) ;
+#endif
+  }
+  else {
+    sts = executeAction() ;
+  }
+#else
+  sts = executeAction() ;
+#endif
+  
+#if SendEventTrace
+  cdebug_out << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name() 
+            << " Event : " << Automaton()->EventName( anEvent )
+            << " State : " << Automaton()->StateName( State() )
+             << endl;
+#endif
 
   return sts ;
 
 }
 
+#define ActionsTrace 1
 // ReadyAction - RunningAction - DoneAction - SuspendedAction :
 // for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
 void GraphExecutor::InNode::ReadyAction() {
@@ -115,9 +155,11 @@ 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 ") ;
   }
@@ -132,9 +174,12 @@ void GraphExecutor::InNode::RunningAction() {
     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 ") ;
   }
@@ -149,9 +194,11 @@ void GraphExecutor::InNode::DoneAction() {
     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 ") ;
   }
@@ -166,9 +213,11 @@ void GraphExecutor::InNode::SuspendedAction() {
     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 ") ;
   }
@@ -195,42 +244,57 @@ GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
       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 ) ;
+//  SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
   _SuspendSync = false ;  
+  if ( ControlState() == SUPERV::ToSuspendStartState ||
+       ControlState() == SUPERV::ToSuspendState ) {
+    ControlState( SUPERV::VoidState ) ;
+  }
   if ( pthread_mutex_unlock( &_MutexWait ) ) {
     perror("SuspendAction pthread_mutex_unlock ") ;
     exit( 0 ) ;
   }
 
-  if ( ControlState() == SUPERV::ToSuspendStartState ) {
-    ControlState( SUPERV::VoidState ) ;
-  }
+  SendEvent( _aResumeEvent ) ;
+//  if ( ControlState() == SUPERV::ToSuspendStartState ) {
+//    ControlState( SUPERV::VoidState ) ;
+//  }
 
   if ( pthread_mutex_lock( &_MutexWait ) ) {
     perror("SuspendAction pthread_mutex_lock ") ;
     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 ) ) {
@@ -258,20 +322,26 @@ bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent
   }
   _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 !...
+      RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
     }
     else {
       _SuspendSync = true ;
@@ -289,22 +359,28 @@ bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent
       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 ;  
@@ -313,8 +389,10 @@ bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent
       exit( 0 ) ;
     }
   }
+#if ActionsTrace
   cdebug << pthread_self() << "/" << ThreadNo()
          << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
+#endif
   return RetVal ;
 }
 
@@ -323,7 +401,8 @@ bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode
   GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
   _aReStartNode = aReStartNode ;
   _aReStartEvent = anEvent ;
-  cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
+  cdebug << pthread_self() << "/" << ThreadNo()
+          << " GraphExecutor::InNodeThreads::ReStartAction from "
          << Name() << " " << Automaton()->StateName( State() ) << " to "
          << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
          << Automaton()->StateName( aReStartNode->State() ) ;
@@ -416,23 +495,125 @@ void GraphExecutor::InNode::StopAction() {
   }
 }
 
+void GraphExecutor::InNode::ThreadStartedAction() {
+  if ( pthread_mutex_lock( &_MutexWait ) ) {
+    perror("ThreadStarted pthread_mutex_lock ") ;
+    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 ) ;
+  }
+}
+
+void GraphExecutor::InNode::ThreadStartAction() {
+  if ( pthread_mutex_lock( &_MutexWait ) ) {
+    perror("ThreadStart pthread_mutex_lock ") ;
+    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 ") ;
+    exit( 0 ) ;
+  }
+}
+
 int GraphExecutor::InNode::executeAction() {
-  if ( !CreateNewThread() && _RewindStack > 101 ) {
+  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 ) {
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//    if ( ThreadNo() == 0 ) {
       _RewindStack = 1 ;
+#if ActionsTrace
       cdebug << pthread_self() << "/" << ThreadNo()
              << " executeAction start Thread _RewindStack " << _RewindStack << " "
              << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
              << endl;
+#endif
       pthread_t T;
       int pthread_sts = 1 ;
 //      _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
-//                           SUPERV::ExecutingState ) ; 
+//                           GraphExecutor::ExecutingState ) ; 
       while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
         char * msg = "Cannot pthread_create " ;
         perror( msg ) ;
@@ -441,7 +622,8 @@ int GraphExecutor::InNode::executeAction() {
                << 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 ;
@@ -450,16 +632,28 @@ int GraphExecutor::InNode::executeAction() {
         delete [] msg ;
         pthread_exit( msg ) ;
       }
-      cdebug << pthread_self() << "/" << ThreadNo()
-             << "executeAction has created thread " << T << endl ;
+#if ActionsTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+             << " executeAction has created thread " << T << endl ;
+#endif
+      ThreadStartedAction() ;
+#if ActionsTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+             << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
+             << Name() << endl ;
+#endif
     }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+#if 0
     else {
+#if ActionsTrace
       cdebug << pthread_self() << "/" << ThreadNo()
              << " executeAction restart Thread _RewindStack " << _RewindStack << " "
              << Automaton()->StateName( State() ) << " "
              << Automaton()->ActionName( _NextAction ) << "(" << Name()
              << ") ReStartAction ==>" << endl;
-      State( SUPERV::SuspendedSuccessedState ) ;
+#endif
+      State( GraphExecutor::SuspendedSuccessedState ) ;
       if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
         cdebug << pthread_self() << "/" << ThreadNo()
                << " executeAction STATE & CALLED "
@@ -467,31 +661,40 @@ int GraphExecutor::InNode::executeAction() {
                << ") ERROR-DEBUG " << endl;
       }
       else {
+#if ActionsTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
                << Automaton()->ActionName( _NextAction ) << "(" << Name()
                << ")" << endl;
+#endif
       }
     }
   }
+#endif
   else {
     if ( _CurrentEvent == ExecuteEvent ) {
       _RewindStack += 1 ;
     }
+#if ActionsTrace
     cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
            << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
            << endl;
+#endif
     return ExecuteAction() ;
   }
   return 1 ;
 }
 
 void GraphExecutor::InNode::coutbegin() {
-  cdebug << ThreadNo() << " " << pthread_self() << " run_function begin"
+#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;
@@ -505,6 +708,9 @@ void * run_function(void *p) {
     perror("pthread_setcancelstate ") ;
     exit(0) ;
   }
+  aNode->ThreadStartAction() ;
+//  cout << "run_function " << aNode->Name() << "->ExecuteAction() Coupled : " << aNode->CoupledNode()
+//       << endl ;
   aNode->ExecuteAction() ;
   char * msg = new char[40] ;
   sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
@@ -519,15 +725,18 @@ void * run_function(void *p) {
 
 int GraphExecutor::InNode::ExecuteAction() {
   int sts ;
-  GraphExecutor::StateEventAction nextaction = _NextAction ;
-  const char * nextactionname = Automaton()->ActionName( nextaction ) ;
+
+#if ActionsTrace
+  const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
   const char * statename = Automaton()->StateName( State() ) ;
   const char * nextstatename = Automaton()->StateName( _NextState ) ;
-  cdebug << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
-         << nextactionname << " "  << statename << " NextState "
-         << nextstatename << endl ;
+  cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name() << " --> ExecuteAction "
+            << nextactionname << " "  << statename << " NextState "
+            << nextstatename << endl ;
+#endif
+
   State( _NextState ) ;
-  switch ( nextaction ) {
+  switch ( _NextAction ) {
   case GraphExecutor::ErrorAction : {
     sts = ErrorAction() ;
     break ;
@@ -588,8 +797,8 @@ int GraphExecutor::InNode::ExecuteAction() {
     sts = Executing_SuccessAction() ;
     break ;
   }
-  case GraphExecutor::Executing_ErrorAction : {
-    sts = Executing_ErrorAction() ;
+  case GraphExecutor::Errored_ExecutingAction : {
+    sts = Errored_ExecutingAction() ;
     break ;
   }
   case GraphExecutor::Successed_SuccessAction : {
@@ -655,8 +864,10 @@ int GraphExecutor::InNode::ExecuteAction() {
     return 0 ;
   }
   }
-  cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
-         << Automaton()->ActionName( nextaction ) << endl ;
+#if ActionsTrace
+  cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
+             << nextactionname << endl ;
+#endif
   return sts ;
 }
 
@@ -671,198 +882,397 @@ int GraphExecutor::InNode::VoidAction() {
   return 1;
 }
 
-
+#define SomeDataReadyActionTrace 1
 int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
-  cdebug << pthread_self() << "/" << ThreadNo()
-         << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
-         << " to " << Name() << endl;
+#if SomeDataReadyActionTrace
+  cdebug_in << pthread_self() << "/" << ThreadNo() << " " << Name()
+            << " DataWaiting_SomeDataReadyAction from " << DataFromNode() << endl;
+#endif
   unsigned int k;
   int InReady = 0 ;
   int res = 1;
-  bool LoopFinished = false ;
   bool LoopBeginning = false ;
+  bool LoopFinished = false ;
   bool SwitchFinished = false ;
+  bool SwitchDefault = false ;
+  bool DoAllDataReadyIf = true ;
 
-  if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
-    LoopFinished = true ; // End of Loop
+  if ( IsLoopNode() ) {
+    GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
+    if ( anOutLoopPort && anOutLoopPort->BoolValue() ) {
+      LoopBeginning = true ; // Beginning of Loop
+    }
   }
-  if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
-    LoopBeginning = true ; // Beginning of Loop
+  else if ( IsEndLoopNode() ) {
+    GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; // DoLoop Port
+    if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) {
+      LoopFinished = true ; // End of Loop
+    }
   }
-  if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
-    SwitchFinished = true ;
+  else if ( IsEndSwitchNode() ) {
+    if ( strcmp( GOTONode()->CoupledNode()->Name() , DataFromNode() ) ) {
+      GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default Port
+//JR 09.02.2005 : SomeDataReady is NOT from the SwitchNode
+      if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) {
+//JR 09.02.2005 : the OutPort of the SwitchNode connected to the default port is closed ===>
+// Here after we consider that that DefaultPort is Ready (even if it's value is false) in
+// order to have the good count of InPorts Ready in the EndSwitchNode
+//        SwitchFinished = true ; // End of Switch
+//JR 25.08.2005 :
+// But we do that only if the InDefaultPort of the EndSwitchNode is not connected or
+// is connected from the OutDefaultPort of the corresponding SwitchNode
+        if ( !strcmp( GOTONode()->CoupledNode()->Name() , anOutGateSwitchPort->NodeName() ) ) {
+          SwitchFinished = true ; // End of Switch
+        }
+      }
+    }
+    else {
+//JR 20.04.2005 : SomeDataReady is FROM the SwitchNode to that EndSwitchNode
+//PAL8518
+//JR 16.02.2005 Debug : Change InPorts of EndSwitchNode that have the same name as an OutPort of
+// the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
+      GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; // Default P
+//JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is activated :
+      if ( anOutGateSwitchPort ) {
+        if ( anOutGateSwitchPort->BoolValue() ) {
+          SwitchDefault = true ;
+       }
+//JR 20.04.2005 : SomeDataReady is from the SwitchNode and Default is NOT activated :
+//                a SwitchBranch should be activated
+        else {
+          DoAllDataReadyIf = false ;
+       }
+#if SomeDataReadyActionTrace
+        cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+               << " activated from CoupledNode " << GOTONode()->CoupledNode()->Name() << " "
+               << anOutGateSwitchPort->NodeName() << "( " << anOutGateSwitchPort->PortName()
+               << " ) to InDefault " ;
+#ifdef _DEBUG_
+        if ( GraphBase::Base::_prof_debug ) {
+          anOutGateSwitchPort->StringValue( *GraphBase::Base::_fdebug ) ;
+       }
+#endif
+        cdebug << endl ;
+#endif
+      }
+//JR 28.06.2005 : SomeDataReady is from the SwitchNode and the InDefault is not connected :
+//                a SwitchBranch should be activated
+      else {
+        DoAllDataReadyIf = false ;
+      }
+    }
   }
+
+#if SomeDataReadyActionTrace
+  cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
+         << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished
+         << " SwitchDefault " << SwitchDefault << " DoAllDataReadyIf " << DoAllDataReadyIf << endl ;
+#endif
   for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
     GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
-    GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
+    GraphBase::OutPort * anOutPort ;
+    if ( SwitchDefault && !anInPort->IsDataStream() ) {
+//Get or Set the field OutPort of that InPort of the EndSwitchNode to the corresponding OutPort
+// of the SwitchNode
+      anOutPort = anInPort->GetOutPort() ;
+      if ( anOutPort ) {
+#if SomeDataReadyActionTrace
+        cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+               << anInPort->PortName() << " already setted to OutPort " << anOutPort->NodeName()
+               << "( " << anOutPort->PortName() << " )" << endl ;
+#endif
+      }
+      else {
+        anOutPort = CoupledNode()->GetChangeOutPort( anInPort->PortName() ) ;
+        if ( anOutPort ) {
+#if SomeDataReadyActionTrace
+          cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+                 << anInPort->PortName() << " change of OutPort from "
+                 << anInPort->GetOutPort()->NodeName() << "( " << anInPort->GetOutPort()->PortName()
+                 << " ) to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )"
+                 << endl ;
+#endif
+       }
+        else {
+          cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+                 << anInPort->PortName() << " have NO OutPort ERROR " << endl ;
+          return 0 ;
+       }
+        anInPort->ChangeOutPort( anOutPort ) ;
+      }
+    }
+    else {
+      anOutPort = anInPort->GetOutPort() ;
+    }
+#if SomeDataReadyActionTrace
+    cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+           << anInPort->PortName() << " " << anInPort->PortState() << " "
+           << anInPort->PortStatus() << " " << anInPort->Kind()  ;
+    if ( anOutPort ) {
+      cdebug << " from OutPort " << anOutPort->NodeName() << "( " << anOutPort->PortName()
+             << " )" ;
+    }
+    else {
+      cdebug << " without OutPort " ;
+    }
+    cdebug<< endl ;
+#endif
     if ( anInPort->IsGate() && anOutPort == NULL ) {
       InReady += 1 ;
-      anInPort->State( SUPERV::ReadyState ) ;
+      anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyActionTrace
       cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
              << anInPort->PortName() << " ControlPort inactive." << endl ;
+#endif
     }
+
+// That InPort get its value from an other node : the node of anOutPort linked to that anInPort is
+// different from the sender of SomeDataReady (DataFromNode) :
     else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
-      if ( anInPort->State() == SUPERV::ReadyState ) {
+      if ( anInPort->PortState() == SUPERV::ReadyState ) {
         InReady += 1 ;
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " " ;
+               << anInPort->PortName() << " " << anInPort->PortState() << " Was Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
+               << anOutPort->PortState() << " ) PortDone " << anOutPort->PortDone() << " " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
       else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
-        anInPort->State( SUPERV::ReadyState ) ;
+        anInPort->PortState( SUPERV::ReadyState ) ;
         InReady += 1 ;
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " LoopBeginning " << LoopBeginning ;
+               << anInPort->PortName() << " Was Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") LoopBeginning " << LoopBeginning << " " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
       else if ( LoopFinished ) {
-        anInPort->State( SUPERV::ReadyState ) ;
+        anInPort->PortState( SUPERV::ReadyState ) ;
         InReady += 1 ;
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " LoopFinished" ;
+               << anInPort->PortName() << " Was Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") LoopFinished " << LoopFinished << " " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
       else if ( anInPort->IsGate() && SwitchFinished ) {
-        anInPort->State( SUPERV::ReadyState ) ;
+        anInPort->PortState( SUPERV::ReadyState ) ;
+        InReady += 1 ;
+#if SomeDataReadyActionTrace
+        cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+               << anInPort->PortName() << " Was Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") SwitchFinished " << SwitchFinished << " " ;
+#ifdef _DEBUG_
+        if ( GraphBase::Base::_prof_debug ) {
+          anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+       }
+#endif
+        cdebug << endl ;
+#endif
+      }
+      else if ( anInPort->IsGate() &&
+                _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) {
+// GateOutPort of GOTONodes are always opened
+        anInPort->PortState( SUPERV::ReadyState ) ;
         InReady += 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()->SetValue( anAny ) ;
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " SwitchFinished" ;
+               << anInPort->PortName() << " Was Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") GOTONode " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
       else {
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was NOT Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
-               << " " << Automaton()->StateName( State() ) << " DataConnected "
-               << anInPort->IsDataConnected() << " LoopBeginning "
-               << LoopBeginning << endl ;
+               << " " << Automaton()->StateName( State() ) << " LoopBeginning "
+               << LoopBeginning << " " << anInPort->PortName() << " DataConnected "
+               << anInPort->IsDataConnected() << " Was NOT Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName() << " , "
+               << anOutPort->PortState() << " , PortDone " << anOutPort->PortDone() << ") "
+               << endl ;
+#endif
       }
     }
+
+// That InPort get its value from the sending node (DataFromNode)
     else if ( anInPort->IsGate() ) {
-      const CORBA::Any * theValue = anOutPort->Value() ;
+//JR 30.03.2005      const CORBA::Any * theValue = anOutPort->Value() ;
+      const CORBA::Any theValue = anOutPort->Value() ;
       long GateOpened ;
-      (*theValue) >>= GateOpened ;
+//JR 30.03.2005      (*theValue) >>= GateOpened ;
+      theValue >>= GateOpened ;
       if ( GateOpened != 0 ) {
         InReady += 1 ;
-        anInPort->State( SUPERV::ReadyState ) ;
+        anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Gate is Opened from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " " ;
+               << anInPort->PortName() << " Gate is Opened from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
       else if ( LoopFinished ) {
-        anInPort->State( SUPERV::ReadyState ) ;
+        anInPort->PortState( SUPERV::ReadyState ) ;
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " GATE IS CLOSED from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " LoopFinished" ;
+               << anInPort->PortName() << " GATE IS CLOSED from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") LoopFinished" ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
       else {
+#if SomeDataReadyActionTrace
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " GATE IS CLOSED from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " " ;
+               << anInPort->PortName() << " GATE IS CLOSED from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
        }
 #endif
         cdebug << endl ;
+#endif
       }
     }
-    else {
-      InReady += 1 ;
-      anInPort->State( SUPERV::ReadyState ) ;
-      cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-             << anInPort->PortName() << " is Done from "
-             << anOutPort->NodeName() << " " << anOutPort->PortName() << " " ;
+    else if ( anOutPort->PortDone() ) {
+#if SomeDataReadyActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort "
+             << anInPort->PortName() << " " << anInPort->PortStatus() << " "
+             << Automaton()->StateName( anInPort->PortState() ) << " is Done from Node "
+             << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+             << anOutPort->PortStatus() << " --> ReadyState " ;
 #ifdef _DEBUG_
-        if ( GraphBase::Base::_prof_debug ) {
-          anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
-       }
+      if ( GraphBase::Base::_prof_debug ) {
+        anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+      }
+#endif
+      cdebug << endl ;
+#endif
+      InReady += 1 ;
+      anInPort->PortState( SUPERV::ReadyState ) ;
+// MacroNode : give immediately the value to the corresponding graph
+      if ( IsMacroNode() ) {
+        GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
+        cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Name() << " --> InputOfAny "
+               << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready ( "
+               << anInPort->PortName() << " ) ===> InputOfAny" << endl ;
+//        GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
+//JR 30.03.2005        aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
+        aMacroGraph->InputOfAny( anInPort->PortName() , anOutPort->Value() ) ;
+      }
+    }
+    else {
+#if SomeDataReadyActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
+             << anInPort->PortName() << ") " << anInPort->PortStatus()
+             << " is NOT Done from Node "
+             << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+             << anOutPort->PortStatus() << " " << anOutPort->PortDone() << endl ;
 #endif
-        cdebug << endl ;
     }
   }
-  
-  if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
-    res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+
+  if ( InReady == GetNodeInPortsSize() && DoAllDataReadyIf ) { // All Flags != 0 :
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//    res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+#if SomeDataReadyActionTrace
+    cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << " HasAllDataReady"
+           << endl ;
+#endif
+    HasAllDataReady( true ) ; // ==> Ready to execute
+    res = 1 ;
   }
   else { // At least one Flag == 0 :
+    HasAllDataReady( false ) ;
     res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
   }
 
-  cdebug << pthread_self() << "/" << ThreadNo()
-         << " <-- DataWaiting_SomeDataReadyAction "  << Name() << endl;
+#if SomeDataReadyActionTrace
+  cdebug_out << pthread_self() << "/" << ThreadNo() << Name()
+             << " DataWaiting_SomeDataReadyAction " << endl;
+#endif
   return res ;
 
 }
 
+#define NotAllDataReadyActionTrace 1
 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
-  CreateNewThreadIf( false ) ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//  CreateNewThreadIf( false ) ;
+#if NotAllDataReadyActionTrace
   cdebug << pthread_self() << " for " << ThreadNo()
          << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+#endif
   return 1;
 }
 
+#define AllDataReadyActionTrace 1
 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
+#if AllDataReadyActionTrace
   cdebug << pthread_self() << "/" << ThreadNo()
-         << " --> DataUndef_AllDataReadyAction " << Name()
-         << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
-         << IsLockedDataWait() ;
-//  if ( !CreateNewThreadIf() && IsLockedDataWait() ) {
-  if ( IsLockedDataWait() ) {
-    cdebug << " WOULD DEAD-LOCK" << endl ;
-    return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
-  }
-  cdebug << endl ;
-  CreateNewThread( CreateNewThreadIf() ) ;
+         << " --> DataUndef_AllDataReadyAction " << Name() << endl ;
+//         << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
+//         << IsLockedDataWait() ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
   if ( !CreateNewThread() ) {
-    cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+#if AllDataReadyActionTrace
+    cdebug << "Thread " << ThreadNo() << " --> " << pthread_self() << endl ;
+#endif
     ThreadNo( pthread_self() ) ;
   }
+  else {
+    _OutNode->IncrCreatedThreads() ;
+  }
   _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
-                       SUPERV::DataReadyState ) ; 
+                       GraphExecutor::DataReadyState ) ; 
   ReadyAction() ;
   SUPERV::ControlState aControl = ControlState() ;
   switch ( aControl ) {
@@ -901,8 +1311,10 @@ int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
     return 0;
   }
   }
+#if AllDataReadyActionTrace
   cdebug << pthread_self() << "/" << ThreadNo()
          << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+#endif
   return 1;
 }
 
@@ -912,7 +1324,7 @@ int GraphExecutor::InNode::DataReady_SuspendAction() {
          << " Threads " << _OutNode->Threads() << " SuspendedThreads "
          << _OutNode->SuspendedThreads() << endl;
   _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
-                       SUPERV::SuspendedReadyState ) ;
+                       GraphExecutor::SuspendedReadyState ) ;
   GraphExecutor::InNode * aReStartNode = SuspendAction() ;
   cdebug << pthread_self() << "/" << ThreadNo()
          << "DataReady_SuspendAction Resumed " << Name() << endl;
@@ -931,13 +1343,13 @@ int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
          << Name() << endl;
 //  ResumeAction() ;
   _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
-                       SUPERV::ResumedReadyState ) ; 
+                       GraphExecutor::ResumedReadyState ) ; 
   return 1 ;
 }
 
 int GraphExecutor::InNode::DataReady_KillAction() {
   _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
-                       SUPERV::KilledReadyState ) ;
+                       GraphExecutor::KilledReadyState ) ;
   KillAction() ;
   cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
          << " will pthread_exit()" << endl;
@@ -946,7 +1358,7 @@ int GraphExecutor::InNode::DataReady_KillAction() {
 
 int GraphExecutor::InNode::DataReady_StopAction() {
   _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
-                       SUPERV::StoppedReadyState ) ; 
+                       GraphExecutor::StoppedReadyState ) ; 
   StopAction() ;
   cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
          << " will pthread_exit()" << endl;
@@ -955,369 +1367,800 @@ int GraphExecutor::InNode::DataReady_StopAction() {
 
 #include <CORBA.h>
 
+#define TraceDataReady_ExecuteAction 1
 int GraphExecutor::InNode::DataReady_ExecuteAction() {
-  int i;
 
-  cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
-         << Name() << endl;
+#if TraceDataReady_ExecuteAction
+  cdebug_in << pthread_self() << "/" << ThreadNo() << " DataReady_ExecuteAction "
+            << Name() << endl;
+#endif
   _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
-                       SUPERV::ExecutingState ) ; 
+                       GraphExecutor::ExecutingState ) ; 
 
   RunningAction() ;
+
+  bool Err = false ;
+
+  Engines::Container_var myContainer ;
+  Engines::Component_var myObjComponent ;
+
   SUPERV::GraphState PortState = SUPERV::ReadyState ;
-  SUPERV::AutomatonState NewState = SUPERV::DataUndefState ;
+  GraphExecutor::AutomatonState NewState = GraphExecutor::DataUndefState ;
   GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
 
-  bool Err = false ;
+  int nInParams ;
+  ServicesAnyData * InParametersList = NULL ;
+  int nOutParams ;
+  ServicesAnyData * OutParametersList = NULL ;
 
-  int nInParams = GetNodeInPortsSize()  ;
-  ServicesAnyData * InParametersList = new ServicesAnyData[nInParams];
+  nInParams = GetNodeInPortsSize()  ;
+#if TraceDataReady_ExecuteAction
+  char * aName = Name() ;
+  cdebug << pthread_self() << "/" << ThreadNo() << " " << aName
+         << " nInParams " << nInParams << " InParametersList "
+         << (void * ) InParametersList << endl ;
+#endif
+  InParametersList = new ServicesAnyData[nInParams];
   InParametersSet( Err , nInParams , InParametersList ) ;
 
-  Engines::Container_var myContainer ;
-  Engines::Component_var myObjComponent ;
-//  if ( strlen( ComponentName() ) == 0 ) {
-  if ( !IsFactoryNode() ) {
-    cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping"
-           << endl ;
-    if ( IsComputingNode() ) {
-      ObjInterface( true ) ;
-      CORBA::Object_ptr obj ;
-      InParametersList[0].Value >>= obj ;
-      CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
-      myObjComponent = Engines::Component::_narrow( objvar ) ;
-    }
-    else {
+  nOutParams = GetNodeOutPortsSize() ;
+  OutParametersList = new ServicesAnyData[nOutParams];
+  InOutParametersSet( nOutParams , OutParametersList ) ;
+#if 0
+  if ( !Err && IsComputingNode() ) {
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+           << " after creation of InParametersList : nInParams " << nInParams
+           << " :" << endl;
+    int i ;
+    for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+      cdebug << "InParametersList[" << i << "] : "
+             << InParametersList[i].Name << " "
+             << AnyValue( InParametersList[i].Value ) << endl ;
     }
-  }
-  else if ( CORBA::is_nil( Component() ) ) {
-    Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
-                                     my_strdup( ComponentName() ) ,
-                                     myContainer , myObjComponent ) ;
-//    if ( !Err && nInParams > 1 &&
-//         strcmp( ComponentName() , InterfaceName() ) &&
-//         InParametersList[ 1 ].Value.type()->kind() ==
-//                                                  CORBA::tk_objref ) {
-//    }
-//    else {
-    ObjInterface( false ) ;
-//    }
-    SetContainer( myContainer ) ;
-    SetComponent( myObjComponent ) ;
-  }
-  else {
-    myContainer = Container() ;
-    myObjComponent = Component() ;
-    cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
+    CORBA::Object * obj ;
+    InParametersList[0].Value >>= obj ;
+    Engines::Component_var theObjComponent ;
+    theObjComponent = Engines::Component::_narrow( obj ) ;
+    DynInvoke( theObjComponent , "ping" ,
+               NULL , 0 , NULL , 0 ) ;
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " ping done "
            << endl ;
-    myObjComponent->ping() ;
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+           << " after creation of OutParametersList :" << endl;
+    for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
+      cdebug << "OutParametersList[" << i << "] : "
+             << OutParametersList[i].Name << " "
+             << AnyValue( OutParametersList[i].Value ) << endl ;
+    }
   }
+#endif
 
-  int nOutParams = GetNodeOutPortsSize()  ;
-  ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams];
-  InOutParametersSet( nOutParams , OutParametersList ) ;
+  if ( !IsMacroNode() ) {
+
+    if ( !IsFactoryNode() ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
+#endif
+      if ( IsComputingNode() ) {
+        ObjInterface( true ) ;
+//JR 05.08.2005 DEBUG : that code runs with SALOME_3 (OMNIOrb4) ...
+#if OMNIORB_VERSION >= 4
+        CORBA::Object * obj ;
+        InParametersList[0].Value >>= obj ;
+        myObjComponent = Engines::Component::_narrow( obj ) ;
+//JR 05.08.2005 DEBUG : the folowing code runs with OMNIOrb3 but gives
+//                      unpredictable results with SALOME_3 (OMNIOrb4) ...
+#else
+        CORBA::Object_ptr obj ;
+        InParametersList[0].Value >>= obj ;
+        CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
+        myObjComponent = Engines::Component::_duplicate( Engines::Component::_narrow( objvar ) ) ;
+#endif
+      }
+      else {
+      }
+    }
+    else if ( CORBA::is_nil( Component() ) ) {
+      Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
+//JR 17.02.2005 Memory Leak                                                my_strdup( ComponentName() ) ,
+                                                ComponentName() ,
+                                                myContainer , myObjComponent ) ;
+      ObjInterface( false ) ;
+      SetContainer( myContainer ) ;
+      SetComponent( myObjComponent ) ;
+    }
+    else {
+      myContainer = Container() ;
+      myObjComponent = Component() ;
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
+             << endl ;
+      try {
+        myObjComponent->ping() ;
+      }
+      catch( ... ) {
+        cdebug << "ping() ERROR catched" << endl ;
+        Err = true ;
+      }
+#endif
+    }
 
-//  if ( strlen( ComponentName() ) ) {
     if ( Err || ControlState() == SUPERV::ToKillState ||
                 ControlState() == SUPERV::ToKillDoneState ||
                 ControlState() == SUPERV::ToStopState ) {
+#if TraceDataReady_ExecuteAction
       cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
+#endif
       Err = true ;
     }
     else {
-      if ( !Err ) {
-        cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
-        for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
-          cdebug << " , " << InParametersList[ i ].Name << "[kind"
-                 << InParametersList[ i ].Value.type()->kind() << "]" ;
-        }
-        for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
-          cdebug << " , " << OutParametersList[ i ].Name << "[kind"
-                 << OutParametersList[ i ].Value.type()->kind() << "]" ;
-        }
-        cdebug << ")" << endl ;
-
-        if ( IsOneOfInLineNodes() ) {
-          bool StsPyDynInvoke = true ;
-          _OutNode->PyThreadLock() ;
-          SetPyCpuUsed() ;
-          try {
-            if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
-                 strlen( InLineNode()->PyFuncName() ) ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-                     << InLineNode()->PyFuncName()
-                     << "' IsInLineNode PyDynInvoke"  << endl ;
-              StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &InParametersList[0] , ServiceInParameter().length() ,
-                               &OutParametersList[0] , ServiceOutParameter().length() ) ;
-           }
-            else if ( IsLoopNode() ) {
-              if ( GetNodeInLoop()->GetOutPort()->BoolValue() ) { // InLoop Port
-                cdebug << ThreadNo() << " !ObjInterface " << Name()
-                       << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
-                       << "'" << endl ;
-                StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &InParametersList[1] , ServiceInParameter().length() ,
-                               &OutParametersList[1] , ServiceOutParameter().length() ) ;
-             }
-              else {
-                cdebug << ThreadNo() << " !ObjInterface " << Name()
-                       << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
-                       << "'" << endl ;
-                StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
-                             LoopNode()->PyNextName() ,
-                             &InParametersList[1] , ServiceInParameter().length() ,
-                             &OutParametersList[1] , ServiceOutParameter().length() ) ;
-             }
-              if ( StsPyDynInvoke ) {
-                cdebug << ThreadNo() << " !ObjInterface " << Name()
-                       << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
-                       << "' Copy of " << ServiceInParameter().length()
-                       << " OutParameters" << endl ;
-                int i ;
-                for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
-                  InParametersList[i].Value = OutParametersList[i].Value ;
-                  InParametersList[i].Name = OutParametersList[i].Name ;
-//#if 0
-                  switch ( InParametersList[i].Value.type()->kind() ) {
-                  case CORBA::tk_string :
-                    char * t;
-                    InParametersList[i].Value >>= t ;
-                    cdebug << "ArgOut->In" << i << " : "
-                           << InParametersList[i].Name.c_str()
-                           << " Value(string) " << t << endl ;
-                    break ;
-                  case CORBA::tk_double :
-                    double d;
-                    InParametersList[i].Value >>= d;
-                    cdebug << "ArgOut->In" << i << " : "
-                           << InParametersList[i].Name.c_str()
-                           << " Value(double) " << d << endl ;
-                    break ;
-                  case CORBA::tk_long :
-                    long l;
-                    InParametersList[i].Value >>= l;
-                    cdebug << "ArgOut->In" << i << " : "
-                           << InParametersList[i].Name.c_str()
-                           << " Value(long) " << l << endl ;
-                    break ;
-                  case CORBA::tk_objref :
-                    CORBA::Object_ptr obj ;
-                    char * retstr ;
-                    try {
-                      InParametersList[i].Value >>= obj ;
-                      retstr = ObjectToString( obj );
-                      cdebug << "ArgOut->In" << i << " : "
-                             << InParametersList[i].Name.c_str()
-                             << " Value(object reference) " << retstr << endl ;
-                    }
-                    catch ( ... ) {
-                      cdebug << "ArgOut->In" << i << " : "
-                             << InParametersList[i].Name.c_str()
-                             << " Value(object reference) Catched ERROR" << endl ;
-                   }
-                    break ;
-                  default :
-                    cdebug << "ArgOut->In" << i << " : "
-                           << InParametersList[i].Name.c_str()
-                           << " Value(other) ERROR" << endl ;
-                 }
-//#endif
-               }
-                StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
-                           LoopNode()->PyMoreName() ,
-                           &InParametersList[1] , ServiceInParameter().length() ,
-                           &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
-             }
-              else {
-                Err = true ;
-                cdebug << ThreadNo() << " InLineNode " << Name() << " "
-                       << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
-                       << " Python Dynamic Call Error"
-                       << endl ;
-             }
-           }
-            else if ( IsSwitchNode() ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-                     << InLineNode()->PyFuncName()
-                     << "' IsSwitchNode PyDynInvoke"  << endl ;
-              StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &InParametersList[0] , ServiceInParameter().length() ,
-                               &OutParametersList[0] , ServiceOutParameter().length() ) ;
-           }
-            else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
-                      strlen( InLineNode()->PyFuncName() ) ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-                     << InLineNode()->PyFuncName()
-                     << "' IsGOTONode PyDynInvoke"  << endl ;
-              StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &InParametersList[0] , ServiceInParameter().length() ,
-                               &OutParametersList[0] , ServiceOutParameter().length() ) ;
-           }
-            else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
-                      strlen( InLineNode()->PyFuncName() ) ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-                     << InLineNode()->PyFuncName()
-                     << "' IsSwitchNode PyDynInvoke"  << endl ;
-              StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &InParametersList[0] , ServiceInParameter().length() ,
-                               &OutParametersList[0] , ServiceOutParameter().length() ) ;
-           }
-            else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
-                      strlen( InLineNode()->PyFuncName() ) == 0 ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name()
-                     << " Copy of " << ServiceInParameter().length()
-                     << " OutParameters" << endl ;
-              int i ;
-              int argout0 = 0 ;
-              int argin0 = 0 ;
-              if ( IsEndLoopNode() ) {
-                argout0 = 1 ;
-                argin0 = 1 ; // after 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[argin0 + i].Name.c_str() << endl ;
-                  break ;
-                case CORBA::tk_double :
-                  cdebug << "ArgOut->In" << argin0 + i << " : "
-                         << InParametersList[argin0 + i].Name.c_str()
-                         << " Value(double) "
-                         << OutParametersList[argin0 + i].Name.c_str() << endl ;
-                  break ;
-                case CORBA::tk_long :
-                  cdebug << "ArgOut->In" << argin0 + i << " : "
-                         << InParametersList[argin0 + i].Name.c_str()
-                         << " Value(long) "
-                         << OutParametersList[ 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[argin0 + i].Name.c_str() << endl ;
-                  break ;
-                default :
-                  cdebug << "ArgOut->In" << argin0 + i << " : "
-                         << InParametersList[argin0 + i].Name.c_str()
-                         << " Value(other) ERROR "
-                         << OutParametersList[argin0 + i].Name.c_str() << endl ;
-               }
-//#endif
-             }
-           }
-            if ( !StsPyDynInvoke ) {
-              Err = true ;
-              cdebug << ThreadNo() << " InLineNode " << Name()
-                     << " Python Dynamic Call Error"
-                     << endl ;
-           }
-         }
-          catch( ... ) {
-            Err = true ;
-            cdebug << ThreadNo() << " InLineNode " << Name()
-                   << " Python Dynamic Call Exception catched ERROR"
-                   << endl ;
-         }
-          CpuUsed( true ) ;
-          _OutNode->PyThreadUnLock() ;
-       }
-        else {
+      if ( ControlState() == SUPERV::ToSuspendState ) {
+#if TraceDataReady_ExecuteAction
+        cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
+        MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
+#endif
+      }
+#if TraceDataReady_ExecuteAction
+      int i;
+      cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
+      for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+        cdebug << " , " << InParametersList[ i ].Name << "[kind"
+               << InParametersList[ i ].Value.type()->kind() << "]" ;
+      }
+      for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
+        cdebug << " , " << OutParametersList[ i ].Name << "[kind"
+               << OutParametersList[ i ].Value.type()->kind() << "]" ;
+      }
+      if ( IsOneOfInLineNodes() ) {
+        cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
+               << InLineNode()->PyRunMethod() << " length "
+               << (*InLineNode()->PythonFunction()).length()
+               << " InParametersList " << InParametersList
+               << " OutParametersList " << OutParametersList ;
+      }
+      cdebug << ")" << endl ;
+#endif
+
+      if ( IsOneOfInLineNodes() ) {
+        Err = DataReady_ExecuteActionInLineNodes( InParametersList ,
+                                                  OutParametersList ) ;
+      }
+
+      else {
+#if 0
+        if ( IsComputingNode() ) {
+          cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+                 << " myObjComponent " << myObjComponent << " "
+                 << ObjectToString( myObjComponent ) << endl ;
+          cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+                 << " before DynInvoke nInParams " << nInParams
+                 << " :" << endl;
+          int i ;
+          CORBA::Object * obj ;
+          InParametersList[0].Value >>= obj ;
+          Engines::Component_var theObjComponent ;
+          theObjComponent = Engines::Component::_narrow( obj ) ;
+          DynInvoke( theObjComponent , "ping" ,
+                     NULL , 0 , NULL , 0 ) ;
+          for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+            cdebug << "InParametersList[" << i << "] : "
+                   << InParametersList[i].Name << " "
+                   << AnyValue( InParametersList[i].Value ) << endl ;
+          }
+        }
+#endif
+        try {
+#if TraceDataReady_ExecuteAction
+          cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
+#endif
+          DynInvoke( myObjComponent, "Names" ,
+                     _OutNode->Name() , Name() ) ;
+        }
+        catch( ... ) {
+          string anErrorMessage = string( "Dynamic CORBA call to Names for node " ) +
+                                  string( Name() ) + " catched." ;
+          _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+          cdebug << "DynInvoke Names catched ERROR" << endl ;
+        }
+// for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
+        if ( ComputingNode()->HasDataStream() ) {
           try {
-            try {
-              DynInvoke( myObjComponent, "Names" ,
-                         _OutNode->Name() , Name() ) ;
+#if TraceDataReady_ExecuteAction
+            cdebug << "DynInvoke -> SetProperties " << _OutNode->Name() << " " << Name() << endl ;
+#endif
+            Engines::FieldsDict_var dict = new Engines::FieldsDict;
+            dict->length( 4 );
+            dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
+               // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
+               //              dict[ 0 ].value <<= myContainer->getHostName() ;
+            char FullyQualifiedDomainName[256]="";
+            gethostname(FullyQualifiedDomainName,255);
+            dict[ 0 ].value <<=  FullyQualifiedDomainName ;
+            dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
+            dict[ 1 ].value <<= "/tmp" ;
+            dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
+            stringstream ofst1 ;
+            ofst1 << ComputingNode()->SubStreamGraph() ;
+            string cpl = string( "/tmp/" ) + string( _OutNode->Name() ) + string( "_" ) + 
+                        ofst1.str() + string( ".cpl" );
+            dict[ 2 ].value <<= cpl.c_str() ;
+            dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
+            string uname = Name();
+            UpperCase( uname);
+            dict[ 3 ].value <<= uname.c_str() ;
+
+            myObjComponent->setProperties( dict ) ;
+          }
+          catch( ... ) {
+            string anErrorMessage = string( "Dynamic CORBA call to setProperties for node " ) +
+                                    string( Name() ) + " catched." ;
+            _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+            cdebug << "DynInvoke setProperties catched ERROR" << endl ;
+            Err = true;
+          }
+        }
+
+        try {
+          if ( !Err && IsComputingNode() ) {
+#if TraceDataReady_ExecuteAction
+            cdebug << ThreadNo() << " !ObjInterface " << Name()
+                   << " IsComputingNode DynInvoke"  << endl ;
+            cdebug << ServiceInParameter().length()-1 << " input parameters and "
+                   << ServiceOutParameter().length() << " output parameters" << endl ;
+#endif
+            IsLoading( false ) ;
+            DynInvoke( myObjComponent,
+                       ServiceName() ,
+                       &InParametersList[1] , ServiceInParameter().length()-1 ,
+                       &OutParametersList[0] , ServiceOutParameter().length() ) ;
+#if 0
+            { cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+                     << " myObjComponent " << myObjComponent << " "
+                     << ObjectToString( myObjComponent ) << endl ;
+              cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+                     << " after DynInvoke nInParams " << nInParams
+                     << " :" << endl;
+              CORBA::Object * obj ;
+              InParametersList[0].Value >>= obj ;
+              Engines::Component_var theObjComponent ;
+              theObjComponent = Engines::Component::_narrow( obj ) ;
+              DynInvoke( theObjComponent , "ping" ,
+                         NULL , 0 , NULL , 0 ) ;
+              for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+                cdebug << "InParametersList[" << i << "] : "
+                       << InParametersList[i].Name << " "
+                       << AnyValue( InParametersList[i].Value ) << endl ;
+              }
             }
-            catch( ... ) {
-              cdebug << "DynInvoke Names catched ERROR" << endl ;
-           }
+#endif
+          }
+          else if ( !Err && IsFactoryNode() ) {
+#if TraceDataReady_ExecuteAction
+            cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
+                   << " IsFactoryNode DynInvoke"  << endl ;
             cdebug << ServiceInParameter().length() << " input parameters and "
                    << ServiceOutParameter().length() << " output parameters" << endl ;
-            if ( IsComputingNode() ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name()
-                     << " IsComputingNode DynInvoke"  << endl ;
-              DynInvoke( myObjComponent,
-                         ServiceName() ,
-                         &InParametersList[1] , ServiceInParameter().length()-1 ,
-                         &OutParametersList[0] , ServiceOutParameter().length() ) ;
-           }
-            else if ( IsFactoryNode() ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name()
-                     << " IsFactoryNode DynInvoke"  << endl ;
-              DynInvoke( myObjComponent,
-                         ServiceName() ,
-                         &InParametersList[0] , ServiceInParameter().length() ,
-                         &OutParametersList[0] , ServiceOutParameter().length() ) ;
-           }
+#endif
+            IsLoading( false ) ;
+            DynInvoke( myObjComponent,
+                       ServiceName() ,
+                       &InParametersList[0] , ServiceInParameter().length() ,
+                       &OutParametersList[0] , ServiceOutParameter().length() ) ;
           }
-          catch( ... ) {
-            Err = true ;
-            cdebug << ThreadNo() << " !ObjInterface " << Name()
-                   << " Node(Component) Dynamic Call Exception catched ERROR"
-                   << endl ;
-         }
+//            cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
+//                   << myObjComponent->CpuUsed_impl() << endl ;
+        }
+        catch( ... ) {
+          Err = true ;
+          string anErrorMessage = string( "Dynamic CORBA call for node " ) +
+                                  string( Name() ) + " catched." ;
+          _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+          cdebug << pthread_self() << "/" << ThreadNo() << " !ObjInterface " << Name()
+                 << " Node(Component) Dynamic Call Exception catched ERROR"
+                 << endl ;
+//Reset of _ThreadId in the Container ...
+//          try {
+//            myObjComponent->Kill_impl() ;
+//          }
+//          catch( ... ) {
+//          }
         }
       }
     }
-//  }
-//  else {
-//    sleep( 1 ) ;
-//  }
+  }
 
   if ( Err ) {
+    
+    // if exception or something else - IsLoading( false ) may not NOT has been called
+    if ( IsLoading() )
+      IsLoading( false );
+
     if ( ControlState() == SUPERV::ToKillState ||
          ControlState() == SUPERV::ToKillDoneState ||
          ControlState() == SUPERV::ToStopState ) {
       PortState = SUPERV::ErrorState ;
-      NewState = SUPERV::KilledState ;
+      NewState = GraphExecutor::KilledState ;
       NewEvent = GraphExecutor::KillEvent ;
     }
     else {
       PortState = SUPERV::ErrorState ;
-      NewState = SUPERV::ErroredState ;
+      NewState = GraphExecutor::ErroredState ;
       NewEvent = GraphExecutor::ErrorEvent ;
     }
   }
   else {
     PortState = SUPERV::ReadyState ;
-    NewState = SUPERV::DataReadyState ;
+    NewState = GraphExecutor::DataReadyState ;
     NewEvent = GraphExecutor::SuccessEvent ;
   }
 
-  bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
-  if ( !ErrOut ) {
-    NewEvent = GraphExecutor::ErrorEvent ;
+  if ( !IsMacroNode() ) {
+//JRStep A
+    bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
+    if ( !ErrOut ) {
+      NewEvent = GraphExecutor::ErrorEvent ;
+    }
+#if 0
+    if ( !Err && IsComputingNode() ) {
+      cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+             << " myObjComponent " << myObjComponent << " "
+             << ObjectToString( myObjComponent ) << endl ;
+      cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+             << " delete [] InParametersList nInParams " << nInParams
+             << " :" << endl;
+      int i ;
+      CORBA::Object * obj ;
+      InParametersList[0].Value >>= obj ;
+      Engines::Component_var theObjComponent ;
+      theObjComponent = Engines::Component::_narrow( obj ) ;
+      DynInvoke( theObjComponent , "ping" ,
+                 NULL , 0 , NULL , 0 ) ;
+      for ( i = 0 ; i < nInParams-1 ; i++ ) { // Without Gates
+        cdebug << "InParametersList[" << i << "] : "
+               << InParametersList[i].Name << " "
+               << AnyValue( InParametersList[i].Value ) << endl ;
+      }
+    }
+#endif
+    try {
+      delete [] InParametersList ;
+    }
+    catch(...) {
+      cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+             << " catch ERROR of delete [] InParametersList" << endl ;
+    }
+#if TraceDataReady_ExecuteAction
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " "
+           << " delete [] OutParametersList :" << endl;
+    int i ;
+    for ( i = 0 ; i < nOutParams-1 ; i++ ) { // Without Gates
+      cdebug << "OutParametersList[" << i << "] : "
+             << OutParametersList[i].Name << " "
+             << AnyValue( OutParametersList[i].Value ) << endl ;
+    }
+#endif
+    try {
+      delete [] OutParametersList ;
+    }
+    catch(...) {
+      cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name()
+             << " catch ERROR of delete [] OutParametersList" << endl ;
+    }
+    SendEvent( NewEvent ) ;
   }
-  delete [] InParametersList ;
-  delete [] OutParametersList ;
+  else {
+    GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
+#if TraceDataReady_ExecuteAction
+    int i ;
+    for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
+      cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
+             << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
+             << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
+      if ( GraphBase::Base::_prof_debug ) {
+        GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
+      }
+      if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
+        cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
+      }
+      cdebug << endl ;
+    }
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
+           << aMacroGraph->Name() << " ->DoneWait()"
+           << " State " << aMacroGraph->State() << endl;
+#endif
+    aMacroGraph->DoneWait() ;
+#if TraceDataReady_ExecuteAction
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State "
+           << aMacroGraph->State() << endl;
+#endif
 
-  SendEvent( NewEvent );
+//JR 29.09.2005 Debug for CEA (examples/GraphMacroNodes1) :
+// Set of value of the OutGate of the corresponding MacroNode was missing
+    CORBA::Any anAny = CORBA::Any() ;
+    anAny <<= (long ) 1 ;
+    GraphMacroNode()->GraphEditor()->Executor()->OutputOfAny( Name() , "Gate" , anAny ) ;
+#if TraceDataReady_ExecuteAction
+    cdebug << "DataReady_ExecuteAction OutputOfAny( " << Name() << " , Gate , 1 )" << endl ;
+
+    for ( i = 0 ; i < GraphMacroNode()->GetNodeOutPortsSize() ; i++ ) {
+      cdebug << "Out" << i << " " << GraphMacroNode()->GetNodeOutPort( i )->PortName() << " "
+             << GraphMacroNode()->GetChangeNodeOutPort( i )->PortState() << " Done="
+             << GraphMacroNode()->GetChangeNodeOutPort( i )->PortDone() << " " ;
+      if ( GraphBase::Base::_prof_debug ) {
+        GraphMacroNode()->GetNodeOutPort( i )->StringValue( *GraphBase::Base::_fdebug ) ;
+      }
+      if ( GraphMacroNode()->GetChangeNodeOutPort( i )->IsGate() ) {
+        cdebug << " BoolValue " << GraphMacroNode()->GetChangeNodeOutPort( i )->BoolValue() ;
+      }
+      cdebug << endl ;
+    }
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
+#endif
+    if ( aMacroGraph->State() == SUPERV::DoneState ) {
+      PortState = SUPERV::ReadyState ;
+      NewState = GraphExecutor::DataReadyState ;
+      NewEvent = GraphExecutor::SuccessEvent ;
+    }
+    else {
+      Err = true ;
+      if ( ControlState() == SUPERV::ToKillState ||
+           ControlState() == SUPERV::ToKillDoneState ||
+           ControlState() == SUPERV::ToStopState ) {
+        PortState = SUPERV::ErrorState ;
+        NewState = GraphExecutor::KilledState ;
+        NewEvent = GraphExecutor::KillEvent ;
+      }
+      else {
+        PortState = SUPERV::ErrorState ;
+        NewState = GraphExecutor::ErroredState ;
+        NewEvent = GraphExecutor::ErrorEvent ;
+      }
+    }
+    bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
+    if ( !ErrOut ) {
+      NewEvent = GraphExecutor::ErrorEvent ;
+    }
+    delete [] InParametersList ;
+    delete [] OutParametersList ;
+    SendEvent( NewEvent ) ;
+  }
 
-  cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+#if TraceDataReady_ExecuteAction
+  cdebug_out << ThreadNo() << " DataReady_ExecuteAction " << Name() << endl;
+#endif
   return 1 ;
 }
 
+int GraphExecutor::InNode::DataReady_ExecuteActionInLineNodes( ServicesAnyData * InParametersList ,
+                                                               ServicesAnyData * OutParametersList ) {
+
+#if TraceDataReady_ExecuteAction
+  cdebug_in << pthread_self() << "/" << ThreadNo()
+            << " DataReady_ExecuteActionInLineNodes " << Name()
+            << " InParametersList " << InParametersList
+            << " OutParametersList " << OutParametersList  << endl;
+#endif
+  bool Err = false ;
+  bool StsPyDynInvoke = true ;
+  _OutNode->PyThreadLock() ;
+  SetPyCpuUsed() ;
+  try {
+    bool ItIsaLoop = false ;
+    bool CopyInOut = false ;
+    if ( IsInLineNode() &&
+         strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+             << InLineNode()->PyFuncName()
+             << "' IsInLineNode PyDynInvoke"  << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                    InLineNode()->PyFuncName() ,
+                                    InParametersList , ServiceInParameter().length() ,
+                                    OutParametersList , ServiceOutParameter().length() ) ;
+      if ( !StsPyDynInvoke ) {
+        RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+      }
+    }
+    else if ( IsLoopNode() ) {
+      ItIsaLoop = true ;
+      Err = DataReady_ExecuteActionLoopNodes( InParametersList ,
+                                              OutParametersList ,
+                                              CopyInOut ) ;
+    }
+    else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
+              strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+             << InLineNode()->PyFuncName()
+             << "' IsSwitchNode PyDynInvoke"  << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                    InLineNode()->PyFuncName() ,
+                                    InParametersList , ServiceInParameter().length() ,
+                                    OutParametersList , ServiceOutParameter().length() ) ;
+      if ( !StsPyDynInvoke ) {
+        string anErrorMessage = string( "Dynamic Python call for node " ) +
+                                string( Name() ) + " function " +
+                                InLineNode()->PyFuncName() + " error." ;
+        _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+        RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+      }
+    }
+    else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
+              strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+             << InLineNode()->PyFuncName()
+             << "' IsGOTONode PyDynInvoke"  << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                    InLineNode()->PyFuncName() ,
+                                    InParametersList , ServiceInParameter().length() ,
+                                    OutParametersList , ServiceOutParameter().length() ) ;
+      if ( !StsPyDynInvoke ) {
+        string anErrorMessage = string( "Dynamic Python call for node " ) +
+                                string( Name() ) + " function " +
+                                InLineNode()->PyFuncName() + " error." ;
+        _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+        RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
+      }
+    }
+    else if ( ( IsEndSwitchNode() ) &&
+              InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+             << InLineNode()->PyFuncName()
+             << "' IsSwitchNode PyDynInvoke"  << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                    InLineNode()->PyFuncName() ,
+                                    InParametersList , ServiceInParameter().length() ,
+                                    OutParametersList , ServiceOutParameter().length() ) ;
+      if ( !StsPyDynInvoke ) {
+        string anErrorMessage = string( "Dynamic Python call for node " ) +
+                                string( Name() ) + " function " +
+                                InLineNode()->PyFuncName() + " error." ;
+        _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+        RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+      }
+    }
+    else if ( IsEndLoopNode() &&
+              InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+             << InLineNode()->PyFuncName()
+             << "' IsSwitchNode PyDynInvoke"  << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                    InLineNode()->PyFuncName() ,
+                                    InParametersList , ServiceInParameter().length() + 1 ,
+                                    OutParametersList , ServiceOutParameter().length() + 1 ) ;
+      if ( !StsPyDynInvoke ) {
+        string anErrorMessage = string( "Dynamic Python call for node " ) +
+                                string( Name() ) + " function " +
+                                InLineNode()->PyFuncName() + " error." ;
+        _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+        RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+      }
+    }
+
+    if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
+                          strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
+// This is a void Python Function : without code (No PyFuncName)
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name()
+             << " Copy of " << ServiceInParameter().length()
+             << " OutParameters" << endl ;
+#endif
+      int i ;
+      int argout0 = 0 ;
+      int argin0 = 0 ;
+      if ( IsLoopNode() || IsEndLoopNode() ) {
+        argout0 = 1 ;
+        argin0 = 1 ; // after DoLoop
+        if ( IsLoopNode() ) { // More() is void
+#if TraceDataReady_ExecuteAction
+          cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
+                 << endl ;
+#endif
+          GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
+          OutParametersList[0].Value = anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
+        }
+      }
+//PAL8072 ==> PAL8512
+//JR 24.03.2005 : Debug : void InLine Python function : check of the number of Input Ports
+//                        equals the number of Output Ports was missing
+      if ( ServiceInParameter().length() != ServiceOutParameter().length() ) {
+         string anErrorMessage = string( "Inconsistent number of In<->Out parameters for the vois Python function of the node " ) +
+                                 string( Name() ) ;
+         _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+         StsPyDynInvoke = false ;
+      }
+      else {
+        for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+          OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
+#if TraceDataReady_ExecuteAction
+          cdebug << "ArgOut->In" << InParametersList[argin0 + i].Name.c_str()
+                 << " " << AnyValue( InParametersList[argin0 + i].Value )
+                 << endl ;
+#endif
+        }
+      }
+    }
+    if ( !StsPyDynInvoke ) {
+      Err = true ;
+      string anErrorMessage = string( "Dynamic Python call for node " ) +
+                              string( Name() ) + " error." ;
+      _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+      cdebug << ThreadNo() << " InLineNode " << Name()
+             << " Python Dynamic Call Error"
+             << endl ;
+    }
+  }
+  catch( ... ) {
+    Err = true ;
+    string anErrorMessage = string( "Dynamic Python call for node " ) +
+                            string( Name() ) + " catched." ;
+    _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+    cdebug << ThreadNo() << " InLineNode " << Name()
+           << " Python Dynamic Call Exception catched ERROR"
+           << endl ;
+  }
+  CpuUsed( true ) ;
+  _OutNode->PyThreadUnLock() ;
+#if TraceDataReady_ExecuteAction
+  cdebug_out << pthread_self() << "/" << ThreadNo()
+             << " DataReady_ExecuteActionInLineNodes " << Name() << endl;
+#endif
+  return Err ;
+}
+
+int GraphExecutor::InNode::DataReady_ExecuteActionLoopNodes( ServicesAnyData * InParametersList ,
+                                                             ServicesAnyData * OutParametersList ,
+                                                             bool & CopyInOut ) {
+
+#if TraceDataReady_ExecuteAction
+  cdebug_in << pthread_self() << "/" << ThreadNo()
+            << " DataReady_ExecuteActionLoopNodes " << Name()
+            << " InParametersList " << InParametersList
+            << " OutParametersList " << OutParametersList  << endl;
+#endif
+  bool Err = false ;
+  bool StsPyDynInvoke = true ;
+      bool CopyOutIn = false ;
+// Switch between Init() and Next()
+// if InLoop port is true and does not come from EndLoop ==> execute Init
+// if InLoop port is false or come from EndLoop ==> execute Next
+  if ( _InitLoop ) {
+    if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name()
+             << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
+             << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                    InLineNode()->PyFuncName() ,
+                                    &InParametersList[1] , ServiceInParameter().length() ,
+                                    &OutParametersList[1] , ServiceOutParameter().length() ) ;
+      if ( !StsPyDynInvoke ) {
+        string anErrorMessage = string( "Dynamic Python call for node " ) +
+                                string( Name() ) + " function " +
+                                InLineNode()->PyFuncName() + " error." ;
+        _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+        RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+      }
+      CopyOutIn = true ;
+    }
+    else {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name()
+             << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
+#endif
+    }
+#if TraceDataReady_ExecuteAction
+    cdebug << ThreadNo() << " !ObjInterface " << Name()
+           << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
+#endif
+    _InitLoop = false ;
+  }
+  else if ( LoopNode()->PyNextMethod() &&
+            strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
+#if TraceDataReady_ExecuteAction
+    cdebug << ThreadNo() << " !ObjInterface " << Name()
+           << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
+           << "' " << LoopNode()->PyNextMethod() << endl ;
+#endif
+    StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
+                                  LoopNode()->PyNextName() ,
+                                  &InParametersList[1] , ServiceInParameter().length() ,
+                                  &OutParametersList[1] , ServiceOutParameter().length() ) ;
+    if ( !StsPyDynInvoke ) {
+      string anErrorMessage = string( "Dynamic Python call for node " ) +
+                              string( Name() ) + " function " +
+                              LoopNode()->PyNextName() + " error." ;
+      _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+      RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
+    }
+    CopyOutIn = true ;
+  }
+  else {
+#if TraceDataReady_ExecuteAction
+    cdebug << ThreadNo() << " !ObjInterface " << Name()
+           << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
+#endif
+  }
+  if ( StsPyDynInvoke ) {
+    if ( CopyOutIn ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name()
+             << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+             << "' Copy of " << ServiceInParameter().length()
+             << " OutParameters" << endl ;
+#endif
+      int i ;
+// Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
+      for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
+        InParametersList[i].Value = OutParametersList[i].Value ;
+        InParametersList[i].Name = OutParametersList[i].Name ;
+#if TraceDataReady_ExecuteAction
+        cdebug << "ArgOut->In" << InParametersList[ i].Name.c_str()
+               << " " << AnyValue( InParametersList[ i].Value )
+               << endl ;
+#endif
+      }
+    }
+    if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name()
+             << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+             << "' " << LoopNode()->PyMoreMethod() << endl ;
+#endif
+      StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
+                                    LoopNode()->PyMoreName() ,
+                                    &InParametersList[1] , ServiceInParameter().length() ,
+                                    &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
+      if ( !StsPyDynInvoke ) {
+        string anErrorMessage = string( "Dynamic Python call for node " ) +
+                                string( Name() ) + " function " +
+                                LoopNode()->PyMoreName() + " error." ;
+        _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+        RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
+      }
+    }
+    else {
+#if TraceDataReady_ExecuteAction
+      cdebug << ThreadNo() << " !ObjInterface " << Name()
+             << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+             << "' No MoreMethod" << endl ;
+#endif
+      CopyInOut = true ;
+    }
+  }
+  else {
+    Err = true ;
+    cdebug << ThreadNo() << " InLineNode " << Name() << " "
+           << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
+           << " Python Dynamic Call Error"
+           << endl ;
+  }
+#if TraceDataReady_ExecuteAction
+  cdebug_out << pthread_self() << "/" << ThreadNo()
+             << " DataReady_ExecuteActionLoopNodes " << Name() << endl;
+#endif
+  return Err ;
+}
+
 int GraphExecutor::InNode::Executing_SuspendAction() {
   _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
-                       SUPERV::SuspendedExecutingState ) ; 
+                       GraphExecutor::SuspendedExecutingState ) ; 
   cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
   return 1 ;
 }
 
 int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
   cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
-  SUPERV::AutomatonState next_state ;
+  GraphExecutor::AutomatonState next_state ;
   next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
   _OutNode->NewThread() ; // Only for Threads count
   _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
@@ -1327,51 +2170,53 @@ int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
 }
 
 int GraphExecutor::InNode::Executing_KillAction() {
-  cdebug << ThreadNo() << " Executing_KillAction " << Name() << endl;
+  cdebug << ThreadNo() << " Executing_KillAction " << Name() << " Thread " << ThreadNo()<< endl;
   int RetVal = 0 ;
   if ( pthread_self() == ThreadNo() ) {
     cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
     KillAction() ;
     _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
-                         SUPERV::KilledExecutingState ) ; 
+                         GraphExecutor::KilledExecutingState ) ; 
     RetVal = 1 ;
   }
   else if ( pthread_cancel( ThreadNo() ) ) {
     perror("Executing_KillAction pthread_cancel error") ;
   }
   else {
-    cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
+    cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
            << " pthread_canceled" << endl ;
     KillAction() ;
-    _OutNode->ExitThread() ;
+    _OutNode->ExitThread( ThreadNo() ) ;
     _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
-                         SUPERV::KilledExecutingState ) ; 
+                         GraphExecutor::KilledExecutingState ) ; 
   }
   return RetVal ;
 }
 
 int GraphExecutor::InNode::Executing_StopAction() {
-  cdebug << ThreadNo() << " Executing_StopAction " << Name() << endl;
+  cdebug << ThreadNo() << " Executing_StopAction " << Name() << " Thread " << ThreadNo() << endl;
   int RetVal = 0 ;
   if ( pthread_cancel( ThreadNo() ) ) {
     perror("Executing_KillAction pthread_cancel error") ;
   }
   else {
-    cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
+    cdebug << pthread_self() << " Executing_KillAction : ThreadId " << ThreadNo()
            << " pthread_canceled" << endl ;
     StopAction() ;
-    _OutNode->ExitThread() ;
+    _OutNode->ExitThread( ThreadNo() ) ;
     _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
-                         SUPERV::StoppedExecutingState ) ; 
+                         GraphExecutor::StoppedExecutingState ) ; 
   }
   return RetVal ;
 }
 
 int GraphExecutor::InNode::Executing_SuccessAction() {
-  cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
+//  cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
   _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
-                       SUPERV::SuccessedState ) ; 
-//  DoneAction() ;
+                       GraphExecutor::SuccessedState ) ; 
+//  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 : {
@@ -1405,15 +2250,16 @@ int GraphExecutor::InNode::Executing_SuccessAction() {
     return 0;
   }
   }
-  cdebug << ThreadNo() << " <-- Executing_SuccessAction "  << Name() << endl;
+//  cdebug << ThreadNo() << " <-- Executing_SuccessAction "  << Name() << endl;
   return 1 ;
 }
 
-int GraphExecutor::InNode::Executing_ErrorAction() {
-  cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
+int GraphExecutor::InNode::Errored_ExecutingAction() {
+  cdebug << ThreadNo() << " --> Errored_ExecutingAction " << Name() << endl;
   _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
-                       SUPERV::ErroredState ) ; 
-//  DoneAction() ;
+                       GraphExecutor::ErroredState ) ; 
+
+  _OutNode->NodeAborted( Name() ) ;
 
   SUPERV::ControlState aControl = ControlState() ;
   switch ( aControl ) {
@@ -1443,61 +2289,164 @@ int GraphExecutor::InNode::Executing_ErrorAction() {
   }
   default : {
     cdebug << ThreadNo()
-           << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
+           << " GraphExecutor::InNodeThreads::Errored_ExecutingAction Error Undefined Control : "
            << aControl << endl ;
     return 0;
   }
   }
-  cdebug << ThreadNo() << " <-- Executing_ErrorAction "  << Name() << endl;
+  cdebug << ThreadNo() << " <-- Errored_ExecutingAction "  << Name() << endl;
   return 1 ;
 }
 
+#define SetWaitingStatesTrace 0
 // Set SUPERV::WaitingState to all InPorts 
 void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
   int i ;
   int j ;
   bool docdebug = false ;
-  State( SUPERV::DataWaitingState ) ;
+  State( GraphExecutor::DataWaitingState ) ;
+#if SetWaitingStatesTrace
+  cdebug << "SetWaitingStates " << Name() << " " << Automaton()->StateName( State() ) << endl ;
+#endif
   for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
     GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
-    if ( anInPort->IsGate() ) { // Loop : Open the doors
+#if SetWaitingStatesTrace
+    cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
+           << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
+#endif
+// PAL8513
+// JR Debug 07.01.2005 : Close the Gates instead of open !!!
+    if ( anInPort->IsGate() ) { // Loop : Close the doors
       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
       if ( anOutPort ) {
-        CORBA::Any * anAny = new CORBA::Any() ;
-        *anAny <<= (long ) 1 ;
-        anOutPort->Value( anAny ) ;
-        anInPort->State( SUPERV::ReadyState ) ;
+//JR 21.02.2005 Debug Memory leak :        CORBA::Any * anAny = new CORBA::Any() ;
+        CORBA::Any anAny = CORBA::Any() ;
+//        *anAny <<= (long ) 1 ;
+//JR 21.02.2005 Debug Memory leak :        *anAny <<= (long ) 0 ;
+        anAny <<= (long ) 0 ;
+        anOutPort->SetValue( anAny ) ;
+        anInPort->PortState( SUPERV::WaitingState ) ;
+//        delete anAny ;
       }
     }
-    else if ( anInPort->State() != SUPERV::WaitingState ) {
+    else if ( anInPort->PortState() != SUPERV::WaitingState &&
+              !anInPort->IsDataConnected() ) {
       if ( !docdebug ) {
+#if SetWaitingStatesTrace
         cdebug << ThreadNo()
                << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
+#endif
         docdebug = true ;
       }
-      anInPort->State( SUPERV::WaitingState ) ;
+      if ( !anInPort->IsDataStream() ) {
+        anInPort->PortState( SUPERV::WaitingState ) ;
+      }
     }
+#if SetWaitingStatesTrace
+    cdebug << "               --> InPort " << Name() << "( " << anInPort->PortName() << " ) "
+           << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
+#endif
   }
   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
-    for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
-      GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
-//      if ( !( IsGOTONode() && i == 0 ) && !( IsEndLoopNode() && i <= 1 ) ) {
+    GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
+// PAL8514
+//JR 07.03.2005 Debug : Reset of Done flag in OutPorts !... :
+    if ( !anOutPort->IsDataStream() ) {
+      anOutPort->PortDone( false ) ;
+      anOutPort->PortState( SUPERV::WaitingState ) ;
+    }
+    for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
       if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
-           !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) ) {
-        GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
+           !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
+           !anOutPort->IsDataStream() &&
+           !anOutPort->ChangeInPorts( j )->IsDataStream() &&
+           !anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
+#if SetWaitingStatesTrace
+        cdebug << ThreadNo()
+               << " InNodeThreads::SetWaitingStates OutPort "
+               << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+               << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
+               << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+               << anOutPort->ChangeInPorts( j )->PortName() << " "
+               << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
+#endif
+       GraphBase::ComputingNode * aToNode ;
+        aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ;
+// JR 12.01.2005 Debug : the OutPort linked to the InPort of a EndSwitchNode was changed so final
+//                       values of InPorts of EndSwitchNode may be wrong
+//                       (depending of order of linkednodes)
+        if ( !aToNode->IsEndSwitchNode() && 
+             strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
+// After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
+// EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
+#if SetWaitingStatesTrace
+          cdebug << ThreadNo()
+                 << " InNodeThreads::SetWaitingStates Node " << Name() << " " 
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
+                 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+                 << anOutPort->PortName() << " )" << endl ;
+#endif
+          anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+        }
+//PAL8624
+//JR 21.04.2005 Debug : the OutPort field of InPorts of EndSwitchNodes must be an OutPort
+//                      of a SwitchBranch or of a NOTSwitchBranch if a link exist
+//                      (if not there is no change)
+        else if ( !IsSwitchNode() && aToNode->IsEndSwitchNode() &&
+                  strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
+#if SetWaitingStatesTrace
+          cdebug << ThreadNo()
+                 << " InNodeThreads::SetWaitingStates Node " << Name() << " " 
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( "
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != "
+                 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+                 << anOutPort->PortName() << " )" << endl ;
+#endif
+          anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+       }
+        GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ;
         if ( aNode != EndNode ) {
           aNode->SetWaitingStates( EndNode ) ;
        }
       }
     }
+#if SetWaitingStatesTrace
+    cdebug << "               --> OutPort " << Name() << "( " << anOutPort->PortName() << " ) "
+           << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
+#endif
   }
 }
 
+#define SuccessActionTrace 1
+//JR Step B
 int GraphExecutor::InNode::Successed_SuccessAction() {
-  cdebug << ThreadNo() << " --> Successed_SuccessAction "  << Name() << endl;
+#if SuccessActionTrace
+  cdebug_in << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "  << Name()
+            << endl;
+#endif
   int res = 1;
-  int linkednodesnumber = LinkedNodesSize() ;
-  GraphExecutor::InNode *firstzeroNode = NULL ;
+//PAL8624
+//JR 15.04.2005 Debug RetroConception :
+//The behavior of firstzeroNode and firsttoNode is not reliable and must be removed
+//The real problem is :
+// 1. send "SomeDataReady" event to linked nodes of the current node
+// 2. DO NOT send "AllDataReady" event even if all data are ready in SomeDataReady Action
+//    but register only that all data are ready :
+//    MAJOR ENHANCEMENT OF GRAPHEXECUTOR
+// 3. activate AllDataReady Action for each node (except the first one ) which have all
+//    its data ready with a creation of a new thread
+// 3. activate AllDataReady Action for the first node which have all its data
+//    ready in the current thread
+//The difficult problem (that I had in the past) was to clearly identify the above behavior ==>
+// firstzeroNode, firsttoNode, createnewthreadif, loackdatawait, "would dead lock" etc...
+// because if SomeDataReady Action see that all data were ready, it called immediately
+// AllDataReady Action ==> bugs difficult to understand and to reproduce
+//And the MAJOR DEBUG is (since the first "maquette") : we may have concurrent executions
+// of "SomeDataReady" in several threads and there WAS NO MUTEX to protect that
+// concurrent actions on the same node
+//  int linkednodesnumber = LinkedNodesSize() ;
+//  GraphExecutor::InNode *firstzeroNode = NULL ;
   GraphExecutor::InNode *firsttoNode = NULL ;
   GraphExecutor::InNode *toNode ;
   int i ;
@@ -1506,8 +2455,21 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
 
   DoneAction() ;
 
+  if ( IsMacroNode() ) {
+#if SuccessActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done for that MacroNode"
+             << endl ;
+#endif
+    return 1;
+  }
+
+//JR 09.02.2005 : That complicated part of the code manages LOOPS and GOTO
   if ( IsGOTONode() ||
        ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
+#if SuccessActionTrace
+    cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+           << " SetWaitingStates " << endl ;
+#endif
     const GraphBase::OutPort * aGateOutPort ;
     if ( IsGOTONode() ) {
       aGateOutPort = GetNodeOutGate() ;
@@ -1515,330 +2477,515 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
     else {
       aGateOutPort = GetNodeOutLoop() ;
     }
+    if ( aGateOutPort->InPortsSize() != 1 ) {
+      cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction aGateOutPort->InPortsSize "
+             << aGateOutPort->InPortsSize() << " != 1 ERROR " << Name() << endl ;
+    }
+    GraphExecutor::InNode * aLabelNode = NULL ;
     for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
       const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
-      GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
-      cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
+      aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+#if SuccessActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
              << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
+#endif
+      State( GraphExecutor::DataWaitingState ) ;
       aLabelNode->SetWaitingStates( this ) ;
+// JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
+      GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
+      if ( anOutPort ) {
+//JR 21.02.2005 Debug Memory leak :        CORBA::Any * anAny = new CORBA::Any() ;
+        CORBA::Any anAny = CORBA::Any() ;
+//JR 21.02.2005 Debug Memory leak :        *anAny <<= (long ) 1 ;
+        anAny <<= (long ) 1 ;
+        anOutPort->SetValue( anAny ) ;
+        aLabelNode->GetChangeNodeInGate()->PortState( SUPERV::ReadyState ) ;
+//        delete anAny ;
+      }
       for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
         const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
         if ( anInPort->GetOutPort() ) {
+#if SuccessActionTrace
           cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
                  << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
                  << endl ;
+#endif
        }
       }
-      for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
-        GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
-        if ( !aBusParamOutPort->IsGate() ) {
-          GraphBase::InPort * aBusParamChangeInPort = NULL ;
-          if ( aBusParamOutPort->IsLoop() ) {
-            aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ;
-         }
-          else {
-            aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
-         }
-          if ( aBusParamChangeInPort ) {
-            aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
-            cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
-                   << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
-                   << aBusParamOutPort->PortName() << endl ;
-            if ( !aLabelNode->IsLockedDataWait() ) {
-              res = aLabelNode->SendSomeDataReady( Name() ) ;
-              if ( res ) {
-                if ( firsttoNode == NULL &&
-                     aLabelNode->ThreadNo() == pthread_self() ) {
-                  firsttoNode = aLabelNode ;
-                  cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
-                         << aLabelNode->Name() << endl ;
-                }
-                else if ( firstzeroNode == NULL &&
-                          aLabelNode->ThreadNo() == 0 ) {
-                  firstzeroNode = aLabelNode ;
-               }
-                else {
-                  SomeDataNodes.push_back( aLabelNode ) ;
-                  cdebug << ThreadNo() << " Successed_SuccessAction push "
-                         << SomeDataNodes.size() << " " << aLabelNode->Name()
-                         << endl ;
-               }
-             }
-           }
+//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 {
-              cdebug << ThreadNo()
-                     << " Successed_SuccessAction Loop to HeadNode "
-                     << aLabelNode->Name() << " with datas from " << Name() << "("
-                     << aBusParamOutPort->PortName() << ") to port "
-                     << aBusParamChangeInPort->PortName() << endl;
+              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 ;
            }
-         }
-          else {
-            cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
-                   << " NO port " << aBusParamOutPort->PortName() << " in "
-                   << aLabelNode->Name() << 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::OutPort * aGateOutPort = GetNodeOutPort( 0 ) ; // DoLoop or OutGate
+    }
+
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// THERE IS ONLY ONE NODE COUPLED TO A GOTONODE OR AN ENDLOOPNODE BUT Mutex/Lock for consistency
+    if ( aLabelNode ) {
       const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
       if ( aGateInPort ) {
         if ( aGateInPort->GetOutPort() ) {
-          aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+//JR 21.02.2005 Debug Memory leak :          aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+//JR 30.03.2005          aGateInPort->GetOutPort()->Value( *aGateOutPort->Value() ) ;
+          aGateInPort->GetOutPort()->SetValue( aGateOutPort->Value() ) ;
        }
-        if ( !aLabelNode->IsLockedDataWait() ) {
-          res = aLabelNode->SendSomeDataReady( Name() ) ;
-          if ( res ) {
-            if ( firsttoNode == NULL &&
-                 aLabelNode->ThreadNo() == pthread_self() ) {
-              firsttoNode = aLabelNode ;
-              cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
-                     << aLabelNode->Name() << endl ;
-            }
-            else if ( firstzeroNode == NULL &&
-                      aLabelNode->ThreadNo() == 0 ) {
-              firstzeroNode = aLabelNode ;
-           }
-            else {
-              SomeDataNodes.push_back( aLabelNode ) ;
-              cdebug << ThreadNo() << " Successed_SuccessAction push "
-                     << SomeDataNodes.size() << " " << aLabelNode->Name()
-                     << endl ;
-           }
-         }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+        if ( !aLabelNode->SendSomeDataReady( Name() ) ) {
+          cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+                 << Name() << " SendSomeDataReady to " << aLabelNode->Name() << " ERROR"
+                 << endl ;
+//JR 30.06.2005 :
+          SendEvent( GraphExecutor::ErrorEvent ) ;
+          return 0 ;
+       }
+        if ( aLabelNode->HasAllDataReady() ) {
+          aLabelNode->ThreadNo( pthread_self() ) ;
+          aLabelNode->CreateNewThread( false ) ;
+          aLabelNode->RewindStack( RewindStack() ) ;
+          aLabelNode->HasAllDataReady( false ) ;
+          res = aLabelNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
        }
       }
       else {
-        cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
+        cdebug << pthread_self() << "/" << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
                << " NO port " << aGateOutPort->PortName() << " in "
                << aLabelNode->Name() << endl;
       }
     }
   }
 
-  else {
+//JR Step B
+//==================================================
+// JR 09.02.2005 : this is not a EndLoop or a GOTO :
+//==================================================
+  else { // Not a EndLoop or a GOTO
+#if SuccessActionTrace
     cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
            << " with " << LinkedNodesSize() << " linked nodes :" ;
     for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
-      if ( LinkedNodes( i )->IsDataFlowNode() ) {
-        linkednodesnumber -= 1 ;
-      }
       cdebug << " " << LinkedNodes( i )->Name() ;
     }
     cdebug << endl;
-//    SUPERV::ControlState aControl = ControlState() ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+// If this is a LoopNode and if DoLoopPort == false, we go directly to the EndOfLoopNode and
+// we do not activate Nodes within the loop
+    bool IgnoreForEndLoop = false ;
+// If this is a SwitchNode and if DefaultOutPort == true, we do not activate Nodes within Switch
+// We activate directly the EnSwitch
+// BUT the NotSwitchBranch(es) are NOT activated :
+    bool IgnoreForDefaultSwitch = false ;
+    if ( IsLoopNode() ) {
+      GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
+      if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
+        IgnoreForEndLoop = true ;
+      }
+    }
+    else if ( IsSwitchNode() ) {
+      const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
+      if ( anOutGatePort->BoolValue() && anOutGatePort->InPortsSize() ) { // DefaultPort is activated
+// The DefaultOutPort of that SwitchNode is true and is connected
+        IgnoreForDefaultSwitch = true ;
+      }
+    }
+
+//Loop of LinkedNodes for SendSomeDataReady :
     for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
-      bool IgnoreForEndLoop = false ;
-      toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
-      cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
-             << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
-      if ( toNode && !toNode->IsDataFlowNode() ) {
+      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 ;
+      if ( toNode ) {
+        cdebug << " " << toNode->Kind() << endl ;
+      }
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+      if ( toNode ) {
+//JR 18.05.2005 : we must lock because of concurrent SendEvent if NotAllDataReady :
+        toNode->LockDataReady() ;
         if ( IsComputingNode() && toNode->IsInLineNode() ) {
           GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
-          toGateInPort->State( SUPERV::ReadyState ) ;
+          toGateInPort->PortState( SUPERV::ReadyState ) ;
           GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
           if ( GateOutPort ) {
             GateOutPort->PortStatus( DataConnected );
-            GateOutPort->State( SUPERV::ReadyState ) ;
-            GateOutPort->Done( true ) ;
+            GateOutPort->PortState( SUPERV::ReadyState ) ;
+            GateOutPort->PortDone( true ) ;
           }
         }
-      }
-      if ( toNode && IsLoopNode() ) {
-        GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
-        if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
-          if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
-            IgnoreForEndLoop = true ;
-         }
-          else { // toNode is the EndLoopNode
+
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+        if ( IsLoopNode() ) {
+          if ( IgnoreForEndLoop && !strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
             GraphBase::InPort * toLoopInPort ;
-//            toLoopInPort = toNode->GetChangeNodeInPort(1) ;
             toLoopInPort = toNode->GetChangeNodeInLoop() ;
-            if ( toLoopInPort->State() != SUPERV::ReadyState ) {
-              toLoopInPort->State( SUPERV::ReadyState ) ;
+            if ( toLoopInPort->PortState() != SUPERV::ReadyState ) {
+              toLoopInPort->PortState( SUPERV::ReadyState ) ;
            }
          }
-       }
-      }
-      else if ( toNode && IsSwitchNode() ) {
-      }
-      else if ( toNode && toNode->IsInLineNode() ) {
-        int j ;
-        for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
-          toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
-       }
-      }
-      if ( toNode && !IgnoreForEndLoop ) {
-        if ( toNode && toNode->IsLoopNode() ) {
-//          GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInPort(1) ;
-          GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
-          toLoopInPort->State( SUPERV::ReadyState ) ;
-          GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
-          LoopOutPort->PortStatus( DataConnected );
-          LoopOutPort->State( SUPERV::ReadyState ) ;
-          LoopOutPort->Done( true ) ;
-          CORBA::Any * anAny = new CORBA::Any() ;
-          *anAny <<= (long ) 1 ;
-          LoopOutPort->Value( anAny ) ;
+        }
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+        else if ( toNode->IsInLineNode() ) {
           int j ;
           for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
             toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
          }
         }
-        res = toNode->SendSomeDataReady( Name() ) ;
-        if ( res ) {
-          if ( firsttoNode == NULL &&
-               toNode->ThreadNo() == pthread_self() ) {
-            firsttoNode = toNode ;
-            cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
-                   << toNode->Name() << endl ;
+
+        bool activatetoNode = true ;
+//We have to execute the loop :
+        if ( !IgnoreForEndLoop ) {
+//The loop is not finished :
+          if (  toNode->IsLoopNode() ) {
+//We enter in a new loop :
+            GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
+            toLoopInPort->PortState( SUPERV::ReadyState ) ;
+            GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
+            LoopOutPort->PortStatus( DataConnected );
+            LoopOutPort->PortState( SUPERV::ReadyState ) ;
+            LoopOutPort->PortDone( true ) ;
+//JR 21.02.2005 Debug Memory leak :          CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
+            CORBA::Any anAny = CORBA::Any() ; // InitLoop
+//JR 21.02.2005 Debug Memory leak :          *anAny <<= (long ) 1 ;
+            anAny <<= (long ) 1 ;
+            LoopOutPort->SetValue( anAny ) ;
+            int j ;
+            for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
+              toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
+           }
           }
-          else if ( firstzeroNode == NULL &&
-                    toNode->ThreadNo() == 0 ) {
-            firstzeroNode = toNode ;
+       }
+//The loop is finished :
+        else if ( IsLoopNode() ) {
+          if ( toNode->IsEndLoopNode() ) {
+//Not the corresponding EndLoopNode :
+            if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
+#if SuccessActionTrace
+              cdebug << pthread_self() << "/" << ThreadNo()
+                     << " Successed_SuccessAction NO activate EndLoopNode " << toNode->Name()
+                     << endl ;
+#endif
+              activatetoNode = false ;
+           }
          }
+//Not a EndLoopNode :
           else {
-            SomeDataNodes.push_back( toNode ) ;
-            cdebug << ThreadNo() << " Successed_SuccessAction push "
-                   << SomeDataNodes.size() << " " << toNode->Name() << endl ;
+#if SuccessActionTrace
+            cdebug << pthread_self() << "/" << ThreadNo()
+                   << " Successed_SuccessAction NO activate node " << toNode->Name() << endl ;
+#endif
+            activatetoNode = false ;
+         }
+       }
+
+// If the DefaultPort of that SwitchNode is connected to the DefaultPort of the EndSwitchNode
+// the NotSwitchBranch(es) are NOT activated :
+        if ( IgnoreForDefaultSwitch ) {
+//We have to activate Default to EndSwitchNode
+#if SuccessActionTrace
+          cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction search "
+                 << toNode->Name() << " among linked nodes to DefaultPort of " << Name()
+                 << "IgnoreForDefaultSwitch" << IgnoreForDefaultSwitch << endl ;
+#endif
+          activatetoNode = false ;
+          const GraphBase::OutPort * anOutGatePort = GetNodeOutGate() ;
+          const GraphBase::InPort * anInPort = NULL ;
+          int j ;
+          for ( j = 0 ; j < anOutGatePort->InPortsSize() ; j++ ) {
+            anInPort = anOutGatePort->InPorts( j ) ;
+            const GraphBase::ComputingNode * aNode ;
+            aNode = _OutNode->Graph()->GetGraphNode( anInPort->NodeName() ) ;
+            if ( aNode ) {
+#if SuccessActionTrace
+              cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction try "
+                     << aNode << " " << aNode->Name() << " == " << toNode << " " << toNode->Name()
+                     << endl ;
+#endif
+           }
+            if ( aNode && (const GraphBase::ComputingNode * ) toNode->ComputingNode() == aNode ) {
+// toNode is connected to the DefaultPort of that SwitchNode :
+#if SuccessActionTrace
+              cdebug << pthread_self() << "/" << ThreadNo()
+                     << " Successed_SuccessAction activate node " << aNode->Name() << endl ;
+#endif
+              activatetoNode = true ;
+              break ;
+           }
+            else {
+#if SuccessActionTrace
+              cdebug << pthread_self() << "/" << ThreadNo()
+                     << " Successed_SuccessAction NO activate node " << aNode->Name() << endl ;
+#endif
+           }
+         }
+       }
+//JR 19.04.2005 Debug : Do not activate the EndSwitchNode if DefaultGate is close.
+//JR 20.04.2005 : it is false : an outport of the SwitchNode may be connected to an
+//                              input port of the EndSwitchNode
+        if ( activatetoNode ) {
+#if SuccessActionTrace
+          cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+                 << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ;
+#endif
+          if ( !toNode->SendSomeDataReady( Name() ) ) {
+            cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+                 << Name() << " SendSomeDataReady to " << toNode->Name() << " ERROR"
+                 << endl ;
+//JR 30.06.2005 :
+            toNode->UnLockDataReady() ;
+            SendEvent( GraphExecutor::ErrorEvent ) ;
+            return 0 ;
          }
        }
+        toNode->UnLockDataReady() ;
       }
-    }
-  }
+    } //End of Loop of LinkedNodes for SendSomeDataReady
 
-  if ( firsttoNode == NULL && firstzeroNode ) {
-    firsttoNode = firstzeroNode ;
-    cdebug << ThreadNo()
-           << " Successed_SuccessAction firsttoNode = firstzeroNode "
-           << endl ;
-  }
-  else if ( firsttoNode && firstzeroNode ) {
-    SomeDataNodes.push_back( firstzeroNode ) ;
-    cdebug << ThreadNo() << " Successed_SuccessAction push firstzeroNode "
-           << SomeDataNodes.size() << " " << firstzeroNode->Name() << endl ;
-  }
+//JR 10.02.2005 : Debug at the end of execution of a SwitchNode :
+// Here after we may start execution of only one SwitchBranch or of the Default
+// But with activation of only one SwitchBranch we may activate several nodes of that SwitchBranch and
+// we may activate several nodes of NotSwitchBranch ( a NotSwitchBranch is a Branch of the Switch
+// where GatePorts of Nodes are not connected ; that Branches are always executed for each of SwitchBranch
+// BUT are not executed when Default is activated).
+    if ( IsSwitchNode() ) {
+      GraphBase::InLineNode * anEndSwitchNode = GOTONode()->CoupledNode() ;
+//The InPorts of the EndSwitchNode may be connected from that SwitchNode
+//So at first, if we activate a SwitchBranch, we have to establish the correct OutPort in the InPorts
+// of the EndSwitchNode (for the SwitchBranch and the NOTSwitchBranch[es] :
+//PAL8517
+// So the bug is that all input ports of the corresponding EndSwitchNode must have the status NOTDONE !
+// (Only if Default OutPort is closed and Default InPort is closed) :
+      if ( !GetNodeOutGate()->BoolValue() && anEndSwitchNode->GetNodeInGate()->GetOutPort() &&
+           !anEndSwitchNode->GetNodeInGate()->GetOutPort()->BoolValue() ) {
+#if SuccessActionTrace
+        cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << anEndSwitchNode->Name()
+               << " reset of InPort()->OutPort()->Done flag in EndSwitch" << endl ;
+#endif
+        int i ;
+        for ( i = 0 ; i < anEndSwitchNode->GetNodeInPortsSize() ; i++ ) {
+          GraphBase::OutPort * anOutPort = anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort() ;
+//PAL8519
+//JR 08.03.2005 Debug : update of state only if not a StreamPort
+          if ( anOutPort && strcmp( anOutPort->NodeName() , Name() ) &&
+               !anOutPort->IsDataStream() ) {
+#if SuccessActionTrace
+            cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+                   << anEndSwitchNode->Name() << " InPort "
+                   << anEndSwitchNode->GetChangeNodeInPort( i )->PortName() << " NOTDONE from "
+                   << anOutPort->NodeName() << " " << anOutPort->PortName() << endl ;
+#endif
+            anEndSwitchNode->GetChangeNodeInPort( i )->PortState( SUPERV::WaitingState ) ;
+            anEndSwitchNode->GetChangeNodeInPort( i )->GetOutPort()->PortDone( false ) ;
+          }
+          else {
+#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
+      }
+    }
 
-  while ( SomeDataNodes.size() ) {
-    GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
-    SomeDataNodes.pop_front() ;
-    cdebug << pthread_self() << "/" << ThreadNo()
-           << " Successed_SuccessAction pop "
-           << SomeDataNodes.size() << " " << aNode->Name() << endl ;
-    if ( aNode->State() == SUPERV::DataReadyState ) {
-      aNode->CreateNewThreadIf( true ) ;
-      aNode->UnLockDataWait() ;
-      res = aNode->DataUndef_AllDataReadyAction() ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//Make the list of nodes to activate :
+    for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+      GraphBase::ComputingNode * aComputingNode ;
+      aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+      toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
+      if ( toNode ) { // Only Not DataFlowNode :
+        toNode->LockDataReady() ; // Only ONE Node may send AllDataReadyEvent to an other node
+        if ( toNode->HasAllDataReady() ) {
+          SomeDataNodes.push_back( toNode ) ;
+          toNode->HasAllDataReady( false ) ;
+#if SuccessActionTrace
+          cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction "
+                 << Name() << " push "
+                 << toNode->Name() << " " << SomeDataNodes.size() << endl ;
+#endif
+       }
+        toNode->UnLockDataReady() ;
+      }
     }
-    else {
-      cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
-             << aNode->Name() << " "
-             << Automaton()->StateName( aNode->State() ) << endl ;
+
+// firsttoNode : node that has the same ThreadNo() as the current node and that have to be activated
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//Activation of nodes that have AllDataReady in a new thread except one :
+    while ( SomeDataNodes.size() > 1 ) {
+      GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
+      SomeDataNodes.pop_front() ;
+#if SuccessActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo()
+             << " Successed_SuccessAction pop size "
+             << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+      cdebug << pthread_self() << "/" << ThreadNo() << " " << aNode->Name()
+             << " Successed_SuccessAction poped and will start in a new thread" << endl ;
+#endif
+      aNode->CreateNewThread( true ) ;
+      _OutNode->IncrCreatedThreads() ;
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+      res = aNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
     }
-  }
 
-  if ( firsttoNode ) {
-//    firsttoNode = SomeDataNodes.front() ;
-//    SomeDataNodes.pop_front() ;
-    cdebug << pthread_self() << "/" << ThreadNo()
-           << " Successed_SuccessAction pop firsttoNode "
-           << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
-    firsttoNode->CreateNewThreadIf( false ) ;
-    firsttoNode->RewindStack( RewindStack() ) ;
-    if ( firsttoNode->State() == SUPERV::SuccessedState ) {
-      cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
-             << " : " << firsttoNode->Name() << " "
-             << Automaton()->StateName( firsttoNode->State() )
-             << " --> DataWaitingState for Thread "
-             << firsttoNode->ThreadNo() << endl ;
-      firsttoNode->State( SUPERV::DataWaitingState ) ;
+//Activation of the last node that have AllDataReady in the same thread :
+    if ( SomeDataNodes.size() ) {
+      firsttoNode = SomeDataNodes.front() ;
+      SomeDataNodes.pop_front() ;
     }
-    pthread_t OldT = firsttoNode->ThreadNo() ;
-    firsttoNode->ThreadNo( pthread_self() ) ;
+    if ( firsttoNode ) {
+#if SuccessActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo()
+             << " Successed_SuccessAction start firsttoNode "
+             << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+#endif
+//      firsttoNode->CreateNewThreadIf( false ) ;
+      firsttoNode->CreateNewThread( false ) ;
+      firsttoNode->RewindStack( RewindStack() ) ;
+      if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
+#if SuccessActionTrace
+        cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+               << " : " << firsttoNode->Name() << " "
+               << Automaton()->StateName( firsttoNode->State() )
+               << " --> DataWaitingState for Thread "
+               << firsttoNode->ThreadNo() << endl ;
+#endif
+        firsttoNode->State( GraphExecutor::DataWaitingState ) ;
+      }
+      firsttoNode->ThreadNo( pthread_self() ) ;
 // On continue avec le meme thread
-    cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
-           << firsttoNode->Name() << "Thread(" << OldT << "-->"
-           << firsttoNode->ThreadNo() << ")" << endl ;
-    ThreadNo( 0 ) ;
-    cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
-           << " for " << firsttoNode->Name()
-           << " !firsttoNode->CreateNewThreadIf() "
-           << !firsttoNode->CreateNewThreadIf()
-           << " " << Automaton()->StateName( firsttoNode->State() ) ;
-    if ( firsttoNode->State() == SUPERV::DataReadyState ) {
-      cdebug << endl ;
-      firsttoNode->UnLockDataWait() ;
-      res = firsttoNode->DataUndef_AllDataReadyAction() ;
+      ThreadNo( 0 ) ;
+#if SuccessActionTrace
+      cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name()
+             << " for firsttoNode " << firsttoNode->Name()
+             << " " << Automaton()->StateName( firsttoNode->State() ) << endl ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+//No creation of thread and with LockDataReady, an other node in an other thread cannot be
+// waiting for that lock ( if it was the case we could not find AllDataReady for firsttoNode
+      res = firsttoNode->SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
     }
     else {
-      cdebug << " ERROR " << endl ;
+#if SuccessActionTrace
+      cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+             << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL" << endl ;
+#endif
+      ThreadNo( 0 ) ;
     }
   }
-  else {
-    cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
-           << " NO DataReady ==> ThreadNo( 0 )" << endl ;
-    ThreadNo( 0 ) ;
-  }
-
-  if ( linkednodesnumber == 0 ) {
-    _OutNode->CheckAllDone() ;
-  }
-
-  cdebug << pthread_self() << "/" << ThreadNo()
-         << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
-         << linkednodesnumber << endl;
+#if SuccessActionTrace
+  cdebug_out << pthread_self() << "/" << ThreadNo()
+             << " Successed_SuccessAction " << Name() << endl;
+#endif
   return 1 ;
 }
 
+#define SendSomeDataReadyTrace 1
 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
   bool RetVal = false ;
   if ( IsDataFlowNode() ) {
-    cdebug << ThreadNo() << " ----> " << Name()
-         << " send Result to graph " << Name() << endl;
+#if SendSomeDataReadyTrace
+    cdebug_in << ThreadNo() << "InNode::SendSomeDataReady " << FromNodeName
+              << " send Result to graph " << Name() << endl;
+#endif
   }
   else {
-    cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
-           << " send SomeDataReady to " << Name() << " "
-           << Automaton()->StateName( State() ) 
-           << " CreateNewThreadIf() " << CreateNewThreadIf()
-           << " LockedDataWait " << IsLockedDataWait() << endl;
-#if 0
-    cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
-         << " send SomeDataReady to " << Name() << " "
-         << Automaton()->StateName( State() ) 
-         << " CreateNewThreadIf() " << CreateNewThreadIf()
-         << " LockedDataWait " << IsLockedDataWait() << endl;
-#endif
-    if ( State() == SUPERV::SuccessedState ||
-         State() == SUPERV::SuspendedSuccessedState ||
-         State() == SUPERV::SuspendedSuccessedToReStartState ) {
+#if SendSomeDataReadyTrace
+    cdebug_in << pthread_self() << "/" << ThreadNo() << FromNodeName
+              << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
+              << Automaton()->StateName( State() ) << endl;
+#endif
+    if ( State() == GraphExecutor::SuccessedState ||
+         State() == GraphExecutor::SuspendedSuccessedState ||
+         State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
+#if SendSomeDataReadyTrace
       cdebug << ThreadNo() << " " << FromNodeName
              << " : " << Name() << " " << Automaton()->StateName( State() )
              << " --> DataWaitingState for Thread "
              << ThreadNo() << " " << endl ;
-      State( SUPERV::DataWaitingState ) ;
+#endif
+      State( GraphExecutor::DataWaitingState ) ;
     }
-    LockDataWait() ;
-    DataFromNode( FromNodeName ) ;
-    RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
-    if ( !RetVal ) {
-      UnLockDataWait() ;
+// We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
+    if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
+#if SendSomeDataReadyTrace
+      cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
+             << FromNodeName << endl ;
+#endif
+      _InitLoop = true ;
     }
-  }
+#if SendSomeDataReadyTrace
+    cdebug << "SendEvent( SomeDataReadyEvent )" << endl ;
+#endif
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+    DataFromNode( FromNodeName ) ;
+//    RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
+    RetVal = SendEvent( GraphExecutor::SomeDataReadyEvent );
+//JR 15.04.2005 Debug PAL8624 RetroConception :
+  }
+#if SendSomeDataReadyTrace
+  cdebug_out << pthread_self() << "/" << ThreadNo() << FromNodeName
+             << " GraphExecutor::InNode::SendSomeDataReady to " << Name() << " State "
+             << Automaton()->StateName( State() ) << " " << RetVal << endl;
+#endif
   return RetVal ;
 }
 
 int GraphExecutor::InNode::Errored_ErrorAction() {
   cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
          << " will pthread_exit" << endl;
+
+  _OutNode->NodeAborted( Name() ) ;
+
   DoneAction() ;
   return 1 ;
 }
@@ -1848,7 +2995,7 @@ int GraphExecutor::InNode::Successed_SuspendAction() {
          << " Threads " << _OutNode->Threads() << " SuspendedThreads "
          << _OutNode->SuspendedThreads() << endl;
   _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
-                       SUPERV::SuspendedSuccessedState ) ; 
+                       GraphExecutor::SuspendedSuccessedState ) ; 
   DoneAction() ;
   GraphExecutor::InNode * aReStartNode = SuspendAction() ;
   cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
@@ -1869,7 +3016,10 @@ int GraphExecutor::InNode::Errored_SuspendAction() {
          << " Threads " << _OutNode->Threads() << " SuspendedThreads "
          << _OutNode->SuspendedThreads() << endl;
   _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
-                       SUPERV::SuspendedErroredState ) ; 
+                       GraphExecutor::SuspendedErroredState ) ; 
+
+  _OutNode->NodeAborted( Name() ) ;
+
   DoneAction() ;
   GraphExecutor::InNode * aReStartNode = SuspendAction() ;
   cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
@@ -1888,7 +3038,7 @@ int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
   cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
 //  ResumeAction() ;
   _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
-                       SUPERV::ResumedSuccessedState ) ; 
+                       GraphExecutor::ResumedSuccessedState ) ; 
   SendEvent( ResumedSuccessedEvent ) ;
   return 1 ;
 }
@@ -1897,7 +3047,10 @@ int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
   cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
 //  ResumeAction() ;
   _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
-                       SUPERV::ResumedErroredState ) ; 
+                       GraphExecutor::ResumedErroredState ) ; 
+
+  _OutNode->NodeAborted( Name() ) ;
+
   SendEvent( ResumedErroredEvent ) ;
   return 1 ;
 }
@@ -1905,7 +3058,7 @@ int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
 int GraphExecutor::InNode::Successed_KillAction() {
   KillAction() ;
   _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
-                       SUPERV::KilledSuccessedState ) ; 
+                       GraphExecutor::KilledSuccessedState ) ; 
   cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
   return 1 ;
 }
@@ -1913,7 +3066,10 @@ int GraphExecutor::InNode::Successed_KillAction() {
 int GraphExecutor::InNode::Errored_KillAction() {
   KillAction() ;
   _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
-                       SUPERV::KilledErroredState ) ; 
+                       GraphExecutor::KilledErroredState ) ; 
+
+  _OutNode->NodeAborted( Name() ) ;
+
   cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
   return 1 ;
 }
@@ -1921,7 +3077,7 @@ int GraphExecutor::InNode::Errored_KillAction() {
 int GraphExecutor::InNode::Successed_StopAction() {
   StopAction() ;
   _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
-                       SUPERV::StoppedSuccessedState ) ; 
+                       GraphExecutor::StoppedSuccessedState ) ; 
   cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
   return 1 ;
 }
@@ -1929,7 +3085,10 @@ int GraphExecutor::InNode::Successed_StopAction() {
 int GraphExecutor::InNode::Errored_StopAction() {
   StopAction() ;
   _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
-                       SUPERV::StoppedErroredState ) ; 
+                       GraphExecutor::StoppedErroredState ) ; 
+
+  _OutNode->NodeAborted( Name() ) ;
+
   cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
   return 1 ;
 }
@@ -1937,10 +3096,10 @@ int GraphExecutor::InNode::Errored_StopAction() {
 int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
   cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
   _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
-                       SUPERV::ReStartedState ) ;
+                       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;
@@ -1950,10 +3109,10 @@ int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
 int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
   cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
   _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
-                       SUPERV::ReStartedState ) ; 
+                       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;
@@ -1964,8 +3123,8 @@ int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
   cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
          << endl;
   _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
-                       SUPERV::ReStartedState ) ; 
-  State( SUPERV::DataWaitingState ) ;
+                       GraphExecutor::ReStartedState ) ; 
+  State( GraphExecutor::DataWaitingState ) ;
   if ( !Suspend() ) {
     cdebug << "InNode::Suspend() Node " << Name() << endl ;
     return false ;
@@ -1984,8 +3143,8 @@ int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
   cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
          << endl;
   _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
-                       SUPERV::ReStartedState ) ; 
-  State( SUPERV::DataWaitingState ) ;
+                       GraphExecutor::ReStartedState ) ; 
+  State( GraphExecutor::DataWaitingState ) ;
   if ( !Suspend() ) {
     cdebug << "InNode::Suspend() Node " << Name() << endl ;
     return false ;
@@ -2000,38 +3159,60 @@ int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
   return 1 ;
 }
 
-void GraphExecutor::InNode::InParametersSet(
-                            bool & Err ,
-                            int  nInParams ,
-                            ServicesAnyData * InParametersList ) {
+#define InParametersSetTrace 1
+void GraphExecutor::InNode::InParametersSet( bool & Err ,
+                                             int  nInParams ,
+                                             ServicesAnyData * InParametersList ) {
   int i ;
+#if InParametersSetTrace
+  cdebug << pthread_self() << "/" << ThreadNo() << " InParametersSet " << Name() << endl ;
+#endif
   for ( i = 0 ; i < nInParams ; i++ ) {
     ServicesAnyData D = InParametersList[i];
     GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
     GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
     if ( anInPort->IsGate() && theOutPort == NULL ) {
+#if InParametersSetTrace
       cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
              << anInPort->GetServicesParameter().Parametertype
              << " is inactive. " << anInPort->Kind() << endl ;
+#endif
     }
-    else if ( anInPort->State() == SUPERV::ReadyState ) {
+    else if ( anInPort->PortState() == SUPERV::ReadyState ) {
       if ( anInPort->IsGate() ) {
-        CORBA::Any * anAny = new CORBA::Any() ;
-        *anAny <<= (long ) 0 ;
-        theOutPort->Value( anAny ) ;
-      }
-      anInPort->State( SUPERV::WaitingState ) ;
-      D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
-      cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
-      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 21.02.2005 Debug Memory leak :        CORBA::Any * anAny = new CORBA::Any() ;
+        CORBA::Any anAny = CORBA::Any() ;
+//JR 21.02.2005 Debug Memory leak :        *anAny <<= (long ) 0 ;
+        anAny <<= (long ) 0 ;
+        theOutPort->SetValue( anAny ) ;
+//        delete anAny ;
+      }
+      if ( !anInPort->IsDataStream() &&
+           !anInPort->IsDataConnected() ) {
+        anInPort->PortState( SUPERV::WaitingState ) ;
+      }
+//JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
+//      D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
+      D.Name = anInPort->PortName() ;
+//JR 30.03.2005      const CORBA::Any * AnyPtr = theOutPort->Value() ;
+      const CORBA::Any AnyRef = theOutPort->Value() ;
+#if InParametersSetTrace
+      cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() << " "
+             << anInPort->PortState() << " " << D.Name << " "
+             << anInPort->GetServicesParameter().Parametertype << endl ;
+#endif
+//JR 30.03.2005      D.Value = * AnyPtr ; // CORBA::Any
+      D.Value = AnyRef ; // CORBA::Any
+//JR 18.02.2005 Debug Memory leak :       string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
+//      const char * Type = _Type.c_str() ;
+      const char * Type = anInPort->GetServicesParameter().Parametertype ;
       switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
       case CORBA::tk_string:
         char * t;
         D.Value >>= t;
+#if InParametersSetTrace
         cdebug << t << " (string)" ;
+#endif
         if ( !strcmp( Type , "string" ) ) {
         }
         else if ( !strcmp( Type , "boolean" ) ) {
@@ -2048,7 +3229,9 @@ void GraphExecutor::InNode::InParametersSet(
           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" ) ) {
@@ -2057,14 +3240,18 @@ void GraphExecutor::InNode::InParametersSet(
           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" ) ) {
@@ -2072,15 +3259,19 @@ void GraphExecutor::InNode::InParametersSet(
           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" ) ) {
@@ -2098,12 +3289,23 @@ void GraphExecutor::InNode::InParametersSet(
 //        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 ) ;
@@ -2150,12 +3352,16 @@ void GraphExecutor::InNode::InParametersSet(
 //        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 ) ;
@@ -2202,14 +3408,20 @@ void GraphExecutor::InNode::InParametersSet(
 //        else {
 //          cdebug << " (other ERROR)" << endl ;
 //        }
+#if InParametersSetTrace
         cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+#endif
         break;
       case CORBA::tk_objref:
         if ( !strcmp( Type , "string" ) ) {
           CORBA::Object_ptr ObjRef ;
           char * retstr ;
           try {
+#if OMNIORB_VERSION >= 4
+            D.Value >>= (CORBA::Any::to_object ) ObjRef ;
+#else
             D.Value >>= ObjRef ;
+#endif
             retstr = ObjectToString( ObjRef ) ;
             D.Value <<= retstr ;
 //            theOutPort->Value( D.Value ) ;
@@ -2256,9 +3468,15 @@ void GraphExecutor::InNode::InParametersSet(
           CORBA::Object_ptr obj ;
           char * retstr ;
           try {
+#if OMNIORB_VERSION >= 4
+            D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
             D.Value >>= obj ;
+#endif
             retstr = ObjectToString( obj ) ;
+#if InParametersSetTrace
             cdebug << retstr << endl ;
+#endif
           }
           catch( ... ) {
             if ( i != 0 ) {
@@ -2270,7 +3488,9 @@ void GraphExecutor::InNode::InParametersSet(
 //        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 ;
@@ -2278,8 +3498,8 @@ void GraphExecutor::InNode::InParametersSet(
     }
     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 ;
@@ -2288,21 +3508,28 @@ void GraphExecutor::InNode::InParametersSet(
   }
 }
 
-void GraphExecutor::InNode::InOutParametersSet(
-                            int nOutParams ,
-                            ServicesAnyData * OutParametersList ) {
+void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
+                                                ServicesAnyData * OutParametersList ) {
+#if InParametersSetTrace
+  cdebug << pthread_self() << "/" << ThreadNo() << " InOutParametersSet " << Name() << endl ;
+#endif
   int i ;
   for ( i = 0 ; i < nOutParams ; i++ ) {
     ServicesAnyData D = OutParametersList[i] ;
 
-    D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
-    string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
-    const char * Type = _Type.c_str() ;
-    bool OutDone = GetChangeNodeOutPort(i)->Done() ;
-    cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
-           << OutDone << ") " << Type << " : " << endl ;
+//JR 18.02.2005 Debug Memory leak : delete does not destroy that string ...
+//    D.Name = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametername);
+    D.Name = GetChangeNodeOutPort(i)->PortName() ;
+//JR 18.02.2005 Debug Memory leak :     string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
+    const char * Type = GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype ;
+#if InParametersSetTrace
+    bool OutDone = GetChangeNodeOutPort(i)->PortDone() ;
+    cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " PortDone( " << OutDone << " ) Type : "
+           << Type << endl ;
+#endif
     if ( !strcmp( Type , "string" ) ) {
-      D.Value <<= (char *) NULL ;
+//      D.Value <<= (char *) NULL ;
+      D.Value <<= "" ;
     }
     else if ( !strcmp( Type , "boolean" ) ) {
       bool b = 0 ;
@@ -2330,7 +3557,7 @@ void GraphExecutor::InNode::InOutParametersSet(
     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;
@@ -2371,7 +3598,11 @@ void GraphExecutor::InNode::InOutParametersSet(
       try {
         CORBA::Object_ptr obj ;
         char * retstr ;
+#if OMNIORB_VERSION >= 4
+            D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
         D.Value >>= obj ;
+#endif
         retstr = ObjectToString( obj ) ;
         cdebug << ThreadNo() << retstr << endl ;
       }
@@ -2382,37 +3613,47 @@ void GraphExecutor::InNode::InOutParametersSet(
     default:
       cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
     }
-//#endif
+#endif
     OutParametersList[i] = D ;
   }
 }
 
-bool GraphExecutor::InNode::OutParametersSet(
-                            bool Err ,
-                            SUPERV::GraphState NewState ,
-                            int nOutParams ,
-                            ServicesAnyData * OutParametersList ) {
+#define OutParametersSetTrace 1
+bool GraphExecutor::InNode::OutParametersSet( bool Err ,
+                                              SUPERV::GraphState PortState ,
+                                              int nOutParams ,
+                                              ServicesAnyData * OutParametersList ) {
   bool RetVal = true ;
   int i ;
   GraphBase::OutPort * aGateOutPort = NULL ;
   bool OrSwitch = false ;
-  if ( nOutParams ) {
+  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: {
@@ -2420,7 +3661,9 @@ bool GraphExecutor::InNode::OutParametersSet(
           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: {
@@ -2428,7 +3671,9 @@ bool GraphExecutor::InNode::OutParametersSet(
           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: {
@@ -2436,13 +3681,17 @@ bool GraphExecutor::InNode::OutParametersSet(
           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: {
@@ -2450,137 +3699,228 @@ bool GraphExecutor::InNode::OutParametersSet(
           D.Value >>= f;
           double d = (double ) f ;
           D.Value <<= d ;
+#if OutParametersSetTrace
           cdebug << ThreadNo() << " " << f << "(float)" << endl ;
+#endif
           break;
        }
         case CORBA::tk_double: {
           double d;
           D.Value >>= d;
+#if OutParametersSetTrace
           cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+#endif
           break;
        }
         case CORBA::tk_objref: {
           try {
             CORBA::Object_ptr obj ;
-            char * retstr ;
+#if OMNIORB_VERSION >= 4
+            D.Value >>= (CORBA::Any::to_object ) obj ;
+#else
             D.Value >>= obj ;
+#endif
+#if OutParametersSetTrace
+            char * retstr ;
             retstr = ObjectToString( obj ) ;
             cdebug << ThreadNo() << retstr << endl ;
+#endif
           }
           catch( ... ) {
             cdebug << "ToString( object ) Catched ERROR" << endl ;
+            RetVal = false ;
           }
           break;
        }
         default: {
           cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
+          RetVal = false ;
        }
         }
         OutParametersList[i] = D ;
-        if ( anOutPort->IsGate() ) {
-          aGateOutPort = anOutPort ;
-          cdebug << " Gate " ;
-          long l = 1;
-          OutParametersList[i].Value <<= l;
-          anOutPort->Value( OutParametersList[i].Value );
-        }
-        else if ( anOutPort->IsLoop() ) {
-          cdebug << " Loop " ;
-          anOutPort->Value( OutParametersList[i].Value );
+        if ( !anOutPort->IsDataStream() ) {
+          if ( anOutPort->IsGate() ) {
+            aGateOutPort = anOutPort ;
+#if OutParametersSetTrace
+            cdebug << " Gate " ;
+#endif
+            long l = 1;
+            OutParametersList[i].Value <<= l;
+            anOutPort->SetValue( OutParametersList[i].Value );
+          }
+          else if ( anOutPort->IsLoop() ) {
+#if OutParametersSetTrace
+            cdebug << " Loop " ;
+#endif
+            anOutPort->SetValue( OutParametersList[i].Value );
 // InLoop Port of EndLoopNode is ready :
-          anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
-        }
-        else if ( anOutPort->IsSwitch() ) {
-          cdebug << " Switch " ;
-          anOutPort->Value( OutParametersList[i].Value );
-          if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
-            if ( OrSwitch && anOutPort->BoolValue() ) {
-              cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
-                     << endl ;
-           }
-            else {
-              OrSwitch = OrSwitch | anOutPort->BoolValue() ;
-           }
-         }
-          cdebug << "OrSwitch " << OrSwitch ;
-        }
-        else {
-          cdebug << " Param " ;
-          anOutPort->Value( OutParametersList[i].Value );
-        }
-        anOutPort->State( NewState ) ;
-        anOutPort->Done( true ) ;
+            anOutPort->ChangeInPorts(0)->PortState( SUPERV::ReadyState ) ;
+          }
+          else if ( anOutPort->IsSwitch() ) {
+#if OutParametersSetTrace
+            cdebug << " Switch " ;
+#endif
+            anOutPort->SetValue( OutParametersList[i].Value );
+            if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
+//We have a SwitchBranch or the DefaultBranch .
+//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches (SwitchParameters) :
+//It controls that there is only one SwitchBranch activated
+//If it's final value is false ==> activation of the Default to GOTO to EndSwitchNode
+//DefaultSwitch is true if a SwitchPort is linked to the DefaultPort of the EndSwitchNode
+              if ( OrSwitch && anOutPort->BoolValue() ) {
+                string anErrorMessage = string( "More than one SwitchBranch should be activated in SwitchNode " ) +
+                                        string( Name() ) + string( "( " ) +
+                                        string( anOutPort->PortName() ) + string( " )" ) ;
+                _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+                cdebug << "Executor::InNodeThreads::OutParameters more than one SwitchBranch is true ERROR"
+                       << endl ;
+                RetVal = false ;
+             }
+              else 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
+             }
+           }
+          }
+          else {
+#if OutParametersSetTrace
+            cdebug << " Param " ;
+#endif
+            anOutPort->SetValue( OutParametersList[i].Value );
+          }
+          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 ;
-          GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInGate()->GetOutPort() ;
-          if ( aGOTOPort ) {
-            fromGOTO = aGOTOPort->IsGOTO() ;
-         }
-          if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
-            cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
-                   << anOutPort->ChangeInPorts( j )->PortName() << ","
-                   << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
-                   << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
-                   << "("
-                   << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
-                   << ") to " << anOutPort->NodeName() << "("
-                   << anOutPort->PortName() << ")" << endl ;
-            anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
-         }
+          const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
+          if ( !strcmp( ToNodeName , _OutNode->Name() ) &&
+               _OutNode->Graph()->GraphMacroLevel() != 0 ) {
+#if OutParametersSetTrace
+            cdebug << "OutParametersSet ToNodeName " << _OutNode->Name() << " CoupledNode "
+                   << _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
+                   << endl ;
+            cdebug << "OutParametersSet GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
+#endif
+            _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
+                                                                            anOutPort->ChangeInPorts( j )->PortName() ,
+//JR 30.03.2005                                                                            *anOutPort->Value() ) ;
+                                                                            anOutPort->Value() ) ;
+#if OutParametersSetTrace
+            cdebug << "OutParametersSet OutputOfAny( "
+                   << _OutNode->Graph()->CoupledNodeName() << " , "
+                   << anOutPort->ChangeInPorts( j )->PortName() << " , value )" << endl ;
+#endif
+
+         }
           else {
-            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 ;
+           GraphBase::ComputingNode * ToNode = _OutNode->Graph()->GetChangeGraphNode( ToNodeName ) ;
+            if ( ToNode ) {
+//              cout << "OutParametersSet ToNodeName " << ToNodeName << 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() << ") CHANGED from "
+                       << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
+                       << "("
+                       << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
+                       << " 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()
+                       << " " << anOutPort->ChangeInPorts( j )->GetOutPort()->Kind()
+                       << ") " << endl ;
+#endif
+             }
+           }
          }
         }
-//#if 0
-        switch (anOutPort->Value()->type()->kind()) {
+#if OutParametersSetTrace
+        switch ( anOutPort->Value().type()->kind() ) {
         case CORBA::tk_string:
           char * t;
-          (*anOutPort->Value()) >>= t;
+          (anOutPort->Value()) >>= t;
           cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
           break;
         case CORBA::tk_boolean:
           bool b ;
-          (*anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
+          (anOutPort->Value()) >>= (CORBA::Any::to_boolean ) b;
           cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
           break;
         case CORBA::tk_char:
           unsigned char c ;
-          (*anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
+          (anOutPort->Value()) >>= (CORBA::Any::to_char ) c;
           cdebug << ThreadNo() << " Out" << i << " : " << c << "(char)" << endl ;
           break;
         case CORBA::tk_short:
           short s;
-          (*anOutPort->Value()) >>= s;
+          (anOutPort->Value()) >>= s;
           cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
           break;
         case CORBA::tk_long:
           long l;
-          (*anOutPort->Value()) >>= l;
+          (anOutPort->Value()) >>= l;
           cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
           break;
         case CORBA::tk_float:
           float f;
-          (*anOutPort->Value()) >>= f;
+          (anOutPort->Value()) >>= f;
           cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
           break;
         case CORBA::tk_double:
           double d;
-          (*anOutPort->Value()) >>= d;
+          (anOutPort->Value()) >>= d;
           cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
           break;
         case CORBA::tk_objref:
           CORBA::Object_ptr obj ;
           char * retstr ;
           try {
-            (*anOutPort->Value()) >>= obj ;
+//JR 02.08.2005 Debug SEGV            anOutPort->Value() >>= obj ;
+            CORBA::Any anAny ;
+            anAny = anOutPort->Value() ;
+#if OMNIORB_VERSION >= 4
+            anAny >>= (CORBA::Any::to_object ) obj ;
+#else
+            anAny >>= obj ;
+#endif
             retstr = ObjectToString( obj );
             cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
                    << retstr << endl ;
@@ -2588,39 +3928,225 @@ bool GraphExecutor::InNode::OutParametersSet(
           catch ( ... ) {
             cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
                    << "Catched ERROR" << endl ;
+            RetVal = false ;
          }
           break;
         default:
           cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
           RetVal = false ;
         }
-//#endif
+#endif
       }
-    }
-    if ( aGateOutPort && IsSwitchNode() ) {
-      if ( OrSwitch ) {
-//        cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
-//               << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+    } // End of : for ( i = 0 ; i < nOutParams ; i++ ) {
+#if OutParametersSetTrace
+    cdebug << ThreadNo() << "OutParametersSet End of loop with " << nOutParams
+           << " OutParams. aGateOutPort " << (void *) aGateOutPort << " IsSwitchNode "
+           << IsSwitchNode() << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch
+           << endl ;
+#endif
+
+//In SwitchNodes :
+    if ( IsSwitchNode() && aGateOutPort ) {
+//JR 09.02.2005 : OrSwitch is the OR of all SwitchBranches :
+//It controls that there is only one SwitchBranch activated
+//If it's final value is false ==> activation of the Default in order to GOTO to EndSwitchNode
+//DefaultSwitch is true if a SwitchPort (SwitchBranch) is linked to the DefaultPort of the EndSwitchNode
+      if ( !OrSwitch && !DefaultSwitch ) {
+        if ( aGateOutPort->InPortsSize() && aGateOutPort->ChangeInPorts( 0 ) ) {
+//Dynamic activation of the Default OutPort :
+#if OutParametersSetTrace
+          cdebug << ThreadNo() << " " << "OutGate " << Name() << " Open of "
+                 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " WITH DefaultPort"
+                 << endl ;
+#endif
+          long l = 1;
+          OutParametersList[0].Value <<= l ;
+          aGateOutPort->SetValue( OutParametersList[0].Value ) ;
+       }
+        else {
+//The Default OutPort is not linked ==> error
+          string anErrorMessage = string( "DefaultPort of SwitchNode " ) +
+                                  string( Name() ) + " is not connected." ;
+          _OutNode->Graph()->SetMessages( anErrorMessage ) ;
+#if OutParametersSetTrace
+          cdebug << ThreadNo() << " " << "OutGate " << Name() << " "
+                 << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NOT CONNECTED ERROR"
+                 << endl ;
+#endif
+          RetVal = false ;
+       }
+      }
+//JR 07.04.2005 Debug : reset only if it is not a default switch (SwitchBranch or
+//                      SwitchParameter of SwitchNode connected to the DefaultInPort of
+//                      EndSwitchNode)
+//      else {
+      else if ( !DefaultSwitch ) {
+#if OutParametersSetTrace
+        cdebug << ThreadNo() << " " << "OutGate " << Name() << " Close of "
+               << aGateOutPort->PortName() << " " << aGateOutPort->Kind() << " NO DefaultPort"
+               << " OrSwitch " << OrSwitch << " DefaultSwitch " << DefaultSwitch << endl ;
+#endif
         long l = 0;
         OutParametersList[0].Value <<= l ;
-        aGateOutPort->Value( OutParametersList[0].Value ) ;
+        aGateOutPort->SetValue( OutParametersList[0].Value ) ;
       }
-      else {
-//        cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
-//               << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
-        long l = 1;
-        OutParametersList[0].Value <<= l ;
-        aGateOutPort->Value( OutParametersList[0].Value ) ;
+      if ( RetVal ) {
+// The OutPort field of InPorts of EndSwitchNode may be updated from each OutPort of that SwitchNode :
+        GraphBase::EndOfSwitchNode * anEndSwitchNode = (GraphBase::EndOfSwitchNode * ) CoupledNode() ;
         int i ;
+//PAL8518
+//JR 16.02.2005 Debug : At first Change InPorts of EndSwitchNode that have the same name as an OutPort of
+// the SwitchNode even if it is the DefaultPort : GraphSwitchCheckDefault1.xml
+//STEP A : InPorts of EndSwitchNode that have the same name as an OutPort of the SwitchNode
         for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
-          GraphBase::InPort * anInPort ;
-          anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
+          GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
+          GraphBase::InPort * anInPort = NULL ;
+          anInPort = anEndSwitchNode->GetChangeInPort( anOutPort->PortName() ) ;
           if ( anInPort ) {
-            anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
-         }
+#if OutParametersSetTrace
+            cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
+                   << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) with same name " ;
+            if ( anInPort->GetOutPort() ) {
+              cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+                     << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+            }
+            else {
+              cdebug << "NOT linked " ;
+            }
+            cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
+                   << anOutPort->PortName() << " )" << endl ;
+#endif
+            anInPort->ChangeOutPort( anOutPort ) ;
+          }
         }
+//STEP B : InPorts of EndSwitchNode directly connected from an OutPort of the SwitchNode
+        for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+          GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i );
+          GraphBase::InPort * anInPort ;
+          int j ;
+          for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+            anInPort = anOutPort->ChangeInPorts( j ) ;
+//Update the OutPort field in the Inports directly connected of the EndSwitchNode :
+            if ( !strcmp( anInPort->NodeName() , anEndSwitchNode->Name() ) ) {
+#if OutParametersSetTrace
+              cdebug << "OutParametersSet " << Name() << " " << anInPort->NodeName()
+                     << "( " << anInPort->PortName() << " , " << anInPort->Kind()
+                     << " ) directly connected " ;
+              if ( anInPort->GetOutPort() ) {
+                cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+                       << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+              }
+              else {
+                cdebug << "NOT linked " ;
+              }
+              cdebug << "CHANGED TO linked from " << anOutPort->NodeName() << "( "
+                     << anOutPort->PortName() << " )" << endl ;
+#endif
+              anInPort->ChangeOutPort( anOutPort ) ;
+           }
+          }
+        }
+//STEP C : If it is not the DefaultBranch, explore the SwitchBranch and all NOTSwitchBranch[es]
+//Change recursively InPorts of EndSwitchNode linked to that Branch (or that SwitchNode)
+        if ( OrSwitch ) {
+          for ( i = 0 ; i <  LinkedNodesSize() ; i++ ) {
+            GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+            if ( aNode != anEndSwitchNode && !aNode->IsGOTONode() &&
+                 !aNode->IsDataFlowNode() && !aNode->IsDataStreamNode()  ) {
+             const GraphBase::InPort * anInGate = aNode->GetNodeInGate() ;
+              GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
+//STEP C1 : SwitchBranch :
+              if ( anInGate->GetOutPort() ) {
+                if ( anInGate->GetOutPort()->BoolValue() ) {
+#if OutParametersSetTrace
+                  cdebug << "OutParametersSet " << Name() << " SWITCHBranch " << aNode->Name() << endl ;
+#endif
+                  int j ;
+                  for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+                    GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
+                    anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
+                 }
+               }
+             }
+//STEP C2 : NOTSwitchBranch :
+              else {
+#if OutParametersSetTrace
+                cdebug << "OutParametersSet " << Name() << " NOTSWITCHBranch " << aNode->Name() << endl ;
+#endif
+                int j ;
+                for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+                  GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j );
+                  anInNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNode->Name() ) ;
+               }
+             }
+           }
+         }
+       }
       }
     }
   }
+#if OutParametersSetTrace
+  cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewPortState "
+             << PortState << " RetVal " << RetVal << endl ;
+#endif
   return RetVal ;
 }
+
+
+void GraphExecutor::InNode::SetOutPortsOfInportsOfEndSwitch( GraphBase::OutPort * anOutPort ,
+                                                             const char * anEndSwitchNodeName ) {
+#if OutParametersSetTrace
+  cdebug_in << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anOutPort->NodeName() << "( "
+            << anOutPort->PortName() << " ) with " << anOutPort->InPortsSize() << " links." << endl ;
+#endif
+  GraphBase::InPort * anInPort ;
+  int i ;
+  for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
+    anInPort = anOutPort->ChangeInPorts( i ) ;
+    if ( !anInPort->IsDataStream() ) {
+//Update the OutPort field in the Inports of the EndSwitchNode :
+      if ( !strcmp( anInPort->NodeName() , anEndSwitchNodeName ) ) {
+#if OutParametersSetTrace
+        cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
+               << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " ;
+        if ( anInPort->GetOutPort() ) {
+          cdebug << "linked from " << anInPort->GetOutPort()->NodeName()
+                 << "( " << anInPort->GetOutPort()->PortName() << " ) " ;
+        }
+        else {
+          cdebug << "NOT linked ERROR " ;
+        }
+        cdebug << "CHANGED TO linked from "
+               << anOutPort->NodeName() << "( "
+               << anOutPort->PortName() << " )" << endl ;
+#endif
+        anInPort->ChangeOutPort( anOutPort ) ;
+      }
+      else {
+#if OutParametersSetTrace
+        cdebug << "SetOutPortsOfInportsOfEndSwitch " << Name() << " " << anInPort->NodeName()
+               << "( " << anInPort->PortName() << " , " << anInPort->Kind() << " ) " << endl ;
+#endif
+        GraphBase::ComputingNode * aComputingNode ;
+        aComputingNode = _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
+        if ( aComputingNode && !aComputingNode->IsGOTONode() &&
+             !( IsEndLoopNode() && GOTONode()->CoupledNode() == aComputingNode ) ) {
+          GraphExecutor::InNode * aNode ;
+          aNode = (GraphExecutor::InNode * ) aComputingNode->GetInNode() ;
+          if ( aNode ) {
+            int j ;
+            for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+              GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
+              aNode->SetOutPortsOfInportsOfEndSwitch( anOutPort , anEndSwitchNodeName ) ;
+           }
+         }
+       }
+      }
+    }
+  }
+#if OutParametersSetTrace
+  cdebug_out << "SetOutPortsOfInportsOfEndSwitch " << Name() << " OutPort " << anOutPort->PortName()
+             << endl ;
+#endif
+}
+