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 << ")" << endl;
531 bool RetVal = false ;
532 if ( !strcmp( OldNodeName , NewNodeName ) ) {
535 else if ( strcmp( Name() , OldNodeName ) ) {
536 int index = GetGraphNodeIndex( OldNodeName ) ;
537 int newindex = GetGraphNodeIndex( NewNodeName ) ;
538 if ( index >= 0 && index < _GraphNodesSize &&
539 ( newindex < 0 || newindex > _GraphNodesSize ) ) {
540 _GraphNodes[ index ]->Name( NewNodeName ) ;
541 _MapOfGraphNodes.erase( OldNodeName ) ;
542 SetGraphNodeIndex( NewNodeName , index ) ;
544 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
545 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
546 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
547 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
548 cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ;
550 cdebug << anOutPort->NodeName() ;
553 cdebug << "without link" ;
555 cdebug << " to " << i << ". " << anInPort->PortName() << " of " << NewNodeName ;
556 if ( !anInPort->IsNotConnected() ) {
557 if ( anOutPort->IsDataConnected() ) {
558 cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ;
561 GraphBase::ComputingNode * FromNode ;
562 if ( strcmp( anOutPort->NodeName() , Name() ) ) {
563 FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
568 cdebug << " fromConnected " << anOutPort->NodeName() << endl ;
569 if ( anInPort->IsDataStream() ) {
570 FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ;
573 FromNode->ReNameLinkedNode( OldNodeName , NewNodeName ) ;
576 char* OldNodePortName = new char[ strlen( OldNodeName ) +
577 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
578 char* NewNodePortName = new char[ strlen( NewNodeName ) +
579 strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 3 ] ;
580 strcpy( OldNodePortName , OldNodeName ) ;
581 // strcat( OldNodePortName , "\\" ) ;
582 strcat( OldNodePortName , "__" ) ;
583 strcat( OldNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
584 strcpy( NewNodePortName , NewNodeName ) ;
585 // strcat( NewNodePortName , "\\" ) ;
586 strcat( NewNodePortName , "__" ) ;
587 strcat( NewNodePortName , aNode->GetChangeNodeInPort( i )->PortName() ) ;
588 RetVal = anOutPort->ReNameInPort( OldNodePortName , NewNodePortName ) ;
589 delete [] OldNodePortName ;
590 delete [] NewNodePortName ;
595 cdebug << " not connected" << endl ;
602 cdebug << "ERROR Node not found" << endl ;
606 RetVal = Name( NewNodeName ) ;
609 cdebug_out << "GraphBase::Graph::ReNameNode RetVal " << RetVal << endl;
613 bool GraphBase::Graph::RemoveNode( const char* aNodeName ) {
614 cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << LinkedNodesSize() << " LinkedNodes :"
617 bool RetVal = false ;
618 int index = GetGraphNodeIndex( aNodeName ) ;
619 GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ;
620 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
621 cdebug << " " << i << ". " << LinkedNodes( i ) << endl ;
624 cdebug << "Graph::RemoveNode " << aNode->GetNodeInPortsSize() << " InPorts " << aNode->GetNodeOutPortsSize()
625 << " OutPorts" << endl ;
626 if ( aNode->GetNodeInPortsSize() ) {
627 for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) {
628 GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ;
629 cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") "
630 << anInPort->PortStatus() << " <-- " ;
631 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
633 cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ;
636 if ( !anInPort->IsNotConnected() ) {
638 if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) {
639 cdebug << " Data/Extern" << endl ;
642 GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ;
643 // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120.
644 if ( !FromNode->IsOneOfGOTONodes() ) {
645 if ( anInPort->IsDataStream() ) {
646 RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ;
649 RetVal = FromNode->RemoveLinkedNode( aNode ) ;
652 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
657 RetVal = anOutPort->RemoveInPort( anInPort ) ;
659 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
672 for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) {
673 GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ;
674 cdebug << "OutPort" << i << ". Remove " << anOutPort->InPortsSize()
675 << " InPortsof OutPort : " << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") "
676 << anOutPort->PortStatus() << " :" << endl ;
678 for ( j = anOutPort->InPortsSize() - 1 ; j >= 0 ; j-- ) {
679 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
680 cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " << anInPort->PortName() << ") "
681 << anInPort->PortStatus() << endl ;
682 if ( !anInPort->IsExternConnected() ) {
683 GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anInPort->NodeName() ) ;
684 RetVal = anInPort->RemoveOutPort() ;
686 cdebug << "anOutPort->RemoveOutPort Error RetVal " << RetVal << endl ;
689 if ( ( aNode->IsGOTONode() && ToNode->IsOneOfInLineNodes() ) ||
690 ( aNode->IsEndLoopNode() && ToNode->IsLoopNode( ) ) ) {
692 else if ( anOutPort->IsDataStream() ) {
693 RetVal = aNode->RemoveStreamLinkedNode( ToNode ) ;
696 RetVal = aNode->RemoveLinkedNode( ToNode ) ;
699 cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ;
702 RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ;
704 cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ;
710 cdebug << "Error RetVal " << RetVal << endl ;
717 _GraphNodesSize -= 1 ;
718 for ( i = index ; i < _GraphNodesSize ; i++ ) {
719 SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ;
720 _GraphNodes[ i ] = _GraphNodes[ i+1 ] ;
722 _GraphNodes.resize( _GraphNodesSize+1 ) ;
723 _MapOfGraphNodes.erase( aNodeName ) ;
728 cdebug << "Node not found ERROR " << index << endl ;
731 cdebug_out << "GraphBase::Graph::RemoveNode " << RetVal << endl;
735 bool GraphBase::Graph::AddLink( const char* FromNodeName ,
736 const char* FromServiceParameterName ,
737 const char* ToNodeName ,
738 const char* ToServiceParameterName ) {
739 // , const CORBA::Any aValue ) {
742 cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
743 << FromServiceParameterName << ") ---> " << ToNodeName << "("
744 << ToServiceParameterName << ") , aValue )" << endl;
746 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
747 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
749 GraphBase::OutPort *fromPort = NULL ;
750 GraphBase::InPort *toPort = NULL ;
753 fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
755 cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode("
756 << FromNodeName << ") not found." << endl ;
760 cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ;
763 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
765 cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode("
766 << ToNodeName << ") not found." << endl ;
770 cdebug << "ERROR AddLink toNode " << ToNodeName << " not found." << endl ;
773 RetVal = AddLink( fromNode , fromPort , toNode , toPort ) ;
776 if ( fromPort->IsGate() && toPort->IsGate() ) {
778 aValue <<= (long ) 1 ;
779 fromPort->Value( aValue ) ;
782 // const CORBA::Any * aDataValue = new CORBA::Any( aValue ) ;
783 // fromPort->Value( aDataValue ) ;
785 // fromPort->PortStatus( DataConnected );
788 cdebug_out << "GraphBase::Graph::AddLink " << RetVal << endl;
792 bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
793 GraphBase::OutPort *fromPort ,
794 GraphBase::ComputingNode *toNode ,
795 GraphBase::InPort *toPort ) {
799 cdebug << "ERROR AddLink fromNode not found." << endl ;
803 cdebug << "ERROR AddLink fromPort not found." << endl ;
808 cdebug << "ERROR AddLink toNode not found." << endl ;
812 cdebug << "ERROR AddLink toPort not found." << endl ;
815 if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) ||
816 ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) {
817 cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ;
820 if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL &&
821 toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) {
822 cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ;
826 cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
827 << fromPort->PortName() << " " << fromPort->PortStatus() << ") ---> " << toNode->Name() << "("
828 << toPort->PortName() << " " << toPort->PortStatus() << ") )" << endl;
829 if ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) {
830 if ( !fromPort->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
831 cdebug_out << "GraphBase::Graph::AddLink(" << fromNode->Name() << "("
832 << fromPort->PortName() << " " << fromPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
836 if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
837 if ( !toPort->GetOutPort()->RemoveInPort() ) { // There is only one ===> RemoveOutPort()
838 cdebug_out << "GraphBase::Graph::AddLink(" << toNode->Name() << "("
839 << toPort->PortName() << " " << toPort->PortStatus() << ") RemoveInPort ERROR " << endl ;
843 else if ( toPort->IsPortConnected() && !toNode->IsEndSwitchNode() ) {
844 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
845 toPort->GetOutPort()->PortName() ,
846 toNode->Name() , toPort->PortName() ) ) {
847 cdebug_out << "RemoveLink(AddLink) toPort->GetOutPort()->NodeName() RemoveLink Error." << endl ;
852 if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() &&
853 !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() &&
854 toPort->GetOutPort() ) {
855 if ( !strcmp( toPort->GetOutPort()->NodePortName() ,
856 fromPort->NodePortName() ) ) {
857 cdebug << "Link already exists" << endl ;
858 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
861 else if ( toPort->IsDataConnected() || toPort->IsExternConnected() ) {
862 toPort->GetOutPort()->RemoveInPort( toPort ) ; //dbg
864 else if ( fromNode->IsGOTONode() ) {
865 if ( !RemoveLink( toPort->GetOutPort()->NodeName() ,
866 toPort->GetOutPort()->PortName() ,
867 toNode->Name() , toPort->PortName() ) ) {
868 cdebug << "RemoveLink(AddLink) Error."
870 cdebug_out << "GraphBase::Graph::AddLink" << endl;
873 if ( fromPort->InPortsSize() ) {
874 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
875 fromPort->ChangeInPorts(0)->NodeName() ,
876 fromPort->ChangeInPorts(0)->PortName() ) ) {
877 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
878 cdebug_out << "GraphBase::Graph::AddLink" << endl;
883 else if ( !toNode->IsEndSwitchNode() ||
884 ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
885 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
886 toNode->Name() , toPort->PortName() ) ) {
887 cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
888 cdebug_out << "GraphBase::Graph::AddLink" << endl;
893 else if ( fromNode->IsGOTONode() && fromPort->InPortsSize() ) {
894 if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
895 fromPort->ChangeInPorts(0)->NodeName() ,
896 fromPort->ChangeInPorts(0)->PortName() ) ) {
897 cdebug << "RemoveLink(AddLink) fromNode->IsGOTONode Error." << endl ;
898 cdebug_out << "GraphBase::Graph::AddLink" << endl;
902 else if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) &&
903 ( toPort->IsDataConnected() || toPort->IsExternConnected() ) ) {
904 fromPort->RemoveInPort( toPort ) ; //dbg
906 else if ( ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) &&
907 ( fromPort->IsDataConnected() || fromPort->IsExternConnected() ) ) {
908 fromPort->RemoveInPort() ; // There is only one
912 if ( toNode->IsEndSwitchNode() && !toPort->IsGate() ) {
913 // if ( !toPort->IsEndSwitch() || !fromPort->AddInPort( toPort ) ) {
914 if ( !fromPort->AddInPort( toPort ) ) {
915 cdebug << "toNode->IsEndSwitchNode() : !fromPort->AddInPort( toPort ) AddLink Error."
917 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
920 if ( !toPort->IsDataStream() ) {
921 toPort->Kind( SUPERV::EndSwitchParameter ) ;
924 else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort
925 cdebug << "!fromPort->AddLink Error." << endl ;
926 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
930 if ( fromNode->IsGOTONode() && ( !fromPort->IsGate() || !toPort->IsGate() ||
931 toNode->IsEndLoopNode() || toNode->IsEndSwitchNode() ) ) {
932 cdebug << "toPort->AddLink Error( fromNode->IsGOTONode() && toNode->IsEndInLineNode() )." << endl ;
933 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
936 else if ( !fromNode->IsSwitchNode() && fromPort->IsParam() && toPort->IsGate() ) {
937 cdebug << "toPort->AddLink Error( fromPort->IsParam() && toPort->IsGate())." << endl ;
938 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
941 else if ( !toNode->IsEndSwitchNode() && !toNode->IsEndLoopNode() ) {
942 if ( !toPort->AddOutPort( fromPort ) ) { // --> Unique OutPort of the InPort
943 cdebug << "toPort->AddLink Error." << endl ;
944 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
949 toPort->AddOutPort( fromPort ) ;
952 if ( ( fromNode->IsGOTONode() && toNode->IsOneOfInLineNodes() ) ||
953 ( fromNode->IsEndLoopNode() && toNode->IsLoopNode() ) ) {
954 cdebug << "AddLink fromPort->PortStatus( PortConnected ) "
955 << "GOTONode/EndLoopNode-->InLineNode/LoopNode/SwitchNode "
956 << fromNode->Name() << " " << fromPort->PortName()
957 << " InLineNode/LoopNode_ConnectedInPortsNumber "
958 << toNode->ConnectedInPortsNumber() << endl;
959 if ( fromNode->IsGOTONode() ) {
960 fromPort->Kind( SUPERV::GOTOParameter ) ;
962 fromPort->PortStatus( PortConnected ); // GOTO - Loop
964 else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) {
965 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( DataConnected ) : "
966 << fromNode->Name() << " " << fromPort->PortName() << endl ;
967 fromPort->PortStatus( ExternConnected );
969 else if ( toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) {
970 cdebug << "AddLink IsDataFlow/StreamNode fromPort->PortStatus( ExternConnected ) : "
971 << fromNode->Name() << " " << fromPort->PortName() << endl ;
972 fromPort->PortStatus( ExternConnected ) ;
975 cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode "
976 << fromNode->Name() << " " << fromPort->PortName() << " "
977 << fromPort->Kind() << " OldPortStatus " << fromPort->PortStatus() << " -> " << toNode->Name()
978 << " " << " " << toPort->PortName() << " " << toPort->Kind() << endl;
979 fromPort->PortStatus( PortConnected );
980 if ( fromPort->IsDataStream() && toPort->IsDataStream() ) {
981 fromNode->AddStreamLinkedNode( toNode ) ;
984 fromNode->AddLinkedNode( toNode ) ;
987 if ( fromNode->IsSwitchNode() ) {
988 if ( !fromPort->IsDataStream() ) {
989 if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
990 fromPort->Kind( SUPERV::SwitchParameter ) ;
992 else if ( !fromPort->IsGate() && !toPort->IsGate() ){
993 fromPort->Kind( SUPERV::InLineParameter ) ;
996 if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
997 GraphBase::InLineNode * anEndSwitchNode ;
998 anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
999 GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
1000 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1001 if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
1002 !strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
1003 anOutPort->IsGate() ) {
1004 if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
1005 anEndSwitchNode->Name() ,
1006 anInPort->PortName() ) ) {
1007 cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
1009 cdebug_out << "GraphBase::Graph::AddLink 0" << endl;
1015 // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ;
1016 cdebug_out << "GraphBase::Graph::AddLink 1" << endl;
1020 bool GraphBase::Graph::RemoveLink( const char* FromNodeName ,
1021 const char* FromServiceParameterName ,
1022 const char* ToNodeName ,
1023 const char* ToServiceParameterName ) {
1024 cdebug_in << "GraphBase::Graph::RemoveLink from " << FromNodeName << "(" << FromServiceParameterName << ")"
1025 << " to " << ToNodeName << "(" << ToServiceParameterName << ")" << endl;
1026 bool RetVal = false ;
1027 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1029 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1030 if ( anInPort && ( anInPort->IsPortConnected() ||
1031 anInPort->IsDataConnected() ||
1032 anInPort->IsExternConnected() ) ) {
1033 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1034 RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> :
1035 // anInPort->RemoveOutPort() ;
1036 const char * FromNodeName = anOutPort->NodeName() ;
1037 GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ;
1040 if ( anInPort->IsDataStream() ) {
1041 fromNode->RemoveStreamLinkedNode( toNode ) ;
1044 fromNode->RemoveLinkedNode( toNode ) ;
1047 if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
1048 anOutPort->Kind( SUPERV::InLineParameter ) ;
1053 cdebug_out << "GraphBase::Graph::RemoveLink " << RetVal << endl;
1057 bool GraphBase::Graph::GetLink(const char* ToNodeName ,
1058 const char* ToServiceParameterName ,
1059 char** FromNodeName ,
1060 char** FromServiceParameterName ) {
1061 // cdebug_in << "GraphBase::Graph::GetLink " << ToNodeName << "("
1062 // << ToServiceParameterName << ")" << endl;
1063 bool RetVal = false ;
1064 GraphBase::ComputingNode * toNode = GetChangeGraphNode( ToNodeName ) ;
1066 GraphBase::InPort * anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1067 if ( anInPort && !anInPort->IsNotConnected() ) {
1068 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1069 *FromNodeName = my_strdup( anOutPort->NodeName() ) ;
1070 *FromServiceParameterName = my_strdup( anOutPort->PortName() ) ;
1074 cdebug << "GraphBase::Graph::GetLink ERROR no InPort or NotConnected " << ToNodeName
1075 << " " << ToServiceParameterName << " " << RetVal << endl;
1079 cdebug << "GraphBase::Graph::GetLink ERROR no Node " << ToNodeName << " " << RetVal
1082 // cdebug_out << "GraphBase::Graph::GetLink " << RetVal << endl;
1086 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1087 const char* ToServiceParameterName ,
1088 const CORBA::Any aValue ) {
1089 bool RetVal = false ;
1090 cdebug_in << "GraphBase::Graph::AddInputData(" << ToNodeName << ","
1091 << ToServiceParameterName << " , Any " ;
1092 switch (aValue.type()->kind()) {
1093 case CORBA::tk_string:
1096 cdebug << t << " (string) " ;
1098 case CORBA::tk_double:
1101 cdebug << d << " (double) " ;
1103 case CORBA::tk_long:
1106 cdebug << l << " (long) " ;
1108 case CORBA::tk_objref:
1109 cdebug << "(object reference) " ;
1112 cdebug << "(other(tk_string(" << CORBA::tk_string << "),tk_double(" << CORBA::tk_double << "),tk_long("
1113 << CORBA::tk_long << "),tk_objref)(" << CORBA::tk_objref << ")) ERROR : " << aValue.type()->kind() ;
1116 cdebug << " ) in Graph " << Name() << endl;
1118 GraphBase::ComputingNode *toNode ;
1119 GraphBase::InPort *toPort ;
1122 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1123 toNode = GetChangeGraphNode( aNodeName ) ;
1124 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1126 toPort = toNode->GetChangeInPort( aPortName ) ;
1127 if ( toPort && !toPort->IsDataConnected() ) {
1128 toPort->RemoveOutPort() ;
1136 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1137 cdebug << "Graph::AddInputData In" << i << " " << *GetNodeOutDataNodePort(i) << endl ;
1139 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1140 cdebug << "Graph::AddInputData Out" << i << " " << *GetNodeInDataNodePort(i) << endl ;
1143 if ( toNode && toPort ) {
1144 GraphBase::OutPort *fromDataNodePort = NULL ;
1145 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1146 if ( fromDataNodePort && fromDataNodePort->GetInPort( toPort ) ) {
1147 fromDataNodePort->RemoveInPort( toPort ) ;
1149 cdebug << "Try AddLink " << toPort->NodePortName() << " : " << Name() << "( "
1150 << fromDataNodePort->PortName() << " ) -->" << toNode->Name() << "( "
1151 << toPort->PortName() << " )" << endl ;
1152 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1155 fromDataNodePort->Value( aValue ) ;
1156 fromDataNodePort->PortStatus( DataConnected ) ;
1160 cdebug << "ERROR Node and/or Port not found : " << aNodeName << " " << aPortName << endl ;
1165 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1169 // Used in the Executor in order to change an Input Value and ReRun
1170 bool GraphBase::Graph::ChangeInputData( const char * ToNodeName ,
1171 const char * ToServiceParameterName ,
1172 const CORBA::Any aValue ) {
1173 bool RetVal = false ;
1174 cdebug_in << "GraphBase::Graph::ChangeInputData( '" << ToNodeName << "' , '"
1175 << ToServiceParameterName << "' , Any " ;
1176 switch (aValue.type()->kind()) {
1177 case CORBA::tk_string:
1180 cdebug << t << " (string) " ;
1182 case CORBA::tk_double:
1185 cdebug << d << " (double) " ;
1187 case CORBA::tk_long:
1190 cdebug << l << " (long) " ;
1192 case CORBA::tk_objref:
1193 cdebug << "(object reference) " ;
1196 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1199 cdebug << " ) in Graph " << Name() << endl;
1201 GraphBase::ComputingNode * toNode ;
1202 GraphBase::InPort * toPort = NULL ;
1205 NodePort( ToNodeName , ToServiceParameterName , &aNodeName , &aPortName ) ;
1206 toNode = GetChangeGraphNode( aNodeName ) ;
1207 cdebug << "in Graph " << Name() << " aNodeName " << aNodeName << " aPortName " << aPortName << endl;
1209 toPort = toNode->GetChangeInPort( aPortName ) ;
1210 if ( toPort && toPort->IsDataConnected() ) {
1211 GraphBase::OutPort * fromPort = toPort->GetOutPort();
1214 fromPort->Value( aValue ) ;
1215 fromPort->PortStatus( DataConnected ) ;
1216 toPort->State( SUPERV::ReadyState ) ;
1219 cdebug << "ERROR ChangeInputData fromPort not found" << endl ;
1223 cdebug << "ERROR ChangeInputData toPort not found" << endl ;
1227 cdebug << "ERROR ChangeInputData Node not found : " << ToNodeName << endl ;
1230 cdebug_out << "GraphBase::Graph::ChangeInputData" << endl;
1234 // To restore InputData in CreateService
1235 bool GraphBase::Graph::AddInputData( const char* ToNodeName ,
1236 const char* ToServiceParameterName ,
1237 const CORBA::Any ** aValue ) {
1238 bool RetVal = false ;
1239 cdebug_in << "GraphBase::Graph::AddInputData( " << ToNodeName << " , "
1240 << ToServiceParameterName << ", **Any " ;
1241 const CORBA::Any theValue = **aValue ;
1242 switch (theValue.type()->kind()) {
1243 case CORBA::tk_string:
1246 cdebug << t << " (string) " ;
1248 case CORBA::tk_double:
1251 cdebug << d << " (double) " ;
1253 case CORBA::tk_long:
1256 cdebug << l << " (long) " ;
1258 case CORBA::tk_objref:
1259 cdebug << "(object reference) " ;
1262 cdebug << "(other(tk_string,tk_double,tk_long,tk_objref)) ERROR";
1265 cdebug << ") of Graph " << Name() << endl;
1267 GraphBase::ComputingNode *toNode = GetChangeGraphNode( ToNodeName ) ;
1270 GraphBase::InPort *toPort = NULL ;
1271 GraphBase::OutPort *fromDataNodePort = NULL ;
1272 toPort = toNode->GetChangeInPort( ToServiceParameterName ) ;
1273 fromDataNodePort = GraphBase::DataNode::GetChangeInDataNodePort( toPort->NodePortName() ) ;
1274 cdebug << "Try AddLink " << Name() << "( " << fromDataNodePort << " ) -->"
1275 << toNode->Name() << "( " << toPort->PortName() << " )" << endl ;
1276 RetVal = AddLink( (GraphBase::ComputingNode * ) this , fromDataNodePort ,
1279 fromDataNodePort->Value( aValue ) ;
1280 fromDataNodePort->PortStatus( DataConnected ) ;
1284 cdebug << "ERROR Node not found " << ToNodeName << " ERROR. Known nodes :" << endl ;
1285 map< string , int >::iterator aMapOfGraphNodesIterator ;
1287 for ( aMapOfGraphNodesIterator = _MapOfGraphNodes.begin() ;
1288 aMapOfGraphNodesIterator != _MapOfGraphNodes.end() ; aMapOfGraphNodesIterator++ ) {
1289 cdebug << "MapOfGraphNodes " << i++ << " " << aMapOfGraphNodesIterator->first << " --> "
1290 << aMapOfGraphNodesIterator->second << endl ;
1294 cdebug_out << "GraphBase::Graph::AddInputData " << RetVal << endl;
1298 bool GraphBase::Graph::AddOutputData( const char* FromNodeName ,
1299 const char* FromServiceParameterName ,
1300 const CORBA::Any aValue ) {
1301 bool RetVal = true ;
1302 cdebug_in << "GraphBase::Graph::AddOutputData(" << FromNodeName << ","
1303 << FromServiceParameterName << ")" << endl;
1304 GraphBase::ComputingNode *fromNode = GetChangeGraphNode( FromNodeName ) ;
1306 GraphBase::OutPort *anOutPort = NULL ;
1309 anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ;
1310 // toDataNodePort = GraphBase::DataNode::GetChangeOutDataNodePort( fromPort->NodePortName() ) ;
1311 // RetVal = AddLink( fromNode , fromPort ,
1312 // (GraphBase::ComputingNode * ) this , toDataNodePort ) ;
1313 anOutPort->Value( aValue ) ;
1314 anOutPort->State( SUPERV::ReadyState ) ;
1315 anOutPort->Done( true ) ;
1316 cdebug << *anOutPort ;
1318 anOutPort->StringValue( *_fdebug ) ;
1323 cdebug << "ERROR Node not found" << endl ;
1326 cdebug_out << "GraphBase::Graph::AddOutputData " << RetVal << endl;
1330 map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() {
1331 return _MapOfServiceNames ; }
1333 GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) {
1334 return _MapOfServiceNames[ name ] ;
1337 bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) {
1338 GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ;
1340 cdebug << "SetServiceOfMap of " << aService->ServiceName()
1341 << " already in MapOfServiceNames : erase" << endl ;
1342 _MapOfServiceNames.erase( aService->ServiceName() ) ;
1344 _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ;
1345 cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ;
1349 int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) {
1350 GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ;
1351 if ( theService == NULL ) {
1354 return theService->NewInstance() ;
1357 void GraphBase::Graph::SetGraphPorts() {
1358 cdebug_in << "GraphBase::Graph::SetGraphPorts fill ports of Graph" << endl;
1360 for ( i = 0 ; i < GetNodeInDataNodePortsSize() ; i++ ) {
1361 GraphBase::OutPort * anOutPort = GetChangeNodeInDataNodePort( i ) ;
1362 cdebug << "SetGraphPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1363 << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << " " << anOutPort->State() << endl ;
1364 if ( !anOutPort->IsGate() ) {
1365 anOutPort->PortStatus( ExternConnected ) ;
1368 for ( i = 0 ; i < GetNodeOutDataNodePortsSize() ; i++ ) {
1369 GraphBase::InPort * anInPort = GetChangeNodeOutDataNodePort( i ) ;
1370 cdebug << "SetGraphPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
1371 << " " << anInPort->Kind() << " " << anInPort->PortStatus() << " " << anInPort->State() << endl ;
1372 if ( !anInPort->IsGate() ) {
1373 GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
1374 anOutPort->PortStatus( ExternConnected ) ;
1377 cdebug_out << "GraphBase::Graph::SetGraphPorts" << endl;
1380 bool GraphBase::Graph::CreateService() {
1381 cdebug_in << "GraphBase::Graph::CreateService " << Name() << " GraphMacroLevel : " << GraphMacroLevel() << endl;
1382 bool RetVal = true ;
1383 SALOME_ModuleCatalog::Service aService ;
1385 GraphBase::ComputingNode * aToNode ;
1388 int instreamnbr = 0 ;
1390 int outstreamnbr = 0 ;
1391 vector< SUPERV::KindOfPort > InPortsKind ;
1392 vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ;
1393 vector< SUPERV::KindOfSchema > InKindOfSchema ;
1394 vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ;
1395 vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ;
1396 vector< SUPERV::KindOfPort > OutPortsKind ;
1397 vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ;
1398 vector< long > OutNumberOfValues ;
1399 // if ( GraphMacroLevel() == 0 ) {
1400 for ( dostore = 0 ; dostore <= 2 ; dostore++ ) {
1401 if ( dostore == 1 ) {
1402 aService.ServiceName = Name() ;
1403 aService.ServiceinParameter.length( 0 ) ;
1404 aService.ServiceinParameter.length( innbr ) ;
1405 aService.ServiceoutParameter.length( 0 ) ;
1406 aService.ServiceoutParameter.length( outnbr ) ;
1407 InPortsKind.resize( innbr ) ;
1408 InDataStreamDependency.resize( innbr ) ;
1409 InKindOfSchema.resize( innbr ) ;
1410 InKindOfInterpolation.resize( innbr ) ;
1411 InKindOfExtrapolation.resize( innbr ) ;
1412 OutPortsKind.resize( outnbr ) ;
1413 OutDataStreamDependency.resize( outnbr ) ;
1414 OutNumberOfValues.resize( outnbr ) ;
1416 else if ( dostore == 2 ) {
1417 cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr
1418 << " instreamnbr " << instreamnbr << " outnbr " << outnbr
1419 << " outstreamnbr " << outstreamnbr << endl ;
1420 DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ;
1421 aService.ServiceinParameter.length( innbr + instreamnbr ) ;
1422 aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ;
1423 InPortsKind.resize( innbr + instreamnbr ) ;
1424 InDataStreamDependency.resize( innbr + instreamnbr ) ;
1425 InKindOfSchema.resize( innbr + instreamnbr ) ;
1426 InKindOfInterpolation.resize( innbr + instreamnbr ) ;
1427 InKindOfExtrapolation.resize( innbr + instreamnbr ) ;
1428 OutPortsKind.resize( outnbr + outstreamnbr ) ;
1429 OutDataStreamDependency.resize( outnbr + outstreamnbr ) ;
1430 OutNumberOfValues.resize( outnbr + outstreamnbr ) ;
1432 if ( dostore == 0 ) {
1438 if ( dostore == 1 ) {
1442 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1443 aToNode = GraphNodes( i ) ;
1444 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1445 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1446 bool isfromcouplednode = false ;
1447 if ( !anInPort->IsNotConnected() ) {
1448 const char * aFromNodeName = anInPort->GetOutPort()->NodeName() ;
1449 GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( aFromNodeName ) ;
1450 cdebug << "GraphBase::Graph::CreateService aFromNodeName " << aFromNodeName << " aToNode "
1451 << aToNode->Name() << " InPort" << j << " " << anInPort->PortName() << endl ;
1452 if ( aFromNode && aFromNode->IsEndLoopNode() &&
1453 ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) {
1454 isfromcouplednode = true ;
1457 if ( !anInPort->IsGate() && !anInPort->IsLoop() &&
1458 ( !anInPort->IsPortConnected() ||
1459 ( anInPort->IsPortConnected() && isfromcouplednode ) ) ) {
1460 if ( dostore == 0 ) {
1461 cdebug << "CreateService " << aToNode->Name() << " Input port "
1462 << anInPort->PortName() << " " << anInPort->Kind() << " " << anInPort->PortStatus() ;
1463 if ( anInPort->GetOutPort() ) {
1464 cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ;
1467 if ( anInPort->IsDataStream() ) {
1474 else if ( ( dostore == 1 && !anInPort->IsDataStream() ) ||
1475 ( dostore == 2 && anInPort->IsDataStream() ) ) {
1476 aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ;
1477 aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ;
1478 InPortsKind[ innbr ] = anInPort->Kind() ;
1479 InDataStreamDependency[ innbr ] = anInPort->Dependency() ;
1480 if ( dostore == 2 && anInPort->IsDataStream() ) {
1481 ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] ,
1482 InKindOfInterpolation[ innbr ] ,
1483 InKindOfExtrapolation[ innbr ] ) ;
1485 cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " "
1486 << anInPort->Kind() << " " << anInPort->PortStatus() << endl ;
1490 else if ( dostore == 0 ) {
1491 cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName()
1492 << " " << anInPort->PortStatus() ;
1493 if ( anInPort->IsPortConnected() ) {
1494 cdebug << " is connected " ;
1497 cdebug << " is NOT connected " ;
1499 if ( anInPort->IsGate() ) {
1500 cdebug << " IsGate " ;
1502 if ( anInPort->GetOutPort() ) {
1503 cdebug << "DataConnected from " << *(anInPort->GetOutPort()) ;
1506 cdebug << "NOT DataConnected" ;
1511 GraphBase::ComputingNode * aFromNode = aToNode ;
1512 for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) {
1513 GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ;
1514 // cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] ";
1515 // if ( anOutPort ) {
1516 // cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ;
1519 // cdebug << " NULL" << endl ;
1521 if ( !aFromNode->IsGOTONode() ) {
1522 if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ||
1523 anOutPort->IsExternConnected() ) {
1524 if ( dostore == 0 ) {
1525 // cdebug << "CreateService " << aFromNode->Name() << " Output port "
1526 // << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1527 if ( anOutPort->IsDataStream() ) {
1534 else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) ||
1535 ( dostore == 2 && anOutPort->IsDataStream() ) ) {
1536 aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ;
1537 aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ;
1538 OutPortsKind[ outnbr ] = anOutPort->Kind() ;
1539 OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ;
1540 if ( dostore == 2 && anOutPort->IsDataStream() ) {
1541 OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1543 // cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " "
1544 // << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
1555 cdebug << "DataFlowNode ServiceName " << aService.ServiceName << " InPorts " << innbr
1556 << " OutPorts " << outnbr << endl ;
1557 for ( i = 0 ; i < innbr ; i++ ) {
1558 cdebug << "aService.ServiceinParameter[" << i << "].Parametertype "
1559 << aService.ServiceinParameter[i].Parametertype << " Parametername "
1560 << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ;
1561 if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1562 cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ;
1565 for ( i = 0 ; i < outnbr ; i++ ) {
1566 cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype "
1567 << aService.ServiceoutParameter[i].Parametertype << " Parametername "
1568 << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ;
1569 if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) {
1570 cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ;
1575 // DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ;
1576 for ( i = 0 ; i < innbr ; i++ ) {
1577 if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1578 GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername ,
1579 StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) ,
1580 InDataStreamDependency[ i ] ,
1581 SUPERV::DataStreamParameter ) ;
1582 anInPort->SetParams( InKindOfSchema[ i ] ,
1583 InKindOfInterpolation[ i ] ,
1584 InKindOfExtrapolation[ i ] ) ;
1585 // NOT A BUG : AddOutPort for an inport (Reversed service)
1586 anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort(
1589 aService.ServiceinParameter[ i ].Parametername ,
1590 aService.ServiceinParameter[ i ].Parametertype ,
1591 SUPERV::DataStreamParameter ,
1593 _Graph_prof_debug , _Graph_fdebug ) ;
1594 anInPort->Dependency( InDataStreamDependency[ i ] ) ;
1595 // Attention : revoir les reversed DataStreamPorts
1596 // anInPort->SetParams( InKindOfSchema[ i ] ,
1597 // InKindOfInterpolation[ i ] ,
1598 // InKindOfExtrapolation[ i ] ) ;
1599 cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1600 cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1604 GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ;
1605 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ;
1606 GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1607 _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ;
1608 cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ;
1609 cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind()
1613 for ( i = 0 ; i < outnbr ; i++ ) {
1614 if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) {
1615 GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername ,
1616 StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) ,
1617 OutDataStreamDependency[ i ] ,
1618 SUPERV::DataStreamParameter ) ;
1619 anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1620 // NOT A BUG : AddInPort for an outport (Reversed service)
1621 anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort(
1624 aService.ServiceoutParameter[ i ].Parametername ,
1625 aService.ServiceoutParameter[ i ].Parametertype ,
1626 SUPERV::DataStreamParameter ,
1628 _Graph_prof_debug , _Graph_fdebug ) ;
1629 anOutPort->Dependency( OutDataStreamDependency[ i ] ) ;
1630 // Attention : revoir les reversed DataStreamPorts
1631 // anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ;
1632 cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1633 cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1637 GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ;
1638 _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ;
1639 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1640 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1641 GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1642 _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ;
1643 cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ;
1644 cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind()
1648 // Restore input datas and links :
1649 DataStreamInPortsNumber( 0 ) ;
1650 DataStreamOutPortsNumber( 0 ) ;
1651 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1652 aToNode = GraphNodes( i ) ;
1653 DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ;
1654 DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ;
1655 for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) {
1656 GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ;
1657 if ( !anInPort->IsGate() && anInPort->IsDataConnected() ) {
1658 if ( !AddInputData( anInPort->NodeName() ,
1659 anInPort->PortName() ,
1660 anInPort->GetOutPort()->ValuePtr() ) ) {
1661 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1662 << anInPort->PortStatus() << " --> AddInputData ERROR" << endl ;
1666 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1667 << anInPort->PortStatus() << " --> AddInputData" << endl ;
1670 else if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
1671 if ( !AddLink( this , GetChangeInDataNodePort( anInPort->NodePortName() ) , aToNode , anInPort ) ) {
1672 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1673 << anInPort->PortStatus() << " --> AddInLink ERROR" << endl ;
1677 cdebug << "CreateService In" << j << " " << anInPort->NodeName() << "(" << anInPort->PortName() << ") "
1678 << anInPort->PortStatus() << " --> AddInLink" << endl ;
1682 for ( j = 0 ; j < aToNode->GetNodeOutPortsSize() ; j++ ) {
1683 GraphBase::OutPort *anOutPort = aToNode->GetChangeNodeOutPort(j) ;
1684 cdebug << "CreateService Out" << j << " " << anOutPort->NodeName() << "(" << anOutPort->PortName()
1685 << ") " << anOutPort->PortStatus() << " :" << endl ;
1686 if ( !anOutPort->IsGate() && anOutPort->IsNotConnected() && !aToNode->IsGOTONode() ) {
1687 GraphBase::InPort *anInPort = GetChangeOutDataNodePort( anOutPort->NodePortName() ) ;
1688 if ( !AddLink( aToNode , anOutPort , this , anInPort ) ) {
1689 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1690 << ") " << anInPort->PortStatus() << " AddOutLink ERROR" << endl ;
1694 cdebug << " --> " << Name() << "(" << anInPort->PortName()
1695 << ") " << anInPort->PortStatus() << " AddOutLink" << endl ;
1701 cdebug_out << "GraphBase::Graph::CreateService " << RetVal << endl;
1705 bool GraphBase::Graph::InLineServices() {
1706 cdebug_in << "GraphBase::Graph::InLineServices" << endl;
1711 ListPorts( *_Graph_fdebug , 0 ) ;
1714 GraphBase::InLineNode * aINode ;
1715 SALOME_ModuleCatalog::Service aService ;
1716 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1717 aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ;
1718 if ( aINode->IsOneOfInLineNodes() ) {
1719 // cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl;
1720 aService.ServiceName = aINode->ServiceName() ;
1721 aService.ServiceinParameter.length( 0 ) ;
1722 aService.ServiceoutParameter.length( 0 ) ;
1723 aINode->DataStreamInPortsNumber( 0 ) ;
1724 aINode->DataStreamOutPortsNumber( 0 ) ;
1726 int InStreamService = 0 ;
1727 for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) {
1728 if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) {
1730 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1731 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1732 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1733 << aINode->GetChangeNodeInPort(j)->PortName() << " ignored "
1734 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1735 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1738 else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) {
1739 aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ;
1740 aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1741 aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1742 aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ;
1743 aINode->IncrDataStreamInPorts() ;
1745 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1746 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1747 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1748 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1749 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1750 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1754 aService.ServiceinParameter.length( InService+1 ) ;
1755 aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ;
1756 aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ;
1758 cdebug << "GraphBase::Graph::InLineServices In" << j << " "
1759 << aINode->GetChangeNodeInPort(j)->Kind() << " "
1760 << aINode->GetChangeNodeInPort(j)->PortType() << " "
1761 << aINode->GetChangeNodeInPort(j)->PortName() << " "
1762 << aINode->GetChangeNodeInPort(j)->IsGate() << " "
1763 << aINode->GetChangeNodeInPort(j)->IsLoop() << endl;
1767 int OutService = 0 ;
1768 int OutStreamService = 0 ;
1769 for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) {
1770 // if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1771 if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) {
1773 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1774 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1775 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1776 << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored "
1777 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1778 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1781 else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) {
1782 aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ;
1783 aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1784 aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1785 aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ;
1786 aINode->IncrDataStreamOutPorts() ;
1788 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1789 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1790 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1791 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1792 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1793 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1797 aService.ServiceoutParameter.length( OutService+1 ) ;
1798 aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ;
1799 aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ;
1801 cdebug << "GraphBase::Graph::InLineServices Out" << j << " "
1802 << aINode->GetChangeNodeOutPort(j)->Kind() << " "
1803 << aINode->GetChangeNodeOutPort(j)->PortType() << " "
1804 << aINode->GetChangeNodeOutPort(j)->PortName() << " "
1805 << aINode->GetChangeNodeOutPort(j)->IsGate() << " "
1806 << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl;
1810 aINode->SetService( aService ) ;
1811 if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) {
1813 cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices"
1814 << " InStreamPort(" << aINode->DataStreamInPortsNumber()
1815 << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ;
1818 // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl;
1822 cdebug_out << "GraphBase::Graph::InLineServices" << endl;
1826 bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) {
1829 int NotSortedNumber = GraphNodesSize() ;
1831 cdebug_in << "GraphBase::Graph::Sort" << endl;
1832 if ( NotSortedNumber ) {
1834 _ParallelExecutionNodes = false ;
1835 _Sorted.resize( GraphNodesSize() ) ;
1836 _CnxInPortsNumber.resize( GraphNodesSize() ) ;
1837 _DecrInPortsNumber.resize( GraphNodesSize() ) ;
1838 if ( _NodesNumber.size() ) {
1839 _NodesNumber.resize( 0 ) ;
1840 _SortedNodes.resize( 0 ) ;
1843 // This is a simulation of the computation of the graph :
1844 // The initial state of nodes is :
1845 // - Sorted = false : the node is not sorted
1846 // - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link
1847 // - DecrInPortsNumber = 0 : there is no value available.
1849 cdebug << "GraphBase::Graph::Sort initial values :" << endl ;
1850 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1851 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
1852 cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ;
1853 for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) {
1854 cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ;
1858 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1859 _Sorted[ i ] = false ;
1860 _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
1861 _DecrInPortsNumber[ i ] = 0 ;
1862 // cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count "
1863 // << _CnxInPortsNumber[ i ] << endl ;
1866 // Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node
1867 // ==============================================================================
1868 while ( NotSortedNumber ) {
1871 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1872 cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
1873 << GraphNodes( i )->Name() << " count "
1874 << _CnxInPortsNumber[ i ] << endl ;
1875 if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
1876 // All inputs of GraphNodes( i ) are available : "AllDataReady"
1877 if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
1878 _NodesNumber.resize( _LevelsNumber+1 ) ;
1879 _SortedNodes.resize( _LevelsNumber+1 ) ;
1880 _NodesNumber[ _LevelsNumber ] = -1 ;
1882 // There is one more node at that level
1883 _NodesNumber[ _LevelsNumber ]++ ;
1884 (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
1885 (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
1886 _Sorted[ i ] = true ;
1888 NotSortedNumber -= 1 ;
1889 cdebug << GraphNodes( i )->Name() << " belongs to level "
1890 << _LevelsNumber << ". " << GraphNodes( i )->LinkedNodesSize() << " linkednodes" << endl ;
1891 // GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution :
1892 // So we loop over all nodes that have a link from that node
1893 // And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this
1894 // execution will give a value in DecrInPortsNumber : "SomeDataReady"
1895 for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
1896 // OutputPorts of GraphNodes( i ) will satisfy
1897 // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
1898 // GraphNodes( i )->LinkedNodes( j )
1899 GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ;
1900 int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ;
1901 cdebug << j << ". LinkedNode " << aLinkedNode->Name() ;
1902 if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) {
1903 cdebug << " _DecrInPortsNumber[ "
1904 << GetGraphNodeIndex( aLinkedNode->Name() )
1906 << _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ]
1907 << " += " << aLinkedInPortsNumber ;
1908 _DecrInPortsNumber[ GetGraphNodeIndex( aLinkedNode->Name() ) ] += aLinkedInPortsNumber ;
1914 // If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph
1915 // will wait for data(s) from node(s) not executed or not executing for ever
1917 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1918 return false ; // Loop in the Graph
1920 // cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
1921 bool ChangeCount = false ;
1922 // We update now the number of InPorts with a link that are waiting for a value
1923 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
1924 if ( _DecrInPortsNumber[ i ] ) {
1925 // int prevcount = _CnxInPortsNumber[ i ] ;
1926 _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ;
1927 _DecrInPortsNumber[ i ] = 0 ;
1928 ChangeCount = true ;
1929 // cdebug << " " << GraphNodes( i )->Name() << " count " << prevcount
1930 // << " --> new count " << _CnxInPortsNumber[ i ] << endl ;
1933 // If there is no loop and if the number of InPorts with a link that are waiting for a value
1934 // does not change, the sort is finished. But there is also NotSortedNumber ...
1935 // if ( !ChangeCount )
1937 if ( NotSortedNumber ) {
1938 _LevelsNumber += 1 ;
1942 int AllSortedNodes = 0 ;
1943 _HeadNodes = _SortedNodes[ 0 ] ;
1944 _HeadNodesSize = _SortedNodes[ 0 ].size() ;
1945 // QueueNodes was used in the past in order to know if the execution of a graph is finished
1946 // But because of loop nodes that was changed. So that part of code is a "clutter"
1947 // Now a graph has finished its execution when the number of executing threads is zero
1948 _QueueNodes = _SortedNodes[ _LevelsNumber ] ;
1949 _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ;
1950 for ( i = 0 ; i < _QueueNodesSize ; i++ ) {
1951 if ( !_QueueNodes[ i ]->IsGOTONode() ) {
1955 if ( i == _QueueNodesSize && _LevelsNumber ) {
1956 _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ;
1957 _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ;
1959 // Computation of the maximum number of threads == the maximum number of nodes of all levels
1960 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
1961 AllSortedNodes += _NodesNumber[ i ]+1 ;
1962 if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) {
1963 _ThreadsMax = _NodesNumber[ i ] + 1 ;
1965 cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : "
1966 << (_SortedNodes[ i ])[ 0 ]->Name() << endl ;
1967 for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) {
1968 _ParallelExecutionNodes = true ;
1969 cdebug << " " << (_SortedNodes[ i ])[ j ]->Name()
1973 if ( _ParallelExecutionNodes ) {
1974 // cdebug << "Parallel Execution Nodes detected." << endl ;
1977 // cdebug << "No Parallel Execution Nodes detected." << endl ;
1979 if ( AllSortedNodes != GraphNodesSize() ) {
1980 cdebug << "Loop detected level " << _LevelsNumber << endl ;
1981 return false ; // Loop in the Graph
1984 for ( i= 0 ; i <= _NodesNumber[ 0 ] ; i++ ) {
1985 (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ;
1988 // Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0)
1989 // There is no substreamgraph for nodes without StreamPorts
1990 for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) {
1991 (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ;
1992 (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ;
1993 (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ;
1994 if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) {
1995 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ;
1998 (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ;
2002 // Give a subgraph/substreamgraph number = 0 to all other nodes :
2003 // the SubGraph of that nodes is unknown
2004 // There is no substreamgraph for nodes without StreamPorts
2005 for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
2006 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2007 (_SortedNodes[ i ])[ j ]->Level( i ) ;
2008 (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ;
2009 (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
2010 if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) {
2011 (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ;
2014 (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ;
2019 // Computation of independent SubGraphs which have NO link between them
2020 cdebug << endl << "Computation of SubGraphs" << endl ;
2021 bool Graphs = true ;
2023 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2024 cdebug << endl << "LevelsNumber " << _LevelsNumber << " " << _NodesNumber[ i ]
2025 << " Nodes :" << endl ;
2026 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2027 GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
2028 cdebug << " " << aNode->Name() << " SubGraph " << aNode->SubGraph() << endl ;
2030 for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
2031 if ( aNode->LinkedNodes( k )->SubGraph() ) {
2032 if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() ) {
2033 // && aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
2034 // aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
2035 int OldSub = aNode->SubGraph() ;
2036 int NewSub = aNode->LinkedNodes( k )->SubGraph() ;
2037 cdebug << " " << aNode->Name() << " changed SubGraph "
2038 << aNode->LinkedNodes( k )->SubGraph() << endl ;
2040 for ( l = 0 ; l <= _LevelsNumber ; l++ ) {
2042 for ( m = 0 ; m <= _NodesNumber[ l ] ; m++ ) {
2043 if ( (_SortedNodes[ l ])[ m ]->SubGraph() == OldSub ) {
2044 GraphBase::ComputingNode * aSubNode = (_SortedNodes[ l ])[ m ] ;
2045 aSubNode->SubGraph( NewSub ) ;
2053 cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
2054 << " same SubGraph " << aNode->LinkedNodes( k )->SubGraph() << endl ;
2058 cdebug << " LinkedNode " << aNode->LinkedNodes( k )->Name()
2059 << " initial SubGraph " << aNode->SubGraph() << endl ;
2060 aNode->LinkedNodes( k )->SubGraph( aNode->SubGraph() ) ;
2072 cdebug << endl << "SubGraphs result : " << endl ;
2075 cdebug << endl << "One more time" << endl ;
2078 // Make a sequential renumbering of SubGraphs :
2079 _SubGraphsNumber = 0 ;
2080 int CurrGraphsNumber = 0;
2082 for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) {
2083 if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) {
2084 CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ;
2085 _SubGraphsNumber += 1 ;
2086 for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
2087 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2088 if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) {
2089 (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ;
2090 cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level "
2091 << i << " : " << (_SortedNodes[ i ])[ j ]->Name()
2099 // cdebug << endl << "Computation of SubStreamGraphs" << endl ;
2100 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2101 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2102 if ( aNode->SubStreamGraph() < 0 ) {
2103 // cdebug << "Graph " << aNode->Name() << " has NO streamport" << endl ;
2106 // cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> "
2107 // << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ;
2108 for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) {
2109 // cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ;
2114 // Computation of independent SubStreamGraphs which have NO StreamLink between them
2115 SubStreamGraphsNumber = 0 ;
2117 for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2118 // Loop for _NodesNumber[ ilevel ] nodes of the level ilevel
2120 for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) {
2121 GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ;
2122 if ( aNode->SubStreamGraph() < 0 ) {
2123 // cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name()
2124 // << " has NO streamport" << endl ;
2127 int CurStreamGraphsNumber ;
2128 if ( aNode->SubStreamGraph() > 0 ) {
2129 // cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name()
2130 // << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ;
2131 CurStreamGraphsNumber = aNode->SubStreamGraph() ;
2134 CurStreamGraphsNumber = SubStreamGraphsNumber+1 ;
2137 while ( RetVal != CurStreamGraphsNumber ) {
2138 RetVal = CurStreamGraphsNumber ;
2139 aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ;
2140 if ( RetVal != CurStreamGraphsNumber ) {
2141 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2142 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2143 if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) {
2144 aNode->SubStreamGraph( RetVal ) ;
2147 CurStreamGraphsNumber = RetVal ;
2150 if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) {
2151 SubStreamGraphsNumber = CurStreamGraphsNumber ;
2157 // Make a sequential renumbering of SubGraphs :
2158 // cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ;
2159 int CurrStreamGraphsNumber = 0 ;
2161 for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2162 bool SearchCurrStreamGraphsNumber = true ;
2163 for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) {
2165 for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) {
2166 if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2167 SearchCurrStreamGraphsNumber = false ;
2169 if ( CurrStreamGraphsNumber != count ) {
2170 // cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count
2171 // << " Level " << k << " n " << l << endl ;
2172 for ( i = k ; i <= _LevelsNumber ; i++ ) {
2173 for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
2174 if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2175 (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ;
2176 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " "
2177 // << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2179 else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) {
2180 // cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph()
2181 // << " != " << CurrStreamGraphsNumber << " Level " << i << " : "
2182 // << (_SortedNodes[ i ])[ j ]->Name() << endl ;
2191 SubStreamGraphsNumber = count ;
2192 // cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ;
2193 // int CurrStreamGraphsNumber ;
2194 // for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) {
2195 // for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) {
2196 // for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) {
2197 // if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) {
2198 // cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : "
2199 // << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ;
2207 ListPorts( *_Graph_fdebug , 0 ) ;
2210 cdebug_out << "GraphBase::Graph::Sort" << endl;
2214 // Controle de la coherence des noeuds de calcul
2215 // Enregistrement dans la liste des noeuds "tete" de graphe
2217 bool GraphBase::Graph::ComputingNodes() const {
2218 bool RetVal = true ;
2219 cdebug << "GraphExecutor::GraphControl::ComputingNodes ()" << endl;
2221 // list<GraphEditor::Node *> aComputingNodesList = _G->ComputingNodesList() ;
2222 // list<GraphEditor::Node *>::iterator aNode = aComputingNodesList.begin();
2223 // GraphEditor::Port * iP;
2225 // for (aNode = _G->ComputingNodesList().begin(); aNode !=_G->ComputingNodesList().end(); aNode++) {
2226 // while ( aNode != aComputingNodesList.end() ) {
2228 GraphBase::ComputingNode * aNode ;
2229 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2230 aNode = GraphNodes( i ) ;
2231 // Tous les ports d'entree de tous les noeuds de calcul sont bien connectes
2232 // Enregistrement eventuel dans la liste des noeuds "tete" de graphe
2233 // if ((*aNode)->GetNodeInPortsSize() == 0)
2234 // _headNodes.push_front(*aNode);
2236 for ( j = 1 ; j < aNode->GetNodeInPortsSize() ; j++ ) {
2237 const GraphBase::InPort *iP = aNode->GetNodeInPort(j);
2238 if ( iP->IsNotConnected() ){
2239 // cdebug << "Le port d'entree " << iP->PortName()
2240 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2241 // << Name() << " n'est pas connecte "<< endl;
2247 // Tous les noeuds de calcul ont au moins un port de sortie connecte
2248 bool oneOutPortConnected = false;
2249 for ( j = 1 ; j < aNode->GetNodeOutPortsSize() ; j++) {
2250 const GraphBase::OutPort *iP = aNode->GetNodeOutPort(j);
2251 if ( iP->IsPortConnected() || iP->IsDataConnected() ){
2252 oneOutPortConnected = true ;
2256 // cdebug << "Le port de sortie " << iP->PortName()
2257 // << " du noeud de calcul " << aNode->Name() << " du graphe "
2258 // << Name() << " n'est pas connecte "<< endl;
2262 if (!oneOutPortConnected) {
2263 // cdebug << "Le noeud de calcul " << aNode->Name() << " du graphe "
2264 // << Name() << " n'a aucun port de sortie connecte "<< endl;
2265 // _computingError.push_front(2);
2268 // return _computingError.size () ;
2272 bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) {
2273 bool RetVal = true ;
2276 cdebug_in << "GraphBase::Graph::LinkLoopNodes()" << endl;
2277 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2278 GraphBase::ComputingNode * aNode = GraphNodes( i ) ;
2279 if ( aNode->IsLoopNode() ) {
2280 GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ;
2281 for ( j = 0 ; j < aLoopNode->GetNodeInPortsSize() ; j++ ) {
2282 GraphBase::InPort *anInPort = aLoopNode->GetChangeNodeInPort(j) ;
2283 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2284 if ( !AddLink( aLoopNode->CoupledNode() , aLoopNode->CoupledNode()->GetChangeNodeOutPort( j ) ,
2285 aLoopNode , anInPort ) ) {
2286 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->CoupledNode()->Name()
2287 // << "( " << aLoopNode->CoupledNode()->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2288 // << aLoopNode->Name() << "( " << anInPort->PortName() << " )" << endl ;
2296 for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) {
2297 GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ;
2298 if ( !anInPort->IsGate() && anInPort->IsNotConnected() ) {
2299 if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) ,
2300 aLoopNode->CoupledNode() , anInPort ) ) {
2301 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( "
2302 // << aLoopNode->GetChangeNodeOutPort( j )->PortName() << " ) --> "
2303 // << aLoopNode->CoupledNode()->Name() << "( " << anInPort->PortName() << " )" << endl ;
2312 else if ( aNode->IsGOTONode() ) {
2313 GraphBase::GOTONode * aGOTONode = (GraphBase::GOTONode * ) aNode ;
2314 GraphBase::OutPort *anOutGate = aGOTONode->GetChangeNodeOutGate() ;
2315 if ( anOutGate->IsNotConnected() ) {
2316 RetVal = aGOTONode->CoupledNode() != NULL;
2318 RetVal = AddLink( aGOTONode , anOutGate ,
2319 aGOTONode->CoupledNode() , aGOTONode->CoupledNode()->GetChangeNodeInGate() );
2320 // cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aGOTONode->Name() << "( "
2321 // << anOutGate->PortName() << " ) --> " << aGOTONode->CoupledNode()->Name() << "( "
2322 // << aGOTONode->CoupledNode()->GetChangeNodeInGate()->PortName() << " )" << endl ;
2329 cdebug_out << "GraphBase::Graph::LinkLoopNodes() " << RetVal << endl;
2333 // Controle de la coherence des noeuds de calcul
2334 // Enregistrement dans la liste des noeuds "tete" de graphe
2336 bool GraphBase::Graph::DataServerNodes() const {
2338 cdebug << "GraphBase::Graph::DataServerNodes ()" << endl;
2340 // const GraphExecutor::InNode *DataFlowDatas = GetDataFlowDatas() ;
2341 int i , j , ierr = 0 ;
2343 // if ( DataFlowDatas == NULL ) {
2344 // MESSAGE( "No input data available in the DataFlow " << _G->Name() );
2348 // const GraphExecutor::InNode *DataFlowNode = _G->GetDataFlowNode() ;
2349 // MESSAGE( "DataServerNodes DataFlowNode : " << *DataFlowNode );
2351 // MESSAGE( "DataServerNodes DataFlowDatas : " << *DataFlowDatas );
2353 // cout are inversed because DataFlowDatas is a mirror node of the DataFlow
2355 ierr = CheckDataServerNodes() ;
2357 // list<GraphExecutor::InNode *> aComputingNodesList = _G->ComputingNodesList() ;
2358 // list<GraphExecutor::InNode *>::iterator aNode = aComputingNodesList.begin();
2359 if ( GraphNodesSize() == 0 ) {
2363 GraphBase::ComputingNode * aNode ;
2364 for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
2365 aNode = GraphNodes( i ) ;
2366 // while ( aNode != aComputingNodesList.end() ) {
2367 if ( aNode->IsFactoryNode() ) {
2368 GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ;
2369 if ( !strlen( FaNode->Computer() ) ) {
2370 // cdebug << "ComputerName missing for node " << FaNode->Name() ;
2371 if ( !strlen( FaNode->Computer() ) ) {
2376 // cdebug << ". " << FaNode->Computer() << " will be used." << endl ;
2380 // For Outputs of the DataFlow :
2381 for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) {
2382 if ( aNode->GetNodeOutPort(j)->IsNotConnected() ) {
2383 if ( aNode->GetNodeOutPort(j)->IsDataStream() ) {
2384 aNode->AddStreamLinkedNode( (GraphBase::ComputingNode *) this ) ;
2387 aNode->AddLinkedNode( (GraphBase::ComputingNode *) this ) ;
2394 // Chaque noeud dataserver ne possede qu'un seul port entree ou sortie et il est bien connecte
2396 // list<GraphExecutor::InNode *> aDataServerNodesList = _G->DataServerNodesList() ;
2397 // list<GraphExecutor::InNode *>::iterator it = aDataServerNodesList.begin() ;
2399 // for (it = _G->DataServerNodesList().begin(); it !=_G->DataServerNodesList().end(); it++){
2400 // while ( it != aDataServerNodesList.end() ) {
2401 // if ( (*it)->GetNodeOutPortsSize() && (*it)->GetNodeInPortsSize() ) {
2402 // cerr << "Erreur dans le noeud serveur de donnees "
2403 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2404 // cerr << "A la fois importation et exportation de donnees" << endl;
2405 // _dataServerError.push_front(1);
2408 // if ((*it)->GetNodeOutPortsSize()) {
2409 // if ((*it)->GetNodeOutPortsSize()==1){
2410 // if ( (*it)->GetNodeOutPort(0)->IsPortConnected() ){
2411 // _headNodes.push_front(*it);
2414 // cerr << "Le port de sortie du noeud serveur de donnees "
2415 // << (*it)->Name() << " du graphe " << _G->Name()
2416 // << " n'est pas connecte "<< endl;
2417 // _dataServerError.push_front(4);
2421 // cerr << "Plus d'une donnee importee du noeud serveur de donnees "
2422 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2423 // _dataServerError.push_front(2);
2427 // if ((*it)->GetNodeInPortsSize()) {
2428 // if ((*it)->GetNodeInPortsSize() > 1){
2429 // cerr << "Plus d'une donnee exportee vers le noeud serveur de donnees "
2430 // << (*it)->Name() << " du graphe " << _G->Name() << endl;
2431 // _dataServerError.push_front(3);
2434 // if ( !(*it)->GetNodeInPort(0)->IsPortConnected() ){
2435 // cerr << "Le port d'entree du noeud serveur de donnees "
2436 // << (*it)->Name() << " du graphe " << _G->Name()
2437 // << " n'est pas connecte "<< endl;
2438 // _dataServerError.push_front(5);
2444 // return _dataServerError.size ();
2445 return ( ierr == 0 ) ;
2448 SUPERV::GraphState GraphBase::Graph::PortState(
2449 const char* NodeName ,
2450 const char* ServiceParameterName ) {
2451 SUPERV::GraphState aRet = SUPERV::UndefinedState ;
2452 // cdebug << "GraphBase::Graph::PortState( " << NodeName << " , "
2453 // << ServiceParameterName << " )" << endl ;
2457 NodePort( NodeName , ServiceParameterName , &theNode , &aPort ) ;
2459 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2461 GraphBase::OutPort *anOutPort ;
2462 anOutPort = aNode->GetChangeOutPort( aPort );
2463 if ( anOutPort == NULL ) {
2464 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2466 anOutPort = anInPort->GetOutPort() ;
2468 cdebug << "ERROR GraphBase::Graph::PortState OutPort/InPort not found --> "
2473 aRet = anOutPort->State() ;
2474 // cdebug << "GraphBase::Graph::PortState --> " << aRet << endl ;
2478 cdebug << "ERROR GraphBase::Graph::PortState Node not found --> " << aRet
2486 const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName ,
2487 const char* ToServiceParameterName ) {
2488 const CORBA::Any * aRet = new CORBA::Any() ;
2491 // cdebug_in << "GraphBase::Graph::PortInData " << ToNodeName << " "
2492 // << ToServiceParameterName << endl ;
2493 NodePort( ToNodeName , ToServiceParameterName , &theNode , &aPort ) ;
2495 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2498 GraphBase::OutPort *anOutPort = NULL ;
2499 GraphBase::InPort *anInPort = aNode->GetChangeInPort( aPort );
2501 anOutPort = anInPort->GetOutPort() ;
2503 aRet = anOutPort->Value() ;
2504 cdebug << "OutPort value " << anOutPort->NodeName() << "("
2505 << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName()
2506 << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ;
2509 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2510 << ToServiceParameterName << " ERROR no OutPort" << endl ;
2514 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2515 << ToServiceParameterName << " ERROR no InPort" << endl ;
2519 cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " "
2520 << ToServiceParameterName << " ERROR no Node" << endl ;
2524 // cdebug_out << "GraphBase::Graph::PortInData " << endl ;
2528 const CORBA::Any * GraphBase::Graph::PortOutData( const char* FromNodeName ,
2529 const char* FromServiceParameterName ) {
2530 const CORBA::Any * aRet = new CORBA::Any() ;
2533 // cdebug_in << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2534 // << FromServiceParameterName << endl ;
2535 NodePort( FromNodeName , FromServiceParameterName , &theNode , &aPort ) ;
2537 GraphBase::ComputingNode * aNode = GetChangeGraphNode( theNode ) ;
2540 GraphBase::OutPort *anOutPort ;
2541 anOutPort = aNode->GetChangeOutPort( aPort );
2543 aRet = anOutPort->Value() ;
2546 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2547 << FromServiceParameterName << " ERROR no OutPort" << endl ;
2551 cdebug << "GraphBase::Graph::PortOutData " << FromNodeName << " "
2552 << FromServiceParameterName << " ERROR no Node" << endl ;
2556 // cdebug_out << "GraphBase::Graph::PortOutData " << endl ;
2560 SUPERV::ListOfStrings * GraphBase::Graph::LevelNodes(long aLevel ) {
2561 SUPERV::ListOfStrings_var RetVal = new SUPERV::ListOfStrings;
2562 if ( aLevel >= 0 && aLevel <= _LevelsNumber ) {
2564 RetVal->length( _NodesNumber[ aLevel ] + 1 );
2565 for ( i= 0 ; i <= _NodesNumber[ aLevel ] ; i++ ) {
2566 RetVal[i] = CORBA::string_dup( (_SortedNodes[ aLevel ])[ i ]->Name() ) ;
2569 return ( RetVal._retn() ) ;
2572 bool GraphBase::Graph::StartComponent(const int aThread ,
2573 const char * aComputerContainer ,
2574 const char * ComponentName ,
2575 Engines::Container_var & myContainer ,
2576 Engines::Component_var & objComponent ) {
2577 cdebug_in << aThread
2578 << " GraphBase::Graph::StartComponent " << aComputerContainer
2579 << " " << ComponentName << endl;
2580 bool RetVal = true ;
2582 SALOME_LifeCycleCORBA LCC( NamingService() ) ;
2583 objComponent = LCC.FindOrLoad_Component( aComputerContainer ,
2585 if ( CORBA::is_nil( objComponent ) ) {
2586 cdebug_out << aThread
2587 << " StartComponent cannot FindOrLoad " << aComputerContainer
2588 << " " << ComponentName << " ERROR" << endl;
2592 myContainer = LCC.FindContainer( aComputerContainer );
2593 if ( CORBA::is_nil( myContainer ) ) {
2594 cdebug_out << aThread
2595 << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '"
2596 << aComputerContainer << "' ) Container does not exist ERROR"
2601 cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl;