Salome HOME
InitLoop and DoLoop parameters names
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_InNodeThreads.cxx
index 927370f3f12c3c7fbf971995b7be865f5f4cf0d2..42661e2dfda57ac0ed65c790919ea761d19edffc 100644 (file)
@@ -1,48 +1,91 @@
+//  SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : DataFlowBase_InNodeThreads.cxx
+//  Author : Jean Rahuel, CEA
+//  Module : SUPERV
+//  $Header:
+
 using namespace std;
-//=============================================================================
-// File      : DataFlowBase_InNodeThreads.cxx
-// Created   : 2002
-// Author    : Jean Rahuel, CEA
-// Project   : SALOME
-// $Header:
-//=============================================================================
 
 #include <stdlib.h>
 #include <iostream>
 #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 ) {  
-  SUPERV::AutomatonState old_state ;
 
+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() ) << endl;
+        << " State : " << Automaton()->StateName( State() ) << " _RewindStack " << _RewindStack  << endl;
 
-  old_state = State() ;
-  _NextState = Automaton()->NextState( old_state , anEvent ) ;
-  if ( _NextState == old_state ) {
+  _OldState = State() ;
+  _NextState = Automaton()->NextState( _OldState , anEvent ) ;
+  if ( _NextState == _OldState ) {
     cdebug << pthread_self() << "/" << ThreadNo()
            << " GraphExecutor::InNodeThreads::SendEvent SameStates "
-           << old_state << endl ;
+           << _OldState << endl ;
     _NextAction = GraphExecutor::VoidAction ;
   }
   else {
@@ -50,25 +93,26 @@ int GraphExecutor::InNode::SendEvent(
   }
 
 //  State( _NextState ) ;
-//  if ( old_state == SUPERV::SuccessedExecutingState ||
-//       old_state == SUPERV::ErroredExecutingState ) {
+//  if ( _OldState == GraphExecutor::SuccessedExecutingState ||
+//       _OldState == GraphExecutor::ErroredExecutingState ) {
 //    DoneAction() ;
 //  }
 
   cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
          << Name() << endl << " ControlState : "
          << Automaton()->ControlStateName( ControlState() ) << endl
-         << " OldState : " << Automaton()->StateName( old_state ) << endl
+         << " OldState : " << Automaton()->StateName( _OldState ) << endl
          << " Event : " << Automaton()->EventName( anEvent ) << endl
          << " NextState : " << Automaton()->StateName( _NextState ) << endl
          << " Action : " << Automaton()->ActionName( _NextAction ) << endl
-         << " CreateNewThread " << CreateNewThread() << endl ;
+         << " CreateNewThread " << CreateNewThread() << endl
+         << " _RewindStack " << _RewindStack  << endl ;
 
 #if 0
-  cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
+  //cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
        << endl << " ControlState : "
        << Automaton()->ControlStateName( ControlState() ) << endl
-       << " OldState : " << Automaton()->StateName( old_state ) << endl
+       << " OldState : " << Automaton()->StateName( _OldState ) << endl
        << " Event : " << Automaton()->EventName( anEvent ) << endl
        << " NextState : " << Automaton()->StateName( _NextState ) << endl
        << " Action : " << Automaton()->ActionName( _NextAction ) << endl
@@ -76,8 +120,8 @@ int GraphExecutor::InNode::SendEvent(
 #endif
 
   int sts = executeAction() ;
-
-  cdebug << pthread_self() << "/" << ThreadNo() << " <- SendEvent Node " << Name() 
+  
+  cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name() 
         << " Event : " << Automaton()->EventName( anEvent )
         << " State : " << Automaton()->StateName( State() )
          << endl;
@@ -113,6 +157,7 @@ void GraphExecutor::InNode::RunningAction() {
   cdebug << pthread_self() << "/" << ThreadNo()
          << "RunningAction pthread_cond_broadcast _RunningWait "
          << Name() << endl ;
+// That activate the pthread_cond_wait for RunninWait
   if ( pthread_cond_broadcast( &_RunningWait ) ) {
     perror("Running pthread_cond_broadcast ") ;
   }
@@ -182,16 +227,21 @@ GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
            << " NO SuspendAction pthread_cond_wait"  
            << Automaton()->StateName( State() ) << endl ;
   }
-  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 ") ;
@@ -249,7 +299,7 @@ bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent
     cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
            << " NO ResumeAction pthread_cond_signal" << endl ;
     if ( pthread_self() == ThreadNo() ) {
-      RetVal = false ; // Ne pas s'attendre soi-meme !...
+      RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
     }
     else {
       _SuspendSync = true ;
@@ -394,45 +444,139 @@ void GraphExecutor::InNode::StopAction() {
   }
 }
 
+void GraphExecutor::InNode::ThreadStartedAction() {
+  if ( pthread_mutex_lock( &_MutexWait ) ) {
+    perror("ThreadStarted pthread_mutex_lock ") ;
+    exit( 0 ) ;
+  }
+  if ( !_ThreadStartedSync ) {
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
+           << endl ;
+    _ThreadStartedSync = true ;
+    if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
+      perror("ThreadStarted pthread_cond_wait ") ;
+    }
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
+           << endl ;
+  }
+  else {
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
+           << endl ;
+//Debug :
+    _ThreadStartedSync = false ;  
+    if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
+      perror("ThreadStart pthread_cond_signal ") ;
+    }
+//Debug
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
+           << endl ;
+  }
+  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 ) {
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
+           << endl ;
+    _ThreadStartedSync = false ;  
+    if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
+      perror("ThreadStart pthread_cond_broadcast ") ;
+    }
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
+           << endl ;
+  }
+  else {
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
+           << endl ;
+    _ThreadStartedSync = true ;
+//Debug :
+    if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
+      perror("ThreadStarted pthread_cond_wait ") ;
+    }
+//Debug
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
+           << endl ;
+  }
+  if ( pthread_mutex_unlock( &_MutexWait ) ) {
+    perror("ThreadStart pthread_mutex_unlock ") ;
+    exit( 0 ) ;
+  }
+}
+
 int GraphExecutor::InNode::executeAction() {
+  int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ;
+  if ( !CreateNewThread() && oldRewindStack ) {
+    cdebug << pthread_self() << "/" << ThreadNo()
+           << " executeAction start Thread _RewindStack " << _RewindStack << " > "
+           << MAXSTACKTHREADSIZE << " CreateNewThread "
+           << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
+           << endl;
+    CreateNewThread( true ) ;
+    ThreadNo( 0 ) ;
+  }
   if ( CreateNewThread() ) {
     CreateNewThread( false ) ;
     if ( ThreadNo() == 0 ) {
+      _RewindStack = 1 ;
       cdebug << pthread_self() << "/" << ThreadNo()
-             << " executeAction start Thread "
+             << " executeAction start Thread _RewindStack " << _RewindStack << " "
              << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
              << endl;
       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 ) ;
-        cdebug << ThreadNo() << " " << msg << endl ;
+        cdebug << ThreadNo() << " " << msg << " --> sleep(5)" << endl ;
         cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
-               << PTHREAD_THREADS_MAX << " " << pthread_sts << endl ;
-//        sleep( 1 ) ;
+               << 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 ;
+       }
+        else {
+          cdebug << pthread_sts << endl ;
+       }
+        string smsg = msg ;
+        delete [] msg ;
         pthread_exit( msg ) ;
       }
       cdebug << pthread_self() << "/" << ThreadNo()
              << "executeAction has created thread " << T << endl ;
+      ThreadStartedAction() ;
+      cdebug << pthread_self() << "/" << ThreadNo()
+             << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
+             << Name() << endl ;
     }
     else {
       cdebug << pthread_self() << "/" << ThreadNo()
-             << " executeAction restart Thread "
+             << " executeAction restart Thread _RewindStack " << _RewindStack << " "
              << Automaton()->StateName( State() ) << " "
              << Automaton()->ActionName( _NextAction ) << "(" << Name()
              << ") ReStartAction ==>" << endl;
-      SUPERV::AutomatonState oldstate = State() ;
-      State( SUPERV::SuspendedSuccessedState ) ;
+      State( GraphExecutor::SuspendedSuccessedState ) ;
       if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
-//        State( oldstate ) ;
         cdebug << pthread_self() << "/" << ThreadNo()
                << " executeAction STATE & CALLED "
                << Automaton()->ActionName( _NextAction ) << "(" << Name()
                << ") ERROR-DEBUG " << endl;
-//        return ExecuteAction() ;
       }
       else {
         cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
@@ -442,23 +586,24 @@ int GraphExecutor::InNode::executeAction() {
     }
   }
   else {
+    if ( _CurrentEvent == ExecuteEvent ) {
+      _RewindStack += 1 ;
+    }
     cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
-           << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
+           << Automaton()->ActionName( _NextAction ) << "(" << Name() << ") _RewindStack " << _RewindStack
            << endl;
     return ExecuteAction() ;
   }
