]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/Supervision/CNode_Impl.cxx
Salome HOME
NRI : Merge from 1.2c.
[modules/superv.git] / src / Supervision / CNode_Impl.cxx
index ebcc16bd5cc8e5fc76abda4c07183304a9409b3e..860dd16a33e58d9d57c3b47c329550cfd35955f2 100644 (file)
 using namespace std;
 #include <stdio.h>
 #include <fstream>
-#include <strstream>
+//#include <sstream>
 #include <string>
 
-#include "utilities.h"
+//#include "utilities.h"
 
 #include "Graph_Impl.hxx"
 
@@ -35,7 +35,7 @@ CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb ,
 //          << hex << (void *) this << dec )
 //  _thisObj = this ;
 //  _id = _poa->activate_object(_thisObj);
-  MESSAGE( "CNode_Impl::CNode_Impl " << aDataFlowName << " " );
+//  MESSAGE( "CNode_Impl::CNode_Impl " << aDataFlowName << " " );
   beginService( "CNode_Impl::CNode_Impl" );
   _Orb = CORBA::ORB::_duplicate(orb);
   _Poa = poa ;
@@ -60,12 +60,13 @@ CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb ,
                         const char * FuncName  ,
                         const SUPERV::ListOfStrings & PythonFunction ) :
   Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) {
-//  beginService( "CNode_Impl::CNode_Impl" );
-  if ( FuncName && NodeName ) {
-    cout << "CNode_Impl::CNode_Impl " << (void *) NodeName << " " << NodeName
-         << " " << strlen(NodeName) << " " << (void *) FuncName << " " << FuncName
-         << " " << strlen( FuncName ) << endl ;
-  }
+  beginService( "CNode_Impl::CNode_Impl" );
+//  cout << "CNode_Impl::CNode_Impl -->" << endl ;
+//  if ( FuncName && NodeName ) {
+//    cout << "CNode_Impl::CNode_Impl " << (void *) NodeName << " " << NodeName
+//         << " " << strlen(NodeName) << " " << (void *) FuncName << " " << FuncName
+//         << " " << strlen( FuncName ) << endl ;
+//  }
   if ( NodeKindOfNode == SUPERV::ComputingNode ) {
     MESSAGE( "CNode_Impl::CNode_Impl " << FuncName << " _poa->activate_object" );
     _thisObj = this ;
@@ -88,7 +89,8 @@ CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb ,
                                             aFuncName ,
                                             aPythonFunction ) ;
   _IsNode = true ;
-//  endService( "CNode_Impl::CNode_Impl" );  
+  endService( "CNode_Impl::CNode_Impl" );  
+//  cout << "<-- CNode_Impl::CNode_Impl" << endl ;
 }
 
 CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb ,
@@ -653,7 +655,7 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName ,
     bool sts = false ;
     GraphBase::InPort * anInPort ;
     if ( _IsNode ) {
-      sts = _DataFlowExecutor->ChangeInputData( _DataFlowEditor->Name() ,
+      sts = _DataFlowExecutor->ChangeInputData( _DataFlowNode->Name() ,
                                                 ToServiceParameterName ,
                                                 *aValue->ToAny() ) ;
       anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ;
@@ -698,18 +700,25 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName ,
 SUPERV::ListOfPorts * CNode_Impl::Ports() {
   bool begin = true ;
   SUPERV::ListOfPorts_var RetVal = new SUPERV::ListOfPorts ;
-//  if ( !_DataFlowNode->IsDataFlowNode() ) {
   if ( _IsNode ) {
     int i , j ;
     RetVal->length( _DataFlowNode->GetNodeInPortsSize() +
                     _DataFlowNode->GetNodeOutPortsSize() ) ;
     for ( i = 0 ; i < _DataFlowNode->GetNodeInPortsSize() ; i++ ) {
       GraphBase::InPort * anInPort = _DataFlowNode->GetChangeNodeInPort( i ) ;
-      if ( CORBA::is_nil( anInPort->ObjRef() ) ) {
-        if ( begin ) {
-          beginService( "CNode_Impl::Ports" );
-          begin = false ;
-       }
+      if ( begin ) {
+        beginService( "CNode_Impl::Ports" );
+        begin = false ;
+      }
+      if ( anInPort->IsLoop() || ( anInPort->IsGate() && !anInPort->IsConnected() && 
+                                   ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) {
+        MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " ignored" ) ;
+        RetVal[ i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ;
+      }
+      else if ( CORBA::is_nil( anInPort->ObjRef() ) ) {
+        MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsExecuting "
+                 << _DataFlowEditor->IsExecuting() << " IsGate/IsConnected " << anInPort->IsGate()
+                 << "/" << anInPort->IsConnected() ) ;
         Port_Impl * myPort ;
         if ( _DataFlowNode->HasInput( anInPort->PortName() ) ) {
           const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ;
@@ -739,16 +748,23 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() {
         anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ;
       }
       else {
+        MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() ) ;
         RetVal[ i ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ;
       }
     }
     for ( i = 0 ; i < _DataFlowNode->GetNodeOutPortsSize() ; i++ ) {
       GraphBase::OutPort * anOutPort = _DataFlowNode->GetChangeNodeOutPort( i ) ;
-      if ( CORBA::is_nil( anOutPort->ObjRef() ) ) {
-        if ( begin ) {
-          beginService( "CNode_Impl::Ports" );
-          begin = false ;
-       }
+      if ( begin ) {
+        beginService( "CNode_Impl::Ports" );
+        begin = false ;
+      }
+      if ( anOutPort->IsLoop() || ( anOutPort->IsGate() && !anOutPort->IsConnected() &&
+                                    ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) {
+        MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " ignored" ) ;
+        RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ;
+      }
+      else if ( CORBA::is_nil( anOutPort->ObjRef() ) ) {
+        MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ;
         const CORBA::Any * anAny = anOutPort->Value() ;
         Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId ,
                                             instanceName() , interfaceName() ,
@@ -766,9 +782,19 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() {
         anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ;
       }
       else {
+        MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ;
         RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ;
       }
     }
+    for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) {
+      if ( CORBA::is_nil( RetVal[ i ] ) ) {
+        for ( j = i ; j < (int ) RetVal->length() - 1 ; j++ ) {
+          RetVal[ j ] = RetVal[ j + 1 ] ;
+       }
+        RetVal->length( RetVal->length() - 1 ) ;
+        i-- ;
+      }
+    }
   }
   else {
     if ( _DataFlowEditor->IsValid() ) {
@@ -915,9 +941,10 @@ long CNode_Impl::SubGraph() {
 }
 
 bool CNode_Impl::IsLinked(const char * ServiceParameterName ) {
-//  beginService( "CNode_Impl::IsLinked" );
+  beginService( "CNode_Impl::IsLinked" );
   bool RetVal = _DataFlowNode->IsLinked( ServiceParameterName ) ;
-//  endService( "CNode_Impl::IsLinked" );
+  MESSAGE( Name() << "->IsLinked( '" << ServiceParameterName << "' )" ) ;
+  endService( "CNode_Impl::IsLinked" );
   return RetVal ;
 }
 
@@ -991,7 +1018,7 @@ SUPERV::ControlState CNode_Impl::Control() {
 }
 void CNode_Impl::ControlClear() {
 //  beginService( "CNode_Impl::ControlClear" );
-  SUPERV::ControlState RetVal = SUPERV::VoidState ;
+//  SUPERV::ControlState RetVal = SUPERV::VoidState ;
   GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ;
   if ( _DataFlowExecutor ) {
     if ( _IsNode ) {
@@ -1342,15 +1369,12 @@ long CNode_Impl::CpuUsed() {
   GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ;
   if ( _DataFlowExecutor ) {
     if ( _IsNode ) {
-//      RetVal = _DataFlowExecutor->CpuUsed( Name() ) ;
+      RetVal = _DataFlowExecutor->CpuUsed( Name() ) ;
     }
     else {
-//      RetVal = _DataFlowExecutor->CpuUsed() ;
+      RetVal = _DataFlowExecutor->CpuUsed() ;
     }
   }
-  else {
-    return 0 ;
-  }
   return RetVal ;
 }