]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
*** empty log message ***
authorrahuel <rahuel@opencascade.com>
Mon, 22 Mar 2004 16:17:00 +0000 (16:17 +0000)
committerrahuel <rahuel@opencascade.com>
Mon, 22 Mar 2004 16:17:00 +0000 (16:17 +0000)
examples/GraphStream.py
examples/GraphStreams.py
src/GraphBase/DataFlowBase_Graph.cxx
src/GraphBase/DataFlowBase_PortsOfNode.cxx
src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx
src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx
src/GraphExecutor/DataFlowExecutor_OutNode.cxx
src/Supervision/Graph_Impl.cxx

index d988ab6f524915202d5a5a477799c193942033d9..4941141e06012573f3ab6ab86a3f6b71ad1173f2 100644 (file)
@@ -85,3 +85,7 @@ Addistream = Add.Input( 'istream' , 1)
 AddFuncValue = Add.Port( 'FuncValue' )
 Divz = Div.Port( 'z' )
 Divostream = Div.Port( 'ostream' )
+
+GraphStream.Run()
+GraphStream.DoneW()
+GraphStream.PrintPorts()
index c23c23c684cd3d9c3a3ccbb3fa01974eab67fcc7..fc9367b61e762e8c2cd66920f4a3ca544790154c 100644 (file)
@@ -272,3 +272,7 @@ EndLoopz_Div = EndLoop.Port( 'z_Div' )
 EndLoopz_Div_1 = EndLoop.Port( 'z_Div_1' )
 EndLoopy_Add = EndLoop.Port( 'y_Add' )
 EndLoopx_Sub = EndLoop.Port( 'x_Sub' )
+
+GraphStreams.Run()
+GraphStreams.DoneW()
+GraphStreams.PrintPorts()
index 9c53a825a15fb63428e09697def687027500f4c0..81c0fe9fa2bf0d2bbc51e82915fa1d7c13bd065d 100644 (file)
@@ -1679,7 +1679,7 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
       }
       for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
         GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
