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 Set_prof_debug( ORB , DebugFileName ) ;
46 cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ")" << endl ;
47 _Orb = CORBA::ORB::_duplicate( ORB ) ;
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)
87 SetDebug( ORB , &_Graph_prof_debug , _Graph_fdebug ) ;
89 cdebug << "GraphBase::Graph::Set_prof_debug redirect Trace to file " << DebugFileName << endl ;
92 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
93 GraphBase::SNode * Info = new GraphBase::SNode ;
94 Info->theComponentName = "" ;
95 Info->theInterfaceName = "" ;
96 Info->theName = Name() ;
97 Info->theKind = Kind() ;
98 Info->theService = *GetService() ;
99 Info->theFirstCreation = FirstCreation() ;
100 Info->theLastModification = LastModification() ;
101 Info->theEditorRelease = EditorRelease() ;
102 Info->theAuthor = Author() ;
103 Info->theContainer = "" ;
104 Info->theComment = Comment() ;
105 Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
106 Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
110 //----------------------------------------------------------------------
111 // Function : GetNodes
112 // Purpose : get a nodes list
113 //----------------------------------------------------------------------
114 GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const {
115 GraphBase::ListOfNodes * _list_nodes =
116 new GraphBase::ListOfNodes;
118 // All the nodes from _InNodes are taken
119 // vector< InNode *> Nodes = InNodes() ;
121 _list_nodes->resize( GraphNodesSize() );
125 GraphBase::ComputingNode * aCNode = NULL ;
126 for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
127 for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
128 aCNode = GraphNodes( ind ) ;
129 if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
130 ( igoto == 1 && aCNode->IsGOTONode() ) ) {
131 if ( aCNode->IsFactoryNode() ) {
132 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
133 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
134 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
137 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
138 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
140 (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
141 (*_list_nodes)[ind].theKind = aCNode->Kind();
142 if ( aCNode->IsInLineNode() ) {
143 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
144 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
145 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
146 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
147 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
149 if ( aCNode->IsGOTONode() ) {
150 GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
151 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
152 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
153 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
154 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
156 if ( aCNode->IsLoopNode() ) {
157 GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
158 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
159 (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
160 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
161 (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
162 (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
163 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
164 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
165 (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
166 (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
168 else if ( aCNode->IsSwitchNode() ) {
169 GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
170 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
171 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
172 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
173 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
174 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
176 else if ( aCNode->IsEndLoopNode() ) {
177 GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
178 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
179 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
180 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
181 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
182 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
184 else if ( aCNode->IsEndSwitchNode() ) {
185 GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
186 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
187 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
188 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
189 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
190 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
193 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
195 (*_list_nodes)[ind].theService = *aCNode->GetService();
196 // (*_list_nodes)[ind].theListOfParameters = *aCNode->GetListOfParameters() ;
197 if ( aCNode->IsOneOfInLineNodes() ) {
198 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
199 GraphBase::LoopNode * aLNode = NULL ;
200 if ( aCNode->IsLoopNode() ) {
201 aLNode = (GraphBase::LoopNode * ) aCNode ;
202 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
203 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
204 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
205 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
207 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
208 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
209 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
210 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
213 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
214 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
215 (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
216 (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
217 if ( aCNode->IsFactoryNode() ) {
218 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
219 (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
222 (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
224 (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
225 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
226 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
230 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
231 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
232 if ( anInPort->IsBus() ) {
234 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
235 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
236 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
237 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
238 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
249 //----------------------------------------------------------------------
250 // Function : GetLinks
251 // Purpose : get a links list
252 //----------------------------------------------------------------------
253 GraphBase::ListOfLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
254 GraphBase::ListOfLinks * _list_links =
255 new GraphBase::ListOfLinks;
257 // All the links from _LinksList are taken
258 // vector< InNode *> Nodes = InNodes() ;
262 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
263 GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
265 for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
266 const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
267 // if ( fromPort->IsPortConnected() && ( !fromPort->IsLoop() || AllLinks ) ) {
269 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
270 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
271 // Desole pour ce cast mais avec les maps difficile de faire const ...
272 const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
273 if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
274 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
275 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
276 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
277 << " " << fromPort->InPortsSize() << " ports" << endl ;
278 _list_links->resize( ind+1 );
279 (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
280 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
281 (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
282 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
283 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
284 if ( toPort->IsEndSwitch() ) {
285 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
288 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
292 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
293 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
294 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
295 << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
305 GraphBase::ListOfGraphs * GraphBase::Graph::GetGraphs() const {
306 GraphBase::ListOfGraphs * _list_graphs =
307 new GraphBase::ListOfGraphs;
312 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
313 GraphBase::InPort* toPort ) {
314 GraphBase::SLink * _link = new GraphBase::SLink ;
315 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
316 _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
317 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
318 _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
319 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
320 CORBA::Any aSPValue = *fromPort->Value() ;
321 _link->aLinkValue = aSPValue;
322 _link->aListOfCoords = *(toPort->Coords()) ;
325 //----------------------------------------------------------------------
326 // Function : GetDatas
327 // Purpose : get the datas list
328 //----------------------------------------------------------------------
329 GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const {
330 GraphBase::ListOfLinks * _list_datalinks =
331 new GraphBase::ListOfLinks;
334 const GraphBase::DataNode * aDataNode = this ;
336 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
337 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
338 if ( fromDataPort->IsDataConnected() ) {
340 //We may have SharedData as input of a DataFlow : same input for one or several
341 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
342 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
343 _list_datalinks->resize( ind+1 );
344 (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
345 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
346 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
347 (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
348 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
349 CORBA::Any aSPValue = *fromDataPort->Value() ;
350 (*_list_datalinks)[ind].aLinkValue = aSPValue;
351 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
357 // Output(s) of a DataFlow match only one input-virtual-dataport
358 for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
359 GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
360 const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
361 if ( fromPort->IsDataConnected() ) {
362 _list_datalinks->length( ind+1 );
363 _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
364 _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
365 _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
366 _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
367 // SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
368 CORBA::Any aSPValue = *fromPort->Value() ;
369 // aSPValue.Value = CORBA::string_dup( fromPort->Value() );
370 // aSPValue.Kind = fromPort->Kind();
371 _list_datalinks[ind].aLinkValue = aSPValue;
372 _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
377 return _list_datalinks ;
380 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
381 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " "
382 << aNode->Name() << " " << aNode->ServiceName() << endl;
383 bool RetVal = false ;
384 int index = GetGraphNodeIndex( aNode->Name() ) ;
386 _GraphNodes.resize( _GraphNodesSize+1 ) ;
387 _GraphNodes[ _GraphNodesSize ] = aNode ;
388 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
389 _GraphNodesSize += 1 ;
392 // cout << "GraphBase::Graph::AddNode(" << aNode->ComponentName() << " , "
393 // << aNode->Name() << ")" << endl;
395 cdebug << "GraphBase::Graph::AddNode Known nodes :" << endl ;
396 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
397 cdebug << i << ". " << GetGraphNode( i )->Name() << " "
398 << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
400 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
401 << aNode->ServiceName() << endl;
405 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
406 const char* NewNodeName ) {
407 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , "
408 << NewNodeName << ")" << endl;
410 bool RetVal = false ;
411 if ( !strcmp( OldNodeName , NewNodeName ) ) {
414 else if ( strcmp( Name() , OldNodeName ) ) {
415 int index = GetGraphNodeIndex( OldNodeName ) ;
416 int newindex = GetGraphNodeIndex( NewNodeName ) ;
417 if ( index >= 0 && index < _GraphNodesSize &&
418 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
419 _GraphNodes[ index ]->Name( NewNodeName ) ;
420 _MapOfGraphNodes.erase( OldNodeName ) ;
421 SetGraphNodeIndex( NewNodeName , index ) ;
423 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
424 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
425 cdebug << i << ". GraphBase::Graph::ReNameNode of LinkedNode : from " ;
426 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
427 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
429 cdebug << anOutPort->NodeName() ;
432 cdebug << "without link" ;
434 cdebug << " to " << i << ". " << anInPort->PortName()
435 << " of " << NewNodeName ;
436 if ( anInPort->IsConnected() ) {
437 if ( anOutPort->IsDataConnected() ) {
438 cdebug << " fromDataConnected "
439 << anOutPort->NodeName()
443 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
444 cdebug << " fromConnected " << FromNode->Name() << endl ;
445 FromNode->ReNameLink( OldNodeName , NewNodeName ) ;
447 char* OldNodePortName = new char[ strlen( OldNodeName ) +
448 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
449 char* NewNodePortName = new char[ strlen( NewNodeName ) +
450 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
451 strcpy( OldNodePortName , OldNodeName ) ;
452 strcat( OldNodePortName , "\\" ) ;
453 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
454 strcpy( NewNodePortName , NewNodeName ) ;
455 strcat( NewNodePortName , "\\" ) ;
456 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
457 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
458 delete [] OldNodePortName ;
459 delete [] NewNodePortName ;
464 cdebug << " not connected" << endl ;
471 cdebug << "Node not found" << endl ;
475 RetVal = Name( NewNodeName ) ;
478 cdebug_out << "GraphBase::Graph::ReNameNode" << endl;
482 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
483 cdebug_in << "GraphBase::Graph::RemoveNode (" << aNodeName << ")" << endl;
485 bool RetVal = false ;
486 int index = GetGraphNodeIndex( aNodeName ) ;
487 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
489 if ( aNode->GetNodeInPortsSize() ) {
490 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
491 cdebug << i << ". GraphBase::Graph::RemoveNode of LinkedNode : from " ;
492 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
493 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
495 cdebug << anOutPort->NodeName() ;
498 cdebug << "without link" ;
500 cdebug << " to " << i << ". " << anInPort->PortName()
501 << " of " << aNodeName ;
502 if ( anInPort->IsConnected() ) {
503 if ( anOutPort->IsDataConnected() ) {
504 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
507 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
508 cdebug << " fromConnected " << FromNode->Name() << endl ;
509 FromNode->RemoveLink( aNode ) ;
511 RetVal = anOutPort->RemoveInPort( anInPort ) ;
516 cdebug << " not connected" << endl ;
525 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
526 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
527 cdebug << "GraphBase::Graph::Remove " <<anOutPort->InPortsSize()
528 << " Links of OutPort : " << i << ". "
529 << *aNode->GetChangeNodeOutPort( i ) ;
531 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
532 cdebug << " to " << j << ". " << *anOutPort->InPorts( j )
534 RetVal = anOutPort->ChangeInPorts( j )->RemoveOutPort() ;
537 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anOutPort->InPorts( j )->NodeName() ) ;
538 aNode->RemoveLink( ToNode ) ;
539 RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
543 // RetVal = aNode->GetChangeNodeOutPort( j )->RemoveLinks() ;
548 // RetVal = aNode->RemoveLinks() ; // In PortsOfNode
550 // if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() || aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
551 // GraphBase::InLineNode * anInLineNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
552 // if ( anInLineNode ) {
553 // RetVal = RemoveNode( anInLineNode->Name() ) ;
559 _GraphNodesSize -= 1 ;
560 for ( i = index ; i < _GraphNodesSize ; i++ ) {
561 SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
562 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
564 _GraphNodes.resize( _GraphNodesSize+1 ) ;
565 _MapOfGraphNodes.erase( aNodeName ) ;
570 cdebug << "Node not found" << endl ;
573 cdebug_out << "GraphBase::Graph::RemoveNode" << endl;
577 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
578 const char* FromServiceParameterName ,
579 const char* ToNodeName ,
580 const char* ToServiceParameterName ,
581 const CORBA::Any aValue ) {
584 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
585 << FromServiceParameterName << ") ---> " << ToNodeName << "("
586 << ToServiceParameterName << ") )" << endl;
588 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
589 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
591 GraphBase::OutPort *fromPort = NULL ;
592 GraphBase::InPort *toPort = NULL ;
595 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
597 cdebug << "AddLink fromPort " << FromServiceParameterName << " FromNode("
598 << FromNodeName << ") not found." << endl ;
602 cdebug << "AddLink FromNode " << FromNodeName << " not found." << endl ;
605 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
607 cdebug << "AddLink toPort " << ToServiceParameterName << " ToNode("
608 << ToNodeName << ") not found." << endl ;
612 cdebug << "AddLink toNode " << ToNodeName << " not found." << endl ;
615 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
618 if ( fromPort->IsGate() && toPort->IsGate() ) {
620 aValue <<= (long ) 1 ;
621 fromPort->Value( aValue ) ;
624 const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
625 fromPort->Value( aDataValue ) ;
629 cdebug_out << "GraphBase::Graph::AddLink" << endl;
633 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
634 GraphBase::OutPort *fromPort ,
635 GraphBase::ComputingNode *toNode ,
636 GraphBase::InPort *toPort ) {
640 cdebug << "AddLink fromNode not found." << endl ;
644 cdebug << "AddLink fromPort not found." << endl ;
649 cdebug << "AddLink toNode not found." << endl ;
653 cdebug << "AddLink toPort not found." << endl ;
657 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
658 << fromPort->PortName() << ") ---> " << toNode->Name() << "("
659 << toPort->PortName() << ") )" << endl;
660 if ( !fromNode->IsDataFlowNode() && !toNode->IsDataFlowNode() &&
661 toPort->GetOutPort() ) {
662 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
663 fromPort->NodePortName() ) ) {
664 cdebug << "Link already exists" << endl ;
665 cdebug_out << "GraphBase::Graph::AddLink" << endl;
668 else if ( toPort->IsDataConnected() ) {
669 toPort->RemoveOutPort() ;
671 else if ( fromNode->IsGOTONode() ) {
672 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
673 toPort->GetOutPort()->PortName() ,
674 toNode->Name() , toPort->PortName() ) ) {
675 cdebug << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() Error."
677 cdebug_out << "GraphBase::Graph::AddLink" << endl;
680 if ( fromPort->InPortsSize() ) {
681 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
682 fromPort->ChangeInPorts(0)->NodeName() ,
683 fromPort->ChangeInPorts(0)->PortName() ) ) {
684 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
685 cdebug_out << "GraphBase::Graph::AddLink" << endl;
690 else if ( !toNode->IsEndSwitchNode() ||
691 ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
692 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
693 toNode->Name() , toPort->PortName() ) ) {
694 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
695 cdebug_out << "GraphBase::Graph::AddLink" << endl;
700 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
701 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
702 fromPort->ChangeInPorts(0)->NodeName() ,
703 fromPort->ChangeInPorts(0)->PortName() ) ) {
704 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
705 cdebug_out << "GraphBase::Graph::AddLink" << endl;
710 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
711 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
712 if ( !fromPort->AddInPort( toPort ) ) {
713 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
715 cdebug_out << "GraphBase::Graph::AddLink" << endl;
718 toPort->Kind( SUPERV::EndSwitchParameter ) ;
720 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
721 cdebug << "!fromPort->AddLink Error." << endl ;
722 cdebug_out << "GraphBase::Graph::AddLink" << endl;
726 if ( fromNode->IsDataFlowNode() && toPort->IsDataConnected() ) {
727 toPort->RemoveOutPort() ;
730 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
731 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
732 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
733 cdebug_out << "GraphBase::Graph::AddLink" << endl;
736 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
737 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
738 cdebug_out << "GraphBase::Graph::AddLink" << endl;
741 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
742 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
743 cdebug << "toPort->AddLink Error." << endl ;
744 cdebug_out << "GraphBase::Graph::AddLink" << endl;
749 toPort->AddOutPort( fromPort ) ;
752 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
753 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
754 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
755 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
756 << fromNode->Name() << " " << fromPort->PortName()
757 << " InLineNode/LoopNode_ConnectedInPortsNumber "
758 << toNode->ConnectedInPortsNumber() << endl;
759 if ( fromNode->IsGOTONode() ) {
760 fromPort->Kind( SUPERV::GOTOParameter ) ;
762 fromPort->PortStatus( PortConnected ); // GOTO - Loop
764 else if ( fromNode->IsDataFlowNode() || toNode->IsDataFlowNode() ) {
765 cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) "
766 << fromNode->Name() << " " << fromPort->PortName() << endl ;
767 fromPort->PortStatus( DataConnected );
770 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
771 << fromNode->Name() << " " << fromPort->PortName() << endl;
772 fromPort->PortStatus( PortConnected );
773 fromNode->AddLink( toNode ) ;
775 if ( fromNode->IsSwitchNode() ) {
776 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
777 fromPort->Kind( SUPERV::SwitchParameter ) ;
779 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
780 fromPort->Kind( SUPERV::InLineParameter ) ;
782 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
783 GraphBase::InLineNode * anEndSwitchNode ;
784 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
785 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
786 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
787 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
788 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
789 anOutPort->IsGate() ) {
790 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
791 anEndSwitchNode->Name() ,
792 anInPort->PortName() ) ) {
793 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
795 cdebug_out << "GraphBase::Graph::AddLink" << endl;
801 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
802 cdebug_out << "GraphBase::Graph::AddLink" << endl;
806 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
807 const char* FromServiceParameterName ,
808 const char* ToNodeName ,
809 const char* ToServiceParameterName ) {
810 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
811 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
812 bool RetVal = false ;
813 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
815 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
816 if ( anInPort && ( anInPort->IsConnected() ||
817 anInPort->IsDataConnected() ) ) {
818 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
819 RetVal = anOutPort->RemoveInPort( anInPort ) ;
820 anInPort->RemoveOutPort() ;
821 const char * FromNodeName = anOutPort->NodeName() ;
822 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
825 fromNode->RemoveLink( toNode ) ;
827 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
828 anOutPort->Kind( SUPERV::InLineParameter ) ;
831 if ( fromNode->IsEndLoopNode() ) {
832 toNode = ((GraphBase::EndOfLoopNode * ) fromNode)->CoupledNode() ;
834 anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
835 RetVal = AddLink( fromNode , anOutPort , toNode , anInPort ) ;
841 if ( toNode->IsLoopNode() ) {
842 fromNode = ((GraphBase::LoopNode * ) toNode)->CoupledNode() ;
844 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
845 RetVal = AddLink( fromNode , anOutPort , toNode , toNode->GetChangeInPort( ToServiceParameterName ) ) ;
855 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
859 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
860 const char* ToServiceParameterName ,
861 char** FromNodeName ,
862 char** FromServiceParameterName ) {
863 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
864 // << ToServiceParameterName << ")" << endl;
865 bool RetVal = false ;
866 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
868 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
869 if ( anInPort && anInPort->IsConnected() ) {
870 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
871 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
872 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
876 cdebug << "GraphEditor::OutNode::GetLink ERROR no InPort or NotConnected " << ToNodeName
877 << " " << ToServiceParameterName << " " << RetVal << endl;
881 cdebug << "GraphEditor::OutNode::GetLink ERROR no Node " << ToNodeName << " " << RetVal
884 // cdebug_out << "GraphEditor::OutNode::GetLink " << RetVal << endl;
888 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
889 const char* ToServiceParameterName ,
890 const CORBA::Any aValue ) {
891 bool RetVal = false ;
892 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
893 << ToServiceParameterName << " , Any " ;
894 switch (aValue.type()->kind()) {
895 case CORBA::tk_string:
898 cdebug << t << " (string) " ;
900 case CORBA::tk_double:
903 cdebug << d << " (double) " ;
908 cdebug << l << " (long) " ;
910 case CORBA::tk_objref:
911 cdebug << "(object reference) " ;
914 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
917 cdebug << ")" << endl;
919 GraphBase::OutPort *fromDataNodePort = NULL ;
921 GraphBase::ComputingNode *toNode ;
922 GraphBase::InPort *toPort ;
925 NodePort( ToNodeName , ToServiceParameterName , &aNode , &aPort ) ;
926 toNode = GetChangeGraphNode( aNode ) ;
928 toPort = toNode->GetChangeInPort( aPort ) ;
929 if ( toPort && !toPort->IsDataConnected() ) {
930 toPort->RemoveOutPort() ;
941 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
942 cdebug "GraphBase::Graph::AddInputData " << GetNodeOutDataNodePort(i) << endl ;
944 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
945 cdebug "GraphBase::Graph::AddInputData " << GetNodeInDataNodePort(i) << endl ;
949 if ( toNode && toPort ) {
950 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
951 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
952 fromDataNodePort->RemoveInPort( toPort ) ;
954 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
955 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
956 << toPort->PortName() << " )" << endl ;
957 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
960 fromDataNodePort->Value( aValue ) ;
964 cdebug << "Node not found" << endl ;
967 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
971 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
972 const char * ToServiceParameterName ,
973 const CORBA::Any aValue ) {
974 bool RetVal = false ;
975 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
976 << ToServiceParameterName << "' , Any " ;
977 switch (aValue.type()->kind()) {
978 case CORBA::tk_string:
981 cdebug << t << " (string) " ;
983 case CORBA::tk_double:
986 cdebug << d << " (double) " ;
991 cdebug << l << " (long) " ;
993 case CORBA::tk_objref:
994 cdebug << "(object reference) " ;
997 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1000 cdebug << ")" << endl;
1002 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1004 GraphBase::OutPort *fromPort = NULL ;
1005 GraphBase::InPort *toPort = NULL ;
1008 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1010 fromPort = toPort->GetOutPort();
1013 fromPort->Value( aValue ) ;
1014 toPort->State( SUPERV::ReadyState ) ;
1017 cdebug << "ChangeInputData fromPort not found" << endl ;
1021 cdebug << "ChangeInputData toPort not found" << endl ;
1025 cdebug << "ChangeInputData Node not found : " << ToNodeName << endl ;
1028 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1032 bool GraphBase::Graph::AddInputData(
1033 const char* ToNodeName1 ,
1034 const char* ToServiceParameterName1 ,
1035 const char* ToNodeName2 ,
1036 const char* ToServiceParameterName2 ) {
1037 bool RetVal = false ;
1038 cdebug_in << "GraphBase::Graph::AddInputSharedData(" << ToNodeName1 << ","
1039 << ToServiceParameterName1 << ", " << ToNodeName2 << ","
1040 << ToServiceParameterName2 << " )" << endl;
1042 GraphBase::ComputingNode *toNode1 = GetChangeGraphNode( ToNodeName1 ) ;
1043 GraphBase::ComputingNode *toNode2 = GetChangeGraphNode( ToNodeName2 ) ;
1045 GraphBase::OutPort *fromDataNodePort1 = NULL ;
1046 GraphBase::OutPort *fromDataNodePort2 = NULL ;
1047 GraphBase::InPort *toPort1 = NULL ;
1048 GraphBase::InPort *toPort2 = NULL ;
1050 if ( toNode1 && toNode2 ) {
1051 toPort1 = toNode1->GetChangeInPort( ToServiceParameterName1 ) ;
1052 toPort2 = toNode2->GetChangeInPort( ToServiceParameterName2 ) ;
1053 fromDataNodePort1 = GraphBase::DataNode::GetChangeInDataNodePort( toPort1->NodePortName() ) ;
1054 // const char* aDataValue = fromDataNodePort->Value() ;
1055 const CORBA::Any ** aDataValue1 = fromDataNodePort1->ValuePtr() ;
1056 fromDataNodePort2 = GraphBase::DataNode::GetChangeInDataNodePort( toPort2->NodePortName() ) ;
1057 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort1 ,
1058 toNode2 , toPort2 ) ;
1060 fromDataNodePort2->Value( aDataValue1 ) ;
1063 cdebug << "Node not found" << endl ;
1066 cdebug_out << "GraphBase::Graph::AddInputSharedData" << endl;
1070 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1071 const char* ToServiceParameterName ,
1072 const CORBA::Any ** aValue ) {
1073 bool RetVal = false ;
1074 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1075 << ToServiceParameterName << " **Any " ;
1076 const CORBA::Any theValue = **aValue ;
1077 switch (theValue.type()->kind()) {
1078 case CORBA::tk_string:
1081 cdebug << t << " (string) " ;
1083 case CORBA::tk_double:
1086 cdebug << d << " (double) " ;
1088 case CORBA::tk_long:
1091 cdebug << l << " (long) " ;
1093 case CORBA::tk_objref:
1094 cdebug << "(object reference) " ;
1097 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1100 cdebug << ")" << endl;
1102 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1104 GraphBase::OutPort *fromDataNodePort = NULL ;
1105 GraphBase::InPort *toPort = NULL ;
1108 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1109 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1110 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1111 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1112 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1115 fromDataNodePort->Value( aValue ) ;
1119 cdebug << "Node not found" << endl ;
1122 cdebug_out << "GraphBase::Graph::AddInputData" << endl;
1126 bool GraphBase::Graph::AddOutputData(
1127 const char* FromNodeName ,
1128 const char* FromServiceParameterName ,
1129 const CORBA::Any aValue ) {
1130 // const char* DataValue ,
1131 // const SUPERV::KindOfPortValue aKindOfPortValue ) {
1132 bool RetVal = false ;
1133 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1134 << FromServiceParameterName
1135 // << FromServiceParameterName << ", " << DataValue << ","
1136 // << aKindOfPortValue
1139 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1141 GraphBase::OutPort *fromPort = NULL ;
1142 GraphBase::InPort *toDataNodePort = NULL ;
1145 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1146 toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1147 RetVal = AddLink( fromNode , fromPort ,
1148 (GraphBase::ComputingNode * ) this , toDataNodePort ,
1150 // DataValue , aKindOfPortValue ) ;
1153 cdebug << "Node not found" << endl ;
1156 cdebug_out << "GraphBase::Graph::AddOutputData" << endl;
1160 bool GraphBase::Graph::CreateService() {
1161 cdebug_in << "GraphBase::Graph::CreateService" << endl;
1162 bool RetVal = true ;
1163 SALOME_ModuleCatalog::Service aService ;
1165 GraphBase::ComputingNode * aToNode ;
1169 for ( dostore = 0 ; dostore <= 1 ; dostore++ ) {
1170 if ( dostore == 1 ) {
1171 aService.ServiceName = Name() ;
1172 aService.ServiceinParameter.length( 0 ) ;
1173 aService.ServiceinParameter.length( innbr ) ;
1174 aService.ServiceoutParameter.length( 0 ) ;
1175 aService.ServiceoutParameter.length( outnbr ) ;
1179 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1180 aToNode = GraphNodes( i ) ;
1181 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1182 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1184 if ( dostore == 0 &&
1185 strcmp( anInPort->ServicesParameterType() , "string" ) &&
1186 strcmp( anInPort->ServicesParameterType() , "long" ) &&
1187 strcmp( anInPort->ServicesParameterType() , "double" ) &&
1188 strcmp( anInPort->ServicesParameterType() , "objref" ) ) {
1189 cdebug << "CreateService Node " << aToNode->Name() << ". Input port " << anInPort->PortName()
1190 << " has illegal type " << anInPort->ServicesParameterType() << endl ;
1194 bool isfromcouplednode = false ;
1195 if ( anInPort->IsConnected() && anInPort->GetOutPort() ) {
1196 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( anInPort->GetOutPort()->NodeName() ) ;
1197 if ( aFromNode->IsEndLoopNode() && ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1198 isfromcouplednode = true ;
1201 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1202 ( !anInPort->IsConnected() || ( anInPort->IsConnected() && isfromcouplednode ) ) ) {
1203 if ( dostore == 0 ) {
1204 cdebug << "CreateService " << aToNode->Name() << " Input port "
1205 << anInPort->PortName() << " " << anInPort->Kind() << " is NOT connected " ;
1206 if ( anInPort->GetOutPort() ) {
1207 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1213 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1214 aService.ServiceinParameter[innbr++].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1218 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName() ;
1219 if ( anInPort->IsConnected() ) {
1220 cdebug << " is connected " ;
1223 cdebug << " is NOT connected " ;
1225 if ( anInPort->IsGate() ) {
1226 cdebug << " IsGate " ;
1228 if ( anInPort->GetOutPort() ) {
1229 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1232 cdebug << "NOT DataConnected" ;
1237 GraphBase::ComputingNode * aFromNode = aToNode ;
1238 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1239 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1240 cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1242 cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1245 cdebug << " NULL" << endl ;
1248 if ( dostore == 0 &&
1249 strcmp( anOutPort->ServicesParameterType() , "string" ) &&
1250 strcmp( anOutPort->ServicesParameterType() , "long" ) &&
1251 strcmp( anOutPort->ServicesParameterType() , "double" ) &&
1252 strcmp( anOutPort->ServicesParameterType() , "objref" ) ) {
1253 cdebug << "CreateService Node " << aFromNode->Name() << ". Output port " << anOutPort->PortName()
1254 << " has illegal type " << anOutPort->ServicesParameterType() << endl ;
1258 if ( !aFromNode->IsGOTONode() ) {
1259 if ( !anOutPort->IsGate() &&
1260 ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) {
1261 if ( dostore == 0 ) {
1262 cdebug << "CreateService " << aFromNode->Name() << " Output port "
1263 << anOutPort->PortName() << endl ;
1267 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1268 aService.ServiceoutParameter[outnbr++].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1276 // MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName );
1277 // for ( i = 0 ; i < innbr ; i++ ) {
1278 // cout << "aService.ServiceinParameter[" << i << "].Parametertype "
1279 // << aService.ServiceinParameter[i].Parametertype << endl ;
1280 // cout << "aService.ServiceinParameter[" << i << "].Parametername "
1281 // << aService.ServiceinParameter[i].Parametername << endl ;
1283 // for ( i = 0 ; i < outnbr ; i++ ) {
1284 // cout << "aService.ServiceoutParameter[" << i << "].Parametertype "
1285 // << aService.ServiceoutParameter[i].Parametertype << endl ;
1286 // cout << "aService.ServiceoutParameter[" << i << "].Parametername "
1287 // << aService.ServiceoutParameter[i].Parametername << endl ;
1290 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1292 // Restore input datas :
1293 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1294 aToNode = GraphNodes( i ) ;
1295 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1296 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1297 if ( anInPort->IsDataConnected() ) {
1298 AddInputData( anInPort->NodeName() ,
1299 anInPort->PortName() ,
1300 anInPort->GetOutPort()->ValuePtr() ) ;
1305 cdebug_out << "GraphBase::Graph::CreateService" << endl;
1309 bool GraphBase::Graph::InLineServices() {
1310 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1313 GraphBase::InLineNode * aINode ;
1314 SALOME_ModuleCatalog::Service aService ;
1315 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1316 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1317 if ( aINode->IsOneOfInLineNodes() ) {
1318 cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1319 aService.ServiceName = aINode->ServiceName() ;
1320 aService.ServiceinParameter.length( 0 ) ;
1321 aService.ServiceoutParameter.length( 0 ) ;
1323 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1324 if ( aINode->GetChangeNodeInPort(j)->IsGate() ||
1325 aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1326 // cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1327 // << aINode->GetChangeNodeInPort(j)->Kind() << " "
1328 // << aINode->GetChangeNodeInPort(j)->PortType() << " "
1329 // << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1330 // << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1331 // << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1334 aService.ServiceinParameter.length( InService+1 ) ;
1335 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1336 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1337 // cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1338 // << aINode->GetChangeNodeInPort(j)->Kind() << " "
1339 // << aINode->GetChangeNodeInPort(j)->PortType() << " "
1340 // << aINode->GetChangeNodeInPort(j)->PortName() << " "
1341 // << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1342 // << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1345 int OutService = 0 ;
1346 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1347 if ( aINode->GetChangeNodeOutPort(j)->IsGate() ||
1348 aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1349 // cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1350 // << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1351 // << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1352 // << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1353 // << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1354 // << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1357 aService.ServiceoutParameter.length( OutService+1 ) ;
1358 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1359 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1360 // cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1361 // << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1362 // << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1363 // << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1364 // << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1365 // << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1368 aINode->SetService( aService ) ;
1369 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1373 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1377 bool GraphBase::Graph::Sort() {
1380 int NotSortedNumber = GraphNodesSize() ;
1382 if ( NotSortedNumber ) {
1384 _ParallelExecutionNodes = false ;
1385 _Sorted.resize( GraphNodesSize() ) ;
1386 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1387 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1388 if ( _NodesNumber.size() )
1389 _NodesNumber.resize( 0 ) ;
1390 _SortedNodes.resize( 0 ) ;
1392 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1393 _Sorted[ i ] = false ;
1394 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1395 _DecrInPortsNumber[ i ] = 0 ;
1398 while ( NotSortedNumber ) {
1401 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1402 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1403 << GraphNodes( i )->Name() << " count "
1404 << _CnxInPortsNumber[ i ] << endl ;
1405 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1406 // All inputs of GraphNodes( i ) are available
1407 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
1408 _NodesNumber.resize( _LevelsNumber+1 ) ;
1409 _SortedNodes.resize( _LevelsNumber+1 ) ;
1410 _NodesNumber[ _LevelsNumber ] = -1 ;
1412 _NodesNumber[ _LevelsNumber ]++ ;
1413 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1414 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1415 _Sorted[ i ] = true ;
1417 cdebug << GraphNodes( i )->Name() << " belongs to level "
1418 << _LevelsNumber << "." << endl ;
1419 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1420 // Outputs of GraphNodes( i ) will satisfy
1421 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1422 // GraphNodes( i )->LinkedNodes( j )
1423 GraphBase::ComputingNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1424 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1425 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1426 if ( !aLinkedNode->IsDataFlowNode() ) {
1427 cdebug << " _DecrInPortsNumber[ "
1428 << GetGraphNodeIndex( aLinkedNode->Name() )
1430 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1431 << " += " << aLinkedInPortsNumber ;
1432 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1435 // GraphNodes( i )->LinkedNodes( j )->IncrDecrConnectedInPortsNumber( GraphNodes( i )->LinkedInPortsNumber( j ) ) ;
1440 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1441 return false ; // Loop in the Graph
1443 cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1444 bool ChangeCount = false ;
1445 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1446 // if ( GraphNodes( i )->DecrIncrDecrConnectedInPortsNumber() ) {
1447 if ( _DecrInPortsNumber[ i ] ) {
1448 int prevcount = _CnxInPortsNumber[ i ] ;
1449 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
1450 _DecrInPortsNumber[ i ] = 0 ;
1451 ChangeCount = true ;
1452 cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
1453 << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1459 _LevelsNumber += 1 ;
1462 int AllSortedNodes = 0 ;
1463 _HeadNodes = _SortedNodes[ 0 ] ;
1464 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1465 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1466 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1467 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1468 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1472 if ( i == _QueueNodesSize && _LevelsNumber ) {
1473 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1474 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1476 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1477 AllSortedNodes += _NodesNumber[ i ]+1 ;
1478 if ( _NodesNumber[ i ] + 1 > _ThreadsMax )
1479 _ThreadsMax = _NodesNumber[ i ] + 1 ;
1480 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1481 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1482 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1483 _ParallelExecutionNodes = true ;
1484 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
1488 if ( _ParallelExecutionNodes ) {
1489 cdebug << "Parallel Execution Nodes detected." << endl ;
1492 cdebug << "No Parallel Execution Nodes detected." << endl ;
1494 if ( AllSortedNodes != GraphNodesSize() ) {
1495 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1496 return false ; // Loop in the Graph
1499 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1500 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
1503 for ( i = 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1504 (_SortedNodes[ 0 ])[ i ]->Level( 0 ) ;
1505 (_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ;
1508 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
1509 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1510 (_SortedNodes[ i ])[ j ]->Level( i ) ;
1511 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
1515 bool Graphs = true ;
1517 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1518 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1519 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
1520 cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name()
1523 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
1524 if ( aNode->LinkedNodes( k )->SubGraph() ) {
1525 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() &&
1526 aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
1527 aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
1528 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1529 << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1530 << ") ==>" << endl ;
1531 cdebug << " Graph " << aNode->SubGraph() << " for "
1532 << aNode->Name() << " ==> again" << endl ;
1534 for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) {
1535 aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ;
1541 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1542 << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1543 << ") distance > 1 ignored" << endl ;
1547 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1548 << " GraphInit to " << aNode->SubGraph() << " from "
1549 << aNode->Name() << endl ;
1550 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
1558 cdebug << endl << "Graphs result : " << endl ;
1561 cdebug << endl << "One more time" << endl ;
1565 int CurrGraphsNumber = 0;
1567 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
1568 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
1569 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
1570 _GraphsNumber += 1 ;
1571 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1572 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1573 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
1574 (_SortedNodes[ i ])[ j ]->SubGraph( _GraphsNumber ) ;
1575 cdebug << "GraphsNumber " << _GraphsNumber << " " << " Level "
1576 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
1588 // Controle de la coherence des noeuds de calcul
1589 // Enregistrement dans la liste des noeuds "tete" de graphe
1591 bool GraphBase::Graph::ComputingNodes() const {
1592 bool RetVal = true ;
1593 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
1595 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
1596 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
1597 // GraphEditor::Port * iP;
1599 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
1600 // while ( aNode != aComputingNodesList.end() ) {
1602 GraphBase::ComputingNode * aNode ;
1603 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1604 aNode = GraphNodes( i ) ;
1605 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
1606 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
1607 // if ((*aNode)->GetNodeInPortsSize() == 0)
1608 // _headNodes.push_front(*aNode);
1610 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1611 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
1612 if ( !iP->IsConnected() ){
1613 cdebug << "Le port d'entree " << iP->PortName()
1614 << " du noeud de calcul " << aNode->Name() << " du graphe "
1615 << Name() << " n'est pas connecte "<< endl;
1621 // Tous les noeuds de calcul ont au moins un port de sortie connecte
1622 bool oneOutPortConnected = false;
1623 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
1624 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
1625 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
1626 oneOutPortConnected = true ;
1630 cdebug << "Le port de sortie " << iP->PortName()
1631 << " du noeud de calcul " << aNode->Name() << " du graphe "
1632 << Name() << " n'est pas connecte "<< endl;
1636 if (!oneOutPortConnected) {
1637 cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
1638 << Name() << " n'a aucun port de sortie connecte "<< endl;
1639 // _computingError.push_front(2);
1642 // return _computingError.size () ;
1646 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
1647 bool RetVal = true ;
1650 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
1651 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1652 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1653 if ( aNode->IsLoopNode() ) {
1654 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
1655 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
1656 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
1657 if ( !anInPort->IsGate() && !anInPort->IsConnected() && !anInPort->IsDataConnected() ) {
1658 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
1659 aLoopNode , anInPort ) ) {
1660 cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
1661 << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
1662 << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
1670 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
1671 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
1672 if ( !anInPort->IsConnected() ) {
1673 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
1674 aLoopNode->CoupledNode() , anInPort ) ) {
1675 cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
1676 << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
1677 << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
1686 else if ( aNode->IsGOTONode() ) {
1687 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
1688 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
1689 if ( !anOutGate->IsConnected() ) {
1690 if ( !AddLink( aGOTONode , anOutGate ,
1691 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() ) ) {
1692 cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
1693 << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
1694 << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
1703 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
1707 // Controle de la coherence des noeuds de calcul
1708 // Enregistrement dans la liste des noeuds "tete" de graphe
1710 bool GraphBase::Graph::DataServerNodes() const {
1712 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
1714 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
1715 int i , j , ierr = 0 ;
1717 // if ( DataFlowDatas == NULL ) {
1718 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
1722 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
1723 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
1725 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
1727 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
1729 ierr = CheckDataServerNodes() ;
1731 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
1732 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
1733 if ( GraphNodesSize() == 0 ) {
1737 GraphBase::ComputingNode * aNode ;
1738 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1739 aNode = GraphNodes( i ) ;
1740 // while ( aNode != aComputingNodesList.end() ) {
1741 if ( aNode->IsFactoryNode() ) {
1742 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
1743 if ( !strlen( FaNode->Computer() ) ) {
1744 cdebug << "ComputerName missing for node " << FaNode->Name() ;
1745 if ( !strlen( FaNode->Computer() ) ) {
1750 cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
1754 // For Outputs of the DataFlow :
1755 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1756 if ( !aNode->GetNodeOutPort(j)->IsConnected() ) {
1757 aNode->AddLink( (GraphBase::ComputingNode *) this ) ;
1763 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
1765 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
1766 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
1768 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
1769 // while ( it != aDataServerNodesList.end() ) {
1770 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
1771 // cerr << "Erreur dans le noeud serveur de donnees "
1772 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1773 // cerr << "A la fois importation et exportation de donnees" << endl;
1774 // _dataServerError.push_front(1);
1777 // if ((*it)->GetNodeOutPortsSize()) {
1778 // if ((*it)->GetNodeOutPortsSize()==1){
1779 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
1780 // _headNodes.push_front(*it);
1783 // cerr << "Le port de sortie du noeud serveur de donnees "
1784 // << (*it)->Name() << " du graphe " << _G->Name()
1785 // << " n'est pas connecte "<< endl;
1786 // _dataServerError.push_front(4);
1790 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
1791 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1792 // _dataServerError.push_front(2);
1796 // if ((*it)->GetNodeInPortsSize()) {
1797 // if ((*it)->GetNodeInPortsSize() > 1){
1798 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
1799 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1800 // _dataServerError.push_front(3);
1803 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
1804 // cerr << "Le port d'entree du noeud serveur de donnees "
1805 // << (*it)->Name() << " du graphe " << _G->Name()
1806 // << " n'est pas connecte "<< endl;
1807 // _dataServerError.push_front(5);
1813 // return _dataServerError.size ();
1814 return ( ierr == 0 ) ;
1817 SUPERV::GraphState GraphBase::Graph::PortState(
1818 const char* NodeName ,
1819 const char* ServiceParameterName ) {
1820 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
1821 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
1822 // << ServiceParameterName << " )" << endl ;
1826 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
1828 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1830 GraphBase::OutPort *anOutPort ;
1831 anOutPort = aNode->GetChangeOutPort( aPort );
1832 if ( anOutPort == NULL ) {
1833 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1835 anOutPort = anInPort->GetOutPort() ;
1837 cdebug << "GraphBase::Graph::PortState OutPort/InPort not found --> "
1842 aRet = anOutPort->State() ;
1843 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
1847 cdebug << "GraphBase::Graph::PortState Node not found --> " << aRet
1855 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
1856 const char* ToServiceParameterName ) {
1857 const CORBA::Any * aRet = new CORBA::Any() ;
1860 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
1861 // << ToServiceParameterName << endl ;
1862 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
1864 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1867 GraphBase::OutPort *anOutPort = NULL ;
1868 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1870 anOutPort = anInPort->GetOutPort() ;
1872 aRet = anOutPort->Value() ;
1873 // cdebug << "OutPort value " << anOutPort->NodeName() << "("
1874 // << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
1875 // << "(" << anInPort->PortName() << ")" << endl ;
1878 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1879 << ToServiceParameterName << " ERROR no OutPort" << endl ;
1883 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1884 << ToServiceParameterName << " ERROR no InPort" << endl ;
1888 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1889 << ToServiceParameterName << " ERROR no Node" << endl ;
1893 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
1897 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
1898 const char* FromServiceParameterName ) {
1899 const CORBA::Any * aRet = new CORBA::Any() ;
1902 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1903 // << FromServiceParameterName << endl ;
1904 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
1906 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1909 GraphBase::OutPort *anOutPort ;
1910 anOutPort = aNode->GetChangeOutPort( aPort );
1912 aRet = anOutPort->Value() ;
1915 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1916 << FromServiceParameterName << " ERROR no OutPort" << endl ;
1920 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1921 << FromServiceParameterName << " ERROR no Node" << endl ;
1925 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
1929 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
1930 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
1931 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
1933 RetVal->length( _NodesNumber[ aLevel ] + 1 );
1934 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
1935 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
1938 return ( RetVal._retn() ) ;
1941 bool GraphBase::Graph::StartComponent(const int aThread ,
1942 const char * aComputerContainer ,
1943 const char * ComponentName ,
1944 Engines::Container_var & myContainer ,
1945 Engines::Component_var & objComponent ) {
1946 cdebug_in << aThread
1947 << " GraphBase::Graph::StartComponent " << aComputerContainer
1948 << " " << ComponentName << endl;
1949 bool RetVal = true ;
1951 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
1952 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
1954 if ( CORBA::is_nil( objComponent ) ) {
1955 cdebug_out << aThread
1956 << " StartComponent cannot FindOrLoad " << aComputerContainer
1957 << " " << ComponentName << endl;
1961 myContainer = LCC.FindContainer( aComputerContainer );
1962 if ( CORBA::is_nil( myContainer ) ) {
1963 cdebug_out << aThread
1964 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
1965 << aComputerContainer << "' ) Container does not exist"
1970 cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl;