Salome HOME
InitLoop and DoLoop parameters names
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.cxx
index 8d97e500e0f1787d215a73bf450368e63e71174f..2a92e6c76a13ece8a7fafa2d47fbacaed3859d61 100644 (file)
@@ -448,17 +448,21 @@ bool GraphExecutor::OutNode::Valid() {
   _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() ;
 
@@ -506,6 +510,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
     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() ;
@@ -578,19 +583,25 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
         }
 //        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 "
@@ -600,17 +611,20 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
          }
           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() ;
         }
       }
@@ -639,20 +653,6 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
   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;
@@ -707,8 +707,6 @@ void GraphExecutor::OutNode::CheckAllDone() {
                   aState == SUPERV::RunningState ||
                   aState == SUPERV::SuspendDoneState ||
                   aState == SUPERV::SuspendErroredState ||
-                  aState == SUPERV::ReRunState ||
-                  aState == SUPERV::ReStartState ||
                   aState == SUPERV::SuspendState ) {
           alivenodes += 1 ;
        }
@@ -944,14 +942,6 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No
     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 ;
@@ -1040,14 +1030,6 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No
     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 ;
@@ -1176,13 +1158,9 @@ SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(GraphExecutor::Au
     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 : "
@@ -1533,7 +1511,10 @@ SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) {
   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 ;
     }
@@ -1872,7 +1853,7 @@ bool GraphExecutor::OutNode::Kill() {
   for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) {
     GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ;
     bool sts = aNode->Kill() ;
-    if ( sts ) {
+    if ( sts && Threads() != 0 ) {
       if ( !aNode->IsKilled() ) {
         cdebug << aNode->Name() << " not killed : "
                << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
@@ -1936,22 +1917,6 @@ bool GraphExecutor::OutNode::Stop() {
   }
   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;