]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphBase/DataFlowBase_ComputingNode.cxx
Salome HOME
Merging with JR_ASV_2_1_0_deb_with_KERNEL_Head branch, which contains many bug fixes...
[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 // JR 12.01.2005 : InitLoop and DoLoop are reserved parameter names in LoopNodes :
612   if ( IsLoopNode() && ( strcmp( InputParameterName , "InitLoop" ) == 0 ||
613                          strcmp( InputParameterName , "DoLoop" ) == 0 ) ) {
614     return NULL ;
615   }
616   return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
617                                             Kind() ,
618                                             InputParameterName ,
619                                             InputParameterType ,
620                                             aKindOfPort ,
621                                             index ,
622                                             _Graph_prof_debug , _Graph_fdebug ) ;
623 }
624 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
625                                                            const char * OutputParameterType ,
626                                                            const SUPERV::KindOfPort aKindOfPort ,
627                                                            int index ) {
628   cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
629   return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
630                                              Kind() ,
631                                              OutputParameterName ,
632                                              OutputParameterType ,
633                                              aKindOfPort ,
634                                              index ,
635                                              _Graph_prof_debug , _Graph_fdebug ) ;
636 }
637
638 void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) {
639   GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
640 }
641 void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) {
642   GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
643 }
644
645 GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName ,
646                                                                              const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
647                                                                              const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
648                                                                              const SUPERV::KindOfPort aKindOfPort ,
649                                                                              int index ) {
650 //  IncrDataStreamInPorts() ;
651   GraphBase::InDataStreamPort * aDataStreamPort ;
652   aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
653                                                                                         Kind() ,
654                                                                                         InputParameterName ,
655                                                                                         DataStreamTypeToString( InputParameterType ).c_str() ,
656                                                                                         aKindOfPort ,
657                                                                                         index ,
658                                                                                         _Graph_prof_debug ,
659                                                                                         _Graph_fdebug ) ;
660   aDataStreamPort->Dependency( aDependency ) ;
661   if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) {
662     aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ;
663   }
664   return aDataStreamPort ;
665 }
666 GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName ,
667                                                                                const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
668                                                                                const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
669                                                                                const SUPERV::KindOfPort aKindOfPort ,
670                                                                                int index ) {
671 //  IncrDataStreamOutPorts() ;
672   GraphBase::OutDataStreamPort * aDataStreamPort ;
673   aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
674                                                                                           Kind() ,
675                                                                                           OutputParameterName ,
676                                                                                           DataStreamTypeToString( OutputParameterType ).c_str() ,
677                                                                                           aKindOfPort ,
678                                                                                           index ,
679                                                                                           _Graph_prof_debug ,
680                                                                                           _Graph_fdebug ) ;
681   aDataStreamPort->Dependency( aDependency ) ;
682   return aDataStreamPort ;
683 }
684
685
686 bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode ,
687                                          GraphBase::EndOfLoopNode * anEndLoopNode ) const {
688   cdebug_in << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
689             << anEndLoopNode->Name() << ") LinkedNodesSize "
690             << LinkedNodesSize() << endl;
691
692   int i ;
693   if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) {
694     cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
695                << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
696                << LinkedNodesSize() << " false" << endl;
697     return false ;
698   }
699 // We check that all nodes linked to that node go to the end of LoopNode :
700   for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
701     GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
702     cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ;
703     if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) {
704       if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
705         cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
706                    << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
707                    << LinkedNodesSize() << " false" << endl;
708         return false ;
709       }
710     }
711   }
712   cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
713              << anEndLoopNode->Name() << ") LinkedNodesSize "
714              << LinkedNodesSize() << " true" << endl;
715   return true ;
716 }
717
718 bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
719                                             GraphBase::EndOfLoopNode * anEndLoopNode ) const {
720   cdebug_in << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
721             << anEndLoopNode->Name() << ") LinkedFromNodesSize "
722             << LinkedFromNodesSize() << endl;
723
724   int i ;
725   if ( LinkedFromNodesSize() == 0 ) {
726     cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
727                << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
728                << LinkedFromNodesSize() << " false" << endl;
729     return false ;
730   }
731 // We have to check that all nodes linked from that node go to the beginning of LoopNode : 
732   for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) {
733     GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
734     cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ;
735     if ( !aNode->IsLoopNode() || aNode != aLoopNode ) {
736       if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
737         cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
738                    << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
739                    << LinkedFromNodesSize() << " false" << endl;
740         return false ;
741       }
742     }
743   }
744   cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
745              << anEndLoopNode->Name() << ") LinkedFromNodesSize "
746              << LinkedFromNodesSize() << " true" << endl;
747   return true ;
748 }
749
750 #include <sys/time.h>
751 #include <sys/resource.h>
752 #include <unistd.h>
753
754 const long GraphBase::ComputingNode::CpuUsed() {
755   struct rusage usage ;
756   if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
757     perror("GraphBase::CpuUsed") ;
758     return 0 ;
759   }
760 //  return usage.ru_utime.__time_t tv_sec ;
761   cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
762          << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
763   return usage.ru_utime.tv_sec ;
764 }
765
766 #if 0
767 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
768   GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
769   if ( IsInLineNode() || IsGOTONode() ) {
770     unsigned int i;
771     for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
772       const InPort * anInPort = GetNodeInPort( i ) ;
773       if ( anInPort->IsBus() ) {
774         int size = aListOfParameters->size() ;
775         aListOfParameters->resize( size + 1 ) ;
776         (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
777         (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
778         const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
779         (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
780         (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
781       }
782     }
783   }
784   return aListOfParameters ;
785 }
786 #endif
787
788 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
789                                         const char * ComponentName ,
790                                         const char * InterfaceName ,
791                                         const char * Computer ,
792                                         const char * CoupledNode ,
793                                         const ListOfFuncName FuncNames ,
794                                         const ListOfPythonFunctions PythonFunctions ,
795                                         int XCoordinate , int YCoordinate ) const {
796   cdebug_in << "SaveXML Node " << Name() << endl ;
797   QDomElement node = Graph.createElement( "node" ) ;
798   info.appendChild( node ) ;
799   QDomElement componentname = Graph.createElement( "component-name" ) ;
800   QDomText aField ;
801   if ( strlen( ComponentName ) ) {
802 //    f << Tabs << "<component-name>" << ComponentName << "</component-name>"
803 //      << endl ;
804 //    componentname.setNodeValue( ComponentName ) ;
805     aField = Graph.createTextNode( ComponentName ) ;
806   }
807   else {
808 //    f << Tabs << "<component-name>?</component-name>" << endl ;
809 //    componentname.setNodeValue( "?" ) ;
810     aField = Graph.createTextNode( "?" ) ;
811   }
812   node.appendChild( componentname ) ;
813   componentname.appendChild( aField ) ;
814
815   QDomElement interfacename = Graph.createElement("interface-name") ;
816   if ( strlen( InterfaceName ) ) {
817 //    f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
818 //      << endl ;
819 //    interfacename.setAttribute("name" , InterfaceName ) ;
820     aField = Graph.createTextNode( InterfaceName ) ;
821   }
822   else {
823 //    f << Tabs << "<interface-name>?</interface-name>" << endl ;
824 //    interfacename.setAttribute("name" , "?" ) ;
825     aField = Graph.createTextNode( "?" ) ;
826   }
827   node.appendChild(interfacename) ;
828   interfacename.appendChild( aField ) ;
829
830 //  f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
831   QDomElement nodename = Graph.createElement("node-name") ;
832   aField = Graph.createTextNode( Name() ) ;
833   node.appendChild( nodename ) ;
834   nodename.appendChild( aField ) ;
835
836 //  f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
837   QDomElement kind = Graph.createElement( "kind" ) ;
838   QString aKind ;
839
840   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
841 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
842   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
843     aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
844   }
845   else {
846     aKind = aKind.setNum( Kind() ) ;
847   }
848   aField = Graph.createTextNode( aKind ) ;
849   node.appendChild( kind ) ;
850   kind.appendChild( aField ) ;
851
852   if ( IsDataStreamNode() && HasDataStream() != 0 ) {
853     long Timeout ;
854     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
855     double DeltaTime ;
856     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
857
858     QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
859     QString aTimeout ;
860     aTimeout = aTimeout.setNum( Timeout ) ;
861     aField = Graph.createTextNode( aTimeout ) ;
862     node.appendChild( timeout ) ;
863     timeout.appendChild( aField ) ;
864
865     QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
866     QString aDataStreamTrace ;
867     aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
868     aField = Graph.createTextNode( aDataStreamTrace ) ;
869     node.appendChild( datastreamtrace ) ;
870     datastreamtrace.appendChild( aField ) ;
871
872     QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
873     QString aDeltaTime ;
874     aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
875     aField = Graph.createTextNode( aDeltaTime ) ;
876     node.appendChild( deltatime ) ;
877     deltatime.appendChild( aField ) ;
878   }
879
880   QDomElement couplednode = Graph.createElement("coupled-node") ;
881   if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
882        IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
883 //    f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
884 //      << endl ;
885     aField = Graph.createTextNode( CoupledNode ) ;
886   }
887   else {
888 //    f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
889     aField = Graph.createTextNode( "?" ) ;
890   }
891   node.appendChild(couplednode) ;
892   couplednode.appendChild( aField ) ;
893
894 //  f << Tabs << "<service>" << endl ;
895   QDomElement service = Graph.createElement("service") ;
896   node.appendChild(service) ;
897   QDomElement servicename = Graph.createElement("service-name") ;
898   if ( strlen( ServiceName() ) ) {
899 //    f << Tabs << "    <service-name>" << ServiceName() << "</service-name>" << endl ;
900     aField = Graph.createTextNode( ServiceName() ) ;
901   }
902   else {
903 //    f << Tabs << "    <service-name>?</service-name>" << endl ;
904     aField = Graph.createTextNode( "?" ) ;
905   }
906   service.appendChild(servicename) ;
907   servicename.appendChild( aField ) ;
908
909   cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
910          << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
911   QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
912   service.appendChild(inParameterlist) ;
913   unsigned int i;
914   GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
915   for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
916     const GraphBase::InPort * anInPort ;
917     anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
918     if ( !anInPort->IsDataStream() ) {
919       cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
920              << " InParameterPort " << anInPort->Kind() << endl ;
921       QDomElement inParameter = Graph.createElement("inParameter") ;
922       inParameterlist.appendChild(inParameter) ;
923       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
924       if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
925         aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
926       }
927       else {
928         aField = Graph.createTextNode( "?" ) ;
929       }
930       inParameter.appendChild(inParametertype) ;
931       inParametertype.appendChild( aField ) ;
932       QDomElement inParametername = Graph.createElement("inParameter-name") ;
933       if ( strlen( ServiceInParameter()[i].Parametername ) ) {
934         aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
935       }
936       else {
937         aField = Graph.createTextNode( "?" ) ;
938       }
939       inParameter.appendChild(inParametername) ;
940       inParametername.appendChild( aField ) ;
941     }
942   }
943   QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
944   service.appendChild(outParameterlist) ;
945   for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
946     const GraphBase::OutPort * anOutPort ;
947     anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
948     if ( !anOutPort->IsDataStream() ) {
949       cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
950              << " OutParameterPort " << anOutPort->Kind() << endl ;
951       QDomElement outParameter = Graph.createElement("outParameter") ;
952       outParameterlist.appendChild(outParameter) ;
953       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
954       if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
955         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
956       }
957       else {
958         aField = Graph.createTextNode( "?" ) ;
959       }
960       outParameter.appendChild(outParametertype) ;
961       outParametertype.appendChild( aField ) ;
962       QDomElement outParametername = Graph.createElement("outParameter-name") ;
963       if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
964         aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
965       }
966       else {
967         aField = Graph.createTextNode( "?" ) ;
968       }
969       outParameter.appendChild(outParametername) ;
970       outParametername.appendChild( aField ) ;
971     }
972   }
973
974   QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
975   node.appendChild( DataStreamlist ) ;
976   for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
977     const GraphBase::InPort * anInPort ;
978     anInPort = aNode->GetNodeInPort( i ) ;
979     if ( anInPort->IsDataStream() ) {
980       cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
981              << " InDataStreamPort " << anInPort->Kind() << endl ;
982       QDomElement inParameter = Graph.createElement("inParameter") ;
983       DataStreamlist.appendChild(inParameter) ;
984       QDomElement inParametertype = Graph.createElement("inParameter-type") ;
985       QString aType ;
986       aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
987       cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
988              << " " << aType << endl ;
989       aField = Graph.createTextNode( aType ) ;
990       inParameter.appendChild(inParametertype) ;
991       inParametertype.appendChild( aField ) ;
992       QDomElement inParametername = Graph.createElement("inParameter-name") ;
993       if ( strlen( anInPort->PortName() ) ) {
994         aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
995       }
996       else {
997         aField = Graph.createTextNode( "?" ) ;
998       }
999       inParameter.appendChild(inParametername) ;
1000       inParametername.appendChild( aField ) ;
1001       cdebug << "SaveXML " << anInPort->PortName() << endl ;
1002       QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
1003       QString aDependency ;
1004       aDependency = aDependency.setNum( anInPort->Dependency() ) ;
1005       aField = Graph.createTextNode( aDependency ) ;
1006       inParameter.appendChild(inParameterdependency) ;
1007       inParameterdependency.appendChild( aField ) ;
1008       cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
1009       SUPERV::KindOfSchema        aKindOfSchema ;
1010       SUPERV::KindOfInterpolation aKindOfInterpolation ;
1011       SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1012       ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1013       QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
1014       QString aSchema ;
1015       aSchema = aSchema.setNum( aKindOfSchema ) ;
1016       aField = Graph.createTextNode( aSchema ) ;
1017       inParameter.appendChild(inParameterKindOfSchema) ;
1018       inParameterKindOfSchema.appendChild( aField ) ;
1019       cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
1020       QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
1021       QString anInterpolation ;
1022       anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
1023       aField = Graph.createTextNode( anInterpolation ) ;
1024       inParameter.appendChild(inParameterKindOfInterpolation) ;
1025       inParameterKindOfInterpolation.appendChild( aField ) ;
1026       cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
1027       QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
1028       QString anExtrapolation ;
1029       anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
1030       aField = Graph.createTextNode( anExtrapolation ) ;
1031       inParameter.appendChild(inParameterKindOfExtrapolation) ;
1032       inParameterKindOfExtrapolation.appendChild( aField ) ;
1033       cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
1034     }
1035   }
1036   for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
1037     const GraphBase::OutPort * anOutPort ;
1038     anOutPort = aNode->GetNodeOutPort( i ) ;
1039     if ( anOutPort->IsDataStream() ) {
1040       cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1041              << " OutDataStreamPort " << anOutPort->Kind() << endl ;
1042       QDomElement outParameter = Graph.createElement("outParameter") ;
1043       DataStreamlist.appendChild(outParameter) ;
1044       QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1045       QString aType ;
1046       aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
1047       cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
1048              << " " << aType << endl ;
1049       aField = Graph.createTextNode( aType ) ;
1050       outParameter.appendChild(outParametertype) ;
1051       outParametertype.appendChild( aField ) ;
1052       QDomElement outParametername = Graph.createElement("outParameter-name") ;
1053       if ( strlen( anOutPort->PortName() ) ) {
1054         aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
1055       }
1056       else {
1057         aField = Graph.createTextNode( "?" ) ;
1058       }
1059       outParameter.appendChild(outParametername) ;
1060       outParametername.appendChild( aField ) ;
1061       cdebug << "SaveXML " << anOutPort->PortName() << endl ;
1062       QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
1063       QString aDependency ;
1064       aDependency = aDependency.setNum( anOutPort->Dependency() )  ;
1065       aField = Graph.createTextNode( aDependency ) ;
1066       outParameter.appendChild(outParameterdependency) ;
1067       outParameterdependency.appendChild( aField ) ;
1068       cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1069       long aNumberOfValues ;
1070       aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1071       QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1072       QString aValues ;
1073       aValues = aValues.setNum( aNumberOfValues ) ;
1074       aField = Graph.createTextNode( aValues ) ;
1075       outParameter.appendChild(outParameterNumberOfValues) ;
1076       outParameterNumberOfValues.appendChild( aField ) ;
1077       cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1078     }
1079   }
1080 //  f << Tabs << "</Parameter-list>" << endl ;    
1081
1082 //  f << Tabs << "<PyFunction-list>" << endl ;
1083   QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1084   node.appendChild( PyFunctionlist ) ;
1085   for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1086 //    f << Tabs << "    <PyFunction>" << endl ;
1087     QDomElement PyFunction = Graph.createElement("PyFunction") ;
1088     PyFunctionlist.appendChild( PyFunction ) ;
1089     int j ;
1090     QDomElement FuncName = Graph.createElement("FuncName") ;
1091     if ( strlen( FuncNames[i].c_str() ) ) {
1092       aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1093     }
1094     else {
1095       aField = Graph.createTextNode( "?" ) ;
1096     }
1097     PyFunction.appendChild( FuncName ) ;
1098     FuncName.appendChild( aField ) ;
1099     if ( (*PythonFunctions[i]).length() ) {
1100       for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1101         QDomElement PyFunc = Graph.createElement("PyFunc") ;
1102         QDomCDATASection aCDATA ;
1103       // mpv: Linux 8.0 compiler compatibility
1104         char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1105         int i ;
1106         for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1107           if ( aCDATAChar[ i ] != ' ' ) {
1108             break ;
1109           }
1110         }
1111         if ( i == (int ) strlen( aCDATAChar ) ) {
1112           aCDATA = Graph.createCDATASection( "?" ) ;
1113         }
1114         else {
1115           aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1116         }
1117         PyFunction.appendChild( PyFunc ) ;
1118         PyFunc.appendChild( aCDATA ) ;
1119       }
1120     }
1121     else {
1122       QDomElement PyFunc = Graph.createElement("PyFunc") ;
1123       QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1124       PyFunction.appendChild( PyFunc ) ;
1125       PyFunc.appendChild( aCDATA ) ;
1126     }
1127   }
1128
1129 //  f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1130 //    << endl ;
1131   QDomElement creationdate = Graph.createElement("creation-date") ;
1132   char fdate[30] ;
1133   sprintf( fdate , "%d/%d/%d - %d:%d:%d" ,  FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1134   aField = Graph.createTextNode( fdate ) ;
1135   node.appendChild( creationdate ) ;
1136   creationdate.appendChild( aField ) ;
1137 //  f << Tabs << "<lastmodification-date>" << LastModification()
1138 //    << "</lastmodification-date>" << endl ;
1139   QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1140   char ldate[30] ;
1141   sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1142   aField = Graph.createTextNode( ldate ) ;
1143   node.appendChild( lastmodificationdate ) ;
1144   lastmodificationdate.appendChild( aField ) ;
1145 //  f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1146 //    << endl ;
1147   QDomElement editorrelease = Graph.createElement("editor-release") ;
1148   aField = Graph.createTextNode( EditorRelease() ) ;
1149   node.appendChild( editorrelease ) ;
1150   editorrelease.appendChild( aField ) ;
1151   QDomElement author = Graph.createElement("author") ;
1152   if ( strlen( Author() ) ) {
1153 //    f << Tabs << "<author>" << Author() << "</author>" << endl ;
1154     aField = Graph.createTextNode( Author() ) ;
1155   }
1156   else {
1157 //    f << Tabs << "<author>?</author>" << endl ;
1158     aField = Graph.createTextNode( "?" ) ;
1159   }
1160   node.appendChild( author ) ;
1161   author.appendChild( aField ) ;
1162   QDomElement container = Graph.createElement("container") ;
1163   if ( IsFactoryNode() && strlen( Computer) ) {
1164 //    f << Tabs << "<container>" << Computer << "</container>" << endl ;
1165     aField = Graph.createTextNode( Computer ) ;
1166   }
1167   else {
1168 //    f << Tabs << "<container>?</container>" << endl ;
1169     aField = Graph.createTextNode( "?" ) ;
1170   }
1171   node.appendChild( container ) ;
1172   container.appendChild( aField ) ;
1173   QDomElement comment = Graph.createElement("comment") ;
1174   if ( strlen( Comment() ) ) {
1175 //    f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1176     aField = Graph.createTextNode( Comment() ) ;
1177   }
1178   else {
1179 //    f << Tabs << "<comment>?</comment>" << endl ;
1180     aField = Graph.createTextNode( "?" ) ;
1181   }
1182   node.appendChild( comment ) ;
1183   comment.appendChild( aField ) ;
1184 //  f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1185   QDomElement xposition = Graph.createElement("x-position") ;
1186   QString aXCoordinate ;
1187   aXCoordinate = aKind.setNum( XCoordinate ) ;
1188   aField = Graph.createTextNode( aXCoordinate ) ;
1189   node.appendChild( xposition ) ;
1190   xposition.appendChild( aField ) ;
1191 //  f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1192   QDomElement yposition = Graph.createElement("y-position") ;
1193   QString aYCoordinate ;
1194   aYCoordinate = aKind.setNum( YCoordinate ) ;
1195   aField = Graph.createTextNode( aYCoordinate ) ;
1196   node.appendChild( yposition ) ;
1197   yposition.appendChild( aField ) ;
1198   cdebug_out << "SaveXML Node " << Name() << endl ;
1199   return true ;
1200 }
1201
1202 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1203                                        const char * ComponentName ,
1204                                        const char * InterfaceName ,
1205                                        const char * Computer ,
1206                                        const GraphBase::InLineNode * aCoupledNode ,
1207                                        const ListOfFuncName FuncNames ,
1208                                        const ListOfPythonFunctions PythonFunctions ,
1209                                        int XCoordinate , int YCoordinate ) const {
1210   // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1211 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1212   if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1213     f << "    " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1214      if ( GraphMacroLevel() ) {
1215       f << "    " << Name() << ".SetCoupled( '"
1216         << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1217     }
1218  }
1219   else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1220     f << "    " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1221     long Timeout ;
1222     SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1223     double DeltaTime ;
1224     ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1225     f << "    " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1226       << " , " << DeltaTime << " )" << endl ;
1227   }
1228   else if ( IsComputingNode() ) {
1229     int i ;
1230     f << "    " << Name() << "_ServiceinParameter = []" << endl ;
1231     for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1232       f << "    " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1233         << ServiceInParameter()[i].Parametertype << "' , '"
1234         << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1235     }
1236     f << "    " << Name() << "_ServiceoutParameter = []" << endl ;
1237     for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1238       f << "    " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1239         << ServiceOutParameter()[i].Parametertype << "' , '"
1240         << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1241     }
1242     f << "    " << Name() << "_ServiceinStreamParameter = []" << endl ;
1243     for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1244       f << "    " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1245         << ServiceInStreamParameter()[i].Parametertype << " , '"
1246         << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1247         << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1248     }
1249     f << "    " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1250     for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1251       f << "    " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1252         << ServiceOutStreamParameter()[i].Parametertype << " , '"
1253         << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1254         << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1255     }
1256     f << "    " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1257       << "' , " << Name() << "_ServiceinParameter"
1258       << " , " << Name() << "_ServiceoutParameter"
1259       << " , " << Name() << "_ServiceinStreamParameter"
1260       << " , " << Name() << "_ServiceoutStreamParameter"
1261       << " , 0 , 0 )" << endl ;
1262     f << "    " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1263       << endl ;
1264   }
1265   else if ( IsFactoryNode() ) {
1266     f << "    " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1267       << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1268       << endl ;
1269   }
1270   else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1271 // It is done with LoopNode or SwitchNode with CoupledNode()
1272   }
1273   else {
1274     if ( !IsMacroNode() ) {
1275       f << "    " << "Py" << Name() << " = []" << endl ;
1276     }
1277     int i ;
1278     SUPERV::ListOfStrings aPyFunc ;
1279     if ( PythonFunctions.size() ) {
1280       aPyFunc = *PythonFunctions[0] ;
1281       for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1282         f << "    " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1283       }
1284     }
1285     if ( IsInLineNode() ) {
1286       f << "    " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1287         << Name() << " )" << endl ;
1288     }
1289     else if ( IsGOTONode() ) {
1290       if ( aCoupledNode ) {
1291         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1292           << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1293       }
1294       else {
1295         f << "    " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1296           << Name() << " , '' )" << endl ;
1297       }
1298     }
1299     else if ( IsMacroNode() ) {
1300       if ( aCoupledNode ) {
1301         f << "    " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1302         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1303       }
1304       else {
1305         f << "    " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1306       }
1307       f << "    " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1308     }
1309     else {
1310 //      char * EndName = NULL ;
1311 //      EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1312 //      strcpy( EndName , "End" ) ;
1313 //      strcat( EndName , Name() ) ;
1314       char * EndName = aCoupledNode->Name() ;
1315       if ( IsLoopNode() ) {
1316         int i ;
1317         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1318         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1319         f << "    " << "PyMore" << Name() << " = []" << endl ;
1320         for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1321           f << "    " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1322         }
1323         f << "    " << "PyNext" << Name() << " = []" << endl ;
1324         for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1325           f << "    " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1326         }
1327         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1328           << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1329           << FuncNames[1].c_str() << "' , PyMore" << Name()
1330           << " , '" << FuncNames[2].c_str() << "' , PyNext"
1331           << Name() << " )" << endl ;
1332         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1333         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1334         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1335         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1336           << aCoupledNode->YCoordinate() << " )" << endl ;
1337         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1338         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1339         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1340           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1341             << endl ;
1342         }
1343         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1344         for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1345           const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1346           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1347                  << " " << anInPort->Kind() << endl ;
1348           if ( anInPort->IsLoop() ) {
1349             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1350               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1351           }
1352           else if ( anInPort->IsInLine() ) {
1353             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1354               << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1355               << anInPort->PortType() << "' )" << endl ;
1356           }
1357           else if ( anInPort->IsDataStream() ) {
1358             f << "    " << "I" << Name() << anInPort->PortName() << " = " << Name()
1359               << ".InStreamPort( '" << anInPort->PortName()
1360               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1361               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1362             SUPERV::KindOfSchema        aKindOfSchema ;
1363             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1364             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1365             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1366             f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1367               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1368           }
1369           else if ( anInPort->IsGate() ) {
1370             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1371               << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1372           }
1373         }
1374         for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1375           const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1376           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1377                  << " " << anOutPort->Kind() << endl ;
1378           if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1379             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1380               << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1381           }
1382           else if ( anOutPort->IsDataStream() ) {
1383             f << "    " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1384               << ".OutStreamPort( '" << anOutPort->PortName()
1385               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1386               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1387             long aNumberOfValues ;
1388             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1389             f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1390               << endl ;
1391           }
1392         }
1393         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1394           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1395           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1396                  << " " << anInPort->Kind() << endl ;
1397           if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1398             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1399               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1400           }
1401           else if ( anInPort->IsDataStream() ) {
1402             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1403               << ".InStreamPort( '" << anInPort->PortName()
1404               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1405               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1406             SUPERV::KindOfSchema        aKindOfSchema ;
1407             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1408             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1409             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1410             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1411               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1412           }
1413         }
1414         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1415           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1416           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1417                  << " " << anOutPort->Kind() << endl ;
1418           if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1419             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1420               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1421           }
1422           else if ( anOutPort->IsDataStream() ) {
1423             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1424               << ".OutStreamPort( '" << anOutPort->PortName()
1425               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1426               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1427             long aNumberOfValues ;
1428             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1429             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1430               << endl ;
1431           }
1432         }
1433       }
1434       else if ( IsSwitchNode() ) {
1435         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1436           << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1437         f << "    " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1438         f << "    " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1439         f << "    " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1440         f << "    " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1441           << aCoupledNode->YCoordinate() << " )" << endl ;
1442         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1443         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1444         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1445           f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1446             << endl ;
1447         }
1448         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1449         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1450           const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1451           cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1452                  << " " << anInPort->Kind() << endl ;
1453 //          if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1454           if ( anInPort->IsGate() ) {
1455             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1456               << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1457           }
1458           else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1459             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1460               << ".InPort( '" << anInPort->PortName()
1461               << "' , '" << anInPort->PortType() << "' )" << endl ;
1462           }
1463           else if ( anInPort->IsDataStream() ) {
1464             f << "    " << "I" << EndName << anInPort->PortName() << " = " << EndName
1465               << ".InStreamPort( '" << anInPort->PortName()
1466               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1467               << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1468             SUPERV::KindOfSchema        aKindOfSchema ;
1469             SUPERV::KindOfInterpolation aKindOfInterpolation ;
1470             SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1471             ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1472             f << "    " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1473               << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1474           }
1475         }
1476         for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1477           const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1478           cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1479                  << " " << anOutPort->Kind() << endl ;
1480 //          if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1481           if ( anOutPort->IsGate() ) {
1482             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1483               << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1484           }
1485           else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1486             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1487               << ".OutPort( '" << anOutPort->PortName()
1488               << "' , '" << anOutPort->PortType() << "' )" << endl ;
1489           }
1490           else if ( anOutPort->IsDataStream() ) {
1491             f << "    " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1492               << ".OutStreamPort( '" << anOutPort->PortName()
1493               << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1494               << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1495             long aNumberOfValues ;
1496             aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1497             f << "    " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1498               << endl ;
1499           }
1500         }
1501       }
1502       delete [] EndName ;
1503     }
1504   }
1505
1506   if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1507 // It is done with LoopNode or SwitchNode with CoupledNode()
1508   }
1509   else {
1510     f << "    " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1511     f << "    " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1512     if ( IsFactoryNode() ) {
1513       f << "    " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1514     }
1515     f << "    " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1516     f << "    " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1517
1518     if ( IsComputingNode() || IsFactoryNode() ) {
1519       int i ;
1520       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1521         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1522         if ( !anInPort->IsDataStream() ) {
1523           cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1524                  << " " << anInPort->Kind() << endl ;
1525           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1526             << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1527         }
1528       }
1529       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1530         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1531         if ( !anOutPort->IsDataStream() ) {
1532           cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1533                  << " " << anOutPort->Kind() << endl ;
1534           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1535             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1536         }
1537       }
1538     }
1539     else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1540       int i ;
1541       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1542         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1543         cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1544                << " " << anInPort->Kind() << endl ;
1545 //        if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1546         if ( anInPort->IsGate() || IsMacroNode() ) {
1547           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1548             << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1549         }
1550         else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1551           f << "    " << "I" << Name() << anInPort->PortName() << " = "
1552             << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1553             << anInPort->PortType() << "' )" << endl ;
1554         }
1555         else {
1556           cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1557 //          f << "    " << "I" << Name() << anInPort->PortName() << " = "
1558 //            << Name() << ".GetInPort( '" << anInPort->PortName()  << "' )" << endl ;
1559         }
1560       }
1561       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1562         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1563         cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1564                << " " << anOutPort->Kind() << endl ;
1565 //        if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1566         if ( anOutPort->IsGate() || IsMacroNode() ) {
1567           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1568             << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1569         }
1570         else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1571           f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1572             << Name() << ".OutPort( '" << anOutPort->PortName()
1573             << "' , '" << anOutPort->PortType() << "' )" << endl ;
1574         }
1575         else {
1576           cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1577 //          f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1578 //            << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1579         }
1580       }
1581     }
1582     if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1583       int i ;
1584       for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1585         const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1586         cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1587                << " " << anInPort->Kind() << endl ;
1588         if ( anInPort->IsDataStream() ) {
1589           if ( IsOneOfInLineNodes() ) {
1590             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1591               << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1592               << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1593               << anInPort->Dependency() << " )" << endl ;
1594           }
1595           else {
1596             f << "    " << "I" << Name() << anInPort->PortName() << " = "
1597               << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1598           }
1599           SUPERV::KindOfSchema        aKindOfSchema ;
1600           SUPERV::KindOfInterpolation aKindOfInterpolation ;
1601           SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1602           ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1603           f << "    " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1604             << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1605         }
1606       }
1607       for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1608         const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1609         cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1610                << " " << anOutPort->Kind() << endl ;
1611         if ( anOutPort->IsDataStream() ) {
1612           if ( IsOneOfInLineNodes() ) {
1613             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1614               << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1615               << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1616               << anOutPort->Dependency() << " )" << endl ;
1617           }
1618           else {
1619             f << "    " << "O" << Name() << anOutPort->PortName() << " = "
1620               << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1621           }
1622           long aNumberOfValues ;
1623           aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1624           f << "    " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1625         }
1626       }
1627     }
1628   }
1629
1630   return true ;
1631 }
1632
1633 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1634   s << *this ;
1635   ListPorts( s , true ) ;
1636   s << ends ;
1637 }
1638
1639 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1640 //  f << "ComponentName    " << G.ComponentName() << endl ;
1641   if ( G.IsComputingNode() ) {
1642     f << "NodeName         " << G.Name() << endl ;
1643   }
1644   else {
1645     f << "DataFlowName     " << G.Name() << endl ;
1646   }
1647   f << "Kind             " << G.Kind() << endl ;
1648   f << "Service          " << *G.GetService() ;
1649   f << "FirstCreation    " << G.FirstCreation () << endl ;
1650   f << "LastModification " << G.LastModification() << endl ;
1651   f << "EditorRelease    " << G.EditorRelease() << endl ;
1652   f << "Author           " << G.Author() << endl ;
1653 //  f << "Computer         " << G.Computer() << endl ;
1654   f << "Comment          " << G.Comment() << endl ;
1655   f << endl ;
1656   
1657   return f;
1658 }
1659
1660 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1661   int i ;
1662   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1663     const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1664     if ( fromPort->IsPortConnected() ) {
1665       int j ;
1666       for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1667         if ( j == 0 ) {
1668           f << "FromNode " << Name() << endl ;
1669         }
1670         f << "         FromServiceParameterName "
1671           << fromPort->GetServicesParameter().Parametername ;
1672         const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1673         f << " ToNode " << toPort->NodeName() ;
1674         f << " ToServiceParameterName "
1675           << toPort->GetServicesParameter().Parametername;
1676         f << " Value " ;
1677         fromPort->StringValue( f ) ;
1678         f << endl ;
1679       }
1680     }
1681   }
1682 }
1683
1684 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1685 //  cdebug_in << "operator<< GraphEditor::Date" << endl;
1686
1687   fOut  << D.Day << "/" 
1688         << D.Month << "/" 
1689         << D.Year << " - " 
1690         << D.Hour << ":" 
1691         << D.Minute <<  ":"  
1692         << D.Second;
1693
1694 //  cdebug_out << "operator<< GraphEditor::Date" << endl;
1695   return fOut;
1696 }
1697