1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
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_OutNode.hxx
25 // Author : Jean Rahuel, CEA
29 #ifndef _DATAFLOWEXECUTOR_OUTNODE_HXX
30 #define _DATAFLOWEXECUTOR_OUTNODE_HXX
32 #include "SALOME_Component_i.hxx"
34 #include "DataFlowExecutor_InNode.hxx"
36 #include "DataFlowBase_StreamGraph.hxx"
38 namespace GraphExecutor {
40 // class OutNode : public GraphBase::Graph {
41 class OutNode : public GraphBase::Base {
45 GraphBase::StreamGraph * _StreamGraph ;
46 GraphBase::Graph * _Graph ;
48 int _Graph_prof_debug ;
53 SUPERV::AutomatonState _State ;
54 SUPERV::ControlState _ControlState ;
57 pthread_mutex_t _PyMutexWait ;
58 pthread_mutex_t _MutexWait ;
59 pthread_cond_t _EventWait ;
60 pthread_cond_t _JoinWait ;
62 int _Threads ; // Number of threads
63 int _SuspendedThreads ;
64 list< char * > _EventNodes ;
65 list< GraphExecutor::NodeEvent > _Events ;
66 list< SUPERV::AutomatonState > _States ;
72 bool LoadNodes( const GraphBase::ListOfNodes &aNodes ) ;
73 bool LoadLinks( const GraphBase::ListOfLinks &aLinks ) ;
74 bool LoadDatas( const GraphBase::ListOfLinks &aDatas ) ;
81 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
82 const char *DataFlowName ,
83 const char * DebugFileName ,
84 const SUPERV::KindOfNode aKindOfNode );
85 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
86 const SALOME_ModuleCatalog::Service& DataFlowService ,
87 const char *DataFlowComponentName ,
88 const char *DataFlowInterfaceName ,
89 const char *DataFlowName ,
90 const SUPERV::KindOfNode DataFlowkind ,
91 const SUPERV::SDate DataFlowFirstCreation ,
92 const SUPERV::SDate DataFlowLastModification ,
93 const char * DataFlowEditorRelease ,
94 const char * DataFlowAuthor ,
95 const char * DataFlowComputer ,
96 const char * DataFlowComment ,
97 const char * DebugFileName ) ;
100 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
101 GraphBase::StreamGraph * StreamGraph() {
102 return _StreamGraph ; } ;
103 GraphBase::StreamGraph * StreamGraph() const {
104 return _StreamGraph ; } ;
105 GraphBase::Graph * Graph() {
107 GraphBase::Graph * Graph() const {
110 bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
111 bool LoadXml( const char* myFileName ) ;
112 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
114 GraphExecutor::InNode * AddNode(
115 const SALOME_ModuleCatalog::Service& NodeService ,
116 GraphBase::ListOfFuncName aFuncName ,
117 GraphBase::ListOfPythonFunctions aPythonFunction ,
118 const char * NodeComponentName ,
119 const char * NodeInterfaceName ,
120 const char * NodeName ,
121 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
122 const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
123 const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
124 const char * NodeEditorRelease = NULLSTRING ,
125 const char * NodeAuthor = NULLSTRING ,
126 const char * NodeComputer = NULLSTRING ,
127 const char * NodeComment = NULLSTRING ,
128 const int NodeX = 0 ,
129 const int NodeY = 0 ) ;
131 bool AddInputData( const char* ToNodeName1 ,
132 const char* ToParameterName1 ,
133 const char* ToNodeName2 ,
134 const char* ToParameterName2 ) ;
136 bool IsValid() { if ( !_Valid )
139 bool IsExecutable() { if ( !_Executable )
140 return Executable() ;
141 return _Executable ; } ;
143 bool Run( const bool AndSuspend ) ;
144 bool Run( const char * aNodeName , const char * AtNodeName ,
145 const bool AndSuspend ) ;
147 void PyInitialized( bool init ) {
148 _PyInitialized = init ; } ;
149 bool PyInitialized() {
150 return _PyInitialized ; } ;
152 void CheckAllDone() ;
154 void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
155 void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
156 void PyThreadLock() ;
157 void PyThreadUnLock() ;
161 void SuspendThread() ;
162 void ResumeThread() ;
163 long Threads() { return _Threads ; } ;
164 long SuspendedThreads() { return _SuspendedThreads ; } ;
167 pthread_t ThreadNo() {
168 return _Graph->ThreadNo() ; } ;
169 long Thread( const char * NodeName ) ;
171 bool PushEvent( GraphExecutor::InNode * aNode ,
172 GraphExecutor::NodeEvent anEvent ,
173 SUPERV::AutomatonState aState ) ;
175 bool StateWait( SUPERV::GraphState aState ) ;
176 bool Event( char ** aNodeName ,
177 SUPERV::GraphEvent & anEvent ,
178 SUPERV::GraphState & aState ,
180 bool EventW( char ** aNodeName ,
181 SUPERV::GraphEvent & anEvent ,
182 SUPERV::GraphState & aState ) ;
183 bool EventWait( char ** aNodeName ,
184 SUPERV::GraphEvent & anEvent ,
185 SUPERV::GraphState & aState ) ;
189 void State(SUPERV::AutomatonState aState ) ;
190 const char * StateName(SUPERV::AutomatonState aState ) {
191 return theAutomaton->StateName( aState ) ; }
193 SUPERV::GraphState State() ;
194 SUPERV::GraphState State( const char * NodeName ) ;
195 SUPERV::GraphState State( const char * NodeName ,
196 const char * ServiceParameterName ) ;
198 SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
199 SUPERV::GraphState AutomatonGraphState(SUPERV::AutomatonState anAutomatonState) ;
201 SUPERV::AutomatonState AutomatonState() ;
202 SUPERV::AutomatonState AutomatonState( const char * NodeName ) ;
204 SUPERV::ControlState ControlState() ;
205 SUPERV::ControlState ControlState( const char * aNodeName ) ;
206 void ControlClear() ;
207 void ControlClear( const char * aNodeName ) ;
209 bool ContainerKill() ;
221 void Done( bool aDone ) { _Done = aDone ; } ;
222 bool Done() { return _Done ; } ;
227 bool IsWaiting( const char * NodeName ) ;
228 bool IsReady( const char * NodeName ) ;
229 bool IsRunning( const char * NodeName ) ;
230 bool IsDone( const char * NodeName ) ;
231 bool IsSuspended( const char * NodeName ) ;
232 bool IsDone( const char * NodeName ,
233 const char * ServiceParameterName ) ;
234 long LastLevelDone() ;
239 bool SuspendedWait() ;
240 bool ReadyWait( const char * NodeName ) ;
241 bool RunningWait( const char * NodeName ) ;
242 bool DoneWait( const char * NodeName ) ;
243 bool SuspendedWait( const char * NodeName ) ;
245 const CORBA::Any *GetInData( const char *ToNodeName ,
246 const char *ToParameterName ) ;
247 const CORBA::Any *GetOutData( const char *FromNodeName ,
248 const char *FromParameterName ) ;
249 const long CpuUsed() ;
250 const long CpuUsed( const char *aNodeName ) ;