]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_ComputingNode.cxx
Salome HOME
1cce3b212b0687aa3df7b0db997bc2ed656fb14b
[modules/superv.git] / src / GraphBase / DataFlowBase_ComputingNode.cxx
1 //  SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : DataFlowBase_ComputingNode.cxx
8 //  Author : Jean Rahuel, CEA
9 //  Module : SUPERV
10 //  $Header:
11
12 using namespace std;
13 //#include <sstream>
14 //#include <iostream>
15
16 #include "DataFlowBase_StreamGraph.hxx"
17 //#include "DataFlowBase_LoopNode.hxx"
18
19 static void InitFields( //SUPERV::KindOfNode &_Kind ,
20                         SUPERV::SDate      &_FirstCreation ,
21                         SUPERV::SDate      &_LastModification ,
22                         char *             &_EditorRelease ,
23                         char *             &_Author ,
24                         char *             &_Comment ,
25                         //bool               &_HeadNode ,
26                         bool               &_GeneratedName ,
27                         //int                &_DataStreamInPortsNumber ,
28                         //int                &_DataStreamOutPortsNumber ,
29                         int                &_ConnectedInPortsNumber ,
30                         int                &_DecrConnectedInPortsNumber ) {
31                         //int                &_LinkedNodesSize ,
32                         //int                &_SubGraphNumber ) {
33   time_t T = time(NULL);
34   struct tm * Tm = localtime(&T);
35
36 //  _Kind = SUPERV::DataFlowGraph ;
37
38   _FirstCreation.Second = _LastModification.Second = Tm->tm_sec;
39   _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min;
40   _FirstCreation.Hour   = _LastModification.Hour   = Tm->tm_hour;
41   _FirstCreation.Day    = _LastModification.Day    = Tm->tm_mday;
42   _FirstCreation.Month  = _LastModification.Month  = Tm->tm_mon + 1;
43   _FirstCreation.Year   = _LastModification.Year   = Tm->tm_year + 1900; 
44
45   _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
46   strcpy( _EditorRelease , SuperVision_Version ) ;
47   _Author = NULLSTRING ;
48 //  _Computer = new char[ strlen( FACTORYSERVER ) + 1 ] ;
49 //  strcpy( _Computer  , FACTORYSERVER ) ;
50   _Comment = NULLSTRING ;
51
52 //  _SubGraphNumber = 0 ;
53 //  _HeadNode = false ;
54   _GeneratedName = false ;
55
56 //  _DataStreamInPortsNumber = 0 ;
57 //  _DataStreamOutPortsNumber = 0 ;
58
59   _ConnectedInPortsNumber = 0 ;
60   _DecrConnectedInPortsNumber = 0 ;
61 //  _LinkedNodesSize = 0 ;
62 //  _SubGraphNumber = 0 ;
63 }
64
65 GraphBase::ComputingNode::ComputingNode() :
66 //  GraphBase::PortsOfNode::PortsOfNode() {
67   GraphBase::StreamNode::StreamNode() {
68
69   InitFields( //_Kind ,
70               _FirstCreation ,
71               _LastModification ,
72               _EditorRelease ,
73               _Author ,
74               _Comment ,
75               //_HeadNode ,
76               _GeneratedName ,
77               //_DataStreamInPortsNumber ,
78               //_DataStreamOutPortsNumber ,
79               _ConnectedInPortsNumber ,
80               _DecrConnectedInPortsNumber ) ;
81               //_LinkedNodesSize ,
82               //_SubGraphNumber ) ;
83   Kind( SUPERV::DataFlowGraph ) ;
84   _NamingService = NULL ;
85   _Node = SUPERV::CNode::_nil() ;
86   _InNode = NULL ;
87   _ThreadNo = pthread_self() ;
88   cdebug << "GraphBase::Node::Node "  << this << " "  << endl ;
89
90 }
91
92 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
93                                          SALOME_NamingService* ptrNamingService ,
94                                          const char * aDataFlowName ,
95                                          const SUPERV::KindOfNode DataFlowkind ,
96                                          int * Graph_prof_debug ,
97                                          ofstream * Graph_fdebug ) :
98 //  GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) {
99   GraphBase::StreamNode::StreamNode( aDataFlowName , DataFlowkind ,
100                                      Graph_prof_debug , Graph_fdebug ) {
101
102 //  MESSAGE( "GraphBase::ComputingNode::ComputingNode " << aDataFlowName << " Graph_prof_debug " << Graph_prof_debug ) ;
103   InitFields( //_Kind ,
104               _FirstCreation ,
105               _LastModification ,
106               _EditorRelease ,
107               _Author ,
108               _Comment ,
109               //_HeadNode ,
110               _GeneratedName ,
111               //_DataStreamInPortsNumber ,
112               //_DataStreamOutPortsNumber ,
113               _ConnectedInPortsNumber ,
114               _DecrConnectedInPortsNumber ) ;
115               //_LinkedNodesSize ,
116               //_SubGraphNumber ) ;
117
118 //  Kind( SUPERV::DataFlowGraph ) ;
119   Kind( DataFlowkind ) ;
120   _ORB = CORBA::ORB::_duplicate( ORB ) ;
121   _NamingService = ptrNamingService ;
122   _Node = SUPERV::CNode::_nil() ;
123   _InNode = NULL ;
124   _ThreadNo = pthread_self() ;
125
126   if ( Graph_prof_debug ) {
127 //    MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug" ) ;
128 //    cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug" << endl ;
129     _Graph_prof_debug = Graph_prof_debug ;
130     _Graph_fdebug = Graph_fdebug ;
131     SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
132   }
133 //  else {
134 //    cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ;
135 //  }
136   DefPortsOfNode( ORB , SALOME_ModuleCatalog::Service() , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
137   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
138          << " Name '" << Name() << "' "  << _FirstCreation
139          << " "  << _LastModification << endl ;
140 }
141
142 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
143                                          SALOME_NamingService* ptrNamingService ,
144                                          const SALOME_ModuleCatalog::Service& aService ,
145                                          const char *NodeName ,
146                                          const SUPERV::KindOfNode akind ,
147                                          const SUPERV::SDate NodeFirstCreation ,
148                                          const SUPERV::SDate NodeLastModification  ,
149                                          const char * NodeEditorRelease ,
150                                          const char * NodeAuthor ,
151                                          const char * NodeComment ,
152                                          const bool   GeneratedName ,
153                                          const long   X ,
154                                          const long   Y ,
155                                          int * Graph_prof_debug ,
156                                          ofstream * Graph_fdebug ) :
157 //  GraphBase::PortsOfNode::PortsOfNode() {
158   GraphBase::StreamNode::StreamNode( NodeName , akind , Graph_prof_debug , Graph_fdebug ) {
159
160   _ORB = CORBA::ORB::_duplicate( ORB ) ;
161   _NamingService = ptrNamingService ;
162   _Node = SUPERV::CNode::_nil() ;
163   _InNode = NULL ;
164   _ThreadNo = pthread_self() ;
165
166   Kind( akind ) ;
167 //  _Kind = akind ;
168
169   time_t T = time(NULL);
170   struct tm * Tm = localtime(&T);
171
172   _FirstCreation.Second = _LastModification.Second = Tm->tm_sec;
173   _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min;
174   _FirstCreation.Hour   = _LastModification.Hour   = Tm->tm_hour;
175   _FirstCreation.Day    = _LastModification.Day    = Tm->tm_mday;
176   _FirstCreation.Month  = _LastModification.Month  = Tm->tm_mon + 1;
177   _FirstCreation.Year   = _LastModification.Year   = Tm->tm_year + 1900; 
178
179   if ( NodeEditorRelease != NULLSTRING ) {
180     _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ;
181     strcpy( _EditorRelease , NodeEditorRelease ) ;
182   }
183   else {
184     _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
185     strcpy( _EditorRelease , SuperVision_Version ) ;
186   }
187
188   if ( NodeAuthor != NULLSTRING ) {
189     _Author = new char[ strlen( NodeAuthor ) + 1 ] ;
190     strcpy( _Author  , NodeAuthor ) ;
191   }
192   else {
193     _Author = NULLSTRING ;
194   }
195
196   if ( NodeComment != NULLSTRING ) {
197     _Comment = new char[ strlen( NodeComment ) + 1 ] ;
198     strcpy( _Comment  , NodeComment ) ;
199   }
200   else {
201     _Comment = NULLSTRING ;
202   }
203
204 //  _SubGraphNumber = 0 ;
205 //  _HeadNode = false ;
206   _GeneratedName = GeneratedName ;
207
208 //  const char *aNodeName = NodeName ;
209 //  _Name = new char[strlen(aNodeName)+1];
210 //  strcpy(_Name , aNodeName);
211
212 //  _DataStreamInPortsNumber = 0 ;
213 //  _DataStreamOutPortsNumber = 0 ;
214
215   _ConnectedInPortsNumber = 0 ;
216   _DecrConnectedInPortsNumber = 0 ;
217 //  _LinkedNodesSize = 0 ;
218
219   _X = X ;
220   _Y = Y ;
221
222   _Graph_prof_debug = Graph_prof_debug ;
223   _Graph_fdebug = Graph_fdebug ;
224 //  MESSAGE( "GraphBase::ComputingNode::ComputingNode " << NodeName
225 //           << " _Graph_prof_debug " << _Graph_prof_debug ) ;
226   SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
227   cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << NodeName << ","
228             << akind << ")" << endl;
229   
230
231   DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
232   cdebug << "GraphBase::ComputingNode::ComputingNode "  << this 
233          << " Name '" << Name()
234          << "' KindOfNode " << Kind()
235          << " ServiceName '" << ServiceName() << "' In(" << ServiceInParameter().length()
236          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
237
238   cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl;
239 }
240
241 GraphBase::ComputingNode::~ComputingNode() {
242   cdebug << "GraphBase::ComputingNode::~ComputingNode "  << this 
243          << " Name() "<< Name() << " _Comment "
244          << (void *) _Comment << " "  << _Comment << " "  << endl ;
245 }
246
247 //->StreamNode bool GraphBase::ComputingNode::Name( const char * aName) {
248 //->StreamNode   cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl;
249 //->StreamNode   if ( _Name ) {
250 //->StreamNode     cdebug << "GraphBase::ComputingNode::ReName "  << _Name << " --> " << aName << endl ;
251 //->StreamNode     delete [] _Name ;
252 //->StreamNode   }
253 //->StreamNode   _Name = new char[strlen(aName)+1] ;
254 //->StreamNode   strcpy( _Name , aName ) ;
255 //->StreamNode   cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl;
256 //->StreamNode   return true ;
257 //->StreamNode }
258
259 SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const {
260 //  cdebug << "GraphBase::ComputingNode::FirstCreation "
261 //         << " Name '" << Name() << "' "  << _FirstCreation << " "  
262 //         << _LastModification << endl ;
263   return _FirstCreation;
264 }
265
266 SUPERV::SDate GraphBase::ComputingNode::LastModification () const {
267   return _LastModification ;
268 }
269
270 void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) {
271   _FirstCreation = aDate ;
272 }
273
274 void GraphBase::ComputingNode::LastModification(const SUPERV::SDate aDate ) {
275   _LastModification = aDate ;
276 }
277
278 bool GraphBase::ComputingNode::EditorRelease(const char * c){
279   if ( _EditorRelease && _EditorRelease != NULLSTRING )
280     delete _EditorRelease;
281   _EditorRelease = my_strdup(c);
282   return true ;
283 }
284
285 bool GraphBase::ComputingNode::Author(const char * a) {
286   cdebug_in << "GraphBase::ComputingNode::Author " << _Author << endl;
287   if ( _Author && _Author != NULLSTRING )
288     delete _Author;
289   _Author = my_strdup(a);
290   cdebug_out << "GraphBase::ComputingNode::Author " << _Author << endl;
291   return true ;
292 }
293
294 bool GraphBase::ComputingNode::Comment(const char *c) {
295   cdebug_in << "GraphBase::ComputingNode::Comment " << _Comment << endl;
296   if ( _Comment != NULLSTRING )
297     delete [] _Comment;
298   _Comment = my_strdup(c);
299   cdebug_out << "GraphBase::ComputingNode::Comment " << _Comment << endl;
300   return true ;
301 }
302
303 void GraphBase::ComputingNode::NodePort( const char * NodeName ,
304                                 const char * ServiceParameterName ,
305                                 char ** aNode , char ** aPort ) {
306   if ( strcmp( NodeName , Name() ) ) {
307     *aNode = my_strdup( NodeName ) ;
308     *aPort = my_strdup( ServiceParameterName ) ;
309   }
310   else {
311 //    char * BPort = strchr( ServiceParameterName , '\\' ) ;
312     char * BPort = (char * ) ServiceParameterName ;
313     while ( ( BPort = strchr( BPort , '_' ) ) ) {
314       if ( BPort[1] == '_' ) {
315         int len = BPort - ServiceParameterName ;
316         *aNode = new char [ len + 1 ] ;
317         strncpy( *aNode , ServiceParameterName , len ) ;
318         (*aNode)[ len ] = '\0' ;
319         *aPort = my_strdup( &BPort[ 2 ] ) ;
320         break ;
321       }
322       else {
323         BPort = &BPort[2] ;
324       }
325     }
326     if ( BPort == NULL ) {
327       *aNode = my_strdup( NULLSTRING ) ;
328       *aPort = my_strdup( NULLSTRING ) ;
329     }
330   }
331 }
332
333 bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) {
334   bool RetVal = false ;
335   const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
336   if ( thePort ) {
337     RetVal = thePort->IsPortConnected() ;
338   }
339   else {
340     const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
341     if ( thePort ) {
342       RetVal = thePort->IsPortConnected() ;
343     }
344   }
345   return RetVal ;
346 }
347
348 bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) {
349   bool RetVal = false ;
350   const GraphBase::InPort * theInPort = GetInPort( ToServiceParameterName ) ;
351 #if 0
352   if ( IsDataFlowNode() && theInPort ) {
353     RetVal = true ;
354   }
355   else 
356 #endif
357   if ( theInPort ) {
358 //    cout << "GraphBase::ComputingNode::HasInput theInPort " << theInPort << " " << theInPort->PortName() << " of "
359 //         << theInPort->NodeName() << " IsDataConnected " << theInPort->IsDataConnected() << " OutPort "
360 //         << theInPort->GetOutPort() << endl ;
361     RetVal = theInPort->IsDataConnected() ;
362   }
363   else {
364     const GraphBase::OutPort * theOutPort = GetOutPort( ToServiceParameterName ) ;
365     if ( theOutPort ) {
366       RetVal = theOutPort->IsDataConnected() ;
367     }
368   }
369   return RetVal ;
370 }
371
372 GraphBase::SNode * GraphBase::ComputingNode::GetInfo() {
373   cdebug_in << "GraphBase::ComputingNode::GetInfo" << endl;
374   GraphBase::SNode * Info = new GraphBase::SNode ;
375 //  Info->theComponentName = ComponentName() ;
376 //  Info->theInterfaceName = InterfaceName() ;
377   Info->theName = Name() ;
378   Info->theKind = Kind() ;
379   if ( IsDataStreamNode() ) {
380     long Timeout ;
381     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
382     double DeltaTime ;
383     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
384     Info->theTimeout = Timeout ;
385     Info->theDataStreamTrace = DataStreamTrace ;
386     Info->theDeltaTime = DeltaTime ;
387   }
388   Info->theService = *GetService() ;
389 //  Info->theListOfParameters = *GetListOfParameters() ;
390   Info->theFirstCreation = FirstCreation() ;
391   Info->theLastModification = LastModification() ;
392   Info->theEditorRelease = EditorRelease() ;
393   Info->theAuthor = Author() ;
394 //  Info->theContainer = Computer() ;
395   Info->theComment = Comment() ;
396   Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
397   Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
398   cdebug_out << "GraphBase::ComputingNode::GetInfo" << endl;
399   return Info ;
400 }
401
402 void GraphBase::ComputingNode::SetMacroPorts( GraphBase::Graph * aGraph ) {
403   cdebug_in << "GraphBase::ComputingNode::SetMacroPorts fill ports of MacroNode" << endl;
404   int i ;
405   for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) {
406     const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ;
407     cdebug << "SetMacroPorts In" << i << " " << anInPort->PortName() << " " << anInPort->PortType()
408            << " " << anInPort->Kind() << endl ;
409     GraphBase::InPort * aNewInPort ;
410     if ( anInPort->IsDataStream() ) {
411       aNewInPort = AddInDataStreamPort( anInPort->PortName() , StringToDataStreamType( anInPort->PortType() ) ,
412                                         anInPort->Dependency() , anInPort->Kind() ) ;
413     }
414     else if ( anInPort->IsParam() || anInPort->IsInLine() ) {
415       aNewInPort = AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() ) ;
416     }
417   }
418   for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() ; i++ ) {
419     const GraphBase::OutPort * anOutPort = aGraph->GetNodeOutPort( i ) ;
420     cdebug << "SetMacroPorts Out" << i << " " << anOutPort->PortName() << " " << anOutPort->PortType()
421            << " " << anOutPort->Kind() << endl ;
422     if ( anOutPort->IsDataStream() ) {
423       AddOutDataStreamPort( anOutPort->PortName() , StringToDataStreamType( anOutPort->PortType() ) ,
424                             anOutPort->Dependency() , anOutPort->Kind() ) ;
425     }
426     else if ( anOutPort->IsParam() || anOutPort->IsInLine() ) {
427       AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() ) ;
428     }
429   }
430   cdebug_out << "GraphBase::ComputingNode::SetMacroPorts" << endl;
431 }
432
433 void GraphBase::ComputingNode::UpdateMacroPorts( GraphBase::Graph * aGraph ) {
434   cdebug_in << "GraphBase::ComputingNode::UpdateMacroPorts fill ports of MacroNode from "
435             << aGraph->Name() << " InPorts(" << aGraph->GetNodeInPortsSize() << ") OutPorts("
436             << aGraph->GetNodeInPortsSize() << ") to MacroNode " << Name() << " InPorts(" << GetNodeInPortsSize()
437             << ") OutPorts(" << GetNodeInPortsSize() << ")" << endl;
438   cdebug << Name() << " : " << *GetService() << endl ;
439   cdebug << aGraph->Name() << " : " << *aGraph->GetService() << endl ;
440   int i ;
441 // Loop over InPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelInPort in the MacroNode
442   for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
443     GraphBase::InPort * anInPort = aGraph->GetChangeInPort( GetNodeInPort( i )->PortName() ) ;
444     if ( anInPort && !anInPort->IsGate() && !GetNodeInPort( i )->IsGate() ) {
445       if ( strcmp( GetNodeInPort( i )->PortType() , anInPort->PortType() ) ) {
446         cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
447                << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
448         cdebug << "  <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
449                << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
450         GetChangeNodeInPort( i )->PortType( (char * ) anInPort->PortType() ) ;
451       }
452       if ( GetNodeInPort( i )->Kind() != anInPort->Kind() ) {
453         cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
454                << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
455         cdebug << "  <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
456                << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
457         GetChangeNodeInPort( i )->Kind( anInPort->Kind() ) ;
458       }
459       if ( GetNodeInPort( i )->Dependency() != anInPort->Dependency() ) {
460         cdebug << Name() << " " << GetNodeInPort( i )->PortName() << " " << GetNodeInPort( i )->PortType()
461                << " " << GetNodeInPort( i )->Kind() << " " << GetNodeInPort( i )->Dependency() << endl ;
462         cdebug << "  <--> " << aGraph->Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
463                << " " << anInPort->Kind() << " " << anInPort->Dependency() << endl ;
464         GetChangeNodeInPort( i )->Dependency( anInPort->Dependency() ) ;
465       }
466     }
467     else if ( !GetNodeInPort( i )->IsGate() ) {
468       cdebug << "UpdateMacroPorts DelInPort In" << i << " " << GetNodeInPort( i )->PortName() << " "
469              << GetNodeInPort( i )->PortType() << " " << GetNodeInPort( i )->Kind() << endl ;
470       DelInPort( GetNodeInPort( i )->PortName() ) ;
471     }
472   }
473   int index ;
474 // Loop over InPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddInPort in the MacroNode
475   for ( index = 0 ; index < aGraph->GetNodeInPortsSize() ; index++ ) {
476     GraphBase::InPort * anInPort = aGraph->GetChangeNodeInPort( index ) ;
477     GraphBase::InPort * aMacroInPort = GetChangeInPort( anInPort->PortName() ) ;
478     if ( !anInPort->IsGate() &&
479          strcmp( GetChangeNodeInPort( index )->PortName() , anInPort->PortName() ) ) {
480       cdebug << "UpdateMacroPorts Add/MoveInPort In" << index << " " << anInPort->PortName() << " "
481              << anInPort->PortType() << " " << anInPort->Kind() << endl ;
482       if ( aMacroInPort ) {
483         MoveInPort( anInPort->PortName() , index ) ;
484       }
485       else {
486         AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() , index ) ;
487       }
488     }
489   }
490 // Loop over OutPorts of MacroNode ; if it does not exist in the MacroGraph ===> DelOutPort in the MacroNode
491   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
492     GraphBase::OutPort * anOutPort = aGraph->GetChangeOutPort( GetNodeOutPort( i )->PortName() ) ;
493     if ( anOutPort && !anOutPort->IsGate() && !GetNodeOutPort( i )->IsGate() ) {
494       if ( strcmp( GetNodeOutPort( i )->PortType() , anOutPort->PortType() ) ) {
495         cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
496                << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
497         cdebug << "  <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
498                << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
499         GetChangeNodeOutPort( i )->PortType( (char * ) anOutPort->PortType() ) ;
500       }
501       if ( GetNodeOutPort( i )->Kind() != anOutPort->Kind() ) {
502         cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
503                << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
504         cdebug << "  <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
505                << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
506         GetChangeNodeOutPort( i )->Kind( anOutPort->Kind() ) ;
507       }
508       if ( GetNodeOutPort( i )->Dependency() != anOutPort->Dependency() ) {
509         cdebug << Name() << " " << GetNodeOutPort( i )->PortName() << " " << GetNodeOutPort( i )->PortType()
510                << " " << GetNodeOutPort( i )->Kind() << " " << GetNodeOutPort( i )->Dependency() << endl ;
511         cdebug << "  <--> " << aGraph->Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
512                << " " << anOutPort->Kind() << " " << anOutPort->Dependency() << endl ;
513         GetChangeNodeOutPort( i )->Dependency( anOutPort->Dependency() ) ;
514       }
515     }
516     else if ( !GetNodeOutPort( i )->IsGate() ) {
517       cdebug << "UpdateMacroPorts DelOutPort Out" << i << " " << GetNodeOutPort( i )->PortName() << " "
518              << GetNodeOutPort( i )->PortType() << " " << GetNodeOutPort( i )->Kind() << endl ;
519       DelOutPort( GetNodeOutPort( i )->PortName() ) ;
520     }
521   }
522 // Loop over OutPorts of the MacroGraph : if it does not exist in the MacroNode ==> AddOutPort in the MacroNode
523   for ( index = 0 ; index < aGraph->GetNodeOutPortsSize() ; index++ ) {
524     GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeOutPort( index ) ;
525     GraphBase::OutPort * aMacroOutPort = GetChangeOutPort( anOutPort->PortName() ) ;
526     if ( !anOutPort->IsGate() && strcmp( GetNodeOutPort( index )->PortName() , anOutPort->PortName() ) ) {
527       cdebug << "UpdateMacroPorts Add/MoveOutPort Out" << index << " " << anOutPort->PortName() << " "
528              << anOutPort->PortType() << " " << anOutPort->Kind() << endl ;
529       if ( aMacroOutPort ) {
530         MoveOutPort( anOutPort->PortName() , index ) ;
531       }
532       else {
533         AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() , index ) ;
534       }
535     }
536   }
537   cdebug_out << "GraphBase::ComputingNode::UpdateMacroPorts" << endl;
538 }
539
540 void GraphBase::ComputingNode::SetMacroDatas( GraphBase::Graph * aGraph ,
541                                               GraphBase::Graph * aGraphOfMacroGraph ) {
542   cdebug_in << "GraphBase::ComputingNode::SetMacroDatas fill inputs of MacroNode" << endl;
543   int i ;
544   for ( i = 0 ; i < aGraph->GetNodeInPortsSize() ; i++ ) {
545     const GraphBase::InPort * anInPort = aGraph->GetNodeInPort( i ) ;
546     GraphBase::OutPort * anOutPort = aGraph->GetChangeNodeInDataNodePort(i) ;
547     cdebug << "                 " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
548            << " " << anOutPort->Kind() << " " << anOutPort->PortStatus() << endl ;
549     if ( anOutPort->IsDataConnected() ) {
550       aGraphOfMacroGraph->AddInputData( Name() , anInPort->PortName() , *(anOutPort->Value()) ) ;
551       anOutPort->PortStatus( ExternConnected ) ;
552     }
553   }
554   cdebug_out << "GraphBase::ComputingNode::SetMacroDatas" << endl;
555 }
556
557 void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) {
558   GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
559 }
560 void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) {
561   GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
562 }
563
564 GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName ,
565                                                          const char * InputParameterType ,
566                                                          const SUPERV::KindOfPort aKindOfPort ,
567                                                          int index ) {
568   cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
569   return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
570                                             Kind() ,
571                                             InputParameterName ,
572                                             InputParameterType ,
573                                             aKindOfPort ,
574                                             index ,
575                                             _Graph_prof_debug , _Graph_fdebug ) ;
576 }
577 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
578                                                            const char * OutputParameterType ,
579                                                            const SUPERV::KindOfPort aKindOfPort ,
580                                                            int index ) {
581   cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
582   return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
583                                              Kind() ,
584                                              OutputParameterName ,
585                                              OutputParameterType ,
586                                              aKindOfPort ,
587                                              index ,
588                                              _Graph_prof_debug , _Graph_fdebug ) ;
589 }
590
591 void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) {
592   GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
593 }
594 void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) {
595   GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
596 }
597
598 GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName ,
599                                                                              const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
600                                                                              const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
601                                                                              const SUPERV::KindOfPort aKindOfPort ,
602                                                                              int index ) {
603 //  IncrDataStreamInPorts() ;
604   GraphBase::InDataStreamPort * aDataStreamPort ;
605   aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
606                                                                                         Kind() ,
607                                                                                         InputParameterName ,
608                                                                                         DataStreamTypeToString( InputParameterType ).c_str() ,
609                                                                                         aKindOfPort ,
610                                                                                         index ,
611                                                                                         _Graph_prof_debug ,
612                                                                                         _Graph_fdebug ) ;
613   aDataStreamPort->Dependency( aDependency ) ;
614   if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) {
615     aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ;
616   }
617   return aDataStreamPort ;
618 }
619 GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName ,
620                                                                                const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
621                                                                                const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
622                                                                                const SUPERV::KindOfPort aKindOfPort ,
623                                                                                int index ) {
624 //  IncrDataStreamOutPorts() ;
625   GraphBase::OutDataStreamPort * aDataStreamPort ;
626   aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
627                                                                                           Kind() ,
628                                                                                           OutputParameterName ,
629                                                                                           DataStreamTypeToString( OutputParameterType ).c_str() ,
630                                                                                           aKindOfPort ,
631                                                                                           index ,
632                                                                                           _Graph_prof_debug ,
633                                                                                           _Graph_fdebug ) ;
634   aDataStreamPort->Dependency( aDependency ) ;
635   return aDataStreamPort ;
636 }
637
638
639 #include <sys/time.h>
640 #include <sys/resource.h>
641 #include <unistd.h>
642
643 const long GraphBase::ComputingNode::CpuUsed() {
644   struct rusage usage ;
645   if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
646     perror("GraphBase::CpuUsed") ;
647     return 0 ;
648   }
649 //  return usage.ru_utime.__time_t tv_sec ;
650   cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
651          << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
652   return usage.ru_utime.tv_sec ;
653 }
654
655 #if 0
656 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
657   GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
658   if ( IsInLineNode() || IsGOTONode() ) {
659     unsigned int i;
660     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
661       const InPort * anInPort = GetNodeInPort( i ) ;
662       if ( anInPort->IsBus() ) {
663         int size = aListOfParameters->size() ;
664         aListOfParameters->resize( size + 1 ) ;
665         (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
666         (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
667         const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
668         (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
669         (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
670       }
671     }
672   }
673   return aListOfParameters ;
674 }
675 #endif
676
677 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
678                                         const char * ComponentName ,
679                                         const char * InterfaceName ,
680                                         const char * Computer ,
681                                         const char * CoupledNode ,
682                                         const ListOfFuncName FuncNames ,
683                                         const ListOfPythonFunctions PythonFunctions ,
684                                         int XCoordinate , int YCoordinate ) const {
685   cdebug_in << "SaveXML Node " << Name() << endl ;
686   QDomElement node = Graph.createElement( "node" ) ;
687   info.appendChild( node ) ;
688   QDomElement componentname = Graph.createElement( "component-name" ) ;
689   QDomText aField ;
690   if ( strlen( ComponentName ) ) {
691 //    f << Tabs << "<component-name>" << ComponentName << "</component-name>"
692 //      << endl ;
693 //    componentname.setNodeValue( ComponentName ) ;
694     aField = Graph.createTextNode( ComponentName ) ;
695   }
696   else {
697 //    f << Tabs << "<component-name>?</component-name>" << endl ;
698 //    componentname.setNodeValue( "?" ) ;
699     aField = Graph.createTextNode( "?" ) ;
700   }
701   node.appendChild( componentname ) ;
702   componentname.appendChild( aField ) ;
703
704   QDomElement interfacename = Graph.createElement("interface-name") ;
705   if ( strlen( InterfaceName ) ) {
706 //    f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
707 //      << endl ;
708 //    interfacename.setAttribute("name" , InterfaceName ) ;
709     aField = Graph.createTextNode( InterfaceName ) ;
710   }
711   else {
712 //    f << Tabs << "<interface-name>?</interface-name>" << endl ;
713 //    interfacename.setAttribute("name" , "?" ) ;
714     aField = Graph.createTextNode( "?" ) ;
715   }
716   node.appendChild(interfacename) ;
717   interfacename.appendChild( aField ) ;
718
719 //  f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
720   QDomElement nodename = Graph.createElement("node-name") ;
721   aField = Graph.createTextNode( Name() ) ;
722   node.appendChild( nodename ) ;
723   nodename.appendChild( aField ) ;
724
725 //  f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
726   QDomElement kind = Graph.createElement( "kind" ) ;
727   QString aKind ;
728
729   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
730 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
731   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
732     aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
733   }
734   else {
735     aKind = aKind.setNum( Kind() ) ;
736   }
737   aField = Graph.createTextNode( aKind ) ;
738   node.appendChild( kind ) ;
739   kind.appendChild( aField ) ;
740
741   if ( IsDataStreamNode() && HasDataStream() != 0 ) {
742     long Timeout ;
743     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
744     double DeltaTime ;
745     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
746
747     QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
748     QString aTimeout ;
749     aTimeout = aTimeout.setNum( Timeout ) ;
750     aField = Graph.createTextNode( aTimeout ) ;
751     node.appendChild( timeout ) ;
752     timeout.appendChild( aField ) ;
753
754     QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
755     QString aDataStreamTrace ;
756     aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
757     aField = Graph.createTextNode( aDataStreamTrace ) ;
758     node.appendChild( datastreamtrace ) ;
759     datastreamtrace.appendChild( aField ) ;
760
761     QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
762     QString aDeltaTime ;
763     aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
764     aField = Graph.createTextNode( aDeltaTime ) ;
765     node.appendChild( deltatime ) ;
766     deltatime.appendChild( aField ) ;
767   }
768
769   QDomElement couplednode = Graph.createElement("coupled-node") ;
770   if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
771        IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
772 //    f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
773 //      << endl ;
774     aField = Graph.createTextNode( CoupledNode ) ;
775   }
776   else {
777 //    f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
778     aField = Graph.createTextNode( "?" ) ;
779   }
780   node.appendChild(couplednode) ;
781   couplednode.appendChild( aField ) ;
782
783 //  f << Tabs << "<service>" << endl ;
784   QDomElement service = Graph.createElement("service") ;
785   node.appendChild(service) ;
786   QDomElement servicename = Graph.createElement("service-name") ;
787   if ( strlen( ServiceName() ) ) {
788 //    f << Tabs << "    <service-name>" << ServiceName() << "</service-name>" << endl ;
789     aField = Graph.createTextNode( ServiceName() ) ;
790   }
791   else {
792 //    f << Tabs << "    <service-name>?</service-name>" << endl ;
793     aField = Graph.createTextNode( "?" ) ;
794   }
795   service.appendChild(servicename) ;
796   servicename.appendChild( aField ) ;
797
798   cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
799          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
800   QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
801   service.appendChild(inParameterlist) ;
802   unsigned int i;
803   GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
804   for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
805     const GraphBase::InPort * anInPort ;
806     anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
807     if ( !anInPort->IsDataStream() ) {
808       cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
809              << " InParameterPort " << anInPort->Kind() << endl ;
810       QDomElement inParameter = Graph.createElement("inParameter") ;
811       inParameterlist.appendChild(inParameter) ;
812       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
813       if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
814         aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
815       }
816       else {
817         aField = Graph.createTextNode( "?" ) ;
818       }
819       inParameter.appendChild(inParametertype) ;
820       inParametertype.appendChild( aField ) ;
821       QDomElement inParametername = Graph.createElement("inParameter-name") ;
822       if ( strlen( ServiceInParameter()[i].Parametername ) ) {
823         aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
824       }
825       else {
826         aField = Graph.createTextNode( "?" ) ;
827       }
828       inParameter.appendChild(inParametername) ;
829       inParametername.appendChild( aField ) ;
830     }
831   }
832   QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
833   service.appendChild(outParameterlist) ;
834   for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
835     const GraphBase::OutPort * anOutPort ;
836     anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
837     if ( !anOutPort->IsDataStream() ) {
838       cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
839              << " OutParameterPort " << anOutPort->Kind() << endl ;
840       QDomElement outParameter = Graph.createElement("outParameter") ;
841       outParameterlist.appendChild(outParameter) ;
842       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
843       if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
844         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
845       }
846       else {
847         aField = Graph.createTextNode( "?" ) ;
848       }
849       outParameter.appendChild(outParametertype) ;
850       outParametertype.appendChild( aField ) ;
851       QDomElement outParametername = Graph.createElement("outParameter-name") ;
852       if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
853         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
854       }
855       else {
856         aField = Graph.createTextNode( "?" ) ;
857       }
858       outParameter.appendChild(outParametername) ;
859       outParametername.appendChild( aField ) ;
860     }
861   }
862
863   QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
864   node.appendChild( DataStreamlist ) ;
865   for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
866     const GraphBase::InPort * anInPort ;
867     anInPort = aNode->GetNodeInPort( i ) ;
868     if ( anInPort->IsDataStream() ) {
869       cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
870              << " InDataStreamPort " << anInPort->Kind() << endl ;
871       QDomElement inParameter = Graph.createElement("inParameter") ;
872       DataStreamlist.appendChild(inParameter) ;
873       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
874       QString aType ;
875       aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
876       cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
877              << " " << aType << endl ;
878       aField = Graph.createTextNode( aType ) ;
879       inParameter.appendChild(inParametertype) ;
880       inParametertype.appendChild( aField ) ;
881       QDomElement inParametername = Graph.createElement("inParameter-name") ;
882       if ( strlen( anInPort->PortName() ) ) {
883         aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
884       }
885       else {
886         aField = Graph.createTextNode( "?" ) ;
887       }
888       inParameter.appendChild(inParametername) ;
889       inParametername.appendChild( aField ) ;
890       cdebug << "SaveXML " << anInPort->PortName() << endl ;
891       QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
892       QString aDependency ;
893       aDependency = aDependency.setNum( anInPort->Dependency() ) ;
894       aField = Graph.createTextNode( aDependency ) ;
895       inParameter.appendChild(inParameterdependency) ;
896       inParameterdependency.appendChild( aField ) ;
897       cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
898       SUPERV::KindOfSchema        aKindOfSchema ;
899       SUPERV::KindOfInterpolation aKindOfInterpolation ;
900       SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
901       ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
902       QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
903       QString aSchema ;
904       aSchema = aSchema.setNum( aKindOfSchema ) ;
905       aField = Graph.createTextNode( aSchema ) ;
906       inParameter.appendChild(inParameterKindOfSchema) ;
907       inParameterKindOfSchema.appendChild( aField ) ;
908       cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
909       QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
910       QString anInterpolation ;
911       anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
912       aField = Graph.createTextNode( anInterpolation ) ;
913       inParameter.appendChild(inParameterKindOfInterpolation) ;
914       inParameterKindOfInterpolation.appendChild( aField ) ;
915       cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
916       QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
917       QString anExtrapolation ;
918       anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
919       aField = Graph.createTextNode( anExtrapolation ) ;
920       inParameter.appendChild(inParameterKindOfExtrapolation) ;
921       inParameterKindOfExtrapolation.appendChild( aField ) ;
922       cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
923     }
924   }
925   for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
926     const GraphBase::OutPort * anOutPort ;
927     anOutPort = aNode->GetNodeOutPort( i ) ;
928     if ( anOutPort->IsDataStream() ) {
929       cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
930              << " OutDataStreamPort " << anOutPort->Kind() << endl ;
931       QDomElement outParameter = Graph.createElement("outParameter") ;
932       DataStreamlist.appendChild(outParameter) ;
933       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
934       QString aType ;
935       aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
936       cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
937              << " " << aType << endl ;
938       aField = Graph.createTextNode( aType ) ;
939       outParameter.appendChild(outParametertype) ;
940       outParametertype.appendChild( aField ) ;
941       QDomElement outParametername = Graph.createElement("outParameter-name") ;
942       if ( strlen( anOutPort->PortName() ) ) {
943         aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
944       }
945       else {
946         aField = Graph.createTextNode( "?" ) ;
947       }
948       outParameter.appendChild(outParametername) ;
949       outParametername.appendChild( aField ) ;
950       cdebug << "SaveXML " << anOutPort->PortName() << endl ;
951       QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
952       QString aDependency ;
953       aDependency = aDependency.setNum( anOutPort->Dependency() )  ;
954       aField = Graph.createTextNode( aDependency ) ;
955       outParameter.appendChild(outParameterdependency) ;
956       outParameterdependency.appendChild( aField ) ;
957       cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
958       long aNumberOfValues ;
959       aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
960       QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
961       QString aValues ;
962       aValues = aValues.setNum( aNumberOfValues ) ;
963       aField = Graph.createTextNode( aValues ) ;
964       outParameter.appendChild(outParameterNumberOfValues) ;
965       outParameterNumberOfValues.appendChild( aField ) ;
966       cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
967     }
968   }
969 //  f << Tabs << "</Parameter-list>" << endl ;    
970
971 //  f << Tabs << "<PyFunction-list>" << endl ;
972   QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
973   node.appendChild( PyFunctionlist ) ;
974   for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
975 //    f << Tabs << "    <PyFunction>" << endl ;
976     QDomElement PyFunction = Graph.createElement("PyFunction") ;
977     PyFunctionlist.appendChild( PyFunction ) ;
978     int j ;
979     QDomElement FuncName = Graph.createElement("FuncName") ;
980     if ( strlen( FuncNames[i].c_str() ) ) {
981       aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
982     }
983     else {
984       aField = Graph.createTextNode( "?" ) ;
985     }
986     PyFunction.appendChild( FuncName ) ;
987     FuncName.appendChild( aField ) ;
988     if ( (*PythonFunctions[i]).length() ) {
989       for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
990         QDomElement PyFunc = Graph.createElement("PyFunc") ;
991         QDomCDATASection aCDATA ;
992       // mpv: Linux 8.0 compiler compatibility
993         char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
994         int i ;
995         for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
996           if ( aCDATAChar[ i ] != ' ' ) {
997             break ;
998           }
999         }
1000         if ( i == (int ) strlen( aCDATAChar ) ) {
1001           aCDATA = Graph.createCDATASection( "?" ) ;
1002         }
1003         else {
1004           aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1005         }
1006         PyFunction.appendChild( PyFunc ) ;
1007         PyFunc.appendChild( aCDATA ) ;
1008       }
1009     }
1010     else {
1011       QDomElement PyFunc = Graph.createElement("PyFunc") ;
1012       QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1013       PyFunction.appendChild( PyFunc ) ;
1014       PyFunc.appendChild( aCDATA ) ;
1015     }
1016   }
1017
1018 //  f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1019 //    << endl ;
1020   QDomElement creationdate = Graph.createElement("creation-date") ;
1021   char fdate[30] ;
1022   sprintf( fdate , "%d/%d/%d - %d:%d:%d" ,  FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1023   aField = Graph.createTextNode( fdate ) ;
1024   node.appendChild( creationdate ) ;
1025   creationdate.appendChild( aField ) ;
1026 //  f << Tabs << "<lastmodification-date>" << LastModification()
1027 //    << "</lastmodification-date>" << endl ;
1028   QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1029   char ldate[30] ;
1030   sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1031   aField = Graph.createTextNode( ldate ) ;
1032   node.appendChild( lastmodificationdate ) ;
1033   lastmodificationdate.appendChild( aField ) ;
1034 //  f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1035 //    << endl ;
1036   QDomElement editorrelease = Graph.createElement("editor-release") ;
1037   aField = Graph.createTextNode( EditorRelease() ) ;
1038   node.appendChild( editorrelease ) ;
1039   editorrelease.appendChild( aField ) ;
1040   QDomElement author = Graph.createElement("author") ;
1041   if ( strlen( Author() ) ) {
1042 //    f << Tabs << "<author>" << Author() << "</author>" << endl ;
1043     aField = Graph.createTextNode( Author() ) ;
1044   }
1045   else {
1046 //    f << Tabs << "<author>?</author>" << endl ;
1047     aField = Graph.createTextNode( "?" ) ;
1048   }
1049   node.appendChild( author ) ;
1050   author.appendChild( aField ) ;
1051   QDomElement container = Graph.createElement("container") ;
1052   if ( IsFactoryNode() && strlen( Computer) ) {
1053 //    f << Tabs << "<container>" << Computer << "</container>" << endl ;
1054     aField = Graph.createTextNode( Computer ) ;
1055   }
1056   else {
1057 //    f << Tabs << "<container>?</container>" << endl ;
1058     aField = Graph.createTextNode( "?" ) ;
1059   }
1060   node.appendChild( container ) ;
1061   container.appendChild( aField ) ;
1062   QDomElement comment = Graph.createElement("comment") ;
1063   if ( strlen( Comment() ) ) {
1064 //    f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1065     aField = Graph.createTextNode( Comment() ) ;
1066   }
1067   else {
1068 //    f << Tabs << "<comment>?</comment>" << endl ;
1069     aField = Graph.createTextNode( "?" ) ;
1070   }
1071   node.appendChild( comment ) ;
1072   comment.appendChild( aField ) ;
1073 //  f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1074   QDomElement xposition = Graph.createElement("x-position") ;
1075   QString aXCoordinate ;
1076   aXCoordinate = aKind.setNum( XCoordinate ) ;
1077   aField = Graph.createTextNode( aXCoordinate ) ;
1078   node.appendChild( xposition ) ;
1079   xposition.appendChild( aField ) ;
1080 //  f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1081   QDomElement yposition = Graph.createElement("y-position") ;
1082   QString aYCoordinate ;
1083   aYCoordinate = aKind.setNum( YCoordinate ) ;
1084   aField = Graph.createTextNode( aYCoordinate ) ;
1085   node.appendChild( yposition ) ;
1086   yposition.appendChild( aField ) ;
1087   cdebug_out << "SaveXML Node " << Name() << endl ;
1088   return true ;
1089 }
1090
1091 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1092                                        const char * ComponentName ,
1093                                        const char * InterfaceName ,
1094                                        const char * Computer ,
1095                                        const GraphBase::InLineNode * aCoupledNode ,
1096                                        const ListOfFuncName FuncNames ,
1097                                        const ListOfPythonFunctions PythonFunctions ,
1098                                        int XCoordinate , int YCoordinate ) const {
1099   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1100 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1101   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1102     f << "    " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1103   }
1104   else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1105     f << "    " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1106     long Timeout ;
1107     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1108     double DeltaTime ;
1109     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1110     f << "    " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1111       << " , " << DeltaTime << " )" << endl ;
1112   }
1113   else if ( IsComputingNode() ) {
1114     int i ;
1115     f << "    " << Name() << "_ServiceinParameter = []" << endl ;
1116     for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1117       f << "    " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1118         << ServiceInParameter()[i].Parametertype << "' , '"
1119         << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1120     }
1121     f << "    " << Name() << "_ServiceoutParameter = []" << endl ;
1122     for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1123       f << "    " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1124         << ServiceOutParameter()[i].Parametertype << "' , '"
1125         << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1126     }
1127     f << "    " << Name() << "_ServiceinStreamParameter = []" << endl ;
1128     for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1129       f << "    " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1130         << ServiceInStreamParameter()[i].Parametertype << " , '"
1131         << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1132         << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1133     }
1134     f << "    " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1135     for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1136       f << "    " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1137         << ServiceOutStreamParameter()[i].Parametertype << " , '"
1138         << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1139         << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1140     }
1141     f << "    " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1142       << "' , " << Name() << "_ServiceinParameter"
1143       << " , " << Name() << "_ServiceoutParameter"
1144       << " , " << Name() << "_ServiceinStreamParameter"
1145       << " , " << Name() << "_ServiceoutStreamParameter"
1146       << " , 0 , 0 )" << endl ;
1147     f << "    " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1148       << endl ;
1149   }
1150   else if ( IsFactoryNode() ) {
1151     f << "    " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1152       << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1153       << endl ;
1154   }
1155   else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1156 // It is done with LoopNode or SwitchNode with CoupledNode()
1157   }
1158   else {
1159     if ( !IsMacroNode() ) {
1160       f << "    " << "Py" << Name() << " = []" << endl ;
1161     }
1162     int i ;
1163     SUPERV::ListOfStrings aPyFunc ;
1164     if ( PythonFunctions.size() ) {
1165       aPyFunc = *PythonFunctions[0] ;
1166       for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1167         f << "    " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1168       }
1169     }
1170     if ( IsInLineNode() ) {
1171       f << "    " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1172         << Name() << " )" << endl ;
1173     }
1174     else if ( IsGOTONode() ) {
1175       if ( aCoupledNode ) {
1176         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1177           << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1178       }
1179       else {
1180         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1181           << Name() << " , '' )" << endl ;
1182       }
1183     }
1184     else if ( IsMacroNode() ) {
1185       if ( aCoupledNode ) {
1186         f << "    " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1187         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1188       }
1189       else {
1190         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1191       }
1192     }
1193     else {
1194 //      char * EndName = NULL ;
1195 //      EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1196 //      strcpy( EndName , "End" ) ;
1197 //      strcat( EndName , Name() ) ;
1198       char * EndName = aCoupledNode->Name() ;
1199       if ( IsLoopNode() ) {
1200         int i ;
1201         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1202         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1203         f << "    " << "PyMore" << Name() << " = []" << endl ;
1204         for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1205           f << "    " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1206         }
1207         f << "    " << "PyNext" << Name() << " = []" << endl ;
1208         for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1209           f << "    " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1210         }
1211         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1212           << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1213           << FuncNames[1].c_str() << "' , PyMore" << Name()
1214           << " , '" << FuncNames[2].c_str() << "' , PyNext"
1215           << Name() << " )" << endl ;
1216         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1217         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1218         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1219         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1220           << aCoupledNode->YCoordinate() << " )" << endl ;
1221         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1222         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1223         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1224           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1225             << endl ;
1226         }
1227         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1228         for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1229           const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1230           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1231                  << " " << anInPort->Kind() << endl ;
1232           if ( anInPort->IsLoop() ) {
1233             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1234               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1235           }
1236           else if ( anInPort->IsInLine() ) {
1237             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1238               << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1239               << anInPort->PortType() << "' )" << endl ;
1240           }
1241           else if ( anInPort->IsDataStream() ) {
1242             f << "    " << "I" << Name() << anInPort->PortName() << " = " << Name()
1243               << ".InStreamPort( '" << anInPort->PortName()
1244               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1245               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1246             SUPERV::KindOfSchema        aKindOfSchema ;
1247             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1248             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1249             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1250             f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1251               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1252           }
1253           else if ( anInPort->IsGate() ) {
1254             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1255               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1256           }
1257         }
1258         for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1259           const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1260           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1261                  << " " << anOutPort->Kind() << endl ;
1262           if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1263             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1264               << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1265           }
1266           else if ( anOutPort->IsDataStream() ) {
1267             f << "    " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1268               << ".OutStreamPort( '" << anOutPort->PortName()
1269               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1270               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1271             long aNumberOfValues ;
1272             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1273             f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1274               << endl ;
1275           }
1276         }
1277         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1278           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1279           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1280                  << " " << anInPort->Kind() << endl ;
1281           if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1282             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1283               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1284           }
1285           else if ( anInPort->IsDataStream() ) {
1286             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1287               << ".InStreamPort( '" << anInPort->PortName()
1288               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1289               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1290             SUPERV::KindOfSchema        aKindOfSchema ;
1291             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1292             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1293             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1294             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1295               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1296           }
1297         }
1298         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1299           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1300           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1301                  << " " << anOutPort->Kind() << endl ;
1302           if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1303             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1304               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1305           }
1306           else if ( anOutPort->IsDataStream() ) {
1307             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1308               << ".OutStreamPort( '" << anOutPort->PortName()
1309               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1310               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1311             long aNumberOfValues ;
1312             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1313             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1314               << endl ;
1315           }
1316         }
1317       }
1318       else if ( IsSwitchNode() ) {
1319         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1320           << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1321         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1322         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1323         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1324         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1325           << aCoupledNode->YCoordinate() << " )" << endl ;
1326         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1327         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1328         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1329           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1330             << endl ;
1331         }
1332         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1333         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1334           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1335           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1336                  << " " << anInPort->Kind() << endl ;
1337 //          if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1338           if ( anInPort->IsGate() ) {
1339             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1340               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1341           }
1342           else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1343             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1344               << ".InPort( '" << anInPort->PortName()
1345               << "' , '" << anInPort->PortType() << "' )" << endl ;
1346           }
1347           else if ( anInPort->IsDataStream() ) {
1348             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1349               << ".InStreamPort( '" << anInPort->PortName()
1350               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1351               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1352             SUPERV::KindOfSchema        aKindOfSchema ;
1353             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1354             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1355             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1356             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1357               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1358           }
1359         }
1360         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1361           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1362           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1363                  << " " << anOutPort->Kind() << endl ;
1364 //          if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1365           if ( anOutPort->IsGate() ) {
1366             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1367               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1368           }
1369           else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1370             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1371               << ".OutPort( '" << anOutPort->PortName()
1372               << "' , '" << anOutPort->PortType() << "' )" << endl ;
1373           }
1374           else if ( anOutPort->IsDataStream() ) {
1375             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1376               << ".OutStreamPort( '" << anOutPort->PortName()
1377               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1378               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1379             long aNumberOfValues ;
1380             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1381             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1382               << endl ;
1383           }
1384         }
1385       }
1386       delete [] EndName ;
1387     }
1388   }
1389
1390   if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1391 // It is done with LoopNode or SwitchNode with CoupledNode()
1392   }
1393   else {
1394     f << "    " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1395     f << "    " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1396     if ( IsFactoryNode() ) {
1397       f << "    " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1398     }
1399     f << "    " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1400     f << "    " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1401
1402     if ( IsComputingNode() || IsFactoryNode() ) {
1403       int i ;
1404       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1405         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1406         if ( !anInPort->IsDataStream() ) {
1407           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1408                  << " " << anInPort->Kind() << endl ;
1409           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1410             << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1411         }
1412       }
1413       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1414         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1415         if ( !anOutPort->IsDataStream() ) {
1416           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1417                  << " " << anOutPort->Kind() << endl ;
1418           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1419             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1420         }
1421       }
1422     }
1423     else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1424       int i ;
1425       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1426         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1427         cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1428                << " " << anInPort->Kind() << endl ;
1429 //        if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1430         if ( anInPort->IsGate() || IsMacroNode() ) {
1431           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1432             << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1433         }
1434         else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1435           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1436             << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1437             << anInPort->PortType() << "' )" << endl ;
1438         }
1439         else {
1440           cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1441 //          f << "    " << "I" << Name() << anInPort->PortName() << " = "
1442 //            << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1443         }
1444       }
1445       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1446         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1447         cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1448                << " " << anOutPort->Kind() << endl ;
1449 //        if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1450         if ( anOutPort->IsGate() || IsMacroNode() ) {
1451           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1452             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1453         }
1454         else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1455           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1456             << Name() << ".OutPort( '" << anOutPort->PortName()
1457             << "' , '" << anOutPort->PortType() << "' )" << endl ;
1458         }
1459         else {
1460           cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1461 //          f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1462 //            << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1463         }
1464       }
1465     }
1466     if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1467       int i ;
1468       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1469         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1470         cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1471                << " " << anInPort->Kind() << endl ;
1472         if ( anInPort->IsDataStream() ) {
1473           if ( IsOneOfInLineNodes() ) {
1474             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1475               << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1476               << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1477               << anInPort->Dependency() << " )" << endl ;
1478           }
1479           else {
1480             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1481               << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1482           }
1483           SUPERV::KindOfSchema        aKindOfSchema ;
1484           SUPERV::KindOfInterpolation aKindOfInterpolation ;
1485           SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1486           ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1487           f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1488             << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1489         }
1490       }
1491       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1492         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1493         cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1494                << " " << anOutPort->Kind() << endl ;
1495         if ( anOutPort->IsDataStream() ) {
1496           if ( IsOneOfInLineNodes() ) {
1497             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1498               << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1499               << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1500               << anOutPort->Dependency() << " )" << endl ;
1501           }
1502           else {
1503             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1504               << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1505           }
1506           long aNumberOfValues ;
1507           aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1508           f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1509         }
1510       }
1511     }
1512   }
1513
1514   return true ;
1515 }
1516
1517 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1518   s << *this ;
1519   ListPorts( s , true ) ;
1520   s << ends ;
1521 }
1522
1523 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1524 //  f << "ComponentName    " << G.ComponentName() << endl ;
1525   if ( G.IsComputingNode() ) {
1526     f << "NodeName         " << G.Name() << endl ;
1527   }
1528   else {
1529     f << "DataFlowName     " << G.Name() << endl ;
1530   }
1531   f << "Kind             " << G.Kind() << endl ;
1532   f << "Service          " << *G.GetService() ;
1533   f << "FirstCreation    " << G.FirstCreation () << endl ;
1534   f << "LastModification " << G.LastModification() << endl ;
1535   f << "EditorRelease    " << G.EditorRelease() << endl ;
1536   f << "Author           " << G.Author() << endl ;
1537 //  f << "Computer         " << G.Computer() << endl ;
1538   f << "Comment          " << G.Comment() << endl ;
1539   f << endl ;
1540   
1541   return f;
1542 }
1543
1544 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1545   int i ;
1546   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1547     const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1548     if ( fromPort->IsPortConnected() ) {
1549       int j ;
1550       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1551         if ( j == 0 ) {
1552           f << "FromNode " << Name() << endl ;
1553         }
1554         f << "         FromServiceParameterName "
1555           << fromPort->GetServicesParameter().Parametername ;
1556         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1557         f << " ToNode " << toPort->NodeName() ;
1558         f << " ToServiceParameterName "
1559           << toPort->GetServicesParameter().Parametername;
1560         f << " Value " ;
1561         fromPort->StringValue( f ) ;
1562         f << endl ;
1563       }
1564     }
1565   }
1566 }
1567
1568 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1569 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
1570
1571   fOut  << D.Day << "/" 
1572         << D.Month << "/" 
1573         << D.Year << " - " 
1574         << D.Hour << ":" 
1575         << D.Minute <<  ":"  
1576         << D.Second;
1577
1578 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
1579   return fOut;
1580 }
1581