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 "DataFlowBase_Graph.hxx"
36 #include "DataFlowExecutor_InNode.hxx"
38 namespace GraphExecutor {
40 class OutNode : public GraphBase::Graph {
47 SUPERV::AutomatonState _State ;
48 SUPERV::ControlState _ControlState ;
51 pthread_mutex_t _PyMutexWait ;
52 pthread_mutex_t _MutexWait ;
53 pthread_cond_t _EventWait ;
54 pthread_cond_t _JoinWait ;
56 int _Threads ; // Number of threads
57 int _SuspendedThreads ;
58 list< char * > _EventNodes ;
59 list< GraphExecutor::NodeEvent > _Events ;
60 list< SUPERV::AutomatonState > _States ;
66 bool LoadNodes( const GraphBase::ListOfNodes &aNodes ) ;
67 bool LoadLinks( const GraphBase::ListOfLinks &aLinks ) ;
68 bool LoadDatas( const GraphBase::ListOfLinks &aDatas ) ;
75 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
76 const char *DataFlowName ,
77 const char * DebugFileName );
78 OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
79 const SALOME_ModuleCatalog::Service& DataFlowService ,
80 const char *DataFlowComponentName ,
81 const char *DataFlowInterfaceName ,
82 const char *DataFlowName ,
83 const SUPERV::KindOfNode DataFlowkind ,
84 const SUPERV::SDate DataFlowFirstCreation ,
85 const SUPERV::SDate DataFlowLastModification ,
86 const char * DataFlowEditorRelease ,
87 const char * DataFlowAuthor ,
88 const char * DataFlowComputer ,
89 const char * DataFlowComment ,
90 const char * DebugFileName ) ;
93 bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
94 bool LoadXml( const char* myFileName ) ;
95 bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
97 GraphExecutor::InNode * AddNode(
98 const SALOME_ModuleCatalog::Service& NodeService ,
99 GraphBase::ListOfFuncName aFuncName ,
100 GraphBase::ListOfPythonFunctions aPythonFunction ,
101 const char * NodeComponentName ,
102 const char * NodeInterfaceName ,
103 const char * NodeName ,
104 const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
105 const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
106 const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
107 const char * NodeEditorRelease = NULLSTRING ,
108 const char * NodeAuthor = NULLSTRING ,
109 const char * NodeComputer = NULLSTRING ,
110 const char * NodeComment = NULLSTRING ,
111 const int NodeX = 0 ,
112 const int NodeY = 0 ) ;
114 bool AddInputData( const char* ToNodeName1 ,
115 const char* ToParameterName1 ,
116 const char* ToNodeName2 ,
117 const char* ToParameterName2 ) ;
119 bool IsValid() { if ( !_Valid )
122 bool IsExecutable() { if ( !_Executable )
123 return Executable() ;
124 return _Executable ; } ;
126 bool Run( const bool AndSuspend ) ;
127 bool Run( const char * aNodeName , const char * AtNodeName ,
128 const bool AndSuspend ) ;
130 void PyInitialized( bool init ) {
131 _PyInitialized = init ; } ;
132 bool PyInitialized() {
133 return _PyInitialized ; } ;
135 void CheckAllDone() ;
137 void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
138 void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
139 void PyThreadLock() ;
140 void PyThreadUnLock() ;
144 void SuspendThread() ;
145 void ResumeThread() ;
146 long Threads() { return _Threads ; } ;
147 long SuspendedThreads() { return _SuspendedThreads ; } ;
150 long Thread( const char * NodeName ) ;
152 bool PushEvent( GraphExecutor::InNode * aNode ,
153 GraphExecutor::NodeEvent anEvent ,
154 SUPERV::AutomatonState aState ) ;
156 bool StateWait( SUPERV::GraphState aState ) ;
157 bool Event( char ** aNodeName ,
158 SUPERV::GraphEvent & anEvent ,
159 SUPERV::GraphState & aState ,
161 bool EventW( char ** aNodeName ,
162 SUPERV::GraphEvent & anEvent ,
163 SUPERV::GraphState & aState ) ;
164 bool EventWait( char ** aNodeName ,
165 SUPERV::GraphEvent & anEvent ,
166 SUPERV::GraphState & aState ) ;
170 void State(SUPERV::AutomatonState aState ) ;
171 const char * StateName(SUPERV::AutomatonState aState ) {
172 return theAutomaton->StateName( aState ) ; }
174 SUPERV::GraphState State() ;
175 SUPERV::GraphState State( const char * NodeName ) ;
176 SUPERV::GraphState State( const char * NodeName ,
177 const char * ServiceParameterName ) ;
179 SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
180 SUPERV::GraphState AutomatonGraphState(SUPERV::AutomatonState anAutomatonState) ;
182 SUPERV::AutomatonState AutomatonState() ;
183 SUPERV::AutomatonState AutomatonState( const char * NodeName ) ;
185 SUPERV::ControlState ControlState() ;
186 SUPERV::ControlState ControlState( const char * aNodeName ) ;
187 void ControlClear() ;
188 void ControlClear( const char * aNodeName ) ;
190 bool ContainerKill() ;
202 void Done( bool aDone ) { _Done = aDone ; } ;
203 bool Done() { return _Done ; } ;
208 bool IsWaiting( const char * NodeName ) ;
209 bool IsReady( const char * NodeName ) ;
210 bool IsRunning( const char * NodeName ) ;
211 bool IsDone( const char * NodeName ) ;
212 bool IsSuspended( const char * NodeName ) ;
213 bool IsDone( const char * NodeName ,
214 const char * ServiceParameterName ) ;
215 long LastLevelDone() ;
220 bool SuspendedWait() ;
221 bool ReadyWait( const char * NodeName ) ;
222 bool RunningWait( const char * NodeName ) ;
223 bool DoneWait( const char * NodeName ) ;
224 bool SuspendedWait( const char * NodeName ) ;
226 const CORBA::Any *GetInData( const char *ToNodeName ,
227 const char *ToParameterName ) ;
228 const CORBA::Any *GetOutData( const char *FromNodeName ,
229 const char *FromParameterName ) ;
230 const long CpuUsed() ;
231 const long CpuUsed( const char *aNodeName ) ;