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 ;
40 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
41 SALOME_NamingService* ptrNamingService ,
42 const char *DataFlowName ,
43 const SUPERV::KindOfNode DataFlowkind ,
44 int * Graph_prof_debug ,
45 ofstream * Graph_fdebug ) :
46 // const char * DebugFileName ) :
47 DataNode( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
48 _Orb = CORBA::ORB::_duplicate( ORB ) ;
49 Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
50 cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ;
54 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
55 SALOME_NamingService* ptrNamingService ,
56 const SALOME_ModuleCatalog::Service& DataFlowService ,
57 const char *DataFlowComponentName ,
58 const char *DataFlowInterfaceName ,
59 const char *DataFlowName ,
60 const SUPERV::KindOfNode DataFlowkind ,
61 const SUPERV::SDate DataFlowFirstCreation ,
62 const SUPERV::SDate DataFlowLastModification ,
63 const char * DataFlowEditorRelease ,
64 const char * DataFlowAuthor ,
65 const char * DataFlowComputer ,
66 const char * DataFlowComment ,
67 int * Graph_prof_debug ,
68 ofstream * Graph_fdebug ) :
69 // const char * DebugFileName ) :
70 DataNode( ORB , ptrNamingService , DataFlowService ,
71 DataFlowName , DataFlowkind ,
72 DataFlowFirstCreation , DataFlowLastModification ,
73 DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
74 _Orb = CORBA::ORB::_duplicate( ORB ) ;
76 Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
77 cdebug_in << "GraphBase::Graph::Graph" << endl ;
78 DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ;
79 cdebug_out << "GraphBase::Graph::Graph" << endl ;
82 GraphBase::Graph::~Graph() {
83 cdebug << "GraphBase::Graph::~Graph" << endl ;
86 void GraphBase::Graph::Set_prof_debug( int * Graph_prof_debug ,
87 ofstream * Graph_fdebug ) {
88 SetDebug( _Orb , Graph_prof_debug , Graph_fdebug ) ;
89 _Graph_prof_debug = Graph_prof_debug ;
90 _Graph_fdebug = Graph_fdebug ;
93 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
94 GraphBase::SNode * Info = new GraphBase::SNode ;
95 Info->theComponentName = "" ;
96 Info->theInterfaceName = "" ;
97 Info->theName = Name() ;
98 Info->theKind = Kind() ;
99 if ( IsDataStreamNode() ) {
101 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
103 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
104 Info->theTimeout = Timeout ;
105 Info->theDataStreamTrace = DataStreamTrace ;
106 Info->theDeltaTime = DeltaTime ;
108 Info->theService = *GetService() ;
109 Info->theFirstCreation = FirstCreation() ;
110 Info->theLastModification = LastModification() ;
111 Info->theEditorRelease = EditorRelease() ;
112 Info->theAuthor = Author() ;
113 Info->theContainer = "" ;
114 Info->theComment = Comment() ;
115 Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
116 Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
120 //----------------------------------------------------------------------
121 // Function : GetNodes
122 // Purpose : get a nodes list
123 //----------------------------------------------------------------------
124 GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
125 GraphBase::ListOfSNodes * _list_nodes = new GraphBase::ListOfSNodes;
127 cdebug_in << "GraphBase::Graph::GetNodes" << endl ;
128 // All the nodes from _InNodes are taken
129 // vector< InNode *> Nodes = InNodes() ;
131 _list_nodes->resize( GraphNodesSize() );
135 GraphBase::ComputingNode * aCNode = NULL ;
136 for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
137 for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
138 aCNode = GraphNodes( ind ) ;
139 if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
140 ( igoto == 1 && aCNode->IsGOTONode() ) ) {
141 if ( aCNode->IsFactoryNode() ) {
142 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
143 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
144 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
147 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
148 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
150 (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
151 (*_list_nodes)[ind].theKind = aCNode->Kind();
152 if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
153 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
154 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
155 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
156 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
157 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
159 if ( aCNode->IsGOTONode() ) {
160 GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
161 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
162 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
163 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
164 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
166 if ( aCNode->IsLoopNode() ) {
167 GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
168 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
169 (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
170 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
171 (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
172 (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
173 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
174 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
175 (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
176 (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
178 else if ( aCNode->IsSwitchNode() ) {
179 GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
180 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
181 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
182 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
183 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
184 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
186 else if ( aCNode->IsEndLoopNode() ) {
187 GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
188 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
189 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
190 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
191 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
192 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
194 else if ( aCNode->IsEndSwitchNode() ) {
195 GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
196 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
197 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
198 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
199 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
200 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
202 else if ( aCNode->IsMacroNode() ) {
203 GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
204 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
205 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
206 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
207 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
208 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
211 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
213 // (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
214 // (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
216 (*_list_nodes)[ind].theListOfInDataStreams.resize( aCNode->DataStreamInPortsNumber() ) ;
217 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamInPortsNumber() << " DataStreamInPortsNumber" << endl ;
220 for ( iostream = 0 ; iostream < aCNode->GetNodeInPortsSize() ; iostream++ ) {
221 const GraphBase::InPort * anInPort ;
222 anInPort = aCNode->GetNodeInPort( iostream ) ;
223 if ( anInPort->IsDataStream() ) {
224 cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName()
226 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ;
227 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
228 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
229 SUPERV::KindOfSchema aKindOfSchema ;
230 SUPERV::KindOfInterpolation aKindOfInterpolation ;
231 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
232 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
233 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema = aKindOfSchema ;
234 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation = aKindOfInterpolation ;
235 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation = aKindOfExtrapolation ;
236 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
237 << anInPort->Dependency() << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation << " list_nodes "
238 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername << " "
239 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype << " "
240 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
241 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema << " "
242 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation << " "
243 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation << " " << endl ;
247 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
248 << anInPort->Kind() << " IsDataStream " << anInPort->IsDataStream() << endl ;
252 (*_list_nodes)[ind].theListOfOutDataStreams.resize( aCNode->DataStreamOutPortsNumber() ) ;
253 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamOutPortsNumber() << " DataStreamOutPortsNumber" << endl ;
255 for ( iostream = 0 ; iostream < aCNode->GetNodeOutPortsSize() ; iostream++ ) {
256 const GraphBase::OutPort * anOutPort ;
257 anOutPort = aCNode->GetNodeOutPort( iostream ) ;
258 if ( anOutPort->IsDataStream() ) {
259 cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
261 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ;
262 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
263 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
264 long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
265 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues = aNumberOfValues ;
266 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
267 << anOutPort->Dependency() << " " << aNumberOfValues << " list_nodes "
268 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername << " "
269 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype << " "
270 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
271 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues << endl ;
275 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
276 << anOutPort->Kind() << " IsDataStream " << anOutPort->IsDataStream() << endl ;
280 (*_list_nodes)[ind].theService = *aCNode->GetService();
281 cdebug << "GraphBase::Graph::GetNodes theService " << &(*_list_nodes)[ind].theService.ServiceName << endl ;
283 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinParameter.length() ; i++ ) {
284 cdebug << " In" << i << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
285 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
286 << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype
287 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype << endl ;
289 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutParameter.length() ; i++ ) {
290 cdebug << " Out" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
291 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
292 << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype
293 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype << endl ;
295 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinDataStreamParameter.length() ; i++ ) {
296 cdebug << " InDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
297 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
298 << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype
299 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype << endl ;
301 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter.length() ; i++ ) {
302 cdebug << " OutDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
303 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
304 << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype
305 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype << endl ;
307 if ( aCNode->IsOneOfInLineNodes() ) {
308 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
309 GraphBase::LoopNode * aLNode = NULL ;
310 if ( aCNode->IsLoopNode() ) {
311 aLNode = (GraphBase::LoopNode * ) aCNode ;
312 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
313 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
314 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
315 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
317 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
318 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
319 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
320 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
323 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
324 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
325 (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
326 (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
327 if ( aCNode->IsFactoryNode() ) {
328 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
329 (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
332 (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
334 (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
335 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
336 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
340 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
341 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
342 if ( anInPort->IsBus() ) {
344 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
345 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
346 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
347 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
348 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
355 cdebug_out << "GraphBase::Graph::GetNodes" << endl ;
360 //----------------------------------------------------------------------
361 // Function : GetLinks
362 // Purpose : get a links list
363 //----------------------------------------------------------------------
364 GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
365 GraphBase::ListOfSLinks * _list_links = new GraphBase::ListOfSLinks;
367 // All the links from _LinksList are taken
368 // vector< InNode *> Nodes = InNodes() ;
372 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
373 GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
375 for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
376 const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
378 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
379 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
380 if ( toPort->IsPortConnected() ) {
381 // Desole pour ce cast mais avec les maps difficile de faire const ...
382 const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
383 if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
384 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
385 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
386 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
387 << " " << fromPort->InPortsSize() << " ports" << endl ;
388 _list_links->resize( ind+1 );
389 (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
390 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
391 (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
392 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
393 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
394 if ( toPort->IsEndSwitch() ) {
395 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
398 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
403 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
404 << fromPort->PortName() << " ) " << fromPort->PortStatus()
405 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
406 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
415 GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const {
416 GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs;
421 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
422 GraphBase::InPort* toPort ) {
423 GraphBase::SLink * _link = new GraphBase::SLink ;
424 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
425 _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
426 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
427 _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
428 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
429 CORBA::Any aSPValue = *fromPort->Value() ;
430 _link->aLinkValue = aSPValue;
431 _link->aListOfCoords = *(toPort->Coords()) ;
434 //----------------------------------------------------------------------
435 // Function : GetDatas
436 // Purpose : get the datas list
437 //----------------------------------------------------------------------
438 GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
439 GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks;
442 const GraphBase::DataNode * aDataNode = this ;
444 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
445 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
446 if ( GraphMacroLevel() == 0 ) {
447 if ( fromDataPort->IsDataConnected() ) {
449 //We may have SharedData as input of a DataFlow : same input for one or several
450 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
451 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
452 _list_datalinks->resize( ind+1 );
453 (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
454 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
455 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
456 (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
457 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
458 CORBA::Any aSPValue = *fromDataPort->Value() ;
459 (*_list_datalinks)[ind].aLinkValue = aSPValue;
460 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
467 // Output(s) of a DataFlow match only one input-virtual-dataport
468 for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
469 GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
470 const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
471 if ( fromPort->IsDataConnected() ) {
472 _list_datalinks->length( ind+1 );
473 _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
474 _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
475 _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
476 _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
477 // SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
478 CORBA::Any aSPValue = *fromPort->Value() ;
479 // aSPValue.Value = CORBA::string_dup( fromPort->Value() );
480 // aSPValue.Kind = fromPort->Kind();
481 _list_datalinks[ind].aLinkValue = aSPValue;
482 _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
487 return _list_datalinks ;
490 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
491 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl;
492 bool RetVal = false ;
493 int index = GetGraphNodeIndex( aNode->Name() ) ;
495 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ;
496 _GraphNodes.resize( _GraphNodesSize+1 ) ;
497 _GraphNodes[ _GraphNodesSize ] = aNode ;
498 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
499 _GraphNodesSize += 1 ;
500 if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) {
501 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ;
504 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName()
505 << " was already in MapOfServices" << endl ;
510 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ;
511 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
512 const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ;
514 cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
517 cdebug << i << ". ERROR" << endl ;
520 aNode->GraphOfNode( this ) ;
522 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
523 << aNode->ServiceName() << endl;
527 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
528 const char* NewNodeName ) {
529 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
532 bool RetVal = false ;
534 GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
535 for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
536 cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ;
539 if ( !strcmp( OldNodeName , NewNodeName ) ) {
542 else if ( strcmp( Name() , OldNodeName ) ) {
543 int index = GetGraphNodeIndex( OldNodeName ) ;
544 int newindex = GetGraphNodeIndex( NewNodeName ) ;
545 if ( index >= 0 && index < _GraphNodesSize &&
546 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
547 _GraphNodes[ index ]->Name( NewNodeName ) ;
548 _MapOfGraphNodes.erase( OldNodeName ) ;
549 SetGraphNodeIndex( NewNodeName , index ) ;
551 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
552 // Update 'ToNode's Map from 'aNode'
553 cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize "
554 << aNode->LinkedNodesSize() << endl ;
555 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
556 GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
557 ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
559 // Update 'FomNode's Map to 'aNode'
560 // Inports 'anInPort' of 'aNode'
561 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
562 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
563 // OutPort 'anOutPort' linked to 'anInPort'
564 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
565 cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
567 cdebug << anOutPort->NodeName() ;
570 cdebug << "without link" ;
572 cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
573 if ( !anInPort->IsNotConnected() ) {
574 if ( anOutPort->IsDataConnected() ) {
575 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
578 // Node 'FromNode' of 'anOutPort'
579 GraphBase::ComputingNode * FromNode ;
580 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
581 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
586 // Rename in _MapOfLinkedFromNodes of 'FromNode'
587 cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
588 if ( anInPort->IsDataStream() ) {
589 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
592 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
595 char* OldNodePortName = new char[ strlen( OldNodeName ) +
596 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
597 char* NewNodePortName = new char[ strlen( NewNodeName ) +
598 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
599 strcpy( OldNodePortName , OldNodeName ) ;
600 // strcat( OldNodePortName , "\\" ) ;
601 strcat( OldNodePortName , "__" ) ;
602 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
603 strcpy( NewNodePortName , NewNodeName ) ;
604 // strcat( NewNodePortName , "\\" ) ;
605 strcat( NewNodePortName , "__" ) ;
606 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
607 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
608 delete [] OldNodePortName ;
609 delete [] NewNodePortName ;
614 cdebug << " not connected" << endl ;
621 cdebug << "ERROR Node not found" << endl ;
625 RetVal = Name( NewNodeName ) ;
628 cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
632 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
633 cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << LinkedNodesSize() << " LinkedNodes :"
636 bool RetVal = false ;
637 int index = GetGraphNodeIndex( aNodeName ) ;
638 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
639 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
640 cdebug << " " << i << ". " << LinkedNodes( i ) << endl ;
643 cdebug << "Graph::RemoveNode " << aNode->GetNodeInPortsSize() << " InPorts " << aNode->GetNodeOutPortsSize()
644 << " OutPorts" << endl ;
645 if ( aNode->GetNodeInPortsSize() ) {
646 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
647 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
648 cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
649 << anInPort->PortStatus() << " <-- " ;
650 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
652 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
655 if ( !anInPort->IsNotConnected() ) {
657 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
658 cdebug << " Data/Extern" << endl ;
661 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
662 // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
663 if ( !FromNode->IsOneOfGOTONodes() ) {
664 if ( anInPort->IsDataStream() ) {
665 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
668 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
671 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
676 RetVal = anOutPort->RemoveInPort( anInPort ) ;
678 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
691 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
692 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
693 cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
694 << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
695 << anOutPort->PortStatus() << " :" << endl ;
697 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
698 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
699 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
700 << anInPort->PortStatus() << endl ;
701 if ( !anInPort->IsExternConnected() ) {
702 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
703 RetVal = anInPort->RemoveOutPort() ;
705 cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
708 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
709 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
711 else if ( anOutPort->IsDataStream() ) {
712 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
715 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
718 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
721 RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
723 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
729 cdebug << "Error RetVal " << RetVal << endl ;
736 _GraphNodesSize -= 1 ;
737 for ( i = index ; i < _GraphNodesSize ; i++ ) {
738 SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
739 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
741 _GraphNodes.resize( _GraphNodesSize+1 ) ;
742 _MapOfGraphNodes.erase( aNodeName ) ;
747 cdebug << "Node not found ERROR " << index << endl ;
750 cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl;
754 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
755 const char* FromServiceParameterName ,
756 const char* ToNodeName ,
757 const char* ToServiceParameterName ) {
758 // , const CORBA::Any aValue ) {
761 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
762 << FromServiceParameterName << ") ---> " << ToNodeName << "("
763 << ToServiceParameterName << ") , aValue )" << endl;
765 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
766 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
768 GraphBase::OutPort *fromPort = NULL ;
769 GraphBase::InPort *toPort = NULL ;
772 if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
773 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
776 fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
779 cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
780 << FromNodeName << ") not found." << endl ;
784 cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
787 if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
788 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
791 toPort = toNode->GetChangeInPort( "DoLoop" ) ;
794 cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
795 << ToNodeName << ") not found." << endl ;
799 cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
802 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
805 if ( fromPort->IsGate() && toPort->IsGate() ) {
807 aValue <<= (long ) 1 ;
808 fromPort->Value( aValue ) ;
811 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
812 // fromPort->Value( aDataValue ) ;
814 // fromPort->PortStatus( DataConnected );
817 cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
821 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
822 GraphBase::OutPort *fromPort ,
823 GraphBase::ComputingNode *toNode ,
824 GraphBase::InPort *toPort ) {
828 cdebug << "ERROR AddLink fromNode not found." << endl ;
832 cdebug << "ERROR AddLink fromPort not found." << endl ;
837 cdebug << "ERROR AddLink toNode not found." << endl ;
841 cdebug << "ERROR AddLink toPort not found." << endl ;
844 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
845 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
846 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
849 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
850 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
851 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
855 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
856 << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "("
857 << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl;
858 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
859 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
860 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
861 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
865 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
866 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
867 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
868 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
872 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
873 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
874 toPort->GetOutPort()->PortName() ,
875 toNode->Name() , toPort->PortName() ) ) {
876 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
881 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
882 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
883 toPort->GetOutPort() ) {
884 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
885 fromPort->NodePortName() ) ) {
886 cdebug << "Link already exists" << endl ;
887 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
890 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
891 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
893 else if ( fromNode->IsGOTONode() ) {
894 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
895 toPort->GetOutPort()->PortName() ,
896 toNode->Name() , toPort->PortName() ) ) {
897 cdebug << "RemoveLink(AddLink) Error."
899 cdebug_out << "GraphBase::Graph::AddLink" << endl;
902 if ( fromPort->InPortsSize() ) {
903 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
904 fromPort->ChangeInPorts(0)->NodeName() ,
905 fromPort->ChangeInPorts(0)->PortName() ) ) {
906 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
907 cdebug_out << "GraphBase::Graph::AddLink" << endl;
912 else if ( !toNode->IsEndSwitchNode() ||
913 ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
914 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
915 toNode->Name() , toPort->PortName() ) ) {
916 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
917 cdebug_out << "GraphBase::Graph::AddLink" << endl;
922 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
923 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
924 fromPort->ChangeInPorts(0)->NodeName() ,
925 fromPort->ChangeInPorts(0)->PortName() ) ) {
926 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
927 cdebug_out << "GraphBase::Graph::AddLink" << endl;
931 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
932 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
933 fromPort->RemoveInPort( toPort ) ; //dbg
935 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
936 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
937 fromPort->RemoveInPort() ; // There is only one
941 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
942 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
943 if ( !fromPort->AddInPort( toPort ) ) {
944 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
946 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
949 if ( !toPort->IsDataStream() ) {
950 toPort->Kind( SUPERV::EndSwitchParameter ) ;
953 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
954 cdebug << "!fromPort->AddLink Error." << endl ;
955 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
959 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
960 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
961 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
962 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
965 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
966 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
967 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
970 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
971 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
972 cdebug << "toPort->AddLink Error." << endl ;
973 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
978 toPort->AddOutPort( fromPort ) ;
981 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
982 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
983 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
984 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
985 << fromNode->Name() << " " << fromPort->PortName()
986 << " InLineNode/LoopNode_ConnectedInPortsNumber "
987 << toNode->ConnectedInPortsNumber() << endl;
988 if ( fromNode->IsGOTONode() ) {
989 fromPort->Kind( SUPERV::GOTOParameter ) ;
991 fromPort->PortStatus( PortConnected ); // GOTO - Loop
993 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
994 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
995 << fromNode->Name() << " " << fromPort->PortName() << endl ;
996 fromPort->PortStatus( ExternConnected );
998 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
999 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
1000 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1001 fromPort->PortStatus( ExternConnected ) ;
1004 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
1005 << fromNode->Name() << " " << fromPort->PortName() << " "
1006 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
1007 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
1008 fromPort->PortStatus( PortConnected );
1009 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
1010 fromNode->AddStreamLinkedNode( toNode ) ;
1013 fromNode->AddLinkedNode( toNode ) ;
1016 if ( fromNode->IsSwitchNode() ) {
1017 if ( !fromPort->IsDataStream() ) {
1018 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1019 fromPort->Kind( SUPERV::SwitchParameter ) ;
1021 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
1022 fromPort->Kind( SUPERV::InLineParameter ) ;
1025 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1026 GraphBase::InLineNode * anEndSwitchNode ;
1027 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1028 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1029 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1030 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1031 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1032 anOutPort->IsGate() ) {
1033 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1034 anEndSwitchNode->Name() ,
1035 anInPort->PortName() ) ) {
1036 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1038 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1044 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1045 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1049 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1050 const char* FromServiceParameterName ,
1051 const char* ToNodeName ,
1052 const char* ToServiceParameterName ) {
1053 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1054 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1055 bool RetVal = false ;
1056 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1058 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1059 if ( anInPort && ( anInPort->IsPortConnected() ||
1060 anInPort->IsDataConnected() ||
1061 anInPort->IsExternConnected() ) ) {
1062 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1063 RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> :
1064 // anInPort->RemoveOutPort() ;
1065 const char * FromNodeName = anOutPort->NodeName() ;
1066 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1069 if ( anInPort->IsDataStream() ) {
1070 fromNode->RemoveStreamLinkedNode( toNode ) ;
1073 fromNode->RemoveLinkedNode( toNode ) ;
1076 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1077 anOutPort->Kind( SUPERV::InLineParameter ) ;
1082 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1086 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1087 const char* ToServiceParameterName ,
1088 char** FromNodeName ,
1089 char** FromServiceParameterName ) {
1090 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1091 // << ToServiceParameterName << ")" << endl;
1092 bool RetVal = false ;
1093 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1095 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1096 if ( anInPort && !anInPort->IsNotConnected() ) {
1097 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1098 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1099 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1103 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1104 << " " << ToServiceParameterName << " " << RetVal << endl;
1108 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1111 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1115 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1116 const char* ToServiceParameterName ,
1117 const CORBA::Any aValue ) {
1118 bool RetVal = false ;
1119 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1120 << ToServiceParameterName << " , Any " ;
1121 switch (aValue.type()->kind()) {
1122 case CORBA::tk_string:
1125 cdebug << t << " (string) " ;
1127 case CORBA::tk_double:
1130 cdebug << d << " (double) " ;
1132 case CORBA::tk_long:
1135 cdebug << l << " (long) " ;
1137 case CORBA::tk_objref:
1138 cdebug << "(object reference) " ;
1141 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1142 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1145 cdebug << " ) in Graph " << Name() << endl;
1147 GraphBase::ComputingNode *toNode ;
1148 GraphBase::InPort *toPort ;
1151 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1152 toNode = GetChangeGraphNode( aNodeName ) ;
1153 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1155 toPort = toNode->GetChangeInPort( aPortName ) ;
1156 if ( toPort && !toPort->IsDataConnected() ) {
1157 toPort->RemoveOutPort() ;
1165 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1166 cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1168 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1169 cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1172 if ( toNode && toPort ) {
1173 GraphBase::OutPort *fromDataNodePort = NULL ;
1174 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1175 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1176 fromDataNodePort->RemoveInPort( toPort ) ;
1178 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1179 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1180 << toPort->PortName() << " )" << endl ;
1181 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1184 fromDataNodePort->Value( aValue ) ;
1185 fromDataNodePort->PortStatus( DataConnected ) ;
1189 cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1194 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1198 // Used in the Executor in order to change an Input Value and ReRun
1199 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1200 const char * ToServiceParameterName ,
1201 const CORBA::Any aValue ) {
1202 bool RetVal = false ;
1203 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1204 << ToServiceParameterName << "' , Any " ;
1205 switch (aValue.type()->kind()) {
1206 case CORBA::tk_string:
1209 cdebug << t << " (string) " ;
1211 case CORBA::tk_double:
1214 cdebug << d << " (double) " ;
1216 case CORBA::tk_long:
1219 cdebug << l << " (long) " ;
1221 case CORBA::tk_objref:
1222 cdebug << "(object reference) " ;
1225 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1228 cdebug << " ) in Graph " << Name() << endl;
1230 GraphBase::ComputingNode * toNode ;
1231 GraphBase::InPort * toPort = NULL ;
1234 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1235 toNode = GetChangeGraphNode( aNodeName ) ;
1236 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1238 toPort = toNode->GetChangeInPort( aPortName ) ;
1239 if ( toPort && toPort->IsDataConnected() ) {
1240 GraphBase::OutPort * fromPort = toPort->GetOutPort();
1243 fromPort->Value( aValue ) ;
1244 fromPort->PortStatus( DataConnected ) ;
1245 toPort->State( SUPERV::ReadyState ) ;
1248 cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1252 cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1256 cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1259 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1263 // To restore InputData in CreateService
1264 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1265 const char* ToServiceParameterName ,
1266 const CORBA::Any ** aValue ) {
1267 bool RetVal = false ;
1268 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1269 << ToServiceParameterName << ", **Any " ;
1270 const CORBA::Any theValue = **aValue ;
1271 switch (theValue.type()->kind()) {
1272 case CORBA::tk_string:
1275 cdebug << t << " (string) " ;
1277 case CORBA::tk_double:
1280 cdebug << d << " (double) " ;
1282 case CORBA::tk_long:
1285 cdebug << l << " (long) " ;
1287 case CORBA::tk_objref:
1288 cdebug << "(object reference) " ;
1291 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1294 cdebug << ") of Graph " << Name() << endl;
1296 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1299 GraphBase::InPort *toPort = NULL ;
1300 GraphBase::OutPort *fromDataNodePort = NULL ;
1301 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1302 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1303 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1304 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1305 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1308 fromDataNodePort->Value( aValue ) ;
1309 fromDataNodePort->PortStatus( DataConnected ) ;
1313 cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1314 map< string , int >::iterator aMapOfGraphNodesIterator ;
1316 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1317 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1318 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1319 << aMapOfGraphNodesIterator->second << endl ;
1323 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1327 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1328 const char* FromServiceParameterName ,
1329 const CORBA::Any aValue ) {
1330 bool RetVal = true ;
1331 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1332 << FromServiceParameterName << ")" << endl;
1333 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1335 GraphBase::OutPort *anOutPort = NULL ;
1338 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1339 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1340 // RetVal = AddLink( fromNode , fromPort ,
1341 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1342 anOutPort->Value( aValue ) ;
1343 anOutPort->State( SUPERV::ReadyState ) ;
1344 anOutPort->Done( true ) ;
1345 cdebug << *anOutPort ;
1347 anOutPort->StringValue( *_fdebug ) ;
1352 cdebug << "ERROR Node not found" << endl ;
1355 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1359 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1360 return _MapOfServiceNames ; }
1362 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1363 return _MapOfServiceNames[ name ] ;
1366 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1367 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1369 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1370 << " already in MapOfServiceNames : erase" << endl ;
1371 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1373 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1374 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1378 int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
1379 GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
1380 if ( theService == NULL ) {
1383 return theService->NewInstance() ;
1386 void GraphBase::Graph::SetGraphPorts() {
1387 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1389 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1390 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1391 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1392 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ;
1393 if ( !anOutPort->IsGate() ) {
1394 anOutPort->PortStatus( ExternConnected ) ;
1397 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1398 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1399 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1400 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ;
1401 if ( !anInPort->IsGate() ) {
1402 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1403 anOutPort->PortStatus( ExternConnected ) ;
1406 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1409 bool GraphBase::Graph::CreateService() {
1410 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1411 bool RetVal = true ;
1412 SALOME_ModuleCatalog::Service aService ;
1414 GraphBase::ComputingNode * aToNode ;
1417 int instreamnbr = 0 ;
1419 int outstreamnbr = 0 ;
1420 vector< SUPERV::KindOfPort > InPortsKind ;
1421 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1422 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1423 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1424 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1425 vector< SUPERV::KindOfPort > OutPortsKind ;
1426 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1427 vector< long > OutNumberOfValues ;
1428 // if ( GraphMacroLevel() == 0 ) {
1429 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1430 if ( dostore == 1 ) {
1431 aService.ServiceName = Name() ;
1432 aService.ServiceinParameter.length( 0 ) ;
1433 aService.ServiceinParameter.length( innbr ) ;
1434 aService.ServiceoutParameter.length( 0 ) ;
1435 aService.ServiceoutParameter.length( outnbr ) ;
1436 InPortsKind.resize( innbr ) ;
1437 InDataStreamDependency.resize( innbr ) ;
1438 InKindOfSchema.resize( innbr ) ;
1439 InKindOfInterpolation.resize( innbr ) ;
1440 InKindOfExtrapolation.resize( innbr ) ;
1441 OutPortsKind.resize( outnbr ) ;
1442 OutDataStreamDependency.resize( outnbr ) ;
1443 OutNumberOfValues.resize( outnbr ) ;
1445 else if ( dostore == 2 ) {
1446 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1447 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1448 << " outstreamnbr " << outstreamnbr << endl ;
1449 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1450 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1451 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1452 InPortsKind.resize( innbr + instreamnbr ) ;
1453 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1454 InKindOfSchema.resize( innbr + instreamnbr ) ;
1455 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1456 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1457 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1458 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1459 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1461 if ( dostore == 0 ) {
1467 if ( dostore == 1 ) {
1471 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1472 aToNode = GraphNodes( i ) ;
1473 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1474 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1475 bool isfromcouplednode = false ;
1476 if ( !anInPort->IsNotConnected() ) {
1477 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1478 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1479 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1480 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1481 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1482 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1483 isfromcouplednode = true ;
1486 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1487 ( !anInPort->IsPortConnected() ||
1488 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1489 if ( dostore == 0 ) {
1490 cdebug << "CreateService " << aToNode->Name() << " Input port "
1491 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1492 if ( anInPort->GetOutPort() ) {
1493 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1496 if ( anInPort->IsDataStream() ) {
1503 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1504 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1505 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1506 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1507 InPortsKind[ innbr ] = anInPort->Kind() ;
1508 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1509 if ( dostore == 2 && anInPort->IsDataStream() ) {
1510 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1511 InKindOfInterpolation[ innbr ] ,
1512 InKindOfExtrapolation[ innbr ] ) ;
1514 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1515 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1519 else if ( dostore == 0 ) {
1520 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1521 << " " << anInPort->PortStatus() ;
1522 if ( anInPort->IsPortConnected() ) {
1523 cdebug << " is connected " ;
1526 cdebug << " is NOT connected " ;
1528 if ( anInPort->IsGate() ) {
1529 cdebug << " IsGate " ;
1531 if ( anInPort->GetOutPort() ) {
1532 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1535 cdebug << "NOT DataConnected" ;
1540 GraphBase::ComputingNode * aFromNode = aToNode ;
1541 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1542 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1543 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1544 // if ( anOutPort ) {
1545 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1548 // cdebug << " NULL" << endl ;
1550 if ( !aFromNode->IsGOTONode() ) {
1551 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
1552 anOutPort->IsExternConnected() ) {
1553 if ( dostore == 0 ) {
1554 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1555 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1556 if ( anOutPort->IsDataStream() ) {
1563 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1564 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1565 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1566 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1567 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1568 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1569 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1570 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1572 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1573 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1584 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1585 << " OutPorts " << outnbr << endl ;
1586 for ( i = 0 ; i < innbr ; i++ ) {
1587 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1588 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1589 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1590 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1591 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1594 for ( i = 0 ; i < outnbr ; i++ ) {
1595 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1596 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1597 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1598 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1599 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1604 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
1605 for ( i = 0 ; i < innbr ; i++ ) {
1606 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1607 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
1608 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
1609 InDataStreamDependency[ i ] ,
1610 SUPERV::DataStreamParameter ) ;
1611 anInPort->SetParams( InKindOfSchema[ i ] ,
1612 InKindOfInterpolation[ i ] ,
1613 InKindOfExtrapolation[ i ] ) ;
1614 // NOT A BUG : AddOutPort for an inport (Reversed service)
1615 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
1618 aService.ServiceinParameter[ i ].Parametername ,
1619 aService.ServiceinParameter[ i ].Parametertype ,
1620 SUPERV::DataStreamParameter ,
1622 _Graph_prof_debug , _Graph_fdebug ) ;
1623 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
1624 // Attention : revoir les reversed DataStreamPorts
1625 // anInPort->SetParams( InKindOfSchema[ i ] ,
1626 // InKindOfInterpolation[ i ] ,
1627 // InKindOfExtrapolation[ i ] ) ;
1628 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1629 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1633 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1634 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1635 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1636 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1637 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1638 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1642 for ( i = 0 ; i < outnbr ; i++ ) {
1643 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1644 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
1645 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
1646 OutDataStreamDependency[ i ] ,
1647 SUPERV::DataStreamParameter ) ;
1648 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1649 // NOT A BUG : AddInPort for an outport (Reversed service)
1650 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
1653 aService.ServiceoutParameter[ i ].Parametername ,
1654 aService.ServiceoutParameter[ i ].Parametertype ,
1655 SUPERV::DataStreamParameter ,
1657 _Graph_prof_debug , _Graph_fdebug ) ;
1658 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
1659 // Attention : revoir les reversed DataStreamPorts
1660 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1661 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1662 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1666 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1667 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1668 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1669 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1670 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1671 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1672 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1673 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1677 // Restore input datas and links :
1678 DataStreamInPortsNumber( 0 ) ;
1679 DataStreamOutPortsNumber( 0 ) ;
1680 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1681 aToNode = GraphNodes( i ) ;
1682 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
1683 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
1684 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1685 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1686 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
1687 if ( !AddInputData( anInPort->NodeName() ,
1688 anInPort->PortName() ,
1689 anInPort->GetOutPort()->ValuePtr() ) ) {
1690 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1691 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
1695 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1696 << anInPort->PortStatus() << " --> AddInputData" << endl ;
1699 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
1700 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
1701 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1702 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
1706 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1707 << anInPort->PortStatus() << " --> AddInLink" << endl ;
1711 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
1712 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
1713 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
1714 << ") " << anOutPort->PortStatus() << " :" << endl ;
1715 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
1716 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
1717 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
1718 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1719 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
1723 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1724 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
1730 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
1734 bool GraphBase::Graph::InLineServices() {
1735 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1740 ListPorts( *_Graph_fdebug , 0 ) ;
1743 GraphBase::InLineNode * aINode ;
1744 SALOME_ModuleCatalog::Service aService ;
1745 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1746 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1747 if ( aINode->IsOneOfInLineNodes() ) {
1748 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1749 aService.ServiceName = aINode->ServiceName() ;
1750 aService.ServiceinParameter.length( 0 ) ;
1751 aService.ServiceoutParameter.length( 0 ) ;
1752 aINode->DataStreamInPortsNumber( 0 ) ;
1753 aINode->DataStreamOutPortsNumber( 0 ) ;
1755 int InStreamService = 0 ;
1756 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1757 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1759 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1760 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1761 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1762 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1763 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1764 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1767 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
1768 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
1769 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1770 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1771 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
1772 aINode->IncrDataStreamInPorts() ;
1774 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1775 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1776 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1777 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1778 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1779 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1783 aService.ServiceinParameter.length( InService+1 ) ;
1784 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1785 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1787 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1788 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1789 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1790 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1791 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1792 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1796 int OutService = 0 ;
1797 int OutStreamService = 0 ;
1798 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1799 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1800 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1802 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1803 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1804 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1805 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1806 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1807 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1810 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1811 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
1812 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1813 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1814 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
1815 aINode->IncrDataStreamOutPorts() ;
1817 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1818 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1819 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1820 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1821 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1822 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1826 aService.ServiceoutParameter.length( OutService+1 ) ;
1827 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1828 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1830 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1831 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1832 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1833 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1834 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1835 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1839 aINode->SetService( aService ) ;
1840 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
1842 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
1843 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
1844 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
1847 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1851 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1855 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
1858 int NotSortedNumber = GraphNodesSize() ;
1860 cdebug_in << "GraphBase::Graph::Sort" << endl;
1861 if ( NotSortedNumber ) {
1863 _ParallelExecutionNodes = false ;
1864 _Sorted.resize( GraphNodesSize() ) ;
1865 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1866 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1867 if ( _NodesNumber.size() ) {
1868 _NodesNumber.resize( 0 ) ;
1869 _SortedNodes.resize( 0 ) ;
1872 // This is a simulation of the computation of the graph :
1873 // The initial state of nodes is :
1874 // - Sorted = false : the node is not sorted
1875 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
1876 // - DecrInPortsNumber = 0 : there is no value available.
1878 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
1879 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1880 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1881 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
1882 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
1883 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
1887 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1888 _Sorted[ i ] = false ;
1889 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1890 _DecrInPortsNumber[ i ] = 0 ;
1891 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
1892 // << _CnxInPortsNumber[ i ] << endl ;
1895 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
1896 // ==============================================================================
1897 while ( NotSortedNumber ) {
1900 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1901 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1902 << GraphNodes( i )->Name() << " count "
1903 << _CnxInPortsNumber[ i ] << endl ;
1904 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1905 // All inputs of GraphNodes( i ) are available : "AllDataReady"
1906 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
1907 _NodesNumber.resize( _LevelsNumber+1 ) ;
1908 _SortedNodes.resize( _LevelsNumber+1 ) ;
1909 _NodesNumber[ _LevelsNumber ] = -1 ;
1911 // There is one more node at that level
1912 _NodesNumber[ _LevelsNumber ]++ ;
1913 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1914 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1915 _Sorted[ i ] = true ;
1917 NotSortedNumber -= 1 ;
1918 cdebug << GraphNodes( i )->Name() << " belongs to level "
1919 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
1920 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
1921 // So we loop over all nodes that have a link from that node
1922 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
1923 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
1924 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1925 // OutputPorts of GraphNodes( i ) will satisfy
1926 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1927 // GraphNodes( i )->LinkedNodes( j )
1928 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1929 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1930 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1931 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
1932 cdebug << " _DecrInPortsNumber[ "
1933 << GetGraphNodeIndex( aLinkedNode->Name() )
1935 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1936 << " += " << aLinkedInPortsNumber ;
1937 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1943 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
1944 // will wait for data(s) from node(s) not executed or not executing for ever
1946 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1947 return false ; // Loop in the Graph
1949 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1950 bool ChangeCount = false ;
1951 // We update now the number of InPorts with a link that are waiting for a value
1952 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1953 if ( _DecrInPortsNumber[ i ] ) {
1954 // int prevcount = _CnxInPortsNumber[ i ] ;
1955 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
1956 _DecrInPortsNumber[ i ] = 0 ;
1957 ChangeCount = true ;
1958 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
1959 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1962 // If there is no loop and if the number of InPorts with a link that are waiting for a value
1963 // does not change, the sort is finished. But there is also NotSortedNumber ...
1964 // if ( !ChangeCount )
1966 if ( NotSortedNumber ) {
1967 _LevelsNumber += 1 ;
1971 int AllSortedNodes = 0 ;
1972 _HeadNodes = _SortedNodes[ 0 ] ;
1973 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1974 // QueueNodes was used in the past in order to know if the execution of a graph is finished
1975 // But because of loop nodes that was changed. So that part of code is a "clutter"
1976 // Now a graph has finished its execution when the number of executing threads is zero
1977 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1978 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1979 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1980 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1984 if ( i == _QueueNodesSize && _LevelsNumber ) {
1985 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1986 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1988 // Computation of the maximum number of threads == the maximum number of nodes of all levels
1989 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1990 AllSortedNodes += _NodesNumber[ i ]+1 ;
1991 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
1992 _ThreadsMax = _NodesNumber[ i ] + 1 ;
1994 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1995 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1996 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1997 _ParallelExecutionNodes = true ;
1998 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
2002 if ( _ParallelExecutionNodes ) {
2003 // cdebug << "Parallel Execution Nodes detected." << endl ;
2006 // cdebug << "No Parallel Execution Nodes detected." << endl ;
2008 if ( AllSortedNodes != GraphNodesSize() ) {
2009 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2010 return false ; // Loop in the Graph
2013 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
2014 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
2017 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
2018 // There is no substreamgraph for nodes without StreamPorts
2019 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
2020 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
2021 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
2022 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
2023 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
2024 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
2027 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2031 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2032 // the SubGraph of that nodes is unknown
2033 // There is no substreamgraph for nodes without StreamPorts
2034 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2035 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2036 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2037 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2038 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2039 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2040 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2043 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2048 // Computation of independent SubGraphs which have NO link between them
2049 cdebug << endl << "Computation of SubGraphs" << endl ;
2050 bool Graphs = true ;
2052 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2053 cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2054 << " Nodes :" << endl ;
2055 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2056 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2057 cdebug << " " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2059 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2060 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2061 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2062 // && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2063 // aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2064 int OldSub = aNode->SubGraph() ;
2065 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2066 cdebug << " " << aNode->Name() << " changed SubGraph "
2067 << aNode->LinkedNodes( k )->SubGraph() << endl ;
2069 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2071 for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2072 if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2073 GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2074 aSubNode->SubGraph( NewSub ) ;
2082 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2083 << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2087 cdebug << " LinkedNode " << aNode->LinkedNodes( k )->Name()
2088 << " initial SubGraph " << aNode->SubGraph() << endl ;
2089 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2101 cdebug << endl << "SubGraphs result : " << endl ;
2104 cdebug << endl << "One more time" << endl ;
2107 // Make a sequential renumbering of SubGraphs :
2108 _SubGraphsNumber = 0 ;
2109 int CurrGraphsNumber = 0;
2111 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2112 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2113 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2114 _SubGraphsNumber += 1 ;
2115 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2116 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2117 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2118 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2119 cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2120 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2128 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2129 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2130 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2131 if ( aNode->SubStreamGraph() < 0 ) {
2132 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2135 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2136 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2137 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2138 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2143 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2144 SubStreamGraphsNumber = 0 ;
2146 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2147 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2149 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2150 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2151 if ( aNode->SubStreamGraph() < 0 ) {
2152 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2153 // << " has NO streamport" << endl ;
2156 int CurStreamGraphsNumber ;
2157 if ( aNode->SubStreamGraph() > 0 ) {
2158 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2159 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2160 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2163 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2166 while ( RetVal != CurStreamGraphsNumber ) {
2167 RetVal = CurStreamGraphsNumber ;
2168 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2169 if ( RetVal != CurStreamGraphsNumber ) {
2170 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2171 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2172 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2173 aNode->SubStreamGraph( RetVal ) ;
2176 CurStreamGraphsNumber = RetVal ;
2179 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2180 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2186 // Make a sequential renumbering of SubGraphs :
2187 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2188 int CurrStreamGraphsNumber = 0 ;
2190 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2191 bool SearchCurrStreamGraphsNumber = true ;
2192 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2194 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2195 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2196 SearchCurrStreamGraphsNumber = false ;
2198 if ( CurrStreamGraphsNumber != count ) {
2199 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2200 // << " Level " << k << " n " << l << endl ;
2201 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2202 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2203 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2204 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2205 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2206 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2208 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2209 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2210 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2211 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2220 SubStreamGraphsNumber = count ;
2221 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2222 // int CurrStreamGraphsNumber ;
2223 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2224 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2225 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2226 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2227 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2228 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2236 ListPorts( *_Graph_fdebug , 0 ) ;
2239 cdebug_out << "GraphBase::Graph::Sort" << endl;
2243 bool GraphBase::Graph::ValidLoops() const {
2244 cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
2247 GraphBase::ComputingNode * aNode ;
2248 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2249 aNode = GraphNodes( i ) ;
2250 if ( aNode->IsLoopNode() ) {
2251 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2252 GraphBase::EndOfLoopNode * anEndLoopNode ;
2253 anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2254 if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
2255 cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
2259 else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
2260 cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
2266 cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
2270 // Controle de la coherence des noeuds de calcul
2271 // Enregistrement dans la liste des noeuds "tete" de graphe
2273 bool GraphBase::Graph::ComputingNodes() const {
2274 bool RetVal = true ;
2275 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
2277 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2278 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2279 // GraphEditor::Port * iP;
2281 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2282 // while ( aNode != aComputingNodesList.end() ) {
2284 GraphBase::ComputingNode * aNode ;
2285 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2286 aNode = GraphNodes( i ) ;
2287 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2288 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2289 // if ((*aNode)->GetNodeInPortsSize() == 0)
2290 // _headNodes.push_front(*aNode);
2292 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2293 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2294 if ( iP->IsNotConnected() ){
2295 // cdebug << "Le port d'entree " << iP->PortName()
2296 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2297 // << Name() << " n'est pas connecte "<< endl;
2303 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2304 bool oneOutPortConnected = false;
2305 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2306 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2307 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2308 oneOutPortConnected = true ;
2312 // cdebug << "Le port de sortie " << iP->PortName()
2313 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2314 // << Name() << " n'est pas connecte "<< endl;
2318 if (!oneOutPortConnected) {
2319 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2320 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2321 // _computingError.push_front(2);
2324 // return _computingError.size () ;
2328 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2329 bool RetVal = true ;
2332 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2333 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2334 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2335 if ( aNode->IsLoopNode() ) {
2336 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2337 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2338 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2339 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2340 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2341 aLoopNode , anInPort ) ) {
2342 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
2343 // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2344 // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
2352 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2353 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
2354 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2355 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2356 aLoopNode->CoupledNode() , anInPort ) ) {
2357 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
2358 // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2359 // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
2368 else if ( aNode->IsGOTONode() ) {
2369 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2370 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2371 if ( anOutGate->IsNotConnected() ) {
2372 RetVal = aGOTONode->CoupledNode() != NULL;
2374 RetVal = AddLink( aGOTONode , anOutGate ,
2375 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() );
2376 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
2377 // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2378 // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2385 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
2389 // Controle de la coherence des noeuds de calcul
2390 // Enregistrement dans la liste des noeuds "tete" de graphe
2392 bool GraphBase::Graph::DataServerNodes() const {
2394 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
2396 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2397 int i , j , ierr = 0 ;
2399 // if ( DataFlowDatas == NULL ) {
2400 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2404 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2405 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2407 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2409 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2411 ierr = CheckDataServerNodes() ;
2413 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2414 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2415 if ( GraphNodesSize() == 0 ) {
2419 GraphBase::ComputingNode * aNode ;
2420 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2421 aNode = GraphNodes( i ) ;
2422 // while ( aNode != aComputingNodesList.end() ) {
2423 if ( aNode->IsFactoryNode() ) {
2424 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2425 if ( !strlen( FaNode->Computer() ) ) {
2426 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2427 if ( !strlen( FaNode->Computer() ) ) {
2432 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2436 // For Outputs of the DataFlow :
2437 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2438 if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
2439 if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
2440 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2443 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2450 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2452 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2453 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2455 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2456 // while ( it != aDataServerNodesList.end() ) {
2457 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2458 // cerr << "Erreur dans le noeud serveur de donnees "
2459 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2460 // cerr << "A la fois importation et exportation de donnees" << endl;
2461 // _dataServerError.push_front(1);
2464 // if ((*it)->GetNodeOutPortsSize()) {
2465 // if ((*it)->GetNodeOutPortsSize()==1){
2466 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2467 // _headNodes.push_front(*it);
2470 // cerr << "Le port de sortie du noeud serveur de donnees "
2471 // << (*it)->Name() << " du graphe " << _G->Name()
2472 // << " n'est pas connecte "<< endl;
2473 // _dataServerError.push_front(4);
2477 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2478 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2479 // _dataServerError.push_front(2);
2483 // if ((*it)->GetNodeInPortsSize()) {
2484 // if ((*it)->GetNodeInPortsSize() > 1){
2485 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2486 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2487 // _dataServerError.push_front(3);
2490 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2491 // cerr << "Le port d'entree du noeud serveur de donnees "
2492 // << (*it)->Name() << " du graphe " << _G->Name()
2493 // << " n'est pas connecte "<< endl;
2494 // _dataServerError.push_front(5);
2500 // return _dataServerError.size ();
2501 return ( ierr == 0 ) ;
2504 SUPERV::GraphState GraphBase::Graph::PortState(
2505 const char* NodeName ,
2506 const char* ServiceParameterName ) {
2507 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2508 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2509 // << ServiceParameterName << " )" << endl ;
2513 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2515 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2517 GraphBase::OutPort *anOutPort ;
2518 anOutPort = aNode->GetChangeOutPort( aPort );
2519 if ( anOutPort == NULL ) {
2520 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2522 anOutPort = anInPort->GetOutPort() ;
2524 cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
2529 aRet = anOutPort->State() ;
2530 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2534 cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
2542 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
2543 const char* ToServiceParameterName ) {
2544 const CORBA::Any * aRet = new CORBA::Any() ;
2547 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
2548 // << ToServiceParameterName << endl ;
2549 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
2551 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2554 GraphBase::OutPort *anOutPort = NULL ;
2555 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2557 anOutPort = anInPort->GetOutPort() ;
2559 aRet = anOutPort->Value() ;
2560 cdebug << "OutPort value " << anOutPort->NodeName() << "("
2561 << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
2562 << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
2565 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2566 << ToServiceParameterName << " ERROR no OutPort" << endl ;
2570 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2571 << ToServiceParameterName << " ERROR no InPort" << endl ;
2575 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2576 << ToServiceParameterName << " ERROR no Node" << endl ;
2580 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
2584 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
2585 const char* FromServiceParameterName ) {
2586 const CORBA::Any * aRet = new CORBA::Any() ;
2589 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2590 // << FromServiceParameterName << endl ;
2591 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
2593 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2596 GraphBase::OutPort *anOutPort ;
2597 anOutPort = aNode->GetChangeOutPort( aPort );
2599 aRet = anOutPort->Value() ;
2602 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2603 << FromServiceParameterName << " ERROR no OutPort" << endl ;
2607 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2608 << FromServiceParameterName << " ERROR no Node" << endl ;
2612 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
2616 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
2617 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
2618 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
2620 RetVal->length( _NodesNumber[ aLevel ] + 1 );
2621 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
2622 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
2625 return ( RetVal._retn() ) ;
2628 bool GraphBase::Graph::StartComponent(const int aThread ,
2629 const char * aComputerContainer ,
2630 const char * ComponentName ,
2631 Engines::Container_var & myContainer ,
2632 Engines::Component_var & objComponent ) {
2633 cdebug_in << aThread
2634 << " GraphBase::Graph::StartComponent " << aComputerContainer
2635 << " " << ComponentName << endl;
2636 bool RetVal = true ;
2638 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
2639 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
2641 if ( CORBA::is_nil( objComponent ) ) {
2642 cdebug_out << aThread
2643 << " StartComponent cannot FindOrLoad " << aComputerContainer
2644 << " " << ComponentName << " ERROR" << endl;
2648 myContainer = LCC.FindContainer( aComputerContainer );
2649 if ( CORBA::is_nil( myContainer ) ) {
2650 cdebug_out << aThread
2651 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
2652 << aComputerContainer << "' ) Container does not exist ERROR"
2657 cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;