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 // JR 12.01.2005 : InitLoop and DoLoop are reserved parameter names in LoopNodes :
612 if ( IsLoopNode() && ( strcmp( InputParameterName , "InitLoop" ) == 0 ||
613 strcmp( InputParameterName , "DoLoop" ) == 0 ) ) {
616 return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
622 _Graph_prof_debug , _Graph_fdebug ) ;
624 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
625 const char * OutputParameterType ,
626 const SUPERV::KindOfPort aKindOfPort ,
628 cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
629 return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
631 OutputParameterName ,
632 OutputParameterType ,
635 _Graph_prof_debug , _Graph_fdebug ) ;
638 void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) {
639 GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
641 void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) {
642 GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
645 GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName ,
646 const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
647 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
648 const SUPERV::KindOfPort aKindOfPort ,
650 // IncrDataStreamInPorts() ;
651 GraphBase::InDataStreamPort * aDataStreamPort ;
652 aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
655 DataStreamTypeToString( InputParameterType ).c_str() ,
660 aDataStreamPort->Dependency( aDependency ) ;
661 if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) {
662 aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ;
664 return aDataStreamPort ;
666 GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName ,
667 const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
668 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
669 const SUPERV::KindOfPort aKindOfPort ,
671 // IncrDataStreamOutPorts() ;
672 GraphBase::OutDataStreamPort * aDataStreamPort ;
673 aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
675 OutputParameterName ,
676 DataStreamTypeToString( OutputParameterType ).c_str() ,
681 aDataStreamPort->Dependency( aDependency ) ;
682 return aDataStreamPort ;
686 bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode ,
687 GraphBase::EndOfLoopNode * anEndLoopNode ) const {
688 cdebug_in << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
689 << anEndLoopNode->Name() << ") LinkedNodesSize "
690 << LinkedNodesSize() << endl;
693 if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) {
694 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
695 << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
696 << LinkedNodesSize() << " false" << endl;
699 // We check that all nodes linked to that node go to the end of LoopNode :
700 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
701 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
702 cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ;
703 if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) {
704 if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) {
705 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name()
706 << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
707 << LinkedNodesSize() << " false" << endl;
712 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
713 << anEndLoopNode->Name() << ") LinkedNodesSize "
714 << LinkedNodesSize() << " true" << endl;
718 bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode ,
719 GraphBase::EndOfLoopNode * anEndLoopNode ) const {
720 cdebug_in << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
721 << anEndLoopNode->Name() << ") LinkedFromNodesSize "
722 << LinkedFromNodesSize() << endl;
725 if ( LinkedFromNodesSize() == 0 ) {
726 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
727 << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
728 << LinkedFromNodesSize() << " false" << endl;
731 // We have to check that all nodes linked from that node go to the beginning of LoopNode :
732 for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) {
733 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ;
734 cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ;
735 if ( !aNode->IsLoopNode() || aNode != aLoopNode ) {
736 if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) {
737 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name()
738 << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
739 << LinkedFromNodesSize() << " false" << endl;
744 cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
745 << anEndLoopNode->Name() << ") LinkedFromNodesSize "
746 << LinkedFromNodesSize() << " true" << endl;
750 #include <sys/time.h>
751 #include <sys/resource.h>
754 const long GraphBase::ComputingNode::CpuUsed() {
755 struct rusage usage ;
756 if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
757 perror("GraphBase::CpuUsed") ;
760 // return usage.ru_utime.__time_t tv_sec ;
761 cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
762 << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
763 return usage.ru_utime.tv_sec ;
767 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
768 GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
769 if ( IsInLineNode() || IsGOTONode() ) {
771 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
772 const InPort * anInPort = GetNodeInPort( i ) ;
773 if ( anInPort->IsBus() ) {
774 int size = aListOfParameters->size() ;
775 aListOfParameters->resize( size + 1 ) ;
776 (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
777 (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
778 const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
779 (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
780 (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
784 return aListOfParameters ;
788 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
789 const char * ComponentName ,
790 const char * InterfaceName ,
791 const char * Computer ,
792 const char * CoupledNode ,
793 const ListOfFuncName FuncNames ,
794 const ListOfPythonFunctions PythonFunctions ,
795 int XCoordinate , int YCoordinate ) const {
796 cdebug_in << "SaveXML Node " << Name() << endl ;
797 QDomElement node = Graph.createElement( "node" ) ;
798 info.appendChild( node ) ;
799 QDomElement componentname = Graph.createElement( "component-name" ) ;
801 if ( strlen( ComponentName ) ) {
802 // f << Tabs << "<component-name>" << ComponentName << "</component-name>"
804 // componentname.setNodeValue( ComponentName ) ;
805 aField = Graph.createTextNode( ComponentName ) ;
808 // f << Tabs << "<component-name>?</component-name>" << endl ;
809 // componentname.setNodeValue( "?" ) ;
810 aField = Graph.createTextNode( "?" ) ;
812 node.appendChild( componentname ) ;
813 componentname.appendChild( aField ) ;
815 QDomElement interfacename = Graph.createElement("interface-name") ;
816 if ( strlen( InterfaceName ) ) {
817 // f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
819 // interfacename.setAttribute("name" , InterfaceName ) ;
820 aField = Graph.createTextNode( InterfaceName ) ;
823 // f << Tabs << "<interface-name>?</interface-name>" << endl ;
824 // interfacename.setAttribute("name" , "?" ) ;
825 aField = Graph.createTextNode( "?" ) ;
827 node.appendChild(interfacename) ;
828 interfacename.appendChild( aField ) ;
830 // f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
831 QDomElement nodename = Graph.createElement("node-name") ;
832 aField = Graph.createTextNode( Name() ) ;
833 node.appendChild( nodename ) ;
834 nodename.appendChild( aField ) ;
836 // f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
837 QDomElement kind = Graph.createElement( "kind" ) ;
840 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
841 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
842 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
843 aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
846 aKind = aKind.setNum( Kind() ) ;
848 aField = Graph.createTextNode( aKind ) ;
849 node.appendChild( kind ) ;
850 kind.appendChild( aField ) ;
852 if ( IsDataStreamNode() && HasDataStream() != 0 ) {
854 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
856 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
858 QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
860 aTimeout = aTimeout.setNum( Timeout ) ;
861 aField = Graph.createTextNode( aTimeout ) ;
862 node.appendChild( timeout ) ;
863 timeout.appendChild( aField ) ;
865 QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
866 QString aDataStreamTrace ;
867 aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
868 aField = Graph.createTextNode( aDataStreamTrace ) ;
869 node.appendChild( datastreamtrace ) ;
870 datastreamtrace.appendChild( aField ) ;
872 QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
874 aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
875 aField = Graph.createTextNode( aDeltaTime ) ;
876 node.appendChild( deltatime ) ;
877 deltatime.appendChild( aField ) ;
880 QDomElement couplednode = Graph.createElement("coupled-node") ;
881 if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
882 IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
883 // f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
885 aField = Graph.createTextNode( CoupledNode ) ;
888 // f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
889 aField = Graph.createTextNode( "?" ) ;
891 node.appendChild(couplednode) ;
892 couplednode.appendChild( aField ) ;
894 // f << Tabs << "<service>" << endl ;
895 QDomElement service = Graph.createElement("service") ;
896 node.appendChild(service) ;
897 QDomElement servicename = Graph.createElement("service-name") ;
898 if ( strlen( ServiceName() ) ) {
899 // f << Tabs << " <service-name>" << ServiceName() << "</service-name>" << endl ;
900 aField = Graph.createTextNode( ServiceName() ) ;
903 // f << Tabs << " <service-name>?</service-name>" << endl ;
904 aField = Graph.createTextNode( "?" ) ;
906 service.appendChild(servicename) ;
907 servicename.appendChild( aField ) ;
909 cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
910 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
911 QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
912 service.appendChild(inParameterlist) ;
914 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
915 for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
916 const GraphBase::InPort * anInPort ;
917 anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
918 if ( !anInPort->IsDataStream() ) {
919 cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
920 << " InParameterPort " << anInPort->Kind() << endl ;
921 QDomElement inParameter = Graph.createElement("inParameter") ;
922 inParameterlist.appendChild(inParameter) ;
923 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
924 if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
925 aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
928 aField = Graph.createTextNode( "?" ) ;
930 inParameter.appendChild(inParametertype) ;
931 inParametertype.appendChild( aField ) ;
932 QDomElement inParametername = Graph.createElement("inParameter-name") ;
933 if ( strlen( ServiceInParameter()[i].Parametername ) ) {
934 aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
937 aField = Graph.createTextNode( "?" ) ;
939 inParameter.appendChild(inParametername) ;
940 inParametername.appendChild( aField ) ;
943 QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
944 service.appendChild(outParameterlist) ;
945 for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
946 const GraphBase::OutPort * anOutPort ;
947 anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
948 if ( !anOutPort->IsDataStream() ) {
949 cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
950 << " OutParameterPort " << anOutPort->Kind() << endl ;
951 QDomElement outParameter = Graph.createElement("outParameter") ;
952 outParameterlist.appendChild(outParameter) ;
953 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
954 if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
955 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
958 aField = Graph.createTextNode( "?" ) ;
960 outParameter.appendChild(outParametertype) ;
961 outParametertype.appendChild( aField ) ;
962 QDomElement outParametername = Graph.createElement("outParameter-name") ;
963 if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
964 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
967 aField = Graph.createTextNode( "?" ) ;
969 outParameter.appendChild(outParametername) ;
970 outParametername.appendChild( aField ) ;
974 QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
975 node.appendChild( DataStreamlist ) ;
976 for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
977 const GraphBase::InPort * anInPort ;
978 anInPort = aNode->GetNodeInPort( i ) ;
979 if ( anInPort->IsDataStream() ) {
980 cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
981 << " InDataStreamPort " << anInPort->Kind() << endl ;
982 QDomElement inParameter = Graph.createElement("inParameter") ;
983 DataStreamlist.appendChild(inParameter) ;
984 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
986 aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
987 cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
988 << " " << aType << endl ;
989 aField = Graph.createTextNode( aType ) ;
990 inParameter.appendChild(inParametertype) ;
991 inParametertype.appendChild( aField ) ;
992 QDomElement inParametername = Graph.createElement("inParameter-name") ;
993 if ( strlen( anInPort->PortName() ) ) {
994 aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
997 aField = Graph.createTextNode( "?" ) ;
999 inParameter.appendChild(inParametername) ;
1000 inParametername.appendChild( aField ) ;
1001 cdebug << "SaveXML " << anInPort->PortName() << endl ;
1002 QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
1003 QString aDependency ;
1004 aDependency = aDependency.setNum( anInPort->Dependency() ) ;
1005 aField = Graph.createTextNode( aDependency ) ;
1006 inParameter.appendChild(inParameterdependency) ;
1007 inParameterdependency.appendChild( aField ) ;
1008 cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
1009 SUPERV::KindOfSchema aKindOfSchema ;
1010 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1011 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1012 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1013 QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
1015 aSchema = aSchema.setNum( aKindOfSchema ) ;
1016 aField = Graph.createTextNode( aSchema ) ;
1017 inParameter.appendChild(inParameterKindOfSchema) ;
1018 inParameterKindOfSchema.appendChild( aField ) ;
1019 cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
1020 QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
1021 QString anInterpolation ;
1022 anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
1023 aField = Graph.createTextNode( anInterpolation ) ;
1024 inParameter.appendChild(inParameterKindOfInterpolation) ;
1025 inParameterKindOfInterpolation.appendChild( aField ) ;
1026 cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
1027 QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
1028 QString anExtrapolation ;
1029 anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
1030 aField = Graph.createTextNode( anExtrapolation ) ;
1031 inParameter.appendChild(inParameterKindOfExtrapolation) ;
1032 inParameterKindOfExtrapolation.appendChild( aField ) ;
1033 cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
1036 for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
1037 const GraphBase::OutPort * anOutPort ;
1038 anOutPort = aNode->GetNodeOutPort( i ) ;
1039 if ( anOutPort->IsDataStream() ) {
1040 cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1041 << " OutDataStreamPort " << anOutPort->Kind() << endl ;
1042 QDomElement outParameter = Graph.createElement("outParameter") ;
1043 DataStreamlist.appendChild(outParameter) ;
1044 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1046 aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
1047 cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
1048 << " " << aType << endl ;
1049 aField = Graph.createTextNode( aType ) ;
1050 outParameter.appendChild(outParametertype) ;
1051 outParametertype.appendChild( aField ) ;
1052 QDomElement outParametername = Graph.createElement("outParameter-name") ;
1053 if ( strlen( anOutPort->PortName() ) ) {
1054 aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
1057 aField = Graph.createTextNode( "?" ) ;
1059 outParameter.appendChild(outParametername) ;
1060 outParametername.appendChild( aField ) ;
1061 cdebug << "SaveXML " << anOutPort->PortName() << endl ;
1062 QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
1063 QString aDependency ;
1064 aDependency = aDependency.setNum( anOutPort->Dependency() ) ;
1065 aField = Graph.createTextNode( aDependency ) ;
1066 outParameter.appendChild(outParameterdependency) ;
1067 outParameterdependency.appendChild( aField ) ;
1068 cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1069 long aNumberOfValues ;
1070 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1071 QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1073 aValues = aValues.setNum( aNumberOfValues ) ;
1074 aField = Graph.createTextNode( aValues ) ;
1075 outParameter.appendChild(outParameterNumberOfValues) ;
1076 outParameterNumberOfValues.appendChild( aField ) ;
1077 cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1080 // f << Tabs << "</Parameter-list>" << endl ;
1082 // f << Tabs << "<PyFunction-list>" << endl ;
1083 QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1084 node.appendChild( PyFunctionlist ) ;
1085 for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1086 // f << Tabs << " <PyFunction>" << endl ;
1087 QDomElement PyFunction = Graph.createElement("PyFunction") ;
1088 PyFunctionlist.appendChild( PyFunction ) ;
1090 QDomElement FuncName = Graph.createElement("FuncName") ;
1091 if ( strlen( FuncNames[i].c_str() ) ) {
1092 aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1095 aField = Graph.createTextNode( "?" ) ;
1097 PyFunction.appendChild( FuncName ) ;
1098 FuncName.appendChild( aField ) ;
1099 if ( (*PythonFunctions[i]).length() ) {
1100 for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1101 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1102 QDomCDATASection aCDATA ;
1103 // mpv: Linux 8.0 compiler compatibility
1104 char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1106 for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1107 if ( aCDATAChar[ i ] != ' ' ) {
1111 if ( i == (int ) strlen( aCDATAChar ) ) {
1112 aCDATA = Graph.createCDATASection( "?" ) ;
1115 aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1117 PyFunction.appendChild( PyFunc ) ;
1118 PyFunc.appendChild( aCDATA ) ;
1122 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1123 QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1124 PyFunction.appendChild( PyFunc ) ;
1125 PyFunc.appendChild( aCDATA ) ;
1129 // f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1131 QDomElement creationdate = Graph.createElement("creation-date") ;
1133 sprintf( fdate , "%d/%d/%d - %d:%d:%d" , FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1134 aField = Graph.createTextNode( fdate ) ;
1135 node.appendChild( creationdate ) ;
1136 creationdate.appendChild( aField ) ;
1137 // f << Tabs << "<lastmodification-date>" << LastModification()
1138 // << "</lastmodification-date>" << endl ;
1139 QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1141 sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1142 aField = Graph.createTextNode( ldate ) ;
1143 node.appendChild( lastmodificationdate ) ;
1144 lastmodificationdate.appendChild( aField ) ;
1145 // f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1147 QDomElement editorrelease = Graph.createElement("editor-release") ;
1148 aField = Graph.createTextNode( EditorRelease() ) ;
1149 node.appendChild( editorrelease ) ;
1150 editorrelease.appendChild( aField ) ;
1151 QDomElement author = Graph.createElement("author") ;
1152 if ( strlen( Author() ) ) {
1153 // f << Tabs << "<author>" << Author() << "</author>" << endl ;
1154 aField = Graph.createTextNode( Author() ) ;
1157 // f << Tabs << "<author>?</author>" << endl ;
1158 aField = Graph.createTextNode( "?" ) ;
1160 node.appendChild( author ) ;
1161 author.appendChild( aField ) ;
1162 QDomElement container = Graph.createElement("container") ;
1163 if ( IsFactoryNode() && strlen( Computer) ) {
1164 // f << Tabs << "<container>" << Computer << "</container>" << endl ;
1165 aField = Graph.createTextNode( Computer ) ;
1168 // f << Tabs << "<container>?</container>" << endl ;
1169 aField = Graph.createTextNode( "?" ) ;
1171 node.appendChild( container ) ;
1172 container.appendChild( aField ) ;
1173 QDomElement comment = Graph.createElement("comment") ;
1174 if ( strlen( Comment() ) ) {
1175 // f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1176 aField = Graph.createTextNode( Comment() ) ;
1179 // f << Tabs << "<comment>?</comment>" << endl ;
1180 aField = Graph.createTextNode( "?" ) ;
1182 node.appendChild( comment ) ;
1183 comment.appendChild( aField ) ;
1184 // f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1185 QDomElement xposition = Graph.createElement("x-position") ;
1186 QString aXCoordinate ;
1187 aXCoordinate = aKind.setNum( XCoordinate ) ;
1188 aField = Graph.createTextNode( aXCoordinate ) ;
1189 node.appendChild( xposition ) ;
1190 xposition.appendChild( aField ) ;
1191 // f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1192 QDomElement yposition = Graph.createElement("y-position") ;
1193 QString aYCoordinate ;
1194 aYCoordinate = aKind.setNum( YCoordinate ) ;
1195 aField = Graph.createTextNode( aYCoordinate ) ;
1196 node.appendChild( yposition ) ;
1197 yposition.appendChild( aField ) ;
1198 cdebug_out << "SaveXML Node " << Name() << endl ;
1202 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1203 const char * ComponentName ,
1204 const char * InterfaceName ,
1205 const char * Computer ,
1206 const GraphBase::InLineNode * aCoupledNode ,
1207 const ListOfFuncName FuncNames ,
1208 const ListOfPythonFunctions PythonFunctions ,
1209 int XCoordinate , int YCoordinate ) const {
1210 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1211 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1212 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1213 f << " " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1214 if ( GraphMacroLevel() ) {
1215 f << " " << Name() << ".SetCoupled( '"
1216 << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1219 else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1220 f << " " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1222 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1224 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1225 f << " " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1226 << " , " << DeltaTime << " )" << endl ;
1228 else if ( IsComputingNode() ) {
1230 f << " " << Name() << "_ServiceinParameter = []" << endl ;
1231 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1232 f << " " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1233 << ServiceInParameter()[i].Parametertype << "' , '"
1234 << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1236 f << " " << Name() << "_ServiceoutParameter = []" << endl ;
1237 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1238 f << " " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1239 << ServiceOutParameter()[i].Parametertype << "' , '"
1240 << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1242 f << " " << Name() << "_ServiceinStreamParameter = []" << endl ;
1243 for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1244 f << " " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1245 << ServiceInStreamParameter()[i].Parametertype << " , '"
1246 << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1247 << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1249 f << " " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1250 for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1251 f << " " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1252 << ServiceOutStreamParameter()[i].Parametertype << " , '"
1253 << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1254 << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1256 f << " " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1257 << "' , " << Name() << "_ServiceinParameter"
1258 << " , " << Name() << "_ServiceoutParameter"
1259 << " , " << Name() << "_ServiceinStreamParameter"
1260 << " , " << Name() << "_ServiceoutStreamParameter"
1261 << " , 0 , 0 )" << endl ;
1262 f << " " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1265 else if ( IsFactoryNode() ) {
1266 f << " " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1267 << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1270 else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1271 // It is done with LoopNode or SwitchNode with CoupledNode()
1274 if ( !IsMacroNode() ) {
1275 f << " " << "Py" << Name() << " = []" << endl ;
1278 SUPERV::ListOfStrings aPyFunc ;
1279 if ( PythonFunctions.size() ) {
1280 aPyFunc = *PythonFunctions[0] ;
1281 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1282 f << " " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1285 if ( IsInLineNode() ) {
1286 f << " " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1287 << Name() << " )" << endl ;
1289 else if ( IsGOTONode() ) {
1290 if ( aCoupledNode ) {
1291 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1292 << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1295 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1296 << Name() << " , '' )" << endl ;
1299 else if ( IsMacroNode() ) {
1300 if ( aCoupledNode ) {
1301 f << " " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1302 f << " " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1305 f << " " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1307 f << " " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1310 // char * EndName = NULL ;
1311 // EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1312 // strcpy( EndName , "End" ) ;
1313 // strcat( EndName , Name() ) ;
1314 char * EndName = aCoupledNode->Name() ;
1315 if ( IsLoopNode() ) {
1317 SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1318 SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1319 f << " " << "PyMore" << Name() << " = []" << endl ;
1320 for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1321 f << " " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1323 f << " " << "PyNext" << Name() << " = []" << endl ;
1324 for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1325 f << " " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1327 f << " " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1328 << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1329 << FuncNames[1].c_str() << "' , PyMore" << Name()
1330 << " , '" << FuncNames[2].c_str() << "' , PyNext"
1331 << Name() << " )" << endl ;
1332 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1333 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1334 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1335 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1336 << aCoupledNode->YCoordinate() << " )" << endl ;
1337 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1338 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1339 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1340 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1343 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1344 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1345 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1346 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1347 << " " << anInPort->Kind() << endl ;
1348 if ( anInPort->IsLoop() ) {
1349 f << " " << "I" << Name() << anInPort->PortName() << " = "
1350 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1352 else if ( anInPort->IsInLine() ) {
1353 f << " " << "I" << Name() << anInPort->PortName() << " = "
1354 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1355 << anInPort->PortType() << "' )" << endl ;
1357 else if ( anInPort->IsDataStream() ) {
1358 f << " " << "I" << Name() << anInPort->PortName() << " = " << Name()
1359 << ".InStreamPort( '" << anInPort->PortName()
1360 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1361 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1362 SUPERV::KindOfSchema aKindOfSchema ;
1363 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1364 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1365 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1366 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1367 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1369 else if ( anInPort->IsGate() ) {
1370 f << " " << "I" << Name() << anInPort->PortName() << " = "
1371 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1374 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1375 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1376 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1377 << " " << anOutPort->Kind() << endl ;
1378 if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1379 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1380 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1382 else if ( anOutPort->IsDataStream() ) {
1383 f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1384 << ".OutStreamPort( '" << anOutPort->PortName()
1385 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1386 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1387 long aNumberOfValues ;
1388 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1389 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1393 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1394 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1395 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1396 << " " << anInPort->Kind() << endl ;
1397 if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1398 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1399 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1401 else if ( anInPort->IsDataStream() ) {
1402 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1403 << ".InStreamPort( '" << anInPort->PortName()
1404 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1405 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1406 SUPERV::KindOfSchema aKindOfSchema ;
1407 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1408 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1409 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1410 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1411 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1414 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1415 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1416 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1417 << " " << anOutPort->Kind() << endl ;
1418 if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1419 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1420 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1422 else if ( anOutPort->IsDataStream() ) {
1423 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1424 << ".OutStreamPort( '" << anOutPort->PortName()
1425 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1426 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1427 long aNumberOfValues ;
1428 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1429 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1434 else if ( IsSwitchNode() ) {
1435 f << " " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1436 << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1437 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1438 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1439 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1440 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1441 << aCoupledNode->YCoordinate() << " )" << endl ;
1442 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1443 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1444 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1445 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1448 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1449 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1450 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1451 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1452 << " " << anInPort->Kind() << endl ;
1453 // if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1454 if ( anInPort->IsGate() ) {
1455 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1456 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1458 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1459 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1460 << ".InPort( '" << anInPort->PortName()
1461 << "' , '" << anInPort->PortType() << "' )" << endl ;
1463 else if ( anInPort->IsDataStream() ) {
1464 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1465 << ".InStreamPort( '" << anInPort->PortName()
1466 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1467 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1468 SUPERV::KindOfSchema aKindOfSchema ;
1469 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1470 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1471 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1472 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1473 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1476 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1477 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1478 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1479 << " " << anOutPort->Kind() << endl ;
1480 // if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1481 if ( anOutPort->IsGate() ) {
1482 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1483 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1485 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1486 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1487 << ".OutPort( '" << anOutPort->PortName()
1488 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1490 else if ( anOutPort->IsDataStream() ) {
1491 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1492 << ".OutStreamPort( '" << anOutPort->PortName()
1493 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1494 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1495 long aNumberOfValues ;
1496 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1497 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1506 if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1507 // It is done with LoopNode or SwitchNode with CoupledNode()
1510 f << " " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1511 f << " " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1512 if ( IsFactoryNode() ) {
1513 f << " " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1515 f << " " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1516 f << " " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1518 if ( IsComputingNode() || IsFactoryNode() ) {
1520 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1521 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1522 if ( !anInPort->IsDataStream() ) {
1523 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1524 << " " << anInPort->Kind() << endl ;
1525 f << " " << "I" << Name() << anInPort->PortName() << " = "
1526 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1529 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1530 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1531 if ( !anOutPort->IsDataStream() ) {
1532 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1533 << " " << anOutPort->Kind() << endl ;
1534 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1535 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1539 else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1541 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1542 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1543 cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1544 << " " << anInPort->Kind() << endl ;
1545 // if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1546 if ( anInPort->IsGate() || IsMacroNode() ) {
1547 f << " " << "I" << Name() << anInPort->PortName() << " = "
1548 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1550 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1551 f << " " << "I" << Name() << anInPort->PortName() << " = "
1552 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1553 << anInPort->PortType() << "' )" << endl ;
1556 cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1557 // f << " " << "I" << Name() << anInPort->PortName() << " = "
1558 // << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1561 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1562 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1563 cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1564 << " " << anOutPort->Kind() << endl ;
1565 // if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1566 if ( anOutPort->IsGate() || IsMacroNode() ) {
1567 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1568 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1570 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1571 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1572 << Name() << ".OutPort( '" << anOutPort->PortName()
1573 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1576 cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1577 // f << " " << "O" << Name() << anOutPort->PortName() << " = "
1578 // << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1582 if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1584 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1585 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1586 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1587 << " " << anInPort->Kind() << endl ;
1588 if ( anInPort->IsDataStream() ) {
1589 if ( IsOneOfInLineNodes() ) {
1590 f << " " << "I" << Name() << anInPort->PortName() << " = "
1591 << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1592 << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1593 << anInPort->Dependency() << " )" << endl ;
1596 f << " " << "I" << Name() << anInPort->PortName() << " = "
1597 << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1599 SUPERV::KindOfSchema aKindOfSchema ;
1600 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1601 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1602 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1603 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1604 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1607 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1608 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1609 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1610 << " " << anOutPort->Kind() << endl ;
1611 if ( anOutPort->IsDataStream() ) {
1612 if ( IsOneOfInLineNodes() ) {
1613 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1614 << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1615 << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1616 << anOutPort->Dependency() << " )" << endl ;
1619 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1620 << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1622 long aNumberOfValues ;
1623 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1624 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1633 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1635 ListPorts( s , true ) ;
1639 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1640 // f << "ComponentName " << G.ComponentName() << endl ;
1641 if ( G.IsComputingNode() ) {
1642 f << "NodeName " << G.Name() << endl ;
1645 f << "DataFlowName " << G.Name() << endl ;
1647 f << "Kind " << G.Kind() << endl ;
1648 f << "Service " << *G.GetService() ;
1649 f << "FirstCreation " << G.FirstCreation () << endl ;
1650 f << "LastModification " << G.LastModification() << endl ;
1651 f << "EditorRelease " << G.EditorRelease() << endl ;
1652 f << "Author " << G.Author() << endl ;
1653 // f << "Computer " << G.Computer() << endl ;
1654 f << "Comment " << G.Comment() << endl ;
1660 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1662 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1663 const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1664 if ( fromPort->IsPortConnected() ) {
1666 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1668 f << "FromNode " << Name() << endl ;
1670 f << " FromServiceParameterName "
1671 << fromPort->GetServicesParameter().Parametername ;
1672 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1673 f << " ToNode " << toPort->NodeName() ;
1674 f << " ToServiceParameterName "
1675 << toPort->GetServicesParameter().Parametername;
1677 fromPort->StringValue( f ) ;
1684 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1685 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1687 fOut << D.Day << "/"
1694 // cdebug_out << "operator<< GraphEditor::Date" << endl;