Salome HOME
InitLoop and DoLoop parameters names
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.cxx
index 5f30b8901841630a503e8f998cddce7f49dfb6da..2a92e6c76a13ece8a7fafa2d47fbacaed3859d61 100644 (file)
@@ -1,33 +1,59 @@
+//  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_OutNode.cxx
+//  Author : Jean Rahuel, CEA
+//  Module : SUPERV
+//  $Header:
+
 using namespace std;
-//=============================================================================
-// File      : DataFlowBase_OutNode.cxx
-// Created   : 2002
-// Author    : Jean Rahuel, CEA
-// Project   : SALOME
-// $Header:
-//=============================================================================
 
 #include "DataFlowExecutor_OutNode.hxx"
 
-// Implementation de la classe GraphEditor::GraphControl
+#include "DataFlowEditor_DataFlow.hxx"
+
+extern Engines_Container_i * _TheContainer ;
 
 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
 
-static const char *ComponentName = "SalomeSuperVisionComponent" ;
+// static const char *ComponentName = "SalomeSuperVisionComponent" ;
 
 extern int _ArgC ;
 extern char ** _ArgV ;
 
-GraphExecutor::OutNode::OutNode() :
-               Graph() {
+GraphExecutor::OutNode::OutNode() {
+//               Graph() {
+  _SuperVisionContainer = _TheContainer ;
+  _MainThreadId = SuperVisionContainer()->MainThreadId() ;
   _Valid = false ;
   _Executable = false ;
   _Done = false ;
   _Threads = 0 ;
   _ControlState = SUPERV::VoidState ;
-  _State = SUPERV::UnKnownState ;
+  _State = GraphExecutor::UnKnownState ;
   _PyInitialized = false ;
   pthread_mutex_init( &_MutexWait , NULL ) ;
+  pthread_mutex_init( &_PyMutexWait , NULL ) ;
   if ( pthread_cond_init( &_EventWait , NULL ) ) {
     perror("pthread_cond_init( &_EventWait , NULL )") ;
     exit( 0 ) ;
@@ -41,18 +67,35 @@ GraphExecutor::OutNode::OutNode() :
 GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, 
                                 SALOME_NamingService* ptrNamingService ,
                                  const char *DataFlowName ,
-                                 const char * DebugFileName ) :
-               Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
-  cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << ")" << endl;
+                                 const char * DebugFileName ,
+                                 const SUPERV::KindOfNode aKindOfNode ) {
+//               Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
+  Set_prof_debug( ORB , DebugFileName ) ;
+  cdebug_in << "GraphExecutor::OutNode::OutNode(" << DataFlowName << " , " << aKindOfNode << ")" << endl;
+  if ( aKindOfNode == SUPERV::DataFlowGraph ) {
+    _StreamGraph = NULL ;
+//    _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;
+    _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
+                                   _prof_debug , _fdebug ) ;
+  }
+  else if ( aKindOfNode == SUPERV::DataStreamGraph ) {
+//    _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;;
+    _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , aKindOfNode ,
+                                               _prof_debug , _fdebug ) ;
+    _Graph = _StreamGraph ;
+  }
+  _SuperVisionContainer = _TheContainer ;
+  _MainThreadId = SuperVisionContainer()->MainThreadId() ;
   _Valid = false ;
   _Executable = false ;
   _Done = false ;
   _Threads = 0 ;
   _ControlState = SUPERV::VoidState ;
-  _State = SUPERV::UnKnownState ;
+  _State = GraphExecutor::UnKnownState ;
   _PyInitialized = false ;
   _Orb = CORBA::ORB::_duplicate( ORB ) ;
   pthread_mutex_init( &_MutexWait , NULL ) ;
+  pthread_mutex_init( &_PyMutexWait , NULL ) ;
   if ( pthread_cond_init( &_EventWait , NULL ) ) {
     perror("pthread_cond_init( &_EventWait , NULL )") ;
     exit( 0 ) ;
@@ -61,38 +104,62 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB,
     perror("pthread_cond_init( &_JoinWait , NULL )") ;
     exit( 0 ) ;
   }
-  cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
-}
-
-GraphExecutor::OutNode::OutNode(
-               CORBA::ORB_ptr ORB, 
-              SALOME_NamingService* ptrNamingService ,
-               const SALOME_ModuleCatalog::Service& DataFlowService ,
-               const char *DataFlowComponentName ,
-               const char *DataFlowInterfaceName ,
-               const char *DataFlowName ,
-               const SUPERV::KindOfNode DataFlowkind ,
-               const SUPERV::SDate DataFlowFirstCreation ,
-               const SUPERV::SDate DataFlowLastModification ,
-               const char * DataFlowEditorRelease ,
-               const char * DataFlowAuthor ,
-               const char * DataFlowComputer ,
-               const char * DataFlowComment ,
-               const char * DebugFileName ) :
-               Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
-                      DataFlowInterfaceName , DataFlowName , DataFlowkind ,
-                      DataFlowFirstCreation , DataFlowLastModification  ,
-                      DataFlowEditorRelease , DataFlowAuthor ,
-                      DataFlowComputer , DataFlowComment , DebugFileName ) {
+  cdebug_out << "GraphExecutor::OutNode::OutNode" << endl;
+}
+
+GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, 
+                                SALOME_NamingService* ptrNamingService ,
+                                 const SALOME_ModuleCatalog::Service& DataFlowService ,
+                                 const char *DataFlowComponentName ,
+                                 const char *DataFlowInterfaceName ,
+                                 const char *DataFlowName ,
+                                 const SUPERV::KindOfNode DataFlowkind ,
+                                 const SUPERV::SDate DataFlowFirstCreation ,
+                                 const SUPERV::SDate DataFlowLastModification ,
+                                 const char * DataFlowEditorRelease ,
+                                 const char * DataFlowAuthor ,
+                                 const char * DataFlowComputer ,
+                                 const char * DataFlowComment ,
+                                 const char * DebugFileName ) {
+//                                 Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
+//                                        DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+//                                        DataFlowFirstCreation , DataFlowLastModification  ,
+//                                        DataFlowEditorRelease , DataFlowAuthor ,
+//                                        DataFlowComputer , DataFlowComment , DebugFileName ) {
+  Set_prof_debug( ORB , DebugFileName ) ;
+
+  cdebug_in << "GraphExecutor::OutNode::OutNode(" << DataFlowName << " , " << DataFlowkind << ")" << endl;
+  if ( DataFlowkind == SUPERV::DataFlowGraph ) {
+    _StreamGraph = NULL ;
+    _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
+                                   DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+                                   DataFlowFirstCreation , DataFlowLastModification  ,
+                                   DataFlowEditorRelease , DataFlowAuthor ,
+                                   DataFlowComputer , DataFlowComment ,
+                                   _prof_debug , _fdebug ) ;
+//                                   DataFlowComputer , DataFlowComment , DebugFileName ) ;
+  }
+  else if ( DataFlowkind == SUPERV::DataStreamGraph ) {
+    _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
+                                               DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+                                               DataFlowFirstCreation , DataFlowLastModification  ,
+                                               DataFlowEditorRelease , DataFlowAuthor ,
+                                               DataFlowComputer , DataFlowComment ,
+                                               _prof_debug , _fdebug ) ;
+    _Graph = _StreamGraph ;
+  }
+  _SuperVisionContainer = _TheContainer ;
+  _MainThreadId = SuperVisionContainer()->MainThreadId() ;
   _Valid = false ;
   _Executable = false ;
   _Done = false ;
   _Threads = 0 ;
   _ControlState = SUPERV::VoidState ;
-  _State = SUPERV::UnKnownState ;
+  _State = GraphExecutor::UnKnownState ;
   _PyInitialized = false ;
   _Orb = CORBA::ORB::_duplicate( ORB ) ;
   pthread_mutex_init( &_MutexWait , NULL ) ;
+  pthread_mutex_init( &_PyMutexWait , NULL ) ;
   if ( pthread_cond_init( &_EventWait , NULL ) ) {
     perror("pthread_cond_init( &_EventWait , NULL )") ;
     exit( 0 ) ;
@@ -106,18 +173,29 @@ GraphExecutor::OutNode::OutNode(
 GraphExecutor::OutNode::~OutNode() {
 }
 
-bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) {
+void GraphExecutor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB ,
+                                             const char * DebugFileName ) {
+  _Graph_prof_debug = 0 ;
+  if ( DebugFileName ) {
+    _fdebug = new ofstream( DebugFileName );
+    SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ;
+    MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
+  }
+}
+
+bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph * aDataFlow ) {
   bool RetVal = false ;
-  RetVal = LoadInfo( aDataFlow.Info ) ;
-  if ( GraphBase::Service::ServiceName() != NULL ) {
+  cdebug_in << "GraphExecutor::OutNode::LoadDataFlow " << (*aDataFlow).Info.theName << endl ;
+  RetVal = LoadInfo( (*aDataFlow).Info ) ;
+  if ( Graph()->ServiceName() != NULL ) {
 //    MESSAGE( "GraphExecutor::OutNode::LoadDataFlow" );
     if ( RetVal ) {
-      RetVal = LoadNodes( aDataFlow.Nodes ) ;
+      RetVal = LoadNodes( (*aDataFlow).Nodes ) ;
       if ( RetVal ) {
-        RetVal = LoadLinks( aDataFlow.Links ) ;
+        RetVal = LoadLinks( (*aDataFlow).Links ) ;
         if ( RetVal ) {
           IsValid() ;
-          RetVal = LoadDatas( aDataFlow.Datas ) ;
+          RetVal = LoadDatas( (*aDataFlow).Datas ) ;
           IsExecutable() ;
           if ( !RetVal) {
             cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error."
@@ -142,43 +220,50 @@ bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) {
   else {
     cdebug << "GraphExecutor::OutNode::LoadDataFlow ServiceName Error." << endl ;
   }
+  cdebug_out << "GraphExecutor::OutNode::LoadDataFlow " << Graph()->Name() << " RetVal "
+             << RetVal << endl ;
   return RetVal ;
 }
 
+#if 0
 bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) {
   bool RetVal = false ;
-  GraphBase::SGraph aDataFlow ;
-  if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) {
-    RetVal = LoadDataFlow( aDataFlow ) ;
+  GraphBase::ListOfSGraphs aListOfDataFlows ;
+  if ( Graph()->LoadXml( _Orb , myFileName , aListOfDataFlows ) ) {
+    RetVal = LoadDataFlow( aListOfDataFlows ) ;
 //    if ( aConstructor && RetVal )
 //      RetVal = Name( aDataFlow.Info.theName.c_str() ) ;
   }
   return RetVal ;
-} 
+}
+#endif
 
 bool GraphExecutor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
-  cdebug << "GraphExecutor::OutNode::LoadInfo" << endl ;
+  cdebug << "GraphExecutor::OutNode::LoadInfo _StreamGraph " << _StreamGraph << endl ;
 //  ComponentName( aDataFlowInfo.theComponentName.c_str()  ) ;
-  Name( aDataFlowInfo.theName.c_str()  ) ;
-  Kind( aDataFlowInfo.theKind ) ;
-  DataService( _Orb , aDataFlowInfo.theService , Graph_prof_debug() , Graph_fdebug() ) ;
-  FirstCreation( aDataFlowInfo.theFirstCreation ) ;
-  LastModification( aDataFlowInfo.theLastModification ) ;
-  EditorRelease( aDataFlowInfo.theEditorRelease.c_str()  ) ;
-  Author( aDataFlowInfo.theAuthor.c_str()   ) ;
-//  Computer( aDataFlowInfo.theContainer.c_str()  ) ;
-  Comment( aDataFlowInfo.theComment.c_str()  ) ;
+  Graph()->Name( aDataFlowInfo.theName.c_str()  ) ;
+  Graph()->Kind( aDataFlowInfo.theKind ) ;
+  if ( Graph()->IsDataStreamNode() && aDataFlowInfo.theKind == SUPERV::DataStreamGraph ) {
+    StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ;
+  }
+  Graph()->DataService( _Orb , aDataFlowInfo.theService , _prof_debug , _fdebug ) ;
+  Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ;
+  Graph()->LastModification( aDataFlowInfo.theLastModification ) ;
+  Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str()  ) ;
+  Graph()->Author( aDataFlowInfo.theAuthor.c_str()   ) ;
+//  Graph()->Computer( aDataFlowInfo.theContainer.c_str()  ) ;
+  Graph()->Comment( aDataFlowInfo.theComment.c_str()  ) ;
 // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
-//  Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
+//  Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
   return true ;
 }
 
-bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNodes ) {
+bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfSNodes &aListOfNodes ) {
   bool RetVal = true ;
   GraphExecutor::InNode * anInNode ;
   cdebug << "GraphExecutor::OutNode::LoadNodes" << endl ;
   int i ;
-  for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
+  for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
     GraphBase::SNode aNode = aListOfNodes[ i ] ;
     anInNode = AddNode( aNode.theService ,
                         aNode.theListOfFuncName ,
@@ -195,101 +280,123 @@ bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNode
       RetVal = false ;
       break ;
     }
-    if ( anInNode->IsOneOfInLineNodes() ) {
+    if ( anInNode->IsOneOfInLineNodes() || anInNode->IsMacroNode() ) {
       anInNode->GraphExecutor::InNode::InLineNode()->DefPortsOfNode(
                                 _Orb , aNode.theService , anInNode->NamePtr() ,
                                 anInNode->Kind() ,
-                                Graph_prof_debug() , Graph_fdebug() ) ;
-#if 0
-      GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
-      GraphBase::LoopNode * aLNode = NULL ;
-      if ( aINode->IsLoopNode() ) {
-        aLNode = anInNode->LoopNode() ;
-        aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
-                                   *aNode.theListOfPythonFunctions[ 0 ] ) ;
-        aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
-                                       *aNode.theListOfPythonFunctions[ 1 ] ) ;
-        aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
-                                       *aNode.theListOfPythonFunctions[ 2 ] ) ;
-      }
-      else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
-                aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
-        aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
-                                   *aNode.theListOfPythonFunctions[ 0 ] ) ;
-      }
-#endif
+                                _prof_debug , _fdebug ) ;
     }
-#if 0
-    if ( aNode.theListOfParameters.size() ) { // BusPorts ...
-      int j ;
-      for ( j = 0 ; j < aNode.theListOfParameters.size() ; j++ ) {
-        GraphBase::InPort * InputPort = anInNode->AddInPort(
-               aNode.theListOfParameters[ j ].theInParameter.Parametername ,
-               aNode.theListOfParameters[ j ].theInParameter.Parametertype ) ;
-        GraphBase::OutPort * OutputPort = anInNode->AddOutPort(
-               aNode.theListOfParameters[ j ].theOutParameter.Parametername ,
-               aNode.theListOfParameters[ j ].theOutParameter.Parametertype ) ;
-        anInNode->InOutPort( InputPort , OutputPort ) ;
-      }
+//    GraphBase::ComputingNode * theNode = Graph()->GetChangeGraphNode( aNode.theName.c_str() ) ;
+
+    unsigned int j ;
+    for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) {
+      GraphBase::InPort * anInPort ;
+      anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ,
+                                                                 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype ,
+                                                                 aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
+                                                                 SUPERV::DataStreamParameter ) ;
+      ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema ,
+                                                              aNode.theListOfInDataStreams[ j ].theKindOfInterpolation ,
+                                                              aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ;
     }
-#endif
-  }
-  for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
+    for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) {
+      GraphBase::OutPort * anOutPort ;
+      anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ,
+                                                                   aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype ,
+                                                                   aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ,
+                                                                   SUPERV::DataStreamParameter ) ;
+      ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ;
+    }
+
+
+//    theNode->DataStreamInPortsNumber( aNode.theDataStreamInArgsNumber ) ;
+//    theNode->DataStreamOutPortsNumber( aNode.theDataStreamOutArgsNumber ) ;
+//    cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
+//           << " InPortsSize " << theNode->GetNodeInPortsSize()
+//           << " OutPortsSize " << theNode->GetNodeOutPortsSize()
+//           << " DataStreamInPortsNumber " << aNode.theDataStreamInArgsNumber
+//           << " DataStreamOutPortsNumber " << aNode.theDataStreamOutArgsNumber
+//           << endl ;
+//    int j ;
+//    if ( aNode.theDataStreamInArgsNumber ) { // -1 because of Gates
+//      for ( j = theNode->GetNodeInPortsSize() - aNode.theDataStreamInArgsNumber - 1 ; j < theNode->GetNodeInPortsSize() - 1 ; j++ ) {
+//        cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
+//               << " InPort " << theNode->GetChangeNodeInPort( j )->PortName()
+//               << " Kind( DataStreamParameter)" << endl ;
+//        theNode->GetChangeNodeInPort( j )->Kind( SUPERV::DataStreamParameter ) ;
+//      }
+//    }
+//    if ( aNode.theDataStreamOutArgsNumber ) {
+//      int withgate = 1 ;
+//      if ( theNode->IsLoopNode() || theNode->IsEndLoopNode() ) {
+//        withgate = 0 ;
+//      }
+//      for ( j = theNode->GetNodeOutPortsSize() - aNode.theDataStreamOutArgsNumber - withgate ; j < theNode->GetNodeOutPortsSize() - withgate ; j++ ) {
+//        cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name()
+//               << " OutPort " << theNode->GetChangeNodeOutPort( j )->PortName()
+//               << " Kind( DataStreamParameter)" << endl ;
+//        theNode->GetChangeNodeOutPort( j )->Kind( SUPERV::DataStreamParameter ) ;
+//      }
+//    }
+  }
+  for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) {
     GraphBase::SNode aNode = aListOfNodes[ i ] ;
-    anInNode = (GraphExecutor::InNode * ) GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
-    cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() << "IsOneOfGOTONodes "
+    anInNode = (GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
+    cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() << " IsOneOfGOTONodes "
            << anInNode->IsOneOfGOTONodes() << " " << aNode.theCoupledNode.c_str() << endl ;
     if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
       GraphBase::GOTONode * aCoupledNode ;
-      aCoupledNode = (GraphBase::GOTONode * ) GetGraphNode( aNode.theName.c_str() ) ;
-      aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ; 
+      aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ;
+      GraphBase::GOTONode * aCoupledCoupledNode ;
+      aCoupledCoupledNode = (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ;
+      if ( aCoupledCoupledNode != NULL ) {
+        aCoupledNode->CoupledNode( aCoupledCoupledNode ) ;
+      }
+      else {
+        aCoupledNode->CoupledNodeName( aNode.theCoupledNode.c_str() ) ;
+      }
     }
   }
   return RetVal ;
 }
 
-bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfLinks &aListOfLinks ) {
+bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfSLinks &aListOfLinks ) {
   bool RetVal = true ;
   cdebug << "GraphExecutor::OutNode::LoadLinks " << aListOfLinks.size()
          << endl ;
   int i ;
-  for ( i = 0 ; i < aListOfLinks.size() ; i++ ) {
+  for ( i = 0 ; i < (int ) aListOfLinks.size() ; i++ ) {
     GraphBase::SLink aLink = aListOfLinks[ i ] ;
-    RetVal = AddLink( aLink.FromNodeName.c_str() ,
-                      aLink.FromServiceParameterName.c_str() ,
-                      aLink.ToNodeName.c_str() ,
-                      aLink.ToServiceParameterName.c_str() ,
-                      aLink.aLinkValue ) ;
-//                      aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
+    RetVal = Graph()->AddLink( aLink.FromNodeName.c_str() ,
+                               aLink.FromServiceParameterName.c_str() ,
+                               aLink.ToNodeName.c_str() ,
+                               aLink.ToServiceParameterName.c_str() ) ;
+//                               , aLink.aLinkValue ) ;
     if ( !RetVal )
       break ;
   }
   return RetVal ;
 }
 
-bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfLinks &aListOfDatas ) {
+bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfSLinks &aListOfDatas ) {
   bool RetVal = true ;
   cdebug << "GraphExecutor::OutNode::LoadDatas " << aListOfDatas.size()
          << endl ;
   int i ;
-  for ( i = 0 ; i < aListOfDatas.size() ; i++ ) {
+  for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) {
     GraphBase::SLink aLink = aListOfDatas[ i ] ;
-    if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) )
-      RetVal = GraphBase::Graph::AddInputData( aLink.ToNodeName.c_str() ,
-                                               aLink.ToServiceParameterName.c_str() ,
-                                               aLink.aLinkValue ) ;
-//                        aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
-    else if ( !strcmp( aLink.ToNodeName.c_str() , Name() ) ) {
-      RetVal = AddOutputData( aLink.FromNodeName.c_str() ,
-                              aLink.FromServiceParameterName.c_str() ,
-                              aLink.aLinkValue ) ;
-//                              aLink.aLinkValue.Value ,
-//                              aLink.aLinkValue.Kind ) ;
-      AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
-    }
+    if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) )
+      RetVal = Graph()->AddInputData( aLink.ToNodeName.c_str() ,
+                                      aLink.ToServiceParameterName.c_str() ,
+                                      aLink.aLinkValue ) ;
+//    else if ( !strcmp( aLink.ToNodeName.c_str() , Graph()->Name() ) ) {
+//      RetVal = Graph()->AddOutputData( aLink.FromNodeName.c_str() ,
+//                                       aLink.FromServiceParameterName.c_str() ) ;
+//      Graph()->AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
+//    }
     else {
       cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName
-           << " and " << aLink.ToNodeName << " differents from " << Name()
+           << " and " << aLink.ToNodeName << " differents from " << Graph()->Name()
            << endl ;
       RetVal = false ;
     }
@@ -318,34 +425,20 @@ GraphExecutor::InNode *GraphExecutor::OutNode::AddNode(
   cdebug_in << "GraphExecutor::OutNode::AddNode(" << NodeComponentName << " , "
             << NodeName << ")" << endl;
   GraphExecutor::InNode *Nd = NULL ;
-  Nd = new GraphExecutor::InNode( _Orb, NamingService() , NodeService ,
+  Nd = new GraphExecutor::InNode( _Orb, Graph()->NamingService() , NodeService ,
                                   NodeComponentName , NodeInterfaceName ,
                                   NodeName , NodeKindOfNode ,
                                   aFuncName , aPythonFunction ,
                                   NodeFirstCreation , NodeLastModification ,
                                   NodeEditorRelease , NodeAuthor ,
                                   NodeComputer , NodeComment , false , NodeX , NodeY ,
-                                  Graph_prof_debug() , Graph_fdebug() ) ;
-  GraphBase::Graph::AddNode( Nd->ComputingNode() ) ;
+                                  _prof_debug , _fdebug ) ;
+  Graph()->AddNode( Nd->ComputingNode() ) ;
   cdebug_out << "GraphExecutor::OutNode::AddNode" << endl;
   return Nd ;
 }
 
 
-bool GraphExecutor::OutNode::AddInputData( const char* ToNodeName1 ,
-                                           const char* ToParameterName1 ,
-                                           const char* ToNodeName2 ,
-                                           const char* ToParameterName2 ) {
-  cdebug_in << "GraphExecutor::OutNode::AddInputData" << endl;
-  bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 ,
-                                                ToParameterName1 ,
-                                                ToNodeName2 ,
-                                                ToParameterName2 ) ;
-  cdebug_out << "GraphExecutor::OutNode::AddInputData" << endl;
-  _Valid = false ;
-  return RetVal ;
-}
-
 bool GraphExecutor::OutNode::Valid() {
   cdebug_in << "GraphExecutor::OutNode::Valid" << endl;
 
@@ -354,18 +447,28 @@ bool GraphExecutor::OutNode::Valid() {
 
   _Executable = false ;
 
-  CreateService() ;
-
-  if ( !Sort() ) {
-    cdebug << "This DataFlow is not valid." << endl ;
+  if ( !Graph()->CreateService() ) {
+    cdebug_out << "This DataFlow has invalid type(s)." << endl ;
+    return false ;
+  }
+  int SubStreamGraphsNumber = 0 ;
+  if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
+    cdebug_out << "This DataFlow is not valid." << endl ;
+    return false ;
+  }
+  if ( Graph()->IsDataStreamNode() ) {
+    StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
+  }
+  if ( !Graph()->ValidLoops() ) {
+    cdebug_out << "This DataFlow have not valid Loops." << endl ;
     return false ;
   }
 
 //  CreateService() ;
 
-  InLineServices() ;
+  Graph()->InLineServices() ;
 
-  ComputingNodes() ;
+  Graph()->ComputingNodes() ;
   
   _Valid = true ;
 
@@ -380,141 +483,203 @@ bool GraphExecutor::OutNode::Executable() {
   if ( !IsValid() )
     return false ;
 
-  if ( DataServerNodes() )
+  if ( Graph()->DataServerNodes() )
     _Executable = true ;
   else {
     cdebug << "This DataFlow is not executable." << endl ;
     _Executable = false ;
   }
 
-  cdebug_out << "GraphExecutor::OutNode::Executable" << endl;
+  cdebug_out << "GraphExecutor::OutNode::Executable " << _Executable << endl;
   return _Executable ;
 }
 
 bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
   bool RetVal = false ;
-  cdebug_in << "GraphExecutor::OutNode::Run" << endl;
+  cdebug_in << pthread_self() << "GraphExecutor::OutNode::Run( AndSuspend " << AndSuspend << " )"
+            << endl;
 
   if ( Executable() ) {
     _ControlState = SUPERV::VoidState ;
     _SuspendedThreads = 0 ;
-    ThreadNo( pthread_self() ) ;
+    Graph()->ThreadNo( pthread_self() ) ;
     Done( false ) ;
     _JustStarted = true ;
+    RetVal = true ;
     int i ;
-    for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
-      GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) GraphNodes( i )->GetInNode() ;
+    for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+      GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
+      anInNode->OutNode( this ) ;
+// Initialize in python interpretor the python functions
       if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) {
         if ( !Py_IsInitialized() ) {
+//          PyEval_InitThreads() ;
 //          Py_Initialize() ;
-          PySys_SetArgv( _ArgC , _ArgV ) ;
+//          PySys_SetArgv( _ArgC , _ArgV ) ;
        }
         anInNode->InitPython() ;
         PyInitialized( true ) ;
       }
-      anInNode->InitialState( this ) ;
+      anInNode->InitialState() ;
+      if ( anInNode->IsOneOfInLineNodes() ) {
+        anInNode->InitPythonFunctions( false ) ;
+      }
     }
-
-    cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
-           << Name() << endl ;
-
-    PushEvent( NULL , GraphExecutor::ReadyEvent ,
-               SUPERV::DataReadyState ) ; 
-    State( SUPERV::DataReadyState ) ;
-
-    for ( i = 0 ; i < HeadNodesSize() ; i++ ) {
-      GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) HeadNodes( i )->GetInNode() ;
-      if ( anInNode->State() != SUPERV::DataReadyState ) {
-        cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
-             << anInNode->Name() << " : " << anInNode->State() << endl ;
-        return false ;
+// One more time because inline nodes may share one definition of the same function
+    for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+      GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
+      if ( anInNode->IsOneOfInLineNodes() ) {
+        if ( !anInNode->InitPythonFunctions( true ) ) {
+          anInNode->State( GraphExecutor::ErroredState ) ;
+          State( GraphExecutor::ErroredState ) ;
+          cdebug_out << "GraphExecutor::OutNode::Run InitPythonFunctions ERROR "
+                     << anInNode->Name() << endl ;
+          return false ;
+       }
       }
-//      PushEvent( anInNode , GraphExecutor::ReadyEvent ,
-//                 SUPERV::DataReadyState ) ; 
-      anInNode->CreateNewThread( true ) ;
-      anInNode->DataFromNode( Name() ) ;
-      if ( AndSuspend ) {
-        anInNode->State( SUPERV::DataWaitingState ) ;
-        anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
-        if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
-          cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
-                 << anInNode->Name() << endl ;
+    }
+    /* asv : 29.09.04 : commented out because it does not do anything useful 
+    for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+      GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
+      if ( RetVal && anInNode->IsMacroNode() ) {
+        GraphBase::Graph * aMacroGraph = anInNode->GraphMacroNode() ;
+        cdebug << "GraphExecutor::OutNode::Run " << anInNode << " MacroNode " << aMacroGraph
+               << aMacroGraph->Name() << endl ;
+        SUPERV::Graph_var iobject = anInNode->GraphMacroNode()->MacroObject() ;
+        if ( CORBA::is_nil( iobject ) ) {
+          cdebug << "GraphExecutor::OutNode::Run MacroObject() is a nil object. Error" << endl ;
+          RetVal = false ;
+       }
+        else {
+          cdebug << "GraphExecutor::OutNode::Run MacroObject() is NOT a nil object." << endl ;
+       }
+      }
+    }
+    */
+    if ( Graph()->GraphMacroLevel() != 0 ) {
+      cdebug << "GraphExecutor::OutNode::Run Execution starting GraphExecutor::Action_DataOk_RunService Node "
+             << Graph()->Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
+      PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
+                 GraphExecutor::DataUndefState ) ; 
+    }
+    else {
+      cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
+             << Graph()->Name() << " GraphMacroLevel " << Graph()->GraphMacroLevel() << endl ;
+      PushEvent( NULL , GraphExecutor::ReadyEvent ,
+                 GraphExecutor::DataReadyState ) ; 
+      State( GraphExecutor::DataReadyState ) ;
+
+      cdebug << pthread_self() << " GraphExecutor::OutNode::Run Start of the " << Graph()->HeadNodesSize()
+             << " HeadNodes" << endl ;
+      for ( i = 0 ; i < Graph()->HeadNodesSize() ; i++ ) {
+        GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->HeadNodes( i )->GetInNode() ;
+        cdebug << pthread_self() <<  "GraphExecutor::OutNode::Run Start of HeadNode " << i << " "
+               << anInNode->Name() << endl ;
+        if ( anInNode->State() != GraphExecutor::DataReadyState ) {
+          cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
+                 << anInNode->Name() << " : " << anInNode->State() << endl ;
+          cdebug_out << "GraphExecutor::OutNode::Run State ERROR" << endl ;
           return false ;
         }
-        anInNode->SuspendedWait() ;
+//        PushEvent( anInNode , GraphExecutor::ReadyEvent ,
+//                   GraphExecutor::DataReadyState ) ; 
+// We say that we have to create a thread for that HeadNode 'anInNode'
+        anInNode->CreateNewThread( true ) ;
+        anInNode->DataFromNode( Graph()->Name() ) ;
+// AndSuspend == true <==> Start()
+        if ( AndSuspend ) {
+          anInNode->State( GraphExecutor::DataWaitingState ) ;
+          anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
+// We send SomeDataReadyEvent
+// It is a HeadNode ==> AllDataReadyEvent ==> InNode::executeAction() ==> pthread_create
+          if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
+            cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
+                   << anInNode->Name() << endl ;
+            cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
+            return false ;
+          }
+// ==> We wait for SuspendedState
+          anInNode->SuspendedWait() ;
+        }
+// AndSuspend == false <==> Run()
+        else if ( anInNode->IsMacroNode() ) {
+          if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
+            cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
+                   << anInNode->Name() << endl ;
+            cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
+            return false ;
+         }
+          cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWait"
+                 << endl ;
+// ==> We wait for RunningState
+          anInNode->RunningWait() ;
+          cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWaited"
+                 << endl ;
+       }
+        else if ( !anInNode->IsMacroNode() ) {
+// It is a HeadNode ==> AllDataReadyEvent ==> InNode::executeAction() ==> pthread_create
+          if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
+            cdebug << "InNode::SendEvent( ExecuteEvent ) ERROR Node "
+                   << anInNode->Name() << endl ;
+            cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
+            return false ;
+         }
+// ==> We wait for RunningState
+          anInNode->RunningWait() ;
+        }
       }
