#include "DataFlowEditor_DataFlow.hxx"
+// asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
+//extern Engines_Container_i * _TheContainer ;
+
extern GraphExecutor::FiniteStateMachine * theAutomaton ;
// static const char *ComponentName = "SalomeSuperVisionComponent" ;
GraphExecutor::OutNode::OutNode() {
// Graph() {
+ // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
+ //_SuperVisionContainer = _TheContainer ;
+ //_MainThreadId = SuperVisionContainer()->MainThreadId() ;
_Valid = false ;
_Executable = false ;
_Done = false ;
_prof_debug , _fdebug ) ;
_Graph = _StreamGraph ;
}
+ // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
+ //_SuperVisionContainer = _TheContainer ;
+ //_MainThreadId = SuperVisionContainer()->MainThreadId() ;
_Valid = false ;
_Executable = false ;
_Done = false ;
_prof_debug , _fdebug ) ;
_Graph = _StreamGraph ;
}
+ // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
+ //_SuperVisionContainer = _TheContainer ;
+ //_MainThreadId = SuperVisionContainer()->MainThreadId() ;
_Valid = false ;
_Executable = false ;
_Done = false ;
_Executable = false ;
if ( !Graph()->CreateService() ) {
- cdebug << "This DataFlow has invalid type(s)." << endl ;
+ cdebug_out << "This DataFlow has invalid type(s)." << endl ;
return false ;
}
int SubStreamGraphsNumber = 0 ;
if ( !Graph()->Sort( SubStreamGraphsNumber ) ) {
- cdebug << "This DataFlow is not valid." << endl ;
+ cdebug_out << "This DataFlow is not valid." << endl ;
return false ;
}
if ( Graph()->IsDataStreamNode() ) {
StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
}
+ if ( !Graph()->ValidLoops() ) {
+ cdebug_out << "This DataFlow have not valid Loops." << endl ;
+ return false ;
+ }
// CreateService() ;
bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
bool RetVal = false ;
- cdebug_in << "GraphExecutor::OutNode::Run( AndSuspend " << AndSuspend << " )" << endl;
+ cdebug_in << pthread_self() << "GraphExecutor::OutNode::Run( AndSuspend " << AndSuspend << " )"
+ << endl;
if ( Executable() ) {
_ControlState = SUPERV::VoidState ;
int i ;
for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ;
+ anInNode->OutNode( this ) ;
+// Initialize in python interpretor the python functions
if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) {
if ( !Py_IsInitialized() ) {
+// PyEval_InitThreads() ;
// Py_Initialize() ;
+ // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
+ // 1 line below uncommented
PySys_SetArgv( _ArgC , _ArgV ) ;
}
anInNode->InitPython() ;
PyInitialized( true ) ;
}
- anInNode->InitialState( this ) ;
+ anInNode->InitialState() ;
if ( anInNode->IsOneOfInLineNodes() ) {
anInNode->InitPythonFunctions( false ) ;
}
}
// PushEvent( anInNode , GraphExecutor::ReadyEvent ,
// GraphExecutor::DataReadyState ) ;
+// We say that we have to create a thread for that HeadNode 'anInNode'
anInNode->CreateNewThread( true ) ;
anInNode->DataFromNode( Graph()->Name() ) ;
+// AndSuspend == true <==> Start()
if ( AndSuspend ) {
anInNode->State( GraphExecutor::DataWaitingState ) ;
anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
+// We send SomeDataReadyEvent
+// It is a HeadNode ==> AllDataReadyEvent ==> InNode::executeAction() ==> pthread_create
if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
<< anInNode->Name() << endl ;
cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
return false ;
}
+// ==> We wait for SuspendedState
anInNode->SuspendedWait() ;
}
+// AndSuspend == false <==> Run()
else if ( anInNode->IsMacroNode() ) {
if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
}
cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWait"
<< endl ;
+// ==> We wait for RunningState
anInNode->RunningWait() ;
cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWaited"
<< endl ;
}
else if ( !anInNode->IsMacroNode() ) {
+// It is a HeadNode ==> AllDataReadyEvent ==> InNode::executeAction() ==> pthread_create
if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
cdebug << "InNode::SendEvent( ExecuteEvent ) ERROR Node "
<< anInNode->Name() << endl ;
cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
return false ;
}
+// ==> We wait for RunningState
anInNode->RunningWait() ;
}
}
}
}
- cdebug_out << "GraphExecutor::OutNode::Run " << Graph()->Name() << " GraphMacroLevel "
+ cdebug_out << pthread_self() << "GraphExecutor::OutNode::Run " << Graph()->Name()
+ << " GraphMacroLevel "
<< Graph()->GraphMacroLevel() << " RetVal " << RetVal << endl ;
return RetVal ;
}
-bool GraphExecutor::OutNode::Run( const char * aNodeName ,
- const char * AtNodeName ,
- const bool AndSuspend ) {
- bool RetVal = false ;
- cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , "
- << AtNodeName << " , " << AndSuspend << ")" << endl;
- GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ;
- if ( anInNode ) {
- RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ;
- }
- cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
- return RetVal ;
-}
-
void GraphExecutor::OutNode::CheckAllDone() {
int j ;
cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl;
aState == SUPERV::RunningState ||
aState == SUPERV::SuspendDoneState ||
aState == SUPERV::SuspendErroredState ||
- aState == SUPERV::ReRunState ||
- aState == SUPERV::ReStartState ||
aState == SUPERV::SuspendState ) {
alivenodes += 1 ;
}
<< _SuspendedThreads << " EventQSize " << EventQSize() << endl ;
}
+// asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL
+//Engines_Container_i * GraphExecutor::OutNode::SuperVisionContainer() {
+// return _SuperVisionContainer ;
+//}
+
+//const pthread_t GraphExecutor::OutNode::MainThreadId() const {
+// return _MainThreadId ;
+//}
+
void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) {
// if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) {
// cdebug << "GraphExecutor::OutNode::PThreadLock " << pthread_self() << " " << aMutex << " "
aGraphEvent = SUPERV::ErroredEvent ;
break ;
}
- case GraphExecutor::ReStartEvent : {
- aGraphEvent = SUPERV::ReRunEvent ;
- break ;
- }
- case GraphExecutor::ReStartAndSuspendEvent : {
- aGraphEvent = SUPERV::ReStartEvent ;
- break ;
- }
case GraphExecutor::NoDataReadyEvent : {
aGraphEvent = SUPERV::WaitingEvent ;
break ;
aGraphEvent = SUPERV::StopEvent ;
break ;
}
- case GraphExecutor::ReStartedEvent : {
- aGraphEvent = SUPERV::ReRunEvent ;
- break ;
- }
- case GraphExecutor::ReStartedAndSuspendEvent : {
- aGraphEvent = SUPERV::ReStartEvent ;
- break ;
- }
case GraphExecutor::EndExecuteEvent : {
aGraphEvent = SUPERV::DoneEvent ;
break ;
aGraphState = SUPERV::StopState ;
break ;
}
- case GraphExecutor::ReRunnedState : {
- aGraphState = SUPERV::ReRunState ;
- break ;
- }
- case GraphExecutor::ReStartedState : {
- aGraphState = SUPERV::ReStartState ;
- break ;
+ case GraphExecutor::LoadingState : {
+ aGraphState = SUPERV::LoadingState ;
+ break;
}
default : {
cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : "
int ThreadsNumber ;
int SuspendedThreadsNumber ;
+ bool cdebuginout = false ;
if ( _EventNodes.size() > 0 ) {
- cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
+// cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
+ cdebuginout = true ;
}
if ( pthread_mutex_lock( &_MutexWait ) ) {
perror("EventLoop pthread_mutex_lock ") ;
perror("EventLoop pthread_mutex_lock ") ;
exit( 0 ) ;
}
- if ( _EventNodes.size() > 0 ) {
- cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue "
- << *aNodeName << " " << anEvent << " " << aState << endl ;
+ if ( cdebuginout ) {
+// cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue"
+// << *aNodeName << " " << anEvent << " " << aState << endl ;
}
return RetVal ;
}
if ( aCNode ) {
GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ;
if ( anInNode ) {
- aret = anInNode->State() ;
+ if ( anInNode->IsLoading() )
+ aret = GraphExecutor::LoadingState;
+ else
+ aret = anInNode->State() ;
// cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
// << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
}
bool GraphExecutor::OutNode::IsSuspended() {
// cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl;
bool aret = false ;
- if ( _SuspendedThreads == _Threads && _Threads != 0 ) {
+// if ( _SuspendedThreads == _Threads && _Threads != 0 ) {
+ if ( AutomatonGraphState( _State ) == SUPERV::SuspendState ) {
aret = true ;
}
// cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
RetVal += 1 ;
cdebug << aNode->Name() << " Suspended" << endl ;
}
- else if ( aNode->IsWaiting() || aNode->IsDone() ) {
+ else if ( aNode->IsWaiting() || aNode->IsReady() ) {
+ RetVal += 1 ;
+ cdebug << aNode->Name() << " will be Suspended" << endl ;
+ }
+ else if ( aNode->IsDone() ) {
cdebug << aNode->Name() << " not Suspended : "
<< theAutomaton->StateName( aNode->State() ) << endl ;
}
else {
- RetVal += 1 ;
+// RetVal += 1 ;
cdebug << aNode->Name() << " cannot be Suspended : "
<< theAutomaton->StateName( aNode->State() ) << endl ;
}
MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ;
MESSAGE("================================================================================") ;
}
- cdebug_out << "GraphExecutor::OutNode::Suspend" << theAutomaton->StateName( State() ) << endl ;
+ for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+ MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ;
+ cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::Suspend " << theAutomaton->StateName( State() )
+ << " EventQSize " << EventQSize() << endl ;
return RetVal ;
}
bool GraphExecutor::OutNode::Resume() {
int RetVal = 0 ;
- cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
+ cdebug_in << "GraphExecutor::OutNode::Resume "
+ << theAutomaton->StateName( State() ) << endl;
if ( IsSuspended() ) {
State( GraphExecutor::ExecutingState ) ;
int i ;
MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ;
MESSAGE("================================================================================") ;
}
- cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal << endl ;
+ int i ;
+ for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+ MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ;
+ cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal
+ << " EventQSize " << EventQSize() << endl ;
return RetVal ;
}
bool GraphExecutor::OutNode::Kill() {
- bool RetVal = true ;
- cdebug_in << "GraphExecutor::OutNode::Kill" << endl;
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::Kill"
+ << " EventQSize " << EventQSize() << endl;
_ControlState = SUPERV::ToSuspendState ;
int i ;
for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
bool sts = aNode->Kill() ;
- if ( sts && aNode->IsKilled() ) {
- cdebug << aNode->Name() << " killed" << endl ;
+ if ( sts && Threads() != 0 ) {
+ if ( !aNode->IsKilled() ) {
+ cdebug << aNode->Name() << " not killed : "
+ << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
+ << "KilledAction()" << endl ;
+ MESSAGE( aNode->Name() << " not killed : KilledAction()" ) ;
+ aNode->KilledAction() ;
+ }
+ if ( aNode->IsKilled() ) {
+ cdebug << aNode->Name() << " killed" << endl ;
+ RetVal = true ;
+ }
}
else if ( aNode->IsWaiting() || aNode->IsDone() ) {
cdebug << aNode->Name() << " not killed : "
else {
cdebug << aNode->Name() << " cannot be killed : "
<< theAutomaton->StateName( aNode->State() ) << endl ;
- RetVal = false ;
- }
- }
- if ( !RetVal || Threads() != 0 ) {
- for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
- GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
- if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
- cdebug << aNode->Name() << " not killed : "
- << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
- << "KilledAction()" << endl ;
- aNode->KilledAction() ;
- }
}
- RetVal = true ;
}
- State( GraphExecutor::KilledState ) ;
if ( RetVal ) {
+ State( GraphExecutor::KilledState ) ;
MESSAGE("================================================================================") ;
MESSAGE( Graph()->Name() << " IS KILLED" << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
<< EventQSize() ) ;
MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ;
MESSAGE("================================================================================") ;
}
+ for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
+ MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ;
+ cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
cdebug_out << "GraphExecutor::OutNode::Kill " << RetVal
- << " Threads " << _Threads << " SuspendedThreads " << _SuspendedThreads << endl ;
+ << " Threads " << _Threads << " SuspendedThreads " << _SuspendedThreads
+ << " EventQSize " << EventQSize() << endl ;
// remove "extra" events from the event queue
siftEvents();
}
return RetVal ;
}
-bool GraphExecutor::OutNode::ReRun() {
- bool RetVal = false ;
- cdebug_in << "GraphExecutor::OutNode::ReRun" << endl;
- if ( IsSuspended() ) {
- }
- cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ;
- return RetVal ;
-}
-bool GraphExecutor::OutNode::ReStart() {
- bool RetVal = false ;
- cdebug_in << "GraphExecutor::OutNode::ReStart" << endl;
- if ( IsSuspended() ) {
- }
- cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ;
- return RetVal ;
-}
bool GraphExecutor::OutNode::ReadyWait() {
cdebug_in << "GraphExecutor::OutNode::ReadyWait" << endl;