1 // SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes.
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : DataFlowBase_StreamGraph.cxx
25 // Author : Jean Rahuel
30 #include "DataFlowBase_StreamGraph.hxx"
32 #include "SALOME_LifeCycleCORBA.hxx"
34 GraphBase::StreamGraph::StreamGraph() :
36 cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ;
39 GraphBase::StreamGraph::StreamGraph( CORBA::ORB_ptr ORB ,
40 SALOME_NamingService* ptrNamingService ,
41 const char *DataFlowName ,
42 const SUPERV::KindOfNode DataFlowkind ,
43 int * Graph_prof_debug ,
44 ofstream * Graph_fdebug ) :
45 // const char * DebugFileName ) :
46 // Graph( ORB ,ptrNamingService , DataFlowName , DebugFileName ) {
47 Graph( ORB ,ptrNamingService , DataFlowName , DataFlowkind , Graph_prof_debug , Graph_fdebug ) {
49 _DataStreamTrace = SUPERV::WithoutTrace ;
51 Kind( SUPERV::DataStreamGraph ) ;
52 cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ;
55 GraphBase::StreamGraph::StreamGraph( CORBA::ORB_ptr ORB ,
56 SALOME_NamingService* ptrNamingService ,
57 const SALOME_ModuleCatalog::Service& DataFlowService ,
58 const char *DataFlowComponentName ,
59 const char *DataFlowInterfaceName ,
60 const char *DataFlowName ,
61 const SUPERV::KindOfNode DataFlowkind ,
62 const SUPERV::SDate DataFlowFirstCreation ,
63 const SUPERV::SDate DataFlowLastModification ,
64 const char * DataFlowEditorRelease ,
65 const char * DataFlowAuthor ,
66 const char * DataFlowComputer ,
67 const char * DataFlowComment ,
68 int * Graph_prof_debug ,
69 ofstream * Graph_fdebug ) :
70 // const char * DebugFileName ) :
71 Graph( ORB ,ptrNamingService , DataFlowService , DataFlowComponentName ,
72 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
73 DataFlowFirstCreation , DataFlowLastModification ,
74 DataFlowEditorRelease , DataFlowAuthor , DataFlowComputer ,
75 DataFlowComment , Graph_prof_debug , Graph_fdebug ) {
76 // DataFlowComment , DebugFileName ) {
78 _DataStreamTrace = SUPERV::WithoutTrace ;
80 cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ;
83 GraphBase::StreamGraph::~StreamGraph() {
84 cdebug << "GraphBase::StreamGraph::~StreamGraph" << endl ;
87 bool GraphBase::StreamGraph::SetStreamParams( const long Timeout ,
88 const SUPERV::KindOfDataStreamTrace DataStreamTrace ,
89 const double DeltaTime ) {
91 _DataStreamTrace = DataStreamTrace ;
92 _DeltaTime = DeltaTime ;
93 cdebug << "GraphBase::StreamGraph:::SetStreamGraph _Timeout " << _Timeout << " _DataStreamTrace " << _DataStreamTrace << " _DeltaTime " << _DeltaTime
98 void GraphBase::StreamGraph::StreamParams( long & Timeout ,
99 SUPERV::KindOfDataStreamTrace & DataStreamTrace ,
100 double & DeltaTime ) const {
102 DataStreamTrace = _DataStreamTrace ;
103 DeltaTime = _DeltaTime ;
104 cdebug << "GraphBase::StreamGraph:::StreamGraph _Timeout " << _Timeout << " _DataStreamTrace " << _DataStreamTrace << " _DeltaTime " << _DeltaTime
108 bool GraphBase::StreamGraph::CreateStreamTopology( const char * aDirectory ) {
109 cdebug_in << "GraphBase::StreamGraph::CreateStreamTopology()" << endl;
111 for ( istream = 1 ; istream <= SubStreamGraphsNumber() ; istream++ ) {
113 astr << istream << ends ;
114 string filename = string( Name() ) + string( "_" ) + astr.str().c_str() ;
115 string fullfilename = aDirectory + filename + ".cpl" ;
116 ofstream f( fullfilename.c_str() ) ;
117 f << "DEBUT " << filename << endl ;
118 f << " TIMEOUT " << _Timeout << endl ;
119 f << " TRACE " << KindOfDataStreamTraceToString( _DataStreamTrace ) << endl ;
120 f << " DELTAT " << _DeltaTime << endl ;
123 f << "# Liste des codes" << endl ;
125 map< string , GraphBase::Service * > aMapOfServiceNames = MapOfServiceNames() ;
126 map< string , GraphBase::Service * >::iterator aMapOfServiceNamesIterator ;
127 for ( aMapOfServiceNamesIterator = aMapOfServiceNames.begin() ;
128 aMapOfServiceNamesIterator != aMapOfServiceNames.end() ; aMapOfServiceNamesIterator++ ) {
129 GraphBase::Service * aService = aMapOfServiceNamesIterator->second ;
131 for ( n = 0 ; n < GraphNodesSize() ; n++ ) {
132 if ( GetGraphNode( n )->HasDataStream() && GetChangeGraphNode( n )->SubStreamGraph() == istream ) {
133 if ( !strcmp( aService->ServiceName() , GetGraphNode( n )->ServiceName() ) ) {
134 f << " CODE " << aService->ServiceName() << endl ;
136 cdebug << "CreateStreamTopology " << aService->ServiceName() << " InStreamParameter("
137 << aService->ServiceInStreamParameter().length() << ") OutStreamParameter("
138 << aService->ServiceOutStreamParameter().length() << ")" << endl ;
139 cdebug << aService->GetService() << endl ;
140 for ( j = 0 ; j < aService->ServiceInStreamParameter().length() ; j++ ) {
141 f << " " << aService->ServiceInStreamParameter()[ j ].Parametername << " "
142 << DataStreamDependencyToString( aService->ServiceInStreamParameter()[ j ].Parameterdependency ) << " IN "
143 << DataStreamToString( aService->ServiceInStreamParameter()[ j ].Parametertype ) << endl ;
145 for ( j = 0 ; j < aService->ServiceOutStreamParameter().length() ; j++ ) {
146 f << " " << aService->ServiceOutStreamParameter()[ j ].Parametername << " "
147 << DataStreamDependencyToString( aService->ServiceOutStreamParameter()[ j ].Parameterdependency ) << " OUT "
148 << DataStreamToString( aService->ServiceOutStreamParameter()[ j ].Parametertype ) << endl ;
150 f << " FIN #" << aService->ServiceName() << endl ;
160 f << "# Liste des instances" << endl ;
162 for ( j = 0 ; j < GraphNodesSize() ; j++ ) {
163 if ( GetGraphNode( j )->HasDataStream() && GetChangeGraphNode( j )->SubStreamGraph() == istream ) {
165 f << " INSTANCE " << GetGraphNode( j )->Name() << endl ;
166 f << " CODE " << GetGraphNode( j )->ServiceName() << endl ;
167 f << " EXEC \"" << GetGraphNode( j )->ServiceName() << "\"" << endl ;
168 f << " FIN" << endl ;
176 f << "# Liste des liens" << endl ;
178 f << " LIEN" << endl ;
179 for ( j = 0 ; j < GraphNodesSize() ; j++ ) {
180 if ( GetGraphNode( j )->HasDataStream() && GetChangeGraphNode( j )->SubStreamGraph() == istream ) {
182 for ( k = 0 ; k < GetGraphNode( j )->GetNodeOutPortsSize() ; k++ ) {
183 if ( GetGraphNode( j )->GetNodeOutPort( k )->IsDataStream() ) {
184 long aNumberOfValues = ((GraphBase::OutDataStreamPort *) GetGraphNode( j )->GetNodeOutPort( k ))->NumberOfValues() ;
186 for ( n = 0 ; n < GetGraphNode( j )->GetNodeOutPort( k )->InPortsSize() ; n++ ) {
187 SUPERV::KindOfSchema aKindOfSchema ;
188 SUPERV::KindOfInterpolation aKindOfInterpolation ;
189 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
190 ((GraphBase::InDataStreamPort *) GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n ))->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
191 f << " " << GetGraphNode( j )->Name() << "."
192 << GetGraphNode( j )->GetNodeOutPort( k )->PortName() ;
193 if ( aNumberOfValues != 0 ) {
194 f << " NIVEAU " << aNumberOfValues ;
197 << GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n )->NodeName() << "."
198 << GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n )->PortName()
199 << " " << aKindOfSchema << " " << aKindOfInterpolation ;
200 if ( aKindOfExtrapolation != SUPERV::EXTRANULL ) {
201 f << " " << aKindOfExtrapolation ;
209 f << " FIN" << endl ;
213 cdebug_out << "GraphBase::StreamGraph::CreateStreamTopology()" << endl;
217 ostream & operator<< (ostream & f ,const SUPERV::KindOfDataStreamTrace & s ) {
219 case SUPERV::WithoutTrace :
222 case SUPERV::SummaryTrace :
225 case SUPERV::DetailedTrace :
226 f << "DetailedTrace";
229 f << "UndefinedKindOfDataStreamTrace";