Salome HOME
*** empty log message ***
[modules/superv.git] / src / Supervision / Port_Impl.cxx
index 96d13d68bace5abd31cd8c64d0e192c74c48bc9a..419adb3655ce222efda59e541c888f33aed0962f 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"
 #include "Port_Impl.hxx"
@@ -175,6 +175,10 @@ bool Port_Impl::Input( const CORBA::Any * anAny ) {
                                                    *anAny ) ;
     }
   }
+  if ( !RetVal ) {
+    MESSAGE( "Port_Impl::Input returns false _InputPort " << _InputPort << " IsEditing "
+             << _DataFlowEditor->IsEditing() << " Executor " << _DataFlowEditor->Executor() ) ;
+  }
   endService( "Port_Impl::Input" );
   return RetVal ;
 }
@@ -236,11 +240,10 @@ SUPERV::Link_ptr Port_Impl::Link() {
     beginService( "Port_Impl::Link" ) ;
     begin = false ;
     SUPERV::ListOfLinks_var Links = new SUPERV::ListOfLinks ;
-    cout << "Port_Impl::Link " << _DataFlowNode->Name() << " "
-         << _DataFlowPort->PortName() << endl ;
-    Links = _DataFlowEditor->ObjImpl()->Links(
-                                        _DataFlowNode->ComputingNode() ,
-                                        _DataFlowPort->PortName() ) ;
+//    cout << "Port_Impl::Link " << _DataFlowNode->Name() << " "
+//         << _DataFlowPort->PortName() << endl ;
+    Links = _DataFlowEditor->ObjImpl()->Links( _DataFlowNode->ComputingNode() ,
+                                               _DataFlowPort->PortName() ) ;
     if ( Links->length() ) {
       iobject = Links[ 0 ] ;
     }
@@ -261,7 +264,13 @@ SUPERV::Link_ptr Port_Impl::Link() {
       GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _DataFlowPort->PortName() ) ;
       if ( anInPort->GetOutPort() ) {
         GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
-        if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
+        if ( _DataFlowNode->IsEndLoopNode() && !strcmp( _DataFlowNode->CoupledNode()->Name() ,
+                                                        anOutPort->NodeName() ) ) {
+//          MESSAGE( "Link " << anOutPort->NodeName() << "("
+//                  << anOutPort->PortName() << ") --> " << _DataFlowNode->Name() << "("
+//                  << anInPort->PortName() << ")" << " ignored" ) ;
+       }
+        else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
           if ( begin ) {
             beginService( "Port_Impl::Link" ) ;
             begin = false ;
@@ -286,6 +295,8 @@ SUPERV::Link_ptr Port_Impl::Link() {
     }
   }
   if ( !begin ) {
+    MESSAGE( "Link " << iobject->OutPort()->Node()->Name() << "( " << iobject->OutPort()->Name() << " ) --> "
+             << iobject->InPort()->Node()->Name() << "( " << iobject->InPort()->Name() << " ) " ) ;
     endService( "Port_Impl::Link" ) ;
   }
   return SUPERV::Link::_duplicate( iobject ) ;
@@ -294,22 +305,28 @@ SUPERV::Link_ptr Port_Impl::Link() {
 bool Port_Impl::IsInput() {
 //  beginService( "Port_Impl::IsInput" ) ;
   bool RetVal = _InputPort ;
+//  MESSAGE( Name() << "IsInput() " << _InputPort ) ;
 //  endService( "Port_Impl::IsInput" ) ;
   return RetVal ;
 }
 
 bool Port_Impl::IsLinked() {
 //  beginService( "Port_Impl::IsLinked" ) ;
-  bool RetVal = true ;
-#if 0
-  if ( _DataFlowNode->IsEndSwitchNode() && _DataFlowPort->IsBus() ) {
+  bool RetVal = false ;
+  GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _DataFlowPort->PortName() ) ;
+  GraphBase::OutPort * anOutPort = NULL ;
+  if ( anInPort) {
+    anOutPort = anInPort->GetOutPort() ;
+  }
+  if ( _DataFlowNode->IsEndLoopNode() && anOutPort &&
+       !strcmp( _DataFlowNode->CoupledNode()->Name() , anOutPort->NodeName() ) ) {
+//    MESSAGE( "Link " << anOutPort->NodeName() << "("
+//            << anOutPort->PortName() << ") --> " << _DataFlowNode->Name() << "("
+//            << anInPort->PortName() << ")" << " ignored" ) ;
   }
   else {
-#endif
     RetVal = _DataFlowNode->IsLinked( _DataFlowPort->PortName() ) ;
-#if 0
   }
-#endif
 //  endService( "Port_Impl::IsLinked" ) ;
   return RetVal ;
 }
@@ -321,6 +338,12 @@ SUPERV::KindOfPort Port_Impl::Kind() {
   return RetVal ;
 }
 
+void Port_Impl::SetKind( SUPERV::KindOfPort aKindOfPort ) {
+//  beginService( "Port_Impl::SetKind" ) ;
+  _DataFlowPort->Kind( aKindOfPort ) ;
+//  endService( "Port_Impl::SetKind" ) ;
+}
+
 bool Port_Impl::IsParam() {
 //  beginService( "Port_Impl::IsParam" ) ;
   bool RetVal = _DataFlowPort->IsParam() ;
@@ -364,9 +387,21 @@ bool Port_Impl::IsEndSwitch() {
   return RetVal ;
 }
 
+bool Port_Impl::IsDataStream() {
+//  beginService( "Port_Impl::IsDataStream" ) ;
+  bool RetVal = _DataFlowPort->IsDataStream() ;
+//  endService( "Port_Impl::IsDataStream" ) ;
+  return RetVal ;
+}
+
 bool Port_Impl::HasInput() {
 //  beginService( "Port_Impl::" ) ;
-  bool RetVal = _DataFlowNode->HasInput( _DataFlowPort->PortName() ) ;
+  bool RetVal = false ;
+  if ( _DataFlowNode ) {
+    RetVal = _DataFlowNode->HasInput( _DataFlowPort->PortName() ) ;
+//    cout << "Port_Impl::HasInput " << RetVal << " NodeName " << _DataFlowPort->NodeName() << " PortName "
+//         << _DataFlowPort->PortName() << endl ;
+  }
 //  endService( "Port_Impl::" ) ;
   return RetVal ;
 }