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 // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
58 //Engines_Container_i * _SuperVisionContainer ;
59 //pthread_t _MainThreadId ;
60 pthread_mutex_t _PyMutexWait ;
61 pthread_mutex_t _MutexWait ;
62 pthread_cond_t _EventWait ;
63 pthread_cond_t _JoinWait ;
65 int _Threads ; // Number of threads
66 long _CreatedThreads ;
67 int _SuspendedThreads ;
68 list< char * > _EventNodes ;
69 list< GraphExecutor::NodeEvent > _Events ;
70 list< GraphExecutor::AutomatonState > _States ;
76 bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
77 bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
78 bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
82 // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came)
83 // event for every node
89 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
90 const char *DataFlowName ,
91 const char * DebugFileName ,
92 const SUPERV::KindOfNode aKindOfNode );
93 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
94 const SALOME_ModuleCatalog::Service& DataFlowService ,
95 const char *DataFlowComponentName ,
96 const char *DataFlowInterfaceName ,
97 const char *DataFlowName ,
98 const SUPERV::KindOfNode DataFlowkind ,
99 const SUPERV::SDate DataFlowFirstCreation ,
100 const SUPERV::SDate DataFlowLastModification ,
101 const char * DataFlowEditorRelease ,
102 const char * DataFlowAuthor ,
103 const char * DataFlowComputer ,
104 const char * DataFlowComment ,
105 const char * DebugFileName ) ;
108 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
109 GraphBase::StreamGraph * StreamGraph() {
110 return _StreamGraph ; } ;
111 GraphBase::StreamGraph * StreamGraph() const {
112 return _StreamGraph ; } ;
113 GraphBase::Graph * Graph() {
115 GraphBase::Graph * Graph() const {
118 bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
119 // bool LoadXml( const char* myFileName ) ;
120 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
122 GraphExecutor::InNode * AddNode(
123 const SALOME_ModuleCatalog::Service& NodeService ,
124 GraphBase::ListOfFuncName aFuncName ,
125 GraphBase::ListOfPythonFunctions aPythonFunction ,
126 const char * NodeComponentName ,
127 const char * NodeInterfaceName ,
128 const char * NodeName ,
129 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
130 const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
131 const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
132 const char * NodeEditorRelease = NULLSTRING ,
133 const char * NodeAuthor = NULLSTRING ,
134 const char * NodeComputer = NULLSTRING ,
135 const char * NodeComment = NULLSTRING ,
136 const int NodeX = 0 ,
137 const int NodeY = 0 ) ;
139 bool IsValid() { if ( !_Valid )
142 bool IsExecutable() { if ( !_Executable )
143 return Executable() ;
144 return _Executable ; } ;
146 bool Run( const bool AndSuspend ) ;
148 void PyInitialized( bool init ) {
149 _PyInitialized = init ; } ;
150 bool PyInitialized() {
151 return _PyInitialized ; } ;
153 void CheckAllDone() ;
155 // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
156 //Engines_Container_i * SuperVisionContainer() ;
157 //const pthread_t MainThreadId() const ;
158 void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
159 void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
160 void PyThreadLock() ;
161 void PyThreadUnLock() ;
164 void ExitThread( pthread_t ThreadNumber = 0 ) ;
165 void SuspendThread() ;
166 void ResumeThread() ;
167 long Threads() { return _Threads ; } ;
168 long SuspendedThreads() { return _SuspendedThreads ; } ;
171 pthread_t ThreadNo() {
172 return _Graph->ThreadNo() ; } ;
173 long Thread( const char * NodeName ) ;
175 void IncrCreatedThreads() {
176 _CreatedThreads += 1 ; } ;
177 long CreatedThreads() {
178 return _CreatedThreads ; } ;
180 bool PushEvent( GraphExecutor::InNode * aNode ,
181 GraphExecutor::NodeEvent anEvent ,
182 GraphExecutor::AutomatonState aState ) ;
184 bool StateWait( SUPERV::GraphState aState ) ;
185 bool Event( char ** aNodeName ,
186 SUPERV::GraphEvent & anEvent ,
187 SUPERV::GraphState & aState ,
189 bool EventW( char ** aNodeName ,
190 SUPERV::GraphEvent & anEvent ,
191 SUPERV::GraphState & aState ) ;
192 bool EventWait( char ** aNodeName ,
193 SUPERV::GraphEvent & anEvent ,
194 SUPERV::GraphState & aState ) ;
198 void SendSomeDataReady( const char * aNodeName ) ;
200 void State(GraphExecutor::AutomatonState aState ) ;
201 const char * StateName(GraphExecutor::AutomatonState aState ) {
202 return theAutomaton->StateName( aState ) ; }
204 SUPERV::GraphState State() ;
205 SUPERV::GraphState State( const char * NodeName ) ;
206 SUPERV::GraphState State( const char * NodeName ,
207 const char * ServiceParameterName ) ;
209 SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
210 SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
212 GraphExecutor::AutomatonState AutomatonState() ;
213 GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
215 SUPERV::ControlState ControlState() ;
216 SUPERV::ControlState ControlState( const char * aNodeName ) ;
217 void ControlClear() ;
218 void ControlClear( const char * aNodeName ) ;
220 bool ContainerKill() ;
230 void Done( bool aDone ) { _Done = aDone ; } ;
231 bool Done() { return _Done ; } ;
236 bool IsWaiting( const char * NodeName ) ;
237 bool IsReady( const char * NodeName ) ;
238 bool IsRunning( const char * NodeName ) ;
239 bool IsDone( const char * NodeName ) ;
240 bool IsSuspended( const char * NodeName ) ;
241 bool PortDone( const char * NodeName ,
242 const char * ServiceParameterName ) ;
243 long LastLevelDone() ;
248 bool SuspendedWait() ;
249 bool ReadyWait( const char * NodeName ) ;
250 bool RunningWait( const char * NodeName ) ;
251 bool DoneWait( const char * NodeName ) ;
252 bool SuspendedWait( const char * NodeName ) ;
254 const CORBA::Any *GetInData( const char *ToNodeName ,
255 const char *ToParameterName ) ;
256 const CORBA::Any *GetOutData( const char *FromNodeName ,
257 const char *FromParameterName ) ;
258 const long CpuUsed() ;
259 const long CpuUsed( const char *aNodeName ) ;