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 = SUPERV::CNode::_nil() ;
87 _ThreadNo = pthread_self() ;
88 cdebug << "GraphBase::Node::Node " << this << " " << endl ;
92 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
93 SALOME_NamingService* ptrNamingService ,
94 const char * aDataFlowName ,
95 int * Graph_prof_debug ,
96 ofstream * Graph_fdebug ) :
97 // GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) {
98 GraphBase::StreamNode::StreamNode( aDataFlowName ) {
100 // MESSAGE( "GraphBase::ComputingNode::ComputingNode " << aDataFlowName << " Graph_prof_debug " << Graph_prof_debug ) ;
101 InitFields( //_Kind ,
109 //_DataStreamInPortsNumber ,
110 //_DataStreamOutPortsNumber ,
111 _ConnectedInPortsNumber ,
112 _DecrConnectedInPortsNumber ) ;
114 //_SubGraphNumber ) ;
116 Kind( SUPERV::DataFlowGraph ) ;
117 _ORB = CORBA::ORB::_duplicate( ORB ) ;
118 _NamingService = ptrNamingService ;
119 _Node = SUPERV::CNode::_nil() ;
121 _ThreadNo = pthread_self() ;
123 if ( Graph_prof_debug ) {
124 // MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug" ) ;
125 // cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug" << endl ;
126 _Graph_prof_debug = Graph_prof_debug ;
127 _Graph_fdebug = Graph_fdebug ;
128 SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
131 // cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ;
133 cdebug << "GraphBase::ComputingNode::ComputingNode " << this
134 << " Name '" << Name() << "' " << _FirstCreation
135 << " " << _LastModification << endl ;
138 GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB ,
139 SALOME_NamingService* ptrNamingService ,
140 const SALOME_ModuleCatalog::Service& aService ,
141 const char *NodeName ,
142 const SUPERV::KindOfNode akind ,
143 const SUPERV::SDate NodeFirstCreation ,
144 const SUPERV::SDate NodeLastModification ,
145 const char * NodeEditorRelease ,
146 const char * NodeAuthor ,
147 const char * NodeComment ,
148 const bool GeneratedName ,
151 int * Graph_prof_debug ,
152 ofstream * Graph_fdebug ) :
153 // GraphBase::PortsOfNode::PortsOfNode() {
154 GraphBase::StreamNode::StreamNode( NodeName ) {
156 _ORB = CORBA::ORB::_duplicate( ORB ) ;
157 _NamingService = ptrNamingService ;
158 _Node = SUPERV::CNode::_nil() ;
160 _ThreadNo = pthread_self() ;
165 time_t T = time(NULL);
166 struct tm * Tm = localtime(&T);
168 _FirstCreation.Second = _LastModification.Second = Tm->tm_sec;
169 _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min;
170 _FirstCreation.Hour = _LastModification.Hour = Tm->tm_hour;
171 _FirstCreation.Day = _LastModification.Day = Tm->tm_mday;
172 _FirstCreation.Month = _LastModification.Month = Tm->tm_mon + 1;
173 _FirstCreation.Year = _LastModification.Year = Tm->tm_year + 1900;
175 if ( NodeEditorRelease != NULLSTRING ) {
176 _EditorRelease = new char[ strlen( NodeEditorRelease ) + 1 ] ;
177 strcpy( _EditorRelease , NodeEditorRelease ) ;
180 _EditorRelease = new char[ strlen( SuperVision_Version ) + 1 ] ;
181 strcpy( _EditorRelease , SuperVision_Version ) ;
184 if ( NodeAuthor != NULLSTRING ) {
185 _Author = new char[ strlen( NodeAuthor ) + 1 ] ;
186 strcpy( _Author , NodeAuthor ) ;
189 _Author = NULLSTRING ;
192 if ( NodeComment != NULLSTRING ) {
193 _Comment = new char[ strlen( NodeComment ) + 1 ] ;
194 strcpy( _Comment , NodeComment ) ;
197 _Comment = NULLSTRING ;
200 // _SubGraphNumber = 0 ;
201 // _HeadNode = false ;
202 _GeneratedName = GeneratedName ;
204 // const char *aNodeName = NodeName ;
205 // _Name = new char[strlen(aNodeName)+1];
206 // strcpy(_Name , aNodeName);
208 // _DataStreamInPortsNumber = 0 ;
209 // _DataStreamOutPortsNumber = 0 ;
211 _ConnectedInPortsNumber = 0 ;
212 _DecrConnectedInPortsNumber = 0 ;
213 // _LinkedNodesSize = 0 ;
218 _Graph_prof_debug = Graph_prof_debug ;
219 _Graph_fdebug = Graph_fdebug ;
220 // MESSAGE( "GraphBase::ComputingNode::ComputingNode " << NodeName
221 // << " _Graph_prof_debug " << _Graph_prof_debug ) ;
222 SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
223 cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << NodeName << ","
224 << akind << ")" << endl;
227 DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ;
228 cdebug << "GraphBase::ComputingNode::ComputingNode " << this
229 << " Name '" << Name()
230 << "' KindOfNode " << Kind()
231 << " ServiceName '" << ServiceName() << "' In(" << ServiceInParameter().length()
232 << ") Out(" << ServiceOutParameter().length() << ")" << endl ;
234 cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl;
237 GraphBase::ComputingNode::~ComputingNode() {
238 cdebug << "GraphBase::ComputingNode::~ComputingNode " << this
239 << " Name() "<< Name() << " _Comment "
240 << (void *) _Comment << " " << _Comment << " " << endl ;
243 //->StreamNode bool GraphBase::ComputingNode::Name( const char * aName) {
244 //->StreamNode cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl;
245 //->StreamNode if ( _Name ) {
246 //->StreamNode cdebug << "GraphBase::ComputingNode::ReName " << _Name << " --> " << aName << endl ;
247 //->StreamNode delete [] _Name ;
249 //->StreamNode _Name = new char[strlen(aName)+1] ;
250 //->StreamNode strcpy( _Name , aName ) ;
251 //->StreamNode cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl;
252 //->StreamNode return true ;
255 SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const {
256 // cdebug << "GraphBase::ComputingNode::FirstCreation "
257 // << " Name '" << Name() << "' " << _FirstCreation << " "
258 // << _LastModification << endl ;
259 return _FirstCreation;
262 SUPERV::SDate GraphBase::ComputingNode::LastModification () const {
263 return _LastModification ;
266 void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) {
267 _FirstCreation = aDate ;
270 void GraphBase::ComputingNode::LastModification(const SUPERV::SDate aDate ) {
271 _LastModification = aDate ;
274 bool GraphBase::ComputingNode::EditorRelease(const char * c){
275 if ( _EditorRelease && _EditorRelease != NULLSTRING )
276 delete _EditorRelease;
277 _EditorRelease = my_strdup(c);
281 bool GraphBase::ComputingNode::Author(const char * a) {
282 cdebug_in << "GraphBase::ComputingNode::Author " << _Author << endl;
283 if ( _Author && _Author != NULLSTRING )
285 _Author = my_strdup(a);
286 cdebug_out << "GraphBase::ComputingNode::Author " << _Author << endl;
290 bool GraphBase::ComputingNode::Comment(const char *c) {
291 cdebug_in << "GraphBase::ComputingNode::Comment " << _Comment << endl;
292 if ( _Comment != NULLSTRING )
294 _Comment = my_strdup(c);
295 cdebug_out << "GraphBase::ComputingNode::Comment " << _Comment << endl;
299 void GraphBase::ComputingNode::NodePort( const char * NodeName ,
300 const char * ServiceParameterName ,
301 char ** aNode , char ** aPort ) {
302 if ( strcmp( NodeName , Name() ) ) {
303 *aNode = my_strdup( NodeName ) ;
304 *aPort = my_strdup( ServiceParameterName ) ;
307 char * BPort = strchr( ServiceParameterName , '\\' ) ;
309 int len = BPort - ServiceParameterName ;
310 *aNode = new char [ len + 1 ] ;
311 strncpy( *aNode , ServiceParameterName , len ) ;
312 (*aNode)[ len ] = '\0' ;
313 *aPort = my_strdup( &BPort[ 1 ] ) ;
316 *aNode = my_strdup( NULLSTRING ) ;
317 *aPort = my_strdup( NULLSTRING ) ;
322 bool GraphBase::ComputingNode::IsLinked(const char * ToServiceParameterName ) {
323 bool RetVal = false ;
324 const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
326 RetVal = thePort->IsConnected() ;
329 const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
331 RetVal = thePort->IsConnected() ;
337 bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) {
338 bool RetVal = false ;
339 const GraphBase::InPort * thePort = GetInPort( ToServiceParameterName ) ;
340 if ( IsDataFlowNode() && thePort ) {
343 else if ( thePort ) {
344 // cout << "GraphBase::ComputingNode::HasInput theInPort " << thePort << " " << thePort->PortName() << " of "
345 // << thePort->NodeName() << " IsDataConnected " << thePort->IsDataConnected() << " OutPort "
346 // << thePort->GetOutPort() << endl ;
347 RetVal = thePort->IsDataConnected() ;
350 const GraphBase::OutPort * thePort = GetOutPort( ToServiceParameterName ) ;
352 RetVal = thePort->IsDataConnected() ;
358 GraphBase::SNode * GraphBase::ComputingNode::GetInfo() {
359 cdebug_in << "GraphBase::ComputingNode::GetInfo" << endl;
360 GraphBase::SNode * Info = new GraphBase::SNode ;
361 // Info->theComponentName = ComponentName() ;
362 // Info->theInterfaceName = InterfaceName() ;
363 Info->theName = Name() ;
364 Info->theKind = Kind() ;
365 if ( IsDataStreamNode() ) {
367 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
369 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
370 Info->theTimeout = Timeout ;
371 Info->theDataStreamTrace = DataStreamTrace ;
372 Info->theDeltaTime = DeltaTime ;
374 Info->theService = *GetService() ;
375 // Info->theListOfParameters = *GetListOfParameters() ;
376 Info->theFirstCreation = FirstCreation() ;
377 Info->theLastModification = LastModification() ;
378 Info->theEditorRelease = EditorRelease() ;
379 Info->theAuthor = Author() ;
380 // Info->theContainer = Computer() ;
381 Info->theComment = Comment() ;
382 Info->theCoords.theX = GraphBase::ComputingNode::XCoordinate() ;
383 Info->theCoords.theY = GraphBase::ComputingNode::YCoordinate() ;
384 cdebug_out << "GraphBase::ComputingNode::GetInfo" << endl;
388 void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) {
389 GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
391 void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) {
392 GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
395 GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName ,
396 const char * InputParameterType ,
397 const SUPERV::KindOfPort aKindOfPort ) {
398 cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
399 return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
404 // DataStreamInPortsNumber() ,
405 _Graph_prof_debug , _Graph_fdebug ) ;
407 GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName ,
408 const char * OutputParameterType ,
409 const SUPERV::KindOfPort aKindOfPort ) {
410 cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ;
411 return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
413 OutputParameterName ,
414 OutputParameterType ,
416 // DataStreamOutPortsNumber() ,
417 _Graph_prof_debug , _Graph_fdebug ) ;
420 void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) {
421 GraphBase::PortsOfNode::DelInPort( InputParameterName ) ;
423 void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) {
424 GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ;
427 GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName ,
428 const SALOME_ModuleCatalog::DataStreamType InputParameterType ,
429 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
430 const SUPERV::KindOfPort aKindOfPort ) {
431 // IncrDataStreamInPorts() ;
432 GraphBase::InDataStreamPort * aDataStreamPort ;
433 aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() ,
436 DataStreamTypeToString( InputParameterType ).c_str() ,
438 // DataStreamInPortsNumber() ,
439 _Graph_prof_debug , _Graph_fdebug ) ;
440 aDataStreamPort->Dependency( aDependency ) ;
441 if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) {
442 aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ;
444 return aDataStreamPort ;
446 GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName ,
447 const SALOME_ModuleCatalog::DataStreamType OutputParameterType ,
448 const SALOME_ModuleCatalog::DataStreamDependency aDependency ,
449 const SUPERV::KindOfPort aKindOfPort ) {
450 // IncrDataStreamOutPorts() ;
451 GraphBase::OutDataStreamPort * aDataStreamPort ;
452 aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() ,
454 OutputParameterName ,
455 DataStreamTypeToString( OutputParameterType ).c_str() ,
457 // DataStreamOutPortsNumber() ,
458 _Graph_prof_debug , _Graph_fdebug ) ;
459 aDataStreamPort->Dependency( aDependency ) ;
460 return aDataStreamPort ;
464 #include <sys/time.h>
465 #include <sys/resource.h>
468 const long GraphBase::ComputingNode::CpuUsed() {
469 struct rusage usage ;
470 if ( getrusage( RUSAGE_SELF , &usage ) == -1 ) {
471 perror("GraphBase::CpuUsed") ;
474 // return usage.ru_utime.__time_t tv_sec ;
475 cdebug << "CpuUsed " << usage.ru_utime.tv_sec << " " << usage.ru_utime.tv_usec << " "
476 << usage.ru_stime.tv_sec << " " << usage.ru_stime.tv_usec << endl ;
477 return usage.ru_utime.tv_sec ;
481 const GraphBase::ListOfParameters * GraphBase::ComputingNode::GetListOfParameters() const {
482 GraphBase::ListOfParameters * aListOfParameters = new GraphBase::ListOfParameters ;
483 if ( IsInLineNode() || IsGOTONode() ) {
485 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
486 const InPort * anInPort = GetNodeInPort( i ) ;
487 if ( anInPort->IsBus() ) {
488 int size = aListOfParameters->size() ;
489 aListOfParameters->resize( size + 1 ) ;
490 (*aListOfParameters)[size].theInParameter.Parametername = anInPort->PortName() ;
491 (*aListOfParameters)[size].theInParameter.Parametertype = anInPort->PortType() ;
492 const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ;
493 (*aListOfParameters)[size].theOutParameter.Parametername = anOutPort->PortName() ;
494 (*aListOfParameters)[size].theOutParameter.Parametertype = anOutPort->PortType() ;
498 return aListOfParameters ;
502 bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & info ,
503 const char * ComponentName ,
504 const char * InterfaceName ,
505 const char * Computer ,
506 const char * CoupledNode ,
507 const ListOfFuncName FuncNames ,
508 const ListOfPythonFunctions PythonFunctions ,
509 int XCoordinate , int YCoordinate ) const {
510 cdebug_in << "SaveXML Node " << Name() << endl ;
511 QDomElement node = Graph.createElement( "node" ) ;
512 info.appendChild( node ) ;
513 QDomElement componentname = Graph.createElement( "component-name" ) ;
515 if ( strlen( ComponentName ) ) {
516 // f << Tabs << "<component-name>" << ComponentName << "</component-name>"
518 // componentname.setNodeValue( ComponentName ) ;
519 aField = Graph.createTextNode( ComponentName ) ;
522 // f << Tabs << "<component-name>?</component-name>" << endl ;
523 // componentname.setNodeValue( "?" ) ;
524 aField = Graph.createTextNode( "?" ) ;
526 node.appendChild( componentname ) ;
527 componentname.appendChild( aField ) ;
529 QDomElement interfacename = Graph.createElement("interface-name") ;
530 if ( strlen( InterfaceName ) ) {
531 // f << Tabs << "<interface-name>" << InterfaceName << "</interface-name>"
533 // interfacename.setAttribute("name" , InterfaceName ) ;
534 aField = Graph.createTextNode( InterfaceName ) ;
537 // f << Tabs << "<interface-name>?</interface-name>" << endl ;
538 // interfacename.setAttribute("name" , "?" ) ;
539 aField = Graph.createTextNode( "?" ) ;
541 node.appendChild(interfacename) ;
542 interfacename.appendChild( aField ) ;
544 // f << Tabs << "<node-name>" << Name() << "</node-name>" << endl ;
545 QDomElement nodename = Graph.createElement("node-name") ;
546 aField = Graph.createTextNode( Name() ) ;
547 node.appendChild( nodename ) ;
548 nodename.appendChild( aField ) ;
550 // f << Tabs << "<kind>" << (int ) Kind() << "</kind>" << endl ;
551 QDomElement kind = Graph.createElement( "kind" ) ;
554 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
555 // JR : the bug was at line 566 : && HasDataStream() != 0 was missing
556 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
557 aKind = aKind.setNum( SUPERV::DataFlowGraph ) ;
560 aKind = aKind.setNum( Kind() ) ;
562 aField = Graph.createTextNode( aKind ) ;
563 node.appendChild( kind ) ;
564 kind.appendChild( aField ) ;
566 if ( IsDataStreamNode() && HasDataStream() != 0 ) {
568 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
570 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
572 QDomElement timeout = Graph.createElement("streamgraph-timeout") ;
574 aTimeout = aTimeout.setNum( Timeout ) ;
575 aField = Graph.createTextNode( aTimeout ) ;
576 node.appendChild( timeout ) ;
577 timeout.appendChild( aField ) ;
579 QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ;
580 QString aDataStreamTrace ;
581 aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ;
582 aField = Graph.createTextNode( aDataStreamTrace ) ;
583 node.appendChild( datastreamtrace ) ;
584 datastreamtrace.appendChild( aField ) ;
586 QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ;
588 aDeltaTime = aDeltaTime.setNum( DeltaTime ) ;
589 aField = Graph.createTextNode( aDeltaTime ) ;
590 node.appendChild( deltatime ) ;
591 deltatime.appendChild( aField ) ;
594 QDomElement couplednode = Graph.createElement("coupled-node") ;
595 if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() ||
596 IsSwitchNode() || IsEndSwitchNode() ) {
597 // f << Tabs << "<coupled-node>" << CoupledNode << "</coupled-node>"
599 aField = Graph.createTextNode( CoupledNode ) ;
602 // f << Tabs << "<coupled-node>?</coupled-node>" << endl ;
603 aField = Graph.createTextNode( "?" ) ;
605 node.appendChild(couplednode) ;
606 couplednode.appendChild( aField ) ;
608 // f << Tabs << "<service>" << endl ;
609 QDomElement service = Graph.createElement("service") ;
610 node.appendChild(service) ;
611 QDomElement servicename = Graph.createElement("service-name") ;
612 if ( strlen( ServiceName() ) ) {
613 // f << Tabs << " <service-name>" << ServiceName() << "</service-name>" << endl ;
614 aField = Graph.createTextNode( ServiceName() ) ;
617 // f << Tabs << " <service-name>?</service-name>" << endl ;
618 aField = Graph.createTextNode( "?" ) ;
620 service.appendChild(servicename) ;
621 servicename.appendChild( aField ) ;
623 QDomElement inParameterlist = Graph.createElement("inParameter-list") ;
624 service.appendChild(inParameterlist) ;
626 GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ;
627 for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
628 const GraphBase::InPort * anInPort ;
629 anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ;
630 if ( !anInPort->IsDataStream() ) {
631 cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername
632 << " InParameterPort " << anInPort->Kind() << endl ;
633 QDomElement inParameter = Graph.createElement("inParameter") ;
634 inParameterlist.appendChild(inParameter) ;
635 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
636 if ( strlen( ServiceInParameter()[i].Parametertype ) ) {
637 aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ;
640 aField = Graph.createTextNode( "?" ) ;
642 inParameter.appendChild(inParametertype) ;
643 inParametertype.appendChild( aField ) ;
644 QDomElement inParametername = Graph.createElement("inParameter-name") ;
645 if ( strlen( ServiceInParameter()[i].Parametername ) ) {
646 aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ;
649 aField = Graph.createTextNode( "?" ) ;
651 inParameter.appendChild(inParametername) ;
652 inParametername.appendChild( aField ) ;
655 QDomElement outParameterlist = Graph.createElement("outParameter-list") ;
656 service.appendChild(outParameterlist) ;
657 for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) {
658 const GraphBase::OutPort * anOutPort ;
659 anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ;
660 if ( !anOutPort->IsDataStream() ) {
661 cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername
662 << " OutParameterPort " << anOutPort->Kind() << endl ;
663 QDomElement outParameter = Graph.createElement("outParameter") ;
664 outParameterlist.appendChild(outParameter) ;
665 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
666 if ( strlen( ServiceOutParameter()[i].Parametertype ) ) {
667 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ;
670 aField = Graph.createTextNode( "?" ) ;
672 outParameter.appendChild(outParametertype) ;
673 outParametertype.appendChild( aField ) ;
674 QDomElement outParametername = Graph.createElement("outParameter-name") ;
675 if ( strlen( ServiceOutParameter()[i].Parametername ) ) {
676 aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ;
679 aField = Graph.createTextNode( "?" ) ;
681 outParameter.appendChild(outParametername) ;
682 outParametername.appendChild( aField ) ;
686 QDomElement DataStreamlist = Graph.createElement("DataStream-list") ;
687 node.appendChild( DataStreamlist ) ;
688 for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) {
689 const GraphBase::InPort * anInPort ;
690 anInPort = aNode->GetNodeInPort( i ) ;
691 if ( anInPort->IsDataStream() ) {
692 cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType()
693 << " InDataStreamPort " << anInPort->Kind() << endl ;
694 QDomElement inParameter = Graph.createElement("inParameter") ;
695 DataStreamlist.appendChild(inParameter) ;
696 QDomElement inParametertype = Graph.createElement("inParameter-type") ;
698 aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ;
699 cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() )
700 << " " << aType << endl ;
701 aField = Graph.createTextNode( aType ) ;
702 inParameter.appendChild(inParametertype) ;
703 inParametertype.appendChild( aField ) ;
704 QDomElement inParametername = Graph.createElement("inParameter-name") ;
705 if ( strlen( anInPort->PortName() ) ) {
706 aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ;
709 aField = Graph.createTextNode( "?" ) ;
711 inParameter.appendChild(inParametername) ;
712 inParametername.appendChild( aField ) ;
713 cdebug << "SaveXML " << anInPort->PortName() << endl ;
714 QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ;
715 QString aDependency ;
716 aDependency = aDependency.setNum( anInPort->Dependency() ) ;
717 aField = Graph.createTextNode( aDependency ) ;
718 inParameter.appendChild(inParameterdependency) ;
719 inParameterdependency.appendChild( aField ) ;
720 cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ;
721 SUPERV::KindOfSchema aKindOfSchema ;
722 SUPERV::KindOfInterpolation aKindOfInterpolation ;
723 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
724 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
725 QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ;
727 aSchema = aSchema.setNum( aKindOfSchema ) ;
728 aField = Graph.createTextNode( aSchema ) ;
729 inParameter.appendChild(inParameterKindOfSchema) ;
730 inParameterKindOfSchema.appendChild( aField ) ;
731 cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ;
732 QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ;
733 QString anInterpolation ;
734 anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ;
735 aField = Graph.createTextNode( anInterpolation ) ;
736 inParameter.appendChild(inParameterKindOfInterpolation) ;
737 inParameterKindOfInterpolation.appendChild( aField ) ;
738 cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ;
739 QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ;
740 QString anExtrapolation ;
741 anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ;
742 aField = Graph.createTextNode( anExtrapolation ) ;
743 inParameter.appendChild(inParameterKindOfExtrapolation) ;
744 inParameterKindOfExtrapolation.appendChild( aField ) ;
745 cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ;
748 for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) {
749 const GraphBase::OutPort * anOutPort ;
750 anOutPort = aNode->GetNodeOutPort( i ) ;
751 if ( anOutPort->IsDataStream() ) {
752 cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType()
753 << " OutDataStreamPort " << anOutPort->Kind() << endl ;
754 QDomElement outParameter = Graph.createElement("outParameter") ;
755 DataStreamlist.appendChild(outParameter) ;
756 QDomElement outParametertype = Graph.createElement("outParameter-type") ;
758 aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ;
759 cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() )
760 << " " << aType << endl ;
761 aField = Graph.createTextNode( aType ) ;
762 outParameter.appendChild(outParametertype) ;
763 outParametertype.appendChild( aField ) ;
764 QDomElement outParametername = Graph.createElement("outParameter-name") ;
765 if ( strlen( anOutPort->PortName() ) ) {
766 aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ;
769 aField = Graph.createTextNode( "?" ) ;
771 outParameter.appendChild(outParametername) ;
772 outParametername.appendChild( aField ) ;
773 cdebug << "SaveXML " << anOutPort->PortName() << endl ;
774 QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ;
775 QString aDependency ;
776 aDependency = aDependency.setNum( anOutPort->Dependency() ) ;
777 aField = Graph.createTextNode( aDependency ) ;
778 outParameter.appendChild(outParameterdependency) ;
779 outParameterdependency.appendChild( aField ) ;
780 cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ;
781 long aNumberOfValues ;
782 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
783 QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ;
785 aValues = aValues.setNum( aNumberOfValues ) ;
786 aField = Graph.createTextNode( aValues ) ;
787 outParameter.appendChild(outParameterNumberOfValues) ;
788 outParameterNumberOfValues.appendChild( aField ) ;
789 cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ;
792 // f << Tabs << "</Parameter-list>" << endl ;
794 // f << Tabs << "<PyFunction-list>" << endl ;
795 QDomElement PyFunctionlist = Graph.createElement("PyFunction-list") ;
796 node.appendChild( PyFunctionlist ) ;
797 for ( i = 0 ; i < PythonFunctions.size() ; i++ ) {
798 // f << Tabs << " <PyFunction>" << endl ;
799 QDomElement PyFunction = Graph.createElement("PyFunction") ;
800 PyFunctionlist.appendChild( PyFunction ) ;
802 QDomElement FuncName = Graph.createElement("FuncName") ;
803 if ( strlen( FuncNames[i].c_str() ) ) {
804 aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
807 aField = Graph.createTextNode( "?" ) ;
809 PyFunction.appendChild( FuncName ) ;
810 FuncName.appendChild( aField ) ;
811 if ( (*PythonFunctions[i]).length() ) {
812 for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
813 QDomElement PyFunc = Graph.createElement("PyFunc") ;
814 QDomCDATASection aCDATA ;
815 // mpv: Linux 8.0 compiler compatibility
816 char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
818 for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
819 if ( aCDATAChar[ i ] != ' ' ) {
823 if ( i == (int ) strlen( aCDATAChar ) ) {
824 aCDATA = Graph.createCDATASection( "?" ) ;
827 aCDATA = Graph.createCDATASection( aCDATAChar ) ;
829 PyFunction.appendChild( PyFunc ) ;
830 PyFunc.appendChild( aCDATA ) ;
834 QDomElement PyFunc = Graph.createElement("PyFunc") ;
835 QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
836 PyFunction.appendChild( PyFunc ) ;
837 PyFunc.appendChild( aCDATA ) ;
841 // f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
843 QDomElement creationdate = Graph.createElement("creation-date") ;
845 sprintf( fdate , "%d/%d/%d - %d:%d:%d" , FirstCreation().Day , FirstCreation().Month , FirstCreation().Year , FirstCreation().Hour , FirstCreation().Minute , FirstCreation().Second ) ;
846 aField = Graph.createTextNode( fdate ) ;
847 node.appendChild( creationdate ) ;
848 creationdate.appendChild( aField ) ;
849 // f << Tabs << "<lastmodification-date>" << LastModification()
850 // << "</lastmodification-date>" << endl ;
851 QDomElement lastmodificationdate = Graph.createElement("lastmodification-date") ;
853 sprintf( ldate , "%d/%d/%d - %d:%d:%d" , LastModification().Day , LastModification().Month , LastModification().Year , LastModification().Hour , LastModification().Minute , LastModification().Second ) ;
854 aField = Graph.createTextNode( ldate ) ;
855 node.appendChild( lastmodificationdate ) ;
856 lastmodificationdate.appendChild( aField ) ;
857 // f << Tabs << "<editor-release>" << EditorRelease() << "</editor-release>"
859 QDomElement editorrelease = Graph.createElement("editor-release") ;
860 aField = Graph.createTextNode( EditorRelease() ) ;
861 node.appendChild( editorrelease ) ;
862 editorrelease.appendChild( aField ) ;
863 QDomElement author = Graph.createElement("author") ;
864 if ( strlen( Author() ) ) {
865 // f << Tabs << "<author>" << Author() << "</author>" << endl ;
866 aField = Graph.createTextNode( Author() ) ;
869 // f << Tabs << "<author>?</author>" << endl ;
870 aField = Graph.createTextNode( "?" ) ;
872 node.appendChild( author ) ;
873 author.appendChild( aField ) ;
874 QDomElement container = Graph.createElement("container") ;
875 if ( IsFactoryNode() && strlen( Computer) ) {
876 // f << Tabs << "<container>" << Computer << "</container>" << endl ;
877 aField = Graph.createTextNode( Computer ) ;
880 // f << Tabs << "<container>?</container>" << endl ;
881 aField = Graph.createTextNode( "?" ) ;
883 node.appendChild( container ) ;
884 container.appendChild( aField ) ;
885 QDomElement comment = Graph.createElement("comment") ;
886 if ( strlen( Comment() ) ) {
887 // f << Tabs << "<comment>" << Comment() << "</comment>" << endl ;
888 aField = Graph.createTextNode( Comment() ) ;
891 // f << Tabs << "<comment>?</comment>" << endl ;
892 aField = Graph.createTextNode( "?" ) ;
894 node.appendChild( comment ) ;
895 comment.appendChild( aField ) ;
896 // f << Tabs << "<x-position>" << XCoordinate << "</x-position>" << endl ;
897 QDomElement xposition = Graph.createElement("x-position") ;
898 QString aXCoordinate ;
899 aXCoordinate = aKind.setNum( XCoordinate ) ;
900 aField = Graph.createTextNode( aXCoordinate ) ;
901 node.appendChild( xposition ) ;
902 xposition.appendChild( aField ) ;
903 // f << Tabs << "<y-position>" << YCoordinate << "</y-position>" << endl ;
904 QDomElement yposition = Graph.createElement("y-position") ;
905 QString aYCoordinate ;
906 aYCoordinate = aKind.setNum( YCoordinate ) ;
907 aField = Graph.createTextNode( aYCoordinate ) ;
908 node.appendChild( yposition ) ;
909 yposition.appendChild( aField ) ;
910 cdebug_out << "SaveXML Node " << Name() << endl ;
914 bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
915 const char * ComponentName ,
916 const char * InterfaceName ,
917 const char * Computer ,
918 const GraphBase::InLineNode * aCoupledNode ,
919 const ListOfFuncName FuncNames ,
920 const ListOfPythonFunctions PythonFunctions ,
921 int XCoordinate , int YCoordinate ) const {
922 // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph
923 // JR : the bug was at line 927 : && HasDataStream() != 0 was missing
924 if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) {
925 f << Name() << " = Graph( '" << Name() << "' )" << endl ;
927 else if ( IsDataStreamNode() && HasDataStream() != 0 ) {
928 f << Name() << " = StreamGraph( '" << Name() << "' )" << endl ;
930 SUPERV::KindOfDataStreamTrace DataStreamTrace ;
932 ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ;
933 f << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace
934 << " , " << DeltaTime << " )" << endl ;
936 else if ( IsComputingNode() ) {
938 f << Name() << "_ServiceinParameter = []" << endl ;
939 for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
940 f << Name() << "_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
941 << ServiceInParameter()[i].Parametertype << "' , '"
942 << ServiceInParameter()[i].Parametername << "' ) )" << endl ;
944 f << Name() << "_ServiceoutParameter = []" << endl ;
945 for ( i = 0 ; i < (int ) ServiceOutParameter().length() ; i++ ) {
946 f << Name() << "_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( '"
947 << ServiceOutParameter()[i].Parametertype << "' , '"
948 << ServiceOutParameter()[i].Parametername << "' ) )" << endl ;
950 f << Name() << "_ServiceinStreamParameter = []" << endl ;
951 for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) {
952 f << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
953 << ServiceInStreamParameter()[i].Parametertype << " , '"
954 << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
955 << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ;
957 f << Name() << "_ServiceoutStreamParameter = []" << endl ;
958 for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) {
959 f << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog."
960 << ServiceOutStreamParameter()[i].Parametertype << " , '"
961 << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog."
962 << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ;
964 f << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName()
965 << "' , " << Name() << "_ServiceinParameter"
966 << " , " << Name() << "_ServiceoutParameter"
967 << " , " << Name() << "_ServiceinStreamParameter"
968 << " , " << Name() << "_ServiceoutStreamParameter"
969 << " , 0 , 0 )" << endl ;
970 f << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )"
973 else if ( IsFactoryNode() ) {
974 f << Name() << " = " << aGraphName << ".FNode( '" << ComponentName
975 << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )"
978 else if ( IsEndLoopNode() || IsEndSwitchNode() ) {
979 // It is done with LoopNode or SwitchNode with CoupledNode()
982 f << "Py" << Name() << " = []" << endl ;
984 SUPERV::ListOfStrings aPyFunc ;
985 if ( PythonFunctions.size() ) {
986 aPyFunc = *PythonFunctions[0] ;
987 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
988 f << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
991 if ( IsInLineNode() ) {
992 f << Name() << " = " << aGraphName << ".INode( '" << FuncNames[0].c_str() << "' , Py"
993 << Name() << " )" << endl ;
995 else if ( IsGOTONode() ) {
996 if ( aCoupledNode ) {
997 f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
998 << Name() << " , '" << aCoupledNode->Name() << "' )" << endl ;
1001 f << Name() << " = " << aGraphName << ".GNode( '" << FuncNames[0].c_str() << "' , Py"
1002 << Name() << " , '' )" << endl ;
1006 // char * EndName = NULL ;
1007 // EndName = new char[ 3 + strlen( Name() ) + 1 ] ;
1008 // strcpy( EndName , "End" ) ;
1009 // strcat( EndName , Name() ) ;
1010 char * EndName = aCoupledNode->Name() ;
1011 if ( IsLoopNode() ) {
1013 SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
1014 SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
1015 f << "PyMore" << Name() << " = []" << endl ;
1016 for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
1017 f << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
1019 f << "PyNext" << Name() << " = []" << endl ;
1020 for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
1021 f << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
1023 f << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
1024 << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
1025 << FuncNames[1].c_str() << "' , PyMore" << Name()
1026 << " , '" << FuncNames[2].c_str() << "' , PyNext"
1027 << Name() << " )" << endl ;
1028 f << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1029 f << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1030 f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1031 f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1032 << aCoupledNode->YCoordinate() << " )" << endl ;
1033 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1034 f << "Py" << aCoupledNode->Name() << " = []" << endl ;
1035 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1036 f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1039 f << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1040 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1041 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1042 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1043 << " " << anInPort->Kind() << endl ;
1044 if ( anInPort->IsLoop() ) {
1045 f << "I" << Name() << anInPort->PortName() << " = "
1046 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1048 else if ( anInPort->IsInLine() ) {
1049 f << "I" << Name() << anInPort->PortName() << " = "
1050 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1051 << anInPort->PortType() << "' )" << endl ;
1053 else if ( anInPort->IsDataStream() ) {
1054 f << "I" << Name() << anInPort->PortName() << " = " << Name()
1055 << ".InStreamPort( '" << anInPort->PortName()
1056 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1057 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1058 SUPERV::KindOfSchema aKindOfSchema ;
1059 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1060 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1061 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1062 f << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1063 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1065 else if ( anInPort->IsGate() ) {
1066 f << "I" << Name() << anInPort->PortName() << " = "
1067 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1070 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1071 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1072 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1073 << " " << anOutPort->Kind() << endl ;
1074 if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) {
1075 f << "O" << Name() << anOutPort->PortName() << " = "
1076 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1078 else if ( anOutPort->IsDataStream() ) {
1079 f << "O" << Name() << anOutPort->PortName() << " = " << Name()
1080 << ".OutStreamPort( '" << anOutPort->PortName()
1081 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1082 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1083 long aNumberOfValues ;
1084 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1085 f << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1089 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1090 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1091 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1092 << " " << anInPort->Kind() << endl ;
1093 if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) {
1094 f << "I" << EndName << anInPort->PortName() << " = " << EndName
1095 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1097 else if ( anInPort->IsDataStream() ) {
1098 f << "I" << EndName << anInPort->PortName() << " = " << EndName
1099 << ".InStreamPort( '" << anInPort->PortName()
1100 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1101 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1102 SUPERV::KindOfSchema aKindOfSchema ;
1103 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1104 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1105 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1106 f << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1107 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1110 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1111 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1112 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1113 << " " << anOutPort->Kind() << endl ;
1114 if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) {
1115 f << "O" << EndName << anOutPort->PortName() << " = " << EndName
1116 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1118 else if ( anOutPort->IsDataStream() ) {
1119 f << "O" << EndName << anOutPort->PortName() << " = " << EndName
1120 << ".OutStreamPort( '" << anOutPort->PortName()
1121 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1122 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1123 long aNumberOfValues ;
1124 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1125 f << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1130 else if ( IsSwitchNode() ) {
1131 f << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
1132 << FuncNames[0].c_str() << "' , Py" << Name() << " )" << endl ;
1133 f << EndName << ".SetName( '" << aCoupledNode->Name() << "' )" << endl ;
1134 f << EndName << ".SetAuthor( '" << aCoupledNode->Author() << "' )" << endl ;
1135 f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
1136 f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
1137 << aCoupledNode->YCoordinate() << " )" << endl ;
1138 SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
1139 f << "Py" << aCoupledNode->Name() << " = []" << endl ;
1140 for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
1141 f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
1144 f << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
1145 for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {
1146 const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ;
1147 cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName()
1148 << " " << anInPort->Kind() << endl ;
1149 // if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) {
1150 if ( anInPort->IsGate() ) {
1151 f << "I" << EndName << anInPort->PortName() << " = " << EndName
1152 << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1154 else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1155 f << "I" << EndName << anInPort->PortName() << " = " << EndName
1156 << ".InPort( '" << anInPort->PortName()
1157 << "' , '" << anInPort->PortType() << "' )" << endl ;
1159 else if ( anInPort->IsDataStream() ) {
1160 f << "I" << EndName << anInPort->PortName() << " = " << EndName
1161 << ".InStreamPort( '" << anInPort->PortName()
1162 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() )
1163 << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ;
1164 SUPERV::KindOfSchema aKindOfSchema ;
1165 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1166 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1167 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1168 f << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1169 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1172 for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) {
1173 const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ;
1174 cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName()
1175 << " " << anOutPort->Kind() << endl ;
1176 // if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) {
1177 if ( anOutPort->IsGate() ) {
1178 f << "O" << EndName << anOutPort->PortName() << " = " << EndName
1179 << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1181 else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1182 f << "O" << EndName << anOutPort->PortName() << " = " << EndName
1183 << ".OutPort( '" << anOutPort->PortName()
1184 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1186 else if ( anOutPort->IsDataStream() ) {
1187 f << "O" << EndName << anOutPort->PortName() << " = " << EndName
1188 << ".OutStreamPort( '" << anOutPort->PortName()
1189 << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() )
1190 << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ;
1191 long aNumberOfValues ;
1192 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1193 f << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )"
1202 if ( IsEndLoopNode() || IsEndSwitchNode() ) {
1203 // It is done with LoopNode or SwitchNode with CoupledNode()
1206 f << Name() << ".SetName( '" << Name() << "' )" << endl ;
1207 f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ;
1208 if ( IsFactoryNode() ) {
1209 f << Name() << ".SetContainer( '" << Computer << "' )" << endl ;
1211 f << Name() << ".SetComment( '" << Comment() << "' )" << endl ;
1212 f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ;
1214 if ( IsComputingNode() || IsFactoryNode() ) {
1216 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1217 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1218 if ( !anInPort->IsDataStream() ) {
1219 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1220 << " " << anInPort->Kind() << endl ;
1221 f << "I" << Name() << anInPort->PortName() << " = "
1222 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1225 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1226 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1227 if ( !anOutPort->IsDataStream() ) {
1228 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1229 << " " << anOutPort->Kind() << endl ;
1230 f << "O" << Name() << anOutPort->PortName() << " = "
1231 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1235 else if ( IsOneOfInLineNodes() && !IsLoopNode() ) {
1237 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1238 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1239 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1240 << " " << anInPort->Kind() << endl ;
1241 if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) {
1242 f << "I" << Name() << anInPort->PortName() << " = "
1243 << Name() << ".InPort( '" << anInPort->PortName() << "' , '"
1244 << anInPort->PortType() << "' )" << endl ;
1246 else if ( anInPort->IsGate() ) {
1247 f << "I" << Name() << anInPort->PortName() << " = "
1248 << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ;
1251 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1252 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1253 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1254 << " " << anOutPort->Kind() << endl ;
1255 if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) {
1256 f << "O" << Name() << anOutPort->PortName() << " = "
1257 << Name() << ".OutPort( '" << anOutPort->PortName()
1258 << "' , '" << anOutPort->PortType() << "' )" << endl ;
1260 else if ( anOutPort->IsGate() ) {
1261 f << "O" << Name() << anOutPort->PortName() << " = "
1262 << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ;
1266 if ( !IsDataFlowNode() && !IsDataStreamNode() ) {
1268 for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
1269 const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
1270 cdebug << "Node " << Name() << " InPort " << anInPort->PortName()
1271 << " " << anInPort->Kind() << endl ;
1272 if ( anInPort->IsDataStream() ) {
1273 if ( IsOneOfInLineNodes() ) {
1274 f << "I" << Name() << anInPort->PortName() << " = "
1275 << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog."
1276 << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog."
1277 << anInPort->Dependency() << " )" << endl ;
1280 f << "I" << Name() << anInPort->PortName() << " = "
1281 << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ;
1283 SUPERV::KindOfSchema aKindOfSchema ;
1284 SUPERV::KindOfInterpolation aKindOfInterpolation ;
1285 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
1286 ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
1287 f << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV."
1288 << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ;
1291 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1292 const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ;
1293 cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName()
1294 << " " << anOutPort->Kind() << endl ;
1295 if ( anOutPort->IsDataStream() ) {
1296 if ( IsOneOfInLineNodes() ) {
1297 f << "O" << Name() << anOutPort->PortName() << " = "
1298 << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog."
1299 << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog."
1300 << anOutPort->Dependency() << " )" << endl ;
1303 f << "O" << Name() << anOutPort->PortName() << " = "
1304 << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ;
1306 long aNumberOfValues ;
1307 aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ;
1308 f << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ;
1317 void GraphBase::ComputingNode::NodeInfo(ostream & s) const {
1319 ListPorts( s , true ) ;
1323 ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) {
1324 // f << "ComponentName " << G.ComponentName() << endl ;
1325 if ( G.IsComputingNode() ) {
1326 f << "NodeName " << G.Name() << endl ;
1329 f << "DataFlowName " << G.Name() << endl ;
1331 f << "Kind " << G.Kind() << endl ;
1332 f << "Service " << *G.GetService() ;
1333 f << "FirstCreation " << G.FirstCreation () << endl ;
1334 f << "LastModification " << G.LastModification() << endl ;
1335 f << "EditorRelease " << G.EditorRelease() << endl ;
1336 f << "Author " << G.Author() << endl ;
1337 // f << "Computer " << G.Computer() << endl ;
1338 f << "Comment " << G.Comment() << endl ;
1344 void GraphBase::ComputingNode::ListLinks(ostream &f ) const {
1346 for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
1347 const GraphBase::OutPort* fromPort = GetNodeOutPort( i ) ;
1348 if ( fromPort->IsPortConnected() ) {
1350 for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) {
1352 f << "FromNode " << Name() << endl ;
1354 f << " FromServiceParameterName "
1355 << fromPort->GetServicesParameter().Parametername ;
1356 const GraphBase::InPort* toPort = fromPort->InPorts( j ) ;
1357 f << " ToNode " << toPort->NodeName() ;
1358 f << " ToServiceParameterName "
1359 << toPort->GetServicesParameter().Parametername;
1361 fromPort->StringValue( f ) ;
1368 ostream & operator<< (ostream &fOut,const SUPERV::SDate &D) {
1369 // cdebug_in << "operator<< GraphEditor::Date" << endl;
1371 fOut << D.Day << "/"
1378 // cdebug_out << "operator<< GraphEditor::Date" << endl;