-  return 1;
+  return 1 ;
 }
 
 void GraphExecutor::InNode::coutbegin() {
-  cdebug << ThreadNo() << " " << pthread_self() << " run_function begin"
-         << " " << Name() << " " << Automaton()->StateName( State() )
-         << endl ;
+  cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin"
+         << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
 }
 void GraphExecutor::InNode::coutexit() {
-  cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit"
-         << " " << Name() << " " << Automaton()->StateName( State() )
-         << endl ;
+  cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit _RewindStack " << _RewindStack
+         << " " << Name() << " " << Automaton()->StateName( State() ) << endl ;
 }
 void * run_function(void *p) {
   GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
@@ -472,28 +617,33 @@ 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" , aNode->ThreadNo() ) ;
+  sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
   strcat( msg , " thread exit" ) ;
   aNode->coutexit() ;
   aNode->ExitThread() ;
   string smsg = msg ;
+  delete [] msg ;
   pthread_exit( (void * ) smsg.c_str() ) ;
   return msg ;
 }
 
 int GraphExecutor::InNode::ExecuteAction() {
   int sts ;
-  GraphExecutor::StateEventAction nextaction = _NextAction ;
-  const char * nextactionname = Automaton()->ActionName( nextaction ) ;
+
+  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() << " --> ExecuteAction "
+            << nextactionname << " "  << statename << " NextState "
+            << nextstatename << endl ;
+
   State( _NextState ) ;
-  switch ( nextaction ) {
+  switch ( _NextAction ) {
   case GraphExecutor::ErrorAction : {
     sts = ErrorAction() ;
     break ;
@@ -621,8 +771,8 @@ int GraphExecutor::InNode::ExecuteAction() {
     return 0 ;
   }
   }
-  cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
-         << Automaton()->ActionName( nextaction ) << endl ;
+  cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
+             << nextactionname << endl ;
   return sts ;
 }
 
@@ -645,35 +795,39 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
   unsigned int k;
   int InReady = 0 ;
   int res = 1;
-  bool LoopFinished = false ;
   bool LoopBeginning = false ;
+  bool LoopFinished = false ;
   bool SwitchFinished = false ;
 
-  if ( IsEndLoopNode() && !GetChangeNodeInPort( 1 )->GetOutPort()->BoolValue() ) {
-    LoopFinished = true ; // End of Loop
-  }
-  if ( IsLoopNode() && GetChangeNodeInPort( 1 )->GetOutPort()->BoolValue() ) {
+  if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
     LoopBeginning = true ; // Beginning of Loop
   }
-  if ( IsEndSwitchNode() && !GetChangeNodeInPort( 0 )->GetOutPort()->BoolValue() ) {
-    SwitchFinished = true ;
+  if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) {
+    LoopFinished = true ; // End of Loop
+  }
+  if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
+    SwitchFinished = true ; // End of Switch
   }
-  for ( k = 0 ; k < GetNodeInPortsSize() ; k++ ) {
+  cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
+         << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
+  for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
     GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
     GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
+    cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->State() << " " << anInPort->PortStatus() << endl ;
     if ( anInPort->IsGate() && anOutPort == NULL ) {
       InReady += 1 ;
       anInPort->State( SUPERV::ReadyState ) ;
       cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
              << anInPort->PortName() << " ControlPort inactive." << endl ;
     }
+// That InPort get its value from an other node
     else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
       if ( anInPort->State() == SUPERV::ReadyState ) {
         InReady += 1 ;
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName()
-               << " " ;
+               << anInPort->PortName() << " Was Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName()
+               << ") ReadyState " ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
@@ -681,14 +835,13 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
 #endif
         cdebug << endl ;
       }
-//      else if ( LoopBeginning && anInPort->IsDataConnected() ) {
       else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
         anInPort->State( SUPERV::ReadyState ) ;
         InReady += 1 ;
         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 ) ;
@@ -700,9 +853,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
         anInPort->State( SUPERV::ReadyState ) ;
         InReady += 1 ;
         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" ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
@@ -714,9 +867,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
         anInPort->State( SUPERV::ReadyState ) ;
         InReady += 1 ;
         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()
+               << ") SwitchFinished" ;
 #ifdef _DEBUG_
         if ( GraphBase::Base::_prof_debug ) {
           anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
@@ -726,13 +879,14 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
       }
       else {
         cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-               << anInPort->PortName() << " Was NOT Done from "
-               << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
+               << anInPort->PortName() << " Was NOT Done from Node "
+               << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
                << " " << Automaton()->StateName( State() ) << " DataConnected "
                << anInPort->IsDataConnected() << " LoopBeginning "
                << LoopBeginning << endl ;
       }
     }
+// That InPort get its value from the sending node
     else if ( anInPort->IsGate() ) {
       const CORBA::Any * theValue = anOutPort->Value() ;
       long GateOpened ;
@@ -741,9 +895,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
         InReady += 1 ;
         anInPort->State( SUPERV::ReadyState ) ;
         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 ) ;
@@ -754,9 +908,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
       else if ( LoopFinished ) {
         anInPort->State( SUPERV::ReadyState ) ;
         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 ) ;
@@ -766,9 +920,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
       }
       else {
         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 ) ;
@@ -777,21 +931,39 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
         cdebug << endl ;
       }
     }
-    else {
+    else if ( anOutPort->Done() ) {
       InReady += 1 ;
       anInPort->State( SUPERV::ReadyState ) ;
       cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
-             << anInPort->PortName() << " is Done from "
-             << anOutPort->NodeName() << " " << anOutPort->PortName() << " " ;
+             << anInPort->PortName() << " " << anInPort->PortStatus() << " is Done from Node "
+             << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+             << anOutPort->PortStatus() << " " ;
 #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 ;
+      cdebug << endl ;
+// MacroNode : give immediately the value to the corresponding graph
+      if ( IsMacroNode() ) {
+        cout << "SomeDataReadyAction " << GraphMacroNode() << " " << GraphMacroNode()->Name()
+             << " coupled to " << GraphMacroNode()->CoupledNode() << endl ;
+        GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
+        cdebug << "SomeDataReadyAction MacroNode " << aMacroGraph->Graph()->Name() << " --> InputOfAny "
+               << InReady << "/" << GetNodeInPortsSize() << " InPorts are Ready" << endl ;
+//        GraphMacroNode()->MacroObject()->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
+        aMacroGraph->InputOfAny( anInPort->PortName() , *anOutPort->Value() ) ;
+      }
+    }
+    else {
+      cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( "
+             << anInPort->PortName() << ") " << anInPort->PortStatus()
+             << " is NOT Done from Node "
+             << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+             << anOutPort->PortStatus() << " " ;
     }
   }
-  
+
   if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
     res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
   }
@@ -807,29 +979,28 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
 
 int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
   CreateNewThreadIf( false ) ;
-  cdebug << pthread_self() << " for " << ThreadNo()
-         << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+//  cdebug << pthread_self() << " for " << ThreadNo()
+//         << " DataUndef_NotAllDataReadyAction " << Name() << endl;
   return 1;
 }
 
 int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
-  cdebug << pthread_self() << "/" << ThreadNo()
-         << " --> DataUndef_AllDataReadyAction " << Name()
-         << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
-         << IsLockedDataWait() ;
-//  if ( !CreateNewThreadIf() && IsLockedDataWait() ) {
+//  cdebug << pthread_self() << "/" << ThreadNo()
+//         << " --> DataUndef_AllDataReadyAction " << Name()
+//         << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
+//         << IsLockedDataWait() ;
   if ( IsLockedDataWait() ) {
-    cdebug << " WOULD DEAD-LOCK" << endl ;
+    cdebug << "DataUndef_AllDataReadyAction() WOULD DEAD-LOCK" << endl ;
     return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
   }
-  cdebug << endl ;
+//  cdebug << endl ;
   CreateNewThread( CreateNewThreadIf() ) ;
   if ( !CreateNewThread() ) {
-    cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+//    cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
     ThreadNo( pthread_self() ) ;
   }
   _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
-                       SUPERV::DataReadyState ) ; 
+                       GraphExecutor::DataReadyState ) ; 
   ReadyAction() ;
   SUPERV::ControlState aControl = ControlState() ;
   switch ( aControl ) {
@@ -868,8 +1039,8 @@ int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
     return 0;
   }
   }
-  cdebug << pthread_self() << "/" << ThreadNo()
-         << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+//  cdebug << pthread_self() << "/" << ThreadNo()
+//         << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
   return 1;
 }
 
@@ -879,7 +1050,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;
@@ -898,13 +1069,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;
@@ -913,7 +1084,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;
@@ -925,152 +1096,253 @@ int GraphExecutor::InNode::DataReady_StopAction() {
 int GraphExecutor::InNode::DataReady_ExecuteAction() {
   int i;
 
-  cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
-         << Name() << endl;
+//  cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
+//         << Name() << endl;
   _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
-                       SUPERV::ExecutingState ) ; 
+                       GraphExecutor::ExecutingState ) ; 
 
   RunningAction() ;
+
+  bool Err = false ;
+
   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 ;
+  int nOutParams ;
+  ServicesAnyData * OutParametersList ;
 
-  int nInParams = GetNodeInPortsSize()  ;
-  ServicesAnyData * aListOfInParameters = new ServicesAnyData[nInParams];
-  InParametersSet( Err , nInParams , aListOfInParameters ) ;
+  nInParams = GetNodeInPortsSize()  ;
+  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 ;
-      aListOfInParameters[1].Value >>= obj ;
-      CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
-      myObjComponent = Engines::Component::_narrow( objvar ) ;
+  nOutParams = GetNodeOutPortsSize() ;
+  OutParametersList = new ServicesAnyData[nOutParams];
+  InOutParametersSet( nOutParams , OutParametersList ) ;
+
+  if ( !IsMacroNode() ) {
+
+    Engines::Container_var myContainer ;
+    Engines::Component_var myObjComponent ;
+    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 {
+      }
+    }
+    else if ( CORBA::is_nil( Component() ) ) {
+//      ostringstream astr ;
+//      astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name()
+//           << " : load of component " << ComponentName() << " in container "
+//           << Computer() ;
+//      _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
+      Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() ,
+                                                my_strdup( ComponentName() ) ,
+                                                myContainer , myObjComponent ) ;
+      ObjInterface( false ) ;
+      SetContainer( myContainer ) ;
+      SetComponent( myObjComponent ) ;
     }
     else {
+      myContainer = Container() ;
+      myObjComponent = Component() ;
+//      cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
+//             << endl ;
+      try {
+        myObjComponent->ping() ;
+      }
+      catch( ... ) {
+        cdebug << "ping() catched" << endl ;
+        Err = true ;
+      }
     }
-  }
-  else if ( CORBA::is_nil( Component() ) ) {
-    Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
-                                     my_strdup( ComponentName() ) ,
-                                     myContainer , myObjComponent ) ;
-//    if ( !Err && nInParams > 1 &&
-//         strcmp( ComponentName() , InterfaceName() ) &&
-//         aListOfInParameters[ 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"
-           << endl ;
-    myObjComponent->ping() ;
-  }
-
-  int nOutParams = GetNodeOutPortsSize()  ;
-  ServicesAnyData * aListOfOutParameters = new ServicesAnyData[nOutParams];
-  InOutParameters( nOutParams , aListOfOutParameters ) ;
 
