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() << "->ComputingNode::CheckLoop( " << aLoopNode->Name() << " , "
689 << anEndLoopNode->Name() << ") LinkedNodesSize "
690 << LinkedNodesSize() << endl;
693 if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) {
694 cdebug_out << Name() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
695 << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
696 << LinkedNodesSize() << " WARNING 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() << "->ComputingNode::CheckLoop( " << aLoopNode->Name()
706 << " , " << anEndLoopNode->Name() << ") LinkedNodesSize "
707 << LinkedNodesSize() << " WARNING false" << endl;
712 cdebug_out << Name() << "->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() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
721 << anEndLoopNode->Name() << ") LinkedFromNodesSize "
722 << LinkedFromNodesSize() << endl;
725 if ( LinkedFromNodesSize() == 0 ) {
726 cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
727 << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
728 << LinkedFromNodesSize() << " WARNING 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() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name()
738 << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize "
739 << LinkedFromNodesSize() << " WARNING false" << endl;
744 cdebug_out << Name() << "->ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , "
745 << anEndLoopNode->Name() << ") LinkedFromNodesSize "
746 << LinkedFromNodesSize() << " true" << endl;
750 bool GraphBase::ComputingNode::InitBranchOfSwitchDone(bool AllInit ,
751 GraphBase::EndOfSwitchNode * anEndSwitchNode ) {
752 bool sts = BranchOfSwitchDone( false ) ;
753 if ( !sts && !AllInit && anEndSwitchNode != this ) {
754 // Common Node in branchs :
755 cdebug << Name() << "->ComputingNode::InitBranchOfSwitchDone WARNING false"
760 if ( !IsGOTONode() && anEndSwitchNode != this ) {
761 for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
762 GraphBase::ComputingNode * aNode ;
763 aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ;
764 if ( !aNode->InitBranchOfSwitchDone( AllInit , anEndSwitchNode ) ) {
772 bool GraphBase::ComputingNode::CheckSwitch(GraphBase::EndOfSwitchNode * anEndSwitchNode ) {
773 cdebug_in << Name() << "->ComputingNode::CheckSwitch( "
774 << anEndSwitchNode->Name() << " ) " << Kind() << endl;
775 if ( anEndSwitchNode == this ) {
777 // if it is a SwitchNode, continue the check at the corresponding EndSwitchNode
778 else if ( IsSwitchNode() ) {
779 GraphBase::EndOfSwitchNode * anOtherEndSwitchNode ;
780 anOtherEndSwitchNode = (GraphBase::EndOfSwitchNode * ) ((GraphBase::SwitchNode * ) this)->CoupledNode() ;
781 cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
782 << anOtherEndSwitchNode->Name() << endl ;
783 if ( !anOtherEndSwitchNode->CheckSwitch( anEndSwitchNode ) ) {
784 cdebug_out << Name() << "->ComputingNode::CheckSwitch "
785 << anOtherEndSwitchNode->Name() << " WARNING false" << endl;
791 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
792 GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
793 if ( !anOutPort->IsDataStream() ) {
795 for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
796 GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( j ) ;
797 if ( !anInPort->IsDataStream() ) {
798 GraphBase::ComputingNode * aNode ;
799 aNode = GraphOfNode()->GetChangeGraphNode( anInPort->NodeName() ) ;
800 GraphBase::LoopNode * aLoopNode = NULL ;
801 GraphBase::EndOfLoopNode * aEndLoopNode = NULL ;
802 if ( IsLoopNode() ) {
803 aEndLoopNode = (GraphBase::EndOfLoopNode * ) ((GraphBase::LoopNode * ) this)->CoupledNode() ;
804 cdebug << Name() << "->ComputingNode::CheckSwitch LoopNode " << Name() << " coupled to "
805 << aEndLoopNode << " " << aEndLoopNode->Name() << " aNode " << aNode << endl ;
807 else if ( IsEndLoopNode() ) {
808 aLoopNode = (GraphBase::LoopNode * ) ((GraphBase::EndOfLoopNode * ) this)->CoupledNode() ;
809 cdebug << Name() << "->ComputingNode::CheckSwitch EndLoopNode " << Name()
811 << aLoopNode << " " << aLoopNode->Name() << " aNode " << aNode << endl ;
813 if ( aNode == NULL ) {
814 cdebug << Name() << "->ComputingNode::CheckSwitch ignore "
815 << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
817 else if ( aNode == anEndSwitchNode ) {
818 ((GraphBase::EndOfSwitchNode * ) aNode)->DecrEndSwitchInPortLinked( anInPort ) ;
820 else if ( aNode->BranchOfSwitchDone() ) {
821 cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
822 << anInPort->NodeName() << "( " << anInPort->PortName() << " ) : already checked"
825 else if ( IsLoopNode() && aNode == aEndLoopNode ) {
826 cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
827 << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
829 else if ( IsEndLoopNode() && aNode == aLoopNode ) {
830 cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
831 << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
833 else if ( aNode->IsGOTONode() ) {
834 cdebug << Name() << "->ComputingNode::CheckSwitch will NOT Check "
835 << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
836 anEndSwitchNode->SetSwitchWithGOTO() ;
839 cdebug << Name() << "->ComputingNode::CheckSwitch will Check "
840 << anInPort->NodeName() << "( " << anInPort->PortName() << " )" << endl ;
841 if ( !aNode->CheckSwitch( anEndSwitchNode ) ) {
842 cdebug_out << Name() << "->ComputingNode::CheckSwitch "
843 << anEndSwitchNode->Name() << " WARNING false" << endl;
846 // aNode->BranchOfSwitchDone( true ) ;
853 BranchOfSwitchDone( true ) ;
854 cdebug_out << Name() << "->ComputingNode::CheckSwitch BranchOfSwitchDone == true "
855 << anEndSwitchNode->Name() << " true" << endl;
859 #include <sys/time.h>
860 #include <sys/resource.h>
863 const long GraphBase::ComputingNode::CpuUsed() {
864 struct rusage usage ;
865 if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
866 perror("GraphBase::CpuUsed") ;
869 // return usage.ru_utime.__time_t tv_sec ;
870 cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
871 << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
872 return usage.ru_utime.tv_sec ;
876 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
877 GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
878 if ( IsInLineNode() || IsGOTONode() ) {
880 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
881 const InPort * anInPort = GetNodeInPort( i ) ;
882 if ( anInPort->IsBus() ) {
883 int size = aListOfParameters->size() ;
884 aListOfParameters->resize( size + 1 ) ;
885 (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
886 (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
887 const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
888 (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
889 (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
893 return aListOfParameters ;
897 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
898 const char * ComponentName ,
899 const char * InterfaceName ,
900 const char * Computer ,
901 const char * CoupledNode ,
902 const ListOfFuncName FuncNames ,
903 const ListOfPythonFunctions PythonFunctions ,
904 int XCoordinate , int YCoordinate ) const {
905 cdebug_in << "SaveXML Node " << Name() << endl ;
906 QDomElement node = Graph.createElement( "node" ) ;
907 info.appendChild( node ) ;
908 QDomElement componentname = Graph.createElement( "component-name" ) ;
910 if ( strlen( ComponentName ) ) {
911 // f << Tabs << "<component-name>" << ComponentName << "</component-name>"
913 // componentname.setNodeValue( ComponentName ) ;
914 aField = Graph.createTextNode( ComponentName ) ;
917 // f << Tabs << "<component-name>?</component-name>" << endl ;
918 // componentname.setNodeValue( "?" ) ;
919 aField = Graph.createTextNode( "?" ) ;
921 node.appendChild( componentname ) ;
922 componentname.appendChild( aField ) ;
924 QDomElement interfacename = Graph.createElement("interface-name") ;
925 if ( strlen( InterfaceName ) ) {
926 // f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
928 // interfacename.setAttribute("name" , InterfaceName ) ;
929 aField = Graph.createTextNode( InterfaceName ) ;
932 // f << Tabs << "<interface-name>?</interface-name>" << endl ;
933 // interfacename.setAttribute("name" , "?" ) ;
934 aField = Graph.createTextNode( "?" ) ;
936 node.appendChild(interfacename) ;
937 interfacename.appendChild( aField ) ;
939 // f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
940 QDomElement nodename = Graph.createElement("node-name") ;
941 aField = Graph.createTextNode( Name() ) ;
942 node.appendChild( nodename ) ;
943 nodename.appendChild( aField ) ;
945 // f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
946 QDomElement kind = Graph.createElement( "kind" ) ;
949 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
950 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
951 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
952 aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
955 aKind = aKind.setNum( Kind() ) ;
957 aField = Graph.createTextNode( aKind ) ;
958 node.appendChild( kind ) ;
959 kind.appendChild( aField ) ;
961 if ( IsDataStreamNode() && HasDataStream() != 0 ) {
963 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
965 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
967 QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
969 aTimeout = aTimeout.setNum( Timeout ) ;
970 aField = Graph.createTextNode( aTimeout ) ;
971 node.appendChild( timeout ) ;
972 timeout.appendChild( aField ) ;
974 QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
975 QString aDataStreamTrace ;
976 aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
977 aField = Graph.createTextNode( aDataStreamTrace ) ;
978 node.appendChild( datastreamtrace ) ;
979 datastreamtrace.appendChild( aField ) ;
981 QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
983 aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
984 aField = Graph.createTextNode( aDeltaTime ) ;
985 node.appendChild( deltatime ) ;
986 deltatime.appendChild( aField ) ;
989 QDomElement couplednode = Graph.createElement("coupled-node") ;
990 if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
991 IsSwitchNode() || IsEndSwitchNode() || IsMacroNode() ) {
992 // f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
994 aField = Graph.createTextNode( CoupledNode ) ;
997 // f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
998 aField = Graph.createTextNode( "?" ) ;
1000 node.appendChild(couplednode) ;
1001 couplednode.appendChild( aField ) ;
1003 // f << Tabs << "<service>" << endl ;
1004 QDomElement service = Graph.createElement("service") ;
1005 node.appendChild(service) ;
1006 QDomElement servicename = Graph.createElement("service-name") ;
1007 if ( strlen( ServiceName() ) ) {
1008 // f << Tabs << " <service-name>" << ServiceName() << "</service-name>" << endl ;
1009 aField = Graph.createTextNode( ServiceName() ) ;
1012 // f << Tabs << " <service-name>?</service-name>" << endl ;
1013 aField = Graph.createTextNode( "?" ) ;
1015 service.appendChild(servicename) ;
1016 servicename.appendChild( aField ) ;
1018 cdebug << "SaveXML " << Name() << " In(" << ServiceInParameter().length()
1019 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
1020 QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
1021 service.appendChild(inParameterlist) ;
1023 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
1024 for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
1025 const GraphBase::InPort * anInPort ;
1026 anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
1027 if ( !anInPort->IsDataStream() ) {
1028 cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
1029 << " InParameterPort " << anInPort->Kind() << endl ;
1030 QDomElement inParameter = Graph.createElement("inParameter") ;
1031 inParameterlist.appendChild(inParameter) ;
1032 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
1033 if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
1034 aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
1037 aField = Graph.createTextNode( "?" ) ;
1039 inParameter.appendChild(inParametertype) ;
1040 inParametertype.appendChild( aField ) ;
1041 QDomElement inParametername = Graph.createElement("inParameter-name") ;
1042 if ( strlen( ServiceInParameter()[i].Parametername ) ) {
1043 aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
1046 aField = Graph.createTextNode( "?" ) ;
1048 inParameter.appendChild(inParametername) ;
1049 inParametername.appendChild( aField ) ;
1052 QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
1053 service.appendChild(outParameterlist) ;
1054 for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
1055 const GraphBase::OutPort * anOutPort ;
1056 anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
1057 if ( !anOutPort->IsDataStream() ) {
1058 cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
1059 << " OutParameterPort " << anOutPort->Kind() << endl ;
1060 QDomElement outParameter = Graph.createElement("outParameter") ;
1061 outParameterlist.appendChild(outParameter) ;
1062 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1063 if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
1064 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
1067 aField = Graph.createTextNode( "?" ) ;
1069 outParameter.appendChild(outParametertype) ;
1070 outParametertype.appendChild( aField ) ;
1071 QDomElement outParametername = Graph.createElement("outParameter-name") ;
1072 if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
1073 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
1076 aField = Graph.createTextNode( "?" ) ;
1078 outParameter.appendChild(outParametername) ;
1079 outParametername.appendChild( aField ) ;
1083 QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
1084 node.appendChild( DataStreamlist ) ;
1085 for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
1086 const GraphBase::InPort * anInPort ;
1087 anInPort = aNode->GetNodeInPort( i ) ;
1088 if ( anInPort->IsDataStream() ) {
1089 cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
1090 << " InDataStreamPort " << anInPort->Kind() << endl ;
1091 QDomElement inParameter = Graph.createElement("inParameter") ;
1092 DataStreamlist.appendChild(inParameter) ;
1093 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
1095 aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
1096 cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
1097 << " " << aType << endl ;
1098 aField = Graph.createTextNode( aType ) ;
1099 inParameter.appendChild(inParametertype) ;
1100 inParametertype.appendChild( aField ) ;
1101 QDomElement inParametername = Graph.createElement("inParameter-name") ;
1102 if ( strlen( anInPort->PortName() ) ) {
1103 aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
1106 aField = Graph.createTextNode( "?" ) ;
1108 inParameter.appendChild(inParametername) ;
1109 inParametername.appendChild( aField ) ;
1110 cdebug << "SaveXML " << anInPort->PortName() << endl ;
1111 QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
1112 QString aDependency ;
1113 aDependency = aDependency.setNum( anInPort->Dependency() ) ;
1114 aField = Graph.createTextNode( aDependency ) ;
1115 inParameter.appendChild(inParameterdependency) ;
1116 inParameterdependency.appendChild( aField ) ;
1117 cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
1118 SUPERV::KindOfSchema aKindOfSchema ;
1119 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1120 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1121 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1122 QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
1124 aSchema = aSchema.setNum( aKindOfSchema ) ;
1125 aField = Graph.createTextNode( aSchema ) ;
1126 inParameter.appendChild(inParameterKindOfSchema) ;
1127 inParameterKindOfSchema.appendChild( aField ) ;
1128 cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
1129 QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
1130 QString anInterpolation ;
1131 anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
1132 aField = Graph.createTextNode( anInterpolation ) ;
1133 inParameter.appendChild(inParameterKindOfInterpolation) ;
1134 inParameterKindOfInterpolation.appendChild( aField ) ;
1135 cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
1136 QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
1137 QString anExtrapolation ;
1138 anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
1139 aField = Graph.createTextNode( anExtrapolation ) ;
1140 inParameter.appendChild(inParameterKindOfExtrapolation) ;
1141 inParameterKindOfExtrapolation.appendChild( aField ) ;
1142 cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
1145 for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
1146 const GraphBase::OutPort * anOutPort ;
1147 anOutPort = aNode->GetNodeOutPort( i ) ;
1148 if ( anOutPort->IsDataStream() ) {
1149 cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
1150 << " OutDataStreamPort " << anOutPort->Kind() << endl ;
1151 QDomElement outParameter = Graph.createElement("outParameter") ;
1152 DataStreamlist.appendChild(outParameter) ;
1153 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
1155 aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
1156 cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
1157 << " " << aType << endl ;
1158 aField = Graph.createTextNode( aType ) ;
1159 outParameter.appendChild(outParametertype) ;
1160 outParametertype.appendChild( aField ) ;
1161 QDomElement outParametername = Graph.createElement("outParameter-name") ;
1162 if ( strlen( anOutPort->PortName() ) ) {
1163 aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
1166 aField = Graph.createTextNode( "?" ) ;
1168 outParameter.appendChild(outParametername) ;
1169 outParametername.appendChild( aField ) ;
1170 cdebug << "SaveXML " << anOutPort->PortName() << endl ;
1171 QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
1172 QString aDependency ;
1173 aDependency = aDependency.setNum( anOutPort->Dependency() ) ;
1174 aField = Graph.createTextNode( aDependency ) ;
1175 outParameter.appendChild(outParameterdependency) ;
1176 outParameterdependency.appendChild( aField ) ;
1177 cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
1178 long aNumberOfValues ;
1179 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1180 QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
1182 aValues = aValues.setNum( aNumberOfValues ) ;
1183 aField = Graph.createTextNode( aValues ) ;
1184 outParameter.appendChild(outParameterNumberOfValues) ;
1185 outParameterNumberOfValues.appendChild( aField ) ;
1186 cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
1189 // f << Tabs << "</Parameter-list>" << endl ;
1191 // f << Tabs << "<PyFunction-list>" << endl ;
1192 QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
1193 node.appendChild( PyFunctionlist ) ;
1194 for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
1195 // f << Tabs << " <PyFunction>" << endl ;
1196 QDomElement PyFunction = Graph.createElement("PyFunction") ;
1197 PyFunctionlist.appendChild( PyFunction ) ;
1199 QDomElement FuncName = Graph.createElement("FuncName") ;
1200 if ( strlen( FuncNames[i].c_str() ) ) {
1201 aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
1204 aField = Graph.createTextNode( "?" ) ;
1206 PyFunction.appendChild( FuncName ) ;
1207 FuncName.appendChild( aField ) ;
1208 if ( (*PythonFunctions[i]).length() ) {
1209 for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
1210 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1211 QDomCDATASection aCDATA ;
1212 // mpv: Linux 8.0 compiler compatibility
1213 char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
1215 for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
1216 if ( aCDATAChar[ i ] != ' ' ) {
1220 if ( i == (int ) strlen( aCDATAChar ) ) {
1221 aCDATA = Graph.createCDATASection( "?" ) ;
1224 aCDATA = Graph.createCDATASection( aCDATAChar ) ;
1226 PyFunction.appendChild( PyFunc ) ;
1227 PyFunc.appendChild( aCDATA ) ;
1231 QDomElement PyFunc = Graph.createElement("PyFunc") ;
1232 QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
1233 PyFunction.appendChild( PyFunc ) ;
1234 PyFunc.appendChild( aCDATA ) ;
1238 // f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
1240 QDomElement creationdate = Graph.createElement("creation-date") ;
1242 sprintf( fdate , "%d/%d/%d - %d:%d:%d" , FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
1243 aField = Graph.createTextNode( fdate ) ;
1244 node.appendChild( creationdate ) ;
1245 creationdate.appendChild( aField ) ;
1246 // f << Tabs << "<lastmodification-date>" << LastModification()
1247 // << "</lastmodification-date>" << endl ;
1248 QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
1250 sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
1251 aField = Graph.createTextNode( ldate ) ;
1252 node.appendChild( lastmodificationdate ) ;
1253 lastmodificationdate.appendChild( aField ) ;
1254 // f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
1256 QDomElement editorrelease = Graph.createElement("editor-release") ;
1257 aField = Graph.createTextNode( EditorRelease() ) ;
1258 node.appendChild( editorrelease ) ;
1259 editorrelease.appendChild( aField ) ;
1260 QDomElement author = Graph.createElement("author") ;
1261 if ( strlen( Author() ) ) {
1262 // f << Tabs << "<author>" << Author() << "</author>" << endl ;
1263 aField = Graph.createTextNode( Author() ) ;
1266 // f << Tabs << "<author>?</author>" << endl ;
1267 aField = Graph.createTextNode( "?" ) ;
1269 node.appendChild( author ) ;
1270 author.appendChild( aField ) ;
1271 QDomElement container = Graph.createElement("container") ;
1272 if ( IsFactoryNode() && strlen( Computer) ) {
1273 // f << Tabs << "<container>" << Computer << "</container>" << endl ;
1274 aField = Graph.createTextNode( Computer ) ;
1277 // f << Tabs << "<container>?</container>" << endl ;
1278 aField = Graph.createTextNode( "?" ) ;
1280 node.appendChild( container ) ;
1281 container.appendChild( aField ) ;
1282 QDomElement comment = Graph.createElement("comment") ;
1283 if ( strlen( Comment() ) ) {
1284 // f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
1285 aField = Graph.createTextNode( Comment() ) ;
1288 // f << Tabs << "<comment>?</comment>" << endl ;
1289 aField = Graph.createTextNode( "?" ) ;
1291 node.appendChild( comment ) ;
1292 comment.appendChild( aField ) ;
1293 // f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
1294 QDomElement xposition = Graph.createElement("x-position") ;
1295 QString aXCoordinate ;
1296 aXCoordinate = aKind.setNum( XCoordinate ) ;
1297 aField = Graph.createTextNode( aXCoordinate ) ;
1298 node.appendChild( xposition ) ;
1299 xposition.appendChild( aField ) ;
1300 // f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
1301 QDomElement yposition = Graph.createElement("y-position") ;
1302 QString aYCoordinate ;
1303 aYCoordinate = aKind.setNum( YCoordinate ) ;
1304 aField = Graph.createTextNode( aYCoordinate ) ;
1305 node.appendChild( yposition ) ;
1306 yposition.appendChild( aField ) ;
1307 cdebug_out << "SaveXML Node " << Name() << endl ;
1311 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
1312 const char * ComponentName ,
1313 const char * InterfaceName ,
1314 const char * Computer ,
1315 const GraphBase::InLineNode * aCoupledNode ,
1316 const ListOfFuncName FuncNames ,
1317 const ListOfPythonFunctions PythonFunctions ,
1318 int XCoordinate , int YCoordinate ) const {
1319 cdebug_in << "ComputingNode::SavePY " << Name() << endl ;
1320 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
1321 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
1322 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
1323 f << " " << Name() << " = Graph( '" << Name() << "' )" << endl ;
1324 if ( GraphMacroLevel() ) {
1325 f << " " << Name() << ".SetCoupled( '"
1326 << ((GraphBase::GOTONode * ) this)->CoupledNodeName() << "' )" << endl ;
1329 else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
1330 f << " " << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
1332 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
1334 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
1335 f << " " << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
1336 << " , " << DeltaTime << " )" << endl ;
1338 else if ( IsComputingNode() ) {
1340 f << " " << Name() << "_ServiceinParameter = []" << endl ;
1341 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
1342 f << " " << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1343 << ServiceInParameter()[i].Parametertype << "' , '"
1344 << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
1346 f << " " << Name() << "_ServiceoutParameter = []" << endl ;
1347 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
1348 f << " " << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
1349 << ServiceOutParameter()[i].Parametertype << "' , '"
1350 << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
1352 f << " " << Name() << "_ServiceinStreamParameter = []" << endl ;
1353 for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
1354 f << " " << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1355 << ServiceInStreamParameter()[i].Parametertype << " , '"
1356 << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1357 << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1359 f << " " << Name() << "_ServiceoutStreamParameter = []" << endl ;
1360 for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
1361 f << " " << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
1362 << ServiceOutStreamParameter()[i].Parametertype << " , '"
1363 << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
1364 << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
1366 f << " " << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
1367 << "' , " << Name() << "_ServiceinParameter"
1368 << " , " << Name() << "_ServiceoutParameter"
1369 << " , " << Name() << "_ServiceinStreamParameter"
1370 << " , " << Name() << "_ServiceoutStreamParameter"
1371 << " , 0 , 0 )" << endl ;
1372 f << " " << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
1375 else if ( IsFactoryNode() ) {
1376 f << " " << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
1377 << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
1380 else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1381 // It is done with LoopNode or SwitchNode with CoupledNode()
1384 if ( !IsMacroNode() ) {
1385 f << " " << "Py" << Name() << " = []" << endl ;
1388 SUPERV::ListOfStrings aPyFunc ;
1389 if ( PythonFunctions.size() ) {
1390 aPyFunc = *PythonFunctions[0] ;
1391 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1392 f << " " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
1395 if ( IsInLineNode() ) {
1396 f << " " << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
1397 << Name() << " )" << endl ;
1399 else if ( IsGOTONode() ) {
1400 if ( aCoupledNode ) {
1401 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1402 << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1405 f << " " << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1406 << Name() << " , '' )" << endl ;
1409 else if ( IsMacroNode() ) {
1410 if ( aCoupledNode ) {
1411 f << " " << aCoupledNode->Name() << " = Def" << aCoupledNode->Name() << "()" << endl ;
1412 f << " " << Name() << " = " << aGraphName << ".GraphMNode( " << aCoupledNode->Name() << " )" << endl ;
1415 f << " " << Name() << " = " << aGraphName << ".GraphMNode( ? )" << endl ;
1417 f << " " << Name() << ".SetCoupled( '" << aCoupledNode->Name() << "' )" << endl ;
1420 // char * EndName = NULL ;
1421 // EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1422 // strcpy( EndName , "End" ) ;
1423 // strcat( EndName , Name() ) ;
1424 char * EndName = aCoupledNode->Name() ;
1425 cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
1427 if ( IsLoopNode() ) {
1429 SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1430 SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1431 f << " " << "PyMore" << Name() << " = []" << endl ;
1432 for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1433 f << " " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1435 f << " " << "PyNext" << Name() << " = []" << endl ;
1436 for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1437 f << " " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1439 f << " " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1440 << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1441 << FuncNames[1].c_str() << "' , PyMore" << Name()
1442 << " , '" << FuncNames[2].c_str() << "' , PyNext"
1443 << Name() << " )" << endl ;
1444 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1445 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1446 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1447 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1448 << aCoupledNode->YCoordinate() << " )" << endl ;
1449 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1450 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1451 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1452 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1455 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1456 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1457 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1458 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1459 << " " << anInPort->Kind() << endl ;
1460 if ( anInPort->IsLoop() ) {
1461 f << " " << "I" << Name() << anInPort->PortName() << " = "
1462 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1464 else if ( anInPort->IsInLine() ) {
1465 f << " " << "I" << Name() << anInPort->PortName() << " = "
1466 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1467 << anInPort->PortType() << "' )" << endl ;
1469 else if ( anInPort->IsDataStream() ) {
1470 f << " " << "I" << Name() << anInPort->PortName() << " = " << Name()
1471 << ".InStreamPort( '" << anInPort->PortName()
1472 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1473 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1474 SUPERV::KindOfSchema aKindOfSchema ;
1475 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1476 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1477 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1478 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1479 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1481 else if ( anInPort->IsGate() ) {
1482 f << " " << "I" << Name() << anInPort->PortName() << " = "
1483 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1486 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1487 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1488 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1489 << " " << anOutPort->Kind() << endl ;
1490 if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1491 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1492 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1494 else if ( anOutPort->IsDataStream() ) {
1495 f << " " << "O" << Name() << anOutPort->PortName() << " = " << Name()
1496 << ".OutStreamPort( '" << anOutPort->PortName()
1497 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1498 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1499 long aNumberOfValues ;
1500 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1501 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1505 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1506 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1507 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1508 << " " << anInPort->Kind() << endl ;
1509 if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1510 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1511 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1513 else if ( anInPort->IsDataStream() ) {
1514 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1515 << ".InStreamPort( '" << anInPort->PortName()
1516 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1517 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1518 SUPERV::KindOfSchema aKindOfSchema ;
1519 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1520 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1521 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1522 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1523 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1526 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1527 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1528 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1529 << " " << anOutPort->Kind() << endl ;
1530 if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1531 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1532 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1534 else if ( anOutPort->IsDataStream() ) {
1535 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1536 << ".OutStreamPort( '" << anOutPort->PortName()
1537 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1538 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1539 long aNumberOfValues ;
1540 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1541 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1546 else if ( IsSwitchNode() ) {
1547 f << " " << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1548 << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1549 f << " " << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1550 f << " " << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1551 f << " " << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1552 f << " " << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1553 << aCoupledNode->YCoordinate() << " )" << endl ;
1554 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1555 f << " " << "Py" << aCoupledNode->Name() << " = []" << endl ;
1556 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1557 f << " " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1560 f << " " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1561 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1562 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1563 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1564 << " " << anInPort->Kind() << endl ;
1565 // if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1566 if ( anInPort->IsGate() ) {
1567 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1568 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1570 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1571 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1572 << ".InPort( '" << anInPort->PortName()
1573 << "' , '" << anInPort->PortType() << "' )" << endl ;
1575 else if ( anInPort->IsDataStream() ) {
1576 f << " " << "I" << EndName << anInPort->PortName() << " = " << EndName
1577 << ".InStreamPort( '" << anInPort->PortName()
1578 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1579 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1580 SUPERV::KindOfSchema aKindOfSchema ;
1581 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1582 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1583 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1584 f << " " << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1585 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1588 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1589 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1590 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1591 << " " << anOutPort->Kind() << endl ;
1592 // if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1593 if ( anOutPort->IsGate() ) {
1594 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1595 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1597 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1598 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1599 << ".OutPort( '" << anOutPort->PortName()
1600 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1602 else if ( anOutPort->IsDataStream() ) {
1603 f << " " << "O" << EndName << anOutPort->PortName() << " = " << EndName
1604 << ".OutStreamPort( '" << anOutPort->PortName()
1605 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1606 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1607 long aNumberOfValues ;
1608 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1609 f << " " << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1614 cdebug << "ComputingNode::SavePY Node " << Name() << " EndName " << EndName
1616 //JR 24.02.2005 Debug !!!... : I should not delete myself : what a stupid thing !
1617 // delete [] EndName ;
1621 if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1622 // It is done with LoopNode or SwitchNode with CoupledNode()
1625 f << " " << Name() << ".SetName( '" << Name() << "' )" << endl ;
1626 f << " " << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1627 if ( IsFactoryNode() ) {
1628 f << " " << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1630 f << " " << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1631 f << " " << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1633 if ( IsComputingNode() || IsFactoryNode() ) {
1635 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1636 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1637 if ( !anInPort->IsDataStream() ) {
1638 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1639 << " " << anInPort->Kind() << endl ;
1640 f << " " << "I" << Name() << anInPort->PortName() << " = "
1641 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1644 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1645 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1646 if ( !anOutPort->IsDataStream() ) {
1647 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1648 << " " << anOutPort->Kind() << endl ;
1649 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1650 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1654 else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1656 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1657 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1658 cdebug << "ComputingNode::SavePY Node " << Name() << " InPort " << anInPort->PortName()
1659 << " " << anInPort->Kind() << endl ;
1660 // if ( anInPort->IsGate() || ( anInPort->IsInLine() && IsMacroNode() ) ) {
1661 if ( anInPort->IsGate() || IsMacroNode() ) {
1662 f << " " << "I" << Name() << anInPort->PortName() << " = "
1663 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1665 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1666 f << " " << "I" << Name() << anInPort->PortName() << " = "
1667 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1668 << anInPort->PortType() << "' )" << endl ;
1671 cdebug << "Ignored " << Name() << " " << anInPort->PortName() << " " << anInPort->PortStatus() << endl ;
1672 // f << " " << "I" << Name() << anInPort->PortName() << " = "
1673 // << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1676 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1677 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1678 cdebug << "ComputingNode::SavePY Node " << Name() << " OutPort " << anOutPort->PortName()
1679 << " " << anOutPort->Kind() << endl ;
1680 // if ( anOutPort->IsGate() || ( anOutPort->IsInLine() && IsMacroNode() ) ) {
1681 if ( anOutPort->IsGate() || IsMacroNode() ) {
1682 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1683 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1685 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1686 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1687 << Name() << ".OutPort( '" << anOutPort->PortName()
1688 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1691 cdebug << "Ignored " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << endl ;
1692 // f << " " << "O" << Name() << anOutPort->PortName() << " = "
1693 // << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1697 if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1699 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1700 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1701 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1702 << " " << anInPort->Kind() << endl ;
1703 if ( anInPort->IsDataStream() ) {
1704 if ( IsOneOfInLineNodes() ) {
1705 f << " " << "I" << Name() << anInPort->PortName() << " = "
1706 << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1707 << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1708 << anInPort->Dependency() << " )" << endl ;
1711 f << " " << "I" << Name() << anInPort->PortName() << " = "
1712 << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1714 SUPERV::KindOfSchema aKindOfSchema ;
1715 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1716 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1717 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1718 f << " " << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1719 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1722 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1723 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1724 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1725 << " " << anOutPort->Kind() << endl ;
1726 if ( anOutPort->IsDataStream() ) {
1727 if ( IsOneOfInLineNodes() ) {
1728 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1729 << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1730 << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1731 << anOutPort->Dependency() << " )" << endl ;
1734 f << " " << "O" << Name() << anOutPort->PortName() << " = "
1735 << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1737 long aNumberOfValues ;
1738 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1739 f << " " << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1745 cdebug_out << "ComputingNode::SavePY " ;
1746 NodeInfo( *_fdebug ) ;
1751 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1753 ListPorts( s , true ) ;
1757 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1758 // f << "ComponentName " << G.ComponentName() << endl ;
1759 if ( G.IsComputingNode() ) {
1760 f << "NodeName " << G.Name() << endl ;
1763 f << "DataFlowName " << G.Name() << endl ;
1765 f << "Kind " << G.Kind() << endl ;
1766 f << "Service " << *G.GetService() ;
1767 f << "FirstCreation " << G.FirstCreation () << endl ;
1768 f << "LastModification " << G.LastModification() << endl ;
1769 f << "EditorRelease " << G.EditorRelease() << endl ;
1770 f << "Author " << G.Author() << endl ;
1771 // f << "Computer " << G.Computer() << endl ;
1772 f << "Comment " << G.Comment() << endl ;
1778 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1780 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1781 const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1782 if ( fromPort->IsPortConnected() ) {
1784 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1786 f << "FromNode " << Name() << endl ;
1788 f << " FromServiceParameterName "
1789 << fromPort->GetServicesParameter().Parametername ;
1790 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1791 f << " ToNode " << toPort->NodeName() ;
1792 f << " ToServiceParameterName "
1793 << toPort->GetServicesParameter().Parametername;
1795 fromPort->StringValue( f ) ;
1802 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1803 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1805 fOut << D.Day << "/"
1812 // cdebug_out << "operator<< GraphEditor::Date" << endl;