Salome HOME
PAL8624
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.hxx
index d13a9d0891810e98b134742e2ea81c9706dfc6e2..4746eaf08c196e28efbb33d3b863ed390ee5288b 100644 (file)
@@ -1,59 +1,96 @@
-//=============================================================================
-// File      : DataFlowBase_OutNode.hxx
-// Created   : 2002
-// Author    : Jean Rahuel, CEA
-// Project   : SALOME
-// $Header:
-//=============================================================================
+//  SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : DataFlowBase_OutNode.hxx
+//  Author : Jean Rahuel, CEA
+//  Module : SUPERV
+//  $Header:
 
 #ifndef _DATAFLOWEXECUTOR_OUTNODE_HXX
 #define _DATAFLOWEXECUTOR_OUTNODE_HXX
 
 #include "SALOME_Component_i.hxx"
 
-#include "DataFlowBase_Graph.hxx"
-
 #include "DataFlowExecutor_InNode.hxx"
 
+#include "DataFlowBase_StreamGraph.hxx"
+
 namespace GraphExecutor {
 
-  class OutNode : public GraphBase::Graph {
+//  class OutNode : public GraphBase::Graph {
+  class OutNode : public GraphBase::Base {
 
     private :
 
+      GraphBase::StreamGraph * _StreamGraph ;
+      GraphBase::Graph       * _Graph ;
+
+      int  _Graph_prof_debug ;
+
       bool                    _PyInitialized ;
       bool                    _Valid ;
       bool                    _Executable ;
-      SUPERV::AutomatonState  _State ;
+      GraphExecutor::AutomatonState  _State ;
       SUPERV::ControlState    _ControlState ;
       bool                    _Done ;
+      bool                    _NodeAborted ;
 
+      // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL    
+      //Engines_Container_i            * _SuperVisionContainer ;
+      //pthread_t                        _MainThreadId ;
+      pthread_mutex_t                  _PyMutexWait ;
       pthread_mutex_t                  _MutexWait ;
       pthread_cond_t                   _EventWait ;
       pthread_cond_t                   _JoinWait ;
       bool                             _JustStarted ;
       int                              _Threads ; // Number of threads
+      long                             _CreatedThreads ; 
       int                              _SuspendedThreads ;
       list< char * >                   _EventNodes ;
       list< GraphExecutor::NodeEvent > _Events ;
-      list< SUPERV::AutomatonState >   _States ;
+      list< GraphExecutor::AutomatonState >   _States ;
 
       bool Valid() ;
       void UnValid() ;
       bool Executable() ;
 
-      bool LoadNodes( const GraphBase::ListOfNodes &aNodes ) ;
-      bool LoadLinks( const GraphBase::ListOfLinks &aLinks ) ;
-      bool LoadDatas( const GraphBase::ListOfLinks &aDatas ) ;
+      bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
+      bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
+      bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
 
       CORBA::ORB_ptr _Orb ;
 
+      // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came) 
+      // event for every node
+      void siftEvents();
+
     public :
   
       OutNode() ;
       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
                const char *DataFlowName ,
-               const char * DebugFileName );
+               const char * DebugFileName ,
+               const SUPERV::KindOfNode aKindOfNode );
       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
                const SALOME_ModuleCatalog::Service& DataFlowService ,
                const char *DataFlowComponentName ,
@@ -69,8 +106,20 @@ namespace GraphExecutor {
                const char * DebugFileName ) ;
       virtual ~OutNode() ;
 
-      bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
-      bool LoadXml( const char* myFileName ) ;
+      void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
+      GraphBase::StreamGraph * StreamGraph() {
+                               return _StreamGraph ; } ;
+      GraphBase::StreamGraph * StreamGraph() const {
+                               return _StreamGraph ; } ;
+      GraphBase::Graph * Graph() {
+                         return _Graph ; } ;
+      GraphBase::Graph * Graph() const {
+                         return _Graph ; } ;
+
+      char * Name() { return Graph()->Name() ; } ;
+
+      bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
+//      bool LoadXml( const char* myFileName ) ;
       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
 
       GraphExecutor::InNode * AddNode(
@@ -83,18 +132,13 @@ namespace GraphExecutor {
                         const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
                         const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
                         const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
-                        const char * NodeEditorRelease = NULL ,
-                        const char * NodeAuthor = NULL ,
-                        const char * NodeComputer = NULL ,
-                        const char * NodeComment = NULL ,
+                        const char * NodeEditorRelease = NULLSTRING ,
+                        const char * NodeAuthor = NULLSTRING ,
+                        const char * NodeComputer = NULLSTRING ,
+                        const char * NodeComment = NULLSTRING ,
                         const int NodeX = 0 ,
                         const int NodeY = 0 ) ;
 
-      bool AddInputData( const char* ToNodeName1 ,
-                         const char* ToParameterName1 ,
-                         const char* ToNodeName2 ,
-                         const char* ToParameterName2 ) ;
-
       bool IsValid() { if ( !_Valid )
                          return Valid() ;
                        return _Valid ; } ;
@@ -103,8 +147,6 @@ namespace GraphExecutor {
                             return _Executable ; } ;
 
       bool Run( const bool AndSuspend ) ;
-      bool Run( const char * aNodeName , const char * AtNodeName ,
-                const bool AndSuspend ) ;
 
       void PyInitialized( bool init ) {
            _PyInitialized = init ; } ;
@@ -113,19 +155,35 @@ namespace GraphExecutor {
 
       void CheckAllDone() ;
 
+      // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL    
+      //Engines_Container_i * SuperVisionContainer() ;
+      //const pthread_t MainThreadId() const ;
+      void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
+      void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
+      void PyThreadLock() ;
+      void PyThreadUnLock() ;
+
       void NewThread() ;
-      void ExitThread() ;
+      void ExitThread( pthread_t ThreadNumber = 0 ) ;
       void SuspendThread() ;
       void ResumeThread() ;
       long Threads() { return _Threads ; } ;
       long SuspendedThreads() { return _SuspendedThreads ; } ;
       void JoinedWait() ;
 
+      pthread_t ThreadNo() {
+                return _Graph->ThreadNo() ; } ;
       long Thread( const char * NodeName ) ;
 
+      void IncrCreatedThreads() {
+           _CreatedThreads += 1 ; } ;
+      long CreatedThreads() {
+           return _CreatedThreads ; } ;
+
       bool PushEvent( GraphExecutor::InNode * aNode ,
                       GraphExecutor::NodeEvent anEvent ,
-                      SUPERV::AutomatonState aState ) ;
+                      GraphExecutor::AutomatonState aState ) ;
+      int GetListSize();
       bool StateWait( SUPERV::GraphState aState ) ;
       bool Event( char ** aNodeName ,
                   SUPERV::GraphEvent & anEvent ,
@@ -137,8 +195,14 @@ namespace GraphExecutor {
       bool EventWait( char ** aNodeName ,
                       SUPERV::GraphEvent & anEvent ,
                       SUPERV::GraphState & aState ) ;
+      long EventQSize() ;
+      void EventList() ;
 
-      void State(SUPERV::AutomatonState aState ) ;
+      void SendSomeDataReady( const char * aNodeName ) ;
+
+      void State(GraphExecutor::AutomatonState aState ) ;
+      const char * StateName(GraphExecutor::AutomatonState aState ) {
+             return theAutomaton->StateName( aState ) ; }
 
       SUPERV::GraphState State() ;
       SUPERV::GraphState State( const char * NodeName ) ;
@@ -146,10 +210,10 @@ namespace GraphExecutor {
                                 const char * ServiceParameterName ) ;
 
       SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
-      SUPERV::GraphState AutomatonGraphState(SUPERV::AutomatonState anAutomatonState) ;
+      SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
 
-      SUPERV::AutomatonState AutomatonState() ;
-      SUPERV::AutomatonState AutomatonState( const char * NodeName ) ;
+      GraphExecutor::AutomatonState AutomatonState() ;
+      GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
 
       SUPERV::ControlState ControlState() ;
       SUPERV::ControlState ControlState( const char * aNodeName ) ;
@@ -162,14 +226,19 @@ namespace GraphExecutor {
       bool Resume() ;
       bool Kill() ;
       bool Stop() ;
-      bool ReRun() ;
-      bool ReStart() ;
 
-      void Done( bool aDone ) { _Done = aDone ; } ;
+      void NodeAborted( const char * aNodeName ) {
+           string aMsg = string( "The node " ) + string( aNodeName ) + " was aborted." ;
+           Graph()->SetMessages( aMsg.c_str() ) ;
+           _NodeAborted = true ; } ;
+      bool IsNodeAborted() {
+           return _NodeAborted ; } ;
 
       bool IsWaiting() ;
       bool IsReady() ;
       bool IsRunning() ;
+      void Done( bool aDone ) { _Done = aDone ; } ;
+      bool Done() { return _Done ; } ;
       bool IsDone() ;
       bool IsSuspended() ;
       bool IsKilled() ;
@@ -179,8 +248,8 @@ namespace GraphExecutor {
       bool IsRunning( const char * NodeName ) ;
       bool IsDone( const char * NodeName ) ;
       bool IsSuspended( const char * NodeName ) ;
-      bool IsDone( const char * NodeName ,
-                   const char * ServiceParameterName ) ;
+      bool PortDone( const char * NodeName ,
+                     const char * ServiceParameterName ) ;
       long LastLevelDone() ;
 
       bool ReadyWait() ;
@@ -192,10 +261,14 @@ namespace GraphExecutor {
       bool DoneWait( const char * NodeName ) ;
       bool SuspendedWait( const char * NodeName ) ;
 
-      const CORBA::Any *GetInData( const char *ToNodeName ,
-                                   const char *ToParameterName ) ;
-      const CORBA::Any *GetOutData( const char *FromNodeName ,
-                                    const char *FromParameterName ) ;
+//JR 30.03.2005      const CORBA::Any *GetInData( const char *ToNodeName ,
+      const CORBA::Any GetInData( const char *ToNodeName ,
+                                  const char *ToParameterName ) ;
+//JR 30.03.2005      const CORBA::Any *GetOutData( const char *FromNodeName ,
+      const CORBA::Any GetOutData( const char *FromNodeName ,
+                                   const char *FromParameterName ) ;
+      const long CpuUsed() ;
+      const long CpuUsed( const char *aNodeName ) ;
   };
 };