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 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
434 if ( toPort->IsEndSwitch() ) {
435 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
438 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
443 // cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
444 // << fromPort->PortName() << " ) " << fromPort->PortStatus()
445 // << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
446 // << " " << toPort->PortStatus() << " " << fromPort->InPortsSize()
447 // << " ports ignored" << endl ;
453 cdebug_out << "Graph::GetLinks( " << AllLinks << " ) " << endl ;
457 GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const {
458 GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs;
463 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
464 GraphBase::InPort* toPort ) {
465 GraphBase::SLink * _link = new GraphBase::SLink ;
466 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
467 //JR 24.02.2005 Memory Leak _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
468 _link->FromNodeName = string( fromPort->NodeName() );
469 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
470 //JR 24.02.2005 Memory Leak _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
471 _link->ToNodeName = string( toPort->NodeName() );
472 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
473 CORBA::Any aSPValue = *fromPort->Value() ;
474 _link->aLinkValue = aSPValue;
475 _link->aListOfCoords = *(toPort->Coords()) ;
478 //----------------------------------------------------------------------
479 // Function : GetDatas
480 // Purpose : get the datas list
481 //----------------------------------------------------------------------
482 GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
483 GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks;
486 const GraphBase::DataNode * aDataNode = this ;
488 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
489 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
490 if ( GraphMacroLevel() == 0 ) {
491 if ( fromDataPort->IsDataConnected() ) {
493 //We may have SharedData as input of a DataFlow : same input for one or several
494 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
495 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
496 _list_datalinks->resize( ind+1 );
497 //JR 24.02.2005 Memory Leak (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
498 (*_list_datalinks)[ind].FromNodeName = string( aDataNode->Name() );
499 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
500 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
501 //JR 24.02.2005 Memory Leak (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
502 (*_list_datalinks)[ind].ToNodeName = string( toPort->NodeName() );
503 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
504 CORBA::Any aSPValue = *fromDataPort->Value() ;
505 (*_list_datalinks)[ind].aLinkValue = aSPValue;
506 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
512 return _list_datalinks ;
515 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
516 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl;
517 bool RetVal = false ;
518 int index = GetGraphNodeIndex( aNode->Name() ) ;
520 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ;
521 _GraphNodes.resize( _GraphNodesSize+1 ) ;
522 _GraphNodes[ _GraphNodesSize ] = aNode ;
523 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
524 _GraphNodesSize += 1 ;
525 if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) {
526 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ;
529 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName()
530 << " was already in MapOfServices" << endl ;
535 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ;
536 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
537 const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ;
539 cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
542 cdebug << i << ". ERROR" << endl ;
545 aNode->GraphOfNode( this ) ;
547 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
548 << aNode->ServiceName() << endl;
552 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
553 const char* NewNodeName ) {
554 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
557 bool RetVal = false ;
559 GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
560 for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
561 cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ;
564 if ( !strcmp( OldNodeName , NewNodeName ) ) {
567 else if ( strcmp( Name() , OldNodeName ) ) {
568 int index = GetGraphNodeIndex( OldNodeName ) ;
569 int newindex = GetGraphNodeIndex( NewNodeName ) ;
570 if ( index >= 0 && index < _GraphNodesSize &&
571 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
572 _GraphNodes[ index ]->Name( NewNodeName ) ;
573 _MapOfGraphNodes.erase( OldNodeName ) ;
574 SetGraphNodeIndex( NewNodeName , index ) ;
576 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
577 // Update 'ToNode's Map from 'aNode'
578 cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize : "
579 << aNode->LinkedNodesSize() << endl ;
580 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
581 GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
582 ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
584 // Rename in _MapOfLinkedNodes of 'FromNode'
585 cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedFromNodesSize : "
586 << aNode->LinkedFromNodesSize() << endl ;
587 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
588 GraphBase::StreamNode * FromNode = aNode->LinkedFromNodes( i ) ;
589 if ( FromNode->GetLinkedNodeIndex( OldNodeName ) >= 0 ) {
590 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
593 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
596 // Inports 'anInPort' of 'aNode'
597 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
598 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
599 // OutPort 'anOutPort' linked to 'anInPort'
600 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
601 cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
603 cdebug << anOutPort->NodeName() ;
606 cdebug << "without link" ;
608 cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
609 if ( !anInPort->IsNotConnected() ) {
610 if ( anOutPort->IsDataConnected() ) {
611 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
614 // Node 'FromNode' of 'anOutPort'
615 GraphBase::ComputingNode * FromNode ;
616 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
617 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
622 cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
624 //JR 26.01.2005 : a same node may be renamed severeal times. So this is done above
625 // Rename in _MapOfLinkedFromNodes of 'FromNode'
626 if ( anInPort->IsDataStream() ) {
627 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
630 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
634 char* OldNodePortName = new char[ strlen( OldNodeName ) +
635 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
636 char* NewNodePortName = new char[ strlen( NewNodeName ) +
637 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
638 strcpy( OldNodePortName , OldNodeName ) ;
639 // strcat( OldNodePortName , "\\" ) ;
640 strcat( OldNodePortName , "__" ) ;
641 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
642 strcpy( NewNodePortName , NewNodeName ) ;
643 // strcat( NewNodePortName , "\\" ) ;
644 strcat( NewNodePortName , "__" ) ;
645 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
646 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
647 delete [] OldNodePortName ;
648 delete [] NewNodePortName ;
653 cdebug << " not connected" << endl ;
658 //JR 02.02.2005 DEBUG : ReName in the CoupledNode was missing
659 if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() ||
660 aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
661 GraphBase::GOTONode * theCoupledNode = NULL ;
662 theCoupledNode = (GraphBase::GOTONode * ) ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
663 theCoupledNode->CoupledNodeName( aNode->Name() ) ;
665 else if ( aNode->IsInLineNode() ) {
666 GraphBase::OutPort * anOutPort = aNode->GetNodeInGate()->GetOutPort() ;
668 GraphBase::ComputingNode * aLinkedNode ;
669 aLinkedNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
670 if ( aLinkedNode->IsGOTONode() ) {
671 ((GraphBase::GOTONode * ) aLinkedNode)->CoupledNodeName( aNode->Name() ) ;
677 cdebug << "ERROR Node not found" << endl ;
681 RetVal = Name( NewNodeName ) ;
684 cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
688 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
689 cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << endl;
691 bool RetVal = false ;
692 int index = GetGraphNodeIndex( aNodeName ) ;
693 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
695 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
696 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
697 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
698 << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode() << endl ;
699 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
700 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
701 << aNode->LinkedNodes( i )->Name() << endl ;
703 if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted
704 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
705 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
706 << aNode->LinkedFromNodes( i )->Name() << endl ;
709 if ( !aNode->IsEndSwitchNode() ) {
710 if ( aNode->GetNodeInPortsSize() ) {
711 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
712 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
713 cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
714 << anInPort->PortStatus() << " <-- " ;
715 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
716 if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
717 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
720 if ( !anInPort->IsNotConnected() ) {
722 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
723 cdebug << " Data/Extern" << endl ;
726 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
727 cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
728 << FromNode->LinkedNodesSize() << " and " << aNode->Name()
729 << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
730 // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
731 // JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode
732 // if ( !FromNode->IsOneOfGOTONodes() ) {
733 // if ( !FromNode->IsGOTONode() ) {
734 if ( !FromNode->IsGOTONode() &&
735 !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
736 if ( anInPort->IsDataStream() ) {
737 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
740 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
743 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
748 RetVal = anOutPort->RemoveInPort( anInPort ) ;
750 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
764 // Special case of EndSwitchNodes : each Input port must be multi-connected.
765 // There is one link for each branch of the switch
766 // But in GraphBase::InPort there is only one field GraphBase::OutPort *
767 // At execution time there is no problem because only one branch of the switch
768 // may be executed and the Executor set the right OutPort in the field
769 // GraphBase::OutPort * of each InPort of the EndSwitchNode
770 // But here we must remove that node EndSwitch from the LinkedNodes field of
771 // terminal nodes of all branches.
772 // And also in the OutPorts of that terminal nodes of branches we must remove
773 // references to InPorts of the EndSwitchNode.
775 // Explore LinkedFromnodes of the EndSwitchNode :
776 for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) {
777 GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ;
778 cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ;
780 for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
781 GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
782 cdebug << "OutPort" << j << ". Remove " << anOutPort->InPortsSize()
783 << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
784 << anOutPort->PortName() << ") "
785 << anOutPort->PortStatus() << " :" << endl ;
787 for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) {
788 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
789 if ( !strcmp( anInPort->NodeName() , aNode->Name() ) ) {
790 // InPort of the EndSwitchNode
791 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
792 << anInPort->PortName() << ") "
793 << anInPort->PortStatus() << endl ;
794 anInPort->RemoveOutPort() ;
795 if ( anOutPort->IsDataStream() ) {
796 aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ;
799 // false ==> No error for aNode->LinkedFromNode()
800 RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
802 cdebug << "aLinkedFromNode->RemoveLinkedNode Error RetVal " << RetVal << endl ;
806 // Remove the InPort of the EndSwitchNode from that OutPort
807 RetVal = anOutPort->RemoveInPort( anInPort ) ;
809 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
819 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
820 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
821 cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
822 << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
823 << anOutPort->PortStatus() << " :" << endl ;
825 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
826 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
827 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
828 << anInPort->PortStatus() << endl ;
829 if ( !anInPort->IsExternConnected() ) {
830 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
831 RetVal = anInPort->RemoveOutPort() ;
832 // JR 04.02.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
835 cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
838 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
839 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
841 else if ( anOutPort->IsDataStream() ) {
842 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
845 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
848 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
851 RetVal = anOutPort->RemoveInPort( anInPort ) ;
853 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
856 if ( ToNode->IsEndSwitchNode() ) {
859 for ( i = 0 ; i < ToNode->LinkedFromNodesSize() ; i++ ) {
860 GraphBase::StreamNode * fromNode = ToNode->LinkedFromNodes( i ) ;
861 // Not the node that we are deleting ... :
862 if ( strcmp( fromNode->Name() , aNode->Name() ) ) {
864 for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
865 GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
867 for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
868 if ( strcmp( ToNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
869 if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
870 // Restore an OutPort in the InPort
871 anInPort->ChangeOutPort( fromOutPort ) ;
872 cdebug << "Graph::RemoveNode reestablish " << fromOutPort->NodeName() << "( "
873 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
874 << ToNode->Name() << "( " << anInPort->PortName() << " )"
875 << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
894 cdebug << "Error RetVal " << RetVal << endl ;
899 if ( aNode->LinkedNodesSize() || aNode->LinkedFromNodesSize() ) {
902 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
903 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
904 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
905 << " LinkedFromNodes " << endl ;
906 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
907 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
908 << aNode->LinkedNodes( i )->Name() << endl ;
910 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
911 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
912 << aNode->LinkedFromNodes( i )->Name() << endl ;
914 // Delete of aNode from the Graph :
915 // The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted
916 // when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode
917 if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) {
918 GraphBase::InLineNode * theCoupledNode = NULL ;
919 char * theCoupledNodeName = NULL ;
920 int CoupledIndex = -1 ;
921 if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
922 theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
923 theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
925 cdebug << "Node" << index << " " << _GraphNodes[ index ]->Name() << " will be deleted"
928 _GraphNodesSize -= 1 ;
929 for ( i = index ; i < _GraphNodesSize ; i++ ) {
930 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
931 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
933 _GraphNodes.resize( _GraphNodesSize+1 ) ;
934 _MapOfGraphNodes.erase( aNodeName ) ;
935 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
936 if ( theCoupledNode ) {
937 //JR 02.02.2005 DEBUG : CoupledIndex must be here after the delete of aNode (not before)
938 CoupledIndex = GetGraphNodeIndex( theCoupledNodeName ) ;
939 cdebug << "CoupledNode" << CoupledIndex << " " << _GraphNodes[ CoupledIndex ]->Name()
940 << " will be deleted" << endl ;
941 delete theCoupledNode ;
942 _GraphNodesSize -= 1 ;
943 for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
944 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
945 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
947 _GraphNodes.resize( _GraphNodesSize+1 ) ;
948 _MapOfGraphNodes.erase( theCoupledNodeName ) ;
954 cdebug << "Node not found ERROR " << index << endl ;
958 cdebug << "Graph::RemoveNode " << _GraphNodesSize << " known nodes" << endl;
959 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
960 cdebug << "Node" << i << _GraphNodes[ i ]->Name() << endl ;
962 map< string , int >::iterator aMapOfGraphNodesIterator ;
964 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
965 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
966 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
967 << aMapOfGraphNodesIterator->second << " - 1" << endl ;
971 cdebug_out << "Graph::RemoveNode " << RetVal << endl;
975 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
976 const char* FromServiceParameterName ,
977 const char* ToNodeName ,
978 const char* ToServiceParameterName ) {
979 // , const CORBA::Any aValue ) {
982 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
983 << FromServiceParameterName << ") ---> " << ToNodeName << "("
984 << ToServiceParameterName << ") , aValue )" << endl;
986 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
987 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
989 GraphBase::OutPort *fromPort = NULL ;
990 GraphBase::InPort *toPort = NULL ;
993 // asv : 29.12.04 : as I understand, replacement of "InitLoop" by "DoLoop" was
994 // done by JR in order to keep old graphs and batch test scripts working after change
995 // of special Loop's port name from "InitLoop" to "DoLoop". I suppose, it is not
996 // needed, all old graphs and tests must be changed to use "DoLoop" name for addressing
997 // this port.. It we don't do it, ANY port with "InitLoop" name will be replaced by "DoLoop"
998 // and it can cause unexpected bugs in future... So I comment out the replacement code.
999 //if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
1000 //JR 12.01.05 : Yes the test is not good ; now I test that PortName only in LoopNodes ==>
1001 // + old graphs will runs normally (it is not possible to ask CEA to edit their graphs)
1002 // + in old graphs "InitLoop" and "DoLoop" were reserved parameter names (but not controlled)
1003 // + in new graphs, I have added a control at port creation of that names : they are refused
1004 if ( !(fromNode->IsLoopNode() && strcmp( FromServiceParameterName , "InitLoop" ) == 0 ) ) {
1005 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1008 fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
1011 cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
1012 << FromNodeName << ") not found." << endl ;
1016 cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
1019 // see comment above
1020 // if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
1021 if ( !(toNode->IsLoopNode() && strcmp( ToServiceParameterName , "InitLoop" ) == 0 ) ) {
1022 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1025 toPort = toNode->GetChangeInPort( "DoLoop" ) ;
1028 cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
1029 << ToNodeName << ") not found." << endl ;
1033 cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
1036 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
1039 if ( fromPort->IsGate() && toPort->IsGate() ) {
1041 aValue <<= (long ) 1 ;
1042 fromPort->Value( aValue ) ;
1045 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
1046 // fromPort->Value( aDataValue ) ;
1048 // fromPort->PortStatus( DataConnected );
1051 cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
1055 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
1056 GraphBase::OutPort *fromPort ,
1057 GraphBase::ComputingNode *toNode ,
1058 GraphBase::InPort *toPort ) {
1062 cdebug << "ERROR AddLink fromNode not found." << endl ;
1066 cdebug << "ERROR AddLink fromPort not found." << endl ;
1071 cdebug << "ERROR AddLink toNode not found." << endl ;
1075 cdebug << "ERROR AddLink toPort not found." << endl ;
1078 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
1079 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
1080 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
1083 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
1084 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
1085 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
1089 cdebug_in << "Graph::AddLink( " << fromNode->Name() << "("
1090 << fromPort->PortName() << " " << fromPort->PortStatus() << ") " << fromPort->Kind()
1091 << " ---> " << toNode->Name() << "(" << toPort->PortName() << " " << toPort->PortStatus()
1092 << ") " << toPort->Kind() << " )" << endl;
1093 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
1094 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1095 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
1096 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
1100 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1101 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
1102 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
1103 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
1107 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
1108 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1109 toPort->GetOutPort()->PortName() ,
1110 toNode->Name() , toPort->PortName() ) ) {
1111 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
1116 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
1117 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1118 toPort->GetOutPort() ) {
1119 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
1120 fromPort->NodePortName() ) ) {
1121 cdebug << "Link already exists" << endl ;
1122 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1125 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
1126 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
1128 else if ( fromNode->IsGOTONode() ) {
1129 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1130 toPort->GetOutPort()->PortName() ,
1131 toNode->Name() , toPort->PortName() ) ) {
1132 cdebug << "RemoveLink(AddLink) Error."
1134 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1137 if ( fromPort->InPortsSize() ) {
1138 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1139 fromPort->ChangeInPorts(0)->NodeName() ,
1140 fromPort->ChangeInPorts(0)->PortName() ) ) {
1141 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1142 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1147 // JR 17.01.2005 : toPort is already linked : RemoveLink
1148 else if ( !toNode->IsEndSwitchNode() ) {
1149 // else if ( !toNode->IsEndSwitchNode() ||
1150 // ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
1151 // Debug : the fromPort was wrong !
1152 // if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1153 if ( !RemoveLink( toPort->GetOutPort()->NodeName() , toPort->GetOutPort()->PortName() ,
1154 toNode->Name() , toPort->PortName() ) ) {
1155 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
1156 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1160 //JR 15.-2.2005 : Not multiple links in that case except if toPort is the DefaultPort
1161 else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1162 cdebug << "fromNode->IsSwitchNode() && toNode->IsEndSwitchNode Error." << endl ;
1163 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1167 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
1168 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1169 fromPort->ChangeInPorts(0)->NodeName() ,
1170 fromPort->ChangeInPorts(0)->PortName() ) ) {
1171 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1172 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1176 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
1177 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
1178 fromPort->RemoveInPort( toPort ) ; //dbg
1180 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
1181 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
1182 fromPort->RemoveInPort() ; // There is only one
1186 // JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate
1187 if ( !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
1188 fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) {
1189 cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ;
1190 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1193 //JR 11.02.2005 : SwitchNode(Default) may be only linked to EndSwitchNode(Default)
1194 // SwitchNode(Param) may be linked to EndSwitchNode(Param)
1195 // SwitchNode(Param-UserDefault) may be linked to EndSwitchNode(Default)
1196 else if ( fromNode->IsSwitchNode() && toNode->IsEndSwitchNode() &&
1197 !( ( fromPort->IsGate() && toPort->IsGate() ) ||
1198 ( !fromPort->IsGate() ) ) ) {
1199 // ( !fromPort->IsGate() && !toPort->IsGate() ) ) ) {
1200 cdebug << "SwitchNode(Default) may be only linked to EndSwitchNode(Default) AddLink Error."
1202 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1205 else if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1206 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
1207 if ( !fromPort->AddInPort( toPort ) ) {
1208 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
1210 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1213 if ( !toPort->IsDataStream() ) {
1214 toPort->Kind( SUPERV::EndSwitchParameter ) ;
1217 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
1218 cdebug << "!fromPort->AddLink Error." << endl ;
1219 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1223 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
1224 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
1225 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
1226 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1229 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
1230 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
1231 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1234 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
1235 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
1236 cdebug << "toPort->AddLink Error." << endl ;
1237 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1242 toPort->AddOutPort( fromPort ) ;
1245 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
1246 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
1247 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
1248 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
1249 << fromNode->Name() << " " << fromPort->PortName()
1250 << " InLineNode/LoopNode_ConnectedInPortsNumber "
1251 << toNode->ConnectedInPortsNumber() << endl;
1252 if ( fromNode->IsGOTONode() ) {
1253 fromPort->Kind( SUPERV::GOTOParameter ) ;
1255 fromPort->PortStatus( PortConnected ); // GOTO - Loop
1257 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
1258 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
1259 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1260 fromPort->PortStatus( ExternConnected );
1262 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
1263 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
1264 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1265 fromPort->PortStatus( ExternConnected ) ;
1268 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
1269 << fromNode->Name() << " " << fromPort->PortName() << " "
1270 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
1271 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
1272 fromPort->PortStatus( PortConnected );
1273 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
1274 fromNode->AddStreamLinkedNode( toNode ) ;
1277 fromNode->AddLinkedNode( toNode ) ;
1280 if ( fromNode->IsSwitchNode() ) {
1281 if ( !fromPort->IsDataStream() ) {
1282 //JR 08.02.2005 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1283 if ( fromPort->IsInLine() && toPort->IsGate() ) {
1284 fromPort->Kind( SUPERV::SwitchParameter ) ;
1286 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
1287 fromPort->Kind( SUPERV::InLineParameter ) ;
1290 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1291 GraphBase::InLineNode * anEndSwitchNode ;
1292 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1293 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1294 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1295 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1296 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1297 anOutPort->IsGate() ) {
1298 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1299 anEndSwitchNode->Name() ,
1300 anInPort->PortName() ) ) {
1301 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1303 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1309 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1310 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1314 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1315 const char* FromServiceParameterName ,
1316 const char* ToNodeName ,
1317 const char* ToServiceParameterName ) {
1318 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1319 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1320 bool RetVal = false ;
1321 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1323 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1324 if ( anInPort && ( anInPort->IsPortConnected() ||
1325 anInPort->IsDataConnected() ||
1326 anInPort->IsExternConnected() ) ) {
1327 // JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The OutPort may be an other one !!!
1328 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1329 GraphBase::OutPort * anOutPort = NULL ;
1330 if ( toNode->IsEndSwitchNode() ) {
1331 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1332 RetVal = anOutPort->RemoveInPort( anInPort ) ;
1335 anOutPort = anInPort->GetOutPort() ;
1336 RetVal = anOutPort->RemoveInPort( anInPort ) ;
1338 // anInPort->RemoveOutPort() ; // Already done in RemoveInPort
1339 // const char * FromNodeName = anOutPort->NodeName() ;
1342 if ( anInPort->IsDataStream() ) {
1343 fromNode->RemoveStreamLinkedNode( toNode ) ;
1346 fromNode->RemoveLinkedNode( toNode ) ;
1349 //JR 7990 : a SwitchPort is an OutPort of a SwitchNode connected to a InGate Port
1350 //Debug : change the kind only if there is no other InGate connected to the OutPort
1351 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && anOutPort->InPortsSize() == 0 ) {
1352 if ( !toNode->IsEndSwitchNode() ) {
1353 anOutPort->Kind( SUPERV::InLineParameter ) ;
1355 else if ( !anInPort->IsGate() ) {
1356 anOutPort->Kind( SUPERV::InLineParameter ) ;
1359 // JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be multiple linked !!!
1360 if ( toNode->IsEndSwitchNode() ) {
1363 for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) {
1364 GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ;
1366 for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) {
1367 GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ;
1369 for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) {
1370 if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) {
1371 if ( strcmp( anInPort->PortName() , fromOutPort->InPorts( k )->PortName() ) == 0 ) {
1372 // Restore an OutPort in the InPort
1373 anInPort->ChangeOutPort( fromOutPort ) ;
1374 cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( "
1375 << fromOutPort->PortName() << " ) in the InPort of EndSwitch : "
1376 << toNode->Name() << "( " << anInPort->PortName() << " )"
1377 << anInPort->Kind() << " " << anInPort->PortStatus() << endl;
1395 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1399 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1400 const char* ToServiceParameterName ,
1401 char** FromNodeName ,
1402 char** FromServiceParameterName ) {
1403 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1404 // << ToServiceParameterName << ")" << endl;
1405 bool RetVal = false ;
1406 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1408 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1409 if ( anInPort && !anInPort->IsNotConnected() ) {
1410 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1411 //JR 17.02.2005 Memory Leak *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1412 *FromNodeName = (char * ) anOutPort->NodeName() ;
1413 //JR 17.02.2005 Memory Leak *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1414 *FromServiceParameterName = (char * ) anOutPort->PortName() ;
1418 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1419 << " " << ToServiceParameterName << " " << RetVal << endl;
1423 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1426 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1430 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1431 const char* ToServiceParameterName ,
1432 const CORBA::Any aValue ) {
1433 bool RetVal = false ;
1434 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1435 << ToServiceParameterName << " , Any " ;
1436 switch (aValue.type()->kind()) {
1437 case CORBA::tk_string:
1440 cdebug << t << " (string) " ;
1442 case CORBA::tk_double:
1445 cdebug << d << " (double) " ;
1447 case CORBA::tk_long:
1450 cdebug << l << " (long) " ;
1452 case CORBA::tk_objref:
1453 cdebug << "(object reference) " ;
1456 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1457 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1460 cdebug << " ) in Graph " << Name() << endl;
1462 GraphBase::ComputingNode *toNode ;
1463 GraphBase::InPort *toPort ;
1466 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1467 toNode = GetChangeGraphNode( aNodeName ) ;
1468 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1470 toPort = toNode->GetChangeInPort( aPortName ) ;
1471 if ( toPort && !toPort->IsDataConnected() ) {
1472 toPort->RemoveOutPort() ;
1480 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1481 cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1483 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1484 cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1487 if ( toNode && toPort ) {
1488 GraphBase::OutPort *fromDataNodePort = NULL ;
1489 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1490 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1491 fromDataNodePort->RemoveInPort( toPort ) ;
1493 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1494 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1495 << toPort->PortName() << " )" << endl ;
1496 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1499 fromDataNodePort->Value( aValue ) ;
1500 fromDataNodePort->PortStatus( DataConnected ) ;
1504 cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1509 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1513 // Used in the Executor in order to change an Input Value and ReRun
1514 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1515 const char * ToServiceParameterName ,
1516 const CORBA::Any aValue ) {
1517 bool RetVal = false ;
1518 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1519 << ToServiceParameterName << "' , Any " ;
1520 switch (aValue.type()->kind()) {
1521 case CORBA::tk_string:
1524 cdebug << t << " (string) " ;
1526 case CORBA::tk_double:
1529 cdebug << d << " (double) " ;
1531 case CORBA::tk_long:
1534 cdebug << l << " (long) " ;
1536 case CORBA::tk_objref:
1537 cdebug << "(object reference) " ;
1540 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1543 cdebug << " ) in Graph " << Name() << endl;
1545 GraphBase::ComputingNode * toNode ;
1546 GraphBase::InPort * toPort = NULL ;
1549 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1550 toNode = GetChangeGraphNode( aNodeName ) ;
1551 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1553 toPort = toNode->GetChangeInPort( aPortName ) ;
1554 if ( toPort && toPort->IsDataConnected() ) {
1555 GraphBase::OutPort * fromPort = toPort->GetOutPort();
1558 fromPort->Value( aValue ) ;
1559 fromPort->PortStatus( DataConnected ) ;
1560 toPort->PortState( SUPERV::ReadyState ) ;
1563 cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1567 cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1571 cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1574 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1579 // To restore InputData in CreateService
1580 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1581 const char* ToServiceParameterName ,
1582 const CORBA::Any ** aValue ) {
1583 bool RetVal = false ;
1584 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1585 << ToServiceParameterName << ", **Any " ;
1586 const CORBA::Any theValue = **aValue ;
1587 switch (theValue.type()->kind()) {
1588 case CORBA::tk_string:
1591 cdebug << t << " (string) " ;
1593 case CORBA::tk_double:
1596 cdebug << d << " (double) " ;
1598 case CORBA::tk_long:
1601 cdebug << l << " (long) " ;
1603 case CORBA::tk_objref:
1604 cdebug << "(object reference) " ;
1607 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1610 cdebug << ") of Graph " << Name() << endl;
1612 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1615 GraphBase::InPort *toPort = NULL ;
1616 GraphBase::OutPort *fromDataNodePort = NULL ;
1617 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1618 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1619 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1620 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1621 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1624 fromDataNodePort->Value( aValue ) ;
1625 fromDataNodePort->PortStatus( DataConnected ) ;
1629 cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1630 map< string , int >::iterator aMapOfGraphNodesIterator ;
1632 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1633 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1634 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1635 << aMapOfGraphNodesIterator->second << endl ;
1639 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1644 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1645 const char* FromServiceParameterName ,
1646 const CORBA::Any aValue ) {
1647 bool RetVal = true ;
1648 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1649 << FromServiceParameterName << ")" << endl;
1650 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1652 GraphBase::OutPort *anOutPort = NULL ;
1655 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1656 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1657 // RetVal = AddLink( fromNode , fromPort ,
1658 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1659 anOutPort->Value( aValue ) ;
1660 anOutPort->PortState( SUPERV::ReadyState ) ;
1661 anOutPort->PortDone( true ) ;
1662 cdebug << *anOutPort ;
1664 anOutPort->StringValue( *_fdebug ) ;
1669 cdebug << "ERROR Node not found" << endl ;
1672 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1676 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1677 return _MapOfServiceNames ; }
1679 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1680 return _MapOfServiceNames[ name ] ;
1683 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1684 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1686 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1687 << " already in MapOfServiceNames : erase" << endl ;
1688 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1690 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1691 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1695 int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
1696 GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
1697 if ( theService == NULL ) {
1700 return theService->NewInstance() ;
1703 void GraphBase::Graph::SetGraphPorts() {
1704 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1706 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1707 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1708 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1709 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->PortState() << endl ;
1710 if ( !anOutPort->IsGate() ) {
1711 anOutPort->PortStatus( ExternConnected ) ;
1714 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1715 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1716 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1717 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->PortState() << endl ;
1718 if ( !anInPort->IsGate() ) {
1719 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1720 anOutPort->PortStatus( ExternConnected ) ;
1723 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1726 bool GraphBase::Graph::CreateService() {
1727 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1728 bool RetVal = true ;
1729 SALOME_ModuleCatalog::Service aService ;
1731 GraphBase::ComputingNode * aToNode ;
1734 int instreamnbr = 0 ;
1736 int outstreamnbr = 0 ;
1737 vector< SUPERV::KindOfPort > InPortsKind ;
1738 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1739 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1740 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1741 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1742 vector< SUPERV::KindOfPort > OutPortsKind ;
1743 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1744 vector< long > OutNumberOfValues ;
1745 // if ( GraphMacroLevel() == 0 ) {
1746 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1747 if ( dostore == 1 ) {
1748 //JR 17.02.2005 Memory Leak aService.ServiceName = Name() ;
1749 aService.ServiceName = my_strdup( Name() ) ;
1750 aService.ServiceinParameter.length( 0 ) ;
1751 aService.ServiceinParameter.length( innbr ) ;
1752 aService.ServiceoutParameter.length( 0 ) ;
1753 aService.ServiceoutParameter.length( outnbr ) ;
1754 InPortsKind.resize( innbr ) ;
1755 InDataStreamDependency.resize( innbr ) ;
1756 InKindOfSchema.resize( innbr ) ;
1757 InKindOfInterpolation.resize( innbr ) ;
1758 InKindOfExtrapolation.resize( innbr ) ;
1759 OutPortsKind.resize( outnbr ) ;
1760 OutDataStreamDependency.resize( outnbr ) ;
1761 OutNumberOfValues.resize( outnbr ) ;
1763 else if ( dostore == 2 ) {
1764 //JR Creation of the Service (and of the Ports) with GraphBase::DataNode::DataService :
1765 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1766 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1767 << " outstreamnbr " << outstreamnbr << endl ;
1768 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1769 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1770 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1771 InPortsKind.resize( innbr + instreamnbr ) ;
1772 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1773 InKindOfSchema.resize( innbr + instreamnbr ) ;
1774 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1775 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1776 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1777 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1778 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1780 if ( dostore == 0 ) {
1786 if ( dostore == 1 ) {
1790 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1791 aToNode = GraphNodes( i ) ;
1792 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1793 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1794 bool isfromcouplednode = false ;
1795 if ( !anInPort->IsNotConnected() ) {
1796 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1797 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1798 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1799 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1800 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1801 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1802 isfromcouplednode = true ;
1805 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1806 ( !anInPort->IsPortConnected() ||
1807 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1808 if ( dostore == 0 ) {
1809 cdebug << "CreateService " << aToNode->Name() << " Input port "
1810 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1811 if ( anInPort->GetOutPort() ) {
1812 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1815 if ( anInPort->IsDataStream() ) {
1822 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1823 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1824 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1825 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1826 InPortsKind[ innbr ] = anInPort->Kind() ;
1827 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1828 if ( dostore == 2 && anInPort->IsDataStream() ) {
1829 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1830 InKindOfInterpolation[ innbr ] ,
1831 InKindOfExtrapolation[ innbr ] ) ;
1833 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1834 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1838 else if ( dostore == 0 ) {
1839 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1840 << " " << anInPort->PortStatus() ;
1841 if ( anInPort->IsPortConnected() ) {
1842 cdebug << " is connected " ;
1845 cdebug << " is NOT connected " ;
1847 if ( anInPort->IsGate() ) {
1848 cdebug << " IsGate " ;
1850 if ( anInPort->GetOutPort() ) {
1851 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1854 cdebug << "NOT DataConnected" ;
1859 GraphBase::ComputingNode * aFromNode = aToNode ;
1860 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1861 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1862 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1863 // if ( anOutPort ) {
1864 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1867 // cdebug << " NULL" << endl ;
1869 if ( !aFromNode->IsGOTONode() ) {
1870 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
1871 anOutPort->IsExternConnected() ) {
1872 if ( dostore == 0 ) {
1873 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1874 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1875 if ( anOutPort->IsDataStream() ) {
1882 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1883 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1884 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1885 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1886 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1887 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1888 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1889 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1891 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1892 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1903 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1904 << " OutPorts " << outnbr << endl ;
1905 for ( i = 0 ; i < innbr ; i++ ) {
1906 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1907 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1908 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1909 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1910 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1913 for ( i = 0 ; i < outnbr ; i++ ) {
1914 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1915 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1916 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1917 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1918 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1923 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
1924 for ( i = 0 ; i < innbr ; i++ ) {
1925 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1926 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
1927 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
1928 InDataStreamDependency[ i ] ,
1929 SUPERV::DataStreamParameter ) ;
1930 anInPort->SetParams( InKindOfSchema[ i ] ,
1931 InKindOfInterpolation[ i ] ,
1932 InKindOfExtrapolation[ i ] ) ;
1933 // NOT A BUG : AddOutPort for an inport (Reversed service)
1934 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
1937 aService.ServiceinParameter[ i ].Parametername ,
1938 aService.ServiceinParameter[ i ].Parametertype ,
1939 SUPERV::DataStreamParameter ,
1941 _Graph_prof_debug , _Graph_fdebug ) ;
1942 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
1943 // Attention : revoir les reversed DataStreamPorts
1944 // anInPort->SetParams( InKindOfSchema[ i ] ,
1945 // InKindOfInterpolation[ i ] ,
1946 // InKindOfExtrapolation[ i ] ) ;
1947 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1948 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1952 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1953 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1954 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1955 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1956 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1957 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1961 for ( i = 0 ; i < outnbr ; i++ ) {
1962 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1963 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
1964 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
1965 OutDataStreamDependency[ i ] ,
1966 SUPERV::DataStreamParameter ) ;
1967 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1968 // NOT A BUG : AddInPort for an outport (Reversed service)
1969 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
1972 aService.ServiceoutParameter[ i ].Parametername ,
1973 aService.ServiceoutParameter[ i ].Parametertype ,
1974 SUPERV::DataStreamParameter ,
1976 _Graph_prof_debug , _Graph_fdebug ) ;
1977 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
1978 // Attention : revoir les reversed DataStreamPorts
1979 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1980 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1981 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1985 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1986 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1987 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1988 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1989 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1990 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1991 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1992 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1996 // Restore input datas and links :
1997 DataStreamInPortsNumber( 0 ) ;
1998 DataStreamOutPortsNumber( 0 ) ;
1999 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2000 aToNode = GraphNodes( i ) ;
2001 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
2002 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
2003 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
2004 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
2005 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
2006 if ( !AddInputData( anInPort->NodeName() ,
2007 anInPort->PortName() ,
2008 //JR 21.02.2005 Debug Memory leak : anInPort->GetOutPort()->ValuePtr() ) ) {
2009 *anInPort->GetOutPort()->Value() ) ) {
2010 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2011 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
2015 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2016 << anInPort->PortStatus() << " --> AddInputData" << endl ;
2019 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2020 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
2021 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2022 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
2026 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
2027 << anInPort->PortStatus() << " --> AddInLink" << endl ;
2031 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
2032 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
2033 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
2034 << ") " << anOutPort->PortStatus() << " :" << endl ;
2035 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
2036 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
2037 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
2038 cdebug << " --> " << Name() << "(" << anInPort->PortName()
2039 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
2043 cdebug << " --> " << Name() << "(" << anInPort->PortName()
2044 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
2051 ListPorts( *_Graph_fdebug , 0 ) ;
2054 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
2058 bool GraphBase::Graph::InLineServices() {
2059 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
2064 ListPorts( *_Graph_fdebug , 0 ) ;
2067 GraphBase::InLineNode * aINode ;
2068 SALOME_ModuleCatalog::Service aService ;
2069 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2070 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
2071 if ( aINode->IsOneOfInLineNodes() ) {
2072 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
2073 aService.ServiceName = aINode->ServiceName() ;
2074 aService.ServiceinParameter.length( 0 ) ;
2075 aService.ServiceoutParameter.length( 0 ) ;
2076 aINode->DataStreamInPortsNumber( 0 ) ;
2077 aINode->DataStreamOutPortsNumber( 0 ) ;
2079 int InStreamService = 0 ;
2080 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
2081 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
2083 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2084 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2085 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2086 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
2087 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2088 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2091 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
2092 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
2093 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2094 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2095 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
2096 aINode->IncrDataStreamInPorts() ;
2098 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2099 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2100 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2101 << aINode->GetChangeNodeInPort(j)->PortName() << " "
2102 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2103 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2107 aService.ServiceinParameter.length( InService+1 ) ;
2108 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
2109 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
2111 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
2112 << aINode->GetChangeNodeInPort(j)->Kind() << " "
2113 << aINode->GetChangeNodeInPort(j)->PortType() << " "
2114 << aINode->GetChangeNodeInPort(j)->PortName() << " "
2115 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
2116 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
2120 int OutService = 0 ;
2121 int OutStreamService = 0 ;
2122 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
2123 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2124 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
2126 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2127 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2128 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2129 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
2130 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2131 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2134 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
2135 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
2136 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2137 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2138 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
2139 aINode->IncrDataStreamOutPorts() ;
2141 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2142 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2143 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2144 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2145 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2146 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2150 aService.ServiceoutParameter.length( OutService+1 ) ;
2151 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
2152 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
2154 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
2155 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
2156 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
2157 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
2158 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
2159 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
2163 aINode->SetService( aService ) ;
2164 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
2166 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
2167 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
2168 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
2171 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
2175 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
2179 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
2181 ListPorts( *_Graph_fdebug , 0 ) ;
2186 int NotSortedNumber = GraphNodesSize() ;
2188 cdebug_in << "GraphBase::Graph::Sort" << endl;
2189 if ( NotSortedNumber ) {
2191 _ParallelExecutionNodes = false ;
2192 _Sorted.resize( GraphNodesSize() ) ;
2193 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
2194 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
2195 if ( _NodesNumber.size() ) {
2196 _NodesNumber.resize( 0 ) ;
2197 _SortedNodes.resize( 0 ) ;
2200 // This is a simulation of the computation of the graph :
2201 // The initial state of nodes is :
2202 // - Sorted = false : the node is not sorted
2203 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
2204 // - DecrInPortsNumber = 0 : there is no value available.
2206 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
2207 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2208 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2209 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
2210 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
2211 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
2215 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2216 _Sorted[ i ] = false ;
2217 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
2218 _DecrInPortsNumber[ i ] = 0 ;
2219 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
2220 // << _CnxInPortsNumber[ i ] << endl ;
2223 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
2224 // ==============================================================================
2225 while ( NotSortedNumber ) {
2228 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2229 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
2230 << GraphNodes( i )->Name() << " count "
2231 << _CnxInPortsNumber[ i ] << endl ;
2232 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
2233 // All inputs of GraphNodes( i ) are available : "AllDataReady"
2234 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
2235 _NodesNumber.resize( _LevelsNumber+1 ) ;
2236 _SortedNodes.resize( _LevelsNumber+1 ) ;
2237 _NodesNumber[ _LevelsNumber ] = -1 ;
2239 // There is one more node at that level
2240 _NodesNumber[ _LevelsNumber ]++ ;
2241 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
2242 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
2243 _Sorted[ i ] = true ;
2245 NotSortedNumber -= 1 ;
2246 cdebug << GraphNodes( i )->Name() << " belongs to level "
2247 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
2248 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
2249 // So we loop over all nodes that have a link from that node
2250 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
2251 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
2252 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
2253 // OutputPorts of GraphNodes( i ) will satisfy
2254 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
2255 // GraphNodes( i )->LinkedNodes( j )
2256 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
2257 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
2258 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
2259 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
2260 cdebug << " _DecrInPortsNumber[ "
2261 << GetGraphNodeIndex( aLinkedNode->Name() )
2263 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
2264 << " += " << aLinkedInPortsNumber ;
2265 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
2271 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
2272 // will wait for data(s) from node(s) not executed or not executing for ever
2274 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2275 return false ; // Loop in the Graph
2277 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
2278 bool ChangeCount = false ;
2279 // We update now the number of InPorts with a link that are waiting for a value
2280 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2281 if ( _DecrInPortsNumber[ i ] ) {
2282 // int prevcount = _CnxInPortsNumber[ i ] ;
2283 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
2284 _DecrInPortsNumber[ i ] = 0 ;
2285 ChangeCount = true ;
2286 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
2287 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
2290 // If there is no loop and if the number of InPorts with a link that are waiting for a value
2291 // does not change, the sort is finished. But there is also NotSortedNumber ...
2292 // if ( !ChangeCount )
2294 if ( NotSortedNumber ) {
2295 _LevelsNumber += 1 ;
2299 int AllSortedNodes = 0 ;
2300 _HeadNodes = _SortedNodes[ 0 ] ;
2301 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
2302 // QueueNodes was used in the past in order to know if the execution of a graph is finished
2303 // But because of loop nodes that was changed. So that part of code is a "clutter"
2304 // Now a graph has finished its execution when the number of executing threads is zero
2305 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
2306 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
2307 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
2308 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
2312 if ( i == _QueueNodesSize && _LevelsNumber ) {
2313 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
2314 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
2316 // Computation of the maximum number of threads == the maximum number of nodes of all levels
2317 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2318 AllSortedNodes += _NodesNumber[ i ]+1 ;
2319 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
2320 _ThreadsMax = _NodesNumber[ i ] + 1 ;
2322 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
2323 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
2324 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
2325 _ParallelExecutionNodes = true ;
2326 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
2330 if ( _ParallelExecutionNodes ) {
2331 // cdebug << "Parallel Execution Nodes detected." << endl ;
2334 // cdebug << "No Parallel Execution Nodes detected." << endl ;
2336 if ( AllSortedNodes != GraphNodesSize() ) {
2337 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2338 return false ; // Loop in the Graph
2341 cdebug << "Graph::Sort " << _NodesNumber[ 0 ] << " HeadNodes :" << endl ;
2342 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
2343 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
2344 cdebug << " " << i << ". : " << (_SortedNodes[ 0 ])[ i ]->Name() << endl ;
2347 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
2348 // There is no substreamgraph for nodes without StreamPorts
2349 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
2350 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
2351 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
2352 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
2353 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
2354 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
2357 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2361 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2362 // the SubGraph of that nodes is unknown
2363 // There is no substreamgraph for nodes without StreamPorts
2364 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2365 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2366 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2367 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2368 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2369 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2370 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2373 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2378 // Computation of independent SubGraphs which have NO link between them
2379 cdebug << endl << "Computation of SubGraphs" << endl ;
2380 bool Graphs = true ;
2382 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2383 cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2384 << " Nodes :" << endl ;
2385 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2386 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2387 cdebug << " " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2389 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2390 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2391 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2392 // && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2393 // aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2394 int OldSub = aNode->SubGraph() ;
2395 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2396 cdebug << " " << aNode->Name() << " changed SubGraph "
2397 << aNode->LinkedNodes( k )->SubGraph() << endl ;
2399 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2401 for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2402 if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2403 GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2404 aSubNode->SubGraph( NewSub ) ;
2412 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2413 << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2417 cdebug << " LinkedNode " << aNode->LinkedNodes( k )->Name()
2418 << " initial SubGraph " << aNode->SubGraph() << endl ;
2419 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2431 cdebug << endl << "SubGraphs result : " << endl ;
2434 cdebug << endl << "One more time" << endl ;
2437 // Make a sequential renumbering of SubGraphs :
2438 _SubGraphsNumber = 0 ;
2439 int CurrGraphsNumber = 0;
2441 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2442 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2443 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2444 _SubGraphsNumber += 1 ;
2445 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2446 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2447 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2448 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2449 cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2450 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2458 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2459 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2460 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2461 if ( aNode->SubStreamGraph() < 0 ) {
2462 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2465 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2466 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2467 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2468 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2473 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2474 SubStreamGraphsNumber = 0 ;
2476 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2477 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2479 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2480 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2481 if ( aNode->SubStreamGraph() < 0 ) {
2482 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2483 // << " has NO streamport" << endl ;
2486 int CurStreamGraphsNumber ;
2487 if ( aNode->SubStreamGraph() > 0 ) {
2488 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2489 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2490 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2493 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2496 while ( RetVal != CurStreamGraphsNumber ) {
2497 RetVal = CurStreamGraphsNumber ;
2498 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2499 if ( RetVal != CurStreamGraphsNumber ) {
2500 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2501 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2502 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2503 aNode->SubStreamGraph( RetVal ) ;
2506 CurStreamGraphsNumber = RetVal ;
2509 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2510 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2516 // Make a sequential renumbering of SubGraphs :
2517 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2518 int CurrStreamGraphsNumber = 0 ;
2520 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2521 bool SearchCurrStreamGraphsNumber = true ;
2522 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2524 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2525 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2526 SearchCurrStreamGraphsNumber = false ;
2528 if ( CurrStreamGraphsNumber != count ) {
2529 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2530 // << " Level " << k << " n " << l << endl ;
2531 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2532 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2533 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2534 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2535 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2536 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2538 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2539 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2540 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2541 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2550 SubStreamGraphsNumber = count ;
2551 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2552 // int CurrStreamGraphsNumber ;
2553 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2554 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2555 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2556 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2557 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2558 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2566 ListPorts( *_Graph_fdebug , 0 ) ;
2569 cdebug_out << "GraphBase::Graph::Sort" << endl;
2573 bool GraphBase::Graph::ValidLoops() const {
2574 cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
2577 GraphBase::ComputingNode * aNode ;
2578 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2579 aNode = GraphNodes( i ) ;
2580 if ( aNode->IsLoopNode() ) {
2581 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2582 GraphBase::EndOfLoopNode * anEndLoopNode ;
2583 anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2584 if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
2585 cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
2589 else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
2590 cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
2596 cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
2600 bool GraphBase::Graph::ValidSwitchs() const {
2601 cdebug_in << "GraphBase::Graph::ValidSwitchs" << endl;
2604 GraphBase::ComputingNode * aNode ;
2605 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2606 aNode = GraphNodes( i ) ;
2607 if ( aNode->IsSwitchNode() ) {
2608 GraphBase::SwitchNode * aSwitchNode = (GraphBase::SwitchNode * ) aNode ;
2609 if ( !aSwitchNode->CheckSwitch() ) {
2610 cdebug_out << "GraphBase::Graph::ValidSwitchs false aSwitchNode " << aSwitchNode->Name()
2616 cdebug_out << "GraphBase::Graph::ValidSwitchs true" << endl;
2620 // Controle de la coherence des noeuds de calcul
2621 // Enregistrement dans la liste des noeuds "tete" de graphe
2623 bool GraphBase::Graph::ComputingNodes() const {
2624 bool RetVal = true ;
2625 cdebug << "GraphExecutor::Graph::ComputingNodes ()" << endl;
2627 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2628 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2629 // GraphEditor::Port * iP;
2631 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2632 // while ( aNode != aComputingNodesList.end() ) {
2634 GraphBase::ComputingNode * aNode ;
2635 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2636 aNode = GraphNodes( i ) ;
2637 cdebug << "Graph::ComputingNodes " << i << ". " << aNode->Name() << " Head " << aNode->IsHeadNode()
2639 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2640 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2641 // if ((*aNode)->GetNodeInPortsSize() == 0)
2642 // _headNodes.push_front(*aNode);
2644 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2645 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2646 if ( iP->IsNotConnected() ){
2647 // cdebug << "Le port d'entree " << iP->PortName()
2648 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2649 // << Name() << " n'est pas connecte "<< endl;
2655 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2656 bool oneOutPortConnected = false;
2657 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2658 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2659 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2660 oneOutPortConnected = true ;
2664 // cdebug << "Le port de sortie " << iP->PortName()
2665 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2666 // << Name() << " n'est pas connecte "<< endl;
2670 if (!oneOutPortConnected) {
2671 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2672 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2673 // _computingError.push_front(2);
2676 // return _computingError.size () ;
2680 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2681 bool RetVal = true ;
2684 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2685 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2686 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2687 if ( aNode->IsLoopNode() ) {
2688 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2689 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2690 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2691 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2692 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2693 aLoopNode , anInPort ) ) {
2694 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
2695 // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2696 // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
2704 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2705 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
2706 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2707 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2708 aLoopNode->CoupledNode() , anInPort ) ) {
2709 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
2710 // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2711 // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
2720 else if ( aNode->IsGOTONode() ) {
2721 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2722 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2723 if ( anOutGate->IsNotConnected() ) {
2724 RetVal = aGOTONode->CoupledNode() != NULL;
2726 RetVal = AddLink( aGOTONode , anOutGate ,
2727 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() );
2728 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
2729 // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2730 // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2737 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
2741 // Controle de la coherence des noeuds de calcul
2742 // Enregistrement dans la liste des noeuds "tete" de graphe
2744 bool GraphBase::Graph::DataServerNodes() const {
2746 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
2748 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2749 int i , j , ierr = 0 ;
2751 // if ( DataFlowDatas == NULL ) {
2752 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2756 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2757 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2759 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2761 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2763 ierr = CheckDataServerNodes() ;
2765 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2766 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2767 if ( GraphNodesSize() == 0 ) {
2771 GraphBase::ComputingNode * aNode ;
2772 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2773 aNode = GraphNodes( i ) ;
2774 // while ( aNode != aComputingNodesList.end() ) {
2775 if ( aNode->IsFactoryNode() ) {
2776 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2777 if ( !strlen( FaNode->Computer() ) ) {
2778 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2779 if ( !strlen( FaNode->Computer() ) ) {
2784 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2788 // For Outputs of the DataFlow :
2789 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2790 if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
2791 if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
2792 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2795 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2802 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2804 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2805 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2807 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2808 // while ( it != aDataServerNodesList.end() ) {
2809 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2810 // cerr << "Erreur dans le noeud serveur de donnees "
2811 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2812 // cerr << "A la fois importation et exportation de donnees" << endl;
2813 // _dataServerError.push_front(1);
2816 // if ((*it)->GetNodeOutPortsSize()) {
2817 // if ((*it)->GetNodeOutPortsSize()==1){
2818 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2819 // _headNodes.push_front(*it);
2822 // cerr << "Le port de sortie du noeud serveur de donnees "
2823 // << (*it)->Name() << " du graphe " << _G->Name()
2824 // << " n'est pas connecte "<< endl;
2825 // _dataServerError.push_front(4);
2829 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2830 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2831 // _dataServerError.push_front(2);
2835 // if ((*it)->GetNodeInPortsSize()) {
2836 // if ((*it)->GetNodeInPortsSize() > 1){
2837 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2838 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2839 // _dataServerError.push_front(3);
2842 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2843 // cerr << "Le port d'entree du noeud serveur de donnees "
2844 // << (*it)->Name() << " du graphe " << _G->Name()
2845 // << " n'est pas connecte "<< endl;
2846 // _dataServerError.push_front(5);
2852 // return _dataServerError.size ();
2853 return ( ierr == 0 ) ;
2856 SUPERV::GraphState GraphBase::Graph::PortState(
2857 const char* NodeName ,
2858 const char* ServiceParameterName ) {
2859 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2860 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2861 // << ServiceParameterName << " )" << endl ;
2865 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2867 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2869 GraphBase::OutPort *anOutPort ;
2870 anOutPort = aNode->GetChangeOutPort( aPort );
2871 if ( anOutPort == NULL ) {
2872 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2874 anOutPort = anInPort->GetOutPort() ;
2876 cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
2881 aRet = anOutPort->PortState() ;
2882 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2886 cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
2894 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
2895 const char* ToServiceParameterName ) {
2896 const CORBA::Any * aRet = new CORBA::Any() ;
2899 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
2900 // << ToServiceParameterName << endl ;
2901 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
2903 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2906 GraphBase::OutPort *anOutPort = NULL ;
2907 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2909 anOutPort = anInPort->GetOutPort() ;
2911 aRet = anOutPort->Value() ;
2912 // cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "("
2913 // << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
2914 // << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
2917 cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " "
2918 << ToServiceParameterName << " ERROR no OutPort" << endl ;
2922 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2923 << ToServiceParameterName << " ERROR no InPort" << endl ;
2927 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2928 << ToServiceParameterName << " ERROR no Node" << endl ;
2932 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
2936 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
2937 const char* FromServiceParameterName ) {
2938 const CORBA::Any * aRet = new CORBA::Any() ;
2941 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2942 // << FromServiceParameterName << endl ;
2943 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
2945 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2948 GraphBase::OutPort *anOutPort ;
2949 anOutPort = aNode->GetChangeOutPort( aPort );
2951 aRet = anOutPort->Value() ;
2954 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2955 << FromServiceParameterName << " ERROR no OutPort" << endl ;
2959 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2960 << FromServiceParameterName << " ERROR no Node" << endl ;
2964 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
2968 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
2969 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
2970 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
2972 RetVal->length( _NodesNumber[ aLevel ] + 1 );
2973 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
2974 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
2977 return ( RetVal._retn() ) ;
2980 bool GraphBase::Graph::StartComponent(const int aThread ,
2981 const char * aComputerContainer ,
2982 const char * ComponentName ,
2983 Engines::Container_var & myContainer ,
2984 Engines::Component_var & objComponent ) {
2985 cdebug_in << aThread
2986 << " GraphBase::Graph::StartComponent " << aComputerContainer
2987 << " " << ComponentName << endl;
2988 bool RetVal = true ;
2990 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
2991 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
2993 if ( CORBA::is_nil( objComponent ) ) {
2994 cdebug_out << aThread
2995 << " StartComponent cannot FindOrLoad " << aComputerContainer
2996 << " " << ComponentName << " ERROR" << endl;
2999 /* asv : 24.01.05 : FindContainer() method does not exist any more. FindOrLoad_Component()
3000 starts the container for us. If it fails to start the container, then it
3001 returns nil component. We don't need to check for if the container was
3002 successfully started..
3004 myContainer = LCC.FindContainer( aComputerContainer );
3005 if ( CORBA::is_nil( myContainer ) ) {
3006 cdebug_out << aThread
3007 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
3008 << aComputerContainer << "' ) Container does not exist ERROR"
3014 cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;