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