#define SuspendedState GraphExecutor::SuspendedState
#define KilledState GraphExecutor::KilledState
#define StoppedState GraphExecutor::StoppedState
-#define ReRunnedState GraphExecutor::ReRunnedState
#define ReStartedState GraphExecutor::ReStartedState
+#define LoadingState GraphExecutor::LoadingState
#define NumberOfAutomatonStates GraphExecutor::NumberOfAutomatonStates
#endif
#define NumberOfEvents GraphExecutor::NumberOfEvents
GraphExecutor::FiniteStateMachine::FiniteStateMachine() {
-// cdebug_in << "FiniteStateMachine::FiniteStateMachine" << endl;
+ MESSAGE( "FiniteStateMachine::FiniteStateMachine" ) ;
_ControlStateName[ VoidState ] = "VoidState" ;
_ControlStateName[ ToSuspendStartState ]= "ToSuspendStartState" ;
_StateName[ SuspendedState ] = "SuspendedState" ;
_StateName[ KilledState ] = "KilledState" ;
_StateName[ StoppedState ] = "StoppedState" ;
- _StateName[ ReRunnedState ] = "ReRunnedState" ;
_StateName[ ReStartedState ] = "ReStartedState" ;
+ _StateName[ LoadingState ] = "LoadingState" ;
_EventName[ UndefinedEvent ] = "UndefinedEvent" ;
_EventName[ NewThreadEvent ] = "NewThreadEvent" ;
_ActionName[ Executing_StopAction ] = "Executing_StopAction" ;
_ActionName[ Executing_SuccessAction ] = "Executing_SuccessAction" ;
- _ActionName[ Executing_ErrorAction ] = "Executing_ErrorAction" ;
+// _ActionName[ Executing_ErrorAction ] = "Executing_ErrorAction" ;
+ _ActionName[ Errored_ExecutingAction ] = "Errored_ExecutingAction" ;
_ActionName[ Successed_SuccessAction ] = "Successed_SuccessAction" ;
_ActionName[ Errored_ErrorAction ] = "Errored_ErrorAction" ;
_GraphStateName[ SUPERV::SuspendErroredState ] = "SuspendErroredState" ;
_GraphStateName[ SUPERV::KillState ] = "KillState" ;
_GraphStateName[ SUPERV::StopState ] = "StopState" ;
- _GraphStateName[ SUPERV::ReRunState ] = "ReRunState" ;
- _GraphStateName[ SUPERV::ReStartState ] = "ReStartState" ;
int i , j ;
// NewStates = _TransitionTable[ States ] [ Events ]
// SuspendedExecutingState : NO ResumeEvent 13-03-2003
_TransitionTable[ SuspendedExecutingState ][ SuccessEvent ] = SuccessedExecutingState ;
_ActionTable[ SuccessedExecutingState ][ SuccessEvent ] = Executing_SuccessAction;
+//JR 24.03.2005 : Debug for PAL8176 : abort of GOTONode
+// ErrorEvent
+ _TransitionTable[ SuccessedState ][ ErrorEvent ] = ErroredExecutingState ;
+// _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+ _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Errored_ExecutingAction;
// ErrorEvent
_TransitionTable[ ExecutingState ][ ErrorEvent ] = ErroredExecutingState ;
- _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+// _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+ _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Errored_ExecutingAction;
// SuspendedExecutingState : NO ResumeEvent 13-03-2003
_TransitionTable[ SuspendedExecutingState ][ ErrorEvent ] = ErroredExecutingState ;
- _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+// _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+ _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Errored_ExecutingAction;
// DONE-CONTROL :
// SuccessedExecutingState - SuccessEvent
perror( msg ) ;
}
+#if omniORB_4_0_5
+ _SuperVisionComponent = SUPERV::SuperG::_nil() ;
+#endif
+
pthread_mutex_init( &_MutexPythonWait , NULL ) ;
+ _MutexPythonLocked = false ;
_ExecNumber = 0 ;
_GraphExecutingNumber = 0 ;
_PyInitModule = false ;
_DbgFileNumber = 0 ;
-// cdebug_out << "FiniteStateMachine::FiniteStateMachine _TransitionTable "
-// << endl;
+ MESSAGE( "FiniteStateMachine::FiniteStateMachine _TransitionTable " ) ;
}
void * start_function( void *p ) {
for ( aPyFunction = _MapOfPyFunctions.begin() ; aPyFunction != _MapOfPyFunctions.end() ; aPyFunction++ ) {
if ( !strcmp( aPyFunction->first.c_str() , "PyObjRef" ) ||
!strcmp( aPyFunction->first.c_str() , "PyObjIor" ) ) {
- //cout << "GraphExecutor::FiniteStateMachine::Executed " << aPyFunction->first << " keeped ..."<< endl ;
+ MESSAGE( "GraphExecutor::FiniteStateMachine::Executed " << aPyFunction->first << " keeped ..."
+ ) ;
}
else {
- //cout << "GraphExecutor::FiniteStateMachine::Executed " << aPyFunction->first << " erased ..."<< endl ;
+ MESSAGE( "GraphExecutor::FiniteStateMachine::Executed " << aPyFunction->first << " erased ..."
+ ) ;
_MapOfPyFunctions.erase( aPyFunction->first ) ;
}
}
}
else {
- //cout << "GraphExecutor::FiniteStateMachine::Executed _GraphExecutingNumber " << _GraphExecutingNumber
- // << " != 0 ==> no erase" << endl ;
+ MESSAGE( "GraphExecutor::FiniteStateMachine::Executed _GraphExecutingNumber "
+ << _GraphExecutingNumber << " != 0 ==> no erase" ) ;
}
PyUnLock() ;
return ;
}
+void GraphExecutor::FiniteStateMachine::PyInitModule( bool aPyInitModule ) {
+ _PyInitModule = aPyInitModule ;
+}
+
bool GraphExecutor::FiniteStateMachine::PyInitModule() {
bool InitedModule = _PyInitModule ;
_PyInitModule = true ;
perror( "GraphExecutor::FiniteStateMachine::PyLock" ) ;
exit( 0 ) ;
}
+ _MutexPythonLocked = true ;
// cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyLocked " << &_MutexPythonWait << endl ;
}
perror( "GraphExecutor::FiniteStateMachine::PyUnLock" ) ;
exit( 0 ) ;
}
+ _MutexPythonLocked = false ;
// cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyUnLocked " << &_MutexPythonWait << endl ;
}
+void GraphExecutor::FiniteStateMachine::PyLockReset() {
+ if ( _MutexPythonLocked ) {
+ PyUnLock() ;
+ }
+}
+
+#define PyFunctionTrace 1
PyObject * GraphExecutor::FiniteStateMachine::PyFunction( const char * aPyFuncName ) {
PyObject * RetVal = NULL ;
PyObject * PyFunctionMapped = _MapOfPyFunctions[ aPyFuncName ] ;
if ( _GraphExecutingNumber > 1 && !PyObjRefIor ) {
RetVal = PyFunctionMapped ;
- //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) --> " ;
+#if PyFunctionTrace
+ MESSAGE( "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) --> " ) ;
if ( RetVal ) {
- //cout << RetVal << " ob_refcnt " << RetVal->ob_refcnt ;
+ MESSAGE( RetVal << " ob_refcnt " << RetVal->ob_refcnt ) ;
}
else {
- //cout << " NULL" ;
+ MESSAGE( " NULL" ) ;
}
- //cout << endl ;
+#endif
}
else {
RetVal = PyFunctionMapped ;
- //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) --> " ;
+#if PyFunctionTrace
+ MESSAGE( "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) --> " ) ;
if ( RetVal && PyObjRefIor ) {
- //cout << RetVal << " " << RetVal->ob_refcnt << endl ;
+ MESSAGE( RetVal << " " << RetVal->ob_refcnt ) ;
}
else if ( RetVal ) {
- //cout << RetVal << " " << RetVal->ob_refcnt << endl ;
-// _MapOfPyFunctions.erase( aPyFuncName ) ;
-// cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) erased --> NULL" << endl ;
+ MESSAGE( RetVal << " " << RetVal->ob_refcnt ) ;
}
else {
- //cout << " NULL" << endl ;
+ MESSAGE( " NULL" ) ;
}
+#endif
}
return RetVal ;
bool RetVal = false ;
if ( _MapOfPyFunctions[ aPyFuncName ] != NULL ) {
- //PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ;
- //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , " << aPyFunction
- // << " ) ob_refcnt " << aPyFunction->ob_refcnt << " already mapped : " << aPyFunc << " ob_refcnt "
- // << aPyFunc->ob_refcnt << endl ;
+#if PyFunctionTrace
+ PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ;
+ MESSAGE( "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , aPyFunction "
+ << aPyFunction << " ) ob_refcnt " << aPyFunction->ob_refcnt << " already mapped : "
+ << aPyFunc << " ob_refcnt " << aPyFunc->ob_refcnt ) ;
+#endif
}
else {
_MapOfPyFunctions[ aPyFuncName ] = aPyFunction ;
- //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , " << aPyFunction
- // << " ) ob_refcnt " << aPyFunction->ob_refcnt << " mapped" << endl ;
+#if PyFunctionTrace
+ MESSAGE( "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) " << aPyFunction
+ << " ) ob_refcnt " << aPyFunction->ob_refcnt << " mapped" ) ;
+#endif
RetVal = true ;
}
return RetVal ;
}
+bool GraphExecutor::FiniteStateMachine::ErasePyFunction( const char * aPyFuncName ) {
+
+#if PyFunctionTrace
+ MESSAGE( "GraphExecutor::FiniteStateMachine::ErasePyFunction( '" << aPyFuncName << "' )" ) ;
+#endif
+ if ( _MapOfPyFunctions[ aPyFuncName ] != NULL ) {
+ _MapOfPyFunctions.erase( aPyFuncName ) ;
+ return true ;
+ }
+ return false ;
+}
+
+/*
GraphBase::Graph * GraphExecutor::FiniteStateMachine::MapGraph( const char * aGraphName ) {
GraphBase::Graph * aGraph = _MapOfGraphs[ aGraphName ] ;
//cout << "MapGraph " << aGraphName << " --> " << aGraph << endl ;
// << theGraphInstanceName << endl ;
return theGraphInstanceName ;
}
+*/
void GraphExecutor::FiniteStateMachine::JoinThread() {
if ( pthread_mutex_lock( &_MutexJoinWait ) ) {
- perror("Join pthread_mutex_lock ") ;
+ perror("FiniteStateMachine:JoinThread pthread_mutex_lock ") ;
exit( 0 ) ;
}
while ( _JoinThread ) {
while ( _ThreadList.size() == 0) {
-// MESSAGE( pthread_self() << " Join pthread_cond_wait" );
+// MESSAGE( pthread_self() << " FiniteStateMachine:Join pthread_cond_wait" );
if ( pthread_cond_wait( &_JoinWait , &_MutexJoinWait ) ) {
- perror("Join pthread_cond_wait ") ;
+ perror("FiniteStateMachine:JoinThread pthread_cond_wait ") ;
}
}
pthread_t _Thread = _ThreadList.front() ;
-// MESSAGE( pthread_self() << " Join pthread_cond_waited : " << _Thread )
- _ThreadList.pop_front() ;
-// MESSAGE( pthread_self() << " Join pthread_join : " << _Thread );
+// MESSAGE( pthread_self() << " FiniteStateMachine:JoinThread pthread_cond_waited : " << _Thread )
+// MESSAGE( pthread_self() << " FiniteStateMachine:JoinThread pthread_join : " << _Thread );
int joinsts = pthread_join( _Thread , NULL ) ;
-// MESSAGE( pthread_self() << " Join pthread_joined : " << _Thread );
if ( joinsts ) {
- perror("Join pthread_join ") ;
-// exit( 0 ) ;
+ perror("FiniteStateMachine:JoinThread pthread_join ") ;
+ MESSAGE( pthread_self() << " FiniteStateMachine:JoinThread pthread_join : " << _Thread
+ << " Error" );
+ exit( 0 ) ;
+ }
+ else {
+// MESSAGE( pthread_self() << " FiniteStateMachine:JoinThread pthread_joined : " << _Thread );
+ _ThreadList.pop_front() ;
}
}
if ( pthread_mutex_unlock( &_MutexJoinWait ) ) {
- perror("Join pthread_mutex_unlock ") ;
+ perror("FiniteStateMachine:JoinThread pthread_mutex_unlock ") ;
exit( 0 ) ;
}
}
case GraphExecutor::SuspendedErroredToReStartState :
f << "SuspendedErroredToReStartState";
break;
- case GraphExecutor::ReRunnedState :
- f << "ReRunnedState";
- break;
case GraphExecutor::ReStartedState :
f << "ReStartedState";
break;
+ case GraphExecutor::LoadingState :
+ f << "LoadingState";
+ break;
default :
f << "GraphExecutor::AutomatonState_?";
break;