-      else if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
-        cdebug << "InNode::SendEvent( RunningEvent ) Node "
-               << anInNode->Name() << endl ;
-        return false ;
+
+      if ( AndSuspend ) {
+        PushEvent( NULL , GraphExecutor::SuspendedReadyEvent ,
+                   GraphExecutor::SuspendedReadyState ) ; 
       }
       else {
-        anInNode->RunningWait() ;
+        PushEvent( NULL , GraphExecutor::ExecutingEvent ,
+                   GraphExecutor::ExecutingState ) ; 
+        if (AutomatonState() == GraphExecutor::DataReadyState) {
+            State( GraphExecutor::ExecutingState ) ;
+        };
       }
+//      ostringstream astr ;
+//      astr << "Graph " << Graph()->Name() << " is running" ;
+//      Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
+      RetVal = true ;
     }
-
-    if ( AndSuspend ) {
-      PushEvent( NULL , GraphExecutor::SuspendedReadyEvent ,
-                 SUPERV::SuspendedReadyState ) ; 
-    }
-    else {
-      PushEvent( NULL , GraphExecutor::ExecutingEvent ,
-                 SUPERV::ExecutingState ) ; 
-      if (AutomatonState() == SUPERV::DataReadyState) {
-          State( SUPERV::ExecutingState ) ;
-      };
-    }
-
-    RetVal = true ;
-  }
-  else {
-    PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
-               SUPERV::DataUndefState ) ; 
   }
 
-  cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
-  return RetVal ;
-}
-
-bool GraphExecutor::OutNode::Run( const char * aNodeName ,
-                                  const char * AtNodeName ,
-                                  const bool AndSuspend ) {
-  bool RetVal = false ;
-  cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , "
-            << AtNodeName << " , " << AndSuspend << ")" << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ;
-  if ( anInNode ) {
-    RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ;
-  }
-  cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
+  cdebug_out << pthread_self() << "GraphExecutor::OutNode::Run " << Graph()->Name()
+             << " GraphMacroLevel "
+             << Graph()->GraphMacroLevel() << " RetVal " << RetVal << endl ;
   return RetVal ;
 }
 
 void GraphExecutor::OutNode::CheckAllDone() {
   int j ;
   cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl;
-  SUPERV::AutomatonState OutNodeState = SUPERV::SuccessedState ;
-  SUPERV::AutomatonState InNodeState ;
+  GraphExecutor::AutomatonState OutNodeState = GraphExecutor::SuccessedState ;
+  GraphExecutor::AutomatonState InNodeState ;
   bool AllDone = true ;
-  if ( !_Done ) {
-    for ( j = 0 ; j < QueueNodesSize() ; j++ ) {
-      InNodeState = ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->State() ;
+  if ( !Done() ) {
+    for ( j = 0 ; j < Graph()->QueueNodesSize() ; j++ ) {
+      InNodeState = ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->State() ;
       cdebug << j << ". "
-             << ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->Name()
+             << ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->Name()
              << " " << theAutomaton->StateName( InNodeState ) << endl ;
-      if ( InNodeState != SUPERV::SuccessedState &&
-           InNodeState != SUPERV::ErroredState &&
-           InNodeState != SUPERV::DataWaitingState ) {
+      if ( InNodeState != GraphExecutor::SuccessedState &&
+           InNodeState != GraphExecutor::ErroredState &&
+           InNodeState != GraphExecutor::DataWaitingState ) {
         AllDone = false ;
       }
-      if ( InNodeState != SUPERV::SuccessedState ) {
+      if ( InNodeState != GraphExecutor::SuccessedState &&
+           InNodeState != GraphExecutor::DataWaitingState &&
+           InNodeState != GraphExecutor::DataReadyState ) {
         OutNodeState = InNodeState ;
       }
     }
     if ( AllDone ) {
       if( _Threads == 0 && _SuspendedThreads == 0 ) {
-        if ( OutNodeState != SUPERV::ErroredState ) {
-          OutNodeState = SUPERV::SuccessedState ;
+        if ( OutNodeState != GraphExecutor::ErroredState ) {
+          OutNodeState = GraphExecutor::SuccessedState ;
         }
       }
       else {
@@ -522,35 +687,75 @@ void GraphExecutor::OutNode::CheckAllDone() {
       }
     }
     if ( AllDone ) {
-      State( OutNodeState ) ;
-      _Done = true ;
-      _JustStarted = false ;
-      for ( j = 0 ; j < GraphNodesSize()  ; j++ ) {
+      int alivenodes = 0 ;
+      for ( j = 0 ; j < Graph()->GraphNodesSize()  ; j++ ) {
         GraphExecutor::InNode * aNode ;
-        aNode = (GraphExecutor::InNode * ) GraphNodes( j )->GetInNode() ;
+        aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( j )->GetInNode() ;
         SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ;
         cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " "
-               << theAutomaton->StateName( aNode->State() ) << " :" << endl ;
+               << theAutomaton->StateName( aNode->State() ) << " CreateNewThread " << aNode->CreateNewThread()
+               << endl ;
         if ( aState == SUPERV::ErrorState ||
              aState == SUPERV::SuspendErroredState ||
              aState == SUPERV::KillState ||
              aState == SUPERV::StopState ) {
           OutNodeState = aNode->State() ;
+          State( OutNodeState ) ;
+       }
+        else if ( aState == SUPERV::ReadyState ||
+                  aState == SUPERV::SuspendReadyState ||
+                  aState == SUPERV::RunningState ||
+                  aState == SUPERV::SuspendDoneState ||
+                  aState == SUPERV::SuspendErroredState ||
+                  aState == SUPERV::SuspendState ) {
+          alivenodes += 1 ;
        }
         aNode->SuspendedAction() ;
         aNode->DoneAction() ;
       }
 // PushEvent AFTER State and _Done ! ...
+      if ( alivenodes == 0 ) {
+        State( OutNodeState ) ;
+        Done( true ) ;
+        _JustStarted = false ;
+      }
+      cdebug << Graph()->Name() << " alivenodes " << alivenodes << " OutNodeState " << OutNodeState
+             << endl ;
       PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
                  OutNodeState ) ;
 //      Py_Finalize() ;
 //      PyInitialized( false ) ;
     }
   }
-  cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << _Done
-             << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
+  if ( IsDone() ) {
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS DONE : " <<  theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+             << EventQSize() ) ;
+    MESSAGE("================================================================================") ;
+    cdebug << "================================================================================" << endl ;
+    cdebug << Graph()->Name() << " IS DONE : " <<  theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+             << EventQSize() << endl  ;
+    cdebug << "================================================================================" << endl ;
+
+    // asv : fix for 6798 and other bugs: "sift" the event queue after execution
+    siftEvents();
+
+    // asv : 25.10.04 : calling Editing() to indicate stop of execution
+    Graph()->GraphEditor()->Editing();
+  }
+  cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << IsDone() << " this " << this << " "
+             << Graph()->Name() << " GraphAutomatonState "
+             << theAutomaton->StateName( AutomatonState() )
              << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
-             << _SuspendedThreads << endl ;
+             << _SuspendedThreads << " EventQSize " << EventQSize() << endl ;
+}
+
+Engines_Container_i * GraphExecutor::OutNode::SuperVisionContainer() {
+  return _SuperVisionContainer ;
+}
+
+const pthread_t GraphExecutor::OutNode::MainThreadId() const {
+  return _MainThreadId ;
 }
 
 void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) {
@@ -579,22 +784,24 @@ void GraphExecutor::OutNode::PThreadUnLock( pthread_mutex_t * aMutex , char * er
   }
 }
 
-void GraphExecutor::OutNode::PThreadLock() {
-  cout << " GraphExecutor::OutNode::PThreadLock " << pthread_self() << endl ;
-  if ( pthread_mutex_lock( &_MutexWait ) ) {
-    perror( "GraphExecutor::OutNode::PThreadLock" ) ;
+void GraphExecutor::OutNode::PyThreadLock() {
+//  cout << " GraphExecutor::OutNode::PyThreadLock " << pthread_self() << endl ;
+  if ( pthread_mutex_lock( &_PyMutexWait ) ) {
+    perror( "GraphExecutor::OutNode::PyThreadLock" ) ;
     exit( 0 ) ;
   }
-  cout << " GraphExecutor::OutNode::PThreadLocked " << pthread_self() << endl ;
+  theAutomaton->PyLock() ;
+//  cout << " GraphExecutor::OutNode::PyThreadLocked " << pthread_self() << endl ;
 }
 
-void GraphExecutor::OutNode::PThreadUnLock() {
-  cout << " GraphExecutor::OutNode::PThreadUnLock " << pthread_self() << endl ;
-  if ( pthread_mutex_unlock( &_MutexWait ) ) {
-    perror( "GraphExecutor::OutNode::PThreadUnLock" ) ;
+void GraphExecutor::OutNode::PyThreadUnLock() {
+//  cout << " GraphExecutor::OutNode::PyThreadUnLock " << pthread_self() << endl ;
+  if ( pthread_mutex_unlock( &_PyMutexWait ) ) {
+    perror( "GraphExecutor::OutNode::PyThreadUnLock" ) ;
     exit( 0 ) ;
   }
-  cout << " GraphExecutor::OutNode::PThreadUnLocked " << pthread_self() << endl ;
+  theAutomaton->PyUnLock() ;
+//  cout << " GraphExecutor::OutNode::PyThreadUnLocked " << pthread_self() << endl ;
 }
 
 void GraphExecutor::OutNode::NewThread() {
@@ -611,25 +818,32 @@ void GraphExecutor::OutNode::NewThread() {
     exit( 0 ) ;
   }
 }
-void GraphExecutor::OutNode::ExitThread() {
+
+void GraphExecutor::OutNode::ExitThread( pthread_t ThreadNumber ) {
   if ( pthread_mutex_lock( &_MutexWait ) ) {
     perror("pthread_mutex_lock _ExitThread") ;
     exit( 0 ) ;
   }
+  if ( ThreadNumber == 0 ) {
+    ThreadNumber = pthread_self() ;
+  }
   _Threads -= 1 ;
-  theAutomaton->JoinThread( pthread_self() ) ;
+  cdebug << pthread_self() << " ExitThread( " << ThreadNumber << " ) " << _Threads << " running threads "
+         << _SuspendedThreads << " suspended threads"
+         << endl ;
+  theAutomaton->JoinThread( ThreadNumber ) ;
   if ( pthread_cond_signal( &_JoinWait ) ) {
     perror("ExitThread pthread_cond_signal ") ;
   }
-  cdebug << "ExitThread : " << _Threads << " running threads "
-         << _SuspendedThreads << " suspended threads"
-         << endl ;
   if ( pthread_mutex_unlock( &_MutexWait ) ) {
     perror("pthread_mutex_unlock _ExitThread") ;
     exit( 0 ) ;
   }
   if ( _Threads == 0 && _SuspendedThreads == 0 ) {
     CheckAllDone() ;
+    if ( IsDone() ) {
+      theAutomaton->Executed() ;
+    }
   }
 }
 void GraphExecutor::OutNode::JoinedWait() {
@@ -647,6 +861,7 @@ void GraphExecutor::OutNode::JoinedWait() {
     exit( 0 ) ;
   }
 }
+
 void GraphExecutor::OutNode::SuspendThread() {
   if ( pthread_mutex_lock( &_MutexWait ) ) {
     perror("pthread_mutex_lock _SuspendThread") ;
@@ -661,7 +876,7 @@ void GraphExecutor::OutNode::SuspendThread() {
     exit( 0 ) ;
   }
   if ( IsSuspended() ) {
-    PushEvent( NULL , GraphExecutor::SuspendEvent , SUPERV::SuspendedState ) ;
+    PushEvent( NULL , GraphExecutor::SuspendEvent , GraphExecutor::SuspendedState ) ;
   }
 }
 void GraphExecutor::OutNode::ResumeThread() {
@@ -681,7 +896,7 @@ void GraphExecutor::OutNode::ResumeThread() {
 
 long GraphExecutor::OutNode::Thread( const char * aNodeName ) {
   long RetVal = 0 ;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ;
   if ( anInNode ) {
     RetVal = anInNode->ThreadNo() ;
   }
@@ -727,14 +942,6 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No
     aGraphEvent = SUPERV::ErroredEvent ;
     break ;
   }
-  case GraphExecutor::ReStartEvent : {
-    aGraphEvent = SUPERV::ReRunEvent ;
-    break ;
-  }
-  case GraphExecutor::ReStartAndSuspendEvent : {
-    aGraphEvent = SUPERV::ReStartEvent ;
-    break ;
-  }
   case GraphExecutor::NoDataReadyEvent : {
     aGraphEvent = SUPERV::WaitingEvent ;
     break ;
@@ -823,14 +1030,6 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No
     aGraphEvent = SUPERV::StopEvent ;
     break ;
   }
-  case GraphExecutor::ReStartedEvent : {
-    aGraphEvent = SUPERV::ReRunEvent ;
-    break ;
-  }
-  case GraphExecutor::ReStartedAndSuspendEvent : {
-    aGraphEvent = SUPERV::ReStartEvent ;
-    break ;
-  }
   case GraphExecutor::EndExecuteEvent : {
     aGraphEvent = SUPERV::DoneEvent ;
     break ;
@@ -844,128 +1043,124 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No
   return aGraphEvent ;
 }
 
-SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::AutomatonState aState ) {
+SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(GraphExecutor::AutomatonState aState ) {
   SUPERV::GraphState aGraphState ;
   switch ( aState ) {
-  case SUPERV::UnKnownState : {
+  case GraphExecutor::UnKnownState : {
     aGraphState = SUPERV::UndefinedState ;
     break ;
   }
-  case SUPERV::DataUndefState : {
+  case GraphExecutor::DataUndefState : {
     aGraphState = SUPERV::UndefinedState ;
     break ;
   }
-  case SUPERV::DataWaitingState : {
+  case GraphExecutor::DataWaitingState : {
     aGraphState = SUPERV::WaitingState ;
     break ;
   }
-  case SUPERV::DataReadyState : {
+  case GraphExecutor::DataReadyState : {
     aGraphState = SUPERV::ReadyState ;
     break ;
   }
-  case SUPERV::SuspendedReadyState : {
+  case GraphExecutor::SuspendedReadyState : {
     aGraphState = SUPERV::SuspendReadyState ;
     break ;
   }
-  case SUPERV::ResumedReadyState : {
+  case GraphExecutor::ResumedReadyState : {
     aGraphState = SUPERV::ReadyState ;
     break ;
   }
-  case SUPERV::KilledReadyState : {
+  case GraphExecutor::KilledReadyState : {
     aGraphState = SUPERV::KillState ;
     break ;
   }
-  case SUPERV::StoppedReadyState : {
+  case GraphExecutor::StoppedReadyState : {
     aGraphState = SUPERV::StopState ;
     break ;
   }
-  case SUPERV::ExecutingState : {
+  case GraphExecutor::ExecutingState : {
     aGraphState = SUPERV::RunningState ;
     break ;
   }
-  case SUPERV::SuspendedExecutingState : {
+  case GraphExecutor::SuspendedExecutingState : {
     aGraphState = SUPERV::SuspendState ;
     break ;
   }
-  case SUPERV::ResumedExecutingState : {
+  case GraphExecutor::ResumedExecutingState : {
     aGraphState = SUPERV::RunningState ;
     break ;
   }
-  case SUPERV::KilledExecutingState : {
+  case GraphExecutor::KilledExecutingState : {
     aGraphState = SUPERV::KillState ;
     break ;
   }
-  case SUPERV::StoppedExecutingState : {
+  case GraphExecutor::StoppedExecutingState : {
     aGraphState = SUPERV::StopState ;
     break ;
   }
-  case SUPERV::SuccessedExecutingState : {
+  case GraphExecutor::SuccessedExecutingState : {
     aGraphState = SUPERV::DoneState ;
     break ;
   }
-  case SUPERV::ErroredExecutingState : {
+  case GraphExecutor::ErroredExecutingState : {
     aGraphState = SUPERV::ErrorState ;
     break ;
   }
-  case SUPERV::SuspendedSuccessedState : {
+  case GraphExecutor::SuspendedSuccessedState : {
     aGraphState = SUPERV::SuspendDoneState ;
     break ;
   }
-  case SUPERV::SuspendedErroredState : {
+  case GraphExecutor::SuspendedErroredState : {
     aGraphState = SUPERV::SuspendErroredState ;
     break ;
   }
-  case SUPERV::ResumedSuccessedState : {
+  case GraphExecutor::ResumedSuccessedState : {
     aGraphState = SUPERV::DoneState ;
     break ;
   }
-  case SUPERV::ResumedErroredState : {
+  case GraphExecutor::ResumedErroredState : {
     aGraphState = SUPERV::ErrorState ;
     break ;
   }
-  case SUPERV::KilledSuccessedState : {
+  case GraphExecutor::KilledSuccessedState : {
     aGraphState = SUPERV::KillState ;
     break ;
   }
-  case SUPERV::KilledErroredState : {
+  case GraphExecutor::KilledErroredState : {
     aGraphState = SUPERV::KillState ;
     break ;
   }
-  case SUPERV::StoppedSuccessedState : {
+  case GraphExecutor::StoppedSuccessedState : {
     aGraphState = SUPERV::StopState ;
     break ;
   }
-  case SUPERV::StoppedErroredState : {
+  case GraphExecutor::StoppedErroredState : {
     aGraphState = SUPERV::StopState ;
     break ;
   }
-  case SUPERV::SuccessedState : {
+  case GraphExecutor::SuccessedState : {
     aGraphState = SUPERV::DoneState ;
     break ;
   }
-  case SUPERV::ErroredState : {
+  case GraphExecutor::ErroredState : {
     aGraphState = SUPERV::ErrorState ;
     break ;
   }
-  case SUPERV::SuspendedState : {
+  case GraphExecutor::SuspendedState : {
     aGraphState = SUPERV::SuspendState ;
     break ;
   }
-  case SUPERV::KilledState : {
+  case GraphExecutor::KilledState : {
     aGraphState = SUPERV::KillState ;
     break ;
   }
-  case SUPERV::StoppedState : {
+  case GraphExecutor::StoppedState : {
     aGraphState = SUPERV::StopState ;
     break ;
   }
-  case SUPERV::ReRunnedState : {
-    aGraphState = SUPERV::ReRunState ;
-    break ;
-  }
-  case SUPERV::ReStartedState : {
-    aGraphState = SUPERV::ReStartState ;
-    break ;
+  case GraphExecutor::LoadingState : {
+    aGraphState = SUPERV::LoadingState ;
+    break;
   }
   default : {
     cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : "
@@ -976,24 +1171,27 @@ SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::Automaton
   return aGraphState ;
 }
 
+int GraphExecutor::OutNode::GetListSize() {
+  return _EventNodes.size();
+}
+
 bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
                                         GraphExecutor::NodeEvent anEvent ,
-                                        SUPERV::AutomatonState aState ) {
+                                        GraphExecutor::AutomatonState aState ) {
 //  cdebug_in << "PushEvent Threads " << Threads() << " SuspendedThreads "
 //            << SuspendedThreads() << endl ;
   if ( pthread_mutex_lock( &_MutexWait ) ) {
     perror("PushEvent pthread_mutex_lock ") ;
     exit( 0 ) ;
   }
-  if ( aNode ) {
-    _EventNodes.push_back( aNode->Name() ) ;
-  }
-  else {
-    _EventNodes.push_back( Name() ) ;
-  }
+  char* aNodeName = aNode ? aNode->Name() : Graph()->Name() ;
+  _EventNodes.push_back( aNodeName ) ;
   _Events.push_back( anEvent ) ;
   _States.push_back( aState ) ;
+
   pthread_cond_broadcast( &_EventWait );
+  cdebug << pthread_self() << " PushEvent Threads " << Threads() << " SuspendedThreads "
+         << SuspendedThreads() << " pthread_cond_broadcast _EventWait " << &_EventWait << endl ;
   if ( aNode ) {
 //    cdebug << aNode->ThreadNo() << " PushEvent " << aNode->Name() ;
 //    cdebug << " " << aNode->Automaton()->EventName( anEvent )
@@ -1002,27 +1200,50 @@ bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
 //           << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ;
   }
   else {
-//    cdebug << "PushEvent " << Name() ;
+//    cdebug << "PushEvent " << Graph()->Name() ;
 //    cdebug << " " << theAutomaton->EventName( anEvent ) << " "
 //           << theAutomaton->StateName( aState ) ;
   }
 //  cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
 //             << SuspendedThreads() << endl ;
+#if 0
+  if ( _EventNodes.size() > 101 ) {
+    while ( _EventNodes.size() > 31 ) {
+      _EventNodes.pop_front() ;
+      _Events.pop_front() ;
+      _States.pop_front() ;
+    }
+  }
+#endif
   if ( pthread_mutex_unlock( &_MutexWait ) ) {
     perror("PushEvent pthread_mutex_unlock ") ;
     exit( 0 ) ;
   }
+  return true ;
 }
 
 bool GraphExecutor::OutNode::StateWait( SUPERV::GraphState aState ) {
+  return false ;
 }
 
 bool GraphExecutor::OutNode::Event( char ** aNodeName ,
                                     SUPERV::GraphEvent & anEvent ,
                                     SUPERV::GraphState & aState ,
                                     bool WithWait ) {
+  // asv : fixing problem of loops with large number of iterations (>5000)
+  // experimentally was found that number of non-handled by GUI events = (number_of_nodes x 7)
+  // or 7 events for each node - so what we want to do here is remove "old" events for nodes
+  // "on the fly".  Once again it is done in Stop(), Kill(), Done() functions.
+  if ( _EventNodes.size() > (unsigned int)Graph()->GraphNodesSize()*7 )
+    siftEvents();
+
   int ThreadsNumber ;
   int SuspendedThreadsNumber ;
+  bool cdebuginout = false ;
+  if ( _EventNodes.size() > 0 ) {
+//    cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
+    cdebuginout = true ;
+  }
   if ( pthread_mutex_lock( &_MutexWait ) ) {
     perror("EventLoop pthread_mutex_lock ") ;
     exit( 0 ) ;
@@ -1034,11 +1255,11 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName ,
                 _EventNodes.size() > 0 ;
   char * NodeName = "" ;
   GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
-  SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
+  GraphExecutor::AutomatonState theState = GraphExecutor::UnKnownState ;
   anEvent = SUPERV::UndefinedEvent ;
   aState = SUPERV::UndefinedState ;
-  if ( ( IsDone() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
-    cdebug << "EventLoop IsDone()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
+  if ( ( Done() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
+//    cdebug << "EventLoop Done()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
     RetVal = false ;
   }
   else if ( !WithWait && _EventNodes.size() == 0 ) {
@@ -1048,10 +1269,10 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName ,
   }
   else if ( RetVal ) {
     while ( !IsSuspended() && _EventNodes.size() == 0 ) {
-      cdebug << "EventLoop pthread_cond_wait _EventWait" << endl ;
+//      cdebug << "EventLoop pthread_cond_wait _EventWait" << endl ;
       pthread_cond_wait( &_EventWait , &_MutexWait );
-      cdebug << "EventLoop pthread_cond_waited _EventWait"
-             << " _EventNodes.size() " << _EventNodes.size() << endl ;
+//      cdebug << "EventLoop pthread_cond_waited _EventWait"
+//             << " _EventNodes.size() " << _EventNodes.size() << endl ;
     }
     if ( _EventNodes.size() ) {
       ThreadsNumber = Threads() ;
@@ -1070,16 +1291,20 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName ,
     RetVal = false ;
   }
   if ( anEvent != SUPERV::NoEvent ) {
-    cdebug << pthread_self() << "EventLoop "
-           << NodeName << " " << theAutomaton->StateName( theState )
-           << " _EventNodes.size() " << _EventNodes.size()
-           << " Threads " << Threads() << " SuspendedThreads "
-           << SuspendedThreads() << " RetVal " << RetVal << endl ;
+//    cdebug << pthread_self() << "EventLoop "
+//           << NodeName << " " << theAutomaton->StateName( theState )
+//           << " _EventNodes.size() " << _EventNodes.size()
+//           << " Threads " << Threads() << " SuspendedThreads "
+//           << SuspendedThreads() << " RetVal " << RetVal << endl ;
   }
   if ( pthread_mutex_unlock( &_MutexWait ) ) {
     perror("EventLoop pthread_mutex_lock ") ;
     exit( 0 ) ;
   }
+  if ( cdebuginout ) {
+//    cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue"
+//               << *aNodeName << " " << anEvent << " " << aState << endl ;
+  }
   return RetVal ;
 }
 
@@ -1094,8 +1319,8 @@ bool GraphExecutor::OutNode::EventW( char ** aNodeName ,
           aState != SUPERV::RunningState &&
           aState != SUPERV::SuspendDoneState &&
           aState != SUPERV::SuspendErroredState ) {
-    NodeName = Name() ;
-    while ( sts && !strcmp( NodeName , Name() ) ) {
+    NodeName = Graph()->Name() ;
+    while ( sts && !strcmp( NodeName , Graph()->Name() ) ) {
       sts = EventWait( aNodeName , anEvent , aState ) ;
       NodeName = *aNodeName ;
     }
@@ -1119,7 +1344,7 @@ bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
   cdebug << "--> EventW RetVal " << RetVal << endl ;
   char * NodeName = "" ;
   GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
-  SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
+  GraphExecutor::AutomatonState theState = GraphExecutor::UnKnownState ;
   anEvent = SUPERV::UndefinedEvent ;
   aState = SUPERV::UndefinedState ;
   if ( IsDone() && _EventNodes.size() == 0 ) {
@@ -1144,7 +1369,7 @@ bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
         _States.pop_front() ;
       }
 
-      aNode = ((GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode()) ;
+      aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode()) ;
       cdebug << "EventW Previous Node " << NodeName << " ThreadsNumber "
              << ThreadsNumber
              << " _EventNodes.size() " << _EventNodes.size() << " "
@@ -1229,8 +1454,45 @@ bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
   }
   return RetVal ;
 }
+long GraphExecutor::OutNode::EventQSize() {
+  return _EventNodes.size() ;
+}
 
-void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) {
+void GraphExecutor::OutNode::EventList() {
+  if ( pthread_mutex_lock( &_MutexWait ) ) {
+    perror("EventList pthread_mutex_lock ") ;
+    exit( 0 ) ;
+  }
+  list< char * >::iterator itEventNodes = _EventNodes.begin() ;
+  list< GraphExecutor::NodeEvent >::iterator itEvents = _Events.begin() ;
+  list< GraphExecutor::AutomatonState >::iterator itStates = _States.begin() ;
+  while ( itEventNodes != _EventNodes.end() ) {
+    cdebug << pthread_self() << "EVENTSTACK "
+           << *itEventNodes << " " << *itEvents << " "
+           << theAutomaton->StateName( *itStates )
+           << " Threads " << Threads() << " SuspendedThreads " << SuspendedThreads() << endl ;
+    itEventNodes++ ;
+    itEvents++ ;
+    itStates++ ;
+  }
+  if ( pthread_mutex_unlock( &_MutexWait ) ) {
+    perror("EventList pthread_mutex_lock ") ;
+    exit( 0 ) ;
+  }
+}
+
+void GraphExecutor::OutNode::SendSomeDataReady( const char * aNodeName ) {
+  cdebug_in << "GraphExecutor::OutNode::SendSomeDataReady " << aNodeName << "->SendSomeDataReady( "
+            << Graph()->Name() << " )" << endl;
+  int sts ;
+  sts = ((GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( aNodeName )->GetInNode())->SendSomeDataReady( Graph()->Name() ) ;
+  cdebug_out << "GraphExecutor::OutNode::SendSomeDataReady sts " << sts << endl ;
+}
+
+void GraphExecutor::OutNode::State(GraphExecutor::AutomatonState aState ) {
+//  cdebug << "GraphExecutor::OutNode::State " << Graph()->Name() << " "
+//         << theAutomaton->StateName( AutomatonGraphState( _State ) ) << " ---> "
+//         << theAutomaton->StateName( AutomatonGraphState( aState ) ) << endl ;
   _State = aState ;
 }
 
@@ -1244,43 +1506,48 @@ SUPERV::GraphState GraphExecutor::OutNode::State() {
 
 SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) {
 //  cdebug_in << "GraphExecutor::OutNode::State " << NodeName << endl;
-  SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
-  const GraphBase::ComputingNode * aCNode =  GetGraphNode( NodeName ) ;
+  GraphExecutor::AutomatonState aret = GraphExecutor::UnKnownState ;
+  const GraphBase::ComputingNode * aCNode =  Graph()->GetGraphNode( NodeName ) ;
   if ( aCNode ) {
     GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ;
     if ( anInNode ) {
-      aret = anInNode->State() ;
-      cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
-             << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
+      if ( anInNode->IsLoading() )
+       aret = GraphExecutor::LoadingState;
+      else
+       aret = anInNode->State() ;
+//      cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
+//             << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
     }
   }
 //  cdebug_out << "GraphExecutor::OutNode::State" << endl ;
   return AutomatonGraphState( aret ) ;
 }
 
-SUPERV::GraphState GraphExecutor::OutNode::State(
-                                    const char * NodeName ,
-                                    const char * ServiceParameterName )  {
+SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ,
+                                                  const char * ServiceParameterName )  {
 //  cdebug_in << "GraphExecutor::OutNode::State " << NodeName << " "
 //            << ServiceParameterName<< endl;
-  SUPERV::GraphState aret =
-                    PortState( NodeName , ServiceParameterName ) ;
+  SUPERV::GraphState aret = Graph()->PortState( NodeName , ServiceParameterName ) ;
 //  cdebug_out << "GraphExecutor::OutNode::State" << endl ;
   return aret ;
 }
 
-SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState() {
+GraphExecutor::AutomatonState GraphExecutor::OutNode::AutomatonState() {
 //  cdebug_in << "GraphExecutor::OutNode::AutomatonState" << endl;
 //  cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
   return _State ;
 }
 
-SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState( const char * NodeName ) {
+GraphExecutor::AutomatonState GraphExecutor::OutNode::AutomatonState( const char * NodeName ) {
 //  cdebug_in << "GraphExecutor::OutNode::AutomatonState " << NodeName << endl;
-  SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
-  if ( anInNode )
-    aret = anInNode->State() ;
+  GraphExecutor::AutomatonState aret = GraphExecutor::UnKnownState ;
+  const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( NodeName ) ;
+  if ( aNode ) {
+    GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) aNode->GetInNode() ;
+    if ( anInNode ) {
+      aret = anInNode->State() ;
+    }
+  }
 //  cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
   return aret ;
 }
@@ -1294,9 +1561,13 @@ SUPERV::ControlState GraphExecutor::OutNode::ControlState() {
 SUPERV::ControlState GraphExecutor::OutNode::ControlState( const char * NodeName ) {
 //  cdebug_in << "GraphExecutor::OutNode::ControlState " << NodeName << endl;
   SUPERV::ControlState aret = SUPERV::VoidState ;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
-  if ( anInNode )
-    aret = anInNode->ControlState() ;
+  const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( NodeName ) ;
+  if ( aNode ) {
+    GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) aNode->GetInNode() ;
+    if ( anInNode ) {
+      aret = anInNode->ControlState() ;
+    }
+  }
 //  cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
   return aret ;
 }
@@ -1309,40 +1580,45 @@ void GraphExecutor::OutNode::ControlClear() {
 
 void GraphExecutor::OutNode::ControlClear( const char * NodeName ) {
 //  cdebug_in << "GraphExecutor::OutNode::ControlClear " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
-  if ( anInNode )
-    anInNode->ControlClear() ;
+  const GraphBase::ComputingNode * aNode = Graph()->GetGraphNode( NodeName ) ;
+  if ( aNode ) {
+    GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) aNode->GetInNode() ;
+    if ( anInNode ) {
+      anInNode->ControlClear() ;
+    }
+  }
 //  cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
 }
 
 bool GraphExecutor::OutNode::IsWaiting() {
 //  cdebug_in << "GraphExecutor::OutNode::IsWaiting" << endl;
 //  cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
-  return !_Done ;
+  return !IsDone() ;
 }
 
 bool GraphExecutor::OutNode::IsReady() {
 //  cdebug_in << "GraphExecutor::OutNode::IsReady" << endl;
 //  cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
-  return !_Done ;
+  return !IsDone() ;
 }
 
 bool GraphExecutor::OutNode::IsRunning() {
 //  cdebug_in << "GraphExecutor::OutNode::IsRunning" << endl;
 //  cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
-  return !_Done ;
+  return !IsDone() ;
 }
 
 bool GraphExecutor::OutNode::IsDone() {
 //  cdebug_in << "GraphExecutor::OutNode::IsDone" << endl;
 //  cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
-  return ( _Done || IsKilled() || IsStopped() ) ;
+  return ( Done() || IsKilled() || IsStopped() ) ;
 }
 
 bool GraphExecutor::OutNode::IsSuspended() {
 //  cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl;
   bool aret = false ;
-  if ( _SuspendedThreads == _Threads ) {
+//  if ( _SuspendedThreads == _Threads && _Threads != 0 ) {
+  if ( AutomatonGraphState( _State ) ==  SUPERV::SuspendState ) {
     aret = true ;
   }
 //  cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
@@ -1372,7 +1648,7 @@ bool GraphExecutor::OutNode::IsStopped() {
 bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) {
   bool aret = false ;
 //  cdebug_in << "GraphExecutor::OutNode::IsWaiting " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->IsWaiting() ;
   }
@@ -1383,7 +1659,7 @@ bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) {
 bool GraphExecutor::OutNode::IsReady( const char * NodeName ) {
   bool aret = false ;
 //  cdebug_in << "GraphExecutor::OutNode::IsReady " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->IsReady() ;
   }
@@ -1394,7 +1670,7 @@ bool GraphExecutor::OutNode::IsReady( const char * NodeName ) {
 bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) {
   bool aret = false ;
 //  cdebug_in << "GraphExecutor::OutNode::IsRunning " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->IsRunning() ;
   }
@@ -1405,7 +1681,7 @@ bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) {
 bool GraphExecutor::OutNode::IsDone( const char * NodeName ) {
   bool aret = false ;
 //  cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->IsDone() ;
   }
@@ -1416,7 +1692,7 @@ bool GraphExecutor::OutNode::IsDone( const char * NodeName ) {
 bool GraphExecutor::OutNode::IsSuspended( const char * NodeName ) {
   bool aret = false ;
 //  cdebug_in << "GraphExecutor::OutNode::IsSuspended " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->IsSuspended() ;
   }
@@ -1428,7 +1704,7 @@ bool GraphExecutor::OutNode::IsDone( const char * NodeName ,
                                      const char * ServiceParameterName )  {
 //  cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " "
 //            << ServiceParameterName<< endl;
-  bool aret = PortDone( NodeName , ServiceParameterName ) ;
+  bool aret = Graph()->PortDone( NodeName , ServiceParameterName ) ;
 //  cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
   return aret ;
 }
@@ -1438,8 +1714,8 @@ bool GraphExecutor::OutNode::ContainerKill() {
   cdebug_in << "GraphExecutor::OutNode::ContainerKill" << endl;
   _ControlState = SUPERV::ToSuspendState ;
   int i ;
-  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
-    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+  for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
     bool sts = aNode->ContainerKill() ;
     if ( sts && aNode->IsKilled() ) {
       cdebug << aNode->Name() << " killed" << endl ;
@@ -1455,61 +1731,140 @@ bool GraphExecutor::OutNode::ContainerKill() {
     }
   }
   if ( !RetVal || Threads() != 0 ) {
-    for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
-      GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+    for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+      GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
       if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
         aNode->KilledAction() ;
       }
     }
     RetVal = true ;
   }
-  State( SUPERV::KilledState ) ;
+  State( GraphExecutor::KilledState ) ;
   cdebug_out << "GraphExecutor::OutNode::ContainerKill" << endl ;
   return RetVal ;
 }
 
 bool GraphExecutor::OutNode::Suspend() {
-  bool RetVal = false ;
+  int RetVal = 0 ;
   cdebug_in << "GraphExecutor::OutNode::Suspend" << endl;
-  _ControlState = SUPERV::ToSuspendState ;
+//  _ControlState = SUPERV::ToSuspendState ;
   int i ;
-  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
-    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+  for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
     bool sts = aNode->Suspend() ;
     if ( sts && aNode->IsSuspended() ) {
-      cdebug << aNode->Name() << " Suspend" << endl ;
+      RetVal += 1 ;
+      cdebug << aNode->Name() << " Suspended" << endl ;
     }
-    else if ( aNode->IsWaiting() || aNode->IsDone() ) {
+    else if ( aNode->IsWaiting() || aNode->IsReady() ) {
+      RetVal += 1 ;
+      cdebug << aNode->Name() << " will be Suspended" << endl ;
+    }
+    else if ( aNode->IsDone() ) {
       cdebug << aNode->Name() << " not Suspended : "
              << theAutomaton->StateName( aNode->State() ) << endl ;
     }
     else {
+//      RetVal += 1 ;
       cdebug << aNode->Name() << " cannot be Suspended : "
              << theAutomaton->StateName( aNode->State() ) << endl ;
-      RetVal = false ;
     }
   }
-  State( SUPERV::SuspendedState ) ;
-  cdebug_out << "GraphExecutor::OutNode::Suspend" << endl ;
+  if ( RetVal ) {
+    State( GraphExecutor::SuspendedState ) ;
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS SUSPENDED" ) ;
+    MESSAGE("================================================================================") ;
+  }
+  else {
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ;
+    MESSAGE("================================================================================") ;
+  }
+  for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+    MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ;
+    cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ;
+  }
+  cdebug_out << "GraphExecutor::OutNode::Suspend " << theAutomaton->StateName( State() )
+             << " EventQSize " << EventQSize() << endl ;
   return RetVal ;
 }
+
 bool GraphExecutor::OutNode::Resume() {
-  bool RetVal = false ;
-  cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
-  cdebug_out << "GraphExecutor::OutNode::Resume" << endl ;
+  int RetVal = 0 ;
+  cdebug_in << "GraphExecutor::OutNode::Resume "
+            << theAutomaton->StateName( State() ) << endl;
+  if ( IsSuspended() ) {
+    State( GraphExecutor::ExecutingState ) ;
+    int i ;
+    for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+      GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+      aNode->ControlState( SUPERV::VoidState ) ;
+      if ( aNode->IsSuspended() ) {
+        cdebug << aNode->Name() << "->Resume " << theAutomaton->StateName( aNode->State() )
+               << endl ;
+        if ( aNode->Resume() ) {
+          cdebug << aNode->Name() << " Resumed " << theAutomaton->StateName( aNode->State() )
+                 << endl ;
+          RetVal += 1 ;
+       }
+        else {
+          cdebug << aNode->Name() << " Resume failed"
+                 << theAutomaton->StateName( aNode->State() ) << endl ;
+        }
+      }
+      else {
+        cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() )
+               << endl ;
+      }
+    }
+  }
+  else {
+    cdebug << Graph()->Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ;
+  }
+  if ( RetVal ) {
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS RESUMED" ) ;
+    MESSAGE("================================================================================") ;
+  }
+  else {
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ;
+    MESSAGE("================================================================================") ;
+  }
+  int i ;
+  for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+    MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ;
+    cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ;
+  }
+  cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal
+             << " EventQSize " << EventQSize() << endl ;
   return RetVal ;
 }
 
 bool GraphExecutor::OutNode::Kill() {
-  bool RetVal = true ;
-  cdebug_in << "GraphExecutor::OutNode::Kill" << endl;
+  bool RetVal = false ;
+  cdebug_in << "GraphExecutor::OutNode::Kill"
+             << " EventQSize " << EventQSize() << endl;
   _ControlState = SUPERV::ToSuspendState ;
   int i ;
-  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
-    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+  for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
     bool sts = aNode->Kill() ;
-    if ( sts && aNode->IsKilled() ) {
-      cdebug << aNode->Name() << " killed" << endl ;
+    if ( sts && Threads() != 0 ) {
+      if ( !aNode->IsKilled() ) {
+        cdebug << aNode->Name() << " not killed : "
+               << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
+               << "KilledAction()" << endl ;
+        MESSAGE( aNode->Name() << " not killed : KilledAction()" ) ;
+        aNode->KilledAction() ;
+      }
+      if ( aNode->IsKilled() ) {
+        cdebug << aNode->Name() << " killed" << endl ;
+        RetVal = true ;
+      }
     }
     else if ( aNode->IsWaiting() || aNode->IsDone() ) {
       cdebug << aNode->Name() << " not killed : "
@@ -1518,44 +1873,48 @@ bool GraphExecutor::OutNode::Kill() {
     else {
       cdebug << aNode->Name() << " cannot be killed : "
              << theAutomaton->StateName( aNode->State() ) << endl ;
-      RetVal = false ;
     }
   }
-  if ( !RetVal || Threads() != 0 ) {
-    for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
-      GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
-      if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
-        aNode->KilledAction() ;
-      }
-    }
-    RetVal = true ;
+  if ( RetVal ) {
+    State( GraphExecutor::KilledState ) ;
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS KILLED" <<  theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+             << EventQSize() ) ;
+    MESSAGE("================================================================================") ;
+  }
+  else {
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ;
+    MESSAGE("================================================================================") ;
+  }
+  for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+    GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+    MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ;
+    cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ;
   }
-  State( SUPERV::KilledState ) ;
-  cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
+  cdebug_out << "GraphExecutor::OutNode::Kill " << RetVal
+             << " Threads " << _Threads << " SuspendedThreads " << _SuspendedThreads
+             << " EventQSize " << EventQSize() << endl ;
+
+  // remove "extra" events from the event queue
+  siftEvents();
+
+  // asv : 25.10.04 : calling Editing() to indicate stop of execution
+  Graph()->GraphEditor()->Editing();
+
   return RetVal ;
 }
 
 bool GraphExecutor::OutNode::Stop() {
   bool RetVal = false ;
   cdebug_in << "GraphExecutor::OutNode::Stop" << endl;
-  Kill() ;
+  RetVal = Kill() ;
   cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
-  return RetVal ;
-}
-bool GraphExecutor::OutNode::ReRun() {
-  bool RetVal = false ;
-  cdebug_in << "GraphExecutor::OutNode::ReRun" << endl;
-  if ( IsSuspended() ) {
-  }
-  cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ;
-  return RetVal ;
-}
-bool GraphExecutor::OutNode::ReStart() {
-  bool RetVal = false ;
-  cdebug_in << "GraphExecutor::OutNode::ReStart" << endl;
-  if ( IsSuspended() ) {
+  if ( RetVal ) {
+    MESSAGE("================================================================================") ;
+    MESSAGE( Graph()->Name() << " IS STOPPED" ) ;
+    MESSAGE("================================================================================") ;
   }
-  cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ;
   return RetVal ;
 }
 
@@ -1603,24 +1962,27 @@ bool GraphExecutor::OutNode::RunningWait() {
 }
 
 bool GraphExecutor::OutNode::DoneWait() {
-  cdebug_in << "GraphExecutor::OutNode::DoneWait" << endl;
+  cdebug_in << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name() << endl;
   bool aret ;
   if ( pthread_mutex_lock( &_MutexWait ) ) {
     perror("pthread_mutex_lock _DoneWait") ;
     exit( 0 ) ;
   }
   aret = IsDone() ;
-  while ( !aret && !IsSuspended() ) {
-    cdebug << "DoneWait pthread_cond_wait _EventWait" << endl;
+  while ( !aret && !IsSuspended() && IsRunning() ) {
+    cdebug << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name()
+           << " DoneWait pthread_cond_wait _EventWait " << &_EventWait << endl;
     pthread_cond_wait( &_EventWait , &_MutexWait );
     aret = IsDone() ;
-    cdebug << "DoneWait pthread_cond_waited _EventWait " << aret << endl;
+    cdebug << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name()
+           << " DoneWait pthread_cond_waited _EventWaited " << &_EventWait << " : "<< aret << endl;
   }
   if ( pthread_mutex_unlock( &_MutexWait ) ) {
     perror("pthread_mutex_lock _DoneWait") ;
     exit( 0 ) ;
   }
-  cdebug_out << "GraphExecutor::OutNode::DoneWait " << aret << endl ;
+  cdebug_out << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Graph()->Name()
+             << " " << State() << " : " << aret << endl ;
   return aret ;
 }
 
@@ -1632,7 +1994,7 @@ bool GraphExecutor::OutNode::SuspendedWait() {
     exit( 0 ) ;
   }
   aret = IsSuspended() ;
-  while ( !aret && !_Done ) {
+  while ( !aret && !IsDone() ) {
     pthread_cond_wait( &_EventWait , &_MutexWait );
     aret = IsSuspended() ;
   }
@@ -1647,7 +2009,7 @@ bool GraphExecutor::OutNode::SuspendedWait() {
 bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) {
   bool aret = false ;
   cdebug_in << "GraphExecutor::OutNode::ReadyWait " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->ReadyWait() ;
   }
@@ -1658,7 +2020,7 @@ bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) {
 bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) {
   bool aret = false ;
   cdebug_in << "GraphExecutor::OutNode::RunningWait " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->RunningWait() ;
   }
@@ -1669,7 +2031,7 @@ bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) {
 bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) {
   bool aret = false ;
   cdebug_in << "GraphExecutor::OutNode::DoneWait " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->DoneWait() ;
   }
@@ -1680,7 +2042,7 @@ bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) {
 bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) {
   bool aret = false ;
   cdebug_in << "GraphExecutor::OutNode::SuspendedWait " << NodeName << endl;
-  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+  GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ;
   if ( anInNode ) {
     aret = anInNode->SuspendedWait() ;
   }
@@ -1691,14 +2053,14 @@ bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) {
 long GraphExecutor::OutNode::LastLevelDone() {
   int RetVal = -1 ;
   int i , j ;
-  for ( i = 0 ; i <= LevelMax() ; i++ ) {
-    for ( j = 0 ; j <= NodesNumber( i ) ; j++ ) {
-      GraphBase::ComputingNode * aNode = SortedNodes( i , j ) ;
+  for ( i = 0 ; i <= Graph()->LevelMax() ; i++ ) {
+    for ( j = 0 ; j <= Graph()->NodesNumber( i ) ; j++ ) {
+      GraphBase::ComputingNode * aNode = Graph()->SortedNodes( i , j ) ;
       if ( !IsDone( aNode->Name() ) ) {
         break ;
       }
     }
-    if ( j != NodesNumber( i ) + 1 )
+    if ( j != Graph()->NodesNumber( i ) + 1 )
       break ;
     RetVal = i ;
   }
@@ -1706,23 +2068,69 @@ long GraphExecutor::OutNode::LastLevelDone() {
 }
 
 
-const CORBA::Any *GraphExecutor::OutNode::GetInData(
-                              const char * NodeName ,
-                              const char * ServiceParameterName ) {
+const CORBA::Any *GraphExecutor::OutNode::GetInData( const char * NodeName ,
+                                                     const char * ServiceParameterName ) {
 //  cdebug_in << "GraphExecutor::OutNode::GetInData " << NodeName << " "
 //            << ServiceParameterName << endl ;
-  const CORBA::Any * retdata = PortInData( NodeName , ServiceParameterName ) ;
+  const CORBA::Any * retdata = Graph()->PortInData( NodeName , ServiceParameterName ) ;
 //  cdebug_out << "GraphExecutor::OutNode::GetInData" << endl ;
   return retdata ;
 }
 
-const CORBA::Any *GraphExecutor::OutNode::GetOutData(
-                              const char * NodeName ,
-                              const char * ServiceParameterName ) {
+const CORBA::Any *GraphExecutor::OutNode::GetOutData( const char * NodeName ,
+                                                      const char * ServiceParameterName ) {
 //  cdebug_in << "GraphExecutor::OutNode::GetOutData " << NodeName << " "
 //            << ServiceParameterName << endl ;
-  const CORBA::Any * retdata = PortOutData( NodeName , ServiceParameterName ) ;
+  const CORBA::Any * retdata = Graph()->PortOutData( NodeName , ServiceParameterName ) ;
 //  cdebug_out << "GraphExecutor::OutNode::GetOutData" << endl ;
   return retdata ;
 }
 
+const long GraphExecutor::OutNode::CpuUsed() {
+  return Graph()->CpuUsed() ;
+}
+
+const long GraphExecutor::OutNode::CpuUsed( const char * aNodeName ) {
+  GraphBase::ComputingNode * aNode = Graph()->GetChangeGraphNode( aNodeName ) ;
+  if ( aNode ) {
+    GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ;
+    if ( anInNode ) {
+      return anInNode->CpuUsed() ;
+    }
+  }
+  return 0 ;
+}
+
+// remove equal sets "Node-Event-State" from _EventNodes/_Events/_States queues
+void GraphExecutor::OutNode::siftEvents() {
+  list<char*>::reverse_iterator itNodes = _EventNodes.rbegin();
+  list<GraphExecutor::NodeEvent>::reverse_iterator itEvents = _Events.rbegin();
+  list<GraphExecutor::AutomatonState>::reverse_iterator itStates = _States.rbegin();
+  list<char*> _NewEventNodes;
+  list<GraphExecutor::NodeEvent> _NewEvents;
+  list<GraphExecutor::AutomatonState> _NewStates;
+  for ( ; itNodes != _EventNodes.rend() ; ++itNodes, ++itEvents, ++itStates) {
+    //cout << "----- aNodeName ==> " << *itNodes;
+    list<char*>::reverse_iterator itNewNodes = _NewEventNodes.rbegin();
+    bool found = false;
+    for ( ; itNewNodes != _NewEventNodes.rend() ; ++itNewNodes ) {
+      if ( !strcmp( *itNewNodes, *itNodes ) ) {
+       found = true;
+       break;
+      }
+    }
+
+    if ( found ) {
+      //cout << "   FOUND";
+    }
+    else {
+      _NewEventNodes.push_back( *itNodes );
+      _NewEvents.push_back( *itEvents );
+      _NewStates.push_back( *itStates );
+    }
+    //cout << endl;
+  }
+  _EventNodes = _NewEventNodes;
+  _Events = _NewEvents;
+  _States = _NewStates;
+}