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 ,
405 beginService( "Graph_Impl::FNode" );
406 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
407 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
408 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
409 instanceName() , interfaceName() ,
415 SUPERV::FactoryNode ,
417 if ( myNode->DataFlowNode() ) {
418 PortableServer::ObjectId * id = myNode->getId() ;
419 CORBA::Object_var obj = _poa->id_to_reference(*id);
420 iobject = SUPERV::FNode::_narrow(obj) ;
421 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
424 DataFlowEditor()->UnValid() ;
425 endService( "Graph_Impl::FNode" );
426 return SUPERV::FNode::_duplicate( iobject ) ;
429 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
430 const SUPERV::ListOfStrings & PythonFuntion ) {
431 beginService( "Graph_Impl::INode" );
432 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
433 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
434 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
435 instanceName() , interfaceName() ,
437 FuncName , PythonFuntion ,
438 SUPERV::InLineNode ) ;
439 if ( myNode->DataFlowNode() ) {
440 PortableServer::ObjectId * id = myNode->getId() ;
441 CORBA::Object_var obj = _poa->id_to_reference(*id);
442 iobject = SUPERV::INode::_narrow(obj) ;
443 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
446 endService( "Graph_Impl::INode" );
447 return SUPERV::INode::_duplicate( iobject ) ;
451 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
452 const SUPERV::ListOfStrings & PythonFuntion ,
453 const char * anInLineNode ) {
454 beginService( "Graph_Impl::GNode" );
455 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
456 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
457 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
458 instanceName() , interfaceName() ,
460 FuncName , PythonFuntion ,
462 if ( myNode->DataFlowNode() ) {
463 PortableServer::ObjectId * id = myNode->getId() ;
464 CORBA::Object_var obj = _poa->id_to_reference(*id);
465 iobject = SUPERV::GNode::_narrow(obj) ;
466 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
467 if ( strlen( anInLineNode ) ) {
468 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
469 if ( anInLineNode ) {
470 myNode->SetCoupled( anInLineNode ) ;
471 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
476 DataFlowEditor()->UnValid() ;
477 endService( "Graph_Impl::GNode" );
478 return SUPERV::GNode::_duplicate( iobject ) ;
481 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
482 const SUPERV::ListOfStrings & InitFunction ,
483 const char * MoreName ,
484 const SUPERV::ListOfStrings & MoreFunction ,
485 const char * NextName ,
486 const SUPERV::ListOfStrings & NextFunction ,
487 SUPERV::INode_out anEndOfLoop ) {
488 beginService( "Graph_Impl::LNode" );
489 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
490 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
491 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
492 GraphBase::ListOfFuncName FuncNameList ;
493 FuncNameList.resize(3) ;
494 FuncNameList[0] = InitName ;
495 FuncNameList[1] = MoreName ;
496 FuncNameList[2] = NextName ;
497 GraphBase::ListOfPythonFunctions PythonFunctionList ;
498 PythonFunctionList.resize(3) ;
499 PythonFunctionList[0] = &InitFunction ;
500 PythonFunctionList[1] = &MoreFunction ;
501 PythonFunctionList[2] = &NextFunction ;
502 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
503 instanceName() , interfaceName() ,
505 FuncNameList , PythonFunctionList ,
506 // InitName , InitFunction ,
507 // MoreName , MoreFunction ,
508 // NextName , NextFunction ,
510 if ( myNode->DataFlowNode() ) {
511 PortableServer::ObjectId * id = myNode->getId() ;
512 CORBA::Object_var obj = _poa->id_to_reference(*id);
513 iobject = SUPERV::LNode::_narrow(obj) ;
514 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
516 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
518 if ( strlen( InitName ) ) {
519 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
520 strcpy( anEndName , "End" ) ;
521 strcat( anEndName , InitName ) ;
524 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
525 strcpy( anEndName , "EndLoop" ) ;
527 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
528 instanceName() , interfaceName() ,
531 SUPERV::EndLoopNode ) ;
532 PortableServer::ObjectId * endid = myEndNode->getId() ;
533 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
534 iendobject = SUPERV::ELNode::_narrow(endobj) ;
535 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
536 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
537 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
538 //JR 25.01.2005 That links are already done in SetCoupled above ...
539 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
540 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
541 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
544 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
545 DataFlowEditor()->UnValid() ;
546 endService( "Graph_Impl::LNode" );
547 return SUPERV::LNode::_duplicate( iobject ) ;
550 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
551 const SUPERV::ListOfStrings & PythonFunction ,
552 SUPERV::INode_out anEndOfSwitch ) {
553 beginService( "Graph_Impl::SNode" );
554 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
555 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
556 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
557 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
558 instanceName() , interfaceName() ,
560 FuncName , PythonFunction ,
561 SUPERV::SwitchNode ) ;
562 if ( myNode->DataFlowNode() ) {
563 PortableServer::ObjectId * id = myNode->getId() ;
564 CORBA::Object_var obj = _poa->id_to_reference(*id);
565 iobject = SUPERV::SNode::_narrow(obj) ;
566 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
568 string anEndName = "End" ;
569 if ( strlen( FuncName ) ) {
570 anEndName += FuncName ;
573 anEndName += "Switch" ;
575 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
576 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
577 // << anEndName.c_str() << endl ;
578 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
579 instanceName() , interfaceName() ,
582 SUPERV::EndSwitchNode ) ;
583 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
584 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
585 // << " " << anEndName.c_str() << endl ;
586 PortableServer::ObjectId * endid = myEndNode->getId() ;
587 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
588 iendobject = SUPERV::ESNode::_narrow(endobj) ;
589 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
590 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
591 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
592 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
593 iobject = SUPERV::SNode::_nil() ;
594 iendobject = SUPERV::ESNode::_nil() ;
598 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
599 DataFlowEditor()->UnValid() ;
600 endService( "Graph_Impl::SNode" );
601 return SUPERV::SNode::_duplicate( iobject ) ;
604 // WARNING : THIS IS COMPLICATED :
605 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
606 GraphBase::ListOfSGraphs * aListOfDataFlows ,
608 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
609 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
611 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
612 // That method is recursive :
613 // At first we load the supergraph with index = 0 :
614 // (After we load the graph corresponding to each MacroNode :)
615 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
616 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
617 return SUPERV::Graph::_duplicate( iobject ) ;
619 // That graph is not a StreamGraph :
620 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
621 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
622 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
623 Graph_Impl * myGraph ;
624 // We create a Graph ObjRef for that graph
625 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
626 instanceName() , interfaceName() ,
627 aDataFlowEditor , NULL ) ;
628 PortableServer::ObjectId * id = myGraph->getId() ;
629 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
630 iobject = SUPERV::Graph::_narrow( obj ) ;
631 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
632 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
633 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
636 // asv: set Editor for the graph itself and for all its macro nodes
637 aGraph->GraphEditor( aDataFlowEditor );
639 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
640 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
641 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
642 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
644 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
645 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
646 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
647 // so here we check if the node is "new" or "old"
648 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
651 // asv: set Editor for the graph itself and for all its macro nodes
652 aMacroNode->GraphEditor( aDataFlowEditor );
654 // Creation of a GraphMacroNode ObjRef in the current editor
655 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
656 Graph_Impl * myMacroNode ;
657 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
658 instanceName() , interfaceName() ,
659 aMacroNode->Name() , SUPERV::MacroNode ) ;
660 id = myMacroNode->getId() ;
661 obj = _poa->id_to_reference(*id);
662 macroiobject = SUPERV::Graph::_narrow( obj ) ;
663 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
664 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
665 myMacroNode->DataFlowNode( aDataFlowNode ) ;
666 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
667 aDataFlowNode->SetObjImpl( myMacroNode ) ;
669 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
670 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
671 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
674 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
675 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
676 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
679 // At first create the editor and a StreamGraph
680 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
681 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
682 dbgfile , &aMacroGraphDataFlowEditor ) ;
684 if ( _DebugFileName ) {
685 delete [] _DebugFileName ;
687 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
688 strcpy( _DebugFileName , dbgfile.c_str() ) ;
690 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
691 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
692 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
693 return SUPERV::Graph::_duplicate( iobject ) ;
696 // That graph is not a StreamGraph :
697 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
698 Graph_Impl * myMacroGraph ;
699 // The Graph ObjRef for that graph was already created
700 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
702 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
704 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
705 aMacroGraph->CoupledNode( aMacroNode ) ;
706 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
708 // Set the GraphMacroNode ObjRef in the MacroNode
709 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
710 aMacroNode->CoupledNode( aMacroGraph ) ;
711 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
712 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
713 << " coupled to " << aMacroGraph->CoupledNode() << " "
714 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
715 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
716 << " coupled to " << aMacroNode->CoupledNode() << " "
717 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
718 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
719 << " coupled to " << aGraph->CoupledNode()
720 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
726 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
731 else if ( (*aListOfDataFlows).size() == 1 ) {
732 StreamGraph_Impl * myStreamGraph ;
733 // We create a Graph ObjRef for that graph
734 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
735 instanceName() , interfaceName() ,
736 aDataFlowEditor , NULL ) ;
737 PortableServer::ObjectId * id = myStreamGraph->getId() ;
738 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
739 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
740 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
741 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
742 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
743 // iobject = SUPERV::Graph::_narrow( obj ) ;
744 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
747 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
750 endService( "Graph_Impl::EditorLoadDataFlows" );
751 return SUPERV::Graph::_duplicate( iobject ) ;
754 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
755 GraphBase::ListOfSGraphs * aListOfDataFlows ,
757 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
758 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
760 // That method is recursive :
761 // At first we load the supergraph with index = 0 :
762 // (After we load the graph corresponding to each MacroNode :)
763 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
764 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
765 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
768 // That graph is not a StreamGraph :
770 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
771 GraphEditor::DataFlow * aDataFlowEditor ;
772 aDataFlowEditor = DataFlowEditor() ;
773 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
774 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
775 if ( aDataFlowEditor->Executor() ) {
776 delete aDataFlowEditor->Executor() ;
777 aDataFlowEditor->Executor( NULL ) ;
778 aDataFlowEditor->Editing() ;
780 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
781 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
783 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
784 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
786 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
787 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
788 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
789 aMacroNode->GraphEditor( aDataFlowEditor ) ;
791 // get the macro node's editor object
792 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
793 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
794 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
796 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
797 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
800 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
801 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
805 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
806 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
808 index--; // it was incremented in "for ..." before last check ( !found ).
810 // At first create the editor and a StreamGraph
812 GraphExecutor::DataFlow * aMacroGraphExecutor ;
813 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
814 dbgfile , &aMacroGraphExecutor );
816 // set GraphMacroLevel for Executor's graph
817 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
818 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
820 // load data flows in MacroGraph's executor
821 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
822 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
823 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
824 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
825 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
828 // set coupled pair MacroNode <--> MacroGraph
829 aMacroGraphExe->CoupledNode( aMacroNode ) ;
830 aMacroNode->CoupledNode( aMacroGraphExe ) ;
832 //JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
833 // InPorts values of MacroGraphs of MacroNodes are done in the Executor
834 // It was probably to try to debug anything but it was a wrong debug and I do not know what bug
835 // ===> folowing code is commented
837 // initialize MacroNode's InPorts with corresponding "external" values
839 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
840 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
841 if ( anInPort->IsDataConnected() ) {
842 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
843 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
844 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
845 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
848 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
849 << aMacroGraphInPortName << " , Value )" ) ;
852 } // end of init MacroNode's InPorts
854 aMacroGraphImpl->Run() ;
857 } // end of for( get nodes of the graph...)
859 } // end of setting initial graph's structure..
861 endService( "Graph_Impl::ExecutorLoadDataFlows" );
863 PortableServer::ObjectId * id = getId();
864 CORBA::Object_var obj = _poa->id_to_reference( *id );
865 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
866 return SUPERV::Graph::_duplicate( iobject ) ;
869 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
870 beginService( "Graph_Impl::MNode" );
871 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
872 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
874 GraphBase::ListOfSGraphs aListOfDataFlows ;
876 // At first create the editor and a StreamGraph with the xml file
877 GraphEditor::DataFlow * aDataFlowEditor ;
878 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
879 dbgfile , &aDataFlowEditor ) ;
881 if ( _DebugFileName ) {
882 delete [] _DebugFileName ;
884 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
885 strcpy( _DebugFileName , dbgfile.c_str() ) ;
887 int lenname = strlen( aXmlFileName ) ;
888 bool loaded = false ;
889 // Import of the xml file
890 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
891 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
893 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
900 // WARNING : THIS IS COMPLICATED :
901 // I should have to remove duplicated code ...
902 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
903 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
904 beginService( "Graph_Impl::MNode" ) ;
905 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
906 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
909 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
910 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
911 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
912 if ( CORBA::is_nil( iobject ) ) {
913 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
917 // That graph is not a StreamGraph :
918 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
919 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
920 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
922 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
923 // Creation of a GraphMacroNode in the current editor
924 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
925 Graph_Impl * myMacroNode ;
926 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
927 instanceName() , interfaceName() ,
928 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
929 PortableServer::ObjectId * id = myMacroNode->getId() ;
930 CORBA::Object_var obj = _poa->id_to_reference(*id);
931 macroiobject = SUPERV::Graph::_narrow( obj ) ;
932 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
934 // Creation of the MacroNode itself in the current Graph
935 GraphBase::ListOfFuncName aFuncName ;
936 aFuncName.resize( 1 ) ;
938 SUPERV::ListOfStrings aListOfStrings ;
939 aListOfStrings.length( 1 ) ;
940 aListOfStrings[0] = "" ;
941 GraphBase::ListOfPythonFunctions aPythonFunction ;
942 aPythonFunction.resize( 1 ) ;
943 aPythonFunction[0] = &aListOfStrings ;
944 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
945 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
946 aMacroNodeName.c_str() , SUPERV::MacroNode ,
947 aFuncName , aPythonFunction ) ;
948 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
949 myMacroNode->DataFlowNode( aDataFlowNode ) ;
950 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
951 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
952 aDataFlowNode->SetObjImpl( this ) ;
954 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
955 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
956 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
957 aMacroGraph->Kind( SUPERV::MacroNode ) ;
958 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
959 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
960 aMacroGraph->SetMacroPorts( aGraph ) ;
961 // Valid ==> creation of Service and the ports of the current Graph
962 DataFlowEditor()->IsValid() ;
963 // Set the Input Datas from the GraphMacroNode to the current Graph
964 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
965 aMacroGraphDataFlowEditor->UnValid() ;
966 // Set the MacroNode ObjRef in the GraphMacroNode
967 aGraph->CoupledNode( aMacroGraph ) ;
968 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
969 // Set the GraphMacroNode ObjRef in the MacroNode
970 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
971 aMacroGraph->CoupledNode( aGraph ) ;
972 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
973 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
974 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
975 // aDataFlowNode->CoupledNode( aGraph ) ;
976 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
977 // Set the MacroLevel of that graph
978 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
979 aMacroGraph->Coordinates( 0 , 0 ) ;
980 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
981 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
982 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
983 << " coupled to " << aGraph->CoupledNode() << " "
984 << aGraph->CoupledNode()->Name() ) ;
985 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
986 << " coupled to " << aMacroGraph->CoupledNode() << " "
987 << aMacroGraph->CoupledNode()->Name() ) ;
988 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
989 << myMacroNode->DataFlowEditor()->Graph()->Name()
990 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
993 delete aMacroGraphDataFlowEditor ;
996 endService( "Graph_Impl::MNode" );
997 return SUPERV::Graph::_duplicate( macroiobject ) ;
1000 // For python supergraph
1001 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
1002 SUPERV::Graph_var iobject = myMacroGraph ;
1003 beginService( "Graph_Impl::GraphMNode" ) ;
1005 // GraphBase::Graph * myMacroGraph = aGraph;
1006 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
1007 // Creation of a GraphMacroNode in the current editor
1009 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
1010 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
1011 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
1012 Graph_Impl * myMacroNode ;
1013 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1014 instanceName() , interfaceName() ,
1015 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1016 PortableServer::ObjectId * id = myMacroNode->getId() ;
1017 CORBA::Object_var obj = _poa->id_to_reference(*id);
1018 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1019 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1021 // Creation of the MacroNode itself in the current Graph
1022 GraphBase::ListOfFuncName aFuncName ;
1023 aFuncName.resize( 1 ) ;
1025 SUPERV::ListOfStrings aListOfStrings ;
1026 aListOfStrings.length( 1 ) ;
1027 aListOfStrings[0] = "" ;
1028 GraphBase::ListOfPythonFunctions aPythonFunction ;
1029 aPythonFunction.resize( 1 ) ;
1030 aPythonFunction[0] = &aListOfStrings ;
1031 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1032 GraphEditor::InNode * aDataFlowNode ;
1033 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1034 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1035 aFuncName , aPythonFunction ) ;
1036 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1037 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1038 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1039 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1040 aDataFlowNode->SetObjImpl( this ) ;
1042 GraphBase::Graph * aSubGraph = NULL ;
1043 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1044 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1045 //JR 20.09.2005 Debug SAB_data_1609_bugPAL.py from CEA (Anthony)
1046 // Graph_Impl * aSubGraphImpl = dynamic_cast<Graph_Impl * >( _Poa->id_to_servant( *myMacroGraph->_Id ) ) ;
1047 myMacroGraph->ping() ;
1048 Graph_Impl * aSubGraphImpl = theAutomaton->GraphImpl() ;
1049 aSubGraph = aSubGraphImpl->DataFlowEditor()->Graph() ;
1050 myMacroGraph->Coupled() ;
1051 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1052 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1053 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1054 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1055 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1056 aMacroGraph->SetMacroPorts( aSubGraph ) ;
1057 // Valid ==> creation of Service and the ports of the current Graph
1058 DataFlowEditor()->IsValid() ;
1059 // Set the Input Datas from the GraphMacroNode to the current Graph
1060 aMacroGraph->SetMacroDatas( aSubGraph , aGraphOfMacroGraph ) ;
1061 // aMacroGraphDataFlowEditor->UnValid() ;
1062 aSubGraph->GraphEditor()->UnValid() ;
1063 // Set the MacroNode ObjRef in the GraphMacroNode
1064 aSubGraph->CoupledNode( aMacroGraph ) ;
1065 aSubGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1066 // Set the GraphMacroNode ObjRef in the MacroNode
1067 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1068 aMacroGraph->CoupledNode( aSubGraph ) ;
1069 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1070 // aDataFlowNode->CoupledNode( aSubGraph ) ;
1071 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1072 // Set the MacroLevel of that graph
1073 aSubGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1074 aMacroGraph->Coordinates( 0 , 0 ) ;
1075 MESSAGE( aSubGraph->Name() << "->CoupledNode()->GraphEditor() : " << aSubGraph->CoupledNode()->GraphEditor() ) ;
1076 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1077 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1078 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1079 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1081 endService( "Graph_Impl::GraphMNode" ) ;
1082 return SUPERV::Graph::_duplicate( macroiobject ) ;
1085 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1086 beginService( "Graph_Impl::FlowObjRef" );
1087 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1089 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1091 else if ( IsGraph() ) {
1092 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1094 if ( CORBA::is_nil( iobject ) ) {
1095 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1097 endService( "Graph_Impl::FlowObjRef" );
1098 return SUPERV::Graph::_duplicate( iobject ) ;
1101 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1102 beginService( "Graph_Impl::StreamObjRef" );
1103 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1105 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1107 else if ( IsGraph() || IsStreamGraph() ) {
1108 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1110 if ( CORBA::is_nil( iobject ) ) {
1111 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1113 endService( "Graph_Impl::StreamObjRef" );
1114 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1117 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1118 // beginService( "Graph_Impl::Node" );
1119 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1121 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1122 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1123 instanceName() , interfaceName() ,
1125 DataFlowEditor()->GetNode( aNodeName ) ) ;
1126 PortableServer::ObjectId * id = myNode->getId() ;
1127 CORBA::Object_var obj = _poa->id_to_reference(*id);
1128 iobject = SUPERV::CNode::_narrow(obj) ;
1129 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1132 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1135 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1137 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1138 SetNodeObjRef( anInNode ) ;
1140 iobject = anInNode->ObjRef() ;
1143 // endService( "Graph_Impl::Node" );
1144 return SUPERV::CNode::_duplicate( iobject ) ;
1147 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1148 SUPERV::Port_ptr InPort ) {
1149 // beginService( "Graph_Impl::Link" );
1150 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1151 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1152 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1153 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1154 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1155 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1156 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1157 if ( anInNode == NULL || anOutNode== NULL ) {
1158 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1159 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1162 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1163 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1164 if ( anInPort == NULL || anOutPort== NULL ) {
1165 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1166 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1168 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1169 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1170 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1171 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1172 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1173 if ( DataFlowOutNode && DataFlowInNode ) {
1175 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1176 instanceName() , interfaceName() ,
1182 true , false , Success ) ;
1184 PortableServer::ObjectId * id = myLink->getId() ;
1185 CORBA::Object_var obj = _poa->id_to_reference(*id);
1186 iobject = SUPERV::Link::_narrow(obj) ;
1187 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1192 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1193 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
1194 iobject = anOutPort->InPortObjRef( anInPort ) ;
1198 DataFlowEditor()->UnValid() ;
1199 // endService( "Graph_Impl::Link" );
1200 return SUPERV::Link::_duplicate( iobject ) ;
1203 // Only to see MacroNodes with actual GUI ... :
1204 #define GOTOMacroNode 0
1206 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1207 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1208 CORBA::Object_var obj ;
1209 if ( anInNode->IsComputingNode() ) {
1210 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1211 instanceName() , interfaceName() ,
1214 PortableServer::ObjectId * id = myNode->getId() ;
1215 obj = _poa->id_to_reference(*id);
1216 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1217 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1219 else if ( anInNode->IsFactoryNode() ) {
1220 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1221 instanceName() , interfaceName() ,
1224 PortableServer::ObjectId * id = myNode->getId() ;
1225 obj = _poa->id_to_reference(*id);
1226 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1227 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1229 else if ( anInNode->IsInLineNode() ) {
1230 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1231 instanceName() , interfaceName() ,
1234 PortableServer::ObjectId * id = myNode->getId() ;
1235 obj = _poa->id_to_reference(*id);
1236 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1237 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1240 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1241 if ( anInNode->IsMacroNode() ) {
1242 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1245 else if ( anInNode->IsGOTONode() ) {
1247 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1248 instanceName() , interfaceName() ,
1251 PortableServer::ObjectId * id = myNode->getId() ;
1252 obj = _poa->id_to_reference(*id);
1253 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1254 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1256 else if ( anInNode->IsMacroNode() ) {
1257 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1258 instanceName() , interfaceName() ,
1261 PortableServer::ObjectId * id = myNode->getId() ;
1262 obj = _poa->id_to_reference(*id);
1263 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1264 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1266 else if ( anInNode->IsLoopNode() ) {
1267 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1268 instanceName() , interfaceName() ,
1271 PortableServer::ObjectId * id = myNode->getId() ;
1272 obj = _poa->id_to_reference(*id);
1273 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1274 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1276 else if ( anInNode->IsEndLoopNode() ) {
1277 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1278 instanceName() , interfaceName() ,
1281 PortableServer::ObjectId * id = myNode->getId() ;
1282 obj = _poa->id_to_reference(*id);
1283 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1284 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1286 else if ( anInNode->IsSwitchNode() ) {
1287 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1288 instanceName() , interfaceName() ,
1291 PortableServer::ObjectId * id = myNode->getId() ;
1292 obj = _poa->id_to_reference(*id);
1293 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1294 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1296 else if ( anInNode->IsEndSwitchNode() ) {
1297 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1298 instanceName() , interfaceName() ,
1301 PortableServer::ObjectId * id = myNode->getId() ;
1302 obj = _poa->id_to_reference(*id);
1303 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1304 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1308 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1309 GraphBase::ComputingNode * aNode ) {
1311 // if ( _DataFlowExecutor ) {
1312 if ( DataFlowExecutor() ) {
1313 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1314 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1317 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1319 if ( aNode->IsComputingNode() ) {
1320 index = RetVal->CNodes.length() ;
1321 RetVal->CNodes.length( index+1 );
1323 else if ( aNode->IsFactoryNode() ) {
1324 index = RetVal->FNodes.length() ;
1325 RetVal->FNodes.length( index+1 );
1327 else if ( aNode->IsInLineNode() ) {
1328 index = RetVal->INodes.length() ;
1329 RetVal->INodes.length( index+1 );
1332 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1334 else if ( aNode->IsGOTONode() ) {
1336 index = RetVal->GNodes.length() ;
1337 RetVal->GNodes.length( index+1 );
1339 else if ( aNode->IsMacroNode() ) {
1340 index = RetVal->Graphs.length() ;
1341 RetVal->Graphs.length( index+1 );
1343 else if ( aNode->IsLoopNode() ) {
1344 index = RetVal->LNodes.length() ;
1345 RetVal->LNodes.length( index+1 );
1347 else if ( aNode->IsEndLoopNode() ) {
1348 index = RetVal->ELNodes.length() ;
1349 RetVal->ELNodes.length( index+1 );
1351 else if ( aNode->IsSwitchNode() ) {
1352 index = RetVal->SNodes.length() ;
1353 RetVal->SNodes.length( index+1 );
1355 else if ( aNode->IsEndSwitchNode() ) {
1356 index = RetVal->ESNodes.length() ;
1357 RetVal->ESNodes.length( index+1 );
1359 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1360 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1362 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1363 if ( aNode->IsComputingNode() ) {
1364 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1366 else if ( aNode->IsFactoryNode() ) {
1367 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1369 else if ( aNode->IsInLineNode() ) {
1370 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1373 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1375 else if ( aNode->IsGOTONode() ) {
1377 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1379 else if ( aNode->IsMacroNode() ) {
1380 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1382 else if ( aNode->IsLoopNode() ) {
1383 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1385 else if ( aNode->IsEndLoopNode() ) {
1386 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1388 else if ( aNode->IsSwitchNode() ) {
1389 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1391 else if ( aNode->IsEndSwitchNode() ) {
1392 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1394 return ( RetVal._retn() ) ;
1397 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1398 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1399 beginService( "Graph_Impl::Nodes" );
1400 RetVal->CNodes.length(0) ;
1401 RetVal->FNodes.length(0) ;
1402 RetVal->INodes.length(0) ;
1403 RetVal->LNodes.length(0) ;
1404 RetVal->SNodes.length(0) ;
1405 RetVal->GNodes.length(0) ;
1406 RetVal->Graphs.length(0) ;
1409 MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1410 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
1411 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1412 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1414 MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
1415 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
1417 RetVal = SetNode( RetVal , aNode ) ;
1420 char * aStateG = "" ;
1421 if ( DataFlowExecutor() ) {
1422 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1424 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1425 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1426 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1428 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1429 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1430 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1432 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1433 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1434 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1436 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1437 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1438 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1440 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1441 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1442 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1444 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1445 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1446 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1448 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1449 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1450 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1452 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1453 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1454 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1456 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1457 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1458 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1460 if ( DataFlowExecutor() ) {
1461 DataFlowExecutor()->EventList() ;
1465 endService( "Graph_Impl::Nodes" );
1466 return ( RetVal._retn() ) ;
1469 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1470 return Links( NULL , NULL ) ;
1473 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1474 const char * anInputParam ) {
1476 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1477 RetVal->length( 0 ) ;
1479 int i , j , countlink ;
1481 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1482 GraphEditor::InNode * aNode = NULL ;
1483 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1484 bool ToProcess = false ;
1485 if ( theNode == NULL ) {
1489 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1490 if ( !theNode->IsEndSwitchNode() ) {
1494 else if ( theNode->IsEndSwitchNode() ) {
1499 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1500 GraphBase::InPort * anInPort = NULL ;
1501 anInPort = aNode->GetChangeNodeInPort( j ) ;
1502 if ( anInputParam == NULL ||
1503 !strcmp( anInPort->PortName() , anInputParam ) ) {
1504 GraphBase::OutPort * anOutPort = NULL ;
1505 anOutPort = anInPort->GetOutPort() ;
1506 if ( anOutPort && !anOutPort->IsDataStream() ) {
1507 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1508 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1509 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1510 // << anInPort->PortName() << ")" ) ;
1511 if ( theNode == NULL ||
1513 //JR 14.02.2005 : Debug : we must see also that links !
1514 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1515 !strcmp( theNode->Name() , aNode->Name() ) ) {
1516 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1517 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1518 anOutPort->NodeName() ) ) ) {
1519 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1520 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1521 // << anInPort->PortName() << ")" << " ignored" ) ;
1523 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1525 beginService( "Graph_Impl::Links" );
1528 GraphEditor::InNode * anOutNode = NULL ;
1529 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1532 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1533 instanceName() , interfaceName() ,
1536 anInPort->PortName() ,
1538 anOutPort->PortName() ,
1539 false , true , Success ) ;
1541 PortableServer::ObjectId * id = myLink->getId() ;
1542 CORBA::Object_var obj = _poa->id_to_reference(*id);
1543 SUPERV::Link_var iobject ;
1544 iobject = SUPERV::Link::_narrow(obj) ;
1545 RetVal->length( countlink + 1 ) ;
1546 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1547 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1552 RetVal->length( countlink + 1 ) ;
1553 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1555 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1556 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1557 // << anInPort->PortName() << ")" << " selected" ) ;
1560 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1561 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1562 // << anInPort->PortName() << ")" << " skipped" ) ;
1569 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1570 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1571 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1572 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1574 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1575 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1576 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1577 // << " " << anInPort->PortStatus() ) ;
1578 if ( anInPort->IsPortConnected() ) {
1579 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1580 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1581 if ( theNode == NULL ||
1582 !strcmp( theNode->Name() , aNode->Name() ) ) {
1583 if ( !anInPort->IsDataStream() ) {
1585 //JR 14.02.2005 : Debug : we must see also that links !
1586 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1587 if ( anInputParam == NULL ||
1588 !strcmp( anInPort->PortName() , anInputParam ) ) {
1589 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1590 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1591 anOutPort->NodeName() ) ) ) {
1592 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1593 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1594 // << anInPort->PortName() << ")" << " ignored" ) ;
1596 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1598 beginService( "Graph_Impl::Links" );
1602 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1603 instanceName() , interfaceName() ,
1606 anInPort->PortName() ,
1608 anOutPort->PortName() ,
1609 false , true , Success ) ;
1611 PortableServer::ObjectId * id = myLink->getId() ;
1612 CORBA::Object_var obj = _poa->id_to_reference(*id);
1613 SUPERV::Link_var iobject ;
1614 iobject = SUPERV::Link::_narrow(obj) ;
1615 RetVal->length( countlink + 1 ) ;
1616 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1617 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1621 RetVal->length( countlink + 1 ) ;
1622 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1624 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1625 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1626 // << anInPort->PortName() << ")" << " selected" ) ;
1629 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1630 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1631 // << anInPort->PortName() << ")" << " skipped" ) ;
1642 const char * NodeName = "" ;
1643 const char * InputParamName = "" ;
1645 NodeName = theNode->Name() ;
1647 if ( anInputParam ) {
1648 InputParamName = anInputParam ;
1650 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1651 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1652 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1653 << RetVal[i]->OutPort()->Name() << ") --> "
1654 << RetVal[i]->InPort()->Node()->Name() << "("
1655 << RetVal[i]->InPort()->Name() << ")" ) ;
1659 endService( "Graph_Impl::Links" );
1662 return ( RetVal._retn() ) ;
1665 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1666 const char * aComponentName ) {
1667 Engines::Component_var objComponent = Engines::Component::_nil() ;
1669 Engines::Container_var myContainer ;
1670 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1671 myContainer , objComponent ) ;
1673 return Engines::Component::_duplicate( objComponent ) ;
1676 char * Graph_Impl::Messages() {
1677 beginService( "Graph_Impl::Messages" );
1679 MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
1680 Messages = DataFlowEditor()->Graph()->Messages() ;
1681 DataFlowEditor()->Graph()->ReSetMessages() ;
1682 if ( DataFlowExecutor() ) {
1683 Messages += DataFlowExecutor()->Graph()->Messages() ;
1684 DataFlowExecutor()->Graph()->ReSetMessages() ;
1686 endService( "Graph_Impl::Messages" );
1687 return ( CORBA::string_dup( Messages.c_str() ) ) ;
1690 bool Graph_Impl::IsValid() {
1691 // beginService( "Graph_Impl::IsValid" );
1692 bool RetVal = false ;
1694 RetVal = DataFlowEditor()->IsValid() ;
1696 // endService( "Graph_Impl::IsValid" );
1699 bool Graph_Impl::IsExecutable() {
1700 // beginService( "Graph_Impl::IsExecutable" );
1701 bool RetVal = false ;
1703 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1704 // subgraphs are not executable by themselves, RetVal = false..
1705 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1706 RetVal = DataFlowEditor()->IsExecutable() ;
1708 // endService( "Graph_Impl::IsExecutable" );
1712 bool Graph_Impl::IsEditing() {
1714 bool RetVal = false ;
1716 RetVal = DataFlowEditor()->IsEditing() ;
1722 return !IsExecuting();
1725 bool Graph_Impl::IsExecuting() {
1727 bool RetVal = false ;
1729 RetVal = !DataFlowEditor()->IsEditing() ;
1733 return CNode_Impl::IsExecuting();
1736 bool Graph_Impl::IsReadOnly() {
1737 // beginService( "Graph_Impl::IsExecuting" );
1738 bool RetVal = false ;
1740 RetVal = DataFlowEditor()->IsReadOnly() ;
1742 // endService( "Graph_Impl::IsExecuting" );
1746 CORBA::Long Graph_Impl::LevelMax() {
1747 // beginService( "Graph_Impl::LevelMax" );
1748 CORBA::Long RetVal = 0 ;
1750 RetVal = DataFlowEditor()->LevelMax() ;
1752 // endService( "Graph_Impl::LevelMax" );
1755 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(CORBA::Long aLevel ) {
1756 // beginService( "Graph_Impl::LevelNodes" );
1757 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1760 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1761 // RetVal->length( Nodes->length() );
1762 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1763 // char * aNode = Nodes[ i ] ;
1764 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1765 RetVal = SetNode( RetVal , aNode ) ;
1766 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1767 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1768 // instanceName() , interfaceName() ,
1769 // DataFlowEditor() ,
1770 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1771 // PortableServer::ObjectId * id = myNode->getId() ;
1772 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1773 // SUPERV::CNode_var iobject ;
1774 // iobject = SUPERV::CNode::_narrow(obj) ;
1775 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1778 // endService( "Graph_Impl::LevelNodes" );
1779 return ( RetVal._retn() ) ;
1781 CORBA::Long Graph_Impl::ThreadsMax() {
1782 // beginService( "Graph_Impl::ThreadsMax" );
1783 CORBA::Long RetVal = 0 ;
1785 RetVal = DataFlowEditor()->ThreadsMax() ;
1787 // endService( "Graph_Impl::ThreadsMax" );
1790 CORBA::Long Graph_Impl::Threads() {
1791 // beginService( "Node_Impl::Threads" );
1792 CORBA::Long RetVal = false ;
1794 RetVal = DataFlowExecutor()->Threads() ;
1796 // endService( "Node_Impl::Threads" );
1799 CORBA::Long Graph_Impl::SuspendedThreads() {
1800 // beginService( "Node_Impl::SuspendedThreads" );
1801 CORBA::Long RetVal = false ;
1803 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1805 // endService( "Node_Impl::SuspendedThreads" );
1809 bool Graph_Impl::Begin() {
1810 bool RetVal = false ;
1811 // mkr : IPAL11408 : "Run()" method returns "0" after trying to start graph execution.
1812 // If we call Run() method from Python script two times for one graph, we have to be sure,
1813 // that first execution of this graph ended (i.e. GraphEditor::DataFlow::Editing() method was called).
1814 // Otherwise, the second call of Run() method will return 0. Therefore, we have to waiting for
1815 // the first execution finish.
1816 // NB! From GUI we cann't run dataflow if its previous execution not finished.
1817 while ( !DataFlowEditor()->IsEditing() ) {} // waiting for the previous execution of this graph ended
1818 if ( DataFlowEditor()->IsEditing() ) {
1819 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1820 perror("pthread_mutex_lock _MutexExecutorWait") ;
1823 DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
1824 if ( DataFlowExecutor() ) {
1825 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1826 Editing(); // just in case it was not called before by GUI..
1828 if ( DataFlowEditor()->IsExecutable() ) {
1829 DataFlowEditor()->EditedAfterExecution( false ) ;
1830 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1832 GraphExecutor::DataFlow * aDataFlowExecutor ;
1834 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1835 dbgfile , &aDataFlowExecutor ) ;
1837 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1838 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1842 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1845 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1846 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1854 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1855 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1856 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1857 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1858 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1860 bool Graph_Impl::run( const bool andSuspend ) {
1861 bool RetVal = false ;
1863 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1864 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1866 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1867 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1868 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1872 // Create Executor instance and its datamodel
1876 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1877 DataFlowEditor()->Executing() ;
1878 DataFlowEditor()->EditedAfterExecution( false );
1880 // THE MAIN RUN METHOD
1881 RetVal = DataFlowExecutor()->Run( andSuspend );
1889 * Run() - called on "Execute" command
1891 bool Graph_Impl::Run() {
1892 beginService( "Graph_Impl::Run" );
1893 bool RetVal = run( /*andSuspend=*/false ) ;
1894 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1895 endService( "Graph_Impl::Run" );
1900 * Run() - called on "Execute step-by-step" command
1902 bool Graph_Impl::Start() {
1903 beginService( "Graph_Impl::Start" );
1904 bool RetVal = run( /*andSuspend=*/true ) ;
1905 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1906 endService( "Graph_Impl::Start" );
1910 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1911 SUPERV::GraphEvent & anEvent ,
1912 SUPERV::GraphState & aState ) {
1913 bool RetVal = false ;
1914 char * aNodeName = NULL ;
1915 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1916 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1917 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1918 perror("pthread_mutex_lock _MutexExecutorWait") ;
1921 if ( DataFlowExecutor() && !IsMacro() &&
1922 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1923 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1924 // endService( "Graph_Impl::Event" );
1925 if ( strlen( aNodeName ) ) {
1926 if ( strcmp( aNodeName , Name() ) ) {
1927 aNode = Node( aNodeName ) ;
1934 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1936 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1939 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1941 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1942 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1945 anEvent = theEvent ;
1950 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1951 SUPERV::GraphEvent & anEvent ,
1952 SUPERV::GraphState & aState ) {
1953 // beginService( "Graph_Impl::Event" );
1954 bool RetVal = false ;
1955 char * aNodeName = NULL ;
1956 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1957 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1958 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1959 perror("pthread_mutex_lock _MutexExecutorWait") ;
1962 if ( DataFlowExecutor() && !IsMacro() &&
1963 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1964 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1965 // endService( "Graph_Impl::Event" );
1966 if ( strlen( aNodeName ) ) {
1967 if ( strcmp( aNodeName , Name() ) ) {
1968 aNode = Node( aNodeName ) ;
1975 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1977 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1980 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1982 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1983 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1986 anEvent = theEvent ;
1992 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1993 SUPERV::GraphEvent & anEvent ,
1994 SUPERV::GraphState & aState ) {
1995 // beginService( "Graph_Impl::EventW" );
1996 bool RetVal = false ;
1997 char * aNodeName = NULL ;
1998 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1999 SUPERV::GraphState theState = SUPERV::UndefinedState ;
2000 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2001 perror("pthread_mutex_lock _MutexExecutorWait") ;
2004 if ( DataFlowExecutor() && !IsMacro() &&
2005 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
2006 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
2007 if ( RetVal && strcmp( aNodeName , Name() ) ) {
2008 aNode = Node( aNodeName ) ;
2014 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2015 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2018 anEvent = theEvent ;
2020 // endService( "Graph_Impl::EventW" );
2024 CORBA::Long Graph_Impl::EventQSize() {
2025 // beginService( "Graph_Impl::EventQSize" );
2026 CORBA::Long QSize = -1 ;
2027 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2028 perror("pthread_mutex_lock _MutexExecutorWait") ;
2031 if ( DataFlowExecutor() && !IsMacro() ) {
2032 QSize = DataFlowExecutor()->EventQSize() ;
2034 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2035 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2038 // endService( "Graph_Impl::EventQSize" );
2042 CORBA::Long Graph_Impl::LastLevelDone() {
2043 // beginService( "Graph_Impl::LastLevelDone" );
2044 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2045 perror("pthread_mutex_lock _MutexExecutorWait") ;
2048 CORBA::Long RetVal = 0 ;
2049 if ( DataFlowExecutor() && !IsMacro() ) {
2050 RetVal = DataFlowExecutor()->LastLevelDone() ;
2052 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2053 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2056 // endService( "Graph_Impl::LastLevelDone" );
2060 CORBA::Long Graph_Impl::SubGraphsNumber() {
2061 // beginService( "Graph_Impl::SubGraphsNumber" );
2062 CORBA::Long RetVal = 0 ;
2063 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2064 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2066 // endService( "Graph_Impl::SubGraphsNumber" );
2070 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( CORBA::Long aSubGraphNumber ) {
2071 beginService( "Graph_Impl::SubGraphsNodes" );
2072 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2073 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2074 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2077 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2078 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2079 if ( aNode->SubGraph() == aSubGraphNumber ) {
2080 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2084 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2085 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2086 if ( aNode->SubGraph() == aSubGraphNumber ) {
2087 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2091 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2092 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2093 if ( aNode->SubGraph() == aSubGraphNumber ) {
2094 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2098 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2099 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2100 if ( aNode->SubGraph() == aSubGraphNumber ) {
2101 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2105 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2106 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2107 if ( aNode->SubGraph() == aSubGraphNumber ) {
2108 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2112 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2113 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2114 if ( aNode->SubGraph() == aSubGraphNumber ) {
2115 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2119 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2120 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2121 if ( aNode->SubGraph() == aSubGraphNumber ) {
2122 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2126 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2127 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2128 if ( aNode->SubGraph() == aSubGraphNumber ) {
2129 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2133 endService( "Graph_Impl::SubGraphsNodes" );
2134 return ( RetVal._retn() ) ;
2137 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2138 // beginService( "Graph_Impl::Merge" );
2139 bool RetVal = true ;
2141 map< string , int > aMapOfNodes ;
2142 RetVal = Merge( aGraph , aMapOfNodes ) ;
2144 // endService( "Graph_Impl::Merge" );
2148 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2149 beginService( "Graph_Impl::Merge" );
2150 bool RetVal = true ;
2151 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2152 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2154 SUPERV::Port_ptr aPort ;
2155 // SUPERV::StreamPort_ptr aStreamPort ;
2157 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2158 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2159 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2160 if ( !CORBA::is_nil( myNode ) ) {
2161 myNode->SetName( aNode->Name() ) ;
2162 myNode->SetAuthor( aNode->Author() ) ;
2163 myNode->SetComment( aNode->Comment() ) ;
2164 myNode->Coords( aNode->X() , aNode->Y() ) ;
2165 string * aNodetheName = new string( aNode->Name() ) ;
2166 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2167 delete aNodetheName ;
2174 // The following informations are now in the service from SALOME_ModuleCatalog
2175 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2177 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2178 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2179 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2181 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2182 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2188 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2189 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2190 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2191 aNode->GetInterfaceName() ,
2192 *(aNode->Service()) ,
2193 aNode->IsCimpl() ) ; // mkr : PAL11273
2194 if ( !CORBA::is_nil( myNode ) ) {
2195 myNode->SetName( aNode->Name() ) ;
2196 myNode->SetAuthor( aNode->Author() ) ;
2197 myNode->SetComment( aNode->Comment() ) ;
2198 myNode->Coords( aNode->X() , aNode->Y() ) ;
2199 string * aNodetheName = new string( aNode->Name() ) ;
2200 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2201 delete aNodetheName ;
2208 // The following informations are now in the service from SALOME_ModuleCatalog
2209 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2211 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2212 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2213 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2215 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2216 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2223 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2224 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2225 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2226 if ( !CORBA::is_nil( myNode ) ) {
2227 myNode->SetName( aNode->Name() ) ;
2228 myNode->SetAuthor( aNode->Author() ) ;
2229 myNode->SetComment( aNode->Comment() ) ;
2230 myNode->Coords( aNode->X() , aNode->Y() ) ;
2231 string * aNodetheName = new string( aNode->Name() ) ;
2232 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2233 delete aNodetheName ;
2234 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2236 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2237 if ( myPorts[ j ]->IsInput() ) {
2238 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2241 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2244 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2245 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2246 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2247 if ( myStreamPorts[ j ]->IsInput() ) {
2248 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2251 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2265 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2266 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2267 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2268 if ( !CORBA::is_nil( myNode ) ) {
2269 myNode->SetName( aNode->Name() ) ;
2270 myNode->SetAuthor( aNode->Author() ) ;
2271 myNode->SetComment( aNode->Comment() ) ;
2272 myNode->Coords( aNode->X() , aNode->Y() ) ;
2273 string * aNodetheName = new string( aNode->Name() ) ;
2274 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2275 delete aNodetheName ;
2276 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2278 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2279 if ( myPorts[ j ]->IsInput() ) {
2280 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2283 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2286 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2287 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2288 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2289 if ( myStreamPorts[ j ]->IsInput() ) {
2290 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2293 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2307 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2308 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2309 SUPERV::INode_ptr anEndOfLoop ;
2310 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2311 *(aNode->PyInit()) ,
2312 aNode->PyMoreName() ,
2313 *(aNode->PyMore()) ,
2314 aNode->PyNextName() ,
2315 *(aNode->PyNext()) ,
2317 if ( !CORBA::is_nil( myNode ) ) {
2318 myNode->SetName( aNode->Name() ) ;
2319 myNode->SetAuthor( aNode->Author() ) ;
2320 myNode->SetComment( aNode->Comment() ) ;
2321 myNode->Coords( aNode->X() , aNode->Y() ) ;
2322 string * aNodetheName = new string( aNode->Name() ) ;
2323 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2324 delete aNodetheName ;
2325 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2327 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2328 if ( myPorts[ j ]->IsInput() ) {
2329 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2332 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2335 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2336 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2337 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2338 if ( myStreamPorts[ j ]->IsInput() ) {
2339 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2342 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2346 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2347 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2348 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2349 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2350 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2351 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2352 aNodetheName = new string( myEndOfLoop->Name() ) ;
2353 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2354 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2355 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2356 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2357 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2358 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2361 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
2365 delete aNodetheName ;
2376 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2377 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2378 SUPERV::INode_ptr anEndOfSwitch ;
2379 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2380 if ( !CORBA::is_nil( myNode ) ) {
2381 myNode->SetName( aNode->Name() ) ;
2382 myNode->SetAuthor( aNode->Author() ) ;
2383 myNode->SetComment( aNode->Comment() ) ;
2384 myNode->Coords( aNode->X() , aNode->Y() ) ;
2385 string * aNodetheName = new string( aNode->Name() ) ;
2386 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2387 delete aNodetheName ;
2388 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2390 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2391 if ( myPorts[ j ]->IsInput() ) {
2392 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2395 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2398 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2399 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2400 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2401 if ( myStreamPorts[ j ]->IsInput() ) {
2402 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2405 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
2409 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2410 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2411 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2412 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2413 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2414 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2415 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2416 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2417 delete aNodetheName ;
2418 myPorts = *(myEndOfSwitch->Ports()) ;
2419 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2420 if ( myPorts[ j ]->IsInput() ) {
2421 aPort = anEndOfSwitch->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2424 aPort = anEndOfSwitch->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2427 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2428 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2429 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2430 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2431 aPort = anEndOfSwitch->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2434 aPort = anEndOfSwitch->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2447 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2448 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2449 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2451 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2452 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2453 SUPERV::Port_var OutPort = aLink->OutPort() ;
2454 SUPERV::Port_var InPort = aLink->InPort() ;
2455 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2456 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2457 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2459 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2463 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2465 RetVal = aLink->Coords( j , X , Y ) ;
2468 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2470 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2478 delete aLinkFromNodeName ;
2479 delete aLinkToNodeName ;
2485 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2486 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2487 if ( !aPort->IsGate() ) {
2488 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2489 char * aPortName = aPort->Name() ;
2490 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2491 strcpy( aNodeName , aPortName ) ;
2492 // char * thePortName = strchr( aNodeName , '\\' ) ;
2493 char * thePortName = aNodeName ;
2494 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2495 if ( thePortName[1] == '_' ) {
2496 thePortName[ 0 ] = '\0' ;
2500 thePortName = &thePortName[2] ;
2503 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2504 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2505 // << " HasInput " << hasinput << endl ;
2507 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2509 *(aPort->ToAny()) ) ;
2511 delete [] aNodeName ;
2520 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2521 endService( "Graph_Impl::Merge" );
2525 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2526 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2527 beginService( "Graph_Impl::ToStreamGraph" );
2528 if ( IsStreamGraph() && !IsMacro() ) {
2529 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2530 // instanceName() , interfaceName() ) ;
2531 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2532 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2533 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2534 if ( CORBA::is_nil( iobject ) ) {
2535 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2539 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2541 endService( "Graph_Impl::ToStreamGraph" );
2542 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2546 * Destroy Executor and use only Editor and its data model
2548 void Graph_Impl::Editing() {
2549 if ( DataFlowEditor() && DataFlowExecutor() ) {
2550 delete DataFlowExecutor() ;
2551 DataFlowEditor()->Executor( NULL );