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 ;
77 bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
78 bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
79 bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
83 // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came)
84 // event for every node
90 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
91 const char *DataFlowName ,
92 const char * DebugFileName ,
93 const SUPERV::KindOfNode aKindOfNode );
94 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
95 const SALOME_ModuleCatalog::Service& DataFlowService ,
96 const char *DataFlowComponentName ,
97 const char *DataFlowInterfaceName ,
98 const char *DataFlowName ,
99 const SUPERV::KindOfNode DataFlowkind ,
100 const SUPERV::SDate DataFlowFirstCreation ,
101 const SUPERV::SDate DataFlowLastModification ,
102 const char * DataFlowEditorRelease ,
103 const char * DataFlowAuthor ,
104 const char * DataFlowComputer ,
105 const char * DataFlowComment ,
106 const char * DebugFileName ) ;
109 void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
110 GraphBase::StreamGraph * StreamGraph() {
111 return _StreamGraph ; } ;
112 GraphBase::StreamGraph * StreamGraph() const {
113 return _StreamGraph ; } ;
114 GraphBase::Graph * Graph() {
116 GraphBase::Graph * Graph() const {
119 char * Name() { return Graph()->Name() ; } ;
121 bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
122 // bool LoadXml( const char* myFileName ) ;
123 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
125 GraphExecutor::InNode * AddNode(
126 const SALOME_ModuleCatalog::Service& NodeService ,
127 GraphBase::ListOfFuncName aFuncName ,
128 GraphBase::ListOfPythonFunctions aPythonFunction ,
129 const char * NodeComponentName ,
130 const char * NodeInterfaceName ,
131 const char * NodeName ,
132 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
133 const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
134 const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
135 const char * NodeEditorRelease = NULLSTRING ,
136 const char * NodeAuthor = NULLSTRING ,
137 const char * NodeComputer = NULLSTRING ,
138 const char * NodeComment = NULLSTRING ,
139 const int NodeX = 0 ,
140 const int NodeY = 0 ) ;
142 bool IsValid() { if ( !_Valid )
145 bool IsExecutable() { if ( !_Executable )
146 return Executable() ;
147 return _Executable ; } ;
149 bool Run( const bool AndSuspend ) ;
151 void PyInitialized( bool init ) {
152 _PyInitialized = init ; } ;
153 bool PyInitialized() {
154 return _PyInitialized ; } ;
156 void CheckAllDone() ;
158 // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
159 //Engines_Container_i * SuperVisionContainer() ;
160 //const pthread_t MainThreadId() const ;
161 void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
162 void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
163 void PyThreadLock() ;
164 void PyThreadUnLock() ;
167 void ExitThread( pthread_t ThreadNumber = 0 ) ;
168 void SuspendThread() ;
169 void ResumeThread() ;
170 long Threads() { return _Threads ; } ;
171 long SuspendedThreads() { return _SuspendedThreads ; } ;
174 pthread_t ThreadNo() {
175 return _Graph->ThreadNo() ; } ;
176 long Thread( const char * NodeName ) ;
178 void IncrCreatedThreads() {
179 _CreatedThreads += 1 ; } ;
180 long CreatedThreads() {
181 return _CreatedThreads ; } ;
183 bool PushEvent( GraphExecutor::InNode * aNode ,
184 GraphExecutor::NodeEvent anEvent ,
185 GraphExecutor::AutomatonState aState ) ;
187 bool StateWait( SUPERV::GraphState aState ) ;
188 bool Event( char ** aNodeName ,
189 SUPERV::GraphEvent & anEvent ,
190 SUPERV::GraphState & aState ,
192 bool EventW( char ** aNodeName ,
193 SUPERV::GraphEvent & anEvent ,
194 SUPERV::GraphState & aState ) ;
195 bool EventWait( char ** aNodeName ,
196 SUPERV::GraphEvent & anEvent ,
197 SUPERV::GraphState & aState ) ;
201 void SendSomeDataReady( const char * aNodeName ) ;
203 void State(GraphExecutor::AutomatonState aState ) ;
204 const char * StateName(GraphExecutor::AutomatonState aState ) {
205 return theAutomaton->StateName( aState ) ; }
207 SUPERV::GraphState State() ;
208 SUPERV::GraphState State( const char * NodeName ) ;
209 SUPERV::GraphState State( const char * NodeName ,
210 const char * ServiceParameterName ) ;
212 SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
213 SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
215 GraphExecutor::AutomatonState AutomatonState() ;
216 GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
218 SUPERV::ControlState ControlState() ;
219 SUPERV::ControlState ControlState( const char * aNodeName ) ;
220 void ControlClear() ;
221 void ControlClear( const char * aNodeName ) ;
223 bool ContainerKill() ;
230 void NodeAborted( const char * aNodeName ) {
231 string aMsg = string( "The node " ) + string( aNodeName ) + " was aborted." ;
232 Graph()->SetMessages( aMsg.c_str() ) ;
233 _NodeAborted = true ; } ;
234 bool IsNodeAborted() {
235 return _NodeAborted ; } ;
240 void Done( bool aDone ) { _Done = aDone ; } ;
241 bool Done() { return _Done ; } ;
246 bool IsWaiting( const char * NodeName ) ;
247 bool IsReady( const char * NodeName ) ;
248 bool IsRunning( const char * NodeName ) ;
249 bool IsDone( const char * NodeName ) ;
250 bool IsSuspended( const char * NodeName ) ;
251 bool PortDone( const char * NodeName ,
252 const char * ServiceParameterName ) ;
253 long LastLevelDone() ;
258 bool SuspendedWait() ;
259 bool ReadyWait( const char * NodeName ) ;
260 bool RunningWait( const char * NodeName ) ;
261 bool DoneWait( const char * NodeName ) ;
262 bool SuspendedWait( const char * NodeName ) ;
264 //JR 30.03.2005 const CORBA::Any *GetInData( const char *ToNodeName ,
265 const CORBA::Any GetInData( const char *ToNodeName ,
266 const char *ToParameterName ) ;
267 //JR 30.03.2005 const CORBA::Any *GetOutData( const char *FromNodeName ,
268 const CORBA::Any GetOutData( const char *FromNodeName ,
269 const char *FromParameterName ) ;
270 const long CpuUsed() ;
271 const long CpuUsed( const char *aNodeName ) ;