--- /dev/null
+using namespace std;
+
+#include "DataFlowEditor_DataFlow.hxx"
+
+// Implementation de la classe GraphEditor::Graph
+
+GraphEditor::DataFlow::DataFlow() :
+ OutNode() {
+ cdebug_in << "GraphEditor::DataFlow::DataFlowEditor()" << endl;
+
+ _theNamingService = NULL ;
+ _DataFlowExecutor = NULL ;
+ _ReadOnly = false ;
+ _Executing = false ;
+
+ cdebug_out << "GraphEditor::DataFlow::DataFlowEditor()" << endl;
+}
+
+GraphEditor::DataFlow::DataFlow( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const char *DataFlowName ,
+ const char * DebugFileName ) :
+ OutNode( ORB, ptrNamingService , DataFlowName , DebugFileName ) {
+ cdebug_in << "GraphEditor::DataFlow::DataFlow(" ;
+ if ( DataFlowName ) {
+ cdebug << DataFlowName ;
+ }
+ cdebug << ")" << endl;
+
+ _theNamingService = ptrNamingService ;
+ _DataFlowExecutor = NULL ;
+ _ReadOnly = false ;
+ _Executing = false ;
+
+ cdebug_out << "GraphEditor::DataFlow::DataFlow" << endl;
+}
+
+GraphEditor::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 * DataFlowEditorRelease ,
+ const char * DataFlowAuthor ,
+ const char * DataFlowComputer ,
+ const char * DataFlowComment ,
+ const char * DebugFileName ) :
+ OutNode( ORB, ptrNamingService , DataFlowService , DataFlowComponentName ,
+ DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+ DataFlowFirstCreation , DataFlowLastModification ,
+ DataFlowEditorRelease , DataFlowAuthor ,
+ DataFlowComputer , DataFlowComment , DebugFileName ) {
+ cdebug_in << "GraphEditor::DataFlow::DataFlow(" << DataFlowName << ")" << endl;
+
+ _theNamingService = ptrNamingService ;
+ _DataFlowExecutor = NULL ;
+ _ReadOnly = false ;
+ _Executing = false ;
+
+ cdebug_out << "GraphEditor::DataFlow::DataFlow" << endl;
+} ;
+
+GraphEditor::DataFlow::~DataFlow() {
+// delete _DataFlowNode ;
+// delete _DataFlowDatas ;
+// delete _GT ;
+}
+
+#if 0
+GraphExecutor::DataFlow * GraphEditor::DataFlow::Run() {
+ cdebug_in << "GraphEditor::DataFlow::Run" << endl;
+ SUPERV::SGraph * theDataFlow ;
+ GraphExecutor::DataFlow * aDataFlowExecutor ;
+ theDataFlow = GetDataFlow() ;
+ aDataFlowExecutor = new GraphExecutor::DataFlow( NamingService() ,
+ theDataFlow->Info.theName ) ;
+ if ( aDataFlowExecutor->LoadDataFlow( *theDataFlow ) ) {
+ aDataFlowExecutor->Run() ;
+ }
+ else {
+ MESSAGE( "GraphEditor::DataFlow::Run error while loading DataFlowExecutor")
+ delete aDataFlowExecutor ;
+ }
+ cdebug_out << "GraphEditor::DataFlow::Run" << endl;
+ return aDataFlowExecutor ;
+}
+#endif
+
--- /dev/null
+#ifndef _DATAFLOWEDITOR_DATAFLOW_HXX
+#define _DATAFLOWEDITOR_DATAFLOW_HXX
+
+//#include "DataFlowExecutor_DataFlow.hxx"
+
+#include "DataFlowExecutor_DataFlow.hxx"
+#include "DataFlowEditor_OutNode.hxx"
+
+namespace GraphEditor {
+
+ class DataFlow : public GraphEditor::OutNode {
+
+ private :
+
+ SALOME_NamingService* _theNamingService ;
+ GraphExecutor::DataFlow * _DataFlowExecutor ;
+ bool _ReadOnly ;
+ bool _Executing ;
+
+ public:
+
+ DataFlow();
+ DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
+ const char * DataFlowName ,
+ const char * DebugFileName );
+ 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 = SUPERV::ComputingNode ,
+ const SUPERV::SDate DataFlowFirstCreation = SUPERV::SDate() ,
+ const SUPERV::SDate DataFlowLastModification = SUPERV::SDate() ,
+ const char * DataFlowEditorRelease = NULL ,
+ const char * DataFlowAuthor = NULL ,
+ const char * DataFlowComputer = NULL ,
+ const char * DataFlowComment = NULL ,
+ const char * DebugFileName = NULL ) ;
+ virtual ~DataFlow();
+
+ void ReadOnly() ;
+ char * DataFlowInfo() ;
+ char * DataNodeInfo() ;
+ char * NodeInfo( const char * aNodeName ) ;
+
+ bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
+ bool LoadXml( const char* myFileName ) ;
+ bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
+
+ bool SaveXml(const char* myFileName ) ;
+ bool SavePy(const char* myFileName ) ;
+
+
+// void DateModification() ;
+
+ GraphBase::SGraph * GetDataFlow() ;
+ GraphBase::SNode * GetInfo() const ;
+ GraphBase::ListOfNodes * GetNodes() const ;
+ GraphBase::ListOfLinks * GetLinks() const ;
+ GraphBase::ListOfGraphs * GetGraphs() const ;
+ GraphBase::ListOfLinks * GetDatas() const ;
+ const SALOME_ModuleCatalog::Service * GetService() ;
+
+ GraphEditor::InNode * AddService (
+ SALOME_ModuleCatalog::Service& aService ,
+ const char *NodeComponentName ,
+ const char* NodeInterfaceName ) {
+ return AddNode( aService , NodeComponentName ,
+ NodeInterfaceName ) ; } ;
+ GraphEditor::InNode * AddNode(
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ const char* NodeComponentName ,
+ const char* NodeInterfaceName ,
+ const char* NodeName = NULL ,
+ const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
+ GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ,
+ GraphBase::ListOfPythonFunctions aPythonFunction = GraphBase::ListOfPythonFunctions() ,
+ 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 int NodeX = 0 ,
+ const int NodeY = 0 ) ;
+ GraphEditor::InNode * GetNode( const char* NodeName ) ;
+ bool RemoveNode( const char* NodeName ) ;
+ bool ReNameNode( const char* OldNodeName ,
+ const char* NewNodeName ) ;
+
+ const SALOME_ModuleCatalog::Service * NodeService( const char * NodeName ) ;
+
+ void Coordinates( const int X , const int Y ) ;
+ const int XCoordinate() ;
+ const int YCoordinate() ;
+ void Coordinates( const char* NodeName , const int X , const int Y ) ;
+ const int XCoordinate( const char* NodeName ) ;
+ const int YCoordinate( const char* NodeName ) ;
+
+ const GraphBase::InPort *GetInPort( const char *name ) ;
+ const GraphBase::OutPort *GetOutPort( const char *name ) ;
+ GraphBase::InPort *GetChangeInPort( const char *name ) ;
+ GraphBase::OutPort *GetChangeOutPort( const char *name ) ;
+
+ bool HasInput(const char * ToServiceParameterName ) ;
+
+ bool AddLinkValue( const char *FromNodeName ,
+ const char *FromServiceParameterName ,
+ const char *ToNodeName ,
+ const char *ToServiceParameterName ,
+ const CORBA::Any aValue ) {
+ return AddLink( FromNodeName, FromServiceParameterName , ToNodeName ,
+ ToServiceParameterName , aValue ) ; } ;
+ bool AddLink( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const CORBA::Any aValue = CORBA::Any() ) ;
+
+ bool GetLink(const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ char** FromNodeName ,
+ char** FromServiceParameterName ) ;
+ GraphBase::SLink * GetLink( GraphBase::ComputingNode * aNode ,
+ const char* ToServiceParameterName ) ;
+
+ bool AddLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int nXY ,
+ const int* X ,
+ const int* Y ) ;
+ bool AddLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) ;
+ bool ChangeLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) ;
+ bool RemoveLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ) ;
+ int GetLinkCoordSize( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) ;
+ bool GetLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ int *X , int *Y ) ;
+ bool GetLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index , long &X , long &Y ) ;
+
+ bool RemoveLink( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) ;
+
+ bool AddInputData( const char* ToNodeName ,
+ const char* ToParameterName ,
+ const CORBA::Any aValue = CORBA::Any() ) ;
+ bool AddInputSharedData( const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) ;
+
+ const CORBA::Any *GetInData( const char * ToNodeName ,
+ const char * ToParameterName ) ;
+ const CORBA::Any *GetOutData( const char * FromNodeName ,
+ const char * FromParameterName ) ;
+
+ bool IsValid() ;
+ bool IsExecutable() ;
+
+ bool IsExecuting() ;
+ bool IsEditing() ;
+
+ bool IsReadOnly() ;
+
+ long LevelMax() ;
+ SUPERV::ListOfStrings * LevelNodes(long aLevel ) ;
+ long ThreadsMax() ;
+ long GraphsNumber() ;
+
+ void Executor(GraphExecutor::DataFlow * DataFlowExecutor ) ;
+ GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const ;
+
+ };
+
+};
+
+#include "DataFlowEditor_DataFlow.lxx"
+
+ostream & operator << (ostream &,const GraphEditor::DataFlow & G);
+ostream & operator << (ostream &,const SUPERV::SDate &);
+
+#endif
+
+
+
--- /dev/null
+#ifndef _DATAFLOWEDITOR_DATAFLOW_LXX
+#define _DATAFLOWEDITOR_DATAFLOW_LXX
+
+#include "DataFlowEditor_OutNode.hxx"
+
+inline void GraphEditor::DataFlow::ReadOnly() {
+ _ReadOnly = true ;
+}
+
+inline char * GraphEditor::DataFlow::DataFlowInfo() {
+ ostrstream s;
+ IsValid() ;
+ GraphEditor::DataFlow::DataFlow aDataFlow = *this ;
+ s << aDataFlow << ends ;
+ return CORBA::string_dup( s.str() );
+}
+
+inline char * GraphEditor::DataFlow::DataNodeInfo() {
+ ostrstream s;
+ IsValid() ;
+ GraphBase::DataNode::DataNodeInfo( s ) ;
+ return CORBA::string_dup(s.str());
+}
+
+inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) {
+ ostrstream s;
+ if ( GetGraphNode( aNodeName ) )
+ GetGraphNode( aNodeName )->NodeInfo( s ) ;
+ else
+ s << aNodeName << " not found" << ends ;
+ return CORBA::string_dup( s.str() );
+}
+
+inline bool GraphEditor::DataFlow::LoadDataFlow(
+ const GraphBase::SGraph *aDataFlow ) {
+ if ( _ReadOnly )
+ return false ;
+ return GraphEditor::OutNode::LoadDataFlow( aDataFlow ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::LoadXml( const char* myFileName ) {
+ if ( _ReadOnly )
+ return false ;
+ return GraphEditor::OutNode::LoadXml( myFileName ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::LoadInfo( const GraphBase::SNode &aDataFlowInfo ) {
+ if ( _ReadOnly )
+ return false ;
+ return GraphEditor::OutNode::LoadInfo( aDataFlowInfo ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::SaveXml(const char* myFileName ) {
+ return GraphEditor::OutNode::SaveXml( myFileName ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::SavePy(const char* myFileName ) {
+ return GraphEditor::OutNode::SavePy( myFileName ) ;
+} ;
+
+// get all DataFlow informations (for a .XML file) :
+inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() {
+ return GraphEditor::OutNode::GetDataFlow() ;
+} ;
+
+// void DateModification() ;
+
+inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const {
+ return GraphEditor::OutNode::GetInfo() ;
+} ;
+
+inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const {
+ return GraphEditor::OutNode::GetNodes() ;
+} ;
+
+inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const {
+ return GraphEditor::OutNode::GetLinks() ;
+} ;
+
+inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const {
+ return GraphEditor::OutNode::GetGraphs() ;
+} ;
+
+inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const {
+ return GraphEditor::OutNode::GetDatas() ;
+} ;
+
+inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() {
+ IsValid() ;
+ return GraphEditor::OutNode::GetService() ;
+} ;
+
+inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode(
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ const char* NodeComponentName ,
+ const char* NodeInterfaceName ,
+ const char* NodeName,
+ const SUPERV::KindOfNode NodeKindOfNode,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const SUPERV::SDate NodeFirstCreation,
+ const SUPERV::SDate NodeLastModification,
+ const char * NodeEditorRelease,
+ const char * NodeAuthor,
+ const char * NodeComputer,
+ const char * NodeComment,
+ const int NodeX,
+ const int NodeY) {
+ if ( _ReadOnly )
+ return (GraphEditor::InNode * ) NULL ;
+ return GraphEditor::OutNode::AddNode( NodeService ,
+ aFuncName , aPythonFunction ,
+ NodeComponentName ,
+ NodeInterfaceName ,
+ NodeName , NodeKindOfNode ,
+ NodeFirstCreation ,
+ NodeLastModification ,
+ NodeEditorRelease ,
+ NodeAuthor , NodeComputer ,
+ NodeComment , NodeX , NodeY ) ;
+} ;
+
+inline GraphEditor::InNode * GraphEditor::DataFlow::GetNode( const char* NodeName ) {
+ return GraphEditor::OutNode::GetNode( NodeName ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::RemoveNode( const char* NodeName ) {
+ if ( _ReadOnly )
+ return false ;
+ return GraphEditor::OutNode::RemoveNode( NodeName ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName ,
+ const char* NewNodeName ) {
+ if ( _ReadOnly )
+ return false ;
+ return GraphEditor::OutNode::ReNameNode( OldNodeName , NewNodeName ) ;
+} ;
+
+inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService(
+ const char * aNodeName ) {
+ if ( GetGraphNode( aNodeName ) )
+ return GetGraphNode( aNodeName )->GetService() ;
+ return NULL ;
+}
+
+inline void GraphEditor::DataFlow::Coordinates( const int X , const int Y ) {
+ return GraphEditor::OutNode::Coordinates( X , Y ) ;
+} ;
+
+inline const int GraphEditor::DataFlow::XCoordinate() {
+ return GraphEditor::OutNode::XCoordinate() ;
+} ;
+
+inline const int GraphEditor::DataFlow::YCoordinate() {
+ return GraphEditor::OutNode::YCoordinate() ;
+} ;
+
+inline void GraphEditor::DataFlow::Coordinates( const char* NodeName ,
+ const int X , const int Y ) {
+ return GraphEditor::OutNode::Coordinates( NodeName , X , Y ) ;
+} ;
+
+inline const int GraphEditor::DataFlow::XCoordinate( const char* NodeName ) {
+ return GraphEditor::OutNode::XCoordinate( NodeName ) ;
+} ;
+
+inline const int GraphEditor::DataFlow::YCoordinate( const char* NodeName ) {
+ return GraphEditor::OutNode::YCoordinate( NodeName ) ;
+} ;
+
+inline const GraphBase::InPort *GraphEditor::DataFlow::GetInPort( const char *name ) {
+ return GraphEditor::OutNode::GetInPort( name ) ;
+}
+inline const GraphBase::OutPort *GraphEditor::DataFlow::GetOutPort( const char *name ) {
+ return GraphEditor::OutNode::GetOutPort( name ) ;
+}
+inline GraphBase::InPort *GraphEditor::DataFlow::GetChangeInPort( const char *name ) {
+ return GraphEditor::OutNode::GetChangeInPort( name ) ;
+}
+inline GraphBase::OutPort *GraphEditor::DataFlow::GetChangeOutPort( const char *name ) {
+ return GraphEditor::OutNode::GetChangeOutPort( name ) ;
+}
+
+inline bool GraphEditor::DataFlow::HasInput(const char * ToServiceParameterName ) {
+ return GraphEditor::OutNode::HasInput( ToServiceParameterName ) ;
+}
+
+inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const CORBA::Any aValue ) {
+ if ( _ReadOnly )
+ return false ;
+ CORBA::Any const * theValue = GetNode( FromNodeName )->GetOutPort( FromServiceParameterName )->Value() ; // Keep the type !
+ return GraphEditor::OutNode::AddLink( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ *theValue ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ char** FromNodeName ,
+ char** FromServiceParameterName ) {
+ return GraphEditor::OutNode::GetLink( ToNodeName , ToServiceParameterName ,
+ FromNodeName ,
+ FromServiceParameterName ) ;
+}
+
+inline GraphBase::SLink * GraphEditor::DataFlow::GetLink(
+ GraphBase::ComputingNode * aNode ,
+ const char* ToServiceParameterName ) {
+ return GraphBase::Graph::GetLink( aNode ,
+ aNode->GetChangeInPort( ToServiceParameterName ) ) ;
+}
+
+inline bool GraphEditor::DataFlow::AddLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int nXY ,
+ const int* X ,
+ const int* Y ) {
+ return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ nXY , X , Y ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::AddLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) {
+ return GraphEditor::OutNode::AddLinkCoord( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ index , X , Y ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::ChangeLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) {
+ return GraphEditor::OutNode::ChangeLinkCoord( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ index , X , Y ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::RemoveLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ) {
+ return GraphEditor::OutNode::RemoveLinkCoord( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ index ) ;
+} ;
+
+inline int GraphEditor::DataFlow::GetLinkCoordSize(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) {
+ return GraphEditor::OutNode::GetLinkCoordSize( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::GetLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ int *X , int *Y ) {
+ return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ X , Y ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::GetLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index , long &X , long &Y ) {
+ return GraphEditor::OutNode::GetLinkCoord( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ,
+ index , X , Y ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::RemoveLink(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) {
+ if ( _ReadOnly )
+ return false ;
+ return GraphEditor::OutNode::RemoveLink( FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName ,
+ const char* ToParameterName ,
+ const CORBA::Any aValue ) {
+#if 0
+ GraphBase::Node *toNode ;
+ GraphBase::InPort *toPort ;
+ char *aNode ;
+ char *aPort ;
+ NodePort( ToNodeName , ToParameterName , &aNode , &aPort ) ;
+ toNode = GetChangeGraphNode( aNode ) ;
+ if ( toNode ) {
+ toPort = toNode->GetChangeInPort( aPort ) ;
+ if ( toPort && ( toPort->IsConnected() ||
+ toPort->IsDataConnected() ) ) {
+ RemoveLink( toNode->Name() , toPort->PortName() ) ;
+ }
+ }
+ else {
+ toPort = NULL ;
+ }
+ delete aNode ;
+ delete aPort ;
+#endif
+ if ( !IsValid() )
+ return false ;
+ return GraphBase::Graph::AddInputData( ToNodeName , ToParameterName ,
+ aValue ) ;
+} ;
+
+inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) {
+ if ( !IsValid() )
+ return false ;
+ return GraphEditor::OutNode::AddInputData( ToNodeName1 , ToParameterName1 ,
+ ToNodeName2 , ToParameterName2 ) ;
+} ;
+
+inline const CORBA::Any *GraphEditor::DataFlow::GetInData(
+ const char * ToNodeName ,
+ const char * ToParameterName ) {
+ return GraphEditor::OutNode::GetInData( ToNodeName ,
+ ToParameterName ) ;
+}
+inline const CORBA::Any *GraphEditor::DataFlow::GetOutData(
+ const char * FromNodeName ,
+ const char * FromParameterName ) {
+ return GraphEditor::OutNode::GetOutData( FromNodeName ,
+ FromParameterName ) ;
+}
+
+inline bool GraphEditor::DataFlow::IsValid() {
+ return GraphEditor::OutNode::IsValid() ;
+}
+
+inline bool GraphEditor::DataFlow::IsExecutable() {
+ return GraphEditor::OutNode::IsExecutable() ;
+}
+
+inline bool GraphEditor::DataFlow::IsExecuting() {
+ if ( _DataFlowExecutor ) {
+ if ( _DataFlowExecutor->IsDone() ) {
+ _Executing = false ;
+ }
+ else {
+ _Executing = true ;
+ }
+ }
+ else {
+ _Executing = false ;
+ }
+ return _Executing ;
+}
+
+inline bool GraphEditor::DataFlow::IsEditing() {
+ return !IsExecuting() ;
+}
+
+inline bool GraphEditor::DataFlow::IsReadOnly() {
+ return _ReadOnly ;
+}
+
+inline long GraphEditor::DataFlow::LevelMax() {
+ if ( !IsValid() )
+ return 0 ;
+ return GraphBase::Graph::LevelMax() ;
+}
+
+inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) {
+ if ( !IsValid() )
+ return ((SUPERV::ListOfStrings * ) NULL ) ;
+ return GraphBase::Graph::LevelNodes( aLevel ) ;
+}
+
+inline long GraphEditor::DataFlow::ThreadsMax() {
+ if ( !IsValid() )
+ return 0 ;
+ return GraphBase::Graph::ThreadsMax() ;
+}
+
+inline long GraphEditor::DataFlow::GraphsNumber() {
+ if ( !IsValid() )
+ return 0 ;
+ return GraphBase::Graph::GraphsNumber() ;
+}
+
+inline void GraphEditor::DataFlow::Executor(
+ GraphExecutor::DataFlow * DataFlowExecutor ) {
+ _DataFlowExecutor = DataFlowExecutor ;
+}
+
+inline GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const {
+ return _DataFlowExecutor ;
+}
+
+#endif
+
+
+
--- /dev/null
+using namespace std;
+#include <string.h>
+#include <strstream>
+#include <iostream>
+
+#include "DataFlowEditor_InNode.hxx"
+
+GraphEditor::InNode::InNode() {
+}
+
+GraphEditor::InNode::InNode( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const SALOME_ModuleCatalog::Service& aService ,
+ const char * ComponentName ,
+ const char* NodeInterfaceName ,
+ const char * NodeName ,
+ const SUPERV::KindOfNode akind ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const bool GeneratedName ,
+ const int X ,
+ const int Y ,
+ int * Graph_prof_debug,
+ ostream * Graph_fdebug) {
+ SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+
+ _ComputingNode = NULL ;
+ _FactoryNode = NULL ;
+ _InLineNode = NULL ;
+ _GOTONode = NULL ;
+ _LoopNode = NULL ;
+ _EndOfLoopNode = NULL ;
+ _SwitchNode = NULL ;
+ _EndOfSwitchNode = NULL ;
+ switch ( akind ) {
+ case SUPERV::ComputingNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::ComputingNode : " << NodeName ;
+ _ComputingNode = new GraphBase::ComputingNode( ORB , ptrNamingService , aService ,
+ NodeName , akind ,
+ NodeFirstCreation ,
+ NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ break ;
+ }
+ case SUPERV::FactoryNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::FactoryNode : " << NodeName ;
+ _FactoryNode = new GraphBase::FactoryNode( ORB , ptrNamingService , aService ,
+ ComponentName , NodeInterfaceName ,
+ NodeName , akind ,
+ NodeFirstCreation ,
+ NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComputer , NodeComment ,
+ GeneratedName , X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _FactoryNode ;
+ break ;
+ }
+ case SUPERV::InLineNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::InLineNode : " << NodeName ;
+ _InLineNode = new GraphBase::InLineNode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _InLineNode ;
+ break ;
+ }
+ case SUPERV::GOTONode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::GOTONode : " << NodeName ;
+ _GOTONode = new GraphBase::GOTONode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _GOTONode ;
+ break ;
+ }
+ case SUPERV::LoopNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::LoopNode : " << NodeName ;
+ _LoopNode = new GraphBase::LoopNode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ aFuncName[1].c_str() , *aPythonFunction[1] ,
+ aFuncName[2].c_str() , *aPythonFunction[2] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _LoopNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ case SUPERV::EndLoopNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::EndOfLoopNode : " << NodeName ;
+ _EndOfLoopNode = new GraphBase::EndOfLoopNode(
+ ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _EndOfLoopNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ case SUPERV::SwitchNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::SwitchNode : " << NodeName ;
+ _SwitchNode = new GraphBase::SwitchNode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _SwitchNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ case SUPERV::EndSwitchNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::EndOfSwitchNode : " << NodeName ;
+ _EndOfSwitchNode = new GraphBase::EndOfSwitchNode(
+ ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ X , Y ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _EndOfSwitchNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ }
+ cdebug << "GraphEditor::InNode::InNode " << (void *) this
+ << " _ComputingNode " << (void *) _ComputingNode ;
+ _ComputingNode->InNode( this ) ;
+}
+
+GraphEditor::InNode::~InNode() {
+}
+
--- /dev/null
+#ifndef _DATAFLOWEDITOR_INNODE_HXX
+#define _DATAFLOWEDITOR_INNODE_HXX
+
+#include "DataFlowBase_FactoryNode.hxx"
+#include "DataFlowBase_GOTONode.hxx"
+#include "DataFlowBase_LoopNode.hxx"
+#include "DataFlowBase_EndOfLoopNode.hxx"
+#include "DataFlowBase_SwitchNode.hxx"
+#include "DataFlowBase_EndOfSwitchNode.hxx"
+
+namespace GraphEditor {
+
+ class InNode : public GraphBase::Base {
+
+ private:
+
+ GraphBase::ComputingNode * _ComputingNode ;
+ GraphBase::FactoryNode * _FactoryNode ;
+ GraphBase::InLineNode * _InLineNode ;
+ GraphBase::GOTONode * _GOTONode ;
+ GraphBase::LoopNode * _LoopNode ;
+ GraphBase::EndOfLoopNode * _EndOfLoopNode ;
+ GraphBase::SwitchNode * _SwitchNode ;
+ GraphBase::EndOfSwitchNode * _EndOfSwitchNode ;
+
+ public:
+
+ InNode() ;
+ InNode( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ const char *NodeComponentName ,
+ const char* NodeInterfaceName ,
+ const char *NodeName ,
+ const SUPERV::KindOfNode akind ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const bool GeneratedName ,
+ const int NodeX ,
+ const int NodeY ,
+ int * Graph_prof_debug = NULL ,
+ ostream * Graph_fdebug = NULL ) ;
+ virtual ~InNode() ;
+
+ char * Name() const { return _ComputingNode->Name() ; } ;
+ const char *const * NamePtr() const {
+ return _ComputingNode->NamePtr() ; } ;
+
+ SUPERV::KindOfNode Kind() const {
+ return _ComputingNode->Kind() ; } ;
+ const bool IsComputingNode() const {
+ return _ComputingNode->IsComputingNode() ; } ;
+ const bool IsFactoryNode() const {
+ return _ComputingNode->IsFactoryNode() ; } ;
+ const bool IsInLineNode() const {
+ return _ComputingNode->IsInLineNode() ; } ;
+ const bool IsOneOfInLineNodes() const {
+ return _ComputingNode->IsOneOfInLineNodes() ; } ;
+ const bool IsOneOfGOTONodes() const {
+ return _ComputingNode->IsOneOfGOTONodes() ; } ;
+ const bool IsDataFlowNode() const {
+ return _ComputingNode->IsDataFlowNode() ; } ;
+ const bool IsGOTONode() const {
+ return _ComputingNode->IsGOTONode() ; } ;
+ const bool IsLoopNode() const {
+ return _ComputingNode->IsLoopNode() ; } ;
+ const bool IsEndLoopNode() const {
+ return _ComputingNode->IsEndLoopNode() ; } ;
+ const bool IsSwitchNode() const {
+ return _ComputingNode->IsSwitchNode() ; } ;
+ const bool IsEndSwitchNode() const {
+ return _ComputingNode->IsEndSwitchNode() ; } ;
+ const bool IsHeadNode() const {
+ return _ComputingNode->IsHeadNode() ; } ;
+ GraphBase::ComputingNode * ComputingNode() {
+ return _ComputingNode ; } ;
+ GraphBase::FactoryNode * FactoryNode() {
+ return _FactoryNode ; } ;
+ GraphBase::GOTONode * GOTONode() {
+ if ( _GOTONode )
+ return _GOTONode ;
+ if ( _LoopNode )
+ return _LoopNode ;
+ if ( _EndOfLoopNode )
+ return _EndOfLoopNode ;
+ if ( _SwitchNode )
+ return _SwitchNode ;
+ if ( _EndOfSwitchNode )
+ return _EndOfSwitchNode ;
+ return NULL ;
+ } ;
+ GraphBase::GOTONode * GOTONode() const {
+ if ( _GOTONode )
+ return _GOTONode ;
+ if ( _LoopNode )
+ return _LoopNode ;
+ if ( _EndOfLoopNode )
+ return _EndOfLoopNode ;
+ if ( _SwitchNode )
+ return _SwitchNode ;
+ if ( _EndOfSwitchNode )
+ return _EndOfSwitchNode ;
+ return NULL ;
+ } ;
+ GraphBase::InLineNode * InLineNode() {
+ GraphBase::InLineNode * aNode = GOTONode() ;
+ if ( aNode == NULL )
+ return _InLineNode ;
+ return aNode ;
+ } ;
+ GraphBase::InLineNode * InLineNode() const {
+ GraphBase::InLineNode * aNode = GOTONode() ;
+ if ( aNode == NULL )
+ return _InLineNode ;
+ return aNode ;
+ } ;
+ GraphBase::LoopNode * LoopNode() {
+ return _LoopNode ; } ;
+ GraphBase::EndOfLoopNode * EndOfLoopNode() {
+ return _EndOfLoopNode ; } ;
+ GraphBase::SwitchNode * SwitchNode() {
+ return _SwitchNode ; } ;
+ GraphBase::EndOfSwitchNode * EndOfSwitchNode() {
+ return _EndOfSwitchNode ; } ;
+
+ SUPERV::CNode_var ObjRef() const { return _ComputingNode->ObjRef() ; } ;
+ void SetObjRef(SUPERV::CNode_var aNode) {
+ _ComputingNode->SetObjRef( aNode ) ; } ;
+
+ const SALOME_ModuleCatalog::Service * GetService() const {
+ return _ComputingNode->GetService() ; } ;
+
+ SUPERV::SDate FirstCreation() const {
+ return _ComputingNode->FirstCreation() ; } ;
+ SUPERV::SDate LastModification() const {
+ return _ComputingNode->LastModification() ; } ;
+ char* Author() const {
+ return my_strdup( _ComputingNode->Author() ) ; }
+ char* EditorRelease() const {
+ return my_strdup( _ComputingNode->EditorRelease() ) ; } ;
+ char * Comment() const {
+ return my_strdup( _ComputingNode->Comment() ) ; } ;
+ bool Author( const char * anAuthor ) {
+ return _ComputingNode->Author( anAuthor ) ; } ;
+ bool EditorRelease( const char* anEditorRelease ) {
+ return _ComputingNode->EditorRelease( anEditorRelease ) ; } ;
+ bool Comment( const char *c ) {
+ return _ComputingNode->Comment( c ) ; };
+
+ GraphBase::SNode * GetInfo() {
+ return _ComputingNode->GetInfo() ; } ;
+
+ GraphBase::InPort * AddInPort( const char * InputParameterName ,
+ const char * InputParameterType ) {
+ return _ComputingNode->AddInPort( InputParameterName ,
+ InputParameterType ) ; } ;
+ GraphBase::OutPort * AddOutPort( const char * OutputParameterName ,
+ const char * OutputParameterType ) {
+ return _ComputingNode->AddOutPort( OutputParameterName ,
+ OutputParameterType ) ; } ;
+
+ void DelInPort( const char * InputParameterName ) {
+ _ComputingNode->DelInPort( InputParameterName ) ; } ;
+ void DelOutPort( const char * OutputParameterName ) {
+ _ComputingNode->DelOutPort( OutputParameterName ) ; } ;
+
+ bool IsLinked(const char * ToServiceParameterName ) {
+ return _ComputingNode->IsLinked( ToServiceParameterName ) ; } ;
+ bool HasInput(const char * ToServiceParameterName ) {
+ return _ComputingNode->HasInput( ToServiceParameterName ) ; } ;
+
+// void InOutPort( GraphBase::InPort * InputPort ,
+// GraphBase::OutPort * OutputPort ) {
+// return _ComputingNode->InOutPort( InputPort , OutputPort ) ; } ;
+
+ const int GetNodeInPortsSize() const {
+ return _ComputingNode->GetNodeInPortsSize() ; } ;
+ const GraphBase::InPort *GetNodeInPort(int i) const {
+ return _ComputingNode->GetNodeInPort( i ) ; } ;
+ GraphBase::InPort *GetChangeNodeInPort(int i) const {
+ return _ComputingNode->GetChangeNodeInPort( i ) ; } ;
+ const int GetNodeOutPortsSize() const {
+ return _ComputingNode->GetNodeOutPortsSize() ; } ;
+ const GraphBase::OutPort *GetNodeOutPort(int i) const {
+ return _ComputingNode->GetNodeOutPort( i ) ; } ;
+ GraphBase::OutPort *GetChangeNodeOutPort(int i) const {
+ return _ComputingNode->GetChangeNodeOutPort( i ) ; } ;
+
+ const GraphBase::InPort *GetInPort( const char *name ) {
+ return _ComputingNode->GetInPort( name ) ; } ;
+ const GraphBase::OutPort *GetOutPort( const char *name ) {
+ return _ComputingNode->GetOutPort( name ) ; } ;
+ GraphBase::InPort *GetChangeInPort( const char *name ) {
+ return _ComputingNode->GetChangeInPort( name ) ; } ;
+ GraphBase::OutPort *GetChangeOutPort( const char *name ) {
+ return _ComputingNode->GetChangeOutPort( name ) ; } ;
+
+ void SetPythonFunction( const char * aFuncName ,
+ const SUPERV::ListOfStrings & aPythonFunction ) {
+ InLineNode()->SetPythonFunction( aFuncName , aPythonFunction ) ; }
+ const SUPERV::ListOfStrings * PythonFunction() const {
+ return InLineNode()->PythonFunction() ; } ;
+ char * PyFuncName() const {
+ return InLineNode()->PyFuncName() ; } ;
+
+ void SetPyMorePythonFunction( const char * aMoreName ,
+ const SUPERV::ListOfStrings & aMorePythonFunction ) {
+ _LoopNode->SetMorePythonFunction( aMoreName , aMorePythonFunction ) ; }
+ SUPERV::ListOfStrings * PyMorePythonFunction() const {
+ return _LoopNode->MorePythonFunction() ; } ;
+ char * PyMoreName() {
+ return _LoopNode->PyMoreName() ; };
+
+ void SetPyNextPythonFunction( const char * aNextName ,
+ const SUPERV::ListOfStrings & aNextPythonFunction ) {
+ _LoopNode->SetNextPythonFunction( aNextName , aNextPythonFunction ) ; }
+ SUPERV::ListOfStrings * PyNextPythonFunction() const {
+ return _LoopNode->NextPythonFunction() ; } ;
+ char * PyNextName() {
+ return _LoopNode->PyNextName() ; } ;
+
+ void CoupledNode( GraphBase::InLineNode * aCoupledNode ) {
+ _GOTONode->CoupledNode( aCoupledNode ) ; } ;
+ GraphBase::InLineNode * CoupledNode() {
+ return _GOTONode->CoupledNode() ; } ;
+
+ int SubGraph() {
+ return _ComputingNode->SubGraph() ; } ;
+
+ char * ComponentName() const {
+ return _FactoryNode->ComponentName() ; } ;
+ char * InterfaceName() const {
+ return _FactoryNode->InterfaceName() ; } ;
+ char * Computer() const {
+ return _FactoryNode->Computer() ; } ;
+
+ bool ComponentName( const char * aComponentName ) {
+ return _FactoryNode->ComponentName( aComponentName ) ; } ;
+ bool InterfaceName( const char * anInterfaceName ) {
+ return _FactoryNode->InterfaceName( anInterfaceName ) ; } ;
+ bool Computer( const char *c ) {
+ return _FactoryNode->Computer( c ) ; } ;
+
+ void Coordinates( const int X , const int Y ) {
+ _ComputingNode->Coordinates( X , Y ) ; } ;
+ int XCoordinate () {
+ return _ComputingNode->XCoordinate () ; } ;
+ int YCoordinate () {
+ return _ComputingNode->YCoordinate () ; } ;
+ };
+
+
+};
+
+#endif
--- /dev/null
+using namespace std;
+
+#include "DataFlowEditor_OutNode.hxx"
+#include "DataFlowBase_EndOfLoopNode.hxx"
+#include "DataFlowBase_EndOfSwitchNode.hxx"
+
+// Implementation de la classe GraphEditor::Graph
+
+GraphEditor::OutNode::OutNode() :
+ Graph() {
+ cdebug_in << "GraphEditor::OutNode::OutNode()" << endl;
+
+ _Imported = false ;
+ _Valid = false ;
+ _Executable = false ;
+
+ cdebug_out << "GraphEditor::OutNode::OutNode()" << endl;
+}
+
+GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB ,
+ SALOME_NamingService* ptrNamingService ,
+ const char *DataFlowName ,
+ const char * DebugFileName ) :
+ Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
+ cdebug_in << "GraphEditor::OutNode::OutNode(" ;
+ if ( DataFlowName ) {
+ cdebug << DataFlowName ;
+ }
+ cdebug << ")" << endl;
+
+ _Orb = CORBA::ORB::_duplicate( ORB ) ;
+ _Imported = false ;
+ _Valid = false ;
+ _Executable = false ;
+
+ cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
+}
+
+GraphEditor::OutNode::OutNode(
+ 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 * DataFlowEditorRelease ,
+ const char * DataFlowAuthor ,
+ const char * DataFlowComputer ,
+ const char * DataFlowComment ,
+ const char * DebugFileName ) :
+ Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
+ DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+ DataFlowFirstCreation , DataFlowLastModification ,
+ DataFlowEditorRelease , DataFlowAuthor ,
+ DataFlowComputer , DataFlowComment , DebugFileName ) {
+
+ _Orb = CORBA::ORB::_duplicate( ORB ) ;
+ _Imported = false ;
+ _Valid = false ;
+ _Executable = false ;
+
+} ;
+
+GraphEditor::OutNode::~OutNode() {
+// delete _DataFlowNode ;
+// delete _DataFlowDatas ;
+// delete _GT ;
+}
+
+bool GraphEditor::OutNode::LoadDataFlow(
+ const GraphBase::SGraph *aDataFlow ) {
+ bool RetVal = false ;
+ cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << aDataFlow->Info.theName.c_str()
+ << endl;
+// if ( GraphBase::Service::ServiceName() == NULL ||
+// !strlen( GraphBase::Service::ServiceName() ) || !aConstructor ) {
+ if ( !_Imported ) {
+ RetVal = LoadInfo( aDataFlow->Info ) ;
+ _Imported = true ;
+ }
+ else
+ RetVal = true ;
+
+ map< string , int > aMapOfNodes ;
+ if ( RetVal )
+ RetVal = LoadNodes( aMapOfNodes , aDataFlow->Nodes ) ;
+ if ( RetVal )
+ RetVal = LoadLinks( aMapOfNodes , aDataFlow->Links ) ;
+ if ( RetVal ) {
+ Valid() ;
+ RetVal = LoadDatas( aMapOfNodes , aDataFlow->Datas ) ;
+ }
+// }
+// else {
+// cdebug << "GraphEditor::OutNode::LoadDataFlow Error. ServiceName : "
+// << (void *) GraphBase::Service::ServiceName() << " '"
+// << GraphBase::Service::ServiceName() << "'" << endl ;
+// }
+ cdebug_out << "GraphEditor::OutNode::LoadDataFlow" << endl;
+ return RetVal ;
+}
+
+bool GraphEditor::OutNode::LoadXml( const char* myFileName ) {
+ bool RetVal = false ;
+ GraphBase::SGraph aDataFlow ;
+ cdebug_in << "GraphEditor::OutNode::LoadXml() " << endl;
+ if ( myFileName == NULL ) {
+ _Imported = true ;
+ RetVal = true ;
+ }
+ else if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) {
+ RetVal = LoadDataFlow( &aDataFlow ) ;
+// if ( RetVal )
+// RetVal = Name( aDataFlow.Info.theName.c_str() ) ;
+ }
+ cdebug_out << "GraphEditor::OutNode::LoadXml" << endl;
+ return RetVal ;
+}
+
+bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
+ cdebug_in << "GraphEditor::OutNode::LoadInfo " << aDataFlowInfo.theName.c_str()
+ << endl ;
+// MESSAGE( "GraphEditor::OutNode::LoadDataFlow" );
+// ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
+// InterfaceName( aDataFlowInfo.theInterfaceName.c_str() ) ;
+ Name( aDataFlowInfo.theName.c_str() ) ;
+ Kind( aDataFlowInfo.theKind ) ;
+ Service( aDataFlowInfo.theService ) ;
+ FirstCreation( aDataFlowInfo.theFirstCreation ) ;
+ LastModification( aDataFlowInfo.theLastModification ) ;
+ EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
+ Author( aDataFlowInfo.theAuthor.c_str() ) ;
+// Computer( aDataFlowInfo.theContainer.c_str() ) ;
+ Comment( aDataFlowInfo.theComment.c_str() ) ;
+// Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
+// Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
+ cdebug_out << "GraphEditor::OutNode::LoadInfo" << endl ;
+ return true ;
+}
+
+bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes ,
+ const GraphBase::ListOfNodes &aListOfNodes ) {
+ GraphEditor::InNode * anInNode ;
+ cdebug_in << "GraphEditor::OutNode::LoadNodes" << endl ;
+ int i ;
+ for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
+ GraphBase::SNode aNode = aListOfNodes[ i ] ;
+// if ( aConstructor ) {
+// anInNode = AddNode( aNode.theService , aNode.theComponentName.c_str() ,
+// aNode.theInterfaceName.c_str() ,
+// aNode.theName.c_str() ,
+// aNode.theKind ,
+// aNode.theFirstCreation , aNode.theLastModification ,
+// aNode.theEditorRelease.c_str() ,
+// aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
+// aNode.theComment.c_str() ,
+// aNode.theCoords.theX , aNode.theCoords.theY ) ;
+// }
+// else {
+ const char * aNodeName = aNode.theName.c_str() ;
+ if ( aNode.theListOfFuncName.size() == 0 ) {
+ aNode.theListOfFuncName.resize( 1 ) ;
+ aNode.theListOfFuncName[ 0 ] = "" ;
+ aNode.theListOfPythonFunctions.resize( 1 ) ;
+ aNode.theListOfPythonFunctions[ 0 ] = new SUPERV::ListOfStrings() ;
+ }
+ if ( GetGraphNode( aNode.theName.c_str() ) )
+ aNodeName = NULL ;
+ anInNode = AddNode( aNode.theService ,
+ aNode.theListOfFuncName ,
+ aNode.theListOfPythonFunctions ,
+ aNode.theComponentName.c_str() ,
+ aNode.theInterfaceName.c_str() , aNodeName ,
+ aNode.theKind ,
+ aNode.theFirstCreation , aNode.theLastModification ,
+ aNode.theEditorRelease.c_str() ,
+ aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
+ aNode.theComment.c_str() ,
+ aNode.theCoords.theX , aNode.theCoords.theY ) ;
+ string * aNodetheName = new string( aNode.theName ) ;
+ aMapOfNodes[ *aNodetheName ] = GetGraphNodeIndex( anInNode->Name() ) ;
+ if ( anInNode->IsOneOfInLineNodes() ) {
+ anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode(
+ _Orb , aNode.theService , anInNode->NamePtr() ,
+ anInNode->Kind() , false ,
+ anInNode->IsLoopNode() || anInNode->IsEndLoopNode() ,
+ true , true , Graph_prof_debug() , Graph_fdebug() ) ;
+ GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
+ GraphBase::LoopNode * aLNode = NULL ;
+ if ( aINode->IsLoopNode() ) {
+ aLNode = anInNode->LoopNode() ;
+ aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 0 ] ) ;
+ aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 1 ] ) ;
+ aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 2 ] ) ;
+ }
+ else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
+ aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
+ aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 0 ] ) ;
+ }
+ }
+#if 0
+ if ( aNode.theListOfParameters.size() ) {
+ int j ;
+ for ( j = 0 ; j < aNode.theListOfParameters.size() ; j++ ) {
+ if ( IsInLineNode() ) {
+ GraphBase::InPort * InputPort = anInNode->AddInPort(
+ aNode.theListOfParameters[ j ].theInParameter.Parametername ,
+ aNode.theListOfParameters[ j ].theInParameter.Parametertype ) ;
+ GraphBase::OutPort * OutputPort = anInNode->AddOutPort(
+ aNode.theListOfParameters[ j ].theOutParameter.Parametername ,
+ aNode.theListOfParameters[ j ].theOutParameter.Parametertype ) ;
+ anInNode->InOutPort( InputPort , OutputPort ) ;
+ }
+ }
+ }
+#endif
+// cout << "LoadNodes " << aNodetheName << " "
+// << GetGraphNodeIndex( anInNode->Name() ) << endl ;
+ delete aNodetheName ;
+// }
+ if ( !anInNode )
+ return false ;
+ }
+ for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
+ GraphBase::SNode aNode = aListOfNodes[ i ] ;
+ cdebug << "GraphEditor::OutNode::LoadNodes " << aNode.theName.c_str() << " Coupled to "
+ << aNode.theCoupledNode.c_str() << endl ;
+ anInNode = (GraphEditor::InNode * ) GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
+ if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
+ GraphBase::GOTONode * aCoupledNode ;
+ aCoupledNode = (GraphBase::GOTONode * ) GetGraphNode( aNode.theName.c_str() ) ;
+ aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ;
+ }
+ }
+ cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ;
+ return true ;
+}
+
+bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes ,
+ const GraphBase::ListOfLinks &aListOfLinks ) {
+ bool RetVal = true ;
+ cdebug_in << "GraphEditor::OutNode::LoadLinks" << endl ;
+// MESSAGE( "GraphEditor::OutNode::LoadLinks" );
+ int i , j ;
+ for ( i = 0 ; i < aListOfLinks.size() ; i++ ) {
+ GraphBase::SLink aLink = aListOfLinks[ i ] ;
+ string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
+ string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
+ RetVal = AddLink( GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
+ aLink.FromServiceParameterName.c_str() ,
+ GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
+ aLink.ToServiceParameterName.c_str() ,
+ *((GraphBase::ComputingNode *) GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ))->GetOutPort( aLink.FromServiceParameterName.c_str() )->Value() ) ;
+// aLink.aLinkValue ) ;
+ if ( !RetVal )
+ break ;
+ else {
+ for ( j = 0 ; j < aLink.aListOfCoords.size() ; j++ ) {
+ RetVal = AddLinkCoord( GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
+ aLink.FromServiceParameterName.c_str() ,
+ GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() ,
+ aLink.ToServiceParameterName.c_str() ,
+ j + 1 ,
+ aLink.aListOfCoords[j].theX ,
+ aLink.aListOfCoords[j].theY ) ;
+ if ( !RetVal )
+ break ;
+ }
+ }
+ delete aLinkFromNodeName ;
+ delete aLinkToNodeName ;
+ }
+ cdebug_out << "GraphEditor::OutNode::LoadLinks" << endl ;
+ return RetVal ;
+}
+
+bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes ,
+ const GraphBase::ListOfLinks &aListOfDatas ) {
+ bool RetVal = true ;
+ cdebug_in << "GraphEditor::OutNode::LoadDatas" << endl ;
+// MESSAGE( "GraphEditor::OutNode::LoadDatas" );
+ int i ;
+ for ( i = 0 ; i < aListOfDatas.size() ; i++ ) {
+ GraphBase::SLink aLink = aListOfDatas[ i ] ;
+ if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) ) {
+ cdebug << "GraphEditor::OutNode::LoadDatas Warning "
+ << aLink.FromNodeName.c_str()
+ << " and " << aLink.ToNodeName.c_str() << " differents from " << Name()
+ << endl ;
+ }
+ string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ;
+ string * aLinkToNodeName = new string( aLink.ToNodeName.c_str() ) ;
+// cout << "LoadDatas " << aLink.FromNodeName.c_str() << " "
+// << aMapOfNodes[ aLinkFromNodeName->c_str() ] << endl ;
+// cout << " " << aLink.ToNodeName.c_str() << " "
+// << aMapOfNodes[ aLinkToNodeName->c_str() ] << endl ;
+ RetVal = GraphBase::Graph::AddInputData( GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
+ aLink.ToServiceParameterName.c_str() ,
+ aLink.aLinkValue ) ;
+ delete aLinkFromNodeName ;
+ delete aLinkToNodeName ;
+ if ( !RetVal )
+ break ;
+ }
+ cdebug_out << "GraphEditor::OutNode::LoadDatas" << endl ;
+ return RetVal ;
+}
+
+bool GraphEditor::OutNode::SaveXml(const char* filename) {
+ bool test;
+ cdebug_in << "GraphEditor::OutNode::SaveXml(" << filename << ")" << endl;
+ ofstream f(filename);
+ IsValid() ;
+// test = SaveXML( f );
+ QDomDocument Graph ;
+ test = SaveXML( Graph );
+ if ( test ) {
+ QString xml = Graph.toString() ;
+// cout << "GraphEditor::OutNode::SaveXML " << xml << endl ;
+ f << xml << endl ;
+ }
+ cdebug_out << "GraphEditor::OutNode::SaveXml" << endl;
+ return test;
+}
+
+
+bool GraphEditor::OutNode::SavePy( const char* filename ) {
+ bool test;
+ cdebug_in << "GraphEditor::OutNode::SavePy(" << filename << ")" << endl;
+ ofstream f( filename ) ;
+ IsValid() ;
+ test = SavePY( f );
+ cdebug_out << "GraphEditor::OutNode::SavePy" << endl;
+ return test;
+}
+
+GraphBase::SGraph * GraphEditor::OutNode::GetDataFlow() {
+ GraphBase::SGraph * aDataFlow = new GraphBase::SGraph;
+ aDataFlow->Info = *GetInfo() ;
+ aDataFlow->Nodes = *GetNodes() ;
+ aDataFlow->Links = *GetLinks() ;
+ aDataFlow->Datas = *GetDatas() ;
+ return aDataFlow ;
+}
+
+void GraphEditor::OutNode::DateModification() {
+ time_t T = time(NULL);
+ struct tm * Tm = localtime(&T);
+ SUPERV::SDate aLastModificationDate ;
+
+ aLastModificationDate.Second = Tm->tm_sec;
+ aLastModificationDate.Minute = Tm->tm_min;
+ aLastModificationDate.Hour = Tm->tm_hour;
+ aLastModificationDate.Day = Tm->tm_mday;
+ aLastModificationDate.Month = Tm->tm_mon + 1;
+ aLastModificationDate.Year = Tm->tm_year + 1900;
+ LastModification( aLastModificationDate ) ;
+}
+
+void GraphEditor::OutNode::Coordinates( const char* NodeName ,
+ const int X ,
+ const int Y ) {
+ ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ;
+}
+
+const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) {
+ return ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->XCoordinate() ;
+}
+
+const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) {
+ return ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->YCoordinate() ;
+}
+
+GraphEditor::InNode *GraphEditor::OutNode::AddNode(
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const char *NodeComponentName ,
+ const char* NodeInterfaceName ,
+ const char *theNodeName ,
+ const SUPERV::KindOfNode NodeKindOfNode ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const int NodeX ,
+ const int NodeY ) {
+ cdebug_in << "GraphEditor::OutNode::AddNode(" << NodeComponentName << " , "
+ << theNodeName << ")" << endl;
+ char * RetVal = NULLSTRING ;
+ GraphEditor::InNode *Nd = NULL ;
+ char * aNodeName = NULL ;
+ bool GeneratedName = false ;
+ if ( NodeKindOfNode == SUPERV::InLineNode ||
+ NodeKindOfNode == SUPERV::LoopNode ||
+ NodeKindOfNode == SUPERV::EndLoopNode ||
+ NodeKindOfNode == SUPERV::SwitchNode ||
+ NodeKindOfNode == SUPERV::EndSwitchNode ||
+ NodeKindOfNode == SUPERV::GOTONode ) {
+ if ( theNodeName == NULL || strlen( theNodeName ) == 0 ) {
+ if ( NodeKindOfNode == SUPERV::InLineNode ) {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "InLine" ) ;
+ }
+ else if ( NodeKindOfNode == SUPERV::LoopNode ) {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Loop" ) ;
+ }
+ else if ( NodeKindOfNode == SUPERV::EndLoopNode ) {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndLoop" ) ;
+ }
+ else if ( NodeKindOfNode == SUPERV::SwitchNode ) {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "Switch" ) ;
+ }
+ else if ( NodeKindOfNode == SUPERV::EndSwitchNode ) {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "EndSwitch" ) ;
+ }
+ else if ( NodeKindOfNode == SUPERV::GOTONode ) {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = my_strdup( "GOTO" ) ;
+ }
+ }
+ else {
+ ((SALOME_ModuleCatalog::Service& ) NodeService).ServiceName = CORBA::string_dup( theNodeName ) ;
+ }
+ theNodeName = NULL ;
+ }
+ if ( theNodeName == NULL ) {
+ aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ;
+ strcpy( aNodeName , NodeService.ServiceName ) ;
+ if ( GetGraphNode( NodeService.ServiceName ) ) {
+ GeneratedName = true ;
+ while ( GetGraphNode( aNodeName ) ) {
+ if ( aNodeName )
+ delete [] aNodeName ;
+ int num = GetServiceNameNumber( NodeService.ServiceName ) ;
+ ostrstream s ;
+ s << num << ends ;
+ const char * n_instance = s.str() ;
+ int lname = strlen( NodeService.ServiceName ) + 1 +
+ strlen( n_instance ) + 1 ;
+ aNodeName = new char[lname] ;
+ strcpy( aNodeName , NodeService.ServiceName ) ;
+ strcat( aNodeName , "_" ) ;
+ strcat( aNodeName , n_instance ) ;
+ }
+ }
+ }
+ else {
+ if ( GetGraphNode( theNodeName ) == NULL ) {
+ aNodeName = new char[ strlen( theNodeName )+1 ] ;
+ strcpy( aNodeName , theNodeName ) ;
+ }
+ }
+ if ( aNodeName != NULL ) {
+ Nd = new GraphEditor::InNode( _Orb , NamingService() ,
+ aFuncName , aPythonFunction , NodeService ,
+ NodeComponentName , NodeInterfaceName ,
+ aNodeName , NodeKindOfNode ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComputer , NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug() , Graph_fdebug() ) ;
+// MESSAGE( "GraphEditor::OutNode::AddNode " << hex << (void *) Nd << dec );
+// if ( GraphBase::Graph::AddNode( Nd ) ) {
+ if ( GraphBase::Graph::AddNode( Nd->ComputingNode() ) ) {
+ DateModification() ;
+ RetVal = Nd->Name() ;
+ }
+ else {
+ cdebug << "NodeName already exists." << endl ;
+ }
+ }
+ else {
+ cdebug << "NodeName is NULL or already exists." << endl ;
+ }
+// delete [] aNodeName ;
+ cdebug_out << "GraphEditor::OutNode::AddNode" << endl;
+ _Valid = false ;
+ return Nd ;
+}
+
+bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int nXY ,
+ const int* X ,
+ const int* Y ) {
+ GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
+ }
+ else {
+ return aLink->AddCoord( nXY , X , Y ) ;
+ }
+ }
+ return false ;
+}
+
+bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) {
+ GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
+ }
+ else {
+ return aLink->AddCoord( index , X , Y ) ;
+ }
+ }
+ return false ;
+}
+
+bool GraphEditor::OutNode::ChangeLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) {
+ GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
+ }
+ else {
+ return aLink->ChangeCoord( index , X , Y ) ;
+ }
+ }
+ return false ;
+}
+
+bool GraphEditor::OutNode::RemoveLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ) {
+ GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
+ }
+ else {
+ return aLink->RemoveCoord( index ) ;
+ }
+ }
+ return false ;
+}
+
+int GraphEditor::OutNode::GetLinkCoordSize(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) {
+ const GraphBase::InPort * aLink = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
+ }
+ else {
+ return aLink->GetCoord() ;
+ }
+ }
+ return 0 ;
+}
+
+bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ int *X , int *Y ) {
+ const GraphBase::InPort * aLink = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
+ }
+ else {
+ return aLink->GetCoord( X , Y ) ;
+ }
+ }
+ return false ;
+}
+
+bool GraphEditor::OutNode::GetLinkCoord(
+ const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index , long &X , long &Y ) {
+ GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+ if ( aLink ) {
+ if ( aLink->IsSwitch() ) {
+ return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
+ }
+ else {
+ return aLink->GetCoord( index , X , Y ) ;
+ }
+ }
+ return false ;
+}
+
+bool GraphEditor::OutNode::AddInputData( const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) {
+ cdebug_in << "GraphEditor::OutNode::AddInputData" << endl;
+ bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 ,
+ ToParameterName1 ,
+ ToNodeName2 ,
+ ToParameterName2 ) ;
+ cdebug_out << "GraphEditor::OutNode::AddInputData" << endl;
+ _Valid = false ;
+ return RetVal ;
+}
+
+bool GraphEditor::OutNode::Valid() {
+ if ( _Valid )
+ return true ;
+
+ cdebug_in << "GraphEditor::OutNode::Valid" << endl;
+ _Executable = false ;
+
+ CreateService() ;
+
+ if ( !Sort() ) {
+ cdebug << "This DataFlow is not valid." << endl ;
+ return false ;
+ }
+
+// CreateService() ;
+
+ InLineServices() ;
+
+ ComputingNodes() ;
+
+ _Valid = true ;
+
+ cdebug_out << "GraphEditor::OutNode::Valid" << endl;
+ return _Valid ;
+}
+
+bool GraphEditor::OutNode::Executable() {
+
+ cdebug_in << "GraphEditor::OutNode::Executable" << endl;
+ if ( !IsValid() )
+ Valid() ;
+ if ( !IsValid() )
+ return false ;
+// if ( !_GT )
+// GraphExecutor::GraphControl _GT = new GraphExecutor::GraphControl( this );
+
+ if ( DataServerNodes() )
+ _Executable = true ;
+ else {
+ cdebug << "This DataFlow is not executable." << endl ;
+ _Executable = false ;
+ }
+
+ cdebug_out << "GraphEditor::OutNode::Executable" << endl;
+ return _Executable ;
+}
+
+const CORBA::Any *GraphEditor::OutNode::GetInData(
+ const char * ToNodeName ,
+ const char * ToParameterName ) {
+ cdebug_in << "GraphEditor::OutNode::GetInData" << endl ;
+ const CORBA::Any * retdata = PortInData( ToNodeName , ToParameterName ) ;
+ cdebug_out << "GraphEditor::OutNode::GetInData " << ToNodeName
+ << " " << ToParameterName << endl ;
+ return retdata ;
+}
+
+const CORBA::Any *GraphEditor::OutNode::GetOutData(
+ const char * FromNodeName ,
+ const char * FromParameterName ) {
+ cdebug_in << "GraphEditor::OutNode::GetOutData" << endl ;
+ const CORBA::Any * retdata = PortOutData( FromNodeName , FromParameterName ) ;
+ cdebug_out << "GraphEditor::OutNode::GetOutData " << FromNodeName
+ << " " << FromParameterName << endl ;
+ return retdata ;
+}
+
+//bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
+bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
+ GraphBase::SLink aLink ,
+ bool wdata ) const {
+ QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ;
+ QDomText aField ;
+ if ( strlen( aLink.FromNodeName.c_str() ) ) {
+// f << Tabs << "<fromnode-name>" << aLink.FromNodeName.c_str()
+// << "</fromnode-name>" << endl ;
+ aField = Graph.createTextNode( aLink.FromNodeName.c_str() ) ;
+ }
+ else {
+// f << Tabs << "<fromnode-name>?</fromnode-name>" << endl ;
+ aField = Graph.createTextNode( "?" ) ;
+ }
+ link.appendChild( fromnodename ) ;
+ fromnodename.appendChild( aField ) ;
+
+// f << Tabs << "<fromserviceparameter-name>"
+// << aLink.FromServiceParameterName.c_str() << "</fromserviceparameter-name>"
+// << endl ;
+ QDomElement fromserviceparametername = Graph.createElement( "fromserviceparameter-name" ) ;
+ aField = Graph.createTextNode( aLink.FromServiceParameterName.c_str() ) ;
+ link.appendChild( fromserviceparametername ) ;
+ fromserviceparametername.appendChild( aField ) ;
+
+ QDomElement tonodename = Graph.createElement( "tonode-name" ) ;
+ if ( strlen( aLink.ToNodeName.c_str() ) ) {
+// f << Tabs << "<tonode-name>" << aLink.ToNodeName.c_str()
+// << "</tonode-name>" << endl ;
+ aField = Graph.createTextNode( aLink.ToNodeName.c_str() ) ;
+ }
+ else {
+// f << Tabs << "<tonode-name>?</tonode-name>" << endl ;
+ aField = Graph.createTextNode( "?" ) ;
+ }
+ link.appendChild( tonodename ) ;
+ tonodename.appendChild( aField ) ;
+
+// f << Tabs << "<toserviceparameter-name>"
+// << aLink.ToServiceParameterName.c_str() << "</toserviceparameter-name>"
+// << endl ;
+ QDomElement toserviceparametername = Graph.createElement( "toserviceparameter-name" ) ;
+ aField = Graph.createTextNode( aLink.ToServiceParameterName.c_str() ) ;
+ link.appendChild( toserviceparametername ) ;
+ toserviceparametername.appendChild( aField ) ;
+
+ if ( wdata ) {
+// f << Tabs << "<data-value>" << endl ;
+ QDomElement datavalue = Graph.createElement( "data-value" ) ;
+ link.appendChild( datavalue ) ;
+// f << Tabs << " <value-type>" << aLink.aLinkValue.type()->kind()
+// << "</value-type>" << endl ;
+ QDomElement valuetype = Graph.createElement( "value-type" ) ;
+ QString aKind ;
+ aKind = aKind.setNum( aLink.aLinkValue.type()->kind() ) ;
+ aField = Graph.createTextNode( aKind ) ;
+ datavalue.appendChild( valuetype ) ;
+ valuetype.appendChild( aField ) ;
+ switch (aLink.aLinkValue.type()->kind()) {
+ case CORBA::tk_string: {
+ char* retstr ;
+ aLink.aLinkValue >>= retstr;
+// f << Tabs << " <value>" << retstr << "</value>" << endl ;
+ QDomElement value = Graph.createElement( "value" ) ;
+ aField = Graph.createTextNode( retstr ) ;
+ datavalue.appendChild( value ) ;
+ value.appendChild( aField ) ;
+// MESSAGE( "ToString( string ) " << retstr );
+ break ;
+ }
+ case CORBA::tk_double: {
+ double d;
+ aLink.aLinkValue >>= d;
+// f << Tabs << " <value>" << d << "</value>" << endl ;
+ QDomElement value = Graph.createElement( "value" ) ;
+ QString aKind ;
+ aKind = aKind.setNum( d ) ;
+ aField = Graph.createTextNode( aKind ) ;
+ datavalue.appendChild( value ) ;
+ value.appendChild( aField ) ;
+// MESSAGE( "ToString( double ) " << d );
+ break ;
+ }
+ case CORBA::tk_long: {
+ long l;
+ aLink.aLinkValue >>= l;
+// f << Tabs << " <value>" << l << "</value>" << endl ;
+ QDomElement value = Graph.createElement( "value" ) ;
+ QString aKind ;
+ aKind = aKind.setNum( l ) ;
+ aField = Graph.createTextNode( aKind ) ;
+ datavalue.appendChild( value ) ;
+ value.appendChild( aField ) ;
+// MESSAGE( "ToString( long ) " << l );
+ break ;
+ }
+ case CORBA::tk_objref: {
+ char* retstr ;
+ CORBA::Object_ptr obj ;
+ aLink.aLinkValue >>= obj ;
+ retstr = _Orb->object_to_string(obj );
+// f << Tabs << " <value>" << retstr << "</value>" << endl ;
+ QDomElement value = Graph.createElement( "value" ) ;
+ aField = Graph.createTextNode( retstr ) ;
+ datavalue.appendChild( value ) ;
+ value.appendChild( aField ) ;
+// MESSAGE( "ToString( object ) " << retstr );
+ break ;
+ }
+ default: {
+// f << Tabs << " <value>?</value>" << endl ;
+ QDomElement value = Graph.createElement( "value" ) ;
+ aField = Graph.createTextNode( "?" ) ;
+ datavalue.appendChild( value ) ;
+ value.appendChild( aField ) ;
+// MESSAGE( "Unknown CORBA::Any Type" );
+ break ;
+ }
+ }
+// f << Tabs << "</data-value>" << endl ;
+ }
+// f << Tabs << "<coord-list>" << endl ;
+ QDomElement coordlist = Graph.createElement( "coord-list" ) ;
+ link.appendChild( coordlist ) ;
+
+ int i ;
+ for ( i = 0 ; i < aLink.aListOfCoords.size() ; i++ ) {
+// f << Tabs << " <coord>" << endl ;
+ QDomElement coord = Graph.createElement( "coord" ) ;
+ coordlist.appendChild( coord ) ;
+// f << Tabs << " <x>" << aLink.aListOfCoords[ i ].theX << "</x>" << endl ;
+ QDomElement x = Graph.createElement( "x" ) ;
+ QString ax ;
+ ax = ax.setNum( aLink.aListOfCoords[ i ].theX ) ;
+ aField = Graph.createTextNode( ax ) ;
+ coord.appendChild( x ) ;
+ x.appendChild( aField ) ;
+// f << Tabs << " <y>" << aLink.aListOfCoords[ i ].theY << "</y>" << endl ;
+ QDomElement y = Graph.createElement( "y" ) ;
+ QString ay ;
+ ay = ay.setNum( aLink.aListOfCoords[ i ].theY ) ;
+ aField = Graph.createTextNode( ay ) ;
+ coord.appendChild( y ) ;
+ y.appendChild( aField ) ;
+// f << Tabs << " </coord>" << endl ;
+ }
+// f << Tabs << "</coord-list>" << endl ;
+ return true ;
+}
+
+bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName ,
+ GraphBase::SLink aLink ,
+ bool intervar , bool wdata ) const {
+ if ( !wdata ) {
+ if ( intervar ) {
+ f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str()
+ << " = "
+ << aLink.FromNodeName.c_str() << ".Port( '"
+ << aLink.FromServiceParameterName.c_str()
+ << "' )" << endl ;
+ }
+ f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
+ << " = " << aGraphName << ".Link( " << aLink.FromNodeName.c_str()
+ << aLink.FromServiceParameterName.c_str() << " , "
+ << aLink.ToNodeName.c_str() << ".Port( '"
+ << aLink.ToServiceParameterName.c_str() << "' ) )" << endl ;
+ }
+ else {
+ f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str()
+ << " = " << aLink.ToNodeName.c_str() << ".Input( '"
+ << aLink.ToServiceParameterName.c_str() << "' , " ;
+ switch (aLink.aLinkValue.type()->kind()) {
+ case CORBA::tk_string: {
+ char* retstr ;
+ aLink.aLinkValue >>= retstr;
+ f << "'" << retstr << "'" ;
+ break ;
+ }
+ case CORBA::tk_double: {
+ double d;
+ aLink.aLinkValue >>= d;
+ f << d ;
+ break ;
+ }
+ case CORBA::tk_long: {
+ long l;
+ aLink.aLinkValue >>= l;
+ f << l ;
+ break ;
+ }
+ case CORBA::tk_objref: {
+ char* retstr ;
+ CORBA::Object_ptr obj ;
+ aLink.aLinkValue >>= obj ;
+ retstr = _Orb->object_to_string(obj );
+ f << "'" << retstr << "'" ;
+ break ;
+ }
+ default: {
+ f << "?" ;
+// MESSAGE( "Unknown CORBA::Any Type" );
+ break ;
+ }
+ }
+ f << ")" << endl ;
+ }
+ int i ;
+ for ( i = 0 ; i < aLink.aListOfCoords.size() ; i++ ) {
+ f << aLink.ToNodeName.c_str()
+ << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , "
+ << aLink.aListOfCoords[ i ].theX << " , "
+ << aLink.aListOfCoords[ i ].theY << " )" << endl ;
+ }
+ return true ;
+}
+
+//bool GraphEditor::OutNode::SaveXML(ostream & f ) {
+bool GraphEditor::OutNode::SaveXML(QDomDocument & Graph ) {
+ int i ;
+// f << "<?xml version='1.0' encoding='us-ascii' ?>" << endl << endl ;
+// f << "<!-- XML Dataflow -->" << endl << endl ;
+// f << "<!-- Dataflow information -->" << endl ;
+ QString Dataflow("Dataflow") ;
+ Graph = QDomDocument(Dataflow) ;
+// f << "<dataflow>" << endl ;
+ QDomElement dataflow = Graph.createElement( "dataflow" ) ;
+ Graph.appendChild( dataflow ) ;
+// f << " <info-list>" << endl ;
+ QDomElement info = Graph.createElement( "info-list" ) ;
+ dataflow.appendChild( info ) ;
+
+// f << " <node>" << endl ;
+
+// GraphBase::DataNode::SaveXML( f , " " , 0 , 0 ) ;
+ GraphBase::DataNode::SaveXML( Graph , info , 0 , 0 ) ;
+
+// f << " </node>" << endl ;
+
+// f << " </info-list>" << endl << endl ;
+
+// f << " <node-list>" << endl ;
+ QDomElement nodelist = Graph.createElement( "node-list" ) ;
+ dataflow.appendChild( nodelist ) ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+// f << " <node>" << endl ;
+ if ( GraphNodes( i )->IsComputingNode() ) {
+// ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsFactoryNode() ) {
+// ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsInLineNode() ) {
+// ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsGOTONode() ) {
+// ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsLoopNode() ) {
+// ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsEndLoopNode() ) {
+// ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsSwitchNode() ) {
+// ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ else if ( GraphNodes( i )->IsEndSwitchNode() ) {
+// ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f ,
+// " " ,
+ ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+// f << " </node>" << endl ;
+// }
+ }
+// f << " </node-list>" << endl << endl ;
+
+// f << " <link-list>" << endl ;
+ QDomElement linklist = Graph.createElement( "link-list" ) ;
+ dataflow.appendChild( linklist ) ;
+ const GraphBase::ListOfLinks * Links = GetLinks() ;
+ for ( i = 0 ; i < Links->size() ; i++ ) {
+// f << " <link>" << endl ;
+ QDomElement link = Graph.createElement( "link" ) ;
+ linklist.appendChild( link ) ;
+// LinkSaveXML( f , " " , (*Links)[ i ] , false ) ;
+ LinkSaveXML( Graph , link , (*Links)[ i ] , false ) ;
+// f << " </link>" << endl ;
+ }
+// f << " </link-list>" << endl << endl ;
+
+// f << " <data-list>" << endl ;
+ QDomElement datalist = Graph.createElement( "data-list" ) ;
+ dataflow.appendChild( datalist ) ;
+ const GraphBase::ListOfLinks * Datas = GetDatas() ;
+ for ( i = 0 ; i < Datas->size() ; i++ ) {
+// f << " <data>" << endl ;
+ QDomElement data = Graph.createElement( "data" ) ;
+ datalist.appendChild( data ) ;
+// LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ;
+ LinkSaveXML( Graph , data , (*Datas)[ i ] , true ) ;
+// f << " </data>" << endl ;
+ }
+//#if 0
+// const GraphEditor::OutNode * aDataNode = (GraphEditor::OutNode *) this ;
+// if ( aDataNode ) {
+// int i ;
+// for ( i = 0 ; i < aDataNode->GetNodeOutPortsSize() ; i++ ) {
+// const GraphBase::InPort *aLink = aDataNode->GetNodeOutPort(i)->GetLink() ;
+// if ( aLink ) {
+// f << " <data>" << endl ;
+// aLink->SaveXML( f , " " ) ;
+// f << " </data>" << endl ;
+// }
+// }
+// for ( i = 0 ; i < aDataNode->GetNodeInPortsSize() ; i++ ) {
+// const GraphBase::InPort *aLink = aDataNode->GetNodeInPort(i)->GetLink() ;
+// if ( aLink ) {
+// f << " <data>" << endl ;
+// aLink->SaveXML( f , " " ) ;
+// f << " </data>" << endl ;
+// }
+// }
+// }
+//#endif
+
+#if 0
+ f << " </data-list>" << endl << endl ;
+ f << "</dataflow>" << endl ;
+#endif
+
+ return true ;
+}
+
+bool GraphEditor::OutNode::SavePY( ostream & f ) {
+ int i ;
+ f << endl << "# Generated python file of Graph " << Name() << endl << endl ;
+
+ f << "from SuperV import *" << endl ;
+
+ f << "# Graph creation " << endl ;
+ GraphBase::DataNode::SavePY( f , Name() , 0 , 0 ) ;
+
+ f << endl << "# Creation of Factory Nodes" << endl ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsFactoryNode() ) {
+ ((GraphBase::FactoryNode * ) GraphNodes( i ))->SavePY( f , Name() ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ }
+
+ bool first = true ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsComputingNode() ) {
+ if ( first ) {
+ f << endl << "# Creation of Computing Nodes" << endl ;
+ first = false ;
+ }
+ ((GraphBase::ComputingNode * ) GraphNodes( i ))->SavePY( f , Name() ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ }
+
+ first = true ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsInLineNode() ) {
+ if ( first ) {
+ f << endl << "# Creation of InLine Nodes" << endl ;
+ first = false ;
+ }
+ ((GraphBase::InLineNode * ) GraphNodes( i ))->SavePY( f , Name() ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ }
+
+ first = true ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsLoopNode() ) {
+ if ( first ) {
+ f << endl << "# Creation of Loop Nodes" << endl ;
+ first = false ;
+ }
+ ((GraphBase::LoopNode * ) GraphNodes( i ))->SavePY( f , Name() ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ }
+
+ first = true ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsSwitchNode() ) {
+ if ( first ) {
+ f << endl << "# Creation of Switch Nodes" << endl ;
+ first = false ;
+ }
+ ((GraphBase::SwitchNode * ) GraphNodes( i ))->SavePY( f , Name() ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ }
+
+ first = true ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsGOTONode() ) {
+ if ( first ) {
+ f << endl << "# Creation of GOTO Nodes" << endl ;
+ first = false ;
+ }
+ ((GraphBase::GOTONode * ) GraphNodes( i ))->SavePY( f , Name() ,
+ GraphNodes( i )->XCoordinate() ,
+ GraphNodes( i )->YCoordinate() ) ;
+ }
+ }
+
+ const GraphBase::ListOfLinks * Links = GetLinks() ;
+ bool intervar ;
+ map< string , int > aMapOfOutPorts ;
+ first = true ;
+ for ( i = 0 ; i < Links->size() ; i++ ) {
+ if ( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsComputingNode() &&
+ GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsComputingNode() ) {
+ if ( first ) {
+ f << endl
+ << "# Creation of intermediate Output variables and of Computing Links"
+ << endl ;
+ first = false ;
+ }
+ char * NodePort = new char [ strlen( (*Links)[ i ].FromNodeName.c_str() ) +
+ strlen( (*Links)[ i ].FromServiceParameterName.c_str() ) + 1 ] ;
+ strcpy( NodePort , (*Links)[ i ].FromNodeName.c_str() ) ;
+ strcat( NodePort , (*Links)[ i ].FromServiceParameterName.c_str() ) ;
+ if ( aMapOfOutPorts[ NodePort ] == 0 ) {
+ aMapOfOutPorts[ NodePort ] = i + 1 ;
+ intervar = true ;
+ }
+ else {
+ intervar = false ;
+ }
+ LinkSavePY( f , Name() , (*Links)[ i ] , intervar , false ) ;
+ delete [] NodePort ;
+ }
+ }
+
+#if 0
+ first = true ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ if ( GraphNodes( i )->IsInLineNode() ||
+ GraphNodes( i )->IsGOTONode() ) {
+ int j ;
+ for ( j = 0 ; j < GraphNodes( i )->GetNodeInPortsSize() ; j++ ) {
+ if ( GraphNodes( i )->GetNodeInPort( j )->IsBus() ) {
+ if ( first ) {
+ f << endl
+ << "# Creation of Output variables and of Bus Ports"
+ << endl ;
+ first = false ;
+ }
+ f << GraphNodes( i )->Name() << ".InOutPort( '"
+ << GraphNodes( i )->GetNodeInPort( j )->PortName() << "' , '"
+ << GraphNodes( i )->GetNodeInPort( j )->PortType() << "' , '"
+ << GraphNodes( i )->GetNodeOutPort( GraphNodes( i )->GetNodeInPort( j )->PortIndex() )->PortName()
+ << "' , '"
+ << GraphNodes( i )->GetNodeOutPort( GraphNodes( i )->GetNodeInPort( j )->PortIndex() )->PortType()
+ << "' )" << endl ;
+ }
+ }
+ }
+ }
+#endif
+
+ first = true ;
+ for ( i = 0 ; i < Links->size() ; i++ ) {
+ if ( !( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsComputingNode() &&
+ GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsComputingNode() ) &&
+ !( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsGOTONode() &&
+ GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsInLineNode() ) ) {
+ if ( first ) {
+ f << endl
+ << "# Creation of intermediate Output variables and of Control Links"
+ << endl ;
+ first = false ;
+ }
+ char * NodePort = new char [ strlen( (*Links)[ i ].FromNodeName.c_str() ) +
+ strlen( (*Links)[ i ].FromServiceParameterName.c_str() ) + 1 ] ;
+ strcpy( NodePort , (*Links)[ i ].FromNodeName.c_str() ) ;
+ strcat( NodePort , (*Links)[ i ].FromServiceParameterName.c_str() ) ;
+ if ( aMapOfOutPorts[ NodePort ] == 0 ) {
+ aMapOfOutPorts[ NodePort ] = i + 1 ;
+ intervar = true ;
+ }
+ else {
+ intervar = false ;
+ }
+ LinkSavePY( f , Name() , (*Links)[ i ] , intervar , false ) ;
+ delete [] NodePort ;
+ }
+ }
+
+ first = true ;
+ for ( i = 0 ; i < Links->size() ; i++ ) {
+ if ( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsGOTONode() &&
+ GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsInLineNode() ) {
+ if ( first ) {
+ f << endl
+ << "# Creation of intermediate Output variables and of Loop Links"
+ << endl ;
+ first = false ;
+ }
+ char * NodePort = new char [ strlen( (*Links)[ i ].FromNodeName.c_str() ) +
+ strlen( (*Links)[ i ].FromServiceParameterName.c_str() ) + 1 ] ;
+ strcpy( NodePort , (*Links)[ i ].FromNodeName.c_str() ) ;
+ strcat( NodePort , (*Links)[ i ].FromServiceParameterName.c_str() ) ;
+ if ( aMapOfOutPorts[ NodePort ] == 0 ) {
+ aMapOfOutPorts[ NodePort ] = i + 1 ;
+ intervar = true ;
+ }
+ else {
+ intervar = false ;
+ }
+ LinkSavePY( f , Name() , (*Links)[ i ] , intervar , false ) ;
+ delete [] NodePort ;
+ }
+ }
+
+ const GraphBase::ListOfLinks * Datas = GetDatas() ;
+ first = true ;
+ for ( i = 0 ; i < Datas->size() ; i++ ) {
+ if ( first ) {
+ f << endl << "# Creation of Input datas" << endl ;
+ first = false ;
+ }
+ LinkSavePY( f , Name() , (*Datas)[ i ] , false , true ) ;
+ }
+
+ first = true ;
+ const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = ServiceInParameter() ;
+ for ( i = 0 ; i < ListOfInParam.length() ; i++ ) {
+ string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ;
+ const char * aParam = _aParam.c_str() ;
+ char * aNodeName ;
+ char * aPortName ;
+ int j , k ;
+ for ( j = 0 ; j < strlen( aParam ) ; j++ ) {
+ if ( aParam[ j ] == '\\' ) {
+ aNodeName = new char[ j+1 ] ;
+ strncpy( aNodeName , aParam , j ) ;
+ aNodeName[ j ] = '\0' ;
+ aPortName = new char[ strlen( aParam ) - j ] ;
+ strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
+ break ;
+ }
+ }
+ if ( !GetChangeGraphNode( aNodeName )->GetInPort( aPortName )->IsDataConnected() ) {
+ if ( first ) {
+ f << endl << "# Missing Input datas" << endl ;
+ first = false ;
+ }
+ f << aNodeName << aPortName << " = " << aNodeName << ".Port( '"
+ << aPortName << "' )" << endl ;
+ }
+ delete [] aNodeName ;
+ delete [] aPortName ;
+ }
+
+ f << endl << "# Creation of Output variables" << endl ;
+ const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = ServiceOutParameter() ;
+ for ( i = 0 ; i < ListOfOutParam.length() ; i++ ) {
+ string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ;
+ const char * aParam = _aParam.c_str() ;
+ char * aNodeName ;
+ char * aPortName ;
+ int j , k ;
+ for ( j = 0 ; j < strlen( aParam ) ; j++ ) {
+ if ( aParam[ j ] == '\\' ) {
+ aNodeName = new char[ j+1 ] ;
+ strncpy( aNodeName , aParam , j ) ;
+ aNodeName[ j ] = '\0' ;
+ aPortName = new char[ strlen( aParam ) - j ] ;
+ strncpy( aPortName , &aParam[ j+1 ] , strlen( aParam ) - j ) ;
+ break ;
+ }
+ }
+ f << aNodeName << aPortName << " = " << aNodeName << ".Port( '"
+ << aPortName << "' )" << endl ;
+ delete [] aNodeName ;
+ delete [] aPortName ;
+ }
+ return true ;
+}
+
+
+
+ostrstream & operator<< (ostrstream & f,const GraphEditor::OutNode & G) {
+ f << (GraphBase::ComputingNode ) G ;
+ f << endl ;
+
+ f << " Nodes : " << G.GraphNodesSize() << " node"
+ << (G.GraphNodesSize() > 1 ? "s" : "") << endl;
+
+ int i ;
+ for ( i = 0 ; i < G.GraphNodesSize() ; i++ ) {
+ f
+// << hex << (void *) G.GraphNodes( i ) << dec << " "
+ << *G.GraphNodes( i ) << endl;
+ }
+
+ f << " Links : " << endl ;
+ for ( i = 0 ; i < G.GraphNodesSize() ; i++ ) {
+ G.GraphNodes( i )->ListLinks( f ) ;
+ }
+
+ f << " Datas : " << endl ;
+ G.ListDatas( f ) ;
+
+ f << "DataFlow " << G.Name() << " is " ;
+ if ( G.IsNotValid() )
+ f << "not " ;
+ f << "valid and is " ;
+ if ( G.IsNotExecutable() )
+ f << "not " ;
+ f << "executable." << endl ;
+
+ f << endl ;
+
+ return f;
+}
+
+ostream & operator<< (ostream &fOut,const SUPERV::SDate &D)
+{
+// cdebug_in << "operator<< GraphEditor::Date" << endl;
+
+ fOut << D.Day << "/"
+ << D.Month << "/"
+ << D.Year << " - "
+ << D.Hour << ":"
+ << D.Minute << ":"
+ << D.Second;
+
+// cdebug_out << "operator<< GraphEditor::Date" << endl;
+ return fOut;
+}
+
+
+
+
+
+
+
+
--- /dev/null
+#ifndef _DATAFLOWEDITOR_OUTNODE_HXX
+#define _DATAFLOWEDITOR_OUTNODE_HXX
+
+#include "DataFlowBase_Graph.hxx"
+
+#include "DataFlowEditor_InNode.hxx"
+
+namespace GraphEditor {
+
+ class OutNode : public GraphBase::Graph {
+
+ private :
+
+ bool _Imported ;
+
+ bool _Valid ;
+
+ bool _Executable ;
+
+ CORBA::ORB_ptr _Orb;
+
+ bool Valid() ;
+ bool Executable() ;
+
+ bool LoadNodes( map< string , int > & aMapOfNodes ,
+ const GraphBase::ListOfNodes &aNodes ) ;
+ bool LoadLinks( map< string , int > & aMapOfNodes ,
+ const GraphBase::ListOfLinks &aLinks ) ;
+ bool LoadDatas( map< string , int > & aMapOfNodes ,
+ const GraphBase::ListOfLinks &aDatas ) ;
+
+// bool GraphEditor::OutNode::LinkSaveXML( ostream &f , char *Tabs ,
+ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link ,
+ GraphBase::SLink aLink ,
+ bool wdata ) const ;
+// bool SaveXML(ostream &f ) ;QDomDocument & Graph
+ bool SaveXML(QDomDocument & Graph ) ;
+
+ bool GraphEditor::OutNode::LinkSavePY( ostream &f ,
+ const char *aGraphName ,
+ GraphBase::SLink aLink ,
+ bool intervar ,
+ bool wdata ) const;
+ bool SavePY(ostream &f ) ;
+
+ void DateModification() ;
+
+ public:
+
+ OutNode();
+ OutNode( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const char *DataFlowName ,
+ const char * DebugFileName );
+ OutNode( 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 * DataFlowEditorRelease ,
+ const char * DataFlowAuthor ,
+ const char * DataFlowComputer ,
+ const char * DataFlowComment ,
+ const char * DebugFileName ) ;
+ virtual ~OutNode();
+
+// SALOME_NamingService* NamingService() const {
+// return _theNamingService ; } ;
+
+ bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ;
+ bool LoadXml( const char* myFileName ) ;
+ bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
+
+ bool SaveXml(const char* myFileName ) ;
+
+ bool SavePy(const char* myFileName ) ;
+
+// get all DataFlow informations (for a .XML file) :
+ GraphBase::SGraph * GetDataFlow() ;
+
+// void DateModification() ;
+
+ GraphEditor::InNode * AddNode(
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const char* NodeComponentName ,
+ const char* NodeInterfaceName ,
+ const char* NodeName ,
+ const SUPERV::KindOfNode NodeKindOfNode ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const int NodeX ,
+ const int NodeY ) ;
+ GraphEditor::InNode * GetNode( const char* NodeName ) {
+ return (GraphEditor::InNode * ) (GraphBase::Graph::GetGraphNode( NodeName )->GetInNode()) ; } ;
+ bool RemoveNode( const char* NodeName ) {
+ DateModification() ;
+ _Valid = false ;
+ return GraphBase::Graph::RemoveNode( NodeName ) ; } ;
+ bool ReNameNode( const char* OldNodeName ,
+ const char* NewNodeName ) {
+ DateModification() ;
+ _Valid = false ;
+ return GraphBase::Graph::ReNameNode( OldNodeName , NewNodeName ) ; } ;
+
+ void Coordinates( const int X , const int Y ) {
+ return GraphBase::Graph::Coordinates( X , Y ) ; } ;
+ const int XCoordinate() {
+ return GraphBase::Graph::XCoordinate() ; } ;
+ const int YCoordinate() {
+ return GraphBase::Graph::YCoordinate() ; } ;
+ void Coordinates( const char* NodeName , const int X , const int Y ) ;
+ const int XCoordinate( const char* NodeName ) ;
+ const int YCoordinate( const char* NodeName ) ;
+
+ const GraphBase::InPort *GetInPort( const char *name ) {
+ return GraphBase::PortsOfNode::GetInPort( name ) ; } ;
+ const GraphBase::OutPort *GetOutPort( const char *name ) {
+ return GraphBase::PortsOfNode::GetOutPort( name ) ; } ;
+ GraphBase::InPort *GetChangeInPort( const char *name ) {
+ return GraphBase::PortsOfNode::GetChangeInPort( name ) ; } ;
+ GraphBase::OutPort *GetChangeOutPort( const char *name ) {
+ return GraphBase::PortsOfNode::GetChangeOutPort( name ) ; } ;
+
+ bool HasInput(const char * ToServiceParameterName ) {
+ return GraphBase::ComputingNode::HasInput( ToServiceParameterName ) ;
+ }
+
+ bool AddLink( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const CORBA::Any aValue ) {
+ DateModification() ;
+ _Valid = false ;
+ return GraphBase::Graph::AddLink(
+ FromNodeName , FromServiceParameterName ,
+ ToNodeName , ToServiceParameterName ,
+ aValue ) ; } ;
+
+ bool RemoveLink( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) {
+ bool RetVal = GraphBase::Graph::RemoveLink(
+ FromNodeName ,
+ FromServiceParameterName ,
+ ToNodeName ,
+ ToServiceParameterName ) ;
+ if ( RetVal )
+ DateModification() ;
+ _Valid = false ;
+ return RetVal ; } ;
+
+ bool GetLink(const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ char** FromNodeName ,
+ char** FromServiceParameterName ) {
+ return GraphBase::Graph::GetLink( ToNodeName ,
+ ToServiceParameterName ,
+ FromNodeName ,
+ FromServiceParameterName ) ; } ;
+
+ bool AddLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int nXY ,
+ const int* X ,
+ const int* Y ) ;
+ bool AddLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) ;
+ bool ChangeLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) ;
+ bool RemoveLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ) ;
+ int GetLinkCoordSize( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) ;
+ bool GetLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ int *X , int *Y ) ;
+ bool GetLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index , long &X , long &Y ) ;
+
+ bool AddInputData( const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) ;
+
+ bool IsValid() {
+ if ( !_Valid )
+ Valid() ;
+ return _Valid ; } ;
+ bool IsNotValid() const {
+ return !_Valid ; } ;
+ bool UnValid() {
+ bool RetVal = _Valid ;
+ _Valid = false ;
+ return RetVal ; } ;
+
+ bool IsExecutable() {
+ if ( !_Valid )
+ Valid() ;
+ if ( _Valid ) {
+ if ( !_Executable )
+ Executable() ;
+ }
+ else
+ _Executable = false ;
+ return _Executable ; } ;
+ bool IsNotExecutable() const {
+ return !_Executable ; } ;
+
+ const CORBA::Any *GetInData( const char *ToNodeName ,
+ const char *ToParameterName ) ;
+ const CORBA::Any *GetOutData( const char *FromNodeName ,
+ const char *FromParameterName ) ;
+ } ;
+
+};
+
+ostrstream & operator << (ostrstream &,const GraphEditor::OutNode & G);
+ostream & operator << (ostream &,const SUPERV::SDate &);
+
+#endif
+
+
+
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : aug 21 2001
+# Author : , CEA
+# Project : SALOME
+# Copyright : CEA 2001
+# $Header:
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+EXPORT_HEADERS = \
+ DataFlowEditor_InNode.hxx \
+ DataFlowEditor_OutNode.hxx \
+ DataFlowEditor_DataFlow.hxx \
+ DataFlowEditor_DataFlow.lxx
+
+# Libraries targets
+LIB = libSalomeSuperVisionEditor.la
+LIB_SRC = \
+ DataFlowEditor_InNode.cxx \
+ DataFlowEditor_OutNode.cxx \
+ DataFlowEditor_DataFlow.cxx
+
+LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \
+ SALOME_Component.idl \
+ SALOMEDS.idl \
+ SUPERV.idl \
+ SALOME_Exception.idl
+
+# Executables targets
+#BIN = SuperVisionEditor_CheckOfUndefined
+BIN_SRC =
+BIN_SERVER_IDL =
+
+CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
+#LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lSalomeSuperVisionExecutor -lOpUtil -lSalomeLoggerServer -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS)
+LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase \
+ -lSalomeSuperVisionExecutor -lOpUtil -lSalomeLoggerServer \
+ -lc $(QT_MT_LIBS) $(OGL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
+
+
+@CONCLUDE@
+
+
--- /dev/null
+using namespace std;
+#include <iostream>
+#include <fstream>
+#include <unistd.h>
+
+#include "DataFlowBase_Base.hxx"
+#include "DataFlowBase_Graph.hxx"
+#include "DataFlowEditor_InNode.hxx"
+#include "DataFlowEditor_OutNode.hxx"
+#include "DataFlowEditor_DataFlow.hxx"
+#include "DataFlowEditor_DataFlow.lxx"
+
+int main(int argc, char **argv) {
+
+ return 1;
+}
+
--- /dev/null
+using namespace std;
+
+#include "DataFlowExecutor_DataFlow.hxx"
+
+// Implementation de la classe GraphExecutor::Graph
+
+GraphExecutor::DataFlow::DataFlow() :
+ OutNode() {
+ cdebug_in << "GraphExecutor::DataFlow::DataFlowExecutor()" << endl;
+
+ _theNamingService = NULL ;
+
+ cdebug_out << "GraphExecutor::DataFlow::DataFlowExecutor()" << endl;
+}
+
+GraphExecutor::DataFlow::DataFlow( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const char *DataFlowName ,
+ const char * DebugFileName ) :
+ OutNode( ORB, ptrNamingService , DataFlowName , DebugFileName ) {
+ cdebug_in << "GraphExecutor::DataFlow::DataFlow(" ;
+ if ( DataFlowName ) {
+ cdebug << DataFlowName ;
+ }
+ cdebug << ")" << endl;
+
+ _theNamingService = ptrNamingService ;
+
+ 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 ) :
+ OutNode( ORB, ptrNamingService , DataFlowService , DataFlowComponentName ,
+ DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+ DataFlowFirstCreation , DataFlowLastModification ,
+ DataFlowExecutorRelease , DataFlowAuthor ,
+ DataFlowComputer , DataFlowComment , DebugFileName ) {
+ cdebug_in << "GraphExecutor::DataFlow::DataFlow(" << DataFlowName << ")" << endl;
+
+ _theNamingService = ptrNamingService ;
+
+ cdebug_out << "GraphExecutor::DataFlow::DataFlow" << endl;
+} ;
+
+GraphExecutor::DataFlow::~DataFlow() {
+// delete _DataFlowNode ;
+// delete _DataFlowDatas ;
+// delete _GT ;
+}
+
+bool GraphExecutor::DataFlow::Ping( const char *aNodeName ) {
+ cdebug_in << "GraphExecutor::DataFlow::Ping" << aNodeName << " )" << endl;
+ bool RetVal = false ;
+ if ( GetGraphNode( aNodeName ) )
+ RetVal = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode())->Ping() ;
+ cdebug_out << "GraphExecutor::DataFlow::Ping" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::ContainerKill() {
+ cdebug_in << "GraphExecutor::DataFlow::ContainerKill()" << endl;
+ bool RetVal = GraphExecutor::OutNode::ContainerKill() ;
+ cdebug_out << "GraphExecutor::DataFlow::ContainerKill()" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::ContainerKill( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::ContainerKill( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->ContainerKill() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::ContainerKill" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Kill() {
+ cdebug_in << "GraphExecutor::DataFlow::Kill()" << endl;
+ bool RetVal = GraphExecutor::OutNode::Kill() ;
+ cdebug_out << "GraphExecutor::DataFlow::Kill()" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Kill( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::Kill( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->Kill() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::Kill" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::KillDone( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::KillDone( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->KillDone() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::KillDone" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Suspend() {
+ cdebug_in << "GraphExecutor::DataFlow::Suspend()" << endl;
+ bool RetVal = false ;
+ MESSAGE("Suspend not yet implemented.") ;
+ cdebug << "Suspend not yet implemented." << endl;
+ cdebug_out << "GraphExecutor::DataFlow::Suspend()" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Suspend( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::Suspend( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->Suspend() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::Suspend" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::SuspendDone() {
+ cdebug_in << "GraphExecutor::DataFlow::SuspendDone()" << endl;
+ bool RetVal = false ;
+ cdebug << "Kill not yet implemented." << endl;
+ cdebug_out << "GraphExecutor::DataFlow::SuspendDone()" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::SuspendDone( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::SuspendDone( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->SuspendDone() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::SuspendDone" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Resume() {
+ cdebug_in << "GraphExecutor::DataFlow::Resume()" << endl;
+ bool RetVal = false ;
+ cdebug << "Resume not yet implemented." << endl;
+ cdebug_out << "GraphExecutor::DataFlow::Resume()" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Resume( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::Resume( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->Resume() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::Resume" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Stop() {
+ cdebug_in << "GraphExecutor::DataFlow::Stop()" << endl;
+ bool RetVal = GraphExecutor::OutNode::Stop() ;
+ cdebug_out << "GraphExecutor::DataFlow::Stop()" << endl;
+ return RetVal ;
+}
+
+bool GraphExecutor::DataFlow::Stop( const char *aNodeName ) {
+// cdebug_in << "GraphExecutor::DataFlow::Stop( " << aNodeName << " )"<< endl;
+ bool RetVal = false ;
+ GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode()) ;
+ if ( aNode ) {
+ RetVal = aNode->Stop() ;
+ }
+// cdebug_out << "GraphExecutor::DataFlow::Stop" << endl;
+ return RetVal ;
+}
+
--- /dev/null
+#ifndef _DATAFLOWEXECUTOR_DATAFLOW_HXX
+#define _DATAFLOWEXECUTOR_DATAFLOW_HXX
+
+#include "DataFlowExecutor_OutNode.hxx"
+
+namespace GraphExecutor {
+
+ class DataFlow : public GraphExecutor::OutNode {
+
+ private :
+
+ SALOME_NamingService* _theNamingService ;
+
+ public:
+
+ DataFlow();
+ DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
+ const char * DataFlowName ,
+ const char * DebugFileName );
+ 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 = SUPERV::ComputingNode ,
+ const SUPERV::SDate DataFlowFirstCreation = SUPERV::SDate() ,
+ const SUPERV::SDate DataFlowLastModification = SUPERV::SDate() ,
+ const char * DataFlowEditorRelease = NULL ,
+ const char * DataFlowAuthor = NULL ,
+ const char * DataFlowComputer = NULL ,
+ const char * DataFlowComment = NULL ,
+ const char * DebugFileName = NULL ) ;
+ virtual ~DataFlow();
+
+ bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
+ bool LoadXml( const char* myFileName ) ;
+
+ const SALOME_ModuleCatalog::Service * NodeService( const char * NodeName ) ;
+
+ bool ChangeInputData( const char* ToNodeName ,
+ const char* ToParameterName ,
+ const CORBA::Any aValue = CORBA::Any() ) ;
+ bool AddInputSharedData( const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) ;
+
+ bool IsValid() ;
+ bool IsExecutable() ;
+
+ bool Run( const bool AndSuspend ) ;
+ bool Run( const char * aNodeName ,
+ const char * AtNodeName , const bool AndSuspend ) ;
+
+ long LastLevelDone() ;
+
+ SUPERV::GraphState State() ;
+ SUPERV::GraphState State(const char * aNodeName ) ;
+ SUPERV::GraphState State( const char * aNodeName ,
+ const char * anOutServiceParameterName ) ;
+
+ long Thread() ;
+ long Thread(const char * aNodeName ) ;
+
+ SUPERV::AutomatonState AutomatonState() ;
+ SUPERV::AutomatonState AutomatonState(const char * aNodeName ) ;
+
+ SUPERV::ControlState ControlState() ;
+ SUPERV::ControlState ControlState(const char * aNodeName ) ;
+ void ControlClear() ;
+ void ControlClear(const char * aNodeName ) ;
+
+ bool Event( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ,
+ bool WithWait = true ) ;
+ bool EventW( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ) ;
+
+ bool IsWaiting() ;
+ bool IsReady() ;
+ bool IsRunning() ;
+ bool IsDone() ;
+ bool IsSuspended() ;
+ bool IsWaiting(const char * aNodeName ) ;
+ bool IsReady(const char * aNodeName ) ;
+ bool IsRunning(const char * aNodeName ) ;
+ bool IsDone(const char * aNodeName ) ;
+ bool IsSuspended(const char * aNodeName ) ;
+ bool IsDone(const char * aNodeName ,
+ const char * anOutServiceParameterName ) ;
+
+ const CORBA::Any *GetInData( const char * ToNodeName ,
+ const char * ToParameterName ) ;
+ const CORBA::Any *GetOutData( const char * FromNodeName ,
+ const char * FromParameterName ) ;
+
+ long Threads() ;
+
+ bool ReadyWait() ;
+ bool RunningWait() ;
+ bool DoneWait() ;
+ bool SuspendedWait() ;
+ bool ReadyWait(const char * aNodeName ) ;
+ bool RunningWait(const char * aNodeName ) ;
+ bool DoneWait(const char * aNodeName ) ;
+ bool SuspendedWait(const char * aNodeName ) ;
+
+ bool Ping(const char * aNodeName ) ;
+ bool ContainerKill() ;
+ bool ContainerKill(const char * aNodeName ) ;
+
+ bool Kill() ;
+ bool Kill(const char * aNodeName ) ;
+ bool KillDone(const char * aNodeName ) ;
+ bool Suspend() ;
+ bool Suspend(const char * aNodeName ) ;
+ bool SuspendDone() ;
+ bool SuspendDone(const char * aNodeName ) ;
+ bool Resume() ;
+ bool Resume(const char * aNodeName ) ;
+ bool Stop() ;
+ bool Stop(const char * aNodeName ) ;
+
+ };
+
+};
+
+#include "DataFlowExecutor_DataFlow.lxx"
+
+ostream & operator << (ostream &,const GraphExecutor::DataFlow & G);
+ostream & operator << (ostream &,const SUPERV::SDate &);
+
+#endif
+
+
+
--- /dev/null
+#ifndef _DATAFLOWEXECUTOR_DATAFLOW_LXX
+#define _DATAFLOWEXECUTOR_DATAFLOW_LXX
+
+#include "DataFlowExecutor_OutNode.hxx"
+
+inline bool GraphExecutor::DataFlow::LoadDataFlow(
+ const GraphBase::SGraph &aDataFlow ) {
+ return GraphExecutor::OutNode::LoadDataFlow( aDataFlow ) ;
+}
+
+inline bool GraphExecutor::DataFlow::LoadXml( const char* myFileName ) {
+ return GraphExecutor::OutNode::LoadXml( myFileName ) ;
+}
+
+inline const SALOME_ModuleCatalog::Service * GraphExecutor::DataFlow::NodeService(
+ const char * aNodeName ) {
+ if ( GetGraphNode( aNodeName ) )
+ return GetGraphNode( aNodeName )->GetService() ;
+ return NULL ;
+}
+
+inline bool GraphExecutor::DataFlow::ChangeInputData( const char* ToNodeName ,
+ const char* ToParameterName ,
+ const CORBA::Any aValue ) {
+ if ( !IsValid() )
+ return false ;
+ return GraphBase::Graph::ChangeInputData( ToNodeName , ToParameterName ,
+ aValue ) ;
+} ;
+
+inline bool GraphExecutor::DataFlow::AddInputSharedData(const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) {
+ if ( !IsValid() )
+ return false ;
+ return GraphExecutor::OutNode::AddInputData( ToNodeName1 ,
+ ToParameterName1 ,
+ ToNodeName2 ,
+ ToParameterName2 ) ;
+// aKindOfPortValue ) ;
+} ;
+
+inline bool GraphExecutor::DataFlow::IsValid() {
+ return GraphExecutor::OutNode::IsValid() ;
+}
+
+inline bool GraphExecutor::DataFlow::IsExecutable() {
+ return GraphExecutor::OutNode::IsExecutable() ;
+}
+
+inline bool GraphExecutor::DataFlow::Run( const bool AndSuspend ) {
+ return GraphExecutor::OutNode::Run( AndSuspend ) ;
+}
+inline bool GraphExecutor::DataFlow::Run( const char * aNodeName ,
+ const char * AtNodeName ,
+ const bool AndSuspend ) {
+ return GraphExecutor::OutNode::Run( aNodeName , AtNodeName , AndSuspend ) ;
+}
+
+inline long GraphExecutor::DataFlow::LastLevelDone() {
+ return GraphExecutor::OutNode::LastLevelDone() ;
+}
+
+inline long GraphExecutor::DataFlow::Threads() {
+ return GraphExecutor::OutNode::Threads() ;
+}
+
+inline bool GraphExecutor::DataFlow::Event( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ,
+ bool WithWait ) {
+ return GraphExecutor::OutNode::Event( aNodeName , anEvent , aState , WithWait ) ;
+}
+inline bool GraphExecutor::DataFlow::EventW( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ) {
+ return GraphExecutor::OutNode::EventW( aNodeName , anEvent , aState ) ;
+}
+
+inline SUPERV::GraphState GraphExecutor::DataFlow::State() {
+ return GraphExecutor::OutNode::State() ;
+}
+
+inline SUPERV::GraphState GraphExecutor::DataFlow::State(
+ const char * aNodeName ) {
+ return GraphExecutor::OutNode::State( aNodeName ) ;
+}
+
+inline SUPERV::GraphState GraphExecutor::DataFlow::State(
+ const char * aNodeName ,
+ const char * anOutServiceParameterName ) {
+ return GraphExecutor::OutNode::State( aNodeName ,
+ anOutServiceParameterName ) ;
+}
+
+inline long GraphExecutor::DataFlow::Thread() {
+ return GraphExecutor::OutNode::ThreadNo() ;
+}
+inline long GraphExecutor::DataFlow::Thread( const char * aNodeName ) {
+ return GraphExecutor::OutNode::Thread( aNodeName ) ;
+}
+
+inline SUPERV::AutomatonState GraphExecutor::DataFlow::AutomatonState() {
+ return GraphExecutor::OutNode::AutomatonState() ;
+}
+
+inline SUPERV::AutomatonState GraphExecutor::DataFlow::AutomatonState(
+ const char * aNodeName ) {
+ return GraphExecutor::OutNode::AutomatonState( aNodeName ) ;
+}
+
+inline SUPERV::ControlState GraphExecutor::DataFlow::ControlState() {
+ return GraphExecutor::OutNode::ControlState() ;
+}
+
+inline SUPERV::ControlState GraphExecutor::DataFlow::ControlState(
+ const char * aNodeName ) {
+ return GraphExecutor::OutNode::ControlState( aNodeName ) ;
+}
+
+inline void GraphExecutor::DataFlow::ControlClear() {
+ return GraphExecutor::OutNode::ControlClear() ;
+}
+
+inline void GraphExecutor::DataFlow::ControlClear(
+ const char * aNodeName ) {
+ return GraphExecutor::OutNode::ControlClear( aNodeName ) ;
+}
+
+inline bool GraphExecutor::DataFlow::IsWaiting() {
+ return GraphExecutor::OutNode::IsWaiting() ;
+}
+inline bool GraphExecutor::DataFlow::IsReady() {
+ return GraphExecutor::OutNode::IsReady() ;
+}
+inline bool GraphExecutor::DataFlow::IsRunning() {
+ return GraphExecutor::OutNode::IsRunning() ;
+}
+inline bool GraphExecutor::DataFlow::IsDone() {
+ return GraphExecutor::OutNode::IsDone() ;
+}
+inline bool GraphExecutor::DataFlow::IsSuspended() {
+ return GraphExecutor::OutNode::IsSuspended() ;
+}
+
+inline bool GraphExecutor::DataFlow::IsWaiting(const char * aNodeName ) {
+ return GraphExecutor::OutNode::IsWaiting( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::IsReady(const char * aNodeName ) {
+ return GraphExecutor::OutNode::IsReady( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::IsRunning(const char * aNodeName ) {
+ return GraphExecutor::OutNode::IsRunning( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::IsDone(const char * aNodeName ) {
+ return GraphExecutor::OutNode::IsDone( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::IsSuspended(const char * aNodeName ) {
+ return GraphExecutor::OutNode::IsSuspended( aNodeName ) ;
+}
+
+inline bool GraphExecutor::DataFlow::IsDone(
+ const char * aNodeName ,
+ const char * anOutServiceParameterName ) {
+ return GraphExecutor::OutNode::IsDone( aNodeName ,
+ anOutServiceParameterName ) ;
+}
+
+inline bool GraphExecutor::DataFlow::ReadyWait() {
+ return GraphExecutor::OutNode::ReadyWait() ;
+}
+inline bool GraphExecutor::DataFlow::RunningWait() {
+ return GraphExecutor::OutNode::RunningWait() ;
+}
+inline bool GraphExecutor::DataFlow::DoneWait() {
+ return GraphExecutor::OutNode::DoneWait() ;
+}
+inline bool GraphExecutor::DataFlow::SuspendedWait() {
+ return GraphExecutor::OutNode::SuspendedWait() ;
+}
+
+inline bool GraphExecutor::DataFlow::ReadyWait(const char * aNodeName ) {
+ return GraphExecutor::OutNode::ReadyWait( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::RunningWait(const char * aNodeName ) {
+ return GraphExecutor::OutNode::RunningWait( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::DoneWait(const char * aNodeName ) {
+ return GraphExecutor::OutNode::DoneWait( aNodeName ) ;
+}
+inline bool GraphExecutor::DataFlow::SuspendedWait(const char * aNodeName ) {
+ return GraphExecutor::OutNode::SuspendedWait( aNodeName ) ;
+}
+
+inline const CORBA::Any *GraphExecutor::DataFlow::GetInData(
+ const char * ToNodeName ,
+ const char * ToParameterName ) {
+ return GraphExecutor::OutNode::GetInData( ToNodeName ,
+ ToParameterName ) ;
+}
+inline const CORBA::Any *GraphExecutor::DataFlow::GetOutData(
+ const char * FromNodeName ,
+ const char * FromParameterName ) {
+ return GraphExecutor::OutNode::GetOutData( FromNodeName ,
+ FromParameterName ) ;
+}
+#endif
+
+
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : DataFlowBase_DynInvoke.cxx
+// Created : 2002
+// Author : Marc Tajchman, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#include <stdarg.h>
+#include <map>
+
+#include "DataFlowExecutor_InNode.hxx"
+
+using namespace CORBA ;
+
+
+
+void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr obj ,
+ const char *method ,
+ ServicesAnyData * inParams , int nInParams ,
+ ServicesAnyData * outParams , int nOutParams ) {
+ Request_var req = obj->_request( method ) ;
+ const char *s ;
+
+ NVList_ptr arguments =req->arguments() ;
+
+ int i ;
+
+ int n_in = nInParams ;
+ int n_out = nOutParams ;
+
+ for ( i = 0 ; i < n_in ; i++ ) {
+ CORBA::Any & data = inParams[i].Value ;
+ s = inParams[i].Name.c_str() ;
+ arguments->add_value( s , data , CORBA::ARG_IN ) ;
+#if 0
+ switch ( data.type()->kind() ) {
+ case CORBA::tk_string :
+ char * t ;
+ data >>= t ;
+ MESSAGE( "ArgIn" << i << " : " << s << " Value " << t << " (string)") ;
+ break ;
+ case CORBA::tk_double :
+ double d ;
+ data >>= d ;
+ MESSAGE( "ArgIn" << i << " : " << s << " Value " << d << " (double)") ;
+ break ;
+ case CORBA::tk_long :
+ long l ;
+ data >>= l ;
+ MESSAGE( "ArgIn" << i << " : " << s << " Value " << l << " (long)") ;
+ break ;
+ case CORBA::tk_objref :
+ MESSAGE( "ArgIn" << i << " : " << s << " Value " << "(object reference)") ;
+ break ;
+ default :
+ MESSAGE( "ArgIn" << i << " : " << s << " Value " << "(other ERROR)") ;
+ }
+ MESSAGE() ;
+#endif
+ }
+
+ for ( i = 0 ; i < n_out ; i++ ) {
+ CORBA::Any & data = outParams[i].Value ;
+ s = outParams[i].Name.c_str() ;
+ arguments->add_value( s , data , CORBA::ARG_OUT ) ;
+#if 0
+ switch ( data.type()->kind() ) {
+ case CORBA::tk_string :
+ char * t ;
+ data >>= t ;
+ MESSAGE( "ArgOut" << i << " : " << s << " Value " << t << " (string)") ;
+ break ;
+ case CORBA::tk_double :
+ double d ;
+ data >>= d ;
+ MESSAGE( "ArgOut" << i << " : " << s << " Value " << d << " (double)") ;
+ break ;
+ case CORBA::tk_long :
+ long l ;
+ data >>= l ;
+ MESSAGE( "ArgOut" << i << " : " << s << " Value " << l << " (long)") ;
+ break ;
+ case CORBA::tk_objref :
+ MESSAGE( "ArgOut" << i << " : " << s << " Value " << "(object reference)") ;
+ break ;
+ default :
+ MESSAGE( "ArgOut" << i << " : " << s << " Value " << "(other ERROR)") ;
+ }
+ MESSAGE() ;
+#endif
+ }
+
+ req->invoke();
+
+ if( req->env()->exception() ) {
+ req->env()->exception()->_raise() ;
+ return ; // pas utile ?
+ }
+
+ for ( i = 0 ; i < n_out ; i++ ) {
+
+ outParams[i].Value = *( arguments->item( i + n_in )->value() ) ;
+ }
+
+ return;
+
+}
+
+void GraphExecutor::InNode::DynInvoke( Engines::Component_ptr obj ,
+ const char *method ,
+ const char * aGraphName ,
+ const char * aNodeName ) {
+ Request_var req = obj->_request( method ) ;
+ const char *s;
+
+ NVList_ptr arguments =req->arguments() ;
+
+ CORBA::Any graph ;
+ graph <<= aGraphName ;
+ arguments->add_value( "aGraphName" , graph , CORBA::ARG_IN ) ;
+ CORBA::Any node ;
+ node <<= aNodeName ;
+ arguments->add_value( "aNodeName" , node , CORBA::ARG_IN ) ;
+
+ req->invoke() ;
+
+ if( req->env()->exception() ) {
+ req->env()->exception()->_raise();
+ }
+ return;
+
+}
--- /dev/null
+#ifndef _DATAFLOWEXECUTOR_DYNINVOKE_
+#define _DATAFLOWEXECUTOR_DYNINVOKE_
+
+#include <SALOMEconfig.h>
+//#include CORBA_CLIENT_HEADER(SALOME_Component)
+//#include CORBA_CLIENT_HEADER(SUPERV)
+#include <string>
+
+struct ServicesAnyData {
+
+ string Name;
+ CORBA::Any Value;
+
+};
+
+
+// dynamic call for function with list of in parameters, followed
+// by out parameters with no return value
+
+void DynInvoke(Engines::Component_ptr obj,
+ const char *method,
+ ServicesAnyData * inParams, int nInParams,
+ ServicesAnyData * inParams, int nOutParams);
+void DynInvoke(Engines::Component_ptr obj,
+ const char *method,
+ const char * aGraphName ,
+ const char * aNodeName );
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : DataFlowBase_FiniteStateMachine.cxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#include <stdlib.h>
+#include <iostream>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "DataFlowExecutor_FiniteStateMachine.hxx"
+
+void * start_function( void *p ) ;
+
+// ControlStates :
+#define VoidState SUPERV::VoidState
+#define ToSuspendStartState SUPERV::ToSuspendStartState
+#define ToSuspendState SUPERV::ToSuspendState
+#define ToSuspendDoneState SUPERV::ToSuspendDoneState
+#define ToKillState SUPERV::ToKillState
+#define ToKillDoneState SUPERV::ToKillDoneState
+#define ToStopState SUPERV::ToStopState
+
+// States :
+#define UnKnownState SUPERV::UnKnownState
+#define DataUndefState SUPERV::DataUndefState
+#define DataWaitingState SUPERV::DataWaitingState
+#define DataReadyState SUPERV::DataReadyState
+#define SuspendedReadyState SUPERV::SuspendedReadyState
+#define SuspendedReadyToResumeState SUPERV::SuspendedReadyToResumeState
+#define ResumedReadyState SUPERV::ResumedReadyState
+#define KilledReadyState SUPERV::KilledReadyState
+#define StoppedReadyState SUPERV::StoppedReadyState
+#define ExecutingState SUPERV::ExecutingState
+#define SuspendedExecutingState SUPERV::SuspendedExecutingState
+#define ResumedExecutingState SUPERV::ResumedExecutingState
+#define KilledExecutingState SUPERV::KilledExecutingState
+#define StoppedExecutingState SUPERV::StoppedExecutingState
+#define SuccessedExecutingState SUPERV::SuccessedExecutingState
+#define ErroredExecutingState SUPERV::ErroredExecutingState
+#define SuspendedSuccessedState SUPERV::SuspendedSuccessedState
+#define SuspendedErroredState SUPERV::SuspendedErroredState
+#define SuspendedSuccessedToReStartState SUPERV::SuspendedSuccessedToReStartState
+#define SuspendedErroredToReStartState SUPERV::SuspendedErroredToReStartState
+#define ResumedSuccessedState SUPERV::ResumedSuccessedState
+#define ResumedErroredState SUPERV::ResumedErroredState
+#define KilledSuccessedState SUPERV::KilledSuccessedState
+#define KilledErroredState SUPERV::KilledErroredState
+#define StoppedSuccessedState SUPERV::StoppedSuccessedState
+#define StoppedErroredState SUPERV::StoppedErroredState
+#define SuccessedState SUPERV::SuccessedState
+#define ErroredState SUPERV::ErroredState
+#define SuspendedState SUPERV::SuspendedState
+#define KilledState SUPERV::KilledState
+#define StoppedState SUPERV::StoppedState
+#define ReRunnedState SUPERV::ReRunnedState
+#define ReStartedState SUPERV::ReStartedState
+#define NumberOfAutomatonStates SUPERV::NumberOfAutomatonStates
+
+// Events :
+#define UndefinedEvent GraphExecutor::UndefinedEvent
+#define NewThreadEvent GraphExecutor::NewThreadEvent
+#define SuspendEvent GraphExecutor::SuspendEvent
+#define ToResumeEvent GraphExecutor::ToResumeEvent
+#define ResumeEvent GraphExecutor::ResumeEvent
+#define KillEvent GraphExecutor::KillEvent
+#define StopEvent GraphExecutor::StopEvent
+#define ExecuteEvent GraphExecutor::ExecuteEvent
+#define SuccessEvent GraphExecutor::SuccessEvent
+#define ErrorEvent GraphExecutor::ErrorEvent
+#define ReStartEvent GraphExecutor::ReStartEvent
+#define ReStartAndSuspendEvent GraphExecutor::ReStartAndSuspendEvent
+#define NoDataReadyEvent GraphExecutor::NoDataReadyEvent
+#define SomeDataReadyEvent GraphExecutor::SomeDataReadyEvent
+#define NotAllDataReadyEvent GraphExecutor::NotAllDataReadyEvent
+#define AllDataReadyEvent GraphExecutor::AllDataReadyEvent
+#define ReadyEvent GraphExecutor::ReadyEvent
+#define SuspendedReadyEvent GraphExecutor::SuspendedReadyEvent
+#define ResumedReadyEvent GraphExecutor::ResumedReadyEvent
+#define KilledReadyEvent GraphExecutor::KilledReadyEvent
+#define StoppedReadyEvent GraphExecutor::StoppedReadyEvent
+#define ExecutingEvent GraphExecutor::ExecutingEvent
+#define SuspendedExecutingEvent GraphExecutor::SuspendedExecutingEvent
+#define ResumedExecutingEvent GraphExecutor::ResumedExecutingEvent
+#define KilledExecutingEvent GraphExecutor::KilledExecutingEvent
+#define StoppedExecutingEvent GraphExecutor::StoppedExecutingEvent
+#define SuccessedExecutingEvent GraphExecutor::SuccessedExecutingEvent
+#define ErroredExecutingEvent GraphExecutor::ErroredExecutingEvent
+#define SuspendedSuccessedEvent GraphExecutor::SuspendedSuccessedEvent
+#define SuspendedErroredEvent GraphExecutor::SuspendedErroredEvent
+#define ResumedSuccessedEvent GraphExecutor::ResumedSuccessedEvent
+#define ResumedErroredEvent GraphExecutor::ResumedErroredEvent
+#define KilledEvent GraphExecutor::KilledEvent
+#define StoppedEvent GraphExecutor::StoppedEvent
+#define ToReStartEvent GraphExecutor::ToReStartEvent
+#define ReStartedEvent GraphExecutor::ReStartedEvent
+#define ReStartedAndSuspendEvent GraphExecutor::ReStartedAndSuspendEvent
+#define EndExecuteEvent GraphExecutor::EndExecuteEvent
+#define NumberOfEvents GraphExecutor::NumberOfEvents
+
+GraphExecutor::FiniteStateMachine::FiniteStateMachine() {
+// cdebug_in << "FiniteStateMachine::FiniteStateMachine" << endl;
+
+ _ControlStateName[ VoidState ] = "VoidState" ;
+ _ControlStateName[ ToSuspendStartState ]= "ToSuspendStartState" ;
+ _ControlStateName[ ToSuspendState ] = "ToSuspendState" ;
+ _ControlStateName[ ToSuspendDoneState ] = "ToSuspendDoneState" ;
+ _ControlStateName[ ToKillState ] = "ToKillState" ;
+ _ControlStateName[ ToKillDoneState ] = "ToKillDoneState" ;
+ _ControlStateName[ ToStopState ] = "ToStopState" ;
+
+ _StateName[ UnKnownState ] = "UnKnownState" ;
+ _StateName[ DataUndefState ] = "DataUndefState" ;
+ _StateName[ DataWaitingState ] = "DataWaitingState" ;
+ _StateName[ DataReadyState ] = "DataReadyState" ;
+ _StateName[ SuspendedReadyState ] = "SuspendedReadyState" ;
+ _StateName[ SuspendedReadyToResumeState ] = "SuspendedReadyToResumeState" ;
+ _StateName[ ResumedReadyState ] = "ResumedReadyState" ;
+ _StateName[ KilledReadyState ] = "KilledReadyState" ;
+ _StateName[ StoppedReadyState ] = "StoppedReadyState" ;
+ _StateName[ ExecutingState ] = "ExecutingState" ;
+ _StateName[ SuspendedExecutingState ] = "SuspendedExecutingState" ;
+ _StateName[ ResumedExecutingState ] = "ResumedExecutingState" ;
+ _StateName[ KilledExecutingState ] = "KilledExecutingState" ;
+ _StateName[ StoppedExecutingState ] = "StoppedExecutingState" ;
+ _StateName[ SuccessedExecutingState ] = "SuccessedExecutingState" ;
+ _StateName[ ErroredExecutingState ] = "ErroredExecutingState" ;
+ _StateName[ SuspendedSuccessedState ] = "SuspendedSuccessedState" ;
+ _StateName[ SuspendedErroredState ] = "SuspendedErroredState" ;
+ _StateName[ SuspendedSuccessedToReStartState ] = "SuspendedSuccessedToReStartState" ;
+ _StateName[ SuspendedErroredToReStartState ] = "SuspendedErroredToReStartState" ;
+ _StateName[ ResumedSuccessedState ] = "ResumedSuccessedState" ;
+ _StateName[ ResumedErroredState ] = "ResumedErroredState" ;
+ _StateName[ KilledSuccessedState ] = "KilledSuccessedState" ;
+ _StateName[ KilledErroredState ] = "KilledErroredState" ;
+ _StateName[ StoppedSuccessedState ] = "StoppedSuccessedState" ;
+ _StateName[ StoppedErroredState ] = "StoppedErroredState" ;
+ _StateName[ SuccessedState ] = "SuccessedState" ;
+ _StateName[ ErroredState ] = "ErroredState" ;
+ _StateName[ SuspendedState ] = "SuspendedState" ;
+ _StateName[ KilledState ] = "KilledState" ;
+ _StateName[ StoppedState ] = "StoppedState" ;
+ _StateName[ ReRunnedState ] = "ReRunnedState" ;
+ _StateName[ ReStartedState ] = "ReStartedState" ;
+
+ _EventName[ UndefinedEvent ] = "UndefinedEvent" ;
+ _EventName[ NewThreadEvent ] = "NewThreadEvent" ;
+ _EventName[ SuspendEvent ] = "SuspendEvent" ;
+ _EventName[ ToResumeEvent ] = "ToResumeEvent" ;
+ _EventName[ ResumeEvent ] = "ResumeEvent" ;
+ _EventName[ KillEvent ] = "KillEvent" ;
+ _EventName[ StopEvent ] = "StopEvent" ;
+ _EventName[ ExecuteEvent ] = "ExecuteEvent" ;
+ _EventName[ SuccessEvent ] = "SuccessEvent" ;
+ _EventName[ ErrorEvent ] = "ErrorEvent" ;
+ _EventName[ ToReStartEvent ] = "ToReStartEvent" ;
+ _EventName[ ReStartEvent ] = "ReStartEvent" ;
+ _EventName[ ReStartAndSuspendEvent ] = "ReStartAndSuspendEvent" ;
+ _EventName[ NoDataReadyEvent ] = "NoDataReadyEvent" ;
+ _EventName[ SomeDataReadyEvent ] = "SomeDataReadyEvent" ;
+ _EventName[ NotAllDataReadyEvent ] = "NotAllDataReadyEvent" ;
+ _EventName[ AllDataReadyEvent ] = "AllDataReadyEvent" ;
+ _EventName[ ReadyEvent ] = "ReadyEvent" ;
+ _EventName[ SuspendedReadyEvent ] = "SuspendedReadyEvent" ;
+ _EventName[ ResumedReadyEvent ] = "ResumedReadyEvent" ;
+ _EventName[ KilledReadyEvent ] = "KilledReadyEvent" ;
+ _EventName[ StoppedReadyEvent ] = "StoppedReadyEvent" ;
+ _EventName[ ExecutingEvent ] = "ExecutingEvent" ;
+ _EventName[ SuspendedExecutingEvent ] = "SuspendedExecutingEvent" ;
+ _EventName[ ResumedExecutingEvent ] = "ResumedExecutingEvent" ;
+ _EventName[ KilledExecutingEvent ] = "KilledExecutingEvent" ;
+ _EventName[ StoppedExecutingEvent ] = "StoppedExecutingEvent" ;
+ _EventName[ SuccessedExecutingEvent ] = "SuccessedExecutingEvent" ;
+ _EventName[ ErroredExecutingEvent ] = "ErroredExecutingEvent" ;
+ _EventName[ SuspendedSuccessedEvent ] = "SuspendedSuccessedEvent" ;
+ _EventName[ SuspendedErroredEvent ] = "SuspendedErroredEvent" ;
+ _EventName[ ResumedSuccessedEvent ] = "ResumedSuccessedEvent" ;
+ _EventName[ ResumedErroredEvent ] = "ResumedErroredEvent" ;
+ _EventName[ KilledEvent ] = "KilledEvent" ;
+ _EventName[ StoppedEvent ] = "StoppedEvent" ;
+ _EventName[ ReStartedEvent ] = "ReStartedEvent" ;
+ _EventName[ ReStartedAndSuspendEvent ]= "ReStartedAndSuspendEvent" ;
+ _EventName[ EndExecuteEvent ] = "EndExecuteEvent" ;
+
+ _ActionName[ ErrorAction ] = "ErrorAction" ;
+ _ActionName[ VoidAction ] = "VoidAction" ;
+ _ActionName[ executeAction ] = "executeAction" ;
+ _ActionName[ ExecuteAction ] = "ExecuteAction" ;
+ _ActionName[ DataWaiting_SomeDataReadyAction ] = "DataWaiting_SomeDataReadyAction" ;
+ _ActionName[ DataUndef_NotAllDataReadyAction ] = "DataUndef_NotAllDataReadyAction";
+ _ActionName[ DataUndef_AllDataReadyAction ] = "DataUndef_AllDataReadyAction" ;
+
+ _ActionName[ DataReady_SuspendAction ] = "DataReady_SuspendAction" ;
+ _ActionName[ SuspendedReady_ResumeAction ] = "SuspendedReady_ResumeAction" ;
+ _ActionName[ DataReady_KillAction ] = "DataReady_KillAction" ;
+ _ActionName[ DataReady_StopAction ] = "DataReady_StopAction" ;
+
+ _ActionName[ DataReady_ExecuteAction ] = "DataReady_ExecuteAction" ;
+
+ _ActionName[ Executing_SuspendAction ] = "Executing_SuspendAction" ;
+ _ActionName[ SuspendedExecuting_ResumeAction ] = "SuspendedExecuting_ResumeAction" ;
+ _ActionName[ Executing_KillAction ] = "Executing_KillAction" ;
+ _ActionName[ Executing_StopAction ] = "Executing_StopAction" ;
+
+ _ActionName[ Executing_SuccessAction ] = "Executing_SuccessAction" ;
+ _ActionName[ Executing_ErrorAction ] = "Executing_ErrorAction" ;
+ _ActionName[ Successed_SuccessAction ] = "Successed_SuccessAction" ;
+ _ActionName[ Errored_ErrorAction ] = "Errored_ErrorAction" ;
+
+ _ActionName[ Successed_SuspendAction ] = "Successed_SuspendAction" ;
+ _ActionName[ Errored_SuspendAction ] = "Errored_SuspendAction" ;
+ _ActionName[ SuspendedSuccessed_ResumeAction ] = "SuspendedSuccessed_ResumeAction" ;
+ _ActionName[ SuspendedErrored_ResumeAction ] = "SuspendedErrored_ResumeAction" ;
+ _ActionName[ Successed_KillAction ] = "Successed_KillAction" ;
+ _ActionName[ Errored_KillAction ] = "Errored_KillAction" ;
+ _ActionName[ Successed_StopAction ] = "Successed_StopAction" ;
+ _ActionName[ Errored_StopAction ] = "Errored_StopAction" ;
+
+ _ActionName[ SuspendedSuccessed_ReStartAction ] = "SuspendedSuccessed_ReStartAction" ;
+ _ActionName[ SuspendedErrored_ReStartAction ] = "SuspendedErrored_ReStartAction" ;
+ _ActionName[ SuspendedSuccessed_ReStartAndSuspendAction ] = "SuspendedSuccessed_ReStartAndSuspendAction" ;
+ _ActionName[ SuspendedErrored_ReStartAndSuspendAction ] = "SuspendedErrored_ReStartAndSuspendAction" ;
+
+ _GraphStateName[ SUPERV::UndefinedState ] = "UndefinedState" ;
+ _GraphStateName[ SUPERV::NoState ] = "NoState" ;
+ _GraphStateName[ SUPERV::EditingState ] = "EditingState" ;
+ _GraphStateName[ SUPERV::SuspendState ] = "SuspendState" ;
+ _GraphStateName[ SUPERV::WaitingState ] = "WaitingState" ;
+ _GraphStateName[ SUPERV::ReadyState ] = "ReadyState" ;
+ _GraphStateName[ SUPERV::SuspendReadyState ] = "SuspendReadyState" ;
+ _GraphStateName[ SUPERV::RunningState ] = "RunningState" ;
+ _GraphStateName[ SUPERV::DoneState ] = "DoneState" ;
+ _GraphStateName[ SUPERV::ErrorState ] = "ErrorState" ;
+ _GraphStateName[ SUPERV::SuspendDoneState ] = "SuspendDoneState" ;
+ _GraphStateName[ SUPERV::SuspendErroredState ] = "SuspendErroredState" ;
+ _GraphStateName[ SUPERV::KillState ] = "KillState" ;
+ _GraphStateName[ SUPERV::StopState ] = "StopState" ;
+ _GraphStateName[ SUPERV::ReRunState ] = "ReRunState" ;
+ _GraphStateName[ SUPERV::ReStartState ] = "ReStartState" ;
+
+ int i , j ;
+// NewStates = _TransitionTable[ States ] [ Events ]
+// associated action = _ActionTable[ NewStates ] [ Events ]
+ for ( i = 0 ; i < NumberOfAutomatonStates ; i++ ) {
+ for ( j = 0 ; j < NumberOfEvents ; j++ ) {
+// id est = SameState and VoidAction
+ _TransitionTable[ i ][ j ] = (SUPERV::AutomatonState ) i ;
+ _ActionTable[ i ][ j ] = GraphExecutor::ErrorAction ;
+ }
+ }
+// OneEvent ===> Change of State and associated Action :
+// _TransitionTable[ OldState ][ OneEvent ] gives a NewState
+// _Action[ NewState ][ OneEvent ] gives what to do
+
+// INPUT-DATAS :
+// NoDataReadyEvent :
+ _TransitionTable[ DataUndefState ][ NoDataReadyEvent ] = DataWaitingState ;
+ _ActionTable[ DataWaitingState ][ NoDataReadyEvent ] = VoidAction ;
+// SomeDataReadyEvent :
+ _TransitionTable[ DataWaitingState ][ SomeDataReadyEvent ] = DataUndefState ;
+ _ActionTable[ DataUndefState ][ SomeDataReadyEvent ] = DataWaiting_SomeDataReadyAction;
+// NotAllDataReadyEvent :
+ _TransitionTable[ DataUndefState ][ NotAllDataReadyEvent ] = DataWaitingState ;
+ _ActionTable[ DataWaitingState ][ NotAllDataReadyEvent ] = DataUndef_NotAllDataReadyAction;
+// AllDataReadyEvent
+ _TransitionTable[ DataUndefState ][ AllDataReadyEvent ] = DataReadyState ;
+ _ActionTable[ DataReadyState ][ AllDataReadyEvent ] = DataUndef_AllDataReadyAction ;
+
+// DATAS-READY-CONTROL :
+// SuspendEvent
+ _TransitionTable[ DataReadyState ][ SuspendEvent ] = SuspendedReadyState ;
+ _ActionTable[ SuspendedReadyState ][ SuspendEvent ] = DataReady_SuspendAction;
+// ResumeEvent
+ _TransitionTable[ SuspendedReadyState ][ ToResumeEvent ] = SuspendedReadyToResumeState ;
+ _ActionTable[ SuspendedReadyToResumeState ][ ToResumeEvent ] = VoidAction ;
+
+ _TransitionTable[ SuspendedReadyToResumeState ][ ResumeEvent ] = ResumedReadyState ;
+ _ActionTable[ ResumedReadyState ][ ResumeEvent] = SuspendedReady_ResumeAction ;
+// KillEvent
+ _TransitionTable[ SuspendedReadyState ][ KillEvent ] = KilledReadyState ;
+// StopEvent
+ _TransitionTable[ SuspendedReadyState ][ StopEvent ] = StoppedReadyState ;
+// KillEvent
+ _TransitionTable[ DataReadyState ][ KillEvent ] = KilledReadyState ;
+ _ActionTable[ KilledReadyState ][ KillEvent] = DataReady_KillAction ;
+// StopEvent
+ _TransitionTable[ DataReadyState ][ StopEvent ] = StoppedReadyState ;
+ _ActionTable[ StoppedReadyState ][ StopEvent] = DataReady_StopAction ;
+
+// RUN :
+// ExecuteEvent
+ _TransitionTable[ SuspendedReadyToResumeState ][ ExecuteEvent ] = ExecutingState ;
+// ExecuteEvent
+ _TransitionTable[ ResumedReadyState ][ ExecuteEvent ] = ExecutingState ;
+// ExecuteEvent
+ _TransitionTable[ DataReadyState ][ ExecuteEvent ] = ExecutingState ;
+// ExecuteEvent
+ _TransitionTable[ ReStartedState ][ ExecuteEvent ] = ExecutingState ;
+ _ActionTable[ ExecutingState ][ ExecuteEvent ] = DataReady_ExecuteAction;
+
+// RUN-CONTROL :
+// SuspendEvent
+ _TransitionTable[ ExecutingState ][ SuspendEvent ] = SuspendedExecutingState ;
+ _ActionTable[ SuspendedExecutingState ][ SuspendEvent ] = Executing_SuspendAction;
+// ResumeEvent
+ _TransitionTable[ SuspendedExecutingState ][ ResumeEvent ] = ResumedExecutingState ;
+ _ActionTable[ ResumedExecutingState ][ ResumeEvent] = SuspendedExecuting_ResumeAction;
+// ExecuteEvent
+ _TransitionTable[ ResumedExecutingState ][ ExecuteEvent ] = ExecutingState ;
+// KillEvent
+ _TransitionTable[ SuspendedExecutingState ][ KillEvent ] = KilledExecutingState ;
+// StopEvent
+ _TransitionTable[ SuspendedExecutingState ][ StopEvent ] = StoppedExecutingState ;
+// KillEvent
+ _TransitionTable[ ExecutingState ][ KillEvent ] = KilledExecutingState ;
+ _ActionTable[ KilledExecutingState ][ KillEvent] = Executing_KillAction;
+ _TransitionTable[ KilledExecutingState ][ KillEvent ] = KilledState ;
+ _ActionTable[ KilledState ][ KillEvent] = VoidAction;
+// StopEvent
+ _TransitionTable[ ExecutingState ][ StopEvent ] = StoppedExecutingState ;
+ _ActionTable[ StoppedExecutingState ][ StopEvent] = Executing_StopAction;
+ _TransitionTable[ StoppedExecutingState ][ StopEvent ] = StoppedState ;
+ _ActionTable[ StoppedState ][ StopEvent] = VoidAction;
+
+// DONE :
+// SuccessEvent
+ _TransitionTable[ ExecutingState ][ SuccessEvent ] = SuccessedExecutingState ;
+ _ActionTable[ SuccessedExecutingState ][ SuccessEvent ] = Executing_SuccessAction;
+// SuspendedExecutingState : NO ResumeEvent 13-03-2003
+ _TransitionTable[ SuspendedExecutingState ][ SuccessEvent ] = SuccessedExecutingState ;
+ _ActionTable[ SuccessedExecutingState ][ SuccessEvent ] = Executing_SuccessAction;
+// ErrorEvent
+ _TransitionTable[ ExecutingState ][ ErrorEvent ] = ErroredExecutingState ;
+ _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+// SuspendedExecutingState : NO ResumeEvent 13-03-2003
+ _TransitionTable[ SuspendedExecutingState ][ ErrorEvent ] = ErroredExecutingState ;
+ _ActionTable[ ErroredExecutingState ][ ErrorEvent ] = Executing_ErrorAction;
+
+// DONE-CONTROL :
+// SuccessedExecutingState - SuccessEvent
+ _TransitionTable[ SuccessedExecutingState ][ SuccessEvent ] = SuccessedState ;
+ _ActionTable[ SuccessedState ][ SuccessEvent ] = Successed_SuccessAction ;
+// ErroredExecutingState - ErrorEvent
+ _TransitionTable[ ErroredExecutingState ][ ErrorEvent ] = ErroredState ;
+ _ActionTable[ ErroredState ][ ErrorEvent ] = Errored_ErrorAction ;
+
+// SuccessedState - SuspendEvent
+ _TransitionTable[ SuccessedExecutingState ][ SuspendEvent ] = SuspendedSuccessedState ;
+ _ActionTable[ SuspendedSuccessedState ][ SuspendEvent ] = Successed_SuspendAction;
+// ErroredState - SuspendEvent
+ _TransitionTable[ ErroredExecutingState ][ SuspendEvent ] = SuspendedErroredState ;
+ _ActionTable[ SuspendedErroredState ][ SuspendEvent ] = Errored_SuspendAction;
+
+// SuccessedState - KillEvent
+ _TransitionTable[ SuccessedExecutingState ][ KillEvent ] = KilledSuccessedState ;
+ _ActionTable[ KilledSuccessedState ][ KillEvent ] = Successed_KillAction;
+// ErroredState - KillEvent
+ _TransitionTable[ ErroredExecutingState ][ KillEvent ] = KilledErroredState ;
+ _ActionTable[ KilledErroredState ][ KillEvent ] = Errored_KillAction;
+
+// SuccessedState - StopEvent
+ _TransitionTable[ SuccessedExecutingState ][ StopEvent ] = StoppedSuccessedState ;
+ _ActionTable[ StoppedSuccessedState ][ StopEvent ] = Successed_StopAction;
+// ErroredState - StopEvent
+ _TransitionTable[ ErroredExecutingState ][ StopEvent ] = StoppedErroredState ;
+ _ActionTable[ StoppedErroredState ][ StopEvent ] = Errored_StopAction;
+
+// SuspendedSuccessedState - ResumeEvent
+ _TransitionTable[ SuspendedSuccessedState ][ ResumeEvent ] = ResumedSuccessedState ;
+ _ActionTable[ ResumedSuccessedState ][ ResumeEvent ] = SuspendedSuccessed_ResumeAction;
+
+ _TransitionTable[ ResumedSuccessedState ][ ResumedSuccessedEvent ] = SuccessedState ;
+ _ActionTable[ SuccessedState ][ ResumedSuccessedEvent] = Successed_SuccessAction;
+
+// SuspendedErroredState - ResumeEvent
+ _TransitionTable[ SuspendedErroredState ][ ResumeEvent ] = ResumedErroredState ;
+ _ActionTable[ ResumedErroredState ][ ResumeEvent ] = SuspendedErrored_ResumeAction;
+ _TransitionTable[ ResumedErroredState ][ ResumedErroredEvent ] = ErroredState ;
+ _ActionTable[ ErroredState ][ ResumedErroredEvent ] = Errored_ErrorAction;
+
+// SuccessedState - KillEvent
+ _TransitionTable[ SuccessedState ][ KillEvent ] = KilledSuccessedState ;
+ _ActionTable[ KilledSuccessedState ][ KillEvent] = Successed_KillAction;
+ _TransitionTable[ KilledSuccessedState ][ KillEvent ] = KilledState ;
+ _ActionTable[ KilledState ][ KillEvent ] = VoidAction;
+// ErroredState - KillEvent
+ _TransitionTable[ ErroredState ][ KillEvent ] = KilledErroredState ;
+ _ActionTable[ KilledErroredState ][ KillEvent] = Errored_KillAction;
+ _TransitionTable[ KilledErroredState ][ KillEvent ] = KilledState ;
+ _ActionTable[ KilledState ][ KillEvent ] = VoidAction;
+
+// SuccessedState - StopEvent
+ _TransitionTable[ SuccessedState ][ StopEvent ] = StoppedSuccessedState ;
+ _ActionTable[ StoppedSuccessedState ][ StopEvent] = Successed_StopAction;
+ _TransitionTable[ StoppedSuccessedState ][ StopEvent ] = StoppedState ;
+ _ActionTable[ StoppedState ][ StopEvent ] = VoidAction;
+// ErroredState - StopEvent
+ _TransitionTable[ ErroredState ][ StopEvent ] = StoppedErroredState ;
+ _ActionTable[ StoppedErroredState ][ StopEvent] = Errored_StopAction;
+ _TransitionTable[ StoppedErroredState ][ StopEvent ] = StoppedState ;
+ _ActionTable[ StoppedState ][ StopEvent ] = VoidAction;
+
+// ReStartEvent
+ _TransitionTable[ SuspendedSuccessedState ][ ToReStartEvent ] = SuspendedSuccessedToReStartState ;
+ _ActionTable[ SuspendedSuccessedToReStartState ][ ToReStartEvent] = VoidAction ;
+
+ _TransitionTable[ SuspendedSuccessedToReStartState ][ ReStartEvent ] = ReStartedState ;
+ _TransitionTable[ SuspendedSuccessedToReStartState ][ ReStartAndSuspendEvent ] = ReStartedState ;
+// ReStartEvent
+ _TransitionTable[ SuspendedErroredState ][ ToReStartEvent ] = SuspendedErroredToReStartState ;
+ _ActionTable[ SuspendedErroredToReStartState ][ ToReStartEvent] = VoidAction ;
+
+ _TransitionTable[ SuspendedErroredToReStartState ][ ReStartEvent ] = ReStartedState ;
+ _TransitionTable[ SuspendedErroredToReStartState ][ ReStartAndSuspendEvent ] = ReStartedState ;
+
+ _ActionTable[ ReStartedState ][ ReStartEvent] = SuspendedSuccessed_ReStartAction;
+ _ActionTable[ ReStartedState ][ ReStartAndSuspendEvent] = SuspendedSuccessed_ReStartAndSuspendAction;
+
+ pthread_mutex_init( &_MutexJoinWait , NULL ) ;
+ if ( pthread_cond_init( &_JoinWait , NULL ) ) {
+ perror("pthread_cond_init( &_JoinWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ _JoinThread = true ;
+ if ( pthread_create( &_JoinThreadNo , NULL , start_function , this ) ) {
+ char * msg = "Cannot pthread_create " ;
+ perror( msg ) ;
+ }
+
+// cdebug_out << "FiniteStateMachine::FiniteStateMachine _TransitionTable "
+// << endl;
+}
+
+void * start_function( void *p ) {
+ GraphExecutor::FiniteStateMachine *anAutomaton = (GraphExecutor::FiniteStateMachine *) p;
+ if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
+ perror("pthread_setcanceltype ") ;
+ exit(0) ;
+ }
+ if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
+ perror("pthread_setcancelstate ") ;
+ exit(0) ;
+ }
+ anAutomaton->JoinThread() ;
+ pthread_exit( PTHREAD_CANCELED ) ;
+}
+
+void GraphExecutor::FiniteStateMachine::JoinThread() {
+ if ( pthread_mutex_lock( &_MutexJoinWait ) ) {
+ perror("Join pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ while ( _JoinThread ) {
+ while ( _ThreadList.size() == 0) {
+// MESSAGE( pthread_self() << " Join pthread_cond_wait" );
+ if ( pthread_cond_wait( &_JoinWait , &_MutexJoinWait ) ) {
+ perror("Join pthread_cond_wait ") ;
+ }
+ }
+ pthread_t _Thread = _ThreadList.front() ;
+// MESSAGE( pthread_self() << " Join pthread_cond_waited : " << _Thread )
+ _ThreadList.pop_front() ;
+// MESSAGE( pthread_self() << " Join pthread_join : " << _Thread );
+ int joinsts = pthread_join( _Thread , NULL ) ;
+// MESSAGE( pthread_self() << " Join pthread_joined : " << _Thread );
+ if ( joinsts ) {
+ perror("Join pthread_join ") ;
+// exit( 0 ) ;
+ }
+ }
+ if ( pthread_mutex_unlock( &_MutexJoinWait ) ) {
+ perror("Join pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::FiniteStateMachine::JoinThread( pthread_t aThread ) {
+ if ( pthread_mutex_lock( &_MutexJoinWait ) ) {
+ perror("Join pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+// MESSAGE(pthread_self() << " JoinThread pthread_cond_signal for " << aThread)
+ _ThreadList.push_back( aThread ) ;
+ if ( pthread_cond_signal( &_JoinWait ) ) {
+ perror("Join pthread_cond_signal ") ;
+ }
+// MESSAGE( pthread_self() << " JoinThread pthread_cond_signaled for " << aThread)
+
+ if ( pthread_mutex_unlock( &_MutexJoinWait ) ) {
+ perror("Join pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
--- /dev/null
+//=============================================================================
+// File : DataFlowBase_FiniteStateMachine.hxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#ifndef _DATAFLOWEXECUTOR_FINITESTATEMACHINE
+#define _DATAFLOWEXECUTOR_FINITESTATEMACHINE
+
+#include <stdlib.h>
+#include <iostream>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "DataFlowBase_Base.hxx"
+
+#include <SALOMEconfig.h>
+//#include CORBA_SERVER_HEADER(SUPERV)
+#include <SALOME_LifeCycleCORBA.hxx>
+
+namespace GraphExecutor {
+
+ enum NodeEvent { UndefinedEvent , NewThreadEvent ,
+ SuspendEvent , ToResumeEvent , ResumeEvent ,
+ KillEvent , StopEvent ,
+ ExecuteEvent , SuccessEvent , ErrorEvent ,
+ ToReStartEvent , ReStartEvent , ReStartAndSuspendEvent ,
+ EndExecuteEvent ,
+ NoDataReadyEvent , SomeDataReadyEvent ,
+ NotAllDataReadyEvent , AllDataReadyEvent ,
+ ReadyEvent , SuspendedReadyEvent ,ResumedReadyEvent ,
+ KilledReadyEvent , StoppedReadyEvent ,
+ ExecutingEvent , SuspendedExecutingEvent ,
+ ResumedExecutingEvent , KilledExecutingEvent ,
+ StoppedExecutingEvent ,
+ SuccessedExecutingEvent , ErroredExecutingEvent ,
+ SuspendedSuccessedEvent , SuspendedErroredEvent ,
+ ResumedSuccessedEvent , ResumedErroredEvent ,
+ KilledEvent , StoppedEvent ,
+ ReStartedEvent , ReStartedAndSuspendEvent ,
+ NumberOfEvents } ;
+
+ enum StateEventAction { ErrorAction ,
+ VoidAction ,
+ executeAction , // +- pthread_create
+ ExecuteAction , // +- pthread_create
+ DataWaiting_SomeDataReadyAction ,
+ DataUndef_NotAllDataReadyAction ,
+ DataUndef_AllDataReadyAction ,
+ DataReady_SuspendAction ,
+ SuspendedReady_ResumeAction ,
+ DataReady_KillAction ,
+ DataReady_StopAction ,
+ DataReady_ExecuteAction ,
+ Executing_SuspendAction ,
+ SuspendedExecuting_ResumeAction ,
+ Executing_KillAction ,
+ Executing_StopAction ,
+ Executing_SuccessAction ,
+ Executing_ErrorAction ,
+ Successed_SuccessAction ,
+ Errored_ErrorAction ,
+ Successed_SuspendAction ,
+ Errored_SuspendAction ,
+ SuspendedSuccessed_ResumeAction ,
+ SuspendedErrored_ResumeAction ,
+ Successed_KillAction ,
+ Errored_KillAction ,
+ Successed_StopAction ,
+ Errored_StopAction ,
+ SuspendedSuccessed_ReStartAction ,
+ SuspendedErrored_ReStartAction ,
+ SuspendedSuccessed_ReStartAndSuspendAction ,
+ SuspendedErrored_ReStartAndSuspendAction ,
+ NumberOfActions } ;
+
+ class FiniteStateMachine {
+
+ private :
+
+ char * _ControlStateName[ SUPERV::NumberOfControlStates ] ;
+ char * _StateName[ SUPERV::NumberOfAutomatonStates ] ;
+ char * _GraphStateName[ SUPERV::NumberOfGraphStates ] ;
+ char * _EventName[ GraphExecutor::NumberOfEvents ] ;
+ char * _ActionName[ NumberOfActions ] ;
+ SUPERV::AutomatonState _TransitionTable[ SUPERV::NumberOfAutomatonStates ]
+ [ GraphExecutor::NumberOfEvents ] ;
+ GraphExecutor::StateEventAction _ActionTable[ SUPERV::NumberOfAutomatonStates ]
+ [ GraphExecutor::NumberOfEvents ] ;
+
+ bool _JoinThread ;
+ pthread_t _JoinThreadNo ;
+ pthread_mutex_t _MutexJoinWait ;
+ pthread_cond_t _JoinWait ;
+ list< pthread_t > _ThreadList ;
+
+ public :
+
+ FiniteStateMachine() ;
+ virtual ~FiniteStateMachine() {} ;
+
+ void JoinThread() ;
+ void JoinThread( pthread_t aThread ) ;
+
+ const char * ControlStateName(
+ const SUPERV::ControlState & aState ) const {
+ return _ControlStateName[ aState ] ; } ;
+ const char * StateName(
+ const SUPERV::AutomatonState & aState ) const {
+ return _StateName[ aState ] ; } ;
+ const char * StateName(
+ const SUPERV::GraphState & aState ) const {
+ return _GraphStateName[ aState ] ; } ;
+ const char * EventName(
+ const GraphExecutor::NodeEvent & anEvent ) const {
+ return _EventName[ anEvent ] ; } ;
+ const char * ActionName(
+ const GraphExecutor::StateEventAction & anAction ) const {
+ return _ActionName[ anAction ] ; } ;
+
+ const SUPERV::AutomatonState NextState(
+ const SUPERV::AutomatonState & aState ,
+ const GraphExecutor::NodeEvent & anEvent ) const {
+ return _TransitionTable[ aState ][ anEvent ] ; } ;
+
+ const GraphExecutor::StateEventAction NextAction(
+ const SUPERV::AutomatonState & aState ,
+ const GraphExecutor::NodeEvent & anEvent ) const {
+ return _ActionTable[ aState ][ anEvent ] ; } ;
+ };
+
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : DataFlowBase_InNode.cxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#include <stdlib.h>
+#include <iostream>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "OpUtil.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Component)
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+
+#include "DataFlowBase_FactoryNode.hxx"
+#include "DataFlowBase_GOTONode.hxx"
+#include "DataFlowBase_LoopNode.hxx"
+#include "DataFlowBase_EndOfLoopNode.hxx"
+#include "DataFlowBase_SwitchNode.hxx"
+#include "DataFlowBase_EndOfSwitchNode.hxx"
+
+#include "DataFlowExecutor_OutNode.hxx"
+
+static void InitInNode( SUPERV::ControlState &_ControlState ,
+ SUPERV::AutomatonState &_currentState ,
+ GraphExecutor::InNode ** _aReStartNode ,
+ bool & _PyFuncRunned ,
+ PyObject ** _MyPyRunMethod ,
+ pthread_mutex_t &_MutexDataWait ,
+ bool &_DataWait ,
+ pthread_mutex_t &_MutexWait ,
+ pthread_cond_t &_ReadyWait ,
+ pthread_cond_t &_RunningWait ,
+ pthread_cond_t &_DoneWait ,
+ pthread_cond_t &_SuspendedWait ,
+ pthread_cond_t &_SuspendWait ,
+ bool &_SuspendSync ,
+ pthread_cond_t &_ResumeWait ,
+ bool &_ResumeSync ,
+ pthread_cond_t &_KillWait ,
+ bool &_KillSync ,
+ pthread_cond_t &_StopWait ,
+ GraphExecutor::FiniteStateMachine ** _Automaton ,
+ GraphExecutor::FiniteStateMachine * theAutomaton ,
+ CORBA::ORB_ptr * _Orb ,
+ CORBA::ORB_ptr ORB ) {
+ _ControlState = SUPERV::VoidState ;
+ _currentState = SUPERV::UnKnownState ;
+ *_aReStartNode = NULL ;
+ _PyFuncRunned = false ;
+ *_MyPyRunMethod = NULL ;
+ pthread_mutex_init( &_MutexDataWait , NULL ) ;
+ _DataWait = false ;
+ pthread_mutex_init( &_MutexWait , NULL ) ;
+ if ( pthread_cond_init( &_ReadyWait , NULL ) ) {
+ perror("pthread_cond_init( &_ReadyWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_RunningWait , NULL ) ) {
+ perror("pthread_cond_init( &_RunningWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_DoneWait , NULL ) ) {
+ perror("pthread_cond_init( &_DoneWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_SuspendedWait , NULL ) ) {
+ perror("pthread_cond_init( &_SuspendedWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_SuspendWait , NULL ) ) {
+ perror("pthread_cond_init( &_SuspendWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ _SuspendSync = false ;
+ if ( pthread_cond_init( &_ResumeWait , NULL ) ) {
+ perror("pthread_cond_init( &_ResumeWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ _ResumeSync = false ;
+ if ( pthread_cond_init( &_KillWait , NULL ) ) {
+ perror("pthread_cond_init( &_KillWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ _KillSync = false ;
+ if ( pthread_cond_init( &_StopWait , NULL ) ) {
+ perror("pthread_cond_init( &_StopWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ *_Automaton = theAutomaton ;
+ *_Orb = CORBA::ORB::_nil();
+}
+
+GraphExecutor::FiniteStateMachine * theAutomaton = new
+ GraphExecutor::FiniteStateMachine() ;
+
+//GraphExecutor::InNode::InNode() :
+// GraphBase::FactoryNode() {
+GraphExecutor::InNode::InNode() {
+ InitInNode( _ControlState ,
+ _currentState ,
+ &_aReStartNode ,
+ _PyFuncRunned ,
+ &_MyPyRunMethod ,
+ _MutexDataWait ,
+ _DataWait ,
+ _MutexWait ,
+ _ReadyWait ,
+ _RunningWait ,
+ _DoneWait ,
+ _SuspendedWait ,
+ _SuspendWait ,
+ _SuspendSync ,
+ _ResumeWait ,
+ _ResumeSync ,
+ _KillWait ,
+ _KillSync ,
+ _StopWait ,
+ &_Automaton ,
+ theAutomaton ,
+ &_Orb ,
+ CORBA::ORB::_nil() ) ;
+}
+
+GraphExecutor::InNode::InNode(CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const SALOME_ModuleCatalog::Service& aService ,
+ const char * ComponentName ,
+ const char * NodeInterfaceName ,
+ const char * NodeName ,
+ const SUPERV::KindOfNode akind ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const bool GeneratedName ,
+ const int NodeX ,
+ const int NodeY ,
+ int * Graph_prof_debug,
+ ostream * Graph_fdebug) {
+// ostream * Graph_fdebug = NULL ) :
+// GraphBase::FactoryNode( ORB , ptrNamingService , aService ,
+// ComponentName , NodeInterfaceName ,
+// NodeName , akind ,
+// NodeFirstCreation , NodeLastModification ,
+// NodeEditorRelease , NodeAuthor ,
+// NodeComputer , NodeComment , GeneratedName ,
+// 0 , 0 ,
+// Graph_prof_debug , Graph_fdebug ) {
+ InitInNode( _ControlState ,
+ _currentState ,
+ &_aReStartNode ,
+ _PyFuncRunned ,
+ &_MyPyRunMethod ,
+ _MutexDataWait ,
+ _DataWait ,
+ _MutexWait ,
+ _ReadyWait ,
+ _RunningWait ,
+ _DoneWait ,
+ _SuspendedWait ,
+ _SuspendWait ,
+ _SuspendSync ,
+ _ResumeWait ,
+ _ResumeSync ,
+ _KillWait ,
+ _KillSync ,
+ _StopWait ,
+ &_Automaton ,
+ theAutomaton ,
+ &_Orb ,
+ ORB ) ;
+ SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ;
+
+ _ComputingNode = NULL ;
+ _FactoryNode = NULL ;
+ _InLineNode = NULL ;
+ _GOTONode = NULL ;
+ _LoopNode = NULL ;
+ _EndOfLoopNode = NULL ;
+ _SwitchNode = NULL ;
+ _EndOfSwitchNode = NULL ;
+ switch ( akind ) {
+ case SUPERV::ComputingNode : {
+ cdebug << "GraphExecutor::InNode::InNode SUPERV::ComputingNode : " << NodeName ;
+ _ComputingNode = new GraphBase::ComputingNode( ORB , ptrNamingService ,
+ aService ,
+ NodeName , akind ,
+ NodeFirstCreation ,
+ NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ break ;
+ }
+ case SUPERV::FactoryNode : {
+ cdebug << "GraphExecutor::InNode::InNode SUPERV::FactoryNode : " << NodeName ;
+ _FactoryNode = new GraphBase::FactoryNode( ORB , ptrNamingService , aService ,
+ ComponentName , NodeInterfaceName ,
+ NodeName , akind ,
+ NodeFirstCreation ,
+ NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComputer , NodeComment ,
+ GeneratedName , NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _FactoryNode ;
+ break ;
+ }
+ case SUPERV::InLineNode : {
+ cdebug << "GraphExecutor::InNode::InNode SUPERV::InLineNode : " << NodeName ;
+ _InLineNode = new GraphBase::InLineNode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _InLineNode ;
+ break ;
+ }
+ case SUPERV::GOTONode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::GOTONode : " << NodeName ;
+ _GOTONode = new GraphBase::GOTONode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _GOTONode ;
+ break ;
+ }
+ case SUPERV::LoopNode : {
+ cdebug << "GraphExecutor::InNode::InNode SUPERV::LoopNode : " << NodeName ;
+ _LoopNode = new GraphBase::LoopNode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ aFuncName[1].c_str() , *aPythonFunction[1] ,
+ aFuncName[2].c_str() , *aPythonFunction[2] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _LoopNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ case SUPERV::EndLoopNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::EndOfLoopNode : " << NodeName ;
+ _EndOfLoopNode = new GraphBase::EndOfLoopNode(
+ ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _EndOfLoopNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ case SUPERV::SwitchNode : {
+ cdebug << "GraphExecutor::InNode::InNode SUPERV::SwitchNode : " << NodeName ;
+ _SwitchNode = new GraphBase::SwitchNode( ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _SwitchNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ case SUPERV::EndSwitchNode : {
+ cdebug << "GraphEditor::InNode::InNode SUPERV::EndOfSwitchNode : " << NodeName ;
+ _EndOfSwitchNode = new GraphBase::EndOfSwitchNode(
+ ORB , ptrNamingService ,
+ aFuncName[0].c_str() , *aPythonFunction[0] ,
+ NodeName , akind ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComment , GeneratedName ,
+ NodeX , NodeY ,
+ Graph_prof_debug , Graph_fdebug ) ;
+ _ComputingNode = (GraphBase::ComputingNode *) _EndOfSwitchNode ;
+ _GOTONode = (GraphBase::GOTONode *) _ComputingNode ;
+ break ;
+ }
+ }
+ cdebug << "GraphExecutor::InNode::InNode " << (void *) this
+ << " _ComputingNode " << (void *) _ComputingNode ;
+ _ComputingNode->InNode( this ) ;
+}
+
+GraphExecutor::InNode::~InNode() {
+}
+
+void GraphExecutor::InNode::LockDataWait() {
+ if ( pthread_mutex_lock( &_MutexDataWait ) ) {
+ perror("Ready pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ _DataWait = true ;
+}
+void GraphExecutor::InNode::UnLockDataWait() {
+ _DataWait = false ;
+ if ( pthread_mutex_unlock( &_MutexDataWait ) ) {
+ perror("Ready pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+bool GraphExecutor::InNode::Ping() {
+// cdebug_in << "GraphExecutor::InNode::Ping" << endl;
+ bool RetVal ;
+ if ( IsFactoryNode() ) {
+ RetVal = !CORBA::is_nil( _FactoryNode->Component() ) ;
+ if ( RetVal ) {
+ if ( State() != SUPERV::SuspendedExecutingState ) {
+ _FactoryNode->Component()->ping() ;
+ }
+ else {
+ RetVal = false ;
+ }
+ }
+ }
+// cdebug_out << "GraphExecutor::InNode::Ping" << endl ;
+ return RetVal ;
+}
+
+void GraphExecutor::InNode::NewThread( pthread_t aThread ) {
+ ThreadNo ( aThread ) ;
+ if ( aThread )
+ _OutNode->NewThread() ;
+}
+void GraphExecutor::InNode::ExitThread() {
+ ThreadNo( 0 ) ;
+ _OutNode->ExitThread() ;
+}
+
+bool GraphExecutor::InNode::Suspend() {
+ cdebug_in << "GraphExecutor::InNode::Suspend " << Name() << " " << ThreadNo()
+ << endl;
+ bool RetVal ;
+ if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ;
+ }
+ else if ( IsWaiting() || IsReady() ) {
+ ControlState( SUPERV::ToSuspendState ) ;
+ RetVal = true ;
+ }
+ else if ( IsRunning() ) {
+ ControlState( SUPERV::ToSuspendState ) ;
+ if ( IsFactoryNode() ) {
+ if ( !CORBA::is_nil( Component() ) ) {
+ RetVal = Component()->Suspend_impl() ;
+ if ( RetVal ) {
+ if ( IsRunning() ) {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ; // Too late ...
+ }
+ else {
+ cdebug << "component Suspended and !IsDone and !IsRunning !"
+ << endl ;
+ }
+ }
+ }
+ else {
+ cdebug << "Suspend cannot Suspend component !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ cdebug << "Suspend with nilComponent while RunningState !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ cdebug << "Suspend and !IsDone and !IsRunning and !IsWaiting ?"
+ << endl ;
+ RetVal = false ;
+ }
+ cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::ContainerKill() {
+ cdebug_in << "GraphExecutor::InNode::ContainerKill " << Name() << " "
+ << ThreadNo() << endl;
+ bool RetVal ;
+ if ( IsFactoryNode() ) {
+ Kill() ;
+ Container()->Kill_impl() ;
+ }
+ cdebug_out << "GraphExecutor::InNode::ContainerKill" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::Kill() {
+ cdebug_in << "GraphExecutor::InNode::Kill " << Name() << " " << ThreadNo() << " "
+ << Automaton()->StateName( State() ) << endl;
+ bool RetVal ;
+ if ( ControlState() == SUPERV::ToKillState || IsDone() ) {
+ RetVal = false ;
+ }
+ else {
+ ControlState( SUPERV::ToKillState ) ;
+ if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ;
+ }
+ else {
+ if ( IsRunning() ) {
+ if ( IsFactoryNode() ) {
+ if ( !CORBA::is_nil( Component() ) ) {
+ RetVal = Component()->Kill_impl() ;
+ if ( RetVal ) {
+ if ( IsRunning() ) {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ; // Too late ...
+ }
+ else {
+ cdebug << "component Killed and !IsDone and !IsRunning !"
+ << endl ;
+ }
+ }
+ }
+ else {
+ cdebug << "Kill cannot Kill component !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ cdebug << "Kill with nilComponent while RunningState !" << endl ;
+ SendEvent( GraphExecutor::KillEvent ) ;
+ RetVal = IsKilled() ;
+ }
+ }
+ else if ( IsSuspended() ) {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ RetVal = true ;
+ }
+ else if ( IsWaiting() ) {
+ RetVal = true ;
+ }
+ else {
+ cdebug << "Kill and !IsDone and !IsRunning and !IsWaiting ?"
+ << endl ;
+ RetVal = false ;
+ }
+ }
+ }
+ cdebug_out << "GraphExecutor::InNode::Kill" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::KillDone() {
+ cdebug_in << "GraphExecutor::InNode::KillDone " << Name() << " " << ThreadNo()
+ << endl;
+ bool RetVal ;
+ if ( ControlState() == SUPERV::ToKillDoneState || IsDone() ) {
+ RetVal = false ;
+ }
+ else {
+ ControlState( SUPERV::ToKillDoneState ) ;
+ if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ;
+ }
+ else {
+ if ( IsRunning() ) {
+ if ( IsFactoryNode() ) {
+ if ( !CORBA::is_nil( Component() ) ) {
+ RetVal = Component()->Kill_impl() ;
+ if ( RetVal ) {
+ if ( IsRunning() ) {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ; // Too late ...
+ }
+ else {
+ cdebug << "component Suspended and !IsDone and !IsRunning !"
+ << endl ;
+ }
+ }
+ }
+ else {
+ cdebug << "Suspend cannot Suspend component !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ cdebug << "Suspend with nilComponent while RunningState !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else if ( IsWaiting() ) {
+ RetVal = true ;
+ }
+ else {
+ cdebug << "Suspend and !IsDone and !IsRunning and !IsWaiting ?"
+ << endl ;
+ RetVal = false ;
+ }
+ }
+ }
+ cdebug_out << "GraphExecutor::InNode::KillDone" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::Stop() {
+ cdebug_in << "GraphExecutor::InNode::Stop " << Name() << " " << ThreadNo()
+ << endl;
+ bool RetVal ;
+ if ( ControlState() == SUPERV::ToStopState || IsDone() ) {
+ RetVal = false ;
+ }
+ else {
+ ControlState( SUPERV::ToStopState ) ;
+ if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ;
+ }
+ else {
+ if ( IsRunning() ) {
+ if ( IsFactoryNode() ) {
+ if ( !CORBA::is_nil( Component() ) ) {
+ RetVal = Component()->Stop_impl() ;
+ if ( RetVal ) {
+ if ( IsRunning() ) {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ; // Too late ...
+ }
+ else {
+ cdebug << "component Suspended and !IsDone and !IsRunning !"
+ << endl ;
+ }
+ }
+ }
+ else {
+ cdebug << "Suspend cannot Suspend component !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ cdebug << "Suspend with nilComponent while RunningState !" << endl ;
+ RetVal = false ;
+ }
+ }
+ else if ( IsWaiting() ) {
+ RetVal = true ;
+ }
+ else {
+ cdebug << "Suspend and !IsDone and !IsRunning and !IsWaiting ?"
+ << endl ;
+ RetVal = false ;
+ }
+ }
+ }
+ cdebug_out << "GraphExecutor::InNode::Stop" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::SuspendDone() {
+ cdebug_in << "GraphExecutor::InNode::SuspendDone " << Name() << " "
+ << ThreadNo() << endl;
+ bool RetVal ;
+ if ( ControlState() == SUPERV::ToSuspendDoneState || IsDone() ) {
+ RetVal = false ;
+ }
+ else {
+ ControlState( SUPERV::ToSuspendDoneState ) ;
+ if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ;
+ }
+ else {
+ RetVal = true ;
+ }
+ }
+ cdebug_out << "GraphExecutor::InNode::SuspendDone" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::Resume() {
+ cdebug_in << pthread_self() << "/" << ThreadNo()
+ << " GraphExecutor::InNode::Resume " << Name() << " "
+ << Automaton()->StateName( State() ) << endl;
+ bool RetVal = false ;
+ if ( IsSuspended() ) {
+ if ( State() == SUPERV::SuspendedReadyState ) {
+ ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ RetVal = true ;
+ }
+ else if ( State() == SUPERV::SuspendedExecutingState ) {
+ if ( IsFactoryNode() ) {
+ RetVal = Component()->Resume_impl() ;
+ }
+ }
+ else if ( State() == SUPERV::SuspendedSuccessedState ) {
+ ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ RetVal = true ;
+ }
+ else if ( State() == SUPERV::SuspendedErroredState ) {
+ ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ RetVal = true ;
+ }
+ else {
+ cdebug << "GraphExecutor::InNode::Resume Not SuspendedReady/Executing/Successed/ErroredState "
+ << Automaton()->StateName( State() ) << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ cdebug << "GraphExecutor::InNode::Resume Not Suspended State "
+ << Automaton()->StateName( State() ) << endl ;
+ RetVal = false ;
+ }
+ if ( ControlState() == SUPERV::ToSuspendStartState ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
+
+#if 0
+ if ( ControlState() == SUPERV::ToSuspendRunState ||
+ ( ControlState() == SUPERV::ToSuspendState &&
+ State() == SUPERV::SuspendedReadyState) ) {
+ if ( IsSuspended() ) {
+ if ( State() == SUPERV::SuspendedReadyState ) {
+ ResumeAction() ;
+ RetVal = true ;
+ }
+ else if ( State() == SUPERV::SuspendedExecutingState ) {
+ ResumeAction() ;
+ RetVal = Component()->Resume_impl() ;
+ }
+ else {
+ cdebug << "GraphExecutor::InNode::Resume State "
+ << Automaton()->StateName( State() ) << endl ;
+ RetVal = false ;
+ }
+ if ( ControlState() != SUPERV::ToSuspendState ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
+ }
+ else if ( IsRunning() ) {
+ RetVal = true ;
+ }
+ else if ( IsWaiting() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = true ;
+ }
+ else if ( IsDone() ) {
+ RetVal = true ;
+ }
+ }
+ else if ( ControlState() == SUPERV::ToSuspendDoneState ||
+ ( ControlState() == SUPERV::ToSuspendState &&
+ State() == SUPERV::SuspendedSuccessedState) ) {
+ if ( IsSuspended() ) {
+ if ( State() == SUPERV::SuspendedSuccessedState ) {
+ ResumeAction() ;
+ RetVal = true ;
+ }
+ else if ( State() == SUPERV::SuspendedErroredState ) {
+ ResumeAction() ;
+ RetVal = true ;
+ }
+ else {
+ cdebug << "GraphExecutor::InNode::Resume State " << State() << endl ;
+ RetVal = false ;
+ }
+ if ( ControlState() != SUPERV::ToSuspendState ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
+ }
+ else if ( IsRunning() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = true ;
+ }
+ else if ( IsWaiting() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = true ;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = true ;
+ }
+ }
+#endif
+ cdebug_out << "GraphExecutor::InNode::Resume " << RetVal << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::ReStart( const char * AtNodeName ,
+ const bool AndSuspend ) {
+ bool RetVal = false ;
+ GraphExecutor::InNode * aRestartNode = (GraphExecutor::InNode *) _OutNode->GetGraphNode( AtNodeName )->GetInNode() ;
+ cdebug_in << pthread_self() << "/" << ThreadNo()
+ << " --> GraphExecutor::InNode::ReStartAt( "
+ << AtNodeName << " , " << AndSuspend << ") " << endl
+ << "thread " << aRestartNode->ThreadNo() << " "
+ << Automaton()->StateName( aRestartNode->State() )
+ << " from " << Name() << " " << Automaton()->StateName( State() )
+ << endl ;
+ if ( IsWaiting() && aRestartNode->IsSuspended() ) {
+ RetVal = aRestartNode->Resume() ;
+ }
+ else if ( IsSuspended() ) {
+ if ( strcmp( AtNodeName , Name() ) ) {
+ aRestartNode->State( SUPERV::SuspendedSuccessedState ) ;
+ }
+ if ( AndSuspend ) {
+ ReStartAction( aRestartNode , GraphExecutor::ReStartAndSuspendEvent ) ;
+ }
+ else {
+ ReStartAction( aRestartNode , GraphExecutor::ReStartEvent ) ;
+ }
+ RetVal = true ;
+ }
+ cdebug_out << "<-- GraphExecutor::InNode::ReStartAt" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::IsWaiting() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsWaiting " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::DataUndefState ||
+ aState == SUPERV::DataWaitingState ||
+ aState == SUPERV::SuspendedReadyState )
+// aState == SUPERV::SuspendedExecutingState ||
+// aState == SUPERV::SuspendedSuccessedState ||
+// aState == SUPERV::SuspendedErroredState ||
+// aState == SUPERV::SuspendedState
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsWaiting" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::IsReady() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsReady " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::DataUndefState ||
+ aState == SUPERV::DataWaitingState ||
+ aState == SUPERV::DataReadyState ||
+ aState == SUPERV::ResumedReadyState )
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsReady" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::IsRunning() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsRunning " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::ExecutingState ||
+ aState == SUPERV::ResumedExecutingState )
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsRunning" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::IsDone() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsDone " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::KilledReadyState ||
+ aState == SUPERV::StoppedReadyState ||
+ aState == SUPERV::KilledExecutingState ||
+ aState == SUPERV::StoppedExecutingState ||
+ aState == SUPERV::SuspendedSuccessedState ||
+ aState == SUPERV::SuspendedErroredState ||
+// aState == SUPERV::SuccessedExecutingState ||
+// aState == SUPERV::ErroredExecutingState ||
+ aState == SUPERV::SuccessedState ||
+ aState == SUPERV::ErroredState ||
+ aState == SUPERV::ResumedSuccessedState ||
+ aState == SUPERV::ResumedErroredState ||
+ aState == SUPERV::KilledSuccessedState ||
+ aState == SUPERV::StoppedSuccessedState )
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsDone" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::IsSuspended() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsSuspended " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::SuspendedReadyState ||
+ aState == SUPERV::SuspendedExecutingState ||
+ aState == SUPERV::SuspendedSuccessedState ||
+ aState == SUPERV::SuspendedErroredState )
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsSuspended" << endl ;
+ return aret ;
+}
+bool GraphExecutor::InNode::IsKilled() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsKilled " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::KilledReadyState ||
+ aState == SUPERV::KilledExecutingState ||
+ aState == SUPERV::KilledSuccessedState ||
+ aState == SUPERV::KilledErroredState ||
+ aState == SUPERV::KilledState )
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsKilled" << endl ;
+ return aret ;
+}
+bool GraphExecutor::InNode::IsStopped() {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::InNode::IsStopped " << Name() << endl;
+ SUPERV::AutomatonState aState = State() ;
+ if ( aState == SUPERV::StoppedReadyState ||
+ aState == SUPERV::StoppedExecutingState ||
+ aState == SUPERV::StoppedSuccessedState ||
+ aState == SUPERV::StoppedErroredState ||
+ aState == SUPERV::StoppedState )
+ aret = true ;
+// cdebug_out << "GraphExecutor::InNode::IsStopped" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::StateWait( SUPERV::GraphState aState ) {
+ bool RetVal = false ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _Wait") ;
+ exit( 0 ) ;
+ }
+ switch ( aState ) {
+ case SUPERV::ReadyState : {
+ RetVal = IsReady() ;
+ cdebug_in << pthread_self() << " StateWait( Ready ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _ReadyWait " << Name() << endl ;
+ while ( !RetVal && !IsDone() ) {
+ cdebug << pthread_self() << " pthread_cond_wait ReadyWait" << endl ;
+ pthread_cond_wait( &_ReadyWait , &_MutexWait );
+ RetVal = IsReady() ;
+ cdebug << pthread_self() << " pthread_cond_waited ReadyWait "
+ << Automaton()->StateName( _currentState ) << " " << RetVal
+ << endl ;
+ }
+ cdebug_out << pthread_self() << " StateWait( Ready ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _ReadyWait " << Name() << endl ;
+ break ;
+ }
+ case SUPERV::RunningState : {
+ RetVal = IsRunning() ;
+ cdebug_in << pthread_self() << " StateWait( Running ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _RunningWait " << Name() << endl ;
+ while ( !RetVal && !IsDone() ) {
+ cdebug << pthread_self() << " pthread_cond_wait RunningWait" << endl ;
+ pthread_cond_wait( &_RunningWait , &_MutexWait );
+ RetVal = IsRunning() ;
+ cdebug << pthread_self() << " pthread_cond_waited RunningWait "
+ << Automaton()->StateName( _currentState ) << " " << RetVal
+ << endl ;
+ }
+ cdebug_out << pthread_self() << " StateWait( Running ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _RunningWait " << Name() << endl ;
+ break ;
+ }
+ case SUPERV::DoneState : {
+ RetVal = IsDone() ;
+ cdebug_in << pthread_self() << " StateWait( Done ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _DoneWait " << Name() << endl ;
+ while ( !RetVal ) {
+ cdebug << pthread_self() << " pthread_cond_wait DoneWait" << endl ;
+ pthread_cond_wait( &_DoneWait , &_MutexWait );
+ RetVal = IsDone() ;
+ cdebug << pthread_self() << " pthread_cond_waited DoneWait "
+ << Automaton()->StateName( _currentState ) << " " << RetVal
+ << endl ;
+ }
+ cdebug_out << pthread_self() << " StateWait( Done ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _DoneWait " << Name() << endl ;
+ break ;
+ }
+ case SUPERV::SuspendState : {
+ RetVal = IsSuspended() ;
+ cdebug_in << pthread_self() << " StateWait( Suspend ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _SuspendedWait " << Name() << endl ;
+ while ( !RetVal && !IsDone() ) {
+ cdebug << pthread_self() << " pthread_cond_wait SuspendedWait" << endl ;
+ pthread_cond_wait( &_SuspendedWait , &_MutexWait );
+ RetVal = IsSuspended() ;
+ cdebug << pthread_self() << " pthread_cond_waited SuspendedWait "
+ << Automaton()->StateName( _currentState ) << " " << RetVal
+ << endl ;
+ }
+ cdebug_out << pthread_self() << " StateWait( Suspend ) " << RetVal
+ << " " << Automaton()->StateName( _currentState )
+ << " pthread_cond_wait _SuspendedWait " << Name() << endl ;
+ break ;
+ }
+ default : {
+ cdebug << " GraphExecutor::OutNode::StateWait Error Undefined State : "
+ << aState << endl ;
+ }
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _Wait") ;
+ exit( 0 ) ;
+ }
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::ReadyWait() {
+// cdebug_in << "GraphExecutor::InNode::ReadyWait " << Name() << endl;
+ bool aret ;
+ aret = StateWait( SUPERV::ReadyState ) ;
+// cdebug_out << "GraphExecutor::InNode::ReadyWait" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::RunningWait() {
+// cdebug_in << "GraphExecutor::InNode::RunningWait " << Name() << endl;
+ bool aret ;
+ aret = StateWait( SUPERV::RunningState ) ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::DoneWait() {
+// cdebug_in << "GraphExecutor::InNode::DoneWait " << Name() << endl;
+ bool aret ;
+ aret = StateWait( SUPERV::DoneState ) ;
+ return aret ;
+}
+
+bool GraphExecutor::InNode::SuspendedWait() {
+// cdebug_in << "GraphExecutor::InNode::SuspendedWait " << Name() << endl;
+ bool aret ;
+ aret = StateWait( SUPERV::SuspendState ) ;
+ return aret ;
+}
+
+void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode )
+{
+ cdebug_in << "GraphExecutor::InNode::InitialState Node " << Name() << endl;
+
+ _OutNode = theOutNode ;
+
+ int i;
+ _ControlState = SUPERV::VoidState ;
+ CreateNewThread( false ) ;
+ CreateNewThreadIf( false ) ;
+ _SuspendSync = false ;
+ _ResumeSync = false ;
+// ThreadNo( pthread_self() ) ;
+ ThreadNo( 0 ) ;
+
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ if ( i != 0 || !IsGOTONode() ) {
+ GetChangeNodeOutPort(i)->State( SUPERV::WaitingState ) ;
+ GetChangeNodeOutPort(i)->Done( false ) ;
+ }
+ }
+
+ int Pc = GetNodeInPortsSize() ;
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ const GraphBase::InPort * anInPort = GetNodeInPort(i) ;
+ 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->Value( anAny ) ;
+ }
+ else if ( anInPort->IsGate() && anOutPort ) {
+ if ( IsComputingNode() || IsFactoryNode() ) {
+ anOutPort->State( SUPERV::WaitingState ) ;
+ anOutPort->Done( false ) ;
+ }
+ else if ( IsOneOfInLineNodes() ) {
+ anOutPort->PortStatus( DataConnected );
+ anOutPort->State( SUPERV::ReadyState ) ;
+ anOutPort->Done( true ) ;
+ }
+ }
+// if ( ( anInPort->IsGate() || anInPort->IsBus() ) && anOutPort == NULL ) {
+ if ( ( anInPort->IsGate() ) && anOutPort == NULL ) {
+ Pc-- ;
+ }
+ else {
+ if ( anOutPort->IsDataConnected() ) {
+ Pc-- ;
+ }
+ if ( anOutPort->IsPortConnected() ) {
+ anOutPort->State( SUPERV::WaitingState ) ;
+ anOutPort->Done( false ) ;
+ }
+ else if ( anOutPort->IsDataConnected() ) {
+ anOutPort->State( SUPERV::ReadyState ) ;
+ anOutPort->Done( true ) ;
+ }
+ }
+ if ( anOutPort ) {
+ GetChangeNodeInPort(i)->State( anOutPort->State() ) ;
+ }
+ if ( anOutPort ) {
+ cdebug << "InPort" << i << " : " << anInPort->PortName() << " from OutPort "
+ << anOutPort->PortName() << " from Node " << anOutPort->NodeName()
+ << " with state " ;
+ if ( anOutPort->State() == SUPERV::WaitingState ) {
+ cdebug << "WaitingState" ;
+ }
+ else if ( anOutPort->State() == SUPERV::ReadyState ) {
+ cdebug << "ReadyState" ;
+ }
+ else {
+ cdebug << "???" ;
+ }
+ cdebug << " PortConnected("
+ << anOutPort->IsPortConnected() << ") DataConnected("
+ << anOutPort->IsDataConnected() << ")" << endl ;
+ }
+
+ if ( !PyFuncRunned() ) {
+ bool Err = false ;
+ if ( IsLoopNode() ) {
+ PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ PyObject * PyMoreMethod = NULL ;
+ if ( PyRunMethod ) {
+ PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
+ LoopNode()->MorePythonFunction() ) ;
+ LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+ }
+ PyObject * PyNextMethod = NULL ;
+ if ( PyMoreMethod ) {
+ PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
+ LoopNode()->NextPythonFunction() ) ;
+ LoopNode()->PyNextMethod( PyNextMethod ) ;
+ }
+ Err = !PyRunMethod || !PyMoreMethod || !PyNextMethod ;
+ }
+ else if ( IsInLineNode() || IsSwitchNode() ) {
+ PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ Err = !PyRunMethod ;
+ }
+ else if ( ( IsEndSwitchNode() || IsGOTONode() ) &&
+ (*InLineNode()->PythonFunction()).length() ) {
+ PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ Err = !PyRunMethod ;
+ }
+ }
+ }
+
+ _currentState = Pc > 0 ? SUPERV::DataWaitingState
+ : SUPERV::DataReadyState ;
+ if ( Pc == GetNodeInPortsSize() ) {
+ _OutNode->PushEvent( this , GraphExecutor::NoDataReadyEvent ,
+ _currentState ) ;
+ }
+ else if ( Pc != 0 ) {
+ _OutNode->PushEvent( this , GraphExecutor::SomeDataReadyEvent ,
+ _currentState ) ;
+ }
+ else {
+ _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
+ _currentState ) ;
+ }
+ cdebug << "CurrentState = " << theAutomaton->StateName( _currentState )
+ << endl;
+
+#if 0
+ GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) _OutNode->GetGraphNode( "label_begin" ) ;
+ const GraphBase::InPort * anInPort = anInNode->GetNodeInPort(0) ;
+ GraphBase::OutPort * anOutPort = anInPort->GetLink() ;
+ if ( anOutPort ) {
+ cdebug << "InPort" << i << " : " << anInPort->PortName() << " from OutPort "
+ << anOutPort->PortName() << " from Node " << anOutPort->NodeName()
+ << " with state " ;
+ if ( anOutPort->State() == SUPERV::WaitingState ) {
+ cdebug << "WaitingState" ;
+ }
+ else if ( anOutPort->State() == SUPERV::ReadyState ) {
+ cdebug << "ReadyState" ;
+ }
+ else {
+ cdebug << "???" ;
+ }
+ cdebug << " PortConnected("
+ << anOutPort->IsPortConnected() << ") DataConnected("
+ << anOutPort->IsDataConnected() << ")" << endl ;
+ }
+#endif
+
+ cdebug_out << "GraphExecutor::InNode::InitialState" << endl;
+}
+
--- /dev/null
+//=============================================================================
+// File : DataFlowBase_InNode.hxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#ifndef _DATAFLOWEXECUTOR_INNODE_HXX
+#define _DATAFLOWEXECUTOR_INNODE_HXX
+
+#include <stdio.h>
+
+#include <Python.h>
+
+#include "DataFlowBase_FactoryNode.hxx"
+#include "DataFlowBase_GOTONode.hxx"
+#include "DataFlowBase_LoopNode.hxx"
+#include "DataFlowBase_EndOfLoopNode.hxx"
+#include "DataFlowBase_SwitchNode.hxx"
+#include "DataFlowBase_EndOfSwitchNode.hxx"
+
+#include "DataFlowExecutor_FiniteStateMachine.hxx"
+
+void * run_function(void *p);
+
+extern GraphExecutor::FiniteStateMachine * theAutomaton ;
+
+extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * args ) ;
+
+namespace GraphExecutor {
+
+ struct ServicesAnyData {
+ string Name;
+ CORBA::Any Value;
+ };
+
+ class OutNode ;
+
+// class InNode : public GraphBase::Node {
+ class InNode : public GraphBase::Base {
+
+ private:
+
+ GraphBase::ComputingNode * _ComputingNode ;
+ GraphBase::FactoryNode * _FactoryNode ;
+ GraphBase::InLineNode * _InLineNode ;
+ GraphBase::GOTONode * _GOTONode ;
+ GraphBase::LoopNode * _LoopNode ;
+ GraphBase::EndOfLoopNode * _EndOfLoopNode ;
+ GraphBase::SwitchNode * _SwitchNode ;
+ GraphBase::EndOfSwitchNode * _EndOfSwitchNode ;
+
+ PyObject * _MyPyRunMethod ;
+
+ bool _createNewThread ;
+ bool _createNewThreadIf ;
+ SUPERV::AutomatonState _currentState ;
+ SUPERV::ControlState _ControlState ;
+ SUPERV::AutomatonState _NextState ;
+ GraphExecutor::StateEventAction _NextAction ;
+ bool _PyFuncRunned ;
+
+ pthread_mutex_t _MutexDataWait ;
+ bool _DataWait ;
+
+ pthread_mutex_t _MutexWait ;
+
+ pthread_cond_t _ReadyWait ;
+ pthread_cond_t _RunningWait ;
+ pthread_cond_t _DoneWait ;
+ pthread_cond_t _SuspendedWait ;
+
+ pthread_cond_t _SuspendWait ;
+ bool _SuspendSync ;
+ pthread_cond_t _ResumeWait ;
+ bool _ResumeSync ;
+ GraphExecutor::NodeEvent _aResumeEvent ;
+ GraphExecutor::InNode * _aReStartNode ;
+ GraphExecutor::NodeEvent _aReStartEvent ;
+
+ pthread_cond_t _KillWait ;
+ bool _KillSync ;
+ pthread_cond_t _StopWait ;
+
+ GraphExecutor::FiniteStateMachine * _Automaton ;
+
+ CORBA::ORB_ptr _Orb;
+
+ GraphExecutor::OutNode * _OutNode ;
+
+ char * _DataFromNode ;
+
+ public:
+
+ InNode() ;
+ InNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService,
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ const char *NodeComponentName ,
+ const char* NodeInterfaceName ,
+ const char *NodeName ,
+ const SUPERV::KindOfNode akind = SUPERV::ComputingNode ,
+ GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ,
+ GraphBase::ListOfPythonFunctions aPythonFunction = GraphBase::ListOfPythonFunctions() ,
+ 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 bool GeneratedName = false ,
+ const int NodeX = 0 ,
+ const int NodeY = 0 ,
+ int * Graph_prof_debug = NULL ,
+ ostream * Graph_fdebug = NULL ) ;
+ virtual ~InNode() ;
+
+ pthread_t ThreadNo() {
+ return _ComputingNode->ThreadNo() ; } ;
+ void ThreadNo( pthread_t aThread ) {
+ _ComputingNode->ThreadNo ( aThread ) ; } ;
+
+ char * Name() const {
+ return _ComputingNode->Name() ; } ;
+ const char *const * NamePtr() const {
+ return _ComputingNode->NamePtr() ; } ;
+ SUPERV::KindOfNode Kind() const {
+ return _ComputingNode->Kind() ; } ;
+ const bool IsComputingNode() const {
+ return _ComputingNode->IsComputingNode() ; } ;
+ const bool IsFactoryNode() const {
+ return _ComputingNode->IsFactoryNode() ; } ;
+ const bool IsInLineNode() const {
+ return _ComputingNode->IsInLineNode() ; } ;
+ const bool IsOneOfInLineNodes() const {
+ return _ComputingNode->IsOneOfInLineNodes() ; } ;
+ const bool IsOneOfGOTONodes() const {
+ return _ComputingNode->IsOneOfGOTONodes() ; } ;
+ const bool IsDataFlowNode() const {
+ return _ComputingNode->IsDataFlowNode() ; } ;
+ const bool IsLoopNode() const {
+ return _ComputingNode->IsLoopNode() ; } ;
+ const bool IsEndLoopNode() const {
+ return _ComputingNode->IsEndLoopNode() ; } ;
+ const bool IsSwitchNode() const {
+ return _ComputingNode->IsSwitchNode() ; } ;
+ const bool IsEndSwitchNode() const {
+ return _ComputingNode->IsEndSwitchNode() ; } ;
+ const bool IsGOTONode() const {
+ return _ComputingNode->IsGOTONode() ; } ;
+ const bool IsHeadNode() const {
+ return _ComputingNode->IsHeadNode() ; } ;
+ GraphBase::ComputingNode * ComputingNode() {
+ return _ComputingNode ; } ;
+ GraphBase::FactoryNode * FactoryNode() {
+ return _FactoryNode ; } ;
+ GraphBase::GOTONode * GOTONode() {
+ if ( _GOTONode )
+ return _GOTONode ;
+ if ( _LoopNode )
+ return _LoopNode ;
+ if ( _EndOfLoopNode )
+ return _EndOfLoopNode ;
+ if ( _SwitchNode )
+ return _SwitchNode ;
+ if ( _EndOfSwitchNode )
+ return _EndOfSwitchNode ;
+ return NULL ;
+ } ;
+ GraphBase::InLineNode * InLineNode() {
+ GraphBase::InLineNode * aNode = GOTONode() ;
+ if ( aNode == NULL )
+ return _InLineNode ;
+ return aNode ;
+ } ;
+ GraphBase::LoopNode * LoopNode() {
+ return _LoopNode ; } ;
+
+ Engines::Component_var Component() const {
+ return _FactoryNode->Component() ; } ;
+ Engines::Container_var Container() const {
+ return _FactoryNode->Container() ; } ;
+ void SetContainer(Engines::Container_var aContainer) {
+ _FactoryNode->SetContainer( aContainer ) ; } ;
+ void SetComponent(Engines::Component_var anObjComponent) {
+ _FactoryNode->SetComponent( anObjComponent ) ; } ;
+ void ObjInterface( bool k_interface ) {
+ _ComputingNode->ObjInterface( k_interface ) ; } ;
+ bool ObjInterface() {
+ return _FactoryNode->ObjInterface() ; } ;
+ char * ComponentName() const { return _FactoryNode->ComponentName() ; } ;
+ char * InterfaceName() const { return _FactoryNode->InterfaceName() ; } ;
+ char * Computer() const { return _FactoryNode->Computer() ; } ;
+ const char * ServiceName() const {
+ return _ComputingNode->ServiceName() ; } ;
+ const SALOME_ModuleCatalog::ListOfServicesParameter ServiceInParameter() const {
+ return _ComputingNode->ServiceInParameter() ; } ;
+ const SALOME_ModuleCatalog::ListOfServicesParameter ServiceOutParameter() const {
+ return _ComputingNode->ServiceOutParameter() ; } ;
+
+ void CoupledNode( GraphBase::InLineNode * aCoupledNode ) {
+ GOTONode()->CoupledNode( aCoupledNode ) ; } ;
+ GraphBase::InLineNode * CoupledNode() {
+ return GOTONode()->CoupledNode() ; } ;
+
+ GraphBase::InPort * AddInPort( const char * InputParameterName ,
+ const char * InputParameterType ) {
+ return _ComputingNode->AddInPort( InputParameterName ,
+ InputParameterType ) ; } ;
+ GraphBase::OutPort * AddOutPort( const char * OutputParameterName ,
+ const char * OutputParameterType ) {
+ return _ComputingNode->AddOutPort( OutputParameterName ,
+ OutputParameterType ) ; } ;
+// void InOutPort( GraphBase::InPort * InputPort ,
+// GraphBase::OutPort * OutputPort ) {
+// return _ComputingNode->InOutPort( InputPort , OutputPort ) ; } ;
+ int LinkedNodesSize() const {
+ return _ComputingNode->LinkedNodesSize() ; } ;
+ GraphBase::ComputingNode * LinkedNodes( int i ) const {
+ return _ComputingNode->LinkedNodes( i ) ; } ;
+ const int LinkedInPortsNumber( int i ) const {
+ return _ComputingNode->LinkedInPortsNumber( i ) ; } ;
+
+ const int GetNodeInPortsSize() const {
+ return _ComputingNode->GetNodeInPortsSize() ; } ;
+ const GraphBase::InPort *GetNodeInPort(int i) const {
+ return _ComputingNode->GetNodeInPort( i ) ; } ;
+ GraphBase::InPort *GetChangeNodeInPort(int i) const {
+ return _ComputingNode->GetChangeNodeInPort( i ) ; } ;
+ const int GetNodeOutPortsSize() const {
+ return _ComputingNode->GetNodeOutPortsSize() ; } ;
+ const GraphBase::OutPort *GetNodeOutPort(int i) const {
+ return _ComputingNode->GetNodeOutPort( i ) ; } ;
+ GraphBase::OutPort *GetChangeNodeOutPort(int i) const {
+ return _ComputingNode->GetChangeNodeOutPort( i ) ; } ;
+
+ const GraphBase::InPort *GetInPort( const char *name ) {
+ return _ComputingNode->GetInPort( name ) ; } ;
+ const GraphBase::OutPort *GetOutPort( const char *name ) {
+ return _ComputingNode->GetOutPort( name ) ; } ;
+ GraphBase::InPort *GetChangeInPort( const char *name ) {
+ return _ComputingNode->GetChangeInPort( name ) ; } ;
+ GraphBase::OutPort *GetChangeOutPort( const char *name ) {
+ return _ComputingNode->GetChangeOutPort( name ) ; } ;
+
+ void PyFuncRunned( bool arunned ) {
+ _PyFuncRunned = arunned ; } ;
+ bool PyFuncRunned() {
+ return _PyFuncRunned ; } ;
+
+ bool InitPython() ;
+ PyObject * InitPyDynInvoke( char * PyFuncName ,
+ const SUPERV::ListOfStrings * aPythonFunction ) ;
+
+ void LockDataWait() ;
+ void UnLockDataWait() ;
+ bool IsLockedDataWait() { return _DataWait ; } ;
+
+ bool Ping() ;
+ bool ContainerKill() ;
+
+ bool Kill() ;
+ bool KillDone() ;
+ bool Suspend() ;
+ bool SuspendDone() ;
+ bool Resume() ;
+ bool ReStart( const char * AtNodeName , const bool AndSuspend ) ;
+ bool Stop() ;
+
+ void CreateNewThread( bool k_create ) { _createNewThread = k_create ; } ;
+ void CreateNewThreadIf( bool k_create ) { _createNewThreadIf = k_create ; } ;
+ bool CreateNewThread() { return _createNewThread ; } ;
+ bool CreateNewThreadIf() { return _createNewThreadIf ; } ;
+ void NewThread( pthread_t aThread ) ;
+ void ExitThread() ;
+
+ SUPERV::AutomatonState State() const {
+ return _currentState; };
+ void State(SUPERV::AutomatonState aState ) {
+ cdebug << "GraphExecutor::InNode::State( "
+ << Automaton()->StateName( _currentState ) << " --> "
+ << Automaton()->StateName( aState ) << " )" << endl ;
+ _currentState = aState ; } ;
+ SUPERV::ControlState ControlState() const {
+ return _ControlState; };
+ void ControlState(SUPERV::ControlState aControlState ) {
+ _ControlState = aControlState ; } ;
+ void ControlClear() {
+ _ControlState = SUPERV::VoidState ; } ;
+
+ void SetAutomaton() {
+ _Automaton = theAutomaton ; } ;
+ GraphExecutor::FiniteStateMachine * Automaton() const {
+ return _Automaton ; } ;
+
+ bool IsWaiting() ;
+ bool IsReady() ;
+ bool IsRunning() ;
+ bool IsDone() ;
+ bool IsSuspended() ;
+ bool IsKilled() ;
+ bool IsStopped() ;
+
+ bool StateWait( SUPERV::GraphState aState ) ;
+ bool ReadyWait() ;
+ bool RunningWait() ;
+ bool DoneWait() ;
+ bool SuspendedWait() ;
+
+ void InitialState( GraphExecutor::OutNode * theOutNode );
+ void SetWaitingStates(GraphExecutor::InNode * EndNode ) ;
+
+ int SendEvent(const GraphExecutor::NodeEvent anEvent ) ;
+ void DataFromNode( char * FromNodeName ) {
+ _DataFromNode = FromNodeName ; } ;
+ const char * DataFromNode() const { return _DataFromNode ; } ;
+
+ int ErrorAction();
+ int VoidAction();
+ void ReadyAction() ;
+ void RunningAction() ;
+ void DoneAction() ;
+ void SuspendedAction() ;
+ GraphExecutor::InNode * SuspendAction() ;
+ bool ResumeAction(GraphExecutor::NodeEvent aResumeEvent ) ;
+ bool ReStartAction( GraphExecutor::InNode * aRestartNode ,
+ GraphExecutor::NodeEvent anEvent ) ;
+ void KillAction() ;
+ void KilledAction() ;
+ void StopAction() ;
+ void StoppedAction() ;
+ int executeAction() ; // New Thread or Same Thread
+ int ExecuteAction() ;
+
+ int DataWaiting_SomeDataReadyAction() ;
+ int DataUndef_NotAllDataReadyAction() ;
+ int DataUndef_AllDataReadyAction() ;
+ int DataReady_SuspendAction() ;
+ int SuspendedReady_ResumeAction() ;
+ int DataReady_KillAction() ;
+ int DataReady_StopAction() ;
+ int DataReady_ExecuteAction() ;
+ void DynInvoke( Engines::Component_ptr obj,
+ const char *method,
+ ServicesAnyData * inParams, int nInParams,
+ ServicesAnyData * outParams, int nOutParams) ;
+ void DynInvoke( Engines::Component_ptr obj,
+ const char *method,
+ const char * aGraphName ,
+ const char * aNodeName );
+ bool PyDynInvoke( PyObject * MyPyRunMethod ,
+ const char *method ,
+ ServicesAnyData * inParams , int nInParams ,
+ ServicesAnyData * inParams , int nOutParams ) ;
+
+ int Executing_SuspendAction() ;
+ int SuspendedExecuting_ResumeAction() ;
+ int Executing_KillAction() ;
+ int Executing_StopAction() ;
+ int Executing_SuccessAction() ;
+ int Executing_ErrorAction() ;
+ int Successed_SuccessAction() ;
+ bool SendSomeDataReady( char * FromNodeName ) ;
+ int Errored_ErrorAction() ;
+ int Successed_SuspendAction() ;
+ int Errored_SuspendAction() ;
+ int SuspendedSuccessed_ResumeAction() ;
+ int SuspendedErrored_ResumeAction() ;
+ int Successed_KillAction() ;
+ int Errored_KillAction() ;
+ int Successed_StopAction() ;
+ int Errored_StopAction() ;
+ int SuspendedSuccessed_ReStartAction() ;
+ int SuspendedErrored_ReStartAction() ;
+ int SuspendedSuccessed_ReStartAndSuspendAction() ;
+ int SuspendedErrored_ReStartAndSuspendAction() ;
+
+ void InParametersSet( bool & Err ,
+ int nInParams ,
+ ServicesAnyData * aListOfInParameters ) ;
+ void InOutParameters( int nOutParams ,
+ ServicesAnyData * aListOfOutParameters ) ;
+ bool OutParameters( bool Err , SUPERV::GraphState NewState ,
+ int nOutParams ,
+ ServicesAnyData * aListOfOutParameters ) ;
+ void coutbegin() ;
+ void coutexit() ;
+ } ;
+
+} ;
+
+#endif
+
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : DataFlowBase_InNodeThreads.cxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#include <stdlib.h>
+#include <iostream>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "Python.h"
+
+#include "OpUtil.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Component)
+#include "SALOME_NamingService.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+
+//#include "DataFlowExecutor_InNode.hxx"
+
+#include "DataFlowExecutor_OutNode.hxx"
+
+static char *containerName = "FactoryServer" ;
+
+int GraphExecutor::InNode::SendEvent(
+ const GraphExecutor::NodeEvent anEvent ) {
+ SUPERV::AutomatonState old_state ;
+
+ cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
+ << " ControlState : "
+ << Automaton()->ControlStateName( ControlState() )
+ << " Event : " << Automaton()->EventName( anEvent )
+ << " State : " << Automaton()->StateName( State() ) << endl;
+
+ old_state = State() ;
+ _NextState = Automaton()->NextState( old_state , anEvent ) ;
+ if ( _NextState == old_state ) {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " GraphExecutor::InNodeThreads::SendEvent SameStates "
+ << old_state << endl ;
+ _NextAction = GraphExecutor::VoidAction ;
+ }
+ else {
+ _NextAction = Automaton()->NextAction( _NextState , anEvent ) ;
+ }
+
+// State( _NextState ) ;
+// if ( old_state == SUPERV::SuccessedExecutingState ||
+// old_state == SUPERV::ErroredExecutingState ) {
+// DoneAction() ;
+// }
+
+ cdebug << pthread_self() << "/" << ThreadNo() << " SendedEvent Node "
+ << Name() << endl << " ControlState : "
+ << Automaton()->ControlStateName( ControlState() ) << endl
+ << " OldState : " << Automaton()->StateName( old_state ) << endl
+ << " Event : " << Automaton()->EventName( anEvent ) << endl
+ << " NextState : " << Automaton()->StateName( _NextState ) << endl
+ << " Action : " << Automaton()->ActionName( _NextAction ) << endl
+ << " CreateNewThread " << CreateNewThread() << endl ;
+
+#if 0
+ cout << pthread_self() << "/" << ThreadNo() << " SendedEvent Node " << Name()
+ << endl << " ControlState : "
+ << Automaton()->ControlStateName( ControlState() ) << endl
+ << " OldState : " << Automaton()->StateName( old_state ) << endl
+ << " Event : " << Automaton()->EventName( anEvent ) << endl
+ << " NextState : " << Automaton()->StateName( _NextState ) << endl
+ << " Action : " << Automaton()->ActionName( _NextAction ) << endl
+ << " CreateNewThread " << CreateNewThread() << endl ;
+#endif
+
+ int sts = executeAction() ;
+
+ cdebug << pthread_self() << "/" << ThreadNo() << " <- SendEvent Node " << Name()
+ << " Event : " << Automaton()->EventName( anEvent )
+ << " State : " << Automaton()->StateName( State() )
+ << endl;
+
+ return sts ;
+
+}
+
+// ReadyAction - RunningAction - DoneAction - SuspendedAction :
+// for StateWait( ReadyW - RunningW - DoneW - SuspendedW )
+void GraphExecutor::InNode::ReadyAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Ready pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "ReadyAction pthread_cond_broadcast _ReadyWait "
+ << Name() << endl ;
+ if ( pthread_cond_broadcast( &_ReadyWait ) ) {
+ perror("Ready pthread_cond_broadcast ") ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Ready pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::RunningAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Running pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "RunningAction pthread_cond_broadcast _RunningWait "
+ << Name() << endl ;
+ if ( pthread_cond_broadcast( &_RunningWait ) ) {
+ perror("Running pthread_cond_broadcast ") ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Running pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::DoneAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Done pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "DoneAction pthread_cond_broadcast _DoneWait "
+ << Name() << endl ;
+ if ( pthread_cond_broadcast( &_DoneWait ) ) {
+ perror("Done pthread_cond_broadcast ") ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Done pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::SuspendedAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Suspended pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "SuspendedAction pthread_cond_broadcast _SuspendedWait "
+ << Name() << endl ;
+ if ( pthread_cond_broadcast( &_SuspendedWait ) ) {
+ perror("Suspended pthread_cond_broadcast ") ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Suspended pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+// SuspendAction <--> { ResumeAction - ReStartAction }
+GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() {
+ SuspendedAction() ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Suspend pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( !_SuspendSync ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " SuspendAction pthread_cond_wait _SuspendWait "
+ << Automaton()->StateName( State() ) << endl ;
+ _SuspendSync = true ;
+ _OutNode->SuspendThread() ;
+ if ( pthread_cond_wait( &_SuspendWait , &_MutexWait ) ) {
+ perror("SuspendAction pthread_cond_wait ") ;
+ }
+ _OutNode->ResumeThread() ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " SuspendAction pthread_cond_waited"
+ << Automaton()->StateName( State() ) << endl ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " NO SuspendAction pthread_cond_wait"
+ << Automaton()->StateName( State() ) << endl ;
+ }
+ SendEvent( _aResumeEvent ) ;
+ _SuspendSync = false ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("SuspendAction pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+
+ if ( ControlState() == SUPERV::ToSuspendStartState ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
+
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("SuspendAction pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( _ResumeSync ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " SuspendAction pthread_cond_signal _ResumeWait" << endl ;
+ if ( pthread_cond_signal( &_ResumeWait ) ) {
+ perror("SuspendAction pthread_cond_signal _ResumeWait ") ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " SuspendAction pthread_cond_signaled _ResumeWait " << endl ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " NO SuspendAction pthread_cond_signal _ResumeWait" << endl ;
+ _ResumeSync = true ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("SuspendAction pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+ if ( _aReStartNode ) {
+ cdebug << Name() << " " << Automaton()->StateName( State() )
+ << "aReStartNode : " << _aReStartNode->Name() << " "
+ << Automaton()->StateName( _aReStartNode->State() ) << endl ;
+ _aReStartNode->SendEvent( _aResumeEvent ) ;
+ }
+ else {
+ cdebug << "NO aReStartNode"
+ << Automaton()->StateName( State() ) << endl ;
+ }
+ return _aReStartNode ;
+}
+
+bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent ) {
+ bool RetVal ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("ResumeAction pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ _aResumeEvent = aResumeEvent ;
+ if ( _SuspendSync ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " ResumeAction pthread_cond_signal" << endl ;
+ if ( pthread_cond_signal( &_SuspendWait ) ) {
+ perror("ResumeAction pthread_cond_signal ") ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " ResumeAction pthread_cond_signaled _SuspendWait " << endl ;
+ RetVal = true ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
+ << " NO ResumeAction pthread_cond_signal" << endl ;
+ if ( pthread_self() == ThreadNo() ) {
+ RetVal = false ; // Ne pas s'attendre soi-meme !...
+ }
+ else {
+ _SuspendSync = true ;
+ RetVal = true ; // Il faut tout de meme attendre ci-apres ...
+ }
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("ResumeAction pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+
+ if ( RetVal ) {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("ResumeAction pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( !_ResumeSync ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
+ << Name() << " ResumeAction pthread_cond_wait _ResumeWait "
+ << Automaton()->StateName( State() ) << endl ;
+ _ResumeSync = true ;
+ if ( pthread_cond_wait( &_ResumeWait , &_MutexWait ) ) {
+ perror("ResumeAction pthread_cond_wait ") ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
+ << Name() << " ResumeAction pthread_cond_waited _ResumeWait"
+ << Automaton()->StateName( State() ) << endl ;
+ RetVal = true ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond "
+ << Name() << " NO ResumeAction pthread_cond_wait _ResumeWait"
+ << Automaton()->StateName( State() ) << endl ;
+ RetVal = false ;
+ }
+ _ResumeSync = false ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("ResumeAction pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "GraphExecutor::InNodeThreads::ResumeAction RetVal " << RetVal << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::InNode::ReStartAction( GraphExecutor::InNode * aReStartNode ,
+ GraphExecutor::NodeEvent anEvent ) {
+ GraphExecutor::InNode * oldReStartNode = _aReStartNode ;
+ _aReStartNode = aReStartNode ;
+ _aReStartEvent = anEvent ;
+ cdebug << pthread_self() << " GraphExecutor::InNodeThreads::ReStartAction from "
+ << Name() << " " << Automaton()->StateName( State() ) << " to "
+ << aReStartNode->ThreadNo() << " " << aReStartNode->Name() << " "
+ << Automaton()->StateName( aReStartNode->State() ) ;
+ if ( oldReStartNode ) {
+ cdebug << " oldReStartNode " << oldReStartNode->Name() << endl ;
+ }
+ else {
+ cdebug << endl ;
+ }
+ return ResumeAction( GraphExecutor::ToReStartEvent ) ;
+}
+
+void GraphExecutor::InNode::KilledAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Killed pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( !_KillSync ) {
+ cdebug << "pthread_cond " << Name() << " Killed pthread_cond_wait"
+ << endl ;
+ _KillSync = true ;
+ if ( pthread_cond_wait( &_KillWait , &_MutexWait ) ) {
+ perror("Killed pthread_cond_wait ") ;
+ }
+ cdebug << "pthread_cond " << Name() << " Killed pthread_cond_waited"
+ << endl ;
+ }
+ else {
+ cdebug << "pthread_cond " << Name() << " NO Killed pthread_cond_wait"
+ << endl ;
+ }
+ _KillSync = false ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Killed pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::KillAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Kill pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( _KillSync ) {
+ cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signal"
+ << endl ;
+// if ( pthread_cond_broadcast( &_KillWait ) ) {
+ if ( pthread_cond_signal( &_KillWait ) ) {
+ perror("Kill pthread_cond_broadcast ") ;
+ }
+ cdebug << "pthread_cond " << Name() << " Kill pthread_cond_signaled"
+ << endl ;
+ }
+ else {
+ cdebug << "pthread_cond " << Name() << " NO Kill pthread_cond_signal"
+ << endl ;
+ _KillSync = true ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Kill pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::StoppedAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Stopped pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_wait( &_StopWait , &_MutexWait ) ) {
+ perror("Stopped pthread_cond_wait ") ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Stopped pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::StopAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("Stop pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_broadcast( &_StopWait ) ) {
+ perror("Stop pthread_cond_broadcast ") ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("Stop pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+int GraphExecutor::InNode::executeAction() {
+ if ( CreateNewThread() ) {
+ CreateNewThread( false ) ;
+ if ( ThreadNo() == 0 ) {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " executeAction start Thread "
+ << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
+ << endl;
+ pthread_t T;
+ int pthread_sts = 1 ;
+// _OutNode->PushEvent( NULL , GraphExecutor::NewThreadEvent ,
+// SUPERV::ExecutingState ) ;
+ while ( (pthread_sts = pthread_create(&T, NULL, run_function, this )) ) {
+ char * msg = "Cannot pthread_create " ;
+ perror( msg ) ;
+ cdebug << ThreadNo() << " " << msg << endl ;
+ cdebug << ThreadNo() << " PTHREAD_THREADS_MAX : "
+ << PTHREAD_THREADS_MAX << " " << pthread_sts << endl ;
+// sleep( 1 ) ;
+ pthread_exit( msg ) ;
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "executeAction has created thread " << T << endl ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " executeAction restart Thread "
+ << Automaton()->StateName( State() ) << " "
+ << Automaton()->ActionName( _NextAction ) << "(" << Name()
+ << ") ReStartAction ==>" << endl;
+ SUPERV::AutomatonState oldstate = State() ;
+ State( SUPERV::SuspendedSuccessedState ) ;
+ if ( !ReStartAction( this , GraphExecutor::ReStartEvent ) ) {
+// State( oldstate ) ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " executeAction STATE & CALLED "
+ << Automaton()->ActionName( _NextAction ) << "(" << Name()
+ << ") ERROR-DEBUG " << endl;
+// return ExecuteAction() ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " executeAction NO CALL "
+ << Automaton()->ActionName( _NextAction ) << "(" << Name()
+ << ")" << endl;
+ }
+ }
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " executeAction call "
+ << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
+ << endl;
+ return ExecuteAction() ;
+ }
+ return 1;
+}
+
+void GraphExecutor::InNode::coutbegin() {
+ cdebug << ThreadNo() << " " << pthread_self() << " run_function begin"
+ << " " << Name() << " " << Automaton()->StateName( State() )
+ << endl ;
+}
+void GraphExecutor::InNode::coutexit() {
+ cdebug << pthread_self() << "/" << ThreadNo() << " run_function pthread_exit"
+ << " " << Name() << " " << Automaton()->StateName( State() )
+ << endl ;
+}
+void * run_function(void *p) {
+ GraphExecutor::InNode *aNode = (GraphExecutor::InNode *) p;
+ aNode->coutbegin() ;
+ aNode->NewThread( pthread_self() ) ;
+ if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) {
+ perror("pthread_setcanceltype ") ;
+ exit(0) ;
+ }
+ if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) {
+ perror("pthread_setcancelstate ") ;
+ exit(0) ;
+ }
+ aNode->ExecuteAction() ;
+ char * msg = new char[40] ;
+ sprintf( msg , "%d" , aNode->ThreadNo() ) ;
+ strcat( msg , " thread exit" ) ;
+ aNode->coutexit() ;
+ aNode->ExitThread() ;
+ string smsg = msg ;
+ pthread_exit( (void * ) smsg.c_str() ) ;
+ return msg ;
+}
+
+int GraphExecutor::InNode::ExecuteAction() {
+ int sts ;
+ GraphExecutor::StateEventAction nextaction = _NextAction ;
+ const char * nextactionname = Automaton()->ActionName( nextaction ) ;
+ const char * statename = Automaton()->StateName( State() ) ;
+ const char * nextstatename = Automaton()->StateName( _NextState ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
+ << nextactionname << " " << statename << " NextState "
+ << nextstatename << endl ;
+ State( _NextState ) ;
+ switch ( nextaction ) {
+ case GraphExecutor::ErrorAction : {
+ sts = ErrorAction() ;
+ break ;
+ }
+ case GraphExecutor::VoidAction : {
+ sts = VoidAction() ;
+ break ;
+ }
+ case GraphExecutor::DataWaiting_SomeDataReadyAction : {
+ sts = DataWaiting_SomeDataReadyAction() ;
+ break ;
+ }
+ case GraphExecutor::DataUndef_NotAllDataReadyAction : {
+ sts = DataUndef_NotAllDataReadyAction() ;
+ break ;
+ }
+ case GraphExecutor::DataUndef_AllDataReadyAction : {
+ sts = DataUndef_AllDataReadyAction() ;
+ break ;
+ }
+ case GraphExecutor::DataReady_SuspendAction : {
+ sts = DataReady_SuspendAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedReady_ResumeAction : {
+ sts = SuspendedReady_ResumeAction() ;
+ break ;
+ }
+ case GraphExecutor::DataReady_KillAction : {
+ sts = DataReady_KillAction() ;
+ break ;
+ }
+ case GraphExecutor::DataReady_StopAction : {
+ sts = DataReady_StopAction() ;
+ break ;
+ }
+ case GraphExecutor::DataReady_ExecuteAction : {
+ sts = DataReady_ExecuteAction() ;
+ break ;
+ }
+ case GraphExecutor::Executing_SuspendAction : {
+ sts = Executing_SuspendAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedExecuting_ResumeAction : {
+ sts = SuspendedExecuting_ResumeAction() ;
+ break ;
+ }
+ case GraphExecutor::Executing_KillAction : {
+ sts = Executing_KillAction() ;
+ break ;
+ }
+ case GraphExecutor::Executing_StopAction : {
+ sts = Executing_StopAction() ;
+ break ;
+ }
+ case GraphExecutor::Executing_SuccessAction : {
+ sts = Executing_SuccessAction() ;
+ break ;
+ }
+ case GraphExecutor::Executing_ErrorAction : {
+ sts = Executing_ErrorAction() ;
+ break ;
+ }
+ case GraphExecutor::Successed_SuccessAction : {
+ sts = Successed_SuccessAction() ;
+ break ;
+ }
+ case GraphExecutor::Errored_ErrorAction : {
+ sts = Errored_ErrorAction() ;
+ break ;
+ }
+ case GraphExecutor::Successed_SuspendAction : {
+ sts = Successed_SuspendAction() ;
+ break ;
+ }
+ case GraphExecutor::Errored_SuspendAction : {
+ sts = Errored_SuspendAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedSuccessed_ResumeAction : {
+ sts = SuspendedSuccessed_ResumeAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedErrored_ResumeAction : {
+ sts = SuspendedErrored_ResumeAction() ;
+ break ;
+ }
+ case GraphExecutor::Successed_KillAction : {
+ sts = Successed_KillAction() ;
+ break ;
+ }
+ case GraphExecutor::Errored_KillAction : {
+ sts = Errored_KillAction() ;
+ break ;
+ }
+ case GraphExecutor::Successed_StopAction : {
+ sts = Successed_StopAction() ;
+ break ;
+ }
+ case GraphExecutor::Errored_StopAction : {
+ sts = Errored_StopAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedSuccessed_ReStartAction : {
+ sts = SuspendedSuccessed_ReStartAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedErrored_ReStartAction : {
+ sts = SuspendedErrored_ReStartAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedSuccessed_ReStartAndSuspendAction : {
+ sts = SuspendedSuccessed_ReStartAndSuspendAction() ;
+ break ;
+ }
+ case GraphExecutor::SuspendedErrored_ReStartAndSuspendAction : {
+ sts = SuspendedErrored_ReStartAndSuspendAction() ;
+ break ;
+ }
+ default : {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " GraphExecutor::InNodeThreads::SendEvent Error Undefined Action : "
+ << _NextAction << endl ;
+ return 0 ;
+ }
+ }
+ cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
+ << Automaton()->ActionName( nextaction ) << endl ;
+ return sts ;
+}
+
+int GraphExecutor::InNode::ErrorAction() {
+ cdebug << pthread_self() << "/" << ThreadNo() << " Automaton ErrorAction Node "
+ << Name() << endl;
+ return 0;
+}
+
+int GraphExecutor::InNode::VoidAction() {
+ cdebug << pthread_self() << "/" << ThreadNo() << " VoidAction " << Name() << endl;
+ return 1;
+}
+
+
+int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
+ << " to " << Name() << endl;
+ unsigned int k;
+ int InReady = 0 ;
+ int res = 1;
+ bool LoopFinished = false ;
+ bool LoopBeginning = false ;
+ bool SwitchFinished = false ;
+
+ if ( IsEndLoopNode() && !GetChangeNodeInPort( 1 )->GetOutPort()->BoolValue() ) {
+ LoopFinished = true ; // End of Loop
+ }
+ if ( IsLoopNode() && GetChangeNodeInPort( 1 )->GetOutPort()->BoolValue() ) {
+ LoopBeginning = true ; // Beginning of Loop
+ }
+ if ( IsEndSwitchNode() && !GetChangeNodeInPort( 0 )->GetOutPort()->BoolValue() ) {
+ SwitchFinished = true ;
+ }
+ for ( k = 0 ; k < GetNodeInPortsSize() ; k++ ) {
+ GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
+ GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
+ if ( anInPort->IsGate() && anOutPort == NULL ) {
+ InReady += 1 ;
+ anInPort->State( SUPERV::ReadyState ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " ControlPort inactive." << endl ;
+ }
+ else if ( strcmp( DataFromNode() , anOutPort->NodeName() ) ) {
+ if ( anInPort->State() == SUPERV::ReadyState ) {
+ InReady += 1 ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " Was Done from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " " ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+// else if ( LoopBeginning && anInPort->IsDataConnected() ) {
+ else if ( IsLoopNode() && anInPort->IsDataConnected() ) {
+ anInPort->State( SUPERV::ReadyState ) ;
+ InReady += 1 ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " Was Done from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " LoopBeginning " << LoopBeginning ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ else if ( LoopFinished ) {
+ anInPort->State( SUPERV::ReadyState ) ;
+ InReady += 1 ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " Was Done from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " LoopFinished" ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ else if ( anInPort->IsGate() && SwitchFinished ) {
+ anInPort->State( SUPERV::ReadyState ) ;
+ InReady += 1 ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " Was Done from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " SwitchFinished" ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " Was NOT Done from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName() << " "
+ << " " << Automaton()->StateName( State() ) << " DataConnected "
+ << anInPort->IsDataConnected() << " LoopBeginning "
+ << LoopBeginning << endl ;
+ }
+ }
+ else if ( anInPort->IsGate() ) {
+ const CORBA::Any * theValue = anOutPort->Value() ;
+ long GateOpened ;
+ (*theValue) >>= GateOpened ;
+ if ( GateOpened != 0 ) {
+ InReady += 1 ;
+ anInPort->State( SUPERV::ReadyState ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " Gate is Opened from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " " ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ else if ( LoopFinished ) {
+ anInPort->State( SUPERV::ReadyState ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " GATE IS CLOSED from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " LoopFinished" ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " GATE IS CLOSED from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName()
+ << " " ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ }
+ else {
+ InReady += 1 ;
+ anInPort->State( SUPERV::ReadyState ) ;
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
+ << anInPort->PortName() << " is Done from "
+ << anOutPort->NodeName() << " " << anOutPort->PortName() << " " ;
+#ifdef _DEBUG_
+ if ( GraphBase::Base::_prof_debug ) {
+ anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
+ }
+#endif
+ cdebug << endl ;
+ }
+ }
+
+ if ( InReady == GetNodeInPortsSize() ) { // All Flags != 0 :
+ res = SendEvent( GraphExecutor::AllDataReadyEvent ); // ==> Ready to execute
+ }
+ else { // At least one Flag == 0 :
+ res = SendEvent( GraphExecutor::NotAllDataReadyEvent );
+ }
+
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " <-- DataWaiting_SomeDataReadyAction " << Name() << endl;
+ return res ;
+
+}
+
+int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
+ CreateNewThreadIf( false ) ;
+ cdebug << pthread_self() << " for " << ThreadNo()
+ << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+ return 1;
+}
+
+int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " --> DataUndef_AllDataReadyAction " << Name()
+ << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
+ << IsLockedDataWait() ;
+// if ( !CreateNewThreadIf() && IsLockedDataWait() ) {
+ if ( IsLockedDataWait() ) {
+ cdebug << " WOULD DEAD-LOCK" << endl ;
+ return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
+ }
+ cdebug << endl ;
+ CreateNewThread( CreateNewThreadIf() ) ;
+ if ( !CreateNewThread() ) {
+ cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+ ThreadNo( pthread_self() ) ;
+ }
+ _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
+ SUPERV::DataReadyState ) ;
+ ReadyAction() ;
+ SUPERV::ControlState aControl = ControlState() ;
+ switch ( aControl ) {
+ case SUPERV::VoidState : {
+ SendEvent( GraphExecutor::ExecuteEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendState : {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendStartState : {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendDoneState : {
+ SendEvent( GraphExecutor::ExecuteEvent ) ;
+ break ;
+ }
+ case SUPERV::ToKillState : {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ break ;
+ }
+ case SUPERV::ToKillDoneState : {
+ SendEvent( GraphExecutor::ExecuteEvent ) ;
+ break ;
+ }
+ case SUPERV::ToStopState : {
+ SendEvent( GraphExecutor::StopEvent ) ;
+ break ;
+ }
+ default : {
+ cdebug << ThreadNo()
+ << " GraphExecutor::InNodeThreads::DataUndef_AllDataReadyAction Error Undefined Control : "
+ << aControl << endl ;
+ return 0;
+ }
+ }
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+ return 1;
+}
+
+int GraphExecutor::InNode::DataReady_SuspendAction() {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "DataReady_SuspendAction --> Suspend " << Name()
+ << " Threads " << _OutNode->Threads() << " SuspendedThreads "
+ << _OutNode->SuspendedThreads() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::SuspendedReadyEvent ,
+ SUPERV::SuspendedReadyState ) ;
+ GraphExecutor::InNode * aReStartNode = SuspendAction() ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "DataReady_SuspendAction Resumed " << Name() << endl;
+ if ( aReStartNode ) {
+ _aReStartNode = NULL ;
+ aReStartNode->SendEvent( _aReStartEvent ) ;
+ }
+ else {
+ SendEvent( GraphExecutor::ExecuteEvent ) ;
+ }
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedReady_ResumeAction() {
+ cdebug << pthread_self() << "/" << ThreadNo() << "SuspendedReady_ResumeAction "
+ << Name() << endl;
+// ResumeAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::ResumedReadyEvent ,
+ SUPERV::ResumedReadyState ) ;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::DataReady_KillAction() {
+ _OutNode->PushEvent( this , GraphExecutor::KilledReadyEvent ,
+ SUPERV::KilledReadyState ) ;
+ KillAction() ;
+ cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_KillAction " << Name()
+ << " will pthread_exit()" << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::DataReady_StopAction() {
+ _OutNode->PushEvent( this , GraphExecutor::StoppedReadyEvent ,
+ SUPERV::StoppedReadyState ) ;
+ StopAction() ;
+ cdebug << pthread_self() << "/" << ThreadNo() << "DataReady_StopAction " << Name()
+ << " will pthread_exit()" << endl;
+ return 1 ;
+}
+
+#include <CORBA.h>
+
+int GraphExecutor::InNode::DataReady_ExecuteAction() {
+ int i;
+
+ cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
+ << Name() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
+ SUPERV::ExecutingState ) ;
+
+ RunningAction() ;
+ SUPERV::GraphState PortState = SUPERV::ReadyState ;
+ SUPERV::AutomatonState NewState = SUPERV::DataUndefState ;
+ GraphExecutor::NodeEvent NewEvent = GraphExecutor::UndefinedEvent ;
+
+ bool Err = false ;
+
+ int nInParams = GetNodeInPortsSize() ;
+ ServicesAnyData * aListOfInParameters = new ServicesAnyData[nInParams];
+ InParametersSet( Err , nInParams , aListOfInParameters ) ;
+
+ Engines::Container_var myContainer ;
+ Engines::Component_var myObjComponent ;
+// if ( strlen( ComponentName() ) == 0 ) {
+ if ( !IsFactoryNode() ) {
+ cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping"
+ << endl ;
+ if ( IsComputingNode() ) {
+ ObjInterface( true ) ;
+ CORBA::Object_ptr obj ;
+ aListOfInParameters[1].Value >>= obj ;
+ CORBA::Object_var objvar = CORBA::Object_var( obj ) ;
+ myObjComponent = Engines::Component::_narrow( objvar ) ;
+ }
+ else {
+ }
+ }
+ else if ( CORBA::is_nil( Component() ) ) {
+ Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
+ my_strdup( ComponentName() ) ,
+ myContainer , myObjComponent ) ;
+// if ( !Err && nInParams > 1 &&
+// strcmp( ComponentName() , InterfaceName() ) &&
+// aListOfInParameters[ 1 ].Value.type()->kind() ==
+// CORBA::tk_objref ) {
+// }
+// else {
+ ObjInterface( false ) ;
+// }
+ SetContainer( myContainer ) ;
+ SetComponent( myObjComponent ) ;
+ }
+ else {
+ myContainer = Container() ;
+ myObjComponent = Component() ;
+ cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
+ << endl ;
+ myObjComponent->ping() ;
+ }
+
+ int nOutParams = GetNodeOutPortsSize() ;
+ ServicesAnyData * aListOfOutParameters = new ServicesAnyData[nOutParams];
+ InOutParameters( nOutParams , aListOfOutParameters ) ;
+
+// if ( strlen( ComponentName() ) ) {
+ if ( Err || ControlState() == SUPERV::ToKillState ||
+ ControlState() == SUPERV::ToKillDoneState ||
+ ControlState() == SUPERV::ToStopState ) {
+ cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ;
+ Err = true ;
+ }
+ else {
+ if ( !Err ) {
+ cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ;
+ for ( i = 0 ; i < nInParams ; i++ ) {
+ cdebug << " , " << aListOfInParameters[ i ].Name ;
+ }
+ cdebug << ")" << endl ;
+
+ if ( IsOneOfInLineNodes() ) {
+ bool StsPyDynInvoke = true ;
+ try {
+ if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
+ strlen( InLineNode()->PyFuncName() ) ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsInLineNode PyDynInvoke" << endl ;
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &aListOfInParameters[1] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ else if ( IsLoopNode() ) {
+ if ( GetNodeInPort( 1 )->GetOutPort()->BoolValue() ) { // InLoop Port
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
+ << "'" << endl ;
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &aListOfInParameters[2] , ServiceInParameter().length() ,
+ &aListOfOutParameters[2] , ServiceOutParameter().length() ) ;
+ }
+ else {
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
+ << "'" << endl ;
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
+ LoopNode()->PyNextName() ,
+ &aListOfInParameters[2] , ServiceInParameter().length() ,
+ &aListOfOutParameters[2] , ServiceOutParameter().length() ) ;
+ }
+ if ( StsPyDynInvoke ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+ << "' Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+ int i ;
+ for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
+ aListOfInParameters[2 + i].Value = aListOfOutParameters[2+ i].Value ;
+ aListOfInParameters[2 + i].Name = aListOfOutParameters[2+ i].Name ;
+ switch ( aListOfInParameters[2 + i].Value.type()->kind() ) {
+ case CORBA::tk_string :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[2 + i].Name.c_str()
+ << " Value(string) " << endl ;
+ break ;
+ case CORBA::tk_double :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[2 + i].Name.c_str()
+ << " Value(double) " << endl ;
+ break ;
+ case CORBA::tk_long :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[2 + i].Name.c_str()
+ << " Value(long) " << endl ;
+ break ;
+ case CORBA::tk_objref :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[2 + i].Name.c_str()
+ << " Value(object reference) " << endl ;
+ break ;
+ default :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[2 + i].Name.c_str()
+ << " Value(other) ERROR" << endl ;
+ }
+ }
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
+ LoopNode()->PyMoreName() ,
+ &aListOfInParameters[2] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length()+1 ) ;
+ }
+ else {
+ Err = true ;
+ cdebug << ThreadNo() << " InLineNode " << Name() << " "
+ << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
+ << " Python Dynamic Call Error"
+ << endl ;
+ }
+ }
+ else if ( IsSwitchNode() ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &aListOfInParameters[1] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
+ strlen( InLineNode()->PyFuncName() ) ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsGOTONode PyDynInvoke" << endl ;
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &aListOfInParameters[1] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
+ strlen( InLineNode()->PyFuncName() ) ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+ << InLineNode()->PyFuncName()
+ << "' IsSwitchNode PyDynInvoke" << endl ;
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &aListOfInParameters[1] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
+ strlen( InLineNode()->PyFuncName() ) == 0 ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " Copy of " << ServiceInParameter().length()
+ << " OutParameters" << endl ;
+ int i ;
+ int argind0 = 1 ;
+ if ( IsEndLoopNode() ) {
+ argind0 = 2 ;
+ }
+ for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) {
+ aListOfOutParameters[argind0 + i].Value = aListOfInParameters[argind0 + i].Value ;
+// aListOfOutParameters[argind0 + i].Name = aListOfInParameters[argind0 + i].Name ;
+ switch ( aListOfInParameters[argind0 + i].Value.type()->kind() ) {
+ case CORBA::tk_string :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[argind0 + i].Name.c_str()
+ << " Value(string) "
+ << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ break ;
+ case CORBA::tk_double :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[argind0 + i].Name.c_str()
+ << " Value(double) "
+ << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ break ;
+ case CORBA::tk_long :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[argind0 + i].Name.c_str()
+ << " Value(long) "
+ << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ break ;
+ case CORBA::tk_objref :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[argind0 + i].Name.c_str()
+ << " Value(object reference) "
+ << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ break ;
+ default :
+ cdebug << "Arg" << i << " : "
+ << aListOfInParameters[argind0 + i].Name.c_str()
+ << " Value(other) ERROR "
+ << aListOfOutParameters[argind0 + i].Name.c_str() << endl ;
+ }
+ }
+ }
+ if ( !StsPyDynInvoke ) {
+ Err = true ;
+ cdebug << ThreadNo() << " InLineNode " << Name()
+ << " Python Dynamic Call Error"
+ << endl ;
+ }
+ }
+ catch( ... ) {
+ Err = true ;
+ cdebug << ThreadNo() << " InLineNode " << Name()
+ << " Python Dynamic Call Exception catched ERROR"
+ << endl ;
+ }
+ }
+// else if ( !ObjInterface() ) {
+ else if ( IsFactoryNode() ) {
+ try {
+ try {
+ DynInvoke( myObjComponent, "Names" ,
+ _OutNode->Name() , Name() ) ;
+ }
+ catch( ... ) {
+ cdebug << "DynInvoke Names catched ERROR" << endl ;
+ }
+ cdebug << ServiceInParameter().length() << " input parameters and "
+ << ServiceOutParameter().length() << " output parameters" << endl ;
+ if ( IsComputingNode() ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsComputingNode DynInvoke" << endl ;
+ DynInvoke( myObjComponent,
+ ServiceName() ,
+ &aListOfInParameters[1] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ else if ( IsFactoryNode() ) {
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " IsFactoryNode DynInvoke" << endl ;
+ DynInvoke( myObjComponent,
+ ServiceName() ,
+ &aListOfInParameters[1] , ServiceInParameter().length() ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ }
+ catch( ... ) {
+ Err = true ;
+ cdebug << ThreadNo() << " !ObjInterface " << Name()
+ << " Node(Component) Dynamic Call Exception catched ERROR"
+ << endl ;
+ }
+ }
+ else {
+ try {
+ try {
+ DynInvoke( myObjComponent, "Names" ,
+ _OutNode->Name() , Name() ) ;
+ }
+ catch( ... ) {
+ }
+ cdebug << ThreadNo() << " ObjInterface " << Name() << " DynInvoke"
+ << endl ;
+ DynInvoke( myObjComponent ,
+ ServiceName() ,
+ &aListOfInParameters[2] , ServiceInParameter().length()-1 ,
+ &aListOfOutParameters[1] , ServiceOutParameter().length() ) ;
+ }
+ catch( ... ) {
+ Err = true ;
+ cdebug << ThreadNo() << " ObjInterface " << Name()
+ << " Node(Interface) Dynamic Call Exception catched ERROR"
+ << endl ;
+ }
+ }
+ }
+ }
+// }
+// else {
+// sleep( 1 ) ;
+// }
+
+ if ( Err ) {
+ if ( ControlState() == SUPERV::ToKillState ||
+ ControlState() == SUPERV::ToKillDoneState ||
+ ControlState() == SUPERV::ToStopState ) {
+ PortState = SUPERV::ErrorState ;
+ NewState = SUPERV::KilledState ;
+ NewEvent = GraphExecutor::KillEvent ;
+ }
+ else {
+ PortState = SUPERV::ErrorState ;
+ NewState = SUPERV::ErroredState ;
+ NewEvent = GraphExecutor::ErrorEvent ;
+ }
+ }
+ else {
+ PortState = SUPERV::ReadyState ;
+ NewState = SUPERV::DataReadyState ;
+ NewEvent = GraphExecutor::SuccessEvent ;
+ }
+
+ bool ErrOut = OutParameters( Err , PortState , nOutParams , aListOfOutParameters ) ;
+ if ( !ErrOut ) {
+ NewEvent = GraphExecutor::ErrorEvent ;
+ }
+ delete [] aListOfInParameters ;
+ delete [] aListOfOutParameters ;
+
+ SendEvent( NewEvent );
+
+ cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Executing_SuspendAction() {
+ _OutNode->PushEvent( this , GraphExecutor::SuspendedExecutingEvent ,
+ SUPERV::SuspendedExecutingState ) ;
+ cdebug << ThreadNo() << " Executing_SuspendAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedExecuting_ResumeAction() {
+ cdebug << ThreadNo() << " SuspendedExecuting_ResumeAction " << Name() << endl;
+ SUPERV::AutomatonState next_state ;
+ next_state = Automaton()->NextState( State() , GraphExecutor::ExecutingEvent ) ;
+ _OutNode->NewThread() ; // Only for Threads count
+ _OutNode->PushEvent( this , GraphExecutor::ResumedExecutingEvent ,
+ next_state ) ;
+ State( next_state ) ;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Executing_KillAction() {
+ cdebug << ThreadNo() << " Executing_KillAction " << Name() << endl;
+ int RetVal = 0 ;
+ if ( pthread_self() == ThreadNo() ) {
+ cdebug << "Executing_KillAction would pthread_canceled itself" << endl ;
+ KillAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
+ SUPERV::KilledExecutingState ) ;
+ RetVal = 1 ;
+ }
+ else if ( pthread_cancel( ThreadNo() ) ) {
+ perror("Executing_KillAction pthread_cancel error") ;
+ }
+ else {
+ cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
+ << " pthread_canceled" << endl ;
+ KillAction() ;
+ _OutNode->ExitThread() ;
+ _OutNode->PushEvent( this , GraphExecutor::KilledExecutingEvent ,
+ SUPERV::KilledExecutingState ) ;
+ }
+ return RetVal ;
+}
+
+int GraphExecutor::InNode::Executing_StopAction() {
+ cdebug << ThreadNo() << " Executing_StopAction " << Name() << endl;
+ int RetVal = 0 ;
+ if ( pthread_cancel( ThreadNo() ) ) {
+ perror("Executing_KillAction pthread_cancel error") ;
+ }
+ else {
+ cdebug << "Executing_KillAction : ThreadId " << ThreadNo()
+ << " pthread_canceled" << endl ;
+ StopAction() ;
+ _OutNode->ExitThread() ;
+ _OutNode->PushEvent( this , GraphExecutor::StoppedExecutingEvent ,
+ SUPERV::StoppedExecutingState ) ;
+ }
+ return RetVal ;
+}
+
+int GraphExecutor::InNode::Executing_SuccessAction() {
+ cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
+ SUPERV::SuccessedState ) ;
+// DoneAction() ;
+ SUPERV::ControlState aControl = ControlState() ;
+ switch ( aControl ) {
+ case SUPERV::VoidState : {
+ SendEvent( SuccessEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendState : {
+ SendEvent( SuccessEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendDoneState : {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ return 1 ;
+ }
+ case SUPERV::ToKillState : {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ return 1 ;
+ }
+ case SUPERV::ToKillDoneState : {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ return 1 ;
+ }
+ case SUPERV::ToStopState : {
+ SendEvent( GraphExecutor::StopEvent ) ;
+ return 1 ;
+ }
+ default : {
+ cdebug << ThreadNo()
+ << " GraphExecutor::InNodeThreads::Executing_SuccessAction Error Undefined Control : "
+ << aControl << endl ;
+ return 0;
+ }
+ }
+ cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Executing_ErrorAction() {
+ cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
+ SUPERV::ErroredState ) ;
+// DoneAction() ;
+
+ SUPERV::ControlState aControl = ControlState() ;
+ switch ( aControl ) {
+ case SUPERV::VoidState : {
+ SendEvent( ErrorEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendState : {
+ SendEvent( ErrorEvent ) ;
+ break ;
+ }
+ case SUPERV::ToSuspendDoneState : {
+ SendEvent( GraphExecutor::SuspendEvent ) ;
+ return 1 ;
+ }
+ case SUPERV::ToKillState : {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ return 1 ;
+ }
+ case SUPERV::ToKillDoneState : {
+ SendEvent( GraphExecutor::KillEvent ) ;
+ return 1 ;
+ }
+ case SUPERV::ToStopState : {
+ SendEvent( GraphExecutor::StopEvent ) ;
+ return 1 ;
+ }
+ default : {
+ cdebug << ThreadNo()
+ << " GraphExecutor::InNodeThreads::Executing_ErrorAction Error Undefined Control : "
+ << aControl << endl ;
+ return 0;
+ }
+ }
+ cdebug << ThreadNo() << " <-- Executing_ErrorAction " << Name() << endl;
+ return 1 ;
+}
+
+// Set SUPERV::WaitingState to all InPorts
+void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) {
+ int i ;
+ int j ;
+ bool docdebug = false ;
+ State( SUPERV::DataWaitingState ) ;
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ;
+ if ( anInPort->IsGate() ) { // Loop : Open the doors
+ GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
+ if ( anOutPort ) {
+ CORBA::Any * anAny = new CORBA::Any() ;
+ *anAny <<= (long ) 1 ;
+ anOutPort->Value( anAny ) ;
+ anInPort->State( SUPERV::ReadyState ) ;
+ }
+ }
+ else if ( anInPort->State() != SUPERV::WaitingState ) {
+ if ( !docdebug ) {
+ cdebug << ThreadNo()
+ << " --> GraphExecutor::InNodeThreads::SetWaitingStates "
+ << Name() << endl;
+ docdebug = true ;
+ }
+ anInPort->State( SUPERV::WaitingState ) ;
+ }
+ }
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ if ( !( IsGOTONode() && i == 0 ) && !( IsEndLoopNode() && i <= 1 ) ) {
+ for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( GetChangeNodeOutPort( i )->ChangeInPorts( j )->NodeName() )->GetInNode() ;
+ if ( aNode != EndNode ) {
+ aNode->SetWaitingStates( EndNode ) ;
+ }
+ }
+ }
+ }
+}
+
+int GraphExecutor::InNode::Successed_SuccessAction() {
+ cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
+ int res = 1;
+ int linkednodesnumber = LinkedNodesSize() ;
+ GraphExecutor::InNode *firstzeroNode = NULL ;
+ GraphExecutor::InNode *firsttoNode = NULL ;
+ GraphExecutor::InNode *toNode ;
+ int i ;
+ int j ;
+ list<GraphExecutor::InNode *> SomeDataNodes ;
+
+ DoneAction() ;
+
+ if ( IsGOTONode() ||
+ ( IsEndLoopNode() && GetNodeInPort(1)->GetOutPort()->BoolValue() ) ) {
+ int index ;
+ if ( IsGOTONode() ) {
+ index = 0 ;
+ }
+ else {
+ index = 1 ;
+ CORBA::Any * anAny = new CORBA::Any() ;
+ *anAny <<= (long ) 0 ;
+ GetChangeNodeOutPort(1)->Value( anAny ) ; // Loop(InLoop) = false
+ }
+ const GraphBase::OutPort * GateOutPort = GetNodeOutPort(index) ;
+ for ( i = 0 ; i < GateOutPort->InPortsSize() ; i++ ) {
+ const GraphBase::InPort * anInPort = GateOutPort->InPorts( i ) ;
+ GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
+ aLabelNode->SetWaitingStates( this ) ;
+ for ( j = 1 ; j < GetNodeOutPortsSize() ; j++ ) {
+ GraphBase::OutPort * aBusParamOutPort = GetChangeNodeOutPort( j ) ;
+ GraphBase::InPort * aBusParamChangeInPort = NULL ;
+ if ( aBusParamOutPort->IsLoop() ) {
+ aBusParamChangeInPort = aLabelNode->GetChangeInPort( "InitLoop" ) ;
+ }
+ else {
+ aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ;
+ }
+// const GraphBase::InPort * aBusParamInPort = aBusParamChangeInPort ;
+// if ( aBusParamInPort ) {
+// GraphBase::OutPort * anOutPort = aBusParamInPort->GetOutPort() ;
+// anOutPort->Value( aBusParamOutPort->Value() ) ;
+// GraphExecutor::InNode * aFromLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ;
+// if ( aFromLabelNode && !aLabelNode->IsLockedDataWait() ) {
+// res = aLabelNode->SendSomeDataReady( aFromLabelNode->Name() , EndTest ) ;
+ if ( aBusParamChangeInPort ) {
+ aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
+ if ( !aLabelNode->IsLockedDataWait() ) {
+ res = aLabelNode->SendSomeDataReady( Name() ) ;
+ if ( res ) {
+ if ( firsttoNode == NULL &&
+ aLabelNode->ThreadNo() == pthread_self() ) {
+ firsttoNode = aLabelNode ;
+ cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+ << aLabelNode->Name() << endl ;
+ }
+ else if ( firstzeroNode == NULL &&
+ aLabelNode->ThreadNo() == 0 ) {
+ firstzeroNode = aLabelNode ;
+ }
+ else {
+ SomeDataNodes.push_back( aLabelNode ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction push "
+ << SomeDataNodes.size() << " " << aLabelNode->Name()
+ << endl ;
+ }
+ }
+ }
+ else {
+ cdebug << ThreadNo()
+ << " Successed_SuccessAction Loop to HeadNode "
+ << aLabelNode->Name() << " with datas from "
+ << aBusParamOutPort->PortName() << " to port "
+ << aBusParamChangeInPort->PortName() << endl;
+// aBusParamChangeInPort->State( SUPERV::ReadyState ) ;
+ }
+ }
+ else {
+ cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
+ << " NO port " << aBusParamOutPort->PortName() << " in "
+ << aLabelNode->Name() << endl;
+ }
+ }
+ const GraphBase::OutPort * aGateOutPort = GetNodeOutPort( index ) ;
+ const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInPort( index ) ;
+ if ( aGateInPort ) {
+ aGateInPort->GetOutPort()->Value( aGateOutPort->Value() ) ;
+ if ( !aLabelNode->IsLockedDataWait() ) {
+ res = aLabelNode->SendSomeDataReady( Name() ) ;
+ if ( res ) {
+ if ( firsttoNode == NULL &&
+ aLabelNode->ThreadNo() == pthread_self() ) {
+ firsttoNode = aLabelNode ;
+ cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+ << aLabelNode->Name() << endl ;
+ }
+ else if ( firstzeroNode == NULL &&
+ aLabelNode->ThreadNo() == 0 ) {
+ firstzeroNode = aLabelNode ;
+ }
+ else {
+ SomeDataNodes.push_back( aLabelNode ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction push "
+ << SomeDataNodes.size() << " " << aLabelNode->Name()
+ << endl ;
+ }
+ }
+ }
+ }
+ else {
+ cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
+ << " NO port " << aGateOutPort->PortName() << " in "
+ << aLabelNode->Name() << endl;
+ }
+ }
+ }
+
+ else {
+ cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
+ << " with " << LinkedNodesSize() << " linked nodes :" ;
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+ if ( LinkedNodes( i )->IsDataFlowNode() ) {
+ linkednodesnumber -= 1 ;
+ }
+ cdebug << " " << LinkedNodes( i )->Name() ;
+ }
+ cdebug << endl;
+ SUPERV::ControlState aControl = ControlState() ;
+ for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
+ bool IgnoreForEndLoop = false ;
+ toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
+ cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
+ << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
+ if ( toNode && !toNode->IsDataFlowNode() ) {
+ GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInPort(0) ;
+ if ( IsComputingNode() && toNode->IsInLineNode() ) {
+ toGateInPort->State( SUPERV::ReadyState ) ;
+ GraphBase::OutPort * GateOutPort = toGateInPort->GetOutPort() ;
+ if ( GateOutPort ) {
+ GateOutPort->PortStatus( DataConnected );
+ GateOutPort->State( SUPERV::ReadyState ) ;
+ GateOutPort->Done( true ) ;
+ }
+ }
+ }
+ if ( toNode && IsLoopNode() ) {
+ GraphBase::OutPort * fromLoopOutPort = GetChangeNodeOutPort(1) ;
+ if ( !fromLoopOutPort->BoolValue() ) {
+ if ( strcmp( toNode->Name() , CoupledNode()->Name() ) ) {
+ IgnoreForEndLoop = true ; // toNode is the EndLoopNode
+ }
+ else {
+ GraphBase::InPort * toLoopInPort ;
+ toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+ if ( toLoopInPort->State() != SUPERV::ReadyState ) {
+ toLoopInPort->State( SUPERV::ReadyState ) ;
+ }
+ }
+ }
+ }
+ else if ( toNode && IsSwitchNode() ) {
+ }
+ else if ( toNode && toNode->IsInLineNode() ) {
+ int j ;
+ for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
+ toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
+ }
+ }
+ if ( toNode && !IgnoreForEndLoop ) {
+ if ( toNode && toNode->IsLoopNode() ) {
+ GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInPort(1) ;
+ toLoopInPort->State( SUPERV::ReadyState ) ;
+ GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
+ LoopOutPort->PortStatus( DataConnected );
+ LoopOutPort->State( SUPERV::ReadyState ) ;
+ LoopOutPort->Done( true ) ;
+ CORBA::Any * anAny = new CORBA::Any() ;
+ *anAny <<= (long ) 1 ;
+ LoopOutPort->Value( anAny ) ;
+ int j ;
+ for ( j = 0 ; j < toNode->GetNodeInPortsSize() ; j++ ) {
+ toNode->GetChangeNodeInPort( j )->InitialOutPort() ;
+ }
+ }
+ res = toNode->SendSomeDataReady( Name() ) ;
+ if ( res ) {
+ if ( firsttoNode == NULL &&
+ toNode->ThreadNo() == pthread_self() ) {
+ firsttoNode = toNode ;
+ cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+ << toNode->Name() << endl ;
+ }
+ else if ( firstzeroNode == NULL &&
+ toNode->ThreadNo() == 0 ) {
+ firstzeroNode = toNode ;
+ }
+ else {
+ SomeDataNodes.push_back( toNode ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction push "
+ << SomeDataNodes.size() << " " << toNode->Name() << endl ;
+ }
+ }
+ }
+ }
+ }
+
+ if ( firsttoNode == NULL && firstzeroNode ) {
+ firsttoNode = firstzeroNode ;
+ cdebug << ThreadNo()
+ << " Successed_SuccessAction firsttoNode = firstzeroNode "
+ << endl ;
+ }
+ else if ( firsttoNode && firstzeroNode ) {
+ SomeDataNodes.push_back( firstzeroNode ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction push firstzeroNode "
+ << SomeDataNodes.size() << " " << firstzeroNode->Name() << endl ;
+ }
+
+ while ( SomeDataNodes.size() ) {
+ GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
+ SomeDataNodes.pop_front() ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction pop "
+ << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+ if ( aNode->State() == SUPERV::DataReadyState ) {
+ aNode->CreateNewThreadIf( true ) ;
+ aNode->UnLockDataWait() ;
+ res = aNode->DataUndef_AllDataReadyAction() ;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
+ << aNode->Name() << " "
+ << Automaton()->StateName( aNode->State() ) << endl ;
+ }
+ }
+
+ if ( firsttoNode ) {
+// firsttoNode = SomeDataNodes.front() ;
+// SomeDataNodes.pop_front() ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " Successed_SuccessAction pop firsttoNode "
+ << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+ firsttoNode->CreateNewThreadIf( false ) ;
+ if ( firsttoNode->State() == SUPERV::SuccessedState ) {
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+ << " : " << firsttoNode->Name() << " "
+ << Automaton()->StateName( firsttoNode->State() )
+ << " --> DataWaitingState for Thread "
+ << firsttoNode->ThreadNo() << endl ;
+ firsttoNode->State( SUPERV::DataWaitingState ) ;
+ }
+ pthread_t OldT = firsttoNode->ThreadNo() ;
+ firsttoNode->ThreadNo( pthread_self() ) ;
+// On continue avec le meme thread
+ cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
+ << firsttoNode->Name() << "Thread(" << OldT << "-->"
+ << firsttoNode->ThreadNo() << ")" << endl ;
+ ThreadNo( 0 ) ;
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " for " << firsttoNode->Name()
+ << " !firsttoNode->CreateNewThreadIf() "
+ << !firsttoNode->CreateNewThreadIf()
+ << " " << Automaton()->StateName( firsttoNode->State() ) ;
+ if ( firsttoNode->State() == SUPERV::DataReadyState ) {
+ cdebug << endl ;
+ firsttoNode->UnLockDataWait() ;
+ res = firsttoNode->DataUndef_AllDataReadyAction() ;
+ }
+ else {
+ cdebug << " ERROR " << endl ;
+ }
+ }
+ else {
+ cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+ << " NO DataReady ==> ThreadNo( 0 )" << endl ;
+ ThreadNo( 0 ) ;
+ }
+
+ if ( linkednodesnumber == 0 ) {
+ _OutNode->CheckAllDone() ;
+ }
+
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
+ << linkednodesnumber << endl;
+ return 1 ;
+}
+
+bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
+ bool RetVal = false ;
+ if ( IsDataFlowNode() ) {
+ cdebug << ThreadNo() << " ----> " << Name()
+ << " send Result to graph " << Name() << endl;
+ }
+ else {
+ cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
+ << " send SomeDataReady to " << Name() << " "
+ << Automaton()->StateName( State() )
+ << " CreateNewThreadIf() " << CreateNewThreadIf()
+ << " LockedDataWait " << IsLockedDataWait() << endl;
+#if 0
+ cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
+ << " send SomeDataReady to " << Name() << " "
+ << Automaton()->StateName( State() )
+ << " CreateNewThreadIf() " << CreateNewThreadIf()
+ << " LockedDataWait " << IsLockedDataWait() << endl;
+#endif
+ if ( State() == SUPERV::SuccessedState ||
+ State() == SUPERV::SuspendedSuccessedState ||
+ State() == SUPERV::SuspendedSuccessedToReStartState ) {
+ cdebug << ThreadNo() << " " << FromNodeName
+ << " : " << Name() << " " << Automaton()->StateName( State() )
+ << " --> DataWaitingState for Thread "
+ << ThreadNo() << " " << endl ;
+ State( SUPERV::DataWaitingState ) ;
+ }
+ LockDataWait() ;
+ DataFromNode( FromNodeName ) ;
+ RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent );
+ if ( !RetVal ) {
+ UnLockDataWait() ;
+ }
+ }
+ return RetVal ;
+}
+
+int GraphExecutor::InNode::Errored_ErrorAction() {
+ cdebug << ThreadNo() << " Errored_ErrorAction " << Name()
+ << " will pthread_exit" << endl;
+ DoneAction() ;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Successed_SuspendAction() {
+ cdebug << ThreadNo() << " Successed_SuspendAction -->Suspend " << Name()
+ << " Threads " << _OutNode->Threads() << " SuspendedThreads "
+ << _OutNode->SuspendedThreads() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::SuspendedSuccessedEvent ,
+ SUPERV::SuspendedSuccessedState ) ;
+ DoneAction() ;
+ GraphExecutor::InNode * aReStartNode = SuspendAction() ;
+ cdebug << ThreadNo() << " Successed_SuspendAction Resumed " << Name() ;
+ if ( aReStartNode ) {
+ _aReStartNode = NULL ;
+ cdebug << " for " << aReStartNode->Name() << endl;
+ aReStartNode->SendEvent( _aReStartEvent ) ;
+ }
+ else {
+ cdebug << endl;
+ SendEvent( GraphExecutor::ResumeEvent ) ;
+ }
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Errored_SuspendAction() {
+ cdebug << ThreadNo() << " Errored_SuspendAction -->Suspend " << Name()
+ << " Threads " << _OutNode->Threads() << " SuspendedThreads "
+ << _OutNode->SuspendedThreads() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::SuspendedErroredEvent ,
+ SUPERV::SuspendedErroredState ) ;
+ DoneAction() ;
+ GraphExecutor::InNode * aReStartNode = SuspendAction() ;
+ cdebug << ThreadNo() << " Errored_SuspendAction Resumed " << Name()
+ << endl;
+ if ( aReStartNode ) {
+ _aReStartNode = NULL ;
+ aReStartNode->SendEvent( _aReStartEvent ) ;
+ }
+ else {
+ SendEvent( GraphExecutor::ResumeEvent ) ;
+ }
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedSuccessed_ResumeAction() {
+ cdebug << ThreadNo() << " SuspendedSuccessed_ResumeAction " << Name() << endl;
+// ResumeAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::ResumedSuccessedEvent ,
+ SUPERV::ResumedSuccessedState ) ;
+ SendEvent( ResumedSuccessedEvent ) ;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedErrored_ResumeAction() {
+ cdebug << ThreadNo() << " SuspendedErrored_ResumeAction " << Name() << endl;
+// ResumeAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::ResumedErroredEvent ,
+ SUPERV::ResumedErroredState ) ;
+ SendEvent( ResumedErroredEvent ) ;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Successed_KillAction() {
+ KillAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
+ SUPERV::KilledSuccessedState ) ;
+ cdebug << ThreadNo() << " Successed_KillAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Errored_KillAction() {
+ KillAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::KilledEvent ,
+ SUPERV::KilledErroredState ) ;
+ cdebug << ThreadNo() << " Errored_KillAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Successed_StopAction() {
+ StopAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
+ SUPERV::StoppedSuccessedState ) ;
+ cdebug << ThreadNo() << " Successed_StopAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::Errored_StopAction() {
+ StopAction() ;
+ _OutNode->PushEvent( this , GraphExecutor::StoppedEvent ,
+ SUPERV::StoppedErroredState ) ;
+ cdebug << ThreadNo() << " Errored_StopAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedSuccessed_ReStartAction() {
+ cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
+ SUPERV::ReStartedState ) ;
+ int i ;
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
+ }
+ SendEvent( ExecuteEvent ) ;
+ cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedErrored_ReStartAction() {
+ cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
+ _OutNode->PushEvent( this , GraphExecutor::ReStartedEvent ,
+ SUPERV::ReStartedState ) ;
+ int i ;
+ for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
+ GetChangeNodeInPort( i )->State( SUPERV::ReadyState ) ;
+ }
+ SendEvent( ExecuteEvent ) ;
+ cdebug << ThreadNo() << " SuspendedErrored_ReStartAction " << Name() << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedSuccessed_ReStartAndSuspendAction() {
+ cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
+ << endl;
+ _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
+ SUPERV::ReStartedState ) ;
+ State( SUPERV::DataWaitingState ) ;
+ if ( !Suspend() ) {
+ cdebug << "InNode::Suspend() Node " << Name() << endl ;
+ return false ;
+ }
+ else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
+ cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
+ << Name() << endl ;
+ return false ;
+ }
+ cdebug << ThreadNo() << " SuspendedSuccessed_ReStartAndSuspendAction " << Name()
+ << endl;
+ return 1 ;
+}
+
+int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() {
+ cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
+ << endl;
+ _OutNode->PushEvent( this , GraphExecutor::ReStartedAndSuspendEvent ,
+ SUPERV::ReStartedState ) ;
+ State( SUPERV::DataWaitingState ) ;
+ if ( !Suspend() ) {
+ cdebug << "InNode::Suspend() Node " << Name() << endl ;
+ return false ;
+ }
+ else if ( SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
+ cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
+ << Name() << endl ;
+ return false ;
+ }
+ cdebug << ThreadNo() << " SuspendedErrored_ReStartAndSuspendAction " << Name()
+ << endl;
+ return 1 ;
+}
+
+void GraphExecutor::InNode::InParametersSet(
+ bool & Err ,
+ int nInParams ,
+ ServicesAnyData * aListOfInParameters ) {
+ int i ;
+ for ( i = 0 ; i < nInParams ; i++ ) {
+ ServicesAnyData D = aListOfInParameters[i];
+ GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ;
+ GraphBase::OutPort * theOutPort = anInPort->GetOutPort() ;
+ if ( anInPort->IsGate() && theOutPort == NULL ) {
+ cdebug << ThreadNo() << " ArgIn" << i << " " << D.Name << " "
+ << anInPort->GetServicesParameter().Parametertype
+ << " is inactive. " << anInPort->Kind() << endl ;
+ }
+// else if ( theOutPort->State() == SUPERV::ReadyState ) {
+ else if ( anInPort->State() == SUPERV::ReadyState ) {
+ if ( anInPort->IsGate() ) {
+ CORBA::Any * anAny = new CORBA::Any() ;
+ *anAny <<= (long ) 0 ;
+ theOutPort->Value( anAny ) ;
+ }
+ anInPort->State( SUPERV::WaitingState ) ;
+// const CORBA::Any * theValue = theOutPort->Value() ;
+ D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ;
+// D.Value = *theValue ; // CORBA::Any
+ D.Value = *theOutPort->Value() ; // CORBA::Any
+ cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ;
+ cdebug << D.Name << " " << anInPort->GetServicesParameter().Parametertype
+ << " : " ;
+ string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ;
+ const char * Type = _Type.c_str() ;
+ switch (D.Value.type()->kind()) {
+ case CORBA::tk_string:
+ char * t;
+ D.Value >>= t;
+ cdebug << t << " (string)" << endl ;
+ if ( !strcmp( Type , "string" ) ) {
+ }
+ else if ( !strcmp( Type , "double" ) ) {
+ double d ;
+ sscanf( t , "%lf" , &d ) ;
+ D.Value <<= d ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ long l ;
+ sscanf( t , "%ld" , &l ) ;
+ D.Value <<= l ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "objref" ) ) {
+ CORBA::Object_ptr ObjRef ;
+ ObjRef = StringToObject( t ) ;
+ D.Value <<= ObjRef ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else {
+ }
+ break;
+ case CORBA::tk_double:
+ double d;
+ D.Value >>= d;
+ cdebug << d << " (double)" << endl ;
+ if ( !strcmp( Type , "string" ) ) {
+ char t[40] ;
+ sprintf( t , "lf" , d ) ;
+ D.Value <<= t ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "double" ) ) {
+ }
+ else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ long l ;
+ l = (long ) d ;
+ D.Value <<= l ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "objref" ) ) {
+ }
+ else {
+ }
+ break;
+ case CORBA::tk_long:
+ long l;
+ D.Value >>= l;
+ cdebug << l << " (long)" << endl ;
+ if ( !strcmp( Type , "string" ) ) {
+ char t[40] ;
+ sprintf( t , "lf" , l ) ;
+ D.Value <<= t ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "double" ) ) {
+ double d ;
+ d = l ;
+ D.Value <<= d ;
+ theOutPort->Value( D.Value ) ;
+ }
+ else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ }
+ else if ( !strcmp( Type , "objref" ) ) {
+ }
+ else {
+ }
+ break;
+ case CORBA::tk_objref:
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ try {
+ D.Value >>= obj ;
+// retstr = _Orb->object_to_string(obj );
+ retstr = ObjectToString( obj ) ;
+ cdebug << retstr << endl ;
+ }
+ catch( ... ) {
+ if ( i != 0 ) {
+ Err = true ;
+ }
+ cdebug << "ToString( object ) Catched ERROR" << endl ;
+ }
+ break;
+ default:
+ cdebug << " (other ERROR)" << endl ;
+ }
+ }
+ else {
+ cdebug << ThreadNo() << " In" << i << " : wrong state ERROR State "
+ << anInPort->State() << " NameState "
+ << Automaton()->StateName( anInPort->State() ) << " PortName "
+ << anInPort->PortName() << " Parametername "
+ << anInPort->GetServicesParameter().Parametername << endl ;
+ Err = true ;
+ }
+ aListOfInParameters[i] = D ;
+ }
+}
+
+void GraphExecutor::InNode::InOutParameters(
+ int nOutParams ,
+ ServicesAnyData * aListOfOutParameters ) {
+ int i ;
+ for ( i = 0 ; i < nOutParams ; i++ ) {
+ ServicesAnyData D = aListOfOutParameters[i] ;
+
+ D.Name = GetChangeNodeOutPort(i)->GetServicesParameter().Parametername;
+ string _Type = CORBA::string_dup(GetChangeNodeOutPort(i)->GetServicesParameter().Parametertype) ;
+ const char * Type = _Type.c_str() ;
+ bool OutDone = GetChangeNodeOutPort(i)->Done() ;
+// cdebug << ThreadNo() << " ArgOut" << i << " " << D.Name << " Done("
+// << OutDone << ") " << Type << " : " << endl ;
+ if ( !strcmp( Type , "string" ) ) {
+ D.Value <<= (char *) NULL ;
+ }
+ else if ( !strcmp( Type , "double" ) ) {
+ D.Value <<= 0. ;
+ }
+ else if ( !strcmp( Type , "long" ) || !strcmp( Type , "bool" ) ) {
+ D.Value <<= (long ) 0 ;
+ }
+ else {
+ D.Value.replace(CORBA::_tc_Object, NULL);
+ }
+// GetChangeNodeOutPort(i)->Value( D.Value ) ;
+#if 0
+ switch (D.Value.type()->kind()) {
+ case CORBA::tk_string:
+ char * t;
+ D.Value >>= t;
+ cdebug << ThreadNo() << " " << t << "(string)" << endl ;
+ break;
+ case CORBA::tk_double:
+ double d;
+ D.Value >>= d;
+ cdebug << ThreadNo() << " " << d << "(double)" << endl ;
+ break;
+ case CORBA::tk_long:
+ long l;
+ D.Value >>= l;
+ cdebug << ThreadNo() << " " << l << "(long)" << endl ;
+ break;
+ case CORBA::tk_objref:
+ cdebug << ThreadNo() << " " << "(object)" << endl ;
+ break;
+ default:
+ cdebug << ThreadNo() << " " << "(other ERROR)" << endl ;
+ }
+#endif
+ aListOfOutParameters[i] = D ;
+ }
+}
+
+bool GraphExecutor::InNode::OutParameters(
+ bool Err ,
+ SUPERV::GraphState NewState ,
+ int nOutParams ,
+ ServicesAnyData * aListOfOutParameters ) {
+ bool RetVal = true ;
+ int i ;
+ GraphBase::OutPort * aGateOutPort = NULL ;
+ bool OrSwitch = false ;
+ GraphBase::OutPort * anOutPort = GetChangeNodeOutPort(0) ;
+ for ( i = 0 ; i < nOutParams ; i++ ) {
+ anOutPort = GetChangeNodeOutPort(i) ;
+ if ( Err ) {
+ anOutPort->State( NewState ) ;
+ anOutPort->Done( true ) ;
+ }
+ else {
+ cdebug << ThreadNo() << " " << "Out" << i << " " << Name() << " "
+ << anOutPort->PortName() << " " << anOutPort->Kind() ;
+ if ( anOutPort->IsGate() ) {
+ aGateOutPort = anOutPort ;
+ cdebug << " Gate " ;
+ long l = 1;
+ aListOfOutParameters[i].Value <<= l;
+ anOutPort->Value( aListOfOutParameters[i].Value );
+ }
+ else if ( anOutPort->IsLoop() ) {
+ cdebug << " Loop " ;
+ anOutPort->Value( aListOfOutParameters[i].Value );
+// InLoop Port of EndLoopNode is ready :
+ anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ;
+ }
+ else if ( anOutPort->IsSwitch() ) {
+ cdebug << " Switch " ;
+ anOutPort->Value( aListOfOutParameters[i].Value );
+ if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) {
+ if ( OrSwitch && anOutPort->BoolValue() ) {
+ cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING"
+ << endl ;
+// RetVal = false ;
+ }
+ else {
+ OrSwitch = OrSwitch | anOutPort->BoolValue() ;
+ }
+ }
+ cdebug << "OrSwitch " << OrSwitch ;
+ }
+ else {
+ cdebug << " Param " ;
+ anOutPort->Value( aListOfOutParameters[i].Value );
+ }
+// else if ( anOutPort->IsBus() ) {
+// cdebug << " Bus " ;
+// anOutPort->Value( GetNodeInPort( anOutPort->PortIndex() )->GetOutPort()->Value() );
+// }
+ anOutPort->State( NewState ) ;
+ anOutPort->Done( true ) ;
+ int j ;
+ for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) {
+ bool fromGOTO = false ;
+ GraphBase::OutPort * aGOTOPort = _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInPort( 0 )->GetOutPort() ;
+ if ( aGOTOPort ) {
+ fromGOTO = aGOTOPort->IsGOTO() ;
+ }
+ if ( anOutPort->ChangeInPorts( j )->IsEndSwitch() || fromGOTO ) {
+ cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
+ << anOutPort->ChangeInPorts( j )->PortName() << ","
+ << anOutPort->ChangeInPorts( j )->Kind() << ") WILL BE changed from "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
+ << "("
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
+ << ") to " << anOutPort->NodeName() << "("
+ << anOutPort->PortName() << ")" << endl ;
+ anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ;
+ }
+ else {
+ cdebug << anOutPort->ChangeInPorts( j )->NodeName() << "("
+ << anOutPort->ChangeInPorts( j )->PortName() << ","
+ << anOutPort->ChangeInPorts( j )->Kind() << ") NOT changed from "
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName()
+ << "("
+ << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName()
+ << ") to " << anOutPort->NodeName() << "("
+ << anOutPort->PortName() << ")" << endl ;
+ }
+ }
+#if 0
+ switch (anOutPort->Value()->type()->kind()) {
+ case CORBA::tk_string:
+ char * t;
+ (*anOutPort->Value()) >>= t;
+ cdebug << ThreadNo() << " Out" << i << " : " << t << "(string)" << endl ;
+ break;
+ case CORBA::tk_double:
+ double d;
+ (*anOutPort->Value()) >>= d;
+ cdebug << ThreadNo() << " Out" << i << " : " << d << "(double)" << endl ;
+ break;
+ case CORBA::tk_long:
+ long l;
+ (*anOutPort->Value()) >>= l;
+ cdebug << ThreadNo() << " Out" << i << " : " << l << "(long)" << endl ;
+ break;
+ case CORBA::tk_objref:
+ CORBA::Object_ptr obj ;
+ char * retstr ;
+ try {
+ (*anOutPort->Value()) >>= obj ;
+ retstr = _Orb->object_to_string(obj );
+ cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
+ << retstr << endl ;
+ }
+ catch ( ... ) {
+ cdebug << ThreadNo() << " Out" << i << " : " << "ToString( object ) "
+ << "Catched ERROR" << endl ;
+ }
+ break;
+ default:
+ cdebug << ThreadNo() << " Out" << i << " : " << "(other ERROR)" << endl ;
+ RetVal = false ;
+ }
+#endif
+ }
+ }
+ if ( aGateOutPort && IsSwitchNode() ) {
+ if ( OrSwitch ) {
+ cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of "
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+ long l = 0;
+ aListOfOutParameters[0].Value <<= l ;
+ aGateOutPort->Value( aListOfOutParameters[0].Value ) ;
+ }
+ else {
+ cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of "
+ << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ;
+ long l = 1;
+ aListOfOutParameters[0].Value <<= l ;
+ aGateOutPort->Value( aListOfOutParameters[0].Value ) ;
+ int i ;
+ for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
+ GraphBase::InPort * anInPort ;
+ anInPort = CoupledNode()->GetChangeInPort( GetNodeOutPort( i )->PortName() ) ;
+ if ( anInPort ) {
+ anInPort->ChangeOutPort( GetChangeNodeOutPort( i ) ) ;
+ }
+ }
+ }
+ }
+ return RetVal ;
+}
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : DataFlowBase_OutNode.cxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#include "DataFlowExecutor_OutNode.hxx"
+
+// Implementation de la classe GraphEditor::GraphControl
+
+extern GraphExecutor::FiniteStateMachine * theAutomaton ;
+
+static const char *ComponentName = "SalomeSuperVisionComponent" ;
+
+GraphExecutor::OutNode::OutNode() :
+ Graph() {
+ _Valid = false ;
+ _Executable = false ;
+ _Done = false ;
+ _Threads = 0 ;
+ _ControlState = SUPERV::VoidState ;
+ _State = SUPERV::UnKnownState ;
+ _PyInitialized = false ;
+ pthread_mutex_init( &_MutexWait , NULL ) ;
+ if ( pthread_cond_init( &_EventWait , NULL ) ) {
+ perror("pthread_cond_init( &_EventWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_JoinWait , NULL ) ) {
+ perror("pthread_cond_init( &_JoinWait , NULL )") ;
+ exit( 0 ) ;
+ }
+}
+
+GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const char *DataFlowName ,
+ const char * DebugFileName ) :
+ Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) {
+ cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << ")" << endl;
+ _Valid = false ;
+ _Executable = false ;
+ _Done = false ;
+ _Threads = 0 ;
+ _ControlState = SUPERV::VoidState ;
+ _State = SUPERV::UnKnownState ;
+ _PyInitialized = false ;
+ _Orb = CORBA::ORB::_duplicate( ORB ) ;
+ pthread_mutex_init( &_MutexWait , NULL ) ;
+ if ( pthread_cond_init( &_EventWait , NULL ) ) {
+ perror("pthread_cond_init( &_EventWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_JoinWait , NULL ) ) {
+ perror("pthread_cond_init( &_JoinWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ cdebug_out << "GraphEditor::OutNode::OutNode" << endl;
+}
+
+GraphExecutor::OutNode::OutNode(
+ 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 * DataFlowEditorRelease ,
+ const char * DataFlowAuthor ,
+ const char * DataFlowComputer ,
+ const char * DataFlowComment ,
+ const char * DebugFileName ) :
+ Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName ,
+ DataFlowInterfaceName , DataFlowName , DataFlowkind ,
+ DataFlowFirstCreation , DataFlowLastModification ,
+ DataFlowEditorRelease , DataFlowAuthor ,
+ DataFlowComputer , DataFlowComment , DebugFileName ) {
+ _Valid = false ;
+ _Executable = false ;
+ _Done = false ;
+ _Threads = 0 ;
+ _ControlState = SUPERV::VoidState ;
+ _State = SUPERV::UnKnownState ;
+ _PyInitialized = false ;
+ _Orb = CORBA::ORB::_duplicate( ORB ) ;
+ pthread_mutex_init( &_MutexWait , NULL ) ;
+ if ( pthread_cond_init( &_EventWait , NULL ) ) {
+ perror("pthread_cond_init( &_EventWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ if ( pthread_cond_init( &_JoinWait , NULL ) ) {
+ perror("pthread_cond_init( &_JoinWait , NULL )") ;
+ exit( 0 ) ;
+ }
+}
+
+GraphExecutor::OutNode::~OutNode() {
+}
+
+bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) {
+ bool RetVal = false ;
+ RetVal = LoadInfo( aDataFlow.Info ) ;
+ if ( GraphBase::Service::ServiceName() != NULL ) {
+// MESSAGE( "GraphExecutor::OutNode::LoadDataFlow" );
+ if ( RetVal ) {
+ RetVal = LoadNodes( aDataFlow.Nodes ) ;
+ if ( RetVal ) {
+ RetVal = LoadLinks( aDataFlow.Links ) ;
+ if ( RetVal ) {
+ IsValid() ;
+ RetVal = LoadDatas( aDataFlow.Datas ) ;
+ IsExecutable() ;
+ if ( !RetVal) {
+ cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadDatas Error."
+ << endl ;
+ }
+ }
+ else {
+ cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadLinks Error."
+ << endl ;
+ }
+ }
+ else {
+ cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadNodes Error."
+ << endl ;
+ }
+ }
+ else {
+ cdebug << "GraphExecutor::OutNode::LoadDataFlow LoadInfo Error."
+ << endl ;
+ }
+ }
+ else {
+ cdebug << "GraphExecutor::OutNode::LoadDataFlow ServiceName Error." << endl ;
+ }
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) {
+ bool RetVal = false ;
+ GraphBase::SGraph aDataFlow ;
+ if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) {
+ RetVal = LoadDataFlow( aDataFlow ) ;
+// if ( aConstructor && RetVal )
+// RetVal = Name( aDataFlow.Info.theName.c_str() ) ;
+ }
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) {
+ cdebug << "GraphExecutor::OutNode::LoadInfo" << endl ;
+// ComponentName( aDataFlowInfo.theComponentName.c_str() ) ;
+ Name( aDataFlowInfo.theName.c_str() ) ;
+ Kind( aDataFlowInfo.theKind ) ;
+ DataService( _Orb , aDataFlowInfo.theService , Graph_prof_debug() , Graph_fdebug() ) ;
+ FirstCreation( aDataFlowInfo.theFirstCreation ) ;
+ LastModification( aDataFlowInfo.theLastModification ) ;
+ EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ;
+ Author( aDataFlowInfo.theAuthor.c_str() ) ;
+// Computer( aDataFlowInfo.theContainer.c_str() ) ;
+ Comment( aDataFlowInfo.theComment.c_str() ) ;
+// Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow
+// Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ;
+ return true ;
+}
+
+bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNodes ) {
+ bool RetVal = true ;
+ GraphExecutor::InNode * anInNode ;
+ cdebug << "GraphExecutor::OutNode::LoadNodes" << endl ;
+ int i ;
+ for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
+ GraphBase::SNode aNode = aListOfNodes[ i ] ;
+ anInNode = AddNode( aNode.theService ,
+ aNode.theListOfFuncName ,
+ aNode.theListOfPythonFunctions ,
+ aNode.theComponentName.c_str() ,
+ aNode.theInterfaceName.c_str() , aNode.theName.c_str() ,
+ aNode.theKind ,
+ aNode.theFirstCreation , aNode.theLastModification ,
+ aNode.theEditorRelease.c_str() ,
+ aNode.theAuthor.c_str() , aNode.theContainer.c_str() ,
+ aNode.theComment.c_str() ,
+ aNode.theCoords.theX , aNode.theCoords.theY ) ;
+ if ( !anInNode ) {
+ RetVal = false ;
+ break ;
+ }
+ if ( anInNode->IsOneOfInLineNodes() ) {
+ anInNode->GraphExecutor::InNode::InLineNode()->DefPortsOfNode(
+ _Orb , aNode.theService , anInNode->NamePtr() ,
+ anInNode->Kind() , false ,
+ anInNode->IsLoopNode() || anInNode->IsEndLoopNode() ,
+ true , true , Graph_prof_debug() , Graph_fdebug() ) ;
+#if 0
+ GraphBase::InLineNode * aINode = anInNode->InLineNode() ;
+ GraphBase::LoopNode * aLNode = NULL ;
+ if ( aINode->IsLoopNode() ) {
+ aLNode = anInNode->LoopNode() ;
+ aLNode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 0 ] ) ;
+ aLNode->SetMorePythonFunction( aNode.theListOfFuncName[ 1 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 1 ] ) ;
+ aLNode->SetNextPythonFunction( aNode.theListOfFuncName[ 2 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 2 ] ) ;
+ }
+ else if ( aINode->IsInLineNode() || aINode->IsGOTONode() ||
+ aINode->IsSwitchNode() || aINode->IsEndSwitchNode() ) {
+ aINode->SetPythonFunction( aNode.theListOfFuncName[ 0 ].c_str() ,
+ *aNode.theListOfPythonFunctions[ 0 ] ) ;
+ }
+#endif
+ }
+#if 0
+ if ( aNode.theListOfParameters.size() ) { // BusPorts ...
+ int j ;
+ for ( j = 0 ; j < aNode.theListOfParameters.size() ; j++ ) {
+ GraphBase::InPort * InputPort = anInNode->AddInPort(
+ aNode.theListOfParameters[ j ].theInParameter.Parametername ,
+ aNode.theListOfParameters[ j ].theInParameter.Parametertype ) ;
+ GraphBase::OutPort * OutputPort = anInNode->AddOutPort(
+ aNode.theListOfParameters[ j ].theOutParameter.Parametername ,
+ aNode.theListOfParameters[ j ].theOutParameter.Parametertype ) ;
+ anInNode->InOutPort( InputPort , OutputPort ) ;
+ }
+ }
+#endif
+ }
+ for ( i = 0 ; i < aListOfNodes.size() ; i++ ) {
+ GraphBase::SNode aNode = aListOfNodes[ i ] ;
+ anInNode = (GraphExecutor::InNode * ) GetChangeGraphNode( aNode.theName.c_str() )->GetInNode() ;
+ cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() << "IsOneOfGOTONodes "
+ << anInNode->IsOneOfGOTONodes() << " " << aNode.theCoupledNode.c_str() << endl ;
+ if ( anInNode->IsOneOfGOTONodes() && strlen( aNode.theCoupledNode.c_str() ) ) {
+ GraphBase::GOTONode * aCoupledNode ;
+ aCoupledNode = (GraphBase::GOTONode * ) GetGraphNode( aNode.theName.c_str() ) ;
+ aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ;
+ }
+ }
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfLinks &aListOfLinks ) {
+ bool RetVal = true ;
+ cdebug << "GraphExecutor::OutNode::LoadLinks " << aListOfLinks.size()
+ << endl ;
+ int i ;
+ for ( i = 0 ; i < aListOfLinks.size() ; i++ ) {
+ GraphBase::SLink aLink = aListOfLinks[ i ] ;
+ RetVal = AddLink( aLink.FromNodeName.c_str() ,
+ aLink.FromServiceParameterName.c_str() ,
+ aLink.ToNodeName.c_str() ,
+ aLink.ToServiceParameterName.c_str() ,
+ aLink.aLinkValue ) ;
+// aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
+ if ( !RetVal )
+ break ;
+ }
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfLinks &aListOfDatas ) {
+ bool RetVal = true ;
+ cdebug << "GraphExecutor::OutNode::LoadDatas " << aListOfDatas.size()
+ << endl ;
+ int i ;
+ for ( i = 0 ; i < aListOfDatas.size() ; i++ ) {
+ GraphBase::SLink aLink = aListOfDatas[ i ] ;
+ if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) )
+ RetVal = GraphBase::Graph::AddInputData( aLink.ToNodeName.c_str() ,
+ aLink.ToServiceParameterName.c_str() ,
+ aLink.aLinkValue ) ;
+// aLink.aLinkValue.Value , aLink.aLinkValue.Kind ) ;
+ else if ( !strcmp( aLink.ToNodeName.c_str() , Name() ) ) {
+ RetVal = AddOutputData( aLink.FromNodeName.c_str() ,
+ aLink.FromServiceParameterName.c_str() ,
+ aLink.aLinkValue ) ;
+// aLink.aLinkValue.Value ,
+// aLink.aLinkValue.Kind ) ;
+ AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ;
+ }
+ else {
+ cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName
+ << " and " << aLink.ToNodeName << " differents from " << Name()
+ << endl ;
+ RetVal = false ;
+ }
+ if ( !RetVal )
+ break ;
+ }
+ return RetVal ;
+}
+
+GraphExecutor::InNode *GraphExecutor::OutNode::AddNode(
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const char * NodeComponentName ,
+ const char * NodeInterfaceName ,
+ const char * NodeName ,
+ const SUPERV::KindOfNode NodeKindOfNode ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const int NodeX ,
+ const int NodeY ) {
+ cdebug_in << "GraphExecutor::OutNode::AddNode(" << NodeComponentName << " , "
+ << NodeName << ")" << endl;
+ GraphExecutor::InNode *Nd = NULL ;
+ Nd = new GraphExecutor::InNode( _Orb, NamingService() , NodeService ,
+ NodeComponentName , NodeInterfaceName ,
+ NodeName , NodeKindOfNode ,
+ aFuncName , aPythonFunction ,
+ NodeFirstCreation , NodeLastModification ,
+ NodeEditorRelease , NodeAuthor ,
+ NodeComputer , NodeComment , false , NodeX , NodeY ,
+ Graph_prof_debug() , Graph_fdebug() ) ;
+ GraphBase::Graph::AddNode( Nd->ComputingNode() ) ;
+ cdebug_out << "GraphExecutor::OutNode::AddNode" << endl;
+ return Nd ;
+}
+
+
+bool GraphExecutor::OutNode::AddInputData( const char* ToNodeName1 ,
+ const char* ToParameterName1 ,
+ const char* ToNodeName2 ,
+ const char* ToParameterName2 ) {
+ cdebug_in << "GraphExecutor::OutNode::AddInputData" << endl;
+ bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 ,
+ ToParameterName1 ,
+ ToNodeName2 ,
+ ToParameterName2 ) ;
+ cdebug_out << "GraphExecutor::OutNode::AddInputData" << endl;
+ _Valid = false ;
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::Valid() {
+ cdebug_in << "GraphExecutor::OutNode::Valid" << endl;
+
+ if ( _Valid )
+ return true ;
+
+ _Executable = false ;
+
+ CreateService() ;
+
+ if ( !Sort() ) {
+ cdebug << "This DataFlow is not valid." << endl ;
+ return false ;
+ }
+
+// CreateService() ;
+
+ InLineServices() ;
+
+ ComputingNodes() ;
+
+ _Valid = true ;
+
+ cdebug_out << "GraphExecutor::OutNode::Valid" << endl;
+ return _Valid ;
+}
+
+
+bool GraphExecutor::OutNode::Executable() {
+
+ cdebug_in << "GraphExecutor::OutNode::Executable" << endl;
+ if ( !IsValid() )
+ return false ;
+
+ if ( DataServerNodes() )
+ _Executable = true ;
+ else {
+ cdebug << "This DataFlow is not executable." << endl ;
+ _Executable = false ;
+ }
+
+ cdebug_out << "GraphExecutor::OutNode::Executable" << endl;
+ return _Executable ;
+}
+
+bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::Run" << endl;
+
+ if ( Executable() ) {
+ _ControlState = SUPERV::VoidState ;
+ _SuspendedThreads = 0 ;
+ ThreadNo( pthread_self() ) ;
+ Done( false ) ;
+ _JustStarted = true ;
+ int i ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) GraphNodes( i )->GetInNode() ;
+ if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) {
+ if ( !Py_IsInitialized() ) {
+ Py_Initialize() ;
+ }
+ anInNode->InitPython() ;
+ PyInitialized( true ) ;
+ }
+ anInNode->InitialState( this ) ;
+ }
+
+ cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
+ << Name() << endl ;
+
+ PushEvent( NULL , GraphExecutor::ReadyEvent ,
+ SUPERV::DataReadyState ) ;
+ State( SUPERV::DataReadyState ) ;
+
+ for ( i = 0 ; i < HeadNodesSize() ; i++ ) {
+ GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) HeadNodes( i )->GetInNode() ;
+ if ( anInNode->State() != SUPERV::DataReadyState ) {
+ cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
+ << anInNode->Name() << " : " << anInNode->State() << endl ;
+ return false ;
+ }
+// PushEvent( anInNode , GraphExecutor::ReadyEvent ,
+// SUPERV::DataReadyState ) ;
+ anInNode->CreateNewThread( true ) ;
+ anInNode->DataFromNode( Name() ) ;
+ if ( AndSuspend ) {
+ anInNode->State( SUPERV::DataWaitingState ) ;
+ anInNode->ControlState( SUPERV::ToSuspendStartState ) ;
+ if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
+ cdebug << "InNode::SendEvent( SomeDataReadyEvent ) Node "
+ << anInNode->Name() << endl ;
+ return false ;
+ }
+ anInNode->SuspendedWait() ;
+ }
+ else if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
+ cdebug << "InNode::SendEvent( RunningEvent ) Node "
+ << anInNode->Name() << endl ;
+ return false ;
+ }
+ else {
+ anInNode->RunningWait() ;
+ }
+ }
+
+ if ( AndSuspend ) {
+ PushEvent( NULL , GraphExecutor::SuspendedReadyEvent ,
+ SUPERV::SuspendedReadyState ) ;
+ }
+ else {
+ PushEvent( NULL , GraphExecutor::ExecutingEvent ,
+ SUPERV::ExecutingState ) ;
+ if (AutomatonState() == SUPERV::DataReadyState) {
+ State( SUPERV::ExecutingState ) ;
+ };
+ }
+
+ RetVal = true ;
+ }
+ else {
+ PushEvent( NULL , GraphExecutor::NoDataReadyEvent ,
+ SUPERV::DataUndefState ) ;
+ }
+
+ cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::Run( const char * aNodeName ,
+ const char * AtNodeName ,
+ const bool AndSuspend ) {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , "
+ << AtNodeName << " , " << AndSuspend << ")" << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ;
+ if ( anInNode ) {
+ RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::Run" << endl ;
+ return RetVal ;
+}
+
+void GraphExecutor::OutNode::CheckAllDone() {
+ int j ;
+ cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl;
+ SUPERV::AutomatonState OutNodeState = SUPERV::SuccessedState ;
+ SUPERV::AutomatonState InNodeState ;
+ bool AllDone = true ;
+ if ( !_Done ) {
+ for ( j = 0 ; j < QueueNodesSize() ; j++ ) {
+ InNodeState = ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->State() ;
+ cdebug << j << ". "
+ << ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->Name()
+ << " " << theAutomaton->StateName( InNodeState ) << endl ;
+ if ( InNodeState != SUPERV::SuccessedState &&
+ InNodeState != SUPERV::ErroredState &&
+ InNodeState != SUPERV::DataWaitingState ) {
+ AllDone = false ;
+ }
+ if ( InNodeState != SUPERV::SuccessedState ) {
+ OutNodeState = InNodeState ;
+ }
+ }
+ if ( AllDone ) {
+ if( _Threads == 0 && _SuspendedThreads == 0 ) {
+ if ( OutNodeState != SUPERV::ErroredState ) {
+ OutNodeState = SUPERV::SuccessedState ;
+ }
+ }
+ else {
+ AllDone = false ;
+ }
+ }
+ if ( AllDone ) {
+ State( OutNodeState ) ;
+ _Done = true ;
+ _JustStarted = false ;
+ for ( j = 0 ; j < GraphNodesSize() ; j++ ) {
+ GraphExecutor::InNode * aNode ;
+ aNode = (GraphExecutor::InNode * ) GraphNodes( j )->GetInNode() ;
+ SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ;
+ cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " "
+ << theAutomaton->StateName( aNode->State() ) << " :" << endl ;
+ if ( aState == SUPERV::ErrorState ||
+ aState == SUPERV::SuspendErroredState ||
+ aState == SUPERV::KillState ||
+ aState == SUPERV::StopState ) {
+ OutNodeState = aNode->State() ;
+ }
+ aNode->SuspendedAction() ;
+ aNode->DoneAction() ;
+ }
+// PushEvent AFTER State and _Done ! ...
+ PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
+ OutNodeState ) ;
+ Py_Finalize() ;
+ PyInitialized( false ) ;
+ }
+ }
+ cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << _Done
+ << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
+ << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
+ << _SuspendedThreads << endl ;
+}
+
+void GraphExecutor::OutNode::NewThread() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _NewThread") ;
+ exit( 0 ) ;
+ }
+ _Threads += 1 ;
+ cdebug << "NewThread : " << _Threads << " running threads "
+ << _SuspendedThreads << " suspended threads"
+ << endl ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_unlock _NewThread") ;
+ exit( 0 ) ;
+ }
+}
+void GraphExecutor::OutNode::ExitThread() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _ExitThread") ;
+ exit( 0 ) ;
+ }
+ _Threads -= 1 ;
+ theAutomaton->JoinThread( pthread_self() ) ;
+ if ( pthread_cond_signal( &_JoinWait ) ) {
+ perror("ExitThread pthread_cond_signal ") ;
+ }
+ cdebug << "ExitThread : " << _Threads << " running threads "
+ << _SuspendedThreads << " suspended threads"
+ << endl ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_unlock _ExitThread") ;
+ exit( 0 ) ;
+ }
+ if ( _Threads == 0 && _SuspendedThreads == 0 ) {
+ CheckAllDone() ;
+ }
+}
+void GraphExecutor::OutNode::JoinedWait() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock JoinedWait") ;
+ exit( 0 ) ;
+ }
+ while ( _Threads ) {
+ if ( pthread_cond_wait( &_JoinWait , &_MutexWait ) ) {
+ perror("JoinedWait pthread_cond_wait ") ;
+ }
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_unlock JoinedWait") ;
+ exit( 0 ) ;
+ }
+}
+void GraphExecutor::OutNode::SuspendThread() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _SuspendThread") ;
+ exit( 0 ) ;
+ }
+ _SuspendedThreads += 1 ;
+ cdebug << "SuspendThread : " << _Threads << " running threads "
+ << _SuspendedThreads << " suspended threads"
+ << endl ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_unlock _SuspendThread") ;
+ exit( 0 ) ;
+ }
+ if ( IsSuspended() ) {
+ PushEvent( NULL , GraphExecutor::SuspendEvent , SUPERV::SuspendedState ) ;
+ }
+}
+void GraphExecutor::OutNode::ResumeThread() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _ResumeThread") ;
+ exit( 0 ) ;
+ }
+ _SuspendedThreads -= 1 ;
+ cdebug << "ResumeThread : " << _Threads << " running threads "
+ << _SuspendedThreads << " suspended threads"
+ << endl ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_unlock _ResumeThread") ;
+ exit( 0 ) ;
+ }
+}
+
+long GraphExecutor::OutNode::Thread( const char * aNodeName ) {
+ long RetVal = 0 ;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ;
+ if ( anInNode ) {
+ RetVal = anInNode->ThreadNo() ;
+ }
+ return RetVal ;
+}
+
+SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent ) {
+ SUPERV::GraphEvent aGraphEvent ;
+ switch ( anEvent ) {
+ case GraphExecutor::UndefinedEvent : {
+ aGraphEvent = SUPERV::UndefinedEvent ;
+ break ;
+ }
+ case GraphExecutor::NewThreadEvent : {
+ aGraphEvent = SUPERV::NewThreadEvent ;
+ break ;
+ }
+ case GraphExecutor::SuspendEvent : {
+ aGraphEvent = SUPERV::SuspendEvent ;
+ break ;
+ }
+ case GraphExecutor::ResumeEvent : {
+ aGraphEvent = SUPERV::ResumeEvent ;
+ break ;
+ }
+ case GraphExecutor::KillEvent : {
+ aGraphEvent = SUPERV::KillEvent ;
+ break ;
+ }
+ case GraphExecutor::StopEvent : {
+ aGraphEvent = SUPERV::StopEvent ;
+ break ;
+ }
+ case GraphExecutor::ExecuteEvent : {
+ aGraphEvent = SUPERV::RunningEvent ;
+ break ;
+ }
+ case GraphExecutor::SuccessEvent : {
+ aGraphEvent = SUPERV::DoneEvent ;
+ break ;
+ }
+ case GraphExecutor::ErrorEvent : {
+ aGraphEvent = SUPERV::ErroredEvent ;
+ break ;
+ }
+ case GraphExecutor::ReStartEvent : {
+ aGraphEvent = SUPERV::ReRunEvent ;
+ break ;
+ }
+ case GraphExecutor::ReStartAndSuspendEvent : {
+ aGraphEvent = SUPERV::ReStartEvent ;
+ break ;
+ }
+ case GraphExecutor::NoDataReadyEvent : {
+ aGraphEvent = SUPERV::WaitingEvent ;
+ break ;
+ }
+ case GraphExecutor::SomeDataReadyEvent : {
+ aGraphEvent = SUPERV::WaitingEvent ;
+ break ;
+ }
+ case GraphExecutor::NotAllDataReadyEvent : {
+ aGraphEvent = SUPERV::WaitingEvent ;
+ break ;
+ }
+ case GraphExecutor::AllDataReadyEvent : {
+ aGraphEvent = SUPERV::ReadyEvent ;
+ break ;
+ }
+ case GraphExecutor::ReadyEvent : {
+ aGraphEvent = SUPERV::ReadyEvent ;
+ break ;
+ }
+ case GraphExecutor::SuspendedReadyEvent : {
+ aGraphEvent = SUPERV::SuspendEvent ;
+ break ;
+ }
+ case GraphExecutor::ResumedReadyEvent : {
+ aGraphEvent = SUPERV::ResumeEvent ;
+ break ;
+ }
+ case GraphExecutor::KilledReadyEvent : {
+ aGraphEvent = SUPERV::KillEvent ;
+ break ;
+ }
+ case GraphExecutor::StoppedReadyEvent : {
+ aGraphEvent = SUPERV::StopEvent ;
+ break ;
+ }
+ case GraphExecutor::ExecutingEvent : {
+ aGraphEvent = SUPERV::RunningEvent ;
+ break ;
+ }
+ case GraphExecutor::SuspendedExecutingEvent : {
+ aGraphEvent = SUPERV::SuspendEvent ;
+ break ;
+ }
+ case GraphExecutor::ResumedExecutingEvent : {
+ aGraphEvent = SUPERV::ResumeEvent ;
+ break ;
+ }
+ case GraphExecutor::KilledExecutingEvent : {
+ aGraphEvent = SUPERV::KillEvent ;
+ break ;
+ }
+ case GraphExecutor::StoppedExecutingEvent : {
+ aGraphEvent = SUPERV::StopEvent ;
+ break ;
+ }
+ case GraphExecutor::SuccessedExecutingEvent : {
+ aGraphEvent = SUPERV::DoneEvent ;
+ break ;
+ }
+ case GraphExecutor::ErroredExecutingEvent : {
+ aGraphEvent = SUPERV:: ErroredEvent;
+ break ;
+ }
+ case GraphExecutor::SuspendedSuccessedEvent : {
+ aGraphEvent = SUPERV::SuspendEvent ;
+ break ;
+ }
+ case GraphExecutor::SuspendedErroredEvent : {
+ aGraphEvent = SUPERV::SuspendEvent ;
+ break ;
+ }
+ case GraphExecutor::ResumedSuccessedEvent : {
+ aGraphEvent = SUPERV::ResumeEvent ;
+ break ;
+ }
+ case GraphExecutor::ResumedErroredEvent : {
+ aGraphEvent = SUPERV::ResumeEvent ;
+ break ;
+ }
+ case GraphExecutor::KilledEvent : {
+ aGraphEvent = SUPERV::KillEvent ;
+ break ;
+ }
+ case GraphExecutor::StoppedEvent : {
+ aGraphEvent = SUPERV::StopEvent ;
+ break ;
+ }
+ case GraphExecutor::ReStartedEvent : {
+ aGraphEvent = SUPERV::ReRunEvent ;
+ break ;
+ }
+ case GraphExecutor::ReStartedAndSuspendEvent : {
+ aGraphEvent = SUPERV::ReStartEvent ;
+ break ;
+ }
+ case GraphExecutor::EndExecuteEvent : {
+ aGraphEvent = SUPERV::DoneEvent ;
+ break ;
+ }
+ default : {
+ cdebug << " GraphExecutor::OutNode::AutomatonGraphEvent Error Undefined Event : "
+ << anEvent << endl ;
+ aGraphEvent = SUPERV::UndefinedEvent ;
+ }
+ }
+ return aGraphEvent ;
+}
+
+SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::AutomatonState aState ) {
+ SUPERV::GraphState aGraphState ;
+ switch ( aState ) {
+ case SUPERV::UnKnownState : {
+ aGraphState = SUPERV::UndefinedState ;
+ break ;
+ }
+ case SUPERV::DataUndefState : {
+ aGraphState = SUPERV::UndefinedState ;
+ break ;
+ }
+ case SUPERV::DataWaitingState : {
+ aGraphState = SUPERV::WaitingState ;
+ break ;
+ }
+ case SUPERV::DataReadyState : {
+ aGraphState = SUPERV::ReadyState ;
+ break ;
+ }
+ case SUPERV::SuspendedReadyState : {
+ aGraphState = SUPERV::SuspendReadyState ;
+ break ;
+ }
+ case SUPERV::ResumedReadyState : {
+ aGraphState = SUPERV::ReadyState ;
+ break ;
+ }
+ case SUPERV::KilledReadyState : {
+ aGraphState = SUPERV::KillState ;
+ break ;
+ }
+ case SUPERV::StoppedReadyState : {
+ aGraphState = SUPERV::StopState ;
+ break ;
+ }
+ case SUPERV::ExecutingState : {
+ aGraphState = SUPERV::RunningState ;
+ break ;
+ }
+ case SUPERV::SuspendedExecutingState : {
+ aGraphState = SUPERV::SuspendState ;
+ break ;
+ }
+ case SUPERV::ResumedExecutingState : {
+ aGraphState = SUPERV::RunningState ;
+ break ;
+ }
+ case SUPERV::KilledExecutingState : {
+ aGraphState = SUPERV::KillState ;
+ break ;
+ }
+ case SUPERV::StoppedExecutingState : {
+ aGraphState = SUPERV::StopState ;
+ break ;
+ }
+ case SUPERV::SuccessedExecutingState : {
+ aGraphState = SUPERV::DoneState ;
+ break ;
+ }
+ case SUPERV::ErroredExecutingState : {
+ aGraphState = SUPERV::ErrorState ;
+ break ;
+ }
+ case SUPERV::SuspendedSuccessedState : {
+ aGraphState = SUPERV::SuspendDoneState ;
+ break ;
+ }
+ case SUPERV::SuspendedErroredState : {
+ aGraphState = SUPERV::SuspendErroredState ;
+ break ;
+ }
+ case SUPERV::ResumedSuccessedState : {
+ aGraphState = SUPERV::DoneState ;
+ break ;
+ }
+ case SUPERV::ResumedErroredState : {
+ aGraphState = SUPERV::ErrorState ;
+ break ;
+ }
+ case SUPERV::KilledSuccessedState : {
+ aGraphState = SUPERV::KillState ;
+ break ;
+ }
+ case SUPERV::KilledErroredState : {
+ aGraphState = SUPERV::KillState ;
+ break ;
+ }
+ case SUPERV::StoppedSuccessedState : {
+ aGraphState = SUPERV::StopState ;
+ break ;
+ }
+ case SUPERV::StoppedErroredState : {
+ aGraphState = SUPERV::StopState ;
+ break ;
+ }
+ case SUPERV::SuccessedState : {
+ aGraphState = SUPERV::DoneState ;
+ break ;
+ }
+ case SUPERV::ErroredState : {
+ aGraphState = SUPERV::ErrorState ;
+ break ;
+ }
+ case SUPERV::SuspendedState : {
+ aGraphState = SUPERV::SuspendState ;
+ break ;
+ }
+ case SUPERV::KilledState : {
+ aGraphState = SUPERV::KillState ;
+ break ;
+ }
+ case SUPERV::StoppedState : {
+ aGraphState = SUPERV::StopState ;
+ break ;
+ }
+ case SUPERV::ReRunnedState : {
+ aGraphState = SUPERV::ReRunState ;
+ break ;
+ }
+ case SUPERV::ReStartedState : {
+ aGraphState = SUPERV::ReStartState ;
+ break ;
+ }
+ default : {
+ cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : "
+ << aGraphState << endl ;
+ aGraphState = SUPERV::UndefinedState ;
+ }
+ }
+ return aGraphState ;
+}
+
+bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
+ GraphExecutor::NodeEvent anEvent ,
+ SUPERV::AutomatonState aState ) {
+ cdebug_in << "PushEvent Threads " << Threads() << " SuspendedThreads "
+ << SuspendedThreads() << endl ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("PushEvent pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( aNode ) {
+ _EventNodes.push_back( aNode->Name() ) ;
+ }
+ else {
+ _EventNodes.push_back( Name() ) ;
+ }
+ _Events.push_back( anEvent ) ;
+ _States.push_back( aState ) ;
+ pthread_cond_broadcast( &_EventWait );
+ if ( aNode ) {
+ cdebug << aNode->ThreadNo() << " PushEvent " << aNode->Name() ;
+ cdebug << " " << aNode->Automaton()->EventName( anEvent )
+ << " " << aNode->Automaton()->StateName( aState )
+ << " ControleState "
+ << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ;
+ }
+ else {
+ cdebug << "PushEvent " << Name() ;
+ cdebug << " " << theAutomaton->EventName( anEvent ) << " "
+ << theAutomaton->StateName( aState ) ;
+ }
+ cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
+ << SuspendedThreads() << endl ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("PushEvent pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+bool GraphExecutor::OutNode::StateWait( SUPERV::GraphState aState ) {
+}
+
+bool GraphExecutor::OutNode::Event( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ,
+ bool WithWait ) {
+ int ThreadsNumber ;
+ int SuspendedThreadsNumber ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("EventLoop pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ _JustStarted = false ;
+ ThreadsNumber = Threads() ;
+ SuspendedThreadsNumber = SuspendedThreads() ;
+ bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
+ _EventNodes.size() > 0 ;
+ char * NodeName = "" ;
+ GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
+ SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
+ anEvent = SUPERV::UndefinedEvent ;
+ aState = SUPERV::UndefinedState ;
+ if ( ( IsDone() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
+ cdebug << "EventLoop IsDone()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
+ RetVal = false ;
+ }
+ else if ( !WithWait && _EventNodes.size() == 0 ) {
+ anEvent = SUPERV::NoEvent ;
+ aState = SUPERV::NoState ;
+ RetVal = true ;
+ }
+ else if ( RetVal ) {
+ while ( !IsSuspended() && _EventNodes.size() == 0 ) {
+ cdebug << "EventLoop pthread_cond_wait _EventWait" << endl ;
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ cdebug << "EventLoop pthread_cond_waited _EventWait"
+ << " _EventNodes.size() " << _EventNodes.size() << endl ;
+ }
+ if ( _EventNodes.size() ) {
+ ThreadsNumber = Threads() ;
+ NodeName = _EventNodes.front() ;
+ _EventNodes.pop_front() ;
+ theEvent = _Events.front() ;
+ anEvent = AutomatonGraphEvent( theEvent ) ;
+ _Events.pop_front() ;
+ theState = _States.front() ;
+ aState = AutomatonGraphState( theState ) ;
+ _States.pop_front() ;
+ }
+ }
+ *aNodeName = NodeName ;
+ if ( IsSuspended() && _EventNodes.size() == 0 ) {
+ RetVal = false ;
+ }
+ if ( anEvent != SUPERV::NoEvent ) {
+ cdebug << pthread_self() << "EventLoop "
+ << NodeName << " " << theAutomaton->StateName( theState )
+ << " _EventNodes.size() " << _EventNodes.size()
+ << " Threads " << Threads() << " SuspendedThreads "
+ << SuspendedThreads() << " RetVal " << RetVal << endl ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("EventLoop pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::EventW( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ) {
+ bool sts = true ;
+ char * NodeName ;
+ aState = SUPERV::UndefinedState ;
+ while ( sts &&
+ aState != SUPERV::SuspendReadyState &&
+ aState != SUPERV::RunningState &&
+ aState != SUPERV::SuspendDoneState &&
+ aState != SUPERV::SuspendErroredState ) {
+ NodeName = Name() ;
+ while ( sts && !strcmp( NodeName , Name() ) ) {
+ sts = EventWait( aNodeName , anEvent , aState ) ;
+ NodeName = *aNodeName ;
+ }
+ }
+ return sts ;
+}
+
+bool GraphExecutor::OutNode::EventWait( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ) {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("EventW pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ int ThreadsNumber ;
+ int SuspendedThreadsNumber ;
+ ThreadsNumber = Threads() ;
+ SuspendedThreadsNumber = SuspendedThreads() ;
+ bool RetVal = ( ThreadsNumber - SuspendedThreadsNumber) != 0 ||
+ _EventNodes.size() > 0 ;
+ cdebug << "--> EventW RetVal " << RetVal << endl ;
+ char * NodeName = "" ;
+ GraphExecutor::NodeEvent theEvent = GraphExecutor::UndefinedEvent ;
+ SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
+ anEvent = SUPERV::UndefinedEvent ;
+ aState = SUPERV::UndefinedState ;
+ if ( IsDone() && _EventNodes.size() == 0 ) {
+ cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
+ RetVal = 0 ;
+ }
+ else if ( RetVal ) {
+ GraphExecutor::InNode * aNode = NULL ;
+ while ( aNode == NULL && RetVal ) {
+ NodeName = _EventNodes.front() ;
+ theEvent = _Events.front() ;
+ anEvent = AutomatonGraphEvent( theEvent ) ;
+ theState = _States.front() ;
+ aState = AutomatonGraphState( theState ) ;
+
+ if ( _JustStarted ) {
+ _JustStarted = false ;
+ }
+ else {
+ _EventNodes.pop_front() ;
+ _Events.pop_front() ;
+ _States.pop_front() ;
+ }
+
+ aNode = ((GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode()) ;
+ cdebug << "EventW Previous Node " << NodeName << " ThreadsNumber "
+ << ThreadsNumber
+ << " _EventNodes.size() " << _EventNodes.size() << " "
+ << theAutomaton->StateName( theState )
+ << " Threads " << Threads() << " SuspendedThreads "
+ << SuspendedThreads() << endl ;
+ if ( aNode ) {
+ }
+ else if ( IsDone() && _EventNodes.size() == 0 ) {
+ cdebug << "EventW IsDone() && _EventNodes.size() == 0" << endl ;
+ RetVal = 0 ;
+ }
+ else {
+ cdebug << "EventW Not InNode " << NodeName
+ << " _EventNodes.size() " << _EventNodes.size() << endl ;
+ while ( _EventNodes.size() == 0 ) {
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ }
+ cdebug << "EventW pthread_cond_waited Not InNode " << NodeName
+ << " _EventNodes.size() " << _EventNodes.size() << endl ;
+ }
+ }
+
+ if ( aNode ) {
+ if ( aState == SUPERV::SuspendState ||
+ aState == SUPERV::SuspendReadyState ||
+ aState == SUPERV::SuspendDoneState ||
+ aState == SUPERV::SuspendErroredState ) {
+ aNode->ControlState( SUPERV::ToSuspendState ) ;
+ if ( aNode->IsSuspended() ) {
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("EventW pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ cdebug << "EventW " << aNode->Name() << " ResumeAction" << endl ;
+ aNode->ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ cdebug << "EventW " << aNode->Name() << " ResumedAction" << endl ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("EventW pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ }
+ else {
+ cdebug << "EventW inconsistent SuspendState" << endl ;
+ RetVal = false ;
+ }
+ }
+ else {
+ if ( aNode->IsDone() ) {
+ RetVal = true ;
+ }
+ else {
+ cdebug << "EventW NOT SuspendedState _EventNodes.size() "
+ << _EventNodes.size() << endl ;
+ RetVal = true ;
+ }
+ }
+ if ( RetVal ) {
+ cdebug << "EventW " << aNode->Name() << " pthread_cond_wait" << endl ;
+ while ( _EventNodes.size() == 0 ) {
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ }
+ ThreadsNumber = Threads() ;
+ NodeName = _EventNodes.front() ;
+ theEvent = _Events.front() ;
+ anEvent = AutomatonGraphEvent( theEvent ) ;
+ theState = _States.front() ;
+ aState = AutomatonGraphState( theState ) ;
+ }
+ }
+ }
+ *aNodeName = NodeName ;
+ cdebug << "<-- EventW RetVal " << RetVal << " " << NodeName
+ << " Threads " << Threads() << " SuspendedThreads "
+ << SuspendedThreads()
+ << " _EventNodes.size() " << _EventNodes.size()
+ << " " << theAutomaton->EventName( theEvent ) << " "
+ << theAutomaton->StateName( theState ) << endl ;
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("EventW pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ return RetVal ;
+}
+
+void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) {
+ _State = aState ;
+}
+
+SUPERV::GraphState GraphExecutor::OutNode::State() {
+// cdebug_in << "GraphExecutor::OutNode::State" << endl;
+// cdebug_out << "GraphExecutor::OutNode::State" << endl ;
+// cdebug << "GraphExecutor::OutNode::State GraphState "
+// << theAutomaton->StateName( AutomatonGraphState( _State ) ) << endl ;
+ return AutomatonGraphState( _State ) ;
+}
+
+SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) {
+// cdebug_in << "GraphExecutor::OutNode::State " << NodeName << endl;
+ SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
+ const GraphBase::ComputingNode * aCNode = GetGraphNode( NodeName ) ;
+ if ( aCNode ) {
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->State() ;
+ cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) "
+ << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ;
+ }
+ }
+// cdebug_out << "GraphExecutor::OutNode::State" << endl ;
+ return AutomatonGraphState( aret ) ;
+}
+
+SUPERV::GraphState GraphExecutor::OutNode::State(
+ const char * NodeName ,
+ const char * ServiceParameterName ) {
+// cdebug_in << "GraphExecutor::OutNode::State " << NodeName << " "
+// << ServiceParameterName<< endl;
+ SUPERV::GraphState aret =
+ PortState( NodeName , ServiceParameterName ) ;
+// cdebug_out << "GraphExecutor::OutNode::State" << endl ;
+ return aret ;
+}
+
+SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState() {
+// cdebug_in << "GraphExecutor::OutNode::AutomatonState" << endl;
+// cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
+ return _State ;
+}
+
+SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState( const char * NodeName ) {
+// cdebug_in << "GraphExecutor::OutNode::AutomatonState " << NodeName << endl;
+ SUPERV::AutomatonState aret = SUPERV::UnKnownState ;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode )
+ aret = anInNode->State() ;
+// cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ;
+ return aret ;
+}
+
+SUPERV::ControlState GraphExecutor::OutNode::ControlState() {
+// cdebug_in << "GraphExecutor::OutNode::ControlState" << endl;
+// cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
+ return _ControlState ;
+}
+
+SUPERV::ControlState GraphExecutor::OutNode::ControlState( const char * NodeName ) {
+// cdebug_in << "GraphExecutor::OutNode::ControlState " << NodeName << endl;
+ SUPERV::ControlState aret = SUPERV::VoidState ;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode )
+ aret = anInNode->ControlState() ;
+// cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ;
+ return aret ;
+}
+
+void GraphExecutor::OutNode::ControlClear() {
+// cdebug_in << "GraphExecutor::OutNode::ControlClear" << endl;
+// cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
+ _ControlState = SUPERV::VoidState;
+}
+
+void GraphExecutor::OutNode::ControlClear( const char * NodeName ) {
+// cdebug_in << "GraphExecutor::OutNode::ControlClear " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode )
+ anInNode->ControlClear() ;
+// cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ;
+}
+
+bool GraphExecutor::OutNode::IsWaiting() {
+// cdebug_in << "GraphExecutor::OutNode::IsWaiting" << endl;
+// cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
+ return !_Done ;
+}
+
+bool GraphExecutor::OutNode::IsReady() {
+// cdebug_in << "GraphExecutor::OutNode::IsReady" << endl;
+// cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
+ return !_Done ;
+}
+
+bool GraphExecutor::OutNode::IsRunning() {
+// cdebug_in << "GraphExecutor::OutNode::IsRunning" << endl;
+// cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
+ return !_Done ;
+}
+
+bool GraphExecutor::OutNode::IsDone() {
+// cdebug_in << "GraphExecutor::OutNode::IsDone" << endl;
+// cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
+ return ( _Done || IsKilled() || IsStopped() ) ;
+}
+
+bool GraphExecutor::OutNode::IsSuspended() {
+// cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl;
+ bool aret = false ;
+ if ( _SuspendedThreads == _Threads ) {
+ aret = true ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsKilled() {
+// cdebug_in << "GraphExecutor::OutNode::IsKilled" << endl;
+ bool aret = false ;
+ if ( AutomatonGraphState( _State ) == SUPERV::KillState ) {
+ aret = true ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsKilled" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsStopped() {
+// cdebug_in << "GraphExecutor::OutNode::IsStopped" << endl;
+ bool aret = false ;
+ if ( AutomatonGraphState( _State ) == SUPERV::StopState ) {
+ aret = true ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsStopped" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::OutNode::IsWaiting " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->IsWaiting() ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsReady( const char * NodeName ) {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::OutNode::IsReady " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->IsReady() ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::OutNode::IsRunning " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->IsRunning() ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsDone( const char * NodeName ) {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->IsDone() ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsSuspended( const char * NodeName ) {
+ bool aret = false ;
+// cdebug_in << "GraphExecutor::OutNode::IsSuspended " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->IsSuspended() ;
+ }
+// cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::IsDone( const char * NodeName ,
+ const char * ServiceParameterName ) {
+// cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " "
+// << ServiceParameterName<< endl;
+ bool aret = PortDone( NodeName , ServiceParameterName ) ;
+// cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::ContainerKill() {
+ bool RetVal = true ;
+ cdebug_in << "GraphExecutor::OutNode::ContainerKill" << endl;
+ _ControlState = SUPERV::ToSuspendState ;
+ int i ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+ bool sts = aNode->ContainerKill() ;
+ if ( sts && aNode->IsKilled() ) {
+ cdebug << aNode->Name() << " killed" << endl ;
+ }
+ else if ( aNode->IsWaiting() || aNode->IsDone() ) {
+ cdebug << aNode->Name() << " not killed : "
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
+ else {
+ cdebug << aNode->Name() << " cannot be killed : "
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ RetVal = false ;
+ }
+ }
+ if ( !RetVal || Threads() != 0 ) {
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+ if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
+ aNode->KilledAction() ;
+ }
+ }
+ RetVal = true ;
+ }
+ State( SUPERV::KilledState ) ;
+ cdebug_out << "GraphExecutor::OutNode::ContainerKill" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::Suspend() {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::Suspend" << endl;
+ _ControlState = SUPERV::ToSuspendState ;
+ int i ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+ bool sts = aNode->Suspend() ;
+ if ( sts && aNode->IsSuspended() ) {
+ cdebug << aNode->Name() << " Suspend" << endl ;
+ }
+ else if ( aNode->IsWaiting() || aNode->IsDone() ) {
+ cdebug << aNode->Name() << " not Suspended : "
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
+ else {
+ cdebug << aNode->Name() << " cannot be Suspended : "
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ RetVal = false ;
+ }
+ }
+ State( SUPERV::SuspendedState ) ;
+ cdebug_out << "GraphExecutor::OutNode::Suspend" << endl ;
+ return RetVal ;
+}
+bool GraphExecutor::OutNode::Resume() {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
+ cdebug_out << "GraphExecutor::OutNode::Resume" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::Kill() {
+ bool RetVal = true ;
+ cdebug_in << "GraphExecutor::OutNode::Kill" << endl;
+ _ControlState = SUPERV::ToSuspendState ;
+ int i ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+ bool sts = aNode->Kill() ;
+ if ( sts && aNode->IsKilled() ) {
+ cdebug << aNode->Name() << " killed" << endl ;
+ }
+ else if ( aNode->IsWaiting() || aNode->IsDone() ) {
+ cdebug << aNode->Name() << " not killed : "
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
+ else {
+ cdebug << aNode->Name() << " cannot be killed : "
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ RetVal = false ;
+ }
+ }
+ if ( !RetVal || Threads() != 0 ) {
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+ if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
+ aNode->KilledAction() ;
+ }
+ }
+ RetVal = true ;
+ }
+ State( SUPERV::KilledState ) ;
+ cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::Stop() {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::Stop" << endl;
+ Kill() ;
+ cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
+ return RetVal ;
+}
+bool GraphExecutor::OutNode::ReRun() {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::ReRun" << endl;
+ if ( IsSuspended() ) {
+ }
+ cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ;
+ return RetVal ;
+}
+bool GraphExecutor::OutNode::ReStart() {
+ bool RetVal = false ;
+ cdebug_in << "GraphExecutor::OutNode::ReStart" << endl;
+ if ( IsSuspended() ) {
+ }
+ cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ;
+ return RetVal ;
+}
+
+bool GraphExecutor::OutNode::ReadyWait() {
+ cdebug_in << "GraphExecutor::OutNode::ReadyWait" << endl;
+ bool aret ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _ReadyWait") ;
+ exit( 0 ) ;
+ }
+ aret = IsReady() ;
+ if ( !aret ) {
+ Suspend() ;
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ aret = IsReady() ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _ReadyWait") ;
+ exit( 0 ) ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::RunningWait() {
+ cdebug_in << "GraphExecutor::OutNode::RunningWait" << endl;
+ bool aret ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _RunningWait") ;
+ exit( 0 ) ;
+ }
+ aret = IsRunning() ;
+ if ( !aret ) {
+ cdebug << "RunningWait pthread_cond_wait _EventWait" << endl;
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ aret = IsRunning() ;
+ cdebug << "RunningWait pthread_cond_waited _EventWait " << aret << endl;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _RunningWait") ;
+ exit( 0 ) ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::RunningWait " << aret << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::DoneWait() {
+ cdebug_in << "GraphExecutor::OutNode::DoneWait" << endl;
+ bool aret ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _DoneWait") ;
+ exit( 0 ) ;
+ }
+ aret = IsDone() ;
+ while ( !aret && !IsSuspended() ) {
+ cdebug << "DoneWait pthread_cond_wait _EventWait" << endl;
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ aret = IsDone() ;
+ cdebug << "DoneWait pthread_cond_waited _EventWait " << aret << endl;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _DoneWait") ;
+ exit( 0 ) ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::DoneWait " << aret << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::SuspendedWait() {
+ cdebug_in << "GraphExecutor::OutNode::SuspendedWait" << endl;
+ bool aret ;
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _SuspendedWait") ;
+ exit( 0 ) ;
+ }
+ aret = IsSuspended() ;
+ while ( !aret && !_Done ) {
+ pthread_cond_wait( &_EventWait , &_MutexWait );
+ aret = IsSuspended() ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("pthread_mutex_lock _SuspendedWait") ;
+ exit( 0 ) ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) {
+ bool aret = false ;
+ cdebug_in << "GraphExecutor::OutNode::ReadyWait " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->ReadyWait() ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::ReadyWait" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) {
+ bool aret = false ;
+ cdebug_in << "GraphExecutor::OutNode::RunningWait " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->RunningWait() ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::RunningWait" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) {
+ bool aret = false ;
+ cdebug_in << "GraphExecutor::OutNode::DoneWait " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->DoneWait() ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::DoneWait" << endl ;
+ return aret ;
+}
+
+bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) {
+ bool aret = false ;
+ cdebug_in << "GraphExecutor::OutNode::SuspendedWait " << NodeName << endl;
+ GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ;
+ if ( anInNode ) {
+ aret = anInNode->SuspendedWait() ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::SuspendedWait" << endl ;
+ return aret ;
+}
+
+long GraphExecutor::OutNode::LastLevelDone() {
+ int RetVal = -1 ;
+ int i , j ;
+ for ( i = 0 ; i <= LevelMax() ; i++ ) {
+ for ( j = 0 ; j <= NodesNumber( i ) ; j++ ) {
+ GraphBase::ComputingNode * aNode = SortedNodes( i , j ) ;
+ if ( !IsDone( aNode->Name() ) ) {
+ break ;
+ }
+ }
+ if ( j != NodesNumber( i ) + 1 )
+ break ;
+ RetVal = i ;
+ }
+ return RetVal ;
+}
+
+
+const CORBA::Any *GraphExecutor::OutNode::GetInData(
+ const char * NodeName ,
+ const char * ServiceParameterName ) {
+ cdebug_in << "GraphExecutor::OutNode::GetInData " << NodeName << " "
+ << ServiceParameterName << endl ;
+ const CORBA::Any * retdata = PortInData( NodeName , ServiceParameterName ) ;
+ cdebug_out << "GraphExecutor::OutNode::GetInData" << endl ;
+ return retdata ;
+}
+
+const CORBA::Any *GraphExecutor::OutNode::GetOutData(
+ const char * NodeName ,
+ const char * ServiceParameterName ) {
+ cdebug_in << "GraphExecutor::OutNode::GetData " << NodeName << " "
+ << ServiceParameterName << endl ;
+ const CORBA::Any * retdata = PortOutData( NodeName , ServiceParameterName ) ;
+ cdebug_out << "GraphExecutor::OutNode::GetOutData" << endl ;
+ return retdata ;
+}
+
--- /dev/null
+//=============================================================================
+// File : DataFlowBase_OutNode.hxx
+// Created : 2002
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#ifndef _DATAFLOWEXECUTOR_OUTNODE_HXX
+#define _DATAFLOWEXECUTOR_OUTNODE_HXX
+
+#include "SALOME_Component_i.hxx"
+
+#include "DataFlowBase_Graph.hxx"
+
+#include "DataFlowExecutor_InNode.hxx"
+
+namespace GraphExecutor {
+
+ class OutNode : public GraphBase::Graph {
+
+ private :
+
+ bool _PyInitialized ;
+ bool _Valid ;
+ bool _Executable ;
+ SUPERV::AutomatonState _State ;
+ SUPERV::ControlState _ControlState ;
+ bool _Done ;
+
+ pthread_mutex_t _MutexWait ;
+ pthread_cond_t _EventWait ;
+ pthread_cond_t _JoinWait ;
+ bool _JustStarted ;
+ int _Threads ; // Number of threads
+ int _SuspendedThreads ;
+ list< char * > _EventNodes ;
+ list< GraphExecutor::NodeEvent > _Events ;
+ list< SUPERV::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 ) ;
+
+ CORBA::ORB_ptr _Orb ;
+
+ public :
+
+ OutNode() ;
+ OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
+ const char *DataFlowName ,
+ const char * DebugFileName );
+ OutNode( 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 * DataFlowEditorRelease ,
+ const char * DataFlowAuthor ,
+ const char * DataFlowComputer ,
+ const char * DataFlowComment ,
+ const char * DebugFileName ) ;
+ virtual ~OutNode() ;
+
+ bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
+ bool LoadXml( const char* myFileName ) ;
+ bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
+
+ GraphExecutor::InNode * AddNode(
+ const SALOME_ModuleCatalog::Service& NodeService ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const char * NodeComponentName ,
+ const char * NodeInterfaceName ,
+ const char * NodeName ,
+ 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 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 ; } ;
+ bool IsExecutable() { if ( !_Executable )
+ return Executable() ;
+ return _Executable ; } ;
+
+ bool Run( const bool AndSuspend ) ;
+ bool Run( const char * aNodeName , const char * AtNodeName ,
+ const bool AndSuspend ) ;
+
+ void PyInitialized( bool init ) {
+ _PyInitialized = init ; } ;
+ bool PyInitialized() {
+ return _PyInitialized ; } ;
+
+ void CheckAllDone() ;
+
+ void NewThread() ;
+ void ExitThread() ;
+ void SuspendThread() ;
+ void ResumeThread() ;
+ long Threads() { return _Threads ; } ;
+ long SuspendedThreads() { return _SuspendedThreads ; } ;
+ void JoinedWait() ;
+
+ long Thread( const char * NodeName ) ;
+
+ bool PushEvent( GraphExecutor::InNode * aNode ,
+ GraphExecutor::NodeEvent anEvent ,
+ SUPERV::AutomatonState aState ) ;
+ bool StateWait( SUPERV::GraphState aState ) ;
+ bool Event( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ,
+ bool WithWait ) ;
+ bool EventW( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ) ;
+ bool EventWait( char ** aNodeName ,
+ SUPERV::GraphEvent & anEvent ,
+ SUPERV::GraphState & aState ) ;
+
+ void State(SUPERV::AutomatonState aState ) ;
+
+ SUPERV::GraphState State() ;
+ SUPERV::GraphState State( const char * NodeName ) ;
+ SUPERV::GraphState State( const char * NodeName ,
+ const char * ServiceParameterName ) ;
+
+ SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
+ SUPERV::GraphState AutomatonGraphState(SUPERV::AutomatonState anAutomatonState) ;
+
+ SUPERV::AutomatonState AutomatonState() ;
+ SUPERV::AutomatonState AutomatonState( const char * NodeName ) ;
+
+ SUPERV::ControlState ControlState() ;
+ SUPERV::ControlState ControlState( const char * aNodeName ) ;
+ void ControlClear() ;
+ void ControlClear( const char * aNodeName ) ;
+
+ bool ContainerKill() ;
+
+ bool Suspend() ;
+ bool Resume() ;
+ bool Kill() ;
+ bool Stop() ;
+ bool ReRun() ;
+ bool ReStart() ;
+
+ void Done( bool aDone ) { _Done = aDone ; } ;
+
+ bool IsWaiting() ;
+ bool IsReady() ;
+ bool IsRunning() ;
+ bool IsDone() ;
+ bool IsSuspended() ;
+ bool IsKilled() ;
+ bool IsStopped() ;
+ bool IsWaiting( const char * NodeName ) ;
+ bool IsReady( const char * NodeName ) ;
+ bool IsRunning( const char * NodeName ) ;
+ bool IsDone( const char * NodeName ) ;
+ bool IsSuspended( const char * NodeName ) ;
+ bool IsDone( const char * NodeName ,
+ const char * ServiceParameterName ) ;
+ long LastLevelDone() ;
+
+ bool ReadyWait() ;
+ bool RunningWait() ;
+ bool DoneWait() ;
+ bool SuspendedWait() ;
+ bool ReadyWait( const char * NodeName ) ;
+ bool RunningWait( const char * NodeName ) ;
+ 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 ) ;
+ };
+};
+
+#endif
--- /dev/null
+using namespace std;
+//=============================================================================
+// File : DataFlowExecutor_PyDynInvoke.cxx
+// Created : 2003
+// Author : Jean Rahuel, CEA
+// Project : SALOME
+// $Header:
+//=============================================================================
+
+#include <stdarg.h>
+#include <map>
+
+#include "DataFlowExecutor_InNode.hxx"
+
+using namespace CORBA ;
+
+static PyObject * MyPyObjRef = NULL ;
+static PyObject * MyPyObjIor = NULL ;
+static PyObject * MyPyRunMethod = NULL ;
+
+static PyMethodDef MethodPyRunMethod[] = {
+ { "RunMethod", PyRunMethod, METH_VARARGS },
+ { NULL, NULL }
+};
+
+bool GraphExecutor::InNode::InitPython() {
+ cdebug_in << "InitPython" << endl ;
+
+ PyObject * Module = Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ;
+ PyObject * Dictionnary = PyModule_GetDict( Module ) ;
+// InitPyDynInvokeError = PyErr_NewException( "InitPyDynInvokeError" , NULL , NULL ) ;
+// PyDict_SetItemString( Dictionnary , InitPyDynInvokeError ) ;
+ cdebug << ThreadNo() << "Py_Initialized() " << endl ;
+
+ string aPyFunc ;
+ aPyFunc = "print 'InitPyRunMethod'\n" ;
+ aPyFunc += "import InitPyRunMethod\n" ;
+ aPyFunc += "print 'sys'\n" ;
+ aPyFunc += "import sys\n" ;
+ aPyFunc += "print 'CORBA'\n" ;
+ aPyFunc += "import CORBA\n" ;
+ aPyFunc += "print 'omniORB'\n" ;
+ aPyFunc += "import omniORB\n" ;
+ aPyFunc += "print 'PyObjRef'\n" ;
+ aPyFunc += "def PyObjRef( IORObjStr ) :\n" ;
+// aPyFunc += " print 'PyObjRef',IORObjStr\n" ;
+ aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
+ aPyFunc += " objref = orb.string_to_object( IORObjStr )\n" ;
+// aPyFunc += " print IORObjStr,objref\n" ;
+// aPyFunc += " return objref,objref\n" ;
+ aPyFunc += " return objref\n" ;
+ aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ;
+ if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
+ cdebug << ThreadNo() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
+ return false ;
+ }
+ MyPyObjRef = MyPyRunMethod ;
+
+ aPyFunc = "import InitPyRunMethod\n" ;
+ aPyFunc += "import sys\n" ;
+ aPyFunc += "import CORBA\n" ;
+ aPyFunc += "import omniORB\n" ;
+ aPyFunc += "def PyObjIor( ObjRef ) :\n" ;
+// aPyFunc += " print 'PyObjIor',ObjRef\n" ;
+ aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
+// aPyFunc += " print 'PyObjIor',orb\n" ;
+ aPyFunc += " objIor = orb.object_to_string( ObjRef )\n" ;
+// aPyFunc += " print 'PyObjIor',ObjRef,objIor\n" ;
+ aPyFunc += " return objIor\n" ;
+ aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ;
+ if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
+ cdebug << ThreadNo() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
+ return false ;
+ }
+ MyPyObjIor = MyPyRunMethod ;
+
+ cdebug_out << "InitPython" << endl ;
+ return true ;
+}
+
+PyObject * GraphExecutor::InNode::InitPyDynInvoke(
+ char * PyFuncName ,
+ const SUPERV::ListOfStrings * aPythonFunction ) {
+ bool RetVal = true ;
+ string aPyFunc ;
+
+ cdebug_in << "InitPyDynInvoke '" << PyFuncName << "' length "
+ << (*aPythonFunction).length() << endl ;
+
+ if ( (*aPythonFunction).length() ) {
+ int i ;
+ aPyFunc += "import InitPyRunMethod\n" ;
+ for ( i = 0 ; i < (*aPythonFunction).length() ; i++ ) {
+ aPyFunc += (*aPythonFunction)[ i ] ;
+ aPyFunc += "\n" ;
+ }
+ aPyFunc += "InitPyRunMethod.RunMethod( " ;
+ aPyFunc += PyFuncName ;
+ aPyFunc += " )\n" ;
+ cdebug << "InitPyDynInvoke PyRun_SimpleString " << endl << aPyFunc << endl ;
+ if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
+ cdebug << ThreadNo() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
+ RetVal = false ;
+ }
+ else {
+ PyFuncRunned( true ) ;
+// _MyPyRunMethod = MyPyRunMethod ; // To mutex
+ cdebug << ThreadNo() << "PyRun_SimpleString( " << (*aPythonFunction)[ 0 ]
+ << " )" << endl ;
+ }
+ cdebug_out << "InitPyDynInvoke" << endl ;
+ if ( RetVal ) {
+ return MyPyRunMethod ;
+ }
+ }
+
+ return NULL ;
+}
+
+extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * Args ) {
+// cout << "PyRunMethod -->" << endl ;
+ PyObject * Result = NULL ;
+ PyObject * Temp = NULL ;
+ if ( PyArg_ParseTuple( Args , "O:set_callback" , & Temp ) ) {
+// cout << "PyArg_ParsedTuple" << endl ;
+ if ( !PyCallable_Check( Temp ) ) {
+// PyErr_SetString( PyExc_TypeError , "PyRunMethod must be callable" ) ;
+// cout << "PyRunMethod must be callable" << endl ;
+ return NULL ;
+ }
+ Py_XINCREF( Temp ) ;
+ Py_XDECREF( MyPyRunMethod ) ;
+ MyPyRunMethod = Temp ;
+ Py_INCREF( Py_None ) ;
+ Result = Py_None ;
+ }
+// cout << "<-- PyRunMethod" << endl ;
+ return Result ;
+}
+
+bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
+ const char *method ,
+ ServicesAnyData * inParams , int nInParams ,
+ ServicesAnyData * outParams , int nOutParams ) {
+ int i ;
+
+ bool RetVal = true ;
+
+ int n_in = nInParams ;
+ int n_out = nOutParams ;
+ const char * sname;
+
+ cdebug_in << "GraphExecutor::InNode::PyDynInvoke " << method << endl ;
+
+ CORBA::Any data ;
+
+ PyObject * ArgsList = NULL ;
+ PyObject * ArgValue ;
+ PyObject * ArgResult ;
+ PyObject * Result ;
+ PyObject * MyPyObjRefList = NULL ;
+ PyObject * ResultObj = NULL ;
+ PyObject * MyPyObjIorList = NULL ;
+ PyObject * ResultIor = NULL ;
+
+ ArgsList = PyTuple_New( n_in ) ;
+ CORBA::Object_ptr ObjRef ;
+ char * IORObjRef ;
+
+ for ( i = 0 ; i < n_in ; i++ ) {
+ data = inParams[i].Value ;
+ sname = inParams[i].Name.c_str() ;
+ switch ( data.type()->kind() ) {
+ case CORBA::tk_string : {
+ char * t ;
+ data >>= t ;
+ ArgValue = Py_BuildValue( "s" , t ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " Value " << t << " (string) "
+ << ArgsList->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_double : {
+ double d ;
+ data >>= d ;
+ ArgValue = Py_BuildValue( "d" , d ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " Value " << d << " (double) "
+ << ArgsList->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_long : {
+ long l ;
+ data >>= l ;
+ ArgValue = Py_BuildValue( "l" , l ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " Value " << l
+ << " (long) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_objref : {
+ MyPyObjRefList = PyTuple_New( 1 ) ;
+ PyObject * ObjValue ;
+ data >>= ObjRef ;
+ IORObjRef = ObjectToString( ObjRef ) ;
+ ObjValue = Py_BuildValue( "s" , IORObjRef ) ;
+ PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " Value " << IORObjRef << " (objref) "
+ << MyPyObjRefList->ob_refcnt << endl ;
+ ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ;
+ cdebug << "MyPyObjRefList->ob_refcnt" << MyPyObjRefList->ob_refcnt << " "
+ << "ResultObj->ob_refcnt" << ResultObj->ob_refcnt << endl ;
+ PyObject_Print( ResultObj , stdout , 0 ) ;
+ PyTuple_SetItem( ArgsList , i , ResultObj ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " Value (objref) ArgsList->ob_refcnt"
+ << ArgsList->ob_refcnt << " ResultObj->ob_refcnt" << ResultObj->ob_refcnt
+ << endl ;
+ break ;
+ }
+ default : {
+ cdebug << "ArgIn" << i << " : " << sname << " Value " << "(other ERROR)" << endl ;
+ }
+ }
+ }
+
+ Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ;
+ cdebug << "ArgsList->ob_refcnt" << ArgsList->ob_refcnt << endl ;
+
+ if ( Result == NULL ) {
+ cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error Result == NULL" << endl ;
+ RetVal = false ;
+ }
+ else {
+ for ( i = 0 ; i < n_out ; i++ ) {
+ data = outParams[i].Value ;
+ sname = outParams[i].Name.c_str() ;
+ switch ( data.type()->kind() ) {
+ case CORBA::tk_string : {
+ char * t ;
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ if ( ArgValue == NULL ) {
+ ArgValue = Result ;
+ }
+ t = PyString_AsString( ArgValue ) ;
+ data <<= t ;
+ cdebug << "ArgOut" << i << " : " << sname << " Value " << t << " (string)"
+ << endl ;
+ break ;
+ }
+ case CORBA::tk_double : {
+ double d ;
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ if ( ArgValue == NULL ) {
+ ArgValue = Result ;
+ }
+ d = PyFloat_AsDouble( ArgValue ) ;
+ data <<= d ;
+ cdebug << "ArgOut" << i << " : " << sname << " Value " << d << " (double)"
+ << endl ;
+ break ;
+ }
+ case CORBA::tk_long : {
+ long l ;
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ if ( ArgValue == NULL ) {
+ ArgValue = Result ;
+ }
+ l = PyInt_AsLong( ArgValue ) ;
+ data <<= l ;
+ cdebug << "ArgOut" << i << " : " << sname << " Value " << l << " (long)" << endl ;
+ break ;
+ }
+ case CORBA::tk_objref : {
+ MyPyObjIorList = PyTuple_New( 1 ) ;
+ PyObject * ObjIor = PyTuple_GetItem( Result , i ) ;
+ if ( ObjIor == NULL ) {
+ ObjIor = Result ;
+ }
+ Py_INCREF( ObjIor ) ;
+ PyObject_Print( ObjIor , stdout , 0 ) ;
+ PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ;
+ Py_DECREF( ObjIor ) ;
+ ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ;
+// ObjRef = PyCObject_AsVoidPtr( ArgValue ) ;
+// ObjRef = (CORBA::Object_ptr ) PyLong_AsVoidPtr( ArgValue ) ;
+ char * IOR = NULL ;
+// ArgValue = PyTuple_GetItem( Result , i ) ;
+ if ( ResultIor ) {
+ IOR = PyString_AsString( ResultIor ) ;
+ ObjRef = StringToObject( IOR ) ;
+ data <<= ObjRef ;
+ IORObjRef = ObjectToString( ObjRef ) ;
+ cdebug << "ArgOut" << i << " : " << sname << " Value " << "(object reference) "
+ << IORObjRef << endl ;
+ }
+ else {
+ cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error ResultIor == NULL"
+ << endl ;
+ RetVal = false ;
+ }
+ break ;
+ }
+ default : {
+ cdebug << "ArgOut" << i << " : " << sname << " Value " << "(other ERROR)" << endl ;
+ }
+ }
+ outParams[i].Value = data ;
+ }
+
+ if ( MyPyObjIorList ) {
+ int cnt = MyPyObjIorList->ob_refcnt ;
+ while ( cnt ) {
+ cnt = MyPyObjIorList->ob_refcnt - 1 ;
+ Py_DECREF( MyPyObjIorList ) ;
+ Py_DECREF( ResultIor ) ;
+ cdebug << "MyPyObjIorList->ob_refcnt" << MyPyObjIorList->ob_refcnt << " "
+ << "ResultIor->ob_refcnt" << ResultIor->ob_refcnt << endl ;
+ }
+ }
+ Py_DECREF( Result ) ;
+ }
+
+ Py_DECREF( ArgsList ) ;
+ if ( MyPyObjRefList ) {
+ int cnt = MyPyObjRefList->ob_refcnt ;
+ while ( cnt ) {
+ cnt = MyPyObjRefList->ob_refcnt - 1 ;
+ Py_DECREF( MyPyObjRefList ) ;
+ Py_DECREF( ResultObj ) ;
+ cdebug << "MyPyObjRefList->ob_refcnt" << MyPyObjRefList->ob_refcnt << " "
+ << "ResultObj->ob_refcnt" << ResultObj->ob_refcnt << endl ;
+ }
+ }
+
+ cdebug_out << "GraphExecutor::InNode::PyDynInvoke " << method << endl ;
+
+ return RetVal ;
+
+}
--- /dev/null
+#==============================================================================
+# File : Makefile.in
+# Created : aug 21 2001
+# Author : , CEA
+# Project : SALOME
+# Copyright : CEA 2001
+# $Header:
+#==============================================================================
+
+# source path
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+EXPORT_HEADERS = \
+ DataFlowExecutor_FiniteStateMachine.hxx \
+ DataFlowExecutor_InNode.hxx \
+ DataFlowExecutor_OutNode.hxx \
+ DataFlowExecutor_DataFlow.hxx \
+ DataFlowExecutor_DataFlow.lxx
+
+# Libraries targets
+LIB = libSalomeSuperVisionExecutor.la
+LIB_SRC = \
+ DataFlowExecutor_FiniteStateMachine.cxx \
+ DataFlowExecutor_PyDynInvoke.cxx \
+ DataFlowExecutor_DynInvoke.cxx \
+ DataFlowExecutor_InNodeThreads.cxx \
+ DataFlowExecutor_InNode.cxx \
+ DataFlowExecutor_OutNode.cxx \
+ DataFlowExecutor_DataFlow.cxx
+
+LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \
+ SALOME_Component.idl \
+ SALOMEDS.idl \
+ SUPERV.idl \
+ SALOME_Exception.idl
+
+# Executables targets
+#BIN = SuperVisionExecutor_CheckOfUndefined
+BIN_SRC =
+BIN_SERVER_IDL =
+
+CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
+#LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lOpUtil -lSalomeLoggerServer -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS)
+LDFLAGS+= -export-dynamic -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lOpUtil -lSalomeLoggerServer -lc $(QT_MT_LIBS) $(OGL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
+
+
+@CONCLUDE@
+
+
--- /dev/null
+using namespace std;
+#include <iostream>
+#include <fstream>
+#include <unistd.h>
+
+#include <Python.h>
+
+#include "DataFlowBase_Base.hxx"
+#include "DataFlowBase_Graph.hxx"
+#include "DataFlowExecutor_InNode.hxx"
+#include "DataFlowExecutor_OutNode.hxx"
+#include "DataFlowExecutor_DataFlow.hxx"
+#include "DataFlowExecutor_DataFlow.lxx"
+
+static PyMethodDef MethodPyVoidMethod[] = {
+ { NULL, NULL }
+};
+
+int main(int argc, char **argv) {
+ Py_Initialize() ;
+ Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ;
+ return 0;
+}
+