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_StreamGraph.hxx"
32 #include "SALOME_LifeCycleCORBA.hxx"
34 GraphBase::Graph::Graph() :
36 cdebug << "GraphBase::Graph::Graph" << endl ;
41 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
42 SALOME_NamingService* ptrNamingService ,
43 const char *DataFlowName ,
44 const SUPERV::KindOfNode DataFlowkind ,
45 int * Graph_prof_debug ,
46 ofstream * Graph_fdebug ) :
47 // const char * DebugFileName ) :
48 DataNode( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
49 _Orb = CORBA::ORB::_duplicate( ORB ) ;
51 Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
52 cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ;
56 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
57 SALOME_NamingService* ptrNamingService ,
58 const SALOME_ModuleCatalog::Service& DataFlowService ,
59 const char *DataFlowComponentName ,
60 const char *DataFlowInterfaceName ,
61 const char *DataFlowName ,
62 const SUPERV::KindOfNode DataFlowkind ,
63 const SUPERV::SDate DataFlowFirstCreation ,
64 const SUPERV::SDate DataFlowLastModification ,
65 const char * DataFlowEditorRelease ,
66 const char * DataFlowAuthor ,
67 const char * DataFlowComputer ,
68 const char * DataFlowComment ,
69 int * Graph_prof_debug ,
70 ofstream * Graph_fdebug ) :
71 // const char * DebugFileName ) :
72 DataNode( ORB , ptrNamingService , DataFlowService ,
73 DataFlowName , DataFlowkind ,
74 DataFlowFirstCreation , DataFlowLastModification ,
75 DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
76 _Orb = CORBA::ORB::_duplicate( ORB ) ;
79 Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
80 cdebug_in << "GraphBase::Graph::Graph" << endl ;
81 DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ;
82 cdebug_out << "GraphBase::Graph::Graph" << endl ;
85 GraphBase::Graph::~Graph() {
86 cdebug << "GraphBase::Graph::~Graph" << endl ;
89 void GraphBase::Graph::Set_prof_debug( int * Graph_prof_debug ,
90 ofstream * Graph_fdebug ) {
91 SetDebug( _Orb , Graph_prof_debug , Graph_fdebug ) ;
92 _Graph_prof_debug = Graph_prof_debug ;
93 _Graph_fdebug = Graph_fdebug ;
96 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
97 GraphBase::SNode * Info = new GraphBase::SNode ;
98 Info->theComponentName = "" ;
99 Info->theInterfaceName = "" ;
100 Info->theName = Name() ;
101 Info->theKind = Kind() ;
102 if ( IsDataStreamNode() ) {
104 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
106 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
107 Info->theTimeout = Timeout ;
108 Info->theDataStreamTrace = DataStreamTrace ;
109 Info->theDeltaTime = DeltaTime ;
111 Info->theService = *GetService() ;
112 Info->theFirstCreation = FirstCreation() ;
113 Info->theLastModification = LastModification() ;
114 Info->theEditorRelease = EditorRelease() ;
115 Info->theAuthor = Author() ;
116 Info->theContainer = "" ;
117 Info->theComment = Comment() ;
118 Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
119 Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
123 //----------------------------------------------------------------------
124 // Function : GetNodes
125 // Purpose : get a nodes list
126 //----------------------------------------------------------------------
127 GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
128 GraphBase::ListOfSNodes * _list_nodes = new GraphBase::ListOfSNodes;
130 cdebug_in << "GraphBase::Graph::GetNodes" << endl ;
131 // All the nodes from _InNodes are taken
132 // vector< InNode *> Nodes = InNodes() ;
134 _list_nodes->resize( GraphNodesSize() );
138 GraphBase::ComputingNode * aCNode = NULL ;
139 for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
140 for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
141 aCNode = GraphNodes( ind ) ;
142 if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
143 ( igoto == 1 && aCNode->IsGOTONode() ) ) {
144 if ( aCNode->IsFactoryNode() ) {
145 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
146 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
147 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
150 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
151 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
153 (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
154 (*_list_nodes)[ind].theKind = aCNode->Kind();
155 if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
156 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
157 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
158 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
159 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
160 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
162 if ( aCNode->IsGOTONode() ) {
163 GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
164 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
165 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
166 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
167 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
169 if ( aCNode->IsLoopNode() ) {
170 GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
171 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
172 (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
173 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
174 (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
175 (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
176 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
177 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
178 (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
179 (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
181 else if ( aCNode->IsSwitchNode() ) {
182 GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
183 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
184 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
185 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
186 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
187 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
189 else if ( aCNode->IsEndLoopNode() ) {
190 GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
191 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
192 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
193 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
194 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
195 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
197 else if ( aCNode->IsEndSwitchNode() ) {
198 GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
199 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
200 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
201 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
202 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
203 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
205 else if ( aCNode->IsMacroNode() ) {
206 GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
207 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
208 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
209 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
210 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
211 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
214 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
216 // (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
217 // (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
219 (*_list_nodes)[ind].theListOfInDataStreams.resize( aCNode->DataStreamInPortsNumber() ) ;
220 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamInPortsNumber() << " DataStreamInPortsNumber" << endl ;
223 for ( iostream = 0 ; iostream < aCNode->GetNodeInPortsSize() ; iostream++ ) {
224 const GraphBase::InPort * anInPort ;
225 anInPort = aCNode->GetNodeInPort( iostream ) ;
226 if ( anInPort->IsDataStream() ) {
227 cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName()
229 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ;
230 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
231 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
232 SUPERV::KindOfSchema aKindOfSchema ;
233 SUPERV::KindOfInterpolation aKindOfInterpolation ;
234 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
235 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
236 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema = aKindOfSchema ;
237 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation = aKindOfInterpolation ;
238 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation = aKindOfExtrapolation ;
239 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
240 << anInPort->Dependency() << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation << " list_nodes "
241 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername << " "
242 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype << " "
243 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
244 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema << " "
245 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation << " "
246 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation << " " << endl ;
250 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
251 << anInPort->Kind() << " IsDataStream " << anInPort->IsDataStream() << endl ;
255 (*_list_nodes)[ind].theListOfOutDataStreams.resize( aCNode->DataStreamOutPortsNumber() ) ;
256 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamOutPortsNumber() << " DataStreamOutPortsNumber" << endl ;
258 for ( iostream = 0 ; iostream < aCNode->GetNodeOutPortsSize() ; iostream++ ) {
259 const GraphBase::OutPort * anOutPort ;
260 anOutPort = aCNode->GetNodeOutPort( iostream ) ;
261 if ( anOutPort->IsDataStream() ) {
262 cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
264 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ;
265 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
266 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
267 long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
268 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues = aNumberOfValues ;
269 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
270 << anOutPort->Dependency() << " " << aNumberOfValues << " list_nodes "
271 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername << " "
272 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype << " "
273 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
274 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues << endl ;
278 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
279 << anOutPort->Kind() << " IsDataStream " << anOutPort->IsDataStream() << endl ;
283 (*_list_nodes)[ind].theService = *aCNode->GetService();
284 cdebug << "GraphBase::Graph::GetNodes theService " << &(*_list_nodes)[ind].theService.ServiceName << endl ;
286 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinParameter.length() ; i++ ) {
287 cdebug << " In" << i << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
288 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
289 << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype
290 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype << endl ;
292 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutParameter.length() ; i++ ) {
293 cdebug << " Out" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
294 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
295 << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype
296 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype << endl ;
298 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinDataStreamParameter.length() ; i++ ) {
299 cdebug << " InDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
300 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
301 << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype
302 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype << endl ;
304 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter.length() ; i++ ) {
305 cdebug << " OutDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
306 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
307 << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype
308 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype << endl ;
310 if ( aCNode->IsOneOfInLineNodes() ) {
311 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
312 GraphBase::LoopNode * aLNode = NULL ;
313 if ( aCNode->IsLoopNode() ) {
314 aLNode = (GraphBase::LoopNode * ) aCNode ;
315 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
316 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
317 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
318 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
320 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
321 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
322 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
323 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
326 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
327 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
328 (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
329 (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
330 if ( aCNode->IsFactoryNode() ) {
331 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
332 (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
335 (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
337 (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
338 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
339 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
343 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
344 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
345 if ( anInPort->IsBus() ) {
347 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
348 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
349 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
350 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
351 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
358 cdebug_out << "GraphBase::Graph::GetNodes" << endl ;
363 //----------------------------------------------------------------------
364 // Function : GetLinks
365 // Purpose : get a links list
366 //----------------------------------------------------------------------
367 GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
368 GraphBase::ListOfSLinks * _list_links = new GraphBase::ListOfSLinks;
370 // All the links from _LinksList are taken
371 // vector< InNode *> Nodes = InNodes() ;
375 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
376 GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
378 for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
379 const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
381 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
382 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
383 if ( toPort->IsPortConnected() ) {
384 // Desole pour ce cast mais avec les maps difficile de faire const ...
385 const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
386 if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
387 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
388 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
389 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
390 << " " << fromPort->InPortsSize() << " ports" << endl ;
391 _list_links->resize( ind+1 );
392 (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
393 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
394 (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
395 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
396 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
397 if ( toPort->IsEndSwitch() ) {
398 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
401 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
406 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
407 << fromPort->PortName() << " ) " << fromPort->PortStatus()
408 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
409 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
418 GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const {
419 GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs;
424 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
425 GraphBase::InPort* toPort ) {
426 GraphBase::SLink * _link = new GraphBase::SLink ;
427 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
428 _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
429 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
430 _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
431 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
432 CORBA::Any aSPValue = *fromPort->Value() ;
433 _link->aLinkValue = aSPValue;
434 _link->aListOfCoords = *(toPort->Coords()) ;
437 //----------------------------------------------------------------------
438 // Function : GetDatas
439 // Purpose : get the datas list
440 //----------------------------------------------------------------------
441 GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
442 GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks;
445 const GraphBase::DataNode * aDataNode = this ;
447 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
448 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
449 if ( GraphMacroLevel() == 0 ) {
450 if ( fromDataPort->IsDataConnected() ) {
452 //We may have SharedData as input of a DataFlow : same input for one or several
453 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
454 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
455 _list_datalinks->resize( ind+1 );
456 (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
457 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
458 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
459 (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
460 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
461 CORBA::Any aSPValue = *fromDataPort->Value() ;
462 (*_list_datalinks)[ind].aLinkValue = aSPValue;
463 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
470 // Output(s) of a DataFlow match only one input-virtual-dataport
471 for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
472 GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
473 const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
474 if ( fromPort->IsDataConnected() ) {
475 _list_datalinks->length( ind+1 );
476 _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
477 _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
478 _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
479 _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
480 // SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
481 CORBA::Any aSPValue = *fromPort->Value() ;
482 // aSPValue.Value = CORBA::string_dup( fromPort->Value() );
483 // aSPValue.Kind = fromPort->Kind();
484 _list_datalinks[ind].aLinkValue = aSPValue;
485 _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
490 return _list_datalinks ;
493 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
494 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl;
495 bool RetVal = false ;
496 int index = GetGraphNodeIndex( aNode->Name() ) ;
498 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ;
499 _GraphNodes.resize( _GraphNodesSize+1 ) ;
500 _GraphNodes[ _GraphNodesSize ] = aNode ;
501 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
502 _GraphNodesSize += 1 ;
503 if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) {
504 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ;
507 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName()
508 << " was already in MapOfServices" << endl ;
513 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ;
514 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
515 const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ;
517 cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
520 cdebug << i << ". ERROR" << endl ;
524 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
525 << aNode->ServiceName() << endl;
529 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
530 const char* NewNodeName ) {
531 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ")" << endl;
533 bool RetVal = false ;
534 if ( !strcmp( OldNodeName , NewNodeName ) ) {
537 else if ( strcmp( Name() , OldNodeName ) ) {
538 int index = GetGraphNodeIndex( OldNodeName ) ;
539 int newindex = GetGraphNodeIndex( NewNodeName ) ;
540 if ( index >= 0 && index < _GraphNodesSize &&
541 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
542 _GraphNodes[ index ]->Name( NewNodeName ) ;
543 _MapOfGraphNodes.erase( OldNodeName ) ;
544 SetGraphNodeIndex( NewNodeName , index ) ;
546 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
547 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
548 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
549 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
550 cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
552 cdebug << anOutPort->NodeName() ;
555 cdebug << "without link" ;
557 cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
558 if ( !anInPort->IsNotConnected() ) {
559 if ( anOutPort->IsDataConnected() ) {
560 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
563 GraphBase::ComputingNode * FromNode ;
564 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
565 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
570 cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
571 if ( anInPort->IsDataStream() ) {
572 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
575 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
578 char* OldNodePortName = new char[ strlen( OldNodeName ) +
579 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
580 char* NewNodePortName = new char[ strlen( NewNodeName ) +
581 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ;
582 strcpy( OldNodePortName , OldNodeName ) ;
583 // strcat( OldNodePortName , "\\" ) ;
584 strcat( OldNodePortName , "_" ) ;
585 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
586 strcpy( NewNodePortName , NewNodeName ) ;
587 // strcat( NewNodePortName , "\\" ) ;
588 strcat( NewNodePortName , "_" ) ;
589 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
590 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
591 delete [] OldNodePortName ;
592 delete [] NewNodePortName ;
597 cdebug << " not connected" << endl ;
604 cdebug << "Node not found" << endl ;
608 RetVal = Name( NewNodeName ) ;
611 cdebug_out << "GraphBase::Graph::ReNameNode" << endl;
615 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
616 cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << LinkedNodesSize() << " LinkedNodes :"
619 bool RetVal = false ;
620 int index = GetGraphNodeIndex( aNodeName ) ;
621 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
622 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
623 cdebug << " " << i << ". " << LinkedNodes( i ) << endl ;
626 cdebug << "Graph::RemoveNode " << aNode->GetNodeInPortsSize() << " InPorts " << aNode->GetNodeOutPortsSize()
627 << " OutPorts" << endl ;
628 if ( aNode->GetNodeInPortsSize() ) {
629 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
630 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
631 cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
632 << anInPort->PortStatus() << " <-- " ;
633 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
635 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
638 if ( !anInPort->IsNotConnected() ) {
640 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
641 cdebug << " Data/Extern" << endl ;
644 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
645 if ( !FromNode->IsGOTONode() ) {
646 if ( anInPort->IsDataStream() ) {
647 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
650 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
653 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
658 RetVal = anOutPort->RemoveInPort( anInPort ) ;
660 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
673 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
674 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
675 cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
676 << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
677 << anOutPort->PortStatus() << " :" << endl ;
679 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
680 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
681 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
682 << anInPort->PortStatus() << endl ;
683 if ( !anInPort->IsExternConnected() ) {
684 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
685 RetVal = anInPort->RemoveOutPort() ;
687 cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
690 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
691 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
693 else if ( anOutPort->IsDataStream() ) {
694 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
697 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
700 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
703 RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
705 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
711 cdebug << "Error RetVal " << RetVal << endl ;
718 _GraphNodesSize -= 1 ;
719 for ( i = index ; i < _GraphNodesSize ; i++ ) {
720 SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
721 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
723 _GraphNodes.resize( _GraphNodesSize+1 ) ;
724 _MapOfGraphNodes.erase( aNodeName ) ;
729 cdebug << "Node not found ERROR " << index << endl ;
732 cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl;
736 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
737 const char* FromServiceParameterName ,
738 const char* ToNodeName ,
739 const char* ToServiceParameterName ) {
740 // , const CORBA::Any aValue ) {
743 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
744 << FromServiceParameterName << ") ---> " << ToNodeName << "("
745 << ToServiceParameterName << ") , aValue )" << endl;
747 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
748 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
750 GraphBase::OutPort *fromPort = NULL ;
751 GraphBase::InPort *toPort = NULL ;
754 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
756 cdebug << "AddLink fromPort " << FromServiceParameterName << " FromNode("
757 << FromNodeName << ") not found." << endl ;
761 cdebug << "AddLink FromNode " << FromNodeName << " not found." << endl ;
764 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
766 cdebug << "AddLink toPort " << ToServiceParameterName << " ToNode("
767 << ToNodeName << ") not found." << endl ;
771 cdebug << "AddLink toNode " << ToNodeName << " not found." << endl ;
774 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
777 if ( fromPort->IsGate() && toPort->IsGate() ) {
779 aValue <<= (long ) 1 ;
780 fromPort->Value( aValue ) ;
783 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
784 // fromPort->Value( aDataValue ) ;
786 // fromPort->PortStatus( DataConnected );
789 cdebug_out << "GraphBase::Graph::AddLink" << endl;
793 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
794 GraphBase::OutPort *fromPort ,
795 GraphBase::ComputingNode *toNode ,
796 GraphBase::InPort *toPort ) {
800 cdebug << "AddLink fromNode not found." << endl ;
804 cdebug << "AddLink fromPort not found." << endl ;
809 cdebug << "AddLink toNode not found." << endl ;
813 cdebug << "AddLink toPort not found." << endl ;
816 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
817 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
818 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
821 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
822 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
823 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
827 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
828 << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "("
829 << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl;
830 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
831 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
832 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
833 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
837 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
838 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
839 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
840 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
844 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
845 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
846 toPort->GetOutPort()->PortName() ,
847 toNode->Name() , toPort->PortName() ) ) {
848 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
853 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
854 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
855 toPort->GetOutPort() ) {
856 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
857 fromPort->NodePortName() ) ) {
858 cdebug << "Link already exists" << endl ;
859 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
862 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
863 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
865 else if ( fromNode->IsGOTONode() ) {
866 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
867 toPort->GetOutPort()->PortName() ,
868 toNode->Name() , toPort->PortName() ) ) {
869 cdebug << "RemoveLink(AddLink) Error."
871 cdebug_out << "GraphBase::Graph::AddLink" << endl;
874 if ( fromPort->InPortsSize() ) {
875 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
876 fromPort->ChangeInPorts(0)->NodeName() ,
877 fromPort->ChangeInPorts(0)->PortName() ) ) {
878 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
879 cdebug_out << "GraphBase::Graph::AddLink" << endl;
884 else if ( !toNode->IsEndSwitchNode() ||
885 ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
886 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
887 toNode->Name() , toPort->PortName() ) ) {
888 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
889 cdebug_out << "GraphBase::Graph::AddLink" << endl;
894 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
895 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
896 fromPort->ChangeInPorts(0)->NodeName() ,
897 fromPort->ChangeInPorts(0)->PortName() ) ) {
898 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
899 cdebug_out << "GraphBase::Graph::AddLink" << endl;
903 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
904 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
905 fromPort->RemoveInPort( toPort ) ; //dbg
907 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
908 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
909 fromPort->RemoveInPort() ; // There is only one
913 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
914 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
915 if ( !fromPort->AddInPort( toPort ) ) {
916 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
918 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
921 if ( !toPort->IsDataStream() ) {
922 toPort->Kind( SUPERV::EndSwitchParameter ) ;
925 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
926 cdebug << "!fromPort->AddLink Error." << endl ;
927 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
931 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
932 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
933 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
934 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
937 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
938 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
939 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
942 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
943 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
944 cdebug << "toPort->AddLink Error." << endl ;
945 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
950 toPort->AddOutPort( fromPort ) ;
953 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
954 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
955 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
956 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
957 << fromNode->Name() << " " << fromPort->PortName()
958 << " InLineNode/LoopNode_ConnectedInPortsNumber "
959 << toNode->ConnectedInPortsNumber() << endl;
960 if ( fromNode->IsGOTONode() ) {
961 fromPort->Kind( SUPERV::GOTOParameter ) ;
963 fromPort->PortStatus( PortConnected ); // GOTO - Loop
965 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
966 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
967 << fromNode->Name() << " " << fromPort->PortName() << endl ;
968 fromPort->PortStatus( ExternConnected );
970 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
971 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
972 << fromNode->Name() << " " << fromPort->PortName() << endl ;
973 fromPort->PortStatus( ExternConnected ) ;
976 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
977 << fromNode->Name() << " " << fromPort->PortName() << " "
978 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
979 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
980 fromPort->PortStatus( PortConnected );
981 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
982 fromNode->AddStreamLinkedNode( toNode ) ;
985 fromNode->AddLinkedNode( toNode ) ;
988 if ( fromNode->IsSwitchNode() ) {
989 if ( !fromPort->IsDataStream() ) {
990 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
991 fromPort->Kind( SUPERV::SwitchParameter ) ;
993 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
994 fromPort->Kind( SUPERV::InLineParameter ) ;
997 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
998 GraphBase::InLineNode * anEndSwitchNode ;
999 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1000 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1001 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1002 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1003 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1004 anOutPort->IsGate() ) {
1005 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1006 anEndSwitchNode->Name() ,
1007 anInPort->PortName() ) ) {
1008 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1010 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1016 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1017 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1021 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1022 const char* FromServiceParameterName ,
1023 const char* ToNodeName ,
1024 const char* ToServiceParameterName ) {
1025 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1026 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1027 bool RetVal = false ;
1028 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1030 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1031 if ( anInPort && ( anInPort->IsPortConnected() ||
1032 anInPort->IsDataConnected() ||
1033 anInPort->IsExternConnected() ) ) {
1034 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1035 RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> :
1036 // anInPort->RemoveOutPort() ;
1037 const char * FromNodeName = anOutPort->NodeName() ;
1038 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1041 if ( anInPort->IsDataStream() ) {
1042 fromNode->RemoveStreamLinkedNode( toNode ) ;
1045 fromNode->RemoveLinkedNode( toNode ) ;
1048 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1049 anOutPort->Kind( SUPERV::InLineParameter ) ;
1054 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1058 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1059 const char* ToServiceParameterName ,
1060 char** FromNodeName ,
1061 char** FromServiceParameterName ) {
1062 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1063 // << ToServiceParameterName << ")" << endl;
1064 bool RetVal = false ;
1065 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1067 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1068 if ( anInPort && !anInPort->IsNotConnected() ) {
1069 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1070 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1071 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1075 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1076 << " " << ToServiceParameterName << " " << RetVal << endl;
1080 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1083 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1087 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1088 const char* ToServiceParameterName ,
1089 const CORBA::Any aValue ) {
1090 bool RetVal = false ;
1091 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1092 << ToServiceParameterName << " , Any " ;
1093 switch (aValue.type()->kind()) {
1094 case CORBA::tk_string:
1097 cdebug << t << " (string) " ;
1099 case CORBA::tk_double:
1102 cdebug << d << " (double) " ;
1104 case CORBA::tk_long:
1107 cdebug << l << " (long) " ;
1109 case CORBA::tk_objref:
1110 cdebug << "(object reference) " ;
1113 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1114 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1117 cdebug << " ) in Graph " << Name() << endl;
1119 GraphBase::ComputingNode *toNode ;
1120 GraphBase::InPort *toPort ;
1123 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1124 toNode = GetChangeGraphNode( aNodeName ) ;
1125 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1127 toPort = toNode->GetChangeInPort( aPortName ) ;
1128 if ( toPort && !toPort->IsDataConnected() ) {
1129 toPort->RemoveOutPort() ;
1137 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1138 cdebug "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1140 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1141 cdebug "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1144 if ( toNode && toPort ) {
1145 GraphBase::OutPort *fromDataNodePort = NULL ;
1146 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1147 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1148 fromDataNodePort->RemoveInPort( toPort ) ;
1150 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1151 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1152 << toPort->PortName() << " )" << endl ;
1153 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1156 fromDataNodePort->Value( aValue ) ;
1157 fromDataNodePort->PortStatus( DataConnected ) ;
1161 cdebug << "Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1166 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1170 // Used in the Executor in order to change an Input Value and ReRun
1171 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1172 const char * ToServiceParameterName ,
1173 const CORBA::Any aValue ) {
1174 bool RetVal = false ;
1175 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1176 << ToServiceParameterName << "' , Any " ;
1177 switch (aValue.type()->kind()) {
1178 case CORBA::tk_string:
1181 cdebug << t << " (string) " ;
1183 case CORBA::tk_double:
1186 cdebug << d << " (double) " ;
1188 case CORBA::tk_long:
1191 cdebug << l << " (long) " ;
1193 case CORBA::tk_objref:
1194 cdebug << "(object reference) " ;
1197 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1200 cdebug << ")" << endl;
1202 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1204 GraphBase::OutPort *fromPort = NULL ;
1205 GraphBase::InPort *toPort = NULL ;
1208 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1210 fromPort = toPort->GetOutPort();
1213 fromPort->Value( aValue ) ;
1214 fromPort->PortStatus( DataConnected ) ;
1215 toPort->State( SUPERV::ReadyState ) ;
1218 cdebug << "ChangeInputData fromPort not found" << endl ;
1222 cdebug << "ChangeInputData toPort not found" << endl ;
1226 cdebug << "ChangeInputData Node not found : " << ToNodeName << endl ;
1229 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1233 // To restore InputData in CreateService
1234 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1235 const char* ToServiceParameterName ,
1236 const CORBA::Any ** aValue ) {
1237 bool RetVal = false ;
1238 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1239 << ToServiceParameterName << ", **Any " ;
1240 const CORBA::Any theValue = **aValue ;
1241 switch (theValue.type()->kind()) {
1242 case CORBA::tk_string:
1245 cdebug << t << " (string) " ;
1247 case CORBA::tk_double:
1250 cdebug << d << " (double) " ;
1252 case CORBA::tk_long:
1255 cdebug << l << " (long) " ;
1257 case CORBA::tk_objref:
1258 cdebug << "(object reference) " ;
1261 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1264 cdebug << ") of Graph " << Name() << endl;
1266 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1269 GraphBase::InPort *toPort = NULL ;
1270 GraphBase::OutPort *fromDataNodePort = NULL ;
1271 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1272 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1273 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1274 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1275 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1278 fromDataNodePort->Value( aValue ) ;
1279 fromDataNodePort->PortStatus( DataConnected ) ;
1283 cdebug << "Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1284 map< string , int >::iterator aMapOfGraphNodesIterator ;
1286 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1287 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1288 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1289 << aMapOfGraphNodesIterator->second << endl ;
1293 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1297 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1298 const char* FromServiceParameterName ,
1299 const CORBA::Any aValue ) {
1300 bool RetVal = true ;
1301 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1302 << FromServiceParameterName << ")" << endl;
1303 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1305 GraphBase::OutPort *anOutPort = NULL ;
1308 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1309 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1310 // RetVal = AddLink( fromNode , fromPort ,
1311 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1312 anOutPort->Value( aValue ) ;
1313 anOutPort->State( SUPERV::ReadyState ) ;
1314 anOutPort->Done( true ) ;
1315 cdebug << *anOutPort ;
1316 anOutPort->StringValue( *_fdebug ) ;
1320 cdebug << "Node not found" << endl ;
1323 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1327 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1328 return _MapOfServiceNames ; }
1330 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1331 return _MapOfServiceNames[ name ] ;
1334 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1335 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1337 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1338 << " already in MapOfServiceNames : erase" << endl ;
1339 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1341 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1342 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1346 int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
1347 GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
1348 if ( theService == NULL ) {
1351 return theService->NewInstance() ;
1354 void GraphBase::Graph::SetGraphPorts() {
1355 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1357 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1358 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1359 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1360 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ;
1361 if ( !anOutPort->IsGate() ) {
1362 anOutPort->PortStatus( ExternConnected ) ;
1365 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1366 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1367 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1368 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ;
1369 if ( !anInPort->IsGate() ) {
1370 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1371 anOutPort->PortStatus( ExternConnected ) ;
1374 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1377 bool GraphBase::Graph::CreateService() {
1378 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1379 bool RetVal = true ;
1380 SALOME_ModuleCatalog::Service aService ;
1382 GraphBase::ComputingNode * aToNode ;
1385 int instreamnbr = 0 ;
1387 int outstreamnbr = 0 ;
1388 vector< SUPERV::KindOfPort > InPortsKind ;
1389 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1390 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1391 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1392 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1393 vector< SUPERV::KindOfPort > OutPortsKind ;
1394 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1395 vector< long > OutNumberOfValues ;
1396 // if ( GraphMacroLevel() == 0 ) {
1397 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1398 if ( dostore == 1 ) {
1399 aService.ServiceName = Name() ;
1400 aService.ServiceinParameter.length( 0 ) ;
1401 aService.ServiceinParameter.length( innbr ) ;
1402 aService.ServiceoutParameter.length( 0 ) ;
1403 aService.ServiceoutParameter.length( outnbr ) ;
1404 InPortsKind.resize( innbr ) ;
1405 InDataStreamDependency.resize( innbr ) ;
1406 InKindOfSchema.resize( innbr ) ;
1407 InKindOfInterpolation.resize( innbr ) ;
1408 InKindOfExtrapolation.resize( innbr ) ;
1409 OutPortsKind.resize( outnbr ) ;
1410 OutDataStreamDependency.resize( outnbr ) ;
1411 OutNumberOfValues.resize( outnbr ) ;
1413 else if ( dostore == 2 ) {
1414 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1415 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1416 << " outstreamnbr " << outstreamnbr << endl ;
1417 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1418 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1419 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1420 InPortsKind.resize( innbr + instreamnbr ) ;
1421 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1422 InKindOfSchema.resize( innbr + instreamnbr ) ;
1423 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1424 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1425 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1426 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1427 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1429 if ( dostore == 0 ) {
1435 if ( dostore == 1 ) {
1439 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1440 aToNode = GraphNodes( i ) ;
1441 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1442 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1443 bool isfromcouplednode = false ;
1444 if ( !anInPort->IsNotConnected() ) {
1445 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1446 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1447 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1448 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1449 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1450 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1451 isfromcouplednode = true ;
1454 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1455 ( !anInPort->IsPortConnected() ||
1456 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1457 if ( dostore == 0 ) {
1458 cdebug << "CreateService " << aToNode->Name() << " Input port "
1459 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1460 if ( anInPort->GetOutPort() ) {
1461 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1464 if ( anInPort->IsDataStream() ) {
1471 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1472 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1473 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1474 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1475 InPortsKind[ innbr ] = anInPort->Kind() ;
1476 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1477 if ( dostore == 2 && anInPort->IsDataStream() ) {
1478 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1479 InKindOfInterpolation[ innbr ] ,
1480 InKindOfExtrapolation[ innbr ] ) ;
1482 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1483 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1487 else if ( dostore == 0 ) {
1488 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1489 << " " << anInPort->PortStatus() ;
1490 if ( anInPort->IsPortConnected() ) {
1491 cdebug << " is connected " ;
1494 cdebug << " is NOT connected " ;
1496 if ( anInPort->IsGate() ) {
1497 cdebug << " IsGate " ;
1499 if ( anInPort->GetOutPort() ) {
1500 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1503 cdebug << "NOT DataConnected" ;
1508 GraphBase::ComputingNode * aFromNode = aToNode ;
1509 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1510 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1511 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1512 // if ( anOutPort ) {
1513 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1516 // cdebug << " NULL" << endl ;
1518 if ( !aFromNode->IsGOTONode() ) {
1519 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
1520 anOutPort->IsExternConnected() ) {
1521 if ( dostore == 0 ) {
1522 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1523 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1524 if ( anOutPort->IsDataStream() ) {
1531 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1532 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1533 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1534 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1535 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1536 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1537 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1538 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1540 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1541 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1552 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1553 << " OutPorts " << outnbr << endl ;
1554 for ( i = 0 ; i < innbr ; i++ ) {
1555 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1556 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1557 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1558 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1559 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1562 for ( i = 0 ; i < outnbr ; i++ ) {
1563 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1564 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1565 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1566 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1567 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1572 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
1573 for ( i = 0 ; i < innbr ; i++ ) {
1574 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1575 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
1576 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
1577 InDataStreamDependency[ i ] ,
1578 SUPERV::DataStreamParameter ) ;
1579 anInPort->SetParams( InKindOfSchema[ i ] ,
1580 InKindOfInterpolation[ i ] ,
1581 InKindOfExtrapolation[ i ] ) ;
1582 // NOT A BUG : AddOutPort for an inport (Reversed service)
1583 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
1586 aService.ServiceinParameter[ i ].Parametername ,
1587 aService.ServiceinParameter[ i ].Parametertype ,
1588 SUPERV::DataStreamParameter ,
1590 _Graph_prof_debug , _Graph_fdebug ) ;
1591 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
1592 // Attention : revoir les reversed DataStreamPorts
1593 // anInPort->SetParams( InKindOfSchema[ i ] ,
1594 // InKindOfInterpolation[ i ] ,
1595 // InKindOfExtrapolation[ i ] ) ;
1596 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1597 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1601 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1602 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1603 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1604 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1605 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1606 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1610 for ( i = 0 ; i < outnbr ; i++ ) {
1611 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1612 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
1613 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
1614 OutDataStreamDependency[ i ] ,
1615 SUPERV::DataStreamParameter ) ;
1616 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1617 // NOT A BUG : AddInPort for an outport (Reversed service)
1618 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
1621 aService.ServiceoutParameter[ i ].Parametername ,
1622 aService.ServiceoutParameter[ i ].Parametertype ,
1623 SUPERV::DataStreamParameter ,
1625 _Graph_prof_debug , _Graph_fdebug ) ;
1626 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
1627 // Attention : revoir les reversed DataStreamPorts
1628 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1629 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1630 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1634 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1635 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1636 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1637 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1638 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1639 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1640 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1641 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1645 // Restore input datas and links :
1646 DataStreamInPortsNumber( 0 ) ;
1647 DataStreamOutPortsNumber( 0 ) ;
1648 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1649 aToNode = GraphNodes( i ) ;
1650 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
1651 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
1652 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1653 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1654 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
1655 if ( !AddInputData( anInPort->NodeName() ,
1656 anInPort->PortName() ,
1657 anInPort->GetOutPort()->ValuePtr() ) ) {
1658 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1659 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
1663 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1664 << anInPort->PortStatus() << " --> AddInputData" << endl ;
1667 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
1668 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
1669 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1670 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
1674 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1675 << anInPort->PortStatus() << " --> AddInLink" << endl ;
1679 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
1680 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
1681 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
1682 << ") " << anOutPort->PortStatus() << " :" << endl ;
1683 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
1684 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
1685 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
1686 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1687 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
1691 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1692 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
1698 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
1702 bool GraphBase::Graph::InLineServices() {
1703 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1706 ListPorts( *_Graph_fdebug , 0 ) ;
1707 GraphBase::InLineNode * aINode ;
1708 SALOME_ModuleCatalog::Service aService ;
1709 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1710 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1711 if ( aINode->IsOneOfInLineNodes() ) {
1712 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1713 aService.ServiceName = aINode->ServiceName() ;
1714 aService.ServiceinParameter.length( 0 ) ;
1715 aService.ServiceoutParameter.length( 0 ) ;
1716 aINode->DataStreamInPortsNumber( 0 ) ;
1717 aINode->DataStreamOutPortsNumber( 0 ) ;
1719 int InStreamService = 0 ;
1720 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1721 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1723 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1724 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1725 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1726 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1727 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1728 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1731 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
1732 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
1733 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1734 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1735 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
1736 aINode->IncrDataStreamInPorts() ;
1738 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1739 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1740 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1741 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1742 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1743 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1747 aService.ServiceinParameter.length( InService+1 ) ;
1748 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1749 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1751 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1752 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1753 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1754 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1755 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1756 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1760 int OutService = 0 ;
1761 int OutStreamService = 0 ;
1762 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1763 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1764 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1766 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1767 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1768 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1769 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1770 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1771 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1774 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1775 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
1776 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1777 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1778 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
1779 aINode->IncrDataStreamOutPorts() ;
1781 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1782 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1783 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1784 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1785 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1786 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1790 aService.ServiceoutParameter.length( OutService+1 ) ;
1791 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1792 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1794 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1795 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1796 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1797 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1798 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1799 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1803 aINode->SetService( aService ) ;
1804 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
1806 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
1807 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
1808 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
1811 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1815 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1819 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
1822 int NotSortedNumber = GraphNodesSize() ;
1824 cdebug_in << "GraphBase::Graph::Sort" << endl;
1825 if ( NotSortedNumber ) {
1827 _ParallelExecutionNodes = false ;
1828 _Sorted.resize( GraphNodesSize() ) ;
1829 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1830 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1831 if ( _NodesNumber.size() ) {
1832 _NodesNumber.resize( 0 ) ;
1833 _SortedNodes.resize( 0 ) ;
1836 // This is a simulation of the computation of the graph :
1837 // The initial state of nodes is :
1838 // - Sorted = false : the node is not sorted
1839 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
1840 // - DecrInPortsNumber = 0 : there is no value available.
1842 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
1843 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1844 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1845 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
1846 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
1847 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
1851 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1852 _Sorted[ i ] = false ;
1853 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1854 _DecrInPortsNumber[ i ] = 0 ;
1855 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
1856 // << _CnxInPortsNumber[ i ] << endl ;
1859 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
1860 // ==============================================================================
1861 while ( NotSortedNumber ) {
1864 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1865 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1866 << GraphNodes( i )->Name() << " count "
1867 << _CnxInPortsNumber[ i ] << endl ;
1868 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1869 // All inputs of GraphNodes( i ) are available : "AllDataReady"
1870 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
1871 _NodesNumber.resize( _LevelsNumber+1 ) ;
1872 _SortedNodes.resize( _LevelsNumber+1 ) ;
1873 _NodesNumber[ _LevelsNumber ] = -1 ;
1875 // There is one more node at that level
1876 _NodesNumber[ _LevelsNumber ]++ ;
1877 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1878 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1879 _Sorted[ i ] = true ;
1881 NotSortedNumber -= 1 ;
1882 cdebug << GraphNodes( i )->Name() << " belongs to level "
1883 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
1884 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
1885 // So we loop over all nodes that have a link from that node
1886 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
1887 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
1888 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1889 // OutputPorts of GraphNodes( i ) will satisfy
1890 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1891 // GraphNodes( i )->LinkedNodes( j )
1892 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1893 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1894 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1895 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
1896 cdebug << " _DecrInPortsNumber[ "
1897 << GetGraphNodeIndex( aLinkedNode->Name() )
1899 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1900 << " += " << aLinkedInPortsNumber ;
1901 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1907 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
1908 // will wait for data(s) from node(s) not executed or not executing for ever
1910 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1911 return false ; // Loop in the Graph
1913 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1914 bool ChangeCount = false ;
1915 // We update now the number of InPorts with a link that are waiting for a value
1916 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1917 if ( _DecrInPortsNumber[ i ] ) {
1918 // int prevcount = _CnxInPortsNumber[ i ] ;
1919 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
1920 _DecrInPortsNumber[ i ] = 0 ;
1921 ChangeCount = true ;
1922 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
1923 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1926 // If there is no loop and if the number of InPorts with a link that are waiting for a value
1927 // does not change, the sort is finished. But there is also NotSortedNumber ...
1928 // if ( !ChangeCount )
1930 if ( NotSortedNumber ) {
1931 _LevelsNumber += 1 ;
1935 int AllSortedNodes = 0 ;
1936 _HeadNodes = _SortedNodes[ 0 ] ;
1937 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1938 // QueueNodes was used in the past in order to know if the execution of a graph is finished
1939 // But because of loop nodes that was changed. So that part of code is a "clutter"
1940 // Now a graph has finished its execution when the number of executing threads is zero
1941 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1942 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1943 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1944 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1948 if ( i == _QueueNodesSize && _LevelsNumber ) {
1949 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1950 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1952 // Computation of the maximum number of threads == the maximum number of nodes of all levels
1953 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1954 AllSortedNodes += _NodesNumber[ i ]+1 ;
1955 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
1956 _ThreadsMax = _NodesNumber[ i ] + 1 ;
1958 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1959 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1960 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1961 _ParallelExecutionNodes = true ;
1962 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
1966 if ( _ParallelExecutionNodes ) {
1967 // cdebug << "Parallel Execution Nodes detected." << endl ;
1970 // cdebug << "No Parallel Execution Nodes detected." << endl ;
1972 if ( AllSortedNodes != GraphNodesSize() ) {
1973 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1974 return false ; // Loop in the Graph
1977 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1978 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
1981 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
1982 // There is no substreamgraph for nodes without StreamPorts
1983 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
1984 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
1985 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
1986 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
1987 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
1988 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
1991 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
1995 // Give a subgraph/substreamgraph number = 0 to all other nodes :
1996 // the SubGraph of that nodes is unknown
1997 // There is no substreamgraph for nodes without StreamPorts
1998 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
1999 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2000 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2001 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2002 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2003 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2004 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2007 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2012 // Computation of independent SubGraphs which have NO link between them
2013 cdebug << endl << "Computation of SubGraphs" << endl ;
2014 bool Graphs = true ;
2016 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2017 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2018 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2019 // cdebug << "SubGraph " << aNode->SubGraph() << " " << aNode->Name()
2022 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2023 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2024 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() &&
2025 aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2026 aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2027 // cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2028 // << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph()
2029 // << ") ==>" << endl ;
2030 // cdebug << " SubGraph " << aNode->SubGraph() << " for "
2031 // << aNode->Name() << " ==> again" << endl ;
2033 for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) {
2034 aNode->LinkedNodes( l )->SubGraph( aNode->SubGraph() ) ;
2040 // cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2041 // << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph()
2042 // << ") distance > 1 ignored" << endl ;
2046 // cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2047 // << " GraphInit to " << aNode->SubGraph() << " from "
2048 // << aNode->Name() << endl ;
2049 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2057 // cdebug << endl << "SubGraphs result : " << endl ;
2060 // cdebug << endl << "One more time" << endl ;
2063 // Make a sequential renumbering of SubGraphs :
2064 _SubGraphsNumber = 0 ;
2065 int CurrGraphsNumber = 0;
2067 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2068 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2069 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2070 _SubGraphsNumber += 1 ;
2071 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2072 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2073 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2074 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2075 // cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2076 // << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2084 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2085 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2086 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2087 if ( aNode->SubStreamGraph() < 0 ) {
2088 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2091 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2092 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2093 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2094 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2099 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2100 SubStreamGraphsNumber = 0 ;
2102 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2103 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2105 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2106 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2107 if ( aNode->SubStreamGraph() < 0 ) {
2108 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2109 // << " has NO streamport" << endl ;
2112 int CurStreamGraphsNumber ;
2113 if ( aNode->SubStreamGraph() > 0 ) {
2114 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2115 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2116 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2119 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2122 while ( RetVal != CurStreamGraphsNumber ) {
2123 RetVal = CurStreamGraphsNumber ;
2124 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2125 if ( RetVal != CurStreamGraphsNumber ) {
2126 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2127 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2128 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2129 aNode->SubStreamGraph( RetVal ) ;
2132 CurStreamGraphsNumber = RetVal ;
2135 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2136 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2142 // Make a sequential renumbering of SubGraphs :
2143 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2144 int CurrStreamGraphsNumber = 0 ;
2146 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2147 bool SearchCurrStreamGraphsNumber = true ;
2148 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2150 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2151 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2152 SearchCurrStreamGraphsNumber = false ;
2154 if ( CurrStreamGraphsNumber != count ) {
2155 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2156 // << " Level " << k << " n " << l << endl ;
2157 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2158 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2159 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2160 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2161 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2162 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2164 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2165 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2166 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2167 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2176 SubStreamGraphsNumber = count ;
2177 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2178 // int CurrStreamGraphsNumber ;
2179 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2180 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2181 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2182 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2183 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2184 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2191 ListPorts( *_Graph_fdebug , 0 ) ;
2193 cdebug_out << "GraphBase::Graph::Sort" << endl;
2197 // Controle de la coherence des noeuds de calcul
2198 // Enregistrement dans la liste des noeuds "tete" de graphe
2200 bool GraphBase::Graph::ComputingNodes() const {
2201 bool RetVal = true ;
2202 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
2204 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2205 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2206 // GraphEditor::Port * iP;
2208 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2209 // while ( aNode != aComputingNodesList.end() ) {
2211 GraphBase::ComputingNode * aNode ;
2212 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2213 aNode = GraphNodes( i ) ;
2214 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2215 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2216 // if ((*aNode)->GetNodeInPortsSize() == 0)
2217 // _headNodes.push_front(*aNode);
2219 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2220 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2221 if ( iP->IsNotConnected() ){
2222 // cdebug << "Le port d'entree " << iP->PortName()
2223 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2224 // << Name() << " n'est pas connecte "<< endl;
2230 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2231 bool oneOutPortConnected = false;
2232 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2233 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2234 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2235 oneOutPortConnected = true ;
2239 // cdebug << "Le port de sortie " << iP->PortName()
2240 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2241 // << Name() << " n'est pas connecte "<< endl;
2245 if (!oneOutPortConnected) {
2246 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2247 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2248 // _computingError.push_front(2);
2251 // return _computingError.size () ;
2255 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2256 bool RetVal = true ;
2259 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2260 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2261 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2262 if ( aNode->IsLoopNode() ) {
2263 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2264 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2265 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2266 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2267 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2268 aLoopNode , anInPort ) ) {
2269 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
2270 // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2271 // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
2279 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2280 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
2281 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2282 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2283 aLoopNode->CoupledNode() , anInPort ) ) {
2284 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
2285 // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2286 // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
2295 else if ( aNode->IsGOTONode() ) {
2296 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2297 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2298 if ( anOutGate->IsNotConnected() ) {
2299 if ( !AddLink( aGOTONode , anOutGate ,
2300 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() ) ) {
2301 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
2302 // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2303 // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2312 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
2316 // Controle de la coherence des noeuds de calcul
2317 // Enregistrement dans la liste des noeuds "tete" de graphe
2319 bool GraphBase::Graph::DataServerNodes() const {
2321 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
2323 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2324 int i , j , ierr = 0 ;
2326 // if ( DataFlowDatas == NULL ) {
2327 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2331 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2332 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2334 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2336 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2338 ierr = CheckDataServerNodes() ;
2340 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2341 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2342 if ( GraphNodesSize() == 0 ) {
2346 GraphBase::ComputingNode * aNode ;
2347 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2348 aNode = GraphNodes( i ) ;
2349 // while ( aNode != aComputingNodesList.end() ) {
2350 if ( aNode->IsFactoryNode() ) {
2351 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2352 if ( !strlen( FaNode->Computer() ) ) {
2353 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2354 if ( !strlen( FaNode->Computer() ) ) {
2359 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2363 // For Outputs of the DataFlow :
2364 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2365 if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
2366 if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
2367 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2370 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2377 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2379 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2380 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2382 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2383 // while ( it != aDataServerNodesList.end() ) {
2384 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2385 // cerr << "Erreur dans le noeud serveur de donnees "
2386 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2387 // cerr << "A la fois importation et exportation de donnees" << endl;
2388 // _dataServerError.push_front(1);
2391 // if ((*it)->GetNodeOutPortsSize()) {
2392 // if ((*it)->GetNodeOutPortsSize()==1){
2393 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2394 // _headNodes.push_front(*it);
2397 // cerr << "Le port de sortie du noeud serveur de donnees "
2398 // << (*it)->Name() << " du graphe " << _G->Name()
2399 // << " n'est pas connecte "<< endl;
2400 // _dataServerError.push_front(4);
2404 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2405 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2406 // _dataServerError.push_front(2);
2410 // if ((*it)->GetNodeInPortsSize()) {
2411 // if ((*it)->GetNodeInPortsSize() > 1){
2412 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2413 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2414 // _dataServerError.push_front(3);
2417 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2418 // cerr << "Le port d'entree du noeud serveur de donnees "
2419 // << (*it)->Name() << " du graphe " << _G->Name()
2420 // << " n'est pas connecte "<< endl;
2421 // _dataServerError.push_front(5);
2427 // return _dataServerError.size ();
2428 return ( ierr == 0 ) ;
2431 SUPERV::GraphState GraphBase::Graph::PortState(
2432 const char* NodeName ,
2433 const char* ServiceParameterName ) {
2434 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2435 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2436 // << ServiceParameterName << " )" << endl ;
2440 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2442 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2444 GraphBase::OutPort *anOutPort ;
2445 anOutPort = aNode->GetChangeOutPort( aPort );
2446 if ( anOutPort == NULL ) {
2447 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2449 anOutPort = anInPort->GetOutPort() ;
2451 cdebug << "GraphBase::Graph::PortState OutPort/InPort not found --> "
2456 aRet = anOutPort->State() ;
2457 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2461 cdebug << "GraphBase::Graph::PortState Node not found --> " << aRet
2469 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
2470 const char* ToServiceParameterName ) {
2471 const CORBA::Any * aRet = new CORBA::Any() ;
2474 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
2475 // << ToServiceParameterName << endl ;
2476 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
2478 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2481 GraphBase::OutPort *anOutPort = NULL ;
2482 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2484 anOutPort = anInPort->GetOutPort() ;
2486 aRet = anOutPort->Value() ;
2487 // cdebug << "OutPort value " << anOutPort->NodeName() << "("
2488 // << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
2489 // << "(" << anInPort->PortName() << ")" << endl ;
2492 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2493 << ToServiceParameterName << " ERROR no OutPort" << endl ;
2497 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2498 << ToServiceParameterName << " ERROR no InPort" << endl ;
2502 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2503 << ToServiceParameterName << " ERROR no Node" << endl ;
2507 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
2511 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
2512 const char* FromServiceParameterName ) {
2513 const CORBA::Any * aRet = new CORBA::Any() ;
2516 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2517 // << FromServiceParameterName << endl ;
2518 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
2520 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2523 GraphBase::OutPort *anOutPort ;
2524 anOutPort = aNode->GetChangeOutPort( aPort );
2526 aRet = anOutPort->Value() ;
2529 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2530 << FromServiceParameterName << " ERROR no OutPort" << endl ;
2534 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2535 << FromServiceParameterName << " ERROR no Node" << endl ;
2539 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
2543 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
2544 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
2545 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
2547 RetVal->length( _NodesNumber[ aLevel ] + 1 );
2548 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
2549 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
2552 return ( RetVal._retn() ) ;
2555 bool GraphBase::Graph::StartComponent(const int aThread ,
2556 const char * aComputerContainer ,
2557 const char * ComponentName ,
2558 Engines::Container_var & myContainer ,
2559 Engines::Component_var & objComponent ) {
2560 cdebug_in << aThread
2561 << " GraphBase::Graph::StartComponent " << aComputerContainer
2562 << " " << ComponentName << endl;
2563 bool RetVal = true ;
2565 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
2566 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
2568 if ( CORBA::is_nil( objComponent ) ) {
2569 cdebug_out << aThread
2570 << " StartComponent cannot FindOrLoad " << aComputerContainer
2571 << " " << ComponentName << endl;
2575 myContainer = LCC.FindContainer( aComputerContainer );
2576 if ( CORBA::is_nil( myContainer ) ) {
2577 cdebug_out << aThread
2578 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
2579 << aComputerContainer << "' ) Container does not exist"
2584 cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl;