1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : DataFlowBase_ComputingNode.cxx
8 // Author : Jean Rahuel, CEA
16 #include "DataFlowBase_StreamGraph.hxx"
17 //#include "DataFlowBase_LoopNode.hxx"
19 static void InitFields( //SUPERV::KindOfNode &_Kind ,
20 SUPERV::SDate &_FirstCreation ,
21 SUPERV::SDate &_LastModification ,
22 char * &_EditorRelease ,
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);
36 // _Kind = SUPERV::DataFlowGraph ;
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;
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 ;
52 // _SubGraphNumber = 0 ;
53 // _HeadNode = false ;
54 _GeneratedName = false ;
56 // _DataStreamInPortsNumber = 0 ;
57 // _DataStreamOutPortsNumber = 0 ;
59 _ConnectedInPortsNumber = 0 ;
60 _DecrConnectedInPortsNumber = 0 ;
61 // _LinkedNodesSize = 0 ;
62 // _SubGraphNumber = 0 ;
65 GraphBase::ComputingNode::ComputingNode() :
66 // GraphBase::PortsOfNode::PortsOfNode() {
67 GraphBase::StreamNode::StreamNode() {
77 //_DataStreamInPortsNumber ,
78 //_DataStreamOutPortsNumber ,
79 _ConnectedInPortsNumber ,
80 _DecrConnectedInPortsNumber ) ;
83 Kind( SUPERV::DataFlowGraph ) ;
84 _NamingService = NULL ;
85 _Node_var = SUPERV::CNode::_nil() ;
88 _ThreadNo = pthread_self() ;
89 cdebug << "GraphBase::Node::Node " << this << " " << endl ;
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 ) {
103 // MESSAGE( "GraphBase::ComputingNode::ComputingNode " << aDataFlowName << " Graph_prof_debug " << Graph_prof_debug ) ;
104 InitFields( //_Kind ,
112 //_DataStreamInPortsNumber ,
113 //_DataStreamOutPortsNumber ,
114 _ConnectedInPortsNumber ,
115 _DecrConnectedInPortsNumber ) ;
117 //_SubGraphNumber ) ;
119 // Kind( SUPERV::DataFlowGraph ) ;
120 Kind( DataFlowkind ) ;
121 _ORB = CORBA::ORB::_duplicate( ORB ) ;
122 _NamingService = ptrNamingService ;
123 _Node_var = SUPERV::CNode::_nil() ;
126 _ThreadNo = pthread_self() ;
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 ) ;
136 // cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ;
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 ;
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 ,
157 int * Graph_prof_debug ,
158 ofstream * Graph_fdebug ) :
159 // GraphBase::PortsOfNode::PortsOfNode() {
160 GraphBase::StreamNode::StreamNode( NodeName , akind , Graph_prof_debug , Graph_fdebug ) {
162 _ORB = CORBA::ORB::_duplicate( ORB ) ;
163 _NamingService = ptrNamingService ;
164 _Node_var = SUPERV::CNode::_nil() ;
167 _ThreadNo = pthread_self() ;
172 time_t T = time(NULL);
173 struct tm * Tm = localtime(&T);
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;
182 if ( NodeEditorRelease != NULLSTRING ) {
183 _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ;
184 strcpy( _EditorRelease , NodeEditorRelease ) ;
187 _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
188 strcpy( _EditorRelease , SuperVision_Version ) ;
191 if ( NodeAuthor != NULLSTRING ) {
192 _Author = new char[ strlen( NodeAuthor ) + 1 ] ;
193 strcpy( _Author , NodeAuthor ) ;
196 _Author = NULLSTRING ;
199 if ( NodeComment != NULLSTRING ) {
200 _Comment = new char[ strlen( NodeComment ) + 1 ] ;
201 strcpy( _Comment , NodeComment ) ;
204 _Comment = NULLSTRING ;
207 // _SubGraphNumber = 0 ;
208 // _HeadNode = false ;
209 _GeneratedName = GeneratedName ;
211 // const char *aNodeName = NodeName ;
212 // _Name = new char[strlen(aNodeName)+1];
213 // strcpy(_Name , aNodeName);
215 // _DataStreamInPortsNumber = 0 ;
216 // _DataStreamOutPortsNumber = 0 ;
218 _ConnectedInPortsNumber = 0 ;
219 _DecrConnectedInPortsNumber = 0 ;
220 // _LinkedNodesSize = 0 ;
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;
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 ;
241 cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl;
244 GraphBase::ComputingNode::~ComputingNode() {
245 cdebug << "GraphBase::ComputingNode::~ComputingNode " << this
246 << " Name() "<< Name() << " _Comment "
247 << (void *) _Comment << " " << _Comment << " " << endl ;
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 ;
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 ;
262 SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const {
263 // cdebug << "GraphBase::ComputingNode::FirstCreation "
264 // << " Name '" << Name() << "' " << _FirstCreation << " "
265 // << _LastModification << endl ;
266 return _FirstCreation;
269 SUPERV::SDate GraphBase::ComputingNode::LastModification () const {
270 return _LastModification ;
273 void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) {
274 _FirstCreation = aDate ;
277 void GraphBase::ComputingNode::LastModification(const SUPERV::SDate aDate ) {
278 _LastModification = aDate ;
281 bool GraphBase::ComputingNode::EditorRelease(const char * c){
282 if ( _EditorRelease && _EditorRelease != NULLSTRING )
283 delete _EditorRelease;
284 _EditorRelease = my_strdup(c);
288 bool GraphBase::ComputingNode::Author(const char * a) {
289 cdebug_in << "GraphBase::ComputingNode::Author " << _Author << endl;
290 if ( _Author && _Author != NULLSTRING )
292 _Author = my_strdup(a);
293 cdebug_out << "GraphBase::ComputingNode::Author " << _Author << endl;
297 bool GraphBase::ComputingNode::Comment(const char *c) {
298 cdebug_in << "GraphBase::ComputingNode::Comment " << _Comment << endl;
299 if ( _Comment != NULLSTRING )
301 _Comment = my_strdup(c);
302 cdebug_out << "GraphBase::ComputingNode::Comment " << _Comment << endl;
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 ) ;
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 ] ) ;
329 if ( BPort == NULL ) {
330 *aNode = my_strdup( NULLSTRING ) ;
331 *aPort = my_strdup( NULLSTRING ) ;
336 bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) {
337 bool RetVal = false ;
338 const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
340 RetVal = thePort->IsPortConnected() ;
343 const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
345 RetVal = thePort->IsPortConnected() ;
351 bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) {
352 bool RetVal = false ;
353 const GraphBase::InPort * theInPort = GetInPort( ToServiceParameterName ) ;
355 RetVal = theInPort->IsDataConnected() ;
358 const GraphBase::OutPort * theOutPort = GetOutPort( ToServiceParameterName ) ;
360 RetVal = theOutPort->IsDataConnected() ;
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() ) {
375 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
377 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
378 Info->theTimeout = Timeout ;
379 Info->theDataStreamTrace = DataStreamTrace ;
380 Info->theDeltaTime = DeltaTime ;
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;
396 void GraphBase::ComputingNode::SetMacroPorts( GraphBase::Graph * aGraph ) {
397 cdebug_in << "GraphBase::ComputingNode::SetMacroPorts fill ports of MacroNode" << endl;
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() ) ;
408 else if ( anInPort->IsParam() || anInPort->IsInLine() ) {
409 aNewInPort = AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() ) ;
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() ) ;
420 else if ( anOutPort->IsParam() || anOutPort->IsInLine() ) {
421 AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() ) ;
424 cdebug_out << "GraphBase::ComputingNode::SetMacroPorts" << endl;
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 ;
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() ) ;
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() ) ;
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() ) ;
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() ) ;
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 ) ;
480 AddInPort( anInPort->PortName() , anInPort->PortType() , anInPort->Kind() , index ) ;
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() ) ;
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() ) ;
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() ) ;
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() ) ;
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 ) ;
527 AddOutPort( anOutPort->PortName() , anOutPort->PortType() , anOutPort->Kind() , index ) ;
531 bool ErrPort = false ;
532 if ( aGraph->GetNodeInPortsSize() != GetNodeInPortsSize() ||
533 aGraph->GetNodeOutPortsSize() != GetNodeOutPortsSize() ) {
536 for ( i = 0 ; i < aGraph->GetNodeInPortsSize() && i < GetNodeInPortsSize() ; i++ ) {
537 if ( !strcmp( aGraph->GetNodeInPort( i )->PortName() , GetNodeInPort( i )->PortName() ) ) {
541 for ( i = 0 ; i < aGraph->GetNodeOutPortsSize() && i < GetNodeOutPortsSize() ; i++ ) {
542 if ( !strcmp( aGraph->GetNodeOutPort( i )->PortName() , GetNodeOutPort( i )->PortName() ) ) {
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 ;
552 else if ( i >= GetNodeInPortsSize() ) {
553 cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << aGraph->GetNodeInPort( i )->PortName()
557 cdebug << "ComputingNode::UpdateMacroPorts In" << i << " " << GetNodeInPort( i )->PortName()
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 ;
566 else if ( i >= GetNodeOutPortsSize() ) {
567 cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << aGraph->GetNodeOutPort( i )->PortName()
571 cdebug << "ComputingNode::UpdateMacroPorts Out" << i << " " << GetNodeOutPort( i )->PortName()
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;
582 void GraphBase::ComputingNode::SetMacroDatas( GraphBase::Graph * aGraph ,
583 GraphBase::Graph * aGraphOfMacroGraph ) {
584 cdebug_in << "GraphBase::ComputingNode::SetMacroDatas fill inputs of MacroNode" << endl;
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 ) ;
596 cdebug_out << "GraphBase::ComputingNode::SetMacroDatas" << endl;
599 void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) {
600 GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
602 void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) {
603 GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
606 GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName ,
607 const char * InputParameterType ,
608 const SUPERV::KindOfPort aKindOfPort ,
610 cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
611 return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
617 _Graph_prof_debug , _Graph_fdebug ) ;
619 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
620 const char * OutputParameterType ,
621 const SUPERV::KindOfPort aKindOfPort ,
623 cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
624 return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
626 OutputParameterName ,
627 OutputParameterType ,
630 _Graph_prof_debug , _Graph_fdebug ) ;
633 void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) {
634 GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
636 void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) {
637 GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
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 ,
645 // IncrDataStreamInPorts() ;
646 GraphBase::InDataStreamPort * aDataStreamPort ;
647 aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
650 DataStreamTypeToString( InputParameterType ).c_str() ,
655 aDataStreamPort->Dependency( aDependency ) ;
656 if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) {
657 aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ;
659 return aDataStreamPort ;
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 ,
666 // IncrDataStreamOutPorts() ;
667 GraphBase::OutDataStreamPort * aDataStreamPort ;
668 aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
670 OutputParameterName ,
671 DataStreamTypeToString( OutputParameterType ).c_str() ,
676 aDataStreamPort->Dependency( aDependency ) ;
677 return aDataStreamPort ;
681 bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode ,
682 GraphBase::EndOfLoopNode * anEndLoopNode ) const {
683 cdebug_in << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
684 << anEndLoopNode->Name() << ") LinkedNodesSize "
685 << LinkedNodesSize() << endl;
688 if ( LinkedNodesSize() == 0 ) {
689 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
690 << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
691 << LinkedNodesSize() << " false" << endl;
694 // We check that all nodes linked to that node go to the end of LoopNode :
695 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
696 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
697 cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ;
698 if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) {
699 if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
700 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
701 << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
702 << LinkedNodesSize() << " false" << endl;
707 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
708 << anEndLoopNode->Name() << ") LinkedNodesSize "
709 << LinkedNodesSize() << " true" << endl;
713 bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
714 GraphBase::EndOfLoopNode * anEndLoopNode ) const {
715 cdebug_in << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
716 << anEndLoopNode->Name() << ") LinkedFromNodesSize "
717 << LinkedFromNodesSize() << endl;
720 if ( LinkedFromNodesSize() == 0 ) {
721 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
722 << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
723 << LinkedFromNodesSize() << " false" << endl;
726 // We have to check that all nodes linked from that node go to the beginning of LoopNode :
727 for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) {
728 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
729 cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ;
730 if ( !aNode->IsLoopNode() || aNode != aLoopNode ) {
731 if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
732 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
733 << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
734 << LinkedFromNodesSize() << " false" << endl;
739 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
740 << anEndLoopNode->Name() << ") LinkedFromNodesSize "
741 << LinkedFromNodesSize() << " true" << endl;
745 #include <sys/time.h>
746 #include <sys/resource.h>
749 const long GraphBase::ComputingNode::CpuUsed() {
750 struct rusage usage ;
751 if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
752 perror("GraphBase::CpuUsed") ;
755 // return usage.ru_utime.__time_t tv_sec ;
756 cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
757 << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
758 return usage.ru_utime.tv_sec ;
762 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
763 GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
764 if ( IsInLineNode() || IsGOTONode() ) {
766 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
767 const InPort * anInPort = GetNodeInPort( i ) ;
768 if ( anInPort->IsBus() ) {
769 int size = aListOfParameters->size() ;
770 aListOfParameters->resize( size + 1 ) ;
771 (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
772 (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
773 const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
774 (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
775 (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
779 return aListOfParameters ;
783 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
784 const char * ComponentName ,
785 const char * InterfaceName ,
786 const char * Computer ,
787 const char * CoupledNode ,
788 const ListOfFuncName FuncNames ,
789 const ListOfPythonFunctions PythonFunctions ,
790 int XCoordinate , int YCoordinate ) const {
791 cdebug_in << "SaveXML Node " << Name() << endl ;
792 QDomElement node = Graph.createElement( "node" ) ;
793 info.appendChild( node ) ;
794 QDomElement componentname = Graph.createElement( "component-name" ) ;
796 if ( strlen( ComponentName ) ) {
797 // f << Tabs << "<component-name>" << ComponentName << "</component-name>"
799 // componentname.setNodeValue( ComponentName ) ;
800 aField = Graph.createTextNode( ComponentName ) ;
803 // f << Tabs << "<component-name>?</component-name>" << endl ;
804 // componentname.setNodeValue( "?" ) ;
805 aField = Graph.createTextNode( "?" ) ;
807 node.appendChild( componentname ) ;
808 componentname.appendChild( aField ) ;
810 QDomElement interfacename = Graph.createElement("interface-name") ;
811 if ( strlen( InterfaceName ) ) {
812 // f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
814 // interfacename.setAttribute("name" , InterfaceName ) ;
815 aField = Graph.createTextNode( InterfaceName ) ;
818 // f << Tabs << "<interface-name>?</interface-name>" << endl ;
819 // interfacename.setAttribute("name" , "?" ) ;
820 aField = Graph.createTextNode( "?" ) ;
822 node.appendChild(interfacename) ;
823 interfacename.appendChild( aField ) ;
825 // f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
826 QDomElement nodename = Graph.createElement("node-name") ;
827 aField = Graph.createTextNode( Name() ) ;
828 node.appendChild( nodename ) ;
829 nodename.appendChild( aField ) ;
831 // f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
832 QDomElement kind = Graph.createElement( "kind" ) ;
835 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
836 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
837 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
838 aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
841 aKind = aKind.setNum( Kind() ) ;
843 aField = Graph.createTextNode( aKind ) ;
844 node.appendChild( kind ) ;
845 kind.appendChild( aField ) ;
847 if ( IsDataStreamNode() && HasDataStream() != 0 ) {
849 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
851 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
853 QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
855 aTimeout = aTimeout.setNum( Timeout ) ;
856 aField = Graph.createTextNode( aTimeout ) ;
857 node.appendChild( timeout ) ;
858 timeout.appendChild( aField ) ;
860 QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
861 QString aDataStreamTrace ;
862 aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
863 aField = Graph.createTextNode( aDataStreamTrace ) ;
864 node.appendChild( datastreamtrace ) ;
865 datastreamtrace.appendChild( aField ) ;
867 QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
869 aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
870 aField = Graph.createTextNode( aDeltaTime ) ;
871 node.appendChild( deltatime ) ;
872 deltatime.appendChild( aField ) ;
875 QDomElement couplednode = Graph.createElement("coupled-node") ;
876 if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
877 IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
878 // f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
880 aField = Graph.createTextNode( CoupledNode ) ;
883 // f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
884 aField = Graph.createTextNode( "?" ) ;
886 node.appendChild(couplednode) ;
887 couplednode.appendChild( aField ) ;
889 // f << Tabs << "<service>" << endl ;
890 QDomElement service = Graph.createElement("service") ;
891 node.appendChild(service) ;
892 QDomElement servicename = Graph.createElement("service-name") ;
893 if ( strlen( ServiceName() ) ) {
894 // f << Tabs << " <service-name>" << ServiceName() << "</service-name>" << endl ;
895 aField = Graph.createTextNode( ServiceName() ) ;
898 // f << Tabs << " <service-name>?</service-name>" << endl ;
899 aField = Graph.createTextNode( "?" ) ;
901 service.appendChild(servicename) ;
902 servicename.appendChild( aField ) ;
904 cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
905 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
906 QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
907 service.appendChild(inParameterlist) ;
909 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
910 for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
911 const GraphBase::InPort * anInPort ;
912 anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
913 if ( !anInPort->IsDataStream() ) {
914 cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
915 << " InParameterPort " << anInPort->Kind() << endl ;
916 QDomElement inParameter = Graph.createElement("inParameter") ;
917 inParameterlist.appendChild(inParameter) ;
918 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
919 if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
920 aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
923 aField = Graph.createTextNode( "?" ) ;
925 inParameter.appendChild(inParametertype) ;
926 inParametertype.appendChild( aField ) ;
927 QDomElement inParametername = Graph.createElement("inParameter-name") ;
928 if ( strlen( ServiceInParameter()[i].Parametername ) ) {
929 aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
932 aField = Graph.createTextNode( "?" ) ;
934 inParameter.appendChild(inParametername) ;
935 inParametername.appendChild( aField ) ;
938 QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
939 service.appendChild(outParameterlist) ;
940 for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
941 const GraphBase::OutPort * anOutPort ;
942 anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
943 if ( !anOutPort->IsDataStream() ) {
944 cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
945 << " OutParameterPort " << anOutPort->Kind() << endl ;
946 QDomElement outParameter = Graph.createElement("outParameter") ;
947 outParameterlist.appendChild(outParameter) ;
948 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
949 if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
950 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
953 aField = Graph.createTextNode( "?" ) ;
955 outParameter.appendChild(outParametertype) ;
956 outParametertype.appendChild( aField ) ;
957 QDomElement outParametername = Graph.createElement("outParameter-name") ;
958 if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
959 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
962 aField = Graph.createTextNode( "?" ) ;
964 outParameter.appendChild(outParametername) ;
965 outParametername.appendChild( aField ) ;
969 QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
970 node.appendChild( DataStreamlist ) ;
971 for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
972 const GraphBase::InPort * anInPort ;
973 anInPort = aNode->GetNodeInPort( i ) ;
974 if ( anInPort->IsDataStream() ) {
975 cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
976 << " InDataStreamPort " << anInPort->Kind() << endl ;
977 QDomElement inParameter = Graph.createElement("inParameter") ;
978 DataStreamlist.appendChild(inParameter) ;
979 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
981 aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
982 cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
983 << " " << aType << endl ;
984 aField = Graph.createTextNode( aType ) ;
985 inParameter.appendChild(inParametertype) ;
986 inParametertype.appendChild( aField ) ;
987 QDomElement inParametername = Graph.createElement("inParameter-name") ;
988 if ( strlen( anInPort->PortName() ) ) {
989 aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
992 aField = Graph.createTextNode( "?" ) ;
994 inParameter.appendChild(inParametername) ;
995 inParametername.appendChild( aField ) ;
996 cdebug << "SaveXML " << anInPort->PortName() << endl ;
997 QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
998 QString aDependency ;
999 aDependency = aDependency.setNum( anInPort->Dependency() ) ;
1000 aField = Graph.createTextNode( aDependency ) ;
1001 inParameter.appendChild(inParameterdependency) ;
1002 inParameterdependency.appendChild( aField ) ;
1003 cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
1004 SUPERV::KindOfSchema aKindOfSchema ;
1005 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1006 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1007 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1008 QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
1010 aSchema = aSchema.setNum( aKindOfSchema ) ;
1011 aField = Graph.createTextNode( aSchema ) ;
1012 inParameter.appendChild(inParameterKindOfSchema) ;
1013 inParameterKindOfSchema.appendChild( aField ) ;
1014 cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
1015 QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
1016 QString anInterpolation ;
1017 anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
1018 aField = Graph.createTextNode( anInterpolation ) ;
1019 inParameter.appendChild(inParameterKindOfInterpolation) ;
1020 inParameterKindOfInterpolation.appendChild( aField ) ;
1021 cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
1022 QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
1023 QString anExtrapolation ;
1024 anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
1025 aField = Graph.createTextNode( anExtrapolation ) ;
1026 inParameter.appendChild(inParameterKindOfExtrapolation) ;
1027 inParameterKindOfExtrapolation.appendChild( aField ) ;
1028 cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
1031 for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
1032 const GraphBase::OutPort * anOutPort ;
1033 anOutPort = aNode->GetNodeOutPort( i ) ;
1034 if ( anOutPort->IsDataStream() ) {
1035 cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1036 << " OutDataStreamPort " << anOutPort->Kind() << endl ;
1037 QDomElement outParameter = Graph.createElement("outParameter") ;
1038 DataStreamlist.appendChild(outParameter) ;
1039 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1041 aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
1042 cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
1043 << " " << aType << endl ;
1044 aField = Graph.createTextNode( aType ) ;
1045 outParameter.appendChild(outParametertype) ;
1046 outParametertype.appendChild( aField ) ;
1047 QDomElement outParametername = Graph.createElement("outParameter-name") ;
1048 if ( strlen( anOutPort->PortName() ) ) {
1049 aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
1052 aField = Graph.createTextNode( "?" ) ;
1054 outParameter.appendChild(outParametername) ;
1055 outParametername.appendChild( aField ) ;
1056 cdebug << "SaveXML " << anOutPort->PortName() << endl ;
1057 QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
1058 QString aDependency ;
1059 aDependency = aDependency.setNum( anOutPort->Dependency() ) ;
1060 aField = Graph.createTextNode( aDependency ) ;
1061 outParameter.appendChild(outParameterdependency) ;
1062 outParameterdependency.appendChild( aField ) ;
1063 cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1064 long aNumberOfValues ;
1065 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1066 QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1068 aValues = aValues.setNum( aNumberOfValues ) ;
1069 aField = Graph.createTextNode( aValues ) ;
1070 outParameter.appendChild(outParameterNumberOfValues) ;
1071 outParameterNumberOfValues.appendChild( aField ) ;
1072 cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1075 // f << Tabs << "</Parameter-list>" << endl ;
1077 // f << Tabs << "<PyFunction-list>" << endl ;
1078 QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1079 node.appendChild( PyFunctionlist ) ;
1080 for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1081 // f << Tabs << " <PyFunction>" << endl ;
1082 QDomElement PyFunction = Graph.createElement("PyFunction") ;
1083 PyFunctionlist.appendChild( PyFunction ) ;
1085 QDomElement FuncName = Graph.createElement("FuncName") ;
1086 if ( strlen( FuncNames[i].c_str() ) ) {
1087 aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1090 aField = Graph.createTextNode( "?" ) ;
1092 PyFunction.appendChild( FuncName ) ;
1093 FuncName.appendChild( aField ) ;
1094 if ( (*PythonFunctions[i]).length() ) {
1095 for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1096 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1097 QDomCDATASection aCDATA ;
1098 // mpv: Linux 8.0 compiler compatibility
1099 char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1101 for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1102 if ( aCDATAChar[ i ] != ' ' ) {
1106 if ( i == (int ) strlen( aCDATAChar ) ) {
1107 aCDATA = Graph.createCDATASection( "?" ) ;
1110 aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1112 PyFunction.appendChild( PyFunc ) ;
1113 PyFunc.appendChild( aCDATA ) ;
1117 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1118 QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1119 PyFunction.appendChild( PyFunc ) ;
1120 PyFunc.appendChild( aCDATA ) ;
1124 // f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1126 QDomElement creationdate = Graph.createElement("creation-date") ;
1128 sprintf( fdate , "%d/%d/%d - %d:%d:%d" , FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1129 aField = Graph.createTextNode( fdate ) ;
1130 node.appendChild( creationdate ) ;
1131 creationdate.appendChild( aField ) ;
1132 // f << Tabs << "<lastmodification-date>" << LastModification()
1133 // << "</lastmodification-date>" << endl ;
1134 QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1136 sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1137 aField = Graph.createTextNode( ldate ) ;
1138 node.appendChild( lastmodificationdate ) ;
1139 lastmodificationdate.appendChild( aField ) ;
1140 // f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1142 QDomElement editorrelease = Graph.createElement("editor-release") ;
1143 aField = Graph.createTextNode( EditorRelease() ) ;
1144 node.appendChild( editorrelease ) ;
1145 editorrelease.appendChild( aField ) ;
1146 QDomElement author = Graph.createElement("author") ;
1147 if ( strlen( Author() ) ) {
1148 // f << Tabs << "<author>" << Author() << "</author>" << endl ;
1149 aField = Graph.createTextNode( Author() ) ;
1152 // f << Tabs << "<author>?</author>" << endl ;
1153 aField = Graph.createTextNode( "?" ) ;
1155 node.appendChild( author ) ;
1156 author.appendChild( aField ) ;
1157 QDomElement container = Graph.createElement("container") ;
1158 if ( IsFactoryNode() && strlen( Computer) ) {
1159 // f << Tabs << "<container>" << Computer << "</container>" << endl ;
1160 aField = Graph.createTextNode( Computer ) ;
1163 // f << Tabs << "<container>?</container>" << endl ;
1164 aField = Graph.createTextNode( "?" ) ;
1166 node.appendChild( container ) ;
1167 container.appendChild( aField ) ;
1168 QDomElement comment = Graph.createElement("comment") ;
1169 if ( strlen( Comment() ) ) {
1170 // f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1171 aField = Graph.createTextNode( Comment() ) ;
1174 // f << Tabs << "<comment>?</comment>" << endl ;
1175 aField = Graph.createTextNode( "?" ) ;
1177 node.appendChild( comment ) ;
1178 comment.appendChild( aField ) ;
1179 // f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1180 QDomElement xposition = Graph.createElement("x-position") ;
1181 QString aXCoordinate ;
1182 aXCoordinate = aKind.setNum( XCoordinate ) ;
1183 aField = Graph.createTextNode( aXCoordinate ) ;
1184 node.appendChild( xposition ) ;
1185 xposition.appendChild( aField ) ;
1186 // f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1187 QDomElement yposition = Graph.createElement("y-position") ;
1188 QString aYCoordinate ;
1189 aYCoordinate = aKind.setNum( YCoordinate ) ;
1190 aField = Graph.createTextNode( aYCoordinate ) ;
1191 node.appendChild( yposition ) ;
1192 yposition.appendChild( aField ) ;
1193 cdebug_out << "SaveXML Node " << Name() << endl ;
1197 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1198 const char * ComponentName ,
1199 const char * InterfaceName ,
1200 const char * Computer ,
1201 const GraphBase::InLineNode * aCoupledNode ,
1202 const ListOfFuncName FuncNames ,
1203 const ListOfPythonFunctions PythonFunctions ,
1204 int XCoordinate , int YCoordinate ) const {
1205 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1206 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1207 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1208 f << " " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1209 if ( GraphMacroLevel() ) {
1210 f << " " << Name() << ".SetCoupled( '"
1211 << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1214 else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1215 f << " " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1217 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1219 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1220 f << " " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1221 << " , " << DeltaTime << " )" << endl ;
1223 else if ( IsComputingNode() ) {
1225 f << " " << Name() << "_ServiceinParameter = []" << endl ;
1226 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1227 f << " " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1228 << ServiceInParameter()[i].Parametertype << "' , '"
1229 << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1231 f << " " << Name() << "_ServiceoutParameter = []" << endl ;
1232 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1233 f << " " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1234 << ServiceOutParameter()[i].Parametertype << "' , '"
1235 << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1237 f << " " << Name() << "_ServiceinStreamParameter = []" << endl ;
1238 for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1239 f << " " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1240 << ServiceInStreamParameter()[i].Parametertype << " , '"
1241 << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1242 << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1244 f << " " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1245 for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1246 f << " " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1247 << ServiceOutStreamParameter()[i].Parametertype << " , '"
1248 << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1249 << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1251 f << " " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1252 << "' , " << Name() << "_ServiceinParameter"
1253 << " , " << Name() << "_ServiceoutParameter"
1254 << " , " << Name() << "_ServiceinStreamParameter"
1255 << " , " << Name() << "_ServiceoutStreamParameter"
1256 << " , 0 , 0 )" << endl ;
1257 f << " " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1260 else if ( IsFactoryNode() ) {
1261 f << " " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1262 << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1265 else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1266 // It is done with LoopNode or SwitchNode with CoupledNode()
1269 if ( !IsMacroNode() ) {
1270 f << " " << "Py" << Name() << " = []" << endl ;
1273 SUPERV::ListOfStrings aPyFunc ;
1274 if ( PythonFunctions.size() ) {
1275 aPyFunc = *PythonFunctions[0] ;
1276 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1277 f << " " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1280 if ( IsInLineNode() ) {
1281 f << " " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1282 << Name() << " )" << endl ;
1284 else if ( IsGOTONode() ) {
1285 if ( aCoupledNode ) {
1286 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1287 << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1290 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1291 << Name() << " , '' )" << endl ;
1294 else if ( IsMacroNode() ) {
1295 if ( aCoupledNode ) {
1296 f << " " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1297 f << " " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1300 f << " " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1302 f << " " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1305 // char * EndName = NULL ;
1306 // EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1307 // strcpy( EndName , "End" ) ;
1308 // strcat( EndName , Name() ) ;
1309 char * EndName = aCoupledNode->Name() ;
1310 if ( IsLoopNode() ) {
1312 SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1313 SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1314 f << " " << "PyMore" << Name() << " = []" << endl ;
1315 for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1316 f << " " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1318 f << " " << "PyNext" << Name() << " = []" << endl ;
1319 for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1320 f << " " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1322 f << " " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1323 << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1324 << FuncNames[1].c_str() << "' , PyMore" << Name()
1325 << " , '" << FuncNames[2].c_str() << "' , PyNext"
1326 << Name() << " )" << endl ;
1327 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1328 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1329 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1330 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1331 << aCoupledNode->YCoordinate() << " )" << endl ;
1332 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1333 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1334 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1335 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1338 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1339 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1340 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1341 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1342 << " " << anInPort->Kind() << endl ;
1343 if ( anInPort->IsLoop() ) {
1344 f << " " << "I" << Name() << anInPort->PortName() << " = "
1345 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1347 else if ( anInPort->IsInLine() ) {
1348 f << " " << "I" << Name() << anInPort->PortName() << " = "
1349 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1350 << anInPort->PortType() << "' )" << endl ;
1352 else if ( anInPort->IsDataStream() ) {
1353 f << " " << "I" << Name() << anInPort->PortName() << " = " << Name()
1354 << ".InStreamPort( '" << anInPort->PortName()
1355 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1356 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1357 SUPERV::KindOfSchema aKindOfSchema ;
1358 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1359 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1360 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1361 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1362 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1364 else if ( anInPort->IsGate() ) {
1365 f << " " << "I" << Name() << anInPort->PortName() << " = "
1366 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1369 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1370 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1371 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1372 << " " << anOutPort->Kind() << endl ;
1373 if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1374 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1375 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1377 else if ( anOutPort->IsDataStream() ) {
1378 f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1379 << ".OutStreamPort( '" << anOutPort->PortName()
1380 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1381 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1382 long aNumberOfValues ;
1383 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1384 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1388 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1389 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1390 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1391 << " " << anInPort->Kind() << endl ;
1392 if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1393 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1394 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1396 else if ( anInPort->IsDataStream() ) {
1397 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1398 << ".InStreamPort( '" << anInPort->PortName()
1399 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1400 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1401 SUPERV::KindOfSchema aKindOfSchema ;
1402 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1403 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1404 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1405 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1406 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1409 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1410 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1411 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1412 << " " << anOutPort->Kind() << endl ;
1413 if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1414 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1415 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1417 else if ( anOutPort->IsDataStream() ) {
1418 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1419 << ".OutStreamPort( '" << anOutPort->PortName()
1420 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1421 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1422 long aNumberOfValues ;
1423 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1424 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1429 else if ( IsSwitchNode() ) {
1430 f << " " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1431 << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1432 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1433 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1434 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1435 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1436 << aCoupledNode->YCoordinate() << " )" << endl ;
1437 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1438 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1439 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1440 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1443 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1444 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1445 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1446 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1447 << " " << anInPort->Kind() << endl ;
1448 // if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1449 if ( anInPort->IsGate() ) {
1450 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1451 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1453 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1454 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1455 << ".InPort( '" << anInPort->PortName()
1456 << "' , '" << anInPort->PortType() << "' )" << endl ;
1458 else if ( anInPort->IsDataStream() ) {
1459 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1460 << ".InStreamPort( '" << anInPort->PortName()
1461 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1462 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1463 SUPERV::KindOfSchema aKindOfSchema ;
1464 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1465 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1466 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1467 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1468 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1471 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1472 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1473 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1474 << " " << anOutPort->Kind() << endl ;
1475 // if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1476 if ( anOutPort->IsGate() ) {
1477 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1478 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1480 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1481 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1482 << ".OutPort( '" << anOutPort->PortName()
1483 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1485 else if ( anOutPort->IsDataStream() ) {
1486 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1487 << ".OutStreamPort( '" << anOutPort->PortName()
1488 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1489 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1490 long aNumberOfValues ;
1491 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1492 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1501 if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1502 // It is done with LoopNode or SwitchNode with CoupledNode()
1505 f << " " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1506 f << " " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1507 if ( IsFactoryNode() ) {
1508 f << " " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1510 f << " " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1511 f << " " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1513 if ( IsComputingNode() || IsFactoryNode() ) {
1515 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1516 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1517 if ( !anInPort->IsDataStream() ) {
1518 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1519 << " " << anInPort->Kind() << endl ;
1520 f << " " << "I" << Name() << anInPort->PortName() << " = "
1521 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1524 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1525 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1526 if ( !anOutPort->IsDataStream() ) {
1527 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1528 << " " << anOutPort->Kind() << endl ;
1529 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1530 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1534 else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1536 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1537 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1538 cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1539 << " " << anInPort->Kind() << endl ;
1540 // if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1541 if ( anInPort->IsGate() || IsMacroNode() ) {
1542 f << " " << "I" << Name() << anInPort->PortName() << " = "
1543 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1545 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1546 f << " " << "I" << Name() << anInPort->PortName() << " = "
1547 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1548 << anInPort->PortType() << "' )" << endl ;
1551 cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1552 // f << " " << "I" << Name() << anInPort->PortName() << " = "
1553 // << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1556 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1557 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1558 cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1559 << " " << anOutPort->Kind() << endl ;
1560 // if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1561 if ( anOutPort->IsGate() || IsMacroNode() ) {
1562 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1563 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1565 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1566 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1567 << Name() << ".OutPort( '" << anOutPort->PortName()
1568 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1571 cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1572 // f << " " << "O" << Name() << anOutPort->PortName() << " = "
1573 // << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1577 if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1579 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1580 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1581 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1582 << " " << anInPort->Kind() << endl ;
1583 if ( anInPort->IsDataStream() ) {
1584 if ( IsOneOfInLineNodes() ) {
1585 f << " " << "I" << Name() << anInPort->PortName() << " = "
1586 << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1587 << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1588 << anInPort->Dependency() << " )" << endl ;
1591 f << " " << "I" << Name() << anInPort->PortName() << " = "
1592 << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1594 SUPERV::KindOfSchema aKindOfSchema ;
1595 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1596 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1597 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1598 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1599 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1602 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1603 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1604 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1605 << " " << anOutPort->Kind() << endl ;
1606 if ( anOutPort->IsDataStream() ) {
1607 if ( IsOneOfInLineNodes() ) {
1608 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1609 << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1610 << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1611 << anOutPort->Dependency() << " )" << endl ;
1614 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1615 << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1617 long aNumberOfValues ;
1618 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1619 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1628 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1630 ListPorts( s , true ) ;
1634 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1635 // f << "ComponentName " << G.ComponentName() << endl ;
1636 if ( G.IsComputingNode() ) {
1637 f << "NodeName " << G.Name() << endl ;
1640 f << "DataFlowName " << G.Name() << endl ;
1642 f << "Kind " << G.Kind() << endl ;
1643 f << "Service " << *G.GetService() ;
1644 f << "FirstCreation " << G.FirstCreation () << endl ;
1645 f << "LastModification " << G.LastModification() << endl ;
1646 f << "EditorRelease " << G.EditorRelease() << endl ;
1647 f << "Author " << G.Author() << endl ;
1648 // f << "Computer " << G.Computer() << endl ;
1649 f << "Comment " << G.Comment() << endl ;
1655 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1657 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1658 const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1659 if ( fromPort->IsPortConnected() ) {
1661 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1663 f << "FromNode " << Name() << endl ;
1665 f << " FromServiceParameterName "
1666 << fromPort->GetServicesParameter().Parametername ;
1667 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1668 f << " ToNode " << toPort->NodeName() ;
1669 f << " ToServiceParameterName "
1670 << toPort->GetServicesParameter().Parametername;
1672 fromPort->StringValue( f ) ;
1679 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1680 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1682 fOut << D.Day << "/"
1689 // cdebug_out << "operator<< GraphEditor::Date" << endl;