Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/superv.git] / src / Supervision / Graph_Impl.cxx
index 726e57403bd4ecc2b6f5cbe75884b26fc019c93f..5eb33e4115de4dc2c3dd4e85649985eaa880fba5 100644 (file)
@@ -34,6 +34,8 @@ using namespace std;
 
 //#include "utilities.h"
 
+#include "SALOME_Container_i.hxx"
+
 #include "StreamGraph_Impl.hxx"
 
 #include "DataFlowEditor_DataFlow.hxx"
@@ -142,6 +144,7 @@ static void CreateExecutor( CORBA::ORB_ptr orb ,
   *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
                                                     theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
                                                     aKindOfNode ) ;
+
   MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
            << dbgfile.c_str() ) ;
 
@@ -251,9 +254,9 @@ void Graph_Impl::destroy() {
     }
   }
   _poa->deactivate_object(*_id) ;
-  CORBA::release(_poa) ;
+//  CORBA::release(_poa) ;
   delete(_id) ;
-  _thisObj->_remove_ref();
+//  _thisObj->_remove_ref();
   endService( "Graph_Impl::destroy" );
 }
 
@@ -365,6 +368,15 @@ bool Graph_Impl::Export(const char * anXmlFile ) {
   return RetVal ;
 }
 
+char *  Graph_Impl::SavePY( bool importSuperV ) {
+  beginService( "Graph_Impl::SavePY" );
+  ostringstream fstring ;
+  bool RetVal ;
+  RetVal = DataFlowEditor()->SavePY( fstring , importSuperV ) ;
+  fstring  << ends ;
+  endService( "Graph_Impl::SavePY" );
+  return CORBA::string_dup( fstring.str().c_str() );
+}
 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
   beginService( "Graph_Impl::CNode" );
   SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
@@ -388,7 +400,8 @@ SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeSe
 
 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
                                      const char * NodeInterfaceName ,
-                                     const SALOME_ModuleCatalog::Service &NodeService ) {
+                                     const SALOME_ModuleCatalog::Service &NodeService ,
+                                    bool isCimpl ) {
   beginService( "Graph_Impl::FNode" );
   SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
   if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
@@ -397,7 +410,10 @@ SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
                                           DataFlowEditor() ,
                                           NodeService ,
                                           NodeComponentName ,
-                                          NodeInterfaceName ) ;
+                                          NodeInterfaceName ,
+                                         NULLSTRING ,
+                                         SUPERV::FactoryNode ,
+                                         isCimpl ) ;
     if ( myNode->DataFlowNode() ) {
       PortableServer::ObjectId * id = myNode->getId() ;
       CORBA::Object_var obj = _poa->id_to_reference(*id);
@@ -519,8 +535,10 @@ SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
       myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
       myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
       myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
-      Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
-      Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
+//JR 25.01.2005  That links are already done in SetCoupled above ...
+//      Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
+//      Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
+//      Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
     }
   }
   anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
@@ -811,13 +829,19 @@ SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlow
           aMacroGraphExe->CoupledNode( aMacroNode ) ;
           aMacroNode->CoupledNode( aMacroGraphExe ) ;
 
+//JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
+//                      InPorts values of MacroGraphs of MacroNodes are done in the Executor
+// It was probably to try to debug anything but it was a wrong debug and I do not know what bug
+// ===> folowing code is commented
+#if 0
          // initialize MacroNode's InPorts with corresponding "external" values
          int q ;
          for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
            const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
            if ( anInPort->IsDataConnected() ) {
              const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
-             if ( !aMacroGraphExecutor->InputOfAny(  aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
+//JR 30.03.2005              if ( !aMacroGraphExecutor->InputOfAny(  aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
+             if ( !aMacroGraphExecutor->InputOfAny(  aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
                return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
              }
              else {
@@ -826,7 +850,7 @@ SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlow
              }
            }
          } // end of init MacroNode's InPorts
-
+#endif
          aMacroGraphImpl->Run() ;
 
         }
@@ -1015,35 +1039,40 @@ SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
     aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
     aDataFlowNode->SetObjImpl( this ) ;
 
+    GraphBase::Graph * aSubGraph = NULL ;
 //    GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
-    GraphBase::Graph * aGraph ;
     //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
+//JR 20.09.2005 Debug SAB_data_1609_bugPAL.py from CEA (Anthony)
+//    Graph_Impl * aSubGraphImpl = dynamic_cast<Graph_Impl * >( _Poa->id_to_servant( *myMacroGraph->_Id ) ) ;
+    myMacroGraph->ping() ;
+    Graph_Impl * aSubGraphImpl = theAutomaton->GraphImpl() ;
+    aSubGraph = aSubGraphImpl->DataFlowEditor()->Graph() ;
     myMacroGraph->Coupled() ;
     GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
     GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
     aMacroGraph->Kind( SUPERV::MacroNode ) ;
     aMacroGraph->GraphEditor( DataFlowEditor() ) ;
 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
-    aMacroGraph->SetMacroPorts( aGraph ) ;
+    aMacroGraph->SetMacroPorts( aSubGraph ) ;
 // Valid ==> creation of Service and the ports of the current Graph
     DataFlowEditor()->IsValid() ;
 // Set the Input Datas from the GraphMacroNode to the current Graph
-    aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
+    aMacroGraph->SetMacroDatas( aSubGraph , aGraphOfMacroGraph ) ;
 //    aMacroGraphDataFlowEditor->UnValid() ;
-    aGraph->GraphEditor()->UnValid() ;
+    aSubGraph->GraphEditor()->UnValid() ;
 // Set the MacroNode ObjRef in the GraphMacroNode
-    aGraph->CoupledNode( aMacroGraph ) ;
-    aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
+    aSubGraph->CoupledNode( aMacroGraph ) ;
+    aSubGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
 // Set the GraphMacroNode ObjRef in the MacroNode
     aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
-    aMacroGraph->CoupledNode( aGraph ) ;
+    aMacroGraph->CoupledNode( aSubGraph ) ;
     aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
-//    aDataFlowNode->CoupledNode( aGraph ) ;
+//    aDataFlowNode->CoupledNode( aSubGraph ) ;
 //    aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
 // Set the MacroLevel of that graph
-    aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
+    aSubGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
     aMacroGraph->Coordinates( 0 , 0 ) ;
-    MESSAGE( aGraph->Name() << "->CoupledNode()->GraphEditor() : " << aGraph->CoupledNode()->GraphEditor() ) ;
+    MESSAGE( aSubGraph->Name() << "->CoupledNode()->GraphEditor() : " << aSubGraph->CoupledNode()->GraphEditor() ) ;
     MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
              << aMacroGraph->CoupledNode()->GraphEditor() ) ;
     MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
@@ -1160,6 +1189,8 @@ SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
         }
       }
       else {
+        MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
+                 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
         iobject = anOutPort->InPortObjRef( anInPort ) ;
       }
     }
@@ -1375,8 +1406,14 @@ SUPERV::ListOfNodes * Graph_Impl::Nodes() {
   RetVal->Graphs.length(0) ;
   if ( !IsMacro() ) {
     int i ;
+    MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
+             << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
     for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
       GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
+#if 1
+      MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
+               << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
+#endif
       RetVal = SetNode( RetVal , aNode ) ;
     }
 #if 0
@@ -1472,8 +1509,10 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
 //                        << anOutPort->PortName() << ") --> " << aNode->Name() << "("
 //                        << anInPort->PortName() << ")" ) ;
                 if ( theNode == NULL ||
-                     ( theNode != NULL && !theNode->IsEndSwitchNode() &&
-                       !strcmp( theNode->Name() , aNode->Name() ) ) ) {
+//PAL8521
+//JR 14.02.2005 : Debug : we must see also that links !
+//                     ( theNode != NULL && !theNode->IsEndSwitchNode() &&
+                       !strcmp( theNode->Name() , aNode->Name() ) ) {
                   if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
                        ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
                                                             anOutPort->NodeName() ) ) ) {
@@ -1542,7 +1581,9 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
             if ( theNode == NULL ||
                  !strcmp( theNode->Name() , aNode->Name() ) ) {
               if ( !anInPort->IsDataStream() ) {
-                if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
+//PAL8521
+//JR 14.02.2005 : Debug : we must see also that links !
+//                if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
                   if ( anInputParam == NULL ||
                        !strcmp( anInPort->PortName() , anInputParam ) ) {
                     if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
@@ -1589,7 +1630,7 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
 //                             << anOutPort->PortName() << ") --> " << toNode->Name() << "("
 //                             << anInPort->PortName() << ")" << " skipped" ) ;
                  }
-               }
+//             }
              }
            }
          }
