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.salome-platform.org/ or email : webmaster.salome@opencascade.com
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 ;
58 // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
59 //Engines_Container_i * _SuperVisionContainer ;
60 //pthread_t _MainThreadId ;
61 pthread_mutex_t _PyMutexWait ;
62 pthread_mutex_t _MutexWait ;
63 pthread_cond_t _EventWait ;
64 pthread_cond_t _JoinWait ;
66 int _Threads ; // Number of threads
67 long _CreatedThreads ;
68 int _SuspendedThreads ;
69 list< char * > _EventNodes ;
70 list< GraphExecutor::NodeEvent > _Events ;
71 list< GraphExecutor::AutomatonState > _States ;
73 pthread_t _run_func_thread ;
79 bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
80 bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
81 bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
85 // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came)
86 // event for every node
92 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
93 const char *DataFlowName ,
94 const char * DebugFileName ,
95 const SUPERV::KindOfNode aKindOfNode );
96 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
97 const SALOME_ModuleCatalog::Service& DataFlowService ,
98 const char *DataFlowComponentName ,
99 const char *DataFlowInterfaceName ,
100 const char *DataFlowName ,
101 const SUPERV::KindOfNode DataFlowkind ,
102 const SUPERV::SDate DataFlowFirstCreation ,
103 const SUPERV::SDate DataFlowLastModification ,
104 const char * DataFlowEditorRelease ,
105 const char * DataFlowAuthor ,
106 const char * DataFlowComputer ,
107 const char * DataFlowComment ,
108 const char * DebugFileName ) ;
111 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
112 GraphBase::StreamGraph * StreamGraph() {
113 return _StreamGraph ; } ;
114 GraphBase::StreamGraph * StreamGraph() const {
115 return _StreamGraph ; } ;
116 GraphBase::Graph * Graph() {
118 GraphBase::Graph * Graph() const {
121 char * Name() { return Graph()->Name() ; } ;
123 bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
124 // bool LoadXml( const char* myFileName ) ;
125 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
127 GraphExecutor::InNode * AddNode(
128 const SALOME_ModuleCatalog::Service& NodeService ,
129 GraphBase::ListOfFuncName aFuncName ,
130 GraphBase::ListOfPythonFunctions aPythonFunction ,
131 const char * NodeComponentName ,
132 const char * NodeInterfaceName ,
133 const char * NodeName ,
134 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
135 const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
136 const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
137 const char * NodeEditorRelease = NULLSTRING ,
138 const char * NodeAuthor = NULLSTRING ,
139 const char * NodeComputer = NULLSTRING ,
140 const char * NodeComment = NULLSTRING ,
141 const int NodeX = 0 ,
142 const int NodeY = 0 ) ;
144 bool IsValid() { if ( !_Valid )
147 bool IsExecutable() { if ( !_Executable )
148 return Executable() ;
149 return _Executable ; } ;
151 bool Run( const bool AndSuspend ) ;
153 void PyInitialized( bool init ) {
154 _PyInitialized = init ; } ;
155 bool PyInitialized() {
156 return _PyInitialized ; } ;
158 void CheckAllDone() ;
160 // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
161 //Engines_Container_i * SuperVisionContainer() ;
162 //const pthread_t MainThreadId() const ;
163 void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
164 void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
165 void PyThreadLock() ;
166 void PyThreadUnLock() ;
169 void ExitThread( pthread_t ThreadNumber = 0 ) ;
170 void SuspendThread() ;
171 void ResumeThread() ;
172 long Threads() { return _Threads ; } ;
173 long SuspendedThreads() { return _SuspendedThreads ; } ;
176 pthread_t ThreadNo() {
177 return _Graph->ThreadNo() ; } ;
178 long Thread( const char * NodeName ) ;
180 void IncrCreatedThreads() {
181 _CreatedThreads += 1 ; } ;
182 long CreatedThreads() {
183 return _CreatedThreads ; } ;
185 bool PushEvent( GraphExecutor::InNode * aNode ,
186 GraphExecutor::NodeEvent anEvent ,
187 GraphExecutor::AutomatonState aState ) ;
189 bool StateWait( SUPERV::GraphState aState ) ;
190 bool Event( char ** aNodeName ,
191 SUPERV::GraphEvent & anEvent ,
192 SUPERV::GraphState & aState ,
194 bool EventW( char ** aNodeName ,
195 SUPERV::GraphEvent & anEvent ,
196 SUPERV::GraphState & aState ) ;
197 bool EventWait( char ** aNodeName ,
198 SUPERV::GraphEvent & anEvent ,
199 SUPERV::GraphState & aState ) ;
203 void SendSomeDataReady( const char * aNodeName ) ;
205 void State(GraphExecutor::AutomatonState aState ) ;
206 const char * StateName(GraphExecutor::AutomatonState aState ) {
207 return theAutomaton->StateName( aState ) ; }
209 SUPERV::GraphState State() ;
210 SUPERV::GraphState State( const char * NodeName ) ;
211 SUPERV::GraphState State( const char * NodeName ,
212 const char * ServiceParameterName ) ;
214 SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
215 SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
217 GraphExecutor::AutomatonState AutomatonState() ;
218 GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
220 SUPERV::ControlState ControlState() ;
221 SUPERV::ControlState ControlState( const char * aNodeName ) ;
222 void ControlClear() ;
223 void ControlClear( const char * aNodeName ) ;
225 bool ContainerKill() ;
232 void NodeAborted( const char * aNodeName ) {
233 string aMsg = string( "The node " ) + string( aNodeName ) + " was aborted." ;
234 Graph()->SetMessages( aMsg.c_str() ) ;
235 _NodeAborted = true ; } ;
236 bool IsNodeAborted() {
237 return _NodeAborted ; } ;
242 void Done( bool aDone ) { _Done = aDone ; } ;
243 bool Done() { return _Done ; } ;
248 bool IsWaiting( const char * NodeName ) ;
249 bool IsReady( const char * NodeName ) ;
250 bool IsRunning( const char * NodeName ) ;
251 bool IsDone( const char * NodeName ) ;
252 bool IsSuspended( const char * NodeName ) ;
253 bool PortDone( const char * NodeName ,
254 const char * ServiceParameterName ) ;
255 long LastLevelDone() ;
260 bool SuspendedWait() ;
261 bool ReadyWait( const char * NodeName ) ;
262 bool RunningWait( const char * NodeName ) ;
263 bool DoneWait( const char * NodeName ) ;
264 bool SuspendedWait( const char * NodeName ) ;
266 //JR 30.03.2005 const CORBA::Any *GetInData( const char *ToNodeName ,
267 const CORBA::Any GetInData( const char *ToNodeName ,
268 const char *ToParameterName ) ;
269 //JR 30.03.2005 const CORBA::Any *GetOutData( const char *FromNodeName ,
270 const CORBA::Any GetOutData( const char *FromNodeName ,
271 const char *FromParameterName ) ;
272 const long CpuUsed() ;
273 const long CpuUsed( const char *aNodeName ) ;
275 void setRunFuncThread( pthread_t theThread ) { _run_func_thread = theThread; } ; // mkr : IPAL14711