1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : Graph_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "SALOME_Container_i.hxx"
39 #include "StreamGraph_Impl.hxx"
41 #include "DataFlowEditor_DataFlow.hxx"
43 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
45 static void CreateEditor( CORBA::ORB_ptr orb ,
46 const char *instanceName ,
47 const char *aDataFlowName ,
48 const SUPERV::KindOfNode aKindOfNode ,
50 GraphEditor::DataFlow ** aDataFlowEditor ) {
51 bool aXmlFile = false ;
52 int lenname = strlen( aDataFlowName ) ;
53 char * theDataFlowName = new char [ lenname+1 ] ;
54 strcpy( theDataFlowName , aDataFlowName ) ;
55 if ( aDataFlowName ) {
56 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
57 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
58 theDataFlowName[ lenname-4 ] = '\0' ;
61 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
62 if ( aDataFlowName[ i ] == '/' ) {
63 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
64 theDataFlowName[ lenname-5-i ] = '\0' ;
70 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
74 string theDataFlowInstanceName = theDataFlowName ;
76 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
77 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
78 dbgfile = "/tmp/logs/" ;
79 dbgfile += getenv( "USER" ) ;
81 dbgfile += instanceName ;
83 dbgfile += theDataFlowInstanceName ;
84 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
85 FILE* f = fopen ( dbgfile.c_str(), "a" );
86 if ( f ) { // check if file can be opened for writing
89 else { // if file can't be opened - use a guaranteed temp file name
90 char* aTempNam = tempnam( NULL, NULL );
95 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
96 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
97 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
99 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
100 << dbgfile.c_str() ) ;
102 delete [] theDataFlowName ;
105 static void CreateExecutor( CORBA::ORB_ptr orb ,
106 const char *instanceName ,
107 const char *aDataFlowName ,
108 const SUPERV::KindOfNode aKindOfNode ,
110 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
111 int lenname = strlen( aDataFlowName ) ;
112 char * theDataFlowName = new char [ lenname+1 ] ;
113 strcpy( theDataFlowName , aDataFlowName ) ;
114 if ( aDataFlowName ) {
115 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
118 string theDataFlowInstanceName = theDataFlowName ;
120 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
121 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
122 dbgfile = "/tmp/logs/" ;
123 dbgfile += getenv( "USER" ) ;
125 dbgfile += instanceName ;
127 dbgfile += theDataFlowInstanceName ;
128 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
130 astr << theAutomaton->ExecNumber() ;
131 dbgfile += astr.str() ;
132 dbgfile += string( "_Exec.log" ) ;
133 FILE* f = fopen ( dbgfile.c_str(), "a" );
134 if ( f ) { // check if file can be opened for writing
137 else { // if file can't be opened - use a guaranteed temp file name
138 char* aTempNam = tempnam( NULL, NULL );
143 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
144 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
145 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
148 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
149 << dbgfile.c_str() ) ;
151 delete [] theDataFlowName ;
154 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
155 PortableServer::POA_ptr poa ,
156 PortableServer::ObjectId * contId ,
157 const char *instanceName ,
158 const char *interfaceName ,
159 const char *aDataFlowName ,
160 const SUPERV::KindOfNode aKindOfNode ) :
161 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
162 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
163 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
164 // << hex << (void *) this << dec )
165 // beginService( "Graph_Impl::Graph_Impl" );
166 _Orb = CORBA::ORB::_duplicate(orb);
169 _DebugFileName = NULL ;
170 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
171 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
173 _id = _poa->activate_object(_thisObj);
176 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
179 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
181 GraphEditor::DataFlow * aDataFlowEditor ;
182 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
183 dbgfile , &aDataFlowEditor ) ;
185 if ( _DebugFileName ) {
186 delete [] _DebugFileName ;
188 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
189 strcpy( _DebugFileName , dbgfile.c_str() ) ;
191 _NamingService = new SALOME_NamingService( orb ) ;
192 DataFlowEditor( aDataFlowEditor ) ;
193 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
194 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
196 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
197 // DataFlowExecutor( NULL ) ;
198 // endService( "Graph_Impl::Graph_Impl" );
201 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
202 PortableServer::POA_ptr poa ,
203 PortableServer::ObjectId * contId ,
204 const char *instanceName ,
205 const char *interfaceName ,
206 GraphEditor::DataFlow * aDataFlowEditor ,
207 GraphEditor::InNode * aDataFlowNode ) :
208 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
209 // beginService( "Graph_Impl::Graph_Impl" );
210 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
211 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
212 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
213 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
215 _id = _poa->activate_object(_thisObj);
218 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
220 _Orb = CORBA::ORB::_duplicate(orb);
223 _DebugFileName = NULL ;
224 DataFlowEditor( aDataFlowEditor ) ;
225 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
226 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
227 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
228 // DataFlowExecutor( NULL ) ;
229 // endService( "Graph_Impl::Graph_Impl" );
232 Graph_Impl::Graph_Impl() {
235 Graph_Impl::~Graph_Impl() {
236 beginService( "Graph_Impl::~Graph_Impl" );
237 endService( "Graph_Impl::~Graph_Impl" );
240 void Graph_Impl::destroy() {
241 beginService( "Graph_Impl::destroy" );
242 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
243 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
244 GNode_Impl::Delete() ;
245 if ( !CORBA::is_nil( aGraph ) ) {
250 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
251 GNode_Impl::Delete() ;
252 if ( !CORBA::is_nil( aGraph ) ) {
256 _poa->deactivate_object(*_id) ;
257 // CORBA::release(_poa) ;
259 // _thisObj->_remove_ref();
260 endService( "Graph_Impl::destroy" );
264 char* Graph_Impl::getIOR() {
266 return CORBA::string_dup( NULLSTRING ) ;
268 else if ( CORBA::is_nil( myServant ) ) {
269 PortableServer::ObjectId* id = getId();
270 CORBA::Object_var obj;
271 obj = _poa->id_to_reference(*id);
272 myServant = SUPERV::Graph::_narrow(obj);
274 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
277 SUPERV::Graph_ptr Graph_Impl::Copy() {
278 beginService( "Graph_Impl::Copy" );
279 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
281 Graph_Impl * myGraph ;
282 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
283 instanceName() , interfaceName() ,
284 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
285 PortableServer::ObjectId * id = myGraph->getId() ;
286 CORBA::Object_var obj = _poa->id_to_reference(*id);
287 iobject = SUPERV::Graph::_narrow(obj) ;
288 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
289 myGraph->LoadGraphs( aListOfSGraphs ) ;
291 endService( "Graph_Impl::Copy" );
292 return SUPERV::Graph::_duplicate(iobject) ;
295 void Graph_Impl::ReadOnly() {
296 DataFlowEditor()->ReadOnly() ;
299 SUPERV::INode_ptr Graph_Impl::Node() {
300 // beginService( "Graph_Impl::Node" );
301 PortableServer::ObjectId * id = getId() ;
302 CORBA::Object_var obj = _poa->id_to_reference(*id);
303 SUPERV::Graph_var iobject ;
304 iobject = SUPERV::Graph::_narrow(obj) ;
305 // endService( "Graph_Impl::Node" );
306 return SUPERV::Graph::_duplicate(iobject) ;
309 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
310 return DataFlowEditor()->GetDataFlows() ;
313 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
314 beginService( "Graph_Impl::LoadGraphs" );
315 bool RetVal = false ;
316 if ( DataFlowEditor()->IsEditing() ) {
317 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
318 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
322 endService( "Graph_Impl::LoadGraphs" );
326 bool Graph_Impl::Import(const char * aXmlFile ) {
327 beginService( "Graph_Impl::Import" );
328 bool RetVal = false ;
329 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
330 GraphBase::ListOfSGraphs aListOfDataFlows ;
331 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
332 if ( RetVal && aXmlFile != NULL ) {
333 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
334 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
339 endService( "Graph_Impl::Import" );
343 bool Graph_Impl::Export(const char * anXmlFile ) {
344 beginService( "Graph_Impl::Export" );
345 bool RetVal = false ;
347 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
348 strcpy( aFile , anXmlFile ) ;
349 int len = strlen( aFile ) ;
350 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
352 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
353 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
354 len = strlen( aFile ) ;
357 strcat( aFile , ".xml" ) ;
358 len = strlen( aFile ) ;
360 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
362 strcpy( &aFile[ len - 4 ] , ".py" ) ;
363 RetVal = DataFlowEditor()->SavePy( aFile ) ;
367 endService( "Graph_Impl::Export" );
371 char * Graph_Impl::SavePY( bool importSuperV ) {
372 beginService( "Graph_Impl::SavePY" );
373 ostringstream fstring ;
375 RetVal = DataFlowEditor()->SavePY( fstring , importSuperV ) ;
377 endService( "Graph_Impl::SavePY" );
378 return CORBA::string_dup( fstring.str().c_str() );
380 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
381 beginService( "Graph_Impl::CNode" );
382 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
383 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
384 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
385 instanceName() , interfaceName() ,
387 NodeService , NULLSTRING ,
388 SUPERV::ComputingNode , NULLSTRING ) ;
389 if ( myNode->DataFlowNode() ) {
390 PortableServer::ObjectId * id = myNode->getId() ;
391 CORBA::Object_var obj = _poa->id_to_reference(*id);
392 iobject = SUPERV::CNode::_narrow(obj) ;
393 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
396 DataFlowEditor()->UnValid() ;
397 endService( "Graph_Impl::CNode" );
398 return SUPERV::CNode::_duplicate( iobject ) ;
401 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
402 const char * NodeInterfaceName ,
403 const SALOME_ModuleCatalog::Service &NodeService ) {
404 beginService( "Graph_Impl::FNode" );
405 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
406 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
407 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
408 instanceName() , interfaceName() ,
412 NodeInterfaceName ) ;
413 if ( myNode->DataFlowNode() ) {
414 PortableServer::ObjectId * id = myNode->getId() ;
415 CORBA::Object_var obj = _poa->id_to_reference(*id);
416 iobject = SUPERV::FNode::_narrow(obj) ;
417 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
420 DataFlowEditor()->UnValid() ;
421 endService( "Graph_Impl::FNode" );
422 return SUPERV::FNode::_duplicate( iobject ) ;
425 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
426 const SUPERV::ListOfStrings & PythonFuntion ) {
427 beginService( "Graph_Impl::INode" );
428 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
429 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
430 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
431 instanceName() , interfaceName() ,
433 FuncName , PythonFuntion ,
434 SUPERV::InLineNode ) ;
435 if ( myNode->DataFlowNode() ) {
436 PortableServer::ObjectId * id = myNode->getId() ;
437 CORBA::Object_var obj = _poa->id_to_reference(*id);
438 iobject = SUPERV::INode::_narrow(obj) ;
439 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
442 endService( "Graph_Impl::INode" );
443 return SUPERV::INode::_duplicate( iobject ) ;
447 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
448 const SUPERV::ListOfStrings & PythonFuntion ,
449 const char * anInLineNode ) {
450 beginService( "Graph_Impl::GNode" );
451 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
452 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
453 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
454 instanceName() , interfaceName() ,
456 FuncName , PythonFuntion ,
458 if ( myNode->DataFlowNode() ) {
459 PortableServer::ObjectId * id = myNode->getId() ;
460 CORBA::Object_var obj = _poa->id_to_reference(*id);
461 iobject = SUPERV::GNode::_narrow(obj) ;
462 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
463 if ( strlen( anInLineNode ) ) {
464 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
465 if ( anInLineNode ) {
466 myNode->SetCoupled( anInLineNode ) ;
467 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
472 DataFlowEditor()->UnValid() ;
473 endService( "Graph_Impl::GNode" );
474 return SUPERV::GNode::_duplicate( iobject ) ;
477 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
478 const SUPERV::ListOfStrings & InitFunction ,
479 const char * MoreName ,
480 const SUPERV::ListOfStrings & MoreFunction ,
481 const char * NextName ,
482 const SUPERV::ListOfStrings & NextFunction ,
483 SUPERV::INode_out anEndOfLoop ) {
484 beginService( "Graph_Impl::LNode" );
485 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
486 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
487 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
488 GraphBase::ListOfFuncName FuncNameList ;
489 FuncNameList.resize(3) ;
490 FuncNameList[0] = InitName ;
491 FuncNameList[1] = MoreName ;
492 FuncNameList[2] = NextName ;
493 GraphBase::ListOfPythonFunctions PythonFunctionList ;
494 PythonFunctionList.resize(3) ;
495 PythonFunctionList[0] = &InitFunction ;
496 PythonFunctionList[1] = &MoreFunction ;
497 PythonFunctionList[2] = &NextFunction ;
498 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
499 instanceName() , interfaceName() ,
501 FuncNameList , PythonFunctionList ,
502 // InitName , InitFunction ,
503 // MoreName , MoreFunction ,
504 // NextName , NextFunction ,
506 if ( myNode->DataFlowNode() ) {
507 PortableServer::ObjectId * id = myNode->getId() ;
508 CORBA::Object_var obj = _poa->id_to_reference(*id);
509 iobject = SUPERV::LNode::_narrow(obj) ;
510 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
512 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
514 if ( strlen( InitName ) ) {
515 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
516 strcpy( anEndName , "End" ) ;
517 strcat( anEndName , InitName ) ;
520 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
521 strcpy( anEndName , "EndLoop" ) ;
523 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
524 instanceName() , interfaceName() ,
527 SUPERV::EndLoopNode ) ;
528 PortableServer::ObjectId * endid = myEndNode->getId() ;
529 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
530 iendobject = SUPERV::ELNode::_narrow(endobj) ;
531 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
532 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
533 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
534 //JR 25.01.2005 That links are already done in SetCoupled above ...
535 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
536 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
537 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
540 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
541 DataFlowEditor()->UnValid() ;
542 endService( "Graph_Impl::LNode" );
543 return SUPERV::LNode::_duplicate( iobject ) ;
546 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
547 const SUPERV::ListOfStrings & PythonFunction ,
548 SUPERV::INode_out anEndOfSwitch ) {
549 beginService( "Graph_Impl::SNode" );
550 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
551 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
552 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
553 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
554 instanceName() , interfaceName() ,
556 FuncName , PythonFunction ,
557 SUPERV::SwitchNode ) ;
558 if ( myNode->DataFlowNode() ) {
559 PortableServer::ObjectId * id = myNode->getId() ;
560 CORBA::Object_var obj = _poa->id_to_reference(*id);
561 iobject = SUPERV::SNode::_narrow(obj) ;
562 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
564 string anEndName = "End" ;
565 if ( strlen( FuncName ) ) {
566 anEndName += FuncName ;
569 anEndName += "Switch" ;
571 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
572 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
573 // << anEndName.c_str() << endl ;
574 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
575 instanceName() , interfaceName() ,
578 SUPERV::EndSwitchNode ) ;
579 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
580 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
581 // << " " << anEndName.c_str() << endl ;
582 PortableServer::ObjectId * endid = myEndNode->getId() ;
583 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
584 iendobject = SUPERV::ESNode::_narrow(endobj) ;
585 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
586 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
587 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
588 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
589 iobject = SUPERV::SNode::_nil() ;
590 iendobject = SUPERV::ESNode::_nil() ;
594 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
595 DataFlowEditor()->UnValid() ;
596 endService( "Graph_Impl::SNode" );
597 return SUPERV::SNode::_duplicate( iobject ) ;
600 // WARNING : THIS IS COMPLICATED :
601 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
602 GraphBase::ListOfSGraphs * aListOfDataFlows ,
604 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
605 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
607 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
608 // That method is recursive :
609 // At first we load the supergraph with index = 0 :
610 // (After we load the graph corresponding to each MacroNode :)
611 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
612 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
613 return SUPERV::Graph::_duplicate( iobject ) ;
615 // That graph is not a StreamGraph :
616 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
617 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
618 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
619 Graph_Impl * myGraph ;
620 // We create a Graph ObjRef for that graph
621 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
622 instanceName() , interfaceName() ,
623 aDataFlowEditor , NULL ) ;
624 PortableServer::ObjectId * id = myGraph->getId() ;
625 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
626 iobject = SUPERV::Graph::_narrow( obj ) ;
627 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
628 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
629 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
632 // asv: set Editor for the graph itself and for all its macro nodes
633 aGraph->GraphEditor( aDataFlowEditor );
635 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
636 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
637 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
638 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
640 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
641 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
642 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
643 // so here we check if the node is "new" or "old"
644 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
647 // asv: set Editor for the graph itself and for all its macro nodes
648 aMacroNode->GraphEditor( aDataFlowEditor );
650 // Creation of a GraphMacroNode ObjRef in the current editor
651 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
652 Graph_Impl * myMacroNode ;
653 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
654 instanceName() , interfaceName() ,
655 aMacroNode->Name() , SUPERV::MacroNode ) ;
656 id = myMacroNode->getId() ;
657 obj = _poa->id_to_reference(*id);
658 macroiobject = SUPERV::Graph::_narrow( obj ) ;
659 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
660 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
661 myMacroNode->DataFlowNode( aDataFlowNode ) ;
662 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
663 aDataFlowNode->SetObjImpl( myMacroNode ) ;
665 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
666 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
667 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
670 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
671 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
672 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
675 // At first create the editor and a StreamGraph
676 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
677 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
678 dbgfile , &aMacroGraphDataFlowEditor ) ;
680 if ( _DebugFileName ) {
681 delete [] _DebugFileName ;
683 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
684 strcpy( _DebugFileName , dbgfile.c_str() ) ;
686 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
687 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
688 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
689 return SUPERV::Graph::_duplicate( iobject ) ;
692 // That graph is not a StreamGraph :
693 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
694 Graph_Impl * myMacroGraph ;
695 // The Graph ObjRef for that graph was already created
696 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
698 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
700 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
701 aMacroGraph->CoupledNode( aMacroNode ) ;
702 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
704 // Set the GraphMacroNode ObjRef in the MacroNode
705 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
706 aMacroNode->CoupledNode( aMacroGraph ) ;
707 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
708 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
709 << " coupled to " << aMacroGraph->CoupledNode() << " "
710 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
711 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
712 << " coupled to " << aMacroNode->CoupledNode() << " "
713 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
714 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
715 << " coupled to " << aGraph->CoupledNode()
716 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
722 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
727 else if ( (*aListOfDataFlows).size() == 1 ) {
728 StreamGraph_Impl * myStreamGraph ;
729 // We create a Graph ObjRef for that graph
730 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
731 instanceName() , interfaceName() ,
732 aDataFlowEditor , NULL ) ;
733 PortableServer::ObjectId * id = myStreamGraph->getId() ;
734 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
735 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
736 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
737 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
738 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
739 // iobject = SUPERV::Graph::_narrow( obj ) ;
740 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
743 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
746 endService( "Graph_Impl::EditorLoadDataFlows" );
747 return SUPERV::Graph::_duplicate( iobject ) ;
750 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
751 GraphBase::ListOfSGraphs * aListOfDataFlows ,
753 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
754 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
756 // That method is recursive :
757 // At first we load the supergraph with index = 0 :
758 // (After we load the graph corresponding to each MacroNode :)
759 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
760 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
761 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
764 // That graph is not a StreamGraph :
766 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
767 GraphEditor::DataFlow * aDataFlowEditor ;
768 aDataFlowEditor = DataFlowEditor() ;
769 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
770 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
771 if ( aDataFlowEditor->Executor() ) {
772 delete aDataFlowEditor->Executor() ;
773 aDataFlowEditor->Executor( NULL ) ;
774 aDataFlowEditor->Editing() ;
776 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
777 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
779 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
780 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
782 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
783 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
784 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
785 aMacroNode->GraphEditor( aDataFlowEditor ) ;
787 // get the macro node's editor object
788 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
789 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
790 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
792 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
793 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
796 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
797 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
801 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
802 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
804 index--; // it was incremented in "for ..." before last check ( !found ).
806 // At first create the editor and a StreamGraph
808 GraphExecutor::DataFlow * aMacroGraphExecutor ;
809 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
810 dbgfile , &aMacroGraphExecutor );
812 // set GraphMacroLevel for Executor's graph
813 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
814 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
816 // load data flows in MacroGraph's executor
817 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
818 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
819 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
820 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
821 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
824 // set coupled pair MacroNode <--> MacroGraph
825 aMacroGraphExe->CoupledNode( aMacroNode ) ;
826 aMacroNode->CoupledNode( aMacroGraphExe ) ;
828 //JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
829 // InPorts values of MacroGraphs of MacroNodes are done in the Executor
830 // It was probably to try to debug anything but it was a wrong debug and I do not know what bug
831 // ===> folowing code is commented
833 // initialize MacroNode's InPorts with corresponding "external" values
835 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
836 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
837 if ( anInPort->IsDataConnected() ) {
838 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
839 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
840 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
841 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
844 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
845 << aMacroGraphInPortName << " , Value )" ) ;
848 } // end of init MacroNode's InPorts
850 aMacroGraphImpl->Run() ;
853 } // end of for( get nodes of the graph...)
855 } // end of setting initial graph's structure..
857 endService( "Graph_Impl::ExecutorLoadDataFlows" );
859 PortableServer::ObjectId * id = getId();
860 CORBA::Object_var obj = _poa->id_to_reference( *id );
861 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
862 return SUPERV::Graph::_duplicate( iobject ) ;
865 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
866 beginService( "Graph_Impl::MNode" );
867 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
868 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
870 GraphBase::ListOfSGraphs aListOfDataFlows ;
872 // At first create the editor and a StreamGraph with the xml file
873 GraphEditor::DataFlow * aDataFlowEditor ;
874 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
875 dbgfile , &aDataFlowEditor ) ;
877 if ( _DebugFileName ) {
878 delete [] _DebugFileName ;
880 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
881 strcpy( _DebugFileName , dbgfile.c_str() ) ;
883 int lenname = strlen( aXmlFileName ) ;
884 bool loaded = false ;
885 // Import of the xml file
886 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
887 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
889 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
896 // WARNING : THIS IS COMPLICATED :
897 // I should have to remove duplicated code ...
898 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
899 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
900 beginService( "Graph_Impl::MNode" ) ;
901 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
902 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
905 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
906 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
907 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
908 if ( CORBA::is_nil( iobject ) ) {
909 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
913 // That graph is not a StreamGraph :
914 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
915 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
916 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
918 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
919 // Creation of a GraphMacroNode in the current editor
920 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
921 Graph_Impl * myMacroNode ;
922 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
923 instanceName() , interfaceName() ,
924 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
925 PortableServer::ObjectId * id = myMacroNode->getId() ;
926 CORBA::Object_var obj = _poa->id_to_reference(*id);
927 macroiobject = SUPERV::Graph::_narrow( obj ) ;
928 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
930 // Creation of the MacroNode itself in the current Graph
931 GraphBase::ListOfFuncName aFuncName ;
932 aFuncName.resize( 1 ) ;
934 SUPERV::ListOfStrings aListOfStrings ;
935 aListOfStrings.length( 1 ) ;
936 aListOfStrings[0] = "" ;
937 GraphBase::ListOfPythonFunctions aPythonFunction ;
938 aPythonFunction.resize( 1 ) ;
939 aPythonFunction[0] = &aListOfStrings ;
940 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
941 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
942 aMacroNodeName.c_str() , SUPERV::MacroNode ,
943 aFuncName , aPythonFunction ) ;
944 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
945 myMacroNode->DataFlowNode( aDataFlowNode ) ;
946 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
947 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
948 aDataFlowNode->SetObjImpl( this ) ;
950 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
951 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
952 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
953 aMacroGraph->Kind( SUPERV::MacroNode ) ;
954 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
955 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
956 aMacroGraph->SetMacroPorts( aGraph ) ;
957 // Valid ==> creation of Service and the ports of the current Graph
958 DataFlowEditor()->IsValid() ;
959 // Set the Input Datas from the GraphMacroNode to the current Graph
960 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
961 aMacroGraphDataFlowEditor->UnValid() ;
962 // Set the MacroNode ObjRef in the GraphMacroNode
963 aGraph->CoupledNode( aMacroGraph ) ;
964 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
965 // Set the GraphMacroNode ObjRef in the MacroNode
966 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
967 aMacroGraph->CoupledNode( aGraph ) ;
968 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
969 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
970 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
971 // aDataFlowNode->CoupledNode( aGraph ) ;
972 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
973 // Set the MacroLevel of that graph
974 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
975 aMacroGraph->Coordinates( 0 , 0 ) ;
976 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
977 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
978 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
979 << " coupled to " << aGraph->CoupledNode() << " "
980 << aGraph->CoupledNode()->Name() ) ;
981 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
982 << " coupled to " << aMacroGraph->CoupledNode() << " "
983 << aMacroGraph->CoupledNode()->Name() ) ;
984 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
985 << myMacroNode->DataFlowEditor()->Graph()->Name()
986 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
989 delete aMacroGraphDataFlowEditor ;
992 endService( "Graph_Impl::MNode" );
993 return SUPERV::Graph::_duplicate( macroiobject ) ;
996 // For python supergraph
997 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
998 SUPERV::Graph_var iobject = myMacroGraph ;
999 beginService( "Graph_Impl::GraphMNode" ) ;
1001 // GraphBase::Graph * myMacroGraph = aGraph;
1002 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
1003 // Creation of a GraphMacroNode in the current editor
1005 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
1006 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
1007 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
1008 Graph_Impl * myMacroNode ;
1009 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1010 instanceName() , interfaceName() ,
1011 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1012 PortableServer::ObjectId * id = myMacroNode->getId() ;
1013 CORBA::Object_var obj = _poa->id_to_reference(*id);
1014 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1015 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1017 // Creation of the MacroNode itself in the current Graph
1018 GraphBase::ListOfFuncName aFuncName ;
1019 aFuncName.resize( 1 ) ;
1021 SUPERV::ListOfStrings aListOfStrings ;
1022 aListOfStrings.length( 1 ) ;
1023 aListOfStrings[0] = "" ;
1024 GraphBase::ListOfPythonFunctions aPythonFunction ;
1025 aPythonFunction.resize( 1 ) ;
1026 aPythonFunction[0] = &aListOfStrings ;
1027 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1028 GraphEditor::InNode * aDataFlowNode ;
1029 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1030 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1031 aFuncName , aPythonFunction ) ;
1032 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1033 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1034 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1035 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1036 aDataFlowNode->SetObjImpl( this ) ;
1038 GraphBase::Graph * aSubGraph = NULL ;
1039 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1040 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1041 //JR 20.09.2005 Debug SAB_data_1609_bugPAL.py from CEA (Anthony)
1042 // Graph_Impl * aSubGraphImpl = dynamic_cast<Graph_Impl * >( _Poa->id_to_servant( *myMacroGraph->_Id ) ) ;
1043 myMacroGraph->ping() ;
1044 Graph_Impl * aSubGraphImpl = theAutomaton->GraphImpl() ;
1045 aSubGraph = aSubGraphImpl->DataFlowEditor()->Graph() ;
1046 myMacroGraph->Coupled() ;
1047 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1048 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1049 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1050 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1051 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1052 aMacroGraph->SetMacroPorts( aSubGraph ) ;
1053 // Valid ==> creation of Service and the ports of the current Graph
1054 DataFlowEditor()->IsValid() ;
1055 // Set the Input Datas from the GraphMacroNode to the current Graph
1056 aMacroGraph->SetMacroDatas( aSubGraph , aGraphOfMacroGraph ) ;
1057 // aMacroGraphDataFlowEditor->UnValid() ;
1058 aSubGraph->GraphEditor()->UnValid() ;
1059 // Set the MacroNode ObjRef in the GraphMacroNode
1060 aSubGraph->CoupledNode( aMacroGraph ) ;
1061 aSubGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1062 // Set the GraphMacroNode ObjRef in the MacroNode
1063 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1064 aMacroGraph->CoupledNode( aSubGraph ) ;
1065 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1066 // aDataFlowNode->CoupledNode( aSubGraph ) ;
1067 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1068 // Set the MacroLevel of that graph
1069 aSubGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1070 aMacroGraph->Coordinates( 0 , 0 ) ;
1071 MESSAGE( aSubGraph->Name() << "->CoupledNode()->GraphEditor() : " << aSubGraph->CoupledNode()->GraphEditor() ) ;
1072 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1073 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1074 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1075 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1077 endService( "Graph_Impl::GraphMNode" ) ;
1078 return SUPERV::Graph::_duplicate( macroiobject ) ;
1081 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1082 beginService( "Graph_Impl::FlowObjRef" );
1083 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1085 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1087 else if ( IsGraph() ) {
1088 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1090 if ( CORBA::is_nil( iobject ) ) {
1091 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1093 endService( "Graph_Impl::FlowObjRef" );
1094 return SUPERV::Graph::_duplicate( iobject ) ;
1097 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1098 beginService( "Graph_Impl::StreamObjRef" );
1099 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1101 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1103 else if ( IsGraph() || IsStreamGraph() ) {
1104 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1106 if ( CORBA::is_nil( iobject ) ) {
1107 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1109 endService( "Graph_Impl::StreamObjRef" );
1110 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1113 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1114 // beginService( "Graph_Impl::Node" );
1115 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1117 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1118 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1119 instanceName() , interfaceName() ,
1121 DataFlowEditor()->GetNode( aNodeName ) ) ;
1122 PortableServer::ObjectId * id = myNode->getId() ;
1123 CORBA::Object_var obj = _poa->id_to_reference(*id);
1124 iobject = SUPERV::CNode::_narrow(obj) ;
1125 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1128 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1131 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1133 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1134 SetNodeObjRef( anInNode ) ;
1136 iobject = anInNode->ObjRef() ;
1139 // endService( "Graph_Impl::Node" );
1140 return SUPERV::CNode::_duplicate( iobject ) ;
1143 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1144 SUPERV::Port_ptr InPort ) {
1145 // beginService( "Graph_Impl::Link" );
1146 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1147 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1148 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1149 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1150 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1151 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1152 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1153 if ( anInNode == NULL || anOutNode== NULL ) {
1154 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1155 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1158 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1159 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1160 if ( anInPort == NULL || anOutPort== NULL ) {
1161 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1162 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1164 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1165 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1166 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1167 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1168 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1169 if ( DataFlowOutNode && DataFlowInNode ) {
1171 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1172 instanceName() , interfaceName() ,
1178 true , false , Success ) ;
1180 PortableServer::ObjectId * id = myLink->getId() ;
1181 CORBA::Object_var obj = _poa->id_to_reference(*id);
1182 iobject = SUPERV::Link::_narrow(obj) ;
1183 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1188 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1189 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
1190 iobject = anOutPort->InPortObjRef( anInPort ) ;
1194 DataFlowEditor()->UnValid() ;
1195 // endService( "Graph_Impl::Link" );
1196 return SUPERV::Link::_duplicate( iobject ) ;
1199 // Only to see MacroNodes with actual GUI ... :
1200 #define GOTOMacroNode 0
1202 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1203 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1204 CORBA::Object_var obj ;
1205 if ( anInNode->IsComputingNode() ) {
1206 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1207 instanceName() , interfaceName() ,
1210 PortableServer::ObjectId * id = myNode->getId() ;
1211 obj = _poa->id_to_reference(*id);
1212 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1213 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1215 else if ( anInNode->IsFactoryNode() ) {
1216 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1217 instanceName() , interfaceName() ,
1220 PortableServer::ObjectId * id = myNode->getId() ;
1221 obj = _poa->id_to_reference(*id);
1222 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1223 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1225 else if ( anInNode->IsInLineNode() ) {
1226 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1227 instanceName() , interfaceName() ,
1230 PortableServer::ObjectId * id = myNode->getId() ;
1231 obj = _poa->id_to_reference(*id);
1232 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1233 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1236 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1237 if ( anInNode->IsMacroNode() ) {
1238 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1241 else if ( anInNode->IsGOTONode() ) {
1243 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1244 instanceName() , interfaceName() ,
1247 PortableServer::ObjectId * id = myNode->getId() ;
1248 obj = _poa->id_to_reference(*id);
1249 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1250 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1252 else if ( anInNode->IsMacroNode() ) {
1253 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1254 instanceName() , interfaceName() ,
1257 PortableServer::ObjectId * id = myNode->getId() ;
1258 obj = _poa->id_to_reference(*id);
1259 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1260 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1262 else if ( anInNode->IsLoopNode() ) {
1263 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1264 instanceName() , interfaceName() ,
1267 PortableServer::ObjectId * id = myNode->getId() ;
1268 obj = _poa->id_to_reference(*id);
1269 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1270 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1272 else if ( anInNode->IsEndLoopNode() ) {
1273 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1274 instanceName() , interfaceName() ,
1277 PortableServer::ObjectId * id = myNode->getId() ;
1278 obj = _poa->id_to_reference(*id);
1279 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1280 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1282 else if ( anInNode->IsSwitchNode() ) {
1283 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1284 instanceName() , interfaceName() ,
1287 PortableServer::ObjectId * id = myNode->getId() ;
1288 obj = _poa->id_to_reference(*id);
1289 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1290 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1292 else if ( anInNode->IsEndSwitchNode() ) {
1293 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1294 instanceName() , interfaceName() ,
1297 PortableServer::ObjectId * id = myNode->getId() ;
1298 obj = _poa->id_to_reference(*id);
1299 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1300 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1304 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1305 GraphBase::ComputingNode * aNode ) {
1307 // if ( _DataFlowExecutor ) {
1308 if ( DataFlowExecutor() ) {
1309 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1310 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1313 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1315 if ( aNode->IsComputingNode() ) {
1316 index = RetVal->CNodes.length() ;
1317 RetVal->CNodes.length( index+1 );
1319 else if ( aNode->IsFactoryNode() ) {
1320 index = RetVal->FNodes.length() ;
1321 RetVal->FNodes.length( index+1 );
1323 else if ( aNode->IsInLineNode() ) {
1324 index = RetVal->INodes.length() ;
1325 RetVal->INodes.length( index+1 );
1328 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1330 else if ( aNode->IsGOTONode() ) {
1332 index = RetVal->GNodes.length() ;
1333 RetVal->GNodes.length( index+1 );
1335 else if ( aNode->IsMacroNode() ) {
1336 index = RetVal->Graphs.length() ;
1337 RetVal->Graphs.length( index+1 );
1339 else if ( aNode->IsLoopNode() ) {
1340 index = RetVal->LNodes.length() ;
1341 RetVal->LNodes.length( index+1 );
1343 else if ( aNode->IsEndLoopNode() ) {
1344 index = RetVal->ELNodes.length() ;
1345 RetVal->ELNodes.length( index+1 );
1347 else if ( aNode->IsSwitchNode() ) {
1348 index = RetVal->SNodes.length() ;
1349 RetVal->SNodes.length( index+1 );
1351 else if ( aNode->IsEndSwitchNode() ) {
1352 index = RetVal->ESNodes.length() ;
1353 RetVal->ESNodes.length( index+1 );
1355 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1356 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1358 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1359 if ( aNode->IsComputingNode() ) {
1360 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1362 else if ( aNode->IsFactoryNode() ) {
1363 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1365 else if ( aNode->IsInLineNode() ) {
1366 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1369 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1371 else if ( aNode->IsGOTONode() ) {
1373 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1375 else if ( aNode->IsMacroNode() ) {
1376 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1378 else if ( aNode->IsLoopNode() ) {
1379 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1381 else if ( aNode->IsEndLoopNode() ) {
1382 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1384 else if ( aNode->IsSwitchNode() ) {
1385 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1387 else if ( aNode->IsEndSwitchNode() ) {
1388 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1390 return ( RetVal._retn() ) ;
1393 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1394 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1395 beginService( "Graph_Impl::Nodes" );
1396 RetVal->CNodes.length(0) ;
1397 RetVal->FNodes.length(0) ;
1398 RetVal->INodes.length(0) ;
1399 RetVal->LNodes.length(0) ;
1400 RetVal->SNodes.length(0) ;
1401 RetVal->GNodes.length(0) ;
1402 RetVal->Graphs.length(0) ;
1405 MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1406 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
1407 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1408 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1410 MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
1411 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
1413 RetVal = SetNode( RetVal , aNode ) ;
1416 char * aStateG = "" ;
1417 if ( DataFlowExecutor() ) {
1418 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1420 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1421 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1422 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1424 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1425 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1426 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1428 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1429 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1430 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1432 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1433 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1434 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1436 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1437 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1438 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1440 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1441 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1442 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1444 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1445 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1446 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1448 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1449 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1450 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1452 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1453 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1454 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1456 if ( DataFlowExecutor() ) {
1457 DataFlowExecutor()->EventList() ;
1461 endService( "Graph_Impl::Nodes" );
1462 return ( RetVal._retn() ) ;
1465 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1466 return Links( NULL , NULL ) ;
1469 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1470 const char * anInputParam ) {
1472 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1473 RetVal->length( 0 ) ;
1475 int i , j , countlink ;
1477 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1478 GraphEditor::InNode * aNode = NULL ;
1479 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1480 bool ToProcess = false ;
1481 if ( theNode == NULL ) {
1485 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1486 if ( !theNode->IsEndSwitchNode() ) {
1490 else if ( theNode->IsEndSwitchNode() ) {
1495 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1496 GraphBase::InPort * anInPort = NULL ;
1497 anInPort = aNode->GetChangeNodeInPort( j ) ;
1498 if ( anInputParam == NULL ||
1499 !strcmp( anInPort->PortName() , anInputParam ) ) {
1500 GraphBase::OutPort * anOutPort = NULL ;
1501 anOutPort = anInPort->GetOutPort() ;
1502 if ( anOutPort && !anOutPort->IsDataStream() ) {
1503 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1504 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1505 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1506 // << anInPort->PortName() << ")" ) ;
1507 if ( theNode == NULL ||
1509 //JR 14.02.2005 : Debug : we must see also that links !
1510 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1511 !strcmp( theNode->Name() , aNode->Name() ) ) {
1512 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1513 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1514 anOutPort->NodeName() ) ) ) {
1515 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1516 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1517 // << anInPort->PortName() << ")" << " ignored" ) ;
1519 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1521 beginService( "Graph_Impl::Links" );
1524 GraphEditor::InNode * anOutNode = NULL ;
1525 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1528 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1529 instanceName() , interfaceName() ,
1532 anInPort->PortName() ,
1534 anOutPort->PortName() ,
1535 false , true , Success ) ;
1537 PortableServer::ObjectId * id = myLink->getId() ;
1538 CORBA::Object_var obj = _poa->id_to_reference(*id);
1539 SUPERV::Link_var iobject ;
1540 iobject = SUPERV::Link::_narrow(obj) ;
1541 RetVal->length( countlink + 1 ) ;
1542 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1543 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1548 RetVal->length( countlink + 1 ) ;
1549 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1551 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1552 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1553 // << anInPort->PortName() << ")" << " selected" ) ;
1556 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1557 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1558 // << anInPort->PortName() << ")" << " skipped" ) ;
1565 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1566 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1567 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1568 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1570 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1571 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1572 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1573 // << " " << anInPort->PortStatus() ) ;
1574 if ( anInPort->IsPortConnected() ) {
1575 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1576 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1577 if ( theNode == NULL ||
1578 !strcmp( theNode->Name() , aNode->Name() ) ) {
1579 if ( !anInPort->IsDataStream() ) {
1581 //JR 14.02.2005 : Debug : we must see also that links !
1582 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1583 if ( anInputParam == NULL ||
1584 !strcmp( anInPort->PortName() , anInputParam ) ) {
1585 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1586 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1587 anOutPort->NodeName() ) ) ) {
1588 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1589 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1590 // << anInPort->PortName() << ")" << " ignored" ) ;
1592 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1594 beginService( "Graph_Impl::Links" );
1598 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1599 instanceName() , interfaceName() ,
1602 anInPort->PortName() ,
1604 anOutPort->PortName() ,
1605 false , true , Success ) ;
1607 PortableServer::ObjectId * id = myLink->getId() ;
1608 CORBA::Object_var obj = _poa->id_to_reference(*id);
1609 SUPERV::Link_var iobject ;
1610 iobject = SUPERV::Link::_narrow(obj) ;
1611 RetVal->length( countlink + 1 ) ;
1612 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1613 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1617 RetVal->length( countlink + 1 ) ;
1618 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1620 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1621 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1622 // << anInPort->PortName() << ")" << " selected" ) ;
1625 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1626 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1627 // << anInPort->PortName() << ")" << " skipped" ) ;
1638 const char * NodeName = "" ;
1639 const char * InputParamName = "" ;
1641 NodeName = theNode->Name() ;
1643 if ( anInputParam ) {
1644 InputParamName = anInputParam ;
1646 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1647 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1648 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1649 << RetVal[i]->OutPort()->Name() << ") --> "
1650 << RetVal[i]->InPort()->Node()->Name() << "("
1651 << RetVal[i]->InPort()->Name() << ")" ) ;
1655 endService( "Graph_Impl::Links" );
1658 return ( RetVal._retn() ) ;
1661 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1662 const char * aComponentName ) {
1663 Engines::Component_var objComponent = Engines::Component::_nil() ;
1665 Engines::Container_var myContainer ;
1666 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1667 myContainer , objComponent ) ;
1669 return Engines::Component::_duplicate( objComponent ) ;
1672 char * Graph_Impl::Messages() {
1673 beginService( "Graph_Impl::Messages" );
1675 MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
1676 Messages = DataFlowEditor()->Graph()->Messages() ;
1677 DataFlowEditor()->Graph()->ReSetMessages() ;
1678 if ( DataFlowExecutor() ) {
1679 Messages += DataFlowExecutor()->Graph()->Messages() ;
1680 DataFlowExecutor()->Graph()->ReSetMessages() ;
1682 endService( "Graph_Impl::Messages" );
1683 return ( CORBA::string_dup( Messages.c_str() ) ) ;
1686 bool Graph_Impl::IsValid() {
1687 // beginService( "Graph_Impl::IsValid" );
1688 bool RetVal = false ;
1690 RetVal = DataFlowEditor()->IsValid() ;
1692 // endService( "Graph_Impl::IsValid" );
1695 bool Graph_Impl::IsExecutable() {
1696 // beginService( "Graph_Impl::IsExecutable" );
1697 bool RetVal = false ;
1699 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1700 // subgraphs are not executable by themselves, RetVal = false..
1701 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1702 RetVal = DataFlowEditor()->IsExecutable() ;
1704 // endService( "Graph_Impl::IsExecutable" );
1708 bool Graph_Impl::IsEditing() {
1710 bool RetVal = false ;
1712 RetVal = DataFlowEditor()->IsEditing() ;
1718 return !IsExecuting();
1721 bool Graph_Impl::IsExecuting() {
1723 bool RetVal = false ;
1725 RetVal = !DataFlowEditor()->IsEditing() ;
1729 return CNode_Impl::IsExecuting();
1732 bool Graph_Impl::IsReadOnly() {
1733 // beginService( "Graph_Impl::IsExecuting" );
1734 bool RetVal = false ;
1736 RetVal = DataFlowEditor()->IsReadOnly() ;
1738 // endService( "Graph_Impl::IsExecuting" );
1742 long Graph_Impl::LevelMax() {
1743 // beginService( "Graph_Impl::LevelMax" );
1746 RetVal = DataFlowEditor()->LevelMax() ;
1748 // endService( "Graph_Impl::LevelMax" );
1751 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
1752 // beginService( "Graph_Impl::LevelNodes" );
1753 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1756 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1757 // RetVal->length( Nodes->length() );
1758 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1759 // char * aNode = Nodes[ i ] ;
1760 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1761 RetVal = SetNode( RetVal , aNode ) ;
1762 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1763 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1764 // instanceName() , interfaceName() ,
1765 // DataFlowEditor() ,
1766 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1767 // PortableServer::ObjectId * id = myNode->getId() ;
1768 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1769 // SUPERV::CNode_var iobject ;
1770 // iobject = SUPERV::CNode::_narrow(obj) ;
1771 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1774 // endService( "Graph_Impl::LevelNodes" );
1775 return ( RetVal._retn() ) ;
1777 long Graph_Impl::ThreadsMax() {
1778 // beginService( "Graph_Impl::ThreadsMax" );
1781 RetVal = DataFlowEditor()->ThreadsMax() ;
1783 // endService( "Graph_Impl::ThreadsMax" );
1786 long Graph_Impl::Threads() {
1787 // beginService( "Node_Impl::Threads" );
1788 long RetVal = false ;
1790 RetVal = DataFlowExecutor()->Threads() ;
1792 // endService( "Node_Impl::Threads" );
1795 long Graph_Impl::SuspendedThreads() {
1796 // beginService( "Node_Impl::SuspendedThreads" );
1797 long RetVal = false ;
1799 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1801 // endService( "Node_Impl::SuspendedThreads" );
1805 bool Graph_Impl::Begin() {
1806 bool RetVal = false ;
1807 if ( DataFlowEditor()->IsEditing() ) {
1808 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1809 perror("pthread_mutex_lock _MutexExecutorWait") ;
1812 DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
1813 if ( DataFlowExecutor() ) {
1814 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1815 Editing(); // just in case it was not called before by GUI..
1817 if ( DataFlowEditor()->IsExecutable() ) {
1818 DataFlowEditor()->EditedAfterExecution( false ) ;
1819 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1821 GraphExecutor::DataFlow * aDataFlowExecutor ;
1823 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1824 dbgfile , &aDataFlowExecutor ) ;
1826 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1827 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1831 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1834 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1835 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1843 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1844 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1845 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1846 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1847 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1849 bool Graph_Impl::run( const bool andSuspend ) {
1850 bool RetVal = false ;
1852 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1853 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1855 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1856 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1857 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1861 // Create Executor instance and its datamodel
1865 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1866 DataFlowEditor()->Executing() ;
1867 DataFlowEditor()->EditedAfterExecution( false );
1869 // THE MAIN RUN METHOD
1870 RetVal = DataFlowExecutor()->Run( andSuspend );
1878 * Run() - called on "Execute" command
1880 bool Graph_Impl::Run() {
1881 beginService( "Graph_Impl::Run" );
1882 bool RetVal = run( /*andSuspend=*/false ) ;
1883 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1884 endService( "Graph_Impl::Run" );
1889 * Run() - called on "Execute step-by-step" command
1891 bool Graph_Impl::Start() {
1892 beginService( "Graph_Impl::Start" );
1893 bool RetVal = run( /*andSuspend=*/true ) ;
1894 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1895 endService( "Graph_Impl::Start" );
1899 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1900 SUPERV::GraphEvent & anEvent ,
1901 SUPERV::GraphState & aState ) {
1902 bool RetVal = false ;
1903 char * aNodeName = NULL ;
1904 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1905 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1906 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1907 perror("pthread_mutex_lock _MutexExecutorWait") ;
1910 if ( DataFlowExecutor() && !IsMacro() &&
1911 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1912 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1913 // endService( "Graph_Impl::Event" );
1914 if ( strlen( aNodeName ) ) {
1915 if ( strcmp( aNodeName , Name() ) ) {
1916 aNode = Node( aNodeName ) ;
1923 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1925 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1928 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1930 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1931 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1934 anEvent = theEvent ;
1939 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1940 SUPERV::GraphEvent & anEvent ,
1941 SUPERV::GraphState & aState ) {
1942 // beginService( "Graph_Impl::Event" );
1943 bool RetVal = false ;
1944 char * aNodeName = NULL ;
1945 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1946 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1947 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1948 perror("pthread_mutex_lock _MutexExecutorWait") ;
1951 if ( DataFlowExecutor() && !IsMacro() &&
1952 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1953 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1954 // endService( "Graph_Impl::Event" );
1955 if ( strlen( aNodeName ) ) {
1956 if ( strcmp( aNodeName , Name() ) ) {
1957 aNode = Node( aNodeName ) ;
1964 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1966 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1969 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1971 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1972 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1975 anEvent = theEvent ;
1981 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1982 SUPERV::GraphEvent & anEvent ,
1983 SUPERV::GraphState & aState ) {
1984 // beginService( "Graph_Impl::EventW" );
1985 bool RetVal = false ;
1986 char * aNodeName = NULL ;
1987 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1988 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1989 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1990 perror("pthread_mutex_lock _MutexExecutorWait") ;
1993 if ( DataFlowExecutor() && !IsMacro() &&
1994 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1995 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
1996 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1997 aNode = Node( aNodeName ) ;
2003 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2004 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2007 anEvent = theEvent ;
2009 // endService( "Graph_Impl::EventW" );
2013 long Graph_Impl::EventQSize() {
2014 // beginService( "Graph_Impl::EventQSize" );
2016 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2017 perror("pthread_mutex_lock _MutexExecutorWait") ;
2020 if ( DataFlowExecutor() && !IsMacro() ) {
2021 QSize = DataFlowExecutor()->EventQSize() ;
2023 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2024 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2027 // endService( "Graph_Impl::EventQSize" );
2031 long Graph_Impl::LastLevelDone() {
2032 // beginService( "Graph_Impl::LastLevelDone" );
2033 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2034 perror("pthread_mutex_lock _MutexExecutorWait") ;
2038 if ( DataFlowExecutor() && !IsMacro() ) {
2039 RetVal = DataFlowExecutor()->LastLevelDone() ;
2041 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2042 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2045 // endService( "Graph_Impl::LastLevelDone" );
2049 long Graph_Impl::SubGraphsNumber() {
2050 // beginService( "Graph_Impl::SubGraphsNumber" );
2052 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2053 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2055 // endService( "Graph_Impl::SubGraphsNumber" );
2059 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
2060 beginService( "Graph_Impl::SubGraphsNodes" );
2061 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2062 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2063 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2066 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2067 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2068 if ( aNode->SubGraph() == aSubGraphNumber ) {
2069 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2073 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2074 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2075 if ( aNode->SubGraph() == aSubGraphNumber ) {
2076 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2080 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2081 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2082 if ( aNode->SubGraph() == aSubGraphNumber ) {
2083 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2087 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2088 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2089 if ( aNode->SubGraph() == aSubGraphNumber ) {
2090 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2094 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2095 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2096 if ( aNode->SubGraph() == aSubGraphNumber ) {
2097 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2101 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2102 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2103 if ( aNode->SubGraph() == aSubGraphNumber ) {
2104 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2108 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2109 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2110 if ( aNode->SubGraph() == aSubGraphNumber ) {
2111 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2115 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2116 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2117 if ( aNode->SubGraph() == aSubGraphNumber ) {
2118 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2122 endService( "Graph_Impl::SubGraphsNodes" );
2123 return ( RetVal._retn() ) ;
2126 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2127 // beginService( "Graph_Impl::Merge" );
2128 bool RetVal = true ;
2130 map< string , int > aMapOfNodes ;
2131 RetVal = Merge( aGraph , aMapOfNodes ) ;
2133 // endService( "Graph_Impl::Merge" );
2137 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2138 beginService( "Graph_Impl::Merge" );
2139 bool RetVal = true ;
2140 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2141 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2143 SUPERV::Port_ptr aPort ;
2144 // SUPERV::StreamPort_ptr aStreamPort ;
2146 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2147 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2148 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2149 if ( !CORBA::is_nil( myNode ) ) {
2150 myNode->SetName( aNode->Name() ) ;
2151 myNode->SetAuthor( aNode->Author() ) ;
2152 myNode->SetComment( aNode->Comment() ) ;
2153 myNode->Coords( aNode->X() , aNode->Y() ) ;
2154 string * aNodetheName = new string( aNode->Name() ) ;
2155 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2156 delete aNodetheName ;
2163 // The following informations are now in the service from SALOME_ModuleCatalog
2164 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2166 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2167 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2168 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2170 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2171 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2177 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2178 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2179 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2180 aNode->GetInterfaceName() ,
2181 *(aNode->Service()) ) ;
2182 if ( !CORBA::is_nil( myNode ) ) {
2183 myNode->SetName( aNode->Name() ) ;
2184 myNode->SetAuthor( aNode->Author() ) ;
2185 myNode->SetComment( aNode->Comment() ) ;
2186 myNode->Coords( aNode->X() , aNode->Y() ) ;
2187 string * aNodetheName = new string( aNode->Name() ) ;
2188 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2189 delete aNodetheName ;
2196 // The following informations are now in the service from SALOME_ModuleCatalog
2197 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2199 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2200 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2201 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2203 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2204 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2211 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2212 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2213 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2214 if ( !CORBA::is_nil( myNode ) ) {
2215 myNode->SetName( aNode->Name() ) ;
2216 myNode->SetAuthor( aNode->Author() ) ;
2217 myNode->SetComment( aNode->Comment() ) ;
2218 myNode->Coords( aNode->X() , aNode->Y() ) ;
2219 string * aNodetheName = new string( aNode->Name() ) ;
2220 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2221 delete aNodetheName ;
2222 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2224 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2225 if ( myPorts[ j ]->IsInput() ) {
2226 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2229 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2232 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2233 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2234 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2235 if ( myStreamPorts[ j ]->IsInput() ) {
2236 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2239 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2253 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2254 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2255 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2256 if ( !CORBA::is_nil( myNode ) ) {
2257 myNode->SetName( aNode->Name() ) ;
2258 myNode->SetAuthor( aNode->Author() ) ;
2259 myNode->SetComment( aNode->Comment() ) ;
2260 myNode->Coords( aNode->X() , aNode->Y() ) ;
2261 string * aNodetheName = new string( aNode->Name() ) ;
2262 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2263 delete aNodetheName ;
2264 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2266 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2267 if ( myPorts[ j ]->IsInput() ) {
2268 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2271 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2274 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2275 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2276 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2277 if ( myStreamPorts[ j ]->IsInput() ) {
2278 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2281 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2295 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2296 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2297 SUPERV::INode_ptr anEndOfLoop ;
2298 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2299 *(aNode->PyInit()) ,
2300 aNode->PyMoreName() ,
2301 *(aNode->PyMore()) ,
2302 aNode->PyNextName() ,
2303 *(aNode->PyNext()) ,
2305 if ( !CORBA::is_nil( myNode ) ) {
2306 myNode->SetName( aNode->Name() ) ;
2307 myNode->SetAuthor( aNode->Author() ) ;
2308 myNode->SetComment( aNode->Comment() ) ;
2309 myNode->Coords( aNode->X() , aNode->Y() ) ;
2310 string * aNodetheName = new string( aNode->Name() ) ;
2311 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2312 delete aNodetheName ;
2313 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2315 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2316 if ( myPorts[ j ]->IsInput() ) {
2317 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2320 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2323 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2324 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2325 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2326 if ( myStreamPorts[ j ]->IsInput() ) {
2327 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2330 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2334 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2335 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2336 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2337 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2338 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2339 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2340 aNodetheName = new string( myEndOfLoop->Name() ) ;
2341 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2342 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2343 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2344 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2345 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2346 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2349 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2353 delete aNodetheName ;
2364 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2365 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2366 SUPERV::INode_ptr anEndOfSwitch ;
2367 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2368 if ( !CORBA::is_nil( myNode ) ) {
2369 myNode->SetName( aNode->Name() ) ;
2370 myNode->SetAuthor( aNode->Author() ) ;
2371 myNode->SetComment( aNode->Comment() ) ;
2372 myNode->Coords( aNode->X() , aNode->Y() ) ;
2373 string * aNodetheName = new string( aNode->Name() ) ;
2374 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2375 delete aNodetheName ;
2376 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2378 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2379 if ( myPorts[ j ]->IsInput() ) {
2380 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2383 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2386 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2387 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2388 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2389 if ( myStreamPorts[ j ]->IsInput() ) {
2390 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2393 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2397 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2398 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2399 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2400 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2401 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2402 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2403 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2404 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2405 delete aNodetheName ;
2406 myPorts = *(myEndOfSwitch->Ports()) ;
2407 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2408 if ( myPorts[ j ]->IsInput() ) {
2409 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2412 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2415 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2416 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2417 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2418 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2419 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2422 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
2435 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2436 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2437 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2439 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2440 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2441 SUPERV::Port_var OutPort = aLink->OutPort() ;
2442 SUPERV::Port_var InPort = aLink->InPort() ;
2443 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2444 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2445 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2447 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2451 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2453 RetVal = aLink->Coords( j , X , Y ) ;
2456 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2458 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2466 delete aLinkFromNodeName ;
2467 delete aLinkToNodeName ;
2473 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2474 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2475 if ( !aPort->IsGate() ) {
2476 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2477 char * aPortName = aPort->Name() ;
2478 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2479 strcpy( aNodeName , aPortName ) ;
2480 // char * thePortName = strchr( aNodeName , '\\' ) ;
2481 char * thePortName = aNodeName ;
2482 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2483 if ( thePortName[1] == '_' ) {
2484 thePortName[ 0 ] = '\0' ;
2488 thePortName = &thePortName[2] ;
2491 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2492 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2493 // << " HasInput " << hasinput << endl ;
2495 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2497 *(aPort->ToAny()) ) ;
2499 delete [] aNodeName ;
2508 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2509 endService( "Graph_Impl::Merge" );
2513 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2514 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2515 beginService( "Graph_Impl::ToStreamGraph" );
2516 if ( IsStreamGraph() && !IsMacro() ) {
2517 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2518 // instanceName() , interfaceName() ) ;
2519 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2520 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2521 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2522 if ( CORBA::is_nil( iobject ) ) {
2523 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2527 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2529 endService( "Graph_Impl::ToStreamGraph" );
2530 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2534 * Destroy Executor and use only Editor and its data model
2536 void Graph_Impl::Editing() {
2537 if ( DataFlowEditor() && DataFlowExecutor() ) {
2538 delete DataFlowExecutor() ;
2539 DataFlowEditor()->Executor( NULL );