]> SALOME platform Git repositories - modules/superv.git/blobdiff - src/GraphExecutor/DataFlowExecutor_DataFlow.cxx
Salome HOME
DCQ:prepare 2.0.0
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_DataFlow.cxx
index 36d198c872b3e9f777314155e0618d8e55869f76..10d4cdb5e87f6917fb8636abee997d0a6753bc7e 100644 (file)
@@ -55,21 +55,20 @@ GraphExecutor::DataFlow::DataFlow( CORBA::ORB_ptr ORB,
   cdebug_out << "GraphExecutor::DataFlow::DataFlow" << endl;
 }
 
-GraphExecutor::DataFlow::DataFlow(
-                     CORBA::ORB_ptr ORB,
-                    SALOME_NamingService* ptrNamingService ,
-                     const SALOME_ModuleCatalog::Service& DataFlowService ,
-                     const char *DataFlowComponentName ,
-                     const char *DataFlowInterfaceName ,
-                     const char *DataFlowName ,
-                     const SUPERV::KindOfNode DataFlowkind ,
-                     const SUPERV::SDate DataFlowFirstCreation ,
-                     const SUPERV::SDate DataFlowLastModification ,
-                     const char * DataFlowExecutorRelease ,
-                     const char * DataFlowAuthor ,
-                     const char * DataFlowComputer ,
-                     const char * DataFlowComment ,
-                     const char * DebugFileName ) :
+GraphExecutor::DataFlow::DataFlow( CORBA::ORB_ptr ORB,
+                                  SALOME_NamingService* ptrNamingService ,
+                                   const SALOME_ModuleCatalog::Service& DataFlowService ,
+                                   const char *DataFlowComponentName ,
+                                   const char *DataFlowInterfaceName ,
+                                   const char *DataFlowName ,
+                                   const SUPERV::KindOfNode DataFlowkind ,
+                                   const SUPERV::SDate DataFlowFirstCreation ,
+                                   const SUPERV::SDate DataFlowLastModification ,
+                                   const char * DataFlowExecutorRelease ,
+                                   const char * DataFlowAuthor ,
+                                   const char * DataFlowComputer ,
+                                   const char * DataFlowComment ,
+                                   const char * DebugFileName ) :
      OutNode( ORB, ptrNamingService , DataFlowService , DataFlowComponentName ,
               DataFlowInterfaceName , DataFlowName , DataFlowkind ,
               DataFlowFirstCreation , DataFlowLastModification  ,
@@ -115,6 +114,91 @@ bool GraphExecutor::DataFlow::ContainerKill( const char *aNodeName ) {
   return RetVal ;
 }
 
+bool GraphExecutor::DataFlow::InputOfAny( const char * ToServiceParameterName ,
+                             const CORBA::Any & aValue ) {
+  cdebug_in "GraphExecutor::DataFlow::InputOfAny" << endl ;
+  bool RetVal = false ;
+  cdebug << pthread_self() << "GraphExecutor::DataFlow::::InputOfAny " << Graph()->Name() << "("
+         << ToServiceParameterName << ")" << endl ;
+  if ( Graph()->GraphMacroLevel() ) {
+    GraphBase::OutPort * anOutPort ;
+    anOutPort = Graph()->GetChangeInDataNodePort( ToServiceParameterName ) ;
+    cdebug << pthread_self() << "GraphExecutor::DataFlow::InputOfAny " << Graph()->Name()
+           << " " << ToServiceParameterName << " " << anOutPort->State() << " Done " << anOutPort->Done()
+           << endl ;
+    RetVal = AddInputData( Graph()->Name() , ToServiceParameterName , aValue ) ;
+    anOutPort->State(  SUPERV::ReadyState ) ;
+    anOutPort->Done( true ) ;
+    GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( anOutPort->InPorts( 0 )->NodeName() )->GetInNode() ;
+    cdebug << pthread_self() << "GraphExecutor::DataFlow::InputOfAny : " << anInNode->Name()
+           << "->SendSomeDataReady( " << Graph()->Name() << " ) " << endl ;
+    anInNode->SendSomeDataReady( Graph()->Name() ) ;
+    if ( anInNode->IsReady() ) {
+      cdebug << pthread_self() << "GraphExecutor::DataFlow::InputOfAny : " << anInNode->Name()
+             << "->SendEvent( GraphExecutor::ExecuteEvent ) "
+             << " " << anInNode->Name() << "->IsReady() " << anInNode->IsReady() << " State "
+             << anInNode->State() << endl ;
+      if ( anInNode->IsLockedDataWait() ) {
+        cdebug << pthread_self() << "GraphExecutor::DataFlow::InputOfAny : " << anInNode->Name()
+               << " IsLockedDataWait() ==> UnLockDataWait" << endl ;
+        anInNode->UnLockDataWait() ;
+      }
+      anInNode->CreateNewThread( true ) ;
+      anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ;
+      State( GraphExecutor::ExecutingState ) ;
+    }
+  }
+  cdebug_out << "GraphExecutor::DataFlow::InputOfAny " << RetVal << endl ;
+  return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::OutputOfAny( const char * aNodeName ,
+                                           const char * ToServiceParameterName ,
+                                           const CORBA::Any & aValue ) {
+  cdebug_in << "GraphExecutor::DataFlow::OutputOfAny" << endl ;
+  bool RetVal = false ;
+  GraphBase::Graph * aMacroGraph = (GraphBase::Graph * ) Graph()->GetChangeGraphNode( aNodeName ) ;
+//  GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aMacroGraph->GetInNode() ;
+  RetVal = Graph()->AddOutputData( aNodeName , ToServiceParameterName , aValue ) ;
+  GraphBase::OutPort * anOutPort = aMacroGraph->GetChangeOutPort( ToServiceParameterName ) ;
+  int i ;
+  for ( i = 0 ; i < anOutPort->InPortsSize() ; i++ ) {
+    if ( strcmp( anOutPort->ChangeInPorts( i )->NodeName() , Graph()->Name() ) ) {
+      cdebug << "GraphExecutor::DataFlow::OutputOfAny toNodeName " << anOutPort->ChangeInPorts( i )->NodeName()
+             << "(" << anOutPort->ChangeInPorts( i )->PortName() << ")" << endl ;
+      GraphExecutor::InNode * aLinkedNode = (GraphExecutor::InNode * ) Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( i )->NodeName() )->GetInNode() ;
+      int sts ;
+      if ( aLinkedNode->IsLockedDataWait() ) {
+        cdebug << "GraphExecutor::DataFlow::OutputOfAny " << aLinkedNode->Name()
+               << " IsLockedDataWait --> UnLockDataWait" << endl ;
+      }
+      sts = aLinkedNode->SendSomeDataReady( (char * ) aNodeName ) ;
+      cdebug << "GraphExecutor::DataFlow::OutputOfAny " << aLinkedNode->Name()
+             << "->SendSomeDataReady( " << aNodeName << " ) sts " << sts << endl ;
+      if ( sts ) {
+        if ( aLinkedNode->State() == GraphExecutor::DataReadyState ) {
+          aLinkedNode->CreateNewThreadIf( true ) ;
+          aLinkedNode->UnLockDataWait() ;
+          int res = aLinkedNode->DataUndef_AllDataReadyAction() ;
+        }
+      }
+    }
+    else if ( Graph()->GraphMacroLevel() != 0 ) {
+      cdebug << "GraphExecutor::DataFlow::OutputOfAny to MacroGraph " << anOutPort->ChangeInPorts( i )->NodeName()
+             << "(" << anOutPort->ChangeInPorts( i )->PortName() << ") " << Graph()->CoupledNodeName () << endl ;
+      Graph()->CoupledNode()->GraphExecutor()->OutputOfAny( Graph()->CoupledNodeName() ,
+                                                            anOutPort->ChangeInPorts( i )->PortName() ,
+                                                            *anOutPort->Value() ) ;
+    }
+    else {
+      cdebug << "GraphExecutor::DataFlow::OutputOfAny to Graph " << anOutPort->ChangeInPorts( i )->NodeName()
+             << "(" << anOutPort->ChangeInPorts( i )->PortName() << ") ignored" << endl ;
+    }
+  }
+  cdebug_out << "GraphExecutor::DataFlow::OutputOfAny " << RetVal << endl ;
+  return RetVal ;
+}
+
 bool GraphExecutor::DataFlow::Kill() {
   cdebug_in << "GraphExecutor::DataFlow::Kill()" << endl;
   bool RetVal = GraphExecutor::OutNode::Kill() ;