X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGraphExecutor%2FDataFlowExecutor_FiniteStateMachine.hxx;h=f03fbdf7bf99189a714d36ced803fb2697a63169;hb=dad24b20fb0b0c18474caa7cb5b94652408b6743;hp=aaeac24bae251a39bfc69c04096b7ca6aaa0d7ea;hpb=c46f174ce52809de76f2a22795db89d229aedc7e;p=modules%2Fsuperv.git diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx index aaeac24..f03fbdf 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx @@ -34,52 +34,120 @@ #include #include +#include + +#include +#include + #include "DataFlowBase_Base.hxx" #include //#include CORBA_SERVER_HEADER(SUPERV) #include +class Graph_Impl ; + +namespace GraphBase { + class Graph ; +} + namespace GraphExecutor { - enum NodeEvent { UndefinedEvent , NewThreadEvent , - SuspendEvent , ToResumeEvent , ResumeEvent , - KillEvent , StopEvent , - ExecuteEvent , SuccessEvent , ErrorEvent , - ToReStartEvent , ReStartEvent , ReStartAndSuspendEvent , - EndExecuteEvent , - NoDataReadyEvent , SomeDataReadyEvent , - NotAllDataReadyEvent , AllDataReadyEvent , - ReadyEvent , SuspendedReadyEvent ,ResumedReadyEvent , - KilledReadyEvent , StoppedReadyEvent , - ExecutingEvent , SuspendedExecutingEvent , - ResumedExecutingEvent , KilledExecutingEvent , +//The AutomatonState is an internal state of the automaton of the Executor + enum AutomatonState { UnKnownState , + DataUndefState , + DataWaitingState , + DataReadyState , + SuspendedReadyState, + SuspendedReadyToResumeState , + ResumedReadyState , + KilledReadyState , + StoppedReadyState , + ExecutingState , + SuspendedExecutingState , + ResumedExecutingState , + KilledExecutingState , + StoppedExecutingState , + SuccessedExecutingState , + ErroredExecutingState , + SuspendedSuccessedState , + SuspendedErroredState, + ResumedSuccessedState , + ResumedErroredState , + KilledSuccessedState , + KilledErroredState , + StoppedSuccessedState , + StoppedErroredState , + SuccessedState , + ErroredState , + SuspendedState , + KilledState , + StoppedState , + SuspendedSuccessedToReStartState , + SuspendedErroredToReStartState , + ReStartedState , + LoadingState, + NumberOfAutomatonStates } ; + + enum NodeEvent { UndefinedEvent , + NewThreadEvent , + SuspendEvent , + ToResumeEvent , + ResumeEvent , + KillEvent , + StopEvent , + ExecuteEvent , + SuccessEvent , + ErrorEvent , + ToReStartEvent , + ReStartEvent , + ReStartAndSuspendEvent , + EndExecuteEvent , + NoDataReadyEvent , + SomeDataReadyEvent , + NotAllDataReadyEvent , + AllDataReadyEvent , + ReadyEvent , + SuspendedReadyEvent , + ResumedReadyEvent , + KilledReadyEvent , + StoppedReadyEvent , + ExecutingEvent , + SuspendedExecutingEvent , + ResumedExecutingEvent , + KilledExecutingEvent , StoppedExecutingEvent , - SuccessedExecutingEvent , ErroredExecutingEvent , - SuspendedSuccessedEvent , SuspendedErroredEvent , - ResumedSuccessedEvent , ResumedErroredEvent , - KilledEvent , StoppedEvent , - ReStartedEvent , ReStartedAndSuspendEvent , - NumberOfEvents } ; + SuccessedExecutingEvent , + ErroredExecutingEvent , + SuspendedSuccessedEvent , + SuspendedErroredEvent , + ResumedSuccessedEvent , + ResumedErroredEvent , + KilledEvent , + StoppedEvent , + ReStartedEvent , + ReStartedAndSuspendEvent , + NumberOfEvents } ; enum StateEventAction { ErrorAction , VoidAction , executeAction , // +- pthread_create ExecuteAction , // +- pthread_create - DataWaiting_SomeDataReadyAction , - DataUndef_NotAllDataReadyAction , - DataUndef_AllDataReadyAction , + DataWaiting_SomeDataReadyAction , + DataUndef_NotAllDataReadyAction , + DataUndef_AllDataReadyAction , DataReady_SuspendAction , SuspendedReady_ResumeAction , DataReady_KillAction , DataReady_StopAction , - DataReady_ExecuteAction , + DataReady_ExecuteAction , Executing_SuspendAction , SuspendedExecuting_ResumeAction , Executing_KillAction , Executing_StopAction , - Executing_SuccessAction , - Executing_ErrorAction , + Executing_SuccessAction , +// Executing_ErrorAction , + Errored_ExecutingAction , Successed_SuccessAction , Errored_ErrorAction , Successed_SuspendAction , @@ -90,10 +158,10 @@ namespace GraphExecutor { Errored_KillAction , Successed_StopAction , Errored_StopAction , - SuspendedSuccessed_ReStartAction , - SuspendedErrored_ReStartAction , - SuspendedSuccessed_ReStartAndSuspendAction , - SuspendedErrored_ReStartAndSuspendAction , + SuspendedSuccessed_ReStartAction , + SuspendedErrored_ReStartAction , + SuspendedSuccessed_ReStartAndSuspendAction , + SuspendedErrored_ReStartAndSuspendAction , NumberOfActions } ; class FiniteStateMachine { @@ -101,56 +169,97 @@ namespace GraphExecutor { private : char * _ControlStateName[ SUPERV::NumberOfControlStates ] ; - char * _StateName[ SUPERV::NumberOfAutomatonStates ] ; + char * _StateName[ GraphExecutor::NumberOfAutomatonStates ] ; char * _GraphStateName[ SUPERV::NumberOfGraphStates ] ; char * _EventName[ GraphExecutor::NumberOfEvents ] ; char * _ActionName[ NumberOfActions ] ; - SUPERV::AutomatonState _TransitionTable[ SUPERV::NumberOfAutomatonStates ] - [ GraphExecutor::NumberOfEvents ] ; - GraphExecutor::StateEventAction _ActionTable[ SUPERV::NumberOfAutomatonStates ] + GraphExecutor::AutomatonState _TransitionTable[ GraphExecutor::NumberOfAutomatonStates ] + [ GraphExecutor::NumberOfEvents ] ; + GraphExecutor::StateEventAction _ActionTable[ GraphExecutor::NumberOfAutomatonStates ] [ GraphExecutor::NumberOfEvents ] ; + pthread_mutex_t _MutexPythonWait ; + bool _MutexPythonLocked ; +// Map between FuncName and corresponding Python Object Function + map< string , PyObject * > _MapOfPyFunctions ; + bool _PyInitModule ; + int _ExecNumber ; + int _GraphExecutingNumber ; + + int _DbgFileNumber ; + +// fields and methods that use them are moved to GraphEditor::OutNode class (asv 20.09.04) +//map< string , GraphBase::Graph * > _MapOfGraphs ; +//map< string , int > _MapOfGraphNames ; + bool _JoinThread ; pthread_t _JoinThreadNo ; pthread_mutex_t _MutexJoinWait ; pthread_cond_t _JoinWait ; list< pthread_t > _ThreadList ; + Graph_Impl * _GraphImpl ; + public : FiniteStateMachine() ; virtual ~FiniteStateMachine() {} ; + int ExecNumber() ; + void Executed() ; + void PyInitModule(bool) ; + bool PyInitModule() ; + void PyLock() ; + void PyUnLock() ; + void PyLockReset() ; + bool PyFunction( const char * aPyFuncName , PyObject * aPyFunction ) ; + PyObject * PyFunction( const char * aPyFuncName ) ; + bool ErasePyFunction( const char * aPyFuncName ) ; + + + string DbgFileNumber() { + _DbgFileNumber += 1 ; + ostringstream astr ; + astr << _DbgFileNumber ; + return astr.str() ; } ; +/* + GraphBase::Graph * MapGraph( const char * aGraphName ) ; + bool MapGraph( GraphBase::Graph * aGraph , const char * aGraphName ) ; + void EraseGraph( const char * aGraphName ) ; + bool GraphName( const char * aGraphName ) ; + string GraphInstanceName( const char * aGraphName ) ; +*/ + void JoinThread() ; void JoinThread( pthread_t aThread ) ; - const char * ControlStateName( - const SUPERV::ControlState & aState ) const { + const char * ControlStateName( const SUPERV::ControlState & aState ) const { return _ControlStateName[ aState ] ; } ; - const char * StateName( - const SUPERV::AutomatonState & aState ) const { + const char * StateName( const GraphExecutor::AutomatonState & aState ) const { return _StateName[ aState ] ; } ; - const char * StateName( - const SUPERV::GraphState & aState ) const { + const char * StateName( const SUPERV::GraphState & aState ) const { return _GraphStateName[ aState ] ; } ; - const char * EventName( - const GraphExecutor::NodeEvent & anEvent ) const { + const char * EventName( const GraphExecutor::NodeEvent & anEvent ) const { return _EventName[ anEvent ] ; } ; - const char * ActionName( - const GraphExecutor::StateEventAction & anAction ) const { + const char * ActionName( const GraphExecutor::StateEventAction & anAction ) const { return _ActionName[ anAction ] ; } ; - const SUPERV::AutomatonState NextState( - const SUPERV::AutomatonState & aState , - const GraphExecutor::NodeEvent & anEvent ) const { + const GraphExecutor::AutomatonState NextState( const GraphExecutor::AutomatonState & aState , + const GraphExecutor::NodeEvent & anEvent ) const { return _TransitionTable[ aState ][ anEvent ] ; } ; - const GraphExecutor::StateEventAction NextAction( - const SUPERV::AutomatonState & aState , - const GraphExecutor::NodeEvent & anEvent ) const { + const GraphExecutor::StateEventAction NextAction( const GraphExecutor::AutomatonState & aState , + const GraphExecutor::NodeEvent & anEvent ) const { return _ActionTable[ aState ][ anEvent ] ; } ; + + void GraphImpl( Graph_Impl * aGraphImpl ) {// For GraphMNode ... + _GraphImpl = aGraphImpl ; } ; + Graph_Impl * GraphImpl() { + return _GraphImpl ; } ; }; }; +ostream & operator<< (ostream &f ,const GraphExecutor::AutomatonState & aState ) ; + #endif