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 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
144 (*_list_nodes)[ind].theComponentName = string( aFNode->ComponentName());
145 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
146 (*_list_nodes)[ind].theInterfaceName = string( aFNode->InterfaceName());
149 (*_list_nodes)[ind].theComponentName = string( "" );
150 (*_list_nodes)[ind].theInterfaceName = string( "" );
152 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
153 (*_list_nodes)[ind].theName = string( aCNode->Name() );
154 (*_list_nodes)[ind].theKind = aCNode->Kind();
155 if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
156 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
157 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
158 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
159 (*_list_nodes)[ind].theListOfFuncName[0] = string( aINode->PyFuncName() ) ;
160 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
161 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
163 if ( aCNode->IsGOTONode() ) {
164 GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
165 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
166 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
167 (*_list_nodes)[ind].theListOfFuncName[0] = string( aGNode->PyFuncName() ) ;
168 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
169 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
171 if ( aCNode->IsLoopNode() ) {
172 GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
173 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
174 (*_list_nodes)[ind].theCoupledNode = string( aLNode->CoupledNode()->Name() ) ;
175 (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
176 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
177 (*_list_nodes)[ind].theListOfFuncName[0] = string( aLNode->PyFuncName() ) ;
178 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
179 (*_list_nodes)[ind].theListOfFuncName[1] = string( aLNode->PyMoreName() ) ;
180 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
181 (*_list_nodes)[ind].theListOfFuncName[2] = string( aLNode->PyNextName() ) ;
182 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
183 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
184 (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
185 (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
187 else if ( aCNode->IsSwitchNode() ) {
188 GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
189 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
190 (*_list_nodes)[ind].theCoupledNode = string( aSNode->CoupledNode()->Name() ) ;
191 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
192 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
193 (*_list_nodes)[ind].theListOfFuncName[0] = string( aSNode->PyFuncName() ) ;
194 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
195 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
197 else if ( aCNode->IsEndLoopNode() ) {
198 GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
199 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
200 (*_list_nodes)[ind].theCoupledNode = string( aELNode->CoupledNode()->Name() ) ;
201 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
202 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
203 (*_list_nodes)[ind].theListOfFuncName[0] = string( aELNode->PyFuncName() ) ;
204 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
205 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
207 else if ( aCNode->IsEndSwitchNode() ) {
208 GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
209 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
210 (*_list_nodes)[ind].theCoupledNode = string( aESNode->CoupledNode()->Name() ) ;
211 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
212 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
213 (*_list_nodes)[ind].theListOfFuncName[0] = string( aESNode->PyFuncName() ) ;
214 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
215 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
217 else if ( aCNode->IsMacroNode() ) {
218 GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
219 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
220 (*_list_nodes)[ind].theCoupledNode = string( aGraph->CoupledNode()->Name() ) ;
221 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
222 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
223 (*_list_nodes)[ind].theListOfFuncName[0] = string( aGraph->PyFuncName() ) ;
224 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
225 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
228 (*_list_nodes)[ind].theCoupledNode = string( "" ) ;
230 // (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
231 // (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
233 (*_list_nodes)[ind].theListOfInDataStreams.resize( aCNode->DataStreamInPortsNumber() ) ;
234 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamInPortsNumber() << " DataStreamInPortsNumber" << endl ;
237 for ( iostream = 0 ; iostream < aCNode->GetNodeInPortsSize() ; iostream++ ) {
238 const GraphBase::InPort * anInPort ;
239 anInPort = aCNode->GetNodeInPort( iostream ) ;
240 if ( anInPort->IsDataStream() ) {
241 cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName()
243 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ;
244 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
245 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
246 SUPERV::KindOfSchema aKindOfSchema ;
247 SUPERV::KindOfInterpolation aKindOfInterpolation ;
248 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
249 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
250 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema = aKindOfSchema ;
251 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation = aKindOfInterpolation ;
252 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation = aKindOfExtrapolation ;
253 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
254 << anInPort->Dependency() << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation << " list_nodes "
255 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername << " "
256 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype << " "
257 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
258 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema << " "
259 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation << " "
260 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation << " " << endl ;
264 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
265 << anInPort->Kind() << " IsDataStream " << anInPort->IsDataStream() << endl ;
269 (*_list_nodes)[ind].theListOfOutDataStreams.resize( aCNode->DataStreamOutPortsNumber() ) ;
270 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamOutPortsNumber() << " DataStreamOutPortsNumber" << endl ;
272 for ( iostream = 0 ; iostream < aCNode->GetNodeOutPortsSize() ; iostream++ ) {
273 const GraphBase::OutPort * anOutPort ;
274 anOutPort = aCNode->GetNodeOutPort( iostream ) ;
275 if ( anOutPort->IsDataStream() ) {
276 cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
278 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ;
279 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
280 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
281 long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
282 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues = aNumberOfValues ;
283 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
284 << anOutPort->Dependency() << " " << aNumberOfValues << " list_nodes "
285 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername << " "
286 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype << " "
287 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
288 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues << endl ;
292 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
293 << anOutPort->Kind() << " IsDataStream " << anOutPort->IsDataStream() << endl ;
297 (*_list_nodes)[ind].theService = *aCNode->GetService();
298 cdebug << "GraphBase::Graph::GetNodes theService " << &(*_list_nodes)[ind].theService.ServiceName << endl ;
300 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinParameter.length() ; i++ ) {
301 cdebug << " In" << i << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
302 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
303 << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype
304 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype << endl ;
306 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutParameter.length() ; i++ ) {
307 cdebug << " Out" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
308 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
309 << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype
310 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype << endl ;
312 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinDataStreamParameter.length() ; i++ ) {
313 cdebug << " InDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
314 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
315 << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype
316 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype << endl ;
318 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter.length() ; i++ ) {
319 cdebug << " OutDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
320 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
321 << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype
322 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype << endl ;
324 if ( aCNode->IsOneOfInLineNodes() ) {
325 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
326 GraphBase::LoopNode * aLNode = NULL ;
327 if ( aCNode->IsLoopNode() ) {
328 aLNode = (GraphBase::LoopNode * ) aCNode ;
329 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
330 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
331 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
332 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
334 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
335 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
336 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
337 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
340 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
341 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
342 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
343 (*_list_nodes)[ind].theEditorRelease = string( aCNode->EditorRelease());
344 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
345 if ( aCNode->IsFactoryNode() ) {
346 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
347 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
348 (*_list_nodes)[ind].theContainer = string( aFNode->Computer());
351 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
352 (*_list_nodes)[ind].theContainer = string( "" );
354 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
355 (*_list_nodes)[ind].theComment = string( aCNode->Comment());
356 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
357 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
361 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
362 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
363 if ( anInPort->IsBus() ) {
365 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
366 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
367 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = string( anInPort->PortType() ) ;
368 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
369 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = string( anInPort->PortName() ) ;
370 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
371 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
372 //JR 24.02.2005 Memory Leak (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
373 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = string( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
380 cdebug_out << "GraphBase::Graph::GetNodes" << endl ;
385 //----------------------------------------------------------------------
386 // Function : GetLinks
387 // Purpose : get a links list
388 //----------------------------------------------------------------------
389 GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
390 GraphBase::ListOfSLinks * _list_links = new GraphBase::ListOfSLinks;
392 // All the links from _LinksList are taken
393 // vector< InNode *> Nodes = InNodes() ;
395 cdebug_in << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
398 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
399 GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
400 // cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name() << endl ;
402 for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
403 const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
404 // cdebug << "GraphBase::Graph::GetLinks k" << k << ". :" << fromNode->Name()
405 // << " i" << i << ". : " << fromPort->PortName() << endl ;
407 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
408 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
409 // cdebug << "GraphBase::Graph::GetLinks k" << k << ". : fromNode " << fromNode << " = "
410 // << fromNode->Name() << " i" << i << ". : fromPort " << fromPort << " = "
411 // << fromPort->PortName() << " j" << j << ". : toPort " << toPort << " = "
412 // << toPort->NodeName() << "( " << toPort->PortName() << " )" << endl ;
413 if ( toPort->IsPortConnected() ) {
414 // Desole pour ce cast mais avec les maps difficile de faire const ...
415 // const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
416 // cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
417 // << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
418 // << " --> toNode " << toNode << " " << toPort->NodeName() << "( "
419 // << toPort->PortName() << " ) " << " " << fromPort->InPortsSize() << " ports"
421 if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
422 // cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
423 // << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
424 // << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
425 // << " " << fromPort->InPortsSize() << " ports" << endl ;
426 _list_links->resize( ind+1 );
427 //JR 23.02.2005 Memory Leak (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
428 (*_list_links)[ind].FromNodeName = string( fromNode->Name() );
429 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
430 //JR 23.02.2005 Memory Leak (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
431 (*_list_links)[ind].ToNodeName = string( toPort->NodeName() );
432 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
433 //JR 30.03.2005 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
434 (*_list_links)[ind].aLinkValue = fromPort->Value() ;
435 if ( toPort->IsEndSwitch() ) {
436 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
439 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
444 // cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
445 // << fromPort->PortName() << " ) " << fromPort->PortStatus()
446 // << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
447 // << " " << toPort->PortStatus() << " " << fromPort->InPortsSize()
448 // << " ports ignored" << endl ;
454 cdebug_out << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
458 GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const {
459 GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs;
464 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
465 GraphBase::InPort* toPort ) {
466 GraphBase::SLink * _link = new GraphBase::SLink ;
467 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
468 //JR 24.02.2005 Memory Leak _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
469 _link->FromNodeName = string( fromPort->NodeName() );
470 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
471 //JR 24.02.2005 Memory Leak _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
472 _link->ToNodeName = string( toPort->NodeName() );
473 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
474 //JR 30.03.2005 CORBA::Any aSPValue = *fromPort->Value() ;
475 CORBA::Any aSPValue = fromPort->Value() ;
476 _link->aLinkValue = aSPValue;
477 _link->aListOfCoords = *(toPort->Coords()) ;
480 //----------------------------------------------------------------------
481 // Function : GetDatas
482 // Purpose : get the datas list
483 //----------------------------------------------------------------------
484 GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
485 GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks;
488 const GraphBase::DataNode * aDataNode = this ;
490 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
491 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
492 if ( GraphMacroLevel() == 0 ) {
493 if ( fromDataPort->IsDataConnected() ) {
495 //We may have SharedData as input of a DataFlow : same input for one or several
496 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
497 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
498 _list_datalinks->resize( ind+1 );
499 //JR 24.02.2005 Memory Leak (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
500 (*_list_datalinks)[ind].FromNodeName = string( aDataNode->Name() );
501 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
502 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
503 //JR 24.02.2005 Memory Leak (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
504 (*_list_datalinks)[ind].ToNodeName = string( toPort->NodeName() );
505 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
506 //JR 30.03.2005 CORBA::Any aSPValue = *fromDataPort->Value() ;
507 CORBA::Any aSPValue = fromDataPort->Value() ;
508 (*_list_datalinks)[ind].aLinkValue = aSPValue;
509 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
515 return _list_datalinks ;
518 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
519 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl;
520 bool RetVal = false ;
521 int index = GetGraphNodeIndex( aNode->Name() ) ;
523 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ;
524 _GraphNodes.resize( _GraphNodesSize+1 ) ;
525 _GraphNodes[ _GraphNodesSize ] = aNode ;
526 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
527 _GraphNodesSize += 1 ;
528 if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) {
529 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ;
532 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName()
533 << " was already in MapOfServices" << endl ;
538 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ;
539 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
540 const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ;
542 cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
545 cdebug << i << ". ERROR" << endl ;
548 aNode->GraphOfNode( this ) ;
550 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
551 << aNode->ServiceName() << endl;
555 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
556 const char* NewNodeName ) {
557 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
560 bool RetVal = false ;
562 GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
563 for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
564 cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ;
567 if ( !strcmp( OldNodeName , NewNodeName ) ) {
570 else if ( strcmp( Name() , OldNodeName ) ) {
571 int index = GetGraphNodeIndex( OldNodeName ) ;
572 int newindex = GetGraphNodeIndex( NewNodeName ) ;
573 if ( index >= 0 && index < _GraphNodesSize &&
574 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
575 _GraphNodes[ index ]->Name( NewNodeName ) ;
576 _MapOfGraphNodes.erase( OldNodeName ) ;
577 SetGraphNodeIndex( NewNodeName , index ) ;
579 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
580 // Update 'ToNode's Map from 'aNode'
581 cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize : "
582 << aNode->LinkedNodesSize() << endl ;
583 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
584 GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
585 ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
587 // Rename in _MapOfLinkedNodes of 'FromNode'
588 cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedFromNodesSize : "
589 << aNode->LinkedFromNodesSize() << endl ;
590 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
591 GraphBase::StreamNode * FromNode = aNode->LinkedFromNodes( i ) ;
592 if ( FromNode->GetLinkedNodeIndex( OldNodeName ) >= 0 ) {
593 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
596 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
599 // Inports 'anInPort' of 'aNode'
600 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
601 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
602 // OutPort 'anOutPort' linked to 'anInPort'
603 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
604 cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
606 cdebug << anOutPort->NodeName() ;
609 cdebug << "without link" ;
611 cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
612 if ( !anInPort->IsNotConnected() ) {
613 if ( anOutPort->IsDataConnected() ) {
614 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
617 // Node 'FromNode' of 'anOutPort'
618 GraphBase::ComputingNode * FromNode ;
619 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
620 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
625 cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
627 //JR 26.01.2005 : a same node may be renamed severeal times. So this is done above
628 // Rename in _MapOfLinkedFromNodes of 'FromNode'
629 if ( anInPort->IsDataStream() ) {
630 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
633 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
637 char* OldNodePortName = new char[ strlen( OldNodeName ) +
638 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
639 char* NewNodePortName = new char[ strlen( NewNodeName ) +
640 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
641 strcpy( OldNodePortName , OldNodeName ) ;
642 // strcat( OldNodePortName , "\\" ) ;
643 strcat( OldNodePortName , "__" ) ;
644 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
645 strcpy( NewNodePortName , NewNodeName ) ;
646 // strcat( NewNodePortName , "\\" ) ;
647 strcat( NewNodePortName , "__" ) ;
648 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
649 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
650 delete [] OldNodePortName ;
651 delete [] NewNodePortName ;
656 cdebug << " not connected" << endl ;
662 //JR 02.02.2005 DEBUG : ReName in the CoupledNode was missing
663 if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() ||
664 aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
665 GraphBase::GOTONode * theCoupledNode = NULL ;
666 theCoupledNode = (GraphBase::GOTONode * ) ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
667 theCoupledNode->CoupledNodeName( aNode->Name() ) ;
669 else if ( aNode->IsInLineNode() ) {
670 GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
672 GraphBase::ComputingNode * aLinkedNode ;
673 aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
674 if ( aLinkedNode->IsGOTONode() ) {
675 ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( aNode->Name() ) ;
681 cdebug << "ERROR Node not found" << endl ;
685 RetVal = Name( NewNodeName ) ;
688 cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
692 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
693 cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << endl;
695 bool RetVal = false ;
696 int index = GetGraphNodeIndex( aNodeName ) ;
697 GraphBase::ComputingNode * aNode = NULL ;
699 aNode = GetChangeGraphNode( index ) ;
702 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
703 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
704 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
705 << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode()
706 << " ConnectedInPortsNumber " << aNode->ConnectedInPortsNumber() << endl ;
707 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
708 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
709 << aNode->LinkedNodes( i )->Name() << endl ;
711 if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted
712 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
713 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
714 << aNode->LinkedFromNodes( i )->Name() << endl ;
718 //JR 24.03.2005 : Debug : CoupledNode field of GOTONodes was not erased
719 if ( aNode->IsInLineNode() ) {
720 GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
722 GraphBase::ComputingNode * aLinkedNode ;
723 aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
724 if ( aLinkedNode->IsGOTONode() ) {
725 cdebug << "Graph::RemoveNode erase CoupledNode " << aLinkedNode->Name() << endl ;
726 ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNode( NULL ) ;
727 ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( "" ) ;
731 if ( !aNode->IsEndSwitchNode() ) {
732 if ( aNode->GetNodeInPortsSize() ) {
733 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
734 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
735 cdebug << "Graph::RemoveNode InPort" << i << ". " << aNodeName << "( "
736 << anInPort->PortName() << ") " << anInPort->PortStatus() << " <-- " ;
737 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
738 if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
739 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
740 << anOutPort->PortStatus() ;
743 if ( !anInPort->IsNotConnected() ) {
744 GraphBase::ComputingNode * FromNode = NULL ;
746 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
747 cdebug << " Data/Extern ignored" << endl ;
750 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
753 cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
754 << FromNode->LinkedNodesSize() << " and " << aNode->Name()
755 << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
756 // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
757 // JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode
758 // if ( !FromNode->IsOneOfGOTONodes() ) {
759 // if ( !FromNode->IsGOTONode() ) {
760 if ( !FromNode->IsGOTONode() &&
761 !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
762 if ( anInPort->IsDataStream() ) {
763 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
766 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
769 cdebug << "Graph::RemoveNode anOutPort->RemoveLinkedNode Error RetVal "
775 RetVal = anOutPort->RemoveInPort( anInPort ) ;
777 cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
792 // Special case of EndSwitchNodes : each Input port must be multi-connected.
793 // There is one link for each branch of the switch
794 // But in GraphBase::InPort there is only one field GraphBase::OutPort *
795 // At execution time there is no problem because only one branch of the switch
796 // may be executed and the Executor set the right OutPort in the field
797 // GraphBase::OutPort * of each InPort of the EndSwitchNode
798 // But here we must remove that node EndSwitch from the LinkedNodes field of
799 // terminal nodes of all branches.
800 // And also in the OutPorts of that terminal nodes of branches we must remove
801 // references to InPorts of the EndSwitchNode.
803 // Explore LinkedFromnodes of the EndSwitchNode :
804 for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) {
805 GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ;
806 cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ;
808 for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
809 GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
810 cdebug << "Graph::RemoveNode OutPort" << j << ". Remove " << anOutPort->InPortsSize()
811 << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
812 << anOutPort->PortName() << ") "
813 << anOutPort->PortStatus() << " :" << endl ;
815 for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) {
816 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
817 if ( !strcmp( anInPort->NodeName() , aNode->Name() ) ) {
818 // InPort of the EndSwitchNode
819 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
820 << anInPort->PortName() << ") "
821 << anInPort->PortStatus() << endl ;
822 anInPort->RemoveOutPort() ;
823 if ( anOutPort->IsDataStream() ) {
824 aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ;
827 // false ==> No error for aNode->LinkedFromNode()
828 RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
830 cdebug << "Graph::RemoveNode aLinkedFromNode->RemoveLinkedNode Error RetVal "
835 // the InPort of the EndSwitchNode from that OutPort was already removed by
836 // anInPort->RemoveOutPort done above :
838 RetVal = anOutPort->RemoveInPort( anInPort ) ;
840 cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
852 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
853 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
854 cdebug << "Graph::RemoveNode OutPort" << i << ". Remove " << anOutPort->InPortsSize()
855 << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
856 << anOutPort->PortName() << ") "
857 << anOutPort->PortStatus() << " :" << endl ;
859 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
860 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
861 GraphBase::ComputingNode * ToNode = NULL ;
862 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
863 << anInPort->PortName() << ") "
864 << anInPort->PortStatus() ;
865 if ( anInPort->IsExternConnected() ) {
866 cdebug << " ExternConnected ignored" << endl ;
870 ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
873 RetVal = anInPort->RemoveOutPort() ;
874 // JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
877 cdebug << "Graph::RemoveNode anOutPort->RemoveOutPort Error RetVal " << RetVal
881 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
882 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
884 else if ( anOutPort->IsDataStream() ) {
885 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
888 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
891 cdebug << "Graph::RemoveNode anOutPort->RemoveLinkedNode Error RetVal " << RetVal
895 // the InPort of the EndSwitchNode from that OutPort was already removed by
896 // anInPort->RemoveOutPort done above :
898 RetVal = anOutPort->RemoveInPort( anInPort ) ;
900 cdebug << "Graph::RemoveNode anOutPort->RemoveInPort( anInPort ) Error RetVal "
905 if ( ToNode->IsEndSwitchNode() ) {
908 for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
909 GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
910 // Not the node that we are deleting ... :
911 if ( strcmp( fromNode->Name() , aNode->Name() ) ) {
913 for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
914 GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
916 for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
917 if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
918 if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
919 // Restore an OutPort in the InPort
920 anInPort->ChangeOutPort( fromOutPort ) ;
921 cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( "
922 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
923 << ToNode->Name() << "( " << anInPort->PortName() << " )"
924 << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
943 cdebug << "Error RetVal " << RetVal << endl ;
948 if ( aNode->LinkedNodesSize() || aNode->LinkedFromNodesSize() ) {
949 cdebug << "Graph::RemoveNode ERROR LinkedNodesSize " << aNode->LinkedNodesSize()
950 << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
953 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
954 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
955 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
956 << " LinkedFromNodes " << endl ;
957 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
958 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
959 << aNode->LinkedNodes( i )->Name() << endl ;
961 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
962 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
963 << aNode->LinkedFromNodes( i )->Name() << endl ;
965 // Delete of aNode from the Graph :
966 // The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted
967 // when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode
968 if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) {
969 GraphBase::InLineNode * theCoupledNode = NULL ;
970 char * theCoupledNodeName = NULL ;
971 int CoupledIndex = -1 ;
972 if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
973 theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
974 theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
976 cdebug << "Graph::RemoveNode Node" << index << " " << _GraphNodes[ index ]->Name()
977 << " will be deleted" << endl ;
979 _GraphNodesSize -= 1 ;
980 for ( i = index ; i < _GraphNodesSize ; i++ ) {
981 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
982 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
984 _GraphNodes.resize( _GraphNodesSize+1 ) ;
985 _MapOfGraphNodes.erase( aNodeName ) ;
987 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
988 if ( theCoupledNode ) {
989 //JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before)
990 CoupledIndex = GetGraphNodeIndex( theCoupledNodeName ) ;
991 cdebug << "Graph::RemoveNode CoupledNode" << CoupledIndex << " "
992 << _GraphNodes[ CoupledIndex ]->Name() << " will be deleted" << endl ;
993 delete theCoupledNode ;
994 _GraphNodesSize -= 1 ;
995 for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
996 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
997 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
999 _GraphNodes.resize( _GraphNodesSize+1 ) ;
1000 _MapOfGraphNodes.erase( theCoupledNodeName ) ;
1006 cdebug << "Graph::RemoveNode Node not found ERROR " << index << endl ;
1010 cdebug << "Graph::RemoveNode " << _GraphNodesSize << " known nodes" << endl;
1011 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
1012 cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
1014 map< string , int >::iterator aMapOfGraphNodesIterator ;
1016 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1017 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1018 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1019 << aMapOfGraphNodesIterator->second << " - 1" << endl ;
1023 cdebug_out << "Graph::RemoveNode " << RetVal << endl;
1027 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
1028 const char* FromServiceParameterName ,
1029 const char* ToNodeName ,
1030 const char* ToServiceParameterName ) {
1031 // , const CORBA::Any aValue ) {
1034 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
1035 << FromServiceParameterName << ") ---> " << ToNodeName << "("
1036 << ToServiceParameterName << ") , aValue )" << endl;
1038 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1039 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1041 GraphBase::OutPort *fromPort = NULL ;
1042 GraphBase::InPort *toPort = NULL ;
1045 // asv : 29.12.04 : as I understand, replacement of "InitLoop" by "DoLoop" was
1046 // done by JR in order to keep old graphs and batch test scripts working after change
1047 // of special Loop's port name from "InitLoop" to "DoLoop". I suppose, it is not
1048 // needed, all old graphs and tests must be changed to use "DoLoop" name for addressing
1049 // this port.. It we don't do it, ANY port with "InitLoop" name will be replaced by "DoLoop"
1050 // and it can cause unexpected bugs in future... So I comment out the replacement code.
1051 //if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
1052 //JR 12.01.05 : Yes the test is not good ; now I test that PortName only in LoopNodes ==>
1053 // + old graphs will runs normally (it is not possible to ask CEA to edit their graphs)
1054 // + in old graphs "InitLoop" and "DoLoop" were reserved parameter names (but not controlled)
1055 // + in new graphs, I have added a control at port creation of that names : they are refused
1056 if ( !(fromNode->IsLoopNode() && strcmp( FromServiceParameterName , "InitLoop" ) == 0 ) ) {
1057 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1060 fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
1063 cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
1064 << FromNodeName << ") not found." << endl ;
1068 cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
1071 // see comment above
1072 // if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
1073 if ( !(toNode->IsLoopNode() && strcmp( ToServiceParameterName , "InitLoop" ) == 0 ) ) {
1074 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1077 toPort = toNode->GetChangeInPort( "DoLoop" ) ;
1080 cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
1081 << ToNodeName << ") not found." << endl ;
1085 cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
1088 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
1091 if ( fromPort->IsGate() && toPort->IsGate() ) {
1093 aValue <<= (long ) 1 ;
1094 fromPort->SetValue( aValue ) ;
1097 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
1098 // fromPort->Value( aDataValue ) ;
1100 // fromPort->PortStatus( DataConnected );
1103 cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
1107 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
1108 GraphBase::OutPort *fromPort ,
1109 GraphBase::ComputingNode *toNode ,
1110 GraphBase::InPort *toPort ) {
1114 cdebug << "ERROR AddLink fromNode not found." << endl ;
1118 cdebug << "ERROR AddLink fromPort not found." << endl ;
1123 cdebug << "ERROR AddLink toNode not found." << endl ;
1127 cdebug << "ERROR AddLink toPort not found." << endl ;
1130 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
1131 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
1132 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
1135 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
1136 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
1137 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
1141 cdebug_in << "Graph::AddLink( " << fromNode->Name() << "("
1142 << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind()
1143 << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
1144 << ") " << toPort->Kind() << " )" << endl;
1145 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
1146 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1147 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
1148 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
1152 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1153 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1154 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
1155 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
1159 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
1160 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1161 toPort->GetOutPort()->PortName() ,
1162 toNode->Name() , toPort->PortName() ) ) {
1163 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
1168 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
1169 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1170 toPort->GetOutPort() ) {
1171 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
1172 fromPort->NodePortName() ) ) {
1173 cdebug << "Link already exists" << endl ;
1174 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1177 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1178 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
1180 else if ( fromNode->IsGOTONode() ) {
1181 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1182 toPort->GetOutPort()->PortName() ,
1183 toNode->Name() , toPort->PortName() ) ) {
1184 cdebug << "RemoveLink(AddLink) Error."
1186 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1189 if ( fromPort->InPortsSize() ) {
1190 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1191 fromPort->ChangeInPorts(0)->NodeName() ,
1192 fromPort->ChangeInPorts(0)->PortName() ) ) {
1193 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1194 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1200 // JR 17.01.2005 : toPort is already linked : RemoveLink
1201 else if ( !toNode->IsEndSwitchNode() ) {
1202 // else if ( !toNode->IsEndSwitchNode() ||
1203 // ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
1204 //JR Debug : the fromPort was wrong !
1205 // if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1206 if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() ,
1207 toNode->Name() , toPort->PortName() ) ) {
1208 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
1209 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1214 //JR Debug 15.02.2005 : Not multiple links in that case except if toPort is the DefaultPort
1215 else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1216 cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error."
1218 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1223 //JR 24.03.2005 : No Link between OutPort of SwitchNode to InPort of EndSwitchNode except if
1224 // they have the same name for a special case :
1225 // Switch with no branch ==> Default is applied always : GraphSyrControl example
1226 else if ( fromNode->IsSwitchNode() && !fromPort->IsGate() &&
1227 toNode->IsEndSwitchNode() && !toPort->IsGate() &&
1228 strcmp( fromPort->PortName() , toPort->PortName() ) ) {
1229 cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode with different PortNames Error." << endl ;
1230 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1233 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
1234 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1235 fromPort->ChangeInPorts(0)->NodeName() ,
1236 fromPort->ChangeInPorts(0)->PortName() ) ) {
1237 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1238 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1242 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
1243 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
1244 fromPort->RemoveInPort( toPort ) ; //dbg
1246 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
1247 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
1248 fromPort->RemoveInPort() ; // There is only one
1252 // JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
1253 if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1254 fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
1255 cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
1256 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1259 //JR 11.02.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
1260 // SwitchNode(Param) may be linked to EndSwitchNode(Param)
1261 // SwitchNode(Param-UserDefault) may be linked to EndSwitchNode(Default)
1262 else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() &&
1263 !( ( fromPort->IsGate() && toPort->IsGate() ) ||
1264 ( !fromPort->IsGate() ) ) ) {
1265 // ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) {
1266 cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
1268 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1271 else if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1272 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
1273 if ( !fromPort->AddInPort( toPort ) ) {
1274 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
1276 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1279 if ( !toPort->IsDataStream() ) {
1280 toPort->Kind( SUPERV::EndSwitchParameter ) ;
1283 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
1284 cdebug << "!fromPort->AddLink Error." << endl ;
1285 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1289 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
1290 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
1291 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
1292 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1295 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
1296 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
1297 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1300 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
1301 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
1302 cdebug << "toPort->AddLink Error." << endl ;
1303 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1308 toPort->AddOutPort( fromPort ) ;
1311 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
1312 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
1313 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
1314 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
1315 << fromNode->Name() << " " << fromPort->PortName()
1316 << " InLineNode/LoopNode_ConnectedInPortsNumber "
1317 << toNode->ConnectedInPortsNumber() << endl;
1318 if ( fromNode->IsGOTONode() ) {
1319 fromPort->Kind( SUPERV::GOTOParameter ) ;
1321 fromPort->PortStatus( PortConnected ); // GOTO - Loop
1323 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
1324 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
1325 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1326 fromPort->PortStatus( ExternConnected );
1328 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
1329 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
1330 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1331 fromPort->PortStatus( ExternConnected ) ;
1334 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
1335 << fromNode->Name() << " " << fromPort->PortName() << " "
1336 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
1337 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
1338 fromPort->PortStatus( PortConnected );
1339 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
1340 fromNode->AddStreamLinkedNode( toNode ) ;
1343 fromNode->AddLinkedNode( toNode ) ;
1346 if ( fromNode->IsSwitchNode() ) {
1347 if ( !fromPort->IsDataStream() ) {
1348 //JR 08.02.2005 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1349 if ( fromPort->IsInLine() && toPort->IsGate() ) {
1350 fromPort->Kind( SUPERV::SwitchParameter ) ;
1352 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
1353 fromPort->Kind( SUPERV::InLineParameter ) ;
1356 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1357 GraphBase::InLineNode * anEndSwitchNode ;
1358 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1359 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1360 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1361 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1362 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1363 anOutPort->IsGate() ) {
1364 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1365 anEndSwitchNode->Name() ,
1366 anInPort->PortName() ) ) {
1367 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1369 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1375 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1376 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1380 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1381 const char* FromServiceParameterName ,
1382 const char* ToNodeName ,
1383 const char* ToServiceParameterName ) {
1384 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1385 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1386 bool RetVal = false ;
1387 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1389 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1390 if ( anInPort && ( anInPort->IsPortConnected() ||
1391 anInPort->IsDataConnected() ||
1392 anInPort->IsExternConnected() ) ) {
1393 // JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
1394 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1395 GraphBase::OutPort * anOutPort = NULL ;
1396 if ( toNode->IsEndSwitchNode() ) {
1397 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1398 RetVal = anOutPort->RemoveInPort( anInPort ) ;
1401 anOutPort = anInPort->GetOutPort() ;
1402 RetVal = anOutPort->RemoveInPort( anInPort ) ;
1404 // anInPort->RemoveOutPort() ; // Already done in RemoveInPort
1405 // const char * FromNodeName = anOutPort->NodeName() ;
1408 if ( anInPort->IsDataStream() ) {
1409 fromNode->RemoveStreamLinkedNode( toNode ) ;
1412 fromNode->RemoveLinkedNode( toNode ) ;
1415 //JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
1416 //Debug : change the kind only if there is no other InGate connected to the OutPort
1417 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) {
1418 if ( !toNode->IsEndSwitchNode() ) {
1419 anOutPort->Kind( SUPERV::InLineParameter ) ;
1421 else if ( !anInPort->IsGate() ) {
1422 anOutPort->Kind( SUPERV::InLineParameter ) ;
1425 // JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
1426 if ( toNode->IsEndSwitchNode() ) {
1429 for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) {
1430 GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ;
1432 for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
1433 GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
1435 for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
1436 if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
1437 if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
1438 // Restore an OutPort in the InPort
1439 anInPort->ChangeOutPort( fromOutPort ) ;
1440 cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
1441 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
1442 << toNode->Name() << "( " << anInPort->PortName() << " )"
1443 << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
1461 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1465 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1466 const char* ToServiceParameterName ,
1467 char** FromNodeName ,
1468 char** FromServiceParameterName ) {
1469 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1470 // << ToServiceParameterName << ")" << endl;
1471 bool RetVal = false ;
1472 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1474 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1475 if ( anInPort && !anInPort->IsNotConnected() ) {
1476 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1477 //JR 17.02.2005 Memory Leak *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1478 *FromNodeName = (char * ) anOutPort->NodeName() ;
1479 //JR 17.02.2005 Memory Leak *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1480 *FromServiceParameterName = (char * ) anOutPort->PortName() ;
1484 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1485 << " " << ToServiceParameterName << " " << RetVal << endl;
1489 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1492 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1496 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1497 const char* ToServiceParameterName ,
1498 const CORBA::Any aValue ) {
1499 bool RetVal = false ;
1500 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1501 << ToServiceParameterName << " , Any " ;
1502 switch (aValue.type()->kind()) {
1503 case CORBA::tk_string:
1506 cdebug << t << " (string) " ;
1508 case CORBA::tk_double:
1511 cdebug << d << " (double) " ;
1513 case CORBA::tk_long:
1516 cdebug << l << " (long) " ;
1518 case CORBA::tk_objref:
1519 cdebug << "(object reference) " ;
1522 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1523 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1526 cdebug << " ) in Graph " << Name() << endl;
1528 GraphBase::ComputingNode *toNode ;
1529 GraphBase::InPort *toPort ;
1532 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1533 toNode = GetChangeGraphNode( aNodeName ) ;
1534 cdebug << "in Graph " << Name() << " aNodeName '" << aNodeName << "' aPortName '" << aPortName
1537 toPort = toNode->GetChangeInPort( aPortName ) ;
1538 if ( toPort && !toPort->IsDataConnected() && toPort->GetOutPort() ) {
1539 toPort->RemoveOutPort() ;
1547 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1548 cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1550 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1551 cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1554 if ( toNode && toPort ) {
1555 GraphBase::OutPort *fromDataNodePort = NULL ;
1556 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1557 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1558 fromDataNodePort->RemoveInPort( toPort ) ;
1560 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1561 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1562 << toPort->PortName() << " )" << endl ;
1563 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1566 fromDataNodePort->SetValue( aValue ) ;
1567 fromDataNodePort->PortStatus( DataConnected ) ;
1571 cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1576 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1580 // Used in the Executor in order to change an Input Value and ReRun
1581 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1582 const char * ToServiceParameterName ,
1583 const CORBA::Any aValue ) {
1584 bool RetVal = false ;
1585 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1586 << ToServiceParameterName << "' , Any " ;
1587 switch (aValue.type()->kind()) {
1588 case CORBA::tk_string:
1591 cdebug << t << " (string) " ;
1593 case CORBA::tk_double:
1596 cdebug << d << " (double) " ;
1598 case CORBA::tk_long:
1601 cdebug << l << " (long) " ;
1603 case CORBA::tk_objref:
1604 cdebug << "(object reference) " ;
1607 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1610 cdebug << " ) in Graph " << Name() << endl;
1612 GraphBase::ComputingNode * toNode ;
1613 GraphBase::InPort * toPort = NULL ;
1616 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1617 toNode = GetChangeGraphNode( aNodeName ) ;
1618 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1620 toPort = toNode->GetChangeInPort( aPortName ) ;
1621 if ( toPort && toPort->IsDataConnected() ) {
1622 GraphBase::OutPort * fromPort = toPort->GetOutPort();
1625 fromPort->SetValue( aValue ) ;
1626 fromPort->PortStatus( DataConnected ) ;
1627 toPort->PortState( SUPERV::ReadyState ) ;
1630 cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1634 cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1638 cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1641 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1646 // To restore InputData in CreateService
1647 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1648 const char* ToServiceParameterName ,
1649 const CORBA::Any ** aValue ) {
1650 bool RetVal = false ;
1651 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1652 << ToServiceParameterName << ", **Any " ;
1653 const CORBA::Any theValue = **aValue ;
1654 switch (theValue.type()->kind()) {
1655 case CORBA::tk_string:
1658 cdebug << t << " (string) " ;
1660 case CORBA::tk_double:
1663 cdebug << d << " (double) " ;
1665 case CORBA::tk_long:
1668 cdebug << l << " (long) " ;
1670 case CORBA::tk_objref:
1671 cdebug << "(object reference) " ;
1674 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1677 cdebug << ") of Graph " << Name() << endl;
1679 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1682 GraphBase::InPort *toPort = NULL ;
1683 GraphBase::OutPort *fromDataNodePort = NULL ;
1684 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1685 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1686 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1687 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1688 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1691 fromDataNodePort->Value( aValue ) ;
1692 fromDataNodePort->PortStatus( DataConnected ) ;
1696 cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1697 map< string , int >::iterator aMapOfGraphNodesIterator ;
1699 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1700 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1701 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1702 << aMapOfGraphNodesIterator->second << endl ;
1706 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1711 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1712 const char* FromServiceParameterName ,
1713 const CORBA::Any aValue ) {
1714 bool RetVal = true ;
1715 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1716 << FromServiceParameterName << ")" << endl;
1717 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1719 GraphBase::OutPort *anOutPort = NULL ;
1722 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1723 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1724 // RetVal = AddLink( fromNode , fromPort ,
1725 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1726 anOutPort->SetValue( aValue ) ;
1727 anOutPort->PortState( SUPERV::ReadyState ) ;
1728 anOutPort->PortDone( true ) ;
1729 cdebug << *anOutPort ;
1731 anOutPort->StringValue( *_fdebug ) ;
1736 cdebug << "ERROR Node not found" << endl ;
1739 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1743 //JR This is used by StreamGraphs to list "CODES" and after that there is instances
1744 // for each Code (Nodes).
1745 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1746 return _MapOfServiceNames ; }
1748 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1749 return _MapOfServiceNames[ name ] ;
1752 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1753 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1755 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1756 << " already in MapOfServiceNames : erase" << endl ;
1757 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1759 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1760 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1765 //JR Debug 25.03.2005 : with multiple instances et delete of instances, it was wrong
1766 //Bug created with the developpement of StreamGraphs
1767 int GraphBase::Graph::GetNewServiceInstanceNumber( char * aServiceName ) {
1768 int InstanceNumber = _MapOfServiceInstanceNumber[ aServiceName ] + 1 ;
1769 _MapOfServiceInstanceNumber[ aServiceName ] = InstanceNumber ;
1770 return InstanceNumber ;
1773 void GraphBase::Graph::SetGraphPorts() {
1774 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1776 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1777 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1778 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1779 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
1780 if ( !anOutPort->IsGate() ) {
1781 anOutPort->PortStatus( ExternConnected ) ;
1784 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1785 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1786 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1787 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
1788 if ( !anInPort->IsGate() ) {
1789 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1790 anOutPort->PortStatus( ExternConnected ) ;
1793 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1796 bool GraphBase::Graph::CreateService() {
1797 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1798 bool RetVal = true ;
1799 SALOME_ModuleCatalog::Service aService ;
1801 GraphBase::ComputingNode * aToNode ;
1804 int instreamnbr = 0 ;
1806 int outstreamnbr = 0 ;
1807 vector< SUPERV::KindOfPort > InPortsKind ;
1808 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1809 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1810 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1811 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1812 vector< SUPERV::KindOfPort > OutPortsKind ;
1813 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1814 vector< long > OutNumberOfValues ;
1815 // if ( GraphMacroLevel() == 0 ) {
1816 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1817 if ( dostore == 1 ) {
1818 //JR 17.02.2005 Memory Leak aService.ServiceName = Name() ;
1819 aService.ServiceName = my_strdup( Name() ) ;
1820 aService.ServiceinParameter.length( 0 ) ;
1821 aService.ServiceinParameter.length( innbr ) ;
1822 aService.ServiceoutParameter.length( 0 ) ;
1823 aService.ServiceoutParameter.length( outnbr ) ;
1824 InPortsKind.resize( innbr ) ;
1825 InDataStreamDependency.resize( innbr ) ;
1826 InKindOfSchema.resize( innbr ) ;
1827 InKindOfInterpolation.resize( innbr ) ;
1828 InKindOfExtrapolation.resize( innbr ) ;
1829 OutPortsKind.resize( outnbr ) ;
1830 OutDataStreamDependency.resize( outnbr ) ;
1831 OutNumberOfValues.resize( outnbr ) ;
1833 else if ( dostore == 2 ) {
1834 //JR Creation of the Service (and of the Ports) with GraphBase::DataNode::DataService :
1835 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1836 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1837 << " outstreamnbr " << outstreamnbr << endl ;
1838 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1839 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1840 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1841 InPortsKind.resize( innbr + instreamnbr ) ;
1842 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1843 InKindOfSchema.resize( innbr + instreamnbr ) ;
1844 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1845 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1846 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1847 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1848 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1850 if ( dostore == 0 ) {
1856 if ( dostore == 1 ) {
1860 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1861 aToNode = GraphNodes( i ) ;
1862 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1863 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1864 bool isfromcouplednode = false ;
1865 if ( !anInPort->IsNotConnected() ) {
1866 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1867 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1868 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1869 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1870 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1871 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1872 isfromcouplednode = true ;
1875 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1876 ( !anInPort->IsPortConnected() ||
1877 // ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1878 //JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph
1879 ( anInPort->IsPortConnected() && isfromcouplednode ) ) &&
1880 !aToNode->IsEndLoopNode() ) {
1881 if ( dostore == 0 ) {
1882 cdebug << "CreateService " << aToNode->Name() << " Input port "
1883 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1884 if ( anInPort->GetOutPort() ) {
1885 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1888 if ( anInPort->IsDataStream() ) {
1895 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1896 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1897 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1898 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1899 InPortsKind[ innbr ] = anInPort->Kind() ;
1900 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1901 if ( dostore == 2 && anInPort->IsDataStream() ) {
1902 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1903 InKindOfInterpolation[ innbr ] ,
1904 InKindOfExtrapolation[ innbr ] ) ;
1906 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1907 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1911 else if ( dostore == 0 ) {
1912 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1913 << " " << anInPort->PortStatus() ;
1914 if ( anInPort->IsPortConnected() ) {
1915 cdebug << " is connected " ;
1918 cdebug << " is NOT connected " ;
1920 if ( anInPort->IsGate() ) {
1921 cdebug << " IsGate " ;
1923 if ( anInPort->GetOutPort() ) {
1924 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1927 cdebug << "NOT DataConnected" ;
1932 GraphBase::ComputingNode * aFromNode = aToNode ;
1933 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1934 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1935 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1936 // if ( anOutPort ) {
1937 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1940 // cdebug << " NULL" << endl ;
1942 if ( !aFromNode->IsGOTONode() ) {
1943 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ||
1944 //JR PAL8914 : OutPorts of LoopNodes may not be in the Service of the Graph
1945 // anOutPort->IsExternConnected() ) {
1946 anOutPort->IsExternConnected() ) &&
1947 !aFromNode->IsLoopNode() ) {
1948 if ( dostore == 0 ) {
1949 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1950 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1951 if ( anOutPort->IsDataStream() ) {
1958 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1959 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1960 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1961 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1962 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1963 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1964 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1965 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1967 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1968 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1979 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1980 << " OutPorts " << outnbr << endl ;
1981 for ( i = 0 ; i < innbr ; i++ ) {
1982 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1983 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1984 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1985 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1986 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1989 for ( i = 0 ; i < outnbr ; i++ ) {
1990 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1991 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1992 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1993 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1994 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1999 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
2000 for ( i = 0 ; i < innbr ; i++ ) {
2001 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
2002 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
2003 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
2004 InDataStreamDependency[ i ] ,
2005 SUPERV::DataStreamParameter ) ;
2006 anInPort->SetParams( InKindOfSchema[ i ] ,
2007 InKindOfInterpolation[ i ] ,
2008 InKindOfExtrapolation[ i ] ) ;
2009 // NOT A BUG : AddOutPort for an inport (Reversed service)
2010 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
2013 aService.ServiceinParameter[ i ].Parametername ,
2014 aService.ServiceinParameter[ i ].Parametertype ,
2015 SUPERV::DataStreamParameter ,
2017 _Graph_prof_debug , _Graph_fdebug ) ;
2018 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
2019 // Attention : revoir les reversed DataStreamPorts
2020 // anInPort->SetParams( InKindOfSchema[ i ] ,
2021 // InKindOfInterpolation[ i ] ,
2022 // InKindOfExtrapolation[ i ] ) ;
2023 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
2024 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
2028 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
2029 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
2030 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
2031 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
2032 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " "
2033 << GetChangeNodeInPort( i )->Kind() << " " << GetChangeNodeInPort( i )->PortStatus()
2035 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " "
2036 << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() << " "
2037 << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortStatus()
2041 for ( i = 0 ; i < outnbr ; i++ ) {
2042 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
2043 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
2044 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
2045 OutDataStreamDependency[ i ] ,
2046 SUPERV::DataStreamParameter ) ;
2047 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
2048 // NOT A BUG : AddInPort for an outport (Reversed service)
2049 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
2052 aService.ServiceoutParameter[ i ].Parametername ,
2053 aService.ServiceoutParameter[ i ].Parametertype ,
2054 SUPERV::DataStreamParameter ,
2056 _Graph_prof_debug , _Graph_fdebug ) ;
2057 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
2058 // Attention : revoir les reversed DataStreamPorts
2059 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
2060 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
2061 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
2065 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
2066 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
2067 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2068 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2069 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2070 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2071 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " "
2072 << GetChangeNodeOutPort( i )->Kind() << " " << GetChangeNodeOutPort( i )->PortStatus()
2074 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName()
2075 << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
2076 << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortStatus()
2080 // Restore input datas and links :
2081 DataStreamInPortsNumber( 0 ) ;
2082 DataStreamOutPortsNumber( 0 ) ;
2083 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2084 aToNode = GraphNodes( i ) ;
2085 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
2086 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
2087 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
2088 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
2089 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
2090 if ( !AddInputData( anInPort->NodeName() ,
2091 anInPort->PortName() ,
2092 //JR 21.02.2005 Debug Memory leak : anInPort->GetOutPort()->ValuePtr() ) ) {
2093 //JR 30.03.2005 *anInPort->GetOutPort()->Value() ) ) {
2094 anInPort->GetOutPort()->Value() ) ) {
2095 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2096 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
2100 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2101 << anInPort->PortStatus() << " --> AddInputData" << endl ;
2104 //JR PAL8914 : InPorts of EndLoopNodes may not be in the Service of the Graph
2105 // else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2106 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() && !aToNode->IsEndLoopNode() ) {
2107 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
2108 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2109 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
2113 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2114 << anInPort->PortStatus() << " --> AddInLink" << endl ;
2118 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
2119 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
2120 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
2121 << ") " << anOutPort->PortStatus() << " :" << endl ;
2122 //JR PAL8914 : OutPorts of LoopNodes may not be in the Service of the Graph
2123 // if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
2124 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() &&
2125 !aToNode->IsLoopNode() ) {
2126 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
2127 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
2128 cdebug << " --> " << Name() << "(" << anInPort->PortName()
2129 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
2133 cdebug << " --> " << Name() << "(" << anInPort->PortName()
2134 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
2141 ListPorts( *_Graph_fdebug , 0 ) ;
2144 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
2148 bool GraphBase::Graph::InLineServices() {
2149 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
2154 ListPorts( *_Graph_fdebug , 0 ) ;
2157 GraphBase::InLineNode * aINode ;
2158 SALOME_ModuleCatalog::Service aService ;
2159 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2160 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
2161 if ( aINode->IsOneOfInLineNodes() ) {
2162 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
2163 aService.ServiceName = aINode->ServiceName() ;
2164 aService.ServiceinParameter.length( 0 ) ;
2165 aService.ServiceoutParameter.length( 0 ) ;
2166 aINode->DataStreamInPortsNumber( 0 ) ;
2167 aINode->DataStreamOutPortsNumber( 0 ) ;
2169 int InStreamService = 0 ;
2170 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
2171 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
2173 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2174 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2175 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2176 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
2177 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2178 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2181 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
2182 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
2183 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2184 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2185 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
2186 aINode->IncrDataStreamInPorts() ;
2188 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2189 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2190 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2191 << aINode->GetChangeNodeInPort(j)->PortName() << " "
2192 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2193 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2197 aService.ServiceinParameter.length( InService+1 ) ;
2198 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2199 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2201 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2202 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2203 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2204 << aINode->GetChangeNodeInPort(j)->PortName() << " "
2205 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2206 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2210 int OutService = 0 ;
2211 int OutStreamService = 0 ;
2212 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
2213 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2214 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
2216 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2217 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2218 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2219 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
2220 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2221 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2224 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2225 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
2226 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2227 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2228 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
2229 aINode->IncrDataStreamOutPorts() ;
2231 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2232 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2233 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2234 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2235 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2236 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2240 aService.ServiceoutParameter.length( OutService+1 ) ;
2241 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2242 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2244 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2245 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2246 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2247 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2248 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2249 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2253 aINode->SetService( aService ) ;
2254 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
2256 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
2257 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
2258 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
2261 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
2265 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
2269 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
2271 ListPorts( *_Graph_fdebug , 0 ) ;
2276 int NotSortedNumber = GraphNodesSize() ;
2278 cdebug_in << "GraphBase::Graph::Sort" << endl;
2279 if ( NotSortedNumber ) {
2281 _ParallelExecutionNodes = false ;
2282 _Sorted.resize( GraphNodesSize() ) ;
2283 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
2284 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
2285 if ( _NodesNumber.size() ) {
2286 _NodesNumber.resize( 0 ) ;
2287 _SortedNodes.resize( 0 ) ;
2290 // This is a simulation of the computation of the graph :
2291 // The initial state of nodes is :
2292 // - Sorted = false : the node is not sorted
2293 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
2294 // - DecrInPortsNumber = 0 : there is no value available.
2296 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
2297 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2298 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2299 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
2300 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
2301 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
2305 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2306 _Sorted[ i ] = false ;
2307 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
2308 _DecrInPortsNumber[ i ] = 0 ;
2309 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
2310 // << _CnxInPortsNumber[ i ] << endl ;
2313 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
2314 // ==============================================================================
2315 while ( NotSortedNumber ) {
2318 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2319 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
2320 << GraphNodes( i )->Name() << " count "
2321 << _CnxInPortsNumber[ i ] << endl ;
2322 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
2323 // All inputs of GraphNodes( i ) are available : "AllDataReady"
2324 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
2325 _NodesNumber.resize( _LevelsNumber+1 ) ;
2326 _SortedNodes.resize( _LevelsNumber+1 ) ;
2327 _NodesNumber[ _LevelsNumber ] = -1 ;
2329 // There is one more node at that level
2330 _NodesNumber[ _LevelsNumber ]++ ;
2331 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
2332 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
2333 _Sorted[ i ] = true ;
2335 NotSortedNumber -= 1 ;
2336 cdebug << GraphNodes( i )->Name() << " belongs to level "
2337 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
2338 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
2339 // So we loop over all nodes that have a link from that node
2340 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
2341 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
2342 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
2343 // OutputPorts of GraphNodes( i ) will satisfy
2344 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
2345 // GraphNodes( i )->LinkedNodes( j )
2346 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
2347 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
2348 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
2349 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
2350 cdebug << " _DecrInPortsNumber[ "
2351 << GetGraphNodeIndex( aLinkedNode->Name() )
2353 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
2354 << " += " << aLinkedInPortsNumber ;
2355 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
2361 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
2362 // will wait for data(s) from node(s) not executed or not executing for ever
2364 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2365 return false ; // Loop in the Graph
2367 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
2368 bool ChangeCount = false ;
2369 // We update now the number of InPorts with a link that are waiting for a value
2370 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2371 if ( _DecrInPortsNumber[ i ] ) {
2372 // int prevcount = _CnxInPortsNumber[ i ] ;
2373 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
2374 _DecrInPortsNumber[ i ] = 0 ;
2375 ChangeCount = true ;
2376 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
2377 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
2380 // If there is no loop and if the number of InPorts with a link that are waiting for a value
2381 // does not change, the sort is finished. But there is also NotSortedNumber ...
2382 // if ( !ChangeCount )
2384 if ( NotSortedNumber ) {
2385 _LevelsNumber += 1 ;
2389 int AllSortedNodes = 0 ;
2390 _HeadNodes = _SortedNodes[ 0 ] ;
2391 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
2392 // QueueNodes was used in the past in order to know if the execution of a graph is finished
2393 // But because of loop nodes that was changed. So that part of code is a "clutter"
2394 // Now a graph has finished its execution when the number of executing threads is zero
2395 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
2396 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
2397 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
2398 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
2402 if ( i == _QueueNodesSize && _LevelsNumber ) {
2403 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
2404 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
2406 // Computation of the maximum number of threads == the maximum number of nodes of all levels
2407 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2408 AllSortedNodes += _NodesNumber[ i ]+1 ;
2409 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
2410 _ThreadsMax = _NodesNumber[ i ] + 1 ;
2412 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
2413 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
2414 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
2415 _ParallelExecutionNodes = true ;
2416 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
2420 if ( _ParallelExecutionNodes ) {
2421 // cdebug << "Parallel Execution Nodes detected." << endl ;
2424 // cdebug << "No Parallel Execution Nodes detected." << endl ;
2426 if ( AllSortedNodes != GraphNodesSize() ) {
2427 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2428 return false ; // Loop in the Graph
2431 cdebug << "Graph::Sort " << _NodesNumber[ 0 ] << " HeadNodes :" << endl ;
2432 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
2433 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
2434 cdebug << " " << i << ". : " << (_SortedNodes[ 0 ])[ i ]->Name() << endl ;
2437 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
2438 // There is no substreamgraph for nodes without StreamPorts
2439 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
2440 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
2441 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
2442 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
2443 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
2444 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
2447 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2451 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2452 // the SubGraph of that nodes is unknown
2453 // There is no substreamgraph for nodes without StreamPorts
2454 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2455 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2456 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2457 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2458 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2459 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2460 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2463 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2468 // Computation of independent SubGraphs which have NO link between them
2469 cdebug << endl << "Computation of SubGraphs" << endl ;
2470 bool Graphs = true ;
2472 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2473 cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2474 << " Nodes :" << endl ;
2475 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2476 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2477 cdebug << " " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2479 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2480 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2481 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2482 // && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2483 // aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2484 int OldSub = aNode->SubGraph() ;
2485 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2486 cdebug << " " << aNode->Name() << " changed SubGraph "
2487 << aNode->LinkedNodes( k )->SubGraph() << endl ;
2489 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2491 for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2492 if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2493 GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2494 aSubNode->SubGraph( NewSub ) ;
2502 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2503 << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2507 cdebug << " LinkedNode " << aNode->LinkedNodes( k )->Name()
2508 << " initial SubGraph " << aNode->SubGraph() << endl ;
2509 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2521 cdebug << endl << "SubGraphs result : " << endl ;
2524 cdebug << endl << "One more time" << endl ;
2527 // Make a sequential renumbering of SubGraphs :
2528 _SubGraphsNumber = 0 ;
2529 int CurrGraphsNumber = 0;
2531 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2532 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2533 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2534 _SubGraphsNumber += 1 ;
2535 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2536 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2537 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2538 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2539 cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2540 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2548 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2549 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2550 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2551 if ( aNode->SubStreamGraph() < 0 ) {
2552 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2555 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2556 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2557 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2558 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2563 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2564 SubStreamGraphsNumber = 0 ;
2566 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2567 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2569 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2570 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2571 if ( aNode->SubStreamGraph() < 0 ) {
2572 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2573 // << " has NO streamport" << endl ;
2576 int CurStreamGraphsNumber ;
2577 if ( aNode->SubStreamGraph() > 0 ) {
2578 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2579 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2580 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2583 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2586 while ( RetVal != CurStreamGraphsNumber ) {
2587 RetVal = CurStreamGraphsNumber ;
2588 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2589 if ( RetVal != CurStreamGraphsNumber ) {
2590 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2591 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2592 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2593 aNode->SubStreamGraph( RetVal ) ;
2596 CurStreamGraphsNumber = RetVal ;
2599 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2600 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2606 // Make a sequential renumbering of SubGraphs :
2607 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2608 int CurrStreamGraphsNumber = 0 ;
2610 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2611 bool SearchCurrStreamGraphsNumber = true ;
2612 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2614 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2615 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2616 SearchCurrStreamGraphsNumber = false ;
2618 if ( CurrStreamGraphsNumber != count ) {
2619 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2620 // << " Level " << k << " n " << l << endl ;
2621 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2622 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2623 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2624 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2625 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2626 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2628 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2629 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2630 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2631 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2640 SubStreamGraphsNumber = count ;
2641 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2642 // int CurrStreamGraphsNumber ;
2643 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2644 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2645 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2646 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2647 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2648 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2656 ListPorts( *_Graph_fdebug , 0 ) ;
2659 cdebug_out << "GraphBase::Graph::Sort" << endl;
2663 bool GraphBase::Graph::ValidLoops() const {
2664 cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
2667 GraphBase::ComputingNode * aNode ;
2668 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2669 aNode = GraphNodes( i ) ;
2670 if ( aNode->IsLoopNode() ) {
2671 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2672 GraphBase::EndOfLoopNode * anEndLoopNode ;
2673 anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2674 if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
2675 cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
2679 else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
2680 cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
2686 cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
2690 bool GraphBase::Graph::ValidSwitchs() const {
2691 cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl;
2694 GraphBase::ComputingNode * aNode ;
2695 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2696 aNode = GraphNodes( i ) ;
2697 if ( aNode->IsSwitchNode() ) {
2698 GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ;
2699 if ( !aSwitchNode->CheckSwitch() ) {
2700 cdebug_out << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name()
2706 cdebug_out << "GraphBase::Graph::ValidSwitchs true" << endl;
2710 // Controle de la coherence des noeuds de calcul
2711 // Enregistrement dans la liste des noeuds "tete" de graphe
2713 bool GraphBase::Graph::ComputingNodes() const {
2714 bool RetVal = true ;
2715 cdebug << "GraphExecutor::Graph::ComputingNodes ()" << endl;
2717 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2718 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2719 // GraphEditor::Port * iP;
2721 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2722 // while ( aNode != aComputingNodesList.end() ) {
2724 GraphBase::ComputingNode * aNode ;
2725 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2726 aNode = GraphNodes( i ) ;
2727 cdebug << "Graph::ComputingNodes " << i << ". " << aNode->Name() << " Head " << aNode->IsHeadNode()
2729 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2730 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2731 // if ((*aNode)->GetNodeInPortsSize() == 0)
2732 // _headNodes.push_front(*aNode);
2734 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2735 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2736 if ( iP->IsNotConnected() ){
2737 // cdebug << "Le port d'entree " << iP->PortName()
2738 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2739 // << Name() << " n'est pas connecte "<< endl;
2745 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2746 bool oneOutPortConnected = false;
2747 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2748 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2749 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2750 oneOutPortConnected = true ;
2754 // cdebug << "Le port de sortie " << iP->PortName()
2755 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2756 // << Name() << " n'est pas connecte "<< endl;
2760 if (!oneOutPortConnected) {
2761 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2762 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2763 // _computingError.push_front(2);
2766 // return _computingError.size () ;
2770 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2771 bool RetVal = true ;
2774 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2775 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2776 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2777 if ( aNode->IsLoopNode() ) {
2778 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2779 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2780 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2781 cdebug << "Graph::LinkLoopNodes " << aLoopNode->Name() << "( " << anInPort->PortName()
2782 << " ) InPort " << anInPort->PortStatus() << endl ;
2783 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2784 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2785 aLoopNode , anInPort ) ) {
2786 cdebug << "Graph::LinkLoopNodes AddLink ERROR "
2787 << aLoopNode->CoupledNode()->Name()
2788 << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName()
2789 << " ) --> " << aLoopNode->Name() << "( " << anInPort->PortName() << " )"
2798 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2799 GraphBase::EndOfLoopNode * anEndLoopNode ;
2800 anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2801 GraphBase::InPort *anInPort = anEndLoopNode->GetChangeNodeInPort( j ) ;
2802 cdebug << "Graph::LinkLoopNodes " << anEndLoopNode->Name() << "( " << anInPort->PortName()
2803 << " ) InPort " << anInPort->PortStatus() << endl ;
2804 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2805 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2806 anEndLoopNode , anInPort ) ) {
2807 cdebug << "Graph::LinkLoopNodes AddLink ERROR " << aLoopNode->Name() << "( "
2808 << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2809 << anEndLoopNode->Name() << "( " << anInPort->PortName() << " )"
2819 else if ( aNode->IsGOTONode() ) {
2820 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2821 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2822 if ( anOutGate->IsNotConnected() ) {
2823 if ( aGOTONode->CoupledNode() ) {
2824 cdebug << "Graph::LinkLoopNodes aNode " << aNode << " : " << aNode->Name()
2825 << aGOTONode->CoupledNode() << " : " << aGOTONode->CoupledNode()->Name()
2827 RetVal = AddLink( aGOTONode , anOutGate , aGOTONode->CoupledNode() ,
2828 aGOTONode->CoupledNode()->GetChangeNodeInGate() );
2829 cdebug << "GraphBase::Graph::LinkLoopNodes AddLink ERROR " << aGOTONode->Name() << "( "
2830 << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2831 << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2838 cdebug_out << "GraphBase::Graph::LinkLoopNodes() NewLink " << NewLink << " returns " << RetVal
2843 // Controle de la coherence des noeuds de calcul
2844 // Enregistrement dans la liste des noeuds "tete" de graphe
2846 bool GraphBase::Graph::DataServerNodes() const {
2848 cdebug_in << "GraphBase::Graph::DataServerNodes ()" << endl;
2850 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2851 int i , j , ierr = 0 ;
2853 // if ( DataFlowDatas == NULL ) {
2854 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2858 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2859 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2861 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2863 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2865 ierr = CheckDataServerNodes() ;
2867 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2868 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2869 if ( GraphNodesSize() == 0 ) {
2873 GraphBase::ComputingNode * aNode ;
2874 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2875 aNode = GraphNodes( i ) ;
2876 // while ( aNode != aComputingNodesList.end() ) {
2877 if ( aNode->IsFactoryNode() ) {
2878 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2879 if ( !strlen( FaNode->Computer() ) ) {
2880 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2881 if ( !strlen( FaNode->Computer() ) ) {
2886 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2890 // For Outputs of the DataFlow :
2891 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2892 const GraphBase::OutPort * anOutPort = aNode->GetNodeOutPort(j) ;
2893 //JR Debug 06.06.2005 : if it is not a Gate !
2894 // if ( anOutPort->IsNotConnected() ) {
2895 if ( anOutPort->IsNotConnected() && !anOutPort->IsGate() ) {
2896 cdebug << "Graph::DataServerNodes Add[Stream]LinkedNode for OutPort "
2897 << aNode->Name() << "( " << anOutPort->PortName() << " , "
2898 << anOutPort->PortStatus() << " )" << endl ;
2899 if ( anOutPort->IsDataStream() ) {
2900 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2903 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2910 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2912 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2913 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2915 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2916 // while ( it != aDataServerNodesList.end() ) {
2917 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2918 // cerr << "Erreur dans le noeud serveur de donnees "
2919 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2920 // cerr << "A la fois importation et exportation de donnees" << endl;
2921 // _dataServerError.push_front(1);
2924 // if ((*it)->GetNodeOutPortsSize()) {
2925 // if ((*it)->GetNodeOutPortsSize()==1){
2926 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2927 // _headNodes.push_front(*it);
2930 // cerr << "Le port de sortie du noeud serveur de donnees "
2931 // << (*it)->Name() << " du graphe " << _G->Name()
2932 // << " n'est pas connecte "<< endl;
2933 // _dataServerError.push_front(4);
2937 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2938 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2939 // _dataServerError.push_front(2);
2943 // if ((*it)->GetNodeInPortsSize()) {
2944 // if ((*it)->GetNodeInPortsSize() > 1){
2945 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2946 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2947 // _dataServerError.push_front(3);
2950 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2951 // cerr << "Le port d'entree du noeud serveur de donnees "
2952 // << (*it)->Name() << " du graphe " << _G->Name()
2953 // << " n'est pas connecte "<< endl;
2954 // _dataServerError.push_front(5);
2960 // return _dataServerError.size ();
2961 cdebug_out << "GraphBase::Graph::DataServerNodes ierr " << ierr << endl;
2962 return ( ierr == 0 ) ;
2965 SUPERV::GraphState GraphBase::Graph::PortState(
2966 const char* NodeName ,
2967 const char* ServiceParameterName ) {
2968 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2969 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2970 // << ServiceParameterName << " )" << endl ;
2974 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2976 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2978 GraphBase::OutPort *anOutPort ;
2979 anOutPort = aNode->GetChangeOutPort( aPort );
2980 if ( anOutPort == NULL ) {
2981 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2983 anOutPort = anInPort->GetOutPort() ;
2985 cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
2990 aRet = anOutPort->PortState() ;
2991 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2995 cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
3003 #define TracePortInOutData 0
3004 //JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
3005 const CORBA::Any GraphBase::Graph::PortInData( const char* ToNodeName ,
3006 const char* ToServiceParameterName ) {
3007 //JR 30.03.2005 const CORBA::Any * aRet = new CORBA::Any() ;
3008 CORBA::Any aRet = CORBA::Any() ;
3011 #if TracePortInOutData
3012 cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
3013 << ToServiceParameterName << endl ;
3015 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
3017 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
3020 GraphBase::OutPort *anOutPort = NULL ;
3021 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
3023 anOutPort = anInPort->GetOutPort() ;
3025 #if TracePortInOutData
3026 cdebug << "-->PortInData " << ToNodeName << " " << ToServiceParameterName << " "
3029 aRet = anOutPort->Value() ;
3030 #if TracePortInOutData
3031 cdebug << "<--PortInData " << ToNodeName << " " << ToServiceParameterName << " " ;
3032 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3034 cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
3035 << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
3036 << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
3040 cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
3041 << ToServiceParameterName << " ERROR no OutPort" << endl ;
3045 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
3046 << ToServiceParameterName << " ERROR no InPort" << endl ;
3050 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
3051 << ToServiceParameterName << " ERROR no Node" << endl ;
3055 #if TracePortInOutData
3056 cdebug_out << "GraphBase::Graph::PortInData " << endl ;
3061 //JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
3062 const CORBA::Any GraphBase::Graph::PortOutData( const char* FromNodeName ,
3063 const char* FromServiceParameterName ) {
3064 //JR 30.03.2005 const CORBA::Any * aRet = new CORBA::Any() ;
3065 CORBA::Any aRet = CORBA::Any() ;
3068 #if TracePortInOutData
3069 cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3070 << FromServiceParameterName << endl ;
3072 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
3074 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
3077 GraphBase::OutPort *anOutPort ;
3078 anOutPort = aNode->GetChangeOutPort( aPort );
3080 #if TracePortInOutData
3081 cdebug << "-->PortOutData " << FromNodeName << " " << FromServiceParameterName << " "
3084 aRet = anOutPort->Value() ;
3085 #if TracePortInOutData
3086 cdebug << "<--PortOutData " << FromNodeName << " " << FromServiceParameterName << " " ;
3087 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3092 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3093 << FromServiceParameterName << " ERROR no OutPort" << endl ;
3097 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3098 << FromServiceParameterName << " ERROR no Node" << endl ;
3102 #if TracePortInOutData
3103 cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
3108 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
3109 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
3110 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
3112 RetVal->length( _NodesNumber[ aLevel ] + 1 );
3113 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
3114 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
3117 return ( RetVal._retn() ) ;
3120 bool GraphBase::Graph::StartComponent(const int aThread ,
3121 const char * aComputerContainer ,
3122 const char * ComponentName ,
3123 Engines::Container_var & myContainer ,
3124 Engines::Component_var & objComponent ) {
3125 cdebug_in << aThread
3126 << " GraphBase::Graph::StartComponent " << aComputerContainer
3127 << " " << ComponentName << endl;
3128 bool RetVal = true ;
3130 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
3131 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
3133 if ( CORBA::is_nil( objComponent ) ) {
3134 cdebug_out << aThread
3135 << " StartComponent cannot FindOrLoad " << aComputerContainer
3136 << " " << ComponentName << " ERROR" << endl;
3139 /* asv : 24.01.05 : FindContainer() method does not exist any more. FindOrLoad_Component()
3140 starts the container for us. If it fails to start the container, then it
3141 returns nil component. We don't need to check for if the container was
3142 successfully started..
3144 myContainer = LCC.FindContainer( aComputerContainer );
3145 if ( CORBA::is_nil( myContainer ) ) {
3146 cdebug_out << aThread
3147 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
3148 << aComputerContainer << "' ) Container does not exist ERROR"
3154 cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;