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 #include <sys/time.h>
682 #include <sys/resource.h>
685 const long GraphBase::ComputingNode::CpuUsed() {
686 struct rusage usage ;
687 if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
688 perror("GraphBase::CpuUsed") ;
691 // return usage.ru_utime.__time_t tv_sec ;
692 cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
693 << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
694 return usage.ru_utime.tv_sec ;
698 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
699 GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
700 if ( IsInLineNode() || IsGOTONode() ) {
702 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
703 const InPort * anInPort = GetNodeInPort( i ) ;
704 if ( anInPort->IsBus() ) {
705 int size = aListOfParameters->size() ;
706 aListOfParameters->resize( size + 1 ) ;
707 (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
708 (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
709 const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
710 (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
711 (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
715 return aListOfParameters ;
719 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
720 const char * ComponentName ,
721 const char * InterfaceName ,
722 const char * Computer ,
723 const char * CoupledNode ,
724 const ListOfFuncName FuncNames ,
725 const ListOfPythonFunctions PythonFunctions ,
726 int XCoordinate , int YCoordinate ) const {
727 cdebug_in << "SaveXML Node " << Name() << endl ;
728 QDomElement node = Graph.createElement( "node" ) ;
729 info.appendChild( node ) ;
730 QDomElement componentname = Graph.createElement( "component-name" ) ;
732 if ( strlen( ComponentName ) ) {
733 // f << Tabs << "<component-name>" << ComponentName << "</component-name>"
735 // componentname.setNodeValue( ComponentName ) ;
736 aField = Graph.createTextNode( ComponentName ) ;
739 // f << Tabs << "<component-name>?</component-name>" << endl ;
740 // componentname.setNodeValue( "?" ) ;
741 aField = Graph.createTextNode( "?" ) ;
743 node.appendChild( componentname ) ;
744 componentname.appendChild( aField ) ;
746 QDomElement interfacename = Graph.createElement("interface-name") ;
747 if ( strlen( InterfaceName ) ) {
748 // f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
750 // interfacename.setAttribute("name" , InterfaceName ) ;
751 aField = Graph.createTextNode( InterfaceName ) ;
754 // f << Tabs << "<interface-name>?</interface-name>" << endl ;
755 // interfacename.setAttribute("name" , "?" ) ;
756 aField = Graph.createTextNode( "?" ) ;
758 node.appendChild(interfacename) ;
759 interfacename.appendChild( aField ) ;
761 // f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
762 QDomElement nodename = Graph.createElement("node-name") ;
763 aField = Graph.createTextNode( Name() ) ;
764 node.appendChild( nodename ) ;
765 nodename.appendChild( aField ) ;
767 // f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
768 QDomElement kind = Graph.createElement( "kind" ) ;
771 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
772 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
773 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
774 aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
777 aKind = aKind.setNum( Kind() ) ;
779 aField = Graph.createTextNode( aKind ) ;
780 node.appendChild( kind ) ;
781 kind.appendChild( aField ) ;
783 if ( IsDataStreamNode() && HasDataStream() != 0 ) {
785 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
787 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
789 QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
791 aTimeout = aTimeout.setNum( Timeout ) ;
792 aField = Graph.createTextNode( aTimeout ) ;
793 node.appendChild( timeout ) ;
794 timeout.appendChild( aField ) ;
796 QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
797 QString aDataStreamTrace ;
798 aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
799 aField = Graph.createTextNode( aDataStreamTrace ) ;
800 node.appendChild( datastreamtrace ) ;
801 datastreamtrace.appendChild( aField ) ;
803 QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
805 aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
806 aField = Graph.createTextNode( aDeltaTime ) ;
807 node.appendChild( deltatime ) ;
808 deltatime.appendChild( aField ) ;
811 QDomElement couplednode = Graph.createElement("coupled-node") ;
812 if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
813 IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
814 // f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
816 aField = Graph.createTextNode( CoupledNode ) ;
819 // f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
820 aField = Graph.createTextNode( "?" ) ;
822 node.appendChild(couplednode) ;
823 couplednode.appendChild( aField ) ;
825 // f << Tabs << "<service>" << endl ;
826 QDomElement service = Graph.createElement("service") ;
827 node.appendChild(service) ;
828 QDomElement servicename = Graph.createElement("service-name") ;
829 if ( strlen( ServiceName() ) ) {
830 // f << Tabs << " <service-name>" << ServiceName() << "</service-name>" << endl ;
831 aField = Graph.createTextNode( ServiceName() ) ;
834 // f << Tabs << " <service-name>?</service-name>" << endl ;
835 aField = Graph.createTextNode( "?" ) ;
837 service.appendChild(servicename) ;
838 servicename.appendChild( aField ) ;
840 cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
841 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
842 QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
843 service.appendChild(inParameterlist) ;
845 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
846 for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
847 const GraphBase::InPort * anInPort ;
848 anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
849 if ( !anInPort->IsDataStream() ) {
850 cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
851 << " InParameterPort " << anInPort->Kind() << endl ;
852 QDomElement inParameter = Graph.createElement("inParameter") ;
853 inParameterlist.appendChild(inParameter) ;
854 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
855 if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
856 aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
859 aField = Graph.createTextNode( "?" ) ;
861 inParameter.appendChild(inParametertype) ;
862 inParametertype.appendChild( aField ) ;
863 QDomElement inParametername = Graph.createElement("inParameter-name") ;
864 if ( strlen( ServiceInParameter()[i].Parametername ) ) {
865 aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
868 aField = Graph.createTextNode( "?" ) ;
870 inParameter.appendChild(inParametername) ;
871 inParametername.appendChild( aField ) ;
874 QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
875 service.appendChild(outParameterlist) ;
876 for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
877 const GraphBase::OutPort * anOutPort ;
878 anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
879 if ( !anOutPort->IsDataStream() ) {
880 cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
881 << " OutParameterPort " << anOutPort->Kind() << endl ;
882 QDomElement outParameter = Graph.createElement("outParameter") ;
883 outParameterlist.appendChild(outParameter) ;
884 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
885 if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
886 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
889 aField = Graph.createTextNode( "?" ) ;
891 outParameter.appendChild(outParametertype) ;
892 outParametertype.appendChild( aField ) ;
893 QDomElement outParametername = Graph.createElement("outParameter-name") ;
894 if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
895 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
898 aField = Graph.createTextNode( "?" ) ;
900 outParameter.appendChild(outParametername) ;
901 outParametername.appendChild( aField ) ;
905 QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
906 node.appendChild( DataStreamlist ) ;
907 for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
908 const GraphBase::InPort * anInPort ;
909 anInPort = aNode->GetNodeInPort( i ) ;
910 if ( anInPort->IsDataStream() ) {
911 cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
912 << " InDataStreamPort " << anInPort->Kind() << endl ;
913 QDomElement inParameter = Graph.createElement("inParameter") ;
914 DataStreamlist.appendChild(inParameter) ;
915 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
917 aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
918 cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
919 << " " << aType << endl ;
920 aField = Graph.createTextNode( aType ) ;
921 inParameter.appendChild(inParametertype) ;
922 inParametertype.appendChild( aField ) ;
923 QDomElement inParametername = Graph.createElement("inParameter-name") ;
924 if ( strlen( anInPort->PortName() ) ) {
925 aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
928 aField = Graph.createTextNode( "?" ) ;
930 inParameter.appendChild(inParametername) ;
931 inParametername.appendChild( aField ) ;
932 cdebug << "SaveXML " << anInPort->PortName() << endl ;
933 QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
934 QString aDependency ;
935 aDependency = aDependency.setNum( anInPort->Dependency() ) ;
936 aField = Graph.createTextNode( aDependency ) ;
937 inParameter.appendChild(inParameterdependency) ;
938 inParameterdependency.appendChild( aField ) ;
939 cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
940 SUPERV::KindOfSchema aKindOfSchema ;
941 SUPERV::KindOfInterpolation aKindOfInterpolation ;
942 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
943 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
944 QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
946 aSchema = aSchema.setNum( aKindOfSchema ) ;
947 aField = Graph.createTextNode( aSchema ) ;
948 inParameter.appendChild(inParameterKindOfSchema) ;
949 inParameterKindOfSchema.appendChild( aField ) ;
950 cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
951 QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
952 QString anInterpolation ;
953 anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
954 aField = Graph.createTextNode( anInterpolation ) ;
955 inParameter.appendChild(inParameterKindOfInterpolation) ;
956 inParameterKindOfInterpolation.appendChild( aField ) ;
957 cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
958 QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
959 QString anExtrapolation ;
960 anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
961 aField = Graph.createTextNode( anExtrapolation ) ;
962 inParameter.appendChild(inParameterKindOfExtrapolation) ;
963 inParameterKindOfExtrapolation.appendChild( aField ) ;
964 cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
967 for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
968 const GraphBase::OutPort * anOutPort ;
969 anOutPort = aNode->GetNodeOutPort( i ) ;
970 if ( anOutPort->IsDataStream() ) {
971 cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
972 << " OutDataStreamPort " << anOutPort->Kind() << endl ;
973 QDomElement outParameter = Graph.createElement("outParameter") ;
974 DataStreamlist.appendChild(outParameter) ;
975 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
977 aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
978 cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
979 << " " << aType << endl ;
980 aField = Graph.createTextNode( aType ) ;
981 outParameter.appendChild(outParametertype) ;
982 outParametertype.appendChild( aField ) ;
983 QDomElement outParametername = Graph.createElement("outParameter-name") ;
984 if ( strlen( anOutPort->PortName() ) ) {
985 aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
988 aField = Graph.createTextNode( "?" ) ;
990 outParameter.appendChild(outParametername) ;
991 outParametername.appendChild( aField ) ;
992 cdebug << "SaveXML " << anOutPort->PortName() << endl ;
993 QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
994 QString aDependency ;
995 aDependency = aDependency.setNum( anOutPort->Dependency() ) ;
996 aField = Graph.createTextNode( aDependency ) ;
997 outParameter.appendChild(outParameterdependency) ;
998 outParameterdependency.appendChild( aField ) ;
999 cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1000 long aNumberOfValues ;
1001 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1002 QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1004 aValues = aValues.setNum( aNumberOfValues ) ;
1005 aField = Graph.createTextNode( aValues ) ;
1006 outParameter.appendChild(outParameterNumberOfValues) ;
1007 outParameterNumberOfValues.appendChild( aField ) ;
1008 cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1011 // f << Tabs << "</Parameter-list>" << endl ;
1013 // f << Tabs << "<PyFunction-list>" << endl ;
1014 QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1015 node.appendChild( PyFunctionlist ) ;
1016 for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1017 // f << Tabs << " <PyFunction>" << endl ;
1018 QDomElement PyFunction = Graph.createElement("PyFunction") ;
1019 PyFunctionlist.appendChild( PyFunction ) ;
1021 QDomElement FuncName = Graph.createElement("FuncName") ;
1022 if ( strlen( FuncNames[i].c_str() ) ) {
1023 aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1026 aField = Graph.createTextNode( "?" ) ;
1028 PyFunction.appendChild( FuncName ) ;
1029 FuncName.appendChild( aField ) ;
1030 if ( (*PythonFunctions[i]).length() ) {
1031 for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1032 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1033 QDomCDATASection aCDATA ;
1034 // mpv: Linux 8.0 compiler compatibility
1035 char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1037 for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1038 if ( aCDATAChar[ i ] != ' ' ) {
1042 if ( i == (int ) strlen( aCDATAChar ) ) {
1043 aCDATA = Graph.createCDATASection( "?" ) ;
1046 aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1048 PyFunction.appendChild( PyFunc ) ;
1049 PyFunc.appendChild( aCDATA ) ;
1053 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1054 QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1055 PyFunction.appendChild( PyFunc ) ;
1056 PyFunc.appendChild( aCDATA ) ;
1060 // f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1062 QDomElement creationdate = Graph.createElement("creation-date") ;
1064 sprintf( fdate , "%d/%d/%d - %d:%d:%d" , FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1065 aField = Graph.createTextNode( fdate ) ;
1066 node.appendChild( creationdate ) ;
1067 creationdate.appendChild( aField ) ;
1068 // f << Tabs << "<lastmodification-date>" << LastModification()
1069 // << "</lastmodification-date>" << endl ;
1070 QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1072 sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1073 aField = Graph.createTextNode( ldate ) ;
1074 node.appendChild( lastmodificationdate ) ;
1075 lastmodificationdate.appendChild( aField ) ;
1076 // f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1078 QDomElement editorrelease = Graph.createElement("editor-release") ;
1079 aField = Graph.createTextNode( EditorRelease() ) ;
1080 node.appendChild( editorrelease ) ;
1081 editorrelease.appendChild( aField ) ;
1082 QDomElement author = Graph.createElement("author") ;
1083 if ( strlen( Author() ) ) {
1084 // f << Tabs << "<author>" << Author() << "</author>" << endl ;
1085 aField = Graph.createTextNode( Author() ) ;
1088 // f << Tabs << "<author>?</author>" << endl ;
1089 aField = Graph.createTextNode( "?" ) ;
1091 node.appendChild( author ) ;
1092 author.appendChild( aField ) ;
1093 QDomElement container = Graph.createElement("container") ;
1094 if ( IsFactoryNode() && strlen( Computer) ) {
1095 // f << Tabs << "<container>" << Computer << "</container>" << endl ;
1096 aField = Graph.createTextNode( Computer ) ;
1099 // f << Tabs << "<container>?</container>" << endl ;
1100 aField = Graph.createTextNode( "?" ) ;
1102 node.appendChild( container ) ;
1103 container.appendChild( aField ) ;
1104 QDomElement comment = Graph.createElement("comment") ;
1105 if ( strlen( Comment() ) ) {
1106 // f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1107 aField = Graph.createTextNode( Comment() ) ;
1110 // f << Tabs << "<comment>?</comment>" << endl ;
1111 aField = Graph.createTextNode( "?" ) ;
1113 node.appendChild( comment ) ;
1114 comment.appendChild( aField ) ;
1115 // f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1116 QDomElement xposition = Graph.createElement("x-position") ;
1117 QString aXCoordinate ;
1118 aXCoordinate = aKind.setNum( XCoordinate ) ;
1119 aField = Graph.createTextNode( aXCoordinate ) ;
1120 node.appendChild( xposition ) ;
1121 xposition.appendChild( aField ) ;
1122 // f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1123 QDomElement yposition = Graph.createElement("y-position") ;
1124 QString aYCoordinate ;
1125 aYCoordinate = aKind.setNum( YCoordinate ) ;
1126 aField = Graph.createTextNode( aYCoordinate ) ;
1127 node.appendChild( yposition ) ;
1128 yposition.appendChild( aField ) ;
1129 cdebug_out << "SaveXML Node " << Name() << endl ;
1133 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1134 const char * ComponentName ,
1135 const char * InterfaceName ,
1136 const char * Computer ,
1137 const GraphBase::InLineNode * aCoupledNode ,
1138 const ListOfFuncName FuncNames ,
1139 const ListOfPythonFunctions PythonFunctions ,
1140 int XCoordinate , int YCoordinate ) const {
1141 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1142 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1143 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1144 f << " " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1145 if ( GraphMacroLevel() ) {
1146 f << " " << Name() << ".SetCoupled( '"
1147 << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1150 else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1151 f << " " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1153 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1155 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1156 f << " " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1157 << " , " << DeltaTime << " )" << endl ;
1159 else if ( IsComputingNode() ) {
1161 f << " " << Name() << "_ServiceinParameter = []" << endl ;
1162 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1163 f << " " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1164 << ServiceInParameter()[i].Parametertype << "' , '"
1165 << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1167 f << " " << Name() << "_ServiceoutParameter = []" << endl ;
1168 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1169 f << " " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1170 << ServiceOutParameter()[i].Parametertype << "' , '"
1171 << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1173 f << " " << Name() << "_ServiceinStreamParameter = []" << endl ;
1174 for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1175 f << " " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1176 << ServiceInStreamParameter()[i].Parametertype << " , '"
1177 << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1178 << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1180 f << " " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1181 for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1182 f << " " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1183 << ServiceOutStreamParameter()[i].Parametertype << " , '"
1184 << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1185 << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1187 f << " " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1188 << "' , " << Name() << "_ServiceinParameter"
1189 << " , " << Name() << "_ServiceoutParameter"
1190 << " , " << Name() << "_ServiceinStreamParameter"
1191 << " , " << Name() << "_ServiceoutStreamParameter"
1192 << " , 0 , 0 )" << endl ;
1193 f << " " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1196 else if ( IsFactoryNode() ) {
1197 f << " " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1198 << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1201 else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1202 // It is done with LoopNode or SwitchNode with CoupledNode()
1205 if ( !IsMacroNode() ) {
1206 f << " " << "Py" << Name() << " = []" << endl ;
1209 SUPERV::ListOfStrings aPyFunc ;
1210 if ( PythonFunctions.size() ) {
1211 aPyFunc = *PythonFunctions[0] ;
1212 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1213 f << " " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1216 if ( IsInLineNode() ) {
1217 f << " " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1218 << Name() << " )" << endl ;
1220 else if ( IsGOTONode() ) {
1221 if ( aCoupledNode ) {
1222 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1223 << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1226 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1227 << Name() << " , '' )" << endl ;
1230 else if ( IsMacroNode() ) {
1231 if ( aCoupledNode ) {
1232 f << " " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1233 f << " " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1236 f << " " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1238 f << " " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1241 // char * EndName = NULL ;
1242 // EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1243 // strcpy( EndName , "End" ) ;
1244 // strcat( EndName , Name() ) ;
1245 char * EndName = aCoupledNode->Name() ;
1246 if ( IsLoopNode() ) {
1248 SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1249 SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1250 f << " " << "PyMore" << Name() << " = []" << endl ;
1251 for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1252 f << " " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1254 f << " " << "PyNext" << Name() << " = []" << endl ;
1255 for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1256 f << " " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1258 f << " " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1259 << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1260 << FuncNames[1].c_str() << "' , PyMore" << Name()
1261 << " , '" << FuncNames[2].c_str() << "' , PyNext"
1262 << Name() << " )" << endl ;
1263 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1264 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1265 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1266 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1267 << aCoupledNode->YCoordinate() << " )" << endl ;
1268 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1269 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1270 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1271 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1274 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1275 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1276 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1277 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1278 << " " << anInPort->Kind() << endl ;
1279 if ( anInPort->IsLoop() ) {
1280 f << " " << "I" << Name() << anInPort->PortName() << " = "
1281 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1283 else if ( anInPort->IsInLine() ) {
1284 f << " " << "I" << Name() << anInPort->PortName() << " = "
1285 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1286 << anInPort->PortType() << "' )" << endl ;
1288 else if ( anInPort->IsDataStream() ) {
1289 f << " " << "I" << Name() << anInPort->PortName() << " = " << Name()
1290 << ".InStreamPort( '" << anInPort->PortName()
1291 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1292 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1293 SUPERV::KindOfSchema aKindOfSchema ;
1294 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1295 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1296 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1297 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1298 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1300 else if ( anInPort->IsGate() ) {
1301 f << " " << "I" << Name() << anInPort->PortName() << " = "
1302 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1305 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1306 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1307 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1308 << " " << anOutPort->Kind() << endl ;
1309 if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1310 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1311 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1313 else if ( anOutPort->IsDataStream() ) {
1314 f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1315 << ".OutStreamPort( '" << anOutPort->PortName()
1316 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1317 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1318 long aNumberOfValues ;
1319 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1320 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1324 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1325 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1326 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1327 << " " << anInPort->Kind() << endl ;
1328 if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1329 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1330 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1332 else if ( anInPort->IsDataStream() ) {
1333 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1334 << ".InStreamPort( '" << anInPort->PortName()
1335 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1336 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1337 SUPERV::KindOfSchema aKindOfSchema ;
1338 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1339 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1340 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1341 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1342 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1345 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1346 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1347 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1348 << " " << anOutPort->Kind() << endl ;
1349 if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1350 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1351 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1353 else if ( anOutPort->IsDataStream() ) {
1354 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1355 << ".OutStreamPort( '" << anOutPort->PortName()
1356 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1357 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1358 long aNumberOfValues ;
1359 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1360 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1365 else if ( IsSwitchNode() ) {
1366 f << " " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1367 << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1368 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1369 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1370 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1371 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1372 << aCoupledNode->YCoordinate() << " )" << endl ;
1373 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1374 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1375 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1376 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1379 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1380 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1381 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1382 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1383 << " " << anInPort->Kind() << endl ;
1384 // if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1385 if ( anInPort->IsGate() ) {
1386 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1387 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1389 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1390 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1391 << ".InPort( '" << anInPort->PortName()
1392 << "' , '" << anInPort->PortType() << "' )" << endl ;
1394 else if ( anInPort->IsDataStream() ) {
1395 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1396 << ".InStreamPort( '" << anInPort->PortName()
1397 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1398 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1399 SUPERV::KindOfSchema aKindOfSchema ;
1400 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1401 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1402 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1403 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1404 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1407 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1408 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1409 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1410 << " " << anOutPort->Kind() << endl ;
1411 // if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1412 if ( anOutPort->IsGate() ) {
1413 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1414 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1416 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1417 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1418 << ".OutPort( '" << anOutPort->PortName()
1419 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1421 else if ( anOutPort->IsDataStream() ) {
1422 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1423 << ".OutStreamPort( '" << anOutPort->PortName()
1424 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1425 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1426 long aNumberOfValues ;
1427 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1428 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1437 if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1438 // It is done with LoopNode or SwitchNode with CoupledNode()
1441 f << " " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1442 f << " " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1443 if ( IsFactoryNode() ) {
1444 f << " " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1446 f << " " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1447 f << " " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1449 if ( IsComputingNode() || IsFactoryNode() ) {
1451 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1452 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1453 if ( !anInPort->IsDataStream() ) {
1454 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1455 << " " << anInPort->Kind() << endl ;
1456 f << " " << "I" << Name() << anInPort->PortName() << " = "
1457 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1460 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1461 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1462 if ( !anOutPort->IsDataStream() ) {
1463 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1464 << " " << anOutPort->Kind() << endl ;
1465 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1466 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1470 else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1472 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1473 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1474 cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1475 << " " << anInPort->Kind() << endl ;
1476 // if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1477 if ( anInPort->IsGate() || IsMacroNode() ) {
1478 f << " " << "I" << Name() << anInPort->PortName() << " = "
1479 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1481 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1482 f << " " << "I" << Name() << anInPort->PortName() << " = "
1483 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1484 << anInPort->PortType() << "' )" << endl ;
1487 cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1488 // f << " " << "I" << Name() << anInPort->PortName() << " = "
1489 // << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1492 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1493 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1494 cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1495 << " " << anOutPort->Kind() << endl ;
1496 // if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1497 if ( anOutPort->IsGate() || IsMacroNode() ) {
1498 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1499 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1501 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1502 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1503 << Name() << ".OutPort( '" << anOutPort->PortName()
1504 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1507 cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1508 // f << " " << "O" << Name() << anOutPort->PortName() << " = "
1509 // << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1513 if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1515 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1516 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1517 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1518 << " " << anInPort->Kind() << endl ;
1519 if ( anInPort->IsDataStream() ) {
1520 if ( IsOneOfInLineNodes() ) {
1521 f << " " << "I" << Name() << anInPort->PortName() << " = "
1522 << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1523 << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1524 << anInPort->Dependency() << " )" << endl ;
1527 f << " " << "I" << Name() << anInPort->PortName() << " = "
1528 << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1530 SUPERV::KindOfSchema aKindOfSchema ;
1531 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1532 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1533 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1534 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1535 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1538 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1539 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1540 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1541 << " " << anOutPort->Kind() << endl ;
1542 if ( anOutPort->IsDataStream() ) {
1543 if ( IsOneOfInLineNodes() ) {
1544 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1545 << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1546 << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1547 << anOutPort->Dependency() << " )" << endl ;
1550 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1551 << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1553 long aNumberOfValues ;
1554 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1555 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1564 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1566 ListPorts( s , true ) ;
1570 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1571 // f << "ComponentName " << G.ComponentName() << endl ;
1572 if ( G.IsComputingNode() ) {
1573 f << "NodeName " << G.Name() << endl ;
1576 f << "DataFlowName " << G.Name() << endl ;
1578 f << "Kind " << G.Kind() << endl ;
1579 f << "Service " << *G.GetService() ;
1580 f << "FirstCreation " << G.FirstCreation () << endl ;
1581 f << "LastModification " << G.LastModification() << endl ;
1582 f << "EditorRelease " << G.EditorRelease() << endl ;
1583 f << "Author " << G.Author() << endl ;
1584 // f << "Computer " << G.Computer() << endl ;
1585 f << "Comment " << G.Comment() << endl ;
1591 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1593 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1594 const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1595 if ( fromPort->IsPortConnected() ) {
1597 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1599 f << "FromNode " << Name() << endl ;
1601 f << " FromServiceParameterName "
1602 << fromPort->GetServicesParameter().Parametername ;
1603 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1604 f << " ToNode " << toPort->NodeName() ;
1605 f << " ToServiceParameterName "
1606 << toPort->GetServicesParameter().Parametername;
1608 fromPort->StringValue( f ) ;
1615 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1616 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1618 fOut << D.Day << "/"
1625 // cdebug_out << "operator<< GraphEditor::Date" << endl;