Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphBase / DataFlowBase_Graph.cxx
index 169fc9ab5d6ce63315c126fefdf90d2ad5cb79ec..e5d072362bdf6226a420d73676706e049f8d0b2c 100644 (file)
@@ -17,7 +17,7 @@
 //  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 
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -35,6 +35,7 @@ GraphBase::Graph::Graph() :
            DataNode() {
   cdebug << "GraphBase::Graph::Graph" << endl ;
   _GraphNodesSize = 0 ;
+  GraphOfNode( this ) ;
 }
 
 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
@@ -49,6 +50,7 @@ GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
   Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
   cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ;
   _GraphNodesSize = 0 ;
+  GraphOfNode( this ) ;
 }
 
 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
@@ -73,6 +75,7 @@ GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
                      DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
   _Orb = CORBA::ORB::_duplicate( ORB ) ;
   _GraphNodesSize = 0 ;
+  GraphOfNode( this ) ;
   Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
   cdebug_in << "GraphBase::Graph::Graph" << endl ;
   DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ;
@@ -97,9 +100,9 @@ GraphBase::SNode * GraphBase::Graph::GetInfo() const {
   Info->theName = Name() ;
   Info->theKind = Kind() ;
   if ( IsDataStreamNode() ) {
-    long Timeout ;
+    CORBA::Long Timeout ;
     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
-    double DeltaTime ;
+    CORBA::Double DeltaTime ;
     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
     Info->theTimeout = Timeout ;
     Info->theDataStreamTrace = DataStreamTrace ;
@@ -140,36 +143,45 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
            ( igoto == 1 && aCNode->IsGOTONode() ) ) {
         if ( aCNode->IsFactoryNode() ) {
           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
-          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
-          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
+          (*_list_nodes)[ind].theComponentName = string( aFNode->ComponentName());
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
+          (*_list_nodes)[ind].theInterfaceName = string( aFNode->InterfaceName());
         }
         else {
-          (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
-          (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
+          (*_list_nodes)[ind].theComponentName = string( "" );
+          (*_list_nodes)[ind].theInterfaceName = string( "" );
         }
-        (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
+        (*_list_nodes)[ind].theName = string( aCNode->Name() );
         (*_list_nodes)[ind].theKind = aCNode->Kind();
         if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
           GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aINode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
         }
         if ( aCNode->IsGOTONode() ) {
           GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aGNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
         }
         if ( aCNode->IsLoopNode() ) {
           GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aLNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
-          (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
-          (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aLNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[1] = string( aLNode->PyMoreName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[2] = string( aLNode->PyNextName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
           (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
@@ -177,38 +189,46 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
         }
         else if ( aCNode->IsSwitchNode() ) {
           GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aSNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aSNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
         }
         else if ( aCNode->IsEndLoopNode() ) {
           GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aELNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aELNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
         }
         else if ( aCNode->IsEndSwitchNode() ) {
           GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aESNode->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aESNode->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
         }
         else if ( aCNode->IsMacroNode() ) {
           GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( aGraph->CoupledNode()->Name() ) ;
           (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
-          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
+          (*_list_nodes)[ind].theListOfFuncName[0] = string( aGraph->PyFuncName() ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
           (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
         }
         else {
-          (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
+          (*_list_nodes)[ind].theCoupledNode = string( "" ) ;
         }
 //        (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
 //        (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
@@ -221,9 +241,9 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
           const GraphBase::InPort * anInPort ;
           anInPort = aCNode->GetNodeInPort( iostream ) ;
           if ( anInPort->IsDataStream() ) {
-            cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName()
-                   << endl ;
-            (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ;
+            cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name()
+                   << " " << anInPort->NodeName() << " " << anInPort->PortName() << endl;
+            (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
             (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
             SUPERV::KindOfSchema        aKindOfSchema ;
@@ -258,7 +278,7 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
           if ( anOutPort->IsDataStream() ) {
             cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
                    << endl ;
-            (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ;
+            (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
             (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
             long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
@@ -322,16 +342,21 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
         }
         (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
         (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
-        (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
-        (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
+        (*_list_nodes)[ind].theEditorRelease = string( aCNode->EditorRelease());
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
+       (*_list_nodes)[ind].theAuthor = string( aCNode->Author()); // mkr : IPAL10200
         if ( aCNode->IsFactoryNode() ) {
           GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
-          (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
+          (*_list_nodes)[ind].theContainer = string( aFNode->Computer());
         }
         else {
-          (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
+//JR 24.02.2005 Memory Leak          (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
+          (*_list_nodes)[ind].theContainer = string( "" );
         }
-        (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
+//JR 24.02.2005 Memory Leak        (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
+        (*_list_nodes)[ind].theComment = string( aCNode->Comment());
         (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
         (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
 #if 0
@@ -342,10 +367,14 @@ GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
           if ( anInPort->IsBus() ) {
             nports += 1 ;
             (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
-            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = string( anInPort->PortType() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = string( anInPort->PortName() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
+//JR 24.02.2005 Memory Leak            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
+            (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
           }
         }
 #endif
@@ -367,30 +396,46 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
 // All the links from _LinksList are taken
 //  vector< InNode *> Nodes = InNodes() ;
 
+  cdebug_in << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
   int ind = 0 ;
   int k ;
   for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
     GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
+//    cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name() << endl ;
     int i ;
     for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
       const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
+//      cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name()
+//             << " i" << i << ". : " << fromPort->PortName() << endl ;
       int j ;
       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
+//        cdebug << "GraphBase::Graph::GetLinks k" << k << ". : fromNode " << fromNode << " = "
+//               << fromNode->Name() << " i" << i << ". : fromPort " << fromPort << " = "
+//               << fromPort->PortName() << " j" << j << ". : toPort " << toPort << " = "
+//               << toPort->NodeName() << "( " << toPort->PortName() << " )" << endl ;
         if ( toPort->IsPortConnected() ) {
 // Desole pour ce cast mais avec les maps difficile de faire const ...
-          const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
+//          const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
+//          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
+//                 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
+//                 << " --> toNode " << toNode << " " << toPort->NodeName() << "( "
+//                 << toPort->PortName() << " ) " << " " << fromPort->InPortsSize() << " ports"
+//                 << endl ;
           if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
-            cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
-                   << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
-                   << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
-                   << " " << fromPort->InPortsSize() << " ports" << endl ;
+//            cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
+//                   << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
+//                   << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
+//                   << " " << fromPort->InPortsSize() << " ports" << endl ;
             _list_links->resize( ind+1 );
-            (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
+//JR 23.02.2005 Memory Leak            (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
+            (*_list_links)[ind].FromNodeName = string( fromNode->Name() );
             (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
-            (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+//JR 23.02.2005 Memory Leak            (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+            (*_list_links)[ind].ToNodeName = string( toPort->NodeName() );
             (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
-            (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
+//JR 30.03.2005            (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
+            (*_list_links)[ind].aLinkValue = fromPort->Value() ;
             if ( toPort->IsEndSwitch() ) {
               (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
            }
@@ -400,15 +445,17 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
          }
        }
         else {
-          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
-                 << fromPort->PortName() << " ) " << fromPort->PortStatus()
-                 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
-                 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
+//          cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
+//                 << fromPort->PortName() << " ) " << fromPort->PortStatus()
+//                 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
+//                 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize()
+//                 << " ports ignored" << endl ;
        }
       }
     }
   }
 
+  cdebug_out << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
   return _list_links;
 }
 
@@ -422,11 +469,14 @@ GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
                                               GraphBase::InPort* toPort ) {
   GraphBase::SLink * _link =  new GraphBase::SLink ;
   GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
-  _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
+//JR 24.02.2005 Memory Leak  _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
+  _link->FromNodeName = string( fromPort->NodeName() );
   _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
-  _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
+//JR 24.02.2005 Memory Leak  _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
+  _link->ToNodeName = string( toPort->NodeName() );
   _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
-  CORBA::Any aSPValue = *fromPort->Value() ;
+//JR 30.03.2005  CORBA::Any aSPValue = *fromPort->Value() ;
+  CORBA::Any aSPValue = fromPort->Value() ;
   _link->aLinkValue = aSPValue;
   _link->aListOfCoords = *(toPort->Coords()) ;
   return _link;
@@ -450,12 +500,15 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
         for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
           _list_datalinks->resize( ind+1 );
-          (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
+//JR 24.02.2005 Memory Leak          (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
+          (*_list_datalinks)[ind].FromNodeName = string( aDataNode->Name() );
           (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
           const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
-          (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+//JR 24.02.2005 Memory Leak          (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
+          (*_list_datalinks)[ind].ToNodeName = string( toPort->NodeName() );
           (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
-          CORBA::Any aSPValue = *fromDataPort->Value() ;
+//JR 30.03.2005          CORBA::Any aSPValue = *fromDataPort->Value() ;
+          CORBA::Any aSPValue = fromDataPort->Value() ;
           (*_list_datalinks)[ind].aLinkValue = aSPValue;
           (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
         }
@@ -463,27 +516,6 @@ GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
     }
   }
 
-#if 0
-// Output(s) of a DataFlow match only one input-virtual-dataport
-  for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
-    GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
-    const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
-    if ( fromPort->IsDataConnected() ) {
-      _list_datalinks->length( ind+1 );
-      _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
-      _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
-      _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
-      _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
-//      SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
-          CORBA::Any aSPValue = *fromPort->Value() ;
-//      aSPValue.Value = CORBA::string_dup( fromPort->Value() );
-//      aSPValue.Kind = fromPort->Kind();
-      _list_datalinks[ind].aLinkValue = aSPValue;
-      _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
-    }
-  }
-#endif
-
   return _list_datalinks ;
 }
 
@@ -529,7 +561,7 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
   cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
             << endl;
   int i ;
-  bool RetVal = false ;
+  bool RetVal = true ;
 //#if 0
   GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
   for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
@@ -537,39 +569,53 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
   }
 //#endif
   if ( !strcmp( OldNodeName , NewNodeName ) ) {
-    RetVal = true ;
   }
   else if ( strcmp( Name() , OldNodeName ) ) {
     int index = GetGraphNodeIndex( OldNodeName ) ;
     int newindex = GetGraphNodeIndex( NewNodeName ) ;
     if ( index >= 0 && index < _GraphNodesSize &&
          ( newindex < 0 || newindex > _GraphNodesSize ) ) {
+      DelGraphNodeIndex( _GraphNodes[ index ]->Name() ) ;
       _GraphNodes[ index ]->Name( NewNodeName ) ;
-      _MapOfGraphNodes.erase( OldNodeName ) ;
-      SetGraphNodeIndex( NewNodeName , index ) ;
+//JR 29.06.2005 Debug ???
+//      SetGraphNodeIndex( NewNodeName , index ) ;
+      SetGraphNodeIndex( _GraphNodes[ index ]->Name() , index ) ;
 
       GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
 // Update 'ToNode's Map from 'aNode'
-      cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize "
+      cdebug << "Graph::ReNameNode " << aNode->Name() << "/" << OldNodeName << " LinkedNodesSize : "
              << aNode->LinkedNodesSize() << endl ;
       for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
         GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
         ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
       }
-// Update 'FomNode's Map to 'aNode'
+// Rename in _MapOfLinkedNodes of 'FromNode'
+      cdebug << "Graph::ReNameNode " << aNode->Name() << "/" << OldNodeName
+             << " LinkedFromNodesSize : " << aNode->LinkedFromNodesSize() << endl ;
+      for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
+        GraphBase::StreamNode * FromNode = aNode->LinkedFromNodes( i ) ;
+        if ( FromNode->GetLinkedNodeIndex( OldNodeName ) >= 0 ) {
+          FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
+       }
+        else {
+          FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
+       }
+      }
 // Inports 'anInPort' of 'aNode'
       for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
         GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
 // OutPort 'anOutPort' linked to 'anInPort'
         GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
-        cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
+        cdebug << i << ". " << aNode->Name() << "/" << OldNodeName
+               << " GraphBase::Graph::ReNameNode of LinkedNode : from " ;
         if ( anOutPort ) {
-          cdebug << anOutPort->NodeName() ;
+          cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )" ;
         }
         else {
           cdebug << "without link" ;
         }
-        cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
+        cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName
+               << " OldNodeName " << OldNodeName ;
         if ( !anInPort->IsNotConnected() ) {
           if ( anOutPort->IsDataConnected() ) {
             cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
@@ -583,25 +629,16 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
             else {
               FromNode = this ;
            }
-// Rename in _MapOfLinkedFromNodes of 'FromNode'
             cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
-            if ( anInPort->IsDataStream() ) {
-              FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
-           }
-            else {
-              FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
-           }
          }
           char* OldNodePortName = new char[ strlen( OldNodeName ) +
                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
           char* NewNodePortName = new char[ strlen( NewNodeName ) +
                                             strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
           strcpy( OldNodePortName , OldNodeName ) ;
-//          strcat( OldNodePortName , "\\" ) ;
           strcat( OldNodePortName , "__" ) ;
           strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
           strcpy( NewNodePortName , NewNodeName ) ;
-//          strcat( NewNodePortName , "\\" ) ;
           strcat( NewNodePortName , "__" ) ;
           strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
           RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
@@ -612,18 +649,50 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
         }
         else {
           cdebug << " not connected" << endl ;
-          RetVal = true ;
         }
       }
-      RetVal = true ;
+// PAL8508
+//JR 02.02.2005 DEBUG : ReName in the CoupledNode was missing
+      if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() ||
+           aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
+        GraphBase::GOTONode * theCoupledNode = NULL ;
+        theCoupledNode = (GraphBase::GOTONode * ) ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
+        theCoupledNode->CoupledNodeName( aNode->Name() ) ;
+      }
+      else if ( aNode->IsInLineNode() ) {
+        GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
+        if ( anOutPort ) {
+          GraphBase::ComputingNode * aLinkedNode ;
+          aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+          if ( aLinkedNode->IsGOTONode() ) {
+            ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( aNode->Name() ) ;
+         }
+       }
+      }
     }
     else {
-      cdebug << "ERROR Node not found" << endl ;
+      cdebug << "ERROR Node not found or conflicting NodeName" << endl ;
+      RetVal = false ;
     }
   }
   else {
-    RetVal = Name( NewNodeName ) ;
+    cdebug << "ReNameNode with same name." << endl ;
+//    RetVal = Name( NewNodeName ) ;
+  }
+
+#if 1
+  cdebug << "Graph::ReNameNode " << _GraphNodesSize << " known nodes" << endl;
+  for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
+    cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
+  }
+  map< string , int >::iterator aMapOfGraphNodesIterator ;
+  i = 0 ;
+  for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
+    aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
+    cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
+           << aMapOfGraphNodesIterator->second << " - 1" << endl ;
   }
+#endif
 
   cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
   return RetVal ;
@@ -634,12 +703,16 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
   int i ;
   bool RetVal = false ;
   int index = GetGraphNodeIndex( aNodeName ) ;
-  GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
+  GraphBase::ComputingNode * aNode = NULL ;
+  if ( index >= 0 ) {
+    aNode = GetChangeGraphNode( index ) ;
+  }
   if ( aNode ) {
     cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
            << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
            << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
-           << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode() << endl ;
+           << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode()
+           << " ConnectedInPortsNumber " << aNode->ConnectedInPortsNumber() << endl ;
     for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
       cdebug << "         LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
              << aNode->LinkedNodes( i )->Name() << endl ;
@@ -650,24 +723,42 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
                << aNode->LinkedFromNodes( i )->Name() << endl ;
       }
     }
+//PAL8177-PAL8509
+//JR 24.03.2005 : Debug : CoupledNode field of GOTONodes was not erased
+    if ( aNode->IsInLineNode() && aNode->GetNodeInPortsSize() ) { //mkr : IPAL10078
+      GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
+      if ( anOutPort ) {
+        GraphBase::ComputingNode * aLinkedNode ;
+        aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+        if ( aLinkedNode->IsGOTONode() ) {
+          cdebug << "Graph::RemoveNode erase CoupledNode " << aLinkedNode->Name() << endl ;
+          ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNode( NULL ) ;
+          ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( "" ) ;
+        }
+      }
+    }
     if ( !aNode->IsEndSwitchNode() ) {
       if ( aNode->GetNodeInPortsSize() ) {
         for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
           GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
-          cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
-                 << anInPort->PortStatus() << " <-- " ;
+          cdebug << "Graph::RemoveNode InPort" << i << ". " << aNodeName << "( "
+                 << anInPort->PortName() << ") " << anInPort->PortStatus() << " <-- " ;
           GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
           if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
-            cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
+            cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+                   << anOutPort->PortStatus() ;
           }
           cdebug << endl ;
           if ( !anInPort->IsNotConnected() ) {
+            GraphBase::ComputingNode * FromNode = NULL ;
             RetVal = true ;
             if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
-              cdebug << "     Data/Extern" << endl ;
+              cdebug << "     Data/Extern ignored" << endl ;
            }
             else {
-              GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+              FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
+           }
+            if ( FromNode ) {
               cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
                      << FromNode->LinkedNodesSize() << " and " << aNode->Name()
                      << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
@@ -684,14 +775,16 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
                   RetVal = FromNode->RemoveLinkedNode( aNode ) ;
                }
                 if ( !RetVal ) {
-                  cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
+                  cdebug << "Graph::RemoveNode anOutPort->RemoveLinkedNode Error RetVal "
+                         << RetVal << endl ;
                   break ;
                }
              }
            }
             RetVal = anOutPort->RemoveInPort( anInPort ) ;
             if ( !RetVal ) {
-              cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
+              cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
+                     << RetVal << endl ;
               break ;
            }
           }
@@ -723,14 +816,14 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
         int j ;
         for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
           GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
-          cdebug << "OutPort" << j << ". Remove " << anOutPort->InPortsSize()
+          cdebug << "Graph::RemoveNode OutPort" << j << ". Remove " << anOutPort->InPortsSize()
                  << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
                  << anOutPort->PortName() << ") "
                  << anOutPort->PortStatus() << " :" << endl ;
           int k ;
           for ( k = anOutPort->InPortsSize() - 1 ; k >= 0  ; k-- ) {
             GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
-            if ( strcmp( anInPort->NodeName() , aNode->Name() ) == 0 ) {
+            if ( !strcmp( anInPort->NodeName() , aNode->Name() ) ) {
 // InPort of the EndSwitchNode
               cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
                      << anInPort->PortName() << ") "
@@ -743,38 +836,57 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
 // false ==> No error for aNode->LinkedFromNode()
                 RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
                 if ( !RetVal ) {
-                  cdebug << "aLinkedFromNode->RemoveLinkedNode Error RetVal " << RetVal << endl ;
+                  cdebug << "Graph::RemoveNode aLinkedFromNode->RemoveLinkedNode Error RetVal "
+                         << RetVal << endl ;
                   break ;
                }
              }
-// Remove the InPort of the EndSwitchNode from that OutPort
+// the InPort of the EndSwitchNode from that OutPort was already removed by
+// anInPort->RemoveOutPort done above :
+#if 0
               RetVal = anOutPort->RemoveInPort( anInPort ) ;
               if ( !RetVal ) {
-                cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
+                cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
+                       << RetVal << endl ;
                 break ;
              }
+#endif
            }
          }
        }
       }
+      //mkr : fix for bugs IPAL9814 and IPAL9630
+      RetVal = true;
     }
 
     if ( RetVal ) {
       for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
         GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
-        cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
-               << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
+        cdebug << "Graph::RemoveNode OutPort" << i << ". Remove " << anOutPort->InPortsSize()
+               << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
+               << anOutPort->PortName() << ") "
                << anOutPort->PortStatus() << " :" << endl ;
         int j ;
         for ( j = anOutPort->InPortsSize() - 1 ; j >= 0  ; j-- ) {
           GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
-          cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
-                 << anInPort->PortStatus() << endl ;
-          if ( !anInPort->IsExternConnected() ) {
-            GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
+          GraphBase::ComputingNode * ToNode = NULL ;
+          cdebug << "       to InPort" << j << ". " << anInPort->NodeName() << "( "
+                 << anInPort->PortName() << ") "
+                 << anInPort->PortStatus() ;
+          if ( anInPort->IsExternConnected() ) {
+            cdebug << " ExternConnected ignored" << endl ;
+         }
+          else {
+            cdebug << endl ;
+            ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
+          }
+          if ( ToNode ) {
             RetVal = anInPort->RemoveOutPort() ;
+// JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
+// PAL7990
             if ( !RetVal ) {
-              cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
+              cdebug << "Graph::RemoveNode anOutPort->RemoveOutPort Error RetVal " << RetVal
+                     << endl ;
               break ;
            }
             if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
@@ -787,14 +899,55 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
               RetVal = aNode->RemoveLinkedNode( ToNode ) ;
            }
             if ( !RetVal ) {
-              cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
+              cdebug << "Graph::RemoveNode anOutPort->RemoveLinkedNode Error RetVal " << RetVal
+                     << endl ;
               break ;
            }
+// the InPort of the EndSwitchNode from that OutPort was already removed by
+// anInPort->RemoveOutPort done above :
+#if 0
             RetVal = anOutPort->RemoveInPort( anInPort ) ;
             if ( !RetVal ) {
-              cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
+              cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
+                     << RetVal << endl ;
               break ;
            }
+#endif
+            if ( ToNode->IsEndSwitchNode() ) {
+              int i ;
+              int done = false ;
+              for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
+                GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
+// Not the node that we are deleting ... :
+                if ( strcmp( fromNode->Name() , aNode->Name() ) ) {
+                  int j ;
+                  for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
+                    GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
+                    int k ;
+                    for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
+                      if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
+                        if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
+// Restore an OutPort in the InPort
+                          anInPort->ChangeOutPort( fromOutPort ) ;
+                          cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( "
+                                 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
+                                 << ToNode->Name() << "( " << anInPort->PortName() << " )"
+                                 << anInPort->Kind() << " " << anInPort->PortStatus()  << endl;
+                          done = true ;
+                          break ;
+                       }
+                     }
+                   }
+                    if ( done ) {
+                      break ;
+                   }
+                 }
+                  if ( done ) {
+                    break ;
+                 }
+               }
+             }
+           }
           }
        }
         if ( !RetVal ) {
@@ -803,6 +956,11 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
        }
       }
     }
+    if ( aNode->LinkedNodesSize() || aNode->LinkedFromNodesSize() ) {
+      cdebug << "Graph::RemoveNode ERROR LinkedNodesSize " << aNode->LinkedNodesSize()
+             << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
+      RetVal = 0 ;
+    }
     cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
            << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
            << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
@@ -823,10 +981,11 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
       char * theCoupledNodeName = NULL ;
       int CoupledIndex = -1 ;
       if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
-        theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
         theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
-        CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ;
+        theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
       }
+      cdebug << "Graph::RemoveNode Node" << index << " " << _GraphNodes[ index ]->Name()
+             << " will be deleted" << endl ;
       delete aNode ;
       _GraphNodesSize -= 1 ;
       for ( i = index ; i < _GraphNodesSize ; i++ ) {
@@ -835,8 +994,13 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
       }
       _GraphNodes.resize( _GraphNodesSize+1 ) ;
       _MapOfGraphNodes.erase( aNodeName ) ;
+// PAL8510
 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
       if ( theCoupledNode ) {
+//JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before)
+        CoupledIndex = GetGraphNodeIndex( theCoupledNodeName ) ;
+        cdebug << "Graph::RemoveNode CoupledNode" << CoupledIndex << " "
+               << _GraphNodes[ CoupledIndex ]->Name() << " will be deleted" << endl ;
         delete theCoupledNode ;
         _GraphNodesSize -= 1 ;
         for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
@@ -850,10 +1014,24 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
     }
   }
   else {
-    cdebug << "Node not found ERROR " << index << endl ;
+    cdebug << "Graph::RemoveNode Node not found ERROR " << index << endl ;
+  }
+
+#if 1
+  cdebug << "Graph::RemoveNode " << _GraphNodesSize << " known nodes" << endl;
+  for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
+    cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
+  }
+  map< string , int >::iterator aMapOfGraphNodesIterator ;
+  i = 0 ;
+  for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
+    aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
+    cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
+           << aMapOfGraphNodesIterator->second << " - 1" << endl ;
   }
+#endif
 
-  cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl;
+  cdebug_out << "Graph::RemoveNode " << RetVal << endl;
   return RetVal ;
 }
 
@@ -923,8 +1101,14 @@ bool GraphBase::Graph::AddLink( const char* FromNodeName ,
   if ( RetVal ) {
     if ( fromPort->IsGate() && toPort->IsGate() ) {
       CORBA::Any aValue ;
-      aValue <<= (long ) 1 ;
-      fromPort->Value( aValue ) ;
+//JR 29.09.2005 Debug for CEA : we do not do that for MacroNodes :
+      if ( !fromNode->IsMacroNode() ) {
+        aValue <<= (CORBA::Long ) 1 ;
+      }
+      else {
+        aValue <<= (CORBA::Long ) 0 ;
+      }
+      fromPort->SetValue( aValue ) ;
     }
 //    else {
 //      const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
@@ -971,20 +1155,29 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
     return false ;
   }
 
-  cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
-            << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "("
-            << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl;
+  cdebug_in << "Graph::AddLink( " << fromNode->Name() << "("
+            << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind()
+            << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
+            << ") " << toPort->Kind() << " )" << endl;
+  ostringstream LinkStrError ;
+  LinkStrError << "Creation of link from " << fromNode->Name() << "( "
+               << fromPort->PortName() << " " << fromPort->PortStatus() << " " << fromPort->Kind()
+               << " ) ---> " << toNode->Name() << "( " << toPort->PortName() << " "
+               << toPort->PortStatus() << " " << toPort->Kind() << " ) :\n" ;
   if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
     if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
-      cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
-                 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
+      cdebug_out << "GraphBase::Graph::AddLink in OutPort ( " << fromNode->Name() << "("
+                 << fromPort->PortName() << " " << fromPort->PortStatus()
+                 << ") RemoveInPort ERROR InPortsSize " << fromPort->InPortsSize() << endl ;
       return false ;
     }
   }
   if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
     if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
-      cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
-                 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
+      cdebug_out << "GraphBase::Graph::AddLink in InPort connected to the OutPort ( "
+                 << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
+                 << ") RemoveInPort ERROR InPortsSize " << toPort->GetOutPort()->InPortsSize()
+                 << endl ;
       return false ;
     }
   }
@@ -995,13 +1188,26 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
       cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
       return false ;
     }
+    if ( fromNode->IsGOTONode() && fromPort->IsGate() ) { // mkr : PAL12575
+      ((GraphBase::GOTONode * ) fromNode)->CoupledNode( (GraphBase::InLineNode * ) toNode ) ;
+    }
   }
 
   if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
        !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
        toPort->GetOutPort() ) {
-    if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
+//JR Debug 15.06.2005 : the case of multiple links to EndSwitchNode was missing :
+    if ( toNode->IsEndSwitchNode() && fromPort->GetInPort( toPort ) == toPort ) {
+      LinkStrError << "Link already exists.\n" ;
+      SetMessages( LinkStrError.str() ) ;
+      cdebug << "Link already exists" << endl ;
+      cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
+      return true ;
+    }
+    else if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
                   fromPort->NodePortName() ) ) {
+      LinkStrError << "Link already exists.\n" ;
+      SetMessages( LinkStrError.str() ) ;
       cdebug << "Link already exists" << endl ;
       cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
       return true ;
@@ -1028,16 +1234,65 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
         }
       }
     }
-    else if ( !toNode->IsEndSwitchNode() ||
-              ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
-      if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
+//PAL8511
+// JR 17.01.2005 : toPort is already linked : RemoveLink
+    else if ( !toNode->IsEndSwitchNode() ) {
+//    else if ( !toNode->IsEndSwitchNode() ||
+//              ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
+//JR Debug : the fromPort was wrong !
+//      if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
+      if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() ,
                         toNode->Name() , toPort->PortName() ) ) {
         cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
         cdebug_out << "GraphBase::Graph::AddLink" << endl;
         return false ;
       }
     }
+//JR 15.06.2005 : disabled : GraphSwitchBranchGates ...
+//    else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
+//      cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error."
+//             << endl ;
+//      LinkStrError << "Link from SwitchNode to EndSwitchNode is not allowed.\n" ;
+//      SetMessages( LinkStrError.str() ) ;
+//      cdebug << "Graph::AddLink ERROR Link from SwitchNode to EndSwitchNode is not allowed."
+//             << endl ;
+//      cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+//      return false ;
+//    }
+//JR 15.06.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
+//PAL8511
+//JR Debug 15.02.2005 : Not multiple links in that case except if toPort is the DefaultPort
+    else if ( fromNode->IsSwitchNode() && fromPort->IsGate() &&
+              !toNode->IsEndSwitchNode() ) {
+      LinkStrError << "Link from SwitchNode(Default) is allowed only to EndSwitchNode(Default).\n" ;
+      SetMessages( LinkStrError.str() ) ;
+      cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
+             << endl ;
+      cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+      return false ;
+    }
+  }
+//PAL7990
+//JR 24.03.2005 : No Link between OutPort of SwitchNode to InPort of EndSwitchNode except if
+// they have the same name for a special case :
+// Switch with no branch ==> Default is applied always : GraphSyrControl example
+//JR 22.06.2005 : Enhancement of the behaviour :
+//                For the DefaultBranch, if we have same PortsNames, Values are automatically
+//                    transmitted
+//                But for the DefaultBranch, if we have NOT same PortsNames, we may create links.
+//                Look at GraphSyrControlAve* ...
+#if 0
+  else if ( fromNode->IsSwitchNode() && !fromPort->IsGate() &&
+            toNode->IsEndSwitchNode() && !toPort->IsGate() &&
+            strcmp( fromPort->PortName() , toPort->PortName() ) ) {
+    LinkStrError << "Link from SwitchNode to EndSwitchNode with different PortNames is not allowed.\n" ;
+    SetMessages( LinkStrError.str() ) ;
+    cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode with different PortNames Error."
+           << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink" << endl;
+    return false ;
   }
+#endif
   else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
     if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
                       fromPort->ChangeInPorts(0)->NodeName() ,
@@ -1057,7 +1312,40 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
   }
 
 
-  if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
+// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
+  if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
+       fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
+    LinkStrError << "Link from SwitchNode Port linked to a Gate may be connected only to Gates.\n" ;
+    SetMessages( LinkStrError.str() ) ;
+    cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+    return false ;
+  }
+//JR 11.02.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
+//                SwitchNode(Param) may be linked to EndSwitchNode(Param)
+//                SwitchNode(Param-UserDefault) may be linked to EndSwitchNode(Default)
+  else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() &&
+            !( ( fromPort->IsGate() && toPort->IsGate() ) ||
+               ( !fromPort->IsGate() ) ) ) {
+//               ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) {
+    LinkStrError << "Link from SwitchNode to EndSwitchNode : different kinds of ports not allowed.\n" ;
+    SetMessages( LinkStrError.str() ) ;
+    cdebug << "Link ERROR from SwitchNode to EndSwitchNode : different kinds of ports not allowed."
+           << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+    return false ;
+  }
+//JR 15.06.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
+  else if ( fromNode->IsSwitchNode() && fromPort->IsGate() &&
+            !toNode->IsEndSwitchNode() ) {
+    LinkStrError << "Link from SwitchNode(Default) is allowed only to EndSwitchNode(Default).\n" ;
+    SetMessages( LinkStrError.str() ) ;
+    cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
+           << endl ;
+    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
+    return false ;
+  }
+  else if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
 //    if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
     if ( !fromPort->AddInPort( toPort ) ) {
       cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
@@ -1069,12 +1357,6 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
       toPort->Kind( SUPERV::EndSwitchParameter ) ;
     }
   }
-// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
-  else if ( fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
-    cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
-    cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
-    return false ;
-  }
   else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
     cdebug << "!fromPort->AddLink Error." << endl ;
     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
@@ -1087,7 +1369,10 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
     return false ;
   }
-  else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
+  else if ( !fromNode->IsSwitchNode() &&
+            ( fromPort->IsParam() || fromPort->IsInLine() ) && toPort->IsGate() ) {
+    LinkStrError << "Link from OutPort to a Gate is not allowed.\n" ;
+    SetMessages( LinkStrError.str() ) ;
     cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
     cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
     return false ;
@@ -1140,7 +1425,8 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
   }
   if ( fromNode->IsSwitchNode() ) {
     if ( !fromPort->IsDataStream() ) {
-      if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
+//JR 08.02.2005      if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
+      if ( fromPort->IsInLine() && toPort->IsGate() ) {
         fromPort->Kind( SUPERV::SwitchParameter ) ;
       }
       else if ( !fromPort->IsGate() && !toPort->IsGate() ){
@@ -1184,7 +1470,7 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
     if ( anInPort && ( anInPort->IsPortConnected() ||
                        anInPort->IsDataConnected() ||
                        anInPort->IsExternConnected() ) ) {
-// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
+// JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
       GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
       GraphBase::OutPort * anOutPort = NULL ;
       if ( toNode->IsEndSwitchNode() ) {
@@ -1204,12 +1490,35 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
          }
           else {
             fromNode->RemoveLinkedNode( toNode ) ;
+           // mkr : PAL12575 -->
+           if ( fromNode->IsGOTONode() ) {
+             GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) fromNode ;
+             if ( aGOTONode->CoupledNode() && strcmp( aGOTONode->CoupledNode()->Name(), toNode->Name() ) == 0 ) {
+               aGOTONode->CoupledNode(NULL);
+               aGOTONode->CoupledNodeName("");
+               
+               // set ExternConnected status for output data port of GoTo node
+               for ( int aPortId = 0 ; aPortId < fromNode->GetNodeOutPortsSize() ; aPortId++ ) {
+                 GraphBase::OutPort * anOutPort = fromNode->GetChangeNodeOutPort(aPortId) ;
+                 if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() )
+                   anOutPort->PortStatus( ExternConnected ) ;
+               }
+             }
+           }
+           // mkr : PAL12575 <--
          }
         }
-        if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
-          anOutPort->Kind( SUPERV::InLineParameter ) ;
+//JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
+//Debug : change the kind only if there is no other InGate connected to the OutPort
+        if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) {
+          if ( !toNode->IsEndSwitchNode() ) {
+            anOutPort->Kind( SUPERV::InLineParameter ) ;
+         }
+          else if ( !anInPort->IsGate() ) {
+            anOutPort->Kind( SUPERV::InLineParameter ) ;
+         }
         }
-// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be linked !!!
+// JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
         if ( toNode->IsEndSwitchNode() ) {
           int i ;
           int done = false ;
@@ -1221,13 +1530,16 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
               int k ;
               for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
                 if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
+                  if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
 // Restore an OutPort in the InPort
-                  anInPort->ChangeOutPort( fromOutPort ) ;
-                  cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
-                         << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
-                         << toNode->Name() << "( " << anInPort->PortName() << " )" << endl;
-                  done = true ;
-                  break ;
+                    anInPort->ChangeOutPort( fromOutPort ) ;
+                    cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
+                           << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
+                           << toNode->Name() << "( " << anInPort->PortName() << " )"
+                           << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
+                    done = true ;
+                    break ;
+                 }
                }
              }
               if ( done ) {
@@ -1258,8 +1570,10 @@ bool GraphBase::Graph::GetLink(const char* ToNodeName ,
     GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
     if ( anInPort && !anInPort->IsNotConnected() ) {
       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
-      *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
-      *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
+//JR 17.02.2005 Memory Leak      *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
+      *FromNodeName = (char * ) anOutPort->NodeName() ;
+//JR 17.02.2005 Memory Leak      *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
+      *FromServiceParameterName = (char * ) anOutPort->PortName() ;
       RetVal = true ;
     }
     else {
@@ -1281,11 +1595,15 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   bool RetVal = false ;
   cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
             << ToServiceParameterName << " , Any " ;
+  bool isUnknown = false;
   switch (aValue.type()->kind()) {
     case CORBA::tk_string:
-      char * t;
+      const char * t;
       aValue >>= t;
       cdebug << t << " (string) " ;
+      if ( !strcmp( t, "Unknown CORBA::Any Type" ) ) 
+       // mkr : IPAL8054 : in this case port has no input value
+       isUnknown = true;
       break;
     case CORBA::tk_double:
       double d;
@@ -1293,9 +1611,9 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
       cdebug << d << " (double) " ;
       break;
     case CORBA::tk_long:
-      long l;
+      CORBA::Long l;
       aValue >>= l;
-      cdebug << l << " (long) " ;
+      cdebug << l << " (CORBA::Long) " ;
       break;
     case CORBA::tk_objref:
       cdebug << "(object reference) " ;
@@ -1313,10 +1631,11 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   char *aPortName ;
   NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
   toNode = GetChangeGraphNode( aNodeName ) ;
-  cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
+  cdebug << "in Graph " << Name() << " aNodeName '" << aNodeName << "' aPortName '" << aPortName
+         << "'" << endl;
   if ( toNode ) {
     toPort = toNode->GetChangeInPort( aPortName ) ;
-    if ( toPort && !toPort->IsDataConnected() ) {
+    if ( toPort && !toPort->IsDataConnected() && toPort->GetOutPort() ) {
       toPort->RemoveOutPort() ;
     }
   }
@@ -1325,6 +1644,7 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   }
 
   int i ;
+  cdebug << endl << "Graph::AddInputData ListOfInOutPorts of the Graph : " << endl ;
   for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
     cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
   }
@@ -1344,15 +1664,16 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
     RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
                       toNode , toPort ) ;
     if ( RetVal ) {
-      fromDataNodePort->Value( aValue ) ;
-      fromDataNodePort->PortStatus( DataConnected ) ;
+      fromDataNodePort->SetValue( aValue ) ;
+      if ( !isUnknown ) // mkr : IPAL8054 : to avoid setting "strange" value to a port
+       fromDataNodePort->PortStatus( DataConnected ) ;
     }
   }
   else {
     cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
   }
-  delete aNodeName ;
-  delete aPortName ;
+  delete [] aNodeName ;
+  delete [] aPortName ;
 
   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
   return RetVal ;
@@ -1367,7 +1688,7 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
             << ToServiceParameterName << "' , Any " ;
   switch (aValue.type()->kind()) {
     case CORBA::tk_string:
-      char * t;
+      const char * t;
       aValue >>= t;
       cdebug << t << " (string) " ;
       break;
@@ -1377,9 +1698,9 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
       cdebug << d << " (double) " ;
       break;
     case CORBA::tk_long:
-      long l;
+      CORBA::Long l;
       aValue >>= l;
-      cdebug << l << " (long) " ;
+      cdebug << l << " (CORBA::Long) " ;
       break;
     case CORBA::tk_objref:
       cdebug << "(object reference) " ;
@@ -1403,9 +1724,9 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
       GraphBase::OutPort * fromPort = toPort->GetOutPort();
       if ( fromPort ) {
         RetVal = true ;
-        fromPort->Value( aValue ) ;
+        fromPort->SetValue( aValue ) ;
         fromPort->PortStatus( DataConnected ) ;
-        toPort->State( SUPERV::ReadyState ) ;
+        toPort->PortState( SUPERV::ReadyState ) ;
       }
       else {
         cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
@@ -1423,6 +1744,7 @@ bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
   return RetVal ;
 }
 
+#if 0
 // To restore InputData in CreateService
 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
                                      const char* ToServiceParameterName ,
@@ -1438,14 +1760,14 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
       cdebug << t << " (string) " ;
       break;
     case CORBA::tk_double:
-      double d;
+      CORBA::Double d;
       theValue >>= d;
       cdebug << d << " (double) " ;
       break;
     case CORBA::tk_long:
-      long l;
+      CORBA::Long l;
       theValue >>= l;
-      cdebug << l << " (long) " ;
+      cdebug << l << " (CORBA::Long) " ;
       break;
     case CORBA::tk_objref:
       cdebug << "(object reference) " ;
@@ -1486,6 +1808,7 @@ bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
   cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
   return RetVal ;
 }
+#endif
 
 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
                                       const char* FromServiceParameterName ,
@@ -1502,9 +1825,9 @@ bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
 //    toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
 //    RetVal = AddLink( fromNode , fromPort ,
 //                      (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
-    anOutPort->Value( aValue ) ;
-    anOutPort->State(  SUPERV::ReadyState ) ;
-    anOutPort->Done( true ) ;
+    anOutPort->SetValue( aValue ) ;
+    anOutPort->PortState(  SUPERV::ReadyState ) ;
+    anOutPort->PortDone( true ) ;
     cdebug << *anOutPort ;
 #ifdef _DEBUG_
     anOutPort->StringValue( *_fdebug ) ;
@@ -1519,6 +1842,8 @@ bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
   return RetVal ;
 }
 
+//JR This is used by StreamGraphs to list "CODES" and after that there is instances
+// for each Code (Nodes).
 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
                                            return _MapOfServiceNames ; }
 
@@ -1538,12 +1863,13 @@ bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
   return true ;
 }
 
-int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
-  GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
-  if ( theService == NULL ) {
-    return 1 ;
-  }
-  return theService->NewInstance() ;
+//PAL7961
+//JR Debug 25.03.2005 : with multiple instances et delete of instances, it was wrong
+//Bug created with the developpement of StreamGraphs
+int GraphBase::Graph::GetNewServiceInstanceNumber( char * aServiceName ) {
+  int InstanceNumber = _MapOfServiceInstanceNumber[ aServiceName ] + 1 ;
+  _MapOfServiceInstanceNumber[ aServiceName ] = InstanceNumber ;
+  return InstanceNumber ;
 }
 
 void GraphBase::Graph::SetGraphPorts() {
@@ -1552,7 +1878,7 @@ void GraphBase::Graph::SetGraphPorts() {
   for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
     GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
     cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
-           << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ;
+           << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
     if ( !anOutPort->IsGate() ) {
       anOutPort->PortStatus( ExternConnected ) ;
     }
@@ -1560,7 +1886,7 @@ void GraphBase::Graph::SetGraphPorts() {
   for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
     GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
     cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
-           << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ;
+           << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
     if ( !anInPort->IsGate() ) {
       GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
       anOutPort->PortStatus( ExternConnected ) ;
@@ -1569,6 +1895,23 @@ void GraphBase::Graph::SetGraphPorts() {
   cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
 }
 
+string GraphBase::Graph::Messages() {
+//  cdebug_in << "Graph::Messages" << endl ;
+//  cdebug_out << "Graph::Messages" << endl ;
+  return ( CORBA::string_dup( _Messages.c_str() ) ) ;
+}
+
+void GraphBase::Graph::ReSetMessages() {
+  cdebug << "Graph::ReSetMessages" << endl ;
+  _Messages = string( "" ) ;
+}
+
+void GraphBase::Graph::SetMessages( string anErrorMessage ) {
+  cdebug_in << "Graph::SetMessages" << endl ;
+  _Messages = _Messages + anErrorMessage + string( "\n" ) ;
+  cdebug_out << "Graph::SetMessages :" << endl << _Messages << endl ;
+}
+
 bool GraphBase::Graph::CreateService() {
   cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
   bool RetVal = true ;
@@ -1591,7 +1934,8 @@ bool GraphBase::Graph::CreateService() {
 //  if ( GraphMacroLevel() == 0 ) {
     for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
       if ( dostore == 1 ) {
-        aService.ServiceName = Name() ;
+//JR 17.02.2005 Memory Leak        aService.ServiceName = Name() ;
+        aService.ServiceName = my_strdup( Name() ) ;
         aService.ServiceinParameter.length( 0 ) ;
         aService.ServiceinParameter.length( innbr ) ;
         aService.ServiceoutParameter.length( 0 ) ;
@@ -1606,6 +1950,7 @@ bool GraphBase::Graph::CreateService() {
         OutNumberOfValues.resize( outnbr ) ;
       }
       else if ( dostore == 2 ) {
+//JR Creation of the Service (and of the Ports) with GraphBase::DataNode::DataService :
         cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
                << " instreamnbr " << instreamnbr << " outnbr " << outnbr
                << " outstreamnbr " << outstreamnbr << endl ;
@@ -1648,7 +1993,10 @@ bool GraphBase::Graph::CreateService() {
          }
           if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
                ( !anInPort->IsPortConnected() ||
-                 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
+//                 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
+//JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph
+                 ( anInPort->IsPortConnected() && isfromcouplednode ) ) &&
+               !aToNode->IsEndLoopNode() ) {
             if ( dostore == 0 ) {
               cdebug << "CreateService " << aToNode->Name() << " Input port "
                      << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
@@ -1711,8 +2059,11 @@ bool GraphBase::Graph::CreateService() {
 //            cdebug << " NULL" << endl ;
 //       }
           if ( !aFromNode->IsGOTONode() ) {
-            if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
-                                           anOutPort->IsExternConnected() ) {
+            if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected()  ||
+//JR PAL8914 : OutPorts of LoopNodes may not be in the Service of the Graph
+//                                           anOutPort->IsExternConnected() ) {
+                                           anOutPort->IsExternConnected() ) &&
+                 !aFromNode->IsLoopNode() ) {
               if ( dostore == 0 ) {
 //                cdebug << "CreateService " << aFromNode->Name() << " Output port "
 //                       << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
@@ -1743,7 +2094,7 @@ bool GraphBase::Graph::CreateService() {
     }
 //  }
 
-#if 0
+#if 1
   cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
          << " OutPorts " << outnbr << endl ;
   for ( i = 0 ; i < innbr ; i++ ) {
@@ -1767,8 +2118,8 @@ bool GraphBase::Graph::CreateService() {
 //  DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
   for ( i = 0 ; i < innbr ; i++ ) {
     if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
-      GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
-                                                                    StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
+      GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername,
+                                                                    aService.ServiceinParameter[ i ].Parametertype,
                                                                     InDataStreamDependency[ i ] ,
                                                                     SUPERV::DataStreamParameter ) ;
       anInPort->SetParams( InKindOfSchema[ i ] ,
@@ -1797,15 +2148,19 @@ bool GraphBase::Graph::CreateService() {
       _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
       GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
       _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
-      cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
-      cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
+      cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " "
+             << GetChangeNodeInPort( i )->Kind() << " " << GetChangeNodeInPort( i )->PortStatus()
+             << endl ;
+      cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " "
+             << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() << " "
+             << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortStatus()
              << endl ;
     }
   }
   for ( i = 0 ; i < outnbr ; i++ ) {
     if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
       GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
-                                                                       StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
+                                                                       aService.ServiceoutParameter[ i ].Parametertype ,
                                                                        OutDataStreamDependency[ i ] ,
                                                                        SUPERV::DataStreamParameter ) ;
       anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
@@ -1832,8 +2187,12 @@ bool GraphBase::Graph::CreateService() {
       _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
       GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
       _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
-      cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
-      cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
+      cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " "
+             << GetChangeNodeOutPort( i )->Kind() << " " << GetChangeNodeOutPort( i )->PortStatus()
+             << endl ;
+      cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName()
+             << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
+             << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortStatus()
              << endl ;
     }
   }
@@ -1849,7 +2208,9 @@ bool GraphBase::Graph::CreateService() {
       if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
         if ( !AddInputData( anInPort->NodeName() ,
                             anInPort->PortName() ,
-                            anInPort->GetOutPort()->ValuePtr() ) ) {
+//JR 21.02.2005 Debug Memory leak :                            anInPort->GetOutPort()->ValuePtr() ) ) {
+//JR 30.03.2005                            *anInPort->GetOutPort()->Value() ) ) {
+                            anInPort->GetOutPort()->Value() ) ) {
           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
                  << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
           RetVal = false ;
@@ -1859,7 +2220,11 @@ bool GraphBase::Graph::CreateService() {
                  << anInPort->PortStatus() << " --> AddInputData" << endl ;
        }
       }
-      else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
+//JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph
+//      else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
+      else if ( !anInPort->IsGate() &&
+                ( anInPort->IsNotConnected() || anInPort->IsExternConnected() ) &&
+                !aToNode->IsEndLoopNode() ) {
         if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
           cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
                  << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
@@ -1870,12 +2235,20 @@ bool GraphBase::Graph::CreateService() {
                  << anInPort->PortStatus() << " --> AddInLink" << endl ;
        }
       }
+      else {
+        cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
+               << anInPort->PortStatus() << " --> NO AddInputData/AddInLink" << endl ;
+      }
     }
     for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
       GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
       cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
              << ") " << anOutPort->PortStatus() << " :" << endl ;
-      if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
+//JR PAL8914 : OutPorts of LoopNodes may not be in the Service of the Graph
+//      if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
+      if ( !anOutPort->IsGate() && !aToNode->IsGOTONode() && !aToNode->IsLoopNode() &&
+//JR Debug : 06.09.2005 : recreate that link if the OutPort is ExternConnected !!!...
+           ( anOutPort->IsNotConnected() || anOutPort->IsExternConnected() ) ) {
         GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
         if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
           cdebug << "       --> " << Name() << "(" << anInPort->PortName()
@@ -1890,6 +2263,14 @@ bool GraphBase::Graph::CreateService() {
     }
   }
 
+#ifdef _DEBUG_
+  ListPorts( *_Graph_fdebug , 0 ) ;
+#endif
+
+  if ( !RetVal ) {
+    SetMessages( "Fail to create the Service of the graph.\n" ) ;
+  }
+
   cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
   return RetVal ;
 }
@@ -1929,7 +2310,7 @@ bool GraphBase::Graph::InLineServices() {
        }
         else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
           aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
-          aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
+          aService.ServiceinDataStreamParameter[InStreamService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
           aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
           aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
           aINode->IncrDataStreamInPorts() ;
@@ -1972,7 +2353,7 @@ bool GraphBase::Graph::InLineServices() {
        }
         else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
           aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
-          aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
+          aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
           aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
           aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
           aINode->IncrDataStreamOutPorts() ;
@@ -2016,6 +2397,10 @@ bool GraphBase::Graph::InLineServices() {
 }
 
 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
+#ifdef _DEBUG_
+  ListPorts( *_Graph_fdebug , 0 ) ;
+#endif
+
   int i ;
   int j ;
   int NotSortedNumber = GraphNodesSize() ;
@@ -2106,7 +2491,8 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
 // will wait for data(s) from node(s) not executed or not executing for ever
       if ( !NewSorted ) {
-        cdebug << "Loop detected level " << _LevelsNumber << endl ;
+        SetMessages( "That graph is cyclic.\n" ) ;
+        cdebug << "ERROR Loop detected at level " << _LevelsNumber << endl ;
        return false ; // Loop in the Graph
       }
 //      cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
@@ -2169,12 +2555,15 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
 //      cdebug << "No Parallel Execution Nodes detected." << endl ;
     }
     if ( AllSortedNodes != GraphNodesSize() ) {
-      cdebug << "Loop detected level " << _LevelsNumber << endl ;
+      SetMessages( "That graph is cyclic.\n" ) ;
+      cdebug << "ERROR Loop detected at level " << _LevelsNumber << endl ;
       return false ; // Loop in the Graph
     }
 
+    cdebug << "Graph::Sort " << _NodesNumber[ 0 ] << " HeadNodes :" << endl ;
     for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
       (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
+      cdebug << "            " << i << ". : " << (_SortedNodes[ 0 ])[ i ]->Name() << endl ;
     }
 
 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
@@ -2403,9 +2792,62 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
   return true ;
 }
 
+// mkr : PAL12575
+bool GraphBase::Graph::ValidGOTO() {
+  cdebug_in << "GraphBase::Graph::ValidGOTO" << endl;
+  bool RetVal = true ;
+  int i, j ;
+  GraphBase::ComputingNode * aNode ;
+  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+    aNode = GraphNodes( i ) ;
+    if ( aNode->IsGOTONode() ) {
+      GraphBase::GOTONode * aGoToNode = (GraphBase::GOTONode * ) aNode ;
+      GraphBase::InLineNode * aCoupledNode ;
+      aCoupledNode = (GraphBase::InLineNode * ) aGoToNode->CoupledNode() ;
+      if ( aCoupledNode ) {
+       ostringstream ErrorMessage ;
+       // 1. Check the number of ports (the number of OutPorts of a GOTONode and of InPorts of its linked
+       //    InLine node must be the same)
+       if ( aNode->GetNodeOutPortsSize() != aCoupledNode->GetNodeInPortsSize() ) {
+         cdebug << "GraphBase::Graph::ValidGOTO : Different ports number!" << endl ;
+         ReSetMessages() ;
+         ErrorMessage << "Different ports number : the number of OutPorts of a " << aNode->Name()
+                      << " node (GoTo node) and of InPorts of its linked " << aCoupledNode->Name()
+                      << " node (InLine node) must be the same!\n" ;
+         SetMessages( ErrorMessage.str() ) ;
+         RetVal = false ;
+       }
+       // 2. Check ports names (the names of OutPorts of a GOTONode and of InPorts of its linked
+       //    InLine node must be the same)
+       else {
+         for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
+           GraphBase::OutPort * aBusParamOutPort = aNode->GetChangeNodeOutPort( j ) ;
+           if ( !aBusParamOutPort->IsGate() ) {
+             GraphBase::InPort * aBusParamChangeInPort = NULL ;
+             aBusParamChangeInPort = aCoupledNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
+             if ( !aBusParamChangeInPort ) {
+               cdebug << "GraphBase::Graph::ValidGOTO : Different names of ports!" << endl ;
+               ReSetMessages() ;
+               ErrorMessage << "Different names of ports : there is no input port of " << aCoupledNode->Name()
+                            << " node (InLine node) coupled to " << aBusParamOutPort->PortName() 
+                            << " output port of a " << aNode->Name()
+                            << " node (GoTo node)\n" ;
+               SetMessages( ErrorMessage.str() ) ;
+               RetVal = false ;
+             }
+           }
+         }
+       }
+      }
+    }
+  }
+  cdebug_out << "GraphBase::Graph::ValidGOTO RetVal " << RetVal << endl;
+  return RetVal ;
+}
+
 bool GraphBase::Graph::ValidLoops() const {
   cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
-
+  bool RetVal = true ;
   int i ;
   GraphBase::ComputingNode * aNode ;
   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
@@ -2414,20 +2856,47 @@ bool GraphBase::Graph::ValidLoops() const {
       GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
       GraphBase::EndOfLoopNode * anEndLoopNode ;
       anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
-      if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
-        cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
-                   << endl;
-        return false ;
+      string anErrorMessage = string( "CheckLoop " ) + string( aLoopNode->Name() ) +
+                              string( " --> " ) + string( anEndLoopNode->Name() ) +
+                              string( " :\n" ) ;
+      if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) {
+        ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
+        cdebug << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
+               << endl;
+        RetVal = false ;
       }
-      else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
-        cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
-                   << endl;
-        return false ;
+      anErrorMessage = string( "CheckEndLoop " ) + string( aLoopNode->Name() ) +
+                       string( " --> " ) + string( anEndLoopNode->Name() ) + string( " :\n" ) ;
+      if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode , anErrorMessage ) ) {
+        ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
+        cdebug << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
+               << endl;
+        RetVal = false ;
       }
     }
   }
-  cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
-  return true ;
+  cdebug_out << "GraphBase::Graph::ValidLoops RetVal " << RetVal << endl;
+  return RetVal ;
+}
+
+bool GraphBase::Graph::ValidSwitchs() const {
+  cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl;
+  bool RetVal = true ;
+  int i ;
+  GraphBase::ComputingNode * aNode ;
+  for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+    aNode = GraphNodes( i ) ;
+    if ( aNode->IsSwitchNode() ) {
+      GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ;
+      if ( !aSwitchNode->CheckSwitch() ) {
+        cdebug << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name()
+               << endl;
+        RetVal = false ;
+      }
+    }
+  }
+  cdebug_out << "GraphBase::Graph::ValidSwitchs RetVal " << RetVal << endl;
+  return RetVal ;
 }
 
 // Controle de la coherence des noeuds de calcul
@@ -2435,7 +2904,7 @@ bool GraphBase::Graph::ValidLoops() const {
 
 bool GraphBase::Graph::ComputingNodes() const {
   bool RetVal = true ;
-  cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
+  cdebug << "GraphExecutor::Graph::ComputingNodes ()" << endl;
 
 //  list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
 //  list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
@@ -2447,6 +2916,8 @@ bool GraphBase::Graph::ComputingNodes() const {
   GraphBase::ComputingNode * aNode ;
   for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
     aNode = GraphNodes( i ) ;
+    cdebug << "Graph::ComputingNodes " << i << ". " << aNode->Name() << " Head " << aNode->IsHeadNode()
+           << endl ;
     // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
     // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
 //    if ((*aNode)->GetNodeInPortsSize() == 0)
@@ -2458,6 +2929,10 @@ bool GraphBase::Graph::ComputingNodes() const {
 //     cdebug << "Le port d'entree " << iP->PortName()
 //               << " du noeud de calcul " << aNode->Name() << " du graphe  "
 //               << Name() << " n'est pas connecte "<< endl;
+//        string anErrorMessage = string( "That graph have InPort not connected " ) +
+//                                string( iP->NodeName() ) +
+//                                string( "( " ) + string( iP->PortName() ) + string( " )\n" ) ;
+//        ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
         RetVal = false ;
       };
 
@@ -2475,6 +2950,10 @@ bool GraphBase::Graph::ComputingNodes() const {
 //     cdebug << "Le port de sortie " << iP->PortName()
 //               << " du noeud de calcul " << aNode->Name() << " du graphe  "
 //               << Name() << " n'est pas connecte "<< endl;
+//        string anErrorMessage = string( "That graph have OutPort not connected " ) +
+//                                string( iP->NodeName() ) +
+//                                string( "( " ) + string( iP->PortName() ) + string( " )\n" ) ;
+//        ((GraphBase::Graph * ) this)->SetMessages( anErrorMessage ) ;
         RetVal = false ;
       }
     };
@@ -2499,12 +2978,16 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
       GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
       for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
         GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
+        cdebug << "Graph::LinkLoopNodes " << aLoopNode->Name() << "( " << anInPort->PortName()
+               << " ) InPort " << anInPort->PortStatus() << endl ;
         if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
           if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
                          aLoopNode , anInPort ) ) {
-//            cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
-//                   << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
-//                   << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
+            cdebug << "Graph::LinkLoopNodes AddLink ERROR "
+                   << aLoopNode->CoupledNode()->Name()
+                   << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName()
+                   << " ) --> " << aLoopNode->Name() << "( " << anInPort->PortName() << " )"
+                   << endl ;
             RetVal = false ;
          }
           else {
@@ -2513,13 +2996,18 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
        }
       }
       for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
-        GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
+        GraphBase::EndOfLoopNode * anEndLoopNode ;
+        anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
+        GraphBase::InPort *anInPort = anEndLoopNode->GetChangeNodeInPort( j ) ;
+        cdebug << "Graph::LinkLoopNodes " << anEndLoopNode->Name() << "( " << anInPort->PortName()
+               << " ) InPort " << anInPort->PortStatus() << endl ;
         if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
           if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
-                         aLoopNode->CoupledNode() , anInPort ) ) {
-//            cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
-//                   << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
-//                   << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
+                         anEndLoopNode , anInPort ) ) {
+            cdebug << "Graph::LinkLoopNodes AddLink ERROR " << aLoopNode->Name() << "( "
+                   << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
+                   << anEndLoopNode->Name() << "( " << anInPort->PortName() << " )"
+                   << endl ;
             RetVal = false ;
          }
           else {
@@ -2532,20 +3020,23 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
       GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
       GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
       if ( anOutGate->IsNotConnected() ) {
-       RetVal = aGOTONode->CoupledNode() != NULL;
-       if ( RetVal ) {
-         RetVal = AddLink( aGOTONode , anOutGate ,
-                       aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() );
-       // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
-       //        << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
-       //        << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
+       if ( aGOTONode->CoupledNode() ) {
+          cdebug << "Graph::LinkLoopNodes aNode " << aNode << " : " << aNode->Name()
+                 << aGOTONode->CoupledNode() << " : " << aGOTONode->CoupledNode()->Name()
+                 << endl ;
+         RetVal = AddLink( aGOTONode , anOutGate , aGOTONode->CoupledNode() ,
+                            aGOTONode->CoupledNode()->GetChangeNodeInGate() );
+         cdebug << "GraphBase::Graph::LinkLoopNodes AddLink ERROR " << aGOTONode->Name() << "( "
+                << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
+                << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
          if ( !RetVal )
            NewLink = true;
        }
       }
     }
   }
-  cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
+  cdebug_out << "GraphBase::Graph::LinkLoopNodes() NewLink " << NewLink << " returns " << RetVal
+             << endl;
   return RetVal ;
 }
 
@@ -2554,7 +3045,7 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
 
 bool GraphBase::Graph::DataServerNodes() const {
 
-  cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
+  cdebug_in << "GraphBase::Graph::DataServerNodes ()" << endl;
 
 //  const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
   int i , j , ierr = 0 ;
@@ -2598,8 +3089,14 @@ bool GraphBase::Graph::DataServerNodes() const {
     }
 // For Outputs of the DataFlow :
       for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
-        if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
-          if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
+        const GraphBase::OutPort * anOutPort = aNode->GetNodeOutPort(j) ;
+//JR Debug 06.06.2005 : if it is not a Gate !
+//        if ( anOutPort->IsNotConnected() ) {
+        if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() && !aNode->IsGOTONode() ) { // mkr : PAL12575
+          cdebug << "Graph::DataServerNodes Add[Stream]LinkedNode for OutPort "
+                 << aNode->Name() << "( " << anOutPort->PortName() << " , "
+                 << anOutPort->PortStatus() << " )" << endl ;
+          if ( anOutPort->IsDataStream() ) {
             aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
          }
           else {
@@ -2661,6 +3158,7 @@ bool GraphBase::Graph::DataServerNodes() const {
 //  };
 
 //  return _dataServerError.size ();
+  cdebug_out << "GraphBase::Graph::DataServerNodes ierr " << ierr << endl;
   return ( ierr == 0 ) ;
 }
 
@@ -2689,7 +3187,7 @@ SUPERV::GraphState GraphBase::Graph::PortState(
       }
     }
     if ( anOutPort ) {
-      aRet = anOutPort->State() ;
+      aRet = anOutPort->PortState() ;
 //      cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
     }
   }
@@ -2702,13 +3200,18 @@ SUPERV::GraphState GraphBase::Graph::PortState(
   return aRet ;
 }
 
-const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
-                                                 const char* ToServiceParameterName ) {
-  const CORBA::Any * aRet = new CORBA::Any() ;
+#define TracePortInOutData 0
+//JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
+const CORBA::Any GraphBase::Graph::PortInData( const char* ToNodeName ,
+                                               const char* ToServiceParameterName ) {
+//JR 30.03.2005  const CORBA::Any * aRet = new CORBA::Any() ;
+  CORBA::Any aRet = CORBA::Any() ;
   char *theNode ;
   char *aPort ;
-//  cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
-//            << ToServiceParameterName << endl ;
+#if TracePortInOutData
+  cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
+            << ToServiceParameterName << endl ;
+#endif
   NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
 
   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
@@ -2719,10 +3222,19 @@ const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
     if ( anInPort ) {
       anOutPort = anInPort->GetOutPort() ;
       if ( anOutPort ) {
+#if TracePortInOutData
+        cdebug << "-->PortInData " << ToNodeName << " " << ToServiceParameterName << " "
+               << endl ;
+#endif
         aRet = anOutPort->Value() ;
+#if TracePortInOutData
+        cdebug << "<--PortInData " << ToNodeName << " " << ToServiceParameterName << " " ;
+        anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+        cdebug << endl ;
         cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
                << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
                << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
+#endif
       }
       else {
         cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
@@ -2734,23 +3246,34 @@ const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
              << ToServiceParameterName << " ERROR no InPort" << endl ;
     }
   }
+  else if ( !strcmp( ToNodeName , Name() ) &&
+            !strcmp( ToServiceParameterName , "Gate" ) ) {
+    cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
+           << ToServiceParameterName << " InGate ignored" << endl ;
+  }
   else {
     cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
            << ToServiceParameterName << " ERROR no Node" << endl ;
   }
-  delete theNode ;
-  delete aPort ;
-//  cdebug_out << "GraphBase::Graph::PortInData " << endl ;
+  delete [] theNode ;
+  delete [] aPort ;
+#if TracePortInOutData
+  cdebug_out << "GraphBase::Graph::PortInData " << endl ;
+#endif
   return aRet ;
 }
 
-const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
-                                                  const char* FromServiceParameterName ) {
-  const CORBA::Any * aRet = new CORBA::Any() ;
+//JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
+const CORBA::Any GraphBase::Graph::PortOutData( const char* FromNodeName ,
+                                                const char* FromServiceParameterName ) {
+//JR 30.03.2005  const CORBA::Any * aRet = new CORBA::Any() ;
+  CORBA::Any aRet = CORBA::Any() ;
   char *theNode ;
   char *aPort ;
-//  cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
-//            << FromServiceParameterName << endl ;
+#if TracePortInOutData
+  cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
+            << FromServiceParameterName << endl ;
+#endif
   NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
 
   GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
@@ -2759,20 +3282,36 @@ const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
     GraphBase::OutPort *anOutPort ;
     anOutPort = aNode->GetChangeOutPort( aPort );
     if ( anOutPort ) {
+#if TracePortInOutData
+      cdebug << "-->PortOutData " << FromNodeName << " " << FromServiceParameterName << " "
+             << endl ;
+#endif
       aRet = anOutPort->Value() ;
+#if TracePortInOutData
+      cdebug << "<--PortOutData " << FromNodeName << " " << FromServiceParameterName << " " ;
+      anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+      cdebug << endl ;
+#endif
     }
     else {
       cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
              << FromServiceParameterName << " ERROR no OutPort" << endl ;
     }
   }
+  else if ( !strcmp( FromNodeName , Name() ) &&
+            !strcmp( FromServiceParameterName , "Gate" ) ) {
+    cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
+           << FromServiceParameterName << " OutGate ignored" << endl ;
+  }
   else {
     cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
            << FromServiceParameterName << " ERROR no Node" << endl ;
   }
-  delete theNode ;
-  delete aPort ;
-//  cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
+  delete [] theNode ;
+  delete [] aPort ;
+#if TracePortInOutData
+  cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
+#endif
   return aRet ;
 }
 
@@ -2797,15 +3336,20 @@ bool GraphBase::Graph::StartComponent(const int aThread ,
             << " GraphBase::Graph::StartComponent " << aComputerContainer
             << " " << ComponentName << endl;
   bool RetVal = true ;
-
+  objComponent = Engines::Component::_nil() ;
   SALOME_LifeCycleCORBA LCC( NamingService() ) ;
-  objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
-                                          ComponentName );
+  try {
+    objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
+                                            ComponentName );
+  }
+  catch (...) {
+    RetVal = 0 ;
+  }
   if ( CORBA::is_nil( objComponent ) ) {
     cdebug_out << aThread 
                << " StartComponent cannot FindOrLoad " << aComputerContainer
                << " " << ComponentName << " ERROR" << endl;
-    return 0 ;
+    RetVal = 0 ;
   }
   /* asv : 24.01.05 : FindContainer() method does not exist any more.  FindOrLoad_Component()
                       starts the container for us.  If it fails to start the container, then it
@@ -2822,6 +3366,12 @@ bool GraphBase::Graph::StartComponent(const int aThread ,
     }
   }
   */
-  cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;
+  if ( !RetVal ) {
+    string anErrorMessage = string( "Error while FindOrLoad_Component " ) +
+                            string( ComponentName ) + string( " in Container " ) +
+                            string( aComputerContainer )  ;
+    SetMessages( anErrorMessage ) ;
+  }
+  cdebug_out << aThread << " GraphBase::Graph::StartComponent RetVal " << RetVal << endl;
   return RetVal ;
 }