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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : Graph_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "SALOME_Container_i.hxx"
39 #include "StreamGraph_Impl.hxx"
41 #include "DataFlowEditor_DataFlow.hxx"
43 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
45 static void CreateEditor( CORBA::ORB_ptr orb ,
46 const char *instanceName ,
47 const char *aDataFlowName ,
48 const SUPERV::KindOfNode aKindOfNode ,
50 GraphEditor::DataFlow ** aDataFlowEditor ) {
51 bool aXmlFile = false ;
52 int lenname = strlen( aDataFlowName ) ;
53 char * theDataFlowName = new char [ lenname+1 ] ;
54 strcpy( theDataFlowName , aDataFlowName ) ;
55 if ( aDataFlowName ) {
56 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
57 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
58 theDataFlowName[ lenname-4 ] = '\0' ;
61 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
62 if ( aDataFlowName[ i ] == '/' ) {
63 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
64 theDataFlowName[ lenname-5-i ] = '\0' ;
70 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
74 string theDataFlowInstanceName = theDataFlowName ;
76 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
77 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
78 dbgfile = "/tmp/logs/" ;
79 dbgfile += getenv( "USER" ) ;
81 dbgfile += instanceName ;
83 dbgfile += theDataFlowInstanceName ;
84 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
85 FILE* f = fopen ( dbgfile.c_str(), "a" );
86 if ( f ) { // check if file can be opened for writing
89 else { // if file can't be opened - use a guaranteed temp file name
90 char* aTempNam = tempnam( NULL, NULL );
95 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
96 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
97 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
99 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
100 << dbgfile.c_str() ) ;
102 delete [] theDataFlowName ;
105 static void CreateExecutor( CORBA::ORB_ptr orb ,
106 const char *instanceName ,
107 const char *aDataFlowName ,
108 const SUPERV::KindOfNode aKindOfNode ,
110 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
111 int lenname = strlen( aDataFlowName ) ;
112 char * theDataFlowName = new char [ lenname+1 ] ;
113 strcpy( theDataFlowName , aDataFlowName ) ;
114 if ( aDataFlowName ) {
115 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
118 string theDataFlowInstanceName = theDataFlowName ;
120 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
121 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
122 dbgfile = "/tmp/logs/" ;
123 dbgfile += getenv( "USER" ) ;
125 dbgfile += instanceName ;
127 dbgfile += theDataFlowInstanceName ;
128 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
130 astr << theAutomaton->ExecNumber() ;
131 dbgfile += astr.str() ;
132 dbgfile += string( "_Exec.log" ) ;
133 FILE* f = fopen ( dbgfile.c_str(), "a" );
134 if ( f ) { // check if file can be opened for writing
137 else { // if file can't be opened - use a guaranteed temp file name
138 char* aTempNam = tempnam( NULL, NULL );
143 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
144 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
145 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
148 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
149 << dbgfile.c_str() ) ;
151 delete [] theDataFlowName ;
154 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
155 PortableServer::POA_ptr poa ,
156 PortableServer::ObjectId * contId ,
157 const char *instanceName ,
158 const char *interfaceName ,
159 const char *aDataFlowName ,
160 const SUPERV::KindOfNode aKindOfNode ) :
161 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
162 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
163 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
164 // << hex << (void *) this << dec )
165 // beginService( "Graph_Impl::Graph_Impl" );
166 _Orb = CORBA::ORB::_duplicate(orb);
169 _DebugFileName = NULL ;
170 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
171 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
173 _id = _poa->activate_object(_thisObj);
176 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
179 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
181 GraphEditor::DataFlow * aDataFlowEditor ;
182 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
183 dbgfile , &aDataFlowEditor ) ;
185 if ( _DebugFileName ) {
186 delete [] _DebugFileName ;
188 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
189 strcpy( _DebugFileName , dbgfile.c_str() ) ;
191 _NamingService = new SALOME_NamingService( orb ) ;
192 DataFlowEditor( aDataFlowEditor ) ;
193 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
194 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
196 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
197 // DataFlowExecutor( NULL ) ;
198 // endService( "Graph_Impl::Graph_Impl" );
201 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
202 PortableServer::POA_ptr poa ,
203 PortableServer::ObjectId * contId ,
204 const char *instanceName ,
205 const char *interfaceName ,
206 GraphEditor::DataFlow * aDataFlowEditor ,
207 GraphEditor::InNode * aDataFlowNode ) :
208 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
209 // beginService( "Graph_Impl::Graph_Impl" );
210 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
211 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
212 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
213 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
215 _id = _poa->activate_object(_thisObj);
218 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
220 _Orb = CORBA::ORB::_duplicate(orb);
223 _DebugFileName = NULL ;
224 DataFlowEditor( aDataFlowEditor ) ;
225 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
226 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
227 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
228 // DataFlowExecutor( NULL ) ;
229 // endService( "Graph_Impl::Graph_Impl" );
232 Graph_Impl::Graph_Impl() {
235 Graph_Impl::~Graph_Impl() {
236 beginService( "Graph_Impl::~Graph_Impl" );
237 endService( "Graph_Impl::~Graph_Impl" );
240 void Graph_Impl::destroy() {
241 beginService( "Graph_Impl::destroy" );
242 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
243 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
244 GNode_Impl::Delete() ;
245 if ( !CORBA::is_nil( aGraph ) ) {
250 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
251 GNode_Impl::Delete() ;
252 if ( !CORBA::is_nil( aGraph ) ) {
256 _poa->deactivate_object(*_id) ;
257 // CORBA::release(_poa) ;
259 // _thisObj->_remove_ref();
260 endService( "Graph_Impl::destroy" );
264 char* Graph_Impl::getIOR() {
266 return CORBA::string_dup( NULLSTRING ) ;
268 else if ( CORBA::is_nil( myServant ) ) {
269 PortableServer::ObjectId* id = getId();
270 CORBA::Object_var obj;
271 obj = _poa->id_to_reference(*id);
272 myServant = SUPERV::Graph::_narrow(obj);
274 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
277 SUPERV::Graph_ptr Graph_Impl::Copy() {
278 beginService( "Graph_Impl::Copy" );
279 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
281 Graph_Impl * myGraph ;
282 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
283 instanceName() , interfaceName() ,
284 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
285 PortableServer::ObjectId * id = myGraph->getId() ;
286 CORBA::Object_var obj = _poa->id_to_reference(*id);
287 iobject = SUPERV::Graph::_narrow(obj) ;
288 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
289 myGraph->LoadGraphs( aListOfSGraphs ) ;
291 endService( "Graph_Impl::Copy" );
292 return SUPERV::Graph::_duplicate(iobject) ;
295 void Graph_Impl::ReadOnly() {
296 DataFlowEditor()->ReadOnly() ;
299 SUPERV::INode_ptr Graph_Impl::Node() {
300 // beginService( "Graph_Impl::Node" );
301 PortableServer::ObjectId * id = getId() ;
302 CORBA::Object_var obj = _poa->id_to_reference(*id);
303 SUPERV::Graph_var iobject ;
304 iobject = SUPERV::Graph::_narrow(obj) ;
305 // endService( "Graph_Impl::Node" );
306 return SUPERV::Graph::_duplicate(iobject) ;
309 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
310 return DataFlowEditor()->GetDataFlows() ;
313 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
314 beginService( "Graph_Impl::LoadGraphs" );
315 bool RetVal = false ;
316 if ( DataFlowEditor()->IsEditing() ) {
317 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
318 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
322 endService( "Graph_Impl::LoadGraphs" );
326 bool Graph_Impl::Import(const char * aXmlFile ) {
327 beginService( "Graph_Impl::Import" );
328 bool RetVal = false ;
329 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
330 GraphBase::ListOfSGraphs aListOfDataFlows ;
331 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
332 if ( RetVal && aXmlFile != NULL ) {
333 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
334 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
339 endService( "Graph_Impl::Import" );
343 bool Graph_Impl::Export(const char * anXmlFile ) {
344 beginService( "Graph_Impl::Export" );
345 bool RetVal = false ;
347 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
348 strcpy( aFile , anXmlFile ) ;
349 int len = strlen( aFile ) ;
350 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
352 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
353 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
354 len = strlen( aFile ) ;
357 strcat( aFile , ".xml" ) ;
358 len = strlen( aFile ) ;
360 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
362 strcpy( &aFile[ len - 4 ] , ".py" ) ;
363 RetVal = DataFlowEditor()->SavePy( aFile ) ;
367 endService( "Graph_Impl::Export" );
371 char * Graph_Impl::SavePY( bool importSuperV ) {
372 beginService( "Graph_Impl::SavePY" );
373 ostringstream fstring ;
375 RetVal = DataFlowEditor()->SavePY( fstring , importSuperV ) ;
377 endService( "Graph_Impl::SavePY" );
378 return CORBA::string_dup( fstring.str().c_str() );
380 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
381 beginService( "Graph_Impl::CNode" );
382 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
383 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
384 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
385 instanceName() , interfaceName() ,
387 NodeService , NULLSTRING ,
388 SUPERV::ComputingNode , NULLSTRING ) ;
389 if ( myNode->DataFlowNode() ) {
390 PortableServer::ObjectId * id = myNode->getId() ;
391 CORBA::Object_var obj = _poa->id_to_reference(*id);
392 iobject = SUPERV::CNode::_narrow(obj) ;
393 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
396 DataFlowEditor()->UnValid() ;
397 endService( "Graph_Impl::CNode" );
398 return SUPERV::CNode::_duplicate( iobject ) ;
401 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
402 const char * NodeInterfaceName ,
403 const SALOME_ModuleCatalog::Service &NodeService ,
404 const SALOME_ModuleCatalog::ImplType ImplType ) {
405 beginService( "Graph_Impl::FNode" );
406 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
410 case SALOME_ModuleCatalog::PY:
413 case SALOME_ModuleCatalog::SO:
414 case SALOME_ModuleCatalog::EXE:
418 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
419 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
420 instanceName() , interfaceName() ,
426 SUPERV::FactoryNode ,
428 if ( myNode->DataFlowNode() ) {
429 PortableServer::ObjectId * id = myNode->getId() ;
430 CORBA::Object_var obj = _poa->id_to_reference(*id);
431 iobject = SUPERV::FNode::_narrow(obj) ;
432 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
435 DataFlowEditor()->UnValid() ;
436 endService( "Graph_Impl::FNode" );
437 return SUPERV::FNode::_duplicate( iobject ) ;
440 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
441 const SUPERV::ListOfStrings & PythonFuntion ) {
442 beginService( "Graph_Impl::INode" );
443 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
444 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
445 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
446 instanceName() , interfaceName() ,
448 FuncName , PythonFuntion ,
449 SUPERV::InLineNode ) ;
450 if ( myNode->DataFlowNode() ) {
451 PortableServer::ObjectId * id = myNode->getId() ;
452 CORBA::Object_var obj = _poa->id_to_reference(*id);
453 iobject = SUPERV::INode::_narrow(obj) ;
454 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
457 endService( "Graph_Impl::INode" );
458 return SUPERV::INode::_duplicate( iobject ) ;
462 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
463 const SUPERV::ListOfStrings & PythonFuntion ,
464 const char * anInLineNode ) {
465 beginService( "Graph_Impl::GNode" );
466 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
467 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
468 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
469 instanceName() , interfaceName() ,
471 FuncName , PythonFuntion ,
473 if ( myNode->DataFlowNode() ) {
474 PortableServer::ObjectId * id = myNode->getId() ;
475 CORBA::Object_var obj = _poa->id_to_reference(*id);
476 iobject = SUPERV::GNode::_narrow(obj) ;
477 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
478 if ( strlen( anInLineNode ) ) {
479 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
480 if ( anInLineNode ) {
481 myNode->SetCoupled( anInLineNode ) ;
482 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
487 DataFlowEditor()->UnValid() ;
488 endService( "Graph_Impl::GNode" );
489 return SUPERV::GNode::_duplicate( iobject ) ;
492 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
493 const SUPERV::ListOfStrings & InitFunction ,
494 const char * MoreName ,
495 const SUPERV::ListOfStrings & MoreFunction ,
496 const char * NextName ,
497 const SUPERV::ListOfStrings & NextFunction ,
498 SUPERV::INode_out anEndOfLoop ) {
499 beginService( "Graph_Impl::LNode" );
500 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
501 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
502 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
503 GraphBase::ListOfFuncName FuncNameList ;
504 FuncNameList.resize(3) ;
505 FuncNameList[0] = InitName ;
506 FuncNameList[1] = MoreName ;
507 FuncNameList[2] = NextName ;
508 GraphBase::ListOfPythonFunctions PythonFunctionList ;
509 PythonFunctionList.resize(3) ;
510 PythonFunctionList[0] = &InitFunction ;
511 PythonFunctionList[1] = &MoreFunction ;
512 PythonFunctionList[2] = &NextFunction ;
513 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
514 instanceName() , interfaceName() ,
516 FuncNameList , PythonFunctionList ,
517 // InitName , InitFunction ,
518 // MoreName , MoreFunction ,
519 // NextName , NextFunction ,
521 if ( myNode->DataFlowNode() ) {
522 PortableServer::ObjectId * id = myNode->getId() ;
523 CORBA::Object_var obj = _poa->id_to_reference(*id);
524 iobject = SUPERV::LNode::_narrow(obj) ;
525 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
527 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
529 if ( strlen( InitName ) ) {
530 anEndName = new char[ 3 + strlen( InitName ) + 1 ];
531 strcpy( anEndName , "End" ) ;
532 strcat( anEndName , InitName ) ;
535 anEndName = new char[ 3 + strlen( "Loop" ) + 1 ];
536 strcpy( anEndName , "EndLoop" ) ;
538 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
539 instanceName() , interfaceName() ,
542 SUPERV::EndLoopNode ) ;
543 PortableServer::ObjectId * endid = myEndNode->getId() ;
544 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
545 iendobject = SUPERV::ELNode::_narrow(endobj) ;
546 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
547 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
548 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
549 //JR 25.01.2005 That links are already done in SetCoupled above ...
550 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
551 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
552 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
555 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
556 DataFlowEditor()->UnValid() ;
557 endService( "Graph_Impl::LNode" );
558 return SUPERV::LNode::_duplicate( iobject ) ;
561 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
562 const SUPERV::ListOfStrings & PythonFunction ,
563 SUPERV::INode_out anEndOfSwitch ) {
564 beginService( "Graph_Impl::SNode" );
565 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
566 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
567 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
568 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
569 instanceName() , interfaceName() ,
571 FuncName , PythonFunction ,
572 SUPERV::SwitchNode ) ;
573 if ( myNode->DataFlowNode() ) {
574 PortableServer::ObjectId * id = myNode->getId() ;
575 CORBA::Object_var obj = _poa->id_to_reference(*id);
576 iobject = SUPERV::SNode::_narrow(obj) ;
577 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
579 string anEndName = "End" ;
580 if ( strlen( FuncName ) ) {
581 anEndName += FuncName ;
584 anEndName += "Switch" ;
586 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
587 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
588 // << anEndName.c_str() << endl ;
589 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
590 instanceName() , interfaceName() ,
593 SUPERV::EndSwitchNode ) ;
594 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
595 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
596 // << " " << anEndName.c_str() << endl ;
597 PortableServer::ObjectId * endid = myEndNode->getId() ;
598 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
599 iendobject = SUPERV::ESNode::_narrow(endobj) ;
600 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
601 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
602 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
603 //JR NPAL14793 05.02.2007 : do not add that link
604 // if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
605 // iobject = SUPERV::SNode::_nil() ;
606 // iendobject = SUPERV::ESNode::_nil() ;
610 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
611 DataFlowEditor()->UnValid() ;
612 endService( "Graph_Impl::SNode" );
613 return SUPERV::SNode::_duplicate( iobject ) ;
616 // WARNING : THIS IS COMPLICATED :
617 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
618 GraphBase::ListOfSGraphs * aListOfDataFlows ,
620 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
621 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
623 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
624 // That method is recursive :
625 // At first we load the supergraph with index = 0 :
626 // (After we load the graph corresponding to each MacroNode :)
627 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
628 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
629 return SUPERV::Graph::_duplicate( iobject ) ;
631 // That graph is not a StreamGraph :
632 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
633 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
634 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
635 Graph_Impl * myGraph ;
636 // We create a Graph ObjRef for that graph
637 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
638 instanceName() , interfaceName() ,
639 aDataFlowEditor , NULL ) ;
640 PortableServer::ObjectId * id = myGraph->getId() ;
641 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
642 iobject = SUPERV::Graph::_narrow( obj ) ;
643 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
644 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
645 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
648 // asv: set Editor for the graph itself and for all its macro nodes
649 aGraph->GraphEditor( aDataFlowEditor );
651 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
652 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
653 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
654 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
656 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
657 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
658 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
659 // so here we check if the node is "new" or "old"
660 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
663 // asv: set Editor for the graph itself and for all its macro nodes
664 aMacroNode->GraphEditor( aDataFlowEditor );
666 // Creation of a GraphMacroNode ObjRef in the current editor
667 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
668 Graph_Impl * myMacroNode ;
669 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
670 instanceName() , interfaceName() ,
671 aMacroNode->Name() , SUPERV::MacroNode ) ;
672 id = myMacroNode->getId() ;
673 obj = _poa->id_to_reference(*id);
674 macroiobject = SUPERV::Graph::_narrow( obj ) ;
675 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
676 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
677 myMacroNode->DataFlowNode( aDataFlowNode ) ;
678 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
679 aDataFlowNode->SetObjImpl( myMacroNode ) ;
681 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
682 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
683 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
686 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
687 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
688 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
691 // At first create the editor and a StreamGraph
692 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
693 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
694 dbgfile , &aMacroGraphDataFlowEditor ) ;
696 if ( _DebugFileName ) {
697 delete [] _DebugFileName ;
699 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
700 strcpy( _DebugFileName , dbgfile.c_str() ) ;
702 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
703 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
704 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
705 return SUPERV::Graph::_duplicate( iobject ) ;
708 // That graph is not a StreamGraph :
709 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
710 Graph_Impl * myMacroGraph ;
711 // The Graph ObjRef for that graph was already created
712 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
714 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
716 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
717 aMacroGraph->CoupledNode( aMacroNode ) ;
718 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
720 // Set the GraphMacroNode ObjRef in the MacroNode
721 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
722 aMacroNode->CoupledNode( aMacroGraph ) ;
723 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
724 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
725 << " coupled to " << aMacroGraph->CoupledNode() << " "
726 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
727 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
728 << " coupled to " << aMacroNode->CoupledNode() << " "
729 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
730 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
731 << " coupled to " << aGraph->CoupledNode()
732 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
738 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
743 else if ( (*aListOfDataFlows).size() == 1 ) {
744 StreamGraph_Impl * myStreamGraph ;
745 // We create a Graph ObjRef for that graph
746 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
747 instanceName() , interfaceName() ,
748 aDataFlowEditor , NULL ) ;
749 PortableServer::ObjectId * id = myStreamGraph->getId() ;
750 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
751 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
752 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
753 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
754 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
755 // iobject = SUPERV::Graph::_narrow( obj ) ;
756 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
759 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
762 endService( "Graph_Impl::EditorLoadDataFlows" );
763 return SUPERV::Graph::_duplicate( iobject ) ;
766 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
767 GraphBase::ListOfSGraphs * aListOfDataFlows ,
769 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
770 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
772 // That method is recursive :
773 // At first we load the supergraph with index = 0 :
774 // (After we load the graph corresponding to each MacroNode :)
775 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
776 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
777 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
780 // That graph is not a StreamGraph :
782 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
783 GraphEditor::DataFlow * aDataFlowEditor ;
784 aDataFlowEditor = DataFlowEditor() ;
785 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
786 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
787 if ( aDataFlowEditor->Executor() ) {
788 delete aDataFlowEditor->Executor() ;
789 aDataFlowEditor->Executor( NULL ) ;
790 aDataFlowEditor->Editing() ;
792 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
793 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
795 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
796 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
798 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
799 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
800 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
801 aMacroNode->GraphEditor( aDataFlowEditor ) ;
803 // get the macro node's editor object
804 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
805 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
806 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
808 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
809 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
812 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
813 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
817 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
818 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
820 index--; // it was incremented in "for ..." before last check ( !found ).
822 // At first create the editor and a StreamGraph
824 GraphExecutor::DataFlow * aMacroGraphExecutor ;
825 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
826 dbgfile , &aMacroGraphExecutor );
827 theAutomaton->Executed() ; // Decrement _GraphExecutingNumber for MacroSubGraph
829 // set GraphMacroLevel for Executor's graph
830 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
831 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
833 // load data flows in MacroGraph's executor
834 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
835 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
836 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
837 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
838 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
841 // set coupled pair MacroNode <--> MacroGraph
842 aMacroGraphExe->CoupledNode( aMacroNode ) ;
843 aMacroNode->CoupledNode( aMacroGraphExe ) ;
845 //JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
846 // InPorts values of MacroGraphs of MacroNodes are done in the Executor
847 // It was probably to try to debug anything but it was a wrong debug and I do not know what bug
848 // ===> folowing code is commented
850 // initialize MacroNode's InPorts with corresponding "external" values
852 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
853 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
854 if ( anInPort->IsDataConnected() ) {
855 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
856 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
857 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
858 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
861 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
862 << aMacroGraphInPortName << " , Value )" ) ;
865 } // end of init MacroNode's InPorts
867 aMacroGraphImpl->Run() ;
870 } // end of for( get nodes of the graph...)
872 } // end of setting initial graph's structure..
874 endService( "Graph_Impl::ExecutorLoadDataFlows" );
876 PortableServer::ObjectId * id = getId();
877 CORBA::Object_var obj = _poa->id_to_reference( *id );
878 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
879 return SUPERV::Graph::_duplicate( iobject ) ;
882 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
883 beginService( "Graph_Impl::MNode" );
884 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
885 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
887 GraphBase::ListOfSGraphs aListOfDataFlows ;
889 // At first create the editor and a StreamGraph with the xml file
890 GraphEditor::DataFlow * aDataFlowEditor ;
891 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
892 dbgfile , &aDataFlowEditor ) ;
894 if ( _DebugFileName ) {
895 delete [] _DebugFileName ;
897 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
898 strcpy( _DebugFileName , dbgfile.c_str() ) ;
900 int lenname = strlen( aXmlFileName ) ;
901 bool loaded = false ;
902 // Import of the xml file
903 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
904 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
906 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
913 // WARNING : THIS IS COMPLICATED :
914 // I should have to remove duplicated code ...
915 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
916 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
917 beginService( "Graph_Impl::MNode" ) ;
918 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
919 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
922 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
923 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
924 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
925 if ( CORBA::is_nil( iobject ) ) {
926 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
930 // That graph is not a StreamGraph :
931 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
932 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
933 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
935 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
936 // Creation of a GraphMacroNode in the current editor
937 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
938 Graph_Impl * myMacroNode ;
939 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
940 instanceName() , interfaceName() ,
941 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
942 PortableServer::ObjectId * id = myMacroNode->getId() ;
943 CORBA::Object_var obj = _poa->id_to_reference(*id);
944 macroiobject = SUPERV::Graph::_narrow( obj ) ;
945 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
947 // Creation of the MacroNode itself in the current Graph
948 GraphBase::ListOfFuncName aFuncName ;
949 aFuncName.resize( 1 ) ;
951 SUPERV::ListOfStrings aListOfStrings ;
952 aListOfStrings.length( 1 ) ;
953 aListOfStrings[0] = "" ;
954 GraphBase::ListOfPythonFunctions aPythonFunction ;
955 aPythonFunction.resize( 1 ) ;
956 aPythonFunction[0] = &aListOfStrings ;
957 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
958 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
959 aMacroNodeName.c_str() , SUPERV::MacroNode ,
960 aFuncName , aPythonFunction ) ;
961 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
962 myMacroNode->DataFlowNode( aDataFlowNode ) ;
963 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
964 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
965 aDataFlowNode->SetObjImpl( this ) ;
967 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
968 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
969 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
970 aMacroGraph->Kind( SUPERV::MacroNode ) ;
971 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
972 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
973 aMacroGraph->SetMacroPorts( aGraph ) ;
974 // Valid ==> creation of Service and the ports of the current Graph
975 DataFlowEditor()->IsValid() ;
976 // Set the Input Datas from the GraphMacroNode to the current Graph
977 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
978 aMacroGraphDataFlowEditor->UnValid() ;
979 // Set the MacroNode ObjRef in the GraphMacroNode
980 aGraph->CoupledNode( aMacroGraph ) ;
981 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
982 // Set the GraphMacroNode ObjRef in the MacroNode
983 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
984 aMacroGraph->CoupledNode( aGraph ) ;
985 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
986 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
987 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
988 // aDataFlowNode->CoupledNode( aGraph ) ;
989 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
990 // Set the MacroLevel of that graph
991 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
992 aMacroGraph->Coordinates( 0 , 0 ) ;
993 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
994 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
995 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
996 << " coupled to " << aGraph->CoupledNode() << " "
997 << aGraph->CoupledNode()->Name() ) ;
998 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
999 << " coupled to " << aMacroGraph->CoupledNode() << " "
1000 << aMacroGraph->CoupledNode()->Name() ) ;
1001 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
1002 << myMacroNode->DataFlowEditor()->Graph()->Name()
1003 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
1006 delete aMacroGraphDataFlowEditor ;
1009 endService( "Graph_Impl::MNode" );
1010 return SUPERV::Graph::_duplicate( macroiobject ) ;
1013 // For python supergraph
1014 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
1015 SUPERV::Graph_var iobject = myMacroGraph ;
1016 beginService( "Graph_Impl::GraphMNode" ) ;
1018 // GraphBase::Graph * myMacroGraph = aGraph;
1019 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
1020 // Creation of a GraphMacroNode in the current editor
1022 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
1023 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
1024 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
1025 Graph_Impl * myMacroNode ;
1026 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1027 instanceName() , interfaceName() ,
1028 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1029 PortableServer::ObjectId * id = myMacroNode->getId() ;
1030 CORBA::Object_var obj = _poa->id_to_reference(*id);
1031 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1032 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1034 // Creation of the MacroNode itself in the current Graph
1035 GraphBase::ListOfFuncName aFuncName ;
1036 aFuncName.resize( 1 ) ;
1038 SUPERV::ListOfStrings aListOfStrings ;
1039 aListOfStrings.length( 1 ) ;
1040 aListOfStrings[0] = "" ;
1041 GraphBase::ListOfPythonFunctions aPythonFunction ;
1042 aPythonFunction.resize( 1 ) ;
1043 aPythonFunction[0] = &aListOfStrings ;
1044 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1045 GraphEditor::InNode * aDataFlowNode ;
1046 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1047 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1048 aFuncName , aPythonFunction ) ;
1049 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1050 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1051 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1052 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1053 aDataFlowNode->SetObjImpl( this ) ;
1055 GraphBase::Graph * aSubGraph = NULL ;
1056 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1057 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1058 //JR 20.09.2005 Debug SAB_data_1609_bugPAL.py from CEA (Anthony)
1059 // Graph_Impl * aSubGraphImpl = dynamic_cast<Graph_Impl * >( _Poa->id_to_servant( *myMacroGraph->_Id ) ) ;
1060 myMacroGraph->ping() ;
1061 Graph_Impl * aSubGraphImpl = theAutomaton->GraphImpl() ;
1062 aSubGraph = aSubGraphImpl->DataFlowEditor()->Graph() ;
1063 myMacroGraph->Coupled() ;
1064 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1065 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1066 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1067 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1068 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1069 aMacroGraph->SetMacroPorts( aSubGraph ) ;
1070 // Valid ==> creation of Service and the ports of the current Graph
1071 DataFlowEditor()->IsValid() ;
1072 // Set the Input Datas from the GraphMacroNode to the current Graph
1073 aMacroGraph->SetMacroDatas( aSubGraph , aGraphOfMacroGraph ) ;
1074 // aMacroGraphDataFlowEditor->UnValid() ;
1075 aSubGraph->GraphEditor()->UnValid() ;
1076 // Set the MacroNode ObjRef in the GraphMacroNode
1077 aSubGraph->CoupledNode( aMacroGraph ) ;
1078 aSubGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1079 // Set the GraphMacroNode ObjRef in the MacroNode
1080 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1081 aMacroGraph->CoupledNode( aSubGraph ) ;
1082 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1083 // aDataFlowNode->CoupledNode( aSubGraph ) ;
1084 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1085 // Set the MacroLevel of that graph
1086 aSubGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1087 aMacroGraph->Coordinates( 0 , 0 ) ;
1088 MESSAGE( aSubGraph->Name() << "->CoupledNode()->GraphEditor() : " << aSubGraph->CoupledNode()->GraphEditor() ) ;
1089 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1090 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1091 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1092 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1094 endService( "Graph_Impl::GraphMNode" ) ;
1095 return SUPERV::Graph::_duplicate( macroiobject ) ;
1098 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1099 beginService( "Graph_Impl::FlowObjRef" );
1100 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1102 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1104 else if ( IsGraph() ) {
1105 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1107 if ( CORBA::is_nil( iobject ) ) {
1108 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1110 endService( "Graph_Impl::FlowObjRef" );
1111 return SUPERV::Graph::_duplicate( iobject ) ;
1114 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1115 beginService( "Graph_Impl::StreamObjRef" );
1116 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1118 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1120 else if ( IsGraph() || IsStreamGraph() ) {
1121 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1123 if ( CORBA::is_nil( iobject ) ) {
1124 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1126 endService( "Graph_Impl::StreamObjRef" );
1127 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1130 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1131 // beginService( "Graph_Impl::Node" );
1132 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1134 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1135 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1136 instanceName() , interfaceName() ,
1138 DataFlowEditor()->GetNode( aNodeName ) ) ;
1139 PortableServer::ObjectId * id = myNode->getId() ;
1140 CORBA::Object_var obj = _poa->id_to_reference(*id);
1141 iobject = SUPERV::CNode::_narrow(obj) ;
1142 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1145 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1148 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1150 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1151 SetNodeObjRef( anInNode ) ;
1153 iobject = anInNode->ObjRef() ;
1156 // endService( "Graph_Impl::Node" );
1157 return SUPERV::CNode::_duplicate( iobject ) ;
1160 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1161 SUPERV::Port_ptr InPort ) {
1162 // beginService( "Graph_Impl::Link" );
1163 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1164 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1165 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1166 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1167 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1168 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1169 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1170 if ( anInNode == NULL || anOutNode== NULL ) {
1171 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1172 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1175 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1176 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1177 if ( anInPort == NULL || anOutPort== NULL ) {
1178 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1179 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1181 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1182 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1183 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1184 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1185 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1186 if ( DataFlowOutNode && DataFlowInNode ) {
1188 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1189 instanceName() , interfaceName() ,
1195 true , false , Success ) ;
1197 PortableServer::ObjectId * id = myLink->getId() ;
1198 CORBA::Object_var obj = _poa->id_to_reference(*id);
1199 iobject = SUPERV::Link::_narrow(obj) ;
1200 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1205 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1206 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
1207 iobject = anOutPort->InPortObjRef( anInPort ) ;
1211 DataFlowEditor()->UnValid() ;
1212 // endService( "Graph_Impl::Link" );
1213 return SUPERV::Link::_duplicate( iobject ) ;
1216 // Only to see MacroNodes with actual GUI ... :
1217 #define GOTOMacroNode 0
1219 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1220 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1221 CORBA::Object_var obj ;
1222 if ( anInNode->IsComputingNode() ) {
1223 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1224 instanceName() , interfaceName() ,
1227 PortableServer::ObjectId * id = myNode->getId() ;
1228 obj = _poa->id_to_reference(*id);
1229 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1230 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1232 else if ( anInNode->IsFactoryNode() ) {
1233 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1234 instanceName() , interfaceName() ,
1237 PortableServer::ObjectId * id = myNode->getId() ;
1238 obj = _poa->id_to_reference(*id);
1239 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1240 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1242 else if ( anInNode->IsInLineNode() ) {
1243 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1244 instanceName() , interfaceName() ,
1247 PortableServer::ObjectId * id = myNode->getId() ;
1248 obj = _poa->id_to_reference(*id);
1249 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1250 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1253 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1254 if ( anInNode->IsMacroNode() ) {
1255 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1258 else if ( anInNode->IsGOTONode() ) {
1260 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1261 instanceName() , interfaceName() ,
1264 PortableServer::ObjectId * id = myNode->getId() ;
1265 obj = _poa->id_to_reference(*id);
1266 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1267 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1269 else if ( anInNode->IsMacroNode() ) {
1270 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1271 instanceName() , interfaceName() ,
1274 PortableServer::ObjectId * id = myNode->getId() ;
1275 obj = _poa->id_to_reference(*id);
1276 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1277 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1279 else if ( anInNode->IsLoopNode() ) {
1280 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1281 instanceName() , interfaceName() ,
1284 PortableServer::ObjectId * id = myNode->getId() ;
1285 obj = _poa->id_to_reference(*id);
1286 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1287 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1289 else if ( anInNode->IsEndLoopNode() ) {
1290 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1291 instanceName() , interfaceName() ,
1294 PortableServer::ObjectId * id = myNode->getId() ;
1295 obj = _poa->id_to_reference(*id);
1296 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1297 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1299 else if ( anInNode->IsSwitchNode() ) {
1300 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1301 instanceName() , interfaceName() ,
1304 PortableServer::ObjectId * id = myNode->getId() ;
1305 obj = _poa->id_to_reference(*id);
1306 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1307 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1309 else if ( anInNode->IsEndSwitchNode() ) {
1310 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1311 instanceName() , interfaceName() ,
1314 PortableServer::ObjectId * id = myNode->getId() ;
1315 obj = _poa->id_to_reference(*id);
1316 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1317 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1321 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1322 GraphBase::ComputingNode * aNode ) {
1324 // if ( _DataFlowExecutor ) {
1325 if ( DataFlowExecutor() ) {
1326 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1327 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1330 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1332 if ( aNode->IsComputingNode() ) {
1333 index = RetVal->CNodes.length() ;
1334 RetVal->CNodes.length( index+1 );
1336 else if ( aNode->IsFactoryNode() ) {
1337 index = RetVal->FNodes.length() ;
1338 RetVal->FNodes.length( index+1 );
1340 else if ( aNode->IsInLineNode() ) {
1341 index = RetVal->INodes.length() ;
1342 RetVal->INodes.length( index+1 );
1345 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1347 else if ( aNode->IsGOTONode() ) {
1349 index = RetVal->GNodes.length() ;
1350 RetVal->GNodes.length( index+1 );
1352 else if ( aNode->IsMacroNode() ) {
1353 index = RetVal->Graphs.length() ;
1354 RetVal->Graphs.length( index+1 );
1356 else if ( aNode->IsLoopNode() ) {
1357 index = RetVal->LNodes.length() ;
1358 RetVal->LNodes.length( index+1 );
1360 else if ( aNode->IsEndLoopNode() ) {
1361 index = RetVal->ELNodes.length() ;
1362 RetVal->ELNodes.length( index+1 );
1364 else if ( aNode->IsSwitchNode() ) {
1365 index = RetVal->SNodes.length() ;
1366 RetVal->SNodes.length( index+1 );
1368 else if ( aNode->IsEndSwitchNode() ) {
1369 index = RetVal->ESNodes.length() ;
1370 RetVal->ESNodes.length( index+1 );
1372 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1373 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1375 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1376 if ( aNode->IsComputingNode() ) {
1377 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1379 else if ( aNode->IsFactoryNode() ) {
1380 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1382 else if ( aNode->IsInLineNode() ) {
1383 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1386 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1388 else if ( aNode->IsGOTONode() ) {
1390 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1392 else if ( aNode->IsMacroNode() ) {
1393 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1395 else if ( aNode->IsLoopNode() ) {
1396 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1398 else if ( aNode->IsEndLoopNode() ) {
1399 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1401 else if ( aNode->IsSwitchNode() ) {
1402 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1404 else if ( aNode->IsEndSwitchNode() ) {
1405 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1407 return ( RetVal._retn() ) ;
1410 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1411 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1412 beginService( "Graph_Impl::Nodes" );
1413 RetVal->CNodes.length(0) ;
1414 RetVal->FNodes.length(0) ;
1415 RetVal->INodes.length(0) ;
1416 RetVal->LNodes.length(0) ;
1417 RetVal->SNodes.length(0) ;
1418 RetVal->GNodes.length(0) ;
1419 RetVal->Graphs.length(0) ;
1422 MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1423 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
1424 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1425 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1427 MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
1428 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
1430 RetVal = SetNode( RetVal , aNode ) ;
1433 char * aStateG = "" ;
1434 if ( DataFlowExecutor() ) {
1435 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1437 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1438 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1439 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1441 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1442 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1443 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1445 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1446 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1447 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1449 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1450 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1451 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1453 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1454 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1455 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1457 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1458 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1459 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1461 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1462 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1463 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1465 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1466 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1467 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1469 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1470 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1471 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1473 if ( DataFlowExecutor() ) {
1474 DataFlowExecutor()->EventList() ;
1478 endService( "Graph_Impl::Nodes" );
1479 return ( RetVal._retn() ) ;
1482 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1483 return Links( NULL , NULL ) ;
1486 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1487 const char * anInputParam ) {
1489 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1490 RetVal->length( 0 ) ;
1492 int i , j , countlink ;
1494 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1495 GraphEditor::InNode * aNode = NULL ;
1496 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1497 bool ToProcess = false ;
1498 if ( theNode == NULL ) {
1502 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1503 if ( !theNode->IsEndSwitchNode() ) {
1507 else if ( theNode->IsEndSwitchNode() ) {
1512 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1513 GraphBase::InPort * anInPort = NULL ;
1514 anInPort = aNode->GetChangeNodeInPort( j ) ;
1515 if ( anInputParam == NULL ||
1516 !strcmp( anInPort->PortName() , anInputParam ) ) {
1517 GraphBase::OutPort * anOutPort = NULL ;
1518 anOutPort = anInPort->GetOutPort() ;
1519 if ( anOutPort && !anOutPort->IsDataStream() ) {
1520 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1521 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1522 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1523 // << anInPort->PortName() << ")" ) ;
1524 if ( theNode == NULL ||
1526 //JR 14.02.2005 : Debug : we must see also that links !
1527 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1528 !strcmp( theNode->Name() , aNode->Name() ) ) {
1529 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1530 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1531 anOutPort->NodeName() ) ) ) {
1532 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1533 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1534 // << anInPort->PortName() << ")" << " ignored" ) ;
1536 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1538 beginService( "Graph_Impl::Links" );
1541 GraphEditor::InNode * anOutNode = NULL ;
1542 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1545 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1546 instanceName() , interfaceName() ,
1549 anInPort->PortName() ,
1551 anOutPort->PortName() ,
1552 false , true , Success ) ;
1554 PortableServer::ObjectId * id = myLink->getId() ;
1555 CORBA::Object_var obj = _poa->id_to_reference(*id);
1556 SUPERV::Link_var iobject ;
1557 iobject = SUPERV::Link::_narrow(obj) ;
1558 RetVal->length( countlink + 1 ) ;
1559 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1560 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1565 RetVal->length( countlink + 1 ) ;
1566 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1568 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1569 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1570 // << anInPort->PortName() << ")" << " selected" ) ;
1573 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1574 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1575 // << anInPort->PortName() << ")" << " skipped" ) ;
1582 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1583 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1584 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1585 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1587 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1588 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1589 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1590 // << " " << anInPort->PortStatus() ) ;
1591 if ( anInPort->IsPortConnected() ) {
1592 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1593 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1594 if ( theNode == NULL ||
1595 !strcmp( theNode->Name() , aNode->Name() ) ) {
1596 if ( !anInPort->IsDataStream() ) {
1598 //JR 14.02.2005 : Debug : we must see also that links !
1599 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1600 if ( anInputParam == NULL ||
1601 !strcmp( anInPort->PortName() , anInputParam ) ) {
1602 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1603 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1604 anOutPort->NodeName() ) ) ) {
1605 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1606 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1607 // << anInPort->PortName() << ")" << " ignored" ) ;
1609 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1611 beginService( "Graph_Impl::Links" );
1615 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1616 instanceName() , interfaceName() ,
1619 anInPort->PortName() ,
1621 anOutPort->PortName() ,
1622 false , true , Success ) ;
1624 PortableServer::ObjectId * id = myLink->getId() ;
1625 CORBA::Object_var obj = _poa->id_to_reference(*id);
1626 SUPERV::Link_var iobject ;
1627 iobject = SUPERV::Link::_narrow(obj) ;
1628 RetVal->length( countlink + 1 ) ;
1629 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1630 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1634 RetVal->length( countlink + 1 ) ;
1635 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1637 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1638 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1639 // << anInPort->PortName() << ")" << " selected" ) ;
1642 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1643 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1644 // << anInPort->PortName() << ")" << " skipped" ) ;
1655 const char * NodeName = "" ;
1656 const char * InputParamName = "" ;
1658 NodeName = theNode->Name() ;
1660 if ( anInputParam ) {
1661 InputParamName = anInputParam ;
1663 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1664 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1665 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1666 << RetVal[i]->OutPort()->Name() << ") --> "
1667 << RetVal[i]->InPort()->Node()->Name() << "("
1668 << RetVal[i]->InPort()->Name() << ")" ) ;
1672 endService( "Graph_Impl::Links" );
1675 return ( RetVal._retn() ) ;
1678 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1679 const char * aComponentName ) {
1680 Engines::Component_var objComponent = Engines::Component::_nil() ;
1682 Engines::Container_var myContainer ;
1683 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1684 myContainer , objComponent ) ;
1686 return Engines::Component::_duplicate( objComponent ) ;
1689 char * Graph_Impl::Messages() {
1690 beginService( "Graph_Impl::Messages" );
1692 MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
1693 Messages = DataFlowEditor()->Graph()->Messages() ;
1694 DataFlowEditor()->Graph()->ReSetMessages() ;
1695 if ( DataFlowExecutor() ) {
1696 Messages += DataFlowExecutor()->Graph()->Messages() ;
1697 DataFlowExecutor()->Graph()->ReSetMessages() ;
1699 endService( "Graph_Impl::Messages" );
1700 return ( CORBA::string_dup( Messages.c_str() ) ) ;
1703 bool Graph_Impl::IsValid() {
1704 // beginService( "Graph_Impl::IsValid" );
1705 bool RetVal = false ;
1707 RetVal = DataFlowEditor()->IsValid() ;
1709 // endService( "Graph_Impl::IsValid" );
1712 bool Graph_Impl::IsExecutable() {
1713 // beginService( "Graph_Impl::IsExecutable" );
1714 bool RetVal = false ;
1716 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1717 // subgraphs are not executable by themselves, RetVal = false..
1718 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1719 RetVal = DataFlowEditor()->IsExecutable() ;
1721 // endService( "Graph_Impl::IsExecutable" );
1725 bool Graph_Impl::IsEditing() {
1727 bool RetVal = false ;
1729 RetVal = DataFlowEditor()->IsEditing() ;
1735 return !IsExecuting();
1738 bool Graph_Impl::IsExecuting() {
1740 bool RetVal = false ;
1742 RetVal = !DataFlowEditor()->IsEditing() ;
1746 return CNode_Impl::IsExecuting();
1749 bool Graph_Impl::IsReadOnly() {
1750 // beginService( "Graph_Impl::IsExecuting" );
1751 bool RetVal = false ;
1753 RetVal = DataFlowEditor()->IsReadOnly() ;
1755 // endService( "Graph_Impl::IsExecuting" );
1759 CORBA::Long Graph_Impl::LevelMax() {
1760 // beginService( "Graph_Impl::LevelMax" );
1761 CORBA::Long RetVal = 0 ;
1763 RetVal = DataFlowEditor()->LevelMax() ;
1765 // endService( "Graph_Impl::LevelMax" );
1768 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(CORBA::Long aLevel ) {
1769 // beginService( "Graph_Impl::LevelNodes" );
1770 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1773 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1774 // RetVal->length( Nodes->length() );
1775 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1776 // char * aNode = Nodes[ i ] ;
1777 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1778 RetVal = SetNode( RetVal , aNode ) ;
1779 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1780 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1781 // instanceName() , interfaceName() ,
1782 // DataFlowEditor() ,
1783 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1784 // PortableServer::ObjectId * id = myNode->getId() ;
1785 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1786 // SUPERV::CNode_var iobject ;
1787 // iobject = SUPERV::CNode::_narrow(obj) ;
1788 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1791 // endService( "Graph_Impl::LevelNodes" );
1792 return ( RetVal._retn() ) ;
1794 CORBA::Long Graph_Impl::ThreadsMax() {
1795 // beginService( "Graph_Impl::ThreadsMax" );
1796 CORBA::Long RetVal = 0 ;
1798 RetVal = DataFlowEditor()->ThreadsMax() ;
1800 // endService( "Graph_Impl::ThreadsMax" );
1803 CORBA::Long Graph_Impl::Threads() {
1804 // beginService( "Node_Impl::Threads" );
1805 CORBA::Long RetVal = false ;
1807 RetVal = DataFlowExecutor()->Threads() ;
1809 // endService( "Node_Impl::Threads" );
1812 CORBA::Long Graph_Impl::SuspendedThreads() {
1813 // beginService( "Node_Impl::SuspendedThreads" );
1814 CORBA::Long RetVal = false ;
1816 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1818 // endService( "Node_Impl::SuspendedThreads" );
1822 bool Graph_Impl::Begin() {
1823 bool RetVal = false ;
1824 // mkr : IPAL11408 : "Run()" method returns "0" after trying to start graph execution.
1825 // If we call Run() method from Python script two times for one graph, we have to be sure,
1826 // that first execution of this graph ended (i.e. GraphEditor::DataFlow::Editing() method was called).
1827 // Otherwise, the second call of Run() method will return 0. Therefore, we have to waiting for
1828 // the first execution finish.
1829 // NB! From GUI we cann't run dataflow if its previous execution not finished.
1830 while ( !DataFlowEditor()->IsEditing() ) {} // waiting for the previous execution of this graph ended
1831 if ( DataFlowEditor()->IsEditing() ) {
1832 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1833 perror("pthread_mutex_lock _MutexExecutorWait") ;
1836 DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
1837 if ( DataFlowExecutor() ) {
1838 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1839 Editing(); // just in case it was not called before by GUI..
1841 if ( DataFlowEditor()->IsExecutable() ) {
1842 DataFlowEditor()->EditedAfterExecution( false ) ;
1843 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1845 GraphExecutor::DataFlow * aDataFlowExecutor ;
1847 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1848 dbgfile , &aDataFlowExecutor ) ;
1850 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1851 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1855 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1858 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1859 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1867 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1868 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1869 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1870 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1871 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1873 bool Graph_Impl::run( const bool andSuspend ) {
1874 bool RetVal = false ;
1876 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1877 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1879 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1880 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1881 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1885 // Create Executor instance and its datamodel
1889 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1890 DataFlowEditor()->Executing() ;
1891 DataFlowEditor()->EditedAfterExecution( false );
1893 // THE MAIN RUN METHOD
1894 RetVal = DataFlowExecutor()->Run( andSuspend );
1902 * Run() - called on "Execute" command
1904 bool Graph_Impl::Run() {
1905 beginService( "Graph_Impl::Run" );
1906 bool RetVal = run( /*andSuspend=*/false ) ;
1907 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1908 endService( "Graph_Impl::Run" );
1913 * Run() - called on "Execute step-by-step" command
1915 bool Graph_Impl::Start() {
1916 beginService( "Graph_Impl::Start" );
1917 bool RetVal = run( /*andSuspend=*/true ) ;
1918 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1919 endService( "Graph_Impl::Start" );
1923 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1924 SUPERV::GraphEvent & anEvent ,
1925 SUPERV::GraphState & aState ) {
1926 bool RetVal = false ;
1927 char * aNodeName = NULL ;
1928 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1929 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1930 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1931 perror("pthread_mutex_lock _MutexExecutorWait") ;
1934 if ( DataFlowExecutor() && !IsMacro() &&
1935 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1936 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1937 // endService( "Graph_Impl::Event" );
1938 if ( strlen( aNodeName ) ) {
1939 if ( strcmp( aNodeName , Name() ) ) {
1940 aNode = Node( aNodeName ) ;
1947 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1949 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1952 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1954 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1955 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1958 anEvent = theEvent ;
1963 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1964 SUPERV::GraphEvent & anEvent ,
1965 SUPERV::GraphState & aState ) {
1966 // beginService( "Graph_Impl::Event" );
1967 bool RetVal = false ;
1968 char * aNodeName = NULL ;
1969 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1970 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1971 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1972 perror("pthread_mutex_lock _MutexExecutorWait") ;
1975 if ( DataFlowExecutor() && !IsMacro() &&
1976 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1977 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1978 // endService( "Graph_Impl::Event" );
1979 if ( strlen( aNodeName ) ) {
1980 if ( strcmp( aNodeName , Name() ) ) {
1981 aNode = Node( aNodeName ) ;
1988 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1990 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1993 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1995 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1996 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1999 anEvent = theEvent ;
2005 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
2006 SUPERV::GraphEvent & anEvent ,
2007 SUPERV::GraphState & aState ) {
2008 // beginService( "Graph_Impl::EventW" );
2009 bool RetVal = false ;
2010 char * aNodeName = NULL ;
2011 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
2012 SUPERV::GraphState theState = SUPERV::UndefinedState ;
2013 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2014 perror("pthread_mutex_lock _MutexExecutorWait") ;
2017 if ( DataFlowExecutor() && !IsMacro() &&
2018 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
2019 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
2020 if ( RetVal && strcmp( aNodeName , Name() ) ) {
2021 aNode = Node( aNodeName ) ;
2027 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2028 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2031 anEvent = theEvent ;
2033 // endService( "Graph_Impl::EventW" );
2037 CORBA::Long Graph_Impl::EventQSize() {
2038 // beginService( "Graph_Impl::EventQSize" );
2039 CORBA::Long QSize = -1 ;
2040 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2041 perror("pthread_mutex_lock _MutexExecutorWait") ;
2044 if ( DataFlowExecutor() && !IsMacro() ) {
2045 QSize = DataFlowExecutor()->EventQSize() ;
2047 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2048 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2051 // endService( "Graph_Impl::EventQSize" );
2055 CORBA::Long Graph_Impl::LastLevelDone() {
2056 // beginService( "Graph_Impl::LastLevelDone" );
2057 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2058 perror("pthread_mutex_lock _MutexExecutorWait") ;
2061 CORBA::Long RetVal = 0 ;
2062 if ( DataFlowExecutor() && !IsMacro() ) {
2063 RetVal = DataFlowExecutor()->LastLevelDone() ;
2065 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2066 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2069 // endService( "Graph_Impl::LastLevelDone" );
2073 CORBA::Long Graph_Impl::SubGraphsNumber() {
2074 // beginService( "Graph_Impl::SubGraphsNumber" );
2075 CORBA::Long RetVal = 0 ;
2076 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2077 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2079 // endService( "Graph_Impl::SubGraphsNumber" );
2083 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( CORBA::Long aSubGraphNumber ) {
2084 beginService( "Graph_Impl::SubGraphsNodes" );
2085 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2086 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2087 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2090 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2091 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2092 if ( aNode->SubGraph() == aSubGraphNumber ) {
2093 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2097 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2098 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2099 if ( aNode->SubGraph() == aSubGraphNumber ) {
2100 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2104 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2105 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2106 if ( aNode->SubGraph() == aSubGraphNumber ) {
2107 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2111 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2112 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2113 if ( aNode->SubGraph() == aSubGraphNumber ) {
2114 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2118 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2119 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2120 if ( aNode->SubGraph() == aSubGraphNumber ) {
2121 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2125 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2126 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2127 if ( aNode->SubGraph() == aSubGraphNumber ) {
2128 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2132 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2133 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2134 if ( aNode->SubGraph() == aSubGraphNumber ) {
2135 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2139 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2140 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2141 if ( aNode->SubGraph() == aSubGraphNumber ) {
2142 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2146 endService( "Graph_Impl::SubGraphsNodes" );
2147 return ( RetVal._retn() ) ;
2150 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2151 // beginService( "Graph_Impl::Merge" );
2152 bool RetVal = true ;
2154 map< string , int > aMapOfNodes ;
2155 RetVal = Merge( aGraph , aMapOfNodes ) ;
2157 // endService( "Graph_Impl::Merge" );
2161 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2162 beginService( "Graph_Impl::Merge" );
2163 bool RetVal = true ;
2164 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2165 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2167 SUPERV::Port_ptr aPort ;
2168 // SUPERV::StreamPort_ptr aStreamPort ;
2170 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2171 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2172 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2173 if ( !CORBA::is_nil( myNode ) ) {
2174 myNode->SetName( aNode->Name() ) ;
2175 myNode->SetAuthor( aNode->Author() ) ;
2176 myNode->SetComment( aNode->Comment() ) ;
2177 myNode->Coords( aNode->X() , aNode->Y() ) ;
2178 string * aNodetheName = new string( aNode->Name() ) ;
2179 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2180 delete aNodetheName ;
2187 // The following informations are now in the service from SALOME_ModuleCatalog
2188 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2190 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2191 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2192 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2194 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2195 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2201 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2202 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2203 SALOME_ModuleCatalog::ImplType implType = SALOME_ModuleCatalog::SO;
2204 if (!aNode->IsCimpl()) implType = SALOME_ModuleCatalog::PY;
2205 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2206 aNode->GetInterfaceName() ,
2207 *(aNode->Service()) ,
2208 implType ) ; // mkr : PAL11273
2209 if ( !CORBA::is_nil( myNode ) ) {
2210 myNode->SetName( aNode->Name() ) ;
2211 myNode->SetAuthor( aNode->Author() ) ;
2212 myNode->SetComment( aNode->Comment() ) ;
2213 myNode->Coords( aNode->X() , aNode->Y() ) ;
2214 string * aNodetheName = new string( aNode->Name() ) ;
2215 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2216 delete aNodetheName ;
2223 // The following informations are now in the service from SALOME_ModuleCatalog
2224 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2226 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2227 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2228 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2230 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2231 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2238 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2239 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2240 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2241 if ( !CORBA::is_nil( myNode ) ) {
2242 myNode->SetName( aNode->Name() ) ;
2243 myNode->SetAuthor( aNode->Author() ) ;
2244 myNode->SetComment( aNode->Comment() ) ;
2245 myNode->Coords( aNode->X() , aNode->Y() ) ;
2246 string * aNodetheName = new string( aNode->Name() ) ;
2247 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2248 delete aNodetheName ;
2249 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2251 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2252 if ( myPorts[ j ]->IsInput() ) {
2253 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2256 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2259 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2260 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2261 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2262 if ( myStreamPorts[ j ]->IsInput() ) {
2263 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2266 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2280 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2281 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2282 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2283 if ( !CORBA::is_nil( myNode ) ) {
2284 myNode->SetName( aNode->Name() ) ;
2285 myNode->SetAuthor( aNode->Author() ) ;
2286 myNode->SetComment( aNode->Comment() ) ;
2287 myNode->Coords( aNode->X() , aNode->Y() ) ;
2288 string * aNodetheName = new string( aNode->Name() ) ;
2289 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2290 delete aNodetheName ;
2291 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2293 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2294 if ( myPorts[ j ]->IsInput() ) {
2295 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2298 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2301 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2302 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2303 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2304 if ( myStreamPorts[ j ]->IsInput() ) {
2305 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2308 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2322 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2323 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2324 SUPERV::INode_ptr anEndOfLoop ;
2325 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2326 *(aNode->PyInit()) ,
2327 aNode->PyMoreName() ,
2328 *(aNode->PyMore()) ,
2329 aNode->PyNextName() ,
2330 *(aNode->PyNext()) ,
2332 if ( !CORBA::is_nil( myNode ) ) {
2333 myNode->SetName( aNode->Name() ) ;
2334 myNode->SetAuthor( aNode->Author() ) ;
2335 myNode->SetComment( aNode->Comment() ) ;
2336 myNode->Coords( aNode->X() , aNode->Y() ) ;
2337 string * aNodetheName = new string( aNode->Name() ) ;
2338 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2339 delete aNodetheName ;
2340 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2342 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2343 if ( myPorts[ j ]->IsInput() ) {
2344 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2347 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2350 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2351 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2352 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2353 if ( myStreamPorts[ j ]->IsInput() ) {
2354 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2357 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2361 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2362 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2363 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2364 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2365 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2366 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2367 aNodetheName = new string( myEndOfLoop->Name() ) ;
2368 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2369 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2370 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2371 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2372 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2373 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
2376 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
2380 delete aNodetheName ;
2391 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2392 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2393 SUPERV::INode_ptr anEndOfSwitch ;
2394 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2395 if ( !CORBA::is_nil( myNode ) ) {
2396 myNode->SetName( aNode->Name() ) ;
2397 myNode->SetAuthor( aNode->Author() ) ;
2398 myNode->SetComment( aNode->Comment() ) ;
2399 myNode->Coords( aNode->X() , aNode->Y() ) ;
2400 string * aNodetheName = new string( aNode->Name() ) ;
2401 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2402 delete aNodetheName ;
2403 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2405 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2406 if ( myPorts[ j ]->IsInput() ) {
2407 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2410 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2413 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2414 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2415 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2416 if ( myStreamPorts[ j ]->IsInput() ) {
2417 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2420 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2424 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2425 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2426 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2427 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2428 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2429 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2430 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2431 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2432 delete aNodetheName ;
2433 myPorts = *(myEndOfSwitch->Ports()) ;
2434 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2435 if ( myPorts[ j ]->IsInput() ) {
2436 aPort = anEndOfSwitch->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2439 aPort = anEndOfSwitch->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2442 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2443 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2444 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2445 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2446 aPort = anEndOfSwitch->InStreamPort( myStreamSwitchPorts[ j ]->Name(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2449 aPort = anEndOfSwitch->OutStreamPort( myStreamSwitchPorts[ j ]->Name(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2462 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2463 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2464 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2466 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2467 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2468 SUPERV::Port_var OutPort = aLink->OutPort() ;
2469 SUPERV::Port_var InPort = aLink->InPort() ;
2470 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2471 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2472 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2474 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2478 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2480 RetVal = aLink->Coords( j , X , Y ) ;
2483 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2485 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2493 delete aLinkFromNodeName ;
2494 delete aLinkToNodeName ;
2500 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2501 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2502 if ( !aPort->IsGate() ) {
2503 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2504 char * aPortName = aPort->Name() ;
2505 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2506 strcpy( aNodeName , aPortName ) ;
2507 // char * thePortName = strchr( aNodeName , '\\' ) ;
2508 char * thePortName = aNodeName ;
2509 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2510 if ( thePortName[1] == '_' ) {
2511 thePortName[ 0 ] = '\0' ;
2515 thePortName = &thePortName[2] ;
2518 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2519 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2520 // << " HasInput " << hasinput << endl ;
2522 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2524 *(aPort->ToAny()) ) ;
2526 delete [] aNodeName ;
2535 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2536 endService( "Graph_Impl::Merge" );
2540 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2541 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2542 beginService( "Graph_Impl::ToStreamGraph" );
2543 if ( IsStreamGraph() && !IsMacro() ) {
2544 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2545 // instanceName() , interfaceName() ) ;
2546 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2547 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2548 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2549 if ( CORBA::is_nil( iobject ) ) {
2550 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2554 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2556 endService( "Graph_Impl::ToStreamGraph" );
2557 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2561 * Destroy Executor and use only Editor and its data model
2563 void Graph_Impl::Editing() {
2564 if ( DataFlowEditor() && DataFlowExecutor() ) {
2565 delete DataFlowExecutor() ;
2566 DataFlowEditor()->Executor( NULL );
2571 * Returns the default name of container for C component
2573 char* Graph_Impl::DefaultCContainerName() {
2574 return ( CORBA::string_dup( FACTORYSERVER ) );
2578 * Returns the default name of container for Python component
2580 char* Graph_Impl::DefaultPythonContainerName() {
2581 return ( CORBA::string_dup( FACTORYSERVERPY ) );
2585 * Returns the last container name associated with theComponentName component
2587 char* Graph_Impl::ContainerNameForComponent( const char * theComponentName ) {
2588 const char* aContainer = DataFlowEditor()->Graph()->RetrieveFromMapOfComponentNameContainer(theComponentName);
2590 return my_strdup(aContainer);