@@ -1632,6 +1673,20 @@ Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer
   return Engines::Component::_duplicate( objComponent ) ;
 }
 
+char * Graph_Impl::Messages() {
+  beginService( "Graph_Impl::Messages" );
+  string Messages  ;
+  MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
+  Messages = DataFlowEditor()->Graph()->Messages() ;
+  DataFlowEditor()->Graph()->ReSetMessages() ;
+  if ( DataFlowExecutor() ) {
+    Messages += DataFlowExecutor()->Graph()->Messages() ;
+    DataFlowExecutor()->Graph()->ReSetMessages() ;
+  }
+  endService( "Graph_Impl::Messages" );
+  return ( CORBA::string_dup( Messages.c_str() ) ) ;
+}
+
 bool Graph_Impl::IsValid() {
 //  beginService( "Graph_Impl::IsValid" );
   bool RetVal = false ;
@@ -1688,16 +1743,16 @@ bool Graph_Impl::IsReadOnly() {
   return RetVal ;
 }
 
-long Graph_Impl::LevelMax() {
+CORBA::Long Graph_Impl::LevelMax() {
 //  beginService( "Graph_Impl::LevelMax" );
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( !IsMacro() ) {
     RetVal = DataFlowEditor()->LevelMax() ;
   }
 //  endService( "Graph_Impl::LevelMax" );
   return RetVal ;
 }
-SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
+SUPERV::ListOfNodes * Graph_Impl::LevelNodes(CORBA::Long aLevel ) {
 //  beginService( "Graph_Impl::LevelNodes" );
   SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
   if ( !IsMacro() ) {
@@ -1723,27 +1778,27 @@ SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
 //  endService( "Graph_Impl::LevelNodes" );
   return ( RetVal._retn() ) ;
 }
-long Graph_Impl::ThreadsMax() {
+CORBA::Long Graph_Impl::ThreadsMax() {
 //  beginService( "Graph_Impl::ThreadsMax" );
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( !IsMacro() ) {
     RetVal =  DataFlowEditor()->ThreadsMax() ;
   }
 //  endService( "Graph_Impl::ThreadsMax" );
   return RetVal ;
 }
-long Graph_Impl::Threads() {
+CORBA::Long Graph_Impl::Threads() {
 //  beginService( "Node_Impl::Threads" );
-  long RetVal = false ;
+  CORBA::Long RetVal = false ;
   if ( !IsMacro() ) {
     RetVal = DataFlowExecutor()->Threads() ;
   }
 //  endService( "Node_Impl::Threads" );
   return RetVal ;
 }
-long Graph_Impl::SuspendedThreads() {
+CORBA::Long Graph_Impl::SuspendedThreads() {
 //  beginService( "Node_Impl::SuspendedThreads" );
-  long RetVal = false ;
+  CORBA::Long RetVal = false ;
   if ( !IsMacro() ) {
     RetVal = DataFlowExecutor()->SuspendedThreads() ;
   }
@@ -1753,18 +1808,22 @@ long Graph_Impl::SuspendedThreads() {
 
 bool Graph_Impl::Begin() {
   bool RetVal = false ;
+  // mkr : IPAL11408 : "Run()" method returns "0" after trying to start graph execution.
+  // If we call Run() method from Python script two times for one graph, we have to be sure,
+  // that first execution of this graph ended (i.e. GraphEditor::DataFlow::Editing() method was called).
+  // Otherwise, the second call of Run() method will return 0. Therefore, we have to waiting for
+  // the first execution finish. 
+  // NB! From GUI we cann't run dataflow if its previous execution not finished.
+  while ( !DataFlowEditor()->IsEditing() ) {} // waiting for the previous execution of this graph ended
   if ( DataFlowEditor()->IsEditing() ) {
     if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
       perror("pthread_mutex_lock _MutexExecutorWait") ;
       exit( 0 ) ;
     }
+    DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
     if ( DataFlowExecutor() ) {
       MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
-//      if ( DataFlowExecutor()->Threads() ) {
-//        DataFlowExecutor()->JoinedWait() ;
-//      }
-      delete DataFlowExecutor() ;
-      DataFlowEditor()->Executor( NULL ) ;
+      Editing(); // just in case it was not called before by GUI..
     }
     if ( DataFlowEditor()->IsExecutable() ) {
       DataFlowEditor()->EditedAfterExecution( false ) ;
@@ -1790,70 +1849,59 @@ bool Graph_Impl::Begin() {
   }
   return RetVal ;
 }
-bool Graph_Impl::Run() {
-  beginService( "Graph_Impl::Run" );
+
+/**
+ * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
+ *         except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
+ *         and Start() calls with AndSuspend=true flag.  The rest of the actions are the same:
+ *         1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
+ *         2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
+ */
+bool Graph_Impl::run( const bool andSuspend ) {
   bool RetVal = false ;
+
+  // if Editing or Finished state, and, naturally, 'this' is not a MacroNode. 
   if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
-    MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" );
+
     if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
-      MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
-               << DataFlowEditor()->Graph()->GraphMacroLevel() ) ;
-      RetVal = true ;
+      // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
+      // Begin() of Supergraph.  See Begin() and LoadDataflows(Executor) for details.
+      RetVal = true ; 
     }
     else {
-      MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
-               << DataFlowEditor()->Graph()->GraphMacroLevel() << " --> Begin()" ) ;
+      // Create Executor instance and its datamodel
       RetVal = Begin() ;
     }
     if ( RetVal ) {
-      MESSAGE( "Graph_Impl::Run " );
+      // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
       DataFlowEditor()->Executing() ;
-      RetVal = CNode_Impl::Run() ;
+      DataFlowEditor()->EditedAfterExecution( false ); 
+
+      // THE MAIN RUN METHOD
+      RetVal = DataFlowExecutor()->Run( andSuspend );
     }
   }
-// It is necessary to reload the dataflow because of ports with input initial values changed
-// during execution to values of outport of EndLoopNode or GOTONode
-//  else if ( !IsMacro() && IsDone() ) {
-//    MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor()
-//             << " IsNOTEditing --> CNode_Impl::ReRun" );
-//    DataFlowEditor()->Executing() ;
-//    RetVal = CNode_Impl::ReRun() ;
-//  }
+  return RetVal ;
+
+}
+
+/**
+ * Run() - called on "Execute" command
+ */
+bool Graph_Impl::Run() {
+  beginService( "Graph_Impl::Run" );
+  bool RetVal = run( /*andSuspend=*/false ) ;
   MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
   endService( "Graph_Impl::Run" );
   return RetVal ;
 }
+
+/**
+ * Run() - called on "Execute step-by-step" command
+ */
 bool Graph_Impl::Start() {
   beginService( "Graph_Impl::Start" );
-  bool RetVal = false ;
-  if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
-    MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" );
-    if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
-      MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
-               << DataFlowEditor()->Graph()->GraphMacroLevel() ) ;
-      RetVal = true ;
-    }
-    else {
-      MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel "
-               << DataFlowEditor()->Graph()->GraphMacroLevel() << " --> Begin()" ) ;
-      RetVal = Begin() ;
-    }
-    if ( RetVal ) {
-      // Added by NKV to fix PAL6222 --> to be confirm by JR ; JR confirmed
-      DataFlowEditor()->Executing() ;
-      // End of NKV's correction
-      MESSAGE( "Graph_Impl::(Re)Start " );
-      RetVal = ReStart() ;
-    }
-  }
-// It is necessary to reload the dataflow because of ports with input initial values changed
-// during execution to values of outport of EndLoopNode or GOTONode
-//  else if ( !IsMacro() && IsDone() ) {
-//    MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor()
-//             << " IsNOTEditing --> CNode_Impl::ReStart" );
-//    DataFlowEditor()->Executing() ;
-//    RetVal = CNode_Impl::ReStart() ;
-//  }
+  bool RetVal = run( /*andSuspend=*/true ) ;
   MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
   endService( "Graph_Impl::Start" );
   return RetVal ;
@@ -1937,6 +1985,7 @@ bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
   }
   anEvent = theEvent ;
   aState = theState ;
+
   return RetVal ;
 }
 
@@ -1972,9 +2021,9 @@ bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
   return RetVal ;
 }
 
-long Graph_Impl::EventQSize() {
+CORBA::Long Graph_Impl::EventQSize() {
 //  beginService( "Graph_Impl::EventQSize" );
-  long QSize = -1 ;
+  CORBA::Long QSize = -1 ;
   if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
     perror("pthread_mutex_lock _MutexExecutorWait") ;
     exit( 0 ) ;
@@ -1990,13 +2039,13 @@ long Graph_Impl::EventQSize() {
   return QSize ;
 }
 
-long Graph_Impl::LastLevelDone() {
+CORBA::Long Graph_Impl::LastLevelDone() {
 //  beginService( "Graph_Impl::LastLevelDone" );
   if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
     perror("pthread_mutex_lock _MutexExecutorWait") ;
     exit( 0 ) ;
   }
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( DataFlowExecutor() && !IsMacro() ) {
     RetVal = DataFlowExecutor()->LastLevelDone() ;
   }
@@ -2008,9 +2057,9 @@ long Graph_Impl::LastLevelDone() {
   return RetVal ;
 }
 
-long Graph_Impl::SubGraphsNumber() {
+CORBA::Long Graph_Impl::SubGraphsNumber() {
 //  beginService( "Graph_Impl::SubGraphsNumber" );
-  long RetVal = 0 ;
+  CORBA::Long RetVal = 0 ;
   if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
     RetVal = DataFlowEditor()->SubGraphsNumber() ;
   }
@@ -2018,7 +2067,7 @@ long Graph_Impl::SubGraphsNumber() {
   return RetVal ;
 }
 
-SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
+SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( CORBA::Long aSubGraphNumber ) {
   beginService( "Graph_Impl::SubGraphsNodes" );
   SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
   if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
@@ -2140,7 +2189,8 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
         SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
         SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
                                           aNode->GetInterfaceName() ,
-                                          *(aNode->Service()) ) ;
+                                          *(aNode->Service()) ,
+                                         aNode->IsCimpl() ) ; // mkr : PAL11273
         if ( !CORBA::is_nil( myNode ) ) {
           myNode->SetName( aNode->Name() ) ;
           myNode->SetAuthor( aNode->Author() ) ;
@@ -2368,20 +2418,20 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
           myPorts = *(myEndOfSwitch->Ports()) ;
           for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
             if ( myPorts[ j ]->IsInput() ) {
-              aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+              aPort = anEndOfSwitch->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
            }
             else {
-              aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+              aPort = anEndOfSwitch->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
            }
          }
           if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
             SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
             for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
               if ( myStreamSwitchPorts[ j ]->IsInput() ) {
-                aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
+                aPort = anEndOfSwitch->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
              }
               else {
-                aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
+                aPort = anEndOfSwitch->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
              }
            }
          }
@@ -2409,9 +2459,9 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aM
                                            DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
                                            InPort->Name() ) ;
         if ( RetVal ) {
-          int j ;
+          CORBA::Long j ;
           for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
-            long X , Y ;
+            CORBA::Long X , Y ;
             RetVal = aLink->Coords( j , X , Y ) ;
             if ( !RetVal )
               break ;
@@ -2492,5 +2542,13 @@ SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
   return SUPERV::StreamGraph::_duplicate( iobject ) ;
 }
 
-
+/**
+ * Destroy Executor and use only Editor and its data model
+ */
+void Graph_Impl::Editing() {
+  if ( DataFlowEditor() && DataFlowExecutor() ) {
+    delete DataFlowExecutor() ;
+    DataFlowEditor()->Executor( NULL );
+  }
+}