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].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
196 (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
197 (*_list_nodes)[ind].theService = *aCNode->GetService();
198 // (*_list_nodes)[ind].theListOfParameters = *aCNode->GetListOfParameters() ;
199 if ( aCNode->IsOneOfInLineNodes() ) {
200 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
201 GraphBase::LoopNode * aLNode = NULL ;
202 if ( aCNode->IsLoopNode() ) {
203 aLNode = (GraphBase::LoopNode * ) aCNode ;
204 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
205 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
206 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
207 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
209 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
210 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
211 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
212 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
215 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
216 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
217 (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
218 (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
219 if ( aCNode->IsFactoryNode() ) {
220 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
221 (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
224 (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
226 (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
227 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
228 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
232 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
233 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
234 if ( anInPort->IsBus() ) {
236 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
237 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
238 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
239 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
240 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
251 //----------------------------------------------------------------------
252 // Function : GetLinks
253 // Purpose : get a links list
254 //----------------------------------------------------------------------
255 GraphBase::ListOfLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
256 GraphBase::ListOfLinks * _list_links =
257 new GraphBase::ListOfLinks;
259 // All the links from _LinksList are taken
260 // vector< InNode *> Nodes = InNodes() ;
264 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
265 GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
267 for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
268 const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
269 // if ( fromPort->IsPortConnected() && ( !fromPort->IsLoop() || AllLinks ) ) {
271 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
272 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
273 // Desole pour ce cast mais avec les maps difficile de faire const ...
274 const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
275 if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
276 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
277 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
278 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
279 << " " << fromPort->InPortsSize() << " ports" << endl ;
280 _list_links->resize( ind+1 );
281 (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
282 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
283 (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
284 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
285 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
286 if ( toPort->IsEndSwitch() ) {
287 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
290 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
294 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
295 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
296 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
297 << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
307 GraphBase::ListOfGraphs * GraphBase::Graph::GetGraphs() const {
308 GraphBase::ListOfGraphs * _list_graphs =
309 new GraphBase::ListOfGraphs;
314 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
315 GraphBase::InPort* toPort ) {
316 GraphBase::SLink * _link = new GraphBase::SLink ;
317 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
318 _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
319 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
320 _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
321 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
322 CORBA::Any aSPValue = *fromPort->Value() ;
323 _link->aLinkValue = aSPValue;
324 _link->aListOfCoords = *(toPort->Coords()) ;
327 //----------------------------------------------------------------------
328 // Function : GetDatas
329 // Purpose : get the datas list
330 //----------------------------------------------------------------------
331 GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const {
332 GraphBase::ListOfLinks * _list_datalinks =
333 new GraphBase::ListOfLinks;
336 const GraphBase::DataNode * aDataNode = this ;
338 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
339 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
340 if ( fromDataPort->IsDataConnected() ) {
342 //We may have SharedData as input of a DataFlow : same input for one or several
343 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
344 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
345 _list_datalinks->resize( ind+1 );
346 (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
347 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
348 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
349 (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
350 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
351 CORBA::Any aSPValue = *fromDataPort->Value() ;
352 (*_list_datalinks)[ind].aLinkValue = aSPValue;
353 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
359 // Output(s) of a DataFlow match only one input-virtual-dataport
360 for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
361 GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
362 const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
363 if ( fromPort->IsDataConnected() ) {
364 _list_datalinks->length( ind+1 );
365 _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
366 _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
367 _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
368 _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
369 // SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
370 CORBA::Any aSPValue = *fromPort->Value() ;
371 // aSPValue.Value = CORBA::string_dup( fromPort->Value() );
372 // aSPValue.Kind = fromPort->Kind();
373 _list_datalinks[ind].aLinkValue = aSPValue;
374 _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
379 return _list_datalinks ;
382 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
383 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " "
384 << aNode->Name() << " " << aNode->ServiceName() << endl;
385 bool RetVal = false ;
386 int index = GetGraphNodeIndex( aNode->Name() ) ;
388 _GraphNodes.resize( _GraphNodesSize+1 ) ;
389 _GraphNodes[ _GraphNodesSize ] = aNode ;
390 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
391 _GraphNodesSize += 1 ;
394 // cout << "GraphBase::Graph::AddNode(" << aNode->ComponentName() << " , "
395 // << aNode->Name() << ")" << endl;
397 cdebug << "GraphBase::Graph::AddNode Known nodes :" << endl ;
398 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
399 cdebug << i << ". " << GetGraphNode( i )->Name() << " "
400 << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
402 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
403 << aNode->ServiceName() << endl;
407 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
408 const char* NewNodeName ) {
409 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , "
410 << NewNodeName << ")" << endl;
412 bool RetVal = false ;
413 if ( !strcmp( OldNodeName , NewNodeName ) ) {
416 else if ( strcmp( Name() , OldNodeName ) ) {
417 int index = GetGraphNodeIndex( OldNodeName ) ;
418 int newindex = GetGraphNodeIndex( NewNodeName ) ;
419 if ( index >= 0 && index < _GraphNodesSize &&
420 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
421 _GraphNodes[ index ]->Name( NewNodeName ) ;
422 _MapOfGraphNodes.erase( OldNodeName ) ;
423 SetGraphNodeIndex( NewNodeName , index ) ;
425 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
426 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
427 cdebug << i << ". GraphBase::Graph::ReNameNode of LinkedNode : from " ;
428 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
429 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
431 cdebug << anOutPort->NodeName() ;
434 cdebug << "without link" ;
436 cdebug << " to " << i << ". " << anInPort->PortName()
437 << " of " << NewNodeName ;
438 if ( anInPort->IsConnected() ) {
439 if ( anOutPort->IsDataConnected() ) {
440 cdebug << " fromDataConnected "
441 << anOutPort->NodeName()
445 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
446 cdebug << " fromConnected " << FromNode->Name() << endl ;
447 FromNode->ReNameLink( OldNodeName , NewNodeName ) ;
449 char* OldNodePortName = new char[ strlen( OldNodeName ) +
450 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
451 char* NewNodePortName = new char[ strlen( NewNodeName ) +
452 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
453 strcpy( OldNodePortName , OldNodeName ) ;
454 strcat( OldNodePortName , "\\" ) ;
455 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
456 strcpy( NewNodePortName , NewNodeName ) ;
457 strcat( NewNodePortName , "\\" ) ;
458 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
459 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
460 delete [] OldNodePortName ;
461 delete [] NewNodePortName ;
466 cdebug << " not connected" << endl ;
473 cdebug << "Node not found" << endl ;
477 RetVal = Name( NewNodeName ) ;
480 cdebug_out << "GraphBase::Graph::ReNameNode" << endl;
484 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
485 cdebug_in << "GraphBase::Graph::RemoveNode (" << aNodeName << ")" << endl;
487 bool RetVal = false ;
488 int index = GetGraphNodeIndex( aNodeName ) ;
489 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
491 if ( aNode->GetNodeInPortsSize() ) {
492 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
493 cdebug << i << ". GraphBase::Graph::RemoveNode of LinkedNode : from " ;
494 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
495 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
497 cdebug << anOutPort->NodeName() ;
500 cdebug << "without link" ;
502 cdebug << " to " << i << ". " << anInPort->PortName()
503 << " of " << aNodeName ;
504 if ( anInPort->IsConnected() ) {
505 if ( anOutPort->IsDataConnected() ) {
506 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
509 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
510 cdebug << " fromConnected " << FromNode->Name() << endl ;
511 FromNode->RemoveLink( aNode ) ;
513 RetVal = anOutPort->RemoveInPort( anInPort ) ;
518 cdebug << " not connected" << endl ;
527 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
528 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
529 cdebug << "GraphBase::Graph::Remove " <<anOutPort->InPortsSize()
530 << " Links of OutPort : " << i << ". "
531 << *aNode->GetChangeNodeOutPort( i ) ;
533 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
534 cdebug << " to " << j << ". " << *anOutPort->InPorts( j )
536 RetVal = anOutPort->ChangeInPorts( j )->RemoveOutPort() ;
539 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anOutPort->InPorts( j )->NodeName() ) ;
540 aNode->RemoveLink( ToNode ) ;
541 RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
545 // RetVal = aNode->GetChangeNodeOutPort( j )->RemoveLinks() ;
550 // RetVal = aNode->RemoveLinks() ; // In PortsOfNode
552 // if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() || aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
553 // GraphBase::InLineNode * anInLineNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
554 // if ( anInLineNode ) {
555 // RetVal = RemoveNode( anInLineNode->Name() ) ;
561 _GraphNodesSize -= 1 ;
562 for ( i = index ; i < _GraphNodesSize ; i++ ) {
563 SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
564 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
566 _GraphNodes.resize( _GraphNodesSize+1 ) ;
567 _MapOfGraphNodes.erase( aNodeName ) ;
572 cdebug << "Node not found" << endl ;
575 cdebug_out << "GraphBase::Graph::RemoveNode" << endl;
579 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
580 const char* FromServiceParameterName ,
581 const char* ToNodeName ,
582 const char* ToServiceParameterName ,
583 const CORBA::Any aValue ) {
586 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
587 << FromServiceParameterName << ") ---> " << ToNodeName << "("
588 << ToServiceParameterName << ") )" << endl;
590 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
591 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
593 GraphBase::OutPort *fromPort = NULL ;
594 GraphBase::InPort *toPort = NULL ;
597 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
599 cdebug << "AddLink fromPort " << FromServiceParameterName << " FromNode("
600 << FromNodeName << ") not found." << endl ;
604 cdebug << "AddLink FromNode " << FromNodeName << " not found." << endl ;
607 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
609 cdebug << "AddLink toPort " << ToServiceParameterName << " ToNode("
610 << ToNodeName << ") not found." << endl ;
614 cdebug << "AddLink toNode " << ToNodeName << " not found." << endl ;
617 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
620 if ( fromPort->IsGate() && toPort->IsGate() ) {
622 aValue <<= (long ) 1 ;
623 fromPort->Value( aValue ) ;
626 const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
627 fromPort->Value( aDataValue ) ;
631 cdebug_out << "GraphBase::Graph::AddLink" << endl;
635 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
636 GraphBase::OutPort *fromPort ,
637 GraphBase::ComputingNode *toNode ,
638 GraphBase::InPort *toPort ) {
642 cdebug << "AddLink fromNode not found." << endl ;
646 cdebug << "AddLink fromPort not found." << endl ;
651 cdebug << "AddLink toNode not found." << endl ;
655 cdebug << "AddLink toPort not found." << endl ;
659 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
660 << fromPort->PortName() << ") ---> " << toNode->Name() << "("
661 << toPort->PortName() << ") )" << endl;
662 if ( !fromNode->IsDataFlowNode() && !toNode->IsDataFlowNode() &&
663 toPort->GetOutPort() ) {
664 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
665 fromPort->NodePortName() ) ) {
666 cdebug << "Link already exists" << endl ;
667 cdebug_out << "GraphBase::Graph::AddLink" << endl;
670 else if ( toPort->IsDataConnected() ) {
671 toPort->RemoveOutPort() ;
673 else if ( fromNode->IsGOTONode() ) {
674 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
675 toPort->GetOutPort()->PortName() ,
676 toNode->Name() , toPort->PortName() ) ) {
677 cdebug << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() Error."
679 cdebug_out << "GraphBase::Graph::AddLink" << endl;
682 if ( 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 else if ( !toNode->IsEndSwitchNode() ||
693 ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
694 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
695 toNode->Name() , toPort->PortName() ) ) {
696 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
697 cdebug_out << "GraphBase::Graph::AddLink" << endl;
702 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
703 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
704 fromPort->ChangeInPorts(0)->NodeName() ,
705 fromPort->ChangeInPorts(0)->PortName() ) ) {
706 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
707 cdebug_out << "GraphBase::Graph::AddLink" << endl;
712 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
713 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
714 if ( !fromPort->AddInPort( toPort ) ) {
715 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
717 cdebug_out << "GraphBase::Graph::AddLink" << endl;
720 toPort->Kind( SUPERV::EndSwitchParameter ) ;
722 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
723 cdebug << "!fromPort->AddLink Error." << endl ;
724 cdebug_out << "GraphBase::Graph::AddLink" << endl;
728 if ( fromNode->IsDataFlowNode() && toPort->IsDataConnected() ) {
729 toPort->RemoveOutPort() ;
732 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
733 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
734 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
735 cdebug_out << "GraphBase::Graph::AddLink" << endl;
738 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
739 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
740 cdebug_out << "GraphBase::Graph::AddLink" << endl;
743 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
744 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
745 cdebug << "toPort->AddLink Error." << endl ;
746 cdebug_out << "GraphBase::Graph::AddLink" << endl;
751 toPort->AddOutPort( fromPort ) ;
754 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
755 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
756 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
757 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
758 << fromNode->Name() << " " << fromPort->PortName()
759 << " InLineNode/LoopNode_ConnectedInPortsNumber "
760 << toNode->ConnectedInPortsNumber() << endl;
761 if ( fromNode->IsGOTONode() ) {
762 fromPort->Kind( SUPERV::GOTOParameter ) ;
764 fromPort->PortStatus( PortConnected ); // GOTO - Loop
766 else if ( fromNode->IsDataFlowNode() || toNode->IsDataFlowNode() ) {
767 cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) "
768 << fromNode->Name() << " " << fromPort->PortName() << endl ;
769 fromPort->PortStatus( DataConnected );
772 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
773 << fromNode->Name() << " " << fromPort->PortName() << " "
774 << fromPort->Kind() << " -> " << toNode->Name() << " " << " "
775 << toPort->PortName() << " " << toPort->Kind() << endl;
776 fromPort->PortStatus( PortConnected );
777 if ( !fromPort->IsDataStream() && !toPort->IsDataStream() ) {
778 fromNode->AddLink( toNode ) ;
781 if ( fromNode->IsSwitchNode() ) {
782 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
783 fromPort->Kind( SUPERV::SwitchParameter ) ;
785 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
786 fromPort->Kind( SUPERV::InLineParameter ) ;
788 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
789 GraphBase::InLineNode * anEndSwitchNode ;
790 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
791 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
792 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
793 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
794 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
795 anOutPort->IsGate() ) {
796 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
797 anEndSwitchNode->Name() ,
798 anInPort->PortName() ) ) {
799 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
801 cdebug_out << "GraphBase::Graph::AddLink" << endl;
807 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
808 cdebug_out << "GraphBase::Graph::AddLink" << endl;
812 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
813 const char* FromServiceParameterName ,
814 const char* ToNodeName ,
815 const char* ToServiceParameterName ) {
816 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
817 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
818 bool RetVal = false ;
819 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
821 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
822 if ( anInPort && ( anInPort->IsConnected() ||
823 anInPort->IsDataConnected() ) ) {
824 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
825 RetVal = anOutPort->RemoveInPort( anInPort ) ;
826 anInPort->RemoveOutPort() ;
827 const char * FromNodeName = anOutPort->NodeName() ;
828 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
831 fromNode->RemoveLink( toNode ) ;
833 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
834 anOutPort->Kind( SUPERV::InLineParameter ) ;
837 if ( fromNode->IsEndLoopNode() ) {
838 toNode = ((GraphBase::EndOfLoopNode * ) fromNode)->CoupledNode() ;
840 anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
841 RetVal = AddLink( fromNode , anOutPort , toNode , anInPort ) ;
847 if ( toNode->IsLoopNode() ) {
848 fromNode = ((GraphBase::LoopNode * ) toNode)->CoupledNode() ;
850 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
851 RetVal = AddLink( fromNode , anOutPort , toNode , toNode->GetChangeInPort( ToServiceParameterName ) ) ;
861 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
865 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
866 const char* ToServiceParameterName ,
867 char** FromNodeName ,
868 char** FromServiceParameterName ) {
869 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
870 // << ToServiceParameterName << ")" << endl;
871 bool RetVal = false ;
872 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
874 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
875 if ( anInPort && anInPort->IsConnected() ) {
876 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
877 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
878 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
882 cdebug << "GraphEditor::OutNode::GetLink ERROR no InPort or NotConnected " << ToNodeName
883 << " " << ToServiceParameterName << " " << RetVal << endl;
887 cdebug << "GraphEditor::OutNode::GetLink ERROR no Node " << ToNodeName << " " << RetVal
890 // cdebug_out << "GraphEditor::OutNode::GetLink " << RetVal << endl;
894 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
895 const char* ToServiceParameterName ,
896 const CORBA::Any aValue ) {
897 bool RetVal = false ;
898 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
899 << ToServiceParameterName << " , Any " ;
900 switch (aValue.type()->kind()) {
901 case CORBA::tk_string:
904 cdebug << t << " (string) " ;
906 case CORBA::tk_double:
909 cdebug << d << " (double) " ;
914 cdebug << l << " (long) " ;
916 case CORBA::tk_objref:
917 cdebug << "(object reference) " ;
920 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
923 cdebug << ")" << endl;
925 GraphBase::OutPort *fromDataNodePort = NULL ;
927 GraphBase::ComputingNode *toNode ;
928 GraphBase::InPort *toPort ;
931 NodePort( ToNodeName , ToServiceParameterName , &aNode , &aPort ) ;
932 toNode = GetChangeGraphNode( aNode ) ;
934 toPort = toNode->GetChangeInPort( aPort ) ;
935 if ( toPort && !toPort->IsDataConnected() ) {
936 toPort->RemoveOutPort() ;
947 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
948 cdebug "GraphBase::Graph::AddInputData " << GetNodeOutDataNodePort(i) << endl ;
950 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
951 cdebug "GraphBase::Graph::AddInputData " << GetNodeInDataNodePort(i) << endl ;
955 if ( toNode && toPort ) {
956 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
957 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
958 fromDataNodePort->RemoveInPort( toPort ) ;
960 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
961 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
962 << toPort->PortName() << " )" << endl ;
963 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
966 fromDataNodePort->Value( aValue ) ;
970 cdebug << "Node not found" << endl ;
973 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
977 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
978 const char * ToServiceParameterName ,
979 const CORBA::Any aValue ) {
980 bool RetVal = false ;
981 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
982 << ToServiceParameterName << "' , Any " ;
983 switch (aValue.type()->kind()) {
984 case CORBA::tk_string:
987 cdebug << t << " (string) " ;
989 case CORBA::tk_double:
992 cdebug << d << " (double) " ;
997 cdebug << l << " (long) " ;
999 case CORBA::tk_objref:
1000 cdebug << "(object reference) " ;
1003 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1006 cdebug << ")" << endl;
1008 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1010 GraphBase::OutPort *fromPort = NULL ;
1011 GraphBase::InPort *toPort = NULL ;
1014 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1016 fromPort = toPort->GetOutPort();
1019 fromPort->Value( aValue ) ;
1020 toPort->State( SUPERV::ReadyState ) ;
1023 cdebug << "ChangeInputData fromPort not found" << endl ;
1027 cdebug << "ChangeInputData toPort not found" << endl ;
1031 cdebug << "ChangeInputData Node not found : " << ToNodeName << endl ;
1034 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1038 bool GraphBase::Graph::AddInputData(
1039 const char* ToNodeName1 ,
1040 const char* ToServiceParameterName1 ,
1041 const char* ToNodeName2 ,
1042 const char* ToServiceParameterName2 ) {
1043 bool RetVal = false ;
1044 cdebug_in << "GraphBase::Graph::AddInputSharedData(" << ToNodeName1 << ","
1045 << ToServiceParameterName1 << ", " << ToNodeName2 << ","
1046 << ToServiceParameterName2 << " )" << endl;
1048 GraphBase::ComputingNode *toNode1 = GetChangeGraphNode( ToNodeName1 ) ;
1049 GraphBase::ComputingNode *toNode2 = GetChangeGraphNode( ToNodeName2 ) ;
1051 GraphBase::OutPort *fromDataNodePort1 = NULL ;
1052 GraphBase::OutPort *fromDataNodePort2 = NULL ;
1053 GraphBase::InPort *toPort1 = NULL ;
1054 GraphBase::InPort *toPort2 = NULL ;
1056 if ( toNode1 && toNode2 ) {
1057 toPort1 = toNode1->GetChangeInPort( ToServiceParameterName1 ) ;
1058 toPort2 = toNode2->GetChangeInPort( ToServiceParameterName2 ) ;
1059 fromDataNodePort1 = GraphBase::DataNode::GetChangeInDataNodePort( toPort1->NodePortName() ) ;
1060 // const char* aDataValue = fromDataNodePort->Value() ;
1061 const CORBA::Any ** aDataValue1 = fromDataNodePort1->ValuePtr() ;
1062 fromDataNodePort2 = GraphBase::DataNode::GetChangeInDataNodePort( toPort2->NodePortName() ) ;
1063 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort1 ,
1064 toNode2 , toPort2 ) ;
1066 fromDataNodePort2->Value( aDataValue1 ) ;
1069 cdebug << "Node not found" << endl ;
1072 cdebug_out << "GraphBase::Graph::AddInputSharedData" << endl;
1076 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1077 const char* ToServiceParameterName ,
1078 const CORBA::Any ** aValue ) {
1079 bool RetVal = false ;
1080 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1081 << ToServiceParameterName << " **Any " ;
1082 const CORBA::Any theValue = **aValue ;
1083 switch (theValue.type()->kind()) {
1084 case CORBA::tk_string:
1087 cdebug << t << " (string) " ;
1089 case CORBA::tk_double:
1092 cdebug << d << " (double) " ;
1094 case CORBA::tk_long:
1097 cdebug << l << " (long) " ;
1099 case CORBA::tk_objref:
1100 cdebug << "(object reference) " ;
1103 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1106 cdebug << ")" << endl;
1108 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1110 GraphBase::OutPort *fromDataNodePort = NULL ;
1111 GraphBase::InPort *toPort = NULL ;
1114 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1115 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1116 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1117 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1118 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1121 fromDataNodePort->Value( aValue ) ;
1125 cdebug << "Node not found" << endl ;
1128 cdebug_out << "GraphBase::Graph::AddInputData" << endl;
1132 bool GraphBase::Graph::AddOutputData(
1133 const char* FromNodeName ,
1134 const char* FromServiceParameterName ,
1135 const CORBA::Any aValue ) {
1136 // const char* DataValue ,
1137 // const SUPERV::KindOfPortValue aKindOfPortValue ) {
1138 bool RetVal = false ;
1139 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1140 << FromServiceParameterName
1141 // << FromServiceParameterName << ", " << DataValue << ","
1142 // << aKindOfPortValue
1145 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1147 GraphBase::OutPort *fromPort = NULL ;
1148 GraphBase::InPort *toDataNodePort = NULL ;
1151 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1152 toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1153 RetVal = AddLink( fromNode , fromPort ,
1154 (GraphBase::ComputingNode * ) this , toDataNodePort ,
1156 // DataValue , aKindOfPortValue ) ;
1159 cdebug << "Node not found" << endl ;
1162 cdebug_out << "GraphBase::Graph::AddOutputData" << endl;
1166 bool GraphBase::Graph::CreateService() {
1167 cdebug_in << "GraphBase::Graph::CreateService" << endl;
1168 bool RetVal = true ;
1169 SALOME_ModuleCatalog::Service aService ;
1171 GraphBase::ComputingNode * aToNode ;
1175 vector< SUPERV::KindOfPort > InPortsKind ;
1176 vector< SUPERV::KindOfPort > OutPortsKind ;
1177 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1178 if ( dostore == 1 ) {
1179 aService.ServiceName = Name() ;
1180 aService.ServiceinParameter.length( 0 ) ;
1181 aService.ServiceinParameter.length( innbr ) ;
1182 aService.ServiceoutParameter.length( 0 ) ;
1183 aService.ServiceoutParameter.length( outnbr ) ;
1184 InPortsKind.resize( innbr ) ;
1185 OutPortsKind.resize( outnbr ) ;
1187 if ( dostore <= 1 ) {
1191 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1192 aToNode = GraphNodes( i ) ;
1193 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1194 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1195 bool isfromcouplednode = false ;
1196 if ( anInPort->IsConnected() && anInPort->GetOutPort() ) {
1197 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( anInPort->GetOutPort()->NodeName() ) ;
1198 if ( aFromNode->IsEndLoopNode() && ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1199 isfromcouplednode = true ;
1202 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1203 ( !anInPort->IsConnected() || ( anInPort->IsConnected() && isfromcouplednode ) ) ) {
1204 if ( dostore == 0 ) {
1205 cdebug << "CreateService " << aToNode->Name() << " Input port "
1206 << anInPort->PortName() << " " << anInPort->Kind() << " is NOT connected " ;
1207 if ( anInPort->GetOutPort() ) {
1208 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1213 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1214 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1215 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1216 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1217 InPortsKind[ innbr++ ] = anInPort->Kind() ;
1218 cdebug << "In " << aService.ServiceinParameter[ innbr - 1 ].Parametername << " " << anInPort->Kind() << endl ;
1222 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName() ;
1223 if ( anInPort->IsConnected() ) {
1224 cdebug << " is connected " ;
1227 cdebug << " is NOT connected " ;
1229 if ( anInPort->IsGate() ) {
1230 cdebug << " IsGate " ;
1232 if ( anInPort->GetOutPort() ) {
1233 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1236 cdebug << "NOT DataConnected" ;
1241 GraphBase::ComputingNode * aFromNode = aToNode ;
1242 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1243 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1244 cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1246 cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1249 cdebug << " NULL" << endl ;
1251 if ( !aFromNode->IsGOTONode() ) {
1252 if ( !anOutPort->IsGate() &&
1253 ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) {
1254 if ( dostore == 0 ) {
1255 cdebug << "CreateService " << aFromNode->Name() << " Output port "
1256 << anOutPort->PortName() << endl ;
1259 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1260 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1261 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1262 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1263 OutPortsKind[ outnbr++ ] = anOutPort->Kind() ;
1264 cdebug << "Out " << aService.ServiceoutParameter[ outnbr - 1 ].Parametername << " " << anOutPort->Kind() << endl ;
1272 // MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName );
1273 // for ( i = 0 ; i < innbr ; i++ ) {
1274 // cout << "aService.ServiceinParameter[" << i << "].Parametertype "
1275 // << aService.ServiceinParameter[i].Parametertype << endl ;
1276 // cout << "aService.ServiceinParameter[" << i << "].Parametername "
1277 // << aService.ServiceinParameter[i].Parametername << endl ;
1279 // for ( i = 0 ; i < outnbr ; i++ ) {
1280 // cout << "aService.ServiceoutParameter[" << i << "].Parametertype "
1281 // << aService.ServiceoutParameter[i].Parametertype << endl ;
1282 // cout << "aService.ServiceoutParameter[" << i << "].Parametername "
1283 // << aService.ServiceoutParameter[i].Parametername << endl ;
1286 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1287 for ( i = 0 ; i < innbr ; i++ ) {
1288 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1289 cdebug << "In " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1290 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1291 cdebug << "ReversedIn " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() << endl ;
1293 for ( i = 0 ; i < outnbr ; i++ ) {
1294 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1295 cdebug << "Out " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1296 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1297 cdebug << "ReversedOut " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind() << endl ;
1299 // Restore input datas :
1300 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1301 aToNode = GraphNodes( i ) ;
1302 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1303 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1304 if ( anInPort->IsDataConnected() ) {
1305 AddInputData( anInPort->NodeName() ,
1306 anInPort->PortName() ,
1307 anInPort->GetOutPort()->ValuePtr() ) ;
1312 cdebug_out << "GraphBase::Graph::CreateService" << endl;
1316 bool GraphBase::Graph::InLineServices() {
1317 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1320 ListPorts( *_Graph_fdebug , 0 ) ;
1321 GraphBase::InLineNode * aINode ;
1322 SALOME_ModuleCatalog::Service aService ;
1323 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1324 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1325 if ( aINode->IsOneOfInLineNodes() || aINode->HasDataStream() ) {
1326 cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1327 aService.ServiceName = aINode->ServiceName() ;
1328 aService.ServiceinParameter.length( 0 ) ;
1329 aService.ServiceoutParameter.length( 0 ) ;
1331 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1332 if ( aINode->GetChangeNodeInPort(j)->IsGate() ||
1333 aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1334 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1335 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1336 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1337 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1338 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1339 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1342 aService.ServiceinParameter.length( InService+1 ) ;
1343 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1344 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1345 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1346 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1347 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1348 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1349 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1350 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1353 int OutService = 0 ;
1354 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1355 if ( aINode->GetChangeNodeOutPort(j)->IsGate() ||
1356 aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1357 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1358 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1359 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1360 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1361 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1362 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1365 aService.ServiceoutParameter.length( OutService+1 ) ;
1366 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1367 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1368 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1369 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1370 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1371 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1372 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1373 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1376 aINode->SetService( aService ) ;
1377 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1381 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1385 bool GraphBase::Graph::Sort() {
1388 int NotSortedNumber = GraphNodesSize() ;
1390 if ( NotSortedNumber ) {
1392 _ParallelExecutionNodes = false ;
1393 _Sorted.resize( GraphNodesSize() ) ;
1394 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1395 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1396 if ( _NodesNumber.size() )
1397 _NodesNumber.resize( 0 ) ;
1398 _SortedNodes.resize( 0 ) ;
1400 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1401 _Sorted[ i ] = false ;
1402 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1403 _DecrInPortsNumber[ i ] = 0 ;
1406 while ( NotSortedNumber ) {
1409 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1410 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1411 << GraphNodes( i )->Name() << " count "
1412 << _CnxInPortsNumber[ i ] << endl ;
1413 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1414 // All inputs of GraphNodes( i ) are available
1415 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
1416 _NodesNumber.resize( _LevelsNumber+1 ) ;
1417 _SortedNodes.resize( _LevelsNumber+1 ) ;
1418 _NodesNumber[ _LevelsNumber ] = -1 ;
1420 _NodesNumber[ _LevelsNumber ]++ ;
1421 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1422 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1423 _Sorted[ i ] = true ;
1425 cdebug << GraphNodes( i )->Name() << " belongs to level "
1426 << _LevelsNumber << "." << endl ;
1427 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1428 // Outputs of GraphNodes( i ) will satisfy
1429 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1430 // GraphNodes( i )->LinkedNodes( j )
1431 GraphBase::ComputingNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1432 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1433 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1434 if ( !aLinkedNode->IsDataFlowNode() ) {
1435 cdebug << " _DecrInPortsNumber[ "
1436 << GetGraphNodeIndex( aLinkedNode->Name() )
1438 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1439 << " += " << aLinkedInPortsNumber ;
1440 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1443 // GraphNodes( i )->LinkedNodes( j )->IncrDecrConnectedInPortsNumber( GraphNodes( i )->LinkedInPortsNumber( j ) ) ;
1448 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1449 return false ; // Loop in the Graph
1451 cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1452 bool ChangeCount = false ;
1453 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1454 // if ( GraphNodes( i )->DecrIncrDecrConnectedInPortsNumber() ) {
1455 if ( _DecrInPortsNumber[ i ] ) {
1456 int prevcount = _CnxInPortsNumber[ i ] ;
1457 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
1458 _DecrInPortsNumber[ i ] = 0 ;
1459 ChangeCount = true ;
1460 cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
1461 << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1467 _LevelsNumber += 1 ;
1470 int AllSortedNodes = 0 ;
1471 _HeadNodes = _SortedNodes[ 0 ] ;
1472 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1473 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1474 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1475 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1476 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1480 if ( i == _QueueNodesSize && _LevelsNumber ) {
1481 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1482 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1484 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1485 AllSortedNodes += _NodesNumber[ i ]+1 ;
1486 if ( _NodesNumber[ i ] + 1 > _ThreadsMax )
1487 _ThreadsMax = _NodesNumber[ i ] + 1 ;
1488 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1489 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1490 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1491 _ParallelExecutionNodes = true ;
1492 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
1496 if ( _ParallelExecutionNodes ) {
1497 cdebug << "Parallel Execution Nodes detected." << endl ;
1500 cdebug << "No Parallel Execution Nodes detected." << endl ;
1502 if ( AllSortedNodes != GraphNodesSize() ) {
1503 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1504 return false ; // Loop in the Graph
1507 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1508 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
1511 for ( i = 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1512 (_SortedNodes[ 0 ])[ i ]->Level( 0 ) ;
1513 (_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ;
1516 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
1517 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1518 (_SortedNodes[ i ])[ j ]->Level( i ) ;
1519 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
1523 bool Graphs = true ;
1525 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1526 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1527 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
1528 cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name()
1531 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
1532 if ( aNode->LinkedNodes( k )->SubGraph() ) {
1533 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() &&
1534 aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
1535 aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
1536 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1537 << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1538 << ") ==>" << endl ;
1539 cdebug << " Graph " << aNode->SubGraph() << " for "
1540 << aNode->Name() << " ==> again" << endl ;
1542 for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) {
1543 aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ;
1549 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1550 << " Graph(" << aNode->LinkedNodes( k )->SubGraph()
1551 << ") distance > 1 ignored" << endl ;
1555 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
1556 << " GraphInit to " << aNode->SubGraph() << " from "
1557 << aNode->Name() << endl ;
1558 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
1566 cdebug << endl << "Graphs result : " << endl ;
1569 cdebug << endl << "One more time" << endl ;
1573 int CurrGraphsNumber = 0;
1575 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
1576 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
1577 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
1578 _GraphsNumber += 1 ;
1579 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1580 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
1581 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
1582 (_SortedNodes[ i ])[ j ]->SubGraph( _GraphsNumber ) ;
1583 cdebug << "GraphsNumber " << _GraphsNumber << " " << " Level "
1584 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
1593 ListPorts( *_Graph_fdebug , 0 ) ;
1598 // Controle de la coherence des noeuds de calcul
1599 // Enregistrement dans la liste des noeuds "tete" de graphe
1601 bool GraphBase::Graph::ComputingNodes() const {
1602 bool RetVal = true ;
1603 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
1605 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
1606 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
1607 // GraphEditor::Port * iP;
1609 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
1610 // while ( aNode != aComputingNodesList.end() ) {
1612 GraphBase::ComputingNode * aNode ;
1613 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1614 aNode = GraphNodes( i ) ;
1615 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
1616 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
1617 // if ((*aNode)->GetNodeInPortsSize() == 0)
1618 // _headNodes.push_front(*aNode);
1620 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
1621 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
1622 if ( !iP->IsConnected() ){
1623 cdebug << "Le port d'entree " << iP->PortName()
1624 << " du noeud de calcul " << aNode->Name() << " du graphe "
1625 << Name() << " n'est pas connecte "<< endl;
1631 // Tous les noeuds de calcul ont au moins un port de sortie connecte
1632 bool oneOutPortConnected = false;
1633 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
1634 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
1635 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
1636 oneOutPortConnected = true ;
1640 cdebug << "Le port de sortie " << iP->PortName()
1641 << " du noeud de calcul " << aNode->Name() << " du graphe "
1642 << Name() << " n'est pas connecte "<< endl;
1646 if (!oneOutPortConnected) {
1647 cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
1648 << Name() << " n'a aucun port de sortie connecte "<< endl;
1649 // _computingError.push_front(2);
1652 // return _computingError.size () ;
1656 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
1657 bool RetVal = true ;
1660 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
1661 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1662 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1663 if ( aNode->IsLoopNode() ) {
1664 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
1665 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
1666 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
1667 if ( !anInPort->IsGate() && !anInPort->IsConnected() && !anInPort->IsDataConnected() ) {
1668 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
1669 aLoopNode , anInPort ) ) {
1670 cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
1671 << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
1672 << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
1680 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
1681 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
1682 if ( !anInPort->IsConnected() ) {
1683 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
1684 aLoopNode->CoupledNode() , anInPort ) ) {
1685 cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
1686 << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
1687 << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
1696 else if ( aNode->IsGOTONode() ) {
1697 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
1698 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
1699 if ( !anOutGate->IsConnected() ) {
1700 if ( !AddLink( aGOTONode , anOutGate ,
1701 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() ) ) {
1702 cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
1703 << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
1704 << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
1713 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
1717 // Controle de la coherence des noeuds de calcul
1718 // Enregistrement dans la liste des noeuds "tete" de graphe
1720 bool GraphBase::Graph::DataServerNodes() const {
1722 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
1724 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
1725 int i , j , ierr = 0 ;
1727 // if ( DataFlowDatas == NULL ) {
1728 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
1732 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
1733 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
1735 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
1737 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
1739 ierr = CheckDataServerNodes() ;
1741 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
1742 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
1743 if ( GraphNodesSize() == 0 ) {
1747 GraphBase::ComputingNode * aNode ;
1748 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1749 aNode = GraphNodes( i ) ;
1750 // while ( aNode != aComputingNodesList.end() ) {
1751 if ( aNode->IsFactoryNode() ) {
1752 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
1753 if ( !strlen( FaNode->Computer() ) ) {
1754 cdebug << "ComputerName missing for node " << FaNode->Name() ;
1755 if ( !strlen( FaNode->Computer() ) ) {
1760 cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
1764 // For Outputs of the DataFlow :
1765 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
1766 if ( !aNode->GetNodeOutPort(j)->IsConnected() ) {
1767 aNode->AddLink( (GraphBase::ComputingNode *) this ) ;
1773 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
1775 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
1776 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
1778 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
1779 // while ( it != aDataServerNodesList.end() ) {
1780 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
1781 // cerr << "Erreur dans le noeud serveur de donnees "
1782 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1783 // cerr << "A la fois importation et exportation de donnees" << endl;
1784 // _dataServerError.push_front(1);
1787 // if ((*it)->GetNodeOutPortsSize()) {
1788 // if ((*it)->GetNodeOutPortsSize()==1){
1789 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
1790 // _headNodes.push_front(*it);
1793 // cerr << "Le port de sortie du noeud serveur de donnees "
1794 // << (*it)->Name() << " du graphe " << _G->Name()
1795 // << " n'est pas connecte "<< endl;
1796 // _dataServerError.push_front(4);
1800 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
1801 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1802 // _dataServerError.push_front(2);
1806 // if ((*it)->GetNodeInPortsSize()) {
1807 // if ((*it)->GetNodeInPortsSize() > 1){
1808 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
1809 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
1810 // _dataServerError.push_front(3);
1813 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
1814 // cerr << "Le port d'entree du noeud serveur de donnees "
1815 // << (*it)->Name() << " du graphe " << _G->Name()
1816 // << " n'est pas connecte "<< endl;
1817 // _dataServerError.push_front(5);
1823 // return _dataServerError.size ();
1824 return ( ierr == 0 ) ;
1827 SUPERV::GraphState GraphBase::Graph::PortState(
1828 const char* NodeName ,
1829 const char* ServiceParameterName ) {
1830 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
1831 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
1832 // << ServiceParameterName << " )" << endl ;
1836 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
1838 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1840 GraphBase::OutPort *anOutPort ;
1841 anOutPort = aNode->GetChangeOutPort( aPort );
1842 if ( anOutPort == NULL ) {
1843 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1845 anOutPort = anInPort->GetOutPort() ;
1847 cdebug << "GraphBase::Graph::PortState OutPort/InPort not found --> "
1852 aRet = anOutPort->State() ;
1853 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
1857 cdebug << "GraphBase::Graph::PortState Node not found --> " << aRet
1865 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
1866 const char* ToServiceParameterName ) {
1867 const CORBA::Any * aRet = new CORBA::Any() ;
1870 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
1871 // << ToServiceParameterName << endl ;
1872 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
1874 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1877 GraphBase::OutPort *anOutPort = NULL ;
1878 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
1880 anOutPort = anInPort->GetOutPort() ;
1882 aRet = anOutPort->Value() ;
1883 // cdebug << "OutPort value " << anOutPort->NodeName() << "("
1884 // << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
1885 // << "(" << anInPort->PortName() << ")" << endl ;
1888 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1889 << ToServiceParameterName << " ERROR no OutPort" << endl ;
1893 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1894 << ToServiceParameterName << " ERROR no InPort" << endl ;
1898 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
1899 << ToServiceParameterName << " ERROR no Node" << endl ;
1903 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
1907 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
1908 const char* FromServiceParameterName ) {
1909 const CORBA::Any * aRet = new CORBA::Any() ;
1912 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1913 // << FromServiceParameterName << endl ;
1914 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
1916 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
1919 GraphBase::OutPort *anOutPort ;
1920 anOutPort = aNode->GetChangeOutPort( aPort );
1922 aRet = anOutPort->Value() ;
1925 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1926 << FromServiceParameterName << " ERROR no OutPort" << endl ;
1930 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
1931 << FromServiceParameterName << " ERROR no Node" << endl ;
1935 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
1939 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
1940 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
1941 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
1943 RetVal->length( _NodesNumber[ aLevel ] + 1 );
1944 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
1945 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
1948 return ( RetVal._retn() ) ;
1951 bool GraphBase::Graph::StartComponent(const int aThread ,
1952 const char * aComputerContainer ,
1953 const char * ComponentName ,
1954 Engines::Container_var & myContainer ,
1955 Engines::Component_var & objComponent ) {
1956 cdebug_in << aThread
1957 << " GraphBase::Graph::StartComponent " << aComputerContainer
1958 << " " << ComponentName << endl;
1959 bool RetVal = true ;
1961 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
1962 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
1964 if ( CORBA::is_nil( objComponent ) ) {
1965 cdebug_out << aThread
1966 << " StartComponent cannot FindOrLoad " << aComputerContainer
1967 << " " << ComponentName << endl;
1971 myContainer = LCC.FindContainer( aComputerContainer );
1972 if ( CORBA::is_nil( myContainer ) ) {
1973 cdebug_out << aThread
1974 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
1975 << aComputerContainer << "' ) Container does not exist"
1980 cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl;