Salome HOME
SMH: 3.0.0 preparation = merged version (POLYWORK + RTVDEBUG01) + adopation for new GUI
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_InNode.cxx
index 4fa3a64de3498c1fd1572c0027c6c7eb86df1987..c504a203d2aa5223119630e00377b7365efc9411 100644 (file)
@@ -386,18 +386,22 @@ GraphExecutor::InNode::~InNode() {
 }
 
 void GraphExecutor::InNode::LockDataWait() {
+//  cdebug_in << "GraphExecutor::InNode::LockDataWait " << endl ;
   if ( pthread_mutex_lock( &_MutexDataWait ) ) {
     perror("Ready pthread_mutex_lock ") ;
     exit( 0 ) ;
   }
   _DataWait = true ;
+//  cdebug_out << "GraphExecutor::InNode::LockDataWait " << endl ;
 }
 void GraphExecutor::InNode::UnLockDataWait() {
+//  cdebug_in << "GraphExecutor::InNode::UnLockDataWait " << endl ;
   _DataWait = false ;
   if ( pthread_mutex_unlock( &_MutexDataWait ) ) {
     perror("Ready pthread_mutex_unlock ") ;
     exit( 0 ) ;
   }
+//  cdebug_out << "GraphExecutor::InNode::UnLockDataWait " << endl ;
 }
 
 Engines::Component_var GraphExecutor::InNode::Component() const {
@@ -405,10 +409,12 @@ Engines::Component_var GraphExecutor::InNode::Component() const {
     return _FactoryNode->Component() ;
   }
   else {
-    CORBA::Any const * anAnyComponent = GetChangeNodeInPort( 0 )->GetOutPort()->Value() ; // this
+//JR 30.03.2005    CORBA::Any const * anAnyComponent = GetChangeNodeInPort( 0 )->GetOutPort()->Value() ; // this
+    const CORBA::Any anAnyComponent = GetChangeNodeInPort( 0 )->GetOutPort()->Value() ; // this
     CORBA::Object_ptr obj ;
     try {
-      *anAnyComponent >>= obj ;
+//JR 30.03.2005      *anAnyComponent >>= obj ;
+      anAnyComponent >>= obj ;
       return Engines::Component::_narrow( obj ) ;
     }
     catch( ... ) {
@@ -782,10 +788,15 @@ bool GraphExecutor::InNode::Kill() {
       }
     }
   }
+// PAL8003
+// JR 24.03.2005 Debug it may have be killed if we have Suspend-Resume-Kill
+  if ( !RetVal && IsKilled() ) {
+    RetVal = true ;
+  }
   cdebug_out << "GraphExecutor::InNode::Kill " << Name() << " " << ThreadNo() << " " 
              << Automaton()->StateName( State() ) << " Threads " << _OutNode->Threads()
              << " SuspendedThreads " << _OutNode->SuspendedThreads()
-             << " EventQSize " << _OutNode->EventQSize() << endl ;
+             << " EventQSize " << _OutNode->EventQSize() << " returns " << RetVal << endl ;
   return RetVal ;
 }
 
@@ -1322,12 +1333,12 @@ void GraphExecutor::InNode::InitialState()
 
   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
     if ( GetNodeOutPort(i)->IsDataStream() ) {
-      GetChangeNodeOutPort(i)->State(  SUPERV::ReadyState ) ;
-      GetChangeNodeOutPort(i)->Done( true ) ;
+      GetChangeNodeOutPort(i)->PortState(  SUPERV::ReadyState ) ;
+      GetChangeNodeOutPort(i)->PortDone( true ) ;
     }
     else if ( i != 0 || !IsGOTONode() ) {
-      GetChangeNodeOutPort(i)->State(  SUPERV::WaitingState ) ;
-      GetChangeNodeOutPort(i)->Done( false ) ;
+      GetChangeNodeOutPort(i)->PortState(  SUPERV::WaitingState ) ;
+      GetChangeNodeOutPort(i)->PortDone( false ) ;
     }
   }
 
@@ -1337,17 +1348,22 @@ void GraphExecutor::InNode::InitialState()
     GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
     if ( IsHeadNode() && IsLoopNode() && anInPort->IsLoop() ) {
       anOutPort->PortStatus( DataConnected );
-      anOutPort->State( SUPERV::ReadyState ) ;
-      anOutPort->Done( true ) ;
-      CORBA::Any * anAny = new CORBA::Any() ;
-      *anAny <<= (long ) 1 ;
+      anOutPort->PortState( SUPERV::ReadyState ) ;
+      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 ;
       anOutPort->Value( anAny ) ;
       _InitLoop = true ;
+      cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
+             << " OutPort " << anOutPort->PortStatus() << theAutomaton->StateName( anOutPort->PortState() )
+             << " InitLoop HeadNode" << endl ;
     }
 // JR 15_09_2004 if backward link from GOTONode or EndLoopNode ==> DataConnected
     else if ( anInPort->IsGate() && anOutPort ) {
-      anOutPort->State( SUPERV::WaitingState ) ;
-      anOutPort->Done( false ) ;
+      anOutPort->PortState( SUPERV::WaitingState ) ;
+      anOutPort->PortDone( false ) ;
       const GraphBase::ComputingNode * aFromNode =  _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() ) ; 
 //JR      if ( aFromNode->IsGOTONode() || aFromNode->IsEndLoopNode() ) {
       if ( aFromNode->IsGOTONode() || ( IsLoopNode() && CoupledNode() == aFromNode ) ) {
@@ -1355,9 +1371,16 @@ void GraphExecutor::InNode::InitialState()
 // before was "else if ( IsOneOfInlineNodes() )"
 // IsOneOfInline() == ( Inline || IsOneOfGOTO() ), so Inline are removed..
         anOutPort->PortStatus( DataConnected );
-        anOutPort->State( SUPERV::ReadyState ) ;
-        anOutPort->Done( true ) ;
+        anOutPort->PortState( SUPERV::ReadyState ) ;
+        anOutPort->PortDone( true ) ;
       }
+      cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
+             << " OutPort " << anOutPort->PortStatus() << theAutomaton->StateName( anOutPort->PortState() )
+             << " Gate HeadNode" << endl ;
+    }
+    else {
+      cdebug << Name() << " IsHeadNode " << IsHeadNode() << " InPort" << i << " " << anInPort->PortName()
+             << " " << anInPort->PortStatus() << endl ;
     }
     if ( anInPort->IsGate() && anOutPort == NULL ) {
       Pc-- ;
@@ -1366,21 +1389,21 @@ void GraphExecutor::InNode::InitialState()
     else if ( anOutPort ) {
       if ( anOutPort->IsDataConnected() || anOutPort->IsDataStream() ) {
         Pc-- ;
-        anOutPort->State( SUPERV::ReadyState ) ;
-        anOutPort->Done( true ) ;
+        anOutPort->PortState( SUPERV::ReadyState ) ;
+        anOutPort->PortDone( true ) ;
         cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
-               << " " << theAutomaton->StateName( anOutPort->State() ) << " Pc " << Pc << endl ;
+               << " " << theAutomaton->StateName( anOutPort->PortState() ) << " Pc " << Pc << endl ;
       }
       else if ( anOutPort->IsPortConnected() ) {
-        anOutPort->State( SUPERV::WaitingState ) ;
-        anOutPort->Done( false ) ;
+        anOutPort->PortState( SUPERV::WaitingState ) ;
+        anOutPort->PortDone( false ) ;
         cdebug << "InPort" << i << " " << anInPort->PortName() << " " << " " << anInPort->PortStatus()
-               << " " << theAutomaton->StateName( anOutPort->State() ) << " Pc " << Pc << endl ;
+               << " " << theAutomaton->StateName( anOutPort->PortState() ) << " Pc " << Pc << endl ;
       }
       else {
         cdebug << "InPort" << i << " " << anInPort->PortName() << " " << anInPort->PortStatus()
                << " OutPort " << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
-               << theAutomaton->StateName( anOutPort->State() ) << " Pc " << Pc << endl ;
+               << theAutomaton->StateName( anOutPort->PortState() ) << " Pc " << Pc << endl ;
       }
     }
     else {
@@ -1391,37 +1414,36 @@ void GraphExecutor::InNode::InitialState()
       if ( !anOutPort->IsDataStream() || anInPort->IsDataStream() ) {
         cdebug << "InPort" << i << " state change : " << anInPort->PortName() << " from OutPort "
                << anOutPort->PortName() << " from Node " << anOutPort->NodeName()
-               << " with state " << theAutomaton->StateName( anOutPort->State() ) << endl ;
-        GetChangeNodeInPort(i)->State( anOutPort->State() ) ;
+               << " with state of OutPort : " << theAutomaton->StateName( anOutPort->PortState() ) << endl ;
+        GetChangeNodeInPort(i)->PortState( anOutPort->PortState() ) ;
       }
       else if ( anOutPort->IsDataConnected() ) {
         cdebug << "InPort" << i << " state change : " << anInPort->PortName() << " from OutPort "
                << anOutPort->PortName() << " from Node " << anOutPort->NodeName()
                << " with state ReadyState" << endl ;
-        GetChangeNodeInPort(i)->State( SUPERV::ReadyState ) ;
+        GetChangeNodeInPort(i)->PortState( SUPERV::ReadyState ) ;
       }
       else {
         cdebug << "InPort" << i << " state NOT changed : " << anInPort->PortName() << " from OutPort "
                << anOutPort->PortName() << " " << anOutPort->PortStatus() << " from Node " << anOutPort->NodeName()
-               << " with state " << anOutPort->State() << endl ;
+               << " with state " << theAutomaton->StateName( anOutPort->PortState() ) << endl ;
       }
     }
     if ( anOutPort ) {
       cdebug << "InPort" << i << " : " << anInPort->PortName() << " from OutPort "
              << anOutPort->PortName() << " from Node " << anOutPort->NodeName()
              << " with state " ;
-      if ( anOutPort->State() == SUPERV::WaitingState ) {
+      if ( anOutPort->PortState() == SUPERV::WaitingState ) {
         cdebug << "WaitingState" ;
       }
-      else if ( anOutPort->State() == SUPERV::ReadyState ) {
+      else if ( anOutPort->PortState() == SUPERV::ReadyState ) {
         cdebug << "ReadyState" ;
       }
       else {
         cdebug << "???" ;
       }
-      cdebug << " PortConnected("
-             << anOutPort->IsPortConnected() << ") DataConnected("
-             << anOutPort->IsDataConnected() << ")" << endl ;
+      cdebug << " OutPortStatus " << anOutPort->PortStatus() << " State "
+             << theAutomaton->StateName( anOutPort->PortState() ) << endl ;
     }
   }
 
@@ -1442,7 +1464,7 @@ void GraphExecutor::InNode::InitialState()
 
   for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
     cdebug << "OutPort" << i << " : " << GetNodeOutPort(i)->PortName() << " "
-           << theAutomaton->StateName( GetChangeNodeOutPort(i)->State() )
+           << theAutomaton->StateName( GetChangeNodeOutPort(i)->PortState() )
            << " " << GetNodeOutPort(i)->Kind() << endl ;
   }
 
@@ -1533,7 +1555,7 @@ const long GraphExecutor::InNode::CpuUsed( bool tot ) {
   CORBA::Long cpu = 0 ;
 //  cout << "Begin CpuUsed " << Name() << " CpuUsed : " << cpu << " State "
 //       << theAutomaton->StateName( _currentState ) << endl ;
-  cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ;
+//  cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ;
   if ( IsOneOfInLineNodes() ) {
 //    cdebug << "CpuUsed " << Name() << " --> PyCpuUsed()" << endl ;
 //    cout << "CpuUsed " << Name() << " --> PyCpuUsed()" << endl ;
@@ -1554,7 +1576,7 @@ const long GraphExecutor::InNode::CpuUsed( bool tot ) {
       }
     }
   }
-  cdebug_out << "GraphExecutor::InNode::CpuUsed " << Name() << " CpuUsed : " << cpu << endl ;
+//  cdebug_out << "GraphExecutor::InNode::CpuUsed " << Name() << " CpuUsed : " << cpu << endl ;
 //  cout << "End CpuUsed " << Name() << " CpuUsed : " << cpu << " State "
 //       << theAutomaton->StateName( _currentState ) << endl ;
   return cpu ;