From 5e7dee297764d1b3517a9793519d077bbea333a6 Mon Sep 17 00:00:00 2001 From: rahuel Date: Mon, 22 Mar 2004 16:17:00 +0000 Subject: [PATCH] *** empty log message *** --- examples/GraphStream.py | 4 + examples/GraphStreams.py | 4 + src/GraphBase/DataFlowBase_Graph.cxx | 2 +- src/GraphBase/DataFlowBase_PortsOfNode.cxx | 171 ++++++++---------- .../DataFlowExecutor_FiniteStateMachine.cxx | 2 +- .../DataFlowExecutor_InNodeThreads.cxx | 14 ++ .../DataFlowExecutor_OutNode.cxx | 10 +- src/Supervision/Graph_Impl.cxx | 1 + 8 files changed, 108 insertions(+), 100 deletions(-) diff --git a/examples/GraphStream.py b/examples/GraphStream.py index d988ab6..4941141 100644 --- a/examples/GraphStream.py +++ b/examples/GraphStream.py @@ -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() diff --git a/examples/GraphStreams.py b/examples/GraphStreams.py index c23c23c..fc9367b 100644 --- a/examples/GraphStreams.py +++ b/examples/GraphStreams.py @@ -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() diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 9c53a82..81c0fe9 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -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() << "( " diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.cxx b/src/GraphBase/DataFlowBase_PortsOfNode.cxx index e3ec6da..b8dcc3e 100644 --- a/src/GraphBase/DataFlowBase_PortsOfNode.cxx +++ b/src/GraphBase/DataFlowBase_PortsOfNode.cxx @@ -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 ; diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx index e63271f..448ad16 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx @@ -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 ; diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index ff45c77..7f7094b 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -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 || diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index 21b4408..81dba0d 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -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 ; } diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index e0c54d3..b09ebbd 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -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 ) ) { -- 2.39.2