1 // SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : Graph_Impl.cxx
25 // Author : Jean Rahuel
35 //#include "utilities.h"
37 #include "Graph_Impl.hxx"
39 #include "DataFlowEditor_DataFlow.hxx"
41 extern GraphExecutor::FiniteStateMachine * theAutomaton ;
43 Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
44 PortableServer::POA_ptr poa ,
45 PortableServer::ObjectId * contId ,
46 const char *instanceName ,
47 const char *interfaceName ,
48 const char *aDataFlowName ,
49 const SUPERV::KindOfNode aKindOfNode ) :
50 INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName ) {
51 // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName("
52 // << instanceName << ") interfaceName(" << interfaceName << ") --> "
53 // << hex << (void *) this << dec )
54 beginService( "Graph_Impl::Graph_Impl" );
55 _Orb = CORBA::ORB::_duplicate(orb);
58 if ( aKindOfNode == SUPERV::DataFlowGraph ) {
60 _id = _poa->activate_object(_thisObj);
63 string dbgfile = "/tmp/" ;
64 dbgfile += instanceName ;
66 int lenname = strlen( aDataFlowName ) ;
67 char * theDataFlowName = new char [ lenname+1 ] ;
68 strcpy( theDataFlowName , aDataFlowName ) ;
69 if ( aDataFlowName ) {
70 if ( lenname > 4 && !strcmp( &aDataFlowName[ lenname - 4 ] , ".xml" ) ) {
71 strncpy( theDataFlowName , &aDataFlowName[ 0 ] , lenname-4 ) ;
72 theDataFlowName[ lenname-4 ] = '\0' ;
74 for ( i = lenname - 5 ; i >= 0 ; i-- ) {
75 if ( aDataFlowName[ i ] == '/' ) {
76 strncpy( theDataFlowName , &aDataFlowName[ i + 1 ] , lenname-5-i ) ;
77 theDataFlowName[ lenname-5-i ] = '\0' ;
83 strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
85 dbgfile += theDataFlowName ;
88 _DebugFileName = new char[ strlen( dbgfile.c_str() )+1 ] ;
89 strcpy( _DebugFileName , dbgfile.c_str() ) ;
91 _NamingService = new SALOME_NamingService( orb ) ;
92 GraphEditor::DataFlow * aDataFlowEditor ;
93 aDataFlowEditor = new GraphEditor::DataFlow( _Orb , _NamingService ,
94 theDataFlowName , _DebugFileName ,
96 DataFlowEditor( aDataFlowEditor ) ;
97 DataFlowEditor()->Graph()->SetObjImpl( this ) ;
98 pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
99 _DataFlowExecutor = NULL ;
100 delete [] theDataFlowName ;
101 endService( "Graph_Impl::Graph_Impl" );
104 Graph_Impl::Graph_Impl() {
107 Graph_Impl::~Graph_Impl() {
108 beginService( "Graph_Impl::~Graph_Impl" );
109 endService( "Graph_Impl::~Graph_Impl" );
112 void Graph_Impl::destroy() {
113 beginService( "Graph_Impl::destroy" );
114 _poa->deactivate_object(*_id) ;
115 CORBA::release(_poa) ;
117 _thisObj->_remove_ref();
118 // endService( "Graph_Impl::destroy" );
121 char* Graph_Impl::getIOR() {
122 if (CORBA::is_nil(myServant)) {
123 PortableServer::ObjectId* id = getId();
124 CORBA::Object_var obj;
125 obj = _poa->id_to_reference(*id);
126 myServant = SUPERV::Graph::_narrow(obj);
128 return(CORBA::string_dup(_Orb->object_to_string(myServant)));
131 SUPERV::Graph_ptr Graph_Impl::Copy() {
132 beginService( "Graph_Impl::Copy" );
133 Graph_Impl * myGraph ;
134 myGraph = new Graph_Impl( _Orb , _Poa, _ContId,
135 instanceName() , interfaceName() ,
136 DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ;
137 PortableServer::ObjectId * id = myGraph->getId() ;
138 CORBA::Object_var obj = _poa->id_to_reference(*id);
139 SUPERV::Graph_var iobject ;
140 iobject = SUPERV::Graph::_narrow(obj) ;
141 GraphBase::SGraph * aSGraph = GetGraph() ;
142 myGraph->LoadGraph( aSGraph ) ;
143 endService( "Graph_Impl::Copy" );
144 return SUPERV::Graph::_duplicate(iobject) ;
147 void Graph_Impl::ReadOnly() {
148 DataFlowEditor()->ReadOnly() ;
151 SUPERV::INode_ptr Graph_Impl::Node() {
152 // beginService( "Graph_Impl::Node" );
153 PortableServer::ObjectId * id = getId() ;
154 CORBA::Object_var obj = _poa->id_to_reference(*id);
155 SUPERV::Graph_var iobject ;
156 iobject = SUPERV::Graph::_narrow(obj) ;
157 // endService( "Graph_Impl::Node" );
158 return SUPERV::Graph::_duplicate(iobject) ;
161 GraphBase::SGraph * Graph_Impl::GetGraph() {
162 return DataFlowEditor()->GetDataFlow() ;
166 char * Graph_Impl::DataFlowInfo() {
167 beginService( "Graph_Impl::DataFlowInfo" );
168 char * RetVal = DataFlowEditor()->DataFlowInfo() ;
169 endService( "Graph_Impl::DataFlowInfo" );
170 return CORBA::string_dup( RetVal ) ;
173 char * Graph_Impl::DataNodeInfo() {
174 beginService( "Graph_Impl::DataNodeInfo" );
175 char * RetVal = DataFlowEditor()->DataNodeInfo() ;
176 endService( "Graph_Impl::DataNodeInfo" );
177 return CORBA::string_dup( RetVal ) ;
180 char * Graph_Impl::NodeInfo( const char * aNodeName ) {
181 beginService( "Graph_Impl::NodeInfo" );
182 char * RetVal = DataFlowEditor()->NodeInfo( aNodeName ) ;
183 endService( "Graph_Impl::NodeInfo" );
184 return CORBA::string_dup( RetVal ) ;
188 bool Graph_Impl::LoadGraph(const GraphBase::SGraph * aDataFlow ) {
189 // beginService( "Graph_Impl::LoadGraph" );
190 bool RetVal = false ;
191 if ( DataFlowEditor()->IsEditing() ) {
192 RetVal = DataFlowEditor()->LoadDataFlow( aDataFlow ) ;
194 // endService( "Graph_Impl::LoadGraph" );
198 bool Graph_Impl::Import(const char * aXmlFile ) {
199 // beginService( "Graph_Impl::Import" );
200 bool RetVal = false ;
201 if ( DataFlowEditor()->IsEditing() ) {
202 RetVal = DataFlowEditor()->LoadXml( aXmlFile ) ;
204 // endService( "Graph_Impl::Import" );
208 bool Graph_Impl::Export(const char * anXmlFile ) {
209 beginService( "Graph_Impl::Export" );
210 char * aFile = new char [ strlen( anXmlFile ) + 5 ] ;
211 strcpy( aFile , anXmlFile ) ;
212 int len = strlen( aFile ) ;
213 if ( !strcmp( &aFile[ len - 4 ] , ".xml" ) ) {
215 else if ( !strcmp( &aFile[ len - 3 ] , ".py" ) ) {
216 strcpy( &aFile[ len - 3 ] , ".xml" ) ;
217 len = strlen( aFile ) ;
220 strcat( aFile , ".xml" ) ;
221 len = strlen( aFile ) ;
223 bool RetVal = DataFlowEditor()->SaveXml( aFile ) ;
225 strcpy( &aFile[ len - 4 ] , ".py" ) ;
226 RetVal = DataFlowEditor()->SavePy( aFile ) ;
229 endService( "Graph_Impl::Export" );
234 GraphBase::ListOfNodes * Graph_Impl::GetNodes() {
235 // beginService( "Graph_Impl::GetNodes" );
236 GraphBase::ListOfNodes * RetVal = DataFlowEditor()->GetNodes() ;
237 // endService( "Graph_Impl::GetNodes" );
240 GraphBase::ListOfLinks * Graph_Impl::GetLinks() {
241 // beginService( "Graph_Impl::GetLinks" );
242 GraphBase::ListOfLinks * RetVal = DataFlowEditor()->GetLinks() ;
243 // endService( "Graph_Impl::GetLinks" );
246 GraphBase::ListOfLinks * Graph_Impl::GetDatas() {
247 // beginService( "Graph_Impl::GetDatas" );
248 GraphBase::ListOfLinks * RetVal = DataFlowEditor()->GetDatas() ;
249 // endService( "Graph_Impl::GetDatas" );
254 SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
255 beginService( "Graph_Impl::CNode" );
256 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
257 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
258 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
259 instanceName() , interfaceName() ,
261 NodeService , NULLSTRING ,
262 SUPERV::ComputingNode , NULLSTRING ) ;
263 if ( myNode->DataFlowNode() ) {
264 PortableServer::ObjectId * id = myNode->getId() ;
265 CORBA::Object_var obj = _poa->id_to_reference(*id);
266 iobject = SUPERV::CNode::_narrow(obj) ;
267 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
270 endService( "Graph_Impl::CNode" );
271 return SUPERV::CNode::_duplicate( iobject ) ;
274 SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
275 const char * NodeInterfaceName ,
276 const SALOME_ModuleCatalog::Service &NodeService ) {
277 beginService( "Graph_Impl::FNode" );
278 SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
279 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
280 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
281 instanceName() , interfaceName() ,
285 NodeInterfaceName ) ;
286 if ( myNode->DataFlowNode() ) {
287 PortableServer::ObjectId * id = myNode->getId() ;
288 CORBA::Object_var obj = _poa->id_to_reference(*id);
289 iobject = SUPERV::FNode::_narrow(obj) ;
290 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
293 endService( "Graph_Impl::FNode" );
294 return SUPERV::FNode::_duplicate( iobject ) ;
297 SUPERV::INode_ptr Graph_Impl::INode( const char * FuncName ,
298 const SUPERV::ListOfStrings & PythonFuntion ) {
299 beginService( "Graph_Impl::INode" );
300 SUPERV::INode_var iobject = SUPERV::INode::_nil() ;
301 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
302 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
303 instanceName() , interfaceName() ,
305 FuncName , PythonFuntion ,
306 SUPERV::InLineNode ) ;
307 if ( myNode->DataFlowNode() ) {
308 PortableServer::ObjectId * id = myNode->getId() ;
309 CORBA::Object_var obj = _poa->id_to_reference(*id);
310 iobject = SUPERV::INode::_narrow(obj) ;
311 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
314 endService( "Graph_Impl::INode" );
315 return SUPERV::INode::_duplicate( iobject ) ;
319 SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName ,
320 const SUPERV::ListOfStrings & PythonFuntion ,
321 const char * anInLineNode ) {
322 beginService( "Graph_Impl::GNode" );
323 SUPERV::GNode_var iobject = SUPERV::GNode::_nil() ;
324 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
325 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
326 instanceName() , interfaceName() ,
328 FuncName , PythonFuntion ,
330 if ( myNode->DataFlowNode() ) {
331 PortableServer::ObjectId * id = myNode->getId() ;
332 CORBA::Object_var obj = _poa->id_to_reference(*id);
333 iobject = SUPERV::GNode::_narrow(obj) ;
334 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
335 if ( strlen( anInLineNode ) ) {
336 GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ;
337 if ( anInLineNode ) {
338 myNode->SetCoupled( anInLineNode ) ;
339 Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ;
344 endService( "Graph_Impl::GNode" );
345 return SUPERV::GNode::_duplicate( iobject ) ;
348 SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
349 const SUPERV::ListOfStrings & InitFunction ,
350 const char * MoreName ,
351 const SUPERV::ListOfStrings & MoreFunction ,
352 const char * NextName ,
353 const SUPERV::ListOfStrings & NextFunction ,
354 SUPERV::INode_out anEndOfLoop ) {
355 beginService( "Graph_Impl::LNode" );
356 SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
357 SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
358 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
359 GraphBase::ListOfFuncName FuncNameList ;
360 FuncNameList.resize(3) ;
361 FuncNameList[0] = InitName ;
362 FuncNameList[1] = MoreName ;
363 FuncNameList[2] = NextName ;
364 GraphBase::ListOfPythonFunctions PythonFunctionList ;
365 PythonFunctionList.resize(3) ;
366 PythonFunctionList[0] = &InitFunction ;
367 PythonFunctionList[1] = &MoreFunction ;
368 PythonFunctionList[2] = &NextFunction ;
369 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
370 instanceName() , interfaceName() ,
372 FuncNameList , PythonFunctionList ,
373 // InitName , InitFunction ,
374 // MoreName , MoreFunction ,
375 // NextName , NextFunction ,
377 if ( myNode->DataFlowNode() ) {
378 PortableServer::ObjectId * id = myNode->getId() ;
379 CORBA::Object_var obj = _poa->id_to_reference(*id);
380 iobject = SUPERV::LNode::_narrow(obj) ;
381 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
383 SALOME_ModuleCatalog::Service aVoidService = SALOME_ModuleCatalog::Service() ;
385 if ( strlen( InitName ) ) {
386 anEndName = new char( 3 + strlen( InitName ) + 1 ) ;
387 strcpy( anEndName , "End" ) ;
388 strcat( anEndName , InitName ) ;
391 anEndName = new char( 3 + strlen( "Loop" ) + 1 ) ;
392 strcpy( anEndName , "EndLoop" ) ;
394 ELNode_Impl * myEndNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
395 instanceName() , interfaceName() ,
398 SUPERV::EndLoopNode ) ;
399 PortableServer::ObjectId * endid = myEndNode->getId() ;
400 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
401 iendobject = SUPERV::ELNode::_narrow(endobj) ;
402 myEndNode->SetObjRef( SUPERV::ELNode::_duplicate( iendobject ) ) ;
403 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
404 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
405 Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ;
406 Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ;
409 anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ;
410 endService( "Graph_Impl::LNode" );
411 return SUPERV::LNode::_duplicate( iobject ) ;
414 SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
415 const SUPERV::ListOfStrings & PythonFunction ,
416 SUPERV::INode_out anEndOfSwitch ) {
417 beginService( "Graph_Impl::SNode" );
418 SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
419 SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
420 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
421 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
422 instanceName() , interfaceName() ,
424 FuncName , PythonFunction ,
425 SUPERV::SwitchNode ) ;
426 if ( myNode->DataFlowNode() ) {
427 PortableServer::ObjectId * id = myNode->getId() ;
428 CORBA::Object_var obj = _poa->id_to_reference(*id);
429 iobject = SUPERV::SNode::_narrow(obj) ;
430 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
432 string anEndName = "End" ;
433 if ( strlen( FuncName ) ) {
434 anEndName += FuncName ;
437 anEndName += "Switch" ;
439 // cout << "Graph_Impl::SNode anEndName " << (void *) FuncName << " " << FuncName
440 // << " " << strlen(FuncName) << " " << (void *) anEndName.c_str() << " "
441 // << anEndName.c_str() << endl ;
442 ESNode_Impl * myEndNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
443 instanceName() , interfaceName() ,
446 SUPERV::EndSwitchNode ) ;
447 // cout << "Graph_Impl::SNode returned anEndName " << (void *) FuncName << " "
448 // << FuncName << " " << strlen(FuncName) << " " << (void *) anEndName.c_str()
449 // << " " << anEndName.c_str() << endl ;
450 PortableServer::ObjectId * endid = myEndNode->getId() ;
451 CORBA::Object_var endobj = _poa->id_to_reference(*endid);
452 iendobject = SUPERV::ESNode::_narrow(endobj) ;
453 myEndNode->SetObjRef( SUPERV::ESNode::_duplicate( iendobject ) ) ;
454 myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ;
455 myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ;
456 if ( !Link( myNode->Port( "Default" ) , myEndNode->Port( "Default" ) ) ) {
457 iobject = SUPERV::SNode::_nil() ;
458 iendobject = SUPERV::ESNode::_nil() ;
462 anEndOfSwitch = SUPERV::ESNode::_duplicate( iendobject ) ;
463 endService( "Graph_Impl::SNode" );
464 return SUPERV::SNode::_duplicate( iobject ) ;
468 SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
469 // beginService( "Graph_Impl::Node" );
470 SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
472 if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
473 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
474 instanceName() , interfaceName() ,
476 DataFlowEditor()->GetNode( aNodeName ) ) ;
477 PortableServer::ObjectId * id = myNode->getId() ;
478 CORBA::Object_var obj = _poa->id_to_reference(*id);
479 iobject = SUPERV::CNode::_narrow(obj) ;
480 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
483 iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
485 GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
487 if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
488 SetNodeObjRef( anInNode ) ;
490 iobject = anInNode->ObjRef() ;
492 // endService( "Graph_Impl::Node" );
493 return SUPERV::CNode::_duplicate( iobject ) ;
496 SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort ,
497 SUPERV::Port_ptr InPort ) {
498 beginService( "Graph_Impl::Link" );
499 SUPERV::Link_var iobject = SUPERV::Link::_nil() ;
500 if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() &&
501 !OutPort->IsDataStream() && !InPort->IsDataStream() ) {
502 GraphBase::InPort * anInPort = DataFlowEditor()->GetNode( InPort->Node()->Name() )->ComputingNode()->GetChangeInPort( InPort->Name() ) ;
503 GraphBase::OutPort * anOutPort = DataFlowEditor()->GetNode( OutPort->Node()->Name() )->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ;
504 if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
505 const char * DataFlowOutNodeName = OutPort->Node()->Name() ;
506 GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ;
507 const char * DataFlowInNodeName = InPort->Node()->Name() ;
508 GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ;
509 if ( DataFlowOutNode && DataFlowInNode ) {
511 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
512 instanceName() , interfaceName() ,
518 true , false , Success ) ;
520 PortableServer::ObjectId * id = myLink->getId() ;
521 CORBA::Object_var obj = _poa->id_to_reference(*id);
522 iobject = SUPERV::Link::_narrow(obj) ;
523 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
528 iobject = anOutPort->InPortObjRef( anInPort ) ;
531 endService( "Graph_Impl::Link" );
532 return SUPERV::Link::_duplicate( iobject ) ;
535 void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
536 CORBA::Object_var obj ;
537 if ( anInNode->IsComputingNode() ) {
538 CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
539 instanceName() , interfaceName() ,
542 PortableServer::ObjectId * id = myNode->getId() ;
543 obj = _poa->id_to_reference(*id);
544 SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
545 myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
547 else if ( anInNode->IsFactoryNode() ) {
548 FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
549 instanceName() , interfaceName() ,
552 PortableServer::ObjectId * id = myNode->getId() ;
553 obj = _poa->id_to_reference(*id);
554 SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
555 myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
557 else if ( anInNode->IsInLineNode() ) {
558 INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
559 instanceName() , interfaceName() ,
562 PortableServer::ObjectId * id = myNode->getId() ;
563 obj = _poa->id_to_reference(*id);
564 SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
565 myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
567 else if ( anInNode->IsGOTONode() ) {
568 GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
569 instanceName() , interfaceName() ,
572 PortableServer::ObjectId * id = myNode->getId() ;
573 obj = _poa->id_to_reference(*id);
574 SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
575 myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
577 else if ( anInNode->IsLoopNode() ) {
578 LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
579 instanceName() , interfaceName() ,
582 PortableServer::ObjectId * id = myNode->getId() ;
583 obj = _poa->id_to_reference(*id);
584 SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
585 myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
587 else if ( anInNode->IsEndLoopNode() ) {
588 ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
589 instanceName() , interfaceName() ,
592 PortableServer::ObjectId * id = myNode->getId() ;
593 obj = _poa->id_to_reference(*id);
594 SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
595 myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
597 else if ( anInNode->IsSwitchNode() ) {
598 SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
599 instanceName() , interfaceName() ,
602 PortableServer::ObjectId * id = myNode->getId() ;
603 obj = _poa->id_to_reference(*id);
604 SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
605 myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
607 else if ( anInNode->IsEndSwitchNode() ) {
608 ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
609 instanceName() , interfaceName() ,
612 PortableServer::ObjectId * id = myNode->getId() ;
613 obj = _poa->id_to_reference(*id);
614 SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
615 myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
619 SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
620 GraphBase::ComputingNode * aNode ) {
622 if ( _DataFlowExecutor ) {
623 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " "
624 << _DataFlowExecutor->StateName( _DataFlowExecutor->AutomatonState( aNode->Name() ) ) ) ;
627 MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ;
629 if ( aNode->IsComputingNode() ) {
630 index = RetVal->CNodes.length() ;
631 RetVal->CNodes.length( index+1 );
633 else if ( aNode->IsFactoryNode() ) {
634 index = RetVal->FNodes.length() ;
635 RetVal->FNodes.length( index+1 );
637 else if ( aNode->IsInLineNode() ) {
638 index = RetVal->INodes.length() ;
639 RetVal->INodes.length( index+1 );
641 else if ( aNode->IsGOTONode() ) {
642 index = RetVal->GNodes.length() ;
643 RetVal->GNodes.length( index+1 );
645 else if ( aNode->IsLoopNode() ) {
646 index = RetVal->LNodes.length() ;
647 RetVal->LNodes.length( index+1 );
649 else if ( aNode->IsEndLoopNode() ) {
650 index = RetVal->ELNodes.length() ;
651 RetVal->ELNodes.length( index+1 );
653 else if ( aNode->IsSwitchNode() ) {
654 index = RetVal->SNodes.length() ;
655 RetVal->SNodes.length( index+1 );
657 else if ( aNode->IsEndSwitchNode() ) {
658 index = RetVal->ESNodes.length() ;
659 RetVal->ESNodes.length( index+1 );
661 if ( CORBA::is_nil( aNode->ObjRef() ) ) {
662 SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
664 SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
665 if ( aNode->IsComputingNode() ) {
666 RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
668 else if ( aNode->IsFactoryNode() ) {
669 RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
671 else if ( aNode->IsInLineNode() ) {
672 RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
674 else if ( aNode->IsGOTONode() ) {
675 RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
677 else if ( aNode->IsLoopNode() ) {
678 RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
680 else if ( aNode->IsEndLoopNode() ) {
681 RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
683 else if ( aNode->IsSwitchNode() ) {
684 RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
686 else if ( aNode->IsEndSwitchNode() ) {
687 RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
689 return ( RetVal._retn() ) ;
692 SUPERV::ListOfNodes * Graph_Impl::Nodes() {
693 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
694 beginService( "Graph_Impl::Nodes" );
695 RetVal->CNodes.length(0) ;
696 RetVal->FNodes.length(0) ;
697 RetVal->INodes.length(0) ;
698 RetVal->LNodes.length(0) ;
699 RetVal->SNodes.length(0) ;
700 RetVal->GNodes.length(0) ;
702 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
703 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ;
704 RetVal = SetNode( RetVal , aNode ) ;
707 char * aStateG = "" ;
708 if ( _DataFlowExecutor ) {
709 aStateG = (char *) _DataFlowExecutor->StateName( _DataFlowExecutor->AutomatonState() ) ;
711 MESSAGE("Graph_Impl::Nodes GraphState " << aStateG
712 << " CNodes " << RetVal->CNodes.length()
713 << " FNodes " << RetVal->FNodes.length()
714 << " INodes " << RetVal->INodes.length()
715 << " GNodes " << RetVal->GNodes.length()
716 << " LNodes " << RetVal->LNodes.length()
717 << " ELNodes " << RetVal->ELNodes.length()
718 << " SNodes " << RetVal->SNodes.length()
719 << " ESNodes " << RetVal->ESNodes.length() ) ;
720 if ( _DataFlowExecutor ) {
721 _DataFlowExecutor->EventList() ;
724 endService( "Graph_Impl::Nodes" );
725 return ( RetVal._retn() ) ;
728 SUPERV::ListOfLinks * Graph_Impl::GLinks() {
729 return Links( NULL , NULL ) ;
732 SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode ,
733 const char * anInputParam ) {
735 SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ;
736 RetVal->length( 0 ) ;
737 int i , j , countlink ;
739 for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) {
740 GraphEditor::InNode * aNode = NULL ;
741 aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ;
742 bool ToProcess = false ;
743 if ( theNode == NULL ) {
747 if ( !strcmp( theNode->Name() , aNode->Name() ) ) {
748 if ( !theNode->IsEndSwitchNode() ) {
752 else if ( theNode->IsEndSwitchNode() ) {
757 for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
758 GraphBase::InPort * anInPort = NULL ;
759 anInPort = aNode->GetChangeNodeInPort( j ) ;
760 if ( anInputParam == NULL ||
761 !strcmp( anInPort->PortName() , anInputParam ) ) {
762 GraphBase::OutPort * anOutPort = NULL ;
763 anOutPort = anInPort->GetOutPort() ;
764 if ( anOutPort && !anOutPort->IsDataStream() ) {
765 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
766 // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
767 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
768 // << anInPort->PortName() << ")" ) ;
769 if ( theNode == NULL ||
770 ( theNode != NULL && !theNode->IsEndSwitchNode() &&
771 !strcmp( theNode->Name() , aNode->Name() ) ) ) {
772 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
773 ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
774 anOutPort->NodeName() ) ) ) {
775 // MESSAGE( "Link " << anOutPort->NodeName() << "("
776 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
777 // << anInPort->PortName() << ")" << " ignored" ) ;
779 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
781 beginService( "Graph_Impl::Links" );
784 GraphEditor::InNode * anOutNode = NULL ;
785 anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
788 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
789 instanceName() , interfaceName() ,
792 anInPort->PortName() ,
794 anOutPort->PortName() ,
795 false , true , Success ) ;
797 PortableServer::ObjectId * id = myLink->getId() ;
798 CORBA::Object_var obj = _poa->id_to_reference(*id);
799 SUPERV::Link_var iobject ;
800 iobject = SUPERV::Link::_narrow(obj) ;
801 RetVal->length( countlink + 1 ) ;
802 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
803 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
808 RetVal->length( countlink + 1 ) ;
809 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ;
811 // MESSAGE( "Link " << anOutPort->NodeName() << "("
812 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
813 // << anInPort->PortName() << ")" << " selected" ) ;
816 // MESSAGE( "Link " << anOutPort->NodeName() << "("
817 // << anOutPort->PortName() << ") --> " << aNode->Name() << "("
818 // << anInPort->PortName() << ")" << " skipped" ) ;
825 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
826 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ;
828 for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) {
829 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
830 GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
831 if ( theNode == NULL ||
832 !strcmp( theNode->Name() , aNode->Name() ) ) {
833 if ( !anInPort->IsDataStream() ) {
834 if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) {
835 if ( anInputParam == NULL ||
836 !strcmp( anInPort->PortName() , anInputParam ) ) {
837 if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
838 ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
839 anOutPort->NodeName() ) ) ) {
840 // MESSAGE( "Link " << anOutPort->NodeName() << "("
841 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
842 // << anInPort->PortName() << ")" << " ignored" ) ;
844 else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
846 beginService( "Graph_Impl::Links" );
850 Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId ,
851 instanceName() , interfaceName() ,
854 anInPort->PortName() ,
856 anOutPort->PortName() ,
857 false , true , Success ) ;
859 PortableServer::ObjectId * id = myLink->getId() ;
860 CORBA::Object_var obj = _poa->id_to_reference(*id);
861 SUPERV::Link_var iobject ;
862 iobject = SUPERV::Link::_narrow(obj) ;
863 RetVal->length( countlink + 1 ) ;
864 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ;
865 anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ;
869 RetVal->length( countlink + 1 ) ;
870 RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ;
872 // MESSAGE( "Link " << anOutPort->NodeName() << "("
873 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
874 // << anInPort->PortName() << ")" << " selected" ) ;
877 // MESSAGE( "Link " << anOutPort->NodeName() << "("
878 // << anOutPort->PortName() << ") --> " << toNode->Name() << "("
879 // << anInPort->PortName() << ")" << " skipped" ) ;
888 const char * NodeName = "" ;
889 const char * InputParamName = "" ;
891 NodeName = theNode->Name() ;
893 if ( anInputParam ) {
894 InputParamName = anInputParam ;
896 MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ;
897 for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
898 MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "("
899 << RetVal[i]->OutPort()->Name() << ") --> "
900 << RetVal[i]->InPort()->Node()->Name() << "("
901 << RetVal[i]->InPort()->Name() << ")" ) ;
905 endService( "Graph_Impl::Links" );
907 return ( RetVal._retn() ) ;
910 Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer ,
911 const char * aComponentName ) {
912 Engines::Container_var myContainer ;
913 Engines::Component_var objComponent ;
914 DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName ,
915 myContainer , objComponent ) ;
916 return Engines::Component::_duplicate( objComponent ) ;
919 bool Graph_Impl::IsValid() {
920 // beginService( "Graph_Impl::IsValid" );
921 bool RetVal = DataFlowEditor()->IsValid() ;
922 // endService( "Graph_Impl::IsValid" );
925 bool Graph_Impl::IsExecutable() {
926 // beginService( "Graph_Impl::IsExecutable" );
927 bool RetVal = DataFlowEditor()->IsExecutable() ;
928 // endService( "Graph_Impl::IsExecutable" );
932 bool Graph_Impl::IsEditing() {
933 // beginService( "Graph_Impl::IsEditing" );
934 bool RetVal = DataFlowEditor()->IsEditing() ;
935 // endService( "Graph_Impl::IsEditing" );
938 bool Graph_Impl::IsExecuting() {
939 // beginService( "Graph_Impl::IsExecuting" );
940 bool RetVal = !DataFlowEditor()->IsEditing() ;
941 // endService( "Graph_Impl::IsExecuting" );
945 bool Graph_Impl::IsReadOnly() {
946 // beginService( "Graph_Impl::IsExecuting" );
947 bool RetVal = DataFlowEditor()->IsReadOnly() ;
948 // endService( "Graph_Impl::IsExecuting" );
952 long Graph_Impl::LevelMax() {
953 // beginService( "Graph_Impl::LevelMax" );
954 long RetVal = DataFlowEditor()->LevelMax() ;
955 // endService( "Graph_Impl::LevelMax" );
958 SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) {
959 // beginService( "Graph_Impl::LevelNodes" );
960 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes;
962 SUPERV::ListOfStrings_var Nodes = DataFlowEditor()->LevelNodes( aLevel ) ;
963 // RetVal->length( Nodes->length() );
964 for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) {
965 // char * aNode = Nodes[ i ] ;
966 GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ;
967 RetVal = SetNode( RetVal , aNode ) ;
968 // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ;
969 // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
970 // instanceName() , interfaceName() ,
971 // DataFlowEditor() ,
972 // (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( aNode )->GetInNode() ) ;
973 // PortableServer::ObjectId * id = myNode->getId() ;
974 // CORBA::Object_var obj = _poa->id_to_reference(*id);
975 // SUPERV::CNode_var iobject ;
976 // iobject = SUPERV::CNode::_narrow(obj) ;
977 // RetVal[i] = SUPERV::CNode::_duplicate( iobject ) ;
979 // endService( "Graph_Impl::LevelNodes" );
980 return ( RetVal._retn() ) ;
982 long Graph_Impl::ThreadsMax() {
983 // beginService( "Graph_Impl::ThreadsMax" );
984 long RetVal = DataFlowEditor()->ThreadsMax() ;
985 // endService( "Graph_Impl::ThreadsMax" );
988 long Graph_Impl::Threads() {
989 // beginService( "Node_Impl::Threads" );
990 long RetVal = _DataFlowExecutor->Threads() ;
991 // endService( "Node_Impl::Threads" );
994 long Graph_Impl::SuspendedThreads() {
995 // beginService( "Node_Impl::SuspendedThreads" );
996 long RetVal = _DataFlowExecutor->SuspendedThreads() ;
997 // endService( "Node_Impl::SuspendedThreads" );
1001 bool Graph_Impl::Begin() {
1002 bool RetVal = false ;
1003 if ( DataFlowEditor()->IsEditing() ) {
1004 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1005 perror("pthread_mutex_lock _MutexExecutorWait") ;
1008 if ( _DataFlowExecutor ) {
1009 MESSAGE( "Graph_Impl::Begin " << _DataFlowExecutor->Threads() << " threads" )
1010 if ( _DataFlowExecutor->Threads() ) {
1011 _DataFlowExecutor->JoinedWait() ;
1013 delete _DataFlowExecutor ;
1014 _DataFlowExecutor = NULL ;
1015 DataFlowEditor()->Executor( NULL ) ;
1017 DataFlowEditor()->EditedAfterExecution( false ) ;
1018 int _ExecNumber = theAutomaton->ExecNumber() ;
1019 char ExecNumber[30] ;
1020 sprintf( ExecNumber , "_%d" , _ExecNumber ) ;
1021 int len = strlen( _DebugFileName ) ;
1022 char * DebugFileName = new char [ len + strlen( ExecNumber ) + 6 ] ;
1023 strncpy( DebugFileName , _DebugFileName , len - 4 ) ;
1024 DebugFileName[ len - 4 ] = '\0' ;
1025 strcat( DebugFileName , ExecNumber ) ;
1026 strcat( DebugFileName , "_Exec.log" ) ;
1027 GraphBase::SGraph * myGraph = DataFlowEditor()->GetDataFlow() ;
1028 _DataFlowExecutor = new GraphExecutor::DataFlow( _Orb , _NamingService ,
1029 myGraph->Info.theName.c_str() ,
1030 DebugFileName , Kind() ) ;
1031 MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" );
1032 RetVal = _DataFlowExecutor->LoadDataFlow( *myGraph ) ;
1034 _DataFlowExecutor->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ;
1035 DataFlowEditor()->Executor( _DataFlowExecutor ) ;
1037 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1038 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1044 bool Graph_Impl::Run() {
1045 beginService( "Graph_Impl::Run" );
1046 bool RetVal = false ;
1047 if ( DataFlowEditor()->IsEditing() ) {
1048 MESSAGE( "Graph_Impl::Run IsEditing" );
1051 MESSAGE( "Graph_Impl::(Re)Run " );
1052 RetVal = CNode_Impl::Run() ;
1056 MESSAGE( "Graph_Impl::(Re)Run " );
1057 RetVal = CNode_Impl::ReRun() ;
1059 endService( "Graph_Impl::Run" );
1062 bool Graph_Impl::Start() {
1063 beginService( "Graph_Impl::Start" );
1064 bool RetVal = false ;
1065 if ( DataFlowEditor()->IsEditing() ) {
1066 MESSAGE( "Graph_Impl::Start IsEditing" );
1073 MESSAGE( "Graph_Impl::(Re)Start " );
1074 RetVal = ReStart() ;
1076 endService( "Graph_Impl::Start" );
1080 bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode ,
1081 SUPERV::GraphEvent & anEvent ,
1082 SUPERV::GraphState & aState ) {
1083 bool RetVal = false ;
1084 char * aNodeName = NULL ;
1085 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1086 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1087 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1088 perror("pthread_mutex_lock _MutexExecutorWait") ;
1091 if ( _DataFlowExecutor &&
1092 ( _DataFlowExecutor->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1093 RetVal = _DataFlowExecutor->Event( & aNodeName , theEvent , theState , false ) ;
1094 // endService( "Graph_Impl::Event" );
1095 if ( strlen( aNodeName ) ) {
1096 if ( strcmp( aNodeName , Name() ) ) {
1097 aNode = Node( aNodeName ) ;
1104 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1106 // cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << _DataFlowExecutor->GetListSize() << endl ;
1109 // cout << "Graph_Impl::EventNoW NO DataFlowExecutor or QSize=0 " << endl ;
1111 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1112 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1115 anEvent = theEvent ;
1120 bool Graph_Impl::Event( SUPERV::CNode_out aNode ,
1121 SUPERV::GraphEvent & anEvent ,
1122 SUPERV::GraphState & aState ) {
1123 // beginService( "Graph_Impl::Event" );
1124 bool RetVal = false ;
1125 char * aNodeName = NULL ;
1126 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1127 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1128 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1129 perror("pthread_mutex_lock _MutexExecutorWait") ;
1132 if ( _DataFlowExecutor &&
1133 ( _DataFlowExecutor->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
1134 RetVal = _DataFlowExecutor->Event( & aNodeName , theEvent , theState ) ;
1135 // endService( "Graph_Impl::Event" );
1136 if ( strlen( aNodeName ) ) {
1137 if ( strcmp( aNodeName , Name() ) ) {
1138 aNode = Node( aNodeName ) ;
1145 aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
1147 // cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << _DataFlowExecutor->GetListSize() << endl ;
1150 // cout << "Graph_Impl::Event NO DataFlowExecutor or QSize=0 " << endl ;
1152 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1153 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1156 anEvent = theEvent ;
1161 bool Graph_Impl::EventW( SUPERV::CNode_out aNode ,
1162 SUPERV::GraphEvent & anEvent ,
1163 SUPERV::GraphState & aState ) {
1164 // beginService( "Graph_Impl::EventW" );
1165 bool RetVal = false ;
1166 char * aNodeName = NULL ;
1167 SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
1168 SUPERV::GraphState theState = SUPERV::UndefinedState ;
1169 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1170 perror("pthread_mutex_lock _MutexExecutorWait") ;
1173 if ( _DataFlowExecutor &&
1174 ( _DataFlowExecutor->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
1175 RetVal = _DataFlowExecutor->EventW( & aNodeName , theEvent , theState ) ;
1176 if ( RetVal && strcmp( aNodeName , Name() ) ) {
1177 aNode = Node( aNodeName ) ;
1183 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1184 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1187 anEvent = theEvent ;
1189 // endService( "Graph_Impl::EventW" );
1193 long Graph_Impl::EventQSize() {
1194 // beginService( "Graph_Impl::EventQSize" );
1196 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1197 perror("pthread_mutex_lock _MutexExecutorWait") ;
1200 if ( _DataFlowExecutor ) {
1201 QSize = _DataFlowExecutor->EventQSize() ;
1203 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1204 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1207 // endService( "Graph_Impl::EventQSize" );
1211 long Graph_Impl::LastLevelDone() {
1212 // beginService( "Graph_Impl::LastLevelDone" );
1213 if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
1214 perror("pthread_mutex_lock _MutexExecutorWait") ;
1218 if ( _DataFlowExecutor ) {
1219 RetVal = _DataFlowExecutor->LastLevelDone() ;
1221 if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
1222 perror("pthread_mutex_unlock _MutexExecutorWait") ;
1225 // endService( "Graph_Impl::LastLevelDone" );
1229 long Graph_Impl::SubGraphsNumber() {
1230 // beginService( "Graph_Impl::SubGraphsNumber" );
1232 if ( DataFlowEditor()->IsExecutable() ) {
1233 RetVal = DataFlowEditor()->SubGraphsNumber() ;
1235 // endService( "Graph_Impl::SubGraphsNumber" );
1239 SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) {
1240 beginService( "Graph_Impl::SubGraphsNodes" );
1241 SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ;
1242 if ( DataFlowEditor()->IsEditing() ) {
1243 SUPERV::ListOfNodes * aGraphNodes = Nodes() ;
1246 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
1247 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
1248 if ( aNode->SubGraph() == aSubGraphNumber ) {
1249 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1253 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
1254 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
1255 if ( aNode->SubGraph() == aSubGraphNumber ) {
1256 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1260 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
1261 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
1262 if ( aNode->SubGraph() == aSubGraphNumber ) {
1263 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1267 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
1268 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
1269 if ( aNode->SubGraph() == aSubGraphNumber ) {
1270 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1274 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
1275 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
1276 if ( aNode->SubGraph() == aSubGraphNumber ) {
1277 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1281 for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) {
1282 SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ;
1283 if ( aNode->SubGraph() == aSubGraphNumber ) {
1284 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1288 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
1289 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
1290 if ( aNode->SubGraph() == aSubGraphNumber ) {
1291 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1295 for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) {
1296 SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ;
1297 if ( aNode->SubGraph() == aSubGraphNumber ) {
1298 RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ;
1302 endService( "Graph_Impl::SubGraphsNodes" );
1303 return ( RetVal._retn() ) ;
1306 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
1307 // beginService( "Graph_Impl::Merge" );
1308 bool RetVal = true ;
1309 map< string , int > aMapOfNodes ;
1310 RetVal = Merge( aGraph , aMapOfNodes ) ;
1311 // endService( "Graph_Impl::Merge" );
1315 bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) {
1316 beginService( "Graph_Impl::Merge" );
1317 bool RetVal = true ;
1318 if ( DataFlowEditor()->IsEditing() ) {
1319 SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
1321 SUPERV::Port_ptr aPort ;
1322 // SUPERV::StreamPort_ptr aStreamPort ;
1324 for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
1325 SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
1326 SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
1327 if ( !CORBA::is_nil( myNode ) ) {
1328 myNode->SetName( aNode->Name() ) ;
1329 myNode->SetAuthor( aNode->Author() ) ;
1330 myNode->SetComment( aNode->Comment() ) ;
1331 myNode->Coords( aNode->X() , aNode->Y() ) ;
1332 string * aNodetheName = new string( aNode->Name() ) ;
1333 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
1334 delete aNodetheName ;
1341 // The following informations are now in the service from SALOME_ModuleCatalog
1342 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
1344 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
1345 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
1346 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
1348 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
1349 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
1355 for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
1356 SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
1357 SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
1358 aNode->GetInterfaceName() ,
1359 *(aNode->Service()) ) ;
1360 if ( !CORBA::is_nil( myNode ) ) {
1361 myNode->SetName( aNode->Name() ) ;
1362 myNode->SetAuthor( aNode->Author() ) ;
1363 myNode->SetComment( aNode->Comment() ) ;
1364 myNode->Coords( aNode->X() , aNode->Y() ) ;
1365 string * aNodetheName = new string( aNode->Name() ) ;
1366 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
1367 delete aNodetheName ;
1374 // The following informations are now in the service from SALOME_ModuleCatalog
1375 // SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
1377 // for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
1378 // if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) {
1379 // aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
1381 // else if ( myStreamPorts[ j ]->IsDataStream() ) {
1382 // aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ;
1389 for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
1390 SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
1391 SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
1392 if ( !CORBA::is_nil( myNode ) ) {
1393 myNode->SetName( aNode->Name() ) ;
1394 myNode->SetAuthor( aNode->Author() ) ;
1395 myNode->SetComment( aNode->Comment() ) ;
1396 myNode->Coords( aNode->X() , aNode->Y() ) ;
1397 string * aNodetheName = new string( aNode->Name() ) ;
1398 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
1399 delete aNodetheName ;
1400 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
1402 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
1403 if ( myPorts[ j ]->IsInput() ) {
1404 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1407 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1410 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
1411 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
1412 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
1413 if ( myStreamPorts[ j ]->IsInput() ) {
1414 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1417 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1431 for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
1432 SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
1433 SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
1434 if ( !CORBA::is_nil( myNode ) ) {
1435 myNode->SetName( aNode->Name() ) ;
1436 myNode->SetAuthor( aNode->Author() ) ;
1437 myNode->SetComment( aNode->Comment() ) ;
1438 myNode->Coords( aNode->X() , aNode->Y() ) ;
1439 string * aNodetheName = new string( aNode->Name() ) ;
1440 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
1441 delete aNodetheName ;
1442 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
1444 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
1445 if ( myPorts[ j ]->IsInput() ) {
1446 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1449 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1452 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
1453 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
1454 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
1455 if ( myStreamPorts[ j ]->IsInput() ) {
1456 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1459 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1473 for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
1474 SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
1475 SUPERV::INode_ptr anEndOfLoop ;
1476 SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
1477 *(aNode->PyInit()) ,
1478 aNode->PyMoreName() ,
1479 *(aNode->PyMore()) ,
1480 aNode->PyNextName() ,
1481 *(aNode->PyNext()) ,
1483 if ( !CORBA::is_nil( myNode ) ) {
1484 myNode->SetName( aNode->Name() ) ;
1485 myNode->SetAuthor( aNode->Author() ) ;
1486 myNode->SetComment( aNode->Comment() ) ;
1487 myNode->Coords( aNode->X() , aNode->Y() ) ;
1488 string * aNodetheName = new string( aNode->Name() ) ;
1489 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
1490 delete aNodetheName ;
1491 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
1493 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
1494 if ( myPorts[ j ]->IsInput() ) {
1495 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1498 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1501 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
1502 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
1503 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
1504 if ( myStreamPorts[ j ]->IsInput() ) {
1505 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1508 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1512 SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
1513 anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
1514 anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
1515 anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
1516 anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
1517 anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
1518 aNodetheName = new string( myEndOfLoop->Name() ) ;
1519 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
1520 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
1521 SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ;
1522 for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) {
1523 if ( myStreamLoopPorts[ j ]->IsInput() ) {
1524 aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
1527 aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ;
1531 delete aNodetheName ;
1542 for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
1543 SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
1544 SUPERV::INode_ptr anEndOfSwitch ;
1545 SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
1546 if ( !CORBA::is_nil( myNode ) ) {
1547 myNode->SetName( aNode->Name() ) ;
1548 myNode->SetAuthor( aNode->Author() ) ;
1549 myNode->SetComment( aNode->Comment() ) ;
1550 myNode->Coords( aNode->X() , aNode->Y() ) ;
1551 string * aNodetheName = new string( aNode->Name() ) ;
1552 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ;
1553 delete aNodetheName ;
1554 SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
1556 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
1557 if ( myPorts[ j ]->IsInput() ) {
1558 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1561 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1564 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
1565 SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ;
1566 for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) {
1567 if ( myStreamPorts[ j ]->IsInput() ) {
1568 aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1571 aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ;
1575 SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
1576 anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
1577 anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
1578 anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
1579 anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
1580 anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
1581 aNodetheName = new string( myEndOfSwitch->Name() ) ;
1582 aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
1583 delete aNodetheName ;
1584 myPorts = *(myEndOfSwitch->Ports()) ;
1585 for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
1586 if ( myPorts[ j ]->IsInput() ) {
1587 aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1590 aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
1593 if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) {
1594 SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ;
1595 for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) {
1596 if ( myStreamSwitchPorts[ j ]->IsInput() ) {
1597 aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
1600 aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ;
1613 SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
1614 SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
1615 // cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
1617 for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
1618 SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
1619 SUPERV::Port_var OutPort = aLink->OutPort() ;
1620 SUPERV::Port_var InPort = aLink->InPort() ;
1621 string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ;
1622 string * aLinkToNodeName = new string( InPort->Node()->Name() ) ;
1623 RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
1625 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
1629 for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
1631 RetVal = aLink->Coords( j , X , Y ) ;
1634 RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
1636 DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
1644 delete aLinkFromNodeName ;
1645 delete aLinkToNodeName ;
1651 for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
1652 SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
1653 if ( !aPort->IsGate() ) {
1654 MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ;
1655 char * aPortName = aPort->Name() ;
1656 char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
1657 strcpy( aNodeName , aPortName ) ;
1658 char * thePortName = strchr( aNodeName , '\\' ) ;
1659 thePortName[ 0 ] = '\0' ;
1660 bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ;
1661 // cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
1662 // << " HasInput " << hasinput << endl ;
1664 RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
1666 *(aPort->ToAny()) ) ;
1668 delete [] aNodeName ;
1677 MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ;
1678 endService( "Graph_Impl::Merge" );
1682 SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() {
1683 SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ;
1684 beginService( "Graph_Impl::ToStreamGraph" );
1685 if ( IsStreamGraph() ) {
1686 // StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId ,
1687 // instanceName() , interfaceName() ) ;
1688 // PortableServer::ObjectId * id = myStreamGraph->getId() ;
1689 // CORBA::Object_var obj = _poa->id_to_reference(*id);
1690 iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ;
1691 if ( CORBA::is_nil( iobject ) ) {
1692 MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ;
1696 MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ;
1698 endService( "Graph_Impl::ToStreamGraph" );
1699 return SUPERV::StreamGraph::_duplicate( iobject ) ;