-        if ( !anInPort->IsConnected() ) {
+        if ( !anInPort->IsConnected() && !anInPort->IsGate() ) {
           if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
                          aLoopNode->CoupledNode() , anInPort ) ) {
             cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
index e3ec6da61320edfb595198e3019cd9175373b7b0..b8dcc3ea9a7b2d011ed43d352f93c413af171441 100644 (file)
@@ -75,13 +75,13 @@ void GraphBase::PortsOfNode::DefPortsOfNode(
   const bool WithInLoop = (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ;
 // WithInGate : InGate or Default
   const bool WithInGate = (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
-                          (aKind == SUPERV::InLineNode) || (aKind == SUPERV::LoopNode) ||
-                          (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ||
-                          (aKind == SUPERV::GOTONode) ;
+                          (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
+                          (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ||
+                          (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ;
 // WithOutGate : OutGate or Default
   const bool WithOutGate = (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ||
-                           (aKind == SUPERV::InLineNode) || (aKind == SUPERV::SwitchNode) ||
-                           (aKind == SUPERV::GOTONode) ;
+                           (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) ||
+                           (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ;
   SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ;
   if ( aKind == SUPERV::InLineNode ) {
     aPortKind = SUPERV::InLineParameter ;
@@ -269,57 +269,42 @@ GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB ,
   cdebug_in << "DefPortsOfNode::AddInPort : " << *NodeName << " " << aKind << " "
             << InputParameterName << " " << InputParameterType << endl ;
   GraphBase::InPort * anInPort = NULL ;
-  SUPERV::KindOfPort aPortKind = SUPERV::UndefinedParameter ;
-  if ( aKind == SUPERV::InLineNode || aKind == SUPERV::LoopNode ||
-       aKind == SUPERV::EndLoopNode || aKind == SUPERV::SwitchNode ||
-       aKind == SUPERV::EndSwitchNode || aKind == SUPERV::GOTONode ) {
-    aPortKind = SUPERV::ServiceParameter ;
-  }
+  SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ;
+  anInPort = GetChangeInPort( InputParameterName ) ;
+  if ( anInPort == NULL ) {
+    _NodeInPortsSize = _NodeInPortsSize + 1 ;
+    _NodeInPorts.resize(_NodeInPortsSize);
+    SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
+    aServiceParameter.Parametername = InputParameterName ;
+    aServiceParameter.Parametertype = InputParameterType ;
+//    if ( aKind != SUPERV::EndLoopNode ) {
+      _NodeInPorts[ _NodeInPortsSize-1 ] = _NodeInPorts[ _NodeInPortsSize-2 ] ; // Gate - Default
+      _MapOfNodeInPorts.erase( _NodeInPorts[ _NodeInPortsSize-1 ]->PortName() ) ;
+      _MapOfNodeInPorts[ _NodeInPorts[ _NodeInPortsSize-1 ]->PortName() ] =  _NodeInPortsSize-1 + 1 ;
+      _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-2 + 1 ;
+      _NodeInPorts[_NodeInPortsSize-2] = new GraphBase::InPort( NodeName ,
+                                                                aServiceParameter ,
+                                                                aPortKind ) ;
+      _NodeInPorts[_NodeInPortsSize-2]->Kind( SUPERV::InLineParameter ) ;
+      _NodeInPorts[_NodeInPortsSize-2]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+      anInPort = _NodeInPorts[_NodeInPortsSize-2] ;
+      cdebug << "NodeInPorts[ " << _NodeInPortsSize-2 << " ]" << endl ;
+    }
+//    else { // EndLoopNode
+//      _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-1 + 1 ;
+//      _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName ,
+//                                                                aServiceParameter ,//
+//                                                                aPortKind ) ;
+//      _NodeInPorts[_NodeInPortsSize-1]->Kind( SUPERV::InLineParameter ) ;
+//      MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << InputParameterName << " --> SetDebug" ) ;
+//      _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+//      anInPort = _NodeInPorts[_NodeInPortsSize-1] ;
+//      cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ;
+//    }
+//  }
   else {
-    aPortKind = SUPERV::DataStreamParameter ;
+    cdebug << "InPort already exists" << endl ;
   }
-
-    //    SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ;
-    //    if ( aKind == SUPERV::EndSwitchNode ) {
-    //      aPortKind = SUPERV::EndSwitchParameter ;
-    //    }
-    anInPort = GetChangeInPort( InputParameterName ) ;
-    if ( anInPort == NULL ) {
-      _NodeInPortsSize = _NodeInPortsSize + 1 ;
-      _NodeInPorts.resize(_NodeInPortsSize);
-      SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
-      aServiceParameter.Parametername = InputParameterName ;
-      aServiceParameter.Parametertype = InputParameterType ;
-      if ( aKind != SUPERV::EndLoopNode ) {
-        _NodeInPorts[ _NodeInPortsSize-1 ] = _NodeInPorts[ _NodeInPortsSize-2 ] ; // Gate - Default
-        _MapOfNodeInPorts.erase( _NodeInPorts[ _NodeInPortsSize-1 ]->PortName() ) ;
-        _MapOfNodeInPorts[ _NodeInPorts[ _NodeInPortsSize-1 ]->PortName() ] =  _NodeInPortsSize-1 + 1 ;
-        _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-2 + 1 ;
-        _NodeInPorts[_NodeInPortsSize-2] = new GraphBase::InPort( NodeName ,
-                                                                  aServiceParameter ,
-                                                                  aPortKind ) ;
-        _NodeInPorts[_NodeInPortsSize-2]->Kind( SUPERV::InLineParameter ) ;
-//        MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << InputParameterName << " --> SetDebug" ) ;
-        _NodeInPorts[_NodeInPortsSize-2]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
-        anInPort = _NodeInPorts[_NodeInPortsSize-2] ;
-        cdebug << "NodeInPorts[ " << _NodeInPortsSize-2 << " ]" << endl ;
-      }
-      else {
-        _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-1 + 1 ;
-        _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName ,
-                                                                  aServiceParameter ,
-                                                                  aPortKind ) ;
-        _NodeInPorts[_NodeInPortsSize-1]->Kind( SUPERV::InLineParameter ) ;
-//        MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << InputParameterName << " --> SetDebug" ) ;
-        _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
-        anInPort = _NodeInPorts[_NodeInPortsSize-1] ;
-        cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ;
-      }
-    }
-    else {
-      cdebug << "InPort already exists" << endl ;
-    }
-    //  }
   cdebug_out << "DefPortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize
              << " " << anInPort->Kind() << endl ;
   return anInPort ;
@@ -335,52 +320,44 @@ GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB ,
   cdebug_in << "DefPortsOfNode::AddOutPort : " << *NodeName << " " << aKind << " "
             << OutputParameterName << " " << OutputParameterType << endl ;
   GraphBase::OutPort * anOutPort = NULL ;
-  SUPERV::KindOfPort aPortKind = SUPERV::UndefinedParameter ;
-  if ( aKind == SUPERV::InLineNode || aKind == SUPERV::LoopNode ||
-       aKind == SUPERV::EndLoopNode || aKind == SUPERV::SwitchNode ||
-       aKind == SUPERV::EndSwitchNode || aKind == SUPERV::GOTONode ) {
-    aPortKind = SUPERV::InLineParameter ;
+  SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ;
+  anOutPort = GetChangeOutPort( OutputParameterName ) ;
+  if ( anOutPort == NULL ) {
+    _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
+    _NodeOutPorts.resize(_NodeOutPortsSize);
+    SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
+    aServiceParameter.Parametername = OutputParameterName ;
+    aServiceParameter.Parametertype = OutputParameterType ;
+    if ( aKind != SUPERV::LoopNode && aKind != SUPERV::EndLoopNode ) {
+//         && aKind != SUPERV::EndSwitchNode ) {
+      _NodeOutPorts[ _NodeOutPortsSize-1 ] = _NodeOutPorts[ _NodeOutPortsSize-2 ] ; // Gate - Default
+      _MapOfNodeOutPorts.erase( _NodeOutPorts[ _NodeOutPortsSize-1 ]->PortName() ) ;
+      _MapOfNodeOutPorts[ _NodeOutPorts[ _NodeOutPortsSize-1 ]->PortName() ] =  _NodeOutPortsSize-1 + 1 ;
+      _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize - 1 ;
+      _NodeOutPorts[_NodeOutPortsSize-2] = new GraphBase::OutPort( NodeName ,
+                                                                   aServiceParameter ,
+                                                                   aPortKind );
+      _NodeOutPorts[_NodeOutPortsSize-2]->Kind( SUPERV::InLineParameter ) ;
+//    MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << OutputParameterName << " --> SetDebug" ) ;
+      _NodeOutPorts[_NodeOutPortsSize-2]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+      anOutPort = _NodeOutPorts[_NodeOutPortsSize-2] ;
+      cdebug << "NodeOutPorts[ " << _NodeOutPortsSize-2 << " ]" << endl ;
+    }
+    else { // LoopNode || EndLoopNode
+      _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize ;
+      _NodeOutPorts[_NodeOutPortsSize-1] = new GraphBase::OutPort( NodeName ,
+                                                                   aServiceParameter ,
+                                                                   aPortKind );
+      _NodeOutPorts[_NodeOutPortsSize-1]->Kind( SUPERV::InLineParameter ) ;
+//    MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << OutputParameterName << " --> SetDebug" ) ;
+      _NodeOutPorts[_NodeOutPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+      anOutPort = _NodeOutPorts[_NodeOutPortsSize-1] ;
+      cdebug << "NodeOutPorts[ " << _NodeOutPortsSize-1 << " ]" << endl ;
+    }
   }
   else {
-    aPortKind = SUPERV::DataStreamParameter ;
+    cdebug << "OutPort already exists" << endl ;
   }
-    anOutPort = GetChangeOutPort( OutputParameterName ) ;
-    if ( anOutPort == NULL ) {
-      _NodeOutPortsSize = _NodeOutPortsSize + 1 ;
-      _NodeOutPorts.resize(_NodeOutPortsSize);
-      SALOME_ModuleCatalog::ServicesParameter aServiceParameter ;
-      aServiceParameter.Parametername = OutputParameterName ;
-      aServiceParameter.Parametertype = OutputParameterType ;
-      if ( aKind != SUPERV::SwitchNode ) {
-        _NodeOutPorts[ _NodeOutPortsSize-1 ] = _NodeOutPorts[ _NodeOutPortsSize-2 ] ; // Gate - Default
-        _MapOfNodeOutPorts.erase( _NodeOutPorts[ _NodeOutPortsSize-1 ]->PortName() ) ;
-        _MapOfNodeOutPorts[ _NodeOutPorts[ _NodeOutPortsSize-1 ]->PortName() ] =  _NodeOutPortsSize-1 + 1 ;
-        _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize - 1 ;
-        _NodeOutPorts[_NodeOutPortsSize-2] = new GraphBase::OutPort( NodeName ,
-                                                                     aServiceParameter ,
-                                                                     aPortKind );
-        _NodeOutPorts[_NodeOutPortsSize-2]->Kind( SUPERV::InLineParameter ) ;
-//      MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << OutputParameterName << " --> SetDebug" ) ;
-        _NodeOutPorts[_NodeOutPortsSize-2]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
-        anOutPort = _NodeOutPorts[_NodeOutPortsSize-2] ;
-        cdebug << "NodeInPorts[ " << _NodeInPortsSize-2 << " ]" << endl ;
-      }
-      else {
-        _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize ;
-        _NodeOutPorts[_NodeOutPortsSize-1] = new GraphBase::OutPort( NodeName ,
-                                                                     aServiceParameter ,
-                                                                     aPortKind );
-        _NodeOutPorts[_NodeOutPortsSize-1]->Kind( SUPERV::InLineParameter ) ;
-//      MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << OutputParameterName << " --> SetDebug" ) ;
-        _NodeOutPorts[_NodeOutPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
-        anOutPort = _NodeOutPorts[_NodeOutPortsSize-1] ;
-        cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ;
-      }
-    }
-    else {
-      cdebug << "OutPort already exists" << endl ;
-    }
-    //  }
   cdebug_out << "DefPortsOfNode::AddOutPort _NodeOutPortsSize "
              << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ;
   return anOutPort ;
index e63271f2f4e9a49ea6c8b2cd75059b0a51fa676b..448ad16da6410c86eed5eacf93fa5f5204192b9d 100644 (file)
@@ -570,7 +570,7 @@ bool GraphExecutor::FiniteStateMachine::PyFunction( const char * aPyFuncName , P
   
   bool RetVal = false ;
   if ( _MapOfPyFunctions[ aPyFuncName ] != NULL ) {
-    PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ;
+    //PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ;
     //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , " << aPyFunction
     //     << " ) ob_refcnt " << aPyFunction->ob_refcnt << " already mapped : " << aPyFunc << " ob_refcnt "
     //     << aPyFunc->ob_refcnt << endl ;
index ff45c77aece1a4a65bb20c8a1a518846529e0167..7f7094b23e7e7c31e48b486af3f81b68d97305fe 100644 (file)
@@ -46,6 +46,8 @@ using namespace std;
 
 #include "DataFlowExecutor_OutNode.hxx"
 
+#include "Graph_Impl.hxx"
+
 //static char *containerName = "FactoryServer" ;
 
 int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {  
@@ -1071,6 +1073,11 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() {
     }
   }
   else if ( CORBA::is_nil( Component() ) ) {
+    ostringstream astr ;
+    astr << "Graph " << _OutNode->Name() << " Node " << Name()
+         << " : load of component " << ComponentName() << " in container "
+         << Computer() ;
+    _OutNode->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
     Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
                                      my_strdup( ComponentName() ) ,
                                      myContainer , myObjComponent ) ;
@@ -1098,6 +1105,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() {
     }
     else {
       if ( !Err ) {
+        ostringstream astr ;
+        astr << "Graph " << _OutNode->Name() << " Run of Node " << Name() ;
+        _OutNode->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
         cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
         for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
           cdebug << " , " << InParametersList[ i ].Name << "[kind"
@@ -1385,6 +1395,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() {
 //    sleep( 1 ) ;
 //  }
 
+  ostringstream astr ;
+  astr << "Graph " << _OutNode->Name() << " Node " << Name() << " is done : "
+       << Automaton()->StateName( State() ) ;
+  _OutNode->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
   if ( Err ) {
     if ( ControlState() == SUPERV::ToKillState ||
          ControlState() == SUPERV::ToKillDoneState ||
index 21b440888036c10a5876830cb991859a4be0c6ee..81dba0de50af02dacabce68c93ad2c9f8ec54b08 100644 (file)
@@ -30,6 +30,8 @@ using namespace std;
 
 #include "DataFlowExecutor_OutNode.hxx"
 
+#include "Graph_Impl.hxx"
+
 // Implementation de la classe GraphEditor::GraphControl
 
 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
@@ -513,7 +515,9 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
           State( SUPERV::ExecutingState ) ;
       };
     }
-
+    ostringstream astr ;
+    astr << "Graph " << Name() << " is running" ;
+    ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
     RetVal = true ;
   }
   else {
@@ -622,6 +626,10 @@ void GraphExecutor::OutNode::CheckAllDone() {
     cdebug << Name() << " IS DONE : " <<  theAutomaton->StateName( AutomatonState() ) << " EventQSize "
              << EventQSize() << endl  ;
     cdebug << "================================================================================" << endl ;
+    ostringstream astr ;
+    astr << "Graph " << Name() << " is done : "
+         << theAutomaton->StateName( AutomatonState() ) ;
+    ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ;
     //cout << Name() << " IS DONE : " <<  theAutomaton->StateName( AutomatonState() ) << " EventQSize "
     //     << EventQSize() << endl  ;
   }
index e0c54d3995ea2e648463f4b711a25beb052f0014..b09ebbd5b31aaf93f3f83cf4fc33c45522b1d09b 100644 (file)
@@ -996,6 +996,7 @@ bool Graph_Impl::Begin() {
     MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
     RetVal = _DataFlowExecutor->LoadDataFlow( *myGraph ) ;
     if ( RetVal ) {
+      _DataFlowExecutor->SetObjImpl( DataFlowEditor()->ObjImpl() ) ;
       DataFlowEditor()->Executor( _DataFlowExecutor ) ;
     }
     if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {