1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
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 : DataFlowBase_Graph.cxx
25 // Author : Jean Rahuel, CEA
30 #include "DataFlowBase_Graph.hxx"
32 #include "SALOME_LifeCycleCORBA.hxx"
34 GraphBase::Graph::Graph() :
36 cdebug << "GraphBase::Graph::Graph" << endl ;
40 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
41 SALOME_NamingService* ptrNamingService ,
42 const char *DataFlowName ,
43 const char * DebugFileName ) :
44 DataNode( ORB ,ptrNamingService , DataFlowName ) {
45 cdebug << "GraphBase::Graph::Graph" << endl ;
46 _Orb = CORBA::ORB::_duplicate( ORB ) ;
48 Set_prof_debug( ORB , DebugFileName ) ;
51 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
52 SALOME_NamingService* ptrNamingService ,
53 const SALOME_ModuleCatalog::Service& DataFlowService ,
54 const char *DataFlowComponentName ,
55 const char *DataFlowInterfaceName ,
56 const char *DataFlowName ,
57 const SUPERV::KindOfNode DataFlowkind ,
58 const SUPERV::SDate DataFlowFirstCreation ,
59 const SUPERV::SDate DataFlowLastModification ,
60 const char * DataFlowEditorRelease ,
61 const char * DataFlowAuthor ,
62 const char * DataFlowComputer ,
63 const char * DataFlowComment ,
64 const char * DebugFileName ) :
65 DataNode( ORB , ptrNamingService , DataFlowService ,
66 DataFlowName , DataFlowkind ,
67 DataFlowFirstCreation , DataFlowLastModification ,
68 DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
69 _Orb = CORBA::ORB::_duplicate( ORB ) ;
71 Set_prof_debug( ORB , DebugFileName ) ;
72 cdebug_in << "GraphBase::Graph::Graph" << endl ;
73 DataService( ORB , DataFlowService , Graph_prof_debug() , Graph_fdebug() ) ;
74 cdebug_out << "GraphBase::Graph::Graph" << endl ;
77 GraphBase::Graph::~Graph() {
78 cdebug << "GraphBase::Graph::~Graph" << endl ;
81 void GraphBase::Graph::Set_prof_debug( CORBA::ORB_ptr ORB ,
82 const char * DebugFileName ) {
83 _Graph_prof_debug = 0 ;
84 if ( DebugFileName ) {
85 _Graph_fdebug = new ofstream( DebugFileName );
86 MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl)
89 _Graph_fdebug = &(std::cerr);
90 SetDebug( ORB , &_Graph_prof_debug , _Graph_fdebug ) ;
93 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
94 GraphBase::SNode * Info = new GraphBase::SNode ;
95 Info->theComponentName = "" ;
96 Info->theInterfaceName = "" ;
97 Info->theName = Name() ;
98 Info->theKind = Kind() ;
99 Info->theService = *GetService() ;
100 Info->theFirstCreation = FirstCreation() ;
101 Info->theLastModification = LastModification() ;
102 Info->theEditorRelease = EditorRelease() ;
103 Info->theAuthor = Author() ;
104 Info->theContainer = "" ;
105 Info->theComment = Comment() ;
106 Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
107 Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
111 //----------------------------------------------------------------------
112 // Function : GetNodes
113 // Purpose : get a nodes list
114 //----------------------------------------------------------------------
115 GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const {
116 GraphBase::ListOfNodes * _list_nodes =
117 new GraphBase::ListOfNodes;
119 // All the nodes from _InNodes are taken
120 // vector< InNode *> Nodes = InNodes() ;
122 _list_nodes->resize( GraphNodesSize() );
126 GraphBase::ComputingNode * aCNode = NULL ;
127 for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
128 for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
129 aCNode = GraphNodes( ind ) ;
130 if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
131 ( igoto == 1 && aCNode->IsGOTONode() ) ) {
132 if ( aCNode->IsFactoryNode() ) {
133 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
134 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
135 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
138 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
139 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
141 (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
142 (*_list_nodes)[ind].theKind = aCNode->Kind();
143 if ( aCNode->IsInLineNode() ) {
144 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
145 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
146 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
147 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
148 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
150 if ( aCNode->IsGOTONode() ) {
151 GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
152 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
153 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
154 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
155 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
157 if ( aCNode->IsLoopNode() ) {
158 GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
159 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
160 (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
161 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
162 (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
163 (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
164 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
165 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
166 (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
167 (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
169 else if ( aCNode->IsSwitchNode() ) {
170 GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
171 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
172 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
173 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
174 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
175 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
177 else if ( aCNode->IsEndLoopNode() ) {
178 GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
179 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
180 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
181 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
182 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
183 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
185 else if ( aCNode->IsEndSwitchNode() ) {
186 GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
187 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
188 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
189 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
190 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
191 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
194 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
196 (*_list_nodes)[ind].theService = *aCNode->GetService();
197 // (*_list_nodes)[ind].theListOfParameters = *aCNode->GetListOfParameters() ;
198 if ( aCNode->IsOneOfInLineNodes() ) {
199 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
200 GraphBase::LoopNode * aLNode = NULL ;
201 if ( aCNode->IsLoopNode() ) {
202 aLNode = (GraphBase::LoopNode * ) aCNode ;
203 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
204 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
205 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
206 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
208 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
209 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
210 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
211 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
214 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
215 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
216 (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
217 (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
218 if ( aCNode->IsFactoryNode() ) {
219 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
220 (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
223 (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
225 (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
226 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
227 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
231 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
232 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
233 if ( anInPort->IsBus() ) {
235 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
236 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
237 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
238 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
239 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
250 //----------------------------------------------------------------------
251 // Function : GetLinks
252 // Purpose : get a links list
253 //----------------------------------------------------------------------
254 GraphBase::ListOfLinks * GraphBase::Graph::GetLinks() const {
255 GraphBase::ListOfLinks * _list_links =
256 new GraphBase::ListOfLinks;
258 // All the links from _LinksList are taken
259 // vector< InNode *> Nodes = InNodes() ;
263 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
264 GraphBase::ComputingNode * aNode = GraphNodes( k ) ;
266 for ( i = 0 ; i < aNode->GetNodeOutPortsSize() ; i++ ) {
267 const GraphBase::OutPort* fromPort = aNode->GetNodeOutPort( i ) ;
268 // cout << "GraphBase::Graph::GetLinks " << aNode->Name() << " "
269 // << fromPort->PortName() << " " << fromPort->IsPortConnected()
270 // << " " << fromPort->InPortsSize() << endl ;
271 if ( fromPort->IsPortConnected() ) {
273 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
274 _list_links->resize( ind+1 );
275 (*_list_links)[ind].FromNodeName = CORBA::string_dup( aNode->Name() );
276 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
277 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
278 (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
279 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
280 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
281 if ( toPort->IsEndSwitch() ) {
282 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
285 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
295 GraphBase::ListOfGraphs * GraphBase::Graph::GetGraphs() const {
296 GraphBase::ListOfGraphs * _list_graphs =
297 new GraphBase::ListOfGraphs;
302 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
303 GraphBase::InPort* toPort ) {
304 GraphBase::SLink * _link = new GraphBase::SLink ;
305 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
306 _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
307 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
308 _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
309 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
310 CORBA::Any aSPValue = *fromPort->Value() ;
311 _link->aLinkValue = aSPValue;
312 _link->aListOfCoords = *(toPort->Coords()) ;
315 //----------------------------------------------------------------------
316 // Function : GetDatas
317 // Purpose : get the datas list
318 //----------------------------------------------------------------------
319 GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const {
320 GraphBase::ListOfLinks * _list_datalinks =
321 new GraphBase::ListOfLinks;
324 const GraphBase::DataNode * aDataNode = this ;
326 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
327 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
328 if ( fromDataPort->IsDataConnected() ) {
330 //We may have SharedData as input of a DataFlow : same input for one or several
331 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
332 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
333 _list_datalinks->resize( ind+1 );
334 (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
335 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
336 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
337 (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
338 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
339 CORBA::Any aSPValue = *fromDataPort->Value() ;
340 (*_list_datalinks)[ind].aLinkValue = aSPValue;
341 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
347 // Output(s) of a DataFlow match only one input-virtual-dataport
348 for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
349 GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
350 const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
351 if ( fromPort->IsDataConnected() ) {
352 _list_datalinks->length( ind+1 );
353 _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
354 _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
355 _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
356 _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
357 // SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
358 CORBA::Any aSPValue = *fromPort->Value() ;
359 // aSPValue.Value = CORBA::string_dup( fromPort->Value() );
360 // aSPValue.Kind = fromPort->Kind();
361 _list_datalinks[ind].aLinkValue = aSPValue;
362 _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
367 return _list_datalinks ;
370 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
371 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " "
372 << aNode->Name() << " " << aNode->ServiceName() << endl;
373 bool RetVal = false ;
374 int index = GetGraphNodeIndex( aNode->Name() ) ;
376 _GraphNodes.resize( _GraphNodesSize+1 ) ;
377 _GraphNodes[ _GraphNodesSize ] = aNode ;
378 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
379 _GraphNodesSize += 1 ;
382 // cout << "GraphBase::Graph::AddNode(" << aNode->ComponentName() << " , "
383 // << aNode->Name() << ")" << endl;
385 cdebug << "GraphBase::Graph::AddNode Known nodes :" << endl ;
386 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
387 cdebug << i << ". " << GetGraphNode( i )->Name() << " "
388 << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
390 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
391 << aNode->ServiceName() << endl;
395 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
396 const char* NewNodeName ) {
397 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , "
398 << NewNodeName << ")" << endl;
400 bool RetVal = false ;
401 if ( !strcmp( OldNodeName , NewNodeName ) ) {
404 else if ( strcmp( Name() , OldNodeName ) ) {
405 int index = GetGraphNodeIndex( OldNodeName ) ;
406 int newindex = GetGraphNodeIndex( NewNodeName ) ;
407 if ( index >= 0 && index < _GraphNodesSize &&
408 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
409 _GraphNodes[ index ]->Name( NewNodeName ) ;
410 _MapOfGraphNodes.erase( OldNodeName ) ;
411 SetGraphNodeIndex( NewNodeName , index ) ;
413 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
414 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
415 cdebug << i << ". GraphBase::Graph::ReNameNode of LinkedNode : from " ;
416 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
417 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
419 cdebug << anOutPort->NodeName() ;
422 cdebug << "without link" ;
424 cdebug << " to " << i << ". " << anInPort->PortName()
425 << " of " << NewNodeName ;
426 if ( anInPort->IsConnected() ) {
427 if ( anOutPort->IsDataConnected() ) {
428 cdebug << " fromDataConnected "
429 << anOutPort->NodeName()
433 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
434 cdebug << " fromConnected " << FromNode->Name() << endl ;
435 FromNode->ReNameLink( OldNodeName , NewNodeName ) ;
437 char* OldNodePortName = new char[ strlen( OldNodeName ) +
438 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
439 char* NewNodePortName = new char[ strlen( NewNodeName ) +
440 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
441 strcpy( OldNodePortName , OldNodeName ) ;
442 strcat( OldNodePortName , "\\" ) ;
443 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
444 strcpy( NewNodePortName , NewNodeName ) ;
445 strcat( NewNodePortName , "\\" ) ;
446 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
447 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
448 delete [] OldNodePortName ;
449 delete [] NewNodePortName ;
454 cdebug << " not connected" << endl ;
461 cdebug << "Node not found" << endl ;
465 RetVal = Name( NewNodeName ) ;
468 cdebug_out << "GraphBase::Graph::ReNameNode" << endl;
472 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
473 cdebug_in << "GraphBase::Graph::RemoveNode (" << aNodeName << ")" << endl;
475 bool RetVal = false ;
476 int index = GetGraphNodeIndex( aNodeName ) ;
477 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
479 if ( aNode->GetNodeInPortsSize() ) {
480 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
481 cdebug << i << ". GraphBase::Graph::RemoveNode of LinkedNode : from " ;
482 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
483 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
485 cdebug << anOutPort->NodeName() ;
488 cdebug << "without link" ;
490 cdebug << " to " << i << ". " << anInPort->PortName()
491 << " of " << aNodeName ;
492 if ( anInPort->IsConnected() ) {
493 if ( anOutPort->IsDataConnected() ) {
494 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
497 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
498 cdebug << " fromConnected " << FromNode->Name() << endl ;
499 FromNode->RemoveLink( aNode ) ;
501 RetVal = anOutPort->RemoveInPort( anInPort ) ;
506 cdebug << " not connected" << endl ;
515 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
516 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
517 cdebug << "GraphBase::Graph::Remove " <<anOutPort->InPortsSize()
518 << " Links of OutPort : " << i << ". "
519 << *aNode->GetChangeNodeOutPort( i ) ;
521 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
522 cdebug << " to " << j << ". " << *anOutPort->InPorts( j )
524 RetVal = anOutPort->ChangeInPorts( j )->RemoveOutPort() ;
527 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anOutPort->InPorts( j )->NodeName() ) ;
528 aNode->RemoveLink( ToNode ) ;
529 RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
533 // RetVal = aNode->GetChangeNodeOutPort( j )->RemoveLinks() ;
538 // RetVal = aNode->RemoveLinks() ; // In PortsOfNode
541 _GraphNodesSize -= 1 ;
542 for ( i = index ; i < _GraphNodesSize ; i++ ) {
543 SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
544 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
546 _GraphNodes.resize( _GraphNodesSize+1 ) ;
547 _MapOfGraphNodes.erase( aNodeName ) ;
552 cdebug << "Node not found" << endl ;
554 cdebug_out << "GraphBase::Graph::RemoveNode" << endl;
558 bool GraphBase::Graph::AddLink(
559 const char* FromNodeName ,
560 const char* FromServiceParameterName ,
561 const char* ToNodeName ,
562 const char* ToServiceParameterName ,
563 const CORBA::Any aValue ) {
566 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
567 << FromServiceParameterName << ") ---> " << ToNodeName << "("
568 << ToServiceParameterName << ") )" << endl;
570 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
571 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
573 GraphBase::OutPort *fromPort = NULL ;
574 GraphBase::InPort *toPort = NULL ;
577 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
579 cdebug << "AddLink fromPort " << FromServiceParameterName << " FromNode("
580 << FromNodeName << ") not found." << endl ;
584 cdebug << "AddLink FromNode " << FromNodeName << " not found." << endl ;
587 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
589 cdebug << "AddLink toPort " << ToServiceParameterName << " ToNode("
590 << ToNodeName << ") not found." << endl ;
594 cdebug << "AddLink toNode " << ToNodeName << " not found." << endl ;
597 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
600 if ( fromPort->IsGate() && toPort->IsGate() ) {
602 aValue <<= (long ) 1 ;
603 fromPort->Value( aValue ) ;
606 const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
607 fromPort->Value( aDataValue ) ;
611 cdebug_out << "GraphBase::Graph::AddLink" << endl;
615 bool GraphBase::Graph::AddLink(
616 GraphBase::ComputingNode *fromNode ,
617 GraphBase::OutPort *fromPort ,
618 GraphBase::ComputingNode *toNode ,
619 GraphBase::InPort *toPort ) {
623 cdebug << "AddLink fromNode not found." << endl ;
627 cdebug << "AddLink fromPort not found." << endl ;
632 cdebug << "AddLink toNode not found." << endl ;
636 cdebug << "AddLink toPort not found." << endl ;
640 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
641 << fromPort->PortName() << ") ---> " << toNode->Name() << "("
642 << toPort->PortName() << ") )" << endl;
643 if ( !fromNode->IsDataFlowNode() && !toNode->IsDataFlowNode() &&
644 toPort->GetOutPort() ) {
645 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
646 fromPort->NodePortName() ) ) {
647 cdebug << "Link already exists" << endl ;
648 cdebug_out << "GraphBase::Graph::AddLink" << endl;
651 else if ( toPort->IsDataConnected() ) {
652 toPort->RemoveOutPort() ;
654 else if ( fromNode->IsGOTONode() ) {
655 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
656 toPort->GetOutPort()->PortName() ,
657 toNode->Name() , toPort->PortName() ) ) {
658 cdebug << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() Error."
660 cdebug_out << "GraphBase::Graph::AddLink" << endl;
663 if ( fromPort->InPortsSize() ) {
664 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
665 fromPort->ChangeInPorts(0)->NodeName() ,
666 fromPort->ChangeInPorts(0)->PortName() ) ) {
667 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
668 cdebug_out << "GraphBase::Graph::AddLink" << endl;
673 else if ( !toNode->IsEndSwitchNode() ) {
674 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
675 toNode->Name() , toPort->PortName() ) ) {
676 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
677 cdebug_out << "GraphBase::Graph::AddLink" << endl;
682 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
683 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
684 fromPort->ChangeInPorts(0)->NodeName() ,
685 fromPort->ChangeInPorts(0)->PortName() ) ) {
686 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
687 cdebug_out << "GraphBase::Graph::AddLink" << endl;
692 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
693 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
694 if ( !fromPort->AddInPort( toPort ) ) {
695 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
697 cdebug_out << "GraphBase::Graph::AddLink" << endl;
700 toPort->Kind( SUPERV::EndSwitchParameter ) ;
702 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
703 cdebug << "!fromPort->AddLink Error." << endl ;
704 cdebug_out << "GraphBase::Graph::AddLink" << endl;
708 if ( fromNode->IsDataFlowNode() && toPort->IsDataConnected() ) {
709 toPort->RemoveOutPort() ;
712 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
713 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
714 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
715 cdebug_out << "GraphBase::Graph::AddLink" << endl;
718 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
719 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
720 cdebug_out << "GraphBase::Graph::AddLink" << endl;
723 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
724 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
725 cdebug << "toPort->AddLink Error." << endl ;
726 cdebug_out << "GraphBase::Graph::AddLink" << endl;
731 toPort->AddOutPort( fromPort ) ;
734 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
735 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
736 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
737 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
738 << fromNode->Name() << " " << fromPort->PortName()
739 << " InLineNode/LoopNode_ConnectedInPortsNumber "
740 << toNode->ConnectedInPortsNumber() << endl;
741 if ( fromNode->IsGOTONode() ) {
742 fromPort->Kind( SUPERV::GOTOParameter ) ;
744 fromPort->PortStatus( PortConnected ); // GOTO - Loop
746 else if ( fromNode->IsDataFlowNode() || toNode->IsDataFlowNode() ) {
747 cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) "
748 << fromNode->Name() << " " << fromPort->PortName() << endl ;
749 fromPort->PortStatus( DataConnected );
752 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
753 << fromNode->Name() << " " << fromPort->PortName() << endl;
754 fromPort->PortStatus( PortConnected );
755 fromNode->AddLink( toNode ) ;
757 if ( fromNode->IsSwitchNode() ) {
758 if ( fromPort->IsInLine() && toPort->IsGate() ) {
759 fromPort->Kind( SUPERV::SwitchParameter ) ;
761 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
762 fromPort->Kind( SUPERV::InLineParameter ) ;
764 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
765 GraphBase::InLineNode * anEndSwitchNode ;
766 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
767 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInPort(0) ;
768 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
769 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
770 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
771 anOutPort->IsGate() ) {
772 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
773 anEndSwitchNode->Name() ,
774 anEndSwitchNode->GetChangeNodeInPort(0)->PortName() ) ) {
775 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
777 cdebug_out << "GraphBase::Graph::AddLink" << endl;
783 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
784 cdebug_out << "GraphBase::Graph::AddLink" << endl;
788 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
789 const char* FromServiceParameterName ,
790 const char* ToNodeName ,
791 const char* ToServiceParameterName ) {
792 cdebug_in << "GraphBase::Graph::RemoveLink to " << ToNodeName << "("
793 << ToServiceParameterName << ")" << endl;
794 bool RetVal = false ;
795 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
797 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
798 if ( anInPort && ( anInPort->IsConnected() ||
799 anInPort->IsDataConnected() ) ) {
800 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
801 RetVal = anOutPort->RemoveInPort( anInPort ) ;
802 anInPort->RemoveOutPort() ;
803 const char * FromNodeName = anOutPort->NodeName() ;
804 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
806 fromNode->RemoveLink( toNode ) ;
808 if ( fromNode->IsSwitchNode() ) {
809 anOutPort->Kind( SUPERV::InLineParameter ) ;
813 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
817 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
818 const char* ToServiceParameterName ,
819 char** FromNodeName ,
820 char** FromServiceParameterName ) {
821 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
822 // << ToServiceParameterName << ")" << endl;
823 bool RetVal = false ;
824 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
826 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
827 if ( anInPort && anInPort->IsConnected() ) {
828 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
829 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
830 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
834 cdebug << "GraphEditor::OutNode::GetLink ERROR no InPort or NotConnected " << ToNodeName
835 << " " << ToServiceParameterName << " " << RetVal << endl;
839 cdebug << "GraphEditor::OutNode::GetLink ERROR no Node " << ToNodeName << " " << RetVal
842 // cdebug_out << "GraphEditor::OutNode::GetLink " << RetVal << endl;
846 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
847 const char* ToServiceParameterName ,
848 const CORBA::Any aValue ) {
849 bool RetVal = false ;
850 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
851 << ToServiceParameterName << " , Any " ;
852 switch (aValue.type()->kind()) {
853 case CORBA::tk_string:
856 cdebug << t << " (string) " ;
858 case CORBA::tk_double:
861 cdebug << d << " (double) " ;
866 cdebug << l << " (long) " ;
868 case CORBA::tk_objref:
869 cdebug << "(object reference) " ;
872 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
875 cdebug << ")" << endl;
877 GraphBase::OutPort *fromDataNodePort = NULL ;
879 GraphBase::ComputingNode *toNode ;
880 GraphBase::InPort *toPort ;
883 NodePort( ToNodeName , ToServiceParameterName , &aNode , &aPort ) ;
884 toNode = GetChangeGraphNode( aNode ) ;
886 toPort = toNode->GetChangeInPort( aPort ) ;
887 if ( toPort && !toPort->IsDataConnected() ) {
888 toPort->RemoveOutPort() ;
899 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
900 cdebug "GraphBase::Graph::AddInputData " << GetNodeOutDataNodePort(i) << endl ;
902 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
903 cdebug "GraphBase::Graph::AddInputData " << GetNodeInDataNodePort(i) << endl ;
907 if ( toNode && toPort ) {
908 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
909 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
910 fromDataNodePort->RemoveInPort( toPort ) ;
912 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
913 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
914 << toPort->PortName() << " )" << endl ;
915 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
918 fromDataNodePort->Value( aValue ) ;
922 cdebug << "Node not found" << endl ;
925 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
929 bool GraphBase::Graph::ChangeInputData( const char* ToNodeName ,
930 const char* ToServiceParameterName ,
931 const CORBA::Any aValue ) {
932 bool RetVal = false ;
933 cdebug_in << "GraphBase::Graph::ChangeInputData(" << ToNodeName << ","
934 << ToServiceParameterName << " Any " ;
935 switch (aValue.type()->kind()) {
936 case CORBA::tk_string:
939 cdebug << t << " (string) " ;
941 case CORBA::tk_double:
944 cdebug << d << " (double) " ;
949 cdebug << l << " (long) " ;
951 case CORBA::tk_objref:
952 cdebug << "(object reference) " ;
955 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
958 cdebug << ")" << endl;
960 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
962 GraphBase::OutPort *fromPort = NULL ;
963 GraphBase::InPort *toPort = NULL ;
966 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
968 fromPort = toPort->GetOutPort();
971 fromPort->Value( aValue ) ;
972 toPort->State( SUPERV::ReadyState ) ;
975 cdebug << "ChangeInputData fromPort not found" << endl ;
979 cdebug << "ChangeInputData toPort not found" << endl ;
983 cdebug << "ChangeInputData Node not found" << endl ;
986 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
990 bool GraphBase::Graph::AddInputData(
991 const char* ToNodeName1 ,
992 const char* ToServiceParameterName1 ,
993 const char* ToNodeName2 ,
994 const char* ToServiceParameterName2 ) {
995 bool RetVal = false ;
996 cdebug_in << "GraphBase::Graph::AddInputSharedData(" << ToNodeName1 << ","
997 << ToServiceParameterName1 << ", " << ToNodeName2 << ","
998 << ToServiceParameterName2 << " )" << endl;
1000 GraphBase::ComputingNode *toNode1 = GetChangeGraphNode( ToNodeName1 ) ;
1001 GraphBase::ComputingNode *toNode2 = GetChangeGraphNode( ToNodeName2 ) ;
1003 GraphBase::OutPort *fromDataNodePort1 = NULL ;
1004 GraphBase::OutPort *fromDataNodePort2 = NULL ;
1005 GraphBase::InPort *toPort1 = NULL ;
1006 GraphBase::InPort *toPort2 = NULL ;
1008 if ( toNode1 && toNode2 ) {
1009 toPort1 = toNode1->GetChangeInPort( ToServiceParameterName1 ) ;
1010 toPort2 = toNode2->GetChangeInPort( ToServiceParameterName2 ) ;
1011 fromDataNodePort1 = GraphBase::DataNode::GetChangeInDataNodePort( toPort1->NodePortName() ) ;
1012 // const char* aDataValue = fromDataNodePort->Value() ;
1013 const CORBA::Any ** aDataValue1 = fromDataNodePort1->ValuePtr() ;
1014 fromDataNodePort2 = GraphBase::DataNode::GetChangeInDataNodePort( toPort2->NodePortName() ) ;
1015 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort1 ,
1016 toNode2 , toPort2 ) ;
1018 fromDataNodePort2->Value( aDataValue1 ) ;
1021 cdebug << "Node not found" << endl ;
1024 cdebug_out << "GraphBase::Graph::AddInputSharedData" << endl;
1028 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1029 const char* ToServiceParameterName ,
1030 const CORBA::Any ** aValue ) {
1031 bool RetVal = false ;
1032 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1033 << ToServiceParameterName << " **Any " ;
1034 const CORBA::Any theValue = **aValue ;
1035 switch (theValue.type()->kind()) {
1036 case CORBA::tk_string:
1039 cdebug << t << " (string) " ;
1041 case CORBA::tk_double:
1044 cdebug << d << " (double) " ;
1046 case CORBA::tk_long:
1049 cdebug << l << " (long) " ;
1051 case CORBA::tk_objref:
1052 cdebug << "(object reference) " ;
1055 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1058 cdebug << ")" << endl;
1060 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1062 GraphBase::OutPort *fromDataNodePort = NULL ;
1063 GraphBase::InPort *toPort = NULL ;
1066 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1067 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1068 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1069 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1070 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1073 fromDataNodePort->Value( aValue ) ;
1077 cdebug << "Node not found" << endl ;
1080 cdebug_out << "GraphBase::Graph::AddInputData" << endl;
1084 bool GraphBase::Graph::AddOutputData(
1085 const char* FromNodeName ,
1086 const char* FromServiceParameterName ,
1087 const CORBA::Any aValue ) {
1088 // const char* DataValue ,
1089 // const SUPERV::KindOfPortValue aKindOfPortValue ) {
1090 bool RetVal = false ;
1091 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1092 << FromServiceParameterName
1093 // << FromServiceParameterName << ", " << DataValue << ","
1094 // << aKindOfPortValue
1097 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1099 GraphBase::OutPort *fromPort = NULL ;
1100 GraphBase::InPort *toDataNodePort = NULL ;
1103 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1104 toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1105 RetVal = AddLink( fromNode , fromPort ,
1106 (GraphBase::ComputingNode * ) this , toDataNodePort ,
1108 // DataValue , aKindOfPortValue ) ;
1111 cdebug << "Node not found" << endl ;
1114 cdebug_out << "GraphBase::Graph::AddOutputData" << endl;
1118 bool GraphBase::Graph::CreateService() {
1119 cdebug_in << "GraphBase::Graph::CreateService" << endl;
1121 SALOME_ModuleCatalog::Service aService ;
1123 GraphBase::ComputingNode * iN ;
1127 for ( dostore = 0 ; dostore <= 1 ; dostore++ ) {
1128 if ( dostore == 1 ) {
1129 aService.ServiceName = Name() ;
1130 aService.ServiceinParameter.length( 0 ) ;
1131 aService.ServiceinParameter.length( innbr ) ;
1132 aService.ServiceoutParameter.length( 0 ) ;
1133 aService.ServiceoutParameter.length( outnbr ) ;
1137 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1138 iN = GraphNodes( i ) ;
1139 for ( j = 0 ; j < iN->GetNodeInPortsSize() ; j++ ) {
1140 GraphBase::InPort *anInPort = iN->GetChangeNodeInPort(j) ;
1141 if ( !anInPort->IsConnected() && !anInPort->IsGate() ) {
1142 // !anInPort->IsLoop() ) {
1143 // if ( !anInPort->IsGate() && !anInPort->IsConnected() &&
1144 // !( iN->IsLoopNode() && anInPort->IsBus() && anInPort->IsParam() )) {
1145 if ( dostore == 0 ) {
1146 cdebug << "CreateService " << iN->Name() << " Input port "
1147 << anInPort->PortName() << " is NOT connected " ;
1148 if ( anInPort->GetOutPort() ) {
1149 cdebug << *(anInPort->GetOutPort()) ;
1155 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1156 aService.ServiceinParameter[innbr++].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1160 if ( !iN->IsGOTONode() ) {
1161 for ( j = 0 ; j < iN->GetNodeOutPortsSize() ; j++ ) {
1162 GraphBase::OutPort *anOutPort = iN->GetChangeNodeOutPort(j) ;
1163 if ( !anOutPort->IsGate() &&
1164 //!anOutPort->IsLoop() &&
1165 // !( iN->IsEndLoopNode() && anOutPort->IsBus() ) &&
1166 ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) {
1167 if ( dostore == 0 ) {
1171 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1172 aService.ServiceoutParameter[outnbr++].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1180 // MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName );
1181 // for ( i = 0 ; i < innbr ; i++ ) {
1182 // cout << "aService.ServiceinParameter[" << i << "].Parametertype "
1183 // << aService.ServiceinParameter[i].Parametertype << endl ;
1184 // cout << "aService.ServiceinParameter[" << i << "].Parametername "
1185 // << aService.ServiceinParameter[i].Parametername << endl ;
1187 // for ( i = 0 ; i < outnbr ; i++ ) {
1188 // cout << "aService.ServiceoutParameter[" << i << "].Parametertype "
1189 // << aService.ServiceoutParameter[i].Parametertype << endl ;
1190 // cout << "aService.ServiceoutParameter[" << i << "].Parametername "
1191 // << aService.ServiceoutParameter[i].Parametername << endl ;
1194 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1196 // Restore input datas :
1197 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1198 // iN = (GraphEditor::InNode * ) GraphNodes( i ) ;
1199 iN = GraphNodes( i ) ;
1200 for ( j = 1 ; j < iN->GetNodeInPortsSize() ; j++ ) {
1201 GraphBase::InPort *anInPort = iN->GetChangeNodeInPort(j) ;
1202 if ( anInPort->IsDataConnected() ) {
1203 // GraphBase::Graph::AddInputData( anInPort->NodeName() ,
1204 AddInputData( anInPort->NodeName() ,
1205 anInPort->PortName() ,
1206 anInPort->GetOutPort()->ValuePtr() ) ;
1211 cdebug_out << "GraphBase::Graph::CreateService" << endl;
1215 bool GraphBase::Graph::InLineServices() {
1216 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1219 GraphBase::InLineNode * aINode ;
1220 SALOME_ModuleCatalog::Service aService ;
1221 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1222 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1223 if ( aINode->IsOneOfInLineNodes() ) {
1224 cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1225 aService.ServiceName = aINode->ServiceName() ;
1226 aService.ServiceinParameter.length( 0 ) ;
1227 aService.ServiceoutParameter.length( 0 ) ;
1229 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1230 if ( aINode->GetChangeNodeInPort(j)->IsGate() ||
1231 aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1232 // cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1233 // << aINode->GetChangeNodeInPort(j)->Kind() << " "
1234 // << aINode->GetChangeNodeInPort(j)->PortType() << " "
1235 // << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1236 // << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1237 // << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1240 aService.ServiceinParameter.length( InService+1 ) ;
1241 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1242 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1243 // cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1244 // << aINode->GetChangeNodeInPort(j)->Kind() << " "
1245 // << aINode->GetChangeNodeInPort(j)->PortType() << " "
1246 // << aINode->GetChangeNodeInPort(j)->PortName() << " "
1247 // << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1248 // << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1251 int OutService = 0 ;
1252 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1253 if ( aINode->GetChangeNodeOutPort(j)->IsGate() ||
1254 aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1255 // cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1256 // << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1257 // << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1258 // << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1259 // << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1260 // << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1263 aService.ServiceoutParameter.length( OutService+1 ) ;
1264 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1265 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1266 // cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1267 // << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1268 // << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1269 // << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1270 // << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1271 // << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1274 aINode->SetService( aService ) ;
1275 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1279 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1283 bool GraphBase::Graph::Sort() {
1286 int NotSortedNumber = GraphNodesSize() ;
1288 if ( NotSortedNumber ) {
1290 _ParallelExecutionNodes = false ;
1291 _Sorted.resize( GraphNodesSize() ) ;
1292 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1293 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1294 if ( _NodesNumber.size() )
1295 _NodesNumber.resize( 0 ) ;
1296 _SortedNodes.resize( 0 ) ;
1297 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1298 _Sorted[ i ] = false ;
1299 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1300 _DecrInPortsNumber[ i ] = 0 ;
1302 while ( NotSortedNumber ) {
1304 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1305 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1306 << GraphNodes( i )->Name() << " count "
1307 << _CnxInPortsNumber[ i ] << endl ;
1308 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1309 // All inputs of GraphNodes( i ) are available
1310 if ( _NodesNumber.size() != _LevelsNumber+1 ) {
1311 _NodesNumber.resize( _LevelsNumber+1 ) ;
1312 _SortedNodes.resize( _LevelsNumber+1 ) ;
1313 _NodesNumber[ _LevelsNumber ] = -1 ;
1315 _NodesNumber[ _LevelsNumber ]++ ;
1316 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1317 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1318 _Sorted[ i ] = true ;
1320 cdebug << GraphNodes( i )->Name() << " belongs to level "
1321 << _LevelsNumber << "." << endl ;
1322 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1323 // Outputs of GraphNodes( i ) will satisfy
1324 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1325 // GraphNodes( i )->LinkedNodes( j )
1326 GraphBase::ComputingNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1327 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1328 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1329 if ( !aLinkedNode->IsDataFlowNode() ) {
1330 cdebug << " _DecrInPortsNumber[ "
1331 << GetGraphNodeIndex( aLinkedNode->Name() )
1333 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1334 << " += " << aLinkedInPortsNumber ;
1335 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1338 // GraphNodes( i )->LinkedNodes( j )->IncrDecrConnectedInPortsNumber( GraphNodes( i )->LinkedInPortsNumber( j ) ) ;
1343 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1344 return false ; // Loop in the Graph
1346 cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1347 bool ChangeCount = false ;
1348 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1349 // if ( GraphNodes( i )->DecrIncrDecrConnectedInPortsNumber() ) {
1350 if ( _DecrInPortsNumber[ i ] ) {
1351 int prevcount = _CnxInPortsNumber[ i ] ;
1352 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
1353 _DecrInPortsNumber[ i ] = 0 ;
1354 ChangeCount = true ;
1355 cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
1356 << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1361 _LevelsNumber += 1 ;
1364 int AllSortedNodes = 0 ;
1365 _HeadNodes = _SortedNodes[ 0 ] ;
1366 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1367 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1368 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1369 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1370 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1374 if ( i == _QueueNodesSize && _LevelsNumber ) {
1375 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1376 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1378 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1379 AllSortedNodes += _NodesNumber[ i ]+1 ;
1380 if ( _NodesNumber[ i ] + 1 > _ThreadsMax )
1381 _ThreadsMax = _NodesNumber[ i ] + 1 ;
1382 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1383 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1384 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1385 _ParallelExecutionNodes = true ;
1386 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
1390 if ( _ParallelExecutionNodes ) {
1391 cdebug << "Parallel Execution Nodes detected." << endl ;
1394 cdebug << "No Parallel Execution Nodes detected." << endl ;
1396 if ( AllSortedNodes != GraphNodesSize() ) {
1397 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1398 return false ; // Loop in the Graph
1401 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1402 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
1405 for ( i = 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1406 (_SortedNodes[ 0 ])[ i ]->Level( 0 ) ;
1407 (_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ;
1409 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
1410 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1411 (_SortedNodes[ i ])[ j ]->Level( i ) ;
1412 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
1415 bool Graphs = true ;
1417 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1418 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1419 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
1420 cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name()
1423 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
1424 if ( aNode->LinkedNodes( k )->SubGraph() ) {
1425 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() &&
1426 aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
1427 aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
1428 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1429 << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1430 << ") ==>" << endl ;
1431 cdebug << " Graph " << aNode->SubGraph() << " for "
1432 << aNode->Name() << " ==> again" << endl ;
1434 for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) {
1435 aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ;
1441 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1442 << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1443 << ") distance > 1 ignored" << endl ;
1447 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1448 << " GraphInit to " << aNode->SubGraph() << " from "
1449 << aNode->Name() << endl ;
1450 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
1458 cdebug << endl << "Graphs result : " << endl ;
1461 cdebug << endl << "One more time" << endl ;
1465 int CurrGraphsNumber = 0;
1467 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
1468 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
1469 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
1470 _GraphsNumber += 1 ;
1471 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1472 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1473 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
1474 (_SortedNodes[ i ])[ j ]->SubGraph( _GraphsNumber ) ;
1475 cdebug << "GraphsNumber " << _GraphsNumber << " " << " Level "
1476 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
1488 // Controle de la coherence des noeuds de calcul
1489 // Enregistrement dans la liste des noeuds "tete" de graphe
1491 bool GraphBase::Graph::ComputingNodes() const {
1492 bool RetVal = true ;
1493 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
1495 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
1496 // list<GraphEditor::Node *>::iterator iN = aComputingNodesList.begin();
1497 // GraphEditor::Port * iP;
1499 // for (iN = _G->ComputingNodesList().begin(); iN !=_G->ComputingNodesList().end(); iN++) {
1500 // while ( iN != aComputingNodesList.end() ) {
1502 GraphBase::ComputingNode * iN ;
1503 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1504 iN = GraphNodes( i ) ;
1505 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
1506 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
1507 // if ((*iN)->GetNodeInPortsSize() == 0)
1508 // _headNodes.push_front(*iN);
1510 for ( j = 1; j < iN->GetNodeInPortsSize() ; j++ ) {
1511 const GraphBase::InPort *iP = iN->GetNodeInPort(j);
1512 if ( !iP->IsConnected() ){
1513 cdebug << "Le port d'entree " << iP->PortName()
1514 << " du noeud de calcul " << iN->Name() << " du graphe "
1515 << Name() << " n'est pas connecte "<< endl;
1521 // Tous les noeuds de calcul ont au moins un port de sortie connecte
1522 bool oneOutPortConnected = false;
1523 for ( j = 1; j < iN->GetNodeOutPortsSize() ; j++) {
1524 const GraphBase::OutPort *iP = iN->GetNodeOutPort(j);
1525 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
1526 oneOutPortConnected = true ;
1530 cdebug << "Le port de sortie " << iP->PortName()
1531 << " du noeud de calcul " << iN->Name() << " du graphe "
1532 << Name() << " n'est pas connecte "<< endl;
1536 if (!oneOutPortConnected) {
1537 cdebug << "Le noeud de calcul " << iN->Name() << " du graphe "
1538 << Name() << " n'a aucun port de sortie connecte "<< endl;
1539 // _computingError.push_front(2);
1542 // return _computingError.size () ;
1546 // Controle de la coherence des noeuds de calcul
1547 // Enregistrement dans la liste des noeuds "tete" de graphe
1549 bool GraphBase::Graph::DataServerNodes() const {
1551 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
1553 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
1554 int i , j , ierr = 0 ;
1556 // if ( DataFlowDatas == NULL ) {
1557 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
1561 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
1562 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
1564 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
1566 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
1568 ierr = CheckDataServerNodes() ;
1570 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
1571 // list<GraphExecutor::InNode *>::iterator iN = aComputingNodesList.begin();
1572 if ( GraphNodesSize() == 0 ) {
1576 GraphBase::ComputingNode * iN ;
1577 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1578 iN = GraphNodes( i ) ;
1579 // while ( iN != aComputingNodesList.end() ) {
1580 if ( iN->IsFactoryNode() ) {
1581 GraphBase::FactoryNode * FiN = (GraphBase::FactoryNode * ) iN ;
1582 if ( !strlen( FiN->Computer() ) ) {
1583 cdebug << "ComputerName missing for node " << FiN->Name() ;
1584 if ( !strlen( FiN->Computer() ) ) {
1589 cdebug << ". " << FiN->Computer() << " will be used." << endl ;
1593 // For Outputs of the DataFlow :
1594 for ( j = 0 ; j < iN->GetNodeOutPortsSize() ; j++ ) {
1595 if ( !iN->GetNodeOutPort(j)->IsConnected() ) {
1596 iN->AddLink( (GraphBase::ComputingNode *) this ) ;
1602 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
1604 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
1605 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
1607 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
1608 // while ( it != aDataServerNodesList.end() ) {
1609 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
1610 // cerr << "Erreur dans le noeud serveur de donnees "
1611 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1612 // cerr << "A la fois importation et exportation de donnees" << endl;
1613 // _dataServerError.push_front(1);
1616 // if ((*it)->GetNodeOutPortsSize()) {
1617 // if ((*it)->GetNodeOutPortsSize()==1){
1618 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
1619 // _headNodes.push_front(*it);
1622 // cerr << "Le port de sortie du noeud serveur de donnees "
1623 // << (*it)->Name() << " du graphe " << _G->Name()
1624 // << " n'est pas connecte "<< endl;
1625 // _dataServerError.push_front(4);
1629 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
1630 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1631 // _dataServerError.push_front(2);
1635 // if ((*it)->GetNodeInPortsSize()) {
1636 // if ((*it)->GetNodeInPortsSize() > 1){
1637 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
1638 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1639 // _dataServerError.push_front(3);
1642 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
1643 // cerr << "Le port d'entree du noeud serveur de donnees "
1644 // << (*it)->Name() << " du graphe " << _G->Name()
1645 // << " n'est pas connecte "<< endl;
1646 // _dataServerError.push_front(5);
1652 // return _dataServerError.size ();
1653 return ( ierr == 0 ) ;
1656 SUPERV::GraphState GraphBase::Graph::PortState(
1657 const char* NodeName ,
1658 const char* ServiceParameterName ) {
1659 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
1660 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
1661 // << ServiceParameterName << " )" << endl ;
1665 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
1667 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1669 GraphBase::OutPort *anOutPort ;
1670 anOutPort = aNode->GetChangeOutPort( aPort );
1671 if ( anOutPort == NULL ) {
1672 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1674 anOutPort = anInPort->GetOutPort() ;
1676 cdebug << "GraphBase::Graph::PortState OutPort/InPort not found --> "
1681 aRet = anOutPort->State() ;
1682 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
1686 cdebug << "GraphBase::Graph::PortState Node not found --> " << aRet
1694 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
1695 const char* ToServiceParameterName ) {
1696 const CORBA::Any * aRet = new CORBA::Any() ;
1699 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
1700 // << ToServiceParameterName << endl ;
1701 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
1703 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1706 GraphBase::OutPort *anOutPort = NULL ;
1707 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1709 anOutPort = anInPort->GetOutPort() ;
1711 aRet = anOutPort->Value() ;
1712 // cdebug << "OutPort value " << anOutPort->NodeName() << "("
1713 // << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
1714 // << "(" << anInPort->PortName() << ")" << endl ;
1717 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1718 << ToServiceParameterName << " ERROR no OutPort" << endl ;
1722 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1723 << ToServiceParameterName << " ERROR no InPort" << endl ;
1727 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1728 << ToServiceParameterName << " ERROR no Node" << endl ;
1732 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
1736 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
1737 const char* FromServiceParameterName ) {
1738 const CORBA::Any * aRet = new CORBA::Any() ;
1741 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1742 // << FromServiceParameterName << endl ;
1743 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
1745 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1748 GraphBase::OutPort *anOutPort ;
1749 anOutPort = aNode->GetChangeOutPort( aPort );
1751 aRet = anOutPort->Value() ;
1754 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1755 << FromServiceParameterName << " ERROR no OutPort" << endl ;
1759 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1760 << FromServiceParameterName << " ERROR no Node" << endl ;
1764 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
1768 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
1769 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
1770 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
1772 RetVal->length( _NodesNumber[ aLevel ] + 1 );
1773 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
1774 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
1777 return ( RetVal._retn() ) ;
1780 bool GraphBase::Graph::StartComponent(const int aThread ,
1781 const char * aComputerContainer ,
1782 const char * ComponentName ,
1783 Engines::Container_var & myContainer ,
1784 Engines::Component_var & objComponent ) {
1785 cdebug_in << aThread
1786 << " GraphBase::Graph::StartComponent " << aComputerContainer
1787 << " " << ComponentName << endl;
1788 bool RetVal = true ;
1790 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
1791 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
1793 if ( CORBA::is_nil( objComponent ) ) {
1794 cdebug_out << aThread
1795 << " StartComponent cannot FindOrLoad " << aComputerContainer
1796 << " " << ComponentName << endl;
1800 myContainer = LCC.FindContainer( aComputerContainer );
1801 if ( CORBA::is_nil( myContainer ) ) {
1802 cdebug_out << aThread
1803 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
1804 << aComputerContainer << "' ) Container does not exist"
1809 cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl;