1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
23 // File : Graph_Impl.cxx
24 // Author : Jean Rahuel
34 //#include "utilities.h"
36 #include "SALOME_Container_i.hxx"
38 #include "StreamGraph_Impl.hxx"
40 #include "DataFlowEditor_DataFlow.hxx"
42 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
44 static void CreateEditor( CORBA::ORB_ptr orb ,
45 const char *instanceName ,
46 const char *aDataFlowName ,
47 const SUPERV::KindOfNode aKindOfNode ,
49 GraphEditor::DataFlow ** aDataFlowEditor ) {
50 bool aXmlFile = false ;
51 int lenname = strlen( aDataFlowName ) ;
52 char * theDataFlowName = new char [ lenname+1 ] ;
53 strcpy( theDataFlowName , aDataFlowName ) ;
54 if ( aDataFlowName ) {
55 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
56 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
57 theDataFlowName[ lenname-4 ] = '\0' ;
60 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
61 if ( aDataFlowName[ i ] == '/' ) {
62 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
63 theDataFlowName[ lenname-5-i ] = '\0' ;
69 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
73 string theDataFlowInstanceName = theDataFlowName ;
75 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
76 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
77 dbgfile = "/tmp/logs/" ;
78 dbgfile += getenv( "USER" ) ;
80 dbgfile += instanceName ;
82 dbgfile += theDataFlowInstanceName ;
83 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
84 FILE* f = fopen ( dbgfile.c_str(), "a" );
85 if ( f ) { // check if file can be opened for writing
88 else { // if file can't be opened - use a guaranteed temp file name
89 char* aTempNam = tempnam( NULL, NULL );
94 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
95 *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
96 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
98 MESSAGE( "CreateEditor " << theDataFlowName << " uniquely named " << theDataFlowInstanceName << " created with "
99 << dbgfile.c_str() ) ;
101 delete [] theDataFlowName ;
104 static void CreateExecutor( CORBA::ORB_ptr orb ,
105 const char *instanceName ,
106 const char *aDataFlowName ,
107 const SUPERV::KindOfNode aKindOfNode ,
109 GraphExecutor::DataFlow ** aDataFlowExecutor ) {
110 int lenname = strlen( aDataFlowName ) ;
111 char * theDataFlowName = new char [ lenname+1 ] ;
112 strcpy( theDataFlowName , aDataFlowName ) ;
113 if ( aDataFlowName ) {
114 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
117 string theDataFlowInstanceName = theDataFlowName ;
119 // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir.
120 // "/tmp/logs/$USER" was created by runSalome.py -> orbmodule.py.
121 dbgfile = "/tmp/logs/" ;
122 dbgfile += getenv( "USER" ) ;
124 dbgfile += instanceName ;
126 dbgfile += theDataFlowInstanceName ;
127 dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
129 astr << theAutomaton->ExecNumber() ;
130 dbgfile += astr.str() ;
131 dbgfile += string( "_Exec.log" ) ;
132 FILE* f = fopen ( dbgfile.c_str(), "a" );
133 if ( f ) { // check if file can be opened for writing
136 else { // if file can't be opened - use a guaranteed temp file name
137 char* aTempNam = tempnam( NULL, NULL );
142 SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
143 *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
144 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
147 MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
148 << dbgfile.c_str() ) ;
150 delete [] theDataFlowName ;
153 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
154 PortableServer::POA_ptr poa ,
155 PortableServer::ObjectId * contId ,
156 const char *instanceName ,
157 const char *interfaceName ,
158 const char *aDataFlowName ,
159 const SUPERV::KindOfNode aKindOfNode ) :
160 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName , aKindOfNode ) {
161 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
162 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
163 // << hex << (void *) this << dec )
164 // beginService( "Graph_Impl::Graph_Impl" );
165 _Orb = CORBA::ORB::_duplicate(orb);
168 _DebugFileName = NULL ;
169 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::MacroNode ) {
170 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
172 _id = _poa->activate_object(_thisObj);
175 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
178 if ( aKindOfNode == SUPERV::DataFlowGraph || aKindOfNode == SUPERV::DataStreamGraph ) {
180 GraphEditor::DataFlow * aDataFlowEditor ;
181 CreateEditor( orb , instanceName , aDataFlowName , aKindOfNode ,
182 dbgfile , &aDataFlowEditor ) ;
184 if ( _DebugFileName ) {
185 delete [] _DebugFileName ;
187 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
188 strcpy( _DebugFileName , dbgfile.c_str() ) ;
190 _NamingService = new SALOME_NamingService( orb ) ;
191 DataFlowEditor( aDataFlowEditor ) ;
192 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
193 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
195 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
196 // DataFlowExecutor( NULL ) ;
197 // endService( "Graph_Impl::Graph_Impl" );
200 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
201 PortableServer::POA_ptr poa ,
202 PortableServer::ObjectId * contId ,
203 const char *instanceName ,
204 const char *interfaceName ,
205 GraphEditor::DataFlow * aDataFlowEditor ,
206 GraphEditor::InNode * aDataFlowNode ) :
207 GNode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowEditor , aDataFlowNode ) {
208 // beginService( "Graph_Impl::Graph_Impl" );
209 // MESSAGE( aDataFlowEditor->Graph()->Name() << " " );
210 if ( aDataFlowEditor->Graph()->IsDataFlowNode() ||
211 ( aDataFlowNode && aDataFlowNode->IsMacroNode() ) ) {
212 // MESSAGE( "Graph_Impl::Graph_Impl _poa->activate_object" );
214 _id = _poa->activate_object(_thisObj);
217 // MESSAGE( "Graph_Impl::Graph_Impl NO _poa->activate_object " );
219 _Orb = CORBA::ORB::_duplicate(orb);
222 _DebugFileName = NULL ;
223 DataFlowEditor( aDataFlowEditor ) ;
224 DataFlowEditor()->Graph()->GraphEditor( aDataFlowEditor ) ;
225 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
226 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
227 // DataFlowExecutor( NULL ) ;
228 // endService( "Graph_Impl::Graph_Impl" );
231 Graph_Impl::Graph_Impl() {
234 Graph_Impl::~Graph_Impl() {
235 beginService( "Graph_Impl::~Graph_Impl" );
236 endService( "Graph_Impl::~Graph_Impl" );
239 void Graph_Impl::destroy() {
240 beginService( "Graph_Impl::destroy" );
241 if ( DataFlowNode() && DataFlowNode()->ComputingNode()->IsMacroNode() ) {
242 SUPERV::Graph_var aGraph = DataFlowNode()->GOTONode()->MacroObject() ;
243 GNode_Impl::Delete() ;
244 if ( !CORBA::is_nil( aGraph ) ) {
249 SUPERV::Graph_var aGraph = DataFlowEditor()->Graph()->MacroObject() ;
250 GNode_Impl::Delete() ;
251 if ( !CORBA::is_nil( aGraph ) ) {
255 _poa->deactivate_object(*_id) ;
256 // CORBA::release(_poa) ;
258 // _thisObj->_remove_ref();
259 endService( "Graph_Impl::destroy" );
263 char* Graph_Impl::getIOR() {
265 return CORBA::string_dup( NULLSTRING ) ;
267 else if ( CORBA::is_nil( myServant ) ) {
268 PortableServer::ObjectId* id = getId();
269 CORBA::Object_var obj;
270 obj = _poa->id_to_reference(*id);
271 myServant = SUPERV::Graph::_narrow(obj);
273 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
276 SUPERV::Graph_ptr Graph_Impl::Copy() {
277 beginService( "Graph_Impl::Copy" );
278 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
280 Graph_Impl * myGraph ;
281 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
282 instanceName() , interfaceName() ,
283 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
284 PortableServer::ObjectId * id = myGraph->getId() ;
285 CORBA::Object_var obj = _poa->id_to_reference(*id);
286 iobject = SUPERV::Graph::_narrow(obj) ;
287 GraphBase::ListOfSGraphs * aListOfSGraphs = GetGraphs() ;
288 myGraph->LoadGraphs( aListOfSGraphs ) ;
290 endService( "Graph_Impl::Copy" );
291 return SUPERV::Graph::_duplicate(iobject) ;
294 void Graph_Impl::ReadOnly() {
295 DataFlowEditor()->ReadOnly() ;
298 SUPERV::INode_ptr Graph_Impl::Node() {
299 // beginService( "Graph_Impl::Node" );
300 PortableServer::ObjectId * id = getId() ;
301 CORBA::Object_var obj = _poa->id_to_reference(*id);
302 SUPERV::Graph_var iobject ;
303 iobject = SUPERV::Graph::_narrow(obj) ;
304 // endService( "Graph_Impl::Node" );
305 return SUPERV::Graph::_duplicate(iobject) ;
308 GraphBase::ListOfSGraphs * Graph_Impl::GetGraphs() {
309 return DataFlowEditor()->GetDataFlows() ;
312 bool Graph_Impl::LoadGraphs( GraphBase::ListOfSGraphs * aListOfDataFlows ) {
313 beginService( "Graph_Impl::LoadGraphs" );
314 bool RetVal = false ;
315 if ( DataFlowEditor()->IsEditing() ) {
316 // RetVal = DataFlowEditor()->LoadDataFlows( aListOfDataFlows ) ;
317 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , aListOfDataFlows , 0 ) ) ) {
321 endService( "Graph_Impl::LoadGraphs" );
325 bool Graph_Impl::Import(const char * aXmlFile ) {
326 beginService( "Graph_Impl::Import" );
327 bool RetVal = false ;
328 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
329 GraphBase::ListOfSGraphs aListOfDataFlows ;
330 RetVal = DataFlowEditor()->LoadXml( aXmlFile , aListOfDataFlows ) ;
331 if ( RetVal && aXmlFile != NULL ) {
332 // RetVal = DataFlowEditor()->LoadDataFlows( &aListOfDataFlows ) ;
333 if ( CORBA::is_nil( LoadDataFlows( DataFlowEditor() , &aListOfDataFlows , 0 ) ) ) {
338 endService( "Graph_Impl::Import" );
342 bool Graph_Impl::Export(const char * anXmlFile ) {
343 beginService( "Graph_Impl::Export" );
344 bool RetVal = false ;
346 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
347 strcpy( aFile , anXmlFile ) ;
348 int len = strlen( aFile ) ;
349 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
351 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
352 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
353 len = strlen( aFile ) ;
356 strcat( aFile , ".xml" ) ;
357 len = strlen( aFile ) ;
359 RetVal = DataFlowEditor()->SaveXml( aFile ) ;
361 strcpy( &aFile[ len - 4 ] , ".py" ) ;
362 RetVal = DataFlowEditor()->SavePy( aFile ) ;
366 endService( "Graph_Impl::Export" );
370 char * Graph_Impl::SavePY( bool importSuperV ) {
371 beginService( "Graph_Impl::SavePY" );
372 ostringstream fstring ;
374 RetVal = DataFlowEditor()->SavePY( fstring , importSuperV ) ;
376 endService( "Graph_Impl::SavePY" );
377 return CORBA::string_dup( fstring.str().c_str() );
379 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
380 beginService( "Graph_Impl::CNode" );
381 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
382 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
383 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
384 instanceName() , interfaceName() ,
386 NodeService , NULLSTRING ,
387 SUPERV::ComputingNode , NULLSTRING ) ;
388 if ( myNode->DataFlowNode() ) {
389 PortableServer::ObjectId * id = myNode->getId() ;
390 CORBA::Object_var obj = _poa->id_to_reference(*id);
391 iobject = SUPERV::CNode::_narrow(obj) ;
392 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
395 DataFlowEditor()->UnValid() ;
396 endService( "Graph_Impl::CNode" );
397 return SUPERV::CNode::_duplicate( iobject ) ;
400 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
401 const char * NodeInterfaceName ,
402 const SALOME_ModuleCatalog::Service &NodeService ,
403 const SALOME_ModuleCatalog::ImplType ImplType ) {
404 beginService( "Graph_Impl::FNode" );
405 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
409 case SALOME_ModuleCatalog::PY:
412 case SALOME_ModuleCatalog::SO:
413 case SALOME_ModuleCatalog::EXE:
417 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
418 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
419 instanceName() , interfaceName() ,
425 SUPERV::FactoryNode ,
427 if ( myNode->DataFlowNode() ) {
428 PortableServer::ObjectId * id = myNode->getId() ;
429 CORBA::Object_var obj = _poa->id_to_reference(*id);
430 iobject = SUPERV::FNode::_narrow(obj) ;
431 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
434 DataFlowEditor()->UnValid() ;
435 endService( "Graph_Impl::FNode" );
436 return SUPERV::FNode::_duplicate( iobject ) ;
439 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
440 const SUPERV::ListOfStrings & PythonFuntion ) {
441 beginService( "Graph_Impl::INode" );
442 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
443 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
444 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
445 instanceName() , interfaceName() ,
447 FuncName , PythonFuntion ,
448 SUPERV::InLineNode ) ;
449 if ( myNode->DataFlowNode() ) {
450 PortableServer::ObjectId * id = myNode->getId() ;
451 CORBA::Object_var obj = _poa->id_to_reference(*id);
452 iobject = SUPERV::INode::_narrow(obj) ;
453 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
456 endService( "Graph_Impl::INode" );
457 return SUPERV::INode::_duplicate( iobject ) ;
461 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
462 const SUPERV::ListOfStrings & PythonFuntion ,
463 const char * anInLineNode ) {
464 beginService( "Graph_Impl::GNode" );
465 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
466 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
467 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
468 instanceName() , interfaceName() ,
470 FuncName , PythonFuntion ,
472 if ( myNode->DataFlowNode() ) {
473 PortableServer::ObjectId * id = myNode->getId() ;
474 CORBA::Object_var obj = _poa->id_to_reference(*id);
475 iobject = SUPERV::GNode::_narrow(obj) ;
476 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
477 if ( strlen( anInLineNode ) ) {
478 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
479 if ( anInLineNode ) {
480 myNode->SetCoupled( anInLineNode ) ;
481 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
486 DataFlowEditor()->UnValid() ;
487 endService( "Graph_Impl::GNode" );
488 return SUPERV::GNode::_duplicate( iobject ) ;
491 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
492 const SUPERV::ListOfStrings & InitFunction ,
493 const char * MoreName ,
494 const SUPERV::ListOfStrings & MoreFunction ,
495 const char * NextName ,
496 const SUPERV::ListOfStrings & NextFunction ,
497 SUPERV::INode_out anEndOfLoop ) {
498 beginService( "Graph_Impl::LNode" );
499 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
500 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
501 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
502 GraphBase::ListOfFuncName FuncNameList ;
503 FuncNameList.resize(3) ;
504 FuncNameList[0] = InitName ;
505 FuncNameList[1] = MoreName ;
506 FuncNameList[2] = NextName ;
507 GraphBase::ListOfPythonFunctions PythonFunctionList ;
508 PythonFunctionList.resize(3) ;
509 PythonFunctionList[0] = &InitFunction ;
510 PythonFunctionList[1] = &MoreFunction ;
511 PythonFunctionList[2] = &NextFunction ;
512 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
513 instanceName() , interfaceName() ,
515 FuncNameList , PythonFunctionList ,
516 // InitName , InitFunction ,
517 // MoreName , MoreFunction ,
518 // NextName , NextFunction ,
520 if ( myNode->DataFlowNode() ) {
521 PortableServer::ObjectId * id = myNode->getId() ;
522 CORBA::Object_var obj = _poa->id_to_reference(*id);
523 iobject = SUPERV::LNode::_narrow(obj) ;
524 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
526 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
528 if ( strlen( InitName ) ) {
529 anEndName = new char[ 3 + strlen( InitName ) + 1 ];
530 strcpy( anEndName , "End" ) ;
531 strcat( anEndName , InitName ) ;
534 anEndName = new char[ 3 + strlen( "Loop" ) + 1 ];
535 strcpy( anEndName , "EndLoop" ) ;
537 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
538 instanceName() , interfaceName() ,
541 SUPERV::EndLoopNode ) ;
542 PortableServer::ObjectId * endid = myEndNode->getId() ;
543 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
544 iendobject = SUPERV::ELNode::_narrow(endobj) ;
545 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
546 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
547 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
548 //JR 25.01.2005 That links are already done in SetCoupled above ...
549 // Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
550 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
551 // Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ;
554 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
555 DataFlowEditor()->UnValid() ;
556 endService( "Graph_Impl::LNode" );
557 return SUPERV::LNode::_duplicate( iobject ) ;
560 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
561 const SUPERV::ListOfStrings & PythonFunction ,
562 SUPERV::INode_out anEndOfSwitch ) {
563 beginService( "Graph_Impl::SNode" );
564 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
565 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
566 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && !IsMacro() ) {
567 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
568 instanceName() , interfaceName() ,
570 FuncName , PythonFunction ,
571 SUPERV::SwitchNode ) ;
572 if ( myNode->DataFlowNode() ) {
573 PortableServer::ObjectId * id = myNode->getId() ;
574 CORBA::Object_var obj = _poa->id_to_reference(*id);
575 iobject = SUPERV::SNode::_narrow(obj) ;
576 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
578 string anEndName = "End" ;
579 if ( strlen( FuncName ) ) {
580 anEndName += FuncName ;
583 anEndName += "Switch" ;
585 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
586 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
587 // << anEndName.c_str() << endl ;
588 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
589 instanceName() , interfaceName() ,
592 SUPERV::EndSwitchNode ) ;
593 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
594 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
595 // << " " << anEndName.c_str() << endl ;
596 PortableServer::ObjectId * endid = myEndNode->getId() ;
597 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
598 iendobject = SUPERV::ESNode::_narrow(endobj) ;
599 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
600 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
601 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
602 //JR NPAL14793 05.02.2007 : do not add that link
603 // if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
604 // iobject = SUPERV::SNode::_nil() ;
605 // iendobject = SUPERV::ESNode::_nil() ;
609 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
610 DataFlowEditor()->UnValid() ;
611 endService( "Graph_Impl::SNode" );
612 return SUPERV::SNode::_duplicate( iobject ) ;
615 // WARNING : THIS IS COMPLICATED :
616 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphEditor::DataFlow * aDataFlowEditor ,
617 GraphBase::ListOfSGraphs * aListOfDataFlows ,
619 beginService( "Graph_Impl::EditorLoadDataFlows" ) ;
620 MESSAGE("Graph_Impl::LoadDataFlows index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
622 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
623 // That method is recursive :
624 // At first we load the supergraph with index = 0 :
625 // (After we load the graph corresponding to each MacroNode :)
626 if ( !aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
627 MESSAGE("Graph_Impl::LoadDataFlows failed " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
628 return SUPERV::Graph::_duplicate( iobject ) ;
630 // That graph is not a StreamGraph :
631 else if ( !aDataFlowEditor->Graph()->HasDataStream() ) {
632 aDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
633 // aDataFlowEditor->Graph()->SetGraphEditor( aDataFlowEditor ) ;
634 Graph_Impl * myGraph ;
635 // We create a Graph ObjRef for that graph
636 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
637 instanceName() , interfaceName() ,
638 aDataFlowEditor , NULL ) ;
639 PortableServer::ObjectId * id = myGraph->getId() ;
640 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
641 iobject = SUPERV::Graph::_narrow( obj ) ;
642 myGraph->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
643 myGraph->SetObjImpl( (CNode_Impl * ) myGraph ) ;
644 GraphBase::Graph * aGraph = myGraph->DataFlowEditor()->Graph() ;
647 // asv: set Editor for the graph itself and for all its macro nodes
648 aGraph->GraphEditor( aDataFlowEditor );
650 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
651 for ( i = 0 ; i < aGraph->GraphNodesSize() ; i++ ) {
652 if ( aGraph->GraphNodes( i )->IsMacroNode() ) {
653 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) aGraph->GraphNodes( i ) ;
655 // asv : 05.11.04 : fix of bug - "insert file" into existing graph with MacroNodes worked incorrectly!
656 // aMacroNode is an "old" node, and here we must analize only "new" nodes, that
657 // came from aListOfDataFlows and were loaded by aDataFlowEditor->LoadDataFlow( &(*aListOfDataFlows)[ index ] )
658 // so here we check if the node is "new" or "old"
659 if ( aMacroNode->GraphEditor() && aMacroNode->CoupledNode() )
662 // asv: set Editor for the graph itself and for all its macro nodes
663 aMacroNode->GraphEditor( aDataFlowEditor );
665 // Creation of a GraphMacroNode ObjRef in the current editor
666 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
667 Graph_Impl * myMacroNode ;
668 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
669 instanceName() , interfaceName() ,
670 aMacroNode->Name() , SUPERV::MacroNode ) ;
671 id = myMacroNode->getId() ;
672 obj = _poa->id_to_reference(*id);
673 macroiobject = SUPERV::Graph::_narrow( obj ) ;
674 myMacroNode->DataFlowEditor( aDataFlowEditor ) ;
675 GraphEditor::InNode * aDataFlowNode = (GraphEditor::InNode * ) aMacroNode->GetInNode() ;
676 myMacroNode->DataFlowNode( aDataFlowNode ) ;
677 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
678 aDataFlowNode->SetObjImpl( myMacroNode ) ;
680 char * aCoupledNodeName = aMacroNode->CoupledNodeName() ;
681 MESSAGE( "LoadDataFlows MacroNode " << aMacroNode->Name() << " --> " << aCoupledNodeName
682 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" ) ;
685 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() ; index++ ) {
686 MESSAGE( "LoadDataFlows Graph" << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() ) ;
687 if ( !strcmp( aCoupledNodeName , (*aListOfDataFlows)[index].Info.theName.c_str() ) ) {
690 // At first create the editor and a StreamGraph
691 GraphEditor::DataFlow * aMacroGraphDataFlowEditor ;
692 CreateEditor( _Orb , instanceName() , aCoupledNodeName , SUPERV::DataStreamGraph ,
693 dbgfile , &aMacroGraphDataFlowEditor ) ;
695 if ( _DebugFileName ) {
696 delete [] _DebugFileName ;
698 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
699 strcpy( _DebugFileName , dbgfile.c_str() ) ;
701 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES :" << aCoupledNodeName ) ;
702 if ( CORBA::is_nil( LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , index ) ) ) {
703 MESSAGE("Graph_Impl::LoadDataFlows failed" ) ;
704 return SUPERV::Graph::_duplicate( iobject ) ;
707 // That graph is not a StreamGraph :
708 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
709 Graph_Impl * myMacroGraph ;
710 // The Graph ObjRef for that graph was already created
711 myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
713 GraphBase::Graph * aMacroGraph = myMacroGraph->DataFlowEditor()->Graph() ;
715 aMacroGraph->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
716 aMacroGraph->CoupledNode( aMacroNode ) ;
717 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
719 // Set the GraphMacroNode ObjRef in the MacroNode
720 aMacroNode->GraphMacroLevel( aGraph->GraphMacroLevel() + 1 ) ;
721 aMacroNode->CoupledNode( aMacroGraph ) ;
722 aMacroNode->MacroObject( SUPERV::Graph::_narrow( aMacroGraphDataFlowEditor->Graph()->ObjRef() ) ) ;
723 MESSAGE( "LoadDataFlows aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
724 << " coupled to " << aMacroGraph->CoupledNode() << " "
725 << aMacroGraph->CoupledNode()->Name() << " Editor " << aMacroGraph->GraphEditor() ) ;
726 MESSAGE( "LoadDataFlows aMacroNode " << aMacroNode << " " << aMacroNode->Name()
727 << " coupled to " << aMacroNode->CoupledNode() << " "
728 << aMacroNode->CoupledNode()->Name() << " Editor " << aMacroNode->GraphEditor() ) ;
729 MESSAGE( "LoadDataFlows current Graph " << aGraph << " " << aGraph->Name()
730 << " coupled to " << aGraph->CoupledNode()
731 << " Editor " << aGraph->GraphEditor() << " " << aGraph->Name() ) ;
737 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
742 else if ( (*aListOfDataFlows).size() == 1 ) {
743 StreamGraph_Impl * myStreamGraph ;
744 // We create a Graph ObjRef for that graph
745 myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId,
746 instanceName() , interfaceName() ,
747 aDataFlowEditor , NULL ) ;
748 PortableServer::ObjectId * id = myStreamGraph->getId() ;
749 CORBA::Object_var obj = _poa->id_to_reference(*id) ;
750 SUPERV::StreamGraph_var Streamiobject = SUPERV::StreamGraph::_nil() ;
751 Streamiobject = SUPERV::StreamGraph::_narrow( obj ) ;
752 myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( Streamiobject ) ) ;
753 myStreamGraph->SetObjImpl( (CNode_Impl * ) myStreamGraph ) ;
754 // iobject = SUPERV::Graph::_narrow( obj ) ;
755 iobject = SUPERV::Graph::_narrow( Streamiobject ) ;
758 MESSAGE( "Graph_Impl::LoadDataFlows StreamGraph with MacroNodes not yet implemented" ) ;
761 endService( "Graph_Impl::EditorLoadDataFlows" );
762 return SUPERV::Graph::_duplicate( iobject ) ;
765 SUPERV::Graph_var Graph_Impl::LoadDataFlows( GraphExecutor::DataFlow * aDataFlowExecutor ,
766 GraphBase::ListOfSGraphs * aListOfDataFlows ,
768 beginService( "Graph_Impl::ExecutorLoadDataFlows" ) ;
769 MESSAGE("Graph_Impl::LoadDataFlows(Executor) index " << index << " " << (*aListOfDataFlows)[index].Info.theName.c_str() << " aDataFlowExecutor " << aDataFlowExecutor ) ;
771 // That method is recursive :
772 // At first we load the supergraph with index = 0 :
773 // (After we load the graph corresponding to each MacroNode :)
774 if ( !aDataFlowExecutor->LoadDataFlow( &(*aListOfDataFlows)[ index ] ) ) {
775 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow(supergraph)" ) ;
776 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
779 // That graph is not a StreamGraph :
781 aDataFlowExecutor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
782 GraphEditor::DataFlow * aDataFlowEditor ;
783 aDataFlowEditor = DataFlowEditor() ;
784 GraphBase::Graph * anEditorGraph = aDataFlowEditor->Graph() ;
785 GraphBase::Graph * anExecutorGraph = aDataFlowExecutor->Graph() ;
786 if ( aDataFlowEditor->Executor() ) {
787 delete aDataFlowEditor->Executor() ;
788 aDataFlowEditor->Executor( NULL ) ;
789 aDataFlowEditor->Editing() ;
791 aDataFlowEditor->Executor( aDataFlowExecutor ) ;
792 anExecutorGraph->GraphEditor( aDataFlowEditor ) ;
794 if ( !aDataFlowExecutor->Graph()->HasDataStream() ) {
795 // For the supergraph or each graph of MacroNodes we search MacroNodes recursively :
797 for ( i = 0 ; i < anExecutorGraph->GraphNodesSize() ; i++ ) {
798 if ( anExecutorGraph->GraphNodes( i )->IsMacroNode() ) {
799 GraphBase::GOTONode * aMacroNode = (GraphBase::GOTONode * ) anExecutorGraph->GraphNodes( i ) ;
800 aMacroNode->GraphEditor( aDataFlowEditor ) ;
802 // get the macro node's editor object
803 char * aMacroGraphName = aMacroNode->CoupledNodeName() ;
804 GraphBase::Graph* aMacroGraph = (GraphBase::Graph*)((GraphBase::GOTONode *)anEditorGraph->GetGraphNode( aMacroNode->Name() ))->CoupledNode() ;
805 GraphEditor::DataFlow* aMacroGraphEditor = aMacroGraph->GraphEditor();
807 MESSAGE( "LoadDataFlows(Executor) MacroNode " << aMacroNode->Name() << " Coupled to " << aMacroGraphName
808 << " to be searched among " << (*aListOfDataFlows).size() << " Graphs" << endl ) ;
811 for ( index = 0 ; index < (int ) (*aListOfDataFlows).size() && !found; index++ ) {
812 if ( !strcmp( aMacroGraphName , (*aListOfDataFlows)[index].Info.theName.c_str() ) )
816 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, Macro node's coupled graph \"" << aMacroGraphName << "\" was not found" ) ;
817 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
819 index--; // it was incremented in "for ..." before last check ( !found ).
821 // At first create the editor and a StreamGraph
823 GraphExecutor::DataFlow * aMacroGraphExecutor ;
824 CreateExecutor( _Orb , instanceName() , aMacroGraphName , SUPERV::DataStreamGraph ,
825 dbgfile , &aMacroGraphExecutor );
826 theAutomaton->Executed() ; // Decrement _GraphExecutingNumber for MacroSubGraph
828 // set GraphMacroLevel for Executor's graph
829 GraphBase::Graph* aMacroGraphExe = aMacroGraphExecutor->Graph();
830 aMacroGraphExe->GraphMacroLevel( anExecutorGraph->GraphMacroLevel() + 1 );
832 // load data flows in MacroGraph's executor
833 Graph_Impl* aMacroGraphImpl = (Graph_Impl*) aMacroGraphEditor->Graph()->ObjImpl();
834 MESSAGE( "RECURSIVE IMPORT OF GRAPHS OF MACRONODES : " << aMacroGraphName ) ;
835 if ( CORBA::is_nil( aMacroGraphImpl->LoadDataFlows( aMacroGraphExecutor, aListOfDataFlows , index ) ) ) {
836 MESSAGE("Graph_Impl::LoadDataFlows(Executor) failed, could not LoadDataFlow( MacroNodeGraph \"" <<aMacroGraphName << "\" )" ) ;
837 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
840 // set coupled pair MacroNode <--> MacroGraph
841 aMacroGraphExe->CoupledNode( aMacroNode ) ;
842 aMacroNode->CoupledNode( aMacroGraphExe ) ;
844 //JR 04.05.2005 Debug : InPorts values of MacroNodes are like for other nodes
845 // InPorts values of MacroGraphs of MacroNodes are done in the Executor
846 // It was probably to try to debug anything but it was a wrong debug and I do not know what bug
847 // ===> folowing code is commented
849 // initialize MacroNode's InPorts with corresponding "external" values
851 for ( q = 0 ; q < aMacroNode->GetNodeInPortsSize() ; q++ ) {
852 const GraphBase::InPort * anInPort = aMacroNode->GetNodeInPort( q ) ;
853 if ( anInPort->IsDataConnected() ) {
854 const char* aMacroGraphInPortName = aMacroGraph->GetNodeInPort( q )->PortName();
855 //JR 30.03.2005 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, *anInPort->GetOutPort()->Value(),false ) ) {
856 if ( !aMacroGraphExecutor->InputOfAny( aMacroGraphInPortName, anInPort->GetOutPort()->Value(),false ) ) {
857 return SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
860 MESSAGE( "LoadDataFlows(Executor) " << aMacroGraph->Name() << "->InputOfAny( "
861 << aMacroGraphInPortName << " , Value )" ) ;
864 } // end of init MacroNode's InPorts
866 aMacroGraphImpl->Run() ;
869 } // end of for( get nodes of the graph...)
871 } // end of setting initial graph's structure..
873 endService( "Graph_Impl::ExecutorLoadDataFlows" );
875 PortableServer::ObjectId * id = getId();
876 CORBA::Object_var obj = _poa->id_to_reference( *id );
877 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow( obj ) ;
878 return SUPERV::Graph::_duplicate( iobject ) ;
881 SUPERV::Graph_ptr Graph_Impl::MNode( const char * aXmlFileName ) {
882 beginService( "Graph_Impl::MNode" );
883 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
884 MESSAGE( "Graph_Impl::MNode( " << aXmlFileName << " )" ) ;
886 GraphBase::ListOfSGraphs aListOfDataFlows ;
888 // At first create the editor and a StreamGraph with the xml file
889 GraphEditor::DataFlow * aDataFlowEditor ;
890 CreateEditor( _Orb , instanceName() , aXmlFileName , SUPERV::DataStreamGraph ,
891 dbgfile , &aDataFlowEditor ) ;
893 if ( _DebugFileName ) {
894 delete [] _DebugFileName ;
896 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
897 strcpy( _DebugFileName , dbgfile.c_str() ) ;
899 int lenname = strlen( aXmlFileName ) ;
900 bool loaded = false ;
901 // Import of the xml file
902 if ( lenname > 4 && !strcmp( &aXmlFileName[ lenname - 4 ] , ".xml" ) ) {
903 loaded = aDataFlowEditor->LoadXml( aXmlFileName , aListOfDataFlows ) ;
905 iobject = MNode( aDataFlowEditor , &aListOfDataFlows ) ;
912 // WARNING : THIS IS COMPLICATED :
913 // I should have to remove duplicated code ...
914 SUPERV::Graph_ptr Graph_Impl::MNode( GraphEditor::DataFlow * aMacroGraphDataFlowEditor ,
915 GraphBase::ListOfSGraphs * aListOfDataFlows ) {
916 beginService( "Graph_Impl::MNode" ) ;
917 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
918 SUPERV::Graph_var macroiobject = SUPERV::Graph::_nil() ;
921 MESSAGE( "Graph_Impl::MNode DataFlowEditor->LoadDataFlow" ) ;
922 // if ( !aMacroGraphDataFlowEditor->LoadDataFlow( &aListOfDataFlows[ 0 ] ) ) {
923 iobject = LoadDataFlows( aMacroGraphDataFlowEditor , aListOfDataFlows , 0 ) ;
924 if ( CORBA::is_nil( iobject ) ) {
925 MESSAGE("Graph_Impl::MNode LoadDataFlow failed" ) ;
929 // That graph is not a StreamGraph :
930 else if ( !aMacroGraphDataFlowEditor->Graph()->HasDataStream() ) {
931 aMacroGraphDataFlowEditor->Graph()->Kind( SUPERV::DataFlowGraph ) ;
932 aMacroGraphDataFlowEditor->Graph()->GraphEditor( aMacroGraphDataFlowEditor ) ;
934 Graph_Impl * myMacroGraph = (Graph_Impl * ) aMacroGraphDataFlowEditor->Graph()->ObjImpl() ;
935 // Creation of a GraphMacroNode in the current editor
936 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
937 Graph_Impl * myMacroNode ;
938 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
939 instanceName() , interfaceName() ,
940 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
941 PortableServer::ObjectId * id = myMacroNode->getId() ;
942 CORBA::Object_var obj = _poa->id_to_reference(*id);
943 macroiobject = SUPERV::Graph::_narrow( obj ) ;
944 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
946 // Creation of the MacroNode itself in the current Graph
947 GraphBase::ListOfFuncName aFuncName ;
948 aFuncName.resize( 1 ) ;
950 SUPERV::ListOfStrings aListOfStrings ;
951 aListOfStrings.length( 1 ) ;
952 aListOfStrings[0] = "" ;
953 GraphBase::ListOfPythonFunctions aPythonFunction ;
954 aPythonFunction.resize( 1 ) ;
955 aPythonFunction[0] = &aListOfStrings ;
956 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
957 GraphEditor::InNode * aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
958 aMacroNodeName.c_str() , SUPERV::MacroNode ,
959 aFuncName , aPythonFunction ) ;
960 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
961 myMacroNode->DataFlowNode( aDataFlowNode ) ;
962 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
963 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
964 aDataFlowNode->SetObjImpl( this ) ;
966 GraphBase::Graph * aGraph = myMacroGraph->DataFlowEditor()->Graph() ;
967 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
968 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
969 aMacroGraph->Kind( SUPERV::MacroNode ) ;
970 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
971 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
972 aMacroGraph->SetMacroPorts( aGraph ) ;
973 // Valid ==> creation of Service and the ports of the current Graph
974 DataFlowEditor()->IsValid() ;
975 // Set the Input Datas from the GraphMacroNode to the current Graph
976 aMacroGraph->SetMacroDatas( aGraph , aGraphOfMacroGraph ) ;
977 aMacroGraphDataFlowEditor->UnValid() ;
978 // Set the MacroNode ObjRef in the GraphMacroNode
979 aGraph->CoupledNode( aMacroGraph ) ;
980 aGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
981 // Set the GraphMacroNode ObjRef in the MacroNode
982 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
983 aMacroGraph->CoupledNode( aGraph ) ;
984 // aGraphOfMacroGraph->CoupledNode( aGraph ) ;
985 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
986 // aGraphOfMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
987 // aDataFlowNode->CoupledNode( aGraph ) ;
988 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
989 // Set the MacroLevel of that graph
990 aGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
991 aMacroGraph->Coordinates( 0 , 0 ) ;
992 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
993 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
994 MESSAGE( "MNode aGraph " << aGraph << " " << aGraph->Name()
995 << " coupled to " << aGraph->CoupledNode() << " "
996 << aGraph->CoupledNode()->Name() ) ;
997 MESSAGE( "MNode aMacroGraph " << aMacroGraph << " " << aMacroGraph->Name()
998 << " coupled to " << aMacroGraph->CoupledNode() << " "
999 << aMacroGraph->CoupledNode()->Name() ) ;
1000 MESSAGE( "MNode aMacroGraph " << myMacroNode->DataFlowEditor()->Graph() << " "
1001 << myMacroNode->DataFlowEditor()->Graph()->Name()
1002 << " coupled to " << myMacroNode->DataFlowEditor()->Graph()->CoupledNode() ) ;
1005 delete aMacroGraphDataFlowEditor ;
1008 endService( "Graph_Impl::MNode" );
1009 return SUPERV::Graph::_duplicate( macroiobject ) ;
1012 // For python supergraph
1013 SUPERV::Graph_ptr Graph_Impl::GraphMNode( SUPERV::Graph_ptr myMacroGraph ) {
1014 SUPERV::Graph_var iobject = myMacroGraph ;
1015 beginService( "Graph_Impl::GraphMNode" ) ;
1017 // GraphBase::Graph * myMacroGraph = aGraph;
1018 SUPERV::Graph_var macroiobject = SUPERV::StreamGraph::_nil() ;
1019 // Creation of a GraphMacroNode in the current editor
1021 string aMacroNodeName = string( "Macro_" ) + string( myMacroGraph->Name() ) ;
1022 //string aMacroNodeName = string( myMacroGraph->CoupledName() ) ;
1023 MESSAGE( "GraphMNode( " << myMacroGraph->Name() << " )" ) ;
1024 Graph_Impl * myMacroNode ;
1025 myMacroNode = new Graph_Impl( _Orb , _Poa, _ContId,
1026 instanceName() , interfaceName() ,
1027 aMacroNodeName.c_str() , SUPERV::MacroNode ) ;
1028 PortableServer::ObjectId * id = myMacroNode->getId() ;
1029 CORBA::Object_var obj = _poa->id_to_reference(*id);
1030 macroiobject = SUPERV::Graph::_narrow( obj ) ;
1031 myMacroNode->DataFlowEditor( DataFlowEditor() ) ;
1033 // Creation of the MacroNode itself in the current Graph
1034 GraphBase::ListOfFuncName aFuncName ;
1035 aFuncName.resize( 1 ) ;
1037 SUPERV::ListOfStrings aListOfStrings ;
1038 aListOfStrings.length( 1 ) ;
1039 aListOfStrings[0] = "" ;
1040 GraphBase::ListOfPythonFunctions aPythonFunction ;
1041 aPythonFunction.resize( 1 ) ;
1042 aPythonFunction[0] = &aListOfStrings ;
1043 SALOME_ModuleCatalog::Service * aMacroNodeService = myMacroGraph->Service() ;
1044 GraphEditor::InNode * aDataFlowNode ;
1045 aDataFlowNode = DataFlowEditor()->AddNode( *aMacroNodeService , "" , "" ,
1046 aMacroNodeName.c_str() , SUPERV::MacroNode ,
1047 aFuncName , aPythonFunction ) ;
1048 aDataFlowNode->SetPythonFunction( "" , aListOfStrings ) ;
1049 myMacroNode->DataFlowNode( aDataFlowNode ) ;
1050 aDataFlowNode->ComputingNode()->SetService( *aMacroNodeService ) ;
1051 aDataFlowNode->SetObjRef( SUPERV::CNode::_duplicate( SUPERV::CNode::_narrow( obj ) ) ) ;
1052 aDataFlowNode->SetObjImpl( this ) ;
1054 GraphBase::Graph * aSubGraph = NULL ;
1055 // GraphBase::Graph * aGraph = DataFlowEditor()->Automaton()->MapGraph( myMacroGraph->Name() ) ;
1056 //DataFlowEditor()->Automaton()->GraphBase( &aGraph ) ;
1057 //JR 20.09.2005 Debug SAB_data_1609_bugPAL.py from CEA (Anthony)
1058 // Graph_Impl * aSubGraphImpl = dynamic_cast<Graph_Impl * >( _Poa->id_to_servant( *myMacroGraph->_Id ) ) ;
1059 myMacroGraph->ping() ;
1060 Graph_Impl * aSubGraphImpl = theAutomaton->GraphImpl() ;
1061 aSubGraph = aSubGraphImpl->DataFlowEditor()->Graph() ;
1062 myMacroGraph->Coupled() ;
1063 GraphBase::Graph * aGraphOfMacroGraph = myMacroNode->DataFlowEditor()->Graph() ;
1064 GraphBase::Graph * aMacroGraph = myMacroNode->DataFlowNode()->GraphMacroNode() ;
1065 aMacroGraph->Kind( SUPERV::MacroNode ) ;
1066 aMacroGraph->GraphEditor( DataFlowEditor() ) ;
1067 // Creation of the Ports of the MacroNode from the ports of the GraphMacroNode
1068 aMacroGraph->SetMacroPorts( aSubGraph ) ;
1069 // Valid ==> creation of Service and the ports of the current Graph
1070 DataFlowEditor()->IsValid() ;
1071 // Set the Input Datas from the GraphMacroNode to the current Graph
1072 aMacroGraph->SetMacroDatas( aSubGraph , aGraphOfMacroGraph ) ;
1073 // aMacroGraphDataFlowEditor->UnValid() ;
1074 aSubGraph->GraphEditor()->UnValid() ;
1075 // Set the MacroNode ObjRef in the GraphMacroNode
1076 aSubGraph->CoupledNode( aMacroGraph ) ;
1077 aSubGraph->MacroObject( SUPERV::Graph::_duplicate( macroiobject ) ) ;
1078 // Set the GraphMacroNode ObjRef in the MacroNode
1079 aDataFlowNode->GraphMacroNode()->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1080 aMacroGraph->CoupledNode( aSubGraph ) ;
1081 aMacroGraph->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1082 // aDataFlowNode->CoupledNode( aSubGraph ) ;
1083 // aDataFlowNode->ComputingNode()->MacroObject( SUPERV::Graph::_duplicate( iobject ) ) ;
1084 // Set the MacroLevel of that graph
1085 aSubGraph->GraphMacroLevel( aGraphOfMacroGraph->GraphMacroLevel() + 1 ) ;
1086 aMacroGraph->Coordinates( 0 , 0 ) ;
1087 MESSAGE( aSubGraph->Name() << "->CoupledNode()->GraphEditor() : " << aSubGraph->CoupledNode()->GraphEditor() ) ;
1088 MESSAGE( aMacroGraph->Name() << "->CoupledNode()->GraphEditor() : "
1089 << aMacroGraph->CoupledNode()->GraphEditor() ) ;
1090 MESSAGE( "DataFlowNode Graph " << this << " DataFlowEditor " << DataFlowEditor() << " aDataFlowNode "
1091 << aDataFlowNode << " " << aDataFlowNode->Name() << " created" ) ;
1093 endService( "Graph_Impl::GraphMNode" ) ;
1094 return SUPERV::Graph::_duplicate( macroiobject ) ;
1097 SUPERV::Graph_ptr Graph_Impl::FlowObjRef() {
1098 beginService( "Graph_Impl::FlowObjRef" );
1099 SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ;
1101 iobject = SUPERV::Graph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1103 else if ( IsGraph() ) {
1104 iobject = SUPERV::Graph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1106 if ( CORBA::is_nil( iobject ) ) {
1107 MESSAGE( "Graph_Impl::FlowObjRef() returns a NIL Object" ) ;
1109 endService( "Graph_Impl::FlowObjRef" );
1110 return SUPERV::Graph::_duplicate( iobject ) ;
1113 SUPERV::StreamGraph_ptr Graph_Impl::StreamObjRef() {
1114 beginService( "Graph_Impl::StreamObjRef" );
1115 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1117 iobject = SUPERV::StreamGraph::_narrow( DataFlowNode()->GraphMacroNode()->MacroObject() ) ;
1119 else if ( IsGraph() || IsStreamGraph() ) {
1120 iobject = SUPERV::StreamGraph::_narrow( DataFlowEditor()->Graph()->MacroObject() ) ;
1122 if ( CORBA::is_nil( iobject ) ) {
1123 MESSAGE( "Graph_Impl::StreamObjRef() returns a NIL Object" ) ;
1125 endService( "Graph_Impl::StreamObjRef" );
1126 return SUPERV::StreamGraph::_duplicate( iobject ) ;
1129 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
1130 // beginService( "Graph_Impl::Node" );
1131 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
1133 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
1134 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1135 instanceName() , interfaceName() ,
1137 DataFlowEditor()->GetNode( aNodeName ) ) ;
1138 PortableServer::ObjectId * id = myNode->getId() ;
1139 CORBA::Object_var obj = _poa->id_to_reference(*id);
1140 iobject = SUPERV::CNode::_narrow(obj) ;
1141 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1144 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
1147 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
1149 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
1150 SetNodeObjRef( anInNode ) ;
1152 iobject = anInNode->ObjRef() ;
1155 // endService( "Graph_Impl::Node" );
1156 return SUPERV::CNode::_duplicate( iobject ) ;
1159 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
1160 SUPERV::Port_ptr InPort ) {
1161 // beginService( "Graph_Impl::Link" );
1162 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
1163 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
1164 !OutPort->IsDataStream() && !InPort->IsDataStream() && !IsMacro() ) {
1165 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << "( " << OutPort->Name() << " ) --> "
1166 << InPort->Node()->Name() << "( " << InPort->Name() << " )" ) ;
1167 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( InPort->Node()->Name() ) ;
1168 GraphEditor::InNode * anOutNode = DataFlowEditor()->GetNode( OutPort->Node()->Name() ) ;
1169 if ( anInNode == NULL || anOutNode== NULL ) {
1170 MESSAGE( "Graph_Impl::Link( " << OutPort->Node()->Name() << " " << anOutNode << " , "
1171 << InPort->Node()->Name() << " " << anInNode << " ) Node(s) not found in " << Name() ) ;
1174 GraphBase::InPort * anInPort = anInNode->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
1175 GraphBase::OutPort * anOutPort = anOutNode->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
1176 if ( anInPort == NULL || anOutPort== NULL ) {
1177 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1178 << InPort->Name() << " " << anInPort << " ) Port(s) not found" ) ;
1180 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1181 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
1182 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
1183 const char * DataFlowInNodeName = InPort->Node()->Name() ;
1184 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
1185 if ( DataFlowOutNode && DataFlowInNode ) {
1187 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1188 instanceName() , interfaceName() ,
1194 true , false , Success ) ;
1196 PortableServer::ObjectId * id = myLink->getId() ;
1197 CORBA::Object_var obj = _poa->id_to_reference(*id);
1198 iobject = SUPERV::Link::_narrow(obj) ;
1199 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1204 MESSAGE( "Graph_Impl::Link( " << OutPort->Name() << " " << anOutPort << " , "
1205 << InPort->Name() << " " << anInPort << " ) ObjRef already exists" ) ;
1206 iobject = anOutPort->InPortObjRef( anInPort ) ;
1210 DataFlowEditor()->UnValid() ;
1211 // endService( "Graph_Impl::Link" );
1212 return SUPERV::Link::_duplicate( iobject ) ;
1215 // Only to see MacroNodes with actual GUI ... :
1216 #define GOTOMacroNode 0
1218 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
1219 MESSAGE("Graph_Impl::SetNodeObjRef " << anInNode->Name() << " " << anInNode->Kind() ) ;
1220 CORBA::Object_var obj ;
1221 if ( anInNode->IsComputingNode() ) {
1222 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1223 instanceName() , interfaceName() ,
1226 PortableServer::ObjectId * id = myNode->getId() ;
1227 obj = _poa->id_to_reference(*id);
1228 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
1229 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
1231 else if ( anInNode->IsFactoryNode() ) {
1232 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
1233 instanceName() , interfaceName() ,
1236 PortableServer::ObjectId * id = myNode->getId() ;
1237 obj = _poa->id_to_reference(*id);
1238 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
1239 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
1241 else if ( anInNode->IsInLineNode() ) {
1242 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
1243 instanceName() , interfaceName() ,
1246 PortableServer::ObjectId * id = myNode->getId() ;
1247 obj = _poa->id_to_reference(*id);
1248 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
1249 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
1252 else if ( anInNode->IsGOTONode() || anInNode->IsMacroNode() ) {
1253 if ( anInNode->IsMacroNode() ) {
1254 anInNode->ComputingNode()->Kind( SUPERV::GOTONode ) ;
1257 else if ( anInNode->IsGOTONode() ) {
1259 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
1260 instanceName() , interfaceName() ,
1263 PortableServer::ObjectId * id = myNode->getId() ;
1264 obj = _poa->id_to_reference(*id);
1265 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
1266 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
1268 else if ( anInNode->IsMacroNode() ) {
1269 Graph_Impl * myNode = new Graph_Impl( _Orb , _Poa , _ContId ,
1270 instanceName() , interfaceName() ,
1273 PortableServer::ObjectId * id = myNode->getId() ;
1274 obj = _poa->id_to_reference(*id);
1275 SUPERV::Graph_var iobject = SUPERV::Graph::_narrow(obj) ;
1276 myNode->SetObjRef( SUPERV::Graph::_duplicate( iobject ) ) ;
1278 else if ( anInNode->IsLoopNode() ) {
1279 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
1280 instanceName() , interfaceName() ,
1283 PortableServer::ObjectId * id = myNode->getId() ;
1284 obj = _poa->id_to_reference(*id);
1285 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
1286 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
1288 else if ( anInNode->IsEndLoopNode() ) {
1289 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
1290 instanceName() , interfaceName() ,
1293 PortableServer::ObjectId * id = myNode->getId() ;
1294 obj = _poa->id_to_reference(*id);
1295 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
1296 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
1298 else if ( anInNode->IsSwitchNode() ) {
1299 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
1300 instanceName() , interfaceName() ,
1303 PortableServer::ObjectId * id = myNode->getId() ;
1304 obj = _poa->id_to_reference(*id);
1305 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
1306 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
1308 else if ( anInNode->IsEndSwitchNode() ) {
1309 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
1310 instanceName() , interfaceName() ,
1313 PortableServer::ObjectId * id = myNode->getId() ;
1314 obj = _poa->id_to_reference(*id);
1315 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
1316 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
1320 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
1321 GraphBase::ComputingNode * aNode ) {
1323 // if ( _DataFlowExecutor ) {
1324 if ( DataFlowExecutor() ) {
1325 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
1326 << DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState( aNode->Name() ) ) ) ;
1329 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
1331 if ( aNode->IsComputingNode() ) {
1332 index = RetVal->CNodes.length() ;
1333 RetVal->CNodes.length( index+1 );
1335 else if ( aNode->IsFactoryNode() ) {
1336 index = RetVal->FNodes.length() ;
1337 RetVal->FNodes.length( index+1 );
1339 else if ( aNode->IsInLineNode() ) {
1340 index = RetVal->INodes.length() ;
1341 RetVal->INodes.length( index+1 );
1344 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1346 else if ( aNode->IsGOTONode() ) {
1348 index = RetVal->GNodes.length() ;
1349 RetVal->GNodes.length( index+1 );
1351 else if ( aNode->IsMacroNode() ) {
1352 index = RetVal->Graphs.length() ;
1353 RetVal->Graphs.length( index+1 );
1355 else if ( aNode->IsLoopNode() ) {
1356 index = RetVal->LNodes.length() ;
1357 RetVal->LNodes.length( index+1 );
1359 else if ( aNode->IsEndLoopNode() ) {
1360 index = RetVal->ELNodes.length() ;
1361 RetVal->ELNodes.length( index+1 );
1363 else if ( aNode->IsSwitchNode() ) {
1364 index = RetVal->SNodes.length() ;
1365 RetVal->SNodes.length( index+1 );
1367 else if ( aNode->IsEndSwitchNode() ) {
1368 index = RetVal->ESNodes.length() ;
1369 RetVal->ESNodes.length( index+1 );
1371 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
1372 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
1374 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
1375 if ( aNode->IsComputingNode() ) {
1376 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
1378 else if ( aNode->IsFactoryNode() ) {
1379 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
1381 else if ( aNode->IsInLineNode() ) {
1382 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
1385 else if ( aNode->IsGOTONode() || aNode->IsMacroNode() ) {
1387 else if ( aNode->IsGOTONode() ) {
1389 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
1391 else if ( aNode->IsMacroNode() ) {
1392 RetVal->Graphs[index] = SUPERV::Graph::_duplicate( SUPERV::Graph::_narrow( aNodeObjRef ) ) ;
1394 else if ( aNode->IsLoopNode() ) {
1395 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
1397 else if ( aNode->IsEndLoopNode() ) {
1398 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
1400 else if ( aNode->IsSwitchNode() ) {
1401 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
1403 else if ( aNode->IsEndSwitchNode() ) {
1404 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
1406 return ( RetVal._retn() ) ;
1409 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
1410 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1411 beginService( "Graph_Impl::Nodes" );
1412 RetVal->CNodes.length(0) ;
1413 RetVal->FNodes.length(0) ;
1414 RetVal->INodes.length(0) ;
1415 RetVal->LNodes.length(0) ;
1416 RetVal->SNodes.length(0) ;
1417 RetVal->GNodes.length(0) ;
1418 RetVal->Graphs.length(0) ;
1421 MESSAGE( DataFlowEditor()->Graph()->GetGraphNodeSize() << " Nodes in the Map and "
1422 << DataFlowEditor()->Graph()->GraphNodesSize() << " Nodes int the Vector" ) ;
1423 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1424 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
1426 MESSAGE( i << ". Vector : " << aNode->Name() << " Map : "
1427 << DataFlowEditor()->Graph()->GetGraphNode( aNode->Name() )->Name() ) ;
1429 RetVal = SetNode( RetVal , aNode ) ;
1432 char * aStateG = "" ;
1433 if ( DataFlowExecutor() ) {
1434 aStateG = (char *) DataFlowExecutor()->StateName( DataFlowExecutor()->AutomatonState() ) ;
1436 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG << " CNodes " << RetVal->CNodes.length() ) ;
1437 for ( i = 0 ; i < RetVal->CNodes.length() ; i++ ) {
1438 MESSAGE(" " << RetVal->CNodes[ i ] ->Name() ) ;
1440 MESSAGE("FNodes " << RetVal->FNodes.length() ) ;
1441 for ( i = 0 ; i < RetVal->FNodes.length() ; i++ ) {
1442 MESSAGE(" " << RetVal->FNodes[ i ] ->Name() ) ;
1444 MESSAGE("INodes " << RetVal->INodes.length() ) ;
1445 for ( i = 0 ; i < RetVal->INodes.length() ; i++ ) {
1446 MESSAGE(" " << RetVal->INodes[ i ] ->Name() ) ;
1448 MESSAGE("GNodes " << RetVal->GNodes.length() ) ;
1449 for ( i = 0 ; i < RetVal->GNodes.length() ; i++ ) {
1450 MESSAGE(" " << RetVal->GNodes[ i ] ->Name() ) ;
1452 MESSAGE("LNodes " << RetVal->LNodes.length() ) ;
1453 for ( i = 0 ; i < RetVal->LNodes.length() ; i++ ) {
1454 MESSAGE(" " << RetVal->LNodes[ i ] ->Name() ) ;
1456 MESSAGE("ELNodes " << RetVal->ELNodes.length() ) ;
1457 for ( i = 0 ; i < RetVal->ELNodes.length() ; i++ ) {
1458 MESSAGE(" " << RetVal->ELNodes[ i ] ->Name() ) ;
1460 MESSAGE("SNodes " << RetVal->SNodes.length() ) ;
1461 for ( i = 0 ; i < RetVal->SNodes.length() ; i++ ) {
1462 MESSAGE(" " << RetVal->SNodes[ i ] ->Name() ) ;
1464 MESSAGE("ESNodes " << RetVal->ESNodes.length() ) ;
1465 for ( i = 0 ; i < RetVal->ESNodes.length() ; i++ ) {
1466 MESSAGE(" " << RetVal->ESNodes[ i ] ->Name() ) ;
1468 MESSAGE("Graphs " << RetVal->Graphs.length() ) ;
1469 for ( i = 0 ; i < RetVal->Graphs.length() ; i++ ) {
1470 MESSAGE(" " << RetVal->Graphs[ i ] ->Name() ) ;
1472 if ( DataFlowExecutor() ) {
1473 DataFlowExecutor()->EventList() ;
1477 endService( "Graph_Impl::Nodes" );
1478 return ( RetVal._retn() ) ;
1481 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
1482 return Links( NULL , NULL ) ;
1485 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
1486 const char * anInputParam ) {
1488 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
1489 RetVal->length( 0 ) ;
1491 int i , j , countlink ;
1493 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
1494 GraphEditor::InNode * aNode = NULL ;
1495 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
1496 bool ToProcess = false ;
1497 if ( theNode == NULL ) {
1501 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
1502 if ( !theNode->IsEndSwitchNode() ) {
1506 else if ( theNode->IsEndSwitchNode() ) {
1511 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1512 GraphBase::InPort * anInPort = NULL ;
1513 anInPort = aNode->GetChangeNodeInPort( j ) ;
1514 if ( anInputParam == NULL ||
1515 !strcmp( anInPort->PortName() , anInputParam ) ) {
1516 GraphBase::OutPort * anOutPort = NULL ;
1517 anOutPort = anInPort->GetOutPort() ;
1518 if ( anOutPort && !anOutPort->IsDataStream() ) {
1519 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
1520 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
1521 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1522 // << anInPort->PortName() << ")" ) ;
1523 if ( theNode == NULL ||
1525 //JR 14.02.2005 : Debug : we must see also that links !
1526 // ( theNode != NULL && !theNode->IsEndSwitchNode() &&
1527 !strcmp( theNode->Name() , aNode->Name() ) ) {
1528 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1529 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
1530 anOutPort->NodeName() ) ) ) {
1531 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1532 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1533 // << anInPort->PortName() << ")" << " ignored" ) ;
1535 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1537 beginService( "Graph_Impl::Links" );
1540 GraphEditor::InNode * anOutNode = NULL ;
1541 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
1544 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1545 instanceName() , interfaceName() ,
1548 anInPort->PortName() ,
1550 anOutPort->PortName() ,
1551 false , true , Success ) ;
1553 PortableServer::ObjectId * id = myLink->getId() ;
1554 CORBA::Object_var obj = _poa->id_to_reference(*id);
1555 SUPERV::Link_var iobject ;
1556 iobject = SUPERV::Link::_narrow(obj) ;
1557 RetVal->length( countlink + 1 ) ;
1558 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1559 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1564 RetVal->length( countlink + 1 ) ;
1565 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
1567 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1568 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1569 // << anInPort->PortName() << ")" << " selected" ) ;
1572 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1573 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
1574 // << anInPort->PortName() << ")" << " skipped" ) ;
1581 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1582 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
1583 // MESSAGE( "Graph_Impl::Links " << aNode->Name() << " Out" << j << " " << anOutPort->PortName() << " "
1584 // << anOutPort->PortStatus() << " PortConnected to " << anOutPort->InPortsSize() << " InPorts" ) ;
1586 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
1587 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
1588 // MESSAGE( " --> In" << k << " " << anInPort->NodeName() << " " << anInPort->PortName()
1589 // << " " << anInPort->PortStatus() ) ;
1590 if ( anInPort->IsPortConnected() ) {
1591 GraphBase::ComputingNode * aComputingNode = DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() ) ;
1592 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) aComputingNode->GetInNode() ;
1593 if ( theNode == NULL ||
1594 !strcmp( theNode->Name() , aNode->Name() ) ) {
1595 if ( !anInPort->IsDataStream() ) {
1597 //JR 14.02.2005 : Debug : we must see also that links !
1598 // if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
1599 if ( anInputParam == NULL ||
1600 !strcmp( anInPort->PortName() , anInputParam ) ) {
1601 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
1602 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
1603 anOutPort->NodeName() ) ) ) {
1604 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1605 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1606 // << anInPort->PortName() << ")" << " ignored" ) ;
1608 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
1610 beginService( "Graph_Impl::Links" );
1614 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
1615 instanceName() , interfaceName() ,
1618 anInPort->PortName() ,
1620 anOutPort->PortName() ,
1621 false , true , Success ) ;
1623 PortableServer::ObjectId * id = myLink->getId() ;
1624 CORBA::Object_var obj = _poa->id_to_reference(*id);
1625 SUPERV::Link_var iobject ;
1626 iobject = SUPERV::Link::_narrow(obj) ;
1627 RetVal->length( countlink + 1 ) ;
1628 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
1629 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
1633 RetVal->length( countlink + 1 ) ;
1634 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
1636 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1637 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1638 // << anInPort->PortName() << ")" << " selected" ) ;
1641 // MESSAGE( "Link " << anOutPort->NodeName() << "("
1642 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
1643 // << anInPort->PortName() << ")" << " skipped" ) ;
1654 const char * NodeName = "" ;
1655 const char * InputParamName = "" ;
1657 NodeName = theNode->Name() ;
1659 if ( anInputParam ) {
1660 InputParamName = anInputParam ;
1662 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
1663 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
1664 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
1665 << RetVal[i]->OutPort()->Name() << ") --> "
1666 << RetVal[i]->InPort()->Node()->Name() << "("
1667 << RetVal[i]->InPort()->Name() << ")" ) ;
1671 endService( "Graph_Impl::Links" );
1674 return ( RetVal._retn() ) ;
1677 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
1678 const char * aComponentName ) {
1679 Engines::Component_var objComponent = Engines::Component::_nil() ;
1681 Engines::Container_var myContainer ;
1682 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
1683 myContainer , objComponent ) ;
1685 return Engines::Component::_duplicate( objComponent ) ;
1688 char * Graph_Impl::Messages() {
1689 beginService( "Graph_Impl::Messages" );
1691 MESSAGE( "Graph_Impl::Messages IsEditing " << DataFlowEditor()->IsEditing() ) ;
1692 Messages = DataFlowEditor()->Graph()->Messages() ;
1693 DataFlowEditor()->Graph()->ReSetMessages() ;
1694 if ( DataFlowExecutor() ) {
1695 Messages += DataFlowExecutor()->Graph()->Messages() ;
1696 DataFlowExecutor()->Graph()->ReSetMessages() ;
1698 endService( "Graph_Impl::Messages" );
1699 return ( CORBA::string_dup( Messages.c_str() ) ) ;
1702 bool Graph_Impl::IsValid() {
1703 // beginService( "Graph_Impl::IsValid" );
1704 bool RetVal = false ;
1706 RetVal = DataFlowEditor()->IsValid() ;
1708 // endService( "Graph_Impl::IsValid" );
1711 bool Graph_Impl::IsExecutable() {
1712 // beginService( "Graph_Impl::IsExecutable" );
1713 bool RetVal = false ;
1715 // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" ->
1716 // subgraphs are not executable by themselves, RetVal = false..
1717 if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
1718 RetVal = DataFlowEditor()->IsExecutable() ;
1720 // endService( "Graph_Impl::IsExecutable" );
1724 bool Graph_Impl::IsEditing() {
1726 bool RetVal = false ;
1728 RetVal = DataFlowEditor()->IsEditing() ;
1734 return !IsExecuting();
1737 bool Graph_Impl::IsExecuting() {
1739 bool RetVal = false ;
1741 RetVal = !DataFlowEditor()->IsEditing() ;
1745 return CNode_Impl::IsExecuting();
1748 bool Graph_Impl::IsReadOnly() {
1749 // beginService( "Graph_Impl::IsExecuting" );
1750 bool RetVal = false ;
1752 RetVal = DataFlowEditor()->IsReadOnly() ;
1754 // endService( "Graph_Impl::IsExecuting" );
1758 CORBA::Long Graph_Impl::LevelMax() {
1759 // beginService( "Graph_Impl::LevelMax" );
1760 CORBA::Long RetVal = 0 ;
1762 RetVal = DataFlowEditor()->LevelMax() ;
1764 // endService( "Graph_Impl::LevelMax" );
1767 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(CORBA::Long aLevel ) {
1768 // beginService( "Graph_Impl::LevelNodes" );
1769 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
1772 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
1773 // RetVal->length( Nodes->length() );
1774 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
1775 // char * aNode = Nodes[ i ] ;
1776 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
1777 RetVal = SetNode( RetVal , aNode ) ;
1778 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
1779 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
1780 // instanceName() , interfaceName() ,
1781 // DataFlowEditor() ,
1782 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
1783 // PortableServer::ObjectId * id = myNode->getId() ;
1784 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1785 // SUPERV::CNode_var iobject ;
1786 // iobject = SUPERV::CNode::_narrow(obj) ;
1787 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
1790 // endService( "Graph_Impl::LevelNodes" );
1791 return ( RetVal._retn() ) ;
1793 CORBA::Long Graph_Impl::ThreadsMax() {
1794 // beginService( "Graph_Impl::ThreadsMax" );
1795 CORBA::Long RetVal = 0 ;
1797 RetVal = DataFlowEditor()->ThreadsMax() ;
1799 // endService( "Graph_Impl::ThreadsMax" );
1802 CORBA::Long Graph_Impl::Threads() {
1803 // beginService( "Node_Impl::Threads" );
1804 CORBA::Long RetVal = false ;
1806 RetVal = DataFlowExecutor()->Threads() ;
1808 // endService( "Node_Impl::Threads" );
1811 CORBA::Long Graph_Impl::SuspendedThreads() {
1812 // beginService( "Node_Impl::SuspendedThreads" );
1813 CORBA::Long RetVal = false ;
1815 RetVal = DataFlowExecutor()->SuspendedThreads() ;
1817 // endService( "Node_Impl::SuspendedThreads" );
1821 bool Graph_Impl::Begin() {
1822 bool RetVal = false ;
1823 // mkr : IPAL11408 : "Run()" method returns "0" after trying to start graph execution.
1824 // If we call Run() method from Python script two times for one graph, we have to be sure,
1825 // that first execution of this graph ended (i.e. GraphEditor::DataFlow::Editing() method was called).
1826 // Otherwise, the second call of Run() method will return 0. Therefore, we have to waiting for
1827 // the first execution finish.
1828 // NB! From GUI we cann't run dataflow if its previous execution not finished.
1829 while ( !DataFlowEditor()->IsEditing() ) {} // waiting for the previous execution of this graph ended
1830 if ( DataFlowEditor()->IsEditing() ) {
1831 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1832 perror("pthread_mutex_lock _MutexExecutorWait") ;
1835 DataFlowEditor()->Graph()->ReSetMessages() ; // ==> Only one set of errors messages ...
1836 if ( DataFlowExecutor() ) {
1837 MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" )
1838 Editing(); // just in case it was not called before by GUI..
1840 if ( DataFlowEditor()->IsExecutable() ) {
1841 DataFlowEditor()->EditedAfterExecution( false ) ;
1842 GraphBase::ListOfSGraphs * myListOfGraphs = DataFlowEditor()->GetDataFlows() ;
1844 GraphExecutor::DataFlow * aDataFlowExecutor ;
1846 CreateExecutor( _Orb , instanceName() , (*myListOfGraphs)[ 0 ].Info.theName.c_str() , Kind() ,
1847 dbgfile , &aDataFlowExecutor ) ;
1849 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1850 if ( !CORBA::is_nil( LoadDataFlows( aDataFlowExecutor, myListOfGraphs , 0 ) ) )
1854 DataFlowExecutor()->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1857 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1858 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1866 * run() : was created in order to reduce code dublication, Run() and Start() do the same thing
1867 * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false
1868 * and Start() calls with AndSuspend=true flag. The rest of the actions are the same:
1869 * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it.
1870 * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it.
1872 bool Graph_Impl::run( const bool andSuspend ) {
1873 bool RetVal = false ;
1875 // if Editing or Finished state, and, naturally, 'this' is not a MacroNode.
1876 if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) {
1878 if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) {
1879 // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from
1880 // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details.
1884 // Create Executor instance and its datamodel
1888 // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false
1889 DataFlowEditor()->Executing() ;
1890 DataFlowEditor()->EditedAfterExecution( false );
1892 // THE MAIN RUN METHOD
1893 RetVal = DataFlowExecutor()->Run( andSuspend );
1901 * Run() - called on "Execute" command
1903 bool Graph_Impl::Run() {
1904 beginService( "Graph_Impl::Run" );
1905 bool RetVal = run( /*andSuspend=*/false ) ;
1906 MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1907 endService( "Graph_Impl::Run" );
1912 * Run() - called on "Execute step-by-step" command
1914 bool Graph_Impl::Start() {
1915 beginService( "Graph_Impl::Start" );
1916 bool RetVal = run( /*andSuspend=*/true ) ;
1917 MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ;
1918 endService( "Graph_Impl::Start" );
1922 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1923 SUPERV::GraphEvent & anEvent ,
1924 SUPERV::GraphState & aState ) {
1925 bool RetVal = false ;
1926 char * aNodeName = NULL ;
1927 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1928 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1929 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1930 perror("pthread_mutex_lock _MutexExecutorWait") ;
1933 if ( DataFlowExecutor() && !IsMacro() &&
1934 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1935 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState , false ) ;
1936 // endService( "Graph_Impl::Event" );
1937 if ( strlen( aNodeName ) ) {
1938 if ( strcmp( aNodeName , Name() ) ) {
1939 aNode = Node( aNodeName ) ;
1946 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1948 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1951 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor() or QSize=0 " << endl ;
1953 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1954 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1957 anEvent = theEvent ;
1962 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1963 SUPERV::GraphEvent & anEvent ,
1964 SUPERV::GraphState & aState ) {
1965 // beginService( "Graph_Impl::Event" );
1966 bool RetVal = false ;
1967 char * aNodeName = NULL ;
1968 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1969 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1970 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1971 perror("pthread_mutex_lock _MutexExecutorWait") ;
1974 if ( DataFlowExecutor() && !IsMacro() &&
1975 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1976 RetVal = DataFlowExecutor()->Event( & aNodeName , theEvent , theState ) ;
1977 // endService( "Graph_Impl::Event" );
1978 if ( strlen( aNodeName ) ) {
1979 if ( strcmp( aNodeName , Name() ) ) {
1980 aNode = Node( aNodeName ) ;
1987 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1989 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << DataFlowExecutor()->GetListSize() << endl ;
1992 // cout << "Graph_Impl::Event NO DataFlowExecutor() or QSize=0 " << endl ;
1994 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1995 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1998 anEvent = theEvent ;
2004 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
2005 SUPERV::GraphEvent & anEvent ,
2006 SUPERV::GraphState & aState ) {
2007 // beginService( "Graph_Impl::EventW" );
2008 bool RetVal = false ;
2009 char * aNodeName = NULL ;
2010 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
2011 SUPERV::GraphState theState = SUPERV::UndefinedState ;
2012 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2013 perror("pthread_mutex_lock _MutexExecutorWait") ;
2016 if ( DataFlowExecutor() && !IsMacro() &&
2017 ( DataFlowExecutor()->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
2018 RetVal = DataFlowExecutor()->EventW( & aNodeName , theEvent , theState ) ;
2019 if ( RetVal && strcmp( aNodeName , Name() ) ) {
2020 aNode = Node( aNodeName ) ;
2026 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2027 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2030 anEvent = theEvent ;
2032 // endService( "Graph_Impl::EventW" );
2036 CORBA::Long Graph_Impl::EventQSize() {
2037 // beginService( "Graph_Impl::EventQSize" );
2038 CORBA::Long QSize = -1 ;
2039 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2040 perror("pthread_mutex_lock _MutexExecutorWait") ;
2043 if ( DataFlowExecutor() && !IsMacro() ) {
2044 QSize = DataFlowExecutor()->EventQSize() ;
2046 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2047 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2050 // endService( "Graph_Impl::EventQSize" );
2054 CORBA::Long Graph_Impl::LastLevelDone() {
2055 // beginService( "Graph_Impl::LastLevelDone" );
2056 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
2057 perror("pthread_mutex_lock _MutexExecutorWait") ;
2060 CORBA::Long RetVal = 0 ;
2061 if ( DataFlowExecutor() && !IsMacro() ) {
2062 RetVal = DataFlowExecutor()->LastLevelDone() ;
2064 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
2065 perror("pthread_mutex_unlock _MutexExecutorWait") ;
2068 // endService( "Graph_Impl::LastLevelDone" );
2072 CORBA::Long Graph_Impl::SubGraphsNumber() {
2073 // beginService( "Graph_Impl::SubGraphsNumber" );
2074 CORBA::Long RetVal = 0 ;
2075 if ( DataFlowEditor()->IsExecutable() && !IsMacro() ) {
2076 RetVal = DataFlowEditor()->SubGraphsNumber() ;
2078 // endService( "Graph_Impl::SubGraphsNumber" );
2082 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( CORBA::Long aSubGraphNumber ) {
2083 beginService( "Graph_Impl::SubGraphsNodes" );
2084 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
2085 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2086 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
2089 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2090 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2091 if ( aNode->SubGraph() == aSubGraphNumber ) {
2092 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2096 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2097 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2098 if ( aNode->SubGraph() == aSubGraphNumber ) {
2099 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2103 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2104 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2105 if ( aNode->SubGraph() == aSubGraphNumber ) {
2106 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2110 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2111 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2112 if ( aNode->SubGraph() == aSubGraphNumber ) {
2113 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2117 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2118 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2119 if ( aNode->SubGraph() == aSubGraphNumber ) {
2120 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2124 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
2125 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
2126 if ( aNode->SubGraph() == aSubGraphNumber ) {
2127 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2131 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2132 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2133 if ( aNode->SubGraph() == aSubGraphNumber ) {
2134 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2138 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
2139 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
2140 if ( aNode->SubGraph() == aSubGraphNumber ) {
2141 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
2145 endService( "Graph_Impl::SubGraphsNodes" );
2146 return ( RetVal._retn() ) ;
2149 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
2150 // beginService( "Graph_Impl::Merge" );
2151 bool RetVal = true ;
2153 map< string , int > aMapOfNodes ;
2154 RetVal = Merge( aGraph , aMapOfNodes ) ;
2156 // endService( "Graph_Impl::Merge" );
2160 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
2161 beginService( "Graph_Impl::Merge" );
2162 bool RetVal = true ;
2163 if ( DataFlowEditor()->IsEditing() && !IsMacro() ) {
2164 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
2166 SUPERV::Port_ptr aPort ;
2167 // SUPERV::StreamPort_ptr aStreamPort ;
2169 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
2170 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
2171 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
2172 if ( !CORBA::is_nil( myNode ) ) {
2173 myNode->SetName( aNode->Name() ) ;
2174 myNode->SetAuthor( aNode->Author() ) ;
2175 myNode->SetComment( aNode->Comment() ) ;
2176 myNode->Coords( aNode->X() , aNode->Y() ) ;
2177 string * aNodetheName = new string( aNode->Name() ) ;
2178 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2179 delete aNodetheName ;
2186 // The following informations are now in the service from SALOME_ModuleCatalog
2187 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2189 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2190 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2191 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2193 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2194 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2200 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
2201 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
2202 SALOME_ModuleCatalog::ImplType implType = SALOME_ModuleCatalog::SO;
2203 if (!aNode->IsCimpl()) implType = SALOME_ModuleCatalog::PY;
2204 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
2205 aNode->GetInterfaceName() ,
2206 *(aNode->Service()) ,
2207 implType ) ; // mkr : PAL11273
2208 if ( !CORBA::is_nil( myNode ) ) {
2209 myNode->SetName( aNode->Name() ) ;
2210 myNode->SetAuthor( aNode->Author() ) ;
2211 myNode->SetComment( aNode->Comment() ) ;
2212 myNode->Coords( aNode->X() , aNode->Y() ) ;
2213 string * aNodetheName = new string( aNode->Name() ) ;
2214 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2215 delete aNodetheName ;
2222 // The following informations are now in the service from SALOME_ModuleCatalog
2223 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2225 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2226 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
2227 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2229 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
2230 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
2237 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
2238 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
2239 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
2240 if ( !CORBA::is_nil( myNode ) ) {
2241 myNode->SetName( aNode->Name() ) ;
2242 myNode->SetAuthor( aNode->Author() ) ;
2243 myNode->SetComment( aNode->Comment() ) ;
2244 myNode->Coords( aNode->X() , aNode->Y() ) ;
2245 string * aNodetheName = new string( aNode->Name() ) ;
2246 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2247 delete aNodetheName ;
2248 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2250 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2251 if ( myPorts[ j ]->IsInput() ) {
2252 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2255 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2258 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2259 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2260 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2261 if ( myStreamPorts[ j ]->IsInput() ) {
2262 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2265 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2279 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
2280 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
2281 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
2282 if ( !CORBA::is_nil( myNode ) ) {
2283 myNode->SetName( aNode->Name() ) ;
2284 myNode->SetAuthor( aNode->Author() ) ;
2285 myNode->SetComment( aNode->Comment() ) ;
2286 myNode->Coords( aNode->X() , aNode->Y() ) ;
2287 string * aNodetheName = new string( aNode->Name() ) ;
2288 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2289 delete aNodetheName ;
2290 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2292 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2293 if ( myPorts[ j ]->IsInput() ) {
2294 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2297 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2300 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2301 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2302 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2303 if ( myStreamPorts[ j ]->IsInput() ) {
2304 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2307 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2321 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
2322 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
2323 SUPERV::INode_ptr anEndOfLoop ;
2324 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
2325 *(aNode->PyInit()) ,
2326 aNode->PyMoreName() ,
2327 *(aNode->PyMore()) ,
2328 aNode->PyNextName() ,
2329 *(aNode->PyNext()) ,
2331 if ( !CORBA::is_nil( myNode ) ) {
2332 myNode->SetName( aNode->Name() ) ;
2333 myNode->SetAuthor( aNode->Author() ) ;
2334 myNode->SetComment( aNode->Comment() ) ;
2335 myNode->Coords( aNode->X() , aNode->Y() ) ;
2336 string * aNodetheName = new string( aNode->Name() ) ;
2337 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2338 delete aNodetheName ;
2339 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2341 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2342 if ( myPorts[ j ]->IsInput() ) {
2343 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2346 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2349 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2350 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2351 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2352 if ( myStreamPorts[ j ]->IsInput() ) {
2353 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2356 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2360 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
2361 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
2362 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
2363 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
2364 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
2365 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
2366 aNodetheName = new string( myEndOfLoop->Name() ) ;
2367 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
2368 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2369 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
2370 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
2371 if ( myStreamLoopPorts[ j ]->IsInput() ) {
2372 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
2375 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name(), myStreamLoopPorts[ j ]->Type(), myStreamLoopPorts[ j ]->Dependency() ) ;
2379 delete aNodetheName ;
2390 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
2391 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
2392 SUPERV::INode_ptr anEndOfSwitch ;
2393 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
2394 if ( !CORBA::is_nil( myNode ) ) {
2395 myNode->SetName( aNode->Name() ) ;
2396 myNode->SetAuthor( aNode->Author() ) ;
2397 myNode->SetComment( aNode->Comment() ) ;
2398 myNode->Coords( aNode->X() , aNode->Y() ) ;
2399 string * aNodetheName = new string( aNode->Name() ) ;
2400 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
2401 delete aNodetheName ;
2402 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
2404 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2405 if ( myPorts[ j ]->IsInput() ) {
2406 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2409 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
2412 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2413 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
2414 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
2415 if ( myStreamPorts[ j ]->IsInput() ) {
2416 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2419 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name(), myStreamPorts[ j ]->Type(), myStreamPorts[ j ]->Dependency() ) ;
2423 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
2424 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
2425 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
2426 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
2427 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
2428 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
2429 aNodetheName = new string( myEndOfSwitch->Name() ) ;
2430 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
2431 delete aNodetheName ;
2432 myPorts = *(myEndOfSwitch->Ports()) ;
2433 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
2434 if ( myPorts[ j ]->IsInput() ) {
2435 aPort = anEndOfSwitch->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2438 aPort = anEndOfSwitch->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2441 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
2442 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
2443 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
2444 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
2445 aPort = anEndOfSwitch->InStreamPort( myStreamSwitchPorts[ j ]->Name(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2448 aPort = anEndOfSwitch->OutStreamPort( myStreamSwitchPorts[ j ]->Name(), myStreamSwitchPorts[ j ]->Type(), myStreamSwitchPorts[ j ]->Dependency() ) ; // mkr : IPAL11394 (add port to !EndSwitch! node)
2461 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
2462 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
2463 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
2465 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
2466 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
2467 SUPERV::Port_var OutPort = aLink->OutPort() ;
2468 SUPERV::Port_var InPort = aLink->InPort() ;
2469 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
2470 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
2471 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2473 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2477 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
2479 RetVal = aLink->Coords( j , X , Y ) ;
2482 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
2484 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
2492 delete aLinkFromNodeName ;
2493 delete aLinkToNodeName ;
2499 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
2500 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
2501 if ( !aPort->IsGate() ) {
2502 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
2503 char * aPortName = aPort->Name() ;
2504 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
2505 strcpy( aNodeName , aPortName ) ;
2506 // char * thePortName = strchr( aNodeName , '\\' ) ;
2507 char * thePortName = aNodeName ;
2508 while ( ( thePortName = strchr( thePortName , '_' ) ) ) {
2509 if ( thePortName[1] == '_' ) {
2510 thePortName[ 0 ] = '\0' ;
2514 thePortName = &thePortName[2] ;
2517 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 2 )->HasInput() ;
2518 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
2519 // << " HasInput " << hasinput << endl ;
2521 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
2523 *(aPort->ToAny()) ) ;
2525 delete [] aNodeName ;
2534 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
2535 endService( "Graph_Impl::Merge" );
2539 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
2540 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
2541 beginService( "Graph_Impl::ToStreamGraph" );
2542 if ( IsStreamGraph() && !IsMacro() ) {
2543 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
2544 // instanceName() , interfaceName() ) ;
2545 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
2546 // CORBA::Object_var obj = _poa->id_to_reference(*id);
2547 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
2548 if ( CORBA::is_nil( iobject ) ) {
2549 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
2553 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
2555 endService( "Graph_Impl::ToStreamGraph" );
2556 return SUPERV::StreamGraph::_duplicate( iobject ) ;
2560 * Destroy Executor and use only Editor and its data model
2562 void Graph_Impl::Editing() {
2563 if ( DataFlowEditor() && DataFlowExecutor() ) {
2564 delete DataFlowExecutor() ;
2565 DataFlowEditor()->Executor( NULL );
2570 * Returns the default name of container for C component
2572 char* Graph_Impl::DefaultCContainerName() {
2573 return ( CORBA::string_dup( FACTORYSERVER ) );
2577 * Returns the default name of container for Python component
2579 char* Graph_Impl::DefaultPythonContainerName() {
2580 return ( CORBA::string_dup( FACTORYSERVERPY ) );
2584 * Returns the last container name associated with theComponentName component
2586 char* Graph_Impl::ContainerNameForComponent( const char * theComponentName ) {
2587 const char* aContainer = DataFlowEditor()->Graph()->RetrieveFromMapOfComponentNameContainer(theComponentName);
2589 return my_strdup(aContainer);