]> SALOME platform Git repositories - modules/superv.git/blob - src/GraphExecutor/DataFlowExecutor_OutNode.hxx
Salome HOME
277d93f027d727c155c8372c5a053d9a900fa9c9
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.hxx
1 //  SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : DataFlowBase_OutNode.hxx
25 //  Author : Jean Rahuel, CEA
26 //  Module : SUPERV
27 //  $Header:
28
29 #ifndef _DATAFLOWEXECUTOR_OUTNODE_HXX
30 #define _DATAFLOWEXECUTOR_OUTNODE_HXX
31
32 #include "SALOME_Component_i.hxx"
33
34 #include "DataFlowExecutor_InNode.hxx"
35
36 #include "DataFlowBase_StreamGraph.hxx"
37
38 namespace GraphExecutor {
39
40 //  class OutNode : public GraphBase::Graph {
41   class OutNode : public GraphBase::Base {
42
43     private :
44
45       GraphBase::StreamGraph * _StreamGraph ;
46       GraphBase::Graph       * _Graph ;
47
48       int  _Graph_prof_debug ;
49
50       bool                    _PyInitialized ;
51       bool                    _Valid ;
52       bool                    _Executable ;
53       GraphExecutor::AutomatonState  _State ;
54       SUPERV::ControlState    _ControlState ;
55       bool                    _Done ;
56
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 ;
64       bool                             _JustStarted ;
65       int                              _Threads ; // Number of threads
66       int                              _SuspendedThreads ;
67       list< char * >                   _EventNodes ;
68       list< GraphExecutor::NodeEvent > _Events ;
69       list< GraphExecutor::AutomatonState >   _States ;
70
71       bool Valid() ;
72       void UnValid() ;
73       bool Executable() ;
74
75       bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
76       bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
77       bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
78
79       CORBA::ORB_ptr _Orb ;
80
81       // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came) 
82       // event for every node
83       void siftEvents();
84
85     public :
86   
87       OutNode() ;
88       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
89                const char *DataFlowName ,
90                const char * DebugFileName ,
91                const SUPERV::KindOfNode aKindOfNode );
92       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
93                const SALOME_ModuleCatalog::Service& DataFlowService ,
94                const char *DataFlowComponentName ,
95                const char *DataFlowInterfaceName ,
96                const char *DataFlowName ,
97                const SUPERV::KindOfNode DataFlowkind ,
98                const SUPERV::SDate DataFlowFirstCreation ,
99                const SUPERV::SDate DataFlowLastModification ,
100                const char * DataFlowEditorRelease ,
101                const char * DataFlowAuthor ,
102                const char * DataFlowComputer ,
103                const char * DataFlowComment ,
104                const char * DebugFileName ) ;
105       virtual ~OutNode() ;
106
107       void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
108       GraphBase::StreamGraph * StreamGraph() {
109                                return _StreamGraph ; } ;
110       GraphBase::StreamGraph * StreamGraph() const {
111                                return _StreamGraph ; } ;
112       GraphBase::Graph * Graph() {
113                          return _Graph ; } ;
114       GraphBase::Graph * Graph() const {
115                          return _Graph ; } ;
116
117       bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
118 //      bool LoadXml( const char* myFileName ) ;
119       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
120
121       GraphExecutor::InNode * AddNode(
122                         const SALOME_ModuleCatalog::Service& NodeService ,
123                         GraphBase::ListOfFuncName aFuncName ,
124                         GraphBase::ListOfPythonFunctions aPythonFunction ,
125                         const char * NodeComponentName ,
126                         const char * NodeInterfaceName ,
127                         const char * NodeName ,
128                         const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
129                         const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
130                         const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
131                         const char * NodeEditorRelease = NULLSTRING ,
132                         const char * NodeAuthor = NULLSTRING ,
133                         const char * NodeComputer = NULLSTRING ,
134                         const char * NodeComment = NULLSTRING ,
135                         const int NodeX = 0 ,
136                         const int NodeY = 0 ) ;
137
138       bool IsValid() { if ( !_Valid )
139                          return Valid() ;
140                        return _Valid ; } ;
141       bool IsExecutable() { if ( !_Executable )
142                                 return Executable() ;
143                             return _Executable ; } ;
144
145       bool Run( const bool AndSuspend ) ;
146
147       void PyInitialized( bool init ) {
148            _PyInitialized = init ; } ;
149       bool PyInitialized() {
150            return _PyInitialized ; } ;
151
152       void CheckAllDone() ;
153
154       // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL    
155       //Engines_Container_i * SuperVisionContainer() ;
156       //const pthread_t MainThreadId() const ;
157       void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
158       void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
159       void PyThreadLock() ;
160       void PyThreadUnLock() ;
161
162       void NewThread() ;
163       void ExitThread( pthread_t ThreadNumber = 0 ) ;
164       void SuspendThread() ;
165       void ResumeThread() ;
166       long Threads() { return _Threads ; } ;
167       long SuspendedThreads() { return _SuspendedThreads ; } ;
168       void JoinedWait() ;
169
170       pthread_t ThreadNo() {
171                 return _Graph->ThreadNo() ; } ;
172       long Thread( const char * NodeName ) ;
173
174       bool PushEvent( GraphExecutor::InNode * aNode ,
175                       GraphExecutor::NodeEvent anEvent ,
176                       GraphExecutor::AutomatonState aState ) ;
177       int GetListSize();
178       bool StateWait( SUPERV::GraphState aState ) ;
179       bool Event( char ** aNodeName ,
180                   SUPERV::GraphEvent & anEvent ,
181                   SUPERV::GraphState & aState ,
182                   bool WithWait ) ;
183       bool EventW( char ** aNodeName ,
184                    SUPERV::GraphEvent & anEvent ,
185                    SUPERV::GraphState & aState ) ;
186       bool EventWait( char ** aNodeName ,
187                       SUPERV::GraphEvent & anEvent ,
188                       SUPERV::GraphState & aState ) ;
189       long EventQSize() ;
190       void EventList() ;
191
192       void SendSomeDataReady( const char * aNodeName ) ;
193
194       void State(GraphExecutor::AutomatonState aState ) ;
195       const char * StateName(GraphExecutor::AutomatonState aState ) {
196              return theAutomaton->StateName( aState ) ; }
197
198       SUPERV::GraphState State() ;
199       SUPERV::GraphState State( const char * NodeName ) ;
200       SUPERV::GraphState State( const char * NodeName ,
201                                 const char * ServiceParameterName ) ;
202
203       SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
204       SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
205
206       GraphExecutor::AutomatonState AutomatonState() ;
207       GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
208
209       SUPERV::ControlState ControlState() ;
210       SUPERV::ControlState ControlState( const char * aNodeName ) ;
211       void ControlClear() ;
212       void ControlClear( const char * aNodeName ) ;
213
214       bool ContainerKill() ;
215
216       bool Suspend() ;
217       bool Resume() ;
218       bool Kill() ;
219       bool Stop() ;
220
221       bool IsWaiting() ;
222       bool IsReady() ;
223       bool IsRunning() ;
224       void Done( bool aDone ) { _Done = aDone ; } ;
225       bool Done() { return _Done ; } ;
226       bool IsDone() ;
227       bool IsSuspended() ;
228       bool IsKilled() ;
229       bool IsStopped() ;
230       bool IsWaiting( const char * NodeName ) ;
231       bool IsReady( const char * NodeName ) ;
232       bool IsRunning( const char * NodeName ) ;
233       bool IsDone( const char * NodeName ) ;
234       bool IsSuspended( const char * NodeName ) ;
235       bool IsDone( const char * NodeName ,
236                    const char * ServiceParameterName ) ;
237       long LastLevelDone() ;
238
239       bool ReadyWait() ;
240       bool RunningWait() ;
241       bool DoneWait() ;
242       bool SuspendedWait() ;
243       bool ReadyWait( const char * NodeName ) ;
244       bool RunningWait( const char * NodeName ) ;
245       bool DoneWait( const char * NodeName ) ;
246       bool SuspendedWait( const char * NodeName ) ;
247
248       const CORBA::Any *GetInData( const char *ToNodeName ,
249                                    const char *ToParameterName ) ;
250       const CORBA::Any *GetOutData( const char *FromNodeName ,
251                                     const char *FromParameterName ) ;
252       const long CpuUsed() ;
253       const long CpuUsed( const char *aNodeName ) ;
254   };
255 };
256
257 #endif