// 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
//
//
//
//#include "utilities.h"
+#include "SALOME_Container_i.hxx"
+
#include "StreamGraph_Impl.hxx"
#include "DataFlowEditor_DataFlow.hxx"
const SUPERV::KindOfNode aKindOfNode ,
string & dbgfile ,
GraphEditor::DataFlow ** aDataFlowEditor ) {
-// string dbgfile = "/tmp/" ;
bool aXmlFile = false ;
- dbgfile = "/tmp/" ;
- dbgfile += instanceName ;
- dbgfile += "_" ;
int lenname = strlen( aDataFlowName ) ;
char * theDataFlowName = new char [ lenname+1 ] ;
strcpy( theDataFlowName , aDataFlowName ) ;
strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
}
}
+
string theDataFlowInstanceName = theDataFlowName ;
- if ( !aXmlFile ) {
- theDataFlowInstanceName = theAutomaton->GraphInstanceName( theDataFlowName ) ;
- }
+
+ // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
+ // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
+ dbgfile = "/tmp/logs/" ;
+ dbgfile += getenv( "USER" ) ;
+ dbgfile += "/" ;
+ dbgfile += instanceName ;
+ dbgfile += "_" ;
dbgfile += theDataFlowInstanceName ;
dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
+ FILE* f = fopen ( dbgfile.c_str(), "a" );
+ if ( f ) { // check if file can be opened for writing
+ fclose( f );
+ }
+ else { // if file can't be opened - use a guaranteed temp file name
+ char* aTempNam = tempnam( NULL, NULL );
+ dbgfile = aTempNam;
+ free ( aTempNam );
+ }
+
SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
*aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
aKindOfNode ) ;
MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
<< dbgfile.c_str() ) ;
+
delete [] theDataFlowName ;
}
-static void CreateEditor( CORBA::ORB_ptr orb ,
+static void CreateExecutor( CORBA::ORB_ptr orb ,
const char *instanceName ,
const char *aDataFlowName ,
const SUPERV::KindOfNode aKindOfNode ,
string & dbgfile ,
GraphExecutor::DataFlow ** aDataFlowExecutor ) {
-// string dbgfile = "/tmp/" ;
- dbgfile = "/tmp/" ;
- dbgfile += instanceName ;
- dbgfile += "_" ;
int lenname = strlen( aDataFlowName ) ;
char * theDataFlowName = new char [ lenname+1 ] ;
strcpy( theDataFlowName , aDataFlowName ) ;
if ( aDataFlowName ) {
strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
}
+
string theDataFlowInstanceName = theDataFlowName ;
+
+ // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
+ // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
+ dbgfile = "/tmp/logs/" ;
+ dbgfile += getenv( "USER" ) ;
+ dbgfile += "/" ;
+ dbgfile += instanceName ;
+ dbgfile += "_" ;
dbgfile += theDataFlowInstanceName ;
dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
-
ostringstream astr ;
astr << theAutomaton->ExecNumber() ;
dbgfile += astr.str() ;
dbgfile += string( "_Exec.log" ) ;
+ FILE* f = fopen ( dbgfile.c_str(), "a" );
+ if ( f ) { // check if file can be opened for writing
+ fclose( f );
+ }
+ else { // if file can't be opened - use a guaranteed temp file name
+ char* aTempNam = tempnam( NULL, NULL );
+ dbgfile = aTempNam;
+ free ( aTempNam );
+ }
SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
*aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
aKindOfNode ) ;
- MESSAGE( "CreateEditor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
+
+ MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
<< dbgfile.c_str() ) ;
+
delete [] theDataFlowName ;
}
_Orb = CORBA::ORB::_duplicate(orb);
_Poa = poa ;
_ContId = contId ;
+ _DebugFileName = NULL ;
if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
// MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
_thisObj = this ;
GraphEditor::DataFlow * aDataFlowEditor ;
CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
dbgfile , &aDataFlowEditor ) ;
+
+ if ( _DebugFileName ) {
+ delete [] _DebugFileName ;
+ }
_DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
strcpy( _DebugFileName , dbgfile.c_str() ) ;
_NamingService = new SALOME_NamingService( orb ) ;
DataFlowEditor( aDataFlowEditor ) ;
- DataFlowEditor()->Graph()->SetGraphEditor( aDataFlowEditor ) ;
+ DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
DataFlowEditor()->Graph()->SetObjImpl( this ) ;
}
pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
// beginService( "Graph_Impl::Graph_Impl" );
// MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
- if ( aDataFlowEditor->Graph()->IsDataFlowNode() || aDataFlowNode->IsMacroNode() ) {
+ if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
+ ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
// MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
_thisObj = this ;
_id = _poa->activate_object(_thisObj);
_Orb = CORBA::ORB::_duplicate(orb);
_Poa = poa ;
_ContId = contId ;
+ _DebugFileName = NULL ;
DataFlowEditor( aDataFlowEditor ) ;
- DataFlowEditor()->Graph()->SetGraphEditor( aDataFlowEditor ) ;
+ DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
DataFlowEditor()->Graph()->SetObjImpl( this ) ;
pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
// DataFlowExecutor( NULL ) ;
// endService( "Graph_Impl::Graph_Impl" );
}
-Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
- PortableServer::POA_ptr poa ,
- PortableServer::ObjectId * contId ,
- const char *instanceName ,
- const char *interfaceName ,
- GraphExecutor::DataFlow * aDataFlowExecutor ,
- GraphExecutor::InNode * aDataFlowExecutorNode ) :
- GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowExecutor , aDataFlowExecutorNode ) {
-// beginService( "Graph_Impl::Graph_Impl" );
-// MESSAGE( aDataFlowExecutor->Graph()->Name() << " " );
- if ( aDataFlowExecutor->Graph()->IsDataFlowNode() || aDataFlowExecutorNode->IsMacroNode() ) {
-// MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
- _thisObj = this ;
- _id = _poa->activate_object(_thisObj);
- }
- else {
-// MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
- }
- _Orb = CORBA::ORB::_duplicate(orb);
- _Poa = poa ;
- _ContId = contId ;
- DataFlowExecutor( aDataFlowExecutor ) ;
- DataFlowExecutor()->Graph()->SetGraphExecutor( aDataFlowExecutor ) ;
- DataFlowExecutor()->Graph()->SetObjImpl( this ) ;
- pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
-// DataFlowExecutor( NULL ) ;
-// endService( "Graph_Impl::Graph_Impl" );
-}
-
Graph_Impl::Graph_Impl() {
}
void Graph_Impl::destroy() {
beginService( "Graph_Impl::destroy" );
+ if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
+ SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
+ GNode_Impl::Delete() ;
+ if ( !CORBA::is_nil( aGraph ) ) {
+ aGraph->destroy() ;
+ }
+ }
+ else {
+ SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
+ GNode_Impl::Delete() ;
+ if ( !CORBA::is_nil( aGraph ) ) {
+ aGraph->destroy() ;
+ }
+ }
_poa->deactivate_object(*_id) ;
- CORBA::release(_poa) ;
+// CORBA::release(_poa) ;
delete(_id) ;
- _thisObj->_remove_ref();
-// endService( "Graph_Impl::destroy" );
+// _thisObj->_remove_ref();
+ endService( "Graph_Impl::destroy" );
}
bool RetVal = false ;
if ( DataFlowEditor()->IsEditing() ) {
// RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
- RetVal = LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ;
+ if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
+ RetVal = false ;
+ }
}
endService( "Graph_Impl::LoadGraphs" );
return RetVal ;
RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
if ( RetVal && aXmlFile != NULL ) {
// RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
- RetVal = LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ;
+ if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
+ RetVal = false ;
+ }
}
}
endService( "Graph_Impl::Import" );
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() ;
myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
}
}
+ DataFlowEditor()->UnValid() ;
endService( "Graph_Impl::CNode" );
return SUPERV::CNode::_duplicate( iobject ) ;
}
SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
const char * NodeInterfaceName ,
- const SALOME_ModuleCatalog::Service &NodeService ) {
+ const SALOME_ModuleCatalog::Service &NodeService ,
+ const SALOME_ModuleCatalog::ImplType ImplType ) {
beginService( "Graph_Impl::FNode" );
SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
+ bool isCimpl = true;
+ switch (ImplType)
+ {
+ case SALOME_ModuleCatalog::PY:
+ isCimpl = false;
+ break;
+ case SALOME_ModuleCatalog::SO:
+ case SALOME_ModuleCatalog::EXE:
+ default:
+ ;
+ }
if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
instanceName() , interfaceName() ,
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);
myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
}
}
+ DataFlowEditor()->UnValid() ;
endService( "Graph_Impl::FNode" );
return SUPERV::FNode::_duplicate( iobject ) ;
}
}
}
}
+ DataFlowEditor()->UnValid() ;
endService( "Graph_Impl::GNode" );
return SUPERV::GNode::_duplicate( iobject ) ;
}
SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
char * anEndName ;
if ( strlen( InitName ) ) {
- anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
+ anEndName = new char[ 3 + strlen( InitName ) + 1 ];
strcpy( anEndName , "End" ) ;
strcat( anEndName , InitName ) ;
}
else {
- anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
+ anEndName = new char[ 3 + strlen( "Loop" ) + 1 ];
strcpy( anEndName , "EndLoop" ) ;
}
ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
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 ) ;
+ DataFlowEditor()->UnValid() ;
endService( "Graph_Impl::LNode" );
return SUPERV::LNode::_duplicate( iobject ) ;
}
myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
- if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
- iobject = SUPERV::SNode::_nil() ;
- iendobject = SUPERV::ESNode::_nil() ;
- }
+//JR NPAL14793 05.02.2007 : do not add that link
+// if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
+// iobject = SUPERV::SNode::_nil() ;
+// iendobject = SUPERV::ESNode::_nil() ;
+// }
}
}
anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
+ DataFlowEditor()->UnValid() ;
endService( "Graph_Impl::SNode" );
return SUPERV::SNode::_duplicate( iobject ) ;
}
// WARNING : THIS IS COMPLICATED :
-bool Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
- GraphBase::ListOfSGraphs * aListOfDataFlows ,
- int index ) {
+SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
+ GraphBase::ListOfSGraphs * aListOfDataFlows ,
+ int index ) {
beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
+ MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
+
SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
+// That method is recursive :
+// At first we load the supergraph with index = 0 :
+// (After we load the graph corresponding to each MacroNode :)
if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
- MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
- return false ;
+ MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
+ return SUPERV::Graph::_duplicate( iobject ) ;
}
// That graph is not a StreamGraph :
else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
- aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
+// aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
Graph_Impl * myGraph ;
// We create a Graph ObjRef for that graph
myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
CORBA::Object_var obj = _poa->id_to_reference(*id) ;
iobject = SUPERV::Graph::_narrow( obj ) ;
myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
+ myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
int i ;
+
+// asv: set Editor for the graph itself and for all its macro nodes
+ aGraph->GraphEditor( aDataFlowEditor );
+
+// For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
+ // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
+ // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
+ // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
+ // so here we check if the node is "new" or "old"
+ if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
+ continue;
+ // asv: set Editor for the graph itself and for all its macro nodes
+ aMacroNode->GraphEditor( aDataFlowEditor );
-// Creation of a GraphMacroNode in the current editor
+ // Creation of a GraphMacroNode ObjRef in the current editor
SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
- string aMacroNodeName = string( "Macro_" ) + string( myGraph->Name() ) ;
Graph_Impl * myMacroNode ;
myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
instanceName() , interfaceName() ,
- aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
+ aMacroNode->Name() , SUPERV::MacroNode ) ;
id = myMacroNode->getId() ;
obj = _poa->id_to_reference(*id);
macroiobject = SUPERV::Graph::_narrow( obj ) ;
- myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
- aMacroNode->SetGraphEditor( DataFlowEditor() ) ;
+ myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
myMacroNode->DataFlowNode( aDataFlowNode ) ;
aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
- aDataFlowNode->SetObjImpl( this ) ;
-
-
-
-
+ aDataFlowNode->SetObjImpl( myMacroNode ) ;
char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
<< " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
int index ;
+ bool found = false ;
for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
+ MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
+ found = true ;
string dbgfile ;
// At first create the editor and a StreamGraph
GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
dbgfile , &aMacroGraphDataFlowEditor ) ;
-// if ( !aDataFlowEditor->LoadDataFlow( aDataFlowEditor , aListOfDataFlows , index ) ) {
+
+ if ( _DebugFileName ) {
+ delete [] _DebugFileName ;
+ }
+ _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
+ strcpy( _DebugFileName , dbgfile.c_str() ) ;
+
MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
- if ( !LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) {
+ if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
- return false ;
+ return SUPERV::Graph::_duplicate( iobject ) ;
}
// That graph is not a StreamGraph :
else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
- aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
- aMacroGraphDataFlowEditor->Graph()->SetGraphEditor( aMacroGraphDataFlowEditor ) ;
Graph_Impl * myMacroGraph ;
-// We create a Graph ObjRef for that graph
- myMacroGraph = new Graph_Impl( _Orb , _Poa, _ContId,
- instanceName() , interfaceName() ,
- aMacroGraphDataFlowEditor , NULL ) ;
- PortableServer::ObjectId * id = myMacroGraph->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
- myMacroGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
+// The Graph ObjRef for that graph was already created
+ myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
+
aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
aMacroGraph->CoupledNode( aMacroNode ) ;
-
- aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
// Set the GraphMacroNode ObjRef in the MacroNode
+ aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
aMacroNode->CoupledNode( aMacroGraph ) ;
- aMacroNode->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
+ aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
+ MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
+ << " coupled to " << aMacroGraph->CoupledNode() << " "
+ << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
+ MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
+ << " coupled to " << aMacroNode->CoupledNode() << " "
+ << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
+ MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
+ << " coupled to " << aGraph->CoupledNode()
+ << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
}
+ break ;
}
}
+ if ( !found ) {
+ return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
+ }
}
}
}
+ else if ( (*aListOfDataFlows).size() == 1 ) {
+ StreamGraph_Impl * myStreamGraph ;
+// We create a Graph ObjRef for that graph
+ myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
+ instanceName() , interfaceName() ,
+ aDataFlowEditor , NULL ) ;
+ PortableServer::ObjectId * id = myStreamGraph->getId() ;
+ CORBA::Object_var obj = _poa->id_to_reference(*id) ;
+ SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
+ Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
+ myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
+ myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
+// iobject = SUPERV::Graph::_narrow( obj ) ;
+ iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
+ }
+ else {
+ MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
+ }
endService( "Graph_Impl::EditorLoadDataFlows" );
- return true ;
+ return SUPERV::Graph::_duplicate( iobject ) ;
}
-bool Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
- GraphBase::ListOfSGraphs * aListOfDataFlows ,
- int index ) {
+SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
+ GraphBase::ListOfSGraphs * aListOfDataFlows ,
+ int index ) {
beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
- MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
- SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
-// That method is recursive :
-// At first we load the supergraph with index = 0 :
-// (After we load the graph corresponding to each MacroNode :)
+ MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
+
+ // That method is recursive :
+ // At first we load the supergraph with index = 0 :
+ // (After we load the graph corresponding to each MacroNode :)
if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
- MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
- return false ;
+ MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
+ return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
}
-// That graph is not a StreamGraph :
- else if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
+
+ // That graph is not a StreamGraph :
+ else {
aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
GraphEditor::DataFlow * aDataFlowEditor ;
- aDataFlowEditor = theAutomaton->MapGraph( (*aListOfDataFlows)[index].Info.theName.c_str() )->GraphEditor() ;
+ aDataFlowEditor = DataFlowEditor() ;
+ GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
+ GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
+ if ( aDataFlowEditor->Executor() ) {
+ delete aDataFlowEditor->Executor() ;
+ aDataFlowEditor->Executor( NULL ) ;
+ aDataFlowEditor->Editing() ;
+ }
aDataFlowEditor->Executor( aDataFlowExecutor ) ;
- aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
- aDataFlowEditor->Graph()->SetGraphExecutor( aDataFlowExecutor ) ;
- aDataFlowExecutor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
- aDataFlowExecutor->Graph()->SetGraphExecutor( aDataFlowExecutor ) ;
- Graph_Impl * myGraph ;
-// We create a Graph ObjRef for that graph
- myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
- instanceName() , interfaceName() ,
- aDataFlowExecutor , NULL ) ;
- PortableServer::ObjectId * id = myGraph->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id) ;
- iobject = SUPERV::Graph::_narrow( obj ) ;
- myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
- myGraph->DataFlowEditor( aDataFlowEditor ) ;
- myGraph->DataFlowExecutor( aDataFlowExecutor ) ;
- MESSAGE("ExecutorLoadDataFlows IsEditing " << myGraph->Name() << " "
- << myGraph->DataFlowEditor() << " " << myGraph->DataFlowEditor()->IsEditing() << " "
- << myGraph->DataFlowEditor()->Graph()->Name() << " "
- << myGraph->DataFlowEditor()->Graph()->GraphEditor() << " "
- << myGraph->DataFlowEditor()->Graph()->GraphEditor()->IsEditing() ) ;
- GraphBase::Graph * aGraph = myGraph->DataFlowExecutor()->Graph() ;
- int i ;
-// For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
- for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
- if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
- GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
-
-
-
-// Creation of a GraphMacroNode ObjRef in the current executor
- SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
- string aMacroNodeName = string( "Macro_" ) + string( aGraph->Name() ) ;
- Graph_Impl * myMacroNode ;
- myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
- instanceName() , interfaceName() ,
- aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
- id = myMacroNode->getId() ;
- obj = _poa->id_to_reference(*id);
- macroiobject = SUPERV::Graph::_narrow( obj ) ;
- myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
- myMacroNode->DataFlowExecutor( DataFlowExecutor() ) ;
- aMacroNode->SetGraphEditor( DataFlowEditor() ) ;
- GraphExecutor::InNode * aDataFlowExecutorNode = (GraphExecutor::InNode * ) aMacroNode->GetInNode() ;
- myMacroNode->DataFlowNode( aDataFlowExecutorNode ) ;
- aDataFlowExecutorNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
- aDataFlowExecutorNode->SetObjImpl( this ) ;
-
- char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
- MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
- << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
- int index ;
- for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
- if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
- string dbgfile ;
-// At first create the editor and a StreamGraph
- GraphExecutor::DataFlow * aMacroGraphDataFlowExecutor ;
- CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
- dbgfile , &aMacroGraphDataFlowExecutor ) ;
-// if ( !aDataFlowEditor->LoadDataFlow( aDataFlowEditor , aListOfDataFlows , index ) ) {
- MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
- if ( !LoadDataFlows( aMacroGraphDataFlowExecutor , aListOfDataFlows , index ) ) {
- MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
- return false ;
- }
-
-// That graph is not a StreamGraph :
- else if ( !aMacroGraphDataFlowExecutor->Graph()->HasDataStream() ) {
- aMacroGraphDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
- aMacroGraphDataFlowExecutor->Graph()->SetGraphExecutor( aMacroGraphDataFlowExecutor ) ;
- GraphEditor::DataFlow * aDataFlow = theAutomaton->MapGraph( aCoupledNodeName )->GraphEditor() ;
- if ( aDataFlow == NULL ) {
- MESSAGE( "ExecutorLoadDataFlows NULL GraphEditor ERROR" ) ;
+ anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
+
+ if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
+ // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
+ int i;
+ for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
+ if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
+ GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
+ aMacroNode->GraphEditor( aDataFlowEditor ) ;
+
+ // get the macro node's editor object
+ char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
+ GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
+ GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
+
+ MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
+ << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
+ int index;
+ bool found = false ;
+ for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
+ if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
+ found = true;
+ }
+ if ( !found ) {
+ MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
+ return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
+ }
+ index--; // it was incremented in "for ..." before last check ( !found ).
+
+ // At first create the editor and a StreamGraph
+ string dbgfile ;
+ GraphExecutor::DataFlow * aMacroGraphExecutor ;
+ CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
+ dbgfile , &aMacroGraphExecutor );
+ theAutomaton->Executed() ; // Decrement _GraphExecutingNumber for MacroSubGraph
+
+ // set GraphMacroLevel for Executor's graph
+ GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
+ aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
+
+ // load data flows in MacroGraph's executor
+ Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
+ MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
+ if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
+ MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
+ return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
+ }
+
+ // set coupled pair MacroNode <--> MacroGraph
+ 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();
+//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 {
+ MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
+ << aMacroGraphInPortName << " , Value )" ) ;
}
- aMacroGraphDataFlowExecutor->Graph()->SetGraphEditor( aDataFlow ) ;
- aMacroGraphDataFlowExecutor->Graph()->SetGraphExecutor( aMacroGraphDataFlowExecutor ) ;
- aMacroGraphDataFlowExecutor->Graph()->SetGraphPorts() ;
- Graph_Impl * myMacroGraph ;
-// We create a Graph ObjRef for that graph
- myMacroGraph = new Graph_Impl( _Orb , _Poa, _ContId,
- instanceName() , interfaceName() ,
- aMacroGraphDataFlowExecutor , NULL ) ;
- PortableServer::ObjectId * id = myMacroGraph->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
- myMacroGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
- myMacroGraph->DataFlowEditor( aDataFlow ) ;
- aDataFlow->Executor( aMacroGraphDataFlowExecutor ) ;
- myMacroGraph->DebugFileName( (char * ) dbgfile.c_str() ) ;
-
- GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowExecutor()->Graph() ;
- aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
-
-// Set the MacroNode ObjRef in the GraphMacroNode
- aMacroGraph->CoupledNode( aMacroNode ) ;
- aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
-
-// Set the GraphMacroNode ObjRef in the MacroNode
- aMacroNode->CoupledNode( aMacroGraph ) ;
- aMacroNode->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
-
- iobject->Run() ;
}
- break ;
- }
- }
- }
+ } // end of init MacroNode's InPorts
+#endif
+ aMacroGraphImpl->Run() ;
+
+ }
+ } // end of for( get nodes of the graph...)
}
- }
+ } // end of setting initial graph's structure..
endService( "Graph_Impl::ExecutorLoadDataFlows" );
- return true ;
+
+ PortableServer::ObjectId * id = getId();
+ CORBA::Object_var obj = _poa->id_to_reference( *id );
+ SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
+ return SUPERV::Graph::_duplicate( iobject ) ;
}
SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
beginService( "Graph_Impl::MNode" );
SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
- if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
+ MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
+ if ( !IsMacro() ) {
GraphBase::ListOfSGraphs aListOfDataFlows ;
string dbgfile ;
// At first create the editor and a StreamGraph with the xml file
GraphEditor::DataFlow * aDataFlowEditor ;
CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
dbgfile , &aDataFlowEditor ) ;
+
+ if ( _DebugFileName ) {
+ delete [] _DebugFileName ;
+ }
+ _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
+ strcpy( _DebugFileName , dbgfile.c_str() ) ;
+
int lenname = strlen( aXmlFileName ) ;
bool loaded = false ;
// Import of the xml file
if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
if ( loaded ) {
- iobject = MNode( aDataFlowEditor , aListOfDataFlows ) ;
+ iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
}
}
}
// WARNING : THIS IS COMPLICATED :
// I should have to remove duplicated code ...
SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
- GraphBase::ListOfSGraphs aListOfDataFlows ) {
+ GraphBase::ListOfSGraphs * aListOfDataFlows ) {
beginService( "Graph_Impl::MNode" ) ;
SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
if ( !IsMacro() ) {
- if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
+ MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
+// if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
+ iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
+ if ( CORBA::is_nil( iobject ) ) {
MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
return false ;
}
// That graph is not a StreamGraph :
else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
- aMacroGraphDataFlowEditor->Graph()->SetGraphEditor( aMacroGraphDataFlowEditor ) ;
- Graph_Impl * myMacroGraph ;
-// We create a Graph ObjRef for that graph
- myMacroGraph = new Graph_Impl( _Orb , _Poa, _ContId,
- instanceName() , interfaceName() ,
- aMacroGraphDataFlowEditor , NULL ) ;
- PortableServer::ObjectId * id = myMacroGraph->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- iobject = SUPERV::Graph::_narrow( obj ) ;
- myMacroGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
-
-
+ aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
+ Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
// Creation of a GraphMacroNode in the current editor
string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
Graph_Impl * myMacroNode ;
myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
instanceName() , interfaceName() ,
aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
- id = myMacroNode->getId() ;
- obj = _poa->id_to_reference(*id);
+ PortableServer::ObjectId * id = myMacroNode->getId() ;
+ CORBA::Object_var obj = _poa->id_to_reference(*id);
macroiobject = SUPERV::Graph::_narrow( obj ) ;
myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
aDataFlowNode->SetObjImpl( this ) ;
-
-
GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
aMacroGraph->Kind( SUPERV::MacroNode ) ;
- aMacroGraph->SetGraphEditor( DataFlowEditor() ) ;
+ aMacroGraph->GraphEditor( DataFlowEditor() ) ;
// Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
aMacroGraph->SetMacroPorts( aGraph ) ;
// Valid ==> creation of Service and the ports of the current Graph
aGraph->CoupledNode( aMacroGraph ) ;
aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
// Set the GraphMacroNode ObjRef in the MacroNode
+ aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
aMacroGraph->CoupledNode( aGraph ) ;
+// aGraphOfMacroGraph->CoupledNode( aGraph ) ;
aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
+// aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
// aDataFlowNode->CoupledNode( aGraph ) ;
// aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
// Set the MacroLevel of that graph
aMacroGraph->Coordinates( 0 , 0 ) ;
MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
<< aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
+ MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
+ << " coupled to " << aGraph->CoupledNode() << " "
+ << aGraph->CoupledNode()->Name() ) ;
+ MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
+ << " coupled to " << aMacroGraph->CoupledNode() << " "
+ << aMacroGraph->CoupledNode()->Name() ) ;
+ MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
+ << myMacroNode->DataFlowEditor()->Graph()->Name()
+ << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
}
else {
delete aMacroGraphDataFlowEditor ;
return SUPERV::Graph::_duplicate( macroiobject ) ;
}
+// For python supergraph
SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
SUPERV::Graph_var iobject = myMacroGraph ;
beginService( "Graph_Impl::GraphMNode" ) ;
// Creation of a GraphMacroNode in the current editor
if ( !IsMacro() ) {
string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
+ //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
Graph_Impl * myMacroNode ;
myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
aPythonFunction.resize( 1 ) ;
aPythonFunction[0] = &aListOfStrings ;
SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
- GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
- aMacroNodeName.c_str() , SUPERV::MacroNode ,
- aFuncName , aPythonFunction ) ;
+ GraphEditor::InNode * aDataFlowNode ;
+ aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
+ aMacroNodeName.c_str() , SUPERV::MacroNode ,
+ aFuncName , aPythonFunction ) ;
aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
myMacroNode->DataFlowNode( aDataFlowNode ) ;
aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
aDataFlowNode->SetObjImpl( this ) ;
-
-
-// GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
- GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
+ GraphBase::Graph * aSubGraph = NULL ;
+// GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
+ //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->SetGraphEditor( DataFlowEditor() ) ;
+ 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
- aMacroGraph->CoupledNode( aGraph ) ;
+ aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
+ 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( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : " << aMacroGraph->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 "
<< aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
}
SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
SUPERV::Port_ptr InPort ) {
- beginService( "Graph_Impl::Link" );
+// beginService( "Graph_Impl::Link" );
SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
!OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
- GraphBase::InPort * anInPort = DataFlowEditor()->GetNode( InPort->Node()->Name() )->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
- GraphBase::OutPort * anOutPort = DataFlowEditor()->GetNode( OutPort->Node()->Name() )->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
- if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
- const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
- GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
- const char * DataFlowInNodeName = InPort->Node()->Name() ;
- GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
- if ( DataFlowOutNode && DataFlowInNode ) {
- bool Success ;
- Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- DataFlowInNode ,
- InPort->Name() ,
- DataFlowOutNode ,
- OutPort->Name() ,
- true , false , Success ) ;
- if ( Success ) {
- PortableServer::ObjectId * id = myLink->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- iobject = SUPERV::Link::_narrow(obj) ;
- anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
- }
- }
+ MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
+ << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
+ GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
+ GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
+ if ( anInNode == NULL || anOutNode== NULL ) {
+ MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
+ << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
}
else {
- iobject = anOutPort->InPortObjRef( anInPort ) ;
+ GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
+ GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
+ if ( anInPort == NULL || anOutPort== NULL ) {
+ MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
+ << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
+ }
+ else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
+ const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
+ GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
+ const char * DataFlowInNodeName = InPort->Node()->Name() ;
+ GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
+ if ( DataFlowOutNode && DataFlowInNode ) {
+ bool Success ;
+ Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ DataFlowInNode ,
+ InPort->Name() ,
+ DataFlowOutNode ,
+ OutPort->Name() ,
+ true , false , Success ) ;
+ if ( Success ) {
+ PortableServer::ObjectId * id = myLink->getId() ;
+ CORBA::Object_var obj = _poa->id_to_reference(*id);
+ iobject = SUPERV::Link::_narrow(obj) ;
+ anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
+ }
+ }
+ }
+ else {
+ MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
+ << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
+ iobject = anOutPort->InPortObjRef( anInPort ) ;
+ }
}
}
- endService( "Graph_Impl::Link" );
+ DataFlowEditor()->UnValid() ;
+// endService( "Graph_Impl::Link" );
return SUPERV::Link::_duplicate( iobject ) ;
}
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
// << 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() ) ) ) {
GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
// MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
// << " " << anInPort->PortStatus() ) ;
- if ( !anInPort->IsExternConnected() ) {
- GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+ if ( anInPort->IsPortConnected() ) {
+ GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
+ GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
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() ||
// << anOutPort->PortName() << ") --> " << toNode->Name() << "("
// << anInPort->PortName() << ")" << " skipped" ) ;
}
- }
+// }
}
}
}
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 ;
bool Graph_Impl::IsExecutable() {
// beginService( "Graph_Impl::IsExecutable" );
bool RetVal = false ;
- if ( !IsMacro() ) {
+
+ // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
+ // subgraphs are not executable by themselves, RetVal = false..
+ if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
RetVal = DataFlowEditor()->IsExecutable() ;
}
// endService( "Graph_Impl::IsExecutable" );
}
bool Graph_Impl::IsEditing() {
-// beginService( "Graph_Impl::IsEditing" );
+/*
bool RetVal = false ;
if ( !IsMacro() ) {
RetVal = DataFlowEditor()->IsEditing() ;
}
-// endService( "Graph_Impl::IsEditing" );
return RetVal ;
+*/
+ if ( IsMacro() )
+ return false;
+ return !IsExecuting();
}
+
bool Graph_Impl::IsExecuting() {
-// beginService( "Graph_Impl::IsExecuting" );
+/*
bool RetVal = false ;
if ( !IsMacro() ) {
RetVal = !DataFlowEditor()->IsEditing() ;
}
-// endService( "Graph_Impl::IsExecuting" );
return RetVal ;
+*/
+ return CNode_Impl::IsExecuting();
}
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() ) {
// 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() ;
}
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() ;
- DataFlowExecutor( NULL ) ;
- DataFlowEditor()->Executor( NULL ) ;
+ Editing(); // just in case it was not called before by GUI..
}
if ( DataFlowEditor()->IsExecutable() ) {
DataFlowEditor()->EditedAfterExecution( false ) ;
- int _ExecNumber = theAutomaton->ExecNumber() ;
- char ExecNumber[30] ;
- sprintf( ExecNumber , "_%d" , _ExecNumber ) ;
- int len = strlen( _DebugFileName ) ;
- char * DebugFileName = new char [ len + strlen( ExecNumber ) + 6 ] ;
- strncpy( DebugFileName , _DebugFileName , len - 4 ) ;
- DebugFileName[ len - 4 ] = '\0' ;
- strcat( DebugFileName , ExecNumber ) ;
- strcat( DebugFileName , "_Exec.log" ) ;
- GraphExecutor::DataFlow * aDataFlowExecutor ;
GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
- int i ;
- for ( i = 0 ; i < (int ) myListOfGraphs->size() ; i++ ) {
- GraphEditor::DataFlow * aDataFlowEditor ;
- aDataFlowEditor = theAutomaton->MapGraph( (*myListOfGraphs)[ i ].Info.theName.c_str() )->GraphEditor() ;
- MESSAGE("myListOfGraphs" << i << " " << (*myListOfGraphs)[ i ].Info.theName.c_str() << " "
- << aDataFlowEditor << " IsEditing " << aDataFlowEditor->IsEditing() ) ;
-
- }
- aDataFlowExecutor = new GraphExecutor::DataFlow( _Orb , _NamingService ,
- (*myListOfGraphs)[ 0 ].Info.theName.c_str() ,
- DebugFileName , Kind() ) ;
- DataFlowExecutor( aDataFlowExecutor ) ;
+
+ GraphExecutor::DataFlow * aDataFlowExecutor ;
+ string dbgfile ;
+ CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
+ dbgfile , &aDataFlowExecutor ) ;
+
MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
- RetVal = LoadDataFlows( DataFlowExecutor() , myListOfGraphs , 0 ) ;
- if ( RetVal ) {
+ if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
+ RetVal = true ;
+
+ if ( RetVal )
DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
- DataFlowEditor()->Executor( DataFlowExecutor() ) ;
- }
+
}
if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
perror("pthread_mutex_unlock _MutexExecutorWait") ;
}
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 ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
- MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" );
+
+ // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
+ if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
+
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 );
}
}
- else if ( !IsMacro() ) {
- 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 ( !IsMacro() ) {
- if ( DataFlowEditor()->IsEditing() ) {
- MESSAGE( "Graph_Impl::Start IsEditing" );
- RetVal = Begin() ;
- }
- else {
- RetVal = true ;
- }
- if ( RetVal ) {
- MESSAGE( "Graph_Impl::(Re)Start " );
- // Added by NKV to fix PAL6222 --> to be confirm by JR
- DataFlowEditor()->Executing() ;
- // End of NKV's correction
- RetVal = ReStart() ;
- }
- }
+ bool RetVal = run( /*andSuspend=*/true ) ;
+ MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
endService( "Graph_Impl::Start" );
return RetVal ;
}
}
anEvent = theEvent ;
aState = theState ;
+
return RetVal ;
}
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 ) ;
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() ;
}
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() ;
}
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() ) {
if ( RetVal ) {
for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
+ SALOME_ModuleCatalog::ImplType implType = SALOME_ModuleCatalog::SO;
+ if (!aNode->IsCimpl()) implType = SALOME_ModuleCatalog::PY;
SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
aNode->GetInterfaceName() ,
- *(aNode->Service()) ) ;
+ *(aNode->Service()) ,
+ implType ) ; // mkr : PAL11273
if ( !CORBA::is_nil( myNode ) ) {
myNode->SetName( aNode->Name() ) ;
myNode->SetAuthor( aNode->Author() ) ;
SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
if ( myStreamPorts[ j ]->IsInput() ) {
- aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
else {
- aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
}
}
SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
if ( myStreamPorts[ j ]->IsInput() ) {
- aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
else {
- aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
}
}
SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
if ( myStreamPorts[ j ]->IsInput() ) {
- aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
else {
- aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
}
}
SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
if ( myStreamLoopPorts[ j ]->IsInput() ) {
- aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
+ aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
}
else {
- aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
+ aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
}
}
}
SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
if ( myStreamPorts[ j ]->IsInput() ) {
- aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
else {
- aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
+ aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
}
}
}
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(), 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(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
}
}
}
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 ;
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 );
+ }
+}
+/**
+ * Returns the default name of container for C component
+ */
+char* Graph_Impl::DefaultCContainerName() {
+ return ( CORBA::string_dup( FACTORYSERVER ) );
+}
+/**
+ * Returns the default name of container for Python component
+ */
+char* Graph_Impl::DefaultPythonContainerName() {
+ return ( CORBA::string_dup( FACTORYSERVERPY ) );
+}
+
+/*!
+ * Returns the last container name associated with theComponentName component
+ */
+char* Graph_Impl::ContainerNameForComponent( const char * theComponentName ) {
+ const char* aContainer = DataFlowEditor()->Graph()->RetrieveFromMapOfComponentNameContainer(theComponentName);
+ if ( aContainer )
+ return my_strdup(aContainer);
+ else
+ return "";
+}