-//  if ( strlen( ComponentName() ) ) {
     if ( Err || ControlState() == SUPERV::ToKillState ||
                 ControlState() == SUPERV::ToKillDoneState ||
                 ControlState() == SUPERV::ToStopState ) {
       cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
+      MESSAGE(pthread_self() << "Executor::InNode::DataReady_ExecuteAction of " << Name()
+              << " ControlState " << Automaton()->ControlStateName( ControlState() )
+              << " BEFORE execution ThreadNo " << ThreadNo() ) ;
       Err = true ;
     }
     else {
+      if ( ControlState() == SUPERV::ToSuspendState ) {
+        cdebug << ThreadNo() << "ToSuspendState before running." << endl ;
+        MESSAGE(ThreadNo() << "ToSuspendState before running.") ;
+      }
       if ( !Err ) {
+//        ostringstream astr ;
+//        astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ;
+//        _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
         cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
-        for ( i = 0 ; i < nInParams ; i++ ) {
-          cdebug << " , " << aListOfInParameters[ i ].Name ;
+        for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
+          cdebug << " , " << InParametersList[ i ].Name << "[kind"
+                 << InParametersList[ i ].Value.type()->kind() << "]" ;
         }
+        for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
+          cdebug << " , " << OutParametersList[ i ].Name << "[kind"
+                 << OutParametersList[ i ].Value.type()->kind() << "]" ;
+        }
+        if ( IsOneOfInLineNodes() ) {
+          cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
+                 << InLineNode()->PyRunMethod() << " length "
+                 << (*InLineNode()->PythonFunction()).length() ;
+       }
         cdebug << ")" << endl ;
 
         if ( IsOneOfInLineNodes() ) {
-          bool StsPyDynInvoke = true ;
+          bool StsPyDynInvoke = true;
+         _OutNode->PyThreadLock() ;
+          SetPyCpuUsed() ;
           try {
-            if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
+//            if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
+            bool ItIsaLoop = false ;
+            bool CopyInOut = false ;
+           if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
                  strlen( InLineNode()->PyFuncName() ) ) {
               cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
                      << InLineNode()->PyFuncName()
                      << "' IsInLineNode PyDynInvoke"  << endl ;
               StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &aListOfInParameters[1] , ServiceInParameter().length() ,
-                               &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
-           }
+                                            InLineNode()->PyFuncName() ,
+                                            &InParametersList[0] , ServiceInParameter().length() ,
+                                            &OutParametersList[0] , ServiceOutParameter().length() ) ;
+              if ( !StsPyDynInvoke ) {
+                RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+             }     }
             else if ( IsLoopNode() ) {
-              if ( GetNodeInPort( 1 )->GetOutPort()->BoolValue() ) { // InLoop Port
+              ItIsaLoop = true ;
+              bool CopyOutIn = false ;
+// Switch between Init() and Next()
+// if InLoop port is true and does not come from EndLoop ==> execute Init
+// if InLoop port is false or come from EndLoop ==> execute Next
+//              GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
+//              if ( GetNodeInLoop()->GetOutPort()->BoolValue() &&
+              if ( _InitLoop ) {
+                if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init()
+                  cdebug << ThreadNo() << " !ObjInterface " << Name()
+                         << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
+                         << "' InitLoop " << LoopNode()->PyRunMethod() << endl ;
+                  StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                                InLineNode()->PyFuncName() ,
+                                                &InParametersList[1] , ServiceInParameter().length() ,
+                                                &OutParametersList[1] , ServiceOutParameter().length() ) ;
+                if ( !StsPyDynInvoke ) {
+                  RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+               }
+                  CopyOutIn = true ;
+               }
+                else {
+                  cdebug << ThreadNo() << " !ObjInterface " << Name()
+                         << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ;
+               }
                 cdebug << ThreadNo() << " !ObjInterface " << Name()
-                       << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
-                       << "'" << endl ;
-                StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &aListOfInParameters[2] , ServiceInParameter().length() ,
-                               &aListOfOutParameters[2] , ServiceOutParameter().length() ) ;
+                       << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ;
+                _InitLoop = false ;
              }
-              else {
+              else if ( LoopNode()->PyNextMethod() &&
+                        strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next()
                 cdebug << ThreadNo() << " !ObjInterface " << Name()
                        << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
-                       << "'" << endl ;
+                       << "' " << LoopNode()->PyNextMethod() << endl ;
                 StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
-                             LoopNode()->PyNextName() ,
-                             &aListOfInParameters[2] , ServiceInParameter().length() ,
-                             &aListOfOutParameters[2] , ServiceOutParameter().length() ) ;
+                                              LoopNode()->PyNextName() ,
+                                              &InParametersList[1] , ServiceInParameter().length() ,
+                                              &OutParametersList[1] , ServiceOutParameter().length() ) ;
+                if ( !StsPyDynInvoke ) {
+                  RemovePyDynInvoke( LoopNode()->PyNextName() ) ;
+               }
+                CopyOutIn = true ;
              }
-              if ( StsPyDynInvoke ) {
+              else {
                 cdebug << ThreadNo() << " !ObjInterface " << Name()
-                       << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
-                       << "' Copy of " << ServiceInParameter().length()
-                       << " OutParameters" << endl ;
-                int i ;
-                for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
-                  aListOfInParameters[2 + i].Value = aListOfOutParameters[2+ i].Value ;
-                  aListOfInParameters[2 + i].Name = aListOfOutParameters[2+ i].Name ;
-                  switch ( aListOfInParameters[2 + i].Value.type()->kind() ) {
-                  case CORBA::tk_string :
-                    cdebug << "Arg" << i << " : "
-                           << aListOfInParameters[2 + i].Name.c_str()
-                           << " Value(string) " << endl ;
-                    break ;
-                  case CORBA::tk_double :
-                    cdebug << "Arg" << i << " : "
-                           << aListOfInParameters[2 + i].Name.c_str()
-                           << " Value(double) " << endl ;
-                    break ;
-                  case CORBA::tk_long :
-                    cdebug << "Arg" << i << " : "
-                           << aListOfInParameters[2 + i].Name.c_str()
-                           << " Value(long) " << endl ;
-                    break ;
-                  case CORBA::tk_objref :
-                    cdebug << "Arg" << i << " : "
-                           << aListOfInParameters[2 + i].Name.c_str()
-                           << " Value(object reference) " << endl ;
-                    break ;
-                  default :
-                    cdebug << "Arg" << i << " : "
-                           << aListOfInParameters[2 + i].Name.c_str()
-                           << " Value(other) ERROR" << endl ;
+                       << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ;
+             }
+              if ( StsPyDynInvoke ) {
+                if ( CopyOutIn ) {
+                  cdebug << ThreadNo() << " !ObjInterface " << Name()
+                         << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+                         << "' Copy of " << ServiceInParameter().length()
+                         << " OutParameters" << endl ;
+                  int i ;
+// Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next )
+                  for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
+                    InParametersList[i].Value = OutParametersList[i].Value ;
+                    InParametersList[i].Name = OutParametersList[i].Name ;
+//#if 0
+                    switch ( InParametersList[i].Value.type()->kind() ) {
+                    case CORBA::tk_string :
+                      char * t;
+                      InParametersList[i].Value >>= t ;
+                      cdebug << "ArgOut->In" << i << " : "
+                             << InParametersList[i].Name.c_str()
+                             << " Value(string) " << t << endl ;
+                      break ;
+                    case CORBA::tk_double :
+                      double d;
+                      InParametersList[i].Value >>= d;
+                      cdebug << "ArgOut->In" << i << " : "
+                             << InParametersList[i].Name.c_str()
+                             << " Value(double) " << d << endl ;
+                      break ;
+                    case CORBA::tk_long :
+                      long l;
+                      InParametersList[i].Value >>= l;
+                      cdebug << "ArgOut->In" << i << " : "
+                             << InParametersList[i].Name.c_str()
+                             << " Value(long) " << l << endl ;
+                      break ;
+                    case CORBA::tk_objref :
+                      CORBA::Object_ptr obj ;
+                      char * retstr ;
+                      try {
+                        InParametersList[i].Value >>= obj ;
+                        retstr = ObjectToString( obj );
+                        cdebug << "ArgOut->In" << i << " : "
+                               << InParametersList[i].Name.c_str()
+                               << " Value(object reference) " << retstr << endl ;
+                      }
+                      catch ( ... ) {
+                        cdebug << "ArgOut->In" << i << " : "
+                               << InParametersList[i].Name.c_str()
+                               << " Value(object reference) Catched ERROR" << endl ;
+                     }
+                      break ;
+                    default :
+                      cdebug << "ArgOut->In" << i << " : "
+                             << InParametersList[i].Name.c_str()
+                             << " Value(other) ERROR" << endl ;
+                   }
+//#endif
                  }
                }
-                StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
-                           LoopNode()->PyMoreName() ,
-                           &aListOfInParameters[2] , ServiceInParameter().length() ,
-                           &aListOfOutParameters[1] , ServiceOutParameter().length()+1 ) ;
+                if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
+                  cdebug << ThreadNo() << " !ObjInterface " << Name()
+                         << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+                         << "' " << LoopNode()->PyMoreMethod() << endl ;
+                  StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
+                                                LoopNode()->PyMoreName() ,
+                                                &InParametersList[1] , ServiceInParameter().length() ,
+                                                &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
+                  if ( !StsPyDynInvoke ) {
+                    RemovePyDynInvoke( LoopNode()->PyMoreName() ) ;
+                 }
+               }
+                else {
+                  cdebug << ThreadNo() << " !ObjInterface " << Name()
+                         << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+                         << "' No MoreMethod" << endl ;
+                  CopyInOut = true ;
+               }
              }
               else {
                 Err = true ;
@@ -1080,203 +1352,311 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() {
                        << endl ;
              }
            }
-            else if ( IsSwitchNode() ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-                     << InLineNode()->PyFuncName()
-                     << "' IsSwitchNode PyDynInvoke"  << endl ;
+            else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
+                      strlen( InLineNode()->PyFuncName() ) ) {
+//              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+//                     << InLineNode()->PyFuncName()
+//                     << "' IsSwitchNode PyDynInvoke"  << endl ;
               StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &aListOfInParameters[1] , ServiceInParameter().length() ,
-                               &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+                                            InLineNode()->PyFuncName() ,
+                                            &InParametersList[0] , ServiceInParameter().length() ,
+                                            &OutParametersList[0] , ServiceOutParameter().length() ) ;
+              if ( !StsPyDynInvoke ) {
+                RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+             }
            }
-            else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
+//            else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
+            else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
                       strlen( InLineNode()->PyFuncName() ) ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
-                     << InLineNode()->PyFuncName()
-                     << "' IsGOTONode PyDynInvoke"  << endl ;
+//              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+//                     << InLineNode()->PyFuncName()
+//                     << "' IsGOTONode PyDynInvoke"  << endl ;
               StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &aListOfInParameters[1] , ServiceInParameter().length() ,
-                               &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+                                            InLineNode()->PyFuncName() ,
+                                            &InParametersList[0] , ServiceInParameter().length() ,
+                                            &OutParametersList[0] , ServiceOutParameter().length() ) ;
+              if ( !StsPyDynInvoke ) {
+                RemovePyDynInvoke( GOTONode()->PyFuncName() ) ;
+             }
            }
-            else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
-                      strlen( InLineNode()->PyFuncName() ) ) {
+//            else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
+            else if ( ( IsEndSwitchNode() ) &&
+                      InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+//              cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+//                     << InLineNode()->PyFuncName()
+//                     << "' IsSwitchNode PyDynInvoke"  << endl ;
+              StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+                                            InLineNode()->PyFuncName() ,
+                                            &InParametersList[0] , ServiceInParameter().length() ,
+                                            &OutParametersList[0] , ServiceOutParameter().length() ) ;
+              if ( !StsPyDynInvoke ) {
+                RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+             }
+           }
+            else if ( ( IsEndLoopNode() ) &&
+                      InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
               cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
                      << InLineNode()->PyFuncName()
                      << "' IsSwitchNode PyDynInvoke"  << endl ;
               StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
-                               InLineNode()->PyFuncName() ,
-                               &aListOfInParameters[1] , ServiceInParameter().length() ,
-                               &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+                                            InLineNode()->PyFuncName() ,
+                                            &InParametersList[0] , ServiceInParameter().length() + 1 ,
+                                            &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
+              if ( !StsPyDynInvoke ) {
+                RemovePyDynInvoke( InLineNode()->PyFuncName() ) ;
+             }
            }
-            else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
-                      strlen( InLineNode()->PyFuncName() ) == 0 ) {
-              cdebug << ThreadNo() << " !ObjInterface " << Name()
-                     << " Copy of " << ServiceInParameter().length()
-                     << " OutParameters" << endl ;
-              int i ;
-              int argind0 = 1 ;
-              if ( IsEndLoopNode() ) {
-                argind0 = 2 ;
+
+//            else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
+            if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL ||
+                                  strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) {
+// This is a void Python Function : without code (No PyFuncName)
+//              cdebug << ThreadNo() << " !ObjInterface " << Name()
+//                     << " Copy of " << ServiceInParameter().length()
+//                     << " OutParameters" << endl ;
+             int i ;
+              int argout0 = 0 ;
+              int argin0 = 0 ;
+              if ( IsLoopNode() || IsEndLoopNode() ) {
+                argout0 = 1 ;
+                argin0 = 1 ; // after DoLoop
+                if ( IsLoopNode() ) { // More() is void
+//                  OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
+                  cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)"
+                         << endl ;
+                  GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ;
+                  OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop)
+               }
              }
-              for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
-                aListOfOutParameters[argind0 + i].Value = aListOfInParameters[argind0 + i].Value ;
-//                aListOfOutParameters[argind0 + i].Name = aListOfInParameters[argind0 + i].Name ;
-                switch ( aListOfInParameters[argind0 + i].Value.type()->kind() ) {
+              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 << "Arg" << i << " : "
-                         << aListOfInParameters[argind0 + i].Name.c_str()
+                  cdebug << "ArgOut->In" << argin0 + i << " : "
+                         << InParametersList[argin0 + i].Name.c_str()
                          << " Value(string) "
-                         << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+                         << OutParametersList[argout0 + i].Name.c_str() << endl ;
                   break ;
                 case CORBA::tk_double :
-                  cdebug << "Arg" << i << " : "
-                         << aListOfInParameters[argind0 + i].Name.c_str()
+                  cdebug << "ArgOut->In" << argin0 + i << " : "
+                         << InParametersList[argin0 + i].Name.c_str()
                          << " Value(double) "
-                         << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+                         << OutParametersList[argout0 + i].Name.c_str() << endl ;
                   break ;
                 case CORBA::tk_long :
-                  cdebug << "Arg" << i << " : "
-                         << aListOfInParameters[argind0 + i].Name.c_str()
+                  cdebug << "ArgOut->In" << argin0 + i << " : "
+                         << InParametersList[argin0 + i].Name.c_str()
                          << " Value(long) "
-                         << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+                         << OutParametersList[argout0 + i ].Name.c_str() << endl ;
                   break ;
                 case CORBA::tk_objref :
-                  cdebug << "Arg" << i << " : "
-                         << aListOfInParameters[argind0 + i].Name.c_str()
+                  cdebug << "ArgOut->In" << argin0 + i << " : "
+                         << InParametersList[argin0 + i].Name.c_str()
                          << " Value(object reference) "
-                         << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+                         << OutParametersList[argout0 + i].Name.c_str() << endl ;
                   break ;
                 default :
-                  cdebug << "Arg" << i << " : "
-                         << aListOfInParameters[argind0 + i].Name.c_str()
+                  cdebug << "ArgOut->In" << argin0 + i << " : "
+                         << InParametersList[argin0 + i].Name.c_str()
                          << " Value(other) ERROR "
-                         << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+                         << OutParametersList[argout0 + i].Name.c_str() << endl ;
                }
+//#endif
              }
            }
             if ( !StsPyDynInvoke ) {
-              Err = true ;
+             Err = true ;
               cdebug << ThreadNo() << " InLineNode " << Name()
                      << " Python Dynamic Call Error"
                      << endl ;
            }
          }
           catch( ... ) {
-            Err = true ;
+           Err = true ;
             cdebug << ThreadNo() << " InLineNode " << Name()
                    << " Python Dynamic Call Exception catched ERROR"
                    << endl ;
          }
+          CpuUsed( true ) ;
+          _OutNode->PyThreadUnLock() ;
        }
-//        else if ( !ObjInterface() ) {
-        else if ( IsFactoryNode() ) {
+        else {
           try {
             try {
+              cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ;
               DynInvoke( myObjComponent, "Names" ,
-                         _OutNode->Name() , Name() ) ;
+                         _OutNode->Graph()->Name() , Name() ) ;
             }
             catch( ... ) {
               cdebug << "DynInvoke Names catched ERROR" << endl ;
            }
-            cdebug << ServiceInParameter().length() << " input parameters and "
-                   << ServiceOutParameter().length() << " output parameters" << endl ;
-            if ( IsComputingNode() ) {
+// for DataStreamNodes : call of SetProperties ===> environment variables in the component/container
+            if ( ComputingNode()->HasDataStream() ) {
+              try {
+                cdebug << "DynInvoke -> SetProperties " << _OutNode->Graph()->Name() << " " << Name() << endl ;
+               Engines::FieldsDict_var dict = new Engines::FieldsDict;
+               dict->length( 4 );
+               dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE");
+               // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine).
+               //              dict[ 0 ].value <<= myContainer->getHostName() ;
+               char FullyQualifiedDomainName[256]="";
+               gethostname(FullyQualifiedDomainName,255);
+               dict[ 0 ].value <<=  FullyQualifiedDomainName ;
+               dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE");
+               dict[ 1 ].value <<= "/tmp" ;
+               dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE");
+                stringstream ofst1 ;
+                ofst1 << ComputingNode()->SubStreamGraph() ;
+               string cpl = string( "/tmp/" ) + string( _OutNode->Graph()->Name() ) + string( "_" ) + 
+                            ofst1.str() + string( ".cpl" );
+               dict[ 2 ].value <<= cpl.c_str() ;
+               dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME");
+               string uname = Name();
+               UpperCase( uname);
+               dict[ 3 ].value <<= uname.c_str() ;
+
+                myObjComponent->setProperties( dict ) ;
+              }
+              catch( ... ) {
+                cdebug << "DynInvoke setProperties catched ERROR" << endl ;
+               Err = true;
+             }
+           }
+            if ( !Err && IsComputingNode() ) {
               cdebug << ThreadNo() << " !ObjInterface " << Name()
                      << " IsComputingNode DynInvoke"  << endl ;
+              cdebug << ServiceInParameter().length()-1 << " input parameters and "
+                     << ServiceOutParameter().length() << " output parameters" << endl ;
+              IsLoading( false ) ;
               DynInvoke( myObjComponent,
                          ServiceName() ,
-                         &aListOfInParameters[1] , ServiceInParameter().length() ,
-                         &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+                         &InParametersList[1] , ServiceInParameter().length()-1 ,
+                         &OutParametersList[0] , ServiceOutParameter().length() ) ;
            }
-            else if ( IsFactoryNode() ) {
+            else if ( !Err && IsFactoryNode() ) {
               cdebug << ThreadNo() << " !ObjInterface " << Name()
                      << " IsFactoryNode DynInvoke"  << endl ;
+              cdebug << ServiceInParameter().length() << " input parameters and "
+                     << ServiceOutParameter().length() << " output parameters" << endl ;
+              IsLoading( false ) ;
               DynInvoke( myObjComponent,
                          ServiceName() ,
-                         &aListOfInParameters[1] , ServiceInParameter().length() ,
-                         &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+                         &InParametersList[0] , ServiceInParameter().length() ,
+                         &OutParametersList[0] , ServiceOutParameter().length() ) ;
            }
+//            cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
+//                   << myObjComponent->CpuUsed_impl() << endl ;
           }
           catch( ... ) {
             Err = true ;
             cdebug << ThreadNo() << " !ObjInterface " << Name()
                    << " Node(Component) Dynamic Call Exception catched ERROR"
                    << endl ;
-         }
-        }
-        else {
-          try {
+//Reset of _ThreadId in the Container ...
             try {
-              DynInvoke( myObjComponent, "Names" ,
-                         _OutNode->Name() , Name() ) ;
-            }
+              myObjComponent->Kill_impl() ;
+           }
             catch( ... ) {
            }
-            cdebug << ThreadNo() << " ObjInterface " << Name() << " DynInvoke"
-                   << endl ;
-            DynInvoke( myObjComponent ,
-                       ServiceName() ,
-                       &aListOfInParameters[2] , ServiceInParameter().length()-1 ,
-                       &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
-         }
-          catch( ... ) {
-            Err = true ;
-            cdebug << ThreadNo() << " ObjInterface " << Name()
-                   << " Node(Interface) Dynamic Call Exception catched ERROR"
-                   << endl ;
          }
         }
       }
     }
-//  }
-//  else {
-//    sleep( 1 ) ;
-//  }
+  }
+
+//  ostringstream astr ;
+//  astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : "
+//       << Automaton()->StateName( State() ) ;
+//  _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
 
   if ( Err ) {
+    
+    // if exception or something else - IsLoading( false ) may not NOT has been called
+    if ( 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 = OutParameters( Err , PortState , nOutParams , aListOfOutParameters ) ;
-  if ( !ErrOut ) {
-    NewEvent = GraphExecutor::ErrorEvent ;
+  if ( !IsMacroNode() ) {
+    bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
+    if ( !ErrOut ) {
+      NewEvent = GraphExecutor::ErrorEvent ;
+    }
+    delete [] InParametersList ;
+    delete [] OutParametersList ;
+  }
+         
+  if ( !IsMacroNode() ) {              
+    SendEvent( NewEvent ) ;
+  }
+  else {
+    GraphExecutor::DataFlow * aMacroGraph = GraphMacroNode()->CoupledNode()->GraphEditor()->Executor() ;
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << aMacroGraph << " "
+           << aMacroGraph->Graph()->Name() << " ->DoneWait()"
+           << " State " << aMacroGraph->State() << endl;
+    aMacroGraph->DoneWait() ;
+    cdebug << ThreadNo() << " DataReady_ExecuteAction " << Name() << " State " << aMacroGraph->State() << endl;
+    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 ) ;
   }
-  delete [] aListOfInParameters ;
-  delete [] aListOfOutParameters ;
-
-  SendEvent( NewEvent );
 
-  cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+//  cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
   return 1 ;
 }
 
 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 ,
@@ -1286,51 +1666,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 : {
@@ -1364,15 +1746,14 @@ 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;
   _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
-                       SUPERV::ErroredState ) ; 
-//  DoneAction() ;
+                       GraphExecutor::ErroredState ) ; 
 
   SUPERV::ControlState aControl = ControlState() ;
   switch ( aControl ) {
@@ -1416,32 +1797,62 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
   int i ;
   int j ;
   bool docdebug = false ;
-  State( SUPERV::DataWaitingState ) ;
+  State( GraphExecutor::DataWaitingState ) ;
   for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
     GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
-    if ( anInPort->IsGate() ) { // Loop : Open the doors
+    cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) "
+           << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+// 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 ;
+//        *anAny <<= (long ) 1 ;
+        *anAny <<= (long ) 0 ;
         anOutPort->Value( anAny ) ;
-        anInPort->State( SUPERV::ReadyState ) ;
+        anInPort->State( SUPERV::WaitingState ) ;
       }
     }
-    else if ( anInPort->State() != SUPERV::WaitingState ) {
+    else if ( anInPort->State() != SUPERV::WaitingState &&
+              !anInPort->IsDataConnected() ) {
       if ( !docdebug ) {
         cdebug << ThreadNo()
-               << " --> GraphExecutor::InNodeThreads::SetWaitingStates "
-               << Name() << endl;
+               << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
         docdebug = true ;
       }
-      anInPort->State( SUPERV::WaitingState ) ;
+      if ( !anInPort->IsDataStream() ) {
+        anInPort->State( SUPERV::WaitingState ) ;
+      }
     }
+    cdebug << "               --> " << Name() << "( " << anInPort->PortName() << " ) "
+           << anInPort->PortStatus() << " " << anInPort->State() << endl ;
   }
   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
-    if ( !( IsGOTONode() && i == 0 ) && !( IsEndLoopNode() && i <= 1 ) ) {
-      for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
-        GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( GetChangeNodeOutPort( i )->ChangeInPorts( j )->NodeName() )->GetInNode() ;
+    GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
+    for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+      if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
+           !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) &&
+           !anOutPort->IsDataStream() &&
+           !anOutPort->ChangeInPorts( j )->IsDataStream() &&
+           !anOutPort->ChangeInPorts( j )->IsExternConnected() ) {
+        cdebug << ThreadNo()
+               << " InNodeThreads::SetWaitingStates OutPort "
+               << Name() << "/" << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+               << anOutPort->PortName() << " " << anOutPort->PortStatus() << " ) --> InPort "
+               << anOutPort->ChangeInPorts( j )->NodeName() << "( "
+               << anOutPort->ChangeInPorts( j )->PortName() << " "
+               << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl;
+        if ( strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) {
+// After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from
+// EndLoopNode or GOTONode. But if there is several nested loops we should re-establish.
+          cdebug << ThreadNo()
+                 << " InNodeThreads::SetWaitingStates OutPort->ChangeInPorts( j )->OutPort()->NodeName "
+                 << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << " != "
+                 << Name() << " : Restored to " << anOutPort->NodeName() << "( "
+                 << anOutPort->PortName() << " )" << endl ;
+          anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+        }
+        GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
         if ( aNode != EndNode ) {
           aNode->SetWaitingStates( EndNode ) ;
        }
@@ -1463,81 +1874,105 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
 
   DoneAction() ;
 
+  if ( IsMacroNode() ) {
+      cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done"
+             << endl ;
+    return 1;
+  }
+
   if ( IsGOTONode() ||
-       ( IsEndLoopNode() && GetNodeInPort(1)->GetOutPort()->BoolValue() ) ) {
-    int index ;
+       ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) {
+    cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+           << " SetWaitingStates " << endl ;
+    const GraphBase::OutPort * aGateOutPort ;
     if ( IsGOTONode() ) {
-      index = 0 ;
+      aGateOutPort = GetNodeOutGate() ;
     }
     else {
-      index = 1 ;
-      CORBA::Any * anAny = new CORBA::Any() ;
-      *anAny <<= (long ) 0 ;
-      GetChangeNodeOutPort(1)->Value( anAny ) ; // Loop(InLoop) = false 
-    }
-    const GraphBase::OutPort * GateOutPort = GetNodeOutPort(index) ;
-    for ( i = 0 ; i < GateOutPort->InPortsSize() ; i++ ) {
-      const GraphBase::InPort * anInPort = GateOutPort->InPorts( i ) ;
-      GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+      aGateOutPort = GetNodeOutLoop() ;
+    }
+    if ( aGateOutPort->InPortsSize() != 1 ) {
+      cdebug << 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 ) ;
+      aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+      cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
+             << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
       aLabelNode->SetWaitingStates( this ) ;
-      for ( j = 1 ; j < GetNodeOutPortsSize() ; j++ ) {
-        GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
-        GraphBase::InPort * aBusParamChangeInPort = NULL ;
-        if ( aBusParamOutPort->IsLoop() ) {
-          aBusParamChangeInPort = aLabelNode->GetChangeInPort( "InitLoop" ) ;
-       }
-        else {
-          aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
+// JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates
+      GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ;
+      if ( anOutPort ) {
+        CORBA::Any * anAny = new CORBA::Any() ;
+        *anAny <<= (long ) 1 ;
+        anOutPort->Value( anAny ) ;
+        aLabelNode->GetChangeNodeInGate()->State( SUPERV::ReadyState ) ;
+      }
+      for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
+        const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
+        if ( anInPort->GetOutPort() ) {
+          cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
+                 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
+                 << endl ;
        }
-//        const GraphBase::InPort * aBusParamInPort = aBusParamChangeInPort ;
-//        if ( aBusParamInPort ) {
-//          GraphBase::OutPort * anOutPort = aBusParamInPort->GetOutPort() ;
-//          anOutPort->Value( aBusParamOutPort->Value() ) ;
-//          GraphExecutor::InNode * aFromLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
-//          if ( aFromLabelNode && !aLabelNode->IsLockedDataWait() ) {
-//            res = aLabelNode->SendSomeDataReady( aFromLabelNode->Name() , EndTest ) ;
-        if ( aBusParamChangeInPort ) {
-          aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
-          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 ;
-             }
-           }
-         }
+      }
+      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 "
-                   << aBusParamOutPort->PortName() << " to port "
-                   << aBusParamChangeInPort->PortName() << endl;
-//            aBusParamChangeInPort->State( SUPERV::ReadyState ) ;
+            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 ;
          }
        }
-        else {
-          cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
-                 << " NO port " << aBusParamOutPort->PortName() << " in "
-                 << aLabelNode->Name() << endl;
+      }
+    }
+
+    if ( aLabelNode && !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 " << Name() << " push "
+                 << aLabelNode->Name() << " " << SomeDataNodes.size() 
+                 << endl ;
+       }
       }
-      const GraphBase::OutPort * aGateOutPort = GetNodeOutPort( index ) ;
-      const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInPort( index ) ;
+
+      for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
+        const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
+        if ( anInPort->GetOutPort() ) {
+          cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
+                 << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
+                 << endl ;
+       }
+      }
+      const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
       if ( aGateInPort ) {
-        aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+        if ( aGateInPort->GetOutPort() ) {
+          aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+       }
         if ( !aLabelNode->IsLockedDataWait() ) {
           res = aLabelNode->SendSomeDataReady( Name() ) ;
           if ( res ) {
@@ -1553,8 +1988,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
            }
             else {
               SomeDataNodes.push_back( aLabelNode ) ;
-              cdebug << ThreadNo() << " Successed_SuccessAction push "
-                     << SomeDataNodes.size() << " " << aLabelNode->Name()
+              cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
+                     << aLabelNode->Name() << " " << SomeDataNodes.size()
                      << endl ;
            }
          }
@@ -1578,15 +2013,20 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
       cdebug << " " << LinkedNodes( i )->Name() ;
     }
     cdebug << endl;
-    SUPERV::ControlState aControl = ControlState() ;
     for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
       bool IgnoreForEndLoop = false ;
-      toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
+      GraphBase::ComputingNode * aComputingNode ;
+      aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
+      toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ;
       cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
-             << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
+             << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode << " IgnoreForEndLoop "
+             << IgnoreForEndLoop ;
+      if ( toNode ) {
+        cdebug << " " << toNode->Kind() << endl ;
+      }
       if ( toNode && !toNode->IsDataFlowNode() ) {
-        GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInPort(0) ;
         if ( IsComputingNode() && toNode->IsInLineNode() ) {
+          GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
           toGateInPort->State( SUPERV::ReadyState ) ;
           GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
           if ( GateOutPort ) {
@@ -1597,14 +2037,14 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
         }
       }
       if ( toNode && IsLoopNode() ) {
-        GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutPort(1) ;
-        if ( !fromLoopOutPort->BoolValue() ) {
+        GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutLoop() ;
+        if ( !fromLoopOutPort->BoolValue() ) { // Ne pas faire la boucle
           if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
-            IgnoreForEndLoop = true ; // toNode is the EndLoopNode
+            IgnoreForEndLoop = true ;
          }
-          else {
+          else { // toNode is the EndLoopNode
             GraphBase::InPort * toLoopInPort ;
-            toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+            toLoopInPort = toNode->GetChangeNodeInLoop() ;
             if ( toLoopInPort->State() != SUPERV::ReadyState ) {
               toLoopInPort->State( SUPERV::ReadyState ) ;
            }
@@ -1621,13 +2061,13 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
       }
       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() ;
+          CORBA::Any * anAny = new CORBA::Any() ; // InitLoop
           *anAny <<= (long ) 1 ;
           LoopOutPort->Value( anAny ) ;
           int j ;
@@ -1635,6 +2075,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
             toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
          }
         }
+        cdebug << ThreadNo() << " Successed_SuccessAction " << toNode->Name() << "->SendSomeDataReady( "
+               << Name() << " )" << endl ;
         res = toNode->SendSomeDataReady( Name() ) ;
         if ( res ) {
           if ( firsttoNode == NULL &&
@@ -1649,8 +2091,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
          }
           else {
             SomeDataNodes.push_back( toNode ) ;
-            cdebug << ThreadNo() << " Successed_SuccessAction push "
-                   << SomeDataNodes.size() << " " << toNode->Name() << endl ;
+            cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
+                   << toNode->Name() << " " << SomeDataNodes.size() << endl ;
          }
        }
       }
@@ -1665,56 +2107,59 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
   }
   else if ( firsttoNode && firstzeroNode ) {
     SomeDataNodes.push_back( firstzeroNode ) ;
-    cdebug << ThreadNo() << " Successed_SuccessAction push firstzeroNode "
-           << SomeDataNodes.size() << " " << firstzeroNode->Name() << endl ;
+    cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
+           << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
+  }
+  else {
+    cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode
+           << " firstzeroNode " << firstzeroNode << endl ;
   }
 
   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 ) {
+//    cdebug << pthread_self() << "/" << ThreadNo()
+//           << " Successed_SuccessAction pop "
+//           << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+    if ( aNode->State() == GraphExecutor::DataReadyState ) {
       aNode->CreateNewThreadIf( true ) ;
       aNode->UnLockDataWait() ;
       res = aNode->DataUndef_AllDataReadyAction() ;
     }
     else {
-      cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
-             << aNode->Name() << " "
-             << Automaton()->StateName( aNode->State() ) << endl ;
+//      cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
+//             << aNode->Name() << " "
+//             << Automaton()->StateName( aNode->State() ) << endl ;
     }
   }
 
   if ( firsttoNode ) {
-//    firsttoNode = SomeDataNodes.front() ;
-//    SomeDataNodes.pop_front() ;
-    cdebug << pthread_self() << "/" << ThreadNo()
-           << " Successed_SuccessAction pop firsttoNode "
-           << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+//    cdebug << pthread_self() << "/" << ThreadNo()
+//           << " Successed_SuccessAction start firsttoNode "
+//           << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
     firsttoNode->CreateNewThreadIf( false ) ;
-    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 ) ;
-    }
-    pthread_t OldT = firsttoNode->ThreadNo() ;
+    firsttoNode->RewindStack( RewindStack() ) ;
+    if ( firsttoNode->State() == GraphExecutor::SuccessedState ) {
+//      cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+//             << " : " << firsttoNode->Name() << " "
+//             << Automaton()->StateName( firsttoNode->State() )
+//             << " --> DataWaitingState for Thread "
+//             << firsttoNode->ThreadNo() << endl ;
+      firsttoNode->State( GraphExecutor::DataWaitingState ) ;
+    }
+//    pthread_t OldT = firsttoNode->ThreadNo() ;
     firsttoNode->ThreadNo( pthread_self() ) ;
 // On continue avec le meme thread
-    cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
-           << firsttoNode->Name() << "Thread(" << OldT << "-->"
-           << firsttoNode->ThreadNo() << ")" << endl ;
+//    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 << ThreadNo() << " Successed_SuccessAction " << Name()
+//           << " for " << firsttoNode->Name()
+//           << " !firsttoNode->CreateNewThreadIf() "
+//           << !firsttoNode->CreateNewThreadIf()
+//           << " " << Automaton()->StateName( firsttoNode->State() ) ;
+    if ( firsttoNode->State() == GraphExecutor::DataReadyState ) {
       cdebug << endl ;
       firsttoNode->UnLockDataWait() ;
       res = firsttoNode->DataUndef_AllDataReadyAction() ;
@@ -1724,48 +2169,56 @@ int GraphExecutor::InNode::Successed_SuccessAction() {
     }
   }
   else {
-    cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
-           << " NO DataReady ==> ThreadNo( 0 )" << endl ;
+//    cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+//           << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
     ThreadNo( 0 ) ;
   }
 
-  if ( linkednodesnumber == 0 ) {
-    _OutNode->CheckAllDone() ;
-  }
+//  if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
+//    cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
+//           << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
+//    _OutNode->CheckAllDone() ;
+//  }
 
-  cdebug << pthread_self() << "/" << ThreadNo()
-         << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
-         << linkednodesnumber << endl;
+//  cdebug << pthread_self() << "/" << ThreadNo()
+//         << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
+//         << linkednodesnumber << endl;
   return 1 ;
 }
 
 bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
   bool RetVal = false ;
   if ( IsDataFlowNode() ) {
-    cdebug << ThreadNo() << " ----> " << Name()
+    cdebug << ThreadNo() << "InNode::SendSomeDataReady ----> " << Name()
          << " send Result to graph " << Name() << endl;
   }
   else {
-    cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
-           << " send SomeDataReady to " << Name() << " "
-           << Automaton()->StateName( State() ) 
-           << " CreateNewThreadIf() " << CreateNewThreadIf()
-           << " LockedDataWait " << IsLockedDataWait() << endl;
+//    cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
+//           << " send SomeDataReady to " << Name() << " "
+//           << Automaton()->StateName( State() ) 
+//           << " CreateNewThreadIf() " << CreateNewThreadIf()
+//           << " LockedDataWait " << IsLockedDataWait() << endl;
 #if 0
-    cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
+  //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 ) {
-      cdebug << ThreadNo() << " " << FromNodeName
-             << " : " << Name() << " " << Automaton()->StateName( State() )
-             << " --> DataWaitingState for Thread "
-             << ThreadNo() << " " << endl ;
-      State( SUPERV::DataWaitingState ) ;
+    if ( State() == GraphExecutor::SuccessedState ||
+         State() == GraphExecutor::SuspendedSuccessedState ||
+         State() == GraphExecutor::SuspendedSuccessedToReStartState ) {
+//      cdebug << ThreadNo() << " " << FromNodeName
+//             << " : " << Name() << " " << Automaton()->StateName( State() )
+//             << " --> DataWaitingState for Thread "
+//             << ThreadNo() << " " << endl ;
+      State( GraphExecutor::DataWaitingState ) ;
+    }
+// We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode
+    if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) {
+      cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from "
+             << FromNodeName << endl ;
+      _InitLoop = true ;
     }
     LockDataWait() ;
     DataFromNode( FromNodeName ) ;
@@ -1789,7 +2242,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() ;
@@ -1810,7 +2263,7 @@ int GraphExecutor::InNode::Errored_SuspendAction() {
          << " Threads " << _OutNode->Threads() << " SuspendedThreads "
          << _OutNode->SuspendedThreads() << endl;
   _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
-                       SUPERV::SuspendedErroredState ) ; 
+                       GraphExecutor::SuspendedErroredState ) ; 
   DoneAction() ;
   GraphExecutor::InNode * aReStartNode = SuspendAction() ;
   cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
@@ -1829,7 +2282,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 ;
 }
@@ -1838,7 +2291,7 @@ int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
   cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
 //  ResumeAction() ;
   _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
-                       SUPERV::ResumedErroredState ) ; 
+                       GraphExecutor::ResumedErroredState ) ; 
   SendEvent( ResumedErroredEvent ) ;
   return 1 ;
 }
@@ -1846,7 +2299,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 ;
 }
@@ -1854,7 +2307,7 @@ int GraphExecutor::InNode::Successed_KillAction() {
 int GraphExecutor::InNode::Errored_KillAction() {
   KillAction() ;
   _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
-                       SUPERV::KilledErroredState ) ; 
+                       GraphExecutor::KilledErroredState ) ; 
   cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
   return 1 ;
 }
@@ -1862,7 +2315,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 ;
 }
@@ -1870,7 +2323,7 @@ int GraphExecutor::InNode::Successed_StopAction() {
 int GraphExecutor::InNode::Errored_StopAction() {
   StopAction() ;
   _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
-                       SUPERV::StoppedErroredState ) ; 
+                       GraphExecutor::StoppedErroredState ) ; 
   cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
   return 1 ;
 }
@@ -1878,7 +2331,7 @@ 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 ) ;
@@ -1891,7 +2344,7 @@ 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 ) ;
@@ -1905,8 +2358,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 ;
@@ -1925,8 +2378,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 ;
@@ -1941,13 +2394,13 @@ int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
   return 1 ;
 }
 
-void GraphExecutor::InNode::InParametersSet(
-                            bool & Err ,
-                            int  nInParams ,
-                            ServicesAnyData * aListOfInParameters ) {
+void GraphExecutor::InNode::InParametersSet( bool & Err ,
+                                             int  nInParams ,
+                                             ServicesAnyData * InParametersList ) {
   int i ;
+  cdebug << ThreadNo() << " InParametersSet " << Name() << endl ;
   for ( i = 0 ; i < nInParams ; i++ ) {
-    ServicesAnyData D = aListOfInParameters[i];
+    ServicesAnyData D = InParametersList[i];
     GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
     GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
     if ( anInPort->IsGate() && theOutPort == NULL ) {
@@ -1955,50 +2408,147 @@ void GraphExecutor::InNode::InParametersSet(
              << anInPort->GetServicesParameter().Parametertype
              << " is inactive. " << anInPort->Kind() << endl ;
     }
-//    else if ( theOutPort->State() == SUPERV::ReadyState ) {
     else if ( anInPort->State() == SUPERV::ReadyState ) {
       if ( anInPort->IsGate() ) {
         CORBA::Any * anAny = new CORBA::Any() ;
         *anAny <<= (long ) 0 ;
         theOutPort->Value( anAny ) ;
       }
-      anInPort->State( SUPERV::WaitingState ) ;
-//      const CORBA::Any * theValue = theOutPort->Value() ;
+      if ( !anInPort->IsDataStream() &&
+           !anInPort->IsDataConnected() ) {
+        anInPort->State( SUPERV::WaitingState ) ;
+      }
       D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
-//      D.Value = *theValue ; // CORBA::Any
+      cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind()
+             << " " << anInPort->State() ;
+      cdebug << "      " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ;
       D.Value = *theOutPort->Value() ; // CORBA::Any
-      cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
-      cdebug << D.Name << " " << anInPort->GetServicesParameter().Parametertype
-             << " : " ;
       string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
       const char * Type = _Type.c_str() ;
-      switch (D.Value.type()->kind()) {
+      switch ( D.Value.type()->kind() ) { // { string , long , double , objref }
       case CORBA::tk_string:
         char * t;
         D.Value >>= t;
-        cdebug << t << " (string)" << endl ;
+        cdebug << t << " (string)" ;
         if ( !strcmp( Type , "string" ) ) {
         }
-        else if ( !strcmp( Type , "double" ) ) {
-          double d ;
-          sscanf( t , "%lf" , &d ) ;
-          D.Value <<= d ;
-          theOutPort->Value( D.Value ) ;
+        else if ( !strcmp( Type , "boolean" ) ) {
+          bool b ;
+          long d ;
+          sscanf( t , "%ld" , &d ) ;
+          b = (bool ) d ;
+          D.Value <<=  (CORBA::Any::from_boolean ) b ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "char" ) ) {
+          unsigned char c ;
+          long d ;
+          sscanf( t , "%ld" , &d ) ;
+          c = (short ) d ;
+          D.Value <<=  (CORBA::Any::from_char ) c ;
+          cdebug << "string '" << t << "' --> " << d << " --> char " << c ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+        else if ( !strcmp( Type , "short" ) ) {
+          short s ;
+          long d ;
+          sscanf( t , "%ld" , &d ) ;
+          s = (short ) d ;
+          D.Value <<=  s ;
+          cdebug << "string '" << t << "' --> " << d << " --> short " << s ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
           long l ;
           sscanf( t , "%ld" , &l ) ;
           D.Value <<=  l ;
-          theOutPort->Value( D.Value ) ;
+          cdebug << "string '" << t << " --> long " << l ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "float" ) ) {
+          double d ;
+          sscanf( t , "%lf" , &d ) ;
+          float f = d ;
+          D.Value <<= f ;
+          cdebug << "string '" << t << "' --> " << setw(25) << setprecision(18) << d << " --> float " << " = "
+                 << setw(25) << setprecision(18) << f ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "objref" ) ) {
+        else if ( !strcmp( Type , "double" ) ) {
+          double d ;
+          sscanf( t , "%lf" , &d ) ;
+          D.Value <<= d ;
+          cdebug << "string '" << t << " --> double " << setw(25) << setprecision(18) << d ;
+//          theOutPort->Value( D.Value ) ;
+        }
+//        else if ( !strcmp( Type , "objref" ) ) {
+        else { // Default
           CORBA::Object_ptr ObjRef ;
-          ObjRef = StringToObject( t ) ;
-          D.Value <<= ObjRef ;
-          theOutPort->Value( D.Value ) ;
+          try {
+            ObjRef = StringToObject( t ) ;
+            D.Value <<= ObjRef ;
+         }
+          catch( ... ) {
+            D.Value <<= CORBA::Object::_nil() ;
+         }
+//          theOutPort->Value( D.Value ) ;
         }
-        else {
+//        else {
+//          cdebug << " (other ERROR)" << endl ;
+//        }
+        cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
+        break;
+      case CORBA::tk_long:
+        long l;
+        D.Value >>= l;
+        cdebug << l << " (long)" << endl ;
+        if ( !strcmp( Type , "string" ) ) {
+          char t[40] ;
+          sprintf( t , "%ld" , l ) ;
+          D.Value <<= t ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "boolean" ) ) {
+          bool b ;
+          b = (bool ) l ;
+          D.Value <<=  (CORBA::Any::from_boolean ) b ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "char" ) ) {
+          unsigned char c ;
+          c = (unsigned char ) l ;
+          D.Value <<=  (CORBA::Any::from_char ) c ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "short" ) ) {
+          short s ;
+          s = (short ) l ;
+          D.Value <<=  s ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
+        }
+        else if ( !strcmp( Type , "float" ) ) {
+          float f ;
+          f = (float ) l ;
+          D.Value <<= f ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "double" ) ) {
+          double d ;
+          d = (double ) l ;
+          D.Value <<= d ;
+//          theOutPort->Value( D.Value ) ;
         }
+//        else if ( !strcmp( Type , "objref" ) ) {
+        else { // Default
+          D.Value <<= CORBA::Object::_nil() ;
+//          theOutPort->Value( D.Value ) ;
+        }
+//        else {
+//          cdebug << " (other ERROR)" << endl ;
+//        }
+        cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
         break;
       case CORBA::tk_double:
         double d;
@@ -2006,64 +2556,122 @@ void GraphExecutor::InNode::InParametersSet(
         cdebug << d << " (double)" << endl ;
         if ( !strcmp( Type , "string" ) ) {
           char t[40] ;
-          sprintf( t , "lf" , d ) ;
+          sprintf( t , "%lf" , d ) ;
           D.Value <<= t ;
-          theOutPort->Value( D.Value ) ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "double" ) ) {
+        else if ( !strcmp( Type , "boolean" ) ) {
+          bool b ;
+          b = (bool ) d ;
+          D.Value <<=  (CORBA::Any::from_boolean ) b ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+        else if ( !strcmp( Type , "char" ) ) {
+          unsigned char c ;
+          c = (unsigned char ) d ;
+          D.Value <<=  (CORBA::Any::from_char ) c ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "short" ) ) {
+          short s ;
+          s = (short ) d ;
+          D.Value <<=  s ;
+//          theOutPort->Value( D.Value ) ;
+        }
+        else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
           long l ;
           l = (long ) d ;
           D.Value <<= l ;
-          theOutPort->Value( D.Value ) ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "objref" ) ) {
+        else if ( !strcmp( Type , "float" ) ) {
+          float f ;
+          f = (float ) d ;
+          D.Value <<= f ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else {
+        else if ( !strcmp( Type , "double" ) ) {
+        }
+//        else if ( !strcmp( Type , "objref" ) ) {
+        else { // Default
+          D.Value <<= CORBA::Object::_nil() ;
+//          theOutPort->Value( D.Value ) ;
         }
+//        else {
+//          cdebug << " (other ERROR)" << endl ;
+//        }
+        cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
         break;
-      case CORBA::tk_long:
-        long l;
-        D.Value >>= l;
-        cdebug << l << " (long)" << endl ;
+      case CORBA::tk_objref:
         if ( !strcmp( Type , "string" ) ) {
-          char t[40] ;
-          sprintf( t , "lf" , l ) ;
-          D.Value <<= t ;
-          theOutPort->Value( D.Value ) ;
+          CORBA::Object_ptr ObjRef ;
+          char * retstr ;
+          try {
+            D.Value >>= ObjRef ;
+            retstr = ObjectToString( ObjRef ) ;
+            D.Value <<= retstr ;
+//            theOutPort->Value( D.Value ) ;
+          }
+          catch( ... ) {
+            if ( i != 0 ) {
+              Err = true ;
+           }
+            cdebug << "ToString( object ) Catched ERROR" << endl ;
+          }
         }
-        else if ( !strcmp( Type , "double" ) ) {
-          double d ;
-          d = l ;
-          D.Value <<= d ;
-          theOutPort->Value( D.Value ) ;
+        else if ( !strcmp( Type , "boolean" ) ) {
+          bool b = 0 ;
+          D.Value <<=  (CORBA::Any::from_boolean ) b ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+        else if ( !strcmp( Type , "char" ) ) {
+          unsigned char c = 0 ;
+          D.Value <<=  (CORBA::Any::from_char ) c ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else if ( !strcmp( Type , "objref" ) ) {
+        else if ( !strcmp( Type , "short" ) ) {
+          short s = 0 ;
+          D.Value <<=  s ;
+//          theOutPort->Value( D.Value ) ;
         }
-        else {
+        else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
+          long l = 0 ;
+          D.Value <<= l ;
+//          theOutPort->Value( D.Value ) ;
         }
-        break;
-      case CORBA::tk_objref:
-        CORBA::Object_ptr obj ;
-        char * retstr ;
-        try {
-          D.Value >>= obj ;
-//          retstr = _Orb->object_to_string(obj );
-          retstr = ObjectToString( obj ) ;
-          cdebug << retstr << endl ;
+        else if ( !strcmp( Type , "float" ) ) {
+          float f = 0 ;
+          D.Value <<= f ;
+//          theOutPort->Value( D.Value ) ;
         }
-        catch( ... ) {
-          if ( i != 0 ) {
-            Err = true ;
-         }
-          cdebug << "ToString( object ) Catched ERROR" << endl ;
+        else if ( !strcmp( Type , "double" ) ) {
+          double d = 0 ;
+          D.Value <<= d ;
+//          theOutPort->Value( D.Value ) ;
+        }
+//        else if ( !strcmp( Type , "objref" ) ) {
+        else { // Default
+          CORBA::Object_ptr obj ;
+          char * retstr ;
+          try {
+            D.Value >>= obj ;
+            retstr = ObjectToString( obj ) ;
+            cdebug << retstr << endl ;
+          }
+          catch( ... ) {
+            if ( i != 0 ) {
+              Err = true ;
+           }
+            cdebug << "ToString( object ) Catched ERROR" << endl ;
+          }
         }
+//        else {
+//          cdebug << " (other ERROR)" << endl ;
+//        }
+        cdebug << " --> call_kind " << D.Value.type()->kind() << endl ;
         break;
       default:
-        cdebug << " (other ERROR)" << endl ;
+        cdebug << " (other ERROR) " << D.Value.type()->kind() << endl ;
       }
     }
     else {
@@ -2074,209 +2682,360 @@ void GraphExecutor::InNode::InParametersSet(
              << anInPort->GetServicesParameter().Parametername << endl ;
       Err = true ;
     }
-    aListOfInParameters[i] = D ;
+    InParametersList[i] = D ;
   }
 }
 
-void GraphExecutor::InNode::InOutParameters(
-                            int nOutParams ,
-                            ServicesAnyData * aListOfOutParameters ) {
+void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
+                                                ServicesAnyData * OutParametersList ) {
   int i ;
   for ( i = 0 ; i < nOutParams ; i++ ) {
-    ServicesAnyData D = aListOfOutParameters[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 ;
+    cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
+           << OutDone << ") " << Type << " : " << endl ;
     if ( !strcmp( Type , "string" ) ) {
       D.Value <<= (char *) NULL ;
     }
-    else if ( !strcmp( Type , "double" ) ) {
-      D.Value <<= 0. ;
+    else if ( !strcmp( Type , "boolean" ) ) {
+      bool b = 0 ;
+      D.Value <<=  (CORBA::Any::from_boolean ) b ;
+    }
+    else if ( !strcmp( Type , "char" ) ) {
+      unsigned char c = 0 ;
+      D.Value <<=  (CORBA::Any::from_char ) c ;
     }
-    else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+    else if ( !strcmp( Type , "short" ) ) {
+      short s = 0 ;
+      D.Value <<=  s ;
+    }
+    else if ( !strcmp( Type , "int" ) || !strcmp( Type , "long" ) ) {
       D.Value <<= (long ) 0 ;
     }
+    else if ( !strcmp( Type , "float" ) ) {
+      float f = 0 ;
+      D.Value <<= f ;
+    }
+    else if ( !strcmp( Type , "double" ) ) {
+      double d = 0 ;
+      D.Value <<= d ;
+    }
     else {
-      D.Value.replace(CORBA::_tc_Object, NULL);
+      D.Value <<= CORBA::Object::_nil() ;
     }
-//    GetChangeNodeOutPort(i)->Value( D.Value ) ;
-#if 0
-    switch (D.Value.type()->kind()) {
+//#if 0
+    switch (D.Value.type()->kind()) { // { string , long , double , objref }
     case CORBA::tk_string:
       char * t;
       D.Value >>= t;
       cdebug << ThreadNo() << " " << t << "(string)" << endl ;
       break;
-    case CORBA::tk_double:
-      double d;
-      D.Value >>= d;
-      cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+    case CORBA::tk_boolean:
+      bool b ;
+      D.Value >>= (CORBA::Any::to_boolean ) b;
+      cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
+      break;
+    case CORBA::tk_char:
+      unsigned char c ;
+      D.Value >>= (CORBA::Any::to_char ) c;
+      cdebug << ThreadNo() << " " << c << "(char)" << endl ;
+      break;
+    case CORBA::tk_short:
+      short s;
+      D.Value >>= s;
+      cdebug << ThreadNo() << " " << s << "(short)" << endl ;
       break;
     case CORBA::tk_long:
       long l;
       D.Value >>= l;
       cdebug << ThreadNo() << " " << l << "(long)" << endl ;
       break;
+    case CORBA::tk_float:
+      float f;
+      D.Value >>= f;
+      cdebug << ThreadNo() << " " << f << "(float)" << endl ;
+      break;
+    case CORBA::tk_double:
+      double d;
+      D.Value >>= d;
+      cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+      break;
     case CORBA::tk_objref:
-      cdebug << ThreadNo() << " " << "(object)" << endl ;
+      try {
+        CORBA::Object_ptr obj ;
+        char * retstr ;
+        D.Value >>= obj ;
+        retstr = ObjectToString( obj ) ;
+        cdebug << ThreadNo() << retstr << endl ;
+      }
+      catch( ... ) {
+        cdebug << "ToString( object ) Catched ERROR" << endl ;
+      }
       break;
     default:
       cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
     }
-#endif
-    aListOfOutParameters[i] = D ;
+//#endif
+    OutParametersList[i] = D ;
   }
 }
 
-bool GraphExecutor::InNode::OutParameters(
-                            bool Err ,
-                            SUPERV::GraphState NewState ,
-                            int nOutParams ,
-                            ServicesAnyData * aListOfOutParameters ) {
+bool GraphExecutor::InNode::OutParametersSet( bool Err ,
+                                              SUPERV::GraphState NewState ,
+                                              int nOutParams ,
+                                              ServicesAnyData * OutParametersList ) {
   bool RetVal = true ;
   int i ;
   GraphBase::OutPort * aGateOutPort = NULL ;
   bool OrSwitch = false ;
-  GraphBase::OutPort * anOutPort = GetChangeNodeOutPort(0) ;
-  for ( i = 0 ; i < nOutParams ; i++ ) {
-    anOutPort = GetChangeNodeOutPort(i) ;
-    if ( Err ) {
-      anOutPort->State( NewState ) ;
-      anOutPort->Done( true ) ;
-    }
-    else {
-      cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
-             << anOutPort->PortName() << " " << anOutPort->Kind() ;
-      if ( anOutPort->IsGate() ) {
-        aGateOutPort = anOutPort ;
-        cdebug << " Gate " ;
-        long l = 1;
-        aListOfOutParameters[i].Value <<= l;
-        anOutPort->Value( aListOfOutParameters[i].Value );
-      }
-      else if ( anOutPort->IsLoop() ) {
-        cdebug << " Loop " ;
-        anOutPort->Value( aListOfOutParameters[i].Value );
-// InLoop Port of EndLoopNode is ready :
-        anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
-      }
-      else if ( anOutPort->IsSwitch() ) {
-        cdebug << " Switch " ;
-        anOutPort->Value( aListOfOutParameters[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 ;
-//            RetVal = false ;
-         }
-          else {
-            OrSwitch = OrSwitch | anOutPort->BoolValue() ;
-         }
-       }
-        cdebug << "OrSwitch " << OrSwitch ;
+  cdebug << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " << NewState << endl ;
+//  cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " << NewState << endl ;
+  if ( nOutParams && !IsMacroNode() ) {
+    GraphBase::OutPort * anOutPort ;
+    for ( i = 0 ; i < nOutParams ; i++ ) {
+      anOutPort = GetChangeNodeOutPort(i) ;
+      if ( Err ) {
+        anOutPort->State( NewState ) ;
+        anOutPort->Done( true ) ;
       }
       else {
-        cdebug << " Param " ;
-        anOutPort->Value( aListOfOutParameters[i].Value );
-      }
-//      else if ( anOutPort->IsBus() ) {
-//        cdebug << " Bus " ;
-//        anOutPort->Value( GetNodeInPort( anOutPort->PortIndex() )->GetOutPort()->Value() );
-//      }
-      anOutPort->State( NewState ) ;
-      anOutPort->Done( true ) ;
-      int j ;
-      for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
-        bool fromGOTO = false ;
-        GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInPort( 0 )->GetOutPort() ;
-        if ( aGOTOPort ) {
-          fromGOTO = aGOTOPort->IsGOTO() ;
+        cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
+               << anOutPort->PortName() << " " << anOutPort->Kind() ;
+        ServicesAnyData D = OutParametersList[i] ;
+        switch (D.Value.type()->kind()) { // { string , long , double , objref }
+        case CORBA::tk_string: {
+          char * t;
+          D.Value >>= t;
+          cdebug << ThreadNo() << " " << t << "(string)" << endl ;
+          break;
        }
-        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 ) ;
+        case CORBA::tk_boolean: {
+          bool b ;
+          D.Value >>= (CORBA::Any::to_boolean ) b;
+          long l = (long ) b ;
+          D.Value <<= l ;
+          cdebug << ThreadNo() << " " << b << "(boolean)" << endl ;
+          break;
        }
-        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 ;
+        case CORBA::tk_char: {
+          unsigned char c ;
+          D.Value >>= (CORBA::Any::to_char ) c;
+          long l = (long ) c ;
+          D.Value <<= l ;
+          cdebug << ThreadNo() << " " << c << "(char)" << endl ;
+          break;
        }
-      }
-#if 0
-      switch (anOutPort->Value()->type()->kind()) {
-      case CORBA::tk_string:
-        char * t;
-        (*anOutPort->Value()) >>= t;
-        cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
-        break;
-      case CORBA::tk_double:
-        double d;
-        (*anOutPort->Value()) >>= d;
-        cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
-        break;
-      case CORBA::tk_long:
-        long l;
-        (*anOutPort->Value()) >>= l;
-        cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
-        break;
-      case CORBA::tk_objref:
-        CORBA::Object_ptr obj ;
-        char * retstr ;
-        try {
-          (*anOutPort->Value()) >>= obj ;
-          retstr = _Orb->object_to_string(obj );
-          cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
-                 << retstr << endl ;
+        case CORBA::tk_short: {
+          short s;
+          D.Value >>= s;
+          long l = (long ) s ;
+          D.Value <<= l ;
+          cdebug << ThreadNo() << " " << s << "(short)" << endl ;
+          break;
        }
-        catch ( ... ) {
-          cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
-                 << "Catched ERROR" << endl ;
+        case CORBA::tk_long: {
+          long l;
+          D.Value >>= l;
+          cdebug << ThreadNo() << " " << l << "(long)" << endl ;
+          break;
        }
-        break;
-      default:
-        cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
-        RetVal = false ;
+        case CORBA::tk_float: {
+          float f;
+          D.Value >>= f;
+          double d = (double ) f ;
+          D.Value <<= d ;
+          cdebug << ThreadNo() << " " << f << "(float)" << endl ;
+          break;
+       }
+        case CORBA::tk_double: {
+          double d;
+          D.Value >>= d;
+          cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+          break;
+       }
+        case CORBA::tk_objref: {
+          try {
+            CORBA::Object_ptr obj ;
+            char * retstr ;
+            D.Value >>= obj ;
+            retstr = ObjectToString( obj ) ;
+            cdebug << ThreadNo() << retstr << endl ;
+          }
+          catch( ... ) {
+            cdebug << "ToString( object ) Catched ERROR" << endl ;
+          }
+          break;
+       }
+        default: {
+          cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
+       }
+        }
+        OutParametersList[i] = D ;
+        if ( !anOutPort->IsDataStream() ) {
+          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 );
+// 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 ) ;
+       }
+        int j ;
+        for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+          bool fromGOTO = false ;
+          const char * ToNodeName = anOutPort->ChangeInPorts( j )->NodeName() ;
+          if ( !strcmp( ToNodeName , _OutNode->Graph()->Name() ) && _OutNode->Graph()->GraphMacroLevel() != 0 ) {
+            cdebug << "OutParametersSet ToNodeName " << _OutNode->Graph()->Name() << " CoupledNode "
+                   << _OutNode->Graph()->CoupledNodeName() << _OutNode->Graph()->CoupledNode()
+                   << endl ;
+            cdebug << " GraphExecutor " << _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor() << endl ;
+            _OutNode->Graph()->CoupledNode()->GraphEditor()->Executor()->OutputOfAny( _OutNode->Graph()->CoupledNodeName() ,
+                                                                            anOutPort->ChangeInPorts( j )->PortName() ,
+                                                                            *anOutPort->Value() ) ;
+         }
+          else {
+           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 ) {
+                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 ) ;
+             }
+              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 ;
+             }
+           }
+         }
+        }
+//#if 0
+        switch (anOutPort->Value()->type()->kind()) {
+        case CORBA::tk_string:
+          char * 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;
+          cdebug << ThreadNo() << " Out" << i << " : " << b << "(boolean)" << endl ;
+          break;
+        case CORBA::tk_char:
+          unsigned 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;
+          cdebug << ThreadNo() << " Out" << i << " : " << s << "(short)" << endl ;
+          break;
+        case CORBA::tk_long:
+          long l;
+          (*anOutPort->Value()) >>= l;
+          cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
+          break;
+        case CORBA::tk_float:
+          float f;
+          (*anOutPort->Value()) >>= f;
+          cdebug << ThreadNo() << " Out" << i << " : " << f << "(float)" << endl ;
+          break;
+        case CORBA::tk_double:
+          double 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 ;
+            retstr = ObjectToString( obj );
+            cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
+                   << retstr << endl ;
+         }
+          catch ( ... ) {
+            cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
+                   << "Catched ERROR" << endl ;
+         }
+          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() ;
-      long l = 0;
-      aListOfOutParameters[0].Value <<= l ;
-      aGateOutPort->Value( aListOfOutParameters[0].Value ) ;
     }
-    else {
-      cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
-             << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
-      long l = 1;
-      aListOfOutParameters[0].Value <<= l ;
-      aGateOutPort->Value( aListOfOutParameters[0].Value ) ;
-      int i ;
-      for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
-        GraphBase::InPort * anInPort ;
-        anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
-        if ( anInPort ) {
-          anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
-       }
+    if ( aGateOutPort && IsSwitchNode() ) {
+      if ( OrSwitch ) {
+//        cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
+//               << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+        long l = 0;
+        OutParametersList[0].Value <<= l ;
+        aGateOutPort->Value( OutParametersList[0].Value ) ;
+      }
+      else {
+//        cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
+//               << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+        long l = 1;
+        OutParametersList[0].Value <<= l ;
+        aGateOutPort->Value( OutParametersList[0].Value ) ;
+        int i ;
+        for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+          GraphBase::InPort * anInPort ;
+          anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
+          if ( anInPort ) {
+            anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
+         }
+        }
       }
     }
   }