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 int * Graph_prof_debug ,
43 ofstream * Graph_fdebug ) :
44 // const char * DebugFileName ) :
45 // Graph( ORB ,ptrNamingService , DataFlowName , DebugFileName ) {
46 Graph( ORB ,ptrNamingService , DataFlowName , Graph_prof_debug , Graph_fdebug ) {
48 _DataStreamTrace = SUPERV::WithoutTrace ;
50 Kind( SUPERV::DataStreamGraph ) ;
51 cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ;
54 GraphBase::StreamGraph::StreamGraph( CORBA::ORB_ptr ORB ,
55 SALOME_NamingService* ptrNamingService ,
56 const SALOME_ModuleCatalog::Service& DataFlowService ,
57 const char *DataFlowComponentName ,
58 const char *DataFlowInterfaceName ,
59 const char *DataFlowName ,
60 const SUPERV::KindOfNode DataFlowkind ,
61 const SUPERV::SDate DataFlowFirstCreation ,
62 const SUPERV::SDate DataFlowLastModification ,
63 const char * DataFlowEditorRelease ,
64 const char * DataFlowAuthor ,
65 const char * DataFlowComputer ,
66 const char * DataFlowComment ,
67 int * Graph_prof_debug ,
68 ofstream * Graph_fdebug ) :
69 // const char * DebugFileName ) :
70 Graph( ORB ,ptrNamingService , DataFlowService , DataFlowComponentName ,
71 DataFlowInterfaceName , DataFlowName , DataFlowkind ,
72 DataFlowFirstCreation , DataFlowLastModification ,
73 DataFlowEditorRelease , DataFlowAuthor , DataFlowComputer ,
74 DataFlowComment , Graph_prof_debug , Graph_fdebug ) {
75 // DataFlowComment , DebugFileName ) {
77 _DataStreamTrace = SUPERV::WithoutTrace ;
79 cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ;
82 GraphBase::StreamGraph::~StreamGraph() {
83 cdebug << "GraphBase::StreamGraph::~StreamGraph" << endl ;
86 bool GraphBase::StreamGraph::SetStreamParams( const long Timeout ,
87 const SUPERV::KindOfDataStreamTrace DataStreamTrace ,
88 const double DeltaTime ) {
90 _DataStreamTrace = DataStreamTrace ;
91 _DeltaTime = DeltaTime ;
92 cdebug << "GraphBase::StreamGraph:::SetStreamGraph _Timeout " << _Timeout << " _DataStreamTrace " << _DataStreamTrace << " _DeltaTime " << _DeltaTime
97 void GraphBase::StreamGraph::StreamParams( long & Timeout ,
98 SUPERV::KindOfDataStreamTrace & DataStreamTrace ,
99 double & DeltaTime ) const {
101 DataStreamTrace = _DataStreamTrace ;
102 DeltaTime = _DeltaTime ;
103 cdebug << "GraphBase::StreamGraph:::StreamGraph _Timeout " << _Timeout << " _DataStreamTrace " << _DataStreamTrace << " _DeltaTime " << _DeltaTime
107 bool GraphBase::StreamGraph::CreateStreamTopology( const char * aDirectory ) {
108 cdebug_in << "GraphBase::StreamGraph::CreateStreamTopology()" << endl;
110 for ( istream = 1 ; istream <= SubStreamGraphsNumber() ; istream++ ) {
112 astr << istream << ends ;
113 string filename = string( Name() ) + string( "_" ) + astr.str().c_str() ;
114 string fullfilename = aDirectory + filename + ".cpl" ;
115 ofstream f( fullfilename.c_str() ) ;
116 f << "DEBUT " << filename << endl ;
117 f << " TIMEOUT " << _Timeout << endl ;
118 f << " TRACE " << KindOfDataStreamTraceToString( _DataStreamTrace ) << endl ;
119 f << " DELTAT " << _DeltaTime << endl ;
122 f << "# Liste des codes" << endl ;
124 map< string , GraphBase::Service * > aMapOfServiceNames = MapOfServiceNames() ;
125 map< string , GraphBase::Service * >::iterator aMapOfServiceNamesIterator ;
126 for ( aMapOfServiceNamesIterator = aMapOfServiceNames.begin() ;
127 aMapOfServiceNamesIterator != aMapOfServiceNames.end() ; aMapOfServiceNamesIterator++ ) {
128 GraphBase::Service * aService = aMapOfServiceNamesIterator->second ;
130 for ( n = 0 ; n < GraphNodesSize() ; n++ ) {
131 if ( GetGraphNode( n )->HasDataStream() && GetChangeGraphNode( n )->SubStreamGraph() == istream ) {
132 if ( !strcmp( aService->ServiceName() , GetGraphNode( n )->ServiceName() ) ) {
133 f << " CODE " << aService->ServiceName() << endl ;
135 cdebug << "CreateStreamTopology " << aService->ServiceName() << " InStreamParameter("
136 << aService->ServiceInStreamParameter().length() << ") OutStreamParameter("
137 << aService->ServiceOutStreamParameter().length() << ")" << endl ;
138 cdebug << aService->GetService() << endl ;
139 for ( j = 0 ; j < aService->ServiceInStreamParameter().length() ; j++ ) {
140 f << " " << aService->ServiceInStreamParameter()[ j ].Parametername << " "
141 << DataStreamDependencyToString( aService->ServiceInStreamParameter()[ j ].Parameterdependency ) << " IN "
142 << DataStreamToString( aService->ServiceInStreamParameter()[ j ].Parametertype ) << endl ;
144 for ( j = 0 ; j < aService->ServiceOutStreamParameter().length() ; j++ ) {
145 f << " " << aService->ServiceOutStreamParameter()[ j ].Parametername << " "
146 << DataStreamDependencyToString( aService->ServiceOutStreamParameter()[ j ].Parameterdependency ) << " OUT "
147 << DataStreamToString( aService->ServiceOutStreamParameter()[ j ].Parametertype ) << endl ;
149 f << " FIN #" << aService->ServiceName() << endl ;
159 f << "# Liste des instances" << endl ;
161 for ( j = 0 ; j < GraphNodesSize() ; j++ ) {
162 if ( GetGraphNode( j )->HasDataStream() && GetChangeGraphNode( j )->SubStreamGraph() == istream ) {
164 f << " INSTANCE " << GetGraphNode( j )->Name() << endl ;
165 f << " CODE " << GetGraphNode( j )->ServiceName() << endl ;
166 f << " EXEC \"" << GetGraphNode( j )->ServiceName() << "\"" << endl ;
167 f << " FIN" << endl ;
175 f << "# Liste des liens" << endl ;
177 f << " LIEN" << endl ;
178 for ( j = 0 ; j < GraphNodesSize() ; j++ ) {
179 if ( GetGraphNode( j )->HasDataStream() && GetChangeGraphNode( j )->SubStreamGraph() == istream ) {
181 for ( k = 0 ; k < GetGraphNode( j )->GetNodeOutPortsSize() ; k++ ) {
182 if ( GetGraphNode( j )->GetNodeOutPort( k )->IsDataStream() ) {
183 long aNumberOfValues = ((GraphBase::OutDataStreamPort *) GetGraphNode( j )->GetNodeOutPort( k ))->NumberOfValues() ;
185 for ( n = 0 ; n < GetGraphNode( j )->GetNodeOutPort( k )->InPortsSize() ; n++ ) {
186 SUPERV::KindOfSchema aKindOfSchema ;
187 SUPERV::KindOfInterpolation aKindOfInterpolation ;
188 SUPERV::KindOfExtrapolation aKindOfExtrapolation ;
189 ((GraphBase::InDataStreamPort *) GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n ))->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ;
190 f << " " << GetGraphNode( j )->Name() << "."
191 << GetGraphNode( j )->GetNodeOutPort( k )->PortName() ;
192 if ( aNumberOfValues != 0 ) {
193 f << " NIVEAU " << aNumberOfValues ;
196 << GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n )->NodeName() << "."
197 << GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n )->PortName()
198 << " " << aKindOfSchema << " " << aKindOfInterpolation ;
199 if ( aKindOfExtrapolation != SUPERV::EXTRANULL ) {
200 f << " " << aKindOfExtrapolation ;
208 f << " FIN" << endl ;
212 cdebug_out << "GraphBase::StreamGraph::CreateStreamTopology()" << endl;
216 ostream & operator<< (ostream & f ,const SUPERV::KindOfDataStreamTrace & s ) {
218 case SUPERV::WithoutTrace :
221 case SUPERV::SummaryTrace :
224 case SUPERV::DetailedTrace :
225 f << "DetailedTrace";
228 f << "UndefinedKindOfDataStreamTrace";