1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_Graph.cxx
25 // Author : Jean Rahuel, CEA
30 #include "DataFlowBase_StreamGraph.hxx"
32 #include "SALOME_LifeCycleCORBA.hxx"
34 GraphBase::Graph::Graph() :
36 cdebug << "GraphBase::Graph::Graph" << endl ;
40 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
41 SALOME_NamingService* ptrNamingService ,
42 const char *DataFlowName ,
43 const SUPERV::KindOfNode DataFlowkind ,
44 int * Graph_prof_debug ,
45 ofstream * Graph_fdebug ) :
46 // const char * DebugFileName ) :
47 DataNode( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
48 _Orb = CORBA::ORB::_duplicate( ORB ) ;
49 Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
50 cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ;
54 GraphBase::Graph::Graph( CORBA::ORB_ptr ORB ,
55 SALOME_NamingService* ptrNamingService ,
56 const SALOME_ModuleCatalog::Service& DataFlowService ,
57 const char *DataFlowComponentName ,
58 const char *DataFlowInterfaceName ,
59 const char *DataFlowName ,
60 const SUPERV::KindOfNode DataFlowkind ,
61 const SUPERV::SDate DataFlowFirstCreation ,
62 const SUPERV::SDate DataFlowLastModification ,
63 const char * DataFlowEditorRelease ,
64 const char * DataFlowAuthor ,
65 const char * DataFlowComputer ,
66 const char * DataFlowComment ,
67 int * Graph_prof_debug ,
68 ofstream * Graph_fdebug ) :
69 // const char * DebugFileName ) :
70 DataNode( ORB , ptrNamingService , DataFlowService ,
71 DataFlowName , DataFlowkind ,
72 DataFlowFirstCreation , DataFlowLastModification ,
73 DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) {
74 _Orb = CORBA::ORB::_duplicate( ORB ) ;
76 Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ;
77 cdebug_in << "GraphBase::Graph::Graph" << endl ;
78 DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ;
79 cdebug_out << "GraphBase::Graph::Graph" << endl ;
82 GraphBase::Graph::~Graph() {
83 cdebug << "GraphBase::Graph::~Graph" << endl ;
86 void GraphBase::Graph::Set_prof_debug( int * Graph_prof_debug ,
87 ofstream * Graph_fdebug ) {
88 SetDebug( _Orb , Graph_prof_debug , Graph_fdebug ) ;
89 _Graph_prof_debug = Graph_prof_debug ;
90 _Graph_fdebug = Graph_fdebug ;
93 GraphBase::SNode * GraphBase::Graph::GetInfo() const {
94 GraphBase::SNode * Info = new GraphBase::SNode ;
95 Info->theComponentName = "" ;
96 Info->theInterfaceName = "" ;
97 Info->theName = Name() ;
98 Info->theKind = Kind() ;
99 if ( IsDataStreamNode() ) {
101 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
103 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
104 Info->theTimeout = Timeout ;
105 Info->theDataStreamTrace = DataStreamTrace ;
106 Info->theDeltaTime = DeltaTime ;
108 Info->theService = *GetService() ;
109 Info->theFirstCreation = FirstCreation() ;
110 Info->theLastModification = LastModification() ;
111 Info->theEditorRelease = EditorRelease() ;
112 Info->theAuthor = Author() ;
113 Info->theContainer = "" ;
114 Info->theComment = Comment() ;
115 Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
116 Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
120 //----------------------------------------------------------------------
121 // Function : GetNodes
122 // Purpose : get a nodes list
123 //----------------------------------------------------------------------
124 GraphBase::ListOfSNodes * GraphBase::Graph::GetNodes() const {
125 GraphBase::ListOfSNodes * _list_nodes = new GraphBase::ListOfSNodes;
127 cdebug_in << "GraphBase::Graph::GetNodes" << endl ;
128 // All the nodes from _InNodes are taken
129 // vector< InNode *> Nodes = InNodes() ;
131 _list_nodes->resize( GraphNodesSize() );
135 GraphBase::ComputingNode * aCNode = NULL ;
136 for ( igoto = 0 ; igoto < 2 ; igoto++ ) {
137 for ( ind = 0 ; ind < GraphNodesSize() ; ind++ ) {
138 aCNode = GraphNodes( ind ) ;
139 if ( ( igoto == 0 && !aCNode->IsGOTONode() ) ||
140 ( igoto == 1 && aCNode->IsGOTONode() ) ) {
141 if ( aCNode->IsFactoryNode() ) {
142 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
143 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( aFNode->ComponentName());
144 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( aFNode->InterfaceName());
147 (*_list_nodes)[ind].theComponentName = CORBA::string_dup( "" );
148 (*_list_nodes)[ind].theInterfaceName = CORBA::string_dup( "" );
150 (*_list_nodes)[ind].theName = CORBA::string_dup( aCNode->Name() );
151 (*_list_nodes)[ind].theKind = aCNode->Kind();
152 if ( aCNode->IsInLineNode() || aCNode->IsMacroNode() ) {
153 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
154 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
155 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aINode->PyFuncName() ) ;
156 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
157 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aINode->PythonFunction() ;
159 if ( aCNode->IsGOTONode() ) {
160 GraphBase::GOTONode * aGNode = (GraphBase::GOTONode * ) aCNode ;
161 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
162 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGNode->PyFuncName() ) ;
163 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
164 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGNode->PythonFunction() ;
166 if ( aCNode->IsLoopNode() ) {
167 GraphBase::LoopNode * aLNode = (GraphBase::LoopNode * ) aCNode ;
168 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aLNode->CoupledNode()->Name() ) ;
169 (*_list_nodes)[ind].theListOfFuncName.resize( 3 ) ;
170 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aLNode->PyFuncName() ) ;
171 (*_list_nodes)[ind].theListOfFuncName[1] = CORBA::string_dup( aLNode->PyMoreName() ) ;
172 (*_list_nodes)[ind].theListOfFuncName[2] = CORBA::string_dup( aLNode->PyNextName() ) ;
173 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
174 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aLNode->PythonFunction() ;
175 (*_list_nodes)[ind].theListOfPythonFunctions[1] = aLNode->MorePythonFunction() ;
176 (*_list_nodes)[ind].theListOfPythonFunctions[2] = aLNode->NextPythonFunction() ;
178 else if ( aCNode->IsSwitchNode() ) {
179 GraphBase::SwitchNode * aSNode = (GraphBase::SwitchNode * ) aCNode ;
180 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aSNode->CoupledNode()->Name() ) ;
181 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
182 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aSNode->PyFuncName() ) ;
183 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
184 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aSNode->PythonFunction() ;
186 else if ( aCNode->IsEndLoopNode() ) {
187 GraphBase::EndOfLoopNode * aELNode = (GraphBase::EndOfLoopNode * ) aCNode ;
188 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aELNode->CoupledNode()->Name() ) ;
189 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
190 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aELNode->PyFuncName() ) ;
191 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
192 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aELNode->PythonFunction() ;
194 else if ( aCNode->IsEndSwitchNode() ) {
195 GraphBase::EndOfSwitchNode * aESNode = (GraphBase::EndOfSwitchNode * ) aCNode ;
196 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aESNode->CoupledNode()->Name() ) ;
197 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
198 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aESNode->PyFuncName() ) ;
199 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
200 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aESNode->PythonFunction() ;
202 else if ( aCNode->IsMacroNode() ) {
203 GraphBase::Graph * aGraph = (GraphBase::Graph * ) aCNode ;
204 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( aGraph->CoupledNode()->Name() ) ;
205 (*_list_nodes)[ind].theListOfFuncName.resize( 1 ) ;
206 (*_list_nodes)[ind].theListOfFuncName[0] = CORBA::string_dup( aGraph->PyFuncName() ) ;
207 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
208 (*_list_nodes)[ind].theListOfPythonFunctions[0] = aGraph->PythonFunction() ;
211 (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ;
213 // (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ;
214 // (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ;
216 (*_list_nodes)[ind].theListOfInDataStreams.resize( aCNode->DataStreamInPortsNumber() ) ;
217 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamInPortsNumber() << " DataStreamInPortsNumber" << endl ;
220 for ( iostream = 0 ; iostream < aCNode->GetNodeInPortsSize() ; iostream++ ) {
221 const GraphBase::InPort * anInPort ;
222 anInPort = aCNode->GetNodeInPort( iostream ) ;
223 if ( anInPort->IsDataStream() ) {
224 cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName()
226 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ;
227 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
228 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ;
229 SUPERV::KindOfSchema aKindOfSchema ;
230 SUPERV::KindOfInterpolation aKindOfInterpolation ;
231 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
232 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
233 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema = aKindOfSchema ;
234 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation = aKindOfInterpolation ;
235 (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation = aKindOfExtrapolation ;
236 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
237 << anInPort->Dependency() << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation << " list_nodes "
238 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername << " "
239 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype << " "
240 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
241 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema << " "
242 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation << " "
243 << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation << " " << endl ;
247 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " "
248 << anInPort->Kind() << " IsDataStream " << anInPort->IsDataStream() << endl ;
252 (*_list_nodes)[ind].theListOfOutDataStreams.resize( aCNode->DataStreamOutPortsNumber() ) ;
253 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamOutPortsNumber() << " DataStreamOutPortsNumber" << endl ;
255 for ( iostream = 0 ; iostream < aCNode->GetNodeOutPortsSize() ; iostream++ ) {
256 const GraphBase::OutPort * anOutPort ;
257 anOutPort = aCNode->GetNodeOutPort( iostream ) ;
258 if ( anOutPort->IsDataStream() ) {
259 cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
261 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ;
262 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ;
263 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ;
264 long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
265 (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues = aNumberOfValues ;
266 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
267 << anOutPort->Dependency() << " " << aNumberOfValues << " list_nodes "
268 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername << " "
269 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype << " "
270 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency << " "
271 << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues << endl ;
275 cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
276 << anOutPort->Kind() << " IsDataStream " << anOutPort->IsDataStream() << endl ;
280 (*_list_nodes)[ind].theService = *aCNode->GetService();
281 cdebug << "GraphBase::Graph::GetNodes theService " << &(*_list_nodes)[ind].theService.ServiceName << endl ;
283 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinParameter.length() ; i++ ) {
284 cdebug << " In" << i << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
285 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername
286 << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype
287 << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype << endl ;
289 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutParameter.length() ; i++ ) {
290 cdebug << " Out" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
291 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername
292 << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype
293 << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype << endl ;
295 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinDataStreamParameter.length() ; i++ ) {
296 cdebug << " InDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
297 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername
298 << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype
299 << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype << endl ;
301 for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter.length() ; i++ ) {
302 cdebug << " OutDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
303 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername
304 << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype
305 << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype << endl ;
307 if ( aCNode->IsOneOfInLineNodes() ) {
308 GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ;
309 GraphBase::LoopNode * aLNode = NULL ;
310 if ( aCNode->IsLoopNode() ) {
311 aLNode = (GraphBase::LoopNode * ) aCNode ;
312 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 3 ) ;
313 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
314 (*_list_nodes)[ind].theListOfPythonFunctions[ 1 ] = aLNode->MorePythonFunction() ;
315 (*_list_nodes)[ind].theListOfPythonFunctions[ 2 ] = aLNode->NextPythonFunction() ;
317 else if ( aCNode->IsInLineNode() || aCNode->IsGOTONode() ||
318 aCNode->IsSwitchNode() || aCNode->IsEndSwitchNode() ) {
319 (*_list_nodes)[ind].theListOfPythonFunctions.resize( 1 ) ;
320 (*_list_nodes)[ind].theListOfPythonFunctions[ 0 ] = aINode->PythonFunction() ;
323 (*_list_nodes)[ind].theFirstCreation = aCNode->FirstCreation();
324 (*_list_nodes)[ind].theLastModification = aCNode->LastModification();
325 (*_list_nodes)[ind].theEditorRelease = CORBA::string_dup( aCNode->EditorRelease());
326 (*_list_nodes)[ind].theAuthor = CORBA::string_dup( aCNode->Author());
327 if ( aCNode->IsFactoryNode() ) {
328 GraphBase::FactoryNode * aFNode = (GraphBase::FactoryNode * ) aCNode ;
329 (*_list_nodes)[ind].theContainer = CORBA::string_dup( aFNode->Computer());
332 (*_list_nodes)[ind].theContainer = CORBA::string_dup( "" );
334 (*_list_nodes)[ind].theComment = CORBA::string_dup( aCNode->Comment());
335 (*_list_nodes)[ind].theCoords.theX = aCNode->XCoordinate();
336 (*_list_nodes)[ind].theCoords.theY = aCNode->YCoordinate();
340 for ( i = 0 ; i < aCNode->GetNodeInPortsSize() ; i++ ) {
341 const GraphBase::InPort * anInPort = aCNode->GetNodeInPort( i ) ;
342 if ( anInPort->IsBus() ) {
344 (*_list_nodes)[ind].theListOfParameters.resize( nports ) ;
345 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
346 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theInParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ;
347 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametertype = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortType() ) ;
348 (*_list_nodes)[ind].theListOfParameters[ nports-1 ].theOutParameter.Parametername = CORBA::string_dup( aCNode->GetNodeOutPort( anInPort->PortIndex() )->PortName() ) ;
355 cdebug_out << "GraphBase::Graph::GetNodes" << endl ;
360 //----------------------------------------------------------------------
361 // Function : GetLinks
362 // Purpose : get a links list
363 //----------------------------------------------------------------------
364 GraphBase::ListOfSLinks * GraphBase::Graph::GetLinks(bool AllLinks ) const {
365 GraphBase::ListOfSLinks * _list_links = new GraphBase::ListOfSLinks;
367 // All the links from _LinksList are taken
368 // vector< InNode *> Nodes = InNodes() ;
372 for ( k = 0 ; k < GraphNodesSize() ; k++ ) {
373 GraphBase::ComputingNode * fromNode = GraphNodes( k ) ;
375 for ( i = 0 ; i < fromNode->GetNodeOutPortsSize() ; i++ ) {
376 const GraphBase::OutPort* fromPort = fromNode->GetNodeOutPort( i ) ;
378 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
379 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
380 if ( toPort->IsPortConnected() ) {
381 // Desole pour ce cast mais avec les maps difficile de faire const ...
382 const GraphBase::ComputingNode * toNode = ((GraphBase::Graph * ) this)->GetGraphNode( toPort->NodeName() ) ;
383 if ( !(fromPort->IsLoop() && toPort->IsLoop() ) || AllLinks ) {
384 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " ("
385 << fromPort->PortName() << " ) IsPortConnected" << fromPort->IsPortConnected()
386 << " --> " << toNode->Name() << "( " << toPort->PortName() << " ) "
387 << " " << fromPort->InPortsSize() << " ports" << endl ;
388 _list_links->resize( ind+1 );
389 (*_list_links)[ind].FromNodeName = CORBA::string_dup( fromNode->Name() );
390 (*_list_links)[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
391 (*_list_links)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
392 (*_list_links)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
393 (*_list_links)[ind].aLinkValue = *fromPort->Value() ;
394 if ( toPort->IsEndSwitch() ) {
395 (*_list_links)[ind++].aListOfCoords = *(fromPort->Coords()) ;
398 (*_list_links)[ind++].aListOfCoords = *(toPort->Coords()) ;
403 cdebug << "GraphBase::Graph::GetLinks " << fromNode->Name() << " "
404 << fromPort->PortName() << " ) " << fromPort->PortStatus()
405 << " --> " << toPort->NodeName() << "( " << toPort->PortName() << " ) "
406 << " " << toPort->PortStatus() << " " << fromPort->InPortsSize() << " ports ignored" << endl ;
415 GraphBase::ListOfSGraphs * GraphBase::Graph::GetGraphs() const {
416 GraphBase::ListOfSGraphs * _list_graphs = new GraphBase::ListOfSGraphs;
421 GraphBase::SLink * GraphBase::Graph::GetLink( GraphBase::ComputingNode * aNode ,
422 GraphBase::InPort* toPort ) {
423 GraphBase::SLink * _link = new GraphBase::SLink ;
424 GraphBase::OutPort* fromPort = toPort->GetOutPort() ;
425 _link->FromNodeName = CORBA::string_dup( fromPort->NodeName() );
426 _link->FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
427 _link->ToNodeName = CORBA::string_dup( toPort->NodeName() );
428 _link->ToServiceParameterName = toPort->GetServicesParameter().Parametername;
429 CORBA::Any aSPValue = *fromPort->Value() ;
430 _link->aLinkValue = aSPValue;
431 _link->aListOfCoords = *(toPort->Coords()) ;
434 //----------------------------------------------------------------------
435 // Function : GetDatas
436 // Purpose : get the datas list
437 //----------------------------------------------------------------------
438 GraphBase::ListOfSLinks * GraphBase::Graph::GetDatas() const {
439 GraphBase::ListOfSLinks * _list_datalinks = new GraphBase::ListOfSLinks;
442 const GraphBase::DataNode * aDataNode = this ;
444 for ( i = 0 ; i < aDataNode->GetNodeInDataNodePortsSize() ; i++ ) {
445 const GraphBase::OutPort* fromDataPort = aDataNode->GetNodeInDataNodePort( i ) ;
446 if ( GraphMacroLevel() == 0 ) {
447 if ( fromDataPort->IsDataConnected() ) {
449 //We may have SharedData as input of a DataFlow : same input for one or several
450 // input ports. Input(s) of a DataFlow match one or several output-virtual-dataport
451 for ( j = 0 ; j < fromDataPort->InPortsSize() ; j++ ) {
452 _list_datalinks->resize( ind+1 );
453 (*_list_datalinks)[ind].FromNodeName = CORBA::string_dup( aDataNode->Name() );
454 (*_list_datalinks)[ind].FromServiceParameterName = fromDataPort->GetServicesParameter().Parametername;
455 const GraphBase::InPort* toPort = fromDataPort->InPorts( j ) ;
456 (*_list_datalinks)[ind].ToNodeName = CORBA::string_dup( toPort->NodeName() );
457 (*_list_datalinks)[ind].ToServiceParameterName = toPort->GetServicesParameter().Parametername;
458 CORBA::Any aSPValue = *fromDataPort->Value() ;
459 (*_list_datalinks)[ind].aLinkValue = aSPValue;
460 (*_list_datalinks)[ind++].aListOfCoords = *(toPort->Coords()) ;
467 // Output(s) of a DataFlow match only one input-virtual-dataport
468 for ( i = 0 ; i < aDataNode->GetNodeOutDataNodePortsSize() ; i++ ) {
469 GraphBase::InPort* toDataPort = aDataNode->GetChangeNodeOutDataNodePort( i ) ;
470 const GraphBase::OutPort* fromPort = toDataPort->GetLink() ;
471 if ( fromPort->IsDataConnected() ) {
472 _list_datalinks->length( ind+1 );
473 _list_datalinks[ind].FromNodeName = CORBA::string_dup( fromPort->NodeName() );
474 _list_datalinks[ind].FromServiceParameterName = fromPort->GetServicesParameter().Parametername;
475 _list_datalinks[ind].ToNodeName = CORBA::string_dup( aDataNode->Name() );
476 _list_datalinks[ind].ToServiceParameterName = toDataPort->GetServicesParameter().Parametername;
477 // SALOME_SuperVisionBase::ServicesParameterValue aSPValue;
478 CORBA::Any aSPValue = *fromPort->Value() ;
479 // aSPValue.Value = CORBA::string_dup( fromPort->Value() );
480 // aSPValue.Kind = fromPort->Kind();
481 _list_datalinks[ind].aLinkValue = aSPValue;
482 _list_datalinks[ind++].aListOfCoords = toDataPort->Coords() ;
487 return _list_datalinks ;
490 bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) {
491 cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl;
492 bool RetVal = false ;
493 int index = GetGraphNodeIndex( aNode->Name() ) ;
495 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ;
496 _GraphNodes.resize( _GraphNodesSize+1 ) ;
497 _GraphNodes[ _GraphNodesSize ] = aNode ;
498 SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ;
499 _GraphNodesSize += 1 ;
500 if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) {
501 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ;
504 cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName()
505 << " was already in MapOfServices" << endl ;
510 cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ;
511 for ( i = 0 ; i < _GraphNodesSize ; i++ ) {
512 const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ;
514 cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ;
517 cdebug << i << ". ERROR" << endl ;
520 aNode->GraphOfNode( this ) ;
522 cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. "
523 << aNode->ServiceName() << endl;
527 bool GraphBase::Graph::ReNameNode( const char* OldNodeName ,
528 const char* NewNodeName ) {
529 cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") "
532 bool RetVal = false ;
534 GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ;
535 for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) {
536 cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ;
539 if ( !strcmp( OldNodeName , NewNodeName ) ) {
542 else if ( strcmp( Name() , OldNodeName ) ) {
543 int index = GetGraphNodeIndex( OldNodeName ) ;
544 int newindex = GetGraphNodeIndex( NewNodeName ) ;
545 if ( index >= 0 && index < _GraphNodesSize &&
546 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
547 _GraphNodes[ index ]->Name( NewNodeName ) ;
548 _MapOfGraphNodes.erase( OldNodeName ) ;
549 SetGraphNodeIndex( NewNodeName , index ) ;
551 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
552 // Update 'ToNode's Map from 'aNode'
553 cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize "
554 << aNode->LinkedNodesSize() << endl ;
555 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
556 GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ;
557 ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ;
559 // Update 'FomNode's Map to 'aNode'
560 // Inports 'anInPort' of 'aNode'
561 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
562 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
563 // OutPort 'anOutPort' linked to 'anInPort'
564 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
565 cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
567 cdebug << anOutPort->NodeName() ;
570 cdebug << "without link" ;
572 cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
573 if ( !anInPort->IsNotConnected() ) {
574 if ( anOutPort->IsDataConnected() ) {
575 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
578 // Node 'FromNode' of 'anOutPort'
579 GraphBase::ComputingNode * FromNode ;
580 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
581 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
586 // Rename in _MapOfLinkedFromNodes of 'FromNode'
587 cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
588 if ( anInPort->IsDataStream() ) {
589 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
592 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
595 char* OldNodePortName = new char[ strlen( OldNodeName ) +
596 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
597 char* NewNodePortName = new char[ strlen( NewNodeName ) +
598 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
599 strcpy( OldNodePortName , OldNodeName ) ;
600 // strcat( OldNodePortName , "\\" ) ;
601 strcat( OldNodePortName , "__" ) ;
602 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
603 strcpy( NewNodePortName , NewNodeName ) ;
604 // strcat( NewNodePortName , "\\" ) ;
605 strcat( NewNodePortName , "__" ) ;
606 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
607 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
608 delete [] OldNodePortName ;
609 delete [] NewNodePortName ;
614 cdebug << " not connected" << endl ;
621 cdebug << "ERROR Node not found" << endl ;
625 RetVal = Name( NewNodeName ) ;
628 cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
632 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
633 cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << endl;
635 bool RetVal = false ;
636 int index = GetGraphNodeIndex( aNodeName ) ;
637 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
639 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
640 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
641 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
642 << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode() << endl ;
643 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
644 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
645 << aNode->LinkedNodes( i )->Name() << endl ;
647 if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted
648 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
649 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
650 << aNode->LinkedFromNodes( i )->Name() << endl ;
653 if ( !aNode->IsEndSwitchNode() ) {
654 if ( aNode->GetNodeInPortsSize() ) {
655 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
656 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
657 cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
658 << anInPort->PortStatus() << " <-- " ;
659 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
660 if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
661 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
664 if ( !anInPort->IsNotConnected() ) {
666 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
667 cdebug << " Data/Extern" << endl ;
670 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
671 cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize "
672 << FromNode->LinkedNodesSize() << " and " << aNode->Name()
673 << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ;
674 // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
675 // JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode
676 // if ( !FromNode->IsOneOfGOTONodes() ) {
677 // if ( !FromNode->IsGOTONode() ) {
678 if ( !FromNode->IsGOTONode() &&
679 !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) {
680 if ( anInPort->IsDataStream() ) {
681 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
684 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
687 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
692 RetVal = anOutPort->RemoveInPort( anInPort ) ;
694 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
708 // Special case of EndSwitchNodes : each Input port must be multi-connected.
709 // There is one link for each branch of the switch
710 // But in GraphBase::InPort there is only one field GraphBase::OutPort *
711 // At execution time there is no problem because only one branch of the switch
712 // may be executed and the Executor set the right OutPort in the field
713 // GraphBase::OutPort * of each InPort of the EndSwitchNode
714 // But here we must remove that node EndSwitch from the LinkedNodes field of
715 // terminal nodes of all branches.
716 // And also in the OutPorts of that terminal nodes of branches we must remove
717 // references to InPorts of the EndSwitchNode.
719 // Explore LinkedFromnodes of the EndSwitchNode :
720 for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) {
721 GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ;
722 cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ;
724 for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) {
725 GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ;
726 cdebug << "OutPort" << j << ". Remove " << anOutPort->InPortsSize()
727 << " InPortsof OutPort : " << anOutPort->NodeName() << "( "
728 << anOutPort->PortName() << ") "
729 << anOutPort->PortStatus() << " :" << endl ;
731 for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) {
732 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ;
733 if ( strcmp( anInPort->NodeName() , aNode->Name() ) == NULL ) {
734 // InPort of the EndSwitchNode
735 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( "
736 << anInPort->PortName() << ") "
737 << anInPort->PortStatus() << endl ;
738 anInPort->RemoveOutPort() ;
739 if ( anOutPort->IsDataStream() ) {
740 aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ;
743 // false ==> No error for aNode->LinkedFromNode()
744 RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ;
746 cdebug << "aLinkedFromNode->RemoveLinkedNode Error RetVal " << RetVal << endl ;
750 // Remove the InPort of the EndSwitchNode from that OutPort
751 RetVal = anOutPort->RemoveInPort( anInPort ) ;
753 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
763 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
764 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
765 cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
766 << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
767 << anOutPort->PortStatus() << " :" << endl ;
769 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
770 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
771 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
772 << anInPort->PortStatus() << endl ;
773 if ( !anInPort->IsExternConnected() ) {
774 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
775 RetVal = anInPort->RemoveOutPort() ;
777 cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
780 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
781 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
783 else if ( anOutPort->IsDataStream() ) {
784 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
787 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
790 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
793 RetVal = anOutPort->RemoveInPort( anInPort ) ;
795 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
801 cdebug << "Error RetVal " << RetVal << endl ;
806 cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize()
807 << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts "
808 << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize()
809 << " LinkedFromNodes " << endl ;
810 for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) {
811 cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " "
812 << aNode->LinkedNodes( i )->Name() << endl ;
814 for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) {
815 cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " "
816 << aNode->LinkedFromNodes( i )->Name() << endl ;
818 // Delete of aNode from the Graph :
819 // The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted
820 // when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode
821 if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) {
822 GraphBase::InLineNode * theCoupledNode = NULL ;
823 char * theCoupledNodeName = NULL ;
824 int CoupledIndex = -1 ;
825 if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) {
826 theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
827 theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ;
828 CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ;
831 _GraphNodesSize -= 1 ;
832 for ( i = index ; i < _GraphNodesSize ; i++ ) {
833 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
834 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
836 _GraphNodes.resize( _GraphNodesSize+1 ) ;
837 _MapOfGraphNodes.erase( aNodeName ) ;
838 // Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode :
839 if ( theCoupledNode ) {
840 delete theCoupledNode ;
841 _GraphNodesSize -= 1 ;
842 for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) {
843 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
844 SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ;
846 _GraphNodes.resize( _GraphNodesSize+1 ) ;
847 _MapOfGraphNodes.erase( theCoupledNodeName ) ;
853 cdebug << "Node not found ERROR " << index << endl ;
856 cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl;
860 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
861 const char* FromServiceParameterName ,
862 const char* ToNodeName ,
863 const char* ToServiceParameterName ) {
864 // , const CORBA::Any aValue ) {
867 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
868 << FromServiceParameterName << ") ---> " << ToNodeName << "("
869 << ToServiceParameterName << ") , aValue )" << endl;
871 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
872 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
874 GraphBase::OutPort *fromPort = NULL ;
875 GraphBase::InPort *toPort = NULL ;
878 if ( strcmp( FromServiceParameterName , "InitLoop" ) ) {
879 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
882 fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ;
885 cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
886 << FromNodeName << ") not found." << endl ;
890 cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
893 if ( strcmp( ToServiceParameterName , "InitLoop" ) ) {
894 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
897 toPort = toNode->GetChangeInPort( "DoLoop" ) ;
900 cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
901 << ToNodeName << ") not found." << endl ;
905 cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
908 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
911 if ( fromPort->IsGate() && toPort->IsGate() ) {
913 aValue <<= (long ) 1 ;
914 fromPort->Value( aValue ) ;
917 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
918 // fromPort->Value( aDataValue ) ;
920 // fromPort->PortStatus( DataConnected );
923 cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
927 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
928 GraphBase::OutPort *fromPort ,
929 GraphBase::ComputingNode *toNode ,
930 GraphBase::InPort *toPort ) {
934 cdebug << "ERROR AddLink fromNode not found." << endl ;
938 cdebug << "ERROR AddLink fromPort not found." << endl ;
943 cdebug << "ERROR AddLink toNode not found." << endl ;
947 cdebug << "ERROR AddLink toPort not found." << endl ;
950 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
951 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
952 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
955 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
956 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
957 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
961 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
962 << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "("
963 << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl;
964 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
965 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
966 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
967 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
971 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
972 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
973 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
974 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
978 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
979 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
980 toPort->GetOutPort()->PortName() ,
981 toNode->Name() , toPort->PortName() ) ) {
982 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
987 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
988 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
989 toPort->GetOutPort() ) {
990 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
991 fromPort->NodePortName() ) ) {
992 cdebug << "Link already exists" << endl ;
993 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
996 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
997 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
999 else if ( fromNode->IsGOTONode() ) {
1000 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
1001 toPort->GetOutPort()->PortName() ,
1002 toNode->Name() , toPort->PortName() ) ) {
1003 cdebug << "RemoveLink(AddLink) Error."
1005 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1008 if ( fromPort->InPortsSize() ) {
1009 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1010 fromPort->ChangeInPorts(0)->NodeName() ,
1011 fromPort->ChangeInPorts(0)->PortName() ) ) {
1012 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1013 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1018 else if ( !toNode->IsEndSwitchNode() ||
1019 ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
1020 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1021 toNode->Name() , toPort->PortName() ) ) {
1022 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
1023 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1028 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
1029 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
1030 fromPort->ChangeInPorts(0)->NodeName() ,
1031 fromPort->ChangeInPorts(0)->PortName() ) ) {
1032 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
1033 cdebug_out << "GraphBase::Graph::AddLink" << endl;
1037 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
1038 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
1039 fromPort->RemoveInPort( toPort ) ; //dbg
1041 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
1042 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
1043 fromPort->RemoveInPort() ; // There is only one
1047 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
1048 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
1049 if ( !fromPort->AddInPort( toPort ) ) {
1050 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
1052 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1055 if ( !toPort->IsDataStream() ) {
1056 toPort->Kind( SUPERV::EndSwitchParameter ) ;
1059 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
1060 cdebug << "!fromPort->AddLink Error." << endl ;
1061 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1065 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
1066 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
1067 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
1068 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1071 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
1072 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
1073 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1076 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
1077 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
1078 cdebug << "toPort->AddLink Error." << endl ;
1079 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1084 toPort->AddOutPort( fromPort ) ;
1087 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
1088 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
1089 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
1090 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
1091 << fromNode->Name() << " " << fromPort->PortName()
1092 << " InLineNode/LoopNode_ConnectedInPortsNumber "
1093 << toNode->ConnectedInPortsNumber() << endl;
1094 if ( fromNode->IsGOTONode() ) {
1095 fromPort->Kind( SUPERV::GOTOParameter ) ;
1097 fromPort->PortStatus( PortConnected ); // GOTO - Loop
1099 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
1100 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
1101 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1102 fromPort->PortStatus( ExternConnected );
1104 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
1105 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
1106 << fromNode->Name() << " " << fromPort->PortName() << endl ;
1107 fromPort->PortStatus( ExternConnected ) ;
1110 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
1111 << fromNode->Name() << " " << fromPort->PortName() << " "
1112 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
1113 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
1114 fromPort->PortStatus( PortConnected );
1115 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
1116 fromNode->AddStreamLinkedNode( toNode ) ;
1119 fromNode->AddLinkedNode( toNode ) ;
1122 if ( fromNode->IsSwitchNode() ) {
1123 if ( !fromPort->IsDataStream() ) {
1124 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1125 fromPort->Kind( SUPERV::SwitchParameter ) ;
1127 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
1128 fromPort->Kind( SUPERV::InLineParameter ) ;
1131 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1132 GraphBase::InLineNode * anEndSwitchNode ;
1133 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
1134 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1135 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1136 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1137 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1138 anOutPort->IsGate() ) {
1139 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1140 anEndSwitchNode->Name() ,
1141 anInPort->PortName() ) ) {
1142 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1144 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1150 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1151 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1155 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1156 const char* FromServiceParameterName ,
1157 const char* ToNodeName ,
1158 const char* ToServiceParameterName ) {
1159 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1160 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1161 bool RetVal = false ;
1162 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1164 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1165 if ( anInPort && ( anInPort->IsPortConnected() ||
1166 anInPort->IsDataConnected() ||
1167 anInPort->IsExternConnected() ) ) {
1168 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1169 RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> :
1170 // anInPort->RemoveOutPort() ;
1171 const char * FromNodeName = anOutPort->NodeName() ;
1172 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1175 if ( anInPort->IsDataStream() ) {
1176 fromNode->RemoveStreamLinkedNode( toNode ) ;
1179 fromNode->RemoveLinkedNode( toNode ) ;
1182 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1183 anOutPort->Kind( SUPERV::InLineParameter ) ;
1188 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1192 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1193 const char* ToServiceParameterName ,
1194 char** FromNodeName ,
1195 char** FromServiceParameterName ) {
1196 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1197 // << ToServiceParameterName << ")" << endl;
1198 bool RetVal = false ;
1199 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1201 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1202 if ( anInPort && !anInPort->IsNotConnected() ) {
1203 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1204 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1205 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1209 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1210 << " " << ToServiceParameterName << " " << RetVal << endl;
1214 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1217 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1221 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1222 const char* ToServiceParameterName ,
1223 const CORBA::Any aValue ) {
1224 bool RetVal = false ;
1225 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1226 << ToServiceParameterName << " , Any " ;
1227 switch (aValue.type()->kind()) {
1228 case CORBA::tk_string:
1231 cdebug << t << " (string) " ;
1233 case CORBA::tk_double:
1236 cdebug << d << " (double) " ;
1238 case CORBA::tk_long:
1241 cdebug << l << " (long) " ;
1243 case CORBA::tk_objref:
1244 cdebug << "(object reference) " ;
1247 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1248 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1251 cdebug << " ) in Graph " << Name() << endl;
1253 GraphBase::ComputingNode *toNode ;
1254 GraphBase::InPort *toPort ;
1257 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1258 toNode = GetChangeGraphNode( aNodeName ) ;
1259 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1261 toPort = toNode->GetChangeInPort( aPortName ) ;
1262 if ( toPort && !toPort->IsDataConnected() ) {
1263 toPort->RemoveOutPort() ;
1271 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1272 cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1274 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1275 cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1278 if ( toNode && toPort ) {
1279 GraphBase::OutPort *fromDataNodePort = NULL ;
1280 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1281 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1282 fromDataNodePort->RemoveInPort( toPort ) ;
1284 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1285 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1286 << toPort->PortName() << " )" << endl ;
1287 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1290 fromDataNodePort->Value( aValue ) ;
1291 fromDataNodePort->PortStatus( DataConnected ) ;
1295 cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1300 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1304 // Used in the Executor in order to change an Input Value and ReRun
1305 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1306 const char * ToServiceParameterName ,
1307 const CORBA::Any aValue ) {
1308 bool RetVal = false ;
1309 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1310 << ToServiceParameterName << "' , Any " ;
1311 switch (aValue.type()->kind()) {
1312 case CORBA::tk_string:
1315 cdebug << t << " (string) " ;
1317 case CORBA::tk_double:
1320 cdebug << d << " (double) " ;
1322 case CORBA::tk_long:
1325 cdebug << l << " (long) " ;
1327 case CORBA::tk_objref:
1328 cdebug << "(object reference) " ;
1331 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1334 cdebug << " ) in Graph " << Name() << endl;
1336 GraphBase::ComputingNode * toNode ;
1337 GraphBase::InPort * toPort = NULL ;
1340 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1341 toNode = GetChangeGraphNode( aNodeName ) ;
1342 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1344 toPort = toNode->GetChangeInPort( aPortName ) ;
1345 if ( toPort && toPort->IsDataConnected() ) {
1346 GraphBase::OutPort * fromPort = toPort->GetOutPort();
1349 fromPort->Value( aValue ) ;
1350 fromPort->PortStatus( DataConnected ) ;
1351 toPort->State( SUPERV::ReadyState ) ;
1354 cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1358 cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1362 cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1365 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1369 // To restore InputData in CreateService
1370 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1371 const char* ToServiceParameterName ,
1372 const CORBA::Any ** aValue ) {
1373 bool RetVal = false ;
1374 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1375 << ToServiceParameterName << ", **Any " ;
1376 const CORBA::Any theValue = **aValue ;
1377 switch (theValue.type()->kind()) {
1378 case CORBA::tk_string:
1381 cdebug << t << " (string) " ;
1383 case CORBA::tk_double:
1386 cdebug << d << " (double) " ;
1388 case CORBA::tk_long:
1391 cdebug << l << " (long) " ;
1393 case CORBA::tk_objref:
1394 cdebug << "(object reference) " ;
1397 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1400 cdebug << ") of Graph " << Name() << endl;
1402 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1405 GraphBase::InPort *toPort = NULL ;
1406 GraphBase::OutPort *fromDataNodePort = NULL ;
1407 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1408 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1409 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1410 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1411 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1414 fromDataNodePort->Value( aValue ) ;
1415 fromDataNodePort->PortStatus( DataConnected ) ;
1419 cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1420 map< string , int >::iterator aMapOfGraphNodesIterator ;
1422 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1423 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1424 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1425 << aMapOfGraphNodesIterator->second << endl ;
1429 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1433 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1434 const char* FromServiceParameterName ,
1435 const CORBA::Any aValue ) {
1436 bool RetVal = true ;
1437 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1438 << FromServiceParameterName << ")" << endl;
1439 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1441 GraphBase::OutPort *anOutPort = NULL ;
1444 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1445 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1446 // RetVal = AddLink( fromNode , fromPort ,
1447 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1448 anOutPort->Value( aValue ) ;
1449 anOutPort->State( SUPERV::ReadyState ) ;
1450 anOutPort->Done( true ) ;
1451 cdebug << *anOutPort ;
1453 anOutPort->StringValue( *_fdebug ) ;
1458 cdebug << "ERROR Node not found" << endl ;
1461 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1465 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1466 return _MapOfServiceNames ; }
1468 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1469 return _MapOfServiceNames[ name ] ;
1472 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1473 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1475 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1476 << " already in MapOfServiceNames : erase" << endl ;
1477 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1479 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1480 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1484 int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
1485 GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
1486 if ( theService == NULL ) {
1489 return theService->NewInstance() ;
1492 void GraphBase::Graph::SetGraphPorts() {
1493 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1495 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1496 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1497 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1498 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ;
1499 if ( !anOutPort->IsGate() ) {
1500 anOutPort->PortStatus( ExternConnected ) ;
1503 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1504 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1505 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1506 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ;
1507 if ( !anInPort->IsGate() ) {
1508 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1509 anOutPort->PortStatus( ExternConnected ) ;
1512 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1515 bool GraphBase::Graph::CreateService() {
1516 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1517 bool RetVal = true ;
1518 SALOME_ModuleCatalog::Service aService ;
1520 GraphBase::ComputingNode * aToNode ;
1523 int instreamnbr = 0 ;
1525 int outstreamnbr = 0 ;
1526 vector< SUPERV::KindOfPort > InPortsKind ;
1527 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1528 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1529 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1530 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1531 vector< SUPERV::KindOfPort > OutPortsKind ;
1532 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1533 vector< long > OutNumberOfValues ;
1534 // if ( GraphMacroLevel() == 0 ) {
1535 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1536 if ( dostore == 1 ) {
1537 aService.ServiceName = Name() ;
1538 aService.ServiceinParameter.length( 0 ) ;
1539 aService.ServiceinParameter.length( innbr ) ;
1540 aService.ServiceoutParameter.length( 0 ) ;
1541 aService.ServiceoutParameter.length( outnbr ) ;
1542 InPortsKind.resize( innbr ) ;
1543 InDataStreamDependency.resize( innbr ) ;
1544 InKindOfSchema.resize( innbr ) ;
1545 InKindOfInterpolation.resize( innbr ) ;
1546 InKindOfExtrapolation.resize( innbr ) ;
1547 OutPortsKind.resize( outnbr ) ;
1548 OutDataStreamDependency.resize( outnbr ) ;
1549 OutNumberOfValues.resize( outnbr ) ;
1551 else if ( dostore == 2 ) {
1552 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1553 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1554 << " outstreamnbr " << outstreamnbr << endl ;
1555 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1556 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1557 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1558 InPortsKind.resize( innbr + instreamnbr ) ;
1559 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1560 InKindOfSchema.resize( innbr + instreamnbr ) ;
1561 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1562 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1563 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1564 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1565 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1567 if ( dostore == 0 ) {
1573 if ( dostore == 1 ) {
1577 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1578 aToNode = GraphNodes( i ) ;
1579 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1580 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1581 bool isfromcouplednode = false ;
1582 if ( !anInPort->IsNotConnected() ) {
1583 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1584 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1585 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1586 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1587 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1588 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1589 isfromcouplednode = true ;
1592 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1593 ( !anInPort->IsPortConnected() ||
1594 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1595 if ( dostore == 0 ) {
1596 cdebug << "CreateService " << aToNode->Name() << " Input port "
1597 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1598 if ( anInPort->GetOutPort() ) {
1599 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1602 if ( anInPort->IsDataStream() ) {
1609 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1610 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1611 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1612 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1613 InPortsKind[ innbr ] = anInPort->Kind() ;
1614 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1615 if ( dostore == 2 && anInPort->IsDataStream() ) {
1616 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1617 InKindOfInterpolation[ innbr ] ,
1618 InKindOfExtrapolation[ innbr ] ) ;
1620 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1621 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1625 else if ( dostore == 0 ) {
1626 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1627 << " " << anInPort->PortStatus() ;
1628 if ( anInPort->IsPortConnected() ) {
1629 cdebug << " is connected " ;
1632 cdebug << " is NOT connected " ;
1634 if ( anInPort->IsGate() ) {
1635 cdebug << " IsGate " ;
1637 if ( anInPort->GetOutPort() ) {
1638 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1641 cdebug << "NOT DataConnected" ;
1646 GraphBase::ComputingNode * aFromNode = aToNode ;
1647 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1648 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1649 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1650 // if ( anOutPort ) {
1651 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1654 // cdebug << " NULL" << endl ;
1656 if ( !aFromNode->IsGOTONode() ) {
1657 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
1658 anOutPort->IsExternConnected() ) {
1659 if ( dostore == 0 ) {
1660 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1661 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1662 if ( anOutPort->IsDataStream() ) {
1669 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1670 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1671 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1672 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1673 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1674 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1675 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1676 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1678 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1679 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1690 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1691 << " OutPorts " << outnbr << endl ;
1692 for ( i = 0 ; i < innbr ; i++ ) {
1693 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1694 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1695 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1696 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1697 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1700 for ( i = 0 ; i < outnbr ; i++ ) {
1701 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1702 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1703 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1704 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1705 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1710 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
1711 for ( i = 0 ; i < innbr ; i++ ) {
1712 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1713 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
1714 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
1715 InDataStreamDependency[ i ] ,
1716 SUPERV::DataStreamParameter ) ;
1717 anInPort->SetParams( InKindOfSchema[ i ] ,
1718 InKindOfInterpolation[ i ] ,
1719 InKindOfExtrapolation[ i ] ) ;
1720 // NOT A BUG : AddOutPort for an inport (Reversed service)
1721 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
1724 aService.ServiceinParameter[ i ].Parametername ,
1725 aService.ServiceinParameter[ i ].Parametertype ,
1726 SUPERV::DataStreamParameter ,
1728 _Graph_prof_debug , _Graph_fdebug ) ;
1729 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
1730 // Attention : revoir les reversed DataStreamPorts
1731 // anInPort->SetParams( InKindOfSchema[ i ] ,
1732 // InKindOfInterpolation[ i ] ,
1733 // InKindOfExtrapolation[ i ] ) ;
1734 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1735 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1739 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1740 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1741 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1742 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1743 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1744 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1748 for ( i = 0 ; i < outnbr ; i++ ) {
1749 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1750 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
1751 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
1752 OutDataStreamDependency[ i ] ,
1753 SUPERV::DataStreamParameter ) ;
1754 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1755 // NOT A BUG : AddInPort for an outport (Reversed service)
1756 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
1759 aService.ServiceoutParameter[ i ].Parametername ,
1760 aService.ServiceoutParameter[ i ].Parametertype ,
1761 SUPERV::DataStreamParameter ,
1763 _Graph_prof_debug , _Graph_fdebug ) ;
1764 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
1765 // Attention : revoir les reversed DataStreamPorts
1766 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1767 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1768 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1772 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1773 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1774 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1775 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1776 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1777 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1778 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1779 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1783 // Restore input datas and links :
1784 DataStreamInPortsNumber( 0 ) ;
1785 DataStreamOutPortsNumber( 0 ) ;
1786 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1787 aToNode = GraphNodes( i ) ;
1788 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
1789 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
1790 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1791 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1792 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
1793 if ( !AddInputData( anInPort->NodeName() ,
1794 anInPort->PortName() ,
1795 anInPort->GetOutPort()->ValuePtr() ) ) {
1796 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1797 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
1801 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1802 << anInPort->PortStatus() << " --> AddInputData" << endl ;
1805 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
1806 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
1807 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1808 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
1812 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1813 << anInPort->PortStatus() << " --> AddInLink" << endl ;
1817 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
1818 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
1819 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
1820 << ") " << anOutPort->PortStatus() << " :" << endl ;
1821 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
1822 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
1823 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
1824 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1825 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
1829 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1830 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
1836 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
1840 bool GraphBase::Graph::InLineServices() {
1841 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1846 ListPorts( *_Graph_fdebug , 0 ) ;
1849 GraphBase::InLineNode * aINode ;
1850 SALOME_ModuleCatalog::Service aService ;
1851 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1852 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1853 if ( aINode->IsOneOfInLineNodes() ) {
1854 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1855 aService.ServiceName = aINode->ServiceName() ;
1856 aService.ServiceinParameter.length( 0 ) ;
1857 aService.ServiceoutParameter.length( 0 ) ;
1858 aINode->DataStreamInPortsNumber( 0 ) ;
1859 aINode->DataStreamOutPortsNumber( 0 ) ;
1861 int InStreamService = 0 ;
1862 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1863 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1865 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1866 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1867 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1868 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1869 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1870 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1873 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
1874 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
1875 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1876 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1877 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
1878 aINode->IncrDataStreamInPorts() ;
1880 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1881 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1882 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1883 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1884 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1885 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1889 aService.ServiceinParameter.length( InService+1 ) ;
1890 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1891 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1893 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1894 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1895 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1896 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1897 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1898 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1902 int OutService = 0 ;
1903 int OutStreamService = 0 ;
1904 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1905 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1906 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1908 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1909 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1910 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1911 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1912 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1913 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1916 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1917 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
1918 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1919 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1920 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
1921 aINode->IncrDataStreamOutPorts() ;
1923 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1924 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1925 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1926 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1927 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1928 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1932 aService.ServiceoutParameter.length( OutService+1 ) ;
1933 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1934 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1936 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1937 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1938 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1939 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1940 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1941 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1945 aINode->SetService( aService ) ;
1946 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
1948 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
1949 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
1950 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
1953 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1957 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1961 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
1964 int NotSortedNumber = GraphNodesSize() ;
1966 cdebug_in << "GraphBase::Graph::Sort" << endl;
1967 if ( NotSortedNumber ) {
1969 _ParallelExecutionNodes = false ;
1970 _Sorted.resize( GraphNodesSize() ) ;
1971 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1972 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1973 if ( _NodesNumber.size() ) {
1974 _NodesNumber.resize( 0 ) ;
1975 _SortedNodes.resize( 0 ) ;
1978 // This is a simulation of the computation of the graph :
1979 // The initial state of nodes is :
1980 // - Sorted = false : the node is not sorted
1981 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
1982 // - DecrInPortsNumber = 0 : there is no value available.
1984 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
1985 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1986 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1987 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
1988 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
1989 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
1993 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1994 _Sorted[ i ] = false ;
1995 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1996 _DecrInPortsNumber[ i ] = 0 ;
1997 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
1998 // << _CnxInPortsNumber[ i ] << endl ;
2001 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
2002 // ==============================================================================
2003 while ( NotSortedNumber ) {
2006 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2007 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
2008 << GraphNodes( i )->Name() << " count "
2009 << _CnxInPortsNumber[ i ] << endl ;
2010 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
2011 // All inputs of GraphNodes( i ) are available : "AllDataReady"
2012 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
2013 _NodesNumber.resize( _LevelsNumber+1 ) ;
2014 _SortedNodes.resize( _LevelsNumber+1 ) ;
2015 _NodesNumber[ _LevelsNumber ] = -1 ;
2017 // There is one more node at that level
2018 _NodesNumber[ _LevelsNumber ]++ ;
2019 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
2020 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
2021 _Sorted[ i ] = true ;
2023 NotSortedNumber -= 1 ;
2024 cdebug << GraphNodes( i )->Name() << " belongs to level "
2025 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
2026 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
2027 // So we loop over all nodes that have a link from that node
2028 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
2029 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
2030 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
2031 // OutputPorts of GraphNodes( i ) will satisfy
2032 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
2033 // GraphNodes( i )->LinkedNodes( j )
2034 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
2035 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
2036 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
2037 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
2038 cdebug << " _DecrInPortsNumber[ "
2039 << GetGraphNodeIndex( aLinkedNode->Name() )
2041 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
2042 << " += " << aLinkedInPortsNumber ;
2043 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
2049 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
2050 // will wait for data(s) from node(s) not executed or not executing for ever
2052 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2053 return false ; // Loop in the Graph
2055 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
2056 bool ChangeCount = false ;
2057 // We update now the number of InPorts with a link that are waiting for a value
2058 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2059 if ( _DecrInPortsNumber[ i ] ) {
2060 // int prevcount = _CnxInPortsNumber[ i ] ;
2061 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
2062 _DecrInPortsNumber[ i ] = 0 ;
2063 ChangeCount = true ;
2064 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
2065 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
2068 // If there is no loop and if the number of InPorts with a link that are waiting for a value
2069 // does not change, the sort is finished. But there is also NotSortedNumber ...
2070 // if ( !ChangeCount )
2072 if ( NotSortedNumber ) {
2073 _LevelsNumber += 1 ;
2077 int AllSortedNodes = 0 ;
2078 _HeadNodes = _SortedNodes[ 0 ] ;
2079 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
2080 // QueueNodes was used in the past in order to know if the execution of a graph is finished
2081 // But because of loop nodes that was changed. So that part of code is a "clutter"
2082 // Now a graph has finished its execution when the number of executing threads is zero
2083 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
2084 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
2085 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
2086 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
2090 if ( i == _QueueNodesSize && _LevelsNumber ) {
2091 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
2092 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
2094 // Computation of the maximum number of threads == the maximum number of nodes of all levels
2095 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2096 AllSortedNodes += _NodesNumber[ i ]+1 ;
2097 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
2098 _ThreadsMax = _NodesNumber[ i ] + 1 ;
2100 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
2101 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
2102 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
2103 _ParallelExecutionNodes = true ;
2104 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
2108 if ( _ParallelExecutionNodes ) {
2109 // cdebug << "Parallel Execution Nodes detected." << endl ;
2112 // cdebug << "No Parallel Execution Nodes detected." << endl ;
2114 if ( AllSortedNodes != GraphNodesSize() ) {
2115 cdebug << "Loop detected level " << _LevelsNumber << endl ;
2116 return false ; // Loop in the Graph
2119 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
2120 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
2123 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
2124 // There is no substreamgraph for nodes without StreamPorts
2125 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
2126 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
2127 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
2128 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
2129 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
2130 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
2133 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2137 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2138 // the SubGraph of that nodes is unknown
2139 // There is no substreamgraph for nodes without StreamPorts
2140 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2141 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2142 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2143 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2144 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2145 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2146 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2149 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2154 // Computation of independent SubGraphs which have NO link between them
2155 cdebug << endl << "Computation of SubGraphs" << endl ;
2156 bool Graphs = true ;
2158 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2159 cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2160 << " Nodes :" << endl ;
2161 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2162 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2163 cdebug << " " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2165 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2166 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2167 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2168 // && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2169 // aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2170 int OldSub = aNode->SubGraph() ;
2171 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2172 cdebug << " " << aNode->Name() << " changed SubGraph "
2173 << aNode->LinkedNodes( k )->SubGraph() << endl ;
2175 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2177 for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2178 if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2179 GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2180 aSubNode->SubGraph( NewSub ) ;
2188 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2189 << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2193 cdebug << " LinkedNode " << aNode->LinkedNodes( k )->Name()
2194 << " initial SubGraph " << aNode->SubGraph() << endl ;
2195 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2207 cdebug << endl << "SubGraphs result : " << endl ;
2210 cdebug << endl << "One more time" << endl ;
2213 // Make a sequential renumbering of SubGraphs :
2214 _SubGraphsNumber = 0 ;
2215 int CurrGraphsNumber = 0;
2217 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2218 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2219 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2220 _SubGraphsNumber += 1 ;
2221 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2222 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2223 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2224 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2225 cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2226 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2234 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2235 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2236 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2237 if ( aNode->SubStreamGraph() < 0 ) {
2238 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2241 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2242 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2243 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2244 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2249 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2250 SubStreamGraphsNumber = 0 ;
2252 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2253 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2255 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2256 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2257 if ( aNode->SubStreamGraph() < 0 ) {
2258 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2259 // << " has NO streamport" << endl ;
2262 int CurStreamGraphsNumber ;
2263 if ( aNode->SubStreamGraph() > 0 ) {
2264 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2265 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2266 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2269 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2272 while ( RetVal != CurStreamGraphsNumber ) {
2273 RetVal = CurStreamGraphsNumber ;
2274 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2275 if ( RetVal != CurStreamGraphsNumber ) {
2276 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2277 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2278 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2279 aNode->SubStreamGraph( RetVal ) ;
2282 CurStreamGraphsNumber = RetVal ;
2285 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2286 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2292 // Make a sequential renumbering of SubGraphs :
2293 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2294 int CurrStreamGraphsNumber = 0 ;
2296 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2297 bool SearchCurrStreamGraphsNumber = true ;
2298 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2300 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2301 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2302 SearchCurrStreamGraphsNumber = false ;
2304 if ( CurrStreamGraphsNumber != count ) {
2305 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2306 // << " Level " << k << " n " << l << endl ;
2307 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2308 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2309 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2310 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2311 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2312 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2314 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2315 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2316 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2317 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2326 SubStreamGraphsNumber = count ;
2327 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2328 // int CurrStreamGraphsNumber ;
2329 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2330 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2331 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2332 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2333 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2334 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2342 ListPorts( *_Graph_fdebug , 0 ) ;
2345 cdebug_out << "GraphBase::Graph::Sort" << endl;
2349 bool GraphBase::Graph::ValidLoops() const {
2350 cdebug_in << "GraphBase::Graph::ValidLoops" << endl;
2353 GraphBase::ComputingNode * aNode ;
2354 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2355 aNode = GraphNodes( i ) ;
2356 if ( aNode->IsLoopNode() ) {
2357 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2358 GraphBase::EndOfLoopNode * anEndLoopNode ;
2359 anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ;
2360 if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
2361 cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name()
2365 else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
2366 cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name()
2372 cdebug_out << "GraphBase::Graph::ValidLoops true" << endl;
2376 // Controle de la coherence des noeuds de calcul
2377 // Enregistrement dans la liste des noeuds "tete" de graphe
2379 bool GraphBase::Graph::ComputingNodes() const {
2380 bool RetVal = true ;
2381 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
2383 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2384 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2385 // GraphEditor::Port * iP;
2387 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2388 // while ( aNode != aComputingNodesList.end() ) {
2390 GraphBase::ComputingNode * aNode ;
2391 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2392 aNode = GraphNodes( i ) ;
2393 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2394 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2395 // if ((*aNode)->GetNodeInPortsSize() == 0)
2396 // _headNodes.push_front(*aNode);
2398 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2399 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2400 if ( iP->IsNotConnected() ){
2401 // cdebug << "Le port d'entree " << iP->PortName()
2402 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2403 // << Name() << " n'est pas connecte "<< endl;
2409 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2410 bool oneOutPortConnected = false;
2411 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2412 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2413 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2414 oneOutPortConnected = true ;
2418 // cdebug << "Le port de sortie " << iP->PortName()
2419 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2420 // << Name() << " n'est pas connecte "<< endl;
2424 if (!oneOutPortConnected) {
2425 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2426 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2427 // _computingError.push_front(2);
2430 // return _computingError.size () ;
2434 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2435 bool RetVal = true ;
2438 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2439 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2440 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2441 if ( aNode->IsLoopNode() ) {
2442 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2443 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2444 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2445 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2446 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2447 aLoopNode , anInPort ) ) {
2448 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
2449 // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2450 // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
2458 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2459 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
2460 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2461 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2462 aLoopNode->CoupledNode() , anInPort ) ) {
2463 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
2464 // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2465 // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
2474 else if ( aNode->IsGOTONode() ) {
2475 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2476 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2477 if ( anOutGate->IsNotConnected() ) {
2478 RetVal = aGOTONode->CoupledNode() != NULL;
2480 RetVal = AddLink( aGOTONode , anOutGate ,
2481 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() );
2482 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
2483 // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2484 // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2491 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
2495 // Controle de la coherence des noeuds de calcul
2496 // Enregistrement dans la liste des noeuds "tete" de graphe
2498 bool GraphBase::Graph::DataServerNodes() const {
2500 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
2502 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2503 int i , j , ierr = 0 ;
2505 // if ( DataFlowDatas == NULL ) {
2506 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2510 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2511 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2513 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2515 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2517 ierr = CheckDataServerNodes() ;
2519 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2520 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2521 if ( GraphNodesSize() == 0 ) {
2525 GraphBase::ComputingNode * aNode ;
2526 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2527 aNode = GraphNodes( i ) ;
2528 // while ( aNode != aComputingNodesList.end() ) {
2529 if ( aNode->IsFactoryNode() ) {
2530 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2531 if ( !strlen( FaNode->Computer() ) ) {
2532 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2533 if ( !strlen( FaNode->Computer() ) ) {
2538 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2542 // For Outputs of the DataFlow :
2543 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2544 if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
2545 if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
2546 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2549 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2556 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2558 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2559 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2561 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2562 // while ( it != aDataServerNodesList.end() ) {
2563 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2564 // cerr << "Erreur dans le noeud serveur de donnees "
2565 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2566 // cerr << "A la fois importation et exportation de donnees" << endl;
2567 // _dataServerError.push_front(1);
2570 // if ((*it)->GetNodeOutPortsSize()) {
2571 // if ((*it)->GetNodeOutPortsSize()==1){
2572 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2573 // _headNodes.push_front(*it);
2576 // cerr << "Le port de sortie du noeud serveur de donnees "
2577 // << (*it)->Name() << " du graphe " << _G->Name()
2578 // << " n'est pas connecte "<< endl;
2579 // _dataServerError.push_front(4);
2583 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2584 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2585 // _dataServerError.push_front(2);
2589 // if ((*it)->GetNodeInPortsSize()) {
2590 // if ((*it)->GetNodeInPortsSize() > 1){
2591 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2592 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2593 // _dataServerError.push_front(3);
2596 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2597 // cerr << "Le port d'entree du noeud serveur de donnees "
2598 // << (*it)->Name() << " du graphe " << _G->Name()
2599 // << " n'est pas connecte "<< endl;
2600 // _dataServerError.push_front(5);
2606 // return _dataServerError.size ();
2607 return ( ierr == 0 ) ;
2610 SUPERV::GraphState GraphBase::Graph::PortState(
2611 const char* NodeName ,
2612 const char* ServiceParameterName ) {
2613 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2614 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2615 // << ServiceParameterName << " )" << endl ;
2619 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2621 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2623 GraphBase::OutPort *anOutPort ;
2624 anOutPort = aNode->GetChangeOutPort( aPort );
2625 if ( anOutPort == NULL ) {
2626 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2628 anOutPort = anInPort->GetOutPort() ;
2630 cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
2635 aRet = anOutPort->State() ;
2636 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2640 cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
2648 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
2649 const char* ToServiceParameterName ) {
2650 const CORBA::Any * aRet = new CORBA::Any() ;
2653 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
2654 // << ToServiceParameterName << endl ;
2655 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
2657 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2660 GraphBase::OutPort *anOutPort = NULL ;
2661 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2663 anOutPort = anInPort->GetOutPort() ;
2665 aRet = anOutPort->Value() ;
2666 cdebug << "OutPort value " << anOutPort->NodeName() << "("
2667 << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
2668 << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
2671 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2672 << ToServiceParameterName << " ERROR no OutPort" << endl ;
2676 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2677 << ToServiceParameterName << " ERROR no InPort" << endl ;
2681 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2682 << ToServiceParameterName << " ERROR no Node" << endl ;
2686 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
2690 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
2691 const char* FromServiceParameterName ) {
2692 const CORBA::Any * aRet = new CORBA::Any() ;
2695 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2696 // << FromServiceParameterName << endl ;
2697 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
2699 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2702 GraphBase::OutPort *anOutPort ;
2703 anOutPort = aNode->GetChangeOutPort( aPort );
2705 aRet = anOutPort->Value() ;
2708 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2709 << FromServiceParameterName << " ERROR no OutPort" << endl ;
2713 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2714 << FromServiceParameterName << " ERROR no Node" << endl ;
2718 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
2722 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
2723 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
2724 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
2726 RetVal->length( _NodesNumber[ aLevel ] + 1 );
2727 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
2728 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
2731 return ( RetVal._retn() ) ;
2734 bool GraphBase::Graph::StartComponent(const int aThread ,
2735 const char * aComputerContainer ,
2736 const char * ComponentName ,
2737 Engines::Container_var & myContainer ,
2738 Engines::Component_var & objComponent ) {
2739 cdebug_in << aThread
2740 << " GraphBase::Graph::StartComponent " << aComputerContainer
2741 << " " << ComponentName << endl;
2742 bool RetVal = true ;
2744 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
2745 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
2747 if ( CORBA::is_nil( objComponent ) ) {
2748 cdebug_out << aThread
2749 << " StartComponent cannot FindOrLoad " << aComputerContainer
2750 << " " << ComponentName << " ERROR" << endl;
2754 myContainer = LCC.FindContainer( aComputerContainer );
2755 if ( CORBA::is_nil( myContainer ) ) {
2756 cdebug_out << aThread
2757 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
2758 << aComputerContainer << "' ) Container does not exist ERROR"
2763 cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;