Salome HOME
Merge from OCC_development_generic_2006
[modules/superv.git] / src / Supervision / Graph_Impl.cxx
index 9be1703f16358377d18d0719da98e2e93e36e8dd..a00e43fd791c8bbf36ec48cacd66db7348d0173b 100644 (file)
@@ -400,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() ) {
@@ -409,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);
@@ -1804,6 +1808,13 @@ 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") ;
@@ -2178,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() ) ;
@@ -2406,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)
              }
            }
          }