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 GraphExecutor::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< GraphExecutor::AutomatonState > _States ;
72 bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
73 bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
74 bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
78 // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came)
79 // event for every node
85 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
86 const char *DataFlowName ,
87 const char * DebugFileName ,
88 const SUPERV::KindOfNode aKindOfNode );
89 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
90 const SALOME_ModuleCatalog::Service& DataFlowService ,
91 const char *DataFlowComponentName ,
92 const char *DataFlowInterfaceName ,
93 const char *DataFlowName ,
94 const SUPERV::KindOfNode DataFlowkind ,
95 const SUPERV::SDate DataFlowFirstCreation ,
96 const SUPERV::SDate DataFlowLastModification ,
97 const char * DataFlowEditorRelease ,
98 const char * DataFlowAuthor ,
99 const char * DataFlowComputer ,
100 const char * DataFlowComment ,
101 const char * DebugFileName ) ;
104 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
105 GraphBase::StreamGraph * StreamGraph() {
106 return _StreamGraph ; } ;
107 GraphBase::StreamGraph * StreamGraph() const {
108 return _StreamGraph ; } ;
109 GraphBase::Graph * Graph() {
111 GraphBase::Graph * Graph() const {
114 bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
115 // bool LoadXml( const char* myFileName ) ;
116 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
118 GraphExecutor::InNode * AddNode(
119 const SALOME_ModuleCatalog::Service& NodeService ,
120 GraphBase::ListOfFuncName aFuncName ,
121 GraphBase::ListOfPythonFunctions aPythonFunction ,
122 const char * NodeComponentName ,
123 const char * NodeInterfaceName ,
124 const char * NodeName ,
125 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
126 const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
127 const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
128 const char * NodeEditorRelease = NULLSTRING ,
129 const char * NodeAuthor = NULLSTRING ,
130 const char * NodeComputer = NULLSTRING ,
131 const char * NodeComment = NULLSTRING ,
132 const int NodeX = 0 ,
133 const int NodeY = 0 ) ;
135 bool IsValid() { if ( !_Valid )
138 bool IsExecutable() { if ( !_Executable )
139 return Executable() ;
140 return _Executable ; } ;
142 bool Run( const bool AndSuspend ) ;
143 bool Run( const char * aNodeName , const char * AtNodeName ,
144 const bool AndSuspend ) ;
146 void PyInitialized( bool init ) {
147 _PyInitialized = init ; } ;
148 bool PyInitialized() {
149 return _PyInitialized ; } ;
151 void CheckAllDone() ;
153 void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
154 void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
155 void PyThreadLock() ;
156 void PyThreadUnLock() ;
159 void ExitThread( pthread_t ThreadNumber = 0 ) ;
160 void SuspendThread() ;
161 void ResumeThread() ;
162 long Threads() { return _Threads ; } ;
163 long SuspendedThreads() { return _SuspendedThreads ; } ;
166 pthread_t ThreadNo() {
167 return _Graph->ThreadNo() ; } ;
168 long Thread( const char * NodeName ) ;
170 bool PushEvent( GraphExecutor::InNode * aNode ,
171 GraphExecutor::NodeEvent anEvent ,
172 GraphExecutor::AutomatonState aState ) ;
174 bool StateWait( SUPERV::GraphState aState ) ;
175 bool Event( char ** aNodeName ,
176 SUPERV::GraphEvent & anEvent ,
177 SUPERV::GraphState & aState ,
179 bool EventW( char ** aNodeName ,
180 SUPERV::GraphEvent & anEvent ,
181 SUPERV::GraphState & aState ) ;
182 bool EventWait( char ** aNodeName ,
183 SUPERV::GraphEvent & anEvent ,
184 SUPERV::GraphState & aState ) ;
188 void SendSomeDataReady( const char * aNodeName ) ;
190 void State(GraphExecutor::AutomatonState aState ) ;
191 const char * StateName(GraphExecutor::AutomatonState aState ) {
192 return theAutomaton->StateName( aState ) ; }
194 SUPERV::GraphState State() ;
195 SUPERV::GraphState State( const char * NodeName ) ;
196 SUPERV::GraphState State( const char * NodeName ,
197 const char * ServiceParameterName ) ;
199 SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
200 SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
202 GraphExecutor::AutomatonState AutomatonState() ;
203 GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
205 SUPERV::ControlState ControlState() ;
206 SUPERV::ControlState ControlState( const char * aNodeName ) ;
207 void ControlClear() ;
208 void ControlClear( const char * aNodeName ) ;
210 bool ContainerKill() ;
222 void Done( bool aDone ) { _Done = aDone ; } ;
223 bool Done() { return _Done ; } ;
228 bool IsWaiting( const char * NodeName ) ;
229 bool IsReady( const char * NodeName ) ;
230 bool IsRunning( const char * NodeName ) ;
231 bool IsDone( const char * NodeName ) ;
232 bool IsSuspended( const char * NodeName ) ;
233 bool IsDone( const char * NodeName ,
234 const char * ServiceParameterName ) ;
235 long LastLevelDone() ;
240 bool SuspendedWait() ;
241 bool ReadyWait( const char * NodeName ) ;
242 bool RunningWait( const char * NodeName ) ;
243 bool DoneWait( const char * NodeName ) ;
244 bool SuspendedWait( const char * NodeName ) ;
246 const CORBA::Any *GetInData( const char *ToNodeName ,
247 const char *ToParameterName ) ;
248 const CORBA::Any *GetOutData( const char *FromNodeName ,
249 const char *FromParameterName ) ;
250 const long CpuUsed() ;
251 const long CpuUsed( const char *aNodeName ) ;