Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_InNode.cxx
index 028a97034ffba4c5a5ac954e73f4dd5c34acddec..bd312f42f758ac346eb7bd066f2b287f95a446b2 100644 (file)
@@ -1394,8 +1394,8 @@ void GraphExecutor::InNode::InitialState()
       anOutPort->PortDone( true ) ;
 //JR 21.02.2005 Debug Memory leak :      CORBA::Any * anAny = new CORBA::Any() ;
       CORBA::Any anAny = CORBA::Any() ;
-//JR 21.02.2005 Debug Memory leak :      *anAny <<= (long ) 1 ;
-      anAny <<= (long ) 1 ;
+//JR 21.02.2005 Debug Memory leak :      *anAny <<= (CORBA::Long ) 1 ;
+      anAny <<= (CORBA::Long ) 1 ;
       anOutPort->SetValue( anAny ) ;
       _InitLoop = true ;
       cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
@@ -1521,6 +1521,7 @@ void GraphExecutor::InNode::InitialState()
 }
 
 bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
+  //JR Look at DataFlowExecutor for the meaning of WithErr
   cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " WithErr " << WithErr
             << " PyFuncRunned() " << PyFuncRunned() << endl;
   bool Err = false ;
@@ -1537,7 +1538,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
                                        InLineNode()->PythonFunction() ,
                                        OneErr ) ;
-        InLineNode()->PyRunMethod( PyRunMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyRunMethod ) {
+          InLineNode()->PyRunMethod( PyRunMethod ) ;
+       }
+        else if ( WithErr && strlen( InLineNode()->PyFuncName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1554,7 +1561,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
                                         LoopNode()->MorePythonFunction() ,
                                         OneErr ) ;
-        LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyMoreMethod ) {
+          LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+       }
+        else if ( WithErr && strlen( LoopNode()->PyMoreName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1571,7 +1584,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
                                         LoopNode()->NextPythonFunction() ,
                                         OneErr ) ;
-        LoopNode()->PyNextMethod( PyNextMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyNextMethod ) {
+          LoopNode()->PyNextMethod( PyNextMethod ) ;
+       }
+        else if ( WithErr && strlen( LoopNode()->PyNextName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1580,6 +1599,10 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
                                 string( Name() ) ;
         _OutNode->Graph()->SetMessages( anErrorMessage ) ;
       }
+      //JR Debug 12854
+      if ( Err ) {
+        PyFuncRunned( false ) ;
+      }
       cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) "
              << PyRunMethod << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod
              << endl;
@@ -1593,7 +1616,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
        PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
                                        InLineNode()->PythonFunction() ,
                                        OneErr ) ;
-        InLineNode()->PyRunMethod( PyRunMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyRunMethod != NULL ) {
+          InLineNode()->PyRunMethod( PyRunMethod ) ;
+       }
+        else if ( WithErr && strlen( InLineNode()->PyFuncName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1614,7 +1643,13 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
         PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
                                        InLineNode()->PythonFunction() ,
                                        OneErr ) ;
-        InLineNode()->PyRunMethod( PyRunMethod ) ;
+       // JR Debug : if we must have a python function and if we have not : error
+        if ( PyRunMethod != NULL ) {
+          InLineNode()->PyRunMethod( PyRunMethod ) ;
+       }
+        else if ( WithErr && strlen( InLineNode()->PyFuncName() ) ) {
+          OneErr = true ;
+       }
       }
       Err = Err || OneErr ;
       if ( OneErr && WithErr ) {
@@ -1626,10 +1661,11 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
       cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
     }
   }
-  Err = WithErr && Err ;
+  //JR Look at DataFlowExecutor :
+  //  Err = WithErr && Err ;
   cdebug_out << "GraphExecutor::InNode::InitPythonFunctions " << Name() ;
-  if ( Err ) {
-    cdebug << " Error " << Err ;
+  if ( WithErr && Err ) {
+    cdebug << " Error " << WithErr && Err ;
   }
   cdebug << endl;
   return !Err ;
@@ -1653,10 +1689,18 @@ const long GraphExecutor::InNode::CpuUsed( bool tot ) {
         cpu = Component()->CpuUsed_impl() ;
       }
       catch ( ... ) {
-        cdebug << "CpuUsed " << Name() << " --> Component()->CpuUsed_impl() ERROR catched "
-               << endl ;
-        State( GraphExecutor::ErroredState ) ;
-        _OutNode->State( GraphExecutor::ErroredState ) ;
+        if ( _OutNode->IsDone() ) {
+          cdebug << "CpuUsed " << Name() << " --> Component()->CpuUsed_impl() WARNING catched Graph is done "
+                 << Automaton()->StateName( _OutNode->State() ) << endl ;
+        }
+        else {
+          cdebug << "CpuUsed " << Name() << " --> Component()->CpuUsed_impl() WARNING catched "
+                 << Automaton()->StateName( _OutNode->State() ) << endl ;
+//JR NPAL14110 09.02.2007 : If there is a shutdown of components ===> NodeState must not
+//                          be aborted ... ==> Commented :
+          //JRState( GraphExecutor::ErroredState ) ;
+          //JR_OutNode->State( GraphExecutor::ErroredState ) ;
+        }
         cpu = -1 ;
       }
     }