bool &_ResumeSync ,
pthread_cond_t &_KillWait ,
bool &_KillSync ,
+ pthread_cond_t &_ThreadStartedWait ,
+ bool &_ThreadStartedSync ,
pthread_cond_t &_StopWait ,
GraphExecutor::FiniteStateMachine ** _Automaton ,
GraphExecutor::FiniteStateMachine * theAutomaton ,
exit( 0 ) ;
}
_KillSync = false ;
+ if ( pthread_cond_init( &_ThreadStartedWait , NULL ) ) {
+ perror("pthread_cond_init( &_ThreadStartedWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ _ThreadStartedSync = false ;
if ( pthread_cond_init( &_StopWait , NULL ) ) {
perror("pthread_cond_init( &_StopWait , NULL )") ;
exit( 0 ) ;
*_Orb = CORBA::ORB::_nil();
}
-GraphExecutor::FiniteStateMachine * theAutomaton = new
- GraphExecutor::FiniteStateMachine() ;
+GraphExecutor::FiniteStateMachine * theAutomaton = new GraphExecutor::FiniteStateMachine() ;
//GraphExecutor::InNode::InNode() :
// GraphBase::FactoryNode() {
_ResumeSync ,
_KillWait ,
_KillSync ,
+ _ThreadStartedWait ,
+ _ThreadStartedSync ,
_StopWait ,
&_Automaton ,
theAutomaton ,
CORBA::ORB::_nil() ) ;
}
-GraphExecutor::InNode::InNode(CORBA::ORB_ptr ORB,
- SALOME_NamingService* ptrNamingService ,
- const SALOME_ModuleCatalog::Service& aService ,
- const char * ComponentName ,
- const char * NodeInterfaceName ,
- const char * NodeName ,
- const SUPERV::KindOfNode akind ,
- GraphBase::ListOfFuncName aFuncName ,
- GraphBase::ListOfPythonFunctions aPythonFunction ,
- const SUPERV::SDate NodeFirstCreation ,
- const SUPERV::SDate NodeLastModification ,
- const char * NodeEditorRelease ,
- const char * NodeAuthor ,
- const char * NodeComputer ,
- const char * NodeComment ,
- const bool GeneratedName ,
- const int NodeX ,
- const int NodeY ,
- int * Graph_prof_debug,
- ofstream * Graph_fdebug) {
+GraphExecutor::InNode::InNode( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const SALOME_ModuleCatalog::Service& aService ,
+ const char * ComponentName ,
+ const char * NodeInterfaceName ,
+ const char * NodeName ,
+ const SUPERV::KindOfNode akind ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const bool GeneratedName ,
+ const int NodeX ,
+ const int NodeY ,
+ int * Graph_prof_debug,
+ ofstream * Graph_fdebug) {
// ostream * Graph_fdebug = NULL ) :
// GraphBase::FactoryNode( ORB , ptrNamingService , aService ,
// ComponentName , NodeInterfaceName ,
_ResumeSync ,
_KillWait ,
_KillSync ,
+ _ThreadStartedWait ,
+ _ThreadStartedSync ,
_StopWait ,
&_Automaton ,
theAutomaton ,
bool RetVal ;
if ( IsDone() ) {
ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else if ( IsWaiting() || IsReady() ) {
}
else if ( IsRunning() ) {
ControlState( SUPERV::ToSuspendState ) ;
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
if ( !CORBA::is_nil( Component() ) ) {
RetVal = Component()->Suspend_impl() ;
if ( RetVal ) {
if ( IsRunning() ) {
+ cdebug << pthread_self() << "GraphExecutor::InNode::Suspend_impl " << Name()
+ << " --> thread" << ThreadNo() << " SuspendEvent " << endl;
SendEvent( GraphExecutor::SuspendEvent ) ;
+ cdebug << pthread_self() << "GraphExecutor::InNode::Suspended_impl in Container"
+ << Name() << " --> thread" << ThreadNo() << endl;
}
else if ( IsDone() ) {
ControlState( SUPERV::VoidState ) ;
<< endl ;
RetVal = false ;
}
- cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << endl ;
+ cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << " "
+ << Automaton()->StateName( State() ) << endl ;
return RetVal ;
}
bool RetVal ;
if ( IsFactoryNode() ) {
Kill() ;
- Container()->Kill_impl() ;
+ RetVal = Container()->Kill_impl() ;
}
cdebug_out << "GraphExecutor::InNode::ContainerKill" << endl ;
return RetVal ;
cdebug_in << "GraphExecutor::InNode::Kill " << Name() << " " << ThreadNo() << " "
<< Automaton()->StateName( State() ) << endl;
bool RetVal ;
- if ( ControlState() == SUPERV::ToKillState || IsDone() ) {
+ if ( IsDone() ) {
+ ControlState( SUPERV::ToKillState ) ; // if loop
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
ControlState( SUPERV::ToKillState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
if ( IsRunning() ) {
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
if ( !CORBA::is_nil( Component() ) ) {
RetVal = Component()->Kill_impl() ;
- if ( RetVal ) {
- if ( IsRunning() ) {
- SendEvent( GraphExecutor::KillEvent ) ;
- }
- else if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
- RetVal = false ; // Too late ...
- }
- else {
- cdebug << "component Killed and !IsDone and !IsRunning !"
- << endl ;
- }
+ cdebug << "Component()->Kill_impl() returns status " << RetVal << endl ;
+ RetVal = true ;
+ if ( IsRunning() ) {
+ cdebug << pthread_self() << "GraphExecutor::InNode::Kill_impl " << Name()
+ << " --> thread" << ThreadNo() << " SuspendEvent " << endl;
+ SendEvent( GraphExecutor::KillEvent ) ;
+ cdebug << pthread_self() << "GraphExecutor::InNode::Killed_impl in Container"
+ << Name() << " --> thread" << ThreadNo() << endl;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ; // Too late ...
+ }
+ else {
+ cdebug << "component Killed and !IsDone and !IsRunning !"
+ << endl ;
}
}
else {
- cdebug << "Kill cannot Kill component !" << endl ;
+ cdebug << "Kill with nilComponent cannot Kill component !" << endl ;
RetVal = false ;
}
}
- else {
- cdebug << "Kill with nilComponent while RunningState !" << endl ;
- SendEvent( GraphExecutor::KillEvent ) ;
- RetVal = IsKilled() ;
- }
}
else if ( IsSuspended() ) {
- SendEvent( GraphExecutor::KillEvent ) ;
+ cdebug << pthread_self() << "GraphExecutor::InNode::Kill " << Name()
+ << " --> thread" << ThreadNo() << " Resume()" << endl;
+ Resume() ;
RetVal = true ;
}
else if ( IsWaiting() ) {
else {
ControlState( SUPERV::ToKillDoneState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
if ( IsRunning() ) {
- if ( IsFactoryNode() ) {
- if ( !CORBA::is_nil( Component() ) ) {
- RetVal = Component()->Kill_impl() ;
- if ( RetVal ) {
- if ( IsRunning() ) {
- SendEvent( GraphExecutor::SuspendEvent ) ;
- }
- else if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
- RetVal = false ; // Too late ...
- }
- else {
- cdebug << "component Suspended and !IsDone and !IsRunning !"
- << endl ;
- }
- }
- }
- else {
- cdebug << "Suspend cannot Suspend component !" << endl ;
- RetVal = false ;
- }
- }
- else {
- cdebug << "Suspend with nilComponent while RunningState !" << endl ;
- RetVal = false ;
- }
+ RetVal = true ;
}
else if ( IsWaiting() ) {
RetVal = true ;
}
else {
- cdebug << "Suspend and !IsDone and !IsRunning and !IsWaiting ?"
+ cdebug << "KillDone and !IsDone and !IsRunning and !IsWaiting ?"
<< endl ;
RetVal = false ;
}
else {
ControlState( SUPERV::ToStopState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
if ( IsRunning() ) {
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
if ( !CORBA::is_nil( Component() ) ) {
RetVal = Component()->Stop_impl() ;
if ( RetVal ) {
if ( IsRunning() ) {
- SendEvent( GraphExecutor::SuspendEvent ) ;
+ SendEvent( GraphExecutor::StopEvent ) ;
}
else if ( IsDone() ) {
ControlState( SUPERV::VoidState ) ;
else {
ControlState( SUPERV::ToSuspendDoneState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
RetVal = true ;
}
else if ( State() == SUPERV::SuspendedExecutingState ) {
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
RetVal = Component()->Resume_impl() ;
}
}
else if ( State() == SUPERV::SuspendedSuccessedState ) {
- ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ ResumeAction( GraphExecutor::ResumeEvent ) ;
RetVal = true ;
}
else if ( State() == SUPERV::SuspendedErroredState ) {
- ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ ResumeAction( GraphExecutor::ResumeEvent ) ;
RetVal = true ;
}
else {
<< anOutPort->IsPortConnected() << ") DataConnected("
<< anOutPort->IsDataConnected() << ")" << endl ;
}
-
- if ( !PyFuncRunned() ) {
- bool Err = false ;
- if ( IsLoopNode() ) {
- PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
- InLineNode()->PythonFunction() ) ;
- InLineNode()->PyRunMethod( PyRunMethod ) ;
- PyObject * PyMoreMethod = NULL ;
- if ( PyRunMethod ) {
- PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
- LoopNode()->MorePythonFunction() ) ;
- LoopNode()->PyMoreMethod( PyMoreMethod ) ;
- }
- PyObject * PyNextMethod = NULL ;
- if ( PyMoreMethod ) {
- PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
- LoopNode()->NextPythonFunction() ) ;
- LoopNode()->PyNextMethod( PyNextMethod ) ;
- }
- Err = !PyRunMethod || !PyMoreMethod || !PyNextMethod ;
- }
- else if ( IsInLineNode() || IsSwitchNode() ) {
- PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
- InLineNode()->PythonFunction() ) ;
- InLineNode()->PyRunMethod( PyRunMethod ) ;
- Err = !PyRunMethod ;
- }
- else if ( ( IsEndSwitchNode() || IsGOTONode() ) &&
- (*InLineNode()->PythonFunction()).length() ) {
- PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
- InLineNode()->PythonFunction() ) ;
- InLineNode()->PyRunMethod( PyRunMethod ) ;
- Err = !PyRunMethod ;
- }
- }
}
_currentState = Pc > 0 ? SUPERV::DataWaitingState
cdebug_out << "GraphExecutor::InNode::InitialState" << endl;
}
+bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
+ cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << endl;
+ bool Err = false ;
+ if ( !PyFuncRunned() && IsOneOfInLineNodes() ) {
+ if ( IsLoopNode() ) {
+ PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
+ if ( PyRunMethod ) {
+ }
+ else {
+ PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ }
+ PyObject * PyMoreMethod = LoopNode()->PyMoreMethod() ;
+ if ( PyMoreMethod ) {
+ }
+ else {
+ PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
+ LoopNode()->MorePythonFunction() ) ;
+ LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+ }
+ PyObject * PyNextMethod = LoopNode()->PyNextMethod() ;
+ if ( PyNextMethod ) {
+ }
+ else {
+ PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
+ LoopNode()->NextPythonFunction() ) ;
+ LoopNode()->PyNextMethod( PyNextMethod ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) " << PyRunMethod
+ << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod << endl;
+ Err = !PyRunMethod || !PyMoreMethod || !PyNextMethod ;
+ }
+ else if ( IsInLineNode() || IsSwitchNode() ) {
+ PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
+ if ( PyRunMethod ) {
+ }
+ else {
+ PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
+ Err = !PyRunMethod ;
+ }
+ else if ( ( IsEndLoopNode() || IsEndSwitchNode() || IsGOTONode() ) &&
+ (*InLineNode()->PythonFunction()).length() ) {
+ PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
+ if ( PyRunMethod ) {
+ }
+ else {
+ PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
+ Err = !PyRunMethod ;
+ }
+ }
+ Err = WithErr && Err ;
+ cdebug_out << "GraphExecutor::InNode::InitPythonFunctions " << Name() ;
+ if ( Err ) {
+ cdebug << " Error " << Err ;
+ }
+ cdebug << endl;
+ return Err ;
+}
+
const long GraphExecutor::InNode::CpuUsed( bool tot ) {
CORBA::Long cpu = 0 ;
// cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ;