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 = GetChangeGraphNode( index ) ;
699 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
700 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
701 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
702 << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode() << endl ;
703 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
704 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
705 << aNode->LinkedNodes( i )->Name() << endl ;
707 if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted
708 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
709 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
710 << aNode->LinkedFromNodes( i )->Name() << endl ;
714 //JR 24.03.2005 : Debug : CoupledNode field of GOTONodes was not erased
715 if ( aNode->IsInLineNode() ) {
716 GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
718 GraphBase::ComputingNode * aLinkedNode ;
719 aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
720 if ( aLinkedNode->IsGOTONode() ) {
721 cdebug << "Graph::RemoveNode erase CoupledNode " << aLinkedNode->Name() << endl ;
722 ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNode( NULL ) ;
723 ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( "" ) ;
727 if ( !aNode->IsEndSwitchNode() ) {
728 if ( aNode->GetNodeInPortsSize() ) {
729 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
730 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
731 cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
732 << anInPort->PortStatus() << " <-- " ;
733 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
734 if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
735 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
738 if ( !anInPort->IsNotConnected() ) {
740 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
741 cdebug << " Data/Extern" << endl ;
744 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
745 cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
746 << FromNode->LinkedNodesSize() << " and " << aNode->Name()
747 << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
748 // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
749 // JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode
750 // if ( !FromNode->IsOneOfGOTONodes() ) {
751 // if ( !FromNode->IsGOTONode() ) {
752 if ( !FromNode->IsGOTONode() &&
753 !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
754 if ( anInPort->IsDataStream() ) {
755 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
758 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
761 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
766 RetVal = anOutPort->RemoveInPort( anInPort ) ;
768 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
782 // Special case of EndSwitchNodes : each Input port must be multi-connected.
783 // There is one link for each branch of the switch
784 // But in GraphBase::InPort there is only one field GraphBase::OutPort *
785 // At execution time there is no problem because only one branch of the switch
786 // may be executed and the Executor set the right OutPort in the field
787 // GraphBase::OutPort * of each InPort of the EndSwitchNode
788 // But here we must remove that node EndSwitch from the LinkedNodes field of
789 // terminal nodes of all branches.
790 // And also in the OutPorts of that terminal nodes of branches we must remove
791 // references to InPorts of the EndSwitchNode.
793 // Explore LinkedFromnodes of the EndSwitchNode :
794 for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) {
795 GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ;
796 cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ;
798 for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
799 GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
800 cdebug << "OutPort" << j << ". Remove " << anOutPort->InPortsSize()
801 << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
802 << anOutPort->PortName() << ") "
803 << anOutPort->PortStatus() << " :" << endl ;
805 for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) {
806 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
807 if ( !strcmp( anInPort->NodeName() , aNode->Name() ) ) {
808 // InPort of the EndSwitchNode
809 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
810 << anInPort->PortName() << ") "
811 << anInPort->PortStatus() << endl ;
812 anInPort->RemoveOutPort() ;
813 if ( anOutPort->IsDataStream() ) {
814 aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ;
817 // false ==> No error for aNode->LinkedFromNode()
818 RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
820 cdebug << "aLinkedFromNode->RemoveLinkedNode Error RetVal " << RetVal << endl ;
824 // Remove the InPort of the EndSwitchNode from that OutPort
825 RetVal = anOutPort->RemoveInPort( anInPort ) ;
827 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
837 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
838 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
839 cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
840 << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
841 << anOutPort->PortStatus() << " :" << endl ;
843 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
844 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
845 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
846 << anInPort->PortStatus() << endl ;
847 if ( !anInPort->IsExternConnected() ) {
848 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
849 RetVal = anInPort->RemoveOutPort() ;
850 // JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
853 cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
856 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
857 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
859 else if ( anOutPort->IsDataStream() ) {
860 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
863 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
866 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
869 RetVal = anOutPort->RemoveInPort( anInPort ) ;
871 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
874 if ( ToNode->IsEndSwitchNode() ) {
877 for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
878 GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
879 // Not the node that we are deleting ... :
880 if ( strcmp( fromNode->Name() , aNode->Name() ) ) {
882 for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
883 GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
885 for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
886 if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
887 if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
888 // Restore an OutPort in the InPort
889 anInPort->ChangeOutPort( fromOutPort ) ;
890 cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( "
891 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
892 << ToNode->Name() << "( " << anInPort->PortName() << " )"
893 << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
912 cdebug << "Error RetVal " << RetVal << endl ;
917 //if ( aNode->LinkedNodesSize() || aNode->LinkedFromNodesSize() ) {
920 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
921 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
922 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
923 << " LinkedFromNodes " << endl ;
924 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
925 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
926 << aNode->LinkedNodes( i )->Name() << endl ;
928 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
929 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
930 << aNode->LinkedFromNodes( i )->Name() << endl ;
932 // Delete of aNode from the Graph :
933 // The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted
934 // when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode
935 if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) {
936 GraphBase::InLineNode * theCoupledNode = NULL ;
937 char * theCoupledNodeName = NULL ;
938 int CoupledIndex = -1 ;
939 if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
940 theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
941 theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
943 cdebug << "Node" << index << " " << _GraphNodes[ index ]->Name() << " will be deleted"
946 _GraphNodesSize -= 1 ;
947 for ( i = index ; i < _GraphNodesSize ; i++ ) {
948 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
949 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
951 _GraphNodes.resize( _GraphNodesSize+1 ) ;
952 _MapOfGraphNodes.erase( aNodeName ) ;
954 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
955 if ( theCoupledNode ) {
956 //JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before)
957 CoupledIndex = GetGraphNodeIndex( theCoupledNodeName ) ;
958 cdebug << "CoupledNode" << CoupledIndex << " " << _GraphNodes[ CoupledIndex ]->Name()
959 << " will be deleted" << endl ;
960 delete theCoupledNode ;
961 _GraphNodesSize -= 1 ;
962 for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
963 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
964 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
966 _GraphNodes.resize( _GraphNodesSize+1 ) ;
967 _MapOfGraphNodes.erase( theCoupledNodeName ) ;
973 cdebug << "Graph::RemoveNode Node not found ERROR " << index << endl ;
977 cdebug << "Graph::RemoveNode " << _GraphNodesSize << " known nodes" << endl;
978 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
979 cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
981 map< string , int >::iterator aMapOfGraphNodesIterator ;
983 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
984 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
985 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
986 << aMapOfGraphNodesIterator->second << " - 1" << endl ;
990 cdebug_out << "Graph::RemoveNode " << RetVal << endl;
994 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
995 const char* FromServiceParameterName ,
996 const char* ToNodeName ,
997 const char* ToServiceParameterName ) {
998 // , const CORBA::Any aValue ) {
1001 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
1002 << FromServiceParameterName << ") ---> " << ToNodeName << "("
1003 << ToServiceParameterName << ") , aValue )" << endl;
1005 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1006 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1008 GraphBase::OutPort *fromPort = NULL ;
1009 GraphBase::InPort *toPort = NULL ;
1012 // asv : 29.12.04 : as I understand, replacement of "InitLoop" by "DoLoop" was
1013 // done by JR in order to keep old graphs and batch test scripts working after change
1014 // of special Loop's port name from "InitLoop" to "DoLoop". I suppose, it is not
1015 // needed, all old graphs and tests must be changed to use "DoLoop" name for addressing
1016 // this port.. It we don't do it, ANY port with "InitLoop" name will be replaced by "DoLoop"
1017 // and it can cause unexpected bugs in future... So I comment out the replacement code.
1018 //if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
1019 //JR 12.01.05 : Yes the test is not good ; now I test that PortName only in LoopNodes ==>
1020 // + old graphs will runs normally (it is not possible to ask CEA to edit their graphs)
1021 // + in old graphs "InitLoop" and "DoLoop" were reserved parameter names (but not controlled)
1022 // + in new graphs, I have added a control at port creation of that names : they are refused
1023 if ( !(fromNode->IsLoopNode() && strcmp( FromServiceParameterName , "InitLoop" ) == 0 ) ) {
1024 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1027 fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
1030 cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
1031 << FromNodeName << ") not found." << endl ;
1035 cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
1038 // see comment above
1039 // if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
1040 if ( !(toNode->IsLoopNode() && strcmp( ToServiceParameterName , "InitLoop" ) == 0 ) ) {
1041 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1044 toPort = toNode->GetChangeInPort( "DoLoop" ) ;
1047 cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
1048 << ToNodeName << ") not found." << endl ;
1052 cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
1055 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
1058 if ( fromPort->IsGate() && toPort->IsGate() ) {
1060 aValue <<= (long ) 1 ;
1061 fromPort->Value( aValue ) ;
1064 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
1065 // fromPort->Value( aDataValue ) ;
1067 // fromPort->PortStatus( DataConnected );
1070 cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
1074 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
1075 GraphBase::OutPort *fromPort ,
1076 GraphBase::ComputingNode *toNode ,
1077 GraphBase::InPort *toPort ) {
1081 cdebug << "ERROR AddLink fromNode not found." << endl ;
1085 cdebug << "ERROR AddLink fromPort not found." << endl ;
1090 cdebug << "ERROR AddLink toNode not found." << endl ;
1094 cdebug << "ERROR AddLink toPort not found." << endl ;
1097 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
1098 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
1099 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
1102 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
1103 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
1104 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
1108 cdebug_in << "Graph::AddLink( " << fromNode->Name() << "("
1109 << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind()
1110 << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
1111 << ") " << toPort->Kind() << " )" << endl;
1112 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
1113 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1114 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
1115 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
1119 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1120 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1121 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
1122 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
1126 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
1127 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1128 toPort->GetOutPort()->PortName() ,
1129 toNode->Name() , toPort->PortName() ) ) {
1130 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
1135 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
1136 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1137 toPort->GetOutPort() ) {
1138 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
1139 fromPort->NodePortName() ) ) {
1140 cdebug << "Link already exists" << endl ;
1141 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1144 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1145 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
1147 else if ( fromNode->IsGOTONode() ) {
1148 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1149 toPort->GetOutPort()->PortName() ,
1150 toNode->Name() , toPort->PortName() ) ) {
1151 cdebug << "RemoveLink(AddLink) Error."
1153 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1156 if ( fromPort->InPortsSize() ) {
1157 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1158 fromPort->ChangeInPorts(0)->NodeName() ,
1159 fromPort->ChangeInPorts(0)->PortName() ) ) {
1160 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1161 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1167 // JR 17.01.2005 : toPort is already linked : RemoveLink
1168 else if ( !toNode->IsEndSwitchNode() ) {
1169 // else if ( !toNode->IsEndSwitchNode() ||
1170 // ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
1171 //JR Debug : the fromPort was wrong !
1172 // if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1173 if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() ,
1174 toNode->Name() , toPort->PortName() ) ) {
1175 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
1176 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1181 //JR Debug 15.02.2005 : Not multiple links in that case except if toPort is the DefaultPort
1182 else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1183 cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode toPort(NotGate)Error."
1185 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1190 //JR 24.03.2005 : No Link between OutPort of SwitchNode to InPort of EndSwitchNode except if
1191 // they have the same name for a special case :
1192 // Switch with no branch ==> Default is applied always : GraphSyrControl example
1193 else if ( fromNode->IsSwitchNode() && !fromPort->IsGate() &&
1194 toNode->IsEndSwitchNode() && !toPort->IsGate() &&
1195 strcmp( fromPort->PortName() , toPort->PortName() ) ) {
1196 cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode Error." << endl ;
1197 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1200 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
1201 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1202 fromPort->ChangeInPorts(0)->NodeName() ,
1203 fromPort->ChangeInPorts(0)->PortName() ) ) {
1204 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1205 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1209 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
1210 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
1211 fromPort->RemoveInPort( toPort ) ; //dbg
1213 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
1214 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
1215 fromPort->RemoveInPort() ; // There is only one
1219 // JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
1220 if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1221 fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
1222 cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
1223 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1226 //JR 11.02.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
1227 // SwitchNode(Param) may be linked to EndSwitchNode(Param)
1228 // SwitchNode(Param-UserDefault) may be linked to EndSwitchNode(Default)
1229 else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() &&
1230 !( ( fromPort->IsGate() && toPort->IsGate() ) ||
1231 ( !fromPort->IsGate() ) ) ) {
1232 // ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) {
1233 cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
1235 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1238 else if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1239 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
1240 if ( !fromPort->AddInPort( toPort ) ) {
1241 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
1243 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1246 if ( !toPort->IsDataStream() ) {
1247 toPort->Kind( SUPERV::EndSwitchParameter ) ;
1250 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
1251 cdebug << "!fromPort->AddLink Error." << endl ;
1252 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1256 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
1257 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
1258 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
1259 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1262 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
1263 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
1264 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1267 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
1268 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
1269 cdebug << "toPort->AddLink Error." << endl ;
1270 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1275 toPort->AddOutPort( fromPort ) ;
1278 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
1279 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
1280 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
1281 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
1282 << fromNode->Name() << " " << fromPort->PortName()
1283 << " InLineNode/LoopNode_ConnectedInPortsNumber "
1284 << toNode->ConnectedInPortsNumber() << endl;
1285 if ( fromNode->IsGOTONode() ) {
1286 fromPort->Kind( SUPERV::GOTOParameter ) ;
1288 fromPort->PortStatus( PortConnected ); // GOTO - Loop
1290 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
1291 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
1292 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1293 fromPort->PortStatus( ExternConnected );
1295 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
1296 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
1297 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1298 fromPort->PortStatus( ExternConnected ) ;
1301 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
1302 << fromNode->Name() << " " << fromPort->PortName() << " "
1303 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
1304 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
1305 fromPort->PortStatus( PortConnected );
1306 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
1307 fromNode->AddStreamLinkedNode( toNode ) ;
1310 fromNode->AddLinkedNode( toNode ) ;
1313 if ( fromNode->IsSwitchNode() ) {
1314 if ( !fromPort->IsDataStream() ) {
1315 //JR 08.02.2005 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1316 if ( fromPort->IsInLine() && toPort->IsGate() ) {
1317 fromPort->Kind( SUPERV::SwitchParameter ) ;
1319 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
1320 fromPort->Kind( SUPERV::InLineParameter ) ;
1323 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1324 GraphBase::InLineNode * anEndSwitchNode ;
1325 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1326 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1327 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1328 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1329 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1330 anOutPort->IsGate() ) {
1331 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1332 anEndSwitchNode->Name() ,
1333 anInPort->PortName() ) ) {
1334 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1336 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1342 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1343 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1347 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1348 const char* FromServiceParameterName ,
1349 const char* ToNodeName ,
1350 const char* ToServiceParameterName ) {
1351 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1352 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1353 bool RetVal = false ;
1354 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1356 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1357 if ( anInPort && ( anInPort->IsPortConnected() ||
1358 anInPort->IsDataConnected() ||
1359 anInPort->IsExternConnected() ) ) {
1360 // JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
1361 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1362 GraphBase::OutPort * anOutPort = NULL ;
1363 if ( toNode->IsEndSwitchNode() ) {
1364 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1365 RetVal = anOutPort->RemoveInPort( anInPort ) ;
1368 anOutPort = anInPort->GetOutPort() ;
1369 RetVal = anOutPort->RemoveInPort( anInPort ) ;
1371 // anInPort->RemoveOutPort() ; // Already done in RemoveInPort
1372 // const char * FromNodeName = anOutPort->NodeName() ;
1375 if ( anInPort->IsDataStream() ) {
1376 fromNode->RemoveStreamLinkedNode( toNode ) ;
1379 fromNode->RemoveLinkedNode( toNode ) ;
1382 //JR PAL7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
1383 //Debug : change the kind only if there is no other InGate connected to the OutPort
1384 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) {
1385 if ( !toNode->IsEndSwitchNode() ) {
1386 anOutPort->Kind( SUPERV::InLineParameter ) ;
1388 else if ( !anInPort->IsGate() ) {
1389 anOutPort->Kind( SUPERV::InLineParameter ) ;
1392 // JR 13.01.2005 : DeBug : if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
1393 if ( toNode->IsEndSwitchNode() ) {
1396 for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) {
1397 GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ;
1399 for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
1400 GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
1402 for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
1403 if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
1404 if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
1405 // Restore an OutPort in the InPort
1406 anInPort->ChangeOutPort( fromOutPort ) ;
1407 cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
1408 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
1409 << toNode->Name() << "( " << anInPort->PortName() << " )"
1410 << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
1428 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1432 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1433 const char* ToServiceParameterName ,
1434 char** FromNodeName ,
1435 char** FromServiceParameterName ) {
1436 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1437 // << ToServiceParameterName << ")" << endl;
1438 bool RetVal = false ;
1439 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1441 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1442 if ( anInPort && !anInPort->IsNotConnected() ) {
1443 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1444 //JR 17.02.2005 Memory Leak *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1445 *FromNodeName = (char * ) anOutPort->NodeName() ;
1446 //JR 17.02.2005 Memory Leak *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1447 *FromServiceParameterName = (char * ) anOutPort->PortName() ;
1451 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1452 << " " << ToServiceParameterName << " " << RetVal << endl;
1456 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1459 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1463 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1464 const char* ToServiceParameterName ,
1465 const CORBA::Any aValue ) {
1466 bool RetVal = false ;
1467 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1468 << ToServiceParameterName << " , Any " ;
1469 switch (aValue.type()->kind()) {
1470 case CORBA::tk_string:
1473 cdebug << t << " (string) " ;
1475 case CORBA::tk_double:
1478 cdebug << d << " (double) " ;
1480 case CORBA::tk_long:
1483 cdebug << l << " (long) " ;
1485 case CORBA::tk_objref:
1486 cdebug << "(object reference) " ;
1489 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1490 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1493 cdebug << " ) in Graph " << Name() << endl;
1495 GraphBase::ComputingNode *toNode ;
1496 GraphBase::InPort *toPort ;
1499 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1500 toNode = GetChangeGraphNode( aNodeName ) ;
1501 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1503 toPort = toNode->GetChangeInPort( aPortName ) ;
1504 if ( toPort && !toPort->IsDataConnected() ) {
1505 toPort->RemoveOutPort() ;
1513 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1514 cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1516 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1517 cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1520 if ( toNode && toPort ) {
1521 GraphBase::OutPort *fromDataNodePort = NULL ;
1522 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1523 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1524 fromDataNodePort->RemoveInPort( toPort ) ;
1526 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1527 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1528 << toPort->PortName() << " )" << endl ;
1529 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1532 fromDataNodePort->Value( aValue ) ;
1533 fromDataNodePort->PortStatus( DataConnected ) ;
1537 cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1542 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1546 // Used in the Executor in order to change an Input Value and ReRun
1547 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1548 const char * ToServiceParameterName ,
1549 const CORBA::Any aValue ) {
1550 bool RetVal = false ;
1551 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1552 << ToServiceParameterName << "' , Any " ;
1553 switch (aValue.type()->kind()) {
1554 case CORBA::tk_string:
1557 cdebug << t << " (string) " ;
1559 case CORBA::tk_double:
1562 cdebug << d << " (double) " ;
1564 case CORBA::tk_long:
1567 cdebug << l << " (long) " ;
1569 case CORBA::tk_objref:
1570 cdebug << "(object reference) " ;
1573 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1576 cdebug << " ) in Graph " << Name() << endl;
1578 GraphBase::ComputingNode * toNode ;
1579 GraphBase::InPort * toPort = NULL ;
1582 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1583 toNode = GetChangeGraphNode( aNodeName ) ;
1584 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1586 toPort = toNode->GetChangeInPort( aPortName ) ;
1587 if ( toPort && toPort->IsDataConnected() ) {
1588 GraphBase::OutPort * fromPort = toPort->GetOutPort();
1591 fromPort->Value( aValue ) ;
1592 fromPort->PortStatus( DataConnected ) ;
1593 toPort->PortState( SUPERV::ReadyState ) ;
1596 cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1600 cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1604 cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1607 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1612 // To restore InputData in CreateService
1613 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1614 const char* ToServiceParameterName ,
1615 const CORBA::Any ** aValue ) {
1616 bool RetVal = false ;
1617 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1618 << ToServiceParameterName << ", **Any " ;
1619 const CORBA::Any theValue = **aValue ;
1620 switch (theValue.type()->kind()) {
1621 case CORBA::tk_string:
1624 cdebug << t << " (string) " ;
1626 case CORBA::tk_double:
1629 cdebug << d << " (double) " ;
1631 case CORBA::tk_long:
1634 cdebug << l << " (long) " ;
1636 case CORBA::tk_objref:
1637 cdebug << "(object reference) " ;
1640 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1643 cdebug << ") of Graph " << Name() << endl;
1645 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1648 GraphBase::InPort *toPort = NULL ;
1649 GraphBase::OutPort *fromDataNodePort = NULL ;
1650 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1651 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1652 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1653 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1654 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1657 fromDataNodePort->Value( aValue ) ;
1658 fromDataNodePort->PortStatus( DataConnected ) ;
1662 cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1663 map< string , int >::iterator aMapOfGraphNodesIterator ;
1665 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1666 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1667 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1668 << aMapOfGraphNodesIterator->second << endl ;
1672 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1677 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1678 const char* FromServiceParameterName ,
1679 const CORBA::Any aValue ) {
1680 bool RetVal = true ;
1681 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1682 << FromServiceParameterName << ")" << endl;
1683 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1685 GraphBase::OutPort *anOutPort = NULL ;
1688 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1689 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1690 // RetVal = AddLink( fromNode , fromPort ,
1691 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1692 anOutPort->Value( aValue ) ;
1693 anOutPort->PortState( SUPERV::ReadyState ) ;
1694 anOutPort->PortDone( true ) ;
1695 cdebug << *anOutPort ;
1697 anOutPort->StringValue( *_fdebug ) ;
1702 cdebug << "ERROR Node not found" << endl ;
1705 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1709 //JR This is used by StreamGraphs to list "CODES" and after that there is instances
1710 // for each Code (Nodes).
1711 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1712 return _MapOfServiceNames ; }
1714 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1715 return _MapOfServiceNames[ name ] ;
1718 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1719 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1721 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1722 << " already in MapOfServiceNames : erase" << endl ;
1723 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1725 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1726 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1731 //JR Debug 25.03.2005 : with multiple instances et delete of instances, it was wrong
1732 //Bug created with the developpement of StreamGraphs
1733 int GraphBase::Graph::GetNewServiceInstanceNumber( char * aServiceName ) {
1734 int InstanceNumber = _MapOfServiceInstanceNumber[ aServiceName ] + 1 ;
1735 _MapOfServiceInstanceNumber[ aServiceName ] = InstanceNumber ;
1736 return InstanceNumber ;
1739 void GraphBase::Graph::SetGraphPorts() {
1740 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1742 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1743 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1744 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1745 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
1746 if ( !anOutPort->IsGate() ) {
1747 anOutPort->PortStatus( ExternConnected ) ;
1750 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1751 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1752 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1753 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
1754 if ( !anInPort->IsGate() ) {
1755 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1756 anOutPort->PortStatus( ExternConnected ) ;
1759 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1762 bool GraphBase::Graph::CreateService() {
1763 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1764 bool RetVal = true ;
1765 SALOME_ModuleCatalog::Service aService ;
1767 GraphBase::ComputingNode * aToNode ;
1770 int instreamnbr = 0 ;
1772 int outstreamnbr = 0 ;
1773 vector< SUPERV::KindOfPort > InPortsKind ;
1774 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1775 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1776 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1777 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1778 vector< SUPERV::KindOfPort > OutPortsKind ;
1779 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1780 vector< long > OutNumberOfValues ;
1781 // if ( GraphMacroLevel() == 0 ) {
1782 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1783 if ( dostore == 1 ) {
1784 //JR 17.02.2005 Memory Leak aService.ServiceName = Name() ;
1785 aService.ServiceName = my_strdup( Name() ) ;
1786 aService.ServiceinParameter.length( 0 ) ;
1787 aService.ServiceinParameter.length( innbr ) ;
1788 aService.ServiceoutParameter.length( 0 ) ;
1789 aService.ServiceoutParameter.length( outnbr ) ;
1790 InPortsKind.resize( innbr ) ;
1791 InDataStreamDependency.resize( innbr ) ;
1792 InKindOfSchema.resize( innbr ) ;
1793 InKindOfInterpolation.resize( innbr ) ;
1794 InKindOfExtrapolation.resize( innbr ) ;
1795 OutPortsKind.resize( outnbr ) ;
1796 OutDataStreamDependency.resize( outnbr ) ;
1797 OutNumberOfValues.resize( outnbr ) ;
1799 else if ( dostore == 2 ) {
1800 //JR Creation of the Service (and of the Ports) with GraphBase::DataNode::DataService :
1801 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1802 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1803 << " outstreamnbr " << outstreamnbr << endl ;
1804 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1805 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1806 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1807 InPortsKind.resize( innbr + instreamnbr ) ;
1808 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1809 InKindOfSchema.resize( innbr + instreamnbr ) ;
1810 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1811 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1812 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1813 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1814 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1816 if ( dostore == 0 ) {
1822 if ( dostore == 1 ) {
1826 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1827 aToNode = GraphNodes( i ) ;
1828 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1829 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1830 bool isfromcouplednode = false ;
1831 if ( !anInPort->IsNotConnected() ) {
1832 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1833 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1834 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1835 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1836 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1837 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1838 isfromcouplednode = true ;
1841 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1842 ( !anInPort->IsPortConnected() ||
1843 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1844 if ( dostore == 0 ) {
1845 cdebug << "CreateService " << aToNode->Name() << " Input port "
1846 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1847 if ( anInPort->GetOutPort() ) {
1848 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1851 if ( anInPort->IsDataStream() ) {
1858 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1859 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1860 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1861 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1862 InPortsKind[ innbr ] = anInPort->Kind() ;
1863 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1864 if ( dostore == 2 && anInPort->IsDataStream() ) {
1865 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1866 InKindOfInterpolation[ innbr ] ,
1867 InKindOfExtrapolation[ innbr ] ) ;
1869 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1870 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1874 else if ( dostore == 0 ) {
1875 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1876 << " " << anInPort->PortStatus() ;
1877 if ( anInPort->IsPortConnected() ) {
1878 cdebug << " is connected " ;
1881 cdebug << " is NOT connected " ;
1883 if ( anInPort->IsGate() ) {
1884 cdebug << " IsGate " ;
1886 if ( anInPort->GetOutPort() ) {
1887 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1890 cdebug << "NOT DataConnected" ;
1895 GraphBase::ComputingNode * aFromNode = aToNode ;
1896 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1897 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1898 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1899 // if ( anOutPort ) {
1900 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1903 // cdebug << " NULL" << endl ;
1905 if ( !aFromNode->IsGOTONode() ) {
1906 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
1907 anOutPort->IsExternConnected() ) {
1908 if ( dostore == 0 ) {
1909 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1910 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1911 if ( anOutPort->IsDataStream() ) {
1918 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1919 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1920 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1921 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1922 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1923 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1924 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1925 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1927 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1928 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1939 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1940 << " OutPorts " << outnbr << endl ;
1941 for ( i = 0 ; i < innbr ; i++ ) {
1942 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1943 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1944 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1945 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1946 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1949 for ( i = 0 ; i < outnbr ; i++ ) {
1950 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1951 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1952 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1953 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1954 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1959 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
1960 for ( i = 0 ; i < innbr ; i++ ) {
1961 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1962 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
1963 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
1964 InDataStreamDependency[ i ] ,
1965 SUPERV::DataStreamParameter ) ;
1966 anInPort->SetParams( InKindOfSchema[ i ] ,
1967 InKindOfInterpolation[ i ] ,
1968 InKindOfExtrapolation[ i ] ) ;
1969 // NOT A BUG : AddOutPort for an inport (Reversed service)
1970 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
1973 aService.ServiceinParameter[ i ].Parametername ,
1974 aService.ServiceinParameter[ i ].Parametertype ,
1975 SUPERV::DataStreamParameter ,
1977 _Graph_prof_debug , _Graph_fdebug ) ;
1978 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
1979 // Attention : revoir les reversed DataStreamPorts
1980 // anInPort->SetParams( InKindOfSchema[ i ] ,
1981 // InKindOfInterpolation[ i ] ,
1982 // InKindOfExtrapolation[ i ] ) ;
1983 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1984 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1988 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1989 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1990 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1991 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1992 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1993 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1997 for ( i = 0 ; i < outnbr ; i++ ) {
1998 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1999 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
2000 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
2001 OutDataStreamDependency[ i ] ,
2002 SUPERV::DataStreamParameter ) ;
2003 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
2004 // NOT A BUG : AddInPort for an outport (Reversed service)
2005 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
2008 aService.ServiceoutParameter[ i ].Parametername ,
2009 aService.ServiceoutParameter[ i ].Parametertype ,
2010 SUPERV::DataStreamParameter ,
2012 _Graph_prof_debug , _Graph_fdebug ) ;
2013 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
2014 // Attention : revoir les reversed DataStreamPorts
2015 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
2016 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
2017 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
2021 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
2022 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
2023 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2024 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2025 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2026 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
2027 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
2028 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
2032 // Restore input datas and links :
2033 DataStreamInPortsNumber( 0 ) ;
2034 DataStreamOutPortsNumber( 0 ) ;
2035 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2036 aToNode = GraphNodes( i ) ;
2037 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
2038 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
2039 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
2040 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
2041 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
2042 if ( !AddInputData( anInPort->NodeName() ,
2043 anInPort->PortName() ,
2044 //JR 21.02.2005 Debug Memory leak : anInPort->GetOutPort()->ValuePtr() ) ) {
2045 //JR 30.03.2005 *anInPort->GetOutPort()->Value() ) ) {
2046 anInPort->GetOutPort()->Value() ) ) {
2047 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2048 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
2052 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2053 << anInPort->PortStatus() << " --> AddInputData" << endl ;
2056 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2057 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
2058 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2059 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
2063 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2064 << anInPort->PortStatus() << " --> AddInLink" << endl ;
2068 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
2069 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
2070 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
2071 << ") " << anOutPort->PortStatus() << " :" << endl ;
2072 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
2073 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
2074 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
2075 cdebug << " --> " << Name() << "(" << anInPort->PortName()
2076 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
2080 cdebug << " --> " << Name() << "(" << anInPort->PortName()
2081 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
2088 ListPorts( *_Graph_fdebug , 0 ) ;
2091 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
2095 bool GraphBase::Graph::InLineServices() {
2096 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
2101 ListPorts( *_Graph_fdebug , 0 ) ;
2104 GraphBase::InLineNode * aINode ;
2105 SALOME_ModuleCatalog::Service aService ;
2106 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2107 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
2108 if ( aINode->IsOneOfInLineNodes() ) {
2109 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
2110 aService.ServiceName = aINode->ServiceName() ;
2111 aService.ServiceinParameter.length( 0 ) ;
2112 aService.ServiceoutParameter.length( 0 ) ;
2113 aINode->DataStreamInPortsNumber( 0 ) ;
2114 aINode->DataStreamOutPortsNumber( 0 ) ;
2116 int InStreamService = 0 ;
2117 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
2118 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
2120 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2121 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2122 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2123 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
2124 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2125 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2128 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
2129 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
2130 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2131 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2132 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
2133 aINode->IncrDataStreamInPorts() ;
2135 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2136 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2137 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2138 << aINode->GetChangeNodeInPort(j)->PortName() << " "
2139 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2140 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2144 aService.ServiceinParameter.length( InService+1 ) ;
2145 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2146 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2148 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2149 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2150 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2151 << aINode->GetChangeNodeInPort(j)->PortName() << " "
2152 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2153 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2157 int OutService = 0 ;
2158 int OutStreamService = 0 ;
2159 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
2160 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2161 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
2163 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2164 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2165 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2166 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
2167 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2168 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2171 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2172 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
2173 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2174 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2175 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
2176 aINode->IncrDataStreamOutPorts() ;
2178 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2179 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2180 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2181 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2182 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2183 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2187 aService.ServiceoutParameter.length( OutService+1 ) ;
2188 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2189 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2191 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2192 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2193 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2194 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2195 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2196 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2200 aINode->SetService( aService ) ;
2201 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
2203 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
2204 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
2205 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
2208 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
2212 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
2216 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
2218 ListPorts( *_Graph_fdebug , 0 ) ;
2223 int NotSortedNumber = GraphNodesSize() ;
2225 cdebug_in << "GraphBase::Graph::Sort" << endl;
2226 if ( NotSortedNumber ) {
2228 _ParallelExecutionNodes = false ;
2229 _Sorted.resize( GraphNodesSize() ) ;
2230 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
2231 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
2232 if ( _NodesNumber.size() ) {
2233 _NodesNumber.resize( 0 ) ;
2234 _SortedNodes.resize( 0 ) ;
2237 // This is a simulation of the computation of the graph :
2238 // The initial state of nodes is :
2239 // - Sorted = false : the node is not sorted
2240 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
2241 // - DecrInPortsNumber = 0 : there is no value available.
2243 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
2244 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2245 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2246 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
2247 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
2248 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
2252 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2253 _Sorted[ i ] = false ;
2254 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
2255 _DecrInPortsNumber[ i ] = 0 ;
2256 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
2257 // << _CnxInPortsNumber[ i ] << endl ;
2260 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
2261 // ==============================================================================
2262 while ( NotSortedNumber ) {
2265 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2266 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
2267 << GraphNodes( i )->Name() << " count "
2268 << _CnxInPortsNumber[ i ] << endl ;
2269 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
2270 // All inputs of GraphNodes( i ) are available : "AllDataReady"
2271 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
2272 _NodesNumber.resize( _LevelsNumber+1 ) ;
2273 _SortedNodes.resize( _LevelsNumber+1 ) ;
2274 _NodesNumber[ _LevelsNumber ] = -1 ;
2276 // There is one more node at that level
2277 _NodesNumber[ _LevelsNumber ]++ ;
2278 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
2279 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
2280 _Sorted[ i ] = true ;
2282 NotSortedNumber -= 1 ;
2283 cdebug << GraphNodes( i )->Name() << " belongs to level "
2284 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
2285 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
2286 // So we loop over all nodes that have a link from that node
2287 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
2288 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
2289 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
2290 // OutputPorts of GraphNodes( i ) will satisfy
2291 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
2292 // GraphNodes( i )->LinkedNodes( j )
2293 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
2294 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
2295 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
2296 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
2297 cdebug << " _DecrInPortsNumber[ "
2298 << GetGraphNodeIndex( aLinkedNode->Name() )
2300 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
2301 << " += " << aLinkedInPortsNumber ;
2302 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
2308 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
2309 // will wait for data(s) from node(s) not executed or not executing for ever
2311 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2312 return false ; // Loop in the Graph
2314 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
2315 bool ChangeCount = false ;
2316 // We update now the number of InPorts with a link that are waiting for a value
2317 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2318 if ( _DecrInPortsNumber[ i ] ) {
2319 // int prevcount = _CnxInPortsNumber[ i ] ;
2320 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
2321 _DecrInPortsNumber[ i ] = 0 ;
2322 ChangeCount = true ;
2323 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
2324 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
2327 // If there is no loop and if the number of InPorts with a link that are waiting for a value
2328 // does not change, the sort is finished. But there is also NotSortedNumber ...
2329 // if ( !ChangeCount )
2331 if ( NotSortedNumber ) {
2332 _LevelsNumber += 1 ;
2336 int AllSortedNodes = 0 ;
2337 _HeadNodes = _SortedNodes[ 0 ] ;
2338 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
2339 // QueueNodes was used in the past in order to know if the execution of a graph is finished
2340 // But because of loop nodes that was changed. So that part of code is a "clutter"
2341 // Now a graph has finished its execution when the number of executing threads is zero
2342 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
2343 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
2344 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
2345 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
2349 if ( i == _QueueNodesSize && _LevelsNumber ) {
2350 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
2351 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
2353 // Computation of the maximum number of threads == the maximum number of nodes of all levels
2354 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2355 AllSortedNodes += _NodesNumber[ i ]+1 ;
2356 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
2357 _ThreadsMax = _NodesNumber[ i ] + 1 ;
2359 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
2360 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
2361 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
2362 _ParallelExecutionNodes = true ;
2363 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
2367 if ( _ParallelExecutionNodes ) {
2368 // cdebug << "Parallel Execution Nodes detected." << endl ;
2371 // cdebug << "No Parallel Execution Nodes detected." << endl ;
2373 if ( AllSortedNodes != GraphNodesSize() ) {
2374 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2375 return false ; // Loop in the Graph
2378 cdebug << "Graph::Sort " << _NodesNumber[ 0 ] << " HeadNodes :" << endl ;
2379 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
2380 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
2381 cdebug << " " << i << ". : " << (_SortedNodes[ 0 ])[ i ]->Name() << endl ;
2384 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
2385 // There is no substreamgraph for nodes without StreamPorts
2386 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
2387 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
2388 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
2389 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
2390 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
2391 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
2394 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2398 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2399 // the SubGraph of that nodes is unknown
2400 // There is no substreamgraph for nodes without StreamPorts
2401 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2402 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2403 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2404 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2405 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2406 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2407 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2410 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2415 // Computation of independent SubGraphs which have NO link between them
2416 cdebug << endl << "Computation of SubGraphs" << endl ;
2417 bool Graphs = true ;
2419 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2420 cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2421 << " Nodes :" << endl ;
2422 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2423 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2424 cdebug << " " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2426 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2427 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2428 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2429 // && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2430 // aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2431 int OldSub = aNode->SubGraph() ;
2432 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2433 cdebug << " " << aNode->Name() << " changed SubGraph "
2434 << aNode->LinkedNodes( k )->SubGraph() << endl ;
2436 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2438 for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2439 if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2440 GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2441 aSubNode->SubGraph( NewSub ) ;
2449 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2450 << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2454 cdebug << " LinkedNode " << aNode->LinkedNodes( k )->Name()
2455 << " initial SubGraph " << aNode->SubGraph() << endl ;
2456 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2468 cdebug << endl << "SubGraphs result : " << endl ;
2471 cdebug << endl << "One more time" << endl ;
2474 // Make a sequential renumbering of SubGraphs :
2475 _SubGraphsNumber = 0 ;
2476 int CurrGraphsNumber = 0;
2478 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2479 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2480 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2481 _SubGraphsNumber += 1 ;
2482 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2483 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2484 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2485 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2486 cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2487 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2495 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2496 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2497 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2498 if ( aNode->SubStreamGraph() < 0 ) {
2499 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2502 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2503 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2504 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2505 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2510 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2511 SubStreamGraphsNumber = 0 ;
2513 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2514 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2516 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2517 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2518 if ( aNode->SubStreamGraph() < 0 ) {
2519 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2520 // << " has NO streamport" << endl ;
2523 int CurStreamGraphsNumber ;
2524 if ( aNode->SubStreamGraph() > 0 ) {
2525 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2526 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2527 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2530 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2533 while ( RetVal != CurStreamGraphsNumber ) {
2534 RetVal = CurStreamGraphsNumber ;
2535 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2536 if ( RetVal != CurStreamGraphsNumber ) {
2537 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2538 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2539 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2540 aNode->SubStreamGraph( RetVal ) ;
2543 CurStreamGraphsNumber = RetVal ;
2546 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2547 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2553 // Make a sequential renumbering of SubGraphs :
2554 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2555 int CurrStreamGraphsNumber = 0 ;
2557 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2558 bool SearchCurrStreamGraphsNumber = true ;
2559 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2561 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2562 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2563 SearchCurrStreamGraphsNumber = false ;
2565 if ( CurrStreamGraphsNumber != count ) {
2566 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2567 // << " Level " << k << " n " << l << endl ;
2568 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2569 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2570 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2571 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2572 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2573 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2575 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2576 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2577 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2578 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2587 SubStreamGraphsNumber = count ;
2588 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2589 // int CurrStreamGraphsNumber ;
2590 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2591 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2592 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2593 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2594 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2595 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2603 ListPorts( *_Graph_fdebug , 0 ) ;
2606 cdebug_out << "GraphBase::Graph::Sort" << endl;
2610 bool GraphBase::Graph::ValidLoops() const {
2611 cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
2614 GraphBase::ComputingNode * aNode ;
2615 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2616 aNode = GraphNodes( i ) ;
2617 if ( aNode->IsLoopNode() ) {
2618 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2619 GraphBase::EndOfLoopNode * anEndLoopNode ;
2620 anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2621 if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
2622 cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
2626 else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
2627 cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
2633 cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
2637 bool GraphBase::Graph::ValidSwitchs() const {
2638 cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl;
2641 GraphBase::ComputingNode * aNode ;
2642 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2643 aNode = GraphNodes( i ) ;
2644 if ( aNode->IsSwitchNode() ) {
2645 GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ;
2646 if ( !aSwitchNode->CheckSwitch() ) {
2647 cdebug_out << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name()
2653 cdebug_out << "GraphBase::Graph::ValidSwitchs true" << endl;
2657 // Controle de la coherence des noeuds de calcul
2658 // Enregistrement dans la liste des noeuds "tete" de graphe
2660 bool GraphBase::Graph::ComputingNodes() const {
2661 bool RetVal = true ;
2662 cdebug << "GraphExecutor::Graph::ComputingNodes ()" << endl;
2664 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2665 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2666 // GraphEditor::Port * iP;
2668 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2669 // while ( aNode != aComputingNodesList.end() ) {
2671 GraphBase::ComputingNode * aNode ;
2672 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2673 aNode = GraphNodes( i ) ;
2674 cdebug << "Graph::ComputingNodes " << i << ". " << aNode->Name() << " Head " << aNode->IsHeadNode()
2676 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2677 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2678 // if ((*aNode)->GetNodeInPortsSize() == 0)
2679 // _headNodes.push_front(*aNode);
2681 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2682 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2683 if ( iP->IsNotConnected() ){
2684 // cdebug << "Le port d'entree " << iP->PortName()
2685 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2686 // << Name() << " n'est pas connecte "<< endl;
2692 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2693 bool oneOutPortConnected = false;
2694 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2695 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2696 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2697 oneOutPortConnected = true ;
2701 // cdebug << "Le port de sortie " << iP->PortName()
2702 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2703 // << Name() << " n'est pas connecte "<< endl;
2707 if (!oneOutPortConnected) {
2708 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2709 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2710 // _computingError.push_front(2);
2713 // return _computingError.size () ;
2717 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2718 bool RetVal = true ;
2721 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2722 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2723 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2724 if ( aNode->IsLoopNode() ) {
2725 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2726 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2727 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2728 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2729 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2730 aLoopNode , anInPort ) ) {
2731 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
2732 // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2733 // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
2741 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2742 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
2743 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2744 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2745 aLoopNode->CoupledNode() , anInPort ) ) {
2746 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
2747 // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2748 // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
2757 else if ( aNode->IsGOTONode() ) {
2758 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2759 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2760 if ( anOutGate->IsNotConnected() ) {
2761 if ( aGOTONode->CoupledNode() ) {
2762 cdebug << "Graph::LinkLoopNodes aNode " << aNode << " : " << aNode->Name()
2763 << aGOTONode->CoupledNode() << " : " << aGOTONode->CoupledNode()->Name()
2765 RetVal = AddLink( aGOTONode , anOutGate , aGOTONode->CoupledNode() ,
2766 aGOTONode->CoupledNode()->GetChangeNodeInGate() );
2767 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
2768 // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2769 // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2776 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
2780 // Controle de la coherence des noeuds de calcul
2781 // Enregistrement dans la liste des noeuds "tete" de graphe
2783 bool GraphBase::Graph::DataServerNodes() const {
2785 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
2787 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2788 int i , j , ierr = 0 ;
2790 // if ( DataFlowDatas == NULL ) {
2791 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2795 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2796 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2798 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2800 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2802 ierr = CheckDataServerNodes() ;
2804 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2805 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2806 if ( GraphNodesSize() == 0 ) {
2810 GraphBase::ComputingNode * aNode ;
2811 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2812 aNode = GraphNodes( i ) ;
2813 // while ( aNode != aComputingNodesList.end() ) {
2814 if ( aNode->IsFactoryNode() ) {
2815 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2816 if ( !strlen( FaNode->Computer() ) ) {
2817 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2818 if ( !strlen( FaNode->Computer() ) ) {
2823 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2827 // For Outputs of the DataFlow :
2828 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2829 if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
2830 if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
2831 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2834 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2841 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2843 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2844 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2846 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2847 // while ( it != aDataServerNodesList.end() ) {
2848 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2849 // cerr << "Erreur dans le noeud serveur de donnees "
2850 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2851 // cerr << "A la fois importation et exportation de donnees" << endl;
2852 // _dataServerError.push_front(1);
2855 // if ((*it)->GetNodeOutPortsSize()) {
2856 // if ((*it)->GetNodeOutPortsSize()==1){
2857 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2858 // _headNodes.push_front(*it);
2861 // cerr << "Le port de sortie du noeud serveur de donnees "
2862 // << (*it)->Name() << " du graphe " << _G->Name()
2863 // << " n'est pas connecte "<< endl;
2864 // _dataServerError.push_front(4);
2868 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2869 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2870 // _dataServerError.push_front(2);
2874 // if ((*it)->GetNodeInPortsSize()) {
2875 // if ((*it)->GetNodeInPortsSize() > 1){
2876 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2877 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2878 // _dataServerError.push_front(3);
2881 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2882 // cerr << "Le port d'entree du noeud serveur de donnees "
2883 // << (*it)->Name() << " du graphe " << _G->Name()
2884 // << " n'est pas connecte "<< endl;
2885 // _dataServerError.push_front(5);
2891 // return _dataServerError.size ();
2892 return ( ierr == 0 ) ;
2895 SUPERV::GraphState GraphBase::Graph::PortState(
2896 const char* NodeName ,
2897 const char* ServiceParameterName ) {
2898 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2899 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2900 // << ServiceParameterName << " )" << endl ;
2904 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2906 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2908 GraphBase::OutPort *anOutPort ;
2909 anOutPort = aNode->GetChangeOutPort( aPort );
2910 if ( anOutPort == NULL ) {
2911 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2913 anOutPort = anInPort->GetOutPort() ;
2915 cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
2920 aRet = anOutPort->PortState() ;
2921 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2925 cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
2933 #define TracePortInOutData 0
2934 //JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
2935 const CORBA::Any GraphBase::Graph::PortInData( const char* ToNodeName ,
2936 const char* ToServiceParameterName ) {
2937 //JR 30.03.2005 const CORBA::Any * aRet = new CORBA::Any() ;
2938 CORBA::Any aRet = CORBA::Any() ;
2941 #if TracePortInOutData
2942 cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
2943 << ToServiceParameterName << endl ;
2945 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
2947 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2950 GraphBase::OutPort *anOutPort = NULL ;
2951 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2953 anOutPort = anInPort->GetOutPort() ;
2955 #if TracePortInOutData
2956 cdebug << "-->PortInData " << ToNodeName << " " << ToServiceParameterName << " "
2959 aRet = anOutPort->Value() ;
2960 #if TracePortInOutData
2961 cdebug << "<--PortInData " << ToNodeName << " " << ToServiceParameterName << " " ;
2962 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
2964 cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
2965 << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
2966 << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
2970 cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
2971 << ToServiceParameterName << " ERROR no OutPort" << endl ;
2975 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2976 << ToServiceParameterName << " ERROR no InPort" << endl ;
2980 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2981 << ToServiceParameterName << " ERROR no Node" << endl ;
2985 #if TracePortInOutData
2986 cdebug_out << "GraphBase::Graph::PortInData " << endl ;
2991 //JR 30.03.2005const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
2992 const CORBA::Any GraphBase::Graph::PortOutData( const char* FromNodeName ,
2993 const char* FromServiceParameterName ) {
2994 //JR 30.03.2005 const CORBA::Any * aRet = new CORBA::Any() ;
2995 CORBA::Any aRet = CORBA::Any() ;
2998 #if TracePortInOutData
2999 cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3000 << FromServiceParameterName << endl ;
3002 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
3004 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
3007 GraphBase::OutPort *anOutPort ;
3008 anOutPort = aNode->GetChangeOutPort( aPort );
3010 #if TracePortInOutData
3011 cdebug << "-->PortOutData " << FromNodeName << " " << FromServiceParameterName << " "
3014 aRet = anOutPort->Value() ;
3015 #if TracePortInOutData
3016 cdebug << "<--PortOutData " << FromNodeName << " " << FromServiceParameterName << " " ;
3017 anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
3022 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3023 << FromServiceParameterName << " ERROR no OutPort" << endl ;
3027 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
3028 << FromServiceParameterName << " ERROR no Node" << endl ;
3032 #if TracePortInOutData
3033 cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
3038 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
3039 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
3040 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
3042 RetVal->length( _NodesNumber[ aLevel ] + 1 );
3043 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
3044 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
3047 return ( RetVal._retn() ) ;
3050 bool GraphBase::Graph::StartComponent(const int aThread ,
3051 const char * aComputerContainer ,
3052 const char * ComponentName ,
3053 Engines::Container_var & myContainer ,
3054 Engines::Component_var & objComponent ) {
3055 cdebug_in << aThread
3056 << " GraphBase::Graph::StartComponent " << aComputerContainer
3057 << " " << ComponentName << endl;
3058 bool RetVal = true ;
3060 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
3061 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
3063 if ( CORBA::is_nil( objComponent ) ) {
3064 cdebug_out << aThread
3065 << " StartComponent cannot FindOrLoad " << aComputerContainer
3066 << " " << ComponentName << " ERROR" << endl;
3069 /* asv : 24.01.05 : FindContainer() method does not exist any more. FindOrLoad_Component()
3070 starts the container for us. If it fails to start the container, then it
3071 returns nil component. We don't need to check for if the container was
3072 successfully started..
3074 myContainer = LCC.FindContainer( aComputerContainer );
3075 if ( CORBA::is_nil( myContainer ) ) {
3076 cdebug_out << aThread
3077 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
3078 << aComputerContainer << "' ) Container does not exist ERROR"
3084 cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;