From: yfr Date: Fri, 18 Jun 2004 12:58:10 +0000 (+0000) Subject: DCQ : Merge with Ecole_Ete_a6. X-Git-Tag: Merge_with_Ecole_Ete_a6~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bae06cd3bdae2ac2acb878e96689b2ea283aad23;p=modules%2Fsuperv.git DCQ : Merge with Ecole_Ete_a6. --- diff --git a/doc/Makefile.in b/doc/Makefile.in index 0190159..7295ede 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -11,9 +11,11 @@ top_builddir=.. srcdir=@srcdir@ VPATH=.:@srcdir@ -SUBDIRS=html +SUBDIRS= salome -doc: +@COMMENCE@ + +docs: @@SETX@; for d in $(SUBDIRS); do \ (cd $$d && $(MAKE) $@) || exit 1; \ done @@ -31,3 +33,8 @@ install: @@SETX@; for d in $(SUBDIRS); do \ (cd $$d && $(MAKE) $@) || exit 1; \ done + +uninstall: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done diff --git a/doc/html/INPUT/doxyfile b/doc/html/INPUT/doxyfile index 998f61f..2a2869b 100755 --- a/doc/html/INPUT/doxyfile +++ b/doc/html/INPUT/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME - SUPERV - v.1.4.0" +PROJECT_NAME = "SALOME - SUPERV - v.2.0.0" PROJECT_NUMBER = id#1.0 OUTPUT_DIRECTORY = ../ OUTPUT_LANGUAGE = English diff --git a/doc/html/INPUT/sources/static/tree.js b/doc/html/INPUT/sources/static/tree.js index c1a8b4d..25dc87a 100755 --- a/doc/html/INPUT/sources/static/tree.js +++ b/doc/html/INPUT/sources/static/tree.js @@ -1,4 +1,4 @@ -foldersTree = gFld("SALOME v.1.4.0 ", "", "") +foldersTree = gFld("SALOME v.2.0.0 ", "", "") insDoc(foldersTree, gLnk("Main Page", "", "main.html")) aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) diff --git a/doc/salome/Makefile.in b/doc/salome/Makefile.in new file mode 100644 index 0000000..30f0ccf --- /dev/null +++ b/doc/salome/Makefile.in @@ -0,0 +1,44 @@ + +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 30/11/2001 +# $Header$ +# +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + +SUBDIRS= tui gui + +@COMMENCE@ + +docs: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done; \ + cp -f $(srcdir)/SUPERV_index.html SUPERV_index.html + +clean: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +distclean: clean + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +install: + $(MAKE) docs + (cd tui && $(MAKE) install); + (cd gui && $(MAKE) install); + cp -f SUPERV_index.html $(docdir) + +uninstall: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done; \ + rm -fr $(docdir)/SUPERV_index.html diff --git a/doc/salome/SUPERV_index.html b/doc/salome/SUPERV_index.html new file mode 100644 index 0000000..ee92824 --- /dev/null +++ b/doc/salome/SUPERV_index.html @@ -0,0 +1,95 @@ + + + + + + + + Supervision Module Documentation + + + +
  +
+
                   +   
+ + + + + + + + + +
+ + + +
+ +
+
+
+

Supervision MODULE Documentation

+
+
+ + + + + +
+
+ +
+

Application-About.png +     

+
+ +
+ + + + +
+
+
+
+
+ +
+ +
GUI Documentation
+ +
+ +
+ +

+
+ +
+ +
TUI Documentation
+ +
+ +
+ +

+
+
+
+
+
+
+ + diff --git a/doc/salome/gui/Makefile.in b/doc/salome/gui/Makefile.in new file mode 100644 index 0000000..fe361d8 --- /dev/null +++ b/doc/salome/gui/Makefile.in @@ -0,0 +1,33 @@ +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : Makefile.in +# Author : Vasily Rusyaev (Open Cascade NN) +# Module : doc +# $Header: + +top_srcdir=@top_srcdir@ +top_builddir=../../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + +@COMMENCE@ + +docs: + cp -fr $(srcdir)/SUPERV ./ + -find $(PWD) -name CVS -exec rm -rf {} \; + +clean: + rm -fr `ls | grep -v "Makefile"` + +distclean: clean + rm -fr SUPERV + +install: + mkdir -p $(docdir)/gui + cp -rf SUPERV $(docdir)/gui + -find $(PWD) -name CVS -exec rm -rf {} \; + +uninstall: + rm -rf $(docdir)/gui/SUPERV diff --git a/src/AddComponent/AddComponent_Impl.cxx b/src/AddComponent/AddComponent_Impl.cxx new file mode 100644 index 0000000..491e79b --- /dev/null +++ b/src/AddComponent/AddComponent_Impl.cxx @@ -0,0 +1,227 @@ +// SuperVisionTest AddComponent : example of component that adds two numbers +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : AddComponent_Impl.cxx +// Author : Jean Rahuel, CEA +// Module : SuperVisionTest + +using namespace std; +#include +#include +#include +#include +#include + +//#include "utilities.h" + +#include "AddComponent_Impl.hxx" +#include "Adder_Impl.hxx" + +AddComponent_Impl::AddComponent_Impl( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) { + MESSAGE("AddComponent_Impl::AddComponent_Impl this " << hex << this << dec + << "activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ")" ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + LastAddition = 0 ; +} + +AddComponent_Impl::AddComponent_Impl() { + LastAddition = 0 ; +} + +AddComponent_Impl::~AddComponent_Impl() { +} + +SuperVisionTest::Adder_ptr AddComponent_Impl::Addition() { + beginService( "AddComponent_Impl::Addition" ); + sendMessage(NOTIF_STEP, "AddComponent_Impl creates Adder_Impl"); + Adder_Impl * myAdder ; + myAdder = new Adder_Impl( _orb , _poa, _contId, + instanceName() , interfaceName() , + graphName() , nodeName() ) ; + SuperVisionTest::Adder_var iobject ; + PortableServer::ObjectId * id = myAdder->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SuperVisionTest::Adder::_narrow(obj) ; + endService( "AddComponent_Impl::Addition" ); + return SuperVisionTest::Adder::_duplicate(iobject) ; +} + +double AddComponent_Impl::Add( double x , double y , double & z ) { + beginService( " AddComponent_Impl::Add" ); + z = x + y ; + int S; + + sendMessage(NOTIF_STEP, "AddComponent_Impl::Add is Computing"); + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + MESSAGE( "AddComponent_Impl::Add( " << x << " , " << y << " , " << z + << " ) returns " << (x - y) << " after " << S << " seconds" ) + LastAddition = z ; + endService( " AddComponent_Impl::Add" ); + return (x - y) ; +} + +long AddComponent_Impl::Sigma( long n ) { + long sigma = 0 ; + int i , j ; + beginService( " AddComponent_Impl::Sigma" ); + for ( j = 0 ; j < 1000000 ; j++ ) { + sigma = 0 ; + for ( i = 1 ; i <= n ; i++ ) { + sigma = sigma + i ; + } + } + endService( " AddComponent_Impl::Sigma" ); + return sigma ; +} + +double AddComponent_Impl::LastResult() { + beginService( " AddComponent_Impl::LastResult" ); + sendMessage(NOTIF_STEP, "AddComponent_Impl::LastResult is Computing"); + int S; + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " AddComponent_Impl::LastResult" ); + return LastAddition ; +} + +extern "C" +{ + PortableServer::ObjectId * AddComponentEngine_factory + (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("AddComponentEngine_factory AddComponentEngine (" + << instanceName << "," << interfaceName << "," << getpid() << ")"); + AddComponent_Impl * myAddComponent + = new AddComponent_Impl(orb, poa, contId, instanceName, interfaceName); + return myAddComponent->getId() ; + } +} + +Adder_Impl::Adder_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char * instanceName , + const char * interfaceName , + const char * graphName , + const char * nodeName ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) { + Names( graphName , nodeName ) ; + MESSAGE("Adder_Impl::Adder_Impl activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ") --> " + << hex << (void *) this << dec ) + beginService( "Adder_Impl::Adder_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + LastAddition = 0 ; + sendMessage(NOTIF_STEP, "Adder_Impl is Created"); + endService( "Adder_Impl::Adder_Impl" ); +} + +Adder_Impl::Adder_Impl() { + LastAddition = 0 ; +} + +Adder_Impl::~Adder_Impl() { + beginService( "Adder_Impl::~Adder_Impl" ); + endService( "Adder_Impl::~Adder_Impl" ); +} + +double Adder_Impl::Add( double x , double y , double & z ) { + beginService( " Adder_Impl::Add" ); + z = x + y ; + int S; + + sendMessage(NOTIF_STEP, "Adder_Impl::Add is Computing"); + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + MESSAGE( "Adder_Impl::Add( " << x << " , " << y << " , " << z + << " ) returns " << -(x - y) << " after " << S << " seconds" ) + LastAddition = z ; + endService( " Adder_Impl::Add" ); + return -(x - y) ; +} + +double Adder_Impl::AddAndCompare( const double x , const double y , + const SuperVisionTest::Adder_ptr anOtherAdder , + double & z ) { + beginService( " Adder_Impl::AddAndCompare" ); + z = x + y ; + int S; + + sendMessage(NOTIF_STEP, "Adder_Impl::AddAndCompare is Computing"); + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + MESSAGE( "Adder_Impl::AddAndCompare( " << x << " , " << y << " , " << z + << " ) returns " << -(x - y) << " after " << S << " seconds" ) + LastAddition = z ; + double ValFunc ; + sendMessage(NOTIF_TRACE, "Adder_Impl::AddAndCompare will call anOtherAdder->LastValue()"); + double RetVal ; + anOtherAdder->LastResult( RetVal ) ; + if ( RetVal > 0 ) { + ValFunc = (x - y) ; + } + else { + ValFunc = -(x - y) ; + } + sendMessage(NOTIF_TRACE, "Adder_Impl::AddAndCompare has called anOtherAdder->LastValue()"); + sendMessage(NOTIF_STEP, "Adder_Impl::AddAndCompare is Finished"); + endService( " Adder_Impl::AddAndCompare" ); + return ValFunc ; +} + +void Adder_Impl::SetLastResult( double z ) { + beginService( " Adder_Impl::SetLastResult" ); + sendMessage(NOTIF_STEP, "Adder_Impl::SetLastResult is Computing"); + int S; + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + LastAddition = z ; + endService( " Adder_Impl::SetLastResult" ); + return ; +} + +void Adder_Impl::LastResult( double & z ) { + beginService( " Adder_Impl::LastResult" ); + sendMessage(NOTIF_STEP, "Adder_Impl::LastResult is Computing"); + int S; + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + z = LastAddition ; + endService( " Adder_Impl::LastResult" ); + return ; +} + + diff --git a/src/GraphBase/DataFlowBase_Base.cxx b/src/GraphBase/DataFlowBase_Base.cxx index 7853f57..f7ddcc9 100644 --- a/src/GraphBase/DataFlowBase_Base.cxx +++ b/src/GraphBase/DataFlowBase_Base.cxx @@ -29,7 +29,7 @@ using namespace std; #include "DataFlowBase_Base.hxx" -char *SuperVision_Version = "1.05" ; +char *SuperVision_Version = "2.0" ; char *NULLSTRING = "" ; @@ -50,6 +50,12 @@ void GraphBase::Base::SetDebug( CORBA::ORB_ptr ORB , _prof_debug = theprof_debug ; _fdebug = thefdebug ; } + else { + MESSAGE( "GraphBase::Base::SetDebug with theprof_debug == NULL" ) ; + } + } + else { + cdebug << "GraphBase::Base::SetDebug already done" << endl ; } // cdebug_in << "GraphBase::Base::SetDebug" << endl ; // cdebug << "GraphBase::Base::SetDebug" << endl ; @@ -63,3 +69,167 @@ char * GraphBase::Base::ObjectToString( CORBA::Object_ptr obj ) const { CORBA::Object_ptr GraphBase::Base::StringToObject( char * obj ) const { return _Orb->string_to_object( obj ); } + +string DataStreamTypeToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) { + string aIdlType ; + switch ( aDataStreamType ) { + case SALOME_ModuleCatalog::DATASTREAM_UNKNOWN : { + aIdlType = "Unknown" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_INTEGER : { + aIdlType = "int" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_FLOAT : { + aIdlType = "float" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_DOUBLE : { + aIdlType = "double" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_STRING : { + aIdlType = "string" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_BOOLEAN : { + aIdlType = "bool" ; + break; + } + default: { + aIdlType = "Unknown" ; + break; + } + } + return aIdlType ; +} + +SALOME_ModuleCatalog::DataStreamType StringToDataStreamType( const char * aIdlType ) { + SALOME_ModuleCatalog::DataStreamType aDataStreamType ; + if ( !strcmp( aIdlType , "Unknown" ) ) { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN ; + } + else if ( !strcmp( aIdlType , "int" ) ) { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_INTEGER ; + } + else if ( !strcmp( aIdlType , "float" ) ) { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_FLOAT ; + } + else if ( !strcmp( aIdlType , "double" ) ) { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_DOUBLE ; + } + else if ( !strcmp( aIdlType , "string" ) ) { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_STRING ; + } + else if ( !strcmp( aIdlType , "bool" ) ) { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN ; + } + else { + aDataStreamType = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN ; + } + return aDataStreamType ; +} + +string KindOfDataStreamTraceToString( SUPERV::KindOfDataStreamTrace aDataStreamTrace ) { + string aTrace ; + switch ( aDataStreamTrace ) { + case SUPERV::WithoutTrace : + aTrace = "SANS"; + break; + case SUPERV::SummaryTrace : + aTrace = "SUCCINT"; + break; + case SUPERV::DetailedTrace : + aTrace = "DETAILLE"; + break; + default : + aTrace = "UndefinedTrace"; + break; + } + return aTrace ; +} + +string DataStreamDependencyToString( const SALOME_ModuleCatalog::DataStreamDependency aDataStreamDependency ) { + string aDependency ; + switch ( aDataStreamDependency ) { + case SALOME_ModuleCatalog::DATASTREAM_UNDEFINED : + aDependency = "U" ; + break; + case SALOME_ModuleCatalog::DATASTREAM_TEMPORAL : + aDependency = "T" ; + break; + case SALOME_ModuleCatalog::DATASTREAM_ITERATIVE : + aDependency = "I" ; + break; + default : + aDependency = "?" ; + break; + } + + return aDependency; +} + +string DataStreamToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) { + string aStreamType ; + switch ( aDataStreamType ) { + case SALOME_ModuleCatalog::DATASTREAM_UNKNOWN : { + aStreamType = "Unknown" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_INTEGER : { + aStreamType = "ENTIER" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_FLOAT : { + aStreamType = "REEL" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_DOUBLE : { + aStreamType = "DOUBLE" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_STRING : { + aStreamType = "CHAINE" ; + break; + } + case SALOME_ModuleCatalog::DATASTREAM_BOOLEAN : { + aStreamType = "LOGIQUE" ; + break; + } + default: { + aStreamType = "?" ; + break; + } + } + return aStreamType ; +} + +ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::DataStreamType & s ) { + switch (s) { + case SALOME_ModuleCatalog::DATASTREAM_UNKNOWN : + f << "DATASTREAM_UNKNOWN"; + break; + case SALOME_ModuleCatalog::DATASTREAM_INTEGER : + f << "DATASTREAM_INTEGER"; + break; + case SALOME_ModuleCatalog::DATASTREAM_FLOAT : + f << "DATASTREAM_FLOAT"; + break; + case SALOME_ModuleCatalog::DATASTREAM_DOUBLE : + f << "DATASTREAM_DOUBLE"; + break; + case SALOME_ModuleCatalog::DATASTREAM_STRING : + f << "DATASTREAM_STRING"; + break; + case SALOME_ModuleCatalog::DATASTREAM_BOOLEAN : + f << "DATASTREAM_BOOLEAN"; + break; + default : + f << "DATASTREAM_UNKNOWN"; + break; + } + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_Base.hxx b/src/GraphBase/DataFlowBase_Base.hxx index 2d77bdd..905fd01 100644 --- a/src/GraphBase/DataFlowBase_Base.hxx +++ b/src/GraphBase/DataFlowBase_Base.hxx @@ -81,6 +81,15 @@ inline char * my_strblkdup( const char * s ) { return t; } +string DataStreamTypeToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ; +SALOME_ModuleCatalog::DataStreamType StringToDataStreamType( const char * aIdlType ) ; + +string KindOfDataStreamTraceToString( SUPERV::KindOfDataStreamTrace aDataStreamTrace ) ; + +string DataStreamDependencyToString( const SALOME_ModuleCatalog::DataStreamDependency aDataStreamDependency ) ; + +string DataStreamToString( const SALOME_ModuleCatalog::DataStreamType aDataStreamType ) ; + enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected , DataConnected } ; @@ -99,21 +108,36 @@ namespace GraphBase { typedef vector ListOfPythonFunctions ; - struct NodeParameter { - SALOME_ModuleCatalog::ServicesParameter theInParameter ; - SALOME_ModuleCatalog::ServicesParameter theOutParameter ; - }; + typedef vector ListOfParameters; + + struct InDataStreamParameter { + SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ; + SUPERV::KindOfSchema theKindOfSchema ; + SUPERV::KindOfInterpolation theKindOfInterpolation ; + SUPERV::KindOfExtrapolation theKindOfExtrapolation ; + }; + typedef vector ListOfInDataStreamParameters; - typedef vector ListOfParameters; + struct OutDataStreamParameter { + SALOME_ModuleCatalog::ServicesDataStreamParameter theDataStreamParameter ; + long theNumberOfValues ; + }; + typedef vector ListOfOutDataStreamParameters; struct SNode { string theComponentName ; string theInterfaceName ; string theName ; SUPERV::KindOfNode theKind ; + long theTimeout ; + SUPERV::KindOfDataStreamTrace theDataStreamTrace ; + double theDeltaTime ; string theCoupledNode ; +// int theDataStreamInArgsNumber ; +// int theDataStreamOutArgsNumber ; SALOME_ModuleCatalog::Service theService ; - ListOfParameters theListOfParameters ; + ListOfInDataStreamParameters theListOfInDataStreams ; + ListOfOutDataStreamParameters theListOfOutDataStreams ; ListOfFuncName theListOfFuncName ; ListOfPythonFunctions theListOfPythonFunctions ; SUPERV::SDate theFirstCreation ; @@ -196,4 +220,6 @@ namespace GraphBase { } ; +ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamType &); + #endif diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index aab8cea..4f04a80 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -4,7 +4,7 @@ // // // -// File : DataFlowBase_Node.cxx +// File : DataFlowBase_ComputingNode.cxx // Author : Jean Rahuel, CEA // Module : SUPERV // $Header: @@ -13,25 +13,27 @@ using namespace std; //#include //#include -#include "DataFlowBase_InLineNode.hxx" -#include "DataFlowBase_LoopNode.hxx" +#include "DataFlowBase_StreamGraph.hxx" +//#include "DataFlowBase_LoopNode.hxx" -static void InitFields( SUPERV::KindOfNode &_Kind , +static void InitFields( //SUPERV::KindOfNode &_Kind , SUPERV::SDate &_FirstCreation , SUPERV::SDate &_LastModification , char * &_EditorRelease , char * &_Author , char * &_Comment , - bool &_HeadNode , + //bool &_HeadNode , bool &_GeneratedName , + //int &_DataStreamInPortsNumber , + //int &_DataStreamOutPortsNumber , int &_ConnectedInPortsNumber , - int &_DecrConnectedInPortsNumber, - int &_LinkedNodesSize , - int &_SubGraphNumber ) { + int &_DecrConnectedInPortsNumber ) { + //int &_LinkedNodesSize , + //int &_SubGraphNumber ) { time_t T = time(NULL); struct tm * Tm = localtime(&T); - _Kind = SUPERV::DataFlowNode ; +// _Kind = SUPERV::DataFlowGraph ; _FirstCreation.Second = _LastModification.Second = Tm->tm_sec; _FirstCreation.Minute = _LastModification.Minute = Tm->tm_min; @@ -47,36 +49,42 @@ static void InitFields( SUPERV::KindOfNode &_Kind , // strcpy( _Computer , FACTORYSERVER ) ; _Comment = NULLSTRING ; - _SubGraphNumber = 0 ; - _HeadNode = false ; +// _SubGraphNumber = 0 ; +// _HeadNode = false ; _GeneratedName = false ; +// _DataStreamInPortsNumber = 0 ; +// _DataStreamOutPortsNumber = 0 ; + _ConnectedInPortsNumber = 0 ; _DecrConnectedInPortsNumber = 0 ; - _LinkedNodesSize = 0 ; - _SubGraphNumber = 0 ; +// _LinkedNodesSize = 0 ; +// _SubGraphNumber = 0 ; } GraphBase::ComputingNode::ComputingNode() : - GraphBase::PortsOfNode::PortsOfNode() { +// GraphBase::PortsOfNode::PortsOfNode() { + GraphBase::StreamNode::StreamNode() { - InitFields( _Kind , + InitFields( //_Kind , _FirstCreation , _LastModification , _EditorRelease , _Author , _Comment , - _HeadNode , + //_HeadNode , _GeneratedName , + //_DataStreamInPortsNumber , + //_DataStreamOutPortsNumber , _ConnectedInPortsNumber , - _DecrConnectedInPortsNumber , - _LinkedNodesSize , - _SubGraphNumber ) ; + _DecrConnectedInPortsNumber ) ; + //_LinkedNodesSize , + //_SubGraphNumber ) ; + Kind( SUPERV::DataFlowGraph ) ; _NamingService = NULL ; _Node = SUPERV::CNode::_nil() ; _InNode = NULL ; _ThreadNo = pthread_self() ; - _Name = NULL ; cdebug << "GraphBase::Node::Node " << this << " " << endl ; } @@ -86,35 +94,32 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , const char * aDataFlowName , int * Graph_prof_debug , ofstream * Graph_fdebug ) : - GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) { +// GraphBase::PortsOfNode::PortsOfNode( aDataFlowName ) { + GraphBase::StreamNode::StreamNode( aDataFlowName ) { - MESSAGE( "GraphBase::ComputingNode::ComputingNode( " << aDataFlowName << " Graph_fdebug " << Graph_fdebug ) ; - InitFields( _Kind , +// MESSAGE( "GraphBase::ComputingNode::ComputingNode " << aDataFlowName << " Graph_prof_debug " << Graph_prof_debug ) ; + InitFields( //_Kind , _FirstCreation , _LastModification , _EditorRelease , _Author , _Comment , - _HeadNode , + //_HeadNode , _GeneratedName , + //_DataStreamInPortsNumber , + //_DataStreamOutPortsNumber , _ConnectedInPortsNumber , - _DecrConnectedInPortsNumber , - _LinkedNodesSize , - _SubGraphNumber ) ; + _DecrConnectedInPortsNumber ) ; + //_LinkedNodesSize , + //_SubGraphNumber ) ; + Kind( SUPERV::DataFlowGraph ) ; _ORB = CORBA::ORB::_duplicate( ORB ) ; _NamingService = ptrNamingService ; _Node = SUPERV::CNode::_nil() ; _InNode = NULL ; _ThreadNo = pthread_self() ; - if ( aDataFlowName != NULLSTRING && strlen( aDataFlowName ) ) { - _Name = new char[ strlen( aDataFlowName )+1 ] ; - strcpy( _Name , aDataFlowName ) ; - } - else { - _Name = NULLSTRING ; - } if ( Graph_prof_debug ) { // MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug" ) ; // cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug" << endl ; @@ -126,8 +131,7 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , // cout << "GraphBase::ComputingNode::ComputingNode NO SetDebug" << endl ; // } cdebug << "GraphBase::ComputingNode::ComputingNode " << this - << "' _Name " - << (void *) _Name << " '" << _Name << " " << _FirstCreation + << " Name '" << Name() << "' " << _FirstCreation << " " << _LastModification << endl ; } @@ -146,7 +150,8 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , const long Y , int * Graph_prof_debug , ofstream * Graph_fdebug ) : - GraphBase::PortsOfNode::PortsOfNode() { +// GraphBase::PortsOfNode::PortsOfNode() { + GraphBase::StreamNode::StreamNode( NodeName ) { _ORB = CORBA::ORB::_duplicate( ORB ) ; _NamingService = ptrNamingService ; @@ -154,7 +159,8 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , _InNode = NULL ; _ThreadNo = pthread_self() ; - _Kind = akind ; + Kind( akind ) ; +// _Kind = akind ; time_t T = time(NULL); struct tm * Tm = localtime(&T); @@ -191,44 +197,38 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , _Comment = NULLSTRING ; } - _SubGraphNumber = 0 ; - _HeadNode = false ; +// _SubGraphNumber = 0 ; +// _HeadNode = false ; _GeneratedName = GeneratedName ; - const char *aNodeName = NodeName ; - _Name = new char[strlen(aNodeName)+1]; - strcpy(_Name , aNodeName); +// const char *aNodeName = NodeName ; +// _Name = new char[strlen(aNodeName)+1]; +// strcpy(_Name , aNodeName); + +// _DataStreamInPortsNumber = 0 ; +// _DataStreamOutPortsNumber = 0 ; _ConnectedInPortsNumber = 0 ; _DecrConnectedInPortsNumber = 0 ; - _LinkedNodesSize = 0 ; +// _LinkedNodesSize = 0 ; _X = X ; _Y = Y ; -// MESSAGE( "GraphBase::ComputingNode::ComputingNode --> SetDebug " << Graph_prof_debug << " Graph_fdebug " -// << Graph_fdebug ) ; -// cout << "GraphBase::ComputingNode::ComputingNode --> SetDebug " << Graph_prof_debug << " Graph_fdebug " -// << Graph_fdebug << endl ; _Graph_prof_debug = Graph_prof_debug ; _Graph_fdebug = Graph_fdebug ; +// MESSAGE( "GraphBase::ComputingNode::ComputingNode " << NodeName +// << " _Graph_prof_debug " << _Graph_prof_debug ) ; SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; -// MESSAGE( "GraphBase::ComputingNode::ComputingNode SetDebug Done " << Graph_prof_debug << " Graph_fdebug " -// << Graph_fdebug << " aService.ServiceName " << aService.ServiceName ) ; -// cout << "GraphBase::ComputingNode::ComputingNode SetDebug Done " << Graph_prof_debug << " Graph_fdebug " -// << Graph_fdebug << endl ; -// cout << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << aNodeName << "," -// << akind << ")" << endl; - cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << aNodeName << "," + cdebug_in << "GraphBase::ComputingNode::ComputingNode(" << aService.ServiceName << "," << NodeName << "," << akind << ")" << endl; DefPortsOfNode( ORB , aService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; - cdebug << "GraphBase::ComputingNode::ComputingNode " << this - << " _Name " << (void *) _Name << " '" << _Name - << " KindOfNode " << _Kind - << " ServiceName " << ServiceName() << " In(" << ServiceInParameter().length() + << " Name '" << Name() + << "' KindOfNode " << Kind() + << " ServiceName '" << ServiceName() << "' In(" << ServiceInParameter().length() << ") Out(" << ServiceOutParameter().length() << ")" << endl ; cdebug_out << "GraphBase::ComputingNode::ComputingNode" << endl; @@ -236,36 +236,25 @@ GraphBase::ComputingNode::ComputingNode( CORBA::ORB_ptr ORB , GraphBase::ComputingNode::~ComputingNode() { cdebug << "GraphBase::ComputingNode::~ComputingNode " << this - << " _Name " - << (void *) _Name << " " << _Name << " _Comment " + << " Name() "<< Name() << " _Comment " << (void *) _Comment << " " << _Comment << " " << endl ; -// if ( _ComponentName != NULLSTRING ) -// delete [] _ComponentName ; -// delete [] _Name ; -// delete [] _EditorRelease ; -// if ( _Author != NULLSTRING ) -// delete [] _Author ; -// if ( _Computer != FACTORYSERVER ) -// delete [] _Computer; -// if ( _Comment != NULLSTRING ) -// delete [] _Comment; } -bool GraphBase::ComputingNode::Name( const char * aName) { - cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl; - if ( _Name ) { - cdebug << "GraphBase::ComputingNode::ReName " << _Name << " --> " << aName << endl ; - delete [] _Name ; - } - _Name = new char[strlen(aName)+1] ; - strcpy( _Name , aName ) ; - cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl; - return true ; -} +//->StreamNode bool GraphBase::ComputingNode::Name( const char * aName) { +//->StreamNode cdebug_in << "GraphBase::ComputingNode::Name " << _Name << endl; +//->StreamNode if ( _Name ) { +//->StreamNode cdebug << "GraphBase::ComputingNode::ReName " << _Name << " --> " << aName << endl ; +//->StreamNode delete [] _Name ; +//->StreamNode } +//->StreamNode _Name = new char[strlen(aName)+1] ; +//->StreamNode strcpy( _Name , aName ) ; +//->StreamNode cdebug_out << "GraphBase::ComputingNode::Name " << _Name << endl; +//->StreamNode return true ; +//->StreamNode } SUPERV::SDate GraphBase::ComputingNode::FirstCreation () const { // cdebug << "GraphBase::ComputingNode::FirstCreation " -// << "' _Name " << _Name << " " << _FirstCreation << " " +// << " Name '" << Name() << "' " << _FirstCreation << " " // << _LastModification << endl ; return _FirstCreation; } @@ -274,11 +263,6 @@ SUPERV::SDate GraphBase::ComputingNode::LastModification () const { return _LastModification ; } -bool GraphBase::ComputingNode::Kind(const SUPERV::KindOfNode aKind) { - _Kind = aKind ; - return true ; -} - void GraphBase::ComputingNode::FirstCreation(const SUPERV::SDate aDate ) { _FirstCreation = aDate ; } @@ -378,6 +362,15 @@ GraphBase::SNode * GraphBase::ComputingNode::GetInfo() { // Info->theInterfaceName = InterfaceName() ; Info->theName = Name() ; Info->theKind = Kind() ; + if ( IsDataStreamNode() ) { + long Timeout ; + SUPERV::KindOfDataStreamTrace DataStreamTrace ; + double DeltaTime ; + ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ; + Info->theTimeout = Timeout ; + Info->theDataStreamTrace = DataStreamTrace ; + Info->theDeltaTime = DeltaTime ; + } Info->theService = *GetService() ; // Info->theListOfParameters = *GetListOfParameters() ; Info->theFirstCreation = FirstCreation() ; @@ -392,90 +385,81 @@ GraphBase::SNode * GraphBase::ComputingNode::GetInfo() { return Info ; } +void GraphBase::ComputingNode::DelInPort( const char * InputParameterName ) { + GraphBase::PortsOfNode::DelInPort( InputParameterName ) ; +} +void GraphBase::ComputingNode::DelOutPort( const char * OutputParameterName ) { + GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ; +} + GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParameterName , - const char * InputParameterType ) { + const char * InputParameterType , + const SUPERV::KindOfPort aKindOfPort ) { + cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ; return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() , Kind() , InputParameterName , InputParameterType , + aKindOfPort , +// DataStreamInPortsNumber() , _Graph_prof_debug , _Graph_fdebug ) ; } GraphBase::OutPort * GraphBase::ComputingNode::AddOutPort( const char * OutputParameterName , - const char * OutputParameterType ) { + const char * OutputParameterType , + const SUPERV::KindOfPort aKindOfPort ) { + cdebug << "AddOutPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ; return GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() , Kind() , OutputParameterName , OutputParameterType , + aKindOfPort , +// DataStreamOutPortsNumber() , _Graph_prof_debug , _Graph_fdebug ) ; } -void GraphBase::ComputingNode::AddLink( GraphBase::ComputingNode * ToNode ) { - int index = GetLinkedNodeIndex( ToNode->Name() ) ; - if ( index < 0 ) { - cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() - << " ) new LinkedNode " << endl ; - _LinkedNodes.resize( _LinkedNodesSize+1 ) ; - _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ; - _LinkedNodes[ _LinkedNodesSize ] = ToNode ; - _LinkedInPortsNumber[ _LinkedNodesSize ] = 1 ; - SetLinkedNodeIndex( ToNode->Name() , _LinkedNodesSize ) ; - index = _LinkedNodesSize ; - _LinkedNodesSize++ ; - } - else { - cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() - << " ) old LinkedNode " << _LinkedNodes[index ]->Name() << endl ; - _LinkedInPortsNumber[ index ] += 1 ; - } - cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() - << " ) LinkedNodesSize " << _LinkedNodesSize << " [ " << index - << " ] _LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] - << " ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber() - << " + 1 Service " << ServiceName() << endl ; - ToNode->IncrConnectedInPortsNumber() ; +void GraphBase::ComputingNode::DelInDataStreamPort( const char * InputParameterName ) { + GraphBase::PortsOfNode::DelInPort( InputParameterName ) ; } - -void GraphBase::ComputingNode::RemoveLink( GraphBase::ComputingNode * ToNode ) { - int index = GetLinkedNodeIndex( ToNode->Name() ) ; - if ( index >= 0 ) { - cdebug << "GraphBase::ComputingNode::RemoveLink( to " << ToNode->Name() << " from " - << Name() << " index : " << index << " ConnectedInPortsNumber " - << ToNode->ConnectedInPortsNumber() - 1 << " LinkedInPortsNumber " - << _LinkedInPortsNumber[ index ] << " - 1" << endl ; - ToNode->DecrConnectedInPortsNumber() ; - _LinkedInPortsNumber[ index ] -= 1 ; - if ( _LinkedInPortsNumber[ index ] == 0 ) { - _LinkedNodesSize-- ; - cdebug << "GraphBase::ComputingNode::RemoveLink new LinkedNodesSize " - << _LinkedNodesSize << " " << ToNode->Name() << " removed from " - << " linkednodes of " << Name() << endl ; - int i ; - for ( i = index ; i < _LinkedNodesSize ; i++ ) { - _LinkedNodes[ i ] = _LinkedNodes[ i+1 ] ; - _LinkedInPortsNumber[ i ] = _LinkedInPortsNumber[ i+1 ] ; - SetLinkedNodeIndex( _LinkedNodes[ i ]->Name() , i ) ; - } - DelLinkedNodeIndex( ToNode->Name() ) ; - _LinkedNodes.resize( _LinkedNodesSize+1 ) ; - _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ; - } - } - else { - cdebug << " Error index " << index << endl ; - } +void GraphBase::ComputingNode::DelOutDataStreamPort( const char * OutputParameterName ) { + GraphBase::PortsOfNode::DelOutPort( OutputParameterName ) ; } -void GraphBase::ComputingNode::ReNameLink( const char* OldNodeName , - const char* NewNodeName ) { - cdebug_in << "GraphBase::ComputingNode::ReNameLink (" << OldNodeName << " , " - << NewNodeName << ")" << endl; - int index = GetLinkedNodeIndex( OldNodeName ) ; - if ( index >= 0 ) { - _MapOfLinkedNodes.erase( OldNodeName ) ; - SetLinkedNodeIndex( NewNodeName , index ) ; +GraphBase::InDataStreamPort * GraphBase::ComputingNode::AddInDataStreamPort( const char * InputParameterName , + const SALOME_ModuleCatalog::DataStreamType InputParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency , + const SUPERV::KindOfPort aKindOfPort ) { +// IncrDataStreamInPorts() ; + GraphBase::InDataStreamPort * aDataStreamPort ; + aDataStreamPort = (GraphBase::InDataStreamPort * ) GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() , + Kind() , + InputParameterName , + DataStreamTypeToString( InputParameterType ).c_str() , + aKindOfPort , +// DataStreamInPortsNumber() , + _Graph_prof_debug , _Graph_fdebug ) ; + aDataStreamPort->Dependency( aDependency ) ; + if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) { + aDataStreamPort->SetParams( SUPERV::TI , SUPERV::L1 , SUPERV::EXTRANULL ) ; } - cdebug_out << "GraphBase::ComputingNode::ReNameLink" << endl ; + return aDataStreamPort ; } +GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( const char * OutputParameterName , + const SALOME_ModuleCatalog::DataStreamType OutputParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency , + const SUPERV::KindOfPort aKindOfPort ) { +// IncrDataStreamOutPorts() ; + GraphBase::OutDataStreamPort * aDataStreamPort ; + aDataStreamPort = (GraphBase::OutDataStreamPort * ) GraphBase::PortsOfNode::AddOutPort( _ORB , NamePtr() , + Kind() , + OutputParameterName , + DataStreamTypeToString( OutputParameterType ).c_str() , + aKindOfPort , +// DataStreamOutPortsNumber() , + _Graph_prof_debug , _Graph_fdebug ) ; + aDataStreamPort->Dependency( aDependency ) ; + return aDataStreamPort ; +} + #include #include @@ -523,6 +507,7 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf const ListOfFuncName FuncNames , const ListOfPythonFunctions PythonFunctions , int XCoordinate , int YCoordinate ) const { + cdebug_in << "SaveXML Node " << Name() << endl ; QDomElement node = Graph.createElement( "node" ) ; info.appendChild( node ) ; QDomElement componentname = Graph.createElement( "component-name" ) ; @@ -565,11 +550,47 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf // f << Tabs << "" << (int ) Kind() << "" << endl ; QDomElement kind = Graph.createElement( "kind" ) ; QString aKind ; - aKind = aKind.setNum( Kind() ) ; + + // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph +// JR : the bug was at line 566 : && HasDataStream() != 0 was missing + if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) { + aKind = aKind.setNum( SUPERV::DataFlowGraph ) ; + } + else { + aKind = aKind.setNum( Kind() ) ; + } aField = Graph.createTextNode( aKind ) ; node.appendChild( kind ) ; kind.appendChild( aField ) ; + if ( IsDataStreamNode() && HasDataStream() != 0 ) { + long Timeout ; + SUPERV::KindOfDataStreamTrace DataStreamTrace ; + double DeltaTime ; + ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ; + + QDomElement timeout = Graph.createElement("streamgraph-timeout") ; + QString aTimeout ; + aTimeout = aTimeout.setNum( Timeout ) ; + aField = Graph.createTextNode( aTimeout ) ; + node.appendChild( timeout ) ; + timeout.appendChild( aField ) ; + + QDomElement datastreamtrace = Graph.createElement("streamgraph-datastreamtrace") ; + QString aDataStreamTrace ; + aDataStreamTrace = aDataStreamTrace.setNum( DataStreamTrace ) ; + aField = Graph.createTextNode( aDataStreamTrace ) ; + node.appendChild( datastreamtrace ) ; + datastreamtrace.appendChild( aField ) ; + + QDomElement deltatime = Graph.createElement("streamgraph-deltatime") ; + QString aDeltaTime ; + aDeltaTime = aDeltaTime.setNum( DeltaTime ) ; + aField = Graph.createTextNode( aDeltaTime ) ; + node.appendChild( deltatime ) ; + deltatime.appendChild( aField ) ; + } + QDomElement couplednode = Graph.createElement("coupled-node") ; if ( IsGOTONode() || IsLoopNode() || IsEndLoopNode() || IsSwitchNode() || IsEndSwitchNode() ) { @@ -599,117 +620,175 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf service.appendChild(servicename) ; servicename.appendChild( aField ) ; -// f << Tabs << " " << endl ; QDomElement inParameterlist = Graph.createElement("inParameter-list") ; service.appendChild(inParameterlist) ; unsigned int i; + GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) this ; for ( i = 0 ; i < ServiceInParameter().length() ; i++ ) { -// f << Tabs << " " << endl ; - QDomElement inParameter = Graph.createElement("inParameter") ; - inParameterlist.appendChild(inParameter) ; -// f << Tabs << " " -// << ServiceInParameter()[i].Parametertype << "" -// << endl ; - QDomElement inParametertype = Graph.createElement("inParameter-type") ; - // mpv: Linux 8.0 compiler compatibility -// aField = Graph.createTextNode( (char *)ServiceInParameter()[i].Parametertype ) ; - if ( strlen( ServiceInParameter()[i].Parametertype ) ) { - aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ; - } - else { - aField = Graph.createTextNode( "?" ) ; - } - inParameter.appendChild(inParametertype) ; - inParametertype.appendChild( aField ) ; -// f << Tabs << " " -// << ServiceInParameter()[i].Parametername << "" -// << endl ; - QDomElement inParametername = Graph.createElement("inParameter-name") ; - // mpv: Linux 8.0 compiler compatibility -// aField = Graph.createTextNode( (char *) ServiceInParameter()[i].Parametername ) ; - if ( strlen( ServiceInParameter()[i].Parametername ) ) { - aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ; - } - else { - aField = Graph.createTextNode( "?" ) ; + const GraphBase::InPort * anInPort ; + anInPort = aNode->GetInPort( ServiceInParameter()[i].Parametername ) ; + if ( !anInPort->IsDataStream() ) { + cdebug << "SaveXML " << i << ". " << ServiceInParameter()[i].Parametername + << " InParameterPort " << anInPort->Kind() << endl ; + QDomElement inParameter = Graph.createElement("inParameter") ; + inParameterlist.appendChild(inParameter) ; + QDomElement inParametertype = Graph.createElement("inParameter-type") ; + if ( strlen( ServiceInParameter()[i].Parametertype ) ) { + aField = Graph.createTextNode( strdup( ServiceInParameter()[i].Parametertype ) ) ; + } + else { + aField = Graph.createTextNode( "?" ) ; + } + inParameter.appendChild(inParametertype) ; + inParametertype.appendChild( aField ) ; + QDomElement inParametername = Graph.createElement("inParameter-name") ; + if ( strlen( ServiceInParameter()[i].Parametername ) ) { + aField = Graph.createTextNode( strdup(ServiceInParameter()[i].Parametername) ) ; + } + else { + aField = Graph.createTextNode( "?" ) ; + } + inParameter.appendChild(inParametername) ; + inParametername.appendChild( aField ) ; } - inParameter.appendChild(inParametername) ; - inParametername.appendChild( aField ) ; -// f << Tabs << " " << endl ; } -// f << Tabs << " " << endl ; -// f << Tabs << " " << endl ; QDomElement outParameterlist = Graph.createElement("outParameter-list") ; service.appendChild(outParameterlist) ; for ( i = 0 ; i < ServiceOutParameter().length() ; i++ ) { -// f << Tabs << " " << endl ; - QDomElement outParameter = Graph.createElement("outParameter") ; - outParameterlist.appendChild(outParameter) ; -// f << Tabs << " " -// << ServiceOutParameter()[i].Parametertype << "" -// << endl ; - QDomElement outParametertype = Graph.createElement("outParameter-type") ; - // mpv: Linux 8.0 compiler compatibility -// aField = Graph.createTextNode( (char *) ServiceOutParameter()[i].Parametertype ) ; - if ( strlen( ServiceOutParameter()[i].Parametertype ) ) { - aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ; - } - else { - aField = Graph.createTextNode( "?" ) ; - } - outParameter.appendChild(outParametertype) ; - outParametertype.appendChild( aField ) ; -// f << Tabs << " " -// << ServiceOutParameter()[i].Parametername << "" -// << endl ; - QDomElement outParametername = Graph.createElement("outParameter-name") ; - // mpv: Linux 8.0 compiler compatibility -// aField = Graph.createTextNode( (char *) ServiceOutParameter()[i].Parametername ) ; - if ( strlen( ServiceOutParameter()[i].Parametername ) ) { - aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ; - } - else { - aField = Graph.createTextNode( "?" ) ; + const GraphBase::OutPort * anOutPort ; + anOutPort = aNode->GetOutPort( ServiceOutParameter()[i].Parametername ) ; + if ( !anOutPort->IsDataStream() ) { + cdebug << "SaveXML " << i << ". " << ServiceOutParameter()[i].Parametername + << " OutParameterPort " << anOutPort->Kind() << endl ; + QDomElement outParameter = Graph.createElement("outParameter") ; + outParameterlist.appendChild(outParameter) ; + QDomElement outParametertype = Graph.createElement("outParameter-type") ; + if ( strlen( ServiceOutParameter()[i].Parametertype ) ) { + aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametertype) ) ; + } + else { + aField = Graph.createTextNode( "?" ) ; + } + outParameter.appendChild(outParametertype) ; + outParametertype.appendChild( aField ) ; + QDomElement outParametername = Graph.createElement("outParameter-name") ; + if ( strlen( ServiceOutParameter()[i].Parametername ) ) { + aField = Graph.createTextNode( strdup(ServiceOutParameter()[i].Parametername) ) ; + } + else { + aField = Graph.createTextNode( "?" ) ; + } + outParameter.appendChild(outParametername) ; + outParametername.appendChild( aField ) ; } - outParameter.appendChild(outParametername) ; - outParametername.appendChild( aField ) ; -// f << Tabs << " " << endl ; } -// f << Tabs << " " << endl ; -// f << Tabs << "" << endl ; -// f << Tabs << "" << endl ; - QDomElement Parameterlist = Graph.createElement("Parameter-list") ; - node.appendChild( Parameterlist ) ; -#if 0 - if ( IsInLineNode() || IsGOTONode() || - IsLoopNode() || IsEndLoopNode() || - IsSwitchNode() || IsEndSwitchNode() ) { - unsigned int i; - for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { - const InPort * anInPort = GetNodeInPort( i ) ; - if ( anInPort->IsBus() ) { - f << Tabs << " " << endl ; - f << Tabs << " " - << anInPort->PortType() << "" - << endl ; - f << Tabs << " " - << anInPort->PortName() << "" - << endl ; - f << Tabs << " " << endl ; - const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ; - f << Tabs << " " << endl ; - f << Tabs << " " - << anOutPort->PortType() << "" - << endl ; - f << Tabs << " " - << anOutPort->PortName() << "" - << endl ; - f << Tabs << " " << endl ; + QDomElement DataStreamlist = Graph.createElement("DataStream-list") ; + node.appendChild( DataStreamlist ) ; + for ( i = 0 ; i < (unsigned int ) GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort ; + anInPort = aNode->GetNodeInPort( i ) ; + if ( anInPort->IsDataStream() ) { + cdebug << "SaveXML " << i << " " << Name() << " " << anInPort->PortName() << " " << anInPort->PortType() + << " InDataStreamPort " << anInPort->Kind() << endl ; + QDomElement inParameter = Graph.createElement("inParameter") ; + DataStreamlist.appendChild(inParameter) ; + QDomElement inParametertype = Graph.createElement("inParameter-type") ; + QString aType ; + aType = aType.setNum( StringToDataStreamType( anInPort->PortType() ) ) ; + cdebug << "SaveXML " << anInPort->PortType() << " --> " << StringToDataStreamType( anInPort->PortType() ) + << " " << aType << endl ; + aField = Graph.createTextNode( aType ) ; + inParameter.appendChild(inParametertype) ; + inParametertype.appendChild( aField ) ; + QDomElement inParametername = Graph.createElement("inParameter-name") ; + if ( strlen( anInPort->PortName() ) ) { + aField = Graph.createTextNode( strdup(anInPort->PortName()) ) ; + } + else { + aField = Graph.createTextNode( "?" ) ; } + inParameter.appendChild(inParametername) ; + inParametername.appendChild( aField ) ; + cdebug << "SaveXML " << anInPort->PortName() << endl ; + QDomElement inParameterdependency = Graph.createElement("inParameter-dependency") ; + QString aDependency ; + aDependency = aDependency.setNum( anInPort->Dependency() ) ; + aField = Graph.createTextNode( aDependency ) ; + inParameter.appendChild(inParameterdependency) ; + inParameterdependency.appendChild( aField ) ; + cdebug << "SaveXML Dependency " << anInPort->Dependency() << endl ; + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + QDomElement inParameterKindOfSchema = Graph.createElement("inParameter-schema") ; + QString aSchema ; + aSchema = aSchema.setNum( aKindOfSchema ) ; + aField = Graph.createTextNode( aSchema ) ; + inParameter.appendChild(inParameterKindOfSchema) ; + inParameterKindOfSchema.appendChild( aField ) ; + cdebug << "SaveXML aKindOfSchema " << aKindOfSchema << endl ; + QDomElement inParameterKindOfInterpolation = Graph.createElement("inParameter-interpolation") ; + QString anInterpolation ; + anInterpolation = anInterpolation.setNum( aKindOfInterpolation ) ; + aField = Graph.createTextNode( anInterpolation ) ; + inParameter.appendChild(inParameterKindOfInterpolation) ; + inParameterKindOfInterpolation.appendChild( aField ) ; + cdebug << "SaveXML aKindOfInterpolation " << aKindOfInterpolation << endl ; + QDomElement inParameterKindOfExtrapolation = Graph.createElement("inParameter-extrapolation") ; + QString anExtrapolation ; + anExtrapolation = anExtrapolation.setNum( aKindOfExtrapolation ) ; + aField = Graph.createTextNode( anExtrapolation ) ; + inParameter.appendChild(inParameterKindOfExtrapolation) ; + inParameterKindOfExtrapolation.appendChild( aField ) ; + cdebug << "SaveXML aKindOfExtrapolation " << aKindOfExtrapolation << endl ; + } + } + for ( i = 0 ; i < (unsigned int ) GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort ; + anOutPort = aNode->GetNodeOutPort( i ) ; + if ( anOutPort->IsDataStream() ) { + cdebug << "SaveXML " << i << " " << Name() << " " << anOutPort->PortName() << " " << anOutPort->PortType() + << " OutDataStreamPort " << anOutPort->Kind() << endl ; + QDomElement outParameter = Graph.createElement("outParameter") ; + DataStreamlist.appendChild(outParameter) ; + QDomElement outParametertype = Graph.createElement("outParameter-type") ; + QString aType ; + aType = aType.setNum( StringToDataStreamType( anOutPort->PortType() ) ) ; + cdebug << "SaveXML " << anOutPort->PortType() << " --> " << StringToDataStreamType( anOutPort->PortType() ) + << " " << aType << endl ; + aField = Graph.createTextNode( aType ) ; + outParameter.appendChild(outParametertype) ; + outParametertype.appendChild( aField ) ; + QDomElement outParametername = Graph.createElement("outParameter-name") ; + if ( strlen( anOutPort->PortName() ) ) { + aField = Graph.createTextNode( strdup(anOutPort->PortName() ) ) ; + } + else { + aField = Graph.createTextNode( "?" ) ; + } + outParameter.appendChild(outParametername) ; + outParametername.appendChild( aField ) ; + cdebug << "SaveXML " << anOutPort->PortName() << endl ; + QDomElement outParameterdependency = Graph.createElement("outParameter-dependency") ; + QString aDependency ; + aDependency = aDependency.setNum( anOutPort->Dependency() ) ; + aField = Graph.createTextNode( aDependency ) ; + outParameter.appendChild(outParameterdependency) ; + outParameterdependency.appendChild( aField ) ; + cdebug << "SaveXML Dependency " << anOutPort->Dependency() << endl ; + long aNumberOfValues ; + aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + QDomElement outParameterNumberOfValues = Graph.createElement("outParameter-values") ; + QString aValues ; + aValues = aValues.setNum( aNumberOfValues ) ; + aField = Graph.createTextNode( aValues ) ; + outParameter.appendChild(outParameterNumberOfValues) ; + outParameterNumberOfValues.appendChild( aField ) ; + cdebug << "SaveXML NumberOfValues " << ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() << endl ; } } -#endif // f << Tabs << "" << endl ; // f << Tabs << "" << endl ; @@ -828,6 +907,7 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf aField = Graph.createTextNode( aYCoordinate ) ; node.appendChild( yposition ) ; yposition.appendChild( aField ) ; + cdebug_out << "SaveXML Node " << Name() << endl ; return true ; } @@ -839,9 +919,20 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , const ListOfFuncName FuncNames , const ListOfPythonFunctions PythonFunctions , int XCoordinate , int YCoordinate ) const { - if ( IsDataFlowNode() ) { + // san - Presumably, data stream graphs should be always saved with kind = DataStreamGraph +// JR : the bug was at line 927 : && HasDataStream() != 0 was missing + if ( IsDataFlowNode() || ( IsDataStreamNode() && HasDataStream() == 0 ) ) { f << Name() << " = Graph( '" << Name() << "' )" << endl ; } + else if ( IsDataStreamNode() && HasDataStream() != 0 ) { + f << Name() << " = StreamGraph( '" << Name() << "' )" << endl ; + long Timeout ; + SUPERV::KindOfDataStreamTrace DataStreamTrace ; + double DeltaTime ; + ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ; + f << aGraphName << ".SetStreamParams( " << Timeout << " , SUPERV." << DataStreamTrace + << " , " << DeltaTime << " )" << endl ; + } else if ( IsComputingNode() ) { int i ; f << Name() << "_ServiceinParameter = []" << endl ; @@ -856,9 +947,26 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , << ServiceOutParameter()[i].Parametertype << "' , '" << ServiceOutParameter()[i].Parametername << "' ) )" << endl ; } + f << Name() << "_ServiceinStreamParameter = []" << endl ; + for ( i = 0 ; i < (int ) ServiceInStreamParameter().length() ; i++ ) { + f << Name() << "_ServiceinStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog." + << ServiceInStreamParameter()[i].Parametertype << " , '" + << ServiceInStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog." + << ServiceInStreamParameter()[i].Parameterdependency << " ) )" << endl ; + } + f << Name() << "_ServiceoutStreamParameter = []" << endl ; + for ( i = 0 ; i < (int ) ServiceOutStreamParameter().length() ; i++ ) { + f << Name() << "_ServiceoutStreamParameter.append( SALOME_ModuleCatalog.ServicesDataStreamParameter( SALOME_ModuleCatalog." + << ServiceOutStreamParameter()[i].Parametertype << " , '" + << ServiceOutStreamParameter()[i].Parametername << "' , SALOME_ModuleCatalog." + << ServiceOutStreamParameter()[i].Parameterdependency << " ) )" << endl ; + } f << Name() << "_Service = SALOME_ModuleCatalog.Service( '" << ServiceName() - << "' , " << Name() << "_ServiceinParameter" << " , " - << Name() << "_ServiceoutParameter" << " , 0 )" << endl ; + << "' , " << Name() << "_ServiceinParameter" + << " , " << Name() << "_ServiceoutParameter" + << " , " << Name() << "_ServiceinStreamParameter" + << " , " << Name() << "_ServiceoutStreamParameter" + << " , 0 , 0 )" << endl ; f << Name() << " = " << aGraphName << ".CNode( " << Name() << "_Service" << " )" << endl ; } @@ -867,6 +975,9 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , << "' , '" << InterfaceName << "' , '" << ServiceName() << "' )" << endl ; } + else if ( IsEndLoopNode() || IsEndSwitchNode() ) { +// It is done with LoopNode or SwitchNode with CoupledNode() + } else { f << "Py" << Name() << " = []" << endl ; int i ; @@ -898,6 +1009,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , // strcat( EndName , Name() ) ; char * EndName = aCoupledNode->Name() ; if ( IsLoopNode() ) { + int i ; SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ; SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ; f << "PyMore" << Name() << " = []" << endl ; @@ -924,7 +1036,96 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; } - f << EndName << ".SetPyFunction( 'End" << FuncNames[0].c_str() << "' , Py" << aCoupledNode->Name() << " )" << endl ; + f << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = GetNodeInPort(i) ; + cdebug << "Node " << Name() << " InPort " << anInPort->PortName() + << " " << anInPort->Kind() << endl ; + if ( anInPort->IsLoop() ) { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + else if ( anInPort->IsInLine() ) { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".InPort( '" << anInPort->PortName() << "' , '" + << anInPort->PortType() << "' )" << endl ; + } + else if ( anInPort->IsDataStream() ) { + f << "I" << Name() << anInPort->PortName() << " = " << Name() + << ".InStreamPort( '" << anInPort->PortName() + << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) + << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + f << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; + } + else if ( anInPort->IsGate() ) { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + } + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; + cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->Kind() << endl ; + if ( anOutPort->IsInLine() || anOutPort->IsLoop() ) { + f << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + } + else if ( anOutPort->IsDataStream() ) { + f << "O" << Name() << anOutPort->PortName() << " = " << Name() + << ".OutStreamPort( '" << anOutPort->PortName() + << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) + << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; + long aNumberOfValues ; + aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + f << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" + << endl ; + } + } + for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ; + cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName() + << " " << anInPort->Kind() << endl ; + if ( anInPort->IsInLine() || anInPort->IsLoop() || anInPort->IsGate() ) { + f << "I" << EndName << anInPort->PortName() << " = " << EndName + << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + else if ( anInPort->IsDataStream() ) { + f << "I" << EndName << anInPort->PortName() << " = " << EndName + << ".InStreamPort( '" << anInPort->PortName() + << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) + << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + f << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; + } + } + for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ; + cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->Kind() << endl ; + if ( anOutPort->IsInLine() || anOutPort->IsLoop() || anOutPort->IsGate() ) { + f << "O" << EndName << anOutPort->PortName() << " = " << EndName + << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + } + else if ( anOutPort->IsDataStream() ) { + f << "O" << EndName << anOutPort->PortName() << " = " << EndName + << ".OutStreamPort( '" << anOutPort->PortName() + << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) + << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; + long aNumberOfValues ; + aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + f << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" + << endl ; + } + } } else if ( IsSwitchNode() ) { f << Name() << "," << EndName << " = " << aGraphName << ".SNode( '" @@ -940,74 +1141,176 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )" << endl ; } - f << EndName << ".SetPyFunction( 'End" << FuncNames[0].c_str() << "' , Py" << aCoupledNode->Name() << " )" << endl ; + f << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ; for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) { const GraphBase::InPort * anInPort = aCoupledNode->GetNodeInPort(i) ; - if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { - f << EndName << ".InPort( '" << anInPort->PortName() + cdebug << "Node " << aCoupledNode->Name() << " InPort " << anInPort->PortName() + << " " << anInPort->Kind() << endl ; +// if ( anInPort->IsGate() || anInPort->IsEndSwitch() ) { + if ( anInPort->IsGate() ) { + f << "I" << EndName << anInPort->PortName() << " = " << EndName + << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + else if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { + f << "I" << EndName << anInPort->PortName() << " = " << EndName + << ".InPort( '" << anInPort->PortName() << "' , '" << anInPort->PortType() << "' )" << endl ; } + else if ( anInPort->IsDataStream() ) { + f << "I" << EndName << anInPort->PortName() << " = " << EndName + << ".InStreamPort( '" << anInPort->PortName() + << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anInPort->PortType() ) + << " , SALOME_ModuleCatalog." << anInPort->Dependency() << " )" << endl ; + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + f << "I" << EndName << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; + } } for ( i = 0 ; i < aCoupledNode->GetNodeOutPortsSize() ; i++ ) { const GraphBase::OutPort * anOutPort = aCoupledNode->GetNodeOutPort(i) ; - if ( anOutPort->IsInLine() ) { - f << EndName << ".OutPort( '" << anOutPort->PortName() + cdebug << "Node " << aCoupledNode->Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->Kind() << endl ; +// if ( anOutPort->IsGate() || anOutPort->IsEndSwitch() ) { + if ( anOutPort->IsGate() ) { + f << "O" << EndName << anOutPort->PortName() << " = " << EndName + << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + } + else if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { + f << "O" << EndName << anOutPort->PortName() << " = " << EndName + << ".OutPort( '" << anOutPort->PortName() << "' , '" << anOutPort->PortType() << "' )" << endl ; } + else if ( anOutPort->IsDataStream() ) { + f << "O" << EndName << anOutPort->PortName() << " = " << EndName + << ".OutStreamPort( '" << anOutPort->PortName() + << "' , SALOME_ModuleCatalog." << StringToDataStreamType( anOutPort->PortType() ) + << " , SALOME_ModuleCatalog." << anOutPort->Dependency() << " )" << endl ; + long aNumberOfValues ; + aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + f << "O" << EndName << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" + << endl ; + } } } delete [] EndName ; } } - f << Name() << ".SetName( '" << Name() << "' )" << endl ; - f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ; - if ( IsFactoryNode() ) { - f << Name() << ".SetContainer( '" << Computer << "' )" << endl ; + if ( IsEndLoopNode() || IsEndSwitchNode() ) { +// It is done with LoopNode or SwitchNode with CoupledNode() } - f << Name() << ".SetComment( '" << Comment() << "' )" << endl ; - f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ; + else { + f << Name() << ".SetName( '" << Name() << "' )" << endl ; + f << Name() << ".SetAuthor( '" << Author() << "' )" << endl ; + if ( IsFactoryNode() ) { + f << Name() << ".SetContainer( '" << Computer << "' )" << endl ; + } + f << Name() << ".SetComment( '" << Comment() << "' )" << endl ; + f << Name() << ".Coords( " << XCoordinate << " , " << YCoordinate << " )" << endl ; - if ( IsOneOfInLineNodes() ) { - int i ; - for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { - const GraphBase::InPort * anInPort = GetNodeInPort(i) ; - if ( anInPort->IsInLine() ) { - f << Name() << ".InPort( '" << anInPort->PortName() << "' , '" - << anInPort->PortType() << "' )" << endl ; + if ( IsComputingNode() || IsFactoryNode() ) { + int i ; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = GetNodeInPort(i) ; + if ( !anInPort->IsDataStream() ) { + cdebug << "Node " << Name() << " InPort " << anInPort->PortName() + << " " << anInPort->Kind() << endl ; + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + } + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; + if ( !anOutPort->IsDataStream() ) { + cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->Kind() << endl ; + f << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + } } } - for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { - const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; - if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { - f << Name() << ".OutPort( '" << anOutPort->PortName() - << "' , '" << anOutPort->PortType() << "' )" << endl ; + else if ( IsOneOfInLineNodes() && !IsLoopNode() ) { + int i ; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = GetNodeInPort(i) ; + cdebug << "Node " << Name() << " InPort " << anInPort->PortName() + << " " << anInPort->Kind() << endl ; + if ( anInPort->IsInLine() || anInPort->IsEndSwitch() ) { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".InPort( '" << anInPort->PortName() << "' , '" + << anInPort->PortType() << "' )" << endl ; + } + else if ( anInPort->IsGate() ) { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".GetInPort( '" << anInPort->PortName() << "' )" << endl ; + } + } + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; + cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->Kind() << endl ; + if ( anOutPort->IsInLine() || anOutPort->IsSwitch() ) { + f << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".OutPort( '" << anOutPort->PortName() + << "' , '" << anOutPort->PortType() << "' )" << endl ; + } + else if ( anOutPort->IsGate() ) { + f << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".GetOutPort( '" << anOutPort->PortName() << "' )" << endl ; + } } } - } - -#if 0 - if ( IsLoopNode() || IsSwitchNode() ) { - f << EndName << ".SetName( '" << CoupledNode - << "' )" << endl ; - f << EndName << ".SetAuthor( '" << CoupledNode->Author() - << "' )" << endl ; - f << EndName << ".SetComment( '" << CoupledNode->Comment() - << "' )" << endl ; - f << EndName << ".Coords( " << CoupledNode->XCoordinate() << " , " - << CoupledNode->YCoordinate() << " )" << endl ; - unsigned int i; - for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { - const InPort * anInPort = GetNodeInPort( i ) ; - if ( anInPort->IsBus() ) { - const OutPort * anOutPort = GetNodeOutPort( anInPort->PortIndex() ) ; - f << Name() << ".BusPorts( '" << anInPort->PortName() << "' , '" - << anInPort->PortType() << "' , '" << anOutPort->PortName() - << "' , '" << anOutPort->PortType() << "' )" << endl ; + if ( !IsDataFlowNode() && !IsDataStreamNode() ) { + int i ; + for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { + const GraphBase::InPort * anInPort = GetNodeInPort(i) ; + cdebug << "Node " << Name() << " InPort " << anInPort->PortName() + << " " << anInPort->Kind() << endl ; + if ( anInPort->IsDataStream() ) { + if ( IsOneOfInLineNodes() ) { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".InStreamPort( '" << anInPort->PortName() << "' , SALOME_ModuleCatalog." + << StringToDataStreamType( anInPort->PortType() ) << " , SALOME_ModuleCatalog." + << anInPort->Dependency() << " )" << endl ; + } + else { + f << "I" << Name() << anInPort->PortName() << " = " + << Name() << ".GetInStreamPort( '" << anInPort->PortName() << "' )" << endl ; + } + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + f << "I" << Name() << anInPort->PortName() << ".SetParams( SUPERV." << aKindOfSchema << " , SUPERV." + << aKindOfInterpolation << " , SUPERV." << aKindOfExtrapolation << " )" << endl ; + } + } + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + const GraphBase::OutPort * anOutPort = GetNodeOutPort(i) ; + cdebug << "Node " << Name() << " OutPort " << anOutPort->PortName() + << " " << anOutPort->Kind() << endl ; + if ( anOutPort->IsDataStream() ) { + if ( IsOneOfInLineNodes() ) { + f << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".OutStreamPort( '" << anOutPort->PortName() << "' , SALOME_ModuleCatalog." + << StringToDataStreamType( anOutPort->PortType() ) << " , SALOME_ModuleCatalog." + << anOutPort->Dependency() << " )" << endl ; + } + else { + f << "O" << Name() << anOutPort->PortName() << " = " + << Name() << ".GetOutStreamPort( '" << anOutPort->PortName() << "' )" << endl ; + } + long aNumberOfValues ; + aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + f << "O" << Name() << anOutPort->PortName() << ".SetNumberOfValues( " << aNumberOfValues << " )" << endl ; + } } } } -#endif + return true ; } @@ -1019,10 +1322,12 @@ void GraphBase::ComputingNode::NodeInfo(ostream & s) const { ostream & operator<< (ostream & f,const GraphBase::ComputingNode & G) { // f << "ComponentName " << G.ComponentName() << endl ; - if ( G.IsComputingNode() ) + if ( G.IsComputingNode() ) { f << "NodeName " << G.Name() << endl ; - else + } + else { f << "DataFlowName " << G.Name() << endl ; + } f << "Kind " << G.Kind() << endl ; f << "Service " << *G.GetService() ; f << "FirstCreation " << G.FirstCreation () << endl ; @@ -1043,8 +1348,9 @@ void GraphBase::ComputingNode::ListLinks(ostream &f ) const { if ( fromPort->IsPortConnected() ) { int j ; for ( j = 0 ; j < fromPort->InPortsSize() ; j++ ) { - if ( j == 0 ) + if ( j == 0 ) { f << "FromNode " << Name() << endl ; + } f << " FromServiceParameterName " << fromPort->GetServicesParameter().Parametername ; const GraphBase::InPort* toPort = fromPort->InPorts( j ) ; diff --git a/src/GraphBase/DataFlowBase_ComputingNode.hxx b/src/GraphBase/DataFlowBase_ComputingNode.hxx index 3774b2d..3458fa8 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.hxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.hxx @@ -9,57 +9,60 @@ // Module : SUPERV // $Header: -#ifndef _DATAFLOWBASE_NODE_HXX -#define _DATAFLOWBASE_NODE_HXX +#ifndef _DATAFLOWBASE_COMPUTINGNODE_HXX +#define _DATAFLOWBASE_COMPUTINGNODE_HXX #include "SALOME_NamingService.hxx" -#include "DataFlowBase_PortsOfNode.hxx" +#include "DataFlowBase_StreamNode.hxx" namespace GraphBase { class InLineNode ; - class ComputingNode : public PortsOfNode { + class ComputingNode : public StreamNode { private: CORBA::ORB_ptr _ORB ; SALOME_NamingService * _NamingService ; - int * _Graph_prof_debug ; - ofstream * _Graph_fdebug ; +//->StreamNode int * _Graph_prof_debug ; +//->StreamNode ofstream * _Graph_fdebug ; SUPERV::CNode_var _Node ; void * _InNode ; // From GraphExecutor:: or GraphEditor:: bool _ObjInterface ; pthread_t _ThreadNo ; - char * _Name ; - SUPERV::KindOfNode _Kind ; +//->StreamNode char * _Name ; +//->StreamNode SUPERV::KindOfNode _Kind ; SUPERV::SDate _FirstCreation ; SUPERV::SDate _LastModification ; char * _EditorRelease ; char * _Author ; char * _Comment ; - bool _HeadNode ; - int _LevelNumber ; - int _SubGraphNumber ; +//->StreamNode bool _HeadNode ; +//->StreamNode int _LevelNumber ; +//->StreamNode int _SubGraphNumber ; bool _GeneratedName ; +//->StreamNode int _DataStreamInPortsNumber ; +//->StreamNode int _DataStreamOutPortsNumber ; + int _ConnectedInPortsNumber ; int _DecrConnectedInPortsNumber ; // For generated NodeNames with ServiceName : number of Nodes using // the same ServiceName. It is not the same Service if it belongs to // a different Interface and/or a different Component ... - map< string , int > _MapOfServiceNames ; +//->StreamNode map< string , int > _MapOfServiceNames ; // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node : - map< string , int > _MapOfLinkedNodes ; - int _LinkedNodesSize ; - vector _LinkedNodes ; - vector _LinkedInPortsNumber ; +//->StreamNode map< string , int > _MapOfLinkedNodes ; +//->StreamNode int _LinkedNodesSize ; +//->StreamNode vector _LinkedNodes ; +//->StreamNode vector _LinkedInPortsNumber ; protected: @@ -94,9 +97,37 @@ namespace GraphBase { SALOME_NamingService * NamingService() const { return _NamingService ; } ; - SUPERV::CNode_var ObjRef() const { return _Node ; } ; + SUPERV::CNode_var ObjRef() const { +// char * _NodeName ; +// cdebug << "ComputingNode::ObjRef() " << _Node << " " << Name() +// << " " << endl ; +// SUPERV::CNode_var _NodeObjRef = SUPERV::CNode::_narrow( _Node ) ; +// if ( CORBA::is_nil( _NodeObjRef ) ) { +// _NodeName = "NilRef" ; +// } +// else { +// try { +// _NodeName = _NodeObjRef->Name() ; +// } +// catch ( ... ) { +// _NodeName = "Catch Error" ; +// } +// } +// cdebug << _NodeName << " " << Name() << endl ; + return _Node ; } ; void SetObjRef(SUPERV::CNode_var aNode) { - _Node = aNode ; } ; +// char * _NodeName ; +// if ( CORBA::is_nil( _Node ) ) { +// _NodeName = "NilRef" ; +// } +// else { +// _NodeName = _Node->Name() ; +// } +// cdebug << "ComputingNode::SetObjRef( " << _Node << " " +// << _NodeName << " ) " << Name() << " --> " ; + _Node = aNode ; +// cdebug << _Node << " " << _Node->Name() << " ) " << Name() << endl ; + } ; void InNode( void * anInNode ) { // cdebug << "GraphBase::ComputingNode::InNode " << Name() << endl ; _InNode = anInNode ; } ; @@ -109,10 +140,8 @@ namespace GraphBase { pthread_t ThreadNo() { return _ThreadNo ; } ; void ThreadNo( pthread_t aThread ) { _ThreadNo = aThread ; } ; - char * Name() const { return my_strdup( _Name ) ; } ; - const char *const * NamePtr() const { return &_Name ; } ; - SUPERV::KindOfNode Kind() const { - return _Kind; } ; +//->StreamNode char * Name() const { return my_strdup( _Name ) ; } ; +//->StreamNode const char *const * NamePtr() const { return &_Name ; } ; // const SALOME_ModuleCatalog::Service * Service() const ; SUPERV::SDate FirstCreation() const ; SUPERV::SDate LastModification() const ; @@ -122,8 +151,7 @@ namespace GraphBase { int XCoordinate() const { return _X ; } ; int YCoordinate() const { return _Y ; } ; - bool Name( const char * aName ) ; - bool Kind( SUPERV::KindOfNode aKind) ; +//->StreamNode bool Name( const char * aName ) ; // void Service( const SALOME_ModuleCatalog::Service aService ) ; void FirstCreation( const SUPERV::SDate aFirstCreation ) ; void LastModification( const SUPERV::SDate aLastModification ) ; @@ -142,56 +170,52 @@ namespace GraphBase { GraphBase::SNode * GetInfo() ; - const bool IsComputingNode() const { - return (_Kind == SUPERV::ComputingNode ) ; } ; - const bool IsFactoryNode() const { - return (_Kind == SUPERV::FactoryNode ) ; } ; - const bool IsOneOfGOTONodes() const { - return (_Kind == SUPERV::LoopNode || - _Kind == SUPERV::EndLoopNode || - _Kind == SUPERV::SwitchNode || - _Kind == SUPERV::EndSwitchNode || - _Kind == SUPERV::GOTONode ) ; } ; - const bool IsOneOfInLineNodes() const { - return (_Kind == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ; - const bool IsInLineNode() const { - return (_Kind == SUPERV::InLineNode ) ; } ; - const bool IsDataFlowNode() const { - return (_Kind == SUPERV::DataFlowNode ) ; } ; - const bool IsLoopNode() const { - return (_Kind == SUPERV::LoopNode ) ; } ; - const bool IsEndLoopNode() const { - return (_Kind == SUPERV::EndLoopNode ) ; } ; - const bool IsSwitchNode() const { - return (_Kind == SUPERV::SwitchNode ) ; } ; - const bool IsEndSwitchNode() const { - return (_Kind == SUPERV::EndSwitchNode ) ; } ; - const bool IsGOTONode() const { - return (_Kind == SUPERV::GOTONode ) ; } ; - void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ; - const bool IsHeadNode() const { return _HeadNode ; } ; +// void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ; +// const bool IsHeadNode() const { return _HeadNode ; } ; bool RemovePorts( const char* aNodeName ) ; + void DelInPort( const char * InputParameterName ) ; + void DelOutPort( const char * OutputParameterName ) ; + InPort * AddInPort( const char * InputParameterName , - const char * InputParameterType ) ; + const char * InputParameterType , + const SUPERV::KindOfPort aKindOfPort ) ; OutPort * AddOutPort( const char * OutputParameterName , - const char * OutputParameterType ) ; + const char * OutputParameterType , + const SUPERV::KindOfPort aKindOfPort ) ; + + void DelInDataStreamPort( const char * InputParameterName ) ; + void DelOutDataStreamPort( const char * OutputParameterName ) ; + + InDataStreamPort * AddInDataStreamPort( const char * InputParameterName , + const SALOME_ModuleCatalog::DataStreamType InputParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency , + const SUPERV::KindOfPort aKindOfPort ) ; + OutDataStreamPort * AddOutDataStreamPort( const char * OutputParameterName , + const SALOME_ModuleCatalog::DataStreamType OutputParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency , + const SUPERV::KindOfPort aKindOfPort ) ; + +// ComputingNode * LinkedNodes( int i ) const { return (GraphBase::ComputingNode *) GraphBase::StreamNode::LinkedNodes( i ) ; } ; + + void AddLink( GraphBase::ComputingNode * ToNode ) { + GraphBase::StreamNode::AddLink( ToNode ) ; + cdebug << Name() << "->GraphBase::ComputingNode::AddLinkedNode( " << ToNode->Name() + << ") ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber() + << " + 1 Service " << ServiceName() << endl ; + ToNode->IncrConnectedInPortsNumber() ; } ; + + void RemoveLink( GraphBase::ComputingNode * ToNode ) { + if ( GraphBase::StreamNode::RemoveLink( ToNode ) ) { + cdebug << "GraphBase::StreamNode::RemoveLink to " << ToNode->Name() << " from " + << Name() << " ConnectedInPortsNumber " + << ToNode->ConnectedInPortsNumber() - 1 << endl ; + ToNode->DecrConnectedInPortsNumber() ; } } ; - void AddLink( ComputingNode * aNode ) ; - void RemoveLink( ComputingNode * aNode ) ; void ReNameLink( const char* OldNodeName , - const char* NewNodeName ) ; - - int GetServiceNameNumber( const char * name ) { - int num = _MapOfServiceNames[ name ] ; - if ( num == 0 ) { - _MapOfServiceNames[ name ] = 1 ; - } - else { - _MapOfServiceNames[ name ] = num + 1 ; - } - return _MapOfServiceNames[ name ] ; } ; + const char* NewNodeName ) { + GraphBase::StreamNode::ReNameLink( OldNodeName , NewNodeName ) ; } ; void IncrConnectedInPortsNumber() { cdebug << "IncrConnectedInPortsNumber " << Name() << " -> " @@ -216,37 +240,6 @@ namespace GraphBase { } return false ; } ; - int GetLinkedNodeIndex( const char * name ) { - int index = _MapOfLinkedNodes[ name ] -1 ; - if ( index >= 0 ) { - cdebug << "GetLinkedNodeIndex of " << name - << " in _MapOfLinkedNodes : " - << index << " Node " << hex << (void *) _LinkedNodes[ index ] - << dec << " '" << _LinkedNodes[ index ]->Name() << "'" - << endl ; - } - return index ; } ; - void SetLinkedNodeIndex( const char * name , const int index ) { - _MapOfLinkedNodes[ name ] = index +1 ; - cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : " - << index << " Node " << hex << (void *) _LinkedNodes[ index ] - << dec << " '" << _LinkedNodes[ index ]->Name() << "'" - << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1 - << endl ; - } ; - void DelLinkedNodeIndex( const char * name ) { - _MapOfLinkedNodes.erase( name ) ; } ; - int LinkedNodesSize() const { return _LinkedNodesSize ; } ; - ComputingNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ; - const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ; - - int Level() { return _LevelNumber ; } ; - void Level( int LevelNumber ) { - _LevelNumber = LevelNumber ; } ; - int SubGraph() { return _SubGraphNumber ; } ; - void SubGraph( int SubGraphNumber ) { - _SubGraphNumber = SubGraphNumber ; } ; - // const GraphBase::ListOfParameters * GetListOfParameters() const ; const long CpuUsed() ; diff --git a/src/GraphBase/DataFlowBase_DataNode.cxx b/src/GraphBase/DataFlowBase_DataNode.cxx index 96cf474..8c4eecc 100644 --- a/src/GraphBase/DataFlowBase_DataNode.cxx +++ b/src/GraphBase/DataFlowBase_DataNode.cxx @@ -39,7 +39,8 @@ GraphBase::DataNode::DataNode( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char *DataFlowName ) : InLineNode( ORB , ptrNamingService , DataFlowName ) { - MESSAGE( "GraphBase::DataNode::DataNode" ); +// MESSAGE( "GraphBase::DataNode::DataNode" ); + cdebug << "GraphBase::DataNode::DataNode" << endl ; _Created = false ; } @@ -66,11 +67,10 @@ GraphBase::DataNode::~DataNode() { // MESSAGE( "GraphBase::DataNode::~DataNode" ); } -void GraphBase::DataNode::DataService( - CORBA::ORB_ptr ORB , - SALOME_ModuleCatalog::Service aService , - int * Graph_prof_debug , - ofstream * Graph_fdebug ) { +void GraphBase::DataNode::DataService( CORBA::ORB_ptr ORB , + SALOME_ModuleCatalog::Service aService , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) { cdebug << "GraphBase::DataNode::DataService : DataFlowPortsOfNode of " << aService.ServiceName << endl ; DefPortsOfNode( ORB , aService , NamePtr() , Kind() , @@ -85,8 +85,7 @@ void GraphBase::DataNode::DataService( _DataFlowDataPorts = new PortsOfNode() ; cdebug << "GraphBase::DataNode::DataService : Mirrored DataFlowPortsOfNode of " << aReversedService.ServiceName << endl ; - _DataFlowDataPorts->DefPortsOfNode( ORB , aReversedService , NamePtr() , - Kind() , + _DataFlowDataPorts->DefPortsOfNode( ORB , aReversedService , NamePtr() , Kind() , Graph_prof_debug , Graph_fdebug ) ; _Created = true ; } @@ -98,13 +97,16 @@ int GraphBase::DataNode::CheckDataServerNodes() const { int i , ierr = 0 ; for ( i = 0 ; i < _DataFlowDataPorts->GetNodeOutPortsSize() ; i++ ) { - if ( !_DataFlowDataPorts->GetNodeOutPort(i)->IsDataConnected() ) { - cdebug << "InPort " << _DataFlowDataPorts->GetNodeOutPort(i)->PortName() +// Not a BUG : Reversed Service of the graph + const GraphBase::OutPort * anOutPort = _DataFlowDataPorts->GetNodeOutPort(i) ; +// if ( !anOutPort->IsGate() && !anOutPort->IsDataStream() && !anOutPort->IsDataConnected() ) { + if ( !anOutPort->IsGate() && !anOutPort->IsDataConnected() ) { + cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " of DataFlow " << Name() << " has NO Data." << endl ; ierr++ ; } else { - cdebug << "InPort " << _DataFlowDataPorts->GetNodeOutPort(i)->PortName() + cdebug << "InPort " << anOutPort->PortName() << " " << anOutPort->PortType() << " of DataFlow " << Name() << " has Data : " // << _DataFlowDataPorts->GetNodeOutPort(i)->Value() << " kind " // << _DataFlowDataPorts->GetNodeOutPort(i)->Kind() diff --git a/src/GraphBase/DataFlowBase_DataNode.hxx b/src/GraphBase/DataFlowBase_DataNode.hxx index c2ceff0..a6a57b0 100644 --- a/src/GraphBase/DataFlowBase_DataNode.hxx +++ b/src/GraphBase/DataFlowBase_DataNode.hxx @@ -37,9 +37,12 @@ namespace GraphBase { private: - GraphBase::PortsOfNode * _DataFlowDataPorts ; bool _Created ; + protected : + + GraphBase::PortsOfNode * _DataFlowDataPorts ; + public: DataNode() ; diff --git a/src/GraphBase/DataFlowBase_DataPort.cxx b/src/GraphBase/DataFlowBase_DataPort.cxx index a623fdf..a4c3663 100644 --- a/src/GraphBase/DataFlowBase_DataPort.cxx +++ b/src/GraphBase/DataFlowBase_DataPort.cxx @@ -30,10 +30,18 @@ using namespace std; #include #include "DataFlowBase_DataPort.hxx" +GraphBase::DataPort::DataPort() : + Port() { + pthread_mutex_init( &_MutexWait , NULL ) ; + InitialValues( CORBA::Any() ) ; +} + GraphBase::DataPort::DataPort( const char *const * NodeName , - const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) : - Port( NodeName , aserviceParameter ) { + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKind , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) : + Port( NodeName , aserviceParameter , aKind , aDependency ) { pthread_mutex_init( &_MutexWait , NULL ) ; InitialValues( CORBA::Any() ) ; } @@ -98,7 +106,8 @@ void GraphBase::DataPort::InitialValues(CORBA::Any aValue ) { } void GraphBase::DataPort::Value( const CORBA::Any & aDataValue ) { - Value( new CORBA::Any( aDataValue ) ) ; + CORBA::Any * aValue = new CORBA::Any( aDataValue ) ; + Value( aValue ) ; } void GraphBase::DataPort::Value( const CORBA::Any * aDataValue ) { diff --git a/src/GraphBase/DataFlowBase_DataPort.hxx b/src/GraphBase/DataFlowBase_DataPort.hxx index 08ed859..0dd2c29 100644 --- a/src/GraphBase/DataFlowBase_DataPort.hxx +++ b/src/GraphBase/DataFlowBase_DataPort.hxx @@ -35,38 +35,43 @@ namespace GraphBase { class DataPort : public Port { - CORBA::Any const * _InitialValue ; - CORBA::Any const * _theValue ; - CORBA::Any const * * _Value ; - SUPERV::GraphState _State ; - bool _Done ; - pthread_mutex_t _MutexWait ; + private: + + CORBA::Any const * _InitialValue ; + CORBA::Any const * _theValue ; + CORBA::Any const * * _Value ; + SUPERV::GraphState _State ; + bool _Done ; + pthread_mutex_t _MutexWait ; public : - DataPort( const char *const * NodeName , - const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) ; - virtual ~DataPort() ; + DataPort() ; + DataPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) ; + virtual ~DataPort() ; - void InitialValues(CORBA::Any aValue ) ; - void Value (const CORBA::Any & aValue ) ; - void Value( const CORBA::Any * aValue ) ; - void Value( const CORBA::Any ** aValue ) ; - CORBA::Any const * Value() const ; - bool BoolValue() const ; - const CORBA::Any ** ValuePtr() const ; + void InitialValues(CORBA::Any aValue ) ; + void Value (const CORBA::Any & aValue ) ; + void Value( const CORBA::Any * aValue ) ; + void Value( const CORBA::Any ** aValue ) ; + CORBA::Any const * Value() const ; + bool BoolValue() const ; + const CORBA::Any ** ValuePtr() const ; - void State( SUPERV::GraphState aState ) { - _State = aState ; } ; - SUPERV::GraphState State() { return _State ; } ; + void State( SUPERV::GraphState aState ) { + _State = aState ; } ; + SUPERV::GraphState State() { return _State ; } ; - void Done( bool aDone ) { -// cdebug << "ChgDone(.) " << NodeName() << " " << PortName() << " " -// << _Done << " -> " << aDone << endl ; - _Done = aDone ; } ; - const bool Done() const { return ( _Done ) ; } ; + void Done( bool aDone ) { +// cdebug << "ChgDone(.) " << NodeName() << " " << PortName() << " " +// << _Done << " -> " << aDone << endl ; + _Done = aDone ; } ; + const bool Done() const { return ( _Done ) ; } ; - void StringValue(ostream & f) const ; + void StringValue(ostream & f) const ; } ; diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index edf6218..2319b70 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -27,7 +27,7 @@ // $Header: using namespace std; -#include "DataFlowBase_Graph.hxx" +#include "DataFlowBase_StreamGraph.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -40,11 +40,13 @@ GraphBase::Graph::Graph() : GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char *DataFlowName , - const char * DebugFileName ) : + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : +// const char * DebugFileName ) : DataNode( ORB ,ptrNamingService , DataFlowName ) { - Set_prof_debug( ORB , DebugFileName ) ; - cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ")" << endl ; _Orb = CORBA::ORB::_duplicate( ORB ) ; + Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ; + cdebug << "GraphBase::Graph::Graph( " << DataFlowName << ") GraphNodesSize() " << GraphNodesSize() << endl ; _GraphNodesSize = 0 ; } @@ -61,16 +63,18 @@ GraphBase::Graph::Graph( CORBA::ORB_ptr ORB , const char * DataFlowAuthor , const char * DataFlowComputer , const char * DataFlowComment , - const char * DebugFileName ) : + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : +// const char * DebugFileName ) : DataNode( ORB , ptrNamingService , DataFlowService , DataFlowName , DataFlowkind , DataFlowFirstCreation , DataFlowLastModification , DataFlowEditorRelease , DataFlowAuthor , DataFlowComment ) { _Orb = CORBA::ORB::_duplicate( ORB ) ; _GraphNodesSize = 0 ; - Set_prof_debug( ORB , DebugFileName ) ; + Set_prof_debug( Graph_prof_debug , Graph_fdebug ) ; cdebug_in << "GraphBase::Graph::Graph" << endl ; - DataService( ORB , DataFlowService , Graph_prof_debug() , Graph_fdebug() ) ; + DataService( ORB , DataFlowService , Graph_prof_debug , Graph_fdebug ) ; cdebug_out << "GraphBase::Graph::Graph" << endl ; } @@ -78,15 +82,11 @@ GraphBase::Graph::~Graph() { cdebug << "GraphBase::Graph::~Graph" << endl ; } -void GraphBase::Graph::Set_prof_debug( CORBA::ORB_ptr ORB , - const char * DebugFileName ) { - _Graph_prof_debug = 0 ; - if ( DebugFileName ) { - _Graph_fdebug = new ofstream( DebugFileName ); - MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl) - SetDebug( ORB , &_Graph_prof_debug , _Graph_fdebug ) ; - } - cdebug << "GraphBase::Graph::Set_prof_debug redirect Trace to file " << DebugFileName << endl ; +void GraphBase::Graph::Set_prof_debug( int * Graph_prof_debug , + ofstream * Graph_fdebug ) { + SetDebug( _Orb , Graph_prof_debug , Graph_fdebug ) ; + _Graph_prof_debug = Graph_prof_debug ; + _Graph_fdebug = Graph_fdebug ; } GraphBase::SNode * GraphBase::Graph::GetInfo() const { @@ -95,6 +95,15 @@ GraphBase::SNode * GraphBase::Graph::GetInfo() const { Info->theInterfaceName = "" ; Info->theName = Name() ; Info->theKind = Kind() ; + if ( IsDataStreamNode() ) { + long Timeout ; + SUPERV::KindOfDataStreamTrace DataStreamTrace ; + double DeltaTime ; + ((GraphBase::StreamGraph * ) this)->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ; + Info->theTimeout = Timeout ; + Info->theDataStreamTrace = DataStreamTrace ; + Info->theDeltaTime = DeltaTime ; + } Info->theService = *GetService() ; Info->theFirstCreation = FirstCreation() ; Info->theLastModification = LastModification() ; @@ -115,6 +124,7 @@ GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { GraphBase::ListOfNodes * _list_nodes = new GraphBase::ListOfNodes; + cdebug_in << "GraphBase::Graph::GetNodes" << endl ; // All the nodes from _InNodes are taken // vector< InNode *> Nodes = InNodes() ; @@ -192,8 +202,100 @@ GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { else { (*_list_nodes)[ind].theCoupledNode = CORBA::string_dup( "" ) ; } +// (*_list_nodes)[ind].theDataStreamInArgsNumber = aCNode->DataStreamInPortsNumber() ; +// (*_list_nodes)[ind].theDataStreamOutArgsNumber = aCNode->DataStreamOutPortsNumber() ; + + (*_list_nodes)[ind].theListOfInDataStreams.resize( aCNode->DataStreamInPortsNumber() ) ; + cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamInPortsNumber() << " DataStreamInPortsNumber" << endl ; + int iostream ; + int streamind = 0 ; + for ( iostream = 0 ; iostream < aCNode->GetNodeInPortsSize() ; iostream++ ) { + const GraphBase::InPort * anInPort ; + anInPort = aCNode->GetNodeInPort( iostream ) ; + if ( anInPort->IsDataStream() ) { + cdebug << "GraphBase::Graph::GetNodes In" << iostream << " " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() + << endl ; + (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anInPort->PortType() ) ; + (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anInPort->PortName() ) ; + (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency = anInPort->Dependency() ; + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) anInPort)->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema = aKindOfSchema ; + (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation = aKindOfInterpolation ; + (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation = aKindOfExtrapolation ; + cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " " + << anInPort->Dependency() << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation << " list_nodes " + << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametername << " " + << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parametertype << " " + << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theDataStreamParameter.Parameterdependency << " " + << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfSchema << " " + << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfInterpolation << " " + << (*_list_nodes)[ind].theListOfInDataStreams[streamind].theKindOfExtrapolation << " " << endl ; + streamind += 1 ; + } + else { + cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anInPort->NodeName() << " " << anInPort->PortName() << " " + << anInPort->Kind() << " IsDataStream " << anInPort->IsDataStream() << endl ; + } + } + + (*_list_nodes)[ind].theListOfOutDataStreams.resize( aCNode->DataStreamOutPortsNumber() ) ; + cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << aCNode->DataStreamOutPortsNumber() << " DataStreamOutPortsNumber" << endl ; + streamind = 0 ; + for ( iostream = 0 ; iostream < aCNode->GetNodeOutPortsSize() ; iostream++ ) { + const GraphBase::OutPort * anOutPort ; + anOutPort = aCNode->GetNodeOutPort( iostream ) ; + if ( anOutPort->IsDataStream() ) { + cdebug << "GraphBase::Graph::GetNodes Out" << iostream << " " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " " + << endl ; + (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype = StringToDataStreamType( anOutPort->PortType() ) ; + (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername = CORBA::string_dup( anOutPort->PortName() ) ; + (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency = anOutPort->Dependency() ; + long aNumberOfValues = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues = aNumberOfValues ; + cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " " + << anOutPort->Dependency() << " " << aNumberOfValues << " list_nodes " + << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametername << " " + << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parametertype << " " + << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theDataStreamParameter.Parameterdependency << " " + << (*_list_nodes)[ind].theListOfOutDataStreams[streamind].theNumberOfValues << endl ; + streamind += 1 ; + } + else { + cdebug << "GraphBase::Graph::GetNodes " << aCNode->Name() << " " << anOutPort->NodeName() << " " << anOutPort->PortName() << " " + << anOutPort->Kind() << " IsDataStream " << anOutPort->IsDataStream() << endl ; + } + } + (*_list_nodes)[ind].theService = *aCNode->GetService(); -// (*_list_nodes)[ind].theListOfParameters = *aCNode->GetListOfParameters() ; + cdebug << "GraphBase::Graph::GetNodes theService " << &(*_list_nodes)[ind].theService.ServiceName << endl ; + unsigned int i ; + for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinParameter.length() ; i++ ) { + cdebug << " In" << i << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername + << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametername + << " " << &(*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype + << " " << (*_list_nodes)[ind].theService.ServiceinParameter[i].Parametertype << endl ; + } + for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutParameter.length() ; i++ ) { + cdebug << " Out" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername + << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametername + << " " << &(*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype + << " " << (*_list_nodes)[ind].theService.ServiceoutParameter[i].Parametertype << endl ; + } + for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceinDataStreamParameter.length() ; i++ ) { + cdebug << " InDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername + << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametername + << " " << &(*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype + << " " << (*_list_nodes)[ind].theService.ServiceinDataStreamParameter[i].Parametertype << endl ; + } + for ( i = 0 ; i < (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter.length() ; i++ ) { + cdebug << " OutDataStream" << i << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername + << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametername + << " " << &(*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype + << " " << (*_list_nodes)[ind].theService.ServiceoutDataStreamParameter[i].Parametertype << endl ; + } if ( aCNode->IsOneOfInLineNodes() ) { GraphBase::InLineNode * aINode = (GraphBase::InLineNode * ) aCNode ; GraphBase::LoopNode * aLNode = NULL ; @@ -242,6 +344,7 @@ GraphBase::ListOfNodes * GraphBase::Graph::GetNodes() const { } } } + cdebug_out << "GraphBase::Graph::GetNodes" << endl ; return _list_nodes ; } @@ -378,24 +481,35 @@ GraphBase::ListOfLinks * GraphBase::Graph::GetDatas() const { } bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) { - cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " - << aNode->Name() << " " << aNode->ServiceName() << endl; + cdebug_in << "GraphBase::Graph::AddNode " << (void *) aNode << " " << aNode->Name() << " " << aNode->ServiceName() << endl; bool RetVal = false ; int index = GetGraphNodeIndex( aNode->Name() ) ; if ( index < 0 ) { + cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " nodes + 1" << endl ; _GraphNodes.resize( _GraphNodesSize+1 ) ; _GraphNodes[ _GraphNodesSize ] = aNode ; SetGraphNodeIndex( aNode->Name() , _GraphNodesSize ) ; _GraphNodesSize += 1 ; + if ( SetServiceOfMap( (GraphBase::Service * ) aNode ) ) { + cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() << " in MapOfServices" << endl ; + } + else { + cdebug << "Graph::AddNode SetServiceOfMap " << aNode->ServiceName() + << " was already in MapOfServices" << endl ; + } + RetVal = true ; - } -// cout << "GraphBase::Graph::AddNode(" << aNode->ComponentName() << " , " -// << aNode->Name() << ")" << endl; - int i ; - cdebug << "GraphBase::Graph::AddNode Known nodes :" << endl ; - for ( i = 0 ; i < _GraphNodesSize ; i++ ) { - cdebug << i << ". " << GetGraphNode( i )->Name() << " " - << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ; + int i ; + cdebug << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Known nodes :" << endl ; + for ( i = 0 ; i < _GraphNodesSize ; i++ ) { + const GraphBase::ComputingNode * aKnownNode = GetGraphNode( i ) ; + if ( aKnownNode ) { + cdebug << i << ". " << aKnownNode->Name() << " " << _MapOfGraphNodes[ GetGraphNode( i )->Name() ] - 1 << endl ; + } + else { + cdebug << i << ". ERROR" << endl ; + } + } } cdebug_out << "GraphBase::Graph::AddNode " << _GraphNodesSize << " Nodes. " << aNode->ServiceName() << endl; @@ -442,7 +556,12 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , else { GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; cdebug << " fromConnected " << FromNode->Name() << endl ; - FromNode->ReNameLink( OldNodeName , NewNodeName ) ; + if ( anInPort->IsDataStream() ) { + FromNode->ReNameStreamLink( OldNodeName , NewNodeName ) ; + } + else { + FromNode->ReNameLink( OldNodeName , NewNodeName ) ; + } } char* OldNodePortName = new char[ strlen( OldNodeName ) + strlen( aNode->GetChangeNodeInPort( i )->PortName() ) + 2 ] ; @@ -506,7 +625,12 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { else { GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; cdebug << " fromConnected " << FromNode->Name() << endl ; - FromNode->RemoveLink( aNode ) ; + if ( anInPort->IsDataStream() ) { + FromNode->RemoveStreamLink( aNode ) ; + } + else { + FromNode->RemoveLink( aNode ) ; + } } RetVal = anOutPort->RemoveInPort( anInPort ) ; if ( !RetVal ) @@ -535,7 +659,12 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { if ( !RetVal ) break ; GraphBase::ComputingNode * ToNode = GetChangeGraphNode( anOutPort->InPorts( j )->NodeName() ) ; - aNode->RemoveLink( ToNode ) ; + if ( anOutPort->IsDataStream() ) { + aNode->RemoveStreamLink( ToNode ) ; + } + else { + aNode->RemoveLink( ToNode ) ; + } RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ; if ( !RetVal ) break ; @@ -653,16 +782,27 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , cdebug << "AddLink toPort not found." << endl ; return false ; } + if ( ( fromPort->IsDataStream() && !toPort->IsDataStream() ) || + ( !fromPort->IsDataStream() && toPort->IsDataStream() ) ) { + cdebug << "AddLink fromPort/toPort Stream/Flow. ERROR" << endl ; + return false ; + } + if ( fromPort->IsDataStream() && fromPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL && + toPort->Dependency() == SALOME_ModuleCatalog::DATASTREAM_ITERATIVE ) { + cdebug << "AddLink fromPort/toPort Stream DATASTREAM_TEMPORAL --> DATASTREAM_ITERATIVE. ERROR" << endl ; + return false ; + } cdebug_in << "GraphBase::Graph::AddLink(" << fromNode->Name() << "(" << fromPort->PortName() << ") ---> " << toNode->Name() << "(" << toPort->PortName() << ") )" << endl; - if ( !fromNode->IsDataFlowNode() && !toNode->IsDataFlowNode() && + if ( !fromNode->IsDataFlowNode() && !fromNode->IsDataStreamNode() && + !toNode->IsDataFlowNode() && !toNode->IsDataStreamNode() && toPort->GetOutPort() ) { if ( !strcmp( toPort->GetOutPort()->NodePortName() , fromPort->NodePortName() ) ) { cdebug << "Link already exists" << endl ; - cdebug_out << "GraphBase::Graph::AddLink" << endl; + cdebug_out << "GraphBase::Graph::AddLink 1" << endl; return true ; } else if ( toPort->IsDataConnected() ) { @@ -715,7 +855,9 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , cdebug_out << "GraphBase::Graph::AddLink" << endl; return false ; } - toPort->Kind( SUPERV::EndSwitchParameter ) ; + if ( !toPort->IsDataStream() ) { + toPort->Kind( SUPERV::EndSwitchParameter ) ; + } } else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort cdebug << "!fromPort->AddLink Error." << endl ; @@ -723,7 +865,8 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , return false ; } - if ( fromNode->IsDataFlowNode() && toPort->IsDataConnected() ) { + if ( ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() ) && + toPort->IsDataConnected() ) { toPort->RemoveOutPort() ; } @@ -761,23 +904,33 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , } fromPort->PortStatus( PortConnected ); // GOTO - Loop } - else if ( fromNode->IsDataFlowNode() || toNode->IsDataFlowNode() ) { + else if ( fromNode->IsDataFlowNode() || fromNode->IsDataStreamNode() || + toNode->IsDataFlowNode() || toNode->IsDataStreamNode() ) { cdebug << "AddLink IsDataFlowNode fromPort->PortStatus( DataConnected ) " << fromNode->Name() << " " << fromPort->PortName() << endl ; fromPort->PortStatus( DataConnected ); } else { cdebug << "AddLink fromPort->PortStatus( PortConnected ) & fromNode->toNode " - << fromNode->Name() << " " << fromPort->PortName() << endl; + << fromNode->Name() << " " << fromPort->PortName() << " " + << fromPort->Kind() << " -> " << toNode->Name() << " " << " " + << toPort->PortName() << " " << toPort->Kind() << endl; fromPort->PortStatus( PortConnected ); - fromNode->AddLink( toNode ) ; + if ( fromPort->IsDataStream() && toPort->IsDataStream() ) { + fromNode->AddStreamLink( toNode ) ; + } + else { + fromNode->AddLink( toNode ) ; + } } if ( fromNode->IsSwitchNode() ) { - if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) { - fromPort->Kind( SUPERV::SwitchParameter ) ; - } - else if ( !fromPort->IsGate() && !toPort->IsGate() ){ - fromPort->Kind( SUPERV::InLineParameter ) ; + if ( !fromPort->IsDataStream() ) { + if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) { + fromPort->Kind( SUPERV::SwitchParameter ) ; + } + else if ( !fromPort->IsGate() && !toPort->IsGate() ){ + fromPort->Kind( SUPERV::InLineParameter ) ; + } } if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) { GraphBase::InLineNode * anEndSwitchNode ; @@ -799,7 +952,7 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , } } // cdebug << fromNode->ServiceName() << " " << toNode->ServiceName() << endl ; - cdebug_out << "GraphBase::Graph::AddLink" << endl; + cdebug_out << "GraphBase::Graph::AddLink 1" << endl; return true ; } @@ -822,33 +975,16 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ; if ( RetVal ) { if ( fromNode ) { - fromNode->RemoveLink( toNode ) ; + if ( anInPort->IsDataStream() ) { + fromNode->RemoveStreamLink( toNode ) ; + } + else { + fromNode->RemoveLink( toNode ) ; + } } if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) { anOutPort->Kind( SUPERV::InLineParameter ) ; } -#if 0 - if ( fromNode->IsEndLoopNode() ) { - toNode = ((GraphBase::EndOfLoopNode * ) fromNode)->CoupledNode() ; - if ( toNode ) { - anInPort = toNode->GetChangeInPort( ToServiceParameterName ) ; - RetVal = AddLink( fromNode , anOutPort , toNode , anInPort ) ; - } - else { - RetVal = false ; - } - } - if ( toNode->IsLoopNode() ) { - fromNode = ((GraphBase::LoopNode * ) toNode)->CoupledNode() ; - if ( fromNode ) { - anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; - RetVal = AddLink( fromNode , anOutPort , toNode , toNode->GetChangeInPort( ToServiceParameterName ) ) ; - } - else { - RetVal = false ; - } - } -#endif } } } @@ -1157,6 +1293,33 @@ bool GraphBase::Graph::AddOutputData( return RetVal ; } +map< string , GraphBase::Service * > GraphBase::Graph::MapOfServiceNames() { + return _MapOfServiceNames ; } + +GraphBase::Service * GraphBase::Graph::GetServiceOfMap( char * name ) { + return _MapOfServiceNames[ name ] ; +} + +bool GraphBase::Graph::SetServiceOfMap( GraphBase::Service * aService ) { + GraphBase::Service * theService = _MapOfServiceNames[ aService->ServiceName() ] ; + if ( theService ) { + cdebug << "SetServiceOfMap of " << aService->ServiceName() + << " already in MapOfServiceNames : erase" << endl ; + _MapOfServiceNames.erase( aService->ServiceName() ) ; + } + _MapOfServiceNames[ (char * ) aService->ServiceName() ] = aService ; + cdebug << "SetServiceOfMap of " << aService->ServiceName() << " done" << endl ; + return true ; +} + +int GraphBase::Graph::GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) { + GraphBase::Service * theService = _MapOfServiceNames[ (char * ) aService.ServiceName ] ; + if ( theService == NULL ) { + return 1 ; + } + return theService->NewInstance() ; +} + bool GraphBase::Graph::CreateService() { cdebug_in << "GraphBase::Graph::CreateService" << endl; bool RetVal = true ; @@ -1165,33 +1328,64 @@ bool GraphBase::Graph::CreateService() { GraphBase::ComputingNode * aToNode ; int dostore ; int innbr ; + int instreamnbr ; int outnbr ; - for ( dostore = 0 ; dostore <= 1 ; dostore++ ) { + int outstreamnbr ; + vector< SUPERV::KindOfPort > InPortsKind ; + vector< SALOME_ModuleCatalog::DataStreamDependency > InDataStreamDependency ; + vector< SUPERV::KindOfSchema > InKindOfSchema ; + vector< SUPERV::KindOfInterpolation > InKindOfInterpolation ; + vector< SUPERV::KindOfExtrapolation > InKindOfExtrapolation ; + vector< SUPERV::KindOfPort > OutPortsKind ; + vector< SALOME_ModuleCatalog::DataStreamDependency > OutDataStreamDependency ; + vector< long > OutNumberOfValues ; + for ( dostore = 0 ; dostore <= 2 ; dostore++ ) { if ( dostore == 1 ) { aService.ServiceName = Name() ; aService.ServiceinParameter.length( 0 ) ; aService.ServiceinParameter.length( innbr ) ; aService.ServiceoutParameter.length( 0 ) ; aService.ServiceoutParameter.length( outnbr ) ; + InPortsKind.resize( innbr ) ; + InDataStreamDependency.resize( innbr ) ; + InKindOfSchema.resize( innbr ) ; + InKindOfInterpolation.resize( innbr ) ; + InKindOfExtrapolation.resize( innbr ) ; + OutPortsKind.resize( outnbr ) ; + OutDataStreamDependency.resize( outnbr ) ; + OutNumberOfValues.resize( outnbr ) ; + } + else if ( dostore == 2 ) { + cdebug << "GraphBase::Graph::CreateService ->DataService innbr " << innbr << " instreamnbr " << instreamnbr << " outnbr " << outnbr + << " outstreamnbr " << outstreamnbr << endl ; + DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ; + aService.ServiceinParameter.length( innbr + instreamnbr ) ; + aService.ServiceoutParameter.length( outnbr + outstreamnbr ) ; + InPortsKind.resize( innbr + instreamnbr ) ; + InDataStreamDependency.resize( innbr + instreamnbr ) ; + InKindOfSchema.resize( innbr + instreamnbr ) ; + InKindOfInterpolation.resize( innbr + instreamnbr ) ; + InKindOfExtrapolation.resize( innbr + instreamnbr ) ; + OutPortsKind.resize( outnbr + outstreamnbr ) ; + OutDataStreamDependency.resize( outnbr + outstreamnbr ) ; + OutNumberOfValues.resize( outnbr + outstreamnbr ) ; + } + if ( dostore == 0 ) { + innbr = 0 ; + instreamnbr = 0 ; + outnbr = 0 ; + outstreamnbr = 0 ; + } + if ( dostore == 1 ) { + innbr = 0 ; + outnbr = 0 ; } - innbr = 0 ; - outnbr = 0 ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { aToNode = GraphNodes( i ) ; for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) { GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ; -#if 0 - if ( dostore == 0 && - strcmp( anInPort->ServicesParameterType() , "string" ) && - strcmp( anInPort->ServicesParameterType() , "long" ) && - strcmp( anInPort->ServicesParameterType() , "double" ) && - strcmp( anInPort->ServicesParameterType() , "objref" ) ) { - cdebug << "CreateService Node " << aToNode->Name() << ". Input port " << anInPort->PortName() - << " has illegal type " << anInPort->ServicesParameterType() << endl ; - RetVal = false ; - } -#endif bool isfromcouplednode = false ; + cdebug << "GraphBase::Graph::CreateService aToNode " << aToNode->Name() << " InPort" << j << endl ; if ( anInPort->IsConnected() && anInPort->GetOutPort() ) { GraphBase::ComputingNode * aFromNode = GetChangeGraphNode( anInPort->GetOutPort()->NodeName() ) ; if ( aFromNode->IsEndLoopNode() && ((GraphBase::EndOfLoopNode * ) aFromNode)->CoupledNode() == aToNode ) { @@ -1207,14 +1401,30 @@ bool GraphBase::Graph::CreateService() { cdebug << "DataConnected from " << *(anInPort->GetOutPort() ) ; } cdebug << endl ; - innbr += 1 ; + if ( anInPort->IsDataStream() ) { + instreamnbr += 1 ; + } + else { + innbr += 1 ; + } } - else { + else if ( ( dostore == 1 && !anInPort->IsDataStream() ) || + ( dostore == 2 && anInPort->IsDataStream() ) ) { aService.ServiceinParameter[innbr].Parametertype = CORBA::string_dup( anInPort->PortType() ) ; - aService.ServiceinParameter[innbr++].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ; + aService.ServiceinParameter[innbr].Parametername = CORBA::string_dup( anInPort->NodePortName() ) ; + InPortsKind[ innbr ] = anInPort->Kind() ; + InDataStreamDependency[ innbr ] = anInPort->Dependency() ; + if ( dostore == 2 && anInPort->IsDataStream() ) { + ((GraphBase::InDataStreamPort * ) anInPort)->Params( InKindOfSchema[ innbr ] , + InKindOfInterpolation[ innbr ] , + InKindOfExtrapolation[ innbr ] ) ; + } + cdebug << "In" << innbr << " " << aService.ServiceinParameter[ innbr ].Parametername << " " + << anInPort->Kind() << endl ; + innbr += 1 ; } } - else { + else if ( dostore == 0 ) { cdebug << "CreateService " << aToNode->Name() << " Input port " << anInPort->PortName() ; if ( anInPort->IsConnected() ) { cdebug << " is connected " ; @@ -1237,35 +1447,38 @@ bool GraphBase::Graph::CreateService() { GraphBase::ComputingNode * aFromNode = aToNode ; for ( j = 0 ; j < aFromNode->GetNodeOutPortsSize() ; j++ ) { GraphBase::OutPort *anOutPort = aFromNode->GetChangeNodeOutPort(j) ; - cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] "; - if ( anOutPort ) { - cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ; - } - else { - cdebug << " NULL" << endl ; - } -#if 0 - if ( dostore == 0 && - strcmp( anOutPort->ServicesParameterType() , "string" ) && - strcmp( anOutPort->ServicesParameterType() , "long" ) && - strcmp( anOutPort->ServicesParameterType() , "double" ) && - strcmp( anOutPort->ServicesParameterType() , "objref" ) ) { - cdebug << "CreateService Node " << aFromNode->Name() << ". Output port " << anOutPort->PortName() - << " has illegal type " << anOutPort->ServicesParameterType() << endl ; - RetVal = false ; - } -#endif +// cdebug << "CreateService Node " << aFromNode->Name() << ". Output port[" << j << "] "; +// if ( anOutPort ) { +// cdebug << anOutPort->PortName() << " " << anOutPort->ServicesParameterType() << endl ; +// } +// else { +// cdebug << " NULL" << endl ; +// } if ( !aFromNode->IsGOTONode() ) { if ( !anOutPort->IsGate() && ( anOutPort->IsNotConnected() || anOutPort->IsDataConnected() ) ) { if ( dostore == 0 ) { - cdebug << "CreateService " << aFromNode->Name() << " Output port " - << anOutPort->PortName() << endl ; - outnbr += 1 ; +// cdebug << "CreateService " << aFromNode->Name() << " Output port " +// << anOutPort->PortName() << endl ; + if ( anOutPort->IsDataStream() ) { + outstreamnbr += 1 ; + } + else { + outnbr += 1 ; + } } - else { + else if ( ( dostore == 1 && !anOutPort->IsDataStream() ) || + ( dostore == 2 && anOutPort->IsDataStream() ) ) { aService.ServiceoutParameter[outnbr].Parametertype = CORBA::string_dup( anOutPort->PortType() ) ; - aService.ServiceoutParameter[outnbr++].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ; + aService.ServiceoutParameter[outnbr].Parametername = CORBA::string_dup( anOutPort->NodePortName() ) ; + OutPortsKind[ outnbr ] = anOutPort->Kind() ; + OutDataStreamDependency[ outnbr ] = anOutPort->Dependency() ; + if ( dostore == 2 && anOutPort->IsDataStream() ) { + OutNumberOfValues[ outnbr ] = ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues() ; + } + cdebug << "Out" << outnbr << " " << aService.ServiceoutParameter[ outnbr ].Parametername << " " + << anOutPort->Kind() << endl ; + outnbr += 1 ; } } } @@ -1273,25 +1486,102 @@ bool GraphBase::Graph::CreateService() { } } -// MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName ); -// for ( i = 0 ; i < innbr ; i++ ) { -// cout << "aService.ServiceinParameter[" << i << "].Parametertype " -// << aService.ServiceinParameter[i].Parametertype << endl ; -// cout << "aService.ServiceinParameter[" << i << "].Parametername " -// << aService.ServiceinParameter[i].Parametername << endl ; -// } -// for ( i = 0 ; i < outnbr ; i++ ) { -// cout << "aService.ServiceoutParameter[" << i << "].Parametertype " -// << aService.ServiceoutParameter[i].Parametertype << endl ; -// cout << "aService.ServiceoutParameter[" << i << "].Parametername " -// << aService.ServiceoutParameter[i].Parametername << endl ; -// } - - DataService( _Orb , aService , Graph_prof_debug() , Graph_fdebug() ) ; - + MESSAGE( "DataFlowNode ServiceName " << aService.ServiceName ); + for ( i = 0 ; i < innbr ; i++ ) { + cdebug << "aService.ServiceinParameter[" << i << "].Parametertype " + << aService.ServiceinParameter[i].Parametertype << " Parametername " + << aService.ServiceinParameter[i].Parametername << " " << InPortsKind[ i ] << endl ; + if ( InPortsKind[ i ] != SUPERV::DataStreamParameter ) { + cdebug << "NodeInPort[" << i << "] " << *GetChangeNodeInPort( i ) << endl ; + } + } + for ( i = 0 ; i < outnbr ; i++ ) { + cdebug << "aService.ServiceoutParameter[" << i << "].Parametertype " + << aService.ServiceoutParameter[i].Parametertype << " Parametername " + << aService.ServiceoutParameter[i].Parametername << " " << OutPortsKind[ i ] << endl ; + if ( OutPortsKind[ i ] != SUPERV::DataStreamParameter ) { + cdebug << "NodeOutPort[" << i << "] " << *GetChangeNodeOutPort( i ) << endl ; + } + } + +// DataService( _Orb , aService , InPortsKind , OutPortsKind , Graph_prof_debug() , Graph_fdebug() ) ; + for ( i = 0 ; i < innbr ; i++ ) { + if ( InPortsKind[ i ] == SUPERV::DataStreamParameter ) { + GraphBase::InDataStreamPort * anInPort = AddInDataStreamPort( aService.ServiceinParameter[ i ].Parametername , + StringToDataStreamType( aService.ServiceinParameter[ i ].Parametertype ) , + InDataStreamDependency[ i ] , + SUPERV::DataStreamParameter ) ; + anInPort->SetParams( InKindOfSchema[ i ] , + InKindOfInterpolation[ i ] , + InKindOfExtrapolation[ i ] ) ; +// NOT A BUG : AddOutPort for an inport (Reversed service) + anInPort = (GraphBase::InDataStreamPort * ) _DataFlowDataPorts->AddOutPort( _Orb , NamePtr() , + Kind() , + aService.ServiceinParameter[ i ].Parametername , + aService.ServiceinParameter[ i ].Parametertype , + SUPERV::DataStreamParameter , +// _DataFlowDataPorts->DataStreamOutPortsNumber() , + _Graph_prof_debug , _Graph_fdebug ) ; + anInPort->Dependency( InDataStreamDependency[ i ] ) ; +// Attention : revoir les reversed DataStreamPorts +// anInPort->SetParams( InKindOfSchema[ i ] , +// InKindOfInterpolation[ i ] , +// InKindOfExtrapolation[ i ] ) ; + cdebug << "InStreamPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ; + cdebug << "ReversedInStreamPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() + << endl ; + } + else { + GetChangeNodeInPort( i )->Kind( InPortsKind[ i ] ) ; + _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind( InPortsKind[ i ] ) ; + GetChangeNodeInPort( i )->Dependency( InDataStreamDependency[ i ] ) ; + _DataFlowDataPorts->GetChangeNodeOutPort( i )->Dependency( InDataStreamDependency[ i ] ) ; + cdebug << "InPort " << GetChangeNodeInPort( i )->PortName() << " " << GetChangeNodeInPort( i )->Kind() << endl ; + cdebug << "ReversedInPort " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeOutPort( i )->Kind() + << endl ; + } + } + for ( i = 0 ; i < outnbr ; i++ ) { + if ( OutPortsKind[ i ] == SUPERV::DataStreamParameter ) { + GraphBase::OutDataStreamPort * anOutPort = AddOutDataStreamPort( aService.ServiceoutParameter[ i ].Parametername , + StringToDataStreamType( aService.ServiceoutParameter[ i ].Parametertype ) , + OutDataStreamDependency[ i ] , + SUPERV::DataStreamParameter ) ; + anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ; +// NOT A BUG : AddInPort for an outport (Reversed service) + anOutPort = (GraphBase::OutDataStreamPort * ) _DataFlowDataPorts->AddInPort( _Orb , NamePtr() , + Kind() , + aService.ServiceoutParameter[ i ].Parametername , + aService.ServiceoutParameter[ i ].Parametertype , + SUPERV::DataStreamParameter , +// _DataFlowDataPorts->DataStreamInPortsNumber() , + _Graph_prof_debug , _Graph_fdebug ) ; + anOutPort->Dependency( OutDataStreamDependency[ i ] ) ; +// Attention : revoir les reversed DataStreamPorts +// anOutPort->NumberOfValues( OutNumberOfValues[ i ] ) ; + cdebug << "OutStreamPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ; + cdebug << "ReversedOutStreamPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind() + << endl ; + } + else { + GetChangeNodeOutPort( i )->Kind( OutPortsKind[ i ] ) ; + _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind( OutPortsKind[ i ] ) ; + GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ; + _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ; + GetChangeNodeOutPort( i )->Dependency( OutDataStreamDependency[ i ] ) ; + _DataFlowDataPorts->GetChangeNodeInPort( i )->Dependency( OutDataStreamDependency[ i ] ) ; + cdebug << "OutPort " << GetChangeNodeOutPort( i )->PortName() << " " << GetChangeNodeOutPort( i )->Kind() << endl ; + cdebug << "ReversedOutPort " << _DataFlowDataPorts->GetChangeNodeInPort( i )->PortName() << " " << _DataFlowDataPorts->GetChangeNodeInPort( i )->Kind() + << endl ; + } + } // Restore input datas : + DataStreamInPortsNumber( 0 ) ; + DataStreamOutPortsNumber( 0 ) ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { aToNode = GraphNodes( i ) ; + DataStreamInPortsNumber( DataStreamInPortsNumber() + aToNode->DataStreamInPortsNumber() ) ; + DataStreamOutPortsNumber( DataStreamOutPortsNumber() + aToNode->DataStreamOutPortsNumber() ) ; for ( j = 0 ; j < aToNode->GetNodeInPortsSize() ; j++ ) { GraphBase::InPort *anInPort = aToNode->GetChangeNodeInPort(j) ; if ( anInPort->IsDataConnected() ) { @@ -1310,62 +1600,99 @@ bool GraphBase::Graph::InLineServices() { cdebug_in << "GraphBase::Graph::InLineServices" << endl; int i , j ; + ListPorts( *_Graph_fdebug , 0 ) ; GraphBase::InLineNode * aINode ; SALOME_ModuleCatalog::Service aService ; for ( i = 0 ; i < GraphNodesSize() ; i++ ) { aINode = (GraphBase::InLineNode * ) GraphNodes( i ) ; +// if ( aINode->IsOneOfInLineNodes() || aINode->HasDataStream() ) { if ( aINode->IsOneOfInLineNodes() ) { cdebug << "GraphBase::Graph::InLineServices " << aINode->Name() << endl; aService.ServiceName = aINode->ServiceName() ; aService.ServiceinParameter.length( 0 ) ; aService.ServiceoutParameter.length( 0 ) ; + aINode->DataStreamInPortsNumber( 0 ) ; + aINode->DataStreamOutPortsNumber( 0 ) ; int InService = 0 ; + int InStreamService = 0 ; for ( j = 0 ; j < aINode->GetNodeInPortsSize() ; j++ ) { - if ( aINode->GetChangeNodeInPort(j)->IsGate() || - aINode->GetChangeNodeInPort(j)->IsLoop() ) { -// cdebug << "GraphBase::Graph::InLineServices In" << j << " " -// << aINode->GetChangeNodeInPort(j)->Kind() << " " -// << aINode->GetChangeNodeInPort(j)->PortType() << " " -// << aINode->GetChangeNodeInPort(j)->PortName() << " ignored " -// << aINode->GetChangeNodeInPort(j)->IsGate() << " " -// << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; +// if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() || aINode->GetChangeNodeInPort(j)->IsDataStream() ) { + if ( aINode->GetChangeNodeInPort(j)->IsGate() || aINode->GetChangeNodeInPort(j)->IsLoop() ) { + cdebug << "GraphBase::Graph::InLineServices In" << j << " " + << aINode->GetChangeNodeInPort(j)->Kind() << " " + << aINode->GetChangeNodeInPort(j)->PortType() << " " + << aINode->GetChangeNodeInPort(j)->PortName() << " ignored " + << aINode->GetChangeNodeInPort(j)->IsGate() << " " + << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; + } + else if ( aINode->GetChangeNodeInPort(j)->IsDataStream() ) { + aService.ServiceinDataStreamParameter.length( InStreamService+1 ) ; + aService.ServiceinDataStreamParameter[InStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeInPort(j)->PortType() ) ; + aService.ServiceinDataStreamParameter[InStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ; + aService.ServiceinDataStreamParameter[InStreamService++].Parameterdependency = aINode->GetChangeNodeInPort(j)->Dependency() ; + aINode->IncrDataStreamInPorts() ; + cdebug << "GraphBase::Graph::InLineServices In" << j << " " + << aINode->GetChangeNodeInPort(j)->Kind() << " " + << aINode->GetChangeNodeInPort(j)->PortType() << " " + << aINode->GetChangeNodeInPort(j)->PortName() << " " + << aINode->GetChangeNodeInPort(j)->IsGate() << " " + << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; } else { aService.ServiceinParameter.length( InService+1 ) ; aService.ServiceinParameter[InService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortType() ) ; aService.ServiceinParameter[InService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeInPort(j)->PortName() ) ; -// cdebug << "GraphBase::Graph::InLineServices In" << j << " " -// << aINode->GetChangeNodeInPort(j)->Kind() << " " -// << aINode->GetChangeNodeInPort(j)->PortType() << " " -// << aINode->GetChangeNodeInPort(j)->PortName() << " " -// << aINode->GetChangeNodeInPort(j)->IsGate() << " " -// << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; + cdebug << "GraphBase::Graph::InLineServices In" << j << " " + << aINode->GetChangeNodeInPort(j)->Kind() << " " + << aINode->GetChangeNodeInPort(j)->PortType() << " " + << aINode->GetChangeNodeInPort(j)->PortName() << " " + << aINode->GetChangeNodeInPort(j)->IsGate() << " " + << aINode->GetChangeNodeInPort(j)->IsLoop() << endl; } } int OutService = 0 ; + int OutStreamService = 0 ; for ( j = 0 ; j < aINode->GetNodeOutPortsSize() ; j++ ) { - if ( aINode->GetChangeNodeOutPort(j)->IsGate() || - aINode->GetChangeNodeOutPort(j)->IsLoop() ) { -// cdebug << "GraphBase::Graph::InLineServices Out" << j << " " -// << aINode->GetChangeNodeOutPort(j)->Kind() << " " -// << aINode->GetChangeNodeOutPort(j)->PortType() << " " -// << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored " -// << aINode->GetChangeNodeOutPort(j)->IsGate() << " " -// << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; +// if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() || aINode->GetChangeNodeOutPort(j)->IsDataStream() ) { + if ( aINode->GetChangeNodeOutPort(j)->IsGate() || aINode->GetChangeNodeOutPort(j)->IsLoop() ) { + cdebug << "GraphBase::Graph::InLineServices Out" << j << " " + << aINode->GetChangeNodeOutPort(j)->Kind() << " " + << aINode->GetChangeNodeOutPort(j)->PortType() << " " + << aINode->GetChangeNodeOutPort(j)->PortName() << " ignored " + << aINode->GetChangeNodeOutPort(j)->IsGate() << " " + << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; + } + else if ( aINode->GetChangeNodeOutPort(j)->IsDataStream() ) { + aService.ServiceoutDataStreamParameter.length( OutStreamService+1 ) ; + aService.ServiceoutDataStreamParameter[OutStreamService].Parametertype = StringToDataStreamType( aINode->GetChangeNodeOutPort(j)->PortType() ) ; + aService.ServiceoutDataStreamParameter[OutStreamService].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ; + aService.ServiceoutDataStreamParameter[OutStreamService++].Parameterdependency = aINode->GetChangeNodeOutPort(j)->Dependency() ; + aINode->IncrDataStreamOutPorts() ; + cdebug << "GraphBase::Graph::InLineServices Out" << j << " " + << aINode->GetChangeNodeOutPort(j)->Kind() << " " + << aINode->GetChangeNodeOutPort(j)->PortType() << " " + << aINode->GetChangeNodeOutPort(j)->PortName() << " " + << aINode->GetChangeNodeOutPort(j)->IsGate() << " " + << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; } else { aService.ServiceoutParameter.length( OutService+1 ) ; aService.ServiceoutParameter[OutService].Parametertype = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortType() ) ; aService.ServiceoutParameter[OutService++].Parametername = CORBA::string_dup( aINode->GetChangeNodeOutPort(j)->PortName() ) ; -// cdebug << "GraphBase::Graph::InLineServices Out" << j << " " -// << aINode->GetChangeNodeOutPort(j)->Kind() << " " -// << aINode->GetChangeNodeOutPort(j)->PortType() << " " -// << aINode->GetChangeNodeOutPort(j)->PortName() << " " -// << aINode->GetChangeNodeOutPort(j)->IsGate() << " " -// << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; + cdebug << "GraphBase::Graph::InLineServices Out" << j << " " + << aINode->GetChangeNodeOutPort(j)->Kind() << " " + << aINode->GetChangeNodeOutPort(j)->PortType() << " " + << aINode->GetChangeNodeOutPort(j)->PortName() << " " + << aINode->GetChangeNodeOutPort(j)->IsGate() << " " + << aINode->GetChangeNodeOutPort(j)->IsLoop() << endl; } } aINode->SetService( aService ) ; + if ( SetServiceOfMap( (GraphBase::Service * ) aINode ) ) { + cdebug << "InLineServices SetServiceOfMap " << aINode->ServiceName() << " in MapOfServices" + << " InStreamPort(" << aINode->DataStreamInPortsNumber() + << ") OutStreamPort(" << aINode->DataStreamOutPortsNumber() << ")" << endl ; + } // cdebug << "GraphBase::Graph::InLineServices" << *aINode->GetService() << endl; } } @@ -1374,27 +1701,45 @@ bool GraphBase::Graph::InLineServices() { return true ; } -bool GraphBase::Graph::Sort() { +bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { int i ; int j ; int NotSortedNumber = GraphNodesSize() ; bool NewSorted ; + cdebug_in << "GraphBase::Graph::Sort" << endl; if ( NotSortedNumber ) { _LevelsNumber = 0 ; _ParallelExecutionNodes = false ; _Sorted.resize( GraphNodesSize() ) ; _CnxInPortsNumber.resize( GraphNodesSize() ) ; _DecrInPortsNumber.resize( GraphNodesSize() ) ; - if ( _NodesNumber.size() ) + if ( _NodesNumber.size() ) { _NodesNumber.resize( 0 ) ; _SortedNodes.resize( 0 ) ; + } +// This is a simulation of the computation of the graph : +// The initial state of nodes is : +// - Sorted = false : the node is not sorted +// - CnxInPortsNumber = ConnectedInPortsNumber : the number of ports that wait for a value from a link +// - DecrInPortsNumber = 0 : there is no value available. + cdebug << "GraphBase::Graph::Sort initial values :" << endl ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = GraphNodes( i ) ; + cdebug << aNode->Name() << " --> " << aNode->LinkedNodesSize() << " LinkedNodes :" << endl ; + for ( j = 0 ; j < aNode->LinkedNodesSize() ; j++ ) { + cdebug << " " << aNode->LinkedNodes( j )->Name() << endl ; + } + } for ( i = 0 ; i < GraphNodesSize() ; i++ ) { _Sorted[ i ] = false ; _CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ; _DecrInPortsNumber[ i ] = 0 ; + cdebug << "Sort Node [" << i << "] " << GraphNodes( i )->Name() << " initial count " << _CnxInPortsNumber[ i ] << endl ; } +// Nodes are linked ONLY if Ports are NOT DataStream for topological sort of node +// ============================================================================== while ( NotSortedNumber ) { NewSorted = false ; @@ -1403,27 +1748,33 @@ bool GraphBase::Graph::Sort() { << GraphNodes( i )->Name() << " count " << _CnxInPortsNumber[ i ] << endl ; if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) { -// All inputs of GraphNodes( i ) are available +// All inputs of GraphNodes( i ) are available : "AllDataReady" if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) { _NodesNumber.resize( _LevelsNumber+1 ) ; _SortedNodes.resize( _LevelsNumber+1 ) ; _NodesNumber[ _LevelsNumber ] = -1 ; } +// There is one more node at that level _NodesNumber[ _LevelsNumber ]++ ; (_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ; (_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ; _Sorted[ i ] = true ; NewSorted = true ; + NotSortedNumber -= 1 ; cdebug << GraphNodes( i )->Name() << " belongs to level " << _LevelsNumber << "." << endl ; +// GraphNodes( i ) has the state "AllDataReady". We simulate the end of its execution : +// So we loop over all nodes that have a link from that node +// And we increment the number of input ports of GraphNodes( i )->LinkedNodes( j ) that this +// execution will give a value in DecrInPortsNumber : "SomeDataReady" for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) { -// Outputs of GraphNodes( i ) will satisfy +// OutputPorts of GraphNodes( i ) will satisfy // GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of // GraphNodes( i )->LinkedNodes( j ) - GraphBase::ComputingNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ; + GraphBase::StreamNode * aLinkedNode = GraphNodes( i )->LinkedNodes( j ) ; int aLinkedInPortsNumber = GraphNodes( i )->LinkedInPortsNumber( j ) ; cdebug << j << ". LinkedNode " << aLinkedNode->Name() ; - if ( !aLinkedNode->IsDataFlowNode() ) { + if ( !aLinkedNode->IsDataFlowNode() && !aLinkedNode->IsDataStreamNode() ) { cdebug << " _DecrInPortsNumber[ " << GetGraphNodeIndex( aLinkedNode->Name() ) << " ] = " @@ -1436,14 +1787,16 @@ bool GraphBase::Graph::Sort() { } } } +// If no node was found, that FlowGraph is not valid : if we try to execute it, that FlowGraph +// will wait for data(s) from node(s) not executed or not executing for ever if ( !NewSorted ) { cdebug << "Loop detected level " << _LevelsNumber << endl ; return false ; // Loop in the Graph } cdebug << "Bilan level " << _LevelsNumber << " : " << endl ; bool ChangeCount = false ; +// We update now the number of InPorts with a link that are waiting for a value for ( i = 0 ; i < GraphNodesSize() ; i++ ) { -// if ( GraphNodes( i )->DecrIncrDecrConnectedInPortsNumber() ) { if ( _DecrInPortsNumber[ i ] ) { int prevcount = _CnxInPortsNumber[ i ] ; _CnxInPortsNumber[ i ] -= _DecrInPortsNumber[ i ] ; @@ -1453,15 +1806,21 @@ bool GraphBase::Graph::Sort() { << " --> new count " << _CnxInPortsNumber[ i ] << endl ; } } - - if ( !ChangeCount ) - break ; - _LevelsNumber += 1 ; +// If there is no loop and if the number of InPorts with a link that are waiting for a value +// does not change, the sort is finished. But there is also NotSortedNumber ... +// if ( !ChangeCount ) +// break ; + if ( NotSortedNumber ) { + _LevelsNumber += 1 ; + } } _ThreadsMax = 0 ; int AllSortedNodes = 0 ; _HeadNodes = _SortedNodes[ 0 ] ; _HeadNodesSize = _SortedNodes[ 0 ].size() ; +// QueueNodes was used in the past in order to know if the execution of a graph is finished +// But because of loop nodes that was changed. So that part of code is a "clutter" +// Now a graph has finished its execution when the number of executing threads is zero _QueueNodes = _SortedNodes[ _LevelsNumber ] ; _QueueNodesSize = _SortedNodes[ _LevelsNumber ].size() ; for ( i = 0 ; i < _QueueNodesSize ; i++ ) { @@ -1473,10 +1832,12 @@ bool GraphBase::Graph::Sort() { _QueueNodes = _SortedNodes[ _LevelsNumber - 1 ] ; _QueueNodesSize = _SortedNodes[ _LevelsNumber - 1 ].size() ; } +// Computation of the maximum number of threads == the maximum number of nodes of all levels for ( i = 0 ; i <= _LevelsNumber ; i++ ) { AllSortedNodes += _NodesNumber[ i ]+1 ; - if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) + if ( _NodesNumber[ i ] + 1 > _ThreadsMax ) { _ThreadsMax = _NodesNumber[ i ] + 1 ; + } cdebug << _NodesNumber[ i ]+1 << " Nodes of level " << i << " : " << (_SortedNodes[ i ])[ 0 ]->Name() << endl ; for ( j = 1 ; j <= _NodesNumber[ i ] ; j++ ) { @@ -1500,24 +1861,45 @@ bool GraphBase::Graph::Sort() { (_SortedNodes[ 0 ])[ i ]->HeadNode( true ) ; } - for ( i = 0 ; i <= _NodesNumber[ 0 ] ; i++ ) { - (_SortedNodes[ 0 ])[ i ]->Level( 0 ) ; - (_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ; +// Give a subgraph/substreamgraph number > 0 to HeadNodes (level 0) +// There is no substreamgraph for nodes without StreamPorts + for ( j = 0 ; j <= _NodesNumber[ 0 ] ; j++ ) { + (_SortedNodes[ 0 ])[ j ]->Level( 0 ) ; + (_SortedNodes[ 0 ])[ j ]->SortedIndex( j ) ; + (_SortedNodes[ 0 ])[ j ]->SubGraph( j + 1 ) ; + if ( (_SortedNodes[ 0 ])[ j ]->HasDataStream() ) { + (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( j + 1 ) ; + } + else { + (_SortedNodes[ 0 ])[ j ]->SubStreamGraph( -1 ) ; + } } +// Give a subgraph/substreamgraph number = 0 to all other nodes : +// the SubGraph of that nodes is unknown +// There is no substreamgraph for nodes without StreamPorts for ( i = 1 ; i <= _LevelsNumber ; i++ ) { for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { (_SortedNodes[ i ])[ j ]->Level( i ) ; + (_SortedNodes[ i ])[ j ]->SortedIndex( j ) ; (_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ; + if ( (_SortedNodes[ i ])[ j ]->HasDataStream() ) { + (_SortedNodes[ i ])[ j ]->SubStreamGraph( 0 ) ; + } + else { + (_SortedNodes[ i ])[ j ]->SubStreamGraph( -1 ) ; + } } } +// Computation of independent SubGraphs which have NO link between them + cdebug << endl << "Computation of SubGraphs" << endl ; bool Graphs = true ; while ( Graphs ) { for ( i = 0 ; i <= _LevelsNumber ; i++ ) { for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ; - cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name() + cdebug << "SubGraph " << aNode->SubGraph() << " " << aNode->Name() << endl ; int k ; for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) { @@ -1526,9 +1908,9 @@ bool GraphBase::Graph::Sort() { aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) { aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ; cdebug << " Linked " << aNode->LinkedNodes( k )->Name() - << " Graph(" << aNode->LinkedNodes( k )->SubGraph() + << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph() << ") ==>" << endl ; - cdebug << " Graph " << aNode->SubGraph() << " for " + cdebug << " SubGraph " << aNode->SubGraph() << " for " << aNode->Name() << " ==> again" << endl ; int l ; for ( l = 0 ; l < aNode->LinkedNodesSize() ; l++ ) { @@ -1539,7 +1921,7 @@ bool GraphBase::Graph::Sort() { } else { cdebug << " Linked " << aNode->LinkedNodes( k )->Name() - << " Graph(" << aNode->LinkedNodes( k )->SubGraph() + << " SubGraph(" << aNode->LinkedNodes( k )->SubGraph() << ") distance > 1 ignored" << endl ; } } @@ -1555,24 +1937,25 @@ bool GraphBase::Graph::Sort() { break ; } if ( Graphs ) { - cdebug << endl << "Graphs result : " << endl ; + cdebug << endl << "SubGraphs result : " << endl ; break ; } cdebug << endl << "One more time" << endl ; Graphs = true ; } - _GraphsNumber = 0 ; +// Make a sequential renumbering of SubGraphs : + _SubGraphsNumber = 0 ; int CurrGraphsNumber = 0; int k ; for ( k = 0 ; k <= _NodesNumber[ 0 ] ; k++ ) { if ( (_SortedNodes[ 0 ])[ k ]->SubGraph() > CurrGraphsNumber ) { CurrGraphsNumber = (_SortedNodes[ 0 ])[ k ]->SubGraph() ; - _GraphsNumber += 1 ; + _SubGraphsNumber += 1 ; for ( i = 0 ; i <= _LevelsNumber ; i++ ) { for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { if ( (_SortedNodes[ i ])[ j ]->SubGraph() == CurrGraphsNumber ) { - (_SortedNodes[ i ])[ j ]->SubGraph( _GraphsNumber ) ; - cdebug << "GraphsNumber " << _GraphsNumber << " " << " Level " + (_SortedNodes[ i ])[ j ]->SubGraph( _SubGraphsNumber ) ; + cdebug << "SubGraphsNumber " << _SubGraphsNumber << " " << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ; } @@ -1580,8 +1963,118 @@ bool GraphBase::Graph::Sort() { } } } + + cdebug << endl << "Computation of SubStreamGraphs" << endl ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = GraphNodes( i ) ; + if ( aNode->SubStreamGraph() < 0 ) { + cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name() + << " has NO streamport" << endl ; + } + else { + cdebug << aNode->Name() << " SubGraph " << aNode->SubGraph() << " --> " + << aNode->LinkedStreamNodesSize() << " LinkedStreamNodes :" << endl ; + for ( j = 0 ; j < aNode->LinkedStreamNodesSize() ; j++ ) { + cdebug << " " << aNode->LinkedStreamNodes( j )->Name() << endl ; + } + } + } + +// Computation of independent SubStreamGraphs which have NO StreamLink between them + SubStreamGraphsNumber = 0 ; + int ilevel ; + for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) { +// Loop for _NodesNumber[ ilevel ] nodes of the level ilevel + int jnode ; + for ( jnode = 0 ; jnode <= _NodesNumber[ ilevel ] ; jnode++ ) { + GraphBase::ComputingNode * aNode = (_SortedNodes[ ilevel ])[ jnode ] ; + if ( aNode->SubStreamGraph() < 0 ) { + cdebug << "Graph " << aNode->SubStreamGraph() << " " << aNode->Name() + << " has NO streamport" << endl ; + } + else { + int CurStreamGraphsNumber ; + if ( aNode->SubStreamGraph() > 0 ) { + cdebug << "SubStreamGraph " << aNode->SubStreamGraph() << " " << aNode->Name() + << " has streamport LinkedStreamNodesSize already in a SubStreamGraph" << endl ; + CurStreamGraphsNumber = aNode->SubStreamGraph() ; + } + else { + CurStreamGraphsNumber = SubStreamGraphsNumber+1 ; + } + int RetVal = 0 ; + while ( RetVal != CurStreamGraphsNumber ) { + RetVal = CurStreamGraphsNumber ; + aNode->SetSubStreamGraph( CurStreamGraphsNumber , RetVal ) ; + if ( RetVal != CurStreamGraphsNumber ) { + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = GraphNodes( i ) ; + if ( aNode->SubStreamGraph() == CurStreamGraphsNumber ) { + aNode->SubStreamGraph( RetVal ) ; + } + } + CurStreamGraphsNumber = RetVal ; + RetVal = 0 ; + } + if ( CurStreamGraphsNumber > SubStreamGraphsNumber ) { + SubStreamGraphsNumber = CurStreamGraphsNumber ; + } + } + } + } + } +// Make a sequential renumbering of SubGraphs : + cdebug << endl << "Last SubStreamGraphsNumber : " << SubStreamGraphsNumber << endl ; + int CurrStreamGraphsNumber = 0 ; + int count = 0 ; + for ( CurrStreamGraphsNumber = 0 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) { + bool SearchCurrStreamGraphsNumber = true ; + for ( k = 0 ; k <= _LevelsNumber && SearchCurrStreamGraphsNumber ; k++ ) { + int l ; + for ( l = 0 ; l <= _NodesNumber[ k ] && SearchCurrStreamGraphsNumber ; l++ ) { + if ( (_SortedNodes[ k ])[ l ]->SubStreamGraph() == CurrStreamGraphsNumber ) { + SearchCurrStreamGraphsNumber = false ; + count = count + 1 ; + if ( CurrStreamGraphsNumber != count ) { + cdebug << "CurrStreamGraphsNumber " << CurrStreamGraphsNumber << " count " << count + << " Level " << k << " n " << l << endl ; + for ( i = k ; i <= _LevelsNumber ; i++ ) { + for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) { + if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() == CurrStreamGraphsNumber ) { + (_SortedNodes[ i ])[ j ]->SubStreamGraph( count ) ; + cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " --> " << count << " " + << " Level " << i << " : " << (_SortedNodes[ i ])[ j ]->Name() << endl ; + } + else if ( (_SortedNodes[ i ])[ j ]->SubStreamGraph() > 0 ) { + cdebug << "SubStreamGraphsNumber " << (_SortedNodes[ i ])[ j ]->SubStreamGraph() + << " != " << CurrStreamGraphsNumber << " Level " << i << " : " + << (_SortedNodes[ i ])[ j ]->Name() << endl ; + } + } + } + } + } + } + } + } + SubStreamGraphsNumber = count ; + cdebug << endl << "SubStreamGraphs result : " << SubStreamGraphsNumber << " SubStreamGraphs" << endl ; +// int CurrStreamGraphsNumber ; +// for ( CurrStreamGraphsNumber = 1 ; CurrStreamGraphsNumber <= SubStreamGraphsNumber ; CurrStreamGraphsNumber++ ) { +// for ( ilevel = 0 ; ilevel <= _LevelsNumber ; ilevel++ ) { +// for ( k = 0 ; k <= _NodesNumber[ ilevel ] ; k++ ) { +// if ( (_SortedNodes[ ilevel ])[ k ]->SubStreamGraph() == CurrStreamGraphsNumber ) { +// cdebug << "SubStreamGraphsNumber " << CurrStreamGraphsNumber << " : " +// << (_SortedNodes[ ilevel ])[ k ]->Name() << endl ; +// } +// } +// } +// } } + ListPorts( *_Graph_fdebug , 0 ) ; + + cdebug_out << "GraphBase::Graph::Sort" << endl; return true ; } @@ -1669,7 +2162,7 @@ bool GraphBase::Graph::LinkLoopNodes(bool & NewLink ) { } for ( j = 0 ; j < aLoopNode->CoupledNode()->GetNodeInPortsSize() ; j++ ) { GraphBase::InPort *anInPort = aLoopNode->CoupledNode()->GetChangeNodeInPort( j ) ; - if ( !anInPort->IsConnected() ) { + if ( !anInPort->IsConnected() && !anInPort->IsGate() ) { if ( !AddLink( aLoopNode , aLoopNode->GetChangeNodeOutPort( j ) , aLoopNode->CoupledNode() , anInPort ) ) { cdebug << "GraphBase::Graph::CreateService AddLink ERROR " << aLoopNode->Name() << "( " @@ -1739,7 +2232,7 @@ bool GraphBase::Graph::DataServerNodes() const { aNode = GraphNodes( i ) ; // while ( aNode != aComputingNodesList.end() ) { if ( aNode->IsFactoryNode() ) { - GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ; + GraphBase::FactoryNode * FaNode = (GraphBase::FactoryNode * ) aNode ; if ( !strlen( FaNode->Computer() ) ) { cdebug << "ComputerName missing for node " << FaNode->Name() ; if ( !strlen( FaNode->Computer() ) ) { @@ -1754,7 +2247,12 @@ bool GraphBase::Graph::DataServerNodes() const { // For Outputs of the DataFlow : for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) { if ( !aNode->GetNodeOutPort(j)->IsConnected() ) { - aNode->AddLink( (GraphBase::ComputingNode *) this ) ; + if ( aNode->GetNodeOutPort(j)->IsDataStream() ) { + aNode->AddStreamLink( (GraphBase::ComputingNode *) this ) ; + } + else { + aNode->AddLink( (GraphBase::ComputingNode *) this ) ; + } } } } diff --git a/src/GraphBase/DataFlowBase_Graph.hxx b/src/GraphBase/DataFlowBase_Graph.hxx index 9b585d4..16130df 100644 --- a/src/GraphBase/DataFlowBase_Graph.hxx +++ b/src/GraphBase/DataFlowBase_Graph.hxx @@ -44,23 +44,22 @@ namespace GraphBase { private: - int _Graph_prof_debug; - ofstream * _Graph_fdebug; +// int _Graph_prof_debug; +// ofstream * _Graph_fdebug; CORBA::ORB_ptr _Orb ; SUPERV::Graph_var _Graph ; Graph_Impl * _GraphImpl ; -// Map of InNodes of the OutNode +// Map of Nodes of the Graph map< string , int > _MapOfGraphNodes ; long _GraphNodesSize ; vector _Sorted ; vector _GraphNodes ; // _SortedNodes[ _LevelsNumber ] : topological sort from 0 to _LevelsNumber -// _SortedNodes[ _level ][ _NodesNumber[ _level ] ] : _NodesNumber[ _level ] Nodes +// _SortedNodes[ _level ][ _NodesNumber[ _level ] ] : _NodesNumber[ _level ] Nodes in the level int _LevelsNumber ; int _ThreadsMax ; - int _GraphsNumber ; vector _NodesNumber ; vector > _SortedNodes ; @@ -73,6 +72,24 @@ namespace GraphBase { vector _QueueNodes ; bool _ParallelExecutionNodes ; +// For generated NodeNames with ServiceName : number of Nodes using +// the same ServiceName. It is not the same Service if it belongs to +// a different Interface and/or a different Component ... + map< string , GraphBase::Service * > _MapOfServiceNames ; + +// Total number of SubGraphs + int _SubGraphsNumber ; +// _SubGraphs[ SubGraphNumero ] [ NodeNumero ] +// SubGraphNumero : [ 0 , _SubGraphsSize [ ; NodeNumero : [ 0 , _SubGraphs[ SubGraphNumero ].size() [ + int _SubGraphsSize ; + vector > _SubGraphs ; + +// _SubStreamGraphs[ SubStreamGraphNumero ] [ NodeNumero ] +// SubStreamGraphNumero : [ 0 , _SubStreamGraphsSize [ +// NodeNumero : [ 0 , _SubStreamGraphs[ SubStreamGraphNumero ].size() [ +// int _SubStreamGraphsSize ; +// vector > _SubStreamGraphs ; + bool AddLink( GraphBase::ComputingNode *fromNode , GraphBase::OutPort *fromPort , GraphBase::ComputingNode *toNode , @@ -84,7 +101,9 @@ namespace GraphBase { Graph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const char *DataFlowName , - const char * DebugFileName ) ; + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; +// const char * DebugFileName ) ; Graph( CORBA::ORB_ptr ORB , SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& DataFlowService , @@ -98,16 +117,18 @@ namespace GraphBase { const char * DataFlowAuthor , const char * DataFlowComputer , const char * DataFlowComment , - const char * DebugFileName ) ; + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; +// const char * DebugFileName ) ; virtual ~Graph() ; - void Set_prof_debug( CORBA::ORB_ptr ORB , - const char * DebugFileName ) ; +// void Set_prof_debug( CORBA::ORB_ptr ORB , +// const char * DebugFileName ) ; + void Set_prof_debug( int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; int * Graph_prof_debug() { -// MESSAGE( "Graph_prof_debug _Graph_prof_debug " << &_Graph_prof_debug << " _Graph_fdebug " -// << _Graph_fdebug ) ; - return &_Graph_prof_debug ; } ; - ofstream * Graph_fdebug() { return _Graph_fdebug ; } ; + return _prof_debug ; } ; + ofstream * Graph_fdebug() { return _fdebug ; } ; SUPERV::Graph_var ObjRef() const { return _Graph ; } ; void SetObjRef( SUPERV::Graph_var aGraph ) { @@ -134,6 +155,7 @@ namespace GraphBase { } ; void DelGraphNodeIndex( const char *name ) { _MapOfGraphNodes.erase( name ) ; } ; + const GraphBase::ComputingNode * GetGraphNode( const int index ) const { const ComputingNode * aNode = GetChangeGraphNode( index ) ; return aNode ; } ; @@ -171,25 +193,41 @@ namespace GraphBase { ComputingNode * QueueNodes( int i ) const { return _QueueNodes[ i ] ; } ; - const GraphBase::InPort *GetInPort( const char* ToNodeName , - const char* ToServiceParameterName ) { + const GraphBase::InPort * GetInPort( const char * ToServiceParameterName ) { + return GraphBase::PortsOfNode::GetInPort( ToServiceParameterName ) ; } ; + GraphBase::InPort * GetChangeInPort( const char * ToServiceParameterName ) { + return GraphBase::PortsOfNode::GetChangeInPort( ToServiceParameterName ) ; } ; + const GraphBase::OutPort * GetOutPort( const char * FromServiceParameterName ) { + return GraphBase::PortsOfNode::GetOutPort( FromServiceParameterName ) ; } ; + GraphBase::OutPort * GetChangeOutPort( const char * FromServiceParameterName ) { + return GraphBase::PortsOfNode::GetChangeOutPort( FromServiceParameterName ); } ; + + const GraphBase::InPort * GetInPort( const char * ToNodeName , + const char * ToServiceParameterName ) { ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ; if ( aNode ) { return aNode->GetInPort(ToServiceParameterName); } else return NULL ; } ; - GraphBase::InPort *GetChangeInPort( const char* ToNodeName , - const char* ToServiceParameterName ) { + GraphBase::InPort * GetChangeInPort( const char * ToNodeName , + const char * ToServiceParameterName ) { ComputingNode * aNode = GetChangeGraphNode( ToNodeName ) ; if ( aNode ) { - return aNode->GetChangeInPort(ToServiceParameterName); + return aNode->GetChangeInPort( ToServiceParameterName ) ; + } + else + return NULL ; } ; + const GraphBase::OutPort * GetOutPort( const char * FromNodeName , + const char * FromServiceParameterName ) { + ComputingNode * aNode = GetChangeGraphNode( FromNodeName ) ; + if ( aNode ) { + return aNode->GetOutPort( FromServiceParameterName ) ; } else return NULL ; } ; - GraphBase::OutPort *GetChangeOutPort( - const char* FromNodeName , - const char* FromServiceParameterName ) { + GraphBase::OutPort * GetChangeOutPort( const char * FromNodeName , + const char * FromServiceParameterName ) { ComputingNode * aNode = GetChangeGraphNode( FromNodeName ) ; if ( aNode ) { return aNode->GetChangeOutPort( FromServiceParameterName ); @@ -220,7 +258,6 @@ namespace GraphBase { GraphBase::ListOfLinks * GetLinks(bool AllLinks = false ) const ; GraphBase::ListOfGraphs * GetGraphs() const ; GraphBase::ListOfLinks * GetDatas() const ; -// SALOME_ModuleCatalog::Service * GetService() const ; bool AddNode( ComputingNode * aNode ) ; bool RemoveNode( const char* NodeName ) ; @@ -265,18 +302,25 @@ namespace GraphBase { bool CreateService() ; bool InLineServices() ; - bool Sort() ; + bool Sort( int & SubStreamGraphsNumber ) ; bool ComputingNodes() const ; bool LinkLoopNodes(bool & NewLink ) ; bool DataServerNodes() const ; long LevelMax() { return _LevelsNumber + 1 ; } ; + + map< string , GraphBase::Service * > MapOfServiceNames() ; + GraphBase::Service * GetServiceOfMap( char * name ) ; + bool SetServiceOfMap( GraphBase::Service * aService ) ; + int GetServiceNameNumber( SALOME_ModuleCatalog::Service aService ) ; + SUPERV::ListOfStrings * LevelNodes(long aLevel ) ; long ThreadsMax() { return _ThreadsMax ; } ; - long GraphsNumber() { - return _GraphsNumber ; } ; + + long SubGraphsNumber() { + return _SubGraphsNumber ; } ; int NodesNumber(const int aLevel ) { return _NodesNumber[ aLevel ] ; } ; diff --git a/src/GraphBase/DataFlowBase_InDataStreamPort.cxx b/src/GraphBase/DataFlowBase_InDataStreamPort.cxx new file mode 100644 index 0000000..84049ff --- /dev/null +++ b/src/GraphBase/DataFlowBase_InDataStreamPort.cxx @@ -0,0 +1,140 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_InDataStreamPort.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; + +#include "DataFlowBase_InDataStreamPort.hxx" + +GraphBase::InDataStreamPort::InDataStreamPort() : + GraphBase::InPort::InPort() { + _KindOfSchema = SUPERV::SCHENULL ; + _KindOfInterpolation = SUPERV::INTERNULL ; + _KindOfExtrapolation = SUPERV::EXTRANULL ; + cdebug << "GraphBase::InDataStreamPort::InDataStreamPort " << this << " " << PortName() << " " << _KindOfSchema << " " << _KindOfInterpolation + << " " << _KindOfExtrapolation << endl ; +} + +GraphBase::InDataStreamPort::InDataStreamPort( + const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency , + const SUPERV::KindOfSchema aKindOfSchema , + const SUPERV::KindOfInterpolation aKindOfInterpolation , + const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) : + InPort( NodeName , aserviceParameter , SUPERV::DataStreamParameter , aDependency ) { + if ( aDependency == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) { + _KindOfSchema = aKindOfSchema ; + _KindOfInterpolation = aKindOfInterpolation ; + _KindOfExtrapolation = aKindOfExtrapolation ; + } + else { + _KindOfSchema = SUPERV::SCHENULL ; + _KindOfInterpolation = SUPERV::INTERNULL ; + _KindOfExtrapolation = SUPERV::EXTRANULL ; + } + cdebug << "GraphBase::InDataStreamPort::InDataStreamPort " << this << " " << PortName() << " " << _KindOfSchema << " " << _KindOfInterpolation + << " " << _KindOfExtrapolation << endl ; +} + +GraphBase::InDataStreamPort::~InDataStreamPort() { + cdebug << "GraphBase::InDataStreamPort::~InDataStreamPort " << this << endl ; +} + +bool GraphBase::InDataStreamPort::SetParams( const SUPERV::KindOfSchema aKindOfSchema , + const SUPERV::KindOfInterpolation aKindOfInterpolation , + const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) { + bool RetVal = true ; + if ( Dependency() == SALOME_ModuleCatalog::DATASTREAM_TEMPORAL ) { + _KindOfSchema = aKindOfSchema ; + _KindOfInterpolation = aKindOfInterpolation ; + _KindOfExtrapolation = aKindOfExtrapolation ; + } + else { + _KindOfSchema = SUPERV::SCHENULL ; + _KindOfInterpolation = SUPERV::INTERNULL ; + _KindOfExtrapolation = SUPERV::EXTRANULL ; + RetVal = false ; + } + cdebug << "GraphBase::InDataStreamPort::SetParams RetVal " << RetVal << " " << PortName() << " " << _KindOfSchema << " " + << _KindOfInterpolation << " " << _KindOfExtrapolation << endl ; + return RetVal ; +} + +void GraphBase::InDataStreamPort::Params( SUPERV::KindOfSchema & aKindOfSchema , + SUPERV::KindOfInterpolation & aKindOfInterpolation , + SUPERV::KindOfExtrapolation & aKindOfExtrapolation ) const { + aKindOfSchema = _KindOfSchema ; + aKindOfInterpolation = _KindOfInterpolation ; + aKindOfExtrapolation = _KindOfExtrapolation ; + cdebug << "GraphBase::InDataStreamPort::Params " << PortName() << " " << _KindOfSchema << " " << _KindOfInterpolation << " " + << _KindOfExtrapolation << endl ; +} + +ostream & operator<< (ostream & f ,const SUPERV::KindOfSchema & s ) { + switch (s) { + case SUPERV::SCHENULL : + f << "SCHENULL"; + break; + case SUPERV::TI : + f << "TI"; + break; + case SUPERV::TF : + f << "TF"; + break; + case SUPERV::DELTA : + f << "DELTA"; + break; + default : + f << "UndefinedKindOfSchema"; + break; + } + + return f; +} + +ostream & operator<< (ostream & f ,const SUPERV::KindOfInterpolation & s ) { + switch (s) { + case SUPERV::INTERNULL : + f << "INTERNULL"; + break; + case SUPERV::L0 : + f << "L0"; + break; + case SUPERV::L1 : + f << "L1"; + break; + default : + f << "UndefinedKindOfInterpolation"; + break; + } + + return f; +} + +ostream & operator<< (ostream & f ,const SUPERV::KindOfExtrapolation & s ) { + switch (s) { + case SUPERV::EXTRANULL : + f << "EXTRANULL"; + break; + case SUPERV::E0 : + f << "E0"; + break; + case SUPERV::E1 : + f << "E1"; + break; + default : + f << "UndefinedKindOfExtrapolation"; + break; + } + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_InDataStreamPort.hxx b/src/GraphBase/DataFlowBase_InDataStreamPort.hxx new file mode 100644 index 0000000..54ecdde --- /dev/null +++ b/src/GraphBase/DataFlowBase_InDataStreamPort.hxx @@ -0,0 +1,65 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_InDataStreamPort.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _DATAFLOWBASE_INDATASTREAMPORT_HXX +#define _DATAFLOWBASE_INDATASTREAMPORT_HXX + +#include "DataFlowBase_OutPort.hxx" + +namespace GraphBase { + + class InDataStreamPort : public InPort { + + private: + +// if TimeDependency : + SUPERV::KindOfSchema _KindOfSchema ; + SUPERV::KindOfInterpolation _KindOfInterpolation ; + SUPERV::KindOfExtrapolation _KindOfExtrapolation ; + + protected: + + public: + + InDataStreamPort() ; + + InDataStreamPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED , + const SUPERV::KindOfSchema aKindOfSchema = SUPERV::SCHENULL , + const SUPERV::KindOfInterpolation aKindOfInterpolation = SUPERV::INTERNULL , + const SUPERV::KindOfExtrapolation aKindOfExtrapolation = SUPERV::EXTRANULL ) ; + + virtual ~InDataStreamPort() ; + + bool SetParams( const SUPERV::KindOfSchema aKindOfSchema , + const SUPERV::KindOfInterpolation aKindOfInterpolation , + const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) ; + + void Params( SUPERV::KindOfSchema & aKindOfSchema , + SUPERV::KindOfInterpolation & aKindOfInterpolation , + SUPERV::KindOfExtrapolation & aKindOfExtrapolation ) const ; + + }; + +}; + +ostream & operator<< (ostream &,const SUPERV::KindOfSchema &); + +ostream & operator<< (ostream &,const SUPERV::KindOfInterpolation &); + +ostream & operator<< (ostream &,const SUPERV::KindOfExtrapolation &); + +#endif + + + + diff --git a/src/GraphBase/DataFlowBase_InLineNode.cxx b/src/GraphBase/DataFlowBase_InLineNode.cxx index 315e6ed..d602ecf 100644 --- a/src/GraphBase/DataFlowBase_InLineNode.cxx +++ b/src/GraphBase/DataFlowBase_InLineNode.cxx @@ -31,7 +31,7 @@ GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , cdebug << "GraphBase::InLineNode::Node " << this << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " - << (void *) Comment() << " " << Comment() << " " << endl ; + << (void *) Comment() << " " << Comment() << endl ; } GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , diff --git a/src/GraphBase/DataFlowBase_InPort.cxx b/src/GraphBase/DataFlowBase_InPort.cxx index 27ec517..3089f38 100644 --- a/src/GraphBase/DataFlowBase_InPort.cxx +++ b/src/GraphBase/DataFlowBase_InPort.cxx @@ -32,14 +32,22 @@ using namespace std; char ** _PortStateName ; +GraphBase::InPort::InPort() : + Port() { + _State = SUPERV::UndefinedState ; + _OutPort = NULL ; + _InitialOutPort = NULL ; +} + GraphBase::InPort::InPort( const char *const * Name , const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , - const SUPERV::KindOfPort aKind) : - Port( Name , aserviceParameter ) { + const SUPERV::KindOfPort aKind , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) : + Port( Name , aserviceParameter , aKind , aDependency ) { + _State = SUPERV::UndefinedState ; _OutPort = NULL ; _InitialOutPort = NULL ; - Kind( aKind ) ; } //GraphBase::InPort::~InPort() { @@ -66,6 +74,8 @@ ostream & operator<< (ostream &f ,const GraphBase::InPort &P) { << "type : " << P.PortType() << ", " ; f << "from " << P.NodeName() << ", "; + f << "kind " + << P.Kind() << ", "; return f; } diff --git a/src/GraphBase/DataFlowBase_InPort.hxx b/src/GraphBase/DataFlowBase_InPort.hxx index 6aa2f79..51224a3 100644 --- a/src/GraphBase/DataFlowBase_InPort.hxx +++ b/src/GraphBase/DataFlowBase_InPort.hxx @@ -37,21 +37,19 @@ namespace GraphBase { class InPort : public Port { - SUPERV::GraphState _State ; - OutPort * _OutPort ; - OutPort * _InitialOutPort ; + private: + + SUPERV::GraphState _State ; + OutPort * _OutPort ; + OutPort * _InitialOutPort ; public: - InPort() { -// cout << "InPort()" << endl ; - _State = SUPERV::UndefinedState ; - _OutPort = NULL ; - _InitialOutPort = NULL ; - } ; + InPort() ; InPort( const char *const * NodeName , const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , - const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) ; + const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) ; virtual ~InPort() { cdebug << "GraphBase::InPort::~InPort " << PortName() << endl ; } ; virtual void destroy() { diff --git a/src/GraphBase/DataFlowBase_OutDataStreamPort.cxx b/src/GraphBase/DataFlowBase_OutDataStreamPort.cxx new file mode 100644 index 0000000..15187ae --- /dev/null +++ b/src/GraphBase/DataFlowBase_OutDataStreamPort.cxx @@ -0,0 +1,35 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_OutDataStreamPort.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; + +#include "DataFlowBase_OutDataStreamPort.hxx" + +GraphBase::OutDataStreamPort::OutDataStreamPort() : + OutPort() { + _NumberOfValues = 0 ; + cdebug << "GraphBase::OutDataStreamPort::OutDataStreamPort " << this << " " << endl ; +} + +GraphBase::OutDataStreamPort::OutDataStreamPort( + const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency , + const long aNumberOfValues ) : + OutPort( NodeName , aserviceParameter , SUPERV::DataStreamParameter , aDependency ) { + _NumberOfValues = aNumberOfValues ; + cdebug << "GraphBase::OutDataStreamPort::OutDataStreamPort " << this << " " << endl ; +} + +GraphBase::OutDataStreamPort::~OutDataStreamPort() { + cdebug << "GraphBase::OutDataStreamPort::~OutDataStreamPort " << this << endl ; +} + diff --git a/src/GraphBase/DataFlowBase_OutDataStreamPort.hxx b/src/GraphBase/DataFlowBase_OutDataStreamPort.hxx new file mode 100644 index 0000000..83010d5 --- /dev/null +++ b/src/GraphBase/DataFlowBase_OutDataStreamPort.hxx @@ -0,0 +1,50 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_OutDataStreamPort.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _DATAFLOWBASE_OUTDATASTREAMPORT_HXX +#define _DATAFLOWBASE_OUTDATASTREAMPORT_HXX + +#include "DataFlowBase_OutPort.hxx" + +namespace GraphBase { + + class OutDataStreamPort : public OutPort { + + private: + + long _NumberOfValues ; // Values Keeped in links ("Niveau") + + protected: + + public: + + OutDataStreamPort() ; + OutDataStreamPort( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED , + const long aNumberOfValues = 0 ) ; + + virtual ~OutDataStreamPort() ; + + void NumberOfValues( const long aNumberOfValues ) { + _NumberOfValues = aNumberOfValues ; } ; + long NumberOfValues() const { + return _NumberOfValues ; } ; + + }; + +}; + +#endif + + + + diff --git a/src/GraphBase/DataFlowBase_OutPort.hxx b/src/GraphBase/DataFlowBase_OutPort.hxx index 92253d4..a6363d0 100644 --- a/src/GraphBase/DataFlowBase_OutPort.hxx +++ b/src/GraphBase/DataFlowBase_OutPort.hxx @@ -48,13 +48,15 @@ namespace GraphBase { public: + OutPort() { + }; OutPort( const char *const * NodeName , const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , - const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter ) : - DataPort( NodeName , aserviceParameter ) { + const SUPERV::KindOfPort aKind = SUPERV::ServiceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) : + DataPort( NodeName , aserviceParameter , aKind , aDependency) { _Connected = NotConnected ; - _InPortsSize = 0 ; - Kind( aKind ) ; } ; + _InPortsSize = 0 ; } ; virtual ~OutPort() { cdebug << "GraphBase::OutPort::~OutPort " << PortName() << endl ; } ; virtual void destroy() { diff --git a/src/GraphBase/DataFlowBase_Port.cxx b/src/GraphBase/DataFlowBase_Port.cxx index 14a89f5..83ae029 100644 --- a/src/GraphBase/DataFlowBase_Port.cxx +++ b/src/GraphBase/DataFlowBase_Port.cxx @@ -192,6 +192,9 @@ ostream & operator<< (ostream & f ,const SUPERV::KindOfPort & s ) { case SUPERV::GOTOParameter : f << "GOTOParameter"; break; + case SUPERV::DataStreamParameter : + f << "DataStreamParameter"; + break; default : f << "UnknownKindOfPort"; break; @@ -200,3 +203,22 @@ ostream & operator<< (ostream & f ,const SUPERV::KindOfPort & s ) { return f; } +ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::DataStreamDependency & s ) { + switch (s) { + case SALOME_ModuleCatalog::DATASTREAM_UNDEFINED : + f << "DATASTREAM_UNDEFINED"; + break; + case SALOME_ModuleCatalog::DATASTREAM_TEMPORAL : + f << "DATASTREAM_TEMPORAL"; + break; + case SALOME_ModuleCatalog::DATASTREAM_ITERATIVE : + f << "DATASTREAM_ITERATIVE"; + break; + default : + f << "DATASTREAM_?"; + break; + } + + return f; +} + diff --git a/src/GraphBase/DataFlowBase_Port.hxx b/src/GraphBase/DataFlowBase_Port.hxx index ddee288..c944750 100644 --- a/src/GraphBase/DataFlowBase_Port.hxx +++ b/src/GraphBase/DataFlowBase_Port.hxx @@ -38,96 +38,108 @@ namespace GraphBase { class Port : public ServicesParameter { - const char *const * _NodeName ; - SUPERV::Port_var _Port ; - SUPERV::KindOfPort _KindOfPort ; + private: - vector _X ; - vector _Y ; + const char *const * _NodeName ; + SUPERV::Port_var _Port ; + SUPERV::KindOfPort _KindOfPort ; + + vector _X ; + vector _Y ; + + SALOME_ModuleCatalog::DataStreamDependency _Dependency ; // Time or Iteration only for DataStreamPorts public: - Port() { -// cout << "Port()" << endl ; - _NodeName = NULL ; - _Port = SUPERV::Port::_nil() ; - _KindOfPort = SUPERV::UndefinedParameter ; - } ; - Port( const char *const * NodeName , - const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , - const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter ) : - ServicesParameter( aserviceParameter ) { - _NodeName = NodeName ; - _Port = SUPERV::Port::_nil() ; - _KindOfPort = aKindOfPort ; - } ; - virtual ~Port() { + Port() { + _NodeName = NULL ; + _Port = SUPERV::Port::_nil() ; + _KindOfPort = SUPERV::UndefinedParameter ; + _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ; } ; + Port( const char *const * NodeName , + const SALOME_ModuleCatalog::ServicesParameter aserviceParameter , + const SUPERV::KindOfPort aKindOfPort = SUPERV::ServiceParameter , + const SALOME_ModuleCatalog::DataStreamDependency aDependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ) : + ServicesParameter( aserviceParameter ) { + _NodeName = NodeName ; + _Port = SUPERV::Port::_nil() ; + _KindOfPort = aKindOfPort ; + if ( IsDataStream() ) { + _Dependency = aDependency ; + } + else { + _Dependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED ; + } } ; + virtual ~Port() { cdebug << "~Port" << endl ; } ; - SUPERV::Port_var ObjRef() const { return _Port ; } ; - void ObjRef(SUPERV::Port_var aPort) { - _Port = aPort ; } ; - - const char * NodeName() const { return *_NodeName ; } ; - const char * NodePortName() const { -// cout << "NodePortName " << hex << (void *) _NodeName << " " -// << dec << _NodeName << endl ; - char * _NodePortName = new char [ strlen( *_NodeName ) + - strlen( ServicesParameterName() ) + 3 ] ; - strcpy( _NodePortName , *_NodeName ) ; - strcat( _NodePortName , "\\" ) ; - strcat( _NodePortName , ServicesParameterName() ) ; -// strcat( _NodePortName , "\\" ) ; - return _NodePortName ; } ; - - const char * PortName() const { - if ( this == NULL ) - return NULLSTRING ; - return ServicesParameterName() ; } ; - const char * PortType() const { return ServicesParameterType() ; } ; - - void Kind( SUPERV::KindOfPort aKindOfPort ) { - if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) { - cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort - << endl ; - } - _KindOfPort = aKindOfPort ; } ; - const SUPERV::KindOfPort Kind() const { return _KindOfPort ; } ; - bool IsParam() const { - return _KindOfPort == SUPERV::ServiceParameter ; } ; - bool IsGate() const { - return _KindOfPort == SUPERV::GateParameter || - _KindOfPort == SUPERV::GOTOParameter ; } ; - bool IsInLine() const { - return _KindOfPort == SUPERV::InLineParameter ; } ; - bool IsLoop() const { - return _KindOfPort == SUPERV::LoopParameter ; } ; - bool IsSwitch() const { - return _KindOfPort == SUPERV::SwitchParameter ; } ; - bool IsEndSwitch() const { - return _KindOfPort == SUPERV::EndSwitchParameter ; } ; - bool IsGOTO() const { - return _KindOfPort == SUPERV::GOTOParameter ; } ; -// bool IsBus() const { return ( ( _KindOfPort == SUPERV::InLineParameter ) || -// ( _PortIndex != -1 ) ) ; } ; - -// void PortIndex( const int anIndex ) { -// _PortIndex = anIndex ; } ; -// const int PortIndex() const { -// return _PortIndex ; } ; - - - bool AddCoord( const int nxy , const int *x , const int *y ) ; - bool AddCoord( const int index , const int x , const int y ) ; - bool ChangeCoord( const int index , - const int x , - const int y ) ; - bool RemoveCoord( const int index ) ; - bool RemoveCoords() ; - int GetCoord() const ; - bool GetCoord( int *x , int *y ) const ; - const GraphBase::ListOfCoords * Coords() const ; - bool GetCoord( const int index , long &x , long &y ) const ; + SUPERV::Port_var ObjRef() const { return _Port ; } ; + void ObjRef(SUPERV::Port_var aPort) { + _Port = aPort ; } ; + + const char * NodeName() const { return *_NodeName ; } ; + const char * NodePortName() const { +// cout << "NodePortName " << hex << (void *) _NodeName << " " +// << dec << _NodeName << endl ; + char * _NodePortName = new char [ strlen( *_NodeName ) + + strlen( ServicesParameterName() ) + 3 ] ; + strcpy( _NodePortName , *_NodeName ) ; + strcat( _NodePortName , "\\" ) ; + strcat( _NodePortName , ServicesParameterName() ) ; + return _NodePortName ; } ; + + const char * PortName() const { + if ( this == NULL ) + return NULLSTRING ; + return ServicesParameterName() ; } ; + const char * PortType() const { return ServicesParameterType() ; } ; + + void Kind( SUPERV::KindOfPort aKindOfPort ) { + if ( _KindOfPort == SUPERV::GateParameter && aKindOfPort == SUPERV::InLineParameter ) { + cdebug << "GraphBase::Port::Kind " << _KindOfPort << " --> " << aKindOfPort + << endl ; + } + _KindOfPort = aKindOfPort ; } ; + const SUPERV::KindOfPort Kind() const { + return _KindOfPort ; } ; + bool IsParam() const { + return _KindOfPort == SUPERV::ServiceParameter ; } ; + bool IsGate() const { + return _KindOfPort == SUPERV::GateParameter || + _KindOfPort == SUPERV::GOTOParameter ; } ; + bool IsInLine() const { + return _KindOfPort == SUPERV::InLineParameter ; } ; + bool IsLoop() const { + return _KindOfPort == SUPERV::LoopParameter ; } ; + bool IsSwitch() const { + return _KindOfPort == SUPERV::SwitchParameter ; } ; + bool IsEndSwitch() const { + return _KindOfPort == SUPERV::EndSwitchParameter ; } ; + bool IsGOTO() const { + return _KindOfPort == SUPERV::GOTOParameter ; } ; + bool IsDataStream() const { + return _KindOfPort == SUPERV::DataStreamParameter ; } ; + + const SALOME_ModuleCatalog::DataStreamDependency Dependency() const { + return _Dependency ; } ; + bool Dependency( SALOME_ModuleCatalog::DataStreamDependency aDependency ) { + if ( IsDataStream() ) { + _Dependency = aDependency ; + return true ; + } + return false ; } ; + + bool AddCoord( const int nxy , const int *x , const int *y ) ; + bool AddCoord( const int index , const int x , const int y ) ; + bool ChangeCoord( const int index , + const int x , + const int y ) ; + bool RemoveCoord( const int index ) ; + bool RemoveCoords() ; + int GetCoord() const ; + bool GetCoord( int *x , int *y ) const ; + const GraphBase::ListOfCoords * Coords() const ; + bool GetCoord( const int index , long &x , long &y ) const ; } ; @@ -135,4 +147,6 @@ namespace GraphBase { ostream & operator<< (ostream &,const SUPERV::KindOfPort &); +ostream & operator<< (ostream &,const SALOME_ModuleCatalog::DataStreamDependency &); + #endif diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.cxx b/src/GraphBase/DataFlowBase_PortsOfNode.cxx index da89abd..73a084b 100644 --- a/src/GraphBase/DataFlowBase_PortsOfNode.cxx +++ b/src/GraphBase/DataFlowBase_PortsOfNode.cxx @@ -36,6 +36,8 @@ GraphBase::PortsOfNode::PortsOfNode() : // cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ; _NodeInPortsSize = 0 ; _NodeOutPortsSize = 0 ; + _DataStreamInPortsNumber = 0 ; + _DataStreamOutPortsNumber = 0 ; } GraphBase::PortsOfNode::PortsOfNode( const char *DataFlowName ) : @@ -45,6 +47,8 @@ GraphBase::PortsOfNode::PortsOfNode( const char *DataFlowName ) : // cdebug << "GraphBase::PortsOfNode::PortsOfNode " << this << endl ; _NodeInPortsSize = 0 ; _NodeOutPortsSize = 0 ; + _DataStreamInPortsNumber = 0 ; + _DataStreamOutPortsNumber = 0 ; } GraphBase::PortsOfNode::~PortsOfNode() { @@ -67,21 +71,26 @@ void GraphBase::PortsOfNode::DefPortsOfNode( int * Graph_prof_debug , ofstream * Graph_fdebug ) { int i ; - cdebug_in << "DefPortsOfNode : " << *NodeName << endl ; - const bool DataFlowOrComputing = (aKind == SUPERV::DataFlowNode) || + SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; +// MESSAGE( "DefPortsOfNode " << NodeName << " Graph_prof_debug " +// << Graph_prof_debug << " _prof_debug " << _prof_debug ) ; + cdebug_in << "DefPortsOfNode : " << *NodeName << " ServiceName " << aService.ServiceName << endl ; + const bool DataFlowOrComputing = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) ; // WithInLoop : InitLoop or DoLoop const bool WithInLoop = (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) ; // WithInGate : InGate or Default - const bool WithInGate = (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || - (aKind == SUPERV::InLineNode) || (aKind == SUPERV::LoopNode) || - (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) || - (aKind == SUPERV::GOTONode) ; + const bool WithInGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) || + (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || + (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) || + (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) || + (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ; // WithOutGate : OutGate or Default - const bool WithOutGate = (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || - (aKind == SUPERV::InLineNode) || (aKind == SUPERV::SwitchNode) || - (aKind == SUPERV::GOTONode) ; + const bool WithOutGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) || + (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || + (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) || + (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) ; SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ; if ( aKind == SUPERV::InLineNode ) { aPortKind = SUPERV::InLineParameter ; @@ -145,7 +154,7 @@ void GraphBase::PortsOfNode::DefPortsOfNode( const char *aParametername = _aParametername.c_str() ; if ( _MapOfNodeInPorts[ aParametername ] ) { if ( !DataFlowOrComputing && - !strcmp( aParametername , "InGate" ) ) { + !strcmp( aParametername , "Gate" ) ) { } else { cdebug << "Error, Parametername duplicated : " << aParametername @@ -169,7 +178,7 @@ void GraphBase::PortsOfNode::DefPortsOfNode( SALOME_ModuleCatalog::ServicesParameter anInGateParameter ; _NodeInPortsSize = _NodeInPortsSize + 1 ; iVec += 1 ; - char *aParametername = "InGate" ; + char *aParametername = "Gate" ; if ( aKind == SUPERV::EndSwitchNode ) { aParametername = "Default" ; } @@ -216,7 +225,7 @@ void GraphBase::PortsOfNode::DefPortsOfNode( const char *aParametername = _aParametername.c_str() ; if ( _MapOfNodeOutPorts[ aParametername ] ) { if ( !DataFlowOrComputing && - !strcmp( aParametername , "OutGate" ) ) { + !strcmp( aParametername , "Gate" ) ) { } else { cdebug << "Error, Parametername duplicated : " << aParametername @@ -224,9 +233,9 @@ void GraphBase::PortsOfNode::DefPortsOfNode( } } else { - _MapOfNodeOutPorts[ aParametername ] = i+1 ; cdebug << "DefPortsOfNode : " << "_MapOfNodeOutPorts[ " << aParametername << " ] = " << i+1 << endl ; + _MapOfNodeOutPorts[ aParametername ] = i+1 ; const SALOME_ModuleCatalog::ServicesParameter aServiceParameter = aService.ServiceoutParameter[i-iVec] ; _NodeOutPorts[i] = new GraphBase::OutPort( NodeName , aServiceParameter , aPortKind ); @@ -240,7 +249,7 @@ void GraphBase::PortsOfNode::DefPortsOfNode( SALOME_ModuleCatalog::ServicesParameter anOutGateParameter ; _NodeOutPortsSize = _NodeOutPortsSize + 1 ; iVec += 1 ; - char *aParametername = "OutGate" ; + char *aParametername = "Gate" ; if ( aKind == SUPERV::SwitchNode ) { aParametername = "Default" ; } @@ -261,116 +270,172 @@ void GraphBase::PortsOfNode::DefPortsOfNode( GraphBase::InPort * GraphBase::PortsOfNode::AddInPort( CORBA::ORB_ptr ORB , const char *const * NodeName , - const SUPERV::KindOfNode aKind , + const SUPERV::KindOfNode aKindOfNode , const char * InputParameterName , const char * InputParameterType , + SUPERV::KindOfPort aKindOfPort , +// const int DataStreamInPortsNumber , int * Graph_prof_debug , ofstream * Graph_fdebug ) { - cdebug_in << "DefPortsOfNode::AddInPort : " << *NodeName << " " << aKind << " " - << InputParameterName << " " << InputParameterType << endl ; +// MESSAGE( "DefPortsOfNode " << *NodeName << " Graph_prof_debug " +// << Graph_prof_debug << " _prof_debug " << _prof_debug ) ; + cdebug_in << "PortsOfNode::AddInPort : " << *NodeName << " " << aKindOfNode << " InputParameterName " << InputParameterName << " InputParameterType " + << InputParameterType << " aKindOfPort " << aKindOfPort << " DataStreamInPortsNumber " << DataStreamInPortsNumber() << " _NodeInPortsSize " + << _NodeInPortsSize << endl ; GraphBase::InPort * anInPort = NULL ; - if ( aKind == SUPERV::InLineNode || aKind == SUPERV::LoopNode || - aKind == SUPERV::EndLoopNode || aKind == SUPERV::SwitchNode || - aKind == SUPERV::EndSwitchNode || aKind == SUPERV::GOTONode ) { - SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ; - if ( aKind == SUPERV::EndSwitchNode ) { - aPortKind = SUPERV::EndSwitchParameter ; - } - anInPort = GetChangeInPort( InputParameterName ) ; - if ( anInPort == NULL ) { - _NodeInPortsSize = _NodeInPortsSize + 1 ; - _NodeInPorts.resize(_NodeInPortsSize); - SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; - aServiceParameter.Parametername = InputParameterName ; - aServiceParameter.Parametertype = InputParameterType ; - SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ; - if ( aKind != SUPERV::EndLoopNode ) { - _NodeInPorts[ _NodeInPortsSize-1 ] = _NodeInPorts[ _NodeInPortsSize-2 ] ; // Gate - Default - _MapOfNodeInPorts.erase( _NodeInPorts[ _NodeInPortsSize-1 ]->PortName() ) ; - _MapOfNodeInPorts[ _NodeInPorts[ _NodeInPortsSize-1 ]->PortName() ] = _NodeInPortsSize-1 + 1 ; - _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-2 + 1 ; - _NodeInPorts[_NodeInPortsSize-2] = new GraphBase::InPort( NodeName , - aServiceParameter , - aPortKind ) ; - _NodeInPorts[_NodeInPortsSize-2]->Kind( SUPERV::InLineParameter ) ; -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << InputParameterName << " --> SetDebug" ) ; - _NodeInPorts[_NodeInPortsSize-2]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - anInPort = _NodeInPorts[_NodeInPortsSize-2] ; - cdebug << "NodeInPorts[ " << _NodeInPortsSize-2 << " ]" << endl ; + int index = 0 ; + anInPort = GetChangeInPort( InputParameterName ) ; + if ( anInPort == NULL ) { + _NodeInPortsSize = _NodeInPortsSize + 1 ; + _NodeInPorts.resize(_NodeInPortsSize); + SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; + aServiceParameter.Parametername = CORBA::string_dup( InputParameterName ) ; + aServiceParameter.Parametertype = CORBA::string_dup( InputParameterType ) ; + if ( aKindOfPort == SUPERV::DataStreamParameter ) { + index = _NodeInPortsSize-2 ; + IncrDataStreamInPorts() ; + } + else { + index = _NodeInPortsSize-2 - DataStreamInPortsNumber() ; + } +// if ( aKindOfNode != SUPERV::EndLoopNode ) { + int i ; + for ( i = _NodeInPortsSize - 2 ; i >= index ; i-- ) { + _NodeInPorts[ i + 1 ] = _NodeInPorts[ i ] ; // Gate - Default + _MapOfNodeInPorts.erase( _NodeInPorts[ i + 1 ]->PortName() ) ; + _MapOfNodeInPorts[ _NodeInPorts[ i + 1 ]->PortName() ] = i + 2 ; + } + _MapOfNodeInPorts[ InputParameterName ] = index + 1 ; + if ( aKindOfPort == SUPERV::DataStreamParameter ) { + _NodeInPorts[index] = new GraphBase::InDataStreamPort( NodeName , + aServiceParameter ) ; } else { - _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-1 + 1 ; - _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName , - aServiceParameter , - aPortKind ) ; - _NodeInPorts[_NodeInPortsSize-1]->Kind( SUPERV::InLineParameter ) ; -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << InputParameterName << " --> SetDebug" ) ; - _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - anInPort = _NodeInPorts[_NodeInPortsSize-1] ; - cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ; + _NodeInPorts[index] = new GraphBase::InPort( NodeName , + aServiceParameter , + aKindOfPort ) ; } + _NodeInPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + anInPort = _NodeInPorts[index] ; + cdebug << "NodeInPorts[ " << index << " ]" << endl ; } - else { - cdebug << "InPort already exists" << endl ; +// else { // EndLoopNode +// _MapOfNodeInPorts[ InputParameterName ] = _NodeInPortsSize-1 + 1 ; +// _NodeInPorts[_NodeInPortsSize-1] = new GraphBase::InPort( NodeName , +// aServiceParameter ,// +// aKindOfPort ) ; +// MESSAGE( "GraphBase::PortsOfNode::AddInPort " << InputParameterName << " --> SetDebug" ) ; +// _NodeInPorts[_NodeInPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; +// anInPort = _NodeInPorts[_NodeInPortsSize-1] ; +// cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ; +// } +// } + else { + cdebug << "GraphBase::PortsOfNode::AddInPort InPort already exists" << endl ; + anInPort->Kind( aKindOfPort ) ; + } + cdebug << "GraphBase::PortsOfNode::AddInPort index " << index << " _NodeInPortsSize " << _NodeInPortsSize << endl ; + int i ; + for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { + cdebug << *NodeName << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName() + << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = " + << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] - 1 << " " + << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ; + if ( _NodeInPorts[ i ]->IsDataStream() ) { + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ; } + cdebug << endl ; } - cdebug_out << "DefPortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize + cdebug_out << "GraphBase::PortsOfNode::AddInPort _NodeInPortsSize " << _NodeInPortsSize << " " << anInPort->Kind() << endl ; return anInPort ; } GraphBase::OutPort * GraphBase::PortsOfNode::AddOutPort( CORBA::ORB_ptr ORB , const char * const * NodeName , - const SUPERV::KindOfNode aKind , + const SUPERV::KindOfNode aKindOfNode , const char * OutputParameterName , const char * OutputParameterType , + SUPERV::KindOfPort aKindOfPort , +// const int DataStreamOutPortsNumber , int * Graph_prof_debug , ofstream * Graph_fdebug ) { - cdebug_in << "DefPortsOfNode::AddOutPort : " << *NodeName << " " << aKind << " " - << OutputParameterName << " " << OutputParameterType << endl ; + cdebug_in << "GraphBase::PortsOfNode::AddOutPort : " << *NodeName << " " << aKindOfNode << " OutputParameterName " << OutputParameterName + << " OutputParameterType " << OutputParameterType << " aKindOfPort " << aKindOfPort << " DataStreamOutPortsNumber " << DataStreamOutPortsNumber() + << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ; GraphBase::OutPort * anOutPort = NULL ; - if ( aKind == SUPERV::InLineNode || aKind == SUPERV::LoopNode || - aKind == SUPERV::EndLoopNode || aKind == SUPERV::SwitchNode || - aKind == SUPERV::EndSwitchNode || aKind == SUPERV::GOTONode ) { - SUPERV::KindOfPort aPortKind = SUPERV::InLineParameter ; - anOutPort = GetChangeOutPort( OutputParameterName ) ; - if ( anOutPort == NULL ) { - _NodeOutPortsSize = _NodeOutPortsSize + 1 ; - _NodeOutPorts.resize(_NodeOutPortsSize); - SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; - aServiceParameter.Parametername = OutputParameterName ; - aServiceParameter.Parametertype = OutputParameterType ; - if ( aKind == SUPERV::SwitchNode ) { - _NodeOutPorts[ _NodeOutPortsSize-1 ] = _NodeOutPorts[ _NodeOutPortsSize-2 ] ; // Default - _MapOfNodeOutPorts.erase( _NodeOutPorts[ _NodeOutPortsSize-1 ]->PortName() ) ; - _MapOfNodeOutPorts[ _NodeOutPorts[ _NodeOutPortsSize-1 ]->PortName() ] = _NodeOutPortsSize-1 + 1 ; - _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize - 1 ; - _NodeOutPorts[_NodeOutPortsSize-2] = new GraphBase::OutPort( NodeName , - aServiceParameter , - aPortKind ); - _NodeOutPorts[_NodeOutPortsSize-2]->Kind( SUPERV::InLineParameter ) ; -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << OutputParameterName << " --> SetDebug" ) ; - _NodeOutPorts[_NodeOutPortsSize-2]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - anOutPort = _NodeOutPorts[_NodeOutPortsSize-2] ; - cdebug << "NodeInPorts[ " << _NodeInPortsSize-2 << " ]" << endl ; - } - else { - _MapOfNodeOutPorts[ OutputParameterName ] = _NodeOutPortsSize ; - _NodeOutPorts[_NodeOutPortsSize-1] = new GraphBase::OutPort( NodeName , - aServiceParameter , - aPortKind ); - _NodeOutPorts[_NodeOutPortsSize-1]->Kind( SUPERV::InLineParameter ) ; -// MESSAGE( "GraphBase::PortsOfNode::DefPortsOfNode " << OutputParameterName << " --> SetDebug" ) ; - _NodeOutPorts[_NodeOutPortsSize-1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; - anOutPort = _NodeOutPorts[_NodeOutPortsSize-1] ; - cdebug << "NodeInPorts[ " << _NodeInPortsSize-1 << " ]" << endl ; - } + int index = 0 ; + anOutPort = GetChangeOutPort( OutputParameterName ) ; + if ( anOutPort == NULL ) { + _NodeOutPortsSize = _NodeOutPortsSize + 1 ; + _NodeOutPorts.resize(_NodeOutPortsSize); + SALOME_ModuleCatalog::ServicesParameter aServiceParameter ; + aServiceParameter.Parametername = CORBA::string_dup( OutputParameterName ) ; + aServiceParameter.Parametertype = CORBA::string_dup( OutputParameterType ) ; + if ( aKindOfPort == SUPERV::DataStreamParameter ) { + index = _NodeOutPortsSize-2 ; + IncrDataStreamOutPorts() ; + } + else { + index = _NodeOutPortsSize-2 - DataStreamOutPortsNumber() ; + } + if ( aKindOfNode == SUPERV::LoopNode || aKindOfNode == SUPERV::EndLoopNode ) { + index += 1 ; + } +// if ( aKindOfNode != SUPERV::LoopNode && aKindOfNode != SUPERV::EndLoopNode ) { + int i ; + for ( i = _NodeOutPortsSize - 2 ; i >= index ; i-- ) { + _NodeOutPorts[ i + 1 ] = _NodeOutPorts[ i ] ; // Gate - Default + _MapOfNodeOutPorts.erase( _NodeOutPorts[ i + 1 ]->PortName() ) ; + _MapOfNodeOutPorts[ _NodeOutPorts[ i + 1 ]->PortName() ] = i + 2 ; + } + _MapOfNodeOutPorts[ OutputParameterName ] = index + 1 ; + if ( aKindOfPort == SUPERV::DataStreamParameter ) { + _NodeOutPorts[index] = new GraphBase::OutDataStreamPort( NodeName , + aServiceParameter ) ; } else { - cdebug << "OutPort already exists" << endl ; + _NodeOutPorts[index] = new GraphBase::OutPort( NodeName , + aServiceParameter , + aKindOfPort ); } +// MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ; + _NodeOutPorts[index]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; + anOutPort = _NodeOutPorts[index] ; + cdebug << "NodeOutPorts[ " << index << " ]" << endl ; + } +// else { // LoopNode || EndLoopNode +// _MapOfNodeOutPorts[ OutputParameterName ] = index + 2 ; +// _NodeOutPorts[index + 1] = new GraphBase::OutPort( NodeName , +// aServiceParameter , +// aKindOfPort ); +// MESSAGE( "GraphBase::PortsOfNode::AddOutPort " << OutputParameterName << " --> SetDebug" ) ; +// _NodeOutPorts[index + 1]->SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; +// anOutPort = _NodeOutPorts[index + 1] ; +// cdebug << "NodeOutPorts[ " << index + 1 << " ]" << endl ; +// } +// } + else { + cdebug << "GraphBase::PortsOfNode::AddOutPort OutPort already exists" << endl ; + anOutPort->Kind( aKindOfPort ) ; } - cdebug_out << "DefPortsOfNode::AddOutPort _NodeOutPortsSize " + cdebug << "GraphBase::PortsOfNode::AddOutPort index " << index << " _NodeOutPortsSize " << _NodeOutPortsSize << endl ; + int i ; + for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { + cdebug << *NodeName << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName() + << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = " + << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] - 1 << " " + << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ; + if ( _NodeOutPorts[ i ]->IsDataStream() ) { + cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ; + } + cdebug << endl ; + } + cdebug_out << "GraphBase::PortsOfNode::AddOutPort _NodeOutPortsSize " << _NodeOutPortsSize << " " << anOutPort->Kind() << endl ; return anOutPort ; } @@ -382,6 +447,9 @@ void GraphBase::PortsOfNode::DelInPort( const char * InputParameterName ) { cdebug << "DefPortsOfNode::DelInPort : _NodeInPorts[" << index << "] " << _NodeInPorts[ index ]->PortName() << " " << _NodeInPorts[ index ]->NodeName() << endl ; + if ( _NodeInPorts[ index ]->IsDataStream() ) { + DecrDataStreamInPorts() ; + } _MapOfNodeInPorts.erase( InputParameterName ) ; _NodeInPorts[ index ]->destroy() ; int i ; @@ -411,6 +479,9 @@ void GraphBase::PortsOfNode::DelOutPort( const char * OutputParameterName ) { cdebug << "DefPortsOfNode::DelOutPort : _NodeOutPorts[" << index << "] " << _NodeOutPorts[ index ]->PortName() << " " << _NodeOutPorts[ index ]->NodeName() << endl ; + if ( _NodeOutPorts[ index ]->IsDataStream() ) { + DecrDataStreamOutPorts() ; + } _MapOfNodeOutPorts.erase( OutputParameterName ) ; _NodeOutPorts[ index ]->destroy() ; int i ; @@ -454,38 +525,85 @@ const GraphBase::OutPort *GraphBase::PortsOfNode::GetOutPort( const char *name) } GraphBase::InPort *GraphBase::PortsOfNode::GetChangeInPort( const char * name) { -// cdebug_in << "GraphBase::PortsOfNode::GetChangePort " << name <<" " << way -// << endl; +// cdebug_in << "GraphBase::PortsOfNode::GetChangeInPort " << name << endl; GraphBase::InPort * pP = NULL; if ( !_MapOfNodeInPorts.empty() ) { - int i = _MapOfNodeInPorts[ name ] ; -// cout << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ " -// << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName() -// << endl ; - if ( i > 0 ) + int i = 0 ; + if ( !strcmp( name , "InGate" ) ) { + i = _MapOfNodeInPorts[ "Gate" ] ; + } + else { + i = _MapOfNodeInPorts[ name ] ; + } + if ( i > 0 ) { +// cdebug << "GraphBase::PortsOfNode::GetChangeInPort _MapOfNodeInPorts[ " +// << name << " ] : " << i-1 << " " << _NodeInPorts[ i-1 ]->NodeName() +// << endl ; pP = _NodeInPorts[ i-1 ] ; + } } +// if ( pP == NULL ) { +// int i ; +// for ( i = 0 ; i < _NodeInPortsSize ; i++ ) { +// cdebug << " _NodeInPorts[ " << i << " ] = " << _NodeInPorts[ i ]->PortName() +// << " _MapOfNodeInPorts[ " << _NodeInPorts[ i ]->PortName() << " ] = " +// << _MapOfNodeInPorts[ _NodeInPorts[ i ]->PortName() ] - 1 << " " +// << _NodeInPorts[ i ]->Kind() << " Dependency " << _NodeInPorts[ i ]->Dependency() ; +// if ( _NodeInPorts[ i ]->IsDataStream() ) { +// SUPERV::KindOfSchema aKindOfSchema ; +// SUPERV::KindOfInterpolation aKindOfInterpolation ; +// SUPERV::KindOfExtrapolation aKindOfExtrapolation ; +// ((GraphBase::InDataStreamPort * ) _NodeInPorts[ i ])->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; +// cdebug << " " << aKindOfSchema << " " << aKindOfInterpolation << " " << aKindOfExtrapolation ; +// } +// if ( !strcmp( _NodeInPorts[ i ]->PortName() , name ) ) { +// cdebug << " ERROR" ; +// } +// cdebug << endl ; +// } +// } // cdebug_out << "GraphBase::PortsOfNode::GetChangeInPort " << endl; return pP; } GraphBase::OutPort *GraphBase::PortsOfNode::GetChangeOutPort( const char * name ) { -// cdebug_in << "GraphBase::PortsOfNode::GetChangePort " << name <<" " << way -// << endl; +// cdebug_in << "GraphBase::PortsOfNode::GetChangeOutPort " << name << endl; GraphBase::OutPort * pP = NULL; if ( !_MapOfNodeOutPorts.empty() ) { - int i = _MapOfNodeOutPorts[ name ] ; -// cout << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ " -// << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() -// << endl ; - if ( i > 0 ) + int i = 0 ; + if ( !strcmp( name , "OutGate" ) ) { + i = _MapOfNodeOutPorts[ "Gate" ] ; + } + else { + i = _MapOfNodeOutPorts[ name ] ; + } + if ( i > 0 ) { +// cdebug << "GraphBase::PortsOfNode::GetChangeOutPort _MapOfNodeOutPorts[ " +// << name << " ] : " << i-1 << " " << _NodeOutPorts[ i-1 ]->NodeName() << endl ; pP = _NodeOutPorts[ i-1 ] ; + } } // cdebug_out << "GraphBase::PortsOfNode::GetChangeOutPort " << endl; +// if ( pP == NULL ) { +// int i ; +// for ( i = 0 ; i < _NodeOutPortsSize ; i++ ) { +// cdebug << " _NodeOutPorts[ " << i << " ] = " << _NodeOutPorts[ i ]->PortName() +// << " _MapOfNodeOutPorts[ " << _NodeOutPorts[ i ]->PortName() << " ] = " +// << _MapOfNodeOutPorts[ _NodeOutPorts[ i ]->PortName() ] - 1 << " " +// << _NodeOutPorts[ i ]->Kind() << " Dependency " << _NodeOutPorts[ i ]->Dependency() ; +// if ( _NodeOutPorts[ i ]->IsDataStream() ) { +// cdebug << " NumberOfValues " << ((GraphBase::OutDataStreamPort * ) _NodeOutPorts[ i ])->NumberOfValues() ; +// } +// if ( !strcmp( _NodeOutPorts[ i ]->PortName() , name ) ) { +// cdebug << " ERROR" ; +// } +// cdebug << endl ; +// } +// } return pP; } @@ -580,8 +698,11 @@ ostream & operator<< (ostream & f ,const SUPERV::KindOfNode & s ) { case SUPERV::InLineNode : f << "InLineNode"; break; - case SUPERV::DataFlowNode : - f << "DataFlowNode"; + case SUPERV::DataFlowGraph : + f << "DataFlowGraph"; + break; + case SUPERV::DataStreamGraph : + f << "DataStreamGraph"; break; case SUPERV::LoopNode : f << "LoopNode"; diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.hxx b/src/GraphBase/DataFlowBase_PortsOfNode.hxx index 395c81a..de75d7c 100644 --- a/src/GraphBase/DataFlowBase_PortsOfNode.hxx +++ b/src/GraphBase/DataFlowBase_PortsOfNode.hxx @@ -31,8 +31,8 @@ #include "DataFlowBase_Service.hxx" -#include "DataFlowBase_InPort.hxx" -#include "DataFlowBase_OutPort.hxx" +#include "DataFlowBase_InDataStreamPort.hxx" +#include "DataFlowBase_OutDataStreamPort.hxx" namespace GraphBase { @@ -49,6 +49,9 @@ namespace GraphBase { int _NodeOutPortsSize ; vector _NodeOutPorts; + int _DataStreamInPortsNumber ; + int _DataStreamOutPortsNumber ; + public: PortsOfNode() ; @@ -59,10 +62,6 @@ namespace GraphBase { const SALOME_ModuleCatalog::Service& NodeService , const char *const * NodeName , const SUPERV::KindOfNode aKind , -// const bool DataFlowOrComputing , -// const bool WithGateArg , -// const bool WithInGate , -// const bool WithOutGate , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; @@ -71,6 +70,8 @@ namespace GraphBase { const SUPERV::KindOfNode aKind , const char * InputParameterName , const char * InputParameterType , + SUPERV::KindOfPort aKindOfPort , +// const int DataStreamInPortsNumber , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; OutPort * AddOutPort( CORBA::ORB_ptr ORB , @@ -78,13 +79,46 @@ namespace GraphBase { const SUPERV::KindOfNode aKind , const char * OutputParameterName , const char * InputParameterType , + SUPERV::KindOfPort aKindOfPort , +// const int DataStreamOutPortsNumber , int * Graph_prof_debug , ofstream * Graph_fdebug ) ; -// void InOutPort( InPort * InputPort , OutPort * OutputPort ) ; void DelInPort( const char * InputParameterName ) ; void DelOutPort( const char * OutputParameterName ) ; + int IncrDataStreamInPorts() { + _DataStreamInPortsNumber++ ; + return _DataStreamInPortsNumber ; + } ; + int DecrDataStreamInPorts() { + _DataStreamInPortsNumber-- ; + return _DataStreamInPortsNumber ; + } ; + int IncrDataStreamOutPorts() { + _DataStreamOutPortsNumber++ ; + return _DataStreamOutPortsNumber ; + } ; + int DecrDataStreamOutPorts() { + _DataStreamOutPortsNumber-- ; + return _DataStreamOutPortsNumber ; + } ; + int DataStreamInPortsNumber() { + return _DataStreamInPortsNumber ; + } ; + int DataStreamOutPortsNumber() { + return _DataStreamOutPortsNumber ; + } ; + void DataStreamInPortsNumber( int aDataStreamInPortsNumber ) { + _DataStreamInPortsNumber = aDataStreamInPortsNumber ; + } ; + void DataStreamOutPortsNumber(int aDataStreamOutPortsNumber ) { + _DataStreamOutPortsNumber = aDataStreamOutPortsNumber ; + } ; + int HasDataStream() const { + return _DataStreamInPortsNumber + _DataStreamOutPortsNumber ; + } ; + const int GetNodeInPortsSize() const { return _NodeInPortsSize ; } ; const InPort * GetNodeInLoop() const { return _NodeInPorts[0] ; } ; @@ -117,7 +151,6 @@ namespace GraphBase { InPort * GetChangeInPort( const char *name ) ; OutPort * GetChangeOutPort( const char *name ) ; -// void ListPorts( ostream & , const bool klink = true ) const ; void ListPorts( ostream & , const bool klink = true ) const ; }; diff --git a/src/GraphBase/DataFlowBase_Service.cxx b/src/GraphBase/DataFlowBase_Service.cxx index 857188c..9bc5788 100644 --- a/src/GraphBase/DataFlowBase_Service.cxx +++ b/src/GraphBase/DataFlowBase_Service.cxx @@ -30,6 +30,7 @@ using namespace std; #include "DataFlowBase_Service.hxx" void GraphBase::Service::SetService( const SALOME_ModuleCatalog::Service aService ) { + _Service.ServiceName = CORBA::string_dup( aService.ServiceName ) ; _Service.ServiceinParameter.length( aService.ServiceinParameter.length() ) ; _Service.ServiceoutParameter.length( aService.ServiceoutParameter.length() ) ; @@ -42,6 +43,19 @@ void GraphBase::Service::SetService( const SALOME_ModuleCatalog::Service aServic _Service.ServiceoutParameter[ i ].Parametertype = CORBA::string_dup( aService.ServiceoutParameter[ i ].Parametertype ) ; _Service.ServiceoutParameter[ i ].Parametername = CORBA::string_dup( aService.ServiceoutParameter[ i ].Parametername ) ; } + + _Service.ServiceinDataStreamParameter.length( aService.ServiceinDataStreamParameter.length() ) ; + _Service.ServiceoutDataStreamParameter.length( aService.ServiceoutDataStreamParameter.length() ) ; + for ( i = 0 ; i < (int ) _Service.ServiceinDataStreamParameter.length() ; i++ ) { + _Service.ServiceinDataStreamParameter[ i ].Parametertype = aService.ServiceinDataStreamParameter[ i ].Parametertype ; + _Service.ServiceinDataStreamParameter[ i ].Parametername = CORBA::string_dup( aService.ServiceinDataStreamParameter[ i ].Parametername ) ; + _Service.ServiceinDataStreamParameter[ i ].Parameterdependency = aService.ServiceinDataStreamParameter[ i ].Parameterdependency ; + } + for ( i = 0 ; i < (int ) _Service.ServiceoutDataStreamParameter.length() ; i++ ) { + _Service.ServiceoutDataStreamParameter[ i ].Parametertype = aService.ServiceoutDataStreamParameter[ i ].Parametertype ; + _Service.ServiceoutDataStreamParameter[ i ].Parametername = CORBA::string_dup( aService.ServiceoutDataStreamParameter[ i ].Parametername ) ; + _Service.ServiceoutDataStreamParameter[ i ].Parameterdependency = aService.ServiceoutDataStreamParameter[ i ].Parameterdependency ; + } cdebug << "GraphBase::Service::SetService : " << _Service << endl ; _Instance = 0 ; } @@ -65,6 +79,24 @@ ostream & operator<< (ostream & f ,const SALOME_ModuleCatalog::Service & s ) { f << ". " << s.ServiceoutParameter[i].Parametername << ". " << s.ServiceoutParameter[i].Parametertype << endl ; } + for ( i = 0 ; i < (int ) s.ServiceinDataStreamParameter.length() ; i++ ) { + if ( i == 0 ) + f << " InStreamparameters " << i ; + else + f << " " << i ; + f << ". " << s.ServiceinDataStreamParameter[i].Parametername + << ". " << s.ServiceinDataStreamParameter[i].Parametertype + << ". " << s.ServiceinDataStreamParameter[i].Parameterdependency << endl ; + } + for ( i = 0 ; i < (int ) s.ServiceoutDataStreamParameter.length() ; i++ ) { + if ( i == 0 ) + f << " OutStreamparameters " << i ; + else + f << " " << i ; + f << ". " << s.ServiceoutDataStreamParameter[i].Parametername + << ". " << s.ServiceoutDataStreamParameter[i].Parametertype + << ". " << s.ServiceoutDataStreamParameter[i].Parameterdependency << endl ; + } return f; } diff --git a/src/GraphBase/DataFlowBase_Service.hxx b/src/GraphBase/DataFlowBase_Service.hxx index e6b7b05..0c4f57a 100644 --- a/src/GraphBase/DataFlowBase_Service.hxx +++ b/src/GraphBase/DataFlowBase_Service.hxx @@ -37,48 +37,51 @@ namespace GraphBase { class Service : public Base { - SALOME_ModuleCatalog::Service _Service ; - int _Instance ; + private: + + SALOME_ModuleCatalog::Service _Service ; + int _Instance ; public: - Service( const SALOME_ModuleCatalog::Service aService ) { + Service( const SALOME_ModuleCatalog::Service aService ) { SetService( aService ) ; // MESSAGE( "GraphBase::Service::Service : " << _Service ) ; // cout << "GraphBase::Service::Service : " << _Service << endl ; cdebug << "GraphBase::Service::Service : " << _Service << endl ; } ; - Service( const char * aServiceName ) { - _Service.ServiceName = CORBA::string_dup( aServiceName ) ; - cdebug << "GraphBase::Service::Service : " << _Service << endl ; - _Instance = 0 ; } ; - virtual ~Service() { - cdebug << "GraphBase::Service::~Service" << endl ; - } ; - - void SetService( const SALOME_ModuleCatalog::Service aService ) ; + Service( const char * aServiceName ) { + _Service.ServiceName = CORBA::string_dup( aServiceName ) ; + cdebug << "GraphBase::Service::Service : " << _Service << endl ; + _Instance = 0 ; } ; + virtual ~Service() { + cdebug << "GraphBase::Service::~Service" << endl ; } ; - const SALOME_ModuleCatalog::Service * GetService() const { - cdebug << "GraphBase::Service::GetService : " << _Service << endl ; - return &_Service ; } ; - const char * ServiceName() const { -// cdebug << "ServiceName " << hex << (void *) _Service.ServiceName -// << dec << " = " << _Service.ServiceName << endl ; - return _Service.ServiceName ; } ; - const SALOME_ModuleCatalog::ListOfServicesParameter ServiceInParameter() const { - return _Service.ServiceinParameter ; } ; - const SALOME_ModuleCatalog::ListOfServicesParameter ServiceOutParameter() const { - return _Service.ServiceoutParameter ; } ; + void SetService( const SALOME_ModuleCatalog::Service aService ) ; - const int Instances() const { return _Instance ; } ; - int NewInstance() { _Instance += 1 ; - return _Instance ; } ; - void Instance( int AddInst = 1 ) { if ( AddInst == 1 ) - _Instance += 1 ; - else - _Instance = AddInst ; } ; + const SALOME_ModuleCatalog::Service * GetService() const { + cdebug << "GraphBase::Service::GetService : " << _Service << endl ; + return &_Service ; } ; + const char * ServiceName() const { +// cdebug << "ServiceName " << hex << (void *) _Service.ServiceName +// << dec << " = " << _Service.ServiceName << endl ; + return _Service.ServiceName ; } ; + const SALOME_ModuleCatalog::ListOfServicesParameter ServiceInParameter() const { + return _Service.ServiceinParameter ; } ; + const SALOME_ModuleCatalog::ListOfServicesParameter ServiceOutParameter() const { + return _Service.ServiceoutParameter ; } ; + const SALOME_ModuleCatalog::ListOfServicesDataStreamParameter ServiceInStreamParameter() const { + return _Service.ServiceinDataStreamParameter ; } ; + const SALOME_ModuleCatalog::ListOfServicesDataStreamParameter ServiceOutStreamParameter() const { + return _Service.ServiceoutDataStreamParameter ; } ; - } ; + const int Instances() const { return _Instance ; } ; + int NewInstance() { _Instance += 1 ; + return _Instance ; } ; + void Instance( int Inst = 1 ) { if ( Inst == 1 ) + _Instance += 1 ; + else + _Instance = Inst ; } ; } ; } ; diff --git a/src/GraphBase/DataFlowBase_ServicesParameter.hxx b/src/GraphBase/DataFlowBase_ServicesParameter.hxx index 786cab9..a14b68a 100644 --- a/src/GraphBase/DataFlowBase_ServicesParameter.hxx +++ b/src/GraphBase/DataFlowBase_ServicesParameter.hxx @@ -33,26 +33,29 @@ namespace GraphBase { class ServicesParameter : public Base { - SALOME_ModuleCatalog::ServicesParameter _ServicesParameter ; + private: + + SALOME_ModuleCatalog::ServicesParameter _ServicesParameter ; public: - ServicesParameter() { + ServicesParameter() { //cout << "ServicesParameter()" << endl ; _ServicesParameter.Parametername = (char *) NULL ; _ServicesParameter.Parametertype = (char *) NULL ; } ; - ServicesParameter( const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) { - _ServicesParameter = aserviceParameter ; } ; - virtual ~ServicesParameter() { + ServicesParameter( const SALOME_ModuleCatalog::ServicesParameter aserviceParameter ) { + _ServicesParameter.Parametertype = CORBA::string_dup( aserviceParameter.Parametertype ) ; + _ServicesParameter.Parametername = CORBA::string_dup( aserviceParameter.Parametername ) ; } ; + virtual ~ServicesParameter() { // cout << "ServicesParameter::~ServicesParameter()" << endl ; } ; - const SALOME_ModuleCatalog::ServicesParameter & GetServicesParameter() const { - return _ServicesParameter ; } ; - const char * ServicesParameterName() const { - return _ServicesParameter.Parametername ; } ; - const char * ServicesParameterType() const { - return _ServicesParameter.Parametertype ; } ; + const SALOME_ModuleCatalog::ServicesParameter & GetServicesParameter() const { + return _ServicesParameter ; } ; + const char * ServicesParameterName() const { + return _ServicesParameter.Parametername ; } ; + const char * ServicesParameterType() const { + return _ServicesParameter.Parametertype ; } ; } ; diff --git a/src/GraphBase/DataFlowBase_StreamGraph.cxx b/src/GraphBase/DataFlowBase_StreamGraph.cxx new file mode 100644 index 0000000..240572b --- /dev/null +++ b/src/GraphBase/DataFlowBase_StreamGraph.cxx @@ -0,0 +1,235 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : DataFlowBase_StreamGraph.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; +#include "DataFlowBase_StreamGraph.hxx" + +#include "SALOME_LifeCycleCORBA.hxx" + +GraphBase::StreamGraph::StreamGraph() : + Graph() { + cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ; +} + +GraphBase::StreamGraph::StreamGraph( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char *DataFlowName , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : +// const char * DebugFileName ) : +// Graph( ORB ,ptrNamingService , DataFlowName , DebugFileName ) { + Graph( ORB ,ptrNamingService , DataFlowName , Graph_prof_debug , Graph_fdebug ) { + _Timeout = 300 ; + _DataStreamTrace = SUPERV::WithoutTrace ; + _DeltaTime = 0 ; + Kind( SUPERV::DataStreamGraph ) ; + cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ; +} + +GraphBase::StreamGraph::StreamGraph( 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 , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) : +// const char * DebugFileName ) : + Graph( ORB ,ptrNamingService , DataFlowService , DataFlowComponentName , + DataFlowInterfaceName , DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , DataFlowComputer , + DataFlowComment , Graph_prof_debug , Graph_fdebug ) { +// DataFlowComment , DebugFileName ) { + _Timeout = 300 ; + _DataStreamTrace = SUPERV::WithoutTrace ; + _DeltaTime = 0 ; + cdebug << "GraphBase::StreamGraph::StreamGraph" << endl ; +} + +GraphBase::StreamGraph::~StreamGraph() { + cdebug << "GraphBase::StreamGraph::~StreamGraph" << endl ; +} + +bool GraphBase::StreamGraph::SetStreamParams( const long Timeout , + const SUPERV::KindOfDataStreamTrace DataStreamTrace , + const double DeltaTime ) { + _Timeout = Timeout ; + _DataStreamTrace = DataStreamTrace ; + _DeltaTime = DeltaTime ; + cdebug << "GraphBase::StreamGraph:::SetStreamGraph _Timeout " << _Timeout << " _DataStreamTrace " << _DataStreamTrace << " _DeltaTime " << _DeltaTime + << endl ; + return true ; +} + +void GraphBase::StreamGraph::StreamParams( long & Timeout , + SUPERV::KindOfDataStreamTrace & DataStreamTrace , + double & DeltaTime ) const { + Timeout = _Timeout ; + DataStreamTrace = _DataStreamTrace ; + DeltaTime = _DeltaTime ; + cdebug << "GraphBase::StreamGraph:::StreamGraph _Timeout " << _Timeout << " _DataStreamTrace " << _DataStreamTrace << " _DeltaTime " << _DeltaTime + << endl ; +} + +bool GraphBase::StreamGraph::CreateStreamTopology( const char * aDirectory ) { + cdebug_in << "GraphBase::StreamGraph::CreateStreamTopology()" << endl; + int istream ; + for ( istream = 1 ; istream <= SubStreamGraphsNumber() ; istream++ ) { + ostringstream astr ; + astr << istream << ends ; + string filename = string( Name() ) + string( "_" ) + astr.str().c_str() ; + string fullfilename = aDirectory + filename + ".cpl" ; + ofstream f( fullfilename.c_str() ) ; + f << "DEBUT " << filename << endl ; + f << " TIMEOUT " << _Timeout << endl ; + f << " TRACE " << KindOfDataStreamTraceToString( _DataStreamTrace ) << endl ; + f << " DELTAT " << _DeltaTime << endl ; + f << endl ; + f << endl ; + f << "# Liste des codes" << endl ; + f << endl ; + map< string , GraphBase::Service * > aMapOfServiceNames = MapOfServiceNames() ; + map< string , GraphBase::Service * >::iterator aMapOfServiceNamesIterator ; + for ( aMapOfServiceNamesIterator = aMapOfServiceNames.begin() ; + aMapOfServiceNamesIterator != aMapOfServiceNames.end() ; aMapOfServiceNamesIterator++ ) { + GraphBase::Service * aService = aMapOfServiceNamesIterator->second ; + int n ; + for ( n = 0 ; n < GraphNodesSize() ; n++ ) { + if ( GetGraphNode( n )->HasDataStream() && GetChangeGraphNode( n )->SubStreamGraph() == istream ) { + if ( !strcmp( aService->ServiceName() , GetGraphNode( n )->ServiceName() ) ) { + f << " CODE " << aService->ServiceName() << endl ; + unsigned int j ; + cdebug << "CreateStreamTopology " << aService->ServiceName() << " InStreamParameter(" + << aService->ServiceInStreamParameter().length() << ") OutStreamParameter(" + << aService->ServiceOutStreamParameter().length() << ")" << endl ; + cdebug << aService->GetService() << endl ; + for ( j = 0 ; j < aService->ServiceInStreamParameter().length() ; j++ ) { + f << " " << aService->ServiceInStreamParameter()[ j ].Parametername << " " + << DataStreamDependencyToString( aService->ServiceInStreamParameter()[ j ].Parameterdependency ) << " IN " + << DataStreamToString( aService->ServiceInStreamParameter()[ j ].Parametertype ) << endl ; + } + for ( j = 0 ; j < aService->ServiceOutStreamParameter().length() ; j++ ) { + f << " " << aService->ServiceOutStreamParameter()[ j ].Parametername << " " + << DataStreamDependencyToString( aService->ServiceOutStreamParameter()[ j ].Parameterdependency ) << " OUT " + << DataStreamToString( aService->ServiceOutStreamParameter()[ j ].Parametertype ) << endl ; + } + f << " FIN #" << aService->ServiceName() << endl ; + f << endl ; + f << endl ; + break ; + } + } + } + } + f << endl ; + f << endl ; + f << "# Liste des instances" << endl ; + int j ; + for ( j = 0 ; j < GraphNodesSize() ; j++ ) { + if ( GetGraphNode( j )->HasDataStream() && GetChangeGraphNode( j )->SubStreamGraph() == istream ) { + f << endl ; + f << " INSTANCE " << GetGraphNode( j )->Name() << endl ; + f << " CODE " << GetGraphNode( j )->ServiceName() << endl ; + f << " EXEC \"" << GetGraphNode( j )->ServiceName() << "\"" << endl ; + f << " FIN" << endl ; + } + } + f << endl ; + f << endl ; + f << endl ; + f << endl ; + f << endl ; + f << "# Liste des liens" << endl ; + f << endl ; + f << " LIEN" << endl ; + for ( j = 0 ; j < GraphNodesSize() ; j++ ) { + if ( GetGraphNode( j )->HasDataStream() && GetChangeGraphNode( j )->SubStreamGraph() == istream ) { + int k ; + for ( k = 0 ; k < GetGraphNode( j )->GetNodeOutPortsSize() ; k++ ) { + if ( GetGraphNode( j )->GetNodeOutPort( k )->IsDataStream() ) { + long aNumberOfValues = ((GraphBase::OutDataStreamPort *) GetGraphNode( j )->GetNodeOutPort( k ))->NumberOfValues() ; + int n ; + for ( n = 0 ; n < GetGraphNode( j )->GetNodeOutPort( k )->InPortsSize() ; n++ ) { + SUPERV::KindOfSchema aKindOfSchema ; + SUPERV::KindOfInterpolation aKindOfInterpolation ; + SUPERV::KindOfExtrapolation aKindOfExtrapolation ; + ((GraphBase::InDataStreamPort *) GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n ))->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + f << " " << GetGraphNode( j )->Name() << "." + << GetGraphNode( j )->GetNodeOutPort( k )->PortName() ; + if ( aNumberOfValues != 0 ) { + f << " NIVEAU " << aNumberOfValues ; + } + f << " => " + << GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n )->NodeName() << "." + << GetGraphNode( j )->GetNodeOutPort( k )->InPorts( n )->PortName() + << " " << aKindOfSchema << " " << aKindOfInterpolation ; + if ( aKindOfExtrapolation != SUPERV::EXTRANULL ) { + f << " " << aKindOfExtrapolation ; + } + f << " ;" << endl ; + } + } + } + } + } + f << " FIN" << endl ; + f << endl ; + f << "FIN" << endl ; + } + cdebug_out << "GraphBase::StreamGraph::CreateStreamTopology()" << endl; + return true ; +} + +ostream & operator<< (ostream & f ,const SUPERV::KindOfDataStreamTrace & s ) { + switch (s) { + case SUPERV::WithoutTrace : + f << "WithoutTrace"; + break; + case SUPERV::SummaryTrace : + f << "SummaryTrace"; + break; + case SUPERV::DetailedTrace : + f << "DetailedTrace"; + break; + default : + f << "UndefinedKindOfDataStreamTrace"; + break; + } + + return f; +} + + diff --git a/src/GraphBase/DataFlowBase_StreamGraph.hxx b/src/GraphBase/DataFlowBase_StreamGraph.hxx new file mode 100644 index 0000000..55d65b9 --- /dev/null +++ b/src/GraphBase/DataFlowBase_StreamGraph.hxx @@ -0,0 +1,82 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_StreamGraph.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _DATAFLOWBASE_STREAMGRAPH_HXX +#define _DATAFLOWBASE_STREAMGRAPH_HXX + +#include "DataFlowBase_Graph.hxx" + +namespace GraphBase { + + class StreamGraph : public Graph { + + private: + +// Configuration : +// The name is the name of the graph + long _Timeout ; + SUPERV::KindOfDataStreamTrace _DataStreamTrace ; + double _DeltaTime ; + +// Total number of SubStreamGraphs + int _SubStreamGraphsNumber ; + + protected: + + public: + + StreamGraph() ; + + StreamGraph( CORBA::ORB_ptr ORB , + SALOME_NamingService* ptrNamingService , + const char * DataFlowName , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; + + StreamGraph( 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 , + int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; + + ~StreamGraph() ; + + bool SetStreamParams( const long Timeout , + const SUPERV::KindOfDataStreamTrace DataStreamTrace , + const double DeltaTime ) ; + void StreamParams( long & Timeout , + SUPERV::KindOfDataStreamTrace & DataStreamTrace , + double & DeltaTime ) const ; + + bool CreateStreamTopology( const char * aDirectory ) ; + + void SubStreamGraphsNumber( int SubStreamGraphsNumber ) { + _SubStreamGraphsNumber = SubStreamGraphsNumber ; } ; + long SubStreamGraphsNumber() const { + return _SubStreamGraphsNumber ; } ; + + }; + +}; + +ostream & operator<< (ostream &,const SUPERV::KindOfDataStreamTrace &); + +#endif diff --git a/src/GraphBase/DataFlowBase_StreamNode.cxx b/src/GraphBase/DataFlowBase_StreamNode.cxx new file mode 100644 index 0000000..04d3176 --- /dev/null +++ b/src/GraphBase/DataFlowBase_StreamNode.cxx @@ -0,0 +1,230 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_StreamNode.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; + +#include "DataFlowBase_StreamNode.hxx" + +GraphBase::StreamNode::StreamNode() : + GraphBase::PortsOfNode::PortsOfNode() { + _Name = NULL ; + _LinkedNodesSize = 0 ; + _LinkedStreamNodesSize = 0 ; + _HeadNode = false ; + _SubGraphNumber = 0 ; + _SubStreamGraphNumber = 0 ; + cdebug << "GraphBase::StreamNode::StreamNode " << this << " " << endl ; +} + +GraphBase::StreamNode::StreamNode( const char * NodeName ) : + GraphBase::PortsOfNode::PortsOfNode( NodeName ) { + if ( NodeName != NULLSTRING && strlen( NodeName ) ) { + _Name = new char[ strlen( NodeName )+1 ] ; + strcpy( _Name , NodeName ) ; + } + else { + _Name = NULLSTRING ; + } + _LinkedNodesSize = 0 ; + _LinkedStreamNodesSize = 0 ; + _HeadNode = false ; + _SubGraphNumber = 0 ; + _SubStreamGraphNumber = 0 ; + cdebug << "GraphBase::StreamNode::StreamNode " << NodeName << " " + << this << " " << endl ; +} + +GraphBase::StreamNode::~StreamNode() { + cdebug << "GraphBase::StreamNode::~StreamNode " << this << endl ; +} + +bool GraphBase::StreamNode::Name( const char * aName) { + cdebug_in << "GraphBase::StreamNode::Name " << _Name << endl; + if ( _Name ) { + cdebug << "GraphBase::StreamNode::ReName " << _Name << " --> " << aName << endl ; + delete [] _Name ; + } + _Name = new char[strlen(aName)+1] ; + strcpy( _Name , aName ) ; + cdebug_out << "GraphBase::StreamNode::Name " << _Name << endl; + return true ; +} + +void GraphBase::StreamNode::SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) { + int jnode ; + cdebug_in << Name() << " GraphBase::StreamNode::SetSubStreamGraph Level "<< Level() << " SortedIndex " + << SortedIndex() << " SubStreamGraphsNumber " << SubStreamGraphsNumber << " RetVal " << RetVal + << endl ; + if ( SubStreamGraph() == 0 || SubStreamGraph() == SubStreamGraphsNumber ) { + SubStreamGraph( SubStreamGraphsNumber ) ; + cdebug << Name() << " SubStreamGraph " << SubStreamGraph() << " SetSubStreamGraph LinkedStreamNodesSize " + << LinkedStreamNodesSize() << endl ; + for ( jnode = 0 ; jnode < LinkedStreamNodesSize() ; jnode++ ) { + if ( LinkedStreamNodes( jnode )->Level() > Level() || + ( LinkedStreamNodes( jnode )->Level() == Level() && + LinkedStreamNodes( jnode )->SortedIndex() > SortedIndex() ) ) { + LinkedStreamNodes( jnode )->SetSubStreamGraph( SubStreamGraphsNumber , RetVal ) ; + if ( RetVal != SubStreamGraphsNumber ) { + break ; + } + } + else if ( LinkedStreamNodes( jnode )->SubStreamGraph() == 0 ) { + LinkedStreamNodes( jnode )->SubStreamGraph( SubStreamGraphsNumber ) ; + cdebug << LinkedStreamNodes( jnode )->Name() << " SubStreamGraph " + << LinkedStreamNodes( jnode )->SubStreamGraph() << endl ; + } + else if ( LinkedStreamNodes( jnode )->SubStreamGraph() != SubStreamGraphsNumber ) { + cdebug << LinkedStreamNodes( jnode )->Name() << " SubStreamGraph " + << LinkedStreamNodes( jnode )->SubStreamGraph() << " != " << SubStreamGraphsNumber << endl ; + RetVal = LinkedStreamNodes( jnode )->SubStreamGraph() ; + break ; + } + } + } + else { + cdebug << Name() << " SubStreamGraph " << SubStreamGraph() << " != " << SubStreamGraphsNumber << endl ; + RetVal = SubStreamGraph() ; + } + + cdebug_out << Name() << "->GraphBase::StreamNode::SetSubStreamGraph RetVal " << RetVal << endl ; + return ; +} + +void GraphBase::StreamNode::AddLink( GraphBase::StreamNode * ToNode ) { + int index = GetLinkedNodeIndex( ToNode->Name() ) ; + if ( index < 0 ) { + cdebug << Name() << "->GraphBase::StreamNode::AddLinkedNode( " << ToNode->Name() + << " ) new LinkedNode " << endl ; + _LinkedNodes.resize( _LinkedNodesSize+1 ) ; + _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ; + _LinkedNodes[ _LinkedNodesSize ] = ToNode ; + _LinkedInPortsNumber[ _LinkedNodesSize ] = 1 ; + SetLinkedNodeIndex( ToNode->Name() , _LinkedNodesSize ) ; + index = _LinkedNodesSize ; + _LinkedNodesSize++ ; + } + else { + cdebug << Name() << "->GraphBase::StreamNode::AddLinkedNode( " << ToNode->Name() + << " ) old LinkedNode " << _LinkedNodes[index ]->Name() << endl ; + _LinkedInPortsNumber[ index ] += 1 ; + } + cdebug << Name() << "->GraphBase::StreamNode::AddLinkedNode( " << ToNode->Name() + << " ) LinkedNodesSize " << _LinkedNodesSize << " [ " << index + << " ] _LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] << endl ; +} + +bool GraphBase::StreamNode::RemoveLink( GraphBase::StreamNode * ToNode ) { + int index = GetLinkedNodeIndex( ToNode->Name() ) ; + if ( index >= 0 ) { + cdebug << "GraphBase::StreamNode::RemoveLink( to " << ToNode->Name() << " from " + << Name() << " index : " << index << " LinkedInPortsNumber " + << _LinkedInPortsNumber[ index ] << " - 1" << endl ; + _LinkedInPortsNumber[ index ] -= 1 ; + if ( _LinkedInPortsNumber[ index ] == 0 ) { + _LinkedNodesSize-- ; + cdebug << "GraphBase::StreamNode::RemoveLink new LinkedNodesSize " + << _LinkedNodesSize << " " << ToNode->Name() << " removed from " + << " linkednodes of " << Name() << endl ; + int i ; + for ( i = index ; i < _LinkedNodesSize ; i++ ) { + _LinkedNodes[ i ] = _LinkedNodes[ i+1 ] ; + _LinkedInPortsNumber[ i ] = _LinkedInPortsNumber[ i+1 ] ; + SetLinkedNodeIndex( _LinkedNodes[ i ]->Name() , i ) ; + } + DelLinkedNodeIndex( ToNode->Name() ) ; + _LinkedNodes.resize( _LinkedNodesSize+1 ) ; + _LinkedInPortsNumber.resize( _LinkedNodesSize+1 ) ; + } + } + else { + cdebug << " Error index " << index << endl ; + } + return (index >= 0 ) ; +} + +void GraphBase::StreamNode::ReNameLink( const char* OldNodeName , + const char* NewNodeName ) { + cdebug_in << "GraphBase::StreamNode::ReNameLink (" << OldNodeName << " , " + << NewNodeName << ")" << endl; + int index = GetLinkedNodeIndex( OldNodeName ) ; + if ( index >= 0 ) { +// _MapOfLinkedNodes.erase( OldNodeName ) ; + DelLinkedNodeIndex( OldNodeName ) ; + SetLinkedNodeIndex( NewNodeName , index ) ; + } + cdebug_out << "GraphBase::StreamNode::ReNameLink" << endl ; +} + +void GraphBase::StreamNode::AddStreamLink( GraphBase::StreamNode * ToNode ) { + int index = GetLinkedStreamNodeIndex( ToNode->Name() ) ; + if ( index < 0 ) { + cdebug_in << Name() << "->GraphBase::StreamNode::AddStreamLink( " << ToNode->Name() + << " ) new LinkedNode " << endl ; + _LinkedStreamNodes.resize( _LinkedStreamNodesSize+1 ) ; + _LinkedInStreamPortsNumber.resize( _LinkedStreamNodesSize+1 ) ; + _LinkedStreamNodes[ _LinkedStreamNodesSize ] = ToNode ; + _LinkedInStreamPortsNumber[ _LinkedStreamNodesSize ] = 1 ; + SetLinkedStreamNodeIndex( ToNode->Name() , _LinkedStreamNodesSize ) ; + index = _LinkedStreamNodesSize ; + _LinkedStreamNodesSize++ ; + } + else { + cdebug_in << Name() << "->GraphBase::StreamNode::AddStreamLink( " << ToNode->Name() + << " ) old LinkedNode " << _LinkedStreamNodes[index ]->Name() << endl ; + _LinkedInStreamPortsNumber[ index ] += 1 ; + } + cdebug_out << Name() << "->GraphBase::StreamNode::AddStreamLinkedNode( " << ToNode->Name() + << " ) LinkedStreamNodesSize " << _LinkedStreamNodesSize << " [ " << index + << " ] _LinkedInStreamPortsNumber " << _LinkedInStreamPortsNumber[ index ] << endl ; +} + +bool GraphBase::StreamNode::RemoveStreamLink( GraphBase::StreamNode * ToNode ) { + int index = GetLinkedStreamNodeIndex( ToNode->Name() ) ; + if ( index >= 0 ) { + cdebug << "GraphBase::StreamNode::RemoveStreamLink( to " << ToNode->Name() << " from " + << Name() << " index : " << index << " LinkedInStreamPortsNumber " + << _LinkedInStreamPortsNumber[ index ] << " - 1" << endl ; + _LinkedInStreamPortsNumber[ index ] -= 1 ; + if ( _LinkedInStreamPortsNumber[ index ] == 0 ) { + _LinkedStreamNodesSize-- ; + cdebug << "GraphBase::StreamNode::RemoveStreamLink new LinkedNodesSize " + << _LinkedStreamNodesSize << " " << ToNode->Name() << " removed from " + << " linkednodes of " << Name() << endl ; + int i ; + for ( i = index ; i < _LinkedStreamNodesSize ; i++ ) { + _LinkedStreamNodes[ i ] = _LinkedStreamNodes[ i+1 ] ; + _LinkedInStreamPortsNumber[ i ] = _LinkedInStreamPortsNumber[ i+1 ] ; + SetLinkedStreamNodeIndex( _LinkedStreamNodes[ i ]->Name() , i ) ; + } + DelLinkedStreamNodeIndex( ToNode->Name() ) ; + _LinkedStreamNodes.resize( _LinkedStreamNodesSize+1 ) ; + _LinkedInStreamPortsNumber.resize( _LinkedStreamNodesSize+1 ) ; + } + } + else { + cdebug << " Error index " << index << endl ; + } + return (index >= 0 ) ; +} + +void GraphBase::StreamNode::ReNameStreamLink( const char* OldNodeName , + const char* NewNodeName ) { + cdebug_in << "GraphBase::StreamNode::ReNameStreamLink (" << OldNodeName << " , " + << NewNodeName << ")" << endl; + int index = GetLinkedStreamNodeIndex( OldNodeName ) ; + if ( index >= 0 ) { +// _MapOfLinkedNodes.erase( OldNodeName ) ; + DelLinkedStreamNodeIndex( OldNodeName ) ; + SetLinkedStreamNodeIndex( NewNodeName , index ) ; + } + cdebug_out << "GraphBase::StreamNode::ReNameStreamLink" << endl ; +} + diff --git a/src/GraphBase/DataFlowBase_StreamNode.hxx b/src/GraphBase/DataFlowBase_StreamNode.hxx new file mode 100644 index 0000000..3a7b5b2 --- /dev/null +++ b/src/GraphBase/DataFlowBase_StreamNode.hxx @@ -0,0 +1,190 @@ +// SUPERV GraphBase : contains fondamental classes for Services, Input Ports, Output Ports Links and Nodes. +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : DataFlowBase_StreamNode.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _DATAFLOWBASE_STREAMNODE_HXX +#define _DATAFLOWBASE_STREAMNODE_HXX + +#include "DataFlowBase_PortsOfNode.hxx" + +namespace GraphBase { + + class StreamNode : public PortsOfNode { + + private: + + char * _Name ; + SUPERV::KindOfNode _Kind ; + +// Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node : + map< string , int > _MapOfLinkedNodes ; + int _LinkedNodesSize ; + vector _LinkedNodes ; + vector _LinkedInPortsNumber ; + +// Nodes with InStreamPort(s) linked to OutStreamport(s) of this node : +// NodeName <--> index of that linked node in _LinkedNodes + map< string , int > _MapOfLinkedStreamNodes ; + int _LinkedStreamNodesSize ; + vector _LinkedStreamNodes ; + vector _LinkedInStreamPortsNumber ; + + bool _HeadNode ; + int _LevelNumber ; + int _SortedIndex ; + + int _SubGraphNumber ; + int _SubStreamGraphNumber ; + + protected: + + int * _Graph_prof_debug ; + ofstream * _Graph_fdebug ; + + StreamNode() ; + + StreamNode( const char * NodeName ) ; + + StreamNode( int * Graph_prof_debug , + ofstream * Graph_fdebug ) ; + + virtual ~StreamNode() ; + + public: + + char * Name() const { return my_strdup( _Name ) ; } ; + const char *const * NamePtr() const { return &_Name ; } ; + bool Name( const char * aName ) ; + + SUPERV::KindOfNode Kind() const { + return _Kind; } ; + bool Kind( SUPERV::KindOfNode aKind) { + _Kind = aKind ; + return true ; } ; + const bool IsComputingNode() const { + return (Kind() == SUPERV::ComputingNode ) ; } ; + const bool IsFactoryNode() const { + return (Kind() == SUPERV::FactoryNode ) ; } ; + const bool IsOneOfGOTONodes() const { + return (Kind() == SUPERV::LoopNode || + Kind() == SUPERV::EndLoopNode || + Kind() == SUPERV::SwitchNode || + Kind() == SUPERV::EndSwitchNode || + Kind() == SUPERV::GOTONode ) ; } ; + const bool IsOneOfInLineNodes() const { + return (Kind() == SUPERV::InLineNode || IsOneOfGOTONodes() ) ; } ; + const bool IsInLineNode() const { + return (Kind() == SUPERV::InLineNode ) ; } ; + const bool IsDataFlowNode() const { + return (Kind() == SUPERV::DataFlowGraph ) ; } ; + const bool IsDataStreamNode() const { + return (Kind() == SUPERV::DataStreamGraph ) ; } ; + const bool IsLoopNode() const { + return (Kind() == SUPERV::LoopNode ) ; } ; + const bool IsEndLoopNode() const { + return (Kind() == SUPERV::EndLoopNode ) ; } ; + const bool IsSwitchNode() const { + return (Kind() == SUPERV::SwitchNode ) ; } ; + const bool IsEndSwitchNode() const { + return (Kind() == SUPERV::EndSwitchNode ) ; } ; + const bool IsGOTONode() const { + return (Kind() == SUPERV::GOTONode ) ; } ; + + int GetLinkedNodeIndex( const char * name ) { + int index = _MapOfLinkedNodes[ name ] -1 ; + if ( index >= 0 ) { + cdebug << "GetLinkedNodeIndex of " << name + << " in _MapOfLinkedNodes : " + << index << " Node " << hex << (void *) _LinkedNodes[ index ] + << dec << " '" << _LinkedNodes[ index ]->Name() << "'" + << endl ; + } + return index ; } ; + void SetLinkedNodeIndex( const char * name , const int index ) { + _MapOfLinkedNodes[ name ] = index +1 ; + cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : " + << index << " Node " << hex << (void *) _LinkedNodes[ index ] + << dec << " '" << _LinkedNodes[ index ]->Name() << "'" + << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1 + << endl ; + } ; + void DelLinkedNodeIndex( const char * name ) { + _MapOfLinkedNodes.erase( name ) ; } ; + + int LinkedNodesSize() const { return _LinkedNodesSize ; } ; + + const int LinkedInPortsNumber( int i ) const { return _LinkedInPortsNumber[ i ] ; } ; + + StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ; + + int GetLinkedStreamNodeIndex( const char * name ) { + int index = _MapOfLinkedStreamNodes[ name ] -1 ; + if ( index >= 0 ) { + cdebug << "GetLinkedStreamNodeIndex of " << name + << " in _MapOfLinkedStreamNodes : " + << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ] + << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'" + << endl ; + } + return index ; } ; + void SetLinkedStreamNodeIndex( const char * name , const int index ) { + _MapOfLinkedStreamNodes[ name ] = index +1 ; + cdebug << "SetLinkedStreamNodeIndex of " << name << " in _MapOfLinkedStreamNodes : " + << index << " Node " << hex << (void *) _LinkedStreamNodes[ index ] + << dec << " '" << _LinkedStreamNodes[ index ]->Name() << "'" + << " _MapOfLinkedStreamNodes " << _MapOfLinkedStreamNodes[ name ] - 1 + << endl ; + } ; + void DelLinkedStreamNodeIndex( const char * name ) { + _MapOfLinkedStreamNodes.erase( name ) ; } ; + + int LinkedStreamNodesSize() const { return _LinkedStreamNodesSize ; } ; + + const int LinkedInStreamPortsNumber( int i ) const { return _LinkedInStreamPortsNumber[ i ] ; } ; + + StreamNode * LinkedStreamNodes( int i ) const { return _LinkedStreamNodes[ i ] ; } ; + + void HeadNode( bool aHeadNode ) { _HeadNode = aHeadNode ; } ; + const bool IsHeadNode() const { return _HeadNode ; } ; + + int Level() { return _LevelNumber ; } ; + void Level( int LevelNumber ) { + _LevelNumber = LevelNumber ; } ; + + void SortedIndex( int aSortedIndex ) { + _SortedIndex = aSortedIndex ; } ; + int SortedIndex() const { + return _SortedIndex ; } ; + + void SetSubStreamGraph( int SubStreamGraphsNumber , int & RetVal ) ; + + int SubGraph() { return _SubGraphNumber ; } ; + void SubGraph( int SubGraphNumber ) { + _SubGraphNumber = SubGraphNumber ; } ; + + int SubStreamGraph() { return _SubStreamGraphNumber ; } ; + void SubStreamGraph( int SubStreamGraphNumber ) { + _SubStreamGraphNumber = SubStreamGraphNumber ; } ; + + void AddLink( StreamNode * aNode ) ; + bool RemoveLink( StreamNode * aNode ) ; + void ReNameLink( const char* OldNodeName , + const char* NewNodeName ) ; + + void AddStreamLink( StreamNode * aNode ) ; + bool RemoveStreamLink( StreamNode * aNode ) ; + void ReNameStreamLink( const char* OldNodeName , + const char* NewNodeName ) ; + + }; + +}; + +#endif diff --git a/src/GraphBase/DataFlowBase_XmlHandler.cxx b/src/GraphBase/DataFlowBase_XmlHandler.cxx index 3a6f82d..01a298c 100644 --- a/src/GraphBase/DataFlowBase_XmlHandler.cxx +++ b/src/GraphBase/DataFlowBase_XmlHandler.cxx @@ -115,7 +115,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, depth -= 1 ; #if TRACE - MESSAGE( " ==========endElement step[" << depth << "]=" + MESSAGE( " ====================endElement step[" << depth << "]=" << step[depth] << " qName " << qName << " fieldvalue '" << fieldvalue[depth] << "'") #endif @@ -186,7 +186,8 @@ bool GraphBase::XmlHandler::endElement( const QString&, step[3] = 0 ; aNode.theService.ServiceinParameter.length( 0 ) ; aNode.theService.ServiceoutParameter.length( 0 ) ; - aNode.theListOfParameters.resize( 0 ) ; + aNode.theListOfInDataStreams.resize( 0 ) ; + aNode.theListOfOutDataStreams.resize( 0 ) ; aNode.theListOfFuncName.resize( 0 ) ; aNode.theListOfPythonFunctions.resize( 0 ) ; break ; @@ -299,12 +300,45 @@ bool GraphBase::XmlHandler::endElement( const QString&, // kind ok sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theKind ) ; fieldvalue[depth] = NULLSTRING ; + if ( aNode.theKind != SUPERV::DataStreamGraph ) { + step[depth]++ ; + step[4] = 0 ; + } + break ; + } + else if ( qName == "streamgraph-timeout" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-3" , qName ) ; + sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theTimeout ) ; + fieldvalue[depth] = NULLSTRING ; +// step[depth]++ ; +// step[4] = 0 ; + break ; + } + else if ( qName == "streamgraph-datastreamtrace" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-3" , qName ) ; + sscanf( fieldvalue[depth].c_str() ,"%d" , (int * ) &aNode.theDataStreamTrace ) ; + fieldvalue[depth] = NULLSTRING ; +// step[depth]++ ; +// step[4] = 0 ; + break ; + } + else if ( qName == "streamgraph-deltatime" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth3-3" , qName ) ; + sscanf( fieldvalue[depth].c_str() ,"%lf" , (int * ) &aNode.theDeltaTime ) ; + fieldvalue[depth] = NULLSTRING ; step[depth]++ ; step[4] = 0 ; + break ; } - else - return returnfalse( this , "depth3-3" , qName ) ; - break ; + else { + step[depth]++ ; + step[4] = 0 ; + } +// return returnfalse( this , "depth3-3" , qName ) ; +// break ; case 4 : if ( qName == "coupled-node" ) { if ( fieldvalue[depth] == NULLSTRING ) @@ -335,7 +369,7 @@ bool GraphBase::XmlHandler::endElement( const QString&, return returnfalse( this , "depth3-5" , qName ) ; break ; case 6 : - if ( qName == "Parameter-list" ) { + if ( qName == "DataStream-list" || qName == "Parameter-list" ) { if ( fieldvalue[depth] != NULLSTRING ) return returnfalse( this , "depth3-6" , qName ) ; fieldvalue[depth] = NULLSTRING ; @@ -772,21 +806,23 @@ bool GraphBase::XmlHandler::endElement( const QString&, if ( qName == "inParameter" ) { if ( fieldvalue[depth] != NULLSTRING ) return returnfalse( this , "depth4-6" , qName ) ; - int size = aNode.theListOfParameters.size() ; - aNode.theListOfParameters.resize( size+1 ) ; - aNode.theListOfParameters[size].theInParameter = aParameter ; - step[depth]++ ; + int size = aNode.theListOfInDataStreams.size() ; + aNode.theListOfInDataStreams.resize( size+1 ) ; + aNode.theListOfInDataStreams[ size ] = anInDataStreamParameter ; + break ; // One more aParameter input } else - return returnfalse( this , "depth4-6" , qName ) ; - break ; + step[depth]++ ; +// return returnfalse( this , "depth4-6" , qName ) ; +// break ; case 7 : if ( qName == "outParameter" ) { if ( fieldvalue[depth] != NULLSTRING ) return returnfalse( this , "depth4-7" , qName ) ; - int size = aNode.theListOfParameters.size() ; - aNode.theListOfParameters[size-1].theOutParameter = aParameter ; + int size = aNode.theListOfOutDataStreams.size() ; + aNode.theListOfOutDataStreams.resize( size+1 ) ; + aNode.theListOfOutDataStreams[ size ] = anOutDataStreamParameter ; // One more aParameter output step[4] = 6 ; step[5] = 4 ; @@ -868,46 +904,103 @@ bool GraphBase::XmlHandler::endElement( const QString&, if ( qName == "inParameter-type" ) { if ( fieldvalue[depth] == NULLSTRING ) return returnfalse( this , "depth5-4" , qName ) ; - if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) { - aParameter.Parametertype = fieldvalue[depth].c_str() ; - } - else { - aParameter.Parametertype = "" ; - } + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theDataStreamParameter.Parametertype ) ; fieldvalue[depth] = NULLSTRING ; step[depth]++ ; +#if TRACE + cout << "InDataStreamParameter.inParameter-type " << anInDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" << step[depth] << endl ; +#endif + break ; } else - return returnfalse( this , "depth5-4" , qName ) ; - break ; + step[depth] = 6 ; +// return returnfalse( this , "depth5-4" , qName ) ; +// break ; case 5 : if ( qName == "inParameter-name" ) { if ( fieldvalue[depth] == NULLSTRING ) return returnfalse( this , "depth5-5" , qName ) ; if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) { - aParameter.Parametername = fieldvalue[depth].c_str() ; + anInDataStreamParameter.theDataStreamParameter.Parametername = fieldvalue[depth].c_str() ; } else { - aParameter.Parametername = "" ; + anInDataStreamParameter.theDataStreamParameter.Parametername = "" ; } fieldvalue[depth] = NULLSTRING ; - step[depth]++ ; +#if TRACE + cout << "InDataStreamParameter.inParameter-name " << anInDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" << step[depth] << endl ; +#endif +// step[depth]++ ; +// step[depth] = 4 ; + break ; } - else - return returnfalse( this , "depth5-5" , qName ) ; - break ; + else if ( qName == "inParameter-dependency" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-5" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theDataStreamParameter.Parameterdependency ) ; + fieldvalue[depth] = NULLSTRING ; +#if TRACE + cout << "InDataStreamParameter.inParameter-dependency " << anInDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" + << step[depth] << endl ; +#endif +// step[depth]++ ; +// step[depth] = 4 ; + break ; + } + else if ( qName == "inParameter-schema" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-5" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfSchema ) ; + fieldvalue[depth] = NULLSTRING ; +#if TRACE + cout << "InDataStreamParameter.inParameter-schema " << anInDataStreamParameter.theKindOfSchema << " step[" << depth << "]" + << step[depth] << endl ; +#endif +// step[depth]++ ; +// step[depth] = 4 ; + break ; + } + else if ( qName == "inParameter-interpolation" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-5" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfInterpolation ) ; + fieldvalue[depth] = NULLSTRING ; +#if TRACE + cout << "InDataStreamParameter.inParameter-interpolation " << anInDataStreamParameter.theKindOfInterpolation << " step[" << depth << "]" + << step[depth] << endl ; +#endif +// step[depth]++ ; +// step[depth] = 4 ; + break ; + } + else if ( qName == "inParameter-extrapolation" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-5" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anInDataStreamParameter.theKindOfExtrapolation ) ; + fieldvalue[depth] = NULLSTRING ; +// step[depth]++ ; + step[depth] = 4 ; +#if TRACE + cout << "InDataStreamParameter.inParameter-extrapolation " << anInDataStreamParameter.theKindOfExtrapolation << " step[" << depth << "]" + << step[depth] << endl ; +#endif + break ; + } +// else +// return returnfalse( this , "depth5-5" , qName ) ; +// break ; case 6 : if ( qName == "outParameter-type" ) { if ( fieldvalue[depth] == NULLSTRING ) return returnfalse( this , "depth5-6" , qName ) ; - if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) { - aParameter.Parametertype = fieldvalue[depth].c_str() ; - } - else { - aParameter.Parametertype = "" ; - } + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theDataStreamParameter.Parametertype ) ; fieldvalue[depth] = NULLSTRING ; - step[depth]++ ; +// step[depth]++ ; + step[depth] = 7 ; +#if TRACE + cout << "OutDataStreamParameter.outParameter-type " << anOutDataStreamParameter.theDataStreamParameter.Parametertype << " step[" << depth << "]" + << step[depth] << endl ; +#endif } else return returnfalse( this , "depth5-6" , qName ) ; @@ -917,13 +1010,42 @@ bool GraphBase::XmlHandler::endElement( const QString&, if ( fieldvalue[depth] == NULLSTRING ) return returnfalse( this , "depth5-7" , qName ) ; if ( strcmp( fieldvalue[depth].c_str() , "?" ) ) { - aParameter.Parametername = fieldvalue[depth].c_str() ; + anOutDataStreamParameter.theDataStreamParameter.Parametername = fieldvalue[depth].c_str() ; } else { - aParameter.Parametername = "" ; + anOutDataStreamParameter.theDataStreamParameter.Parametername = "" ; } fieldvalue[depth] = NULLSTRING ; - step[depth]++ ; +#if TRACE + cout << "OutDataStreamParameter.outParameter-name " << anOutDataStreamParameter.theDataStreamParameter.Parametername << " step[" << depth << "]" + << step[depth] << endl ; +#endif +// step[depth]++ ; +// step[depth] = 6 ; + } + else if ( qName == "outParameter-dependency" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-7" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theDataStreamParameter.Parameterdependency ) ; + fieldvalue[depth] = NULLSTRING ; +#if TRACE + cout << "OutDataStreamParameter.outParameter-dependency " << anOutDataStreamParameter.theDataStreamParameter.Parameterdependency << " step[" << depth << "]" + << step[depth] << endl ; +#endif +// step[depth]++ ; +// step[depth] = 6 ; + } + else if ( qName == "outParameter-values" ) { + if ( fieldvalue[depth] == NULLSTRING ) + return returnfalse( this , "depth5-7" , qName ) ; + sscanf( fieldvalue[depth].c_str() , "%d" , (int * ) &anOutDataStreamParameter.theNumberOfValues ) ; + fieldvalue[depth] = NULLSTRING ; +// step[depth]++ ; + step[depth] = 6 ; +#if TRACE + cout << "OutDataStreamParameter.outParameter-values " << anOutDataStreamParameter.theNumberOfValues << " step[" << depth << "]" + << step[depth] << endl ; +#endif } else return returnfalse( this , "depth5-7" , qName ) ; @@ -1042,6 +1164,9 @@ bool GraphBase::XmlHandler::endElement( const QString&, } } +#if TRACE + cout << "return from endElement " << qName << " step[" << depth << "]" << step[depth] << endl ; +#endif return TRUE; } diff --git a/src/GraphBase/DataFlowBase_XmlHandler.hxx b/src/GraphBase/DataFlowBase_XmlHandler.hxx index 9d00b72..5bfcdb9 100755 --- a/src/GraphBase/DataFlowBase_XmlHandler.hxx +++ b/src/GraphBase/DataFlowBase_XmlHandler.hxx @@ -54,6 +54,9 @@ namespace GraphBase { bool constructor ; GraphBase::SNode aNode ; SALOME_ModuleCatalog::ServicesParameter aParameter ; + GraphBase::InDataStreamParameter anInDataStreamParameter ; + GraphBase::OutDataStreamParameter anOutDataStreamParameter ; +// SALOME_ModuleCatalog::ServicesDataStreamParameter aDataStreamParameter ; SUPERV::ListOfStrings aPythonFunction ; GraphBase::SLink aLink ; // SALOME_SuperVisionBase::ServicesParameterValue aLinkValue ; diff --git a/src/GraphBase/Makefile.in b/src/GraphBase/Makefile.in index 17aec82..ba02798 100644 --- a/src/GraphBase/Makefile.in +++ b/src/GraphBase/Makefile.in @@ -40,9 +40,12 @@ EXPORT_HEADERS = \ DataFlowBase_Port.hxx \ DataFlowBase_DataPort.hxx \ DataFlowBase_InPort.hxx \ + DataFlowBase_InDataStreamPort.hxx \ DataFlowBase_OutPort.hxx \ + DataFlowBase_OutDataStreamPort.hxx \ DataFlowBase_Service.hxx \ DataFlowBase_PortsOfNode.hxx \ + DataFlowBase_StreamNode.hxx \ DataFlowBase_ComputingNode.hxx \ DataFlowBase_FactoryNode.hxx \ DataFlowBase_InLineNode.hxx \ @@ -53,6 +56,7 @@ EXPORT_HEADERS = \ DataFlowBase_EndOfSwitchNode.hxx \ DataFlowBase_DataNode.hxx \ DataFlowBase_XmlHandler.hxx \ + DataFlowBase_StreamGraph.hxx \ DataFlowBase_Graph.hxx # Libraries targets @@ -62,9 +66,12 @@ LIB_SRC = \ DataFlowBase_Port.cxx \ DataFlowBase_DataPort.cxx \ DataFlowBase_InPort.cxx \ + DataFlowBase_InDataStreamPort.cxx \ DataFlowBase_OutPort.cxx \ + DataFlowBase_OutDataStreamPort.cxx \ DataFlowBase_Service.cxx \ DataFlowBase_PortsOfNode.cxx \ + DataFlowBase_StreamNode.cxx \ DataFlowBase_ComputingNode.cxx \ DataFlowBase_FactoryNode.cxx \ DataFlowBase_InLineNode.cxx \ @@ -76,6 +83,7 @@ LIB_SRC = \ DataFlowBase_DataNode.cxx \ DataFlowBase_XmlHandler.cxx \ DataFlowBase_LoadXml.cxx \ + DataFlowBase_StreamGraph.cxx \ DataFlowBase_Graph.cxx LIB_CLIENT_IDL = Logger.idl \ @@ -92,12 +100,11 @@ 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 CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS= -L../../lib/salome $(CORBA_LIBS) -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace \ -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS) \ -L${KERNEL_ROOT_DIR}/lib/salome -#LDFLAGS= -L../../../lib $(CORBA_LIBS) -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -lCOSDynamic4 -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeLoggerServer -lc $(QT_MT_LIBS) +//LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) @CONCLUDE@ diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.cxx b/src/GraphEditor/DataFlowEditor_DataFlow.cxx index 73654b3..a02e77d 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.cxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.cxx @@ -46,8 +46,9 @@ GraphEditor::DataFlow::DataFlow() : GraphEditor::DataFlow::DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const char *DataFlowName , - const char * DebugFileName ) : - OutNode( ORB, ptrNamingService , DataFlowName , DebugFileName ) { + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ) : + OutNode( ORB, ptrNamingService , DataFlowName , DebugFileName , aKindOfNode ) { // cout << "GraphEditor::DataFlow::DataFlow(" ; cdebug_in << "GraphEditor::DataFlow::DataFlow(" ; if ( DataFlowName ) { diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.hxx b/src/GraphEditor/DataFlowEditor_DataFlow.hxx index 23e65b1..c405e0b 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.hxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.hxx @@ -49,7 +49,8 @@ namespace GraphEditor { DataFlow(); DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService * ptrNamingService , const char * DataFlowName , - const char * DebugFileName ); + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ); DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService * ptrNamingService , const SALOME_ModuleCatalog::Service& DataFlowService , const char * DataFlowComponentName , @@ -223,7 +224,8 @@ namespace GraphEditor { long LevelMax() ; SUPERV::ListOfStrings * LevelNodes(long aLevel ) ; long ThreadsMax() ; - long GraphsNumber() ; + long SubGraphsNumber() ; + long SubStreamGraphsNumber() ; void Executor(GraphExecutor::DataFlow * DataFlowExecutor ) ; GraphExecutor::DataFlow * GraphEditor::DataFlow::Executor() const ; diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.lxx b/src/GraphEditor/DataFlowEditor_DataFlow.lxx index 1a783e8..699c7a1 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.lxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.lxx @@ -44,14 +44,14 @@ inline char * GraphEditor::DataFlow::DataFlowInfo() { inline char * GraphEditor::DataFlow::DataNodeInfo() { ostringstream s; IsValid() ; - GraphBase::DataNode::DataNodeInfo( s ) ; + Graph()->DataNodeInfo( s ) ; return CORBA::string_dup( s.str().c_str() ); } inline char * GraphEditor::DataFlow::NodeInfo( const char * aNodeName ) { ostringstream s; - if ( GetGraphNode( aNodeName ) ) - GetGraphNode( aNodeName )->NodeInfo( s ) ; + if ( Graph()->GetGraphNode( aNodeName ) ) + Graph()->GetGraphNode( aNodeName )->NodeInfo( s ) ; else s << aNodeName << " not found" << ends ; return CORBA::string_dup( s.str().c_str() ); @@ -93,29 +93,29 @@ inline GraphBase::SGraph * GraphEditor::DataFlow::GetDataFlow() { // void DateModification() ; -inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const { - return GraphEditor::OutNode::GetInfo() ; -} ; +//inline GraphBase::SNode * GraphEditor::DataFlow::GetInfo() const { +// return GraphEditor::OutNode::GetInfo() ; +//} ; inline GraphBase::ListOfNodes * GraphEditor::DataFlow::GetNodes() const { - return GraphEditor::OutNode::GetNodes() ; + return Graph()->GetNodes() ; } ; inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetLinks() const { - return GraphEditor::OutNode::GetLinks() ; + return Graph()->GetLinks() ; } ; inline GraphBase::ListOfGraphs * GraphEditor::DataFlow::GetGraphs() const { - return GraphEditor::OutNode::GetGraphs() ; + return Graph()->GetGraphs() ; } ; inline GraphBase::ListOfLinks * GraphEditor::DataFlow::GetDatas() const { - return GraphEditor::OutNode::GetDatas() ; + return Graph()->GetDatas() ; } ; inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::GetService() { IsValid() ; - return GraphEditor::OutNode::GetService() ; + return Graph()->GetService() ; } ; inline GraphEditor::InNode * GraphEditor::DataFlow::AddNode( @@ -188,8 +188,8 @@ inline bool GraphEditor::DataFlow::ReNameNode( const char* OldNodeName , inline const SALOME_ModuleCatalog::Service * GraphEditor::DataFlow::NodeService( const char * aNodeName ) { - if ( GetGraphNode( aNodeName ) ) { - return GetGraphNode( aNodeName )->GetService() ; + if ( Graph()->GetGraphNode( aNodeName ) ) { + return Graph()->GetGraphNode( aNodeName )->GetService() ; } return NULL ; } @@ -242,16 +242,22 @@ inline bool GraphEditor::DataFlow::AddLink( const char* FromNodeName , const char* ToNodeName , const char* ToServiceParameterName , const CORBA::Any aValue ) { - if ( _ReadOnly ) { - return false ; + if ( !_ReadOnly ) { + GraphEditor::InNode * aFromNode = GetNode( FromNodeName ) ; + if ( aFromNode ) { + GraphBase::OutPort * anOutPort = aFromNode->GetChangeOutPort( FromServiceParameterName ) ; + if ( anOutPort ) { + CORBA::Any const * theValue = anOutPort->Value() ; // Keep the type ! + _EditedAfterExecution = true ; + return GraphEditor::OutNode::AddLink( FromNodeName , + FromServiceParameterName , + ToNodeName , + ToServiceParameterName , + *theValue ) ; + } + } } - CORBA::Any const * theValue = GetNode( FromNodeName )->GetOutPort( FromServiceParameterName )->Value() ; // Keep the type ! - _EditedAfterExecution = true ; - return GraphEditor::OutNode::AddLink( FromNodeName , - FromServiceParameterName , - ToNodeName , - ToServiceParameterName , - *theValue ) ; + return false ; } ; inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName , @@ -266,8 +272,7 @@ inline bool GraphEditor::DataFlow::GetLink(const char* ToNodeName , inline GraphBase::SLink * GraphEditor::DataFlow::GetLink( GraphBase::ComputingNode * aNode , const char* ToServiceParameterName ) { - return GraphBase::Graph::GetLink( aNode , - aNode->GetChangeInPort( ToServiceParameterName ) ) ; + return Graph()->GetLink( aNode , aNode->GetChangeInPort( ToServiceParameterName ) ) ; } inline bool GraphEditor::DataFlow::AddLinkCoord( @@ -410,8 +415,7 @@ inline bool GraphEditor::DataFlow::AddInputData( const char* ToNodeName , if ( !IsValid() ) { return false ; } - return GraphBase::Graph::AddInputData( ToNodeName , ToParameterName , - aValue ) ; + return Graph()->AddInputData( ToNodeName , ToParameterName , aValue ) ; } ; inline bool GraphEditor::DataFlow::AddInputSharedData(const char* ToNodeName1 , @@ -481,28 +485,35 @@ inline long GraphEditor::DataFlow::LevelMax() { if ( !IsValid() ) { return 0 ; } - return GraphBase::Graph::LevelMax() ; + return Graph()->LevelMax() ; } inline SUPERV::ListOfStrings * GraphEditor::DataFlow::LevelNodes(long aLevel ) { if ( !IsValid() ) { return ((SUPERV::ListOfStrings * ) NULL ) ; } - return GraphBase::Graph::LevelNodes( aLevel ) ; + return Graph()->LevelNodes( aLevel ) ; } inline long GraphEditor::DataFlow::ThreadsMax() { if ( !IsValid() ) { return 0 ; } - return GraphBase::Graph::ThreadsMax() ; + return Graph()->ThreadsMax() ; +} + +inline long GraphEditor::DataFlow::SubGraphsNumber() { + if ( !IsValid() ) { + return 0 ; + } + return Graph()->SubGraphsNumber() ; } -inline long GraphEditor::DataFlow::GraphsNumber() { +inline long GraphEditor::DataFlow::SubStreamGraphsNumber() { if ( !IsValid() ) { return 0 ; } - return GraphBase::Graph::GraphsNumber() ; + return StreamGraph()->SubStreamGraphsNumber() ; } inline void GraphEditor::DataFlow::Executor( diff --git a/src/GraphEditor/DataFlowEditor_InNode.cxx b/src/GraphEditor/DataFlowEditor_InNode.cxx index 28044aa..4dee936 100644 --- a/src/GraphEditor/DataFlowEditor_InNode.cxx +++ b/src/GraphEditor/DataFlowEditor_InNode.cxx @@ -191,8 +191,11 @@ GraphEditor::InNode::InNode( CORBA::ORB_ptr ORB, _InLineNode = (GraphBase::InLineNode *) _ComputingNode ; break ; } - case SUPERV::DataFlowNode : { - cdebug << "GraphEditor::InNode::InNode ERROR SUPERV::DataFlowNode : " << NodeName << endl ; + case SUPERV::DataFlowGraph : { + cdebug << "GraphEditor::InNode::InNode ERROR SUPERV::DataFlowGraph : " << NodeName << endl ; + } + case SUPERV::DataStreamGraph : { + cdebug << "GraphEditor::InNode::InNode ERROR SUPERV::DataStreamGraph : " << NodeName << endl ; } case SUPERV::UnknownNode : { cdebug << "GraphEditor::InNode::InNode ERROR SUPERV::UnknownNode : " << NodeName << endl ; diff --git a/src/GraphEditor/DataFlowEditor_InNode.hxx b/src/GraphEditor/DataFlowEditor_InNode.hxx index c94afc4..9352544 100644 --- a/src/GraphEditor/DataFlowEditor_InNode.hxx +++ b/src/GraphEditor/DataFlowEditor_InNode.hxx @@ -92,6 +92,8 @@ namespace GraphEditor { return _ComputingNode->IsOneOfGOTONodes() ; } ; const bool IsDataFlowNode() const { return _ComputingNode->IsDataFlowNode() ; } ; + const bool IsDataStreamNode() const { + return _ComputingNode->IsDataStreamNode() ; } ; const bool IsGOTONode() const { return _ComputingNode->IsGOTONode() ; } ; const bool IsLoopNode() const { @@ -183,18 +185,28 @@ namespace GraphEditor { return _ComputingNode->GetInfo() ; } ; GraphBase::InPort * AddInPort( const char * InputParameterName , - const char * InputParameterType ) { - return _InLineNode->AddInPort( InputParameterName , - InputParameterType ) ; } ; + const char * InputParameterType , + const SUPERV::KindOfPort aKindOfPort ) { + return _ComputingNode->AddInPort( InputParameterName , + InputParameterType , + aKindOfPort ) ; } ; GraphBase::OutPort * AddOutPort( const char * OutputParameterName , - const char * OutputParameterType ) { - return _InLineNode->AddOutPort( OutputParameterName , - OutputParameterType ) ; } ; + const char * OutputParameterType , + const SUPERV::KindOfPort aKindOfPort ) { + return _ComputingNode->AddOutPort( OutputParameterName , + OutputParameterType , + aKindOfPort ) ; } ; + int IncrDataStreamInPorts() { + return _ComputingNode->IncrDataStreamInPorts() ; + } ; + int IncrDataStreamOutPorts() { + return _ComputingNode->IncrDataStreamOutPorts() ; + } ; void DelInPort( const char * InputParameterName ) { - _InLineNode->DelInPort( InputParameterName ) ; } ; + _ComputingNode->DelInPort( InputParameterName ) ; } ; void DelOutPort( const char * OutputParameterName ) { - _InLineNode->DelOutPort( OutputParameterName ) ; } ; + _ComputingNode->DelOutPort( OutputParameterName ) ; } ; bool IsLinked(const char * ToServiceParameterName ) { return _ComputingNode->IsLinked( ToServiceParameterName ) ; } ; @@ -258,6 +270,8 @@ namespace GraphEditor { int SubGraph() { return _ComputingNode->SubGraph() ; } ; + int SubStreamGraph() { + return _ComputingNode->SubStreamGraph() ; } ; char * ComponentName() const { return _FactoryNode->ComponentName() ; } ; diff --git a/src/GraphEditor/DataFlowEditor_OutNode.cxx b/src/GraphEditor/DataFlowEditor_OutNode.cxx index cd7876c..202b157 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.cxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.cxx @@ -33,8 +33,8 @@ using namespace std; // Implementation de la classe GraphEditor::Graph -GraphEditor::OutNode::OutNode() : - Graph() { +GraphEditor::OutNode::OutNode() { +// Graph() { cdebug_in << "GraphEditor::OutNode::OutNode()" << endl; _Imported = false ; @@ -47,14 +47,28 @@ GraphEditor::OutNode::OutNode() : GraphEditor::OutNode::OutNode( CORBA::ORB_ptr ORB , SALOME_NamingService * ptrNamingService , const char * DataFlowName , - const char * DebugFileName ) : - Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) { + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ) { +// Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) { + Set_prof_debug( ORB , DebugFileName ) ; cdebug_in << "GraphEditor::OutNode::OutNode(" ; if ( DataFlowName ) { cdebug << DataFlowName ; } cdebug << ")" << endl; + if ( aKindOfNode == SUPERV::DataFlowGraph ) { + _StreamGraph = NULL ; +// _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ; + _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , + _prof_debug , _fdebug ) ; + } + else if ( aKindOfNode == SUPERV::DataStreamGraph ) { +// _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;; + _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , + _prof_debug , _fdebug ) ; + _Graph = _StreamGraph ; + } _Orb = CORBA::ORB::_duplicate( ORB ) ; _Imported = false ; _Valid = false ; @@ -77,13 +91,34 @@ GraphEditor::OutNode::OutNode( 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 ) { - + const char * DebugFileName ) { +// Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName , +// DataFlowInterfaceName , DataFlowName , DataFlowkind , +// DataFlowFirstCreation , DataFlowLastModification , +// DataFlowEditorRelease , DataFlowAuthor , +// DataFlowComputer , DataFlowComment , DebugFileName ) { + Set_prof_debug( ORB , DebugFileName ) ; + + if ( DataFlowkind == SUPERV::DataFlowGraph ) { + _StreamGraph = NULL ; + _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName , + DataFlowInterfaceName , DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , + DataFlowComputer , DataFlowComment , + _prof_debug , _fdebug ) ; +// DataFlowComputer , DataFlowComment , DebugFileName ) ; + } + else if ( DataFlowkind == SUPERV::DataStreamGraph ) { + _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName , + DataFlowInterfaceName , DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , + DataFlowComputer , DataFlowComment , + _prof_debug , _fdebug ) ; +// DataFlowComputer , DataFlowComment , DebugFileName ) ; + _Graph = _StreamGraph ; + } _Orb = CORBA::ORB::_duplicate( ORB ) ; _Imported = false ; _Valid = false ; @@ -97,28 +132,45 @@ GraphEditor::OutNode::~OutNode() { // delete _GT ; } +void GraphEditor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB , + const char * DebugFileName ) { + _Graph_prof_debug = 0 ; + _prof_debug = 0 ; + if ( DebugFileName ) { + _fdebug = new ofstream( DebugFileName ); + SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ; + MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl) + } +} + bool GraphEditor::OutNode::LoadDataFlow( const GraphBase::SGraph *aDataFlow ) { bool RetVal = false ; cdebug_in << "GraphEditor::OutNode::LoadDataFlow() " << aDataFlow->Info.theName.c_str() - << endl; + << " GraphNodesSize " << Graph()->GraphNodesSize() << endl; if ( !_Imported ) { RetVal = LoadInfo( aDataFlow->Info ) ; _Imported = true ; } - else { + else if ( Graph()->IsDataStreamNode() || aDataFlow->Info.theKind == SUPERV::DataFlowGraph ) { RetVal = true ; } + cdebug << "GraphEditor::OutNode::LoadDataFlow() _Imported " << _Imported << " RetVal " << RetVal << endl; map< string , int > aMapOfNodes ; - if ( RetVal ) + if ( RetVal ) { + cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadNodes GraphNodesSize " << Graph()->GraphNodesSize() << endl; RetVal = LoadNodes( aMapOfNodes , aDataFlow->Nodes ) ; - if ( RetVal ) + } + if ( RetVal ) { + cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadLinks GraphNodesSize " << Graph()->GraphNodesSize() << endl; RetVal = LoadLinks( aMapOfNodes , aDataFlow->Links ) ; + } if ( RetVal ) { Valid() ; + cdebug << "GraphEditor::OutNode::LoadDataFlow() LoadDatas GraphNodesSize " << Graph()->GraphNodesSize() << endl; RetVal = LoadDatas( aMapOfNodes , aDataFlow->Datas ) ; } - cdebug_out << "GraphEditor::OutNode::LoadDataFlow" << endl; + cdebug_out << "GraphEditor::OutNode::LoadDataFlow done GraphNodesSize " << Graph()->GraphNodesSize() << endl; return RetVal ; } @@ -130,8 +182,8 @@ bool GraphEditor::OutNode::LoadXml( const char* myFileName ) { _Imported = true ; RetVal = true ; } - else if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) { - cdebug_in << "GraphEditor::OutNode::LoadXml() " << endl; + else if ( Graph()->LoadXml( _Orb , myFileName , aDataFlow ) ) { + cdebug_in << "GraphEditor::OutNode::LoadXml() " << myFileName << endl; RetVal = LoadDataFlow( &aDataFlow ) ; cdebug_out << "GraphEditor::OutNode::LoadXml " << RetVal << endl; } @@ -139,43 +191,84 @@ bool GraphEditor::OutNode::LoadXml( const char* myFileName ) { } bool GraphEditor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) { + bool RetVal = false ; 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() ) ; + if ( Graph()->IsDataStreamNode() || aDataFlowInfo.theKind == SUPERV::DataFlowGraph ) { + Graph()->Name( aDataFlowInfo.theName.c_str() ) ; +// Graph()->Kind( aDataFlowInfo.theKind ) ; + cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind + << " Kind() " << Graph()->Kind() << endl ; + if ( Graph()->IsDataStreamNode() ) { + Graph()->Kind( SUPERV::DataStreamGraph ) ; + StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ; + } + else { + Graph()->Kind( SUPERV::DataFlowGraph ) ; + } + Graph()->SetService( aDataFlowInfo.theService ) ; + Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ; + Graph()->LastModification( aDataFlowInfo.theLastModification ) ; + Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ; + Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ; +// Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ; + Graph()->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 ; +// Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ; + RetVal = true ; + } + else { + Graph()->Kind( aDataFlowInfo.theKind ) ; + cdebug << "GraphEditor::OutNode::LoadInfo aDataFlowInfo.Kind " << aDataFlowInfo.theKind + << " != IsDataStreamNode() " << Graph()->IsDataStreamNode() << endl ; + } + cdebug_out << "GraphEditor::OutNode::LoadInfo " << RetVal << endl ; + return RetVal ; } bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes , const GraphBase::ListOfNodes &aListOfNodes ) { GraphEditor::InNode * anInNode ; - cdebug_in << "GraphEditor::OutNode::LoadNodes" << endl ; + cdebug_in << "GraphEditor::OutNode::LoadNodes " << endl ; int i ; for ( i = 0 ; i < (int ) aListOfNodes.size() ; i++ ) { GraphBase::SNode aNode = aListOfNodes[ i ] ; const char * aNodeName = aNode.theName.c_str() ; + cout << "GraphEditor::OutNode::LoadNodes " << aNodeName << " " + << aNode.theListOfInDataStreams.size() << " InDataStreams " + << aNode.theListOfOutDataStreams.size() << " OutDataStreams " + << " _prof_debug " << _prof_debug << endl ; + cdebug << "GraphEditor::OutNode::LoadNodes " << aNodeName << " " + << aNode.theListOfInDataStreams.size() << " InDataStreams " + << aNode.theListOfOutDataStreams.size() << " OutDataStreams " + << endl ; 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 ; + if ( Graph()->GetGraphNode( aNode.theName.c_str() ) ) { + aNodeName = NULLSTRING ; + } + + aNode.theService.ServiceinDataStreamParameter.length( aNode.theListOfInDataStreams.size() ) ; + aNode.theService.ServiceoutDataStreamParameter.length( aNode.theListOfOutDataStreams.size() ) ; + unsigned int j ; + for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) { + aNode.theService.ServiceinDataStreamParameter[ j ].Parametername = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername , + aNode.theService.ServiceinDataStreamParameter[ j ].Parametertype = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype , + aNode.theService.ServiceinDataStreamParameter[ j ].Parameterdependency = aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency ; + } + for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) { + aNode.theService.ServiceoutDataStreamParameter[ j ].Parametername = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername , + aNode.theService.ServiceoutDataStreamParameter[ j ].Parametertype = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype , + aNode.theService.ServiceoutDataStreamParameter[ j ].Parameterdependency = aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency ; } + anInNode = AddNode( aNode.theService , aNode.theListOfFuncName , aNode.theListOfPythonFunctions , @@ -188,12 +281,12 @@ bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes , aNode.theComment.c_str() , aNode.theCoords.theX , aNode.theCoords.theY ) ; string * aNodetheName = new string( aNode.theName ) ; - aMapOfNodes[ *aNodetheName ] = GetGraphNodeIndex( anInNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = Graph()->GetGraphNodeIndex( anInNode->Name() ) ; if ( anInNode->IsOneOfInLineNodes() ) { anInNode->GraphEditor::InNode::InLineNode()->DefPortsOfNode( _Orb , aNode.theService , anInNode->NamePtr() , anInNode->Kind() , - Graph_prof_debug() , Graph_fdebug() ) ; + _prof_debug , _fdebug ) ; GraphBase::InLineNode * aINode = anInNode->InLineNode() ; GraphBase::LoopNode * aLNode = NULL ; if ( aINode->IsLoopNode() ) { @@ -211,6 +304,35 @@ bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes , *aNode.theListOfPythonFunctions[ 0 ] ) ; } } + + for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) { + GraphBase::InPort * anInPort ; + if ( anInNode->IsOneOfInLineNodes() ) { + anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername , + aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype , + aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency , + SUPERV::DataStreamParameter ) ; + } + else { + anInPort = anInNode->ComputingNode()->GetChangeInPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername ) ; + } + ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema , + aNode.theListOfInDataStreams[ j ].theKindOfInterpolation , + aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ; + } + for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) { + GraphBase::OutPort * anOutPort ; + if ( anInNode->IsOneOfInLineNodes() ) { + anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername , + aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype , + aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency , + SUPERV::DataStreamParameter ) ; + } + else { + anOutPort = anInNode->ComputingNode()->GetChangeOutPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername ) ; + } + ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ; + } delete aNodetheName ; if ( !anInNode ) { return false ; @@ -220,11 +342,11 @@ bool GraphEditor::OutNode::LoadNodes(map< string , int > & aMapOfNodes , 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() ; + anInNode = (GraphEditor::InNode * ) Graph()->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() ) ) ; + aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ; + aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ; } } cdebug_out << "GraphEditor::OutNode::LoadNodes" << endl ; @@ -244,14 +366,16 @@ bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes , cdebug << "LoadLinks " << aLinkFromNodeName->c_str() << "( " << aLink.FromServiceParameterName.c_str() << " ) --> " << aLinkToNodeName->c_str() << "( " - << aLink.FromServiceParameterName.c_str() << " )" << endl ; - if ( GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) && - GetGraphNode( aMapOfNodes[ aLinkToNodeName->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.ToServiceParameterName.c_str() << " )" << endl ; + if ( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) && + Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] ) ) { + GraphBase::ComputingNode * aFromNode = (GraphBase::ComputingNode * ) Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] ) ; + const GraphBase::OutPort * anOutPort = aFromNode->GetOutPort( aLink.FromServiceParameterName.c_str() ) ; + RetVal = AddLink( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + aLink.FromServiceParameterName.c_str() , + Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + aLink.ToServiceParameterName.c_str() , + *anOutPort->Value() ) ; } else { RetVal = false ; @@ -261,13 +385,13 @@ bool GraphEditor::OutNode::LoadLinks(map< string , int > & aMapOfNodes , break ; else { for ( j = 0 ; j < (int ) 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 ) ; + RetVal = AddLinkCoord( Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + aLink.FromServiceParameterName.c_str() , + Graph()->GetGraphNode( aMapOfNodes[ aLink.ToNodeName.c_str() ] )->Name() , + aLink.ToServiceParameterName.c_str() , + j + 1 , + aLink.aListOfCoords[j].theX , + aLink.aListOfCoords[j].theY ) ; if ( !RetVal ) break ; } @@ -287,10 +411,10 @@ bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes , int i ; for ( i = 0 ; i < (int ) aListOfDatas.size() ; i++ ) { GraphBase::SLink aLink = aListOfDatas[ i ] ; - if ( !strcmp( aLink.FromNodeName.c_str() , Name() ) ) { + if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) ) { cdebug << "GraphEditor::OutNode::LoadDatas Warning " << aLink.FromNodeName.c_str() - << " and " << aLink.ToNodeName.c_str() << " differents from " << Name() + << " and " << aLink.ToNodeName.c_str() << " differents from " << Graph()->Name() << endl ; } string * aLinkFromNodeName = new string( aLink.FromNodeName.c_str() ) ; @@ -299,9 +423,9 @@ bool GraphEditor::OutNode::LoadDatas(map< string , int > & aMapOfNodes , // << 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 ) ; + RetVal = Graph()->AddInputData( Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + aLink.ToServiceParameterName.c_str() , + aLink.aLinkValue ) ; delete aLinkFromNodeName ; delete aLinkToNodeName ; if ( !RetVal ) @@ -341,10 +465,18 @@ bool GraphEditor::OutNode::SavePy( const char* filename ) { GraphBase::SGraph * GraphEditor::OutNode::GetDataFlow() { GraphBase::SGraph * aDataFlow = new GraphBase::SGraph; - aDataFlow->Info = *GetInfo() ; - aDataFlow->Nodes = *GetNodes() ; - aDataFlow->Links = *GetLinks( true ) ; - aDataFlow->Datas = *GetDatas() ; + if ( Graph()->IsDataFlowNode() ) { + aDataFlow->Info = *Graph()->GetInfo() ; + aDataFlow->Nodes = *Graph()->GetNodes() ; + aDataFlow->Links = *Graph()->GetLinks( true ) ; + aDataFlow->Datas = *Graph()->GetDatas() ; + } + else { + aDataFlow->Info = *StreamGraph()->GetInfo() ; + aDataFlow->Nodes = *StreamGraph()->GetNodes() ; + aDataFlow->Links = *StreamGraph()->GetLinks( true ) ; + aDataFlow->Datas = *StreamGraph()->GetDatas() ; + } return aDataFlow ; } @@ -359,21 +491,21 @@ void GraphEditor::OutNode::DateModification() { aLastModificationDate.Day = Tm->tm_mday; aLastModificationDate.Month = Tm->tm_mon + 1; aLastModificationDate.Year = Tm->tm_year + 1900; - LastModification( aLastModificationDate ) ; + Graph()->LastModification( aLastModificationDate ) ; } void GraphEditor::OutNode::Coordinates( const char* NodeName , const int X , const int Y ) { - ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ; + ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->Coordinates( X , Y ) ; } const int GraphEditor::OutNode::XCoordinate( const char* NodeName ) { - return ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->XCoordinate() ; + return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->XCoordinate() ; } const int GraphEditor::OutNode::YCoordinate( const char* NodeName ) { - return ((GraphEditor::InNode * ) GetChangeGraphNode( NodeName ))->YCoordinate() ; + return ((GraphEditor::InNode * ) Graph()->GetChangeGraphNode( NodeName ))->YCoordinate() ; } GraphEditor::InNode * GraphEditor::OutNode::AddNode( @@ -394,17 +526,21 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( const int NodeY ) { cdebug_in << "GraphEditor::OutNode::AddNode( " ; if ( NodeComponentName != NULLSTRING && strlen( NodeComponentName ) ) { - cdebug << NodeComponentName << " , " ; + cdebug << "Component('" << NodeComponentName << "') , Node('" ; } else { cdebug << "NodeComponentName[NULL] )" << endl; } + if ( theNodeName == NULL ) { + theNodeName = NULLSTRING ; + } if ( theNodeName != NULLSTRING && strlen( theNodeName ) ) { - cdebug << theNodeName << " )" << endl; + cdebug << theNodeName << "' )" ; } else { - cdebug << "NodeName[NULL] )" << endl; + cdebug << "NodeName[NULLSTRING]' )" ; } + cdebug << " " << NodeKindOfNode << endl ; char * RetVal = NULLSTRING ; GraphEditor::InNode *Nd = NULL ; char * aNodeName = NULL ; @@ -443,13 +579,13 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( if ( theNodeName == NULLSTRING || strlen( theNodeName ) == 0 ) { aNodeName = new char[ strlen( NodeService.ServiceName )+1 ] ; strcpy( aNodeName , NodeService.ServiceName ) ; - if ( GetGraphNode( NodeService.ServiceName ) ) { + if ( Graph()->GetGraphNode( NodeService.ServiceName ) ) { GeneratedName = true ; - while ( GetGraphNode( aNodeName ) ) { + while ( Graph()->GetGraphNode( aNodeName ) ) { if ( aNodeName ) { delete [] aNodeName ; } - int num = GetServiceNameNumber( NodeService.ServiceName ) ; + int num = Graph()->GetServiceNameNumber( NodeService ) ; ostringstream astr ; astr << num << ends ; const char * n_instance = astr.str().c_str() ; @@ -463,13 +599,13 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( } } else { - if ( GetGraphNode( theNodeName ) == NULL ) { + if ( Graph()->GetGraphNode( theNodeName ) == NULL ) { aNodeName = new char[ strlen( theNodeName )+1 ] ; strcpy( aNodeName , theNodeName ) ; } } if ( aNodeName != NULLSTRING ) { - Nd = new GraphEditor::InNode( _Orb , NamingService() , + Nd = new GraphEditor::InNode( _Orb , Graph()->NamingService() , aFuncName , aPythonFunction , NodeService , NodeComponentName , NodeInterfaceName , aNodeName , NodeKindOfNode , @@ -477,10 +613,31 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( NodeEditorRelease , NodeAuthor , NodeComputer , NodeComment , GeneratedName , NodeX , NodeY , - Graph_prof_debug() , Graph_fdebug() ) ; + _prof_debug , _fdebug ) ; // MESSAGE( "GraphEditor::OutNode::AddNode " << hex << (void *) Nd << dec ); // if ( GraphBase::Graph::AddNode( Nd ) ) { - if ( GraphBase::Graph::AddNode( Nd->ComputingNode() ) ) { + + if ( Graph()->IsDataStreamNode() && ( Nd->IsComputingNode() || Nd->IsFactoryNode() ) ) { + unsigned int i ; + for ( i = 0 ; i < NodeService.ServiceinDataStreamParameter.length() ; i++ ) { + GraphBase::InDataStreamPort * aDataStreamPort ; + aDataStreamPort = Nd->ComputingNode()->AddInDataStreamPort( + my_strdup( NodeService.ServiceinDataStreamParameter[i].Parametername ) , + NodeService.ServiceinDataStreamParameter[i].Parametertype , + NodeService.ServiceinDataStreamParameter[i].Parameterdependency , + SUPERV::DataStreamParameter ) ; + } + for ( i = 0 ; i < NodeService.ServiceoutDataStreamParameter.length() ; i++ ) { + GraphBase::OutDataStreamPort * aDataStreamPort ; + aDataStreamPort = Nd->ComputingNode()->AddOutDataStreamPort( + my_strdup( NodeService.ServiceoutDataStreamParameter[i].Parametername ) , + NodeService.ServiceoutDataStreamParameter[i].Parametertype , + NodeService.ServiceoutDataStreamParameter[i].Parameterdependency , + SUPERV::DataStreamParameter ) ; + } + } + + if ( Graph()->AddNode( Nd->ComputingNode() ) ) { DateModification() ; RetVal = Nd->Name() ; } @@ -489,7 +646,7 @@ GraphEditor::InNode * GraphEditor::OutNode::AddNode( } } else { - cdebug << "NodeName is NULL or already exists." << endl ; + cdebug << "ERROR NodeName is NULL or already exists." << endl ; } // delete [] aNodeName ; cdebug_out << "GraphEditor::OutNode::AddNode" << endl; @@ -504,15 +661,15 @@ bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName , const int nXY , const int* X , const int* Y ) { - GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName , - ToServiceParameterName ) ; + GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName , + ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ; } else { return anInPort->AddCoord( nXY , X , Y ) ; @@ -528,15 +685,15 @@ bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName , const int index , const int X , const int Y ) { - GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName , - ToServiceParameterName ) ; + GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName , + ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ; } else { return anInPort->AddCoord( index , X , Y ) ; @@ -552,15 +709,15 @@ bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName , const int index , const int X , const int Y ) { - GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName , - ToServiceParameterName ) ; + GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName , + ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ; } else { return anInPort->ChangeCoord( index , X , Y ) ; @@ -574,15 +731,15 @@ bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName , const char* ToNodeName , const char* ToServiceParameterName , const int index ) { - GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName , - ToServiceParameterName ) ; + GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName , + ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ; } else { return anInPort->RemoveCoord( index ) ; @@ -595,14 +752,14 @@ int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName , const char* FromServiceParameterName , const char* ToNodeName , const char* ToServiceParameterName ) { - const GraphBase::InPort * anInPort = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ; + const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ; } else { return anInPort->GetCoord() ; @@ -616,14 +773,14 @@ bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName , const char* ToNodeName , const char* ToServiceParameterName , int *X , int *Y ) { - const GraphBase::InPort * anInPort = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ; + const GraphBase::InPort * anInPort = Graph()->GetInPort( ToNodeName , ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ; } else { return anInPort->GetCoord( X , Y ) ; @@ -637,15 +794,15 @@ bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName , const char* ToNodeName , const char* ToServiceParameterName , const int index , long &X , long &Y ) { - GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName , - ToServiceParameterName ) ; + GraphBase::InPort * anInPort = Graph()->GetChangeInPort( ToNodeName , + ToServiceParameterName ) ; // cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName // << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ; if ( anInPort ) { if ( anInPort->IsEndSwitch() ) { // cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName // << " )" << endl ; - return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ; + return Graph()->GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ; } else { return anInPort->GetCoord( index , X , Y ) ; @@ -659,7 +816,7 @@ bool GraphEditor::OutNode::AddInputData( const char* ToNodeName1 , const char* ToNodeName2 , const char* ToParameterName2 ) { cdebug_in << "GraphEditor::OutNode::AddInputData" << endl; - bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 , + bool RetVal = Graph()->AddInputData( ToNodeName1 , ToParameterName1 , ToNodeName2 , ToParameterName2 ) ; @@ -675,19 +832,22 @@ bool GraphEditor::OutNode::Valid() { cdebug_in << "GraphEditor::OutNode::Valid" << endl; _Executable = false ; - CreateService() ; + Graph()->CreateService() ; - if ( !Sort() ) { + int SubStreamGraphsNumber = 0 ; + if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { cdebug << "This DataFlow is not valid." << endl ; return false ; } - + if ( Graph()->IsDataStreamNode() ) { + StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; + } // CreateService() ; - InLineServices() ; + Graph()->InLineServices() ; - ComputingNodes() ; + Graph()->ComputingNodes() ; _Valid = true ; @@ -698,7 +858,7 @@ bool GraphEditor::OutNode::Valid() { bool GraphEditor::OutNode::Executable() { cdebug_in << "GraphEditor::OutNode::Executable" << endl; bool NewLink ; - if ( LinkLoopNodes( NewLink ) ) { + if ( Graph()->LinkLoopNodes( NewLink ) ) { if ( NewLink ) { _Valid = false ; } @@ -713,13 +873,17 @@ bool GraphEditor::OutNode::Executable() { if ( !IsValid() ) { return false ; } - if ( DataServerNodes() ) + if ( Graph()->DataServerNodes() ) _Executable = true ; else { cdebug << "This DataFlow is not executable." << endl ; _Executable = false ; } + if ( _Executable && Graph()->IsDataStreamNode() ) { + StreamGraph()->CreateStreamTopology( "/tmp/" ) ; + } + cdebug_out << "GraphEditor::OutNode::Executable" << endl; return _Executable ; } @@ -729,7 +893,7 @@ const CORBA::Any *GraphEditor::OutNode::GetInData( const char * ToParameterName ) { // cdebug_in << "GraphEditor::OutNode::GetInData " << ToNodeName // << " " << ToParameterName << endl ; - const CORBA::Any * retdata = PortInData( ToNodeName , ToParameterName ) ; + const CORBA::Any * retdata = Graph()->PortInData( ToNodeName , ToParameterName ) ; // cdebug_out << "GraphEditor::OutNode::GetInData" << endl ; return retdata ; } @@ -739,7 +903,7 @@ const CORBA::Any *GraphEditor::OutNode::GetOutData( const char * FromParameterName ) { // cdebug_in << "GraphEditor::OutNode::GetOutData " << FromNodeName // << " " << FromParameterName << endl ; - const CORBA::Any * retdata = PortOutData( FromNodeName , FromParameterName ) ; + const CORBA::Any * retdata = Graph()->PortOutData( FromNodeName , FromParameterName ) ; // cdebug_out << "GraphEditor::OutNode::GetOutData" << endl ; return retdata ; } @@ -748,6 +912,9 @@ const CORBA::Any *GraphEditor::OutNode::GetOutData( bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & link , GraphBase::SLink aLink , bool wdata ) const { + cdebug_in << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName + << "(" << aLink.FromServiceParameterName << ") --> " + << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" << endl ; QDomElement fromnodename = Graph.createElement( "fromnode-name" ) ; QDomText aField ; if ( strlen( aLink.FromNodeName.c_str() ) ) { @@ -892,30 +1059,47 @@ bool GraphEditor::OutNode::LinkSaveXML( QDomDocument & Graph , QDomElement & lin // f << Tabs << " " << endl ; } // f << Tabs << "" << endl ; + cdebug_out << "GraphEditor::OutNode::LinkSaveXML " << aLink.FromNodeName + << "(" << aLink.FromServiceParameterName << ") --> " + << aLink.ToNodeName << "(" << aLink.ToServiceParameterName << ")" + << endl ; return true ; } bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName , GraphBase::SLink aLink , - bool intervar , bool wdata ) const { + bool fromparam , bool toparam , + 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 ; +// if ( intervar ) { +// f << "O" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() +// << " = " +// << aLink.FromNodeName.c_str() << ".GetOutPort( '" +// << aLink.FromServiceParameterName.c_str() +// << "' )" << endl ; +// } + f << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() + << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() ; + if ( ((GraphBase::Graph *) Graph())->GetChangeGraphNode( aLink.FromNodeName.c_str() )->GetChangeOutPort( aLink.FromServiceParameterName.c_str() )->IsDataStream() ) { + f << " = " << aGraphName << ".StreamLink( " ; } - 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 << " = " << aGraphName << ".Link( " ; + } +// if ( !fromparam ) { + f << "O" ; +// } + f << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() << " , " ; +// if ( !toparam ) { + f << "I" ; +// } + f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << " )" << endl ; } else { - f << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() - << " = " << aLink.ToNodeName.c_str() << ".Input( '" - << aLink.ToServiceParameterName.c_str() << "' , " ; + f << "I"<< aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() +// << " = " << aLink.ToNodeName.c_str() << ".Input( '" +// << aLink.ToServiceParameterName.c_str() << "' , " ; + << ".Input( " ; switch (aLink.aLinkValue.type()->kind()) { case CORBA::tk_string: { char* retstr ; @@ -949,12 +1133,12 @@ bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName , break ; } } - f << ")" << endl ; + f << " )" << endl ; } int i ; for ( i = 0 ; i < (int ) aLink.aListOfCoords.size() ; i++ ) { - f << aLink.ToNodeName.c_str() - << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , " + f << "L" << aLink.FromNodeName.c_str() << aLink.FromServiceParameterName.c_str() + << aLink.ToNodeName.c_str() << aLink.ToServiceParameterName.c_str() << ".AddCoord( " << i+1 << " , " << aLink.aListOfCoords[ i ].theX << " , " << aLink.aListOfCoords[ i ].theY << " )" << endl ; } @@ -962,89 +1146,89 @@ bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char * aGraphName , } //bool GraphEditor::OutNode::SaveXML(ostream & f ) { -bool GraphEditor::OutNode::SaveXML(QDomDocument & Graph ) { +bool GraphEditor::OutNode::SaveXML(QDomDocument & GraphQDom ) { int i ; // f << "" << endl << endl ; // f << "" << endl << endl ; // f << "" << endl ; QString Dataflow("Dataflow") ; - Graph = QDomDocument(Dataflow) ; + GraphQDom = QDomDocument(Dataflow) ; // f << "" << endl ; - QDomElement dataflow = Graph.createElement( "dataflow" ) ; - Graph.appendChild( dataflow ) ; + QDomElement dataflow = GraphQDom.createElement( "dataflow" ) ; + GraphQDom.appendChild( dataflow ) ; // f << " " << endl ; - QDomElement info = Graph.createElement( "info-list" ) ; + QDomElement info = GraphQDom.createElement( "info-list" ) ; dataflow.appendChild( info ) ; // f << " " << endl ; // GraphBase::DataNode::SaveXML( f , " " , 0 , 0 ) ; - GraphBase::DataNode::SaveXML( Graph , info , 0 , 0 ) ; + Graph()->SaveXML( GraphQDom , info , 0 , 0 ) ; // f << " " << endl ; // f << " " << endl << endl ; // f << " " << endl ; - QDomElement nodelist = Graph.createElement( "node-list" ) ; + QDomElement nodelist = GraphQDom.createElement( "node-list" ) ; dataflow.appendChild( nodelist ) ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { // f << " " << endl ; - if ( GraphNodes( i )->IsComputingNode() ) { + if ( Graph()->GraphNodes( i )->IsComputingNode() ) { // ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::ComputingNode *)GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::ComputingNode *) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsFactoryNode() ) { + else if ( Graph()->GraphNodes( i )->IsFactoryNode() ) { // ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::FactoryNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsInLineNode() ) { + else if ( Graph()->GraphNodes( i )->IsInLineNode() ) { // ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::InLineNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsGOTONode() ) { + else if ( Graph()->GraphNodes( i )->IsGOTONode() ) { // ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::GOTONode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsLoopNode() ) { + else if ( Graph()->GraphNodes( i )->IsLoopNode() ) { // ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::LoopNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsEndLoopNode() ) { + else if ( Graph()->GraphNodes( i )->IsEndLoopNode() ) { // ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::EndOfLoopNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::EndOfLoopNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsSwitchNode() ) { + else if ( Graph()->GraphNodes( i )->IsSwitchNode() ) { // ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::SwitchNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } - else if ( GraphNodes( i )->IsEndSwitchNode() ) { + else if ( Graph()->GraphNodes( i )->IsEndSwitchNode() ) { // ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( f , // " " , - ((GraphBase::EndOfSwitchNode * ) GraphNodes( i ))->SaveXML( Graph , nodelist , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::EndOfSwitchNode * ) Graph()->GraphNodes( i ))->SaveXML( GraphQDom , nodelist , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } // f << " " << endl ; // } @@ -1052,29 +1236,29 @@ bool GraphEditor::OutNode::SaveXML(QDomDocument & Graph ) { // f << " " << endl << endl ; // f << " " << endl ; - QDomElement linklist = Graph.createElement( "link-list" ) ; + QDomElement linklist = GraphQDom.createElement( "link-list" ) ; dataflow.appendChild( linklist ) ; - const GraphBase::ListOfLinks * Links = GetLinks( true ) ; + const GraphBase::ListOfLinks * Links = Graph()->GetLinks( true ) ; for ( i = 0 ; i < (int ) Links->size() ; i++ ) { // f << " " << endl ; - QDomElement link = Graph.createElement( "link" ) ; + QDomElement link = GraphQDom.createElement( "link" ) ; linklist.appendChild( link ) ; // LinkSaveXML( f , " " , (*Links)[ i ] , false ) ; - LinkSaveXML( Graph , link , (*Links)[ i ] , false ) ; + LinkSaveXML( GraphQDom , link , (*Links)[ i ] , false ) ; // f << " " << endl ; } // f << " " << endl << endl ; // f << " " << endl ; - QDomElement datalist = Graph.createElement( "data-list" ) ; + QDomElement datalist = GraphQDom.createElement( "data-list" ) ; dataflow.appendChild( datalist ) ; - const GraphBase::ListOfLinks * Datas = GetDatas() ; + const GraphBase::ListOfLinks * Datas = Graph()->GetDatas() ; for ( i = 0 ; i < (int ) Datas->size() ; i++ ) { // f << " " << endl ; - QDomElement data = Graph.createElement( "data" ) ; + QDomElement data = GraphQDom.createElement( "data" ) ; datalist.appendChild( data ) ; // LinkSaveXML( f , " " , (*Datas)[ i ] , true ) ; - LinkSaveXML( Graph , data , (*Datas)[ i ] , true ) ; + LinkSaveXML( GraphQDom , data , (*Datas)[ i ] , true ) ; // f << " " << endl ; } //#if 0 @@ -1111,26 +1295,26 @@ bool GraphEditor::OutNode::SaveXML(QDomDocument & Graph ) { bool GraphEditor::OutNode::SavePY( ostream & f ) { int i ; int j ; - f << endl << "# Generated python file of Graph " << Name() << endl << endl ; + f << endl << "# Generated python file of Graph " << Graph()->Name() << endl << endl ; f << "from SuperV import *" << endl ; f << "# Graph creation " << endl ; - GraphBase::DataNode::SavePY( f , Name() , 0 , 0 ) ; + Graph()->SavePY( f , Graph()->Name() , 0 , 0 ) ; f << endl << "# Creation of Factory Nodes" << endl ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - if ( GraphNodes( i )->IsFactoryNode() ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + if ( Graph()->GraphNodes( i )->IsFactoryNode() ) { f << endl ; - ((GraphBase::FactoryNode * ) GraphNodes( i ))->SavePY( f , Name() , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::FactoryNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } } bool first = true ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - if ( GraphNodes( i )->IsComputingNode() ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + if ( Graph()->GraphNodes( i )->IsComputingNode() ) { if ( first ) { f << endl << "# Creation of Computing Nodes" << endl ; first = false ; @@ -1138,15 +1322,15 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { else { f << endl ; } - ((GraphBase::ComputingNode * ) GraphNodes( i ))->SavePY( f , Name() , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::ComputingNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } } first = true ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - if ( GraphNodes( i )->IsInLineNode() ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + if ( Graph()->GraphNodes( i )->IsInLineNode() ) { if ( first ) { f << endl << "# Creation of InLine Nodes" << endl ; first = false ; @@ -1154,15 +1338,15 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { else { f << endl ; } - ((GraphBase::InLineNode * ) GraphNodes( i ))->SavePY( f , Name() , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::InLineNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } } first = true ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - if ( GraphNodes( i )->IsLoopNode() ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + if ( Graph()->GraphNodes( i )->IsLoopNode() ) { if ( first ) { f << endl << "# Creation of Loop Nodes" << endl ; first = false ; @@ -1170,15 +1354,15 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { else { f << endl ; } - ((GraphBase::LoopNode * ) GraphNodes( i ))->SavePY( f , Name() , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::LoopNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } } first = true ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - if ( GraphNodes( i )->IsSwitchNode() ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + if ( Graph()->GraphNodes( i )->IsSwitchNode() ) { if ( first ) { f << endl << "# Creation of Switch Nodes" << endl ; first = false ; @@ -1186,15 +1370,15 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { else { f << endl ; } - ((GraphBase::SwitchNode * ) GraphNodes( i ))->SavePY( f , Name() , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::SwitchNode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } } first = true ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - if ( GraphNodes( i )->IsGOTONode() ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + if ( Graph()->GraphNodes( i )->IsGOTONode() ) { if ( first ) { f << endl << "# Creation of GOTO Nodes" << endl ; first = false ; @@ -1202,19 +1386,19 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { else { f << endl ; } - ((GraphBase::GOTONode * ) GraphNodes( i ))->SavePY( f , Name() , - GraphNodes( i )->XCoordinate() , - GraphNodes( i )->YCoordinate() ) ; + ((GraphBase::GOTONode * ) Graph()->GraphNodes( i ))->SavePY( f , Graph()->Name() , + Graph()->GraphNodes( i )->XCoordinate() , + Graph()->GraphNodes( i )->YCoordinate() ) ; } } - const GraphBase::ListOfLinks * Links = GetLinks() ; - bool intervar ; - map< string , int > aMapOfOutPorts ; + const GraphBase::ListOfLinks * Links = Graph()->GetLinks() ; +// bool intervar ; +// map< string , int > aMapOfOutPorts ; first = true ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { for ( j = 0 ; j < (int ) Links->size() ; j++ ) { - if ( !strcmp( GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) { + if ( !strcmp( Graph()->GraphNodes( i )->Name() , (*Links)[ j ].FromNodeName.c_str() ) ) { if ( first ) { f << endl << "# Creation of Links" @@ -1224,91 +1408,45 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { else { f << endl ; } - char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) + - strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ; - strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ; - strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ; - if ( aMapOfOutPorts[ NodePort ] == 0 ) { - aMapOfOutPorts[ NodePort ] = j + 1 ; - intervar = true ; - } - else { - intervar = false ; - } - LinkSavePY( f , Name() , (*Links)[ j ] , intervar , false ) ; - delete [] NodePort ; - } - } - } - -#if 0 - first = true ; - for ( i = 0 ; i < Links->size() ; i++ ) { - if ( GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsSwitchNode() || - GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsSwitchNode() || - GetGraphNode( (*Links)[ i ].FromNodeName.c_str() )->IsEndSwitchNode() || - GetGraphNode( (*Links)[ i ].ToNodeName.c_str() )->IsEndSwitchNode() ) { - if ( first ) { - f << endl - << "# Creation of Switch 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 ; +// char * NodePort = new char [ strlen( (*Links)[ j ].FromNodeName.c_str() ) + +// strlen( (*Links)[ j ].FromServiceParameterName.c_str() ) + 1 ] ; +// strcpy( NodePort , (*Links)[ j ].FromNodeName.c_str() ) ; +// strcat( NodePort , (*Links)[ j ].FromServiceParameterName.c_str() ) ; +// if ( aMapOfOutPorts[ NodePort ] == 0 ) { +// aMapOfOutPorts[ NodePort ] = j + 1 ; +// intervar = true ; +// } +// else { +// intervar = false ; +// } + bool fromparam = false ; + if ( Graph()->GraphNodes( i )->GetOutPort( (*Links)[ j ].FromServiceParameterName.c_str() )->IsParam() ) { + fromparam = true ; + } + bool toparam = false ; + if ( Graph()->GetChangeGraphNode( (*Links)[ j ].ToNodeName.c_str() )->GetInPort( (*Links)[ j ].ToServiceParameterName.c_str() )->IsParam() ) { + toparam = true ; + } + LinkSavePY( f , Graph()->Name() , (*Links)[ j ] , fromparam , toparam , false ) ; +// delete [] NodePort ; } - LinkSavePY( f , Name() , (*Links)[ i ] , intervar , false ) ; - delete [] NodePort ; } } -#endif - const GraphBase::ListOfLinks * Datas = GetDatas() ; + const GraphBase::ListOfLinks * Datas = Graph()->GetDatas() ; first = true ; for ( i = 0 ; i < (int ) Datas->size() ; i++ ) { if ( first ) { - f << endl << "# Creation of Input datas" << endl ; + f << endl << "# Input datas" << endl ; first = false ; } - LinkSavePY( f , Name() , (*Datas)[ i ] , false , true ) ; + bool fromparam = true ; + bool toparam = true ; + LinkSavePY( f , Graph()->Name() , (*Datas)[ i ] , fromparam , toparam , true ) ; } first = true ; - const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = ServiceInParameter() ; + const SALOME_ModuleCatalog::ListOfServicesParameter ListOfInParam = Graph()->ServiceInParameter() ; for ( i = 0 ; i < (int ) ListOfInParam.length() ; i++ ) { string _aParam = CORBA::string_dup(ListOfInParam[ i ].Parametername) ; const char * aParam = _aParam.c_str() ; @@ -1325,20 +1463,21 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { break ; } } - if ( !GetChangeGraphNode( aNodeName )->GetInPort( aPortName )->IsDataConnected() ) { + const GraphBase::InPort * anInPort = Graph()->GetChangeGraphNode( aNodeName )->GetInPort( aPortName ) ; + if ( !anInPort->IsDataConnected() ) { if ( first ) { - f << endl << "# Missing Input datas" << endl ; + f << endl << "# Input Ports of the graph" << endl ; first = false ; } - f << aNodeName << aPortName << " = " << aNodeName << ".Port( '" + f << "#I" << aNodeName << aPortName << " = " << aNodeName << ".GetInPort( '" << aPortName << "' )" << endl ; } delete [] aNodeName ; delete [] aPortName ; } - f << endl << "# Creation of Output variables" << endl ; - const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = ServiceOutParameter() ; + f << endl << "# Output Ports of the graph" << endl ; + const SALOME_ModuleCatalog::ListOfServicesParameter ListOfOutParam = Graph()->ServiceOutParameter() ; for ( i = 0 ; i < (int ) ListOfOutParam.length() ; i++ ) { string _aParam = CORBA::string_dup(ListOfOutParam[ i ].Parametername) ; const char * aParam = _aParam.c_str() ; @@ -1355,7 +1494,7 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { break ; } } - f << aNodeName << aPortName << " = " << aNodeName << ".Port( '" + f << "#O" << aNodeName << aPortName << " = " << aNodeName << ".GetOutPort( '" << aPortName << "' )" << endl ; delete [] aNodeName ; delete [] aPortName ; @@ -1366,28 +1505,28 @@ bool GraphEditor::OutNode::SavePY( ostream & f ) { ostream & operator<< (ostream & f,const GraphEditor::OutNode & G) { - f << (GraphBase::ComputingNode ) G ; + f << (GraphBase::ComputingNode ) *(G.Graph()) ; f << endl ; - f << " Nodes : " << G.GraphNodesSize() << " node" - << (G.GraphNodesSize() > 1 ? "s" : "") << endl; + f << " Nodes : " << (G.Graph())->GraphNodesSize() << " node" + << ((G.Graph())->GraphNodesSize() > 1 ? "s" : "") << endl; int i ; - for ( i = 0 ; i < G.GraphNodesSize() ; i++ ) { + for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) { f -// << hex << (void *) G.GraphNodes( i ) << dec << " " - << *G.GraphNodes( i ) << endl; +// << hex << (void *) G.Graph().GraphNodes( i ) << dec << " " + << (G.Graph())->GraphNodes( i ) << endl; } f << " Links : " << endl ; - for ( i = 0 ; i < G.GraphNodesSize() ; i++ ) { - G.GraphNodes( i )->ListLinks( f ) ; + for ( i = 0 ; i < (G.Graph())->GraphNodesSize() ; i++ ) { + (G.Graph())->GraphNodes( i )->ListLinks( f ) ; } f << " Datas : " << endl ; - G.ListDatas( f ) ; + (G.Graph())->ListDatas( f ) ; - f << "DataFlow " << G.Name() << " is " ; + f << "DataFlow " << (G.Graph())->Name() << " is " ; if ( G.IsNotValid() ) f << "not " ; f << "valid and is " ; diff --git a/src/GraphEditor/DataFlowEditor_OutNode.hxx b/src/GraphEditor/DataFlowEditor_OutNode.hxx index c36b243..351707d 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.hxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.hxx @@ -27,16 +27,22 @@ #ifndef _DATAFLOWEDITOR_OUTNODE_HXX #define _DATAFLOWEDITOR_OUTNODE_HXX -#include "DataFlowBase_Graph.hxx" +#include "DataFlowBase_StreamGraph.hxx" #include "DataFlowEditor_InNode.hxx" namespace GraphEditor { - class OutNode : public GraphBase::Graph { +// class OutNode : public GraphBase::Graph { + class OutNode : public GraphBase::Base { private : + GraphBase::StreamGraph * _StreamGraph ; + GraphBase::Graph * _Graph ; + + int _Graph_prof_debug ; + bool _Imported ; bool _Valid ; @@ -65,7 +71,8 @@ namespace GraphEditor { bool GraphEditor::OutNode::LinkSavePY( ostream &f , const char *aGraphName , GraphBase::SLink aLink , - bool intervar , + bool fromparam , + bool toparam , bool wdata ) const; bool SavePY(ostream &f ) ; @@ -77,7 +84,8 @@ namespace GraphEditor { OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const char *DataFlowName , - const char * DebugFileName ); + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ); OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& DataFlowService , @@ -94,8 +102,15 @@ namespace GraphEditor { const char * DebugFileName ) ; virtual ~OutNode(); -// SALOME_NamingService* NamingService() const { -// return _theNamingService ; } ; + void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ; + GraphBase::StreamGraph * StreamGraph() { + return _StreamGraph ; } ; + GraphBase::StreamGraph * StreamGraph() const { + return _StreamGraph ; } ; + GraphBase::Graph * Graph() { + return _Graph ; } ; + const GraphBase::Graph * Graph() const { + return _Graph ; } ; bool LoadDataFlow( const GraphBase::SGraph *aDataFlow ) ; bool LoadXml( const char* myFileName ) ; @@ -127,7 +142,7 @@ namespace GraphEditor { const int NodeX , const int NodeY ) ; GraphEditor::InNode * GetNode( const char* NodeName ) { - const GraphBase::Graph::ComputingNode * aNode = GraphBase::Graph::GetGraphNode( NodeName ) ; + const GraphBase::Graph::ComputingNode * aNode = _Graph->GetGraphNode( NodeName ) ; if ( aNode ) { return (GraphEditor::InNode * ) (aNode->GetInNode()) ; } @@ -137,34 +152,34 @@ namespace GraphEditor { bool RemoveNode( const char* NodeName ) { DateModification() ; _Valid = false ; - return GraphBase::Graph::RemoveNode( NodeName ) ; } ; + return _Graph->RemoveNode( NodeName ) ; } ; bool ReNameNode( const char* OldNodeName , const char* NewNodeName ) { DateModification() ; _Valid = false ; - return GraphBase::Graph::ReNameNode( OldNodeName , NewNodeName ) ; } ; + return _Graph->ReNameNode( OldNodeName , NewNodeName ) ; } ; void Coordinates( const int X , const int Y ) { - return GraphBase::Graph::Coordinates( X , Y ) ; } ; + return _Graph->Coordinates( X , Y ) ; } ; const int XCoordinate() { - return GraphBase::Graph::XCoordinate() ; } ; + return _Graph->XCoordinate() ; } ; const int YCoordinate() { - return GraphBase::Graph::YCoordinate() ; } ; + return _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 ) ; } ; + const GraphBase::InPort *GetInPort( const char * InPortName ) { + return _Graph->GetInPort( InPortName ) ; } ; + const GraphBase::OutPort *GetOutPort( const char * OutPortName ) { + return _Graph->GetOutPort( OutPortName ) ; } ; + GraphBase::InPort *GetChangeInPort( const char * InPortName ) { + return _Graph->GetChangeInPort( InPortName ) ; } ; + GraphBase::OutPort *GetChangeOutPort( const char * OutPortName ) { + return _Graph->GetChangeOutPort( OutPortName ) ; } ; bool HasInput(const char * ToServiceParameterName ) { - return GraphBase::ComputingNode::HasInput( ToServiceParameterName ) ; + return _Graph->HasInput( ToServiceParameterName ) ; } bool AddLink( const char* FromNodeName , @@ -174,20 +189,18 @@ namespace GraphEditor { const CORBA::Any aValue ) { DateModification() ; _Valid = false ; - return GraphBase::Graph::AddLink( - FromNodeName , FromServiceParameterName , - ToNodeName , ToServiceParameterName , - aValue ) ; } ; + return _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 ) ; + bool RetVal = _Graph->RemoveLink( FromNodeName , + FromServiceParameterName , + ToNodeName , + ToServiceParameterName ) ; if ( RetVal ) DateModification() ; _Valid = false ; @@ -197,10 +210,10 @@ namespace GraphEditor { const char* ToServiceParameterName , char** FromNodeName , char** FromServiceParameterName ) { - return GraphBase::Graph::GetLink( ToNodeName , - ToServiceParameterName , - FromNodeName , - FromServiceParameterName ) ; } ; + return _Graph->GetLink( ToNodeName , + ToServiceParameterName , + FromNodeName , + FromServiceParameterName ) ; } ; bool AddLinkCoord( const char* FromNodeName , const char* FromServiceParameterName , diff --git a/src/GraphEditor/Makefile.in b/src/GraphEditor/Makefile.in index d1acd91..6bd73f7 100644 --- a/src/GraphEditor/Makefile.in +++ b/src/GraphEditor/Makefile.in @@ -60,12 +60,11 @@ 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 -Wno-deprecated CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ -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 -lSALOMELocalTrace \ -lc $(QT_MT_LIBS) $(OGL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome +#LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) @CONCLUDE@ diff --git a/src/GraphExecutor/DataFlowExecutor_DataFlow.cxx b/src/GraphExecutor/DataFlowExecutor_DataFlow.cxx index ce71218..36d198c 100644 --- a/src/GraphExecutor/DataFlowExecutor_DataFlow.cxx +++ b/src/GraphExecutor/DataFlowExecutor_DataFlow.cxx @@ -41,8 +41,9 @@ GraphExecutor::DataFlow::DataFlow() : GraphExecutor::DataFlow::DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const char *DataFlowName , - const char * DebugFileName ) : - OutNode( ORB, ptrNamingService , DataFlowName , DebugFileName ) { + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ) : + OutNode( ORB, ptrNamingService , DataFlowName , DebugFileName , aKindOfNode ) { cdebug_in << "GraphExecutor::DataFlow::DataFlow(" ; if ( DataFlowName ) { cdebug << DataFlowName ; @@ -90,8 +91,8 @@ GraphExecutor::DataFlow::~DataFlow() { 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() ; + if ( Graph()->GetGraphNode( aNodeName ) ) + RetVal = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode())->Ping() ; cdebug_out << "GraphExecutor::DataFlow::Ping" << endl; return RetVal ; } @@ -106,7 +107,7 @@ bool GraphExecutor::DataFlow::ContainerKill() { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->ContainerKill() ; } @@ -124,7 +125,7 @@ bool GraphExecutor::DataFlow::Kill() { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->Kill() ; } @@ -135,7 +136,7 @@ bool GraphExecutor::DataFlow::Kill( const char *aNodeName ) { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->KillDone() ; } @@ -153,7 +154,7 @@ bool GraphExecutor::DataFlow::Suspend() { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->Suspend() ; } @@ -172,7 +173,7 @@ bool GraphExecutor::DataFlow::SuspendDone() { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->SuspendDone() ; } @@ -190,7 +191,7 @@ bool GraphExecutor::DataFlow::Resume() { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->Resume() ; } @@ -208,7 +209,7 @@ bool GraphExecutor::DataFlow::Stop() { 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()) ; + GraphExecutor::InNode * aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode()) ; if ( aNode ) { RetVal = aNode->Stop() ; } diff --git a/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx b/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx index 5f1f153..b5774e7 100644 --- a/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx +++ b/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx @@ -42,7 +42,8 @@ namespace GraphExecutor { DataFlow(); DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const char * DataFlowName , - const char * DebugFileName ); + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ); DataFlow( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& DataFlowService , const char *DataFlowComponentName , diff --git a/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx b/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx index ce3c606..2cf8cf4 100644 --- a/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx +++ b/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx @@ -40,8 +40,8 @@ inline bool GraphExecutor::DataFlow::LoadXml( const char* myFileName ) { inline const SALOME_ModuleCatalog::Service * GraphExecutor::DataFlow::NodeService( const char * aNodeName ) { - if ( GetGraphNode( aNodeName ) ) - return GetGraphNode( aNodeName )->GetService() ; + if ( Graph()->GetGraphNode( aNodeName ) ) + return Graph()->GetGraphNode( aNodeName )->GetService() ; return NULL ; } @@ -50,8 +50,7 @@ inline bool GraphExecutor::DataFlow::ChangeInputData( const char* ToNodeName , const CORBA::Any aValue ) { if ( !IsValid() ) return false ; - return GraphBase::Graph::ChangeInputData( ToNodeName , ToParameterName , - aValue ) ; + return Graph()->ChangeInputData( ToNodeName , ToParameterName , aValue ) ; } ; inline bool GraphExecutor::DataFlow::AddInputSharedData(const char* ToNodeName1 , diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx index e63271f..448ad16 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx @@ -570,7 +570,7 @@ bool GraphExecutor::FiniteStateMachine::PyFunction( const char * aPyFuncName , P bool RetVal = false ; if ( _MapOfPyFunctions[ aPyFuncName ] != NULL ) { - PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ; + //PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ; //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , " << aPyFunction // << " ) ob_refcnt " << aPyFunction->ob_refcnt << " already mapped : " << aPyFunc << " ob_refcnt " // << aPyFunc->ob_refcnt << endl ; diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.cxx b/src/GraphExecutor/DataFlowExecutor_InNode.cxx index 45ebcad..76ff07f 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.cxx @@ -345,8 +345,11 @@ GraphExecutor::InNode::InNode( CORBA::ORB_ptr ORB, _InLineNode = (GraphBase::InLineNode *) _ComputingNode ; break ; } - case SUPERV::DataFlowNode : { - cdebug << "GraphEditor::InNode::InNode SUPERV::DataFlowNode ERROR : " << NodeName ; + case SUPERV::DataFlowGraph : { + cdebug << "GraphEditor::InNode::InNode SUPERV::DataFlowGraph ERROR : " << NodeName ; + } + case SUPERV::DataStreamGraph : { + cdebug << "GraphEditor::InNode::InNode SUPERV::DataStreamGraph ERROR : " << NodeName ; } case SUPERV::UnknownNode : { cdebug << "GraphEditor::InNode::InNode SUPERV::UnknownNode ERROR : " << NodeName ; @@ -408,7 +411,15 @@ bool GraphExecutor::InNode::Ping() { RetVal = !CORBA::is_nil( _FactoryNode->Component() ) ; if ( RetVal ) { if ( State() != SUPERV::SuspendedExecutingState ) { - _FactoryNode->Component()->ping() ; + try { + _FactoryNode->Component()->ping() ; + } + catch( ... ) { + cdebug << "InNode::Ping() catched" << endl ; + State( SUPERV::ErroredState ) ; + _OutNode->State( SUPERV::ErroredState ) ; + RetVal = false ; + } } else { RetVal = false ; @@ -448,7 +459,15 @@ bool GraphExecutor::InNode::Suspend() { ControlState( SUPERV::ToSuspendState ) ; if ( IsFactoryNode() || IsComputingNode() ) { if ( !CORBA::is_nil( Component() ) ) { - RetVal = Component()->Suspend_impl() ; + try { + RetVal = Component()->Suspend_impl() ; + } + catch( ... ) { + cdebug << "InNode::Suspend() catched" << endl ; + State( SUPERV::ErroredState ) ; + _OutNode->State( SUPERV::ErroredState ) ; + RetVal = false ; + } if ( RetVal ) { if ( IsRunning() ) { cdebug << pthread_self() << "GraphExecutor::InNode::Suspend_impl " << Name() @@ -522,7 +541,15 @@ bool GraphExecutor::InNode::Kill() { if ( IsRunning() ) { if ( IsFactoryNode() || IsComputingNode() ) { if ( !CORBA::is_nil( Component() ) ) { - RetVal = Component()->Kill_impl() ; + try { + RetVal = Component()->Kill_impl() ; + } + catch( ... ) { + cdebug << "InNode::Suspend() catched" << endl ; + State( SUPERV::ErroredState ) ; + _OutNode->State( SUPERV::ErroredState ) ; + RetVal = false ; + } cdebug << "Component()->Kill_impl() returns status " << RetVal << endl ; RetVal = true ; if ( IsRunning() ) { @@ -619,7 +646,15 @@ bool GraphExecutor::InNode::Stop() { if ( IsRunning() ) { if ( IsFactoryNode() || IsComputingNode() ) { if ( !CORBA::is_nil( Component() ) ) { - RetVal = Component()->Stop_impl() ; + try { + RetVal = Component()->Stop_impl() ; + } + catch( ... ) { + cdebug << "InNode::Stop() catched" << endl ; + State( SUPERV::ErroredState ) ; + _OutNode->State( SUPERV::ErroredState ) ; + RetVal = false ; + } if ( RetVal ) { if ( IsRunning() ) { SendEvent( GraphExecutor::StopEvent ) ; @@ -693,7 +728,15 @@ bool GraphExecutor::InNode::Resume() { } else if ( State() == SUPERV::SuspendedExecutingState ) { if ( IsFactoryNode() || IsComputingNode() ) { - RetVal = Component()->Resume_impl() ; + try { + RetVal = Component()->Resume_impl() ; + } + catch( ... ) { + cdebug << "InNode::Resume() catched" << endl ; + State( SUPERV::ErroredState ) ; + _OutNode->State( SUPERV::ErroredState ) ; + RetVal = false ; + } } } else if ( State() == SUPERV::SuspendedSuccessedState ) { @@ -793,7 +836,7 @@ bool GraphExecutor::InNode::Resume() { bool GraphExecutor::InNode::ReStart( const char * AtNodeName , const bool AndSuspend ) { bool RetVal = false ; - GraphExecutor::InNode * aRestartNode = (GraphExecutor::InNode *) _OutNode->GetGraphNode( AtNodeName )->GetInNode() ; + GraphExecutor::InNode * aRestartNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetGraphNode( AtNodeName )->GetInNode() ; cdebug_in << pthread_self() << "/" << ThreadNo() << " --> GraphExecutor::InNode::ReStartAt( " << AtNodeName << " , " << AndSuspend << ") " << endl @@ -1058,7 +1101,11 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) ThreadNo( 0 ) ; for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { - if ( i != 0 || !IsGOTONode() ) { + if ( GetNodeOutPort(i)->IsDataStream() ) { + GetChangeNodeOutPort(i)->State( SUPERV::ReadyState ) ; + GetChangeNodeOutPort(i)->Done( true ) ; + } + else if ( i != 0 || !IsGOTONode() ) { GetChangeNodeOutPort(i)->State( SUPERV::WaitingState ) ; GetChangeNodeOutPort(i)->Done( false ) ; } @@ -1091,21 +1138,32 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) if ( anInPort->IsGate() && anOutPort == NULL ) { Pc-- ; } - else { - if ( anOutPort->IsDataConnected() ) { + else if ( anOutPort ) { + if ( anOutPort->IsDataConnected() || anOutPort->IsDataStream() ) { Pc-- ; } - if ( anOutPort->IsPortConnected() ) { - anOutPort->State( SUPERV::WaitingState ) ; - anOutPort->Done( false ) ; - } - else if ( anOutPort->IsDataConnected() ) { + if ( anOutPort->IsDataConnected() || anOutPort->IsDataStream() ) { anOutPort->State( SUPERV::ReadyState ) ; anOutPort->Done( true ) ; } + else if ( anOutPort->IsPortConnected() ) { + anOutPort->State( SUPERV::WaitingState ) ; + anOutPort->Done( false ) ; + } } if ( anOutPort ) { - GetChangeNodeInPort(i)->State( anOutPort->State() ) ; + if ( !anOutPort->IsDataStream() || anInPort->IsDataStream() ) { + cdebug << "InPort" << i << " state change : " << anInPort->PortName() << " from OutPort " + << anOutPort->PortName() << " from Node " << anOutPort->NodeName() + << " with state " << theAutomaton->StateName( anOutPort->State() ) << endl ; + GetChangeNodeInPort(i)->State( anOutPort->State() ) ; + } + else { + cdebug << "InPort" << i << " state change : " << anInPort->PortName() << " from OutPort " + << anOutPort->PortName() << " from Node " << anOutPort->NodeName() + << " with state ReadyState" << endl ; + GetChangeNodeInPort(i)->State( SUPERV::ReadyState ) ; + } } if ( anOutPort ) { cdebug << "InPort" << i << " : " << anInPort->PortName() << " from OutPort " @@ -1140,6 +1198,13 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) _OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent , _currentState ) ; } + + for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { + cdebug << "OutPort" << i << " : " << GetNodeOutPort(i)->PortName() << " " + << theAutomaton->StateName( GetChangeNodeOutPort(i)->State() ) + << " " << GetNodeOutPort(i)->Kind() << endl ; + } + cdebug << "CurrentState = " << theAutomaton->StateName( _currentState ) << endl; @@ -1152,32 +1217,40 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { if ( !PyFuncRunned() && IsOneOfInLineNodes() ) { if ( IsLoopNode() ) { PyObject * PyRunMethod = InLineNode()->PyRunMethod() ; + PyObject * PyMoreMethod = NULL ; + PyObject * PyNextMethod = NULL ; if ( PyRunMethod ) { } else { - PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , - InLineNode()->PythonFunction() ) ; + PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , + InLineNode()->PythonFunction() , + Err ) ; InLineNode()->PyRunMethod( PyRunMethod ) ; } - PyObject * PyMoreMethod = LoopNode()->PyMoreMethod() ; - if ( PyMoreMethod ) { - } - else { - PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() , - LoopNode()->MorePythonFunction() ) ; - LoopNode()->PyMoreMethod( PyMoreMethod ) ; - } - PyObject * PyNextMethod = LoopNode()->PyNextMethod() ; - if ( PyNextMethod ) { + if ( !Err ) { + PyMoreMethod = LoopNode()->PyMoreMethod() ; + if ( PyMoreMethod ) { + } + else { + PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() , + LoopNode()->MorePythonFunction() , + Err ) ; + LoopNode()->PyMoreMethod( PyMoreMethod ) ; + } } - else { - PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() , - LoopNode()->NextPythonFunction() ) ; - LoopNode()->PyNextMethod( PyNextMethod ) ; + if ( !Err ) { + PyNextMethod = LoopNode()->PyNextMethod() ; + if ( PyNextMethod ) { + } + else { + PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() , + LoopNode()->NextPythonFunction() , + Err ) ; + LoopNode()->PyNextMethod( PyNextMethod ) ; + } } cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) " << PyRunMethod << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod << endl; - Err = !PyRunMethod || !PyMoreMethod || !PyNextMethod ; } else if ( IsInLineNode() || IsSwitchNode() ) { PyObject * PyRunMethod = InLineNode()->PyRunMethod() ; @@ -1185,11 +1258,11 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { } else { PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , - InLineNode()->PythonFunction() ) ; + InLineNode()->PythonFunction() , + Err ) ; InLineNode()->PyRunMethod( PyRunMethod ) ; } cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl; - Err = !PyRunMethod ; } else if ( ( IsEndLoopNode() || IsEndSwitchNode() || IsGOTONode() ) && (*InLineNode()->PythonFunction()).length() ) { @@ -1198,11 +1271,11 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { } else { PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() , - InLineNode()->PythonFunction() ) ; + InLineNode()->PythonFunction() , + Err ) ; InLineNode()->PyRunMethod( PyRunMethod ) ; } cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl; - Err = !PyRunMethod ; } } Err = WithErr && Err ; @@ -1211,7 +1284,7 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { cdebug << " Error " << Err ; } cdebug << endl; - return Err ; + return !Err ; } const long GraphExecutor::InNode::CpuUsed( bool tot ) { @@ -1231,6 +1304,8 @@ const long GraphExecutor::InNode::CpuUsed( bool tot ) { } catch ( ... ) { cdebug << "CpuUsed " << Name() << " --> Component()->CpuUsed_impl() ERROR catched " << endl ; + State( SUPERV::ErroredState ) ; + _OutNode->State( SUPERV::ErroredState ) ; cpu = 0 ; } } diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.hxx b/src/GraphExecutor/DataFlowExecutor_InNode.hxx index 6351e1f..9eb952c 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.hxx @@ -42,6 +42,8 @@ #include "DataFlowExecutor_FiniteStateMachine.hxx" +#define MAXSTACKTHREADSIZE 8191 + void * run_function(void *p); extern GraphExecutor::FiniteStateMachine * theAutomaton ; @@ -232,20 +234,25 @@ namespace GraphExecutor { return GOTONode()->CoupledNode() ; } ; GraphBase::InPort * AddInPort( const char * InputParameterName , - const char * InputParameterType ) { + const char * InputParameterType , + const SUPERV::KindOfPort aKindOfPort ) { return _ComputingNode->AddInPort( InputParameterName , - InputParameterType ) ; } ; + InputParameterType , + aKindOfPort ) ; } ; GraphBase::OutPort * AddOutPort( const char * OutputParameterName , - const char * OutputParameterType ) { + const char * OutputParameterType , + const SUPERV::KindOfPort aKindOfPort ) { return _ComputingNode->AddOutPort( OutputParameterName , - OutputParameterType ) ; } ; + OutputParameterType , + aKindOfPort ) ; } ; // 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 ) ; } ; +// GraphBase::ComputingNode * LinkedNodes( int i ) const { + GraphBase::StreamNode * LinkedNodes( int i ) const { + return _ComputingNode->LinkedNodes( i ) ; } ; const int LinkedInPortsNumber( int i ) const { return _ComputingNode->LinkedInPortsNumber( i ) ; } ; @@ -294,7 +301,8 @@ namespace GraphExecutor { bool InitPython() ; PyObject * InitPyDynInvoke( char * PyFuncName , - const SUPERV::ListOfStrings * aPythonFunction ) ; + const SUPERV::ListOfStrings * aPythonFunction , + bool & Err ) ; void LockDataWait() ; void UnLockDataWait() ; diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index ab2e17f..b8a9eda 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -39,14 +39,18 @@ using namespace std; #include #include CORBA_CLIENT_HEADER(SALOME_Component) -//#include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" -//#include "DataFlowExecutor_InNode.hxx" +//#include "StreamGraph_Impl.hxx" #include "DataFlowExecutor_OutNode.hxx" -//static char *containerName = "FactoryServer" ; + +static void UpperCase(std::string& rstr) +{ + std::transform(rstr.begin(), rstr.end(), rstr.begin(), towupper); +} + int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) { @@ -487,10 +491,11 @@ void GraphExecutor::InNode::ThreadStartAction() { } int GraphExecutor::InNode::executeAction() { - int oldRewindStack = ( _RewindStack > 101 ) ; + int oldRewindStack = ( _RewindStack > MAXSTACKTHREADSIZE ) ; if ( !CreateNewThread() && oldRewindStack ) { cdebug << pthread_self() << "/" << ThreadNo() - << " executeAction start Thread _RewindStack " << _RewindStack << " > 101 CreateNewThread " + << " executeAction start Thread _RewindStack " << _RewindStack << " > " + << MAXSTACKTHREADSIZE << " CreateNewThread " << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")" << endl; CreateNewThread( true ) ; @@ -754,9 +759,9 @@ int GraphExecutor::InNode::VoidAction() { int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { -// cdebug << pthread_self() << "/" << ThreadNo() -// << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode() -// << " to " << Name() << endl; + cdebug << pthread_self() << "/" << ThreadNo() + << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode() + << " to " << Name() << endl; unsigned int k; int InReady = 0 ; int res = 1; @@ -778,6 +783,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) { GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ; GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << endl ; if ( anInPort->IsGate() && anOutPort == NULL ) { InReady += 1 ; anInPort->State( SUPERV::ReadyState ) ; @@ -1071,9 +1077,14 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } } else if ( CORBA::is_nil( Component() ) ) { - Err = !_OutNode->StartComponent( ThreadNo() , Computer() , - my_strdup( ComponentName() ) , - myContainer , myObjComponent ) ; + ostringstream astr ; + astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() + << " : load of component " << ComponentName() << " in container " + << Computer() ; +// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; + Err = !_OutNode->Graph()->StartComponent( ThreadNo() , Computer() , + my_strdup( ComponentName() ) , + myContainer , myObjComponent ) ; ObjInterface( false ) ; SetContainer( myContainer ) ; SetComponent( myObjComponent ) ; @@ -1083,7 +1094,13 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { myObjComponent = Component() ; // cdebug << ThreadNo() << "Component known : NO StartComponent & Ping" // << endl ; - myObjComponent->ping() ; + try { + myObjComponent->ping() ; + } + catch( ... ) { + cdebug << "ping() catched" << endl ; + Err = true ; + } } int nOutParams = GetNodeOutPortsSize() ; @@ -1098,6 +1115,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } else { if ( !Err ) { + ostringstream astr ; + astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ; +// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; cdebug << ThreadNo() << " Run( '" << ServiceName() << "'" ; for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) { cdebug << " , " << InParametersList[ i ].Name << "[kind" @@ -1341,26 +1361,60 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { else { try { try { - cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ; + cdebug << "DynInvoke -> Names " << _OutNode->Graph()->Name() << " " << Name() << endl ; DynInvoke( myObjComponent, "Names" , - _OutNode->Name() , Name() ) ; + _OutNode->Graph()->Name() , Name() ) ; } catch( ... ) { cdebug << "DynInvoke Names catched ERROR" << endl ; } - cdebug << ServiceInParameter().length() << " input parameters and " - << ServiceOutParameter().length() << " output parameters" << endl ; - if ( IsComputingNode() ) { +// for DataStreamNodes : call of SetProperties ===> environment variables in the component/container + if ( ComputingNode()->HasDataStream() ) { + try { + cdebug << "DynInvoke -> SetProperties " << _OutNode->Graph()->Name() << " " << Name() << endl ; + Engines::FieldsDict_var dict = new Engines::FieldsDict; + dict->length( 4 ); + dict[ 0 ].key = CORBA::string_dup( "CAL_MACHINE"); + // myContainer->getHostName() ne renvoit pas le nom complet (avec domaine). + // dict[ 0 ].value <<= myContainer->getHostName() ; + char FullyQualifiedDomainName[256]=""; + gethostname(FullyQualifiedDomainName,255); + dict[ 0 ].value <<= FullyQualifiedDomainName ; + dict[ 1 ].key = CORBA::string_dup( "CAL_REPERTOIRE"); + dict[ 1 ].value <<= "/tmp" ; + dict[ 2 ].key = CORBA::string_dup( "CAL_COUPLAGE"); + stringstream ofst1 ; + ofst1 << ComputingNode()->SubStreamGraph() ; + string cpl = string( "/tmp/" ) + string( _OutNode->Graph()->Name() ) + string( "_" ) + + ofst1.str() + string( ".cpl" ); + dict[ 2 ].value <<= cpl.c_str() ; + dict[ 3 ].key = CORBA::string_dup( "SALOME_INSTANCE_NAME"); + string uname = Name(); + UpperCase( uname); + dict[ 3 ].value <<= uname.c_str() ; + + myObjComponent->setProperties( dict ) ; + } + catch( ... ) { + cdebug << "DynInvoke setProperties catched ERROR" << endl ; + Err = true ; + } + } + if ( !Err && IsComputingNode() ) { cdebug << ThreadNo() << " !ObjInterface " << Name() << " IsComputingNode DynInvoke" << endl ; + cdebug << ServiceInParameter().length()-1 << " input parameters and " + << ServiceOutParameter().length() << " output parameters" << endl ; DynInvoke( myObjComponent, ServiceName() , &InParametersList[1] , ServiceInParameter().length()-1 , &OutParametersList[0] , ServiceOutParameter().length() ) ; } - else if ( IsFactoryNode() ) { + else if ( !Err &&IsFactoryNode() ) { cdebug << ThreadNo() << " !ObjInterface " << Name() << " IsFactoryNode DynInvoke" << endl ; + cdebug << ServiceInParameter().length() << " input parameters and " + << ServiceOutParameter().length() << " output parameters" << endl ; DynInvoke( myObjComponent, ServiceName() , &InParametersList[0] , ServiceInParameter().length() , @@ -1383,6 +1437,10 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { // sleep( 1 ) ; // } + ostringstream astr ; + astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : " + << Automaton()->StateName( State() ) ; +// _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; if ( Err ) { if ( ControlState() == SUPERV::ToKillState || ControlState() == SUPERV::ToKillDoneState || @@ -1584,15 +1642,25 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { // << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl; docdebug = true ; } - anInPort->State( SUPERV::WaitingState ) ; + if ( !anInPort->IsDataStream() ) { + anInPort->State( SUPERV::WaitingState ) ; + } } } for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { - for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) { - GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ; + GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ; + for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) { if ( !( IsGOTONode() && anOutPort->IsGate() ) && - !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) ) { - GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ; + !( IsEndLoopNode() && ( anOutPort->IsGate() || + anOutPort->IsLoop() ) ) && + !anOutPort->IsDataStream() && + !anOutPort->ChangeInPorts( j )->IsDataStream() ) { +// cdebug << ThreadNo() +// << " GraphExecutor::InNodeThreads::SetWaitingStates " +// << Name() << "( " << anOutPort->PortName() << " ) --> InPort " +// << anOutPort->ChangeInPorts( j )->PortName() << " from Node " +// << anOutPort->ChangeInPorts( j )->NodeName() << endl; + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ; if ( aNode != EndNode ) { aNode->SetWaitingStates( EndNode ) ; } @@ -1616,6 +1684,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { if ( IsGOTONode() || ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) { + cdebug << ThreadNo() << " Successed_SuccessAction " << Name() + << " SetWaitingStates " << endl ; const GraphBase::OutPort * aGateOutPort ; if ( IsGOTONode() ) { aGateOutPort = GetNodeOutGate() ; @@ -1625,7 +1695,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) { const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ; - GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; + GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; // cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode " // << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ; aLabelNode->SetWaitingStates( this ) ; @@ -1743,7 +1813,9 @@ int GraphExecutor::InNode::Successed_SuccessAction() { // cdebug << endl; for ( i = 0 ; i < LinkedNodesSize() ; i++ ) { bool IgnoreForEndLoop = false ; - toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ; + GraphBase::ComputingNode * aComputingNode ; + aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; + toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ; // cdebug << ThreadNo() << " Successed_SuccessAction of " << Name() // << " [" << i << "] " << LinkedNodes( i )->Name() << endl ; if ( toNode && !toNode->IsDataFlowNode() ) { @@ -2123,7 +2195,9 @@ void GraphExecutor::InNode::InParametersSet( bool & Err , *anAny <<= (long ) 0 ; theOutPort->Value( anAny ) ; } - anInPort->State( SUPERV::WaitingState ) ; + if ( !anInPort->IsDataStream() ) { + anInPort->State( SUPERV::WaitingState ) ; + } D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ; cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ; cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ; @@ -2578,43 +2652,45 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , } } OutParametersList[i] = D ; - if ( anOutPort->IsGate() ) { - aGateOutPort = anOutPort ; - cdebug << " Gate " ; - long l = 1; - OutParametersList[i].Value <<= l; - anOutPort->Value( OutParametersList[i].Value ); - } - else if ( anOutPort->IsLoop() ) { - cdebug << " Loop " ; - anOutPort->Value( OutParametersList[i].Value ); + if ( !anOutPort->IsDataStream() ) { + if ( anOutPort->IsGate() ) { + aGateOutPort = anOutPort ; + cdebug << " Gate " ; + long l = 1; + OutParametersList[i].Value <<= l; + anOutPort->Value( OutParametersList[i].Value ); + } + else if ( anOutPort->IsLoop() ) { + cdebug << " Loop " ; + anOutPort->Value( OutParametersList[i].Value ); // InLoop Port of EndLoopNode is ready : - anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ; - } - else if ( anOutPort->IsSwitch() ) { - cdebug << " Switch " ; - anOutPort->Value( OutParametersList[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 ; - } - else { - OrSwitch = OrSwitch | anOutPort->BoolValue() ; - } - } - cdebug << "OrSwitch " << OrSwitch ; - } - else { - cdebug << " Param " ; - anOutPort->Value( OutParametersList[i].Value ); - } - anOutPort->State( NewState ) ; - anOutPort->Done( true ) ; + anOutPort->ChangeInPorts(0)->State( SUPERV::ReadyState ) ; + } + else if ( anOutPort->IsSwitch() ) { + cdebug << " Switch " ; + anOutPort->Value( OutParametersList[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 ; + } + else { + OrSwitch = OrSwitch | anOutPort->BoolValue() ; + } + } + cdebug << "OrSwitch " << OrSwitch ; + } + else { + cdebug << " Param " ; + anOutPort->Value( OutParametersList[i].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() )->GetChangeNodeInGate()->GetOutPort() ; + GraphBase::OutPort * aGOTOPort = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetChangeNodeInGate()->GetOutPort() ; if ( aGOTOPort ) { fromGOTO = aGOTOPort->IsGOTO() ; } diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index d9e0fb8..d8031a4 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -39,8 +39,8 @@ extern GraphExecutor::FiniteStateMachine * theAutomaton ; extern int _ArgC ; extern char ** _ArgV ; -GraphExecutor::OutNode::OutNode() : - Graph() { +GraphExecutor::OutNode::OutNode() { +// Graph() { _Valid = false ; _Executable = false ; _Done = false ; @@ -63,9 +63,23 @@ GraphExecutor::OutNode::OutNode() : 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; + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ) { +// Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) { + Set_prof_debug( ORB , DebugFileName ) ; + cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << " , " << aKindOfNode << ")" << endl; + if ( aKindOfNode == SUPERV::DataFlowGraph ) { + _StreamGraph = NULL ; +// _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ; + _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowName , + _prof_debug , _fdebug ) ; + } + else if ( aKindOfNode == SUPERV::DataStreamGraph ) { +// _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , DebugFileName ) ;; + _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowName , + _prof_debug , _fdebug ) ; + _Graph = _StreamGraph ; + } _Valid = false ; _Executable = false ; _Done = false ; @@ -101,12 +115,34 @@ GraphExecutor::OutNode::OutNode( 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 ) { + const char * DebugFileName ) { +// Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName , +// DataFlowInterfaceName , DataFlowName , DataFlowkind , +// DataFlowFirstCreation , DataFlowLastModification , +// DataFlowEditorRelease , DataFlowAuthor , +// DataFlowComputer , DataFlowComment , DebugFileName ) { + Set_prof_debug( ORB , DebugFileName ) ; + + cdebug_in << "GraphEditor::OutNode::OutNode(" << DataFlowName << " , " << DataFlowkind << ")" << endl; + if ( DataFlowkind == SUPERV::DataFlowGraph ) { + _StreamGraph = NULL ; + _Graph = new GraphBase::Graph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName , + DataFlowInterfaceName , DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , + DataFlowComputer , DataFlowComment , + _prof_debug , _fdebug ) ; +// DataFlowComputer , DataFlowComment , DebugFileName ) ; + } + else if ( DataFlowkind == SUPERV::DataStreamGraph ) { + _StreamGraph = new GraphBase::StreamGraph( ORB , ptrNamingService , DataFlowService , DataFlowComponentName , + DataFlowInterfaceName , DataFlowName , DataFlowkind , + DataFlowFirstCreation , DataFlowLastModification , + DataFlowEditorRelease , DataFlowAuthor , + DataFlowComputer , DataFlowComment , + _prof_debug , _fdebug ) ; + _Graph = _StreamGraph ; + } _Valid = false ; _Executable = false ; _Done = false ; @@ -130,10 +166,20 @@ GraphExecutor::OutNode::OutNode( GraphExecutor::OutNode::~OutNode() { } +void GraphExecutor::OutNode::Set_prof_debug( CORBA::ORB_ptr ORB , + const char * DebugFileName ) { + _Graph_prof_debug = 0 ; + if ( DebugFileName ) { + _fdebug = new ofstream( DebugFileName ); + SetDebug( ORB , &_Graph_prof_debug , _fdebug ) ; + MESSAGE( endl << "Trace redirected to file " << DebugFileName << endl) + } +} + bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) { bool RetVal = false ; RetVal = LoadInfo( aDataFlow.Info ) ; - if ( GraphBase::Service::ServiceName() != NULL ) { + if ( Graph()->ServiceName() != NULL ) { // MESSAGE( "GraphExecutor::OutNode::LoadDataFlow" ); if ( RetVal ) { RetVal = LoadNodes( aDataFlow.Nodes ) ; @@ -172,7 +218,7 @@ bool GraphExecutor::OutNode::LoadDataFlow(const GraphBase::SGraph &aDataFlow ) { bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) { bool RetVal = false ; GraphBase::SGraph aDataFlow ; - if ( GraphBase::Graph::LoadXml( _Orb , myFileName , aDataFlow ) ) { + if ( Graph()->LoadXml( _Orb , myFileName , aDataFlow ) ) { RetVal = LoadDataFlow( aDataFlow ) ; // if ( aConstructor && RetVal ) // RetVal = Name( aDataFlow.Info.theName.c_str() ) ; @@ -181,19 +227,22 @@ bool GraphExecutor::OutNode::LoadXml( const char* myFileName ) { } bool GraphExecutor::OutNode::LoadInfo(const GraphBase::SNode &aDataFlowInfo ) { - cdebug << "GraphExecutor::OutNode::LoadInfo" << endl ; + cdebug << "GraphExecutor::OutNode::LoadInfo _StreamGraph " << _StreamGraph << 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() ) ; + Graph()->Name( aDataFlowInfo.theName.c_str() ) ; + Graph()->Kind( aDataFlowInfo.theKind ) ; + if ( Graph()->IsDataStreamNode() ) { + StreamGraph()->SetStreamParams( aDataFlowInfo.theTimeout , aDataFlowInfo.theDataStreamTrace , aDataFlowInfo.theDeltaTime ) ; + } + Graph()->DataService( _Orb , aDataFlowInfo.theService , _prof_debug , _fdebug ) ; + Graph()->FirstCreation( aDataFlowInfo.theFirstCreation ) ; + Graph()->LastModification( aDataFlowInfo.theLastModification ) ; + Graph()->EditorRelease( aDataFlowInfo.theEditorRelease.c_str() ) ; + Graph()->Author( aDataFlowInfo.theAuthor.c_str() ) ; +// Graph()->Computer( aDataFlowInfo.theContainer.c_str() ) ; + Graph()->Comment( aDataFlowInfo.theComment.c_str() ) ; // Not in OutNode/DataFlow but in InNode/DataFlow_in_an_other_DataFlow -// Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ; +// Graph()->Coordinates( aDataFlowInfo.theX , aDataFlowInfo.theY ) ; return true ; } @@ -223,50 +272,70 @@ bool GraphExecutor::OutNode::LoadNodes(const GraphBase::ListOfNodes &aListOfNode anInNode->GraphExecutor::InNode::InLineNode()->DefPortsOfNode( _Orb , aNode.theService , anInNode->NamePtr() , anInNode->Kind() , - 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 + _prof_debug , _fdebug ) ; } -#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 ) ; - } +// GraphBase::ComputingNode * theNode = Graph()->GetChangeGraphNode( aNode.theName.c_str() ) ; + + unsigned int j ; + for ( j = 0 ; j < aNode.theListOfInDataStreams.size() ; j++ ) { + GraphBase::InPort * anInPort ; + anInPort = anInNode->ComputingNode()->AddInDataStreamPort( aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametername , + aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parametertype , + aNode.theListOfInDataStreams[ j ].theDataStreamParameter.Parameterdependency , + SUPERV::DataStreamParameter ) ; + ((GraphBase::InDataStreamPort * ) anInPort)->SetParams( aNode.theListOfInDataStreams[ j ].theKindOfSchema , + aNode.theListOfInDataStreams[ j ].theKindOfInterpolation , + aNode.theListOfInDataStreams[ j ].theKindOfExtrapolation ) ; } -#endif + for ( j = 0 ; j < aNode.theListOfOutDataStreams.size() ; j++ ) { + GraphBase::OutPort * anOutPort ; + anOutPort = anInNode->ComputingNode()->AddOutDataStreamPort( aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametername , + aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parametertype , + aNode.theListOfOutDataStreams[ j ].theDataStreamParameter.Parameterdependency , + SUPERV::DataStreamParameter ) ; + ((GraphBase::OutDataStreamPort * ) anOutPort)->NumberOfValues( aNode.theListOfOutDataStreams[ j ].theNumberOfValues ) ; + } + + +// theNode->DataStreamInPortsNumber( aNode.theDataStreamInArgsNumber ) ; +// theNode->DataStreamOutPortsNumber( aNode.theDataStreamOutArgsNumber ) ; +// cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() +// << " InPortsSize " << theNode->GetNodeInPortsSize() +// << " OutPortsSize " << theNode->GetNodeOutPortsSize() +// << " DataStreamInPortsNumber " << aNode.theDataStreamInArgsNumber +// << " DataStreamOutPortsNumber " << aNode.theDataStreamOutArgsNumber +// << endl ; +// int j ; +// if ( aNode.theDataStreamInArgsNumber ) { // -1 because of Gates +// for ( j = theNode->GetNodeInPortsSize() - aNode.theDataStreamInArgsNumber - 1 ; j < theNode->GetNodeInPortsSize() - 1 ; j++ ) { +// cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() +// << " InPort " << theNode->GetChangeNodeInPort( j )->PortName() +// << " Kind( DataStreamParameter)" << endl ; +// theNode->GetChangeNodeInPort( j )->Kind( SUPERV::DataStreamParameter ) ; +// } +// } +// if ( aNode.theDataStreamOutArgsNumber ) { +// int withgate = 1 ; +// if ( theNode->IsLoopNode() || theNode->IsEndLoopNode() ) { +// withgate = 0 ; +// } +// for ( j = theNode->GetNodeOutPortsSize() - aNode.theDataStreamOutArgsNumber - withgate ; j < theNode->GetNodeOutPortsSize() - withgate ; j++ ) { +// cdebug << "GraphExecutor::OutNode::LoadNodes " << anInNode->Name() +// << " OutPort " << theNode->GetChangeNodeOutPort( j )->PortName() +// << " Kind( DataStreamParameter)" << endl ; +// theNode->GetChangeNodeOutPort( j )->Kind( SUPERV::DataStreamParameter ) ; +// } +// } } for ( i = 0 ; i < (int ) 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 = (GraphExecutor::InNode * ) Graph()->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() ) ) ; + aCoupledNode = (GraphBase::GOTONode * ) Graph()->GetGraphNode( aNode.theName.c_str() ) ; + aCoupledNode->CoupledNode( (GraphBase::GOTONode * ) Graph()->GetChangeGraphNode( aNode.theCoupledNode.c_str() ) ) ; } } return RetVal ; @@ -279,11 +348,11 @@ bool GraphExecutor::OutNode::LoadLinks(const GraphBase::ListOfLinks &aListOfLink int i ; for ( i = 0 ; i < (int ) 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 ) ; + RetVal = Graph()->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 ; @@ -298,22 +367,22 @@ bool GraphExecutor::OutNode::LoadDatas(const GraphBase::ListOfLinks &aListOfData int i ; for ( i = 0 ; i < (int ) 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 ) ; + if ( !strcmp( aLink.FromNodeName.c_str() , Graph()->Name() ) ) + RetVal = 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 ) ; + else if ( !strcmp( aLink.ToNodeName.c_str() , Graph()->Name() ) ) { + RetVal = Graph()->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 ) ; + Graph()->AddLink( aLink.FromNodeName.c_str() , (GraphBase::ComputingNode *) this ) ; } else { cdebug << "GraphExecutor::OutNode::LoadDatas Error " << aLink.FromNodeName - << " and " << aLink.ToNodeName << " differents from " << Name() + << " and " << aLink.ToNodeName << " differents from " << Graph()->Name() << endl ; RetVal = false ; } @@ -342,15 +411,15 @@ GraphExecutor::InNode *GraphExecutor::OutNode::AddNode( cdebug_in << "GraphExecutor::OutNode::AddNode(" << NodeComponentName << " , " << NodeName << ")" << endl; GraphExecutor::InNode *Nd = NULL ; - Nd = new GraphExecutor::InNode( _Orb, NamingService() , NodeService , + Nd = new GraphExecutor::InNode( _Orb, Graph()->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() ) ; + _prof_debug , _fdebug ) ; + Graph()->AddNode( Nd->ComputingNode() ) ; cdebug_out << "GraphExecutor::OutNode::AddNode" << endl; return Nd ; } @@ -361,10 +430,10 @@ bool GraphExecutor::OutNode::AddInputData( const char* ToNodeName1 , const char* ToNodeName2 , const char* ToParameterName2 ) { cdebug_in << "GraphExecutor::OutNode::AddInputData" << endl; - bool RetVal = GraphBase::Graph::AddInputData( ToNodeName1 , - ToParameterName1 , - ToNodeName2 , - ToParameterName2 ) ; + bool RetVal = Graph()->AddInputData( ToNodeName1 , + ToParameterName1 , + ToNodeName2 , + ToParameterName2 ) ; cdebug_out << "GraphExecutor::OutNode::AddInputData" << endl; _Valid = false ; return RetVal ; @@ -378,21 +447,24 @@ bool GraphExecutor::OutNode::Valid() { _Executable = false ; - if ( !CreateService() ) { + if ( !Graph()->CreateService() ) { cdebug << "This DataFlow has invalid type(s)." << endl ; return false ; } - - if ( !Sort() ) { + int SubStreamGraphsNumber = 0 ; + if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { cdebug << "This DataFlow is not valid." << endl ; return false ; } + if ( Graph()->IsDataStreamNode() ) { + StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; + } // CreateService() ; - InLineServices() ; + Graph()->InLineServices() ; - ComputingNodes() ; + Graph()->ComputingNodes() ; _Valid = true ; @@ -407,7 +479,7 @@ bool GraphExecutor::OutNode::Executable() { if ( !IsValid() ) return false ; - if ( DataServerNodes() ) + if ( Graph()->DataServerNodes() ) _Executable = true ; else { cdebug << "This DataFlow is not executable." << endl ; @@ -425,12 +497,12 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { if ( Executable() ) { _ControlState = SUPERV::VoidState ; _SuspendedThreads = 0 ; - ThreadNo( pthread_self() ) ; + Graph()->ThreadNo( pthread_self() ) ; Done( false ) ; _JustStarted = true ; int i ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) GraphNodes( i )->GetInNode() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ; if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) { if ( !Py_IsInitialized() ) { // Py_Initialize() ; @@ -445,23 +517,28 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { } } // One more time because inline nodes may share one definition of the same function - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) GraphNodes( i )->GetInNode() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ; if ( anInNode->IsOneOfInLineNodes() ) { - if ( anInNode->InitPythonFunctions( true ) ) { + if ( !anInNode->InitPythonFunctions( true ) ) { + anInNode->State( SUPERV::ErroredState ) ; + State( SUPERV::ErroredState ) ; + cdebug_out << "GraphExecutor::OutNode::Run InitPythonFunctions ERROR " + << anInNode->Name() << endl ; + return false ; } } } cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node " - << Name() << endl ; + << Graph()->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() ; + for ( i = 0 ; i < Graph()->HeadNodesSize() ; i++ ) { + GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->HeadNodes( i )->GetInNode() ; if ( anInNode->State() != SUPERV::DataReadyState ) { cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node " << anInNode->Name() << " : " << anInNode->State() << endl ; @@ -471,7 +548,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { // PushEvent( anInNode , GraphExecutor::ReadyEvent , // SUPERV::DataReadyState ) ; anInNode->CreateNewThread( true ) ; - anInNode->DataFromNode( Name() ) ; + anInNode->DataFromNode( Graph()->Name() ) ; if ( AndSuspend ) { anInNode->State( SUPERV::DataWaitingState ) ; anInNode->ControlState( SUPERV::ToSuspendStartState ) ; @@ -505,7 +582,9 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { State( SUPERV::ExecutingState ) ; }; } - +// ostringstream astr ; +// astr << "Graph " << Graph()->Name() << " is running" ; +// Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; RetVal = true ; } else { @@ -523,7 +602,7 @@ bool GraphExecutor::OutNode::Run( const char * aNodeName , bool RetVal = false ; cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , " << AtNodeName << " , " << AndSuspend << ")" << endl; - GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ; if ( anInNode ) { RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ; } @@ -538,10 +617,10 @@ void GraphExecutor::OutNode::CheckAllDone() { SUPERV::AutomatonState InNodeState ; bool AllDone = true ; if ( !Done() ) { - for ( j = 0 ; j < QueueNodesSize() ; j++ ) { - InNodeState = ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->State() ; + for ( j = 0 ; j < Graph()->QueueNodesSize() ; j++ ) { + InNodeState = ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->State() ; cdebug << j << ". " - << ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->Name() + << ( (GraphExecutor::InNode * ) Graph()->QueueNodes( j )->GetInNode() )->Name() << " " << theAutomaton->StateName( InNodeState ) << endl ; if ( InNodeState != SUPERV::SuccessedState && InNodeState != SUPERV::ErroredState && @@ -566,9 +645,9 @@ void GraphExecutor::OutNode::CheckAllDone() { } if ( AllDone ) { int alivenodes = 0 ; - for ( j = 0 ; j < GraphNodesSize() ; j++ ) { + for ( j = 0 ; j < Graph()->GraphNodesSize() ; j++ ) { GraphExecutor::InNode * aNode ; - aNode = (GraphExecutor::InNode * ) GraphNodes( j )->GetInNode() ; + aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( j )->GetInNode() ; SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ; cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << " CreateNewThread " << aNode->CreateNewThread() @@ -607,14 +686,18 @@ void GraphExecutor::OutNode::CheckAllDone() { } if ( IsDone() ) { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " + MESSAGE( Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " << EventQSize() ) ; MESSAGE("================================================================================") ; cdebug << "================================================================================" << endl ; - cdebug << Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " + cdebug << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " << EventQSize() << endl ; cdebug << "================================================================================" << endl ; - //cout << Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " +// ostringstream astr ; +// astr << "Graph " << Graph()->Name() << " is done : " +// << theAutomaton->StateName( AutomatonState() ) ; +// Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; + //cout << Graph()->Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " // << EventQSize() << endl ; } cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << IsDone() @@ -758,7 +841,7 @@ void GraphExecutor::OutNode::ResumeThread() { long GraphExecutor::OutNode::Thread( const char * aNodeName ) { long RetVal = 0 ; - GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( aNodeName )->GetInNode() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ; if ( anInNode ) { RetVal = anInNode->ThreadNo() ; } @@ -1070,7 +1153,7 @@ bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode , _EventNodes.push_back( aNode->Name() ) ; } else { - _EventNodes.push_back( Name() ) ; + _EventNodes.push_back( Graph()->Name() ) ; } _Events.push_back( anEvent ) ; _States.push_back( aState ) ; @@ -1083,7 +1166,7 @@ bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode , // << aNode->Automaton()->ControlStateName( aNode->ControlState() ) ; } else { -// cdebug << "PushEvent " << Name() ; +// cdebug << "PushEvent " << Graph()->Name() ; // cdebug << " " << theAutomaton->EventName( anEvent ) << " " // << theAutomaton->StateName( aState ) ; } @@ -1192,8 +1275,8 @@ bool GraphExecutor::OutNode::EventW( char ** aNodeName , aState != SUPERV::RunningState && aState != SUPERV::SuspendDoneState && aState != SUPERV::SuspendErroredState ) { - NodeName = Name() ; - while ( sts && !strcmp( NodeName , Name() ) ) { + NodeName = Graph()->Name() ; + while ( sts && !strcmp( NodeName , Graph()->Name() ) ) { sts = EventWait( aNodeName , anEvent , aState ) ; NodeName = *aNodeName ; } @@ -1242,7 +1325,7 @@ bool GraphExecutor::OutNode::EventWait( char ** aNodeName , _States.pop_front() ; } - aNode = ((GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode()) ; + aNode = ((GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode()) ; cdebug << "EventW Previous Node " << NodeName << " ThreadsNumber " << ThreadsNumber << " _EventNodes.size() " << _EventNodes.size() << " " @@ -1355,7 +1438,7 @@ void GraphExecutor::OutNode::EventList() { } void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) { -// cdebug << "GraphExecutor::OutNode::State " << Name() << " " +// cdebug << "GraphExecutor::OutNode::State " << Graph()->Name() << " " // << theAutomaton->StateName( AutomatonGraphState( _State ) ) << " ---> " // << theAutomaton->StateName( AutomatonGraphState( aState ) ) << endl ; _State = aState ; @@ -1372,7 +1455,7 @@ SUPERV::GraphState GraphExecutor::OutNode::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 ) ; + const GraphBase::ComputingNode * aCNode = Graph()->GetGraphNode( NodeName ) ; if ( aCNode ) { GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ; if ( anInNode ) { @@ -1389,7 +1472,7 @@ 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 ) ; + SUPERV::GraphState aret = Graph()->PortState( NodeName , ServiceParameterName ) ; // cdebug_out << "GraphExecutor::OutNode::State" << endl ; return aret ; } @@ -1403,7 +1486,7 @@ SUPERV::AutomatonState GraphExecutor::OutNode::AutomatonState() { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) aret = anInNode->State() ; // cdebug_out << "GraphExecutor::OutNode::AutomatonState" << endl ; @@ -1419,7 +1502,7 @@ SUPERV::ControlState GraphExecutor::OutNode::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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) aret = anInNode->ControlState() ; // cdebug_out << "GraphExecutor::OutNode::ControlState" << endl ; @@ -1434,7 +1517,7 @@ void GraphExecutor::OutNode::ControlClear() { void GraphExecutor::OutNode::ControlClear( const char * NodeName ) { // cdebug_in << "GraphExecutor::OutNode::ControlClear " << NodeName << endl; - GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) GetGraphNode( NodeName )->GetInNode() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) anInNode->ControlClear() ; // cdebug_out << "GraphExecutor::OutNode::ControlClear" << endl ; @@ -1497,7 +1580,7 @@ bool GraphExecutor::OutNode::IsStopped() { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->IsWaiting() ; } @@ -1508,7 +1591,7 @@ bool GraphExecutor::OutNode::IsWaiting( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->IsReady() ; } @@ -1519,7 +1602,7 @@ bool GraphExecutor::OutNode::IsReady( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->IsRunning() ; } @@ -1530,7 +1613,7 @@ bool GraphExecutor::OutNode::IsRunning( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->IsDone() ; } @@ -1541,7 +1624,7 @@ bool GraphExecutor::OutNode::IsDone( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->IsSuspended() ; } @@ -1553,7 +1636,7 @@ bool GraphExecutor::OutNode::IsDone( const char * NodeName , const char * ServiceParameterName ) { // cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " " // << ServiceParameterName<< endl; - bool aret = PortDone( NodeName , ServiceParameterName ) ; + bool aret = Graph()->PortDone( NodeName , ServiceParameterName ) ; // cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ; return aret ; } @@ -1563,8 +1646,8 @@ bool GraphExecutor::OutNode::ContainerKill() { 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() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; bool sts = aNode->ContainerKill() ; if ( sts && aNode->IsKilled() ) { cdebug << aNode->Name() << " killed" << endl ; @@ -1580,8 +1663,8 @@ bool GraphExecutor::OutNode::ContainerKill() { } } if ( !RetVal || Threads() != 0 ) { - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) { aNode->KilledAction() ; } @@ -1598,8 +1681,8 @@ bool GraphExecutor::OutNode::Suspend() { 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() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; bool sts = aNode->Suspend() ; if ( sts && aNode->IsSuspended() ) { RetVal += 1 ; @@ -1618,12 +1701,12 @@ bool GraphExecutor::OutNode::Suspend() { if ( RetVal ) { State( SUPERV::SuspendedState ) ; MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS SUSPENDED" ) ; + MESSAGE( Graph()->Name() << " IS SUSPENDED" ) ; MESSAGE("================================================================================") ; } else { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS NOT SUSPENDED" ) ; + MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ; MESSAGE("================================================================================") ; } cdebug_out << "GraphExecutor::OutNode::Suspend" << theAutomaton->StateName( State() ) << endl ; @@ -1636,8 +1719,8 @@ bool GraphExecutor::OutNode::Resume() { if ( IsSuspended() ) { State( SUPERV::ExecutingState ) ; int i ; - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; aNode->ControlState( SUPERV::VoidState ) ; if ( aNode->IsSuspended() ) { cdebug << aNode->Name() << "->Resume " << theAutomaton->StateName( aNode->State() ) @@ -1659,16 +1742,16 @@ bool GraphExecutor::OutNode::Resume() { } } else { - cdebug << Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ; + cdebug << Graph()->Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ; } if ( RetVal ) { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS RESUMED" ) ; + MESSAGE( Graph()->Name() << " IS RESUMED" ) ; MESSAGE("================================================================================") ; } else { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS NOT RESUMED" ) ; + MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ; MESSAGE("================================================================================") ; } cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal << endl ; @@ -1680,8 +1763,8 @@ bool GraphExecutor::OutNode::Kill() { 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() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; bool sts = aNode->Kill() ; if ( sts && aNode->IsKilled() ) { cdebug << aNode->Name() << " killed" << endl ; @@ -1697,8 +1780,8 @@ bool GraphExecutor::OutNode::Kill() { } } if ( !RetVal || Threads() != 0 ) { - for ( i = 0 ; i < GraphNodesSize() ; i++ ) { - GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) { cdebug << aNode->Name() << " not killed : " << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->" @@ -1711,15 +1794,16 @@ bool GraphExecutor::OutNode::Kill() { State( SUPERV::KilledState ) ; if ( RetVal ) { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS KILLED" ) ; + MESSAGE( Graph()->Name() << " IS KILLED" << theAutomaton->StateName( AutomatonState() ) << " EventQSize " + << EventQSize() ) ; MESSAGE("================================================================================") ; } else { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS NOT KILLED" ) ; + MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ; MESSAGE("================================================================================") ; } - cdebug_out << "GraphExecutor::OutNode::Kill" << endl ; + cdebug_out << "GraphExecutor::OutNode::Kill " << RetVal << endl ; return RetVal ; } @@ -1730,7 +1814,7 @@ bool GraphExecutor::OutNode::Stop() { cdebug_out << "GraphExecutor::OutNode::Stop" << endl ; if ( RetVal ) { MESSAGE("================================================================================") ; - MESSAGE( Name() << " IS STOPPED" ) ; + MESSAGE( Graph()->Name() << " IS STOPPED" ) ; MESSAGE("================================================================================") ; } return RetVal ; @@ -1840,7 +1924,7 @@ bool GraphExecutor::OutNode::SuspendedWait() { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->ReadyWait() ; } @@ -1851,7 +1935,7 @@ bool GraphExecutor::OutNode::ReadyWait( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->RunningWait() ; } @@ -1862,7 +1946,7 @@ bool GraphExecutor::OutNode::RunningWait( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->DoneWait() ; } @@ -1873,7 +1957,7 @@ bool GraphExecutor::OutNode::DoneWait( const char * NodeName ) { 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() ; + GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( NodeName )->GetInNode() ; if ( anInNode ) { aret = anInNode->SuspendedWait() ; } @@ -1884,14 +1968,14 @@ bool GraphExecutor::OutNode::SuspendedWait( const char * NodeName ) { 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 ) ; + for ( i = 0 ; i <= Graph()->LevelMax() ; i++ ) { + for ( j = 0 ; j <= Graph()->NodesNumber( i ) ; j++ ) { + GraphBase::ComputingNode * aNode = Graph()->SortedNodes( i , j ) ; if ( !IsDone( aNode->Name() ) ) { break ; } } - if ( j != NodesNumber( i ) + 1 ) + if ( j != Graph()->NodesNumber( i ) + 1 ) break ; RetVal = i ; } @@ -1903,7 +1987,7 @@ 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 ) ; + const CORBA::Any * retdata = Graph()->PortInData( NodeName , ServiceParameterName ) ; // cdebug_out << "GraphExecutor::OutNode::GetInData" << endl ; return retdata ; } @@ -1912,17 +1996,17 @@ const CORBA::Any *GraphExecutor::OutNode::GetOutData( const char * NodeName , const char * ServiceParameterName ) { // cdebug_in << "GraphExecutor::OutNode::GetOutData " << NodeName << " " // << ServiceParameterName << endl ; - const CORBA::Any * retdata = PortOutData( NodeName , ServiceParameterName ) ; + const CORBA::Any * retdata = Graph()->PortOutData( NodeName , ServiceParameterName ) ; // cdebug_out << "GraphExecutor::OutNode::GetOutData" << endl ; return retdata ; } const long GraphExecutor::OutNode::CpuUsed() { - return GraphBase::Graph::CpuUsed() ; + return Graph()->CpuUsed() ; } const long GraphExecutor::OutNode::CpuUsed( const char * aNodeName ) { - GraphBase::ComputingNode * aNode = GetChangeGraphNode( aNodeName ) ; + GraphBase::ComputingNode * aNode = Graph()->GetChangeGraphNode( aNodeName ) ; if ( aNode ) { GraphExecutor::InNode * anInNode = (GraphExecutor::InNode * ) aNode->GetInNode() ; if ( anInNode ) { diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx index 1f764f5..2676c74 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx @@ -31,16 +31,22 @@ #include "SALOME_Component_i.hxx" -#include "DataFlowBase_Graph.hxx" - #include "DataFlowExecutor_InNode.hxx" +#include "DataFlowBase_StreamGraph.hxx" + namespace GraphExecutor { - class OutNode : public GraphBase::Graph { +// class OutNode : public GraphBase::Graph { + class OutNode : public GraphBase::Base { private : + GraphBase::StreamGraph * _StreamGraph ; + GraphBase::Graph * _Graph ; + + int _Graph_prof_debug ; + bool _PyInitialized ; bool _Valid ; bool _Executable ; @@ -74,7 +80,8 @@ namespace GraphExecutor { OutNode() ; OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const char *DataFlowName , - const char * DebugFileName ); + const char * DebugFileName , + const SUPERV::KindOfNode aKindOfNode ); OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService , const SALOME_ModuleCatalog::Service& DataFlowService , const char *DataFlowComponentName , @@ -90,6 +97,16 @@ namespace GraphExecutor { const char * DebugFileName ) ; virtual ~OutNode() ; + void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ; + GraphBase::StreamGraph * StreamGraph() { + return _StreamGraph ; } ; + GraphBase::StreamGraph * StreamGraph() const { + return _StreamGraph ; } ; + GraphBase::Graph * Graph() { + return _Graph ; } ; + GraphBase::Graph * Graph() const { + return _Graph ; } ; + bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ; bool LoadXml( const char* myFileName ) ; bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ; @@ -147,6 +164,8 @@ namespace GraphExecutor { long SuspendedThreads() { return _SuspendedThreads ; } ; void JoinedWait() ; + pthread_t ThreadNo() { + return _Graph->ThreadNo() ; } ; long Thread( const char * NodeName ) ; bool PushEvent( GraphExecutor::InNode * aNode , diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 03fe20f..22ac4d0 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -104,8 +104,10 @@ bool GraphExecutor::InNode::InitPython() { } PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName , - const SUPERV::ListOfStrings * aPythonFunction ) { + const SUPERV::ListOfStrings * aPythonFunction , + bool & Err ) { bool RetVal = true ; + Err = false ; string aPyFunc ; PyObject * thePyRunMethod = NULL ; @@ -129,6 +131,7 @@ PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName , if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ; RetVal = false ; + Err = true ; } else { PyFuncRunned( true ) ; diff --git a/src/GraphExecutor/Makefile.in b/src/GraphExecutor/Makefile.in index 6582602..2786b4f 100644 --- a/src/GraphExecutor/Makefile.in +++ b/src/GraphExecutor/Makefile.in @@ -47,13 +47,12 @@ 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 -Wno-deprecated CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ -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 -lSALOMELocalTrace \ -lc $(QT_MT_LIBS) $(OGL_LIBS) \ -L${KERNEL_ROOT_DIR}/lib/salome +#LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) @CONCLUDE@ diff --git a/src/MulComponent/MulComponent.cxx b/src/MulComponent/MulComponent.cxx new file mode 100644 index 0000000..1b4c41f --- /dev/null +++ b/src/MulComponent/MulComponent.cxx @@ -0,0 +1,90 @@ +// SuperVisionTest MulComponent : example of component that multiplies two numbers +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : MulComponentEngine.cxx +// Author : MARC TAJCHMAN, CEA +// Module : SuperVisionTest + +using namespace std; +#include +#include +#include +#include +#include + +//#include "utilities.h" +#include "MulComponent.hxx" + +MulComponentEngine::MulComponentEngine( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) +{ +// MESSAGE("MulComponentEngine::MulComponentEngine activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ")" ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _nexec = 0 ; +} + +MulComponentEngine::MulComponentEngine() +{ +} + +MulComponentEngine::~MulComponentEngine() +{ +} + +void MulComponentEngine::Mul( double x , double y , double & z ) { + beginService( " MulComponentEngine::Mul" ); + z = x * y ; + int S; + + sendMessage(NOTIF_STEP, "Mul is Computing"); + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + MESSAGE( "MulComponentEngine::Mul( " << x << " , " << y << " , " << z + << " ) after " << S << " seconds" ) + endService( " MulComponentEngine::Mul" ); +} + +extern "C" +{ + PortableServer::ObjectId * MulComponentEngine_factory + (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("MulComponentEngine_factory MulComponentEngine (" + << instanceName << "," << interfaceName << ")"); + MulComponentEngine * myMulComponent + = new MulComponentEngine(orb, poa, contId, instanceName, interfaceName); + return myMulComponent->getId() ; + } +} + + diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in index 1598252..1cb62bb 100644 --- a/src/SUPERVGUI/Makefile.in +++ b/src/SUPERVGUI/Makefile.in @@ -96,7 +96,7 @@ LIB_SERVER_IDL = CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+=$(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS)\ - -lSalomeGUI -lSalomeNS -lqsplitterP \ + -lSalomeGUI -lSalomeNS -lqsplitterP -lEvent \ -lSalomeLifeCycleCORBA -lSalomeNotification -lSUPERVGraph \ -L${KERNEL_ROOT_DIR}/lib/salome diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index 5f57e85..64aa853 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -49,13 +49,14 @@ using namespace std; int SUPERVGUI::factory = 0; -SUPERVGUI Supervision; +SUPERVGUI Supervision(""); -SUPERVGUI::SUPERVGUI(): QObject(), - desktop(0), - study(0), - browser(0) +SUPERVGUI::SUPERVGUI(const QString& theName, QObject* theParent) + : SALOMEGUI( theName, theParent ), + desktop(0), + study(0), + browser(0) //info(0) { Trace("SUPERVGUI::SUPERVGUI") @@ -91,6 +92,10 @@ void SUPERVGUI::init(QAD_Desktop* parent) { //info = new SUPERVGUI_Information(); cursor = desktop->cursor(); connect(desktop->getMainFrame(), SIGNAL(windowActivated(QWidget*)), this, SLOT(setMain(QWidget*))); + + int anId = 300; + parent->menuBar()->changeItem(anId,parent->getComponentUserName("SUPERV")); + }; } @@ -100,7 +105,7 @@ QAD_StudyFrame* SUPERVGUI::createGraph() { VIEW_GRAPHSUPERV, false); if (aStudyFrame) { connect(aStudyFrame, - SIGNAL(sfBeforeStudyFrameClosing(QAD_StudyFrame*)), + SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*)), &Supervision, SLOT(onGraphClosed(QAD_StudyFrame*))); } @@ -236,7 +241,7 @@ void SUPERVGUI::importDataflow() { return; } - SUPERV_Graph aGraph = engine->GraphE(f); + SUPERV_Graph aGraph = engine->StreamGraphE(f); //QFileInfo aFile(f); //aGraph->SetName(aFile.baseName()); if (SUPERV_isNull(aGraph)) { @@ -274,7 +279,7 @@ void SUPERVGUI::displayDataflow() { QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) return; } - aDataFlow = engine->getGraph(ior); + aDataFlow = engine->getStreamGraph(ior); if (SUPERV_isNull(aDataFlow)) { QMessageBox::warning(0, tr("ERROR"), tr("MSG_ACCESS_BAD_IOR")); return; @@ -365,7 +370,7 @@ void SUPERVGUI::modifyDataflow() { return; } - SUPERV_Graph aGraph = engine->Graph(f); + SUPERV_Graph aGraph = engine->StreamGraph(f); //QFile aFile(f); //aGraph->SetName(aFile.name()); if (SUPERV_isNull(aGraph)) { @@ -441,8 +446,10 @@ void SUPERVGUI::showComponents() { } } -void SUPERVGUI::customPopup(QPopupMenu* popup) { + +bool SUPERVGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject) { Trace("SUPERVGUI::customPopup"); + Supervision.init(parent); if(popup->count() > 3) { // Temporary code: is to be deleted soon popup->removeItem(QAD_Display_Popup_ID); @@ -453,7 +460,7 @@ void SUPERVGUI::customPopup(QPopupMenu* popup) { // Temporary code end } SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() ); - if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return; + if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return false; if (Sel->IObjectCount() == 1) { Handle(SALOME_InteractiveObject) anIObj = Sel->firstIObject(); @@ -484,6 +491,7 @@ void SUPERVGUI::customPopup(QPopupMenu* popup) { if (aIObjCount == Sel->IObjectCount()) //all selected objects belong to Supervision popup->insertItem(tr("MSG_DELETE"), this, SLOT(deleteObject())); } + return(true); } @@ -514,7 +522,7 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b SALOMEDS::GenericAttribute_var anAttr; if (obj->FindAttribute(anAttr, "AttributeIOR")) { SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - SUPERV_Graph aDataFlow = engine->getGraph(anIOR->Value()); + SUPERV_Graph aDataFlow = engine->getStreamGraph(anIOR->Value()); if (!SUPERV_isNull(aDataFlow)) theIsDataflow = true; } @@ -573,105 +581,81 @@ void SUPERVGUI::deleteObject() { Sel->ClearIObjects() ; } - - -void SUPERVGUI::activeStudyChanged() { - Trace("SUPERVGUI::activeStudyChanged"); - study = desktop->getActiveStudy(); -} - -extern "C" bool OnGUIEvent(int command, QAD_Desktop* parent) { - Supervision.init(parent); - switch (command) { - case 301: - Supervision.importDataflow(); - return(false); - - case 302: - Supervision.exportDataflow(); - return(false); - - case 303: - Supervision.newDataflow(); - return(false); - - case 304: - Supervision.modifyDataflow(); - return(false); - - case 305: - Supervision.reloadDataflow(); - return(false); - - case 306: - Supervision.runDataflow(); - return(false); - - case 307: - Supervision.killDataflow(); - return(false); - - case 308: - Supervision.suspendResumeDataflow(); - return(false); - - case 309: - Supervision.showComponents(); - return(false); - - case 310: - Supervision.stepByStep(); - return(false); - - default: - QMessageBox::warning(QAD_Application::getDesktop(), "Supervision Error", "Unknown Command From Salome"); - return(false); - - } -} - -extern "C" bool OnKeyPress(QKeyEvent* e, QAD_Desktop* parent, SUPERVGUI_Main* s) { +bool SUPERVGUI::OnGUIEvent(int command, QAD_Desktop* parent) { + Supervision.init(parent); + switch (command) { + case 301: + Supervision.importDataflow(); return(false); -} - -extern "C" bool OnMousePress(QMouseEvent* e, QAD_Desktop* parent, SUPERVGUI_Main* s) { + + case 302: + Supervision.exportDataflow(); return(false); -} - -extern "C" bool OnMouseMove(QMouseEvent* e, QAD_Desktop* parent, SUPERVGUI_Main* s) { + + case 303: + Supervision.newDataflow(); return(false); -} - -extern "C" bool OnPopupGUIEvent(int theCommandID, QAD_Desktop* parent) { + + case 304: + Supervision.modifyDataflow(); return(false); + + case 305: + Supervision.reloadDataflow(); + return(false); + + case 306: + Supervision.runDataflow(); + return(false); + + case 307: + Supervision.killDataflow(); + return(false); + + case 308: + Supervision.suspendResumeDataflow(); + return(false); + + case 309: + Supervision.showComponents(); + return(false); + + case 310: + Supervision.stepByStep(); + return(false); + + default: + QMessageBox::warning(QAD_Application::getDesktop(), "Supervision Error", "Unknown Command From Salome"); + return(false); + } } -extern "C" bool SetSettings(QAD_Desktop* parent) { - Trace("extern SUPERVGUI::SetSettings") - Supervision.init(parent); - return(true); -} - -extern "C" void definePopup(QString& theContext, QString& theParent, QString& theObject) { - theObject = ""; - theContext = ""; +bool SUPERVGUI::SetSettings(QAD_Desktop* parent) { + Trace("SUPERVGUI::SetSettings"); + Supervision.init(parent); + return(true); } -extern "C" bool customPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, const QString& theParent, const QString& theObject) { - Supervision.init(parent); - Supervision.customPopup(popup); - return(true); +void SUPERVGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject) { + theObject = ""; + theContext = ""; } -extern "C" void activeStudyChanged(QAD_Desktop* parent) { - Supervision.activeStudyChanged(); +bool SUPERVGUI::ActiveStudyChanged(QAD_Desktop* parent) { + Trace("SUPERVGUI::activeStudyChanged"); + study = desktop->getActiveStudy(); + return true; } -extern "C" int supportedViewType() +void SUPERVGUI::SupportedViewType (int* buffer, int bufferSize) { - return (int)VIEW_GRAPHSUPERV; + if (!buffer || !bufferSize) return; + buffer[0] = (int)VIEW_GRAPHSUPERV; } -extern "C" void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) +extern "C" { + Standard_EXPORT SALOMEGUI* GetComponentGUI() { + return &Supervision; + } } diff --git a/src/SUPERVGUI/SUPERVGUI.h b/src/SUPERVGUI/SUPERVGUI.h index 3bf4606..977e719 100644 --- a/src/SUPERVGUI/SUPERVGUI.h +++ b/src/SUPERVGUI/SUPERVGUI.h @@ -28,7 +28,7 @@ #ifndef SUPERVGUI_H #define SUPERVGUI_H -// Acces a l'ihm de SALOME +// Acces a l`ihm de SALOME // ----------------------- #include "QAD_Desktop.h" @@ -39,15 +39,16 @@ #include "SUPERVGUI_Main.h" //#include "SUPERVGUI_Information.h" +#include "SALOMEGUI.h" // Definition de la classe principale du module de supervision // ----------------------------------------------------------- -class SUPERVGUI: public QObject { +class SUPERVGUI: public SALOMEGUI { Q_OBJECT public: - SUPERVGUI(); + SUPERVGUI( const QString&, QObject* = 0 ); virtual ~SUPERVGUI(); QAD_Desktop* getDesktop(); @@ -73,8 +74,19 @@ class SUPERVGUI: public QObject { void init(QAD_Desktop* parent); SUPERVGUI_Main* getMain(); - void customPopup(QPopupMenu* popup); - void activeStudyChanged(); + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + bool SetSettings(QAD_Desktop* parent); + void DefinePopup(QString & theContext, + QString & theParent, + QString & theObject ) ; + bool CustomPopup(QAD_Desktop* parent, + QPopupMenu* popup, + const QString & theContext, + const QString & theParent, + const QString & theObject); + bool ActiveStudyChanged( QAD_Desktop* parent ); + void SupportedViewType (int* buffer, int bufferSize); bool isContains(QAD_Study* theStudy, const QString theKey); diff --git a/src/SUPERVGUI/SUPERVGUI_Def.h b/src/SUPERVGUI/SUPERVGUI_Def.h index 2145c27..8a8c906 100644 --- a/src/SUPERVGUI/SUPERVGUI_Def.h +++ b/src/SUPERVGUI/SUPERVGUI_Def.h @@ -95,7 +95,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true // ---------------------------- #define LABEL_WIDTH 160 -#define LABEL_HEIGHT 20 +#define LABEL_HEIGHT 15 // Taille de la boite de filtre de notification // -------------------------------------------- @@ -174,7 +174,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_Engine SUPERV::SuperG_var -#define SUPERV_Graph SUPERV::Graph_var +#define SUPERV_Graph SUPERV::StreamGraph_var #define SUPERV_CNode SUPERV::CNode_var #define SUPERV_FNode SUPERV::FNode_var @@ -187,12 +187,14 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_Links SUPERV::ListOfLinks_var #define SUPERV_Ports SUPERV::ListOfPorts_var +#define SUPERV_StreamPorts SUPERV::ListOfStreamPorts_var #define SUPERV_Nodes SUPERV::ListOfNodes_var #define SUPERV_Strings SUPERV::ListOfStrings_var #define SUPERV_Link SUPERV::Link_var #define SUPERV_Date SUPERV::SDate #define SUPERV_Port SUPERV::Port_var +#define SUPERV_StreamPort SUPERV::StreamPort_var #define SUPERV_Editing SUPERV::EditingState #define SUPERV_Running SUPERV::RunningState diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.cxx b/src/SUPERVGUI/SUPERVGUI_Graph.cxx index b1f2084..d1feb17 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Graph.cxx @@ -33,6 +33,11 @@ using namespace std; #include "SUPERVGUI_ControlNode.h" #include "SUPERVGUI.h" +#include +#include +#include +#include +#include //#define CHECKTIME @@ -263,6 +268,7 @@ void SUPERVGUI_Graph::contentsMousePressEvent(QMouseEvent* e) { main->showPopup(myLinkPopup, e); } else { mySelectedLink = 0; + addDSPopupItem(); main->showPopup(myPopup, e); } } @@ -320,21 +326,27 @@ void SUPERVGUI_Graph::deleteLink() { void SUPERVGUI_Graph::deleteLink(SUPERVGUI_Link* theLink) { - //update values of input ports of theLink if theLink is deleted - if ( theLink->getInputPort() ) { - //input port exist + if (getMain()->getDataflow()->IsDone()) { + //update values of input ports of theLink if theLink is deleted and dataflow has been executed any times SUPERVGUI_PortIn* aInPort = theLink->getInputPort(); - if (aInPort->getPort()->IsParam() || aInPort->getPort()->IsInLine()) { - QString aPortValue = QString(aInPort->getPort()->ToString()); - if (!aPortValue.isNull()) { + if ( aInPort ) { + //input port exist + QString aPortValue = QString(aInPort->getPort()->ToString()); + if ( (aInPort->getPort()->IsParam() || aInPort->getPort()->IsInLine()) + && + !aPortValue.isNull()) { //gives a value to an input port theLink->destroyEngine(); aInPort->getPort()->Input( Supervision.getEngine()->StringValue( aPortValue ) ); aInPort->sync(); } + else + theLink->destroyEngine(); } + else + theLink->destroyEngine(); } - else + else theLink->destroyEngine(); myLinksList.removeRef(theLink); @@ -413,7 +425,9 @@ void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) { if (aName != "Default") myNewLink->setInputPortES(dynamic_cast(thePort)); } - else{ + else if (aPort->Kind() == SUPERV::DataStreamParameter){ + myNewLink->setInputPort(dynamic_cast(thePort)); + } else { if (aPort->IsLinked()) return; if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) { @@ -437,22 +451,23 @@ void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) { } else return; - } - else { + } else { int aKind = myNewLink->getInputPort()->getPort()->Kind(); if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) { - if (aKind != aPort->Kind() && aKind != SUPERV::InLineParameter - && aPort->Kind() != SUPERV::InLineParameter) { + if (aKind != aPort->Kind() && + aKind != SUPERV::InLineParameter && + aPort->Kind() != SUPERV::InLineParameter) { return; - } - else //connection like Gate <--> Gate - myNewLink->setOutputPort(dynamic_cast(thePort)); - } else + } else //connection like Gate <--> Gate + myNewLink->setOutputPort(dynamic_cast(thePort)); + } else if (aPort->Kind() == SUPERV::DataStreamParameter){ + myNewLink->setOutputPort(dynamic_cast(thePort)); + } else myNewLink->setOutputPort(dynamic_cast(thePort)); } } - + if (myNewLink->isCreationComplete()) { // if everything is defined if (myNewLink->createEngine()) { myLinksList.append(myNewLink); @@ -628,3 +643,113 @@ void SUPERVGUI_Graph::deleteNode(SUPERVGUI_Node* theNode) { draw(); } +/*! + Constructor +*/ +SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly) + : QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + Trace("SUPERVGUI_DSGraphParameters::SUPERVGUI_DSGraphParameters"); + setCaption( tr( "TLT_DSGRAPHPARAMS" ) ); + setSizeGripEnabled( true ); + myGraph = theGraph; + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + // DeltaTime + QLabel* DeltaTimeL = new QLabel( tr( "DELTATIME_LBL" ), TopGroup ); + TopGroupLayout->addWidget( DeltaTimeL, 0, 0 ); + + myDeltaTime = new QAD_SpinBoxDbl( TopGroup, 0.0, 1.0, 0.1); + myDeltaTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TopGroupLayout->addWidget( myDeltaTime, 0, 1 ); + + // TimeOut + QLabel* TimeOutL = new QLabel( tr( "TIMEOUT_LBL" ), TopGroup); + TopGroupLayout->addWidget( TimeOutL, 1, 0 ); + + myTimeOut = new QLineEdit( TopGroup ); + myTimeOut->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTimeOut->setValidator( new QIntValidator(this) ); + myTimeOut->setMinimumSize( 100, 0 ); + myTimeOut->setReadOnly( isReadOnly ); + TopGroupLayout->addWidget( myTimeOut, 1, 1 ); + + // DataStreamTrace + QLabel* DataStreamTraceL = new QLabel( tr( "DATASTREAMTRACE_LBL" ), TopGroup); + TopGroupLayout->addWidget( DataStreamTraceL, 2, 0 ); + + myDataStreamTrace = new QComboBox( TopGroup ); + myDataStreamTrace->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myDataStreamTrace->insertItem("WithoutTrace"); + myDataStreamTrace->insertItem("SummaryTrace"); + myDataStreamTrace->insertItem("DetailedTrace"); + TopGroupLayout->addWidget( myDataStreamTrace, 2, 1 ); + + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + setData(); +} + +/*! + Destructor +*/ +SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters() { + Trace("SUPERVGUI_DSGraphParameters::~SUPERVGUI_DSGraphParameters"); +} + +/*! + Sets data function +*/ +void SUPERVGUI_DSGraphParameters::setData() { + double aDeltaTime; + long aTimeOut; + SUPERV::KindOfDataStreamTrace aDataStreamTrace; + + myGraph->StreamParams(aTimeOut, aDataStreamTrace, aDeltaTime); + + myDeltaTime->setValue(aDeltaTime); + myTimeOut->setText(QString("%1").arg(aTimeOut)); + myDataStreamTrace->setCurrentItem((int)aDataStreamTrace); +} + +/*! + button slot +*/ +void SUPERVGUI_DSGraphParameters::accept() { + myGraph->SetStreamParams( myTimeOut->text().toLong(), + (SUPERV::KindOfDataStreamTrace) myDataStreamTrace->currentItem(), + myDeltaTime->value()); + QDialog::accept(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.h b/src/SUPERVGUI/SUPERVGUI_Graph.h index dcde3ea..a3e6dce 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.h +++ b/src/SUPERVGUI/SUPERVGUI_Graph.h @@ -34,7 +34,11 @@ using namespace std; #include "SUPERVGUI_Node.h" #include "SUPERVGUI_Link.h" #include "SUPERVGUI_CtrlLink.h" +#include "SUPERVGUI_Def.h" +#include "QAD_SpinBoxDbl.h" #include +#include +#include class SUPERVGUI_Main; @@ -116,4 +120,26 @@ private slots: QMap myCtrlLinks; }; +//************************************************************** +class SUPERVGUI_DSGraphParameters: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_DSGraphParameters(SUPERV_Graph theGraph, bool isReadOnly); + virtual ~SUPERVGUI_DSGraphParameters(); + + private slots: + void accept(); + + private: + + void setData(); + + QAD_SpinBoxDbl* myDeltaTime; + QLineEdit* myTimeOut; + QComboBox* myDataStreamTrace; + + SUPERV_Graph myGraph; +}; + #endif diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx index af07998..75a214f 100644 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx @@ -31,6 +31,19 @@ SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* the myValuesBox = new QWidget(myPortsBox); myPortLayout = new QGridLayout(myValuesBox, 0, 2, 0, 1); + SUPERV_StreamPorts aStreamPorts = myNode->StreamPorts(); + int aStreamNb = aStreamPorts->length(); + if (aStreamNb) { + myStreamBox = new QFrame(myPortsBox); + myStreamBox->setPaletteForegroundColor(red.dark()); + myStreamBox->setPaletteBackgroundColor(paletteBackgroundColor()); + myStreamBox->setFrameStyle( QFrame::Box | QFrame::Plain ); + myStreamBox->setLineWidth(1); + myStreamLayout = new QGridLayout(myStreamBox, 0, 2, 2, 3); + } else { + myStreamBox = 0; + myStreamLayout = 0; + } myGatesBox = new QFrame(myPortsBox); myGatesBox->setFrameStyle( QFrame::Panel | QFrame::Raised ); myGatesBox->setLineWidth(2); @@ -59,35 +72,47 @@ SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* the if (ports[i]->IsInput()) { if (getComputingNode()->IsEndSwitch()) { if (ports[i]->IsGate()) - myGatesLayout->addWidget(new SUPERVGUI_PortInESNode(myGatesBox, myMain, ports[i]), + myGatesLayout->addWidget(new SUPERVGUI_PortInESNode(myGatesBox, myMain, ports[i].in()), 0, 0); else { - myPortLayout->addWidget(new SUPERVGUI_PortInESNode(myValuesBox, myMain, ports[i]), + myPortLayout->addWidget(new SUPERVGUI_PortInESNode(myValuesBox, myMain, ports[i].in()), myPIcount, 0); myPIcount++; } } else { if (ports[i]->IsGate()) - myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i]), + myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i].in()), 0, 0); else { - myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i]), + myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i].in()), myPIcount, 0); myPIcount++; } } } else { if (ports[i]->IsGate()) - myGatesLayout->addWidget(new SUPERVGUI_PortOut(myGatesBox, myMain, ports[i]), + myGatesLayout->addWidget(new SUPERVGUI_PortOut(myGatesBox, myMain, ports[i].in()), 0, 1, Qt::AlignRight); else { - myPortLayout->addWidget(new SUPERVGUI_PortOut(myValuesBox, myMain, ports[i]), + myPortLayout->addWidget(new SUPERVGUI_PortOut(myValuesBox, myMain, ports[i].in()), myPOcount, 1, Qt::AlignRight); myPOcount++; } } } - + myStrPIcount = 0; + myStrPOcount = 0; + for (int i=0; i < aStreamNb; i++) { + if (aStreamPorts[i]->IsInput()) { + myStreamLayout->addWidget(new SUPERVGUI_StreamPortIn(myStreamBox, myMain, aStreamPorts[i].in()), + myStrPIcount, 0); + myStrPIcount++; + } else { + myStreamLayout->addWidget(new SUPERVGUI_StreamPortOut(myStreamBox, myMain, aStreamPorts[i].in()), + myStrPOcount, 1, Qt::AlignRight); + myStrPOcount++; + } + } } @@ -374,7 +399,7 @@ void SUPERVGUI_GraphNode::addInputPort() { if (aPort == NULL) return; if (getNodeType() == SUPERV::EndSwitchNode) { - SUPERVGUI_PortInESNode* aPortPrs = new SUPERVGUI_PortInESNode(myValuesBox, myMain, aPort); + SUPERVGUI_PortInESNode* aPortPrs = new SUPERVGUI_PortInESNode(myValuesBox, myMain, aPort.in()); myPortLayout->addWidget(aPortPrs, myPIcount, 0); if (myPortsBox->isVisible()) { @@ -382,7 +407,7 @@ void SUPERVGUI_GraphNode::addInputPort() { } } else { - SUPERVGUI_PortIn* aPortPrs = new SUPERVGUI_PortIn(myValuesBox, myMain, aPort); + SUPERVGUI_PortIn* aPortPrs = new SUPERVGUI_PortIn(myValuesBox, myMain, aPort.in()); myPortLayout->addWidget(aPortPrs, myPIcount, 0); if (myPortsBox->isVisible()) { @@ -400,7 +425,7 @@ void SUPERVGUI_GraphNode::addOutputPort() { SUPERV_Port aPort = createOutPort(); if (aPort == NULL) return; - SUPERVGUI_PortOut* aPortPrs = new SUPERVGUI_PortOut(myValuesBox, myMain, aPort); + SUPERVGUI_PortOut* aPortPrs = new SUPERVGUI_PortOut(myValuesBox, myMain, aPort.in()); myPortLayout->addWidget(aPortPrs, myPOcount, 1, Qt::AlignRight); myPOcount++; if (myPortsBox->isVisible()) { @@ -425,10 +450,10 @@ void SUPERVGUI_GraphNode::updatePorts() { if (aPorts[i]->IsInput()) { SUPERVGUI_PortIn* aPortIn; if (aPorts[i]->IsGate()) { - aPortIn = new SUPERVGUI_PortIn(myGatesBox, myMain, aPorts[i]); + aPortIn = new SUPERVGUI_PortIn(myGatesBox, myMain, aPorts[i].in()); myGatesLayout->addWidget(aPortIn, myPIcount, 0); } else { - aPortIn = new SUPERVGUI_PortIn(myValuesBox, myMain, aPorts[i]); + aPortIn = new SUPERVGUI_PortIn(myValuesBox, myMain, aPorts[i].in()); myPortLayout->addWidget(aPortIn, myPIcount, 0); myPIcount++; } @@ -437,10 +462,10 @@ void SUPERVGUI_GraphNode::updatePorts() { } else { SUPERVGUI_PortOut* aPortOut; if (aPorts[i]->IsGate()) { - aPortOut = new SUPERVGUI_PortOut(myGatesBox, myMain, aPorts[i]); + aPortOut = new SUPERVGUI_PortOut(myGatesBox, myMain, aPorts[i].in()); myGatesLayout->addWidget(aPortOut, myPOcount, 1, Qt::AlignRight); } else { - aPortOut = new SUPERVGUI_PortOut(myValuesBox, myMain, aPorts[i]); + aPortOut = new SUPERVGUI_PortOut(myValuesBox, myMain, aPorts[i].in()); myPortLayout->addWidget(aPortOut, myPOcount, 1, Qt::AlignRight); myPOcount++; } diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.h b/src/SUPERVGUI/SUPERVGUI_GraphNode.h index 1378581..03c227f 100644 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.h +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.h @@ -65,11 +65,17 @@ class SUPERVGUI_GraphNode: public SUPERVGUI_Node { QFrame* myGatesBox; QGridLayout* myGatesLayout; + + QFrame * myStreamBox; + QGridLayout* myStreamLayout; QTimer* myTimer; int myPIcount; int myPOcount; + int myStrPIcount; + int myStrPOcount; + private: void StartTimer(); void StopTimer(); diff --git a/src/SUPERVGUI/SUPERVGUI_Information.cxx b/src/SUPERVGUI/SUPERVGUI_Information.cxx index 1151a77..5ee9b3c 100644 --- a/src/SUPERVGUI/SUPERVGUI_Information.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Information.cxx @@ -88,7 +88,8 @@ SUPERVGUI_Information::SUPERVGUI_Information(SUPERV_CNode node, bool isReadOnly) compnameV->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); compnameV->setMinimumSize( 200, 0 ); compnameV->setReadOnly( true/*isReadOnly*/ ); - compnameV->setText( SUPERV::FNode::_narrow(node)->GetComponentName() ); + compnameV->setText( QAD_Application::getDesktop()->getComponentUserName( + SUPERV::FNode::_narrow(node)->GetComponentName()) ); intnameL = new QLabel( tr( "INTERFACE_NAME_LBL" ), TopGroup ); intnameV = new QLineEdit( TopGroup ); diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx index d7e5a82..80158db 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Link.cxx @@ -253,7 +253,8 @@ void SUPERVGUI_Link::paint(bool toErase) { if (toErase) { aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); } else { - if (strcmp(myEngine->InPort()->Name(), "InVoid")==0) + if ((strcmp(myEngine->InPort()->Name(), "InVoid")==0) || + (myEngine->InPort()->Kind() == SUPERV::DataStreamParameter )) aDataPen.setColor(CTRL_CLR); else aDataPen.setColor(DRAW_CLR); @@ -279,7 +280,8 @@ void SUPERVGUI_Link::paint(QPainter* thePainter, bool toErase) { if (toErase) { aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); } else { - if (strcmp(myEngine->InPort()->Name(), "InVoid")==0) + if ((strcmp(myEngine->InPort()->Name(), "InVoid")==0)|| + (myEngine->InPort()->Kind() == SUPERV::DataStreamParameter )) aDataPen.setColor(CTRL_CLR); else aDataPen.setColor(DRAW_CLR); @@ -395,12 +397,20 @@ void SUPERVGUI_Link::setVisible(bool theVisible) { bool SUPERVGUI_Link::isCreationComplete() { bool aIsBoth = myPortIn && myPortOut; if (myPortIn && myPortOut) { + // Check: is the same node? SUPERV_Port aInPort = myPortIn->getPort(); QString aInNodeName(aInPort->Node()->Name()); SUPERV_Port aOutPort = myPortOut->getPort(); QString aOutNodeName(aOutPort->Node()->Name()); + + bool aCanCreate = true; + // Stream port can be connected only with stream port + if (myPortIn->getPort()->Kind() == SUPERV::DataStreamParameter) + aCanCreate = (myPortOut->getPort()->Kind() == SUPERV::DataStreamParameter); + else if (myPortOut->getPort()->Kind() == SUPERV::DataStreamParameter) + aCanCreate = (myPortIn->getPort()->Kind() == SUPERV::DataStreamParameter); - return (aInNodeName != aOutNodeName); + return aCanCreate && (aInNodeName != aOutNodeName); } else if (myPortInES && myPortOut) { SUPERV_Port aInPortES = myPortInES->getPort(); @@ -447,10 +457,16 @@ bool SUPERVGUI_Link::createEngine() { } // Create engine - if (!isESInputPort()) - myEngine = myGraph->getMain()->getDataflow()-> - Link(myPortOut->getPort(), myPortIn->getPort()); - else + if (!isESInputPort()) { + if (myStartPort->getPort()->Kind() == SUPERV::DataStreamParameter) { + SUPERVGUI_StreamPortOut* aOut = dynamic_cast(myPortOut); + SUPERVGUI_StreamPortIn* aIn = dynamic_cast(myPortIn); + myEngine = myGraph->getMain()->getDataflow()-> + StreamLink(aOut->getStreamPort(), aIn->getStreamPort()); + } else + myEngine = myGraph->getMain()->getDataflow()-> + Link(myPortOut->getPort(), myPortIn->getPort()); + } else myEngine = myGraph->getMain()->getDataflow()-> Link(myPortOut->getPort(), myPortInES->getPort()); @@ -556,6 +572,7 @@ void SUPERVGUI_Link::onMousePress(QMouseEvent * theEvent) { return; } if (theEvent->button() != Qt::LeftButton) { + SelectedLink = 0; myHltPnt = -1; return; } diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 2848887..6dc5b61 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -36,6 +36,7 @@ using namespace std; #include "QAD_Application.h" #include "SUPERVGUI_Def.h" #include "QAD_RightFrame.h" +#include "SALOME_Event.hxx" #include "SUPERVGraph_ViewFrame.h" #include #include @@ -76,7 +77,7 @@ SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* th if (obj->FindAttribute(anAttr, "AttributeIOR")) { SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); Standard_CString ior = anIOR->Value(); - dataflow = Supervision.getEngine()->getGraph(ior); + dataflow = Supervision.getEngine()->getStreamGraph(ior); if (SUPERV_isNull(dataflow)) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_ACCESS_BAD_IOR")); close(); @@ -88,7 +89,7 @@ SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* th close(); } } else { - dataflow = Supervision.getEngine()->Graph(MAIN_NEW); + dataflow = Supervision.getEngine()->StreamGraph(MAIN_NEW); if (SUPERV_isNull(dataflow)) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF")); close(); @@ -112,9 +113,9 @@ SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* th Trace("SUPERVGUI_Main::SUPERVGUI_Main (file)") theParent->setViewWidget(this); if (isModify) { - dataflow = Supervision.getEngine()->Graph(f); + dataflow = Supervision.getEngine()->StreamGraph(f); } else { - dataflow = Supervision.getEngine()->GraphE(f); + dataflow = Supervision.getEngine()->StreamGraphE(f); } if (SUPERV_isNull(dataflow)) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); @@ -157,6 +158,7 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { myThread = new SUPERVGUI_Thread(); myThread->setMain(this); + connect(this, SIGNAL(KillMyThread(bool)), myThread, SLOT(KillThread(bool))); myIsKilled = false; //myIsRunned = false; @@ -225,13 +227,27 @@ SUPERVGUI_Main::~SUPERVGUI_Main() { delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit if (!SUPERV_isNull(dataflow)) { if (dataflow->IsExecuting()) { - if (QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), + if (QMessageBox::warning(QAD_Application::getDesktop(), + tr("WARNING"), tr("MSG_DF_RUNNING"), tr("MSG_DF_EXECUTION"), tr("MSG_DF_KILL")) == 1) { - dataflow->Kill(); + if (dataflow->Kill()) { + if (myThread->running()) + myThread->wait(); + } + } + else { + emit KillMyThread(true); + if (myThread->running()) + myThread->wait(); } } + else { + emit KillMyThread(true); + if (myThread->running()) + myThread->wait(); + } } } @@ -267,6 +283,13 @@ void SUPERVGUI_Main::filterNotification() { } } +void SUPERVGUI_Main::changeDSGraphParameters() { + SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly()); + if (aDlg->exec() ) + sync(); + delete aDlg; +} + void SUPERVGUI_Main::syncAsync() { Trace("SUPERVGUI_Main::syncAsync") QTimer::singleShot(1, this, SLOT(sync())); @@ -393,7 +416,7 @@ void SUPERVGUI_Main::copy() { SUPERVGraph_ViewFrame* aViewFrame = dynamic_cast (aStudyFrame->getRightFrame()->getViewFrame()); if(aViewFrame){ - SUPERV_Graph aNewGraph = dataflow->Copy(); + SUPERV_Graph aNewGraph = dataflow->StreamCopy(); QString aNewName(tr("MSG_COPY_PREFIX").arg(++myCopyNum)); aNewName += dataflow->Name(); aNewGraph->SetName(aNewName); @@ -421,18 +444,21 @@ void SUPERVGUI_Main::run() { //if (myIsRunned) { if (!dataflow->ReRun()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + if (dataflow->State() == SUPERV::ErrorState) { + kill(); + } } else { myThread->startThread(tr("MSG_GRAPH_STARTED")); - //syncNotification(); sync(); } } else { if (!dataflow->Run()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + if (dataflow->State() == SUPERV::ErrorState) { + kill(); + } } else { myThread->startThread(tr("MSG_GRAPH_STARTED")); - //syncNotification(); - //myIsRunned = true; sync(); } } @@ -463,7 +489,6 @@ void SUPERVGUI_Main::startExecute() { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); } else { myThread->startThread(tr("MSG_GRAPH_STARTED")); - //syncNotification(); } } else { @@ -471,7 +496,6 @@ void SUPERVGUI_Main::startExecute() { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); } else { myThread->startThread(tr("MSG_GRAPH_STARTED")); - //syncNotification(); } } } @@ -708,6 +732,7 @@ void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) { Trace("SUPERVGUI_Main::showPopup"); // To check is Supervision active? if (myIsLocked) return; + //if (dataflow->IsExecuting()) return; //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return; if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return; @@ -1134,8 +1159,6 @@ void SUPERVGUI_Main::checkExecution() { } } - - /******************************* SUPERVGUI_Thread class ****************************************/ SUPERVGUI_Thread::SUPERVGUI_Thread() :QThread() @@ -1160,8 +1183,6 @@ void SUPERVGUI_Thread::startThread(const char* m) void SUPERVGUI_Thread::stopThread(const char* m) { - //myIsActive = false; - //myMain->sync(); myMain->getMessage()->setMessage(m); } @@ -1170,6 +1191,15 @@ void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain) myMain = theMain; } +void SUPERVGUI_Thread::KillThread(bool theValue) +{ + myMutex.lock(); + myIsActive = !(theValue); + myMutex.unlock(); +} + +typedef TVoidMemFun2ArgEvent TNodeSyncEvent; + void SUPERVGUI_Thread::run() { SUPERV_CNode aNode = NULL; @@ -1192,7 +1222,9 @@ void SUPERVGUI_Thread::run() if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState || - aEvent == SUPERV::NoEvent && aState == SUPERV::NoState) { + aEvent == SUPERV::NoEvent && aState == SUPERV::NoState + || + aEvent == SUPERV::KillEvent && aState == SUPERV::KillState) { if (myMain->getEventNodes().count()) { myMain->removeEventNodes(); } @@ -1257,6 +1289,10 @@ void SUPERVGUI_Thread::run() case SUPERV_Error : stopThread(tr("MSG_GRAPH_ABORTED")); break; + + case SUPERV_Kill: + stopThread(tr("MSG_GRAPH_KILLED")); + break; } break; @@ -1266,11 +1302,13 @@ void SUPERVGUI_Thread::run() //if list not empty call execute() -> sync() char * aNodeName = *(myMain->getEventNodes().getFirst()); SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst()); - qApp->lock(); - myMain->execute(aNodeName,aNodeState); //this is from main - qApp->unlock(); + + // It is PROHIBITED to deal with widgets in a secondary thread, so event posting is used here + ProcessVoidEvent( new TNodeSyncEvent( myMain, &SUPERVGUI_Main::execute, aNodeName, aNodeState ) ); + myMain->removeFirstEN(); myMain->removeFirstS(); + } aPrevNode = aNode; diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 0869204..e1e51a5 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -98,6 +98,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void lockedGraph(bool theLock) { myIsLocked = theLock; } bool isLocked() { return myIsLocked; } + bool isKilled() { return myIsKilled; } SUPERV::GraphState getNodeExecState(); void setNodeExecState(SUPERV::GraphState theNodeExecState); @@ -118,6 +119,9 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void startTimer(); void executionFinished(); + signals: + void KillMyThread(bool theValue); + public slots: void execute(char * theNodeNode, SUPERV::GraphState theNodeState); void sync(); @@ -131,6 +135,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void showFullGraph(); void showContolFlow(); void filterNotification(); + void changeDSGraphParameters(); private slots: void chooseData(QListViewItem* item); @@ -191,12 +196,16 @@ class SUPERVGUI_Thread : public QObject, public QThread { void stopThread(const char* m); void setMain(SUPERVGUI_Main* theMain); + public slots: + void KillThread(bool theValue); + protected: void run(); private: bool myIsActive; SUPERVGUI_Main* myMain; + QMutex myMutex; }; diff --git a/src/SUPERVGUI/SUPERVGUI_Node.cxx b/src/SUPERVGUI/SUPERVGUI_Node.cxx index f8e56a6..1d5a39c 100644 --- a/src/SUPERVGUI/SUPERVGUI_Node.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Node.cxx @@ -342,7 +342,8 @@ void SUPERVGUI_Node::showPopup(QMouseEvent* e) { void SUPERVGUI_Node::mousePressEvent(QMouseEvent* e) { - myMain->showPopup(myPopup, e); + if (!myMain->getDataflow()->IsExecuting()) + myMain->showPopup(myPopup, e); } diff --git a/src/SUPERVGUI/SUPERVGUI_Port.cxx b/src/SUPERVGUI/SUPERVGUI_Port.cxx index 40fbd64..c773024 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Port.cxx @@ -35,24 +35,25 @@ using namespace std; #include "QAD_LeftFrame.h" #include "QAD_ObjectBrowser.h" #include +#include #include "SUPERVGUI_GraphNode.h" // Port en general // --------------- -SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p): +SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p): SUPERVGUI_Label(parent, PORT_WIDTH, PORT_HEIGHT, "", QLabel::AlignLeft | QLabel::AlignVCenter), - main(m), - port(p) + main(m) { Trace("SUPERVGUI_Port::SUPERVGUI_Port"); + port = SUPERV::Port::_duplicate(p); myName = port->Name(); QString aName(port->Name()); aName += (port->IsInput())? "Input":"Output"; - setName(aName); + setName(aName); - if (myName.compare(OUTVOID) == 0) + if (!port->IsInput() && port->IsGate()) setAlignment(QLabel::AlignRight | QLabel::AlignVCenter); if (port->IsParam() || port->IsInLine()) @@ -81,6 +82,8 @@ SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p ( port->IsEndSwitch() && port->IsInput())) { myDelItem = popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(deletePort())); } + browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); + connect(this, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); connect(this, SIGNAL(MouseRelease(QMouseEvent*)), this, SLOT(endSketch())); } @@ -99,7 +102,7 @@ void SUPERVGUI_Port::showPopup(QMouseEvent* e) { if (e->button() != RightButton) return; if (main->getDataflow()->IsExecuting()) popup->setItemEnabled(mySketchItem, false); - else + /* else if (!port->IsInput() //output port || port->IsInput() && (!port->IsLinked() //not linked input port @@ -107,11 +110,19 @@ void SUPERVGUI_Port::showPopup(QMouseEvent* e) { port->Kind() == SUPERV::EndSwitchParameter)) { //input port of EndSwitch node popup->setItemEnabled(mySketchItem, true); } - + */ main->showPopup(popup, e); } +void SUPERVGUI_Port::browse() { + Trace("SUPERVGUI_Port::browse") + QString mess = (port->IsInput())? (tr("MSG_IPORT_VAL")) : (tr("MSG_OPORT_VAL")); + mess += port->ToString(); + QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); +} + + QPoint SUPERVGUI_Port::getConnectPnt() { return QPoint(0,0); } @@ -153,7 +164,7 @@ void SUPERVGUI_Port::deletePort() { // Port d'entree // ------------- -SUPERVGUI_PortIn::SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p) +SUPERVGUI_PortIn::SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p) : SUPERVGUI_Port(parent, m, p), myDlg( 0 ) { Trace("SUPERVGUI_PortIn::SUPERVGUI_PortIn"); @@ -166,7 +177,7 @@ SUPERVGUI_PortIn::SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Po if ((!port->IsGate()) && editing ) { psc = popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); } - browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + // browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); } SUPERVGUI_PortIn::~SUPERVGUI_PortIn() { @@ -181,6 +192,16 @@ bool SUPERVGUI_PortIn::eventFilter( QObject* o, QEvent* e ) return SUPERVGUI_Port::eventFilter( o, e ); } +void SUPERVGUI_PortIn::showPopup(QMouseEvent* e){ + if (e->button() != RightButton) return; + if (main->getDataflow()->IsExecuting()) + popup->setItemEnabled(mySketchItem, false); + else { + popup->setItemEnabled(mySketchItem, !port->IsLinked()); + popup->setItemEnabled(psc, !port->IsLinked()); + } + main->showPopup(popup, e); +} void SUPERVGUI_PortIn::deleteLinks() { if (myLinkPrs) { @@ -193,14 +214,15 @@ void SUPERVGUI_PortIn::deleteLinks() { void SUPERVGUI_PortIn::sync() { SUPERVGUI_Port::sync(); - if (port->IsLinked()) { - popup->setItemEnabled(browser, port->State() == SUPERV_Ready); - } else { + // if (port->IsLinked()) { + // popup->setItemEnabled(browser, port->State() == SUPERV_Ready); + //} else { + if (!port->IsLinked()) { if (port->HasInput()) { - popup->setItemEnabled(browser, true); + // popup->setItemEnabled(browser, true); setLineWidth(2); } else { - popup->setItemEnabled(browser, false); + //popup->setItemEnabled(browser, false); setLineWidth(1); } } @@ -230,12 +252,12 @@ void SUPERVGUI_PortIn::setInput() { } } -void SUPERVGUI_PortIn::browse() { +/*void SUPERVGUI_PortIn::browse() { Trace("SUPERVGUI_PortIn::browse") QString mess(tr("MSG_IPORT_VAL")); mess += port->ToString(); QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} + }*/ @@ -284,7 +306,7 @@ void SUPERVGUI_PortIn::onDeleteLink(SUPERVGUI_Link*) { // Port de sortie // -------------- -SUPERVGUI_PortOut::SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p): +SUPERVGUI_PortOut::SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p): SUPERVGUI_Port(parent, m, p), study(false) { @@ -295,7 +317,7 @@ SUPERVGUI_PortOut::SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV_ if (!port->IsGate()) { pls = popup->insertItem(tr("MSG_PUT_INSTUDY"), this, SLOT(toStudy())); } - browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); + //browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); if (!main->getDataflow()->IsReadOnly()) { popup->setItemEnabled(mySketchItem, true); @@ -313,7 +335,7 @@ void SUPERVGUI_PortOut::sync() { SUPERVGUI_Port::sync(); bool ok = (port->State() == SUPERV_Ready); - popup->setItemEnabled(browser, ok); + // popup->setItemEnabled(browser, ok); if (study && ok) { study = main->putDataStudy(port, STUDY_PORT_OUT); } @@ -356,12 +378,12 @@ void SUPERVGUI_PortOut::toStudy() { sync(); } -void SUPERVGUI_PortOut::browse() { +/*void SUPERVGUI_PortOut::browse() { Trace("SUPERVGUI_PortOut::browse") QString mess(tr("MSG_OPORT_VAL")); mess += port->ToString(); QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} + }*/ /** @@ -412,7 +434,7 @@ void SUPERVGUI_PortOut::deleteLinks() { // ---------------------------- // Input Port of EndSwitch Node // ---------------------------- -SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p) +SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p) : SUPERVGUI_Port(parent, m, p), myDlg( 0 ) { Trace("SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode"); @@ -422,7 +444,7 @@ SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* if ((!port->IsGate()) && editing ) { psc = popup->insertItem(tr("MSG_SETVALUE"),this, SLOT(setInput())); } - browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); + // browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); } SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode() { @@ -437,14 +459,15 @@ bool SUPERVGUI_PortInESNode::eventFilter( QObject* o, QEvent* e ) { void SUPERVGUI_PortInESNode::sync() { SUPERVGUI_Port::sync(); - if (port->IsLinked()) { + /* if (port->IsLinked()) { popup->setItemEnabled(browser, port->State() == SUPERV_Ready); - } else { + } else {*/ + if (!port->IsLinked()) { if (port->HasInput()) { - popup->setItemEnabled(browser, true); + // popup->setItemEnabled(browser, true); setLineWidth(2); } else { - popup->setItemEnabled(browser, false); + // popup->setItemEnabled(browser, false); setLineWidth(1); } } @@ -508,12 +531,12 @@ void SUPERVGUI_PortInESNode::setInput() { } } -void SUPERVGUI_PortInESNode::browse() { +/*void SUPERVGUI_PortInESNode::browse() { Trace("SUPERVGUI_PortInESNode::browse") QString mess(tr("MSG_IPORT_VAL")); mess += port->ToString(); QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} + }*/ void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { @@ -536,3 +559,217 @@ void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { } } + + +// ---------------------------- +// Stream Ports +// ---------------------------- +SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = thePort; + setSizeGripEnabled( true ); + setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); + + QFrame* aCtrlPane = new QFrame(this); + QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); + + // Schema + QLabel* aSchemaLbl = new QLabel(tr("MSG_STREAM_SCHEMA"),aCtrlPane); + aCtrlLayout->addWidget(aSchemaLbl, 0, 0); + + mySchemaCombo = new QComboBox(aCtrlPane, "SchemaBox" ); + mySchemaCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + mySchemaCombo->insertItem("SCHENULL"); + mySchemaCombo->insertItem("TI"); + mySchemaCombo->insertItem("TF"); + mySchemaCombo->insertItem("DELTA"); + aCtrlLayout->addWidget(mySchemaCombo, 0, 1); + + // Interpolation + QLabel* aInterLbl = new QLabel(tr("MSG_STREAM_INTER"),aCtrlPane); + aCtrlLayout->addWidget(aInterLbl, 1, 0); + + myInterCombo = new QComboBox(aCtrlPane, "InterBox" ); + myInterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myInterCombo->insertItem("INTERNULL"); + myInterCombo->insertItem("L0"); + myInterCombo->insertItem("L1"); + aCtrlLayout->addWidget(myInterCombo, 1, 1); + + // Extrapolation + QLabel* aExtraLbl = new QLabel(tr("MSG_STREAM_EXTRA"),aCtrlPane); + aCtrlLayout->addWidget(aExtraLbl, 2, 0); + + myExterCombo = new QComboBox(aCtrlPane, "ExtraBox" ); + myExterCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myExterCombo->insertItem("EXTRANULL"); + myExterCombo->insertItem("E0"); + myExterCombo->insertItem("E1"); + aCtrlLayout->addWidget(myExterCombo, 2, 1); + + TopLayout->addWidget( aCtrlPane ); + + // Buttons + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 5 ); + GroupButtonsLayout->setMargin( 8 ); + + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); + setData(); +} + + +void SUPERVGUI_StreamInDlg::setData() { + SUPERV::KindOfSchema aSchema; + SUPERV::KindOfInterpolation aInterpolat; + SUPERV::KindOfExtrapolation aExtrapolat; + + myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat); + + mySchemaCombo->setCurrentItem((int)aSchema); + myInterCombo->setCurrentItem((int)aInterpolat); + myExterCombo->setCurrentItem((int)aExtrapolat); +} + + + +void SUPERVGUI_StreamInDlg::accept() { + myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), + (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), + (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); + QDialog::accept(); +} + +//--------------------------------------------------------------------------------------- + + +SUPERVGUI_StreamPortIn::SUPERVGUI_StreamPortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): + SUPERVGUI_PortIn(parent, m, p) +{ + myPort = SUPERV::StreamPort::_duplicate(p); + myParamItem = popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); +} + +SUPERVGUI_StreamPortIn::~SUPERVGUI_StreamPortIn() +{ +} + + +void SUPERVGUI_StreamPortIn::setParams() +{ + SUPERVGUI_StreamInDlg* aDlg = new SUPERVGUI_StreamInDlg(this); + aDlg->exec(); + delete aDlg; +} + + +void SUPERVGUI_StreamPortIn::sync() +{ + SUPERVGUI_PortIn::sync(); + setText(myName + "=" + myPort->ToString()); +} + +//------------------------------------------------------------------------- + +SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort) + :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myPort = thePort; + setSizeGripEnabled( true ); + setCaption( tr( "MSG_STREAM_DLG_TIT" ) ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this, 11, 6 ); + + QFrame* aCtrlPane = new QFrame(this); + QGridLayout* aCtrlLayout = new QGridLayout( aCtrlPane, 4, 10 ); + + QLabel* aLbl = new QLabel(tr("MSG_STREAM_LEVEL"),aCtrlPane); + aCtrlLayout->addWidget(aLbl, 0, 0); + + myValEdit = new QLineEdit( aCtrlPane, "ValEdit" ); + myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myValEdit->setValidator( new QIntValidator(this) ); + myValEdit->setText(QString("%1").arg(myPort->getStreamPort()->NumberOfValues())); + aCtrlLayout->addWidget(myValEdit, 0, 1); + TopLayout->addWidget( aCtrlPane ); + + // Buttons + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 5 ); + GroupButtonsLayout->setMargin( 8 ); + + QPushButton* okB = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + QPushButton* cancelB = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons ); + + GroupButtonsLayout->addWidget( okB, 0, 0 ); + GroupButtonsLayout->addItem ( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + GroupButtonsLayout->addWidget( cancelB, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + connect( okB, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( cancelB, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +void SUPERVGUI_StreamOutDlg::accept() { + int aRes = 0; + QString aStr = myValEdit->text(); + if (!aStr.isEmpty()) + aRes = aStr.toLong(); + myPort->getStreamPort()->SetNumberOfValues(aRes); + QDialog::accept(); +} + + +//------------------------------------------------------------------------------------------------ + +SUPERVGUI_StreamPortOut::SUPERVGUI_StreamPortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): + SUPERVGUI_PortOut(parent, m, p) +{ + myPort = SUPERV::StreamPort::_duplicate(p); + myParamItem = popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); +} + +SUPERVGUI_StreamPortOut::~SUPERVGUI_StreamPortOut() +{ +} + +void SUPERVGUI_StreamPortOut::setParams() +{ + SUPERVGUI_StreamOutDlg* aDlg = new SUPERVGUI_StreamOutDlg(this); + aDlg->exec(); + delete aDlg; +} + + +void SUPERVGUI_StreamPortOut::sync() +{ + SUPERVGUI_PortOut::sync(); + setText(myName + "=" + myPort->ToString()); +} + + +//------------------------------------------------------------------------------------------------ diff --git a/src/SUPERVGUI/SUPERVGUI_Port.h b/src/SUPERVGUI/SUPERVGUI_Port.h index 99b8125..8137e35 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.h +++ b/src/SUPERVGUI/SUPERVGUI_Port.h @@ -40,7 +40,7 @@ class SUPERVGUI_Port: public SUPERVGUI_Label { Q_OBJECT public: - SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); virtual ~SUPERVGUI_Port(); SUPERV_Port getPort(); @@ -56,11 +56,12 @@ class SUPERVGUI_Port: public SUPERVGUI_Label { void endSketch(); protected slots: + void browse(); virtual void deletePort(); protected: SUPERVGUI_Main* main; - SUPERV_Port port; + SUPERV_Port port; QPopupMenu* popup; int mySketchItem; @@ -72,7 +73,7 @@ class SUPERVGUI_Port: public SUPERVGUI_Label { QString myName; private slots: - void showPopup(QMouseEvent* e); + virtual void showPopup(QMouseEvent* e); }; @@ -83,7 +84,7 @@ class SUPERVGUI_PortIn: public SUPERVGUI_Port { Q_OBJECT public: - SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); virtual ~SUPERVGUI_PortIn(); bool eventFilter( QObject* o, QEvent* e ); @@ -101,8 +102,9 @@ class SUPERVGUI_PortIn: public SUPERVGUI_Port { private slots: void setInput(); - void browse(); + // void browse(); void onDeleteLink(SUPERVGUI_Link*); + virtual void showPopup(QMouseEvent* e); private: @@ -120,7 +122,7 @@ class SUPERVGUI_PortOut: public SUPERVGUI_Port { Q_OBJECT public: - SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); virtual ~SUPERVGUI_PortOut(); void sync(); @@ -141,7 +143,7 @@ class SUPERVGUI_PortOut: public SUPERVGUI_Port { private slots: void toStudy(); - void browse(); + // void browse(); void sketch(QMouseEvent* e); void onDeleteLink(SUPERVGUI_Link*); @@ -158,7 +160,7 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { Q_OBJECT public: - SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p); + SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); virtual ~SUPERVGUI_PortInESNode(); bool eventFilter( QObject* o, QEvent* e ); @@ -180,7 +182,7 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { private slots: void setInput(); - void browse(); + // void browse(); void onDeleteLink(SUPERVGUI_Link*); @@ -191,4 +193,88 @@ class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { SUPERVGUI_GetValueDlg* myDlg; }; + + + + + + + +//**************************************************************** +class SUPERVGUI_StreamPortIn; +class SUPERVGUI_StreamInDlg: public QDialog +{ + Q_OBJECT +public: + SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort); + virtual ~SUPERVGUI_StreamInDlg() {}; + +protected slots: + void accept(); + +private: + void setData(); + + SUPERVGUI_StreamPortIn* myPort; + QComboBox* mySchemaCombo; + QComboBox* myInterCombo; + QComboBox* myExterCombo; +}; + +class SUPERVGUI_StreamPortIn: public SUPERVGUI_PortIn +{ + Q_OBJECT +public: + SUPERVGUI_StreamPortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p); + virtual ~SUPERVGUI_StreamPortIn(); + + void sync(); + SUPERV_StreamPort getStreamPort() { return myPort;} + +private slots: + void setParams(); + +private: + SUPERV_StreamPort myPort; + + int myParamItem; +}; + + +//************************************************************** +class SUPERVGUI_StreamPortOut; +class SUPERVGUI_StreamOutDlg: public QDialog +{ + Q_OBJECT +public: + SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort); + virtual ~SUPERVGUI_StreamOutDlg() {}; + +protected slots: + void accept(); + +private: + SUPERVGUI_StreamPortOut* myPort; + QLineEdit* myValEdit; +}; + +class SUPERVGUI_StreamPortOut: public SUPERVGUI_PortOut +{ + Q_OBJECT +public: + SUPERVGUI_StreamPortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p); + virtual ~SUPERVGUI_StreamPortOut(); + + void sync(); + SUPERV_StreamPort getStreamPort() { return myPort;} + +private slots: + void setParams(); + +private: + SUPERV_StreamPort myPort; + int myParamItem; +}; + + #endif diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index 2b13b08..749ed00 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -127,16 +127,16 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): //QHGroupBox* aAddBox = new QHGroupBox(tr("TIT_ADDNODE"), aCorbaPane); //!! //aAddBox->setInsideSpacing(20); //!! - QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!! - connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!! - aComputeCBtn->setDefault(false); +//NRI QPushButton* aComputeCBtn = new QPushButton(tr("TIT_ADDCNODE"), aCorbaPane); //!! +//NRI connect(aComputeCBtn, SIGNAL(clicked()), this, SLOT(addComputeNode())); //!! +//NRI aComputeCBtn->setDefault(false); QPushButton* aComputeBtn = new QPushButton(tr("TIT_ADDFNODE"), aCorbaPane); connect(aComputeBtn, SIGNAL(clicked()), this, SLOT(addFactoryNode())); aComputeBtn->setDefault(true); aBaseLayout->addWidget(aComputeBtn); - aBaseLayout->addWidget(aComputeCBtn); //!! + //NRI aBaseLayout->addWidget(aComputeCBtn); //!! aBaseLayoutV->insertLayout(-1, aBaseLayout); myTabPane->addTab(aCorbaPane, tr("MODULES_PANE")); @@ -213,6 +213,23 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): } +char* getDataStreamParameterName(int aType) +{ + switch(aType) { + case 1: + return "integer"; + case 2: + return "float"; + case 3: + return "double"; + case 4: + return "string"; + case 6: + return "boolean"; + default: + return "unknown"; + } +} void SUPERVGUI_Service::initialise() { CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog"); @@ -229,7 +246,7 @@ void SUPERVGUI_Service::initialise() { long nbComp = lComponents->length(); for (int i=0; iGetComponent((char *)lComponents[i]); - QListViewItem* myComponentItem = new QListViewItem(components, (char*)lComponents[i]); + QListViewItem* myComponentItem = new QListViewItem(components, (char*)C->componentusername()); myComponentItem->setSelectable(false); QString aIconName = C->component_icone(); if (!aIconName.isEmpty()) { @@ -263,14 +280,34 @@ void SUPERVGUI_Service::initialise() { long nbPortsOut = Service->ServiceoutParameter.length(); for (int m=0; mServiceoutParameter[m]); - QListViewItem* myPortOutItem = new QListViewItem(myServiceItem, (char*)PortOut->Parametername, (char*)PortOut->Parametertype, "Out"); + QListViewItem* myPortOutItem = + new QListViewItem(myServiceItem, (char*)PortOut->Parametername, (char*)PortOut->Parametertype, "Out"); + myPortOutItem->setSelectable(false); + } + + long nbStreamPortsOut = Service->ServiceoutDataStreamParameter.length(); + for (int m=0; mServiceoutDataStreamParameter[m]); + QListViewItem* myPortOutItem = + new QListViewItem(myServiceItem, (char*)PortOut->Parametername, + getDataStreamParameterName(PortOut->Parametertype), "DataStream Out"); myPortOutItem->setSelectable(false); } long nbPortsIn = Service->ServiceinParameter.length(); for (int l=0; lServiceinParameter[l]); - QListViewItem* myPortInItem = new QListViewItem(myServiceItem, (char*)PortIn->Parametername, (char*)PortIn->Parametertype, "In"); + QListViewItem* myPortInItem = + new QListViewItem(myServiceItem, (char*)PortIn->Parametername, (char*)PortIn->Parametertype, "In"); + myPortInItem->setSelectable(false); + } + + long nbStreamPortsIn = Service->ServiceinDataStreamParameter.length(); + for (int l=0; lServiceinDataStreamParameter[l]); + QListViewItem* myPortInItem = + new QListViewItem(myServiceItem, (char*)PortIn->Parametername, + getDataStreamParameterName(PortIn->Parametertype), "DataStream In"); myPortInItem->setSelectable(false); } } @@ -285,9 +322,10 @@ SUPERVGUI_Service::~SUPERVGUI_Service() { } void SUPERVGUI_Service::addComputeNode() { + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain==0) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); } else { CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog"); SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var; @@ -304,9 +342,9 @@ void SUPERVGUI_Service::addComputeNode() { const char* service = item->text(0).latin1(); const char* interface = item->parent()->text(0).latin1(); const char* component = item->parent()->parent()->text(0).latin1(); - SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component); + SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(aDesktop->getComponentName(component)); if (myComponent==NULL) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); } else { const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service); b = true; @@ -324,16 +362,17 @@ void SUPERVGUI_Service::addComputeNode() { } } if (!b) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD")); + QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD")); } } } } void SUPERVGUI_Service::addFactoryNode() { + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain==0) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); + QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); } else { CORBA::Object_ptr obj = naming->Resolve("/Kernel/ModulCatalog"); SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var; @@ -349,24 +388,49 @@ void SUPERVGUI_Service::addFactoryNode() { if (item->isSelected()) { const char* service = item->text(0).latin1(); const char* interface = item->parent()->text(0).latin1(); - const char* component = item->parent()->parent()->text(0).latin1(); + const char* component = aDesktop->getComponentName(item->parent()->parent()->text(0).latin1()); SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component); if (myComponent==NULL) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); + QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); } else { const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service); b = true; - SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); - if (CORBA::is_nil(node)) { - QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); - return; + MESSAGE ( " myService->TypeOfNode == " << myService->TypeOfNode ) + + if ( myService->TypeOfNode == 0 ) { // ComputeNode + SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); + if (CORBA::is_nil(node)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + node->Coords(myX, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + } else { // Factory Node + SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); + if (CORBA::is_nil(node)) { + QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + node->Coords(myX, myY); + myX += NODE_DX; + myY += NODE_DY; + aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + } - node->Coords(myX, myY); - myX += NODE_DX; - myY += NODE_DY; - aMain->addComputeNode(SUPERV::CNode::_narrow(node)); - } + +// SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); +// if (CORBA::is_nil(node)) { +// QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); +// return; +// } +// node->Coords(myX, myY); +// myX += NODE_DX; +// myY += NODE_DY; +// aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + } } } if (!b) { diff --git a/src/SUPERVGUI/SUPERVGUI_View.cxx b/src/SUPERVGUI/SUPERVGUI_View.cxx index 86fc5a6..30e5348 100644 --- a/src/SUPERVGUI/SUPERVGUI_View.cxx +++ b/src/SUPERVGUI/SUPERVGUI_View.cxx @@ -12,7 +12,7 @@ using namespace std; #include "SUPERVGUI_View.h" #include "SUPERVGUI_Main.h" #include "QAD_Config.h" - +#include #if QT_VERSION >= 0x030005 @@ -33,6 +33,7 @@ SUPERVGUI_View::SUPERVGUI_View(SUPERVGUI_Main* theMain): myLastY = 0; myIsDragging = false; myCursor = cursor(); + myDSItemID = -1; // myLastMinVisX = horizontalScrollBar()->value(); //viewport()->x(); // myLastMinVisY = verticalScrollBar()->value(); //viewport()->y(); @@ -60,6 +61,9 @@ SUPERVGUI_View::SUPERVGUI_View(SUPERVGUI_Main* theMain): myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), main, SLOT(copy())); myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), main, SLOT(filterNotification())); + myPopup->insertSeparator(); + myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground())); + QString aRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed"); QString aGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen"); QString aBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue"); @@ -76,6 +80,72 @@ SUPERVGUI_View::~SUPERVGUI_View() { } +bool SUPERVGUI_View::isHavingStreamPort() +{ + SUPERV::ListOfNodes* aNodesList = main->getDataflow()->Nodes(); + + //Computing Nodes + for ( int i = 0 ; i < (int) aNodesList->CNodes.length() ; i++ ) { + SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->CNodes)[i]->StreamPorts() ); + if ((int) aStrPortsList.length() > 0) { + return true; + } + } + + //FactoryNodes + for ( int i = 0 ; i < (int) aNodesList->FNodes.length() ; i++ ) { + SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->FNodes)[i]->StreamPorts() ); + if ((int) aStrPortsList.length() > 0) { + return true; + } + } + + //InLineNodes + for ( int i = 0 ; i < (int) aNodesList->INodes.length() ; i++ ) { + SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->INodes)[i]->StreamPorts() ); + if ((int) aStrPortsList.length() > 0) { + return true; + } + } + + //GOTONodes + for ( int i = 0 ; i < (int) aNodesList->GNodes.length() ; i++ ) { + SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->GNodes)[i]->StreamPorts() ); + if ((int) aStrPortsList.length() > 0) { + return true; + } + } + + //LoopNodes + for ( int i = 0 ; i < (int) aNodesList->LNodes.length() ; i++ ) { + SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->LNodes)[i]->StreamPorts() ); + if ((int) aStrPortsList.length() > 0) { + return true; + } + } + + //SwitchNodes + for ( int i = 0 ; i < (int) aNodesList->SNodes.length() ; i++ ) { + SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->SNodes)[i]->StreamPorts() ); + if ((int) aStrPortsList.length() > 0) { + return true; + } + } + + return false; +} + +void SUPERVGUI_View::addDSPopupItem() +{ + if (myDSItemID == -1) { + //Popupmenu items for user specification of parameters, if there are any DataStream ports in the graph + if (isHavingStreamPort()) { + myPopup->insertSeparator(); + myDSItemID = myPopup->insertItem(tr("MSG_SET_GRAPHPARAMS"), main, SLOT(changeDSGraphParameters())); + } + } +} + void SUPERVGUI_View::viewportMousePressEvent(QMouseEvent* theEvent) { myIsDragging = true; @@ -174,3 +244,10 @@ int SUPERVGUI_View::getLastX() { int SUPERVGUI_View::getLastY() { return myLastY; } +void SUPERVGUI_View::changeBackground() +{ + QColor selColor = QColorDialog::getColor(viewport()->paletteBackgroundColor(), this ); + if ( selColor.isValid() ) { + setPaletteBackgroundColor( selColor ); + } +} diff --git a/src/SUPERVGUI/SUPERVGUI_View.h b/src/SUPERVGUI/SUPERVGUI_View.h index cfc8565..38b8814 100644 --- a/src/SUPERVGUI/SUPERVGUI_View.h +++ b/src/SUPERVGUI/SUPERVGUI_View.h @@ -43,13 +43,17 @@ class SUPERVGUI_View: public QScrollView { int getLastX(); int getLastY(); + void addDSPopupItem(); + public slots: void addToStudy(); + void changeBackground(); protected: void viewportMouseMoveEvent(QMouseEvent* theEvent); void viewportMouseReleaseEvent(QMouseEvent* theEvent); void viewportMousePressEvent(QMouseEvent* theEvent); + bool isHavingStreamPort(); SUPERVGUI_Main* main; QPopupMenu* myPopup; @@ -58,6 +62,7 @@ class SUPERVGUI_View: public QScrollView { int myAddStudyItem; private: + int myDSItemID; int myDx; int myDy; int myLastX; diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index d53ad9c..5b94656 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -336,6 +336,27 @@ msgstr "Set Value" msgid "MSG_BROWSE" msgstr "Browse" +msgid "MSG_STREAM_PARAM" +msgstr "Parameters..." + +msgid "MSG_STREAM_DLG_TIT" +msgstr "Stream Port Parameters" + +msgid "MSG_STREAM_DLG_TIT" +msgstr "Stream Port Parameters" + +msgid "MSG_STREAM_SCHEMA" +msgstr "Schema" + +msgid "MSG_STREAM_INTER" +msgstr "Interpolation" + +msgid "MSG_STREAM_EXTRA" +msgstr "Extrapolation" + +msgid "MSG_STREAM_LEVEL" +msgstr "Level" + msgid "MSG_DELLINK" msgstr "Delete Link" @@ -423,6 +444,9 @@ msgstr "Add Point" msgid "MSG_INS_FILE" msgstr "Insert File" +msgid "MSG_SET_GRAPHPARAMS" +msgstr "Stream Graph Parameters..." + msgid "MSG_COPY_DATAFLOW" msgstr "Copy Dataflow" @@ -432,6 +456,9 @@ msgstr "Switch Array" msgid "MSG_FILTER_NOTIFY" msgstr "Filter Notification" +msgid "MSG_CHANGE_BACKGROUND" +msgstr "Change background..." + msgid "MSG_SWITCH_GRAPH" msgstr "Switch Graph" @@ -444,6 +471,18 @@ msgstr "Rename Dataflow" msgid "TLT_INFORMATIONS" msgstr "Informations" +msgid "TLT_DSGRAPHPARAMS" +msgstr "Data Stream Graph Parameters" + +msgid "DELTATIME_LBL" +msgstr "DeltaTime (double):" + +msgid "TIMEOUT_LBL" +msgstr "TimeOut (unsigned long):" + +msgid "DATASTREAMTRACE_LBL" +msgstr "DataStreamTrace:" + msgid "NAME_LBL" msgstr "Name:" @@ -559,7 +598,7 @@ msgid "TIT_ADDCNODE" msgstr "Add Compute Node" msgid "TIT_ADDFNODE" -msgstr "Add Factory Node" +msgstr "Add Node" msgid "BTN_FACTORYNODE" msgstr "Factory" diff --git a/src/SubComponent/SubComponent.cxx b/src/SubComponent/SubComponent.cxx new file mode 100644 index 0000000..76ed6e1 --- /dev/null +++ b/src/SubComponent/SubComponent.cxx @@ -0,0 +1,90 @@ +// SuperVisionTest SubComponent : example of component that sunstracts one number from another +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SubComponentEngine.cxx +// Author : MARC TAJCHMAN, CEA +// Module : SuperVisionTest + +using namespace std; +#include +#include +#include +#include +#include + +//#include "utilities.h" +#include "SubComponent.hxx" + +SubComponentEngine::SubComponentEngine( CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) +{ +// MESSAGE("SubComponentEngine::SubComponentEngine activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ")" ) + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _nexec = 0 ; +} + +SubComponentEngine::SubComponentEngine() +{ +} + +SubComponentEngine::~SubComponentEngine() +{ +} + +void SubComponentEngine::Sub( double x , double y , double & z ) { + beginService( " SubComponentEngine::Sub" ); + z = x - y ; + int S; + + sendMessage(NOTIF_STEP, "Sub is Computing"); + S = 1+(int) (15.0*rand()/(RAND_MAX+1.0)); + sleep(S); + MESSAGE( "SubComponentEngine::Sub( " << x << " , " << y << " , " << z + << " ) after " << S << " seconds" ) + endService( " SubComponentEngine::Sub" ); +} + +extern "C" +{ + PortableServer::ObjectId * SubComponentEngine_factory + (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("SubComponentEngine_factory SubComponentEngine (" + << instanceName << "," << interfaceName << ")"); + SubComponentEngine * mySubComponent + = new SubComponentEngine(orb, poa, contId, instanceName, interfaceName); + return mySubComponent->getId() ; + } +} + + diff --git a/src/Supervision/CNode_Impl.cxx b/src/Supervision/CNode_Impl.cxx index 02cf4ad..452dff0 100644 --- a/src/Supervision/CNode_Impl.cxx +++ b/src/Supervision/CNode_Impl.cxx @@ -17,11 +17,11 @@ using namespace std; //#include "utilities.h" -#include "Graph_Impl.hxx" +#include "StreamGraph_Impl.hxx" #include "CNode_Impl.hxx" -#include "Port_Impl.hxx" +#include "StreamPort_Impl.hxx" CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb , PortableServer::POA_ptr poa , @@ -142,6 +142,9 @@ CNode_Impl::CNode_Impl( CORBA::ORB_ptr orb , _thisObj = this ; _id = _poa->activate_object(_thisObj); } + else { + MESSAGE( "CNode_Impl::CNode_Impl NO _poa->activate_object " ); + } _Orb = CORBA::ORB::_duplicate(orb); _Poa = poa ; _ContId = contId ; @@ -167,7 +170,7 @@ void CNode_Impl::destroy() { _thisObj->_remove_ref(); } } - endService( "CNode_Impl::Destroy" ); +// endService( "CNode_Impl::Destroy" ); } bool CNode_Impl::Delete() { @@ -176,7 +179,7 @@ bool CNode_Impl::Delete() { if ( _DataFlowEditor->IsEditing() ) { RetVal = _DataFlowEditor->RemoveNode( Name() ) ; if ( RetVal ) { - RetVal = _DataFlowEditor->IsValid() ; + RetVal = _DataFlowEditor->UnValid() ; } } endService( "CNode_Impl::Delete" ); @@ -203,7 +206,7 @@ char * CNode_Impl::Name() { RetVal = _DataFlowNode->Name() ; } else { - RetVal = _DataFlowEditor->Name() ; + RetVal = _DataFlowEditor->Graph()->Name() ; } // endService( "CNode_Impl::Name" ); return CORBA::string_dup( RetVal ); @@ -217,7 +220,7 @@ bool CNode_Impl::SetName( const char * aDataFlowName ) { aDataFlowName ) ; } else { - RetVal = _DataFlowEditor->Name( aDataFlowName ) ; + RetVal = _DataFlowEditor->Graph()->Name( aDataFlowName ) ; } } // endService( "CNode_Impl::SetName" ); @@ -230,7 +233,7 @@ SUPERV::KindOfNode CNode_Impl::Kind() { RetVal = _DataFlowNode->Kind() ; } else { - RetVal = _DataFlowEditor->Kind() ; + RetVal = _DataFlowEditor->Graph()->Kind() ; } // endService( "CNode_Impl::Kind" ); return RetVal ; @@ -242,11 +245,23 @@ bool CNode_Impl::IsGraph() { RetVal = _DataFlowNode->IsDataFlowNode() ; } else { - RetVal = _DataFlowEditor->IsDataFlowNode() ; + RetVal = _DataFlowEditor->Graph()->IsDataFlowNode() ; } // endService( "CNode_Impl::IsGraph" ); return RetVal ; } +bool CNode_Impl::IsStreamGraph() { +// beginService( "CNode_Impl::IsStreamGraph" ); + bool RetVal = false ; + if ( _IsNode ) { + RetVal = _DataFlowNode->IsDataStreamNode() ; + } + else { + RetVal = _DataFlowEditor->Graph()->IsDataStreamNode() ; + } +// endService( "CNode_Impl::IsStreamGraph" ); + return RetVal ; +} bool CNode_Impl::IsComputing() { // beginService( "CNode_Impl::IsComputing" ); bool RetVal = SUPERV::UnknownNode ; @@ -254,7 +269,7 @@ bool CNode_Impl::IsComputing() { RetVal = _DataFlowNode->IsComputingNode() ; } else { - RetVal = _DataFlowEditor->IsComputingNode() ; + RetVal = _DataFlowEditor->Graph()->IsComputingNode() ; } // endService( "CNode_Impl::IsComputing" ); return RetVal ; @@ -266,7 +281,7 @@ bool CNode_Impl::IsFactory() { RetVal = _DataFlowNode->IsFactoryNode() ; } else { - RetVal = _DataFlowEditor->IsFactoryNode() ; + RetVal = _DataFlowEditor->Graph()->IsFactoryNode() ; } // endService( "CNode_Impl::IsFactory" ); return RetVal ; @@ -278,7 +293,7 @@ bool CNode_Impl::IsInLine() { RetVal = _DataFlowNode->IsInLineNode() ; } else { - RetVal = _DataFlowEditor->IsInLineNode() ; + RetVal = _DataFlowEditor->Graph()->IsInLineNode() ; } // endService( "CNode_Impl::IsInLine" ); return RetVal ; @@ -290,7 +305,7 @@ bool CNode_Impl::IsGOTO() { RetVal = _DataFlowNode->IsGOTONode() ; } else { - RetVal = _DataFlowEditor->IsGOTONode() ; + RetVal = _DataFlowEditor->Graph()->IsGOTONode() ; } // endService( "CNode_Impl::IsGOTO" ); return RetVal ; @@ -302,7 +317,7 @@ bool CNode_Impl::IsLoop() { RetVal = _DataFlowNode->IsLoopNode() ; } else { - RetVal = _DataFlowEditor->IsLoopNode() ; + RetVal = _DataFlowEditor->Graph()->IsLoopNode() ; } // endService( "CNode_Impl::IsLoop" ); return RetVal ; @@ -314,7 +329,7 @@ bool CNode_Impl::IsEndLoop() { RetVal = _DataFlowNode->IsEndLoopNode() ; } else { - RetVal = _DataFlowEditor->IsEndLoopNode() ; + RetVal = _DataFlowEditor->Graph()->IsEndLoopNode() ; } // endService( "CNode_Impl::IsEndLoop" ); return RetVal ; @@ -326,7 +341,7 @@ bool CNode_Impl::IsSwitch() { RetVal = _DataFlowNode->IsSwitchNode() ; } else { - RetVal = _DataFlowEditor->IsSwitchNode() ; + RetVal = _DataFlowEditor->Graph()->IsSwitchNode() ; } // endService( "CNode_Impl::IsSwitch" ); return RetVal ; @@ -338,7 +353,7 @@ bool CNode_Impl::IsEndSwitch() { RetVal = _DataFlowNode->IsEndSwitchNode() ; } else { - RetVal = _DataFlowEditor->IsEndSwitchNode() ; + RetVal = _DataFlowEditor->Graph()->IsEndSwitchNode() ; } // endService( "CNode_Impl::IsEndSwitch" ); return RetVal ; @@ -353,7 +368,7 @@ SUPERV::SDate CNode_Impl::CreationDate() { else { // cout << " CNode_Impl::CreationDate " << _DataFlowEditor->FirstCreation() // << endl ; - RetVal = new SUPERV::SDate( _DataFlowEditor->FirstCreation() ) ; + RetVal = new SUPERV::SDate( _DataFlowEditor->Graph()->FirstCreation() ) ; } // endService( "CNode_Impl::CreationDate" ); return (RetVal._retn()) ; @@ -365,7 +380,7 @@ SUPERV::SDate CNode_Impl::LastUpdateDate() { RetVal = new SUPERV::SDate( _DataFlowNode->LastModification() ) ; } else { - RetVal = new SUPERV::SDate( _DataFlowEditor->LastModification() ) ; + RetVal = new SUPERV::SDate( _DataFlowEditor->Graph()->LastModification() ) ; } // endService( "CNode_Impl::LastUpdateDate" ); return (RetVal._retn()) ; @@ -377,7 +392,7 @@ char * CNode_Impl::Version() { RetVal = _DataFlowNode->EditorRelease() ; } else { - RetVal = _DataFlowEditor->EditorRelease() ; + RetVal = _DataFlowEditor->Graph()->EditorRelease() ; } // endService( "CNode_Impl::Version" ); return CORBA::string_dup( RetVal ) ; @@ -389,7 +404,7 @@ char * CNode_Impl::Author() { RetVal = _DataFlowNode->Author() ; } else { - RetVal = _DataFlowEditor->Author() ; + RetVal = _DataFlowEditor->Graph()->Author() ; } // endService( "CNode_Impl::Author" ); return CORBA::string_dup( RetVal ) ; @@ -402,7 +417,7 @@ bool CNode_Impl::SetAuthor( const char * aDataFlowAuthor ) { RetVal = _DataFlowNode->Author( aDataFlowAuthor ) ; } else { - RetVal = _DataFlowEditor->Author( aDataFlowAuthor ) ; + RetVal = _DataFlowEditor->Graph()->Author( aDataFlowAuthor ) ; } } // endService( "CNode_Impl::SetAuthor" ); @@ -415,7 +430,7 @@ char * CNode_Impl::Comment() { RetVal = _DataFlowNode->Comment() ; } else { - RetVal = _DataFlowEditor->Comment() ; + RetVal = _DataFlowEditor->Graph()->Comment() ; } // endService( "CNode_Impl::Comment" ); return CORBA::string_dup( RetVal ) ; @@ -428,23 +443,13 @@ bool CNode_Impl::SetComment( const char * aDataFlowComment ) { RetVal = _DataFlowNode->Comment( aDataFlowComment ) ; } else { - RetVal = _DataFlowEditor->Comment( aDataFlowComment ) ; + RetVal = _DataFlowEditor->Graph()->Comment( aDataFlowComment ) ; } } // endService( "CNode_Impl::SetComment" ); return RetVal ; } -SUPERV::ListOfLinks * CNode_Impl::Links() { - beginService( "CNode_Impl::Links" ) ; - SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; - if ( _DataFlowNode ) { - RetVal = DataFlowEditor()->ObjImpl()->Links( _DataFlowNode->ComputingNode() , NULL ) ; - } - endService( "CNode_Impl::Links" ) ; - return ( RetVal._retn() ) ; -} - void CNode_Impl::Coords(long X , long Y ) { // beginService( "CNode_Impl::Coords" ); if ( _DataFlowEditor->IsEditing() ) { @@ -452,7 +457,7 @@ void CNode_Impl::Coords(long X , long Y ) { ((GraphEditor::InNode *) _DataFlowNode)->Coordinates( X , Y ) ; } else { - _DataFlowEditor->Coordinates( X , Y ) ; + _DataFlowEditor->Graph()->Coordinates( X , Y ) ; } } // endService( "CNode_Impl::Coords" ); @@ -464,8 +469,7 @@ long CNode_Impl::X() { RetVal = _DataFlowNode->XCoordinate() ; } else { -// RetVal = _DataFlowEditor->XCoordinate() ; - RetVal = 0 ; + RetVal = _DataFlowEditor->Graph()->XCoordinate() ; } // endService( "CNode_Impl::X" ); return RetVal ; @@ -477,32 +481,12 @@ long CNode_Impl::Y() { RetVal = _DataFlowNode->YCoordinate() ; } else { -// RetVal = _DataFlowEditor->YCoordinate() ; - RetVal = 0 ; + RetVal = _DataFlowEditor->Graph()->YCoordinate() ; } // endService( "CNode_Impl::Y" ); return RetVal ; } -#if 0 -SUPERV::Link_ptr CNode_Impl::Link( const char * ToServiceParameterName , - const SUPERV::Value_ptr aValue ) { - beginService( "CNode_Impl::Link" ); - Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowNode , - ToServiceParameterName , - aValue ) ; - PortableServer::ObjectId * id = myLink->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Link_var iobject ; - iobject = SUPERV::Link::_narrow(obj) ; - endService( "CNode_Impl::Link" ); - return SUPERV::Link::_duplicate( iobject ) ; -} -#endif - SUPERV::Port_ptr CNode_Impl::Port( const char * ServiceParameterName ) { bool begin = true ; Port_Impl * myPort = NULL ; @@ -520,7 +504,7 @@ SUPERV::Port_ptr CNode_Impl::Port( const char * ServiceParameterName ) { } else { anoutport = _DataFlowEditor->GetOutPort( ServiceParameterName ) ; - } + } if ( aninport ) { GraphBase::InPort * anInPort ; if ( _IsNode ) { @@ -529,7 +513,10 @@ SUPERV::Port_ptr CNode_Impl::Port( const char * ServiceParameterName ) { else { anInPort = _DataFlowEditor->GetChangeInPort( ServiceParameterName ) ; } - if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( anInPort->IsDataStream() ) { + MESSAGE( "CNode_Impl::Port ERROR IsDataStream " ) ; + } + else if ( CORBA::is_nil( anInPort->ObjRef() ) ) { if ( begin ) { beginService( "CNode_Impl::Port" ); begin = false ; @@ -578,7 +565,10 @@ SUPERV::Port_ptr CNode_Impl::Port( const char * ServiceParameterName ) { else { anOutPort = _DataFlowEditor->GetChangeOutPort( ServiceParameterName ) ; } - if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( anOutPort->IsDataStream() ) { + MESSAGE( "CNode_Impl::Port ERROR IsDataStream " ) ; + } + else if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { if ( begin ) { beginService( "CNode_Impl::Port" ); begin = false ; @@ -604,6 +594,7 @@ SUPERV::Port_ptr CNode_Impl::Port( const char * ServiceParameterName ) { if ( !begin ) { endService( "CNode_Impl::Port" ); } + DataFlowEditor()->UnValid() ; return SUPERV::Port::_duplicate( iobject ) ; } @@ -622,10 +613,10 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName , anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; } else { - sts = _DataFlowEditor->AddInputData( _DataFlowEditor->Name() , + sts = _DataFlowEditor->AddInputData( _DataFlowEditor->Graph()->Name() , ToServiceParameterName , *aValue->ToAny() ) ; - anInPort = _DataFlowEditor->GetChangeInPort( ToServiceParameterName ) ; + anInPort = _DataFlowEditor->Graph()->GetChangeInPort( ToServiceParameterName ) ; } if ( sts && anInPort ) { if ( CORBA::is_nil( anInPort->ObjRef() ) ) { @@ -660,10 +651,10 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName , anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; } else { - sts = _DataFlowExecutor->ChangeInputData( _DataFlowEditor->Name() , + sts = _DataFlowExecutor->ChangeInputData( _DataFlowEditor->Graph()->Name() , ToServiceParameterName , *aValue->ToAny() ) ; - anInPort = _DataFlowEditor->GetChangeInPort( ToServiceParameterName ) ; + anInPort = _DataFlowEditor->Graph()->GetChangeInPort( ToServiceParameterName ) ; } if ( sts && anInPort ) { if ( CORBA::is_nil( anInPort->ObjRef() ) ) { @@ -697,129 +688,239 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName , MESSAGE( "CNode_Impl::Input returns nil object _IsNode " << _IsNode << " sts " << sts << " anInPort " << anInPort ) ; } + DataFlowEditor()->UnValid() ; return SUPERV::Port::_duplicate( iobject ) ; } -SUPERV::ListOfPorts * CNode_Impl::Ports() { - bool begin = true ; - SUPERV::ListOfPorts_var RetVal = new SUPERV::ListOfPorts ; - if ( _IsNode ) { - int i , j ; - RetVal->length( _DataFlowNode->GetNodeInPortsSize() + - _DataFlowNode->GetNodeOutPortsSize() ) ; - for ( i = 0 ; i < _DataFlowNode->GetNodeInPortsSize() ; i++ ) { - GraphBase::InPort * anInPort = _DataFlowNode->GetChangeNodeInPort( i ) ; - if ( begin ) { - beginService( "CNode_Impl::Ports" ); - begin = false ; +SUPERV::Port_ptr CNode_Impl::GetInPort( const char *aParameterName ) { + SUPERV::Port_ptr Inobject = SUPERV::Port::_nil() ; + Port_Impl * myInPort = NULL ; + GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ; + if ( anInPort && !anInPort->IsDataStream() ) { + Inobject = anInPort->ObjRef() ; + if ( CORBA::is_nil( Inobject ) ) { + myInPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anInPort , + true ) ; + if ( myInPort ) { + PortableServer::ObjectId * id = myInPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Inobject = SUPERV::Port::_narrow(obj) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( Inobject ) ) ; } - if ( anInPort->IsLoop() || ( anInPort->IsGate() && !anInPort->IsConnected() && - ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) { -// MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " ignored" ) ; - RetVal[ i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + } + return SUPERV::Port::_duplicate( Inobject ) ; +} + +SUPERV::Port_ptr CNode_Impl::GetOutPort( const char *aParameterName ) { + Port_Impl * myOutPort = NULL ; + SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ; + GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ; + if ( anOutPort && !anOutPort->IsDataStream() ) { + Outobject = anOutPort->ObjRef() ; + if ( CORBA::is_nil( Outobject ) ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myOutPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + if ( myOutPort ) { + PortableServer::ObjectId * id = myOutPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Outobject = SUPERV::Port::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::Port::_duplicate( Outobject ) ) ; } - else if ( CORBA::is_nil( anInPort->ObjRef() ) ) { -// MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsExecuting " -// << _DataFlowEditor->IsExecuting() << " IsGate/IsConnected " << anInPort->IsGate() -// << "/" << anInPort->IsConnected() ) ; - Port_Impl * myPort ; - if ( _DataFlowNode->HasInput( anInPort->PortName() ) ) { - const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; - myPort = new Port_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowNode , -// anInPort->PortName() , - (GraphBase::Port * ) anInPort , - true , - anAny ) ; - } - else { - myPort = new Port_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowNode , -// anInPort->PortName() ) ; - (GraphBase::Port * ) anInPort , - true ) ; + } + } + return SUPERV::Port::_duplicate( Outobject ); +} + +SUPERV::StreamPort_ptr CNode_Impl::GetInStreamPort( const char *aParameterName ) { + SUPERV::StreamPort_ptr Inobject = SUPERV::StreamPort::_nil() ; + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + StreamPort_Impl * myInStreamPort = NULL ; + GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ; + if ( anInPort && anInPort->IsDataStream() ) { + Inobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ; + if ( CORBA::is_nil( Inobject ) ) { + myInStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anInPort , + true ) ; + if ( myInStreamPort ) { + PortableServer::ObjectId * id = myInStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Inobject = SUPERV::StreamPort::_narrow(obj) ; + anInPort->ObjRef( SUPERV::StreamPort::_duplicate( Inobject ) ) ; + } + } + } + } + return SUPERV::StreamPort::_duplicate( Inobject ) ; +} + +SUPERV::StreamPort_ptr CNode_Impl::GetOutStreamPort( const char *aParameterName ) { + StreamPort_Impl * myOutStreamPort = NULL ; + SUPERV::StreamPort_ptr Outobject = SUPERV::StreamPort::_nil() ; + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ; + if ( anOutPort && anOutPort->IsDataStream() ) { + Outobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ; + if ( CORBA::is_nil( Outobject ) ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myOutStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + if ( myOutStreamPort ) { + PortableServer::ObjectId * id = myOutStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Outobject = SUPERV::StreamPort::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( Outobject ) ) ; } - PortableServer::ObjectId * id = myPort->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Port_var iobject ; - iobject = SUPERV::Port::_narrow(obj) ; - RetVal[ i ] = SUPERV::Port::_duplicate( iobject ) ; - anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; - } - else { -// MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() ) ; - RetVal[ i ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ; } } - for ( i = 0 ; i < _DataFlowNode->GetNodeOutPortsSize() ; i++ ) { - GraphBase::OutPort * anOutPort = _DataFlowNode->GetChangeNodeOutPort( i ) ; - if ( begin ) { - beginService( "CNode_Impl::Ports" ); - begin = false ; - } - if ( anOutPort->IsLoop() || ( anOutPort->IsGate() && !anOutPort->IsConnected() && - ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) { -// MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " ignored" ) ; - RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; - } - else if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { -// MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ; - const CORBA::Any * anAny = anOutPort->Value() ; - Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + } + return SUPERV::StreamPort::_duplicate( Outobject ); +} + +SUPERV::Link_ptr CNode_Impl::GetLink(const char * ToServiceParameterName ) { + bool begin = true ; + SUPERV::Link_var iobject = SUPERV::Link::_nil() ; + char* FromNodeName ; + char* FromServiceParameterName ; + bool status = _DataFlowEditor->GetLink( _DataFlowNode->Name() , + ToServiceParameterName , + & FromNodeName , + & FromServiceParameterName ) ; + if ( status ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; + if ( !anInPort->IsDataStream() && anInPort->GetOutPort() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "CNode_Impl::GetLink" ); + begin = false ; + } + bool Success ; + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , _DataFlowEditor , _DataFlowNode , -// anOutPort->PortName() , - (GraphBase::Port * ) anOutPort , - false , - anAny ) ; - PortableServer::ObjectId * id = myPort->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Port_var iobject ; - iobject = SUPERV::Port::_narrow(obj) ; - RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( iobject ) ; - anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + ToServiceParameterName , + (GraphEditor::InNode *) _DataFlowEditor->Graph()->GetChangeGraphNode( FromNodeName )->GetInNode() , + FromServiceParameterName , + true , false , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Link::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } } else { -// MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ; - RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ; - } - } - for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) { - if ( CORBA::is_nil( RetVal[ i ] ) ) { - for ( j = i ; j < (int ) RetVal->length() - 1 ; j++ ) { - RetVal[ j ] = RetVal[ j + 1 ] ; - } - RetVal->length( RetVal->length() - 1 ) ; - i-- ; + iobject = anOutPort->InPortObjRef( anInPort ) ; } } } - else { - if ( _DataFlowEditor->IsValid() ) { - int i , j ; - RetVal->length( _DataFlowEditor->GetNodeInDataNodePortsSize() + - _DataFlowEditor->GetNodeOutDataNodePortsSize() ) ; - for ( i = 0 ; i < _DataFlowEditor->GetNodeInDataNodePortsSize() ; i++ ) { - GraphBase::OutPort * anOutPort = _DataFlowEditor->GetChangeNodeInDataNodePort(i) ; - if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( !begin ) { + endService( "CNode_Impl::GetLink" ); + } + return SUPERV::Link::_duplicate( iobject ) ; +} + +SUPERV::StreamLink_ptr CNode_Impl::GetStreamLink(const char * ToServiceParameterName ) { + bool begin = true ; + SUPERV::StreamLink_var iobject = SUPERV::StreamLink::_nil() ; + char* FromNodeName ; + char* FromServiceParameterName ; + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + bool status = _DataFlowEditor->GetLink( _DataFlowNode->Name() , + ToServiceParameterName , + & FromNodeName , + & FromServiceParameterName ) ; + if ( status ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; + if ( anInPort->IsDataStream() && anInPort->GetOutPort() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { if ( begin ) { - beginService( "CNode_Impl::Ports" ); + beginService( "CNode_Impl::GetLink" ); begin = false ; + } + bool Success ; + StreamLink_Impl * myStreamLink = new StreamLink_Impl( + _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + ToServiceParameterName , + (GraphEditor::InNode *) _DataFlowEditor->Graph()->GetChangeGraphNode( FromNodeName )->GetInNode() , + FromServiceParameterName , + true , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myStreamLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamLink::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ; } + } + else { + iobject = SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ; + } + } + } + } + if ( !begin ) { + endService( "CNode_Impl::GetLink" ); + } + return SUPERV::StreamLink::_duplicate( iobject ) ; +} + +SUPERV::ListOfPorts * CNode_Impl::Ports() { + bool begin = true ; + int i , j ; + int PortCount = 0 ; + SUPERV::ListOfPorts_var RetVal = new SUPERV::ListOfPorts ; + if ( _IsNode ) { +// RetVal->length( _DataFlowNode->GetNodeInPortsSize() + +// _DataFlowNode->GetNodeOutPortsSize() ) ; + for ( i = 0 ; i < _DataFlowNode->GetNodeInPortsSize() ; i++ ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeNodeInPort( i ) ; + if ( !anInPort->IsDataStream() ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + if ( anInPort->IsLoop() || ( anInPort->IsGate() && !anInPort->IsConnected() && + ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) { + MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " ignored" ) ; +// RetVal[ i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + else if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsExecuting " + << _DataFlowEditor->IsExecuting() << " IsGate/IsConnected " << anInPort->IsGate() + << "/" << anInPort->IsConnected() ) ; Port_Impl * myPort ; - if ( anOutPort->IsDataConnected() ) { - const CORBA::Any * anAny = anOutPort->Value() ; + if ( _DataFlowNode->HasInput( anInPort->PortName() ) ) { + const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; myPort = new Port_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , _DataFlowEditor , _DataFlowNode , -// anOutPort->PortName() , - (GraphBase::Port * ) anOutPort , + (GraphBase::Port * ) anInPort , true , anAny ) ; } @@ -828,109 +929,427 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() { instanceName() , interfaceName() , _DataFlowEditor , _DataFlowNode , -// anOutPort->PortName() ) ; - (GraphBase::Port * ) anOutPort , + (GraphBase::Port * ) anInPort , true ) ; } PortableServer::ObjectId * id = myPort->getId() ; CORBA::Object_var obj = _poa->id_to_reference(*id); SUPERV::Port_var iobject ; iobject = SUPERV::Port::_narrow(obj) ; - RetVal[ i ] = SUPERV::Port::_duplicate( iobject ) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( iobject ) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() ) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ; + } + } + else { + MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsDataStream" ) ; +// RetVal[ i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + } + for ( i = 0 ; i < _DataFlowNode->GetNodeOutPortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = _DataFlowNode->GetChangeNodeOutPort( i ) ; + if ( !anOutPort->IsDataStream() ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + if ( anOutPort->IsLoop() || ( anOutPort->IsGate() && !anOutPort->IsConnected() && + ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) { + MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " ignored" ) ; +// RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + else if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ; + const CORBA::Any * anAny = anOutPort->Value() ; + Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( iobject ) ; anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; } else { - RetVal[ i ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ; + MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ; } } - j = _DataFlowEditor->GetNodeInDataNodePortsSize() ; - for ( i = 0 ; i < _DataFlowEditor->GetNodeOutDataNodePortsSize() ; i++ ) { - GraphBase::InPort * anInPort = _DataFlowEditor->GetChangeNodeOutDataNodePort(i) ; - if ( CORBA::is_nil( anInPort->ObjRef() ) ) { - if ( begin ) { - beginService( "CNode_Impl::Ports" ); - begin = false ; + else { + MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " IsDataStream" ) ; +// RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + } + } + else { + if ( _DataFlowEditor->IsValid() ) { + RetVal->length( _DataFlowEditor->Graph()->GetNodeInDataNodePortsSize() + + _DataFlowEditor->Graph()->GetNodeOutDataNodePortsSize() ) ; + for ( i = 0 ; i < _DataFlowEditor->Graph()->GetNodeInDataNodePortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = _DataFlowEditor->Graph()->GetChangeNodeInDataNodePort(i) ; + if ( !anOutPort->IsDataStream() ) { + if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + Port_Impl * myPort ; + if ( anOutPort->IsDataConnected() ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anOutPort , + true , + anAny ) ; + } + else { + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anOutPort , + true ) ; + } + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( iobject ) ; + anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ; } - Port_Impl * myPort ; - if ( anInPort->IsDataConnected() ) { + } + else { +// RetVal[ i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + } + j = _DataFlowEditor->Graph()->GetNodeInDataNodePortsSize() ; + for ( i = 0 ; i < _DataFlowEditor->Graph()->GetNodeOutDataNodePortsSize() ; i++ ) { + GraphBase::InPort * anInPort = _DataFlowEditor->Graph()->GetChangeNodeOutDataNodePort(i) ; + if ( !anInPort->IsDataStream() ) { + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::Ports" ); + begin = false ; + } + Port_Impl * myPort ; + if ( anInPort->IsDataConnected() ) { + const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anInPort , + false , + anAny ) ; + } + else { + myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + anInPort , + false ) ; + } + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Port_var iobject ; + iobject = SUPERV::Port::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( iobject ) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ; + } + } + else { +// RetVal[ j + i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ; + } + } + } + } +// int RetVallength = (unsigned int ) RetVal->length() ; +// for ( i = 0 ; i < RetVallength ; i++ ) { +// MESSAGE( "Port " << i << " " << RetVal[i]->Name() << " of Node " << Name() ) ; +// } + if ( !begin ) { + endService( "CNode_Impl::Ports " ) ; + } + return ( RetVal._retn() ) ; +} + +SUPERV::ListOfStreamPorts * CNode_Impl::StreamPorts() { + bool begin = true ; + int i , j ; + int PortCount = 0 ; + SUPERV::ListOfStreamPorts_var RetVal = new SUPERV::ListOfStreamPorts ; + if ( !DataFlowEditor()->Graph()->IsDataStreamNode() ) { +// MESSAGE("CNode_Impl::StreamPorts NOT a DataStreamNode" ) ; + } + else if ( _IsNode ) { +// RetVal->length( _DataFlowNode->GetNodeInPortsSize() + +// _DataFlowNode->GetNodeOutPortsSize() ) ; + for ( i = 0 ; i < _DataFlowNode->GetNodeInPortsSize() ; i++ ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeNodeInPort( i ) ; + if ( anInPort->IsDataStream() ) { + if ( begin ) { + beginService( "CNode_Impl::StreamPorts" ); + begin = false ; + } + if ( anInPort->IsLoop() || ( anInPort->IsGate() && !anInPort->IsConnected() && + ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) { + MESSAGE( "InStreamPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " ignored" ) ; +// RetVal[ i ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( CORBA::Object::_nil() ) ) ; + } + else if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + MESSAGE( "InStreamPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsExecuting " + << _DataFlowEditor->IsExecuting() << " IsGate/IsConnected " << anInPort->IsGate() + << "/" << anInPort->IsConnected() ) ; + StreamPort_Impl * myStreamPort ; + if ( _DataFlowNode->HasInput( anInPort->PortName() ) ) { const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; - myPort = new Port_Impl( _Orb , _Poa , _ContId , + myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , _DataFlowEditor , _DataFlowNode , -// anInPort->PortName() , (GraphBase::Port * ) anInPort , - false , + true , anAny ) ; } else { - myPort = new Port_Impl( _Orb , _Poa , _ContId , + myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , _DataFlowEditor , _DataFlowNode , -// anInPort->PortName() ) ; - anInPort , - false ) ; + (GraphBase::Port * ) anInPort , + true ) ; } - PortableServer::ObjectId * id = myPort->getId() ; + PortableServer::ObjectId * id = myStreamPort->getId() ; CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Port_var iobject ; - iobject = SUPERV::Port::_narrow(obj) ; - RetVal[ j + i ] = SUPERV::Port::_duplicate( iobject ) ; - anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + SUPERV::StreamPort_var iobject ; + iobject = SUPERV::StreamPort::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( iobject ) ; + anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ; } else { - RetVal[ j + i ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ; + MESSAGE( "InStreamPort " << i << " " << anInPort->PortName() << " of Node " << Name() ) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ) ; } } + else { +// RetVal[ i ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( CORBA::Object::_nil() ) ) ; + } } - } - if ( !begin ) { - endService( "CNode_Impl::Ports" ); - } - return ( RetVal._retn() ) ; -} - -SUPERV::Link_ptr CNode_Impl::GetLink(const char * ToServiceParameterName ) { - bool begin = true ; - SUPERV::Link_var iobject = SUPERV::Link::_nil() ; - char* FromNodeName ; - char* FromServiceParameterName ; - bool status = _DataFlowEditor->GetLink( _DataFlowNode->Name() , - ToServiceParameterName , - & FromNodeName , - & FromServiceParameterName ) ; - if ( status ) { - GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( ToServiceParameterName ) ; - if ( anInPort->GetOutPort() ) { - GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + for ( i = 0 ; i < _DataFlowNode->GetNodeOutPortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = _DataFlowNode->GetChangeNodeOutPort( i ) ; + if ( anOutPort->IsDataStream() ) { if ( begin ) { - beginService( "CNode_Impl::GetLink" ); + beginService( "CNode_Impl::StreamPorts" ); begin = false ; - } - Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowNode , - ToServiceParameterName , - (GraphEditor::InNode *) _DataFlowEditor->GetChangeGraphNode( FromNodeName )->GetInNode() , - FromServiceParameterName , - true ) ; - PortableServer::ObjectId * id = myLink->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - iobject = SUPERV::Link::_narrow(obj) ; - anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + if ( anOutPort->IsLoop() || ( anOutPort->IsGate() && !anOutPort->IsConnected() && + ( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) { + MESSAGE( "OutStreamPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " ignored" ) ; +// RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( CORBA::Object::_nil() ) ) ; + } + else if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + MESSAGE( "OutStreamPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ; + const CORBA::Any * anAny = anOutPort->Value() ; + StreamPort_Impl * myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamPort_var iobject ; + iobject = SUPERV::StreamPort::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( iobject ) ; + anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ; + } + else { + MESSAGE( "OutStreamPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ) ; + } } else { - iobject = anOutPort->InPortObjRef( anInPort ) ; +// RetVal[ i ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( CORBA::Object::_nil() ) ) ; } } } + else { + if ( _DataFlowEditor->IsValid() ) { +// RetVal->length( _DataFlowEditor->Graph()->GetNodeInDataNodePortsSize() + +// _DataFlowEditor->Graph()->GetNodeOutDataNodePortsSize() ) ; + for ( i = 0 ; i < _DataFlowEditor->Graph()->GetNodeInDataNodePortsSize() ; i++ ) { + GraphBase::OutPort * anOutPort = _DataFlowEditor->Graph()->GetChangeNodeInDataNodePort(i) ; + if ( anOutPort->IsDataStream() ) { + if ( CORBA::is_nil( anOutPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::StreamPorts" ); + begin = false ; + } + StreamPort_Impl * myStreamPort ; + if ( anOutPort->IsDataConnected() ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anOutPort , + true , + anAny ) ; + } + else { + myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anOutPort , + true ) ; + } + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamPort_var iobject ; + iobject = SUPERV::StreamPort::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( iobject ) ; + anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ; + } + else { + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ) ; + } + } + else { +// RetVal[ i ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( CORBA::Object::_nil() ) ) ; + } + } + j = _DataFlowEditor->Graph()->GetNodeInDataNodePortsSize() ; + for ( i = 0 ; i < _DataFlowEditor->Graph()->GetNodeOutDataNodePortsSize() ; i++ ) { + GraphBase::InPort * anInPort = _DataFlowEditor->Graph()->GetChangeNodeOutDataNodePort(i) ; + if ( anInPort->IsDataStream() ) { + if ( CORBA::is_nil( anInPort->ObjRef() ) ) { + if ( begin ) { + beginService( "CNode_Impl::StreamPorts" ); + begin = false ; + } + StreamPort_Impl * myStreamPort ; + if ( anInPort->IsDataConnected() ) { + const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ; + myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anInPort , + false , + anAny ) ; + } + else { + myStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + anInPort , + false ) ; + } + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamPort_var iobject ; + iobject = SUPERV::StreamPort::_narrow(obj) ; + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( iobject ) ; + anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ; + } + else { + PortCount += 1 ; + RetVal->length( PortCount ) ; + RetVal[ PortCount - 1 ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ) ; + } + } + else { +// RetVal[ i ] = SUPERV::StreamPort::_duplicate( SUPERV::StreamPort::_narrow( CORBA::Object::_nil() ) ) ; + } + } + } + } +// int RetVallength = (unsigned int ) RetVal->length() ; +// for ( i = 0 ; i < RetVallength ; i++ ) { +// MESSAGE( "StreamPort " << i << " " << RetVal[i]->Name() << " of Node " << Name() ) ; +// } if ( !begin ) { - endService( "CNode_Impl::GetLink" ); + endService( "CNode_Impl::StreamPorts " ) ; } - return SUPERV::Link::_duplicate( iobject ) ; + return ( RetVal._retn() ) ; +} + +SUPERV::ListOfLinks * CNode_Impl::Links() { + beginService( "CNode_Impl::Links" ) ; + SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; + if ( _DataFlowNode ) { + RetVal = DataFlowEditor()->Graph()->ObjImpl()->Links( _DataFlowNode->ComputingNode() , NULL ) ; + } + else { + RetVal = DataFlowEditor()->Graph()->ObjImpl()->Links( NULL , NULL ) ; + } + MESSAGE( "CNode_Impl::Links " << RetVal->length() << " Links" ) ; + endService( "CNode_Impl::Links" ) ; + return ( RetVal._retn() ) ; +} + +SUPERV::ListOfStreamLinks * CNode_Impl::StreamLinks() { + beginService( "CNode_Impl::StreamLinks" ) ; + SUPERV::ListOfStreamLinks_var RetVal = new SUPERV::ListOfStreamLinks ; + if ( _DataFlowNode && DataFlowEditor()->Graph()->IsDataStreamNode() ) { + RetVal = ((StreamGraph_Impl *) (DataFlowEditor()->StreamGraph()->ObjImpl()))->StreamLinks( _DataFlowNode->ComputingNode() , NULL ) ; + } + else if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + RetVal = ((StreamGraph_Impl *) (DataFlowEditor()->StreamGraph()->ObjImpl()))->StreamLinks( NULL , NULL ) ; + } + MESSAGE( "CNode_Impl::StreamLinks " << RetVal->length() << " StreamLinks" ) ; + endService( "CNode_Impl::StreamLinks" ) ; + return ( RetVal._retn() ) ; } long CNode_Impl::SubGraph() { @@ -943,6 +1362,16 @@ long CNode_Impl::SubGraph() { return RetVal ; } +long CNode_Impl::SubStreamGraph() { +// beginService( "CNode_Impl::SubStreamGraph" ); + long RetVal = 0 ; + if ( _IsNode ) { + RetVal = _DataFlowNode->SubStreamGraph() ; + } +// endService( "CNode_Impl::SubStreamGraph" ); + return RetVal ; +} + bool CNode_Impl::IsLinked(const char * ServiceParameterName ) { beginService( "CNode_Impl::IsLinked" ); bool RetVal = _DataFlowNode->IsLinked( ServiceParameterName ) ; @@ -1211,7 +1640,7 @@ bool CNode_Impl::ContainerKill() { return RetVal ; } bool CNode_Impl::Kill() { -// beginService( "CNode_Impl::Kill" ); + beginService( "CNode_Impl::Kill" ); bool RetVal = false ; GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; if ( _DataFlowExecutor ) { @@ -1220,9 +1649,10 @@ bool CNode_Impl::Kill() { } else { RetVal = _DataFlowExecutor->Kill() ; + MESSAGE( "Graph execution was killed " << RetVal ) ; } } -// endService( "CNode_Impl::Kill" ); + endService( "CNode_Impl::Kill" ); return RetVal ; } bool CNode_Impl::KillDone() { @@ -1244,18 +1674,20 @@ bool CNode_Impl::Stop() { return RetVal ; } bool CNode_Impl::Suspend() { -// beginService( "CNode_Impl::Suspend" ); + beginService( "CNode_Impl::Suspend" ); bool RetVal = false ; GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; if ( _DataFlowExecutor ) { if ( _IsNode ) { + MESSAGE( "CNode_Impl::Suspend " << Name() ) ; RetVal = _DataFlowExecutor->Suspend( Name() ) ; } else { + MESSAGE( "CNode_Impl::Suspend " << _DataFlowExecutor->Graph()->Name() ) ; RetVal = _DataFlowExecutor->Suspend() ; } } -// endService( "CNode_Impl::Suspend" ); + endService( "CNode_Impl::Suspend" ); return RetVal ; } bool CNode_Impl::SuspendDone() { @@ -1274,18 +1706,20 @@ bool CNode_Impl::SuspendDone() { return RetVal ; } bool CNode_Impl::Resume() { -// beginService( "CNode_Impl::Resume" ); bool RetVal = false ; + beginService( "CNode_Impl::Resume" ); GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; if ( _DataFlowExecutor ) { if ( _IsNode ) { + MESSAGE( "CNode_Impl::Resume " << Name() ) ; RetVal = _DataFlowExecutor->Resume( Name() ) ; } else { + MESSAGE( "CNode_Impl::Resume " << _DataFlowExecutor->Graph()->Name() ) ; RetVal = _DataFlowExecutor->Resume() ; } } -// endService( "CNode_Impl::Resume" ); + endService( "CNode_Impl::Resume" ); return RetVal ; } diff --git a/src/Supervision/CNode_Impl.hxx b/src/Supervision/CNode_Impl.hxx index a642a9f..eeb4028 100644 --- a/src/Supervision/CNode_Impl.hxx +++ b/src/Supervision/CNode_Impl.hxx @@ -108,7 +108,7 @@ class CNode_Impl : public POA_SUPERV::CNode , iobject = SUPERV::CNode::_narrow( _DataFlowNode->ObjRef() ) ; } else { - iobject = SUPERV::CNode::_narrow( _DataFlowEditor->ObjRef() ) ; + iobject = SUPERV::CNode::_narrow( _DataFlowEditor->Graph()->ObjRef() ) ; } return iobject ; } ; virtual void SetObjRef(SUPERV::CNode_var aNode ) { @@ -116,8 +116,9 @@ class CNode_Impl : public POA_SUPERV::CNode , _DataFlowNode->SetObjRef( aNode ) ; } else { - _DataFlowEditor->SetObjRef( SUPERV::Graph::_narrow( aNode ) ) ; - } } ; + _DataFlowEditor->Graph()->SetObjRef( SUPERV::Graph::_narrow( aNode ) ) ; + } + } ; virtual void Coords( const long X , const long Y ) ; virtual long X() ; @@ -138,12 +139,22 @@ class CNode_Impl : public POA_SUPERV::CNode , virtual SUPERV::Port_ptr Input( const char * ToServiceParameterName , const SUPERV::Value_ptr aValue ) ; + virtual SUPERV::Port_ptr GetInPort( const char * aParameterName ) ; + virtual SUPERV::Port_ptr GetOutPort( const char * aParameterName ) ; + + virtual SUPERV::StreamPort_ptr GetInStreamPort( const char * aParameterName ) ; + virtual SUPERV::StreamPort_ptr GetOutStreamPort( const char * aParameterName ) ; + virtual SUPERV::ListOfPorts * Ports() ; + virtual SUPERV::ListOfStreamPorts * StreamPorts() ; virtual SUPERV::ListOfLinks * Links() ; + virtual SUPERV::ListOfStreamLinks * StreamLinks() ; virtual SUPERV::Link_ptr GetLink( const char * ToServiceParameterName ) ; + virtual SUPERV::StreamLink_ptr GetStreamLink( const char * ToServiceParameterName ) ; + virtual bool IsStreamGraph() ; virtual bool IsGraph() ; virtual bool IsComputing() ; virtual bool IsFactory() ; @@ -155,6 +166,7 @@ class CNode_Impl : public POA_SUPERV::CNode , virtual bool IsEndSwitch() ; virtual long SubGraph() ; + virtual long SubStreamGraph() ; virtual bool IsLinked(const char * ToServiceParameterName ) ; virtual bool HasInput(const char * ToServiceParameterName ) ; diff --git a/src/Supervision/ELNode_Impl.cxx b/src/Supervision/ELNode_Impl.cxx index d0d4c86..86290ca 100644 --- a/src/Supervision/ELNode_Impl.cxx +++ b/src/Supervision/ELNode_Impl.cxx @@ -72,8 +72,8 @@ ELNode_Impl::~ELNode_Impl() { } void ELNode_Impl::destroy() { - MESSAGE("--------> ELNode_Impl::destroy() BEGIN"); - beginService( "ELNode_Impl::Destroy" ); +// MESSAGE("--------> ELNode_Impl::destroy() BEGIN"); +// beginService( "ELNode_Impl::Destroy" ); if ( DataFlowEditor()->IsEditing() ) { MESSAGE("--------> Editing dataflow"); SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ; @@ -89,8 +89,8 @@ void ELNode_Impl::destroy() { aCoupled->destroy() ; } } - endService( "ELNode_Impl::Destroy" ); - MESSAGE("--------> ELNode_Impl::destroy() END"); +// endService( "ELNode_Impl::Destroy" ); +// MESSAGE("--------> ELNode_Impl::destroy() END"); } bool ELNode_Impl::Delete() { diff --git a/src/Supervision/ESNode_Impl.cxx b/src/Supervision/ESNode_Impl.cxx index ee2230f..0329f2d 100644 --- a/src/Supervision/ESNode_Impl.cxx +++ b/src/Supervision/ESNode_Impl.cxx @@ -91,7 +91,7 @@ void ESNode_Impl::destroy() { aCoupled->destroy() ; } } - endService( "ESNode_Impl::Destroy" ); +// endService( "ESNode_Impl::Destroy" ); } bool ESNode_Impl::Delete() { diff --git a/src/Supervision/FNode_Impl.cxx b/src/Supervision/FNode_Impl.cxx index 49e6e5c..d5c9f0c 100644 --- a/src/Supervision/FNode_Impl.cxx +++ b/src/Supervision/FNode_Impl.cxx @@ -86,7 +86,7 @@ void FNode_Impl::destroy() { _thisObj->_remove_ref(); } } - endService( "FNode_Impl::Destroy" ); +// endService( "FNode_Impl::Destroy" ); } bool FNode_Impl::Delete() { @@ -146,8 +146,8 @@ bool FNode_Impl::SetContainer( const char * aDataFlowContainer ) { } else if ( _DataFlowExecutor && ( _DataFlowExecutor->IsSuspended() || _DataFlowExecutor->IsSuspended( DataFlowNode()->Name() ) ) ) { - if ( _DataFlowExecutor->GetChangeGraphNode( DataFlowNode()->Name() ) ) { - RetVal = ((GraphEditor::InNode * ) _DataFlowExecutor->GetChangeGraphNode( DataFlowNode()->Name() )->GetInNode())->Computer( aDataFlowContainer ) ; + if ( _DataFlowExecutor->Graph()->GetChangeGraphNode( DataFlowNode()->Name() ) ) { + RetVal = ((GraphEditor::InNode * ) _DataFlowExecutor->Graph()->GetChangeGraphNode( DataFlowNode()->Name() )->GetInNode())->Computer( aDataFlowContainer ) ; } } // endService( "FNode_Impl::SetContainer" ); diff --git a/src/Supervision/GNode_Impl.cxx b/src/Supervision/GNode_Impl.cxx index 2612505..02fc37e 100644 --- a/src/Supervision/GNode_Impl.cxx +++ b/src/Supervision/GNode_Impl.cxx @@ -120,7 +120,7 @@ void GNode_Impl::destroy() { _thisObj->_remove_ref(); } } - endService( "GNode_Impl::Destroy" ); +// endService( "GNode_Impl::Destroy" ); } bool GNode_Impl::Delete() { @@ -136,7 +136,7 @@ bool GNode_Impl::Delete() { } SUPERV::INode_ptr GNode_Impl::Coupled() { - beginService( "GNode_Impl::Coupled" ); +// beginService( "GNode_Impl::Coupled" ); SUPERV::INode_var iobject = SUPERV::INode::_nil() ; if ( DataFlowNode()->CoupledNode() ) { if ( CORBA::is_nil( DataFlowNode()->CoupledNode()->ObjRef() ) ) { @@ -153,7 +153,7 @@ SUPERV::INode_ptr GNode_Impl::Coupled() { iobject = SUPERV::INode::_narrow( DataFlowNode()->CoupledNode()->ObjRef() ) ; } } - endService( "GNode_Impl::Coupled" ); +// endService( "GNode_Impl::Coupled" ); return SUPERV::INode::_duplicate( iobject ) ; } diff --git a/src/Supervision/GNode_Impl.hxx b/src/Supervision/GNode_Impl.hxx index 72eed81..3821296 100644 --- a/src/Supervision/GNode_Impl.hxx +++ b/src/Supervision/GNode_Impl.hxx @@ -66,7 +66,7 @@ class GNode_Impl : public INode_Impl , virtual bool Delete() ; virtual bool SetCoupled( const char * anInLineNode ) { - GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->GetGraphNode( anInLineNode ) ; + GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ; // cout << Name() << ".SetCoupled " << anInLineNode << endl ; // if ( CoupledINode && ( IsGOTO() && if ( ( IsGOTO() && diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index 5a33219..abbebd9 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -45,17 +45,20 @@ Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb , PortableServer::ObjectId * contId , const char *instanceName , const char *interfaceName , - const char *aDataFlowName ) : - INode_Impl(orb, poa, contId, instanceName, interfaceName, aDataFlowName) { + const char *aDataFlowName , + const SUPERV::KindOfNode aKindOfNode ) : + INode_Impl( orb , poa , contId , instanceName , interfaceName , aDataFlowName ) { // MESSAGE("Graph_Impl::Graph_Impl activate object instanceName(" // << instanceName << ") interfaceName(" << interfaceName << ") --> " // << hex << (void *) this << dec ) beginService( "Graph_Impl::Graph_Impl" ); - _thisObj = this ; - _id = _poa->activate_object(_thisObj); _Orb = CORBA::ORB::_duplicate(orb); _Poa = poa ; _ContId = contId ; + if ( aKindOfNode == SUPERV::DataFlowGraph ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } string dbgfile = "/tmp/" ; dbgfile += instanceName ; @@ -86,11 +89,12 @@ Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb , strcpy( _DebugFileName , dbgfile.c_str() ) ; _NamingService = new SALOME_NamingService( orb ) ; - GraphEditor::DataFlow * aDataFlowEditor = new GraphEditor::DataFlow( _Orb , _NamingService , - theDataFlowName , - _DebugFileName ) ; + GraphEditor::DataFlow * aDataFlowEditor ; + aDataFlowEditor = new GraphEditor::DataFlow( _Orb , _NamingService , + theDataFlowName , _DebugFileName , + aKindOfNode ) ; DataFlowEditor( aDataFlowEditor ) ; - DataFlowEditor()->SetObjImpl( this ) ; + DataFlowEditor()->Graph()->SetObjImpl( this ) ; pthread_mutex_init( &_MutexExecutorWait , NULL ) ; _DataFlowExecutor = NULL ; delete [] theDataFlowName ; @@ -111,7 +115,7 @@ void Graph_Impl::destroy() { CORBA::release(_poa) ; delete(_id) ; _thisObj->_remove_ref(); - endService( "Graph_Impl::destroy" ); +// endService( "Graph_Impl::destroy" ); } char* Graph_Impl::getIOR() { @@ -129,12 +133,11 @@ SUPERV::Graph_ptr Graph_Impl::Copy() { Graph_Impl * myGraph ; myGraph = new Graph_Impl( _Orb , _Poa, _ContId, instanceName() , interfaceName() , - Name() ) ; + DataFlowEditor()->Graph()->Name() , SUPERV::DataFlowGraph ) ; PortableServer::ObjectId * id = myGraph->getId() ; CORBA::Object_var obj = _poa->id_to_reference(*id); SUPERV::Graph_var iobject ; iobject = SUPERV::Graph::_narrow(obj) ; -// GraphBase::SGraph * aSGraph = aGraph->GetGraph() ; GraphBase::SGraph * aSGraph = GetGraph() ; myGraph->LoadGraph( aSGraph ) ; endService( "Graph_Impl::Copy" ); @@ -203,7 +206,7 @@ bool Graph_Impl::Import(const char * aXmlFile ) { } bool Graph_Impl::Export(const char * anXmlFile ) { -// beginService( "Graph_Impl::Export" ); + beginService( "Graph_Impl::Export" ); char * aFile = new char [ strlen( anXmlFile ) + 5 ] ; strcpy( aFile , anXmlFile ) ; int len = strlen( aFile ) ; @@ -223,7 +226,7 @@ bool Graph_Impl::Export(const char * anXmlFile ) { RetVal = DataFlowEditor()->SavePy( aFile ) ; } delete [] aFile ; -// endService( "Graph_Impl::Export" ); + endService( "Graph_Impl::Export" ); return RetVal ; } @@ -330,7 +333,7 @@ SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName , iobject = SUPERV::GNode::_narrow(obj) ; myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ; if ( strlen( anInLineNode ) ) { - GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->GetGraphNode( anInLineNode ) ; + GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->Graph()->GetGraphNode( anInLineNode ) ; if ( anInLineNode ) { myNode->SetCoupled( anInLineNode ) ; Link( myNode->Port( "OutGate" ) , CoupledINode->ObjRef()->Port( "InGate" ) ) ; @@ -494,25 +497,35 @@ SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort , SUPERV::Port_ptr InPort ) { beginService( "Graph_Impl::Link" ); SUPERV::Link_var iobject = SUPERV::Link::_nil() ; - if ( DataFlowEditor()->IsEditing() && - !DataFlowEditor()->IsReadOnly() ) { - const char * DataFlowOutNodeName = OutPort->Node()->Name() ; - GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ; - const char * DataFlowInNodeName = InPort->Node()->Name() ; - GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ; - if ( DataFlowOutNode && DataFlowInNode ) { - Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - DataFlowEditor() , - DataFlowInNode , - InPort->Name() , - DataFlowOutNode , - OutPort->Name() , - true ) ; - PortableServer::ObjectId * id = myLink->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - iobject = SUPERV::Link::_narrow(obj) ; -// iobject = InPort->Link() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && + !OutPort->IsDataStream() && !InPort->IsDataStream() ) { + GraphBase::InPort * anInPort = DataFlowEditor()->GetNode( InPort->Node()->Name() )->ComputingNode()->GetChangeInPort( InPort->Name() ) ; + GraphBase::OutPort * anOutPort = DataFlowEditor()->GetNode( OutPort->Node()->Name() )->ComputingNode()->GetChangeOutPort( OutPort->Name() ) ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + const char * DataFlowOutNodeName = OutPort->Node()->Name() ; + GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ; + const char * DataFlowInNodeName = InPort->Node()->Name() ; + GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ; + if ( DataFlowOutNode && DataFlowInNode ) { + bool Success ; + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowInNode , + InPort->Name() , + DataFlowOutNode , + OutPort->Name() , + true , false , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Link::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + } + } + else { + iobject = anOutPort->InPortObjRef( anInPort ) ; } } endService( "Graph_Impl::Link" ); @@ -606,14 +619,13 @@ void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) { SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal , GraphBase::ComputingNode * aNode ) { int index = 0 ; -// MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ; -// if ( _DataFlowExecutor ) { -// MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " " -// << _DataFlowExecutor->StateName( _DataFlowExecutor->AutomatonState( aNode->Name() ) ) ) ; -// } -// else { -// MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ; -// } + if ( _DataFlowExecutor ) { + MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() << " " + << _DataFlowExecutor->StateName( _DataFlowExecutor->AutomatonState( aNode->Name() ) ) ) ; + } + else { + MESSAGE("Graph_Impl::SetNode " << aNode->Name() << " " << aNode->Kind() ) ; + } if ( aNode->IsComputingNode() ) { index = RetVal->CNodes.length() ; RetVal->CNodes.length( index+1 ); @@ -687,26 +699,28 @@ SUPERV::ListOfNodes * Graph_Impl::Nodes() { RetVal->SNodes.length(0) ; RetVal->GNodes.length(0) ; int i ; - for ( i = 0 ; i < DataFlowEditor()->GraphNodesSize() ; i++ ) { - GraphBase::ComputingNode * aNode = DataFlowEditor()->GraphNodes( i ) ; + for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GraphNodes( i ) ; RetVal = SetNode( RetVal , aNode ) ; } +#if 0 char * aStateG = "" ; if ( _DataFlowExecutor ) { aStateG = (char *) _DataFlowExecutor->StateName( _DataFlowExecutor->AutomatonState() ) ; } -// MESSAGE("Graph_Impl::Nodes GraphState " << aStateG -// << " CNodes " << RetVal->CNodes.length() -// << " FNodes " << RetVal->FNodes.length() -// << " INodes " << RetVal->INodes.length() -// << " GNodes " << RetVal->GNodes.length() -// << " LNodes " << RetVal->LNodes.length() -// << " ELNodes " << RetVal->ELNodes.length() -// << " SNodes " << RetVal->SNodes.length() -// << " ESNodes " << RetVal->ESNodes.length() ) ; -// if ( _DataFlowExecutor ) { -// _DataFlowExecutor->EventList() ; -// } + MESSAGE("Graph_Impl::Nodes GraphState " << aStateG + << " CNodes " << RetVal->CNodes.length() + << " FNodes " << RetVal->FNodes.length() + << " INodes " << RetVal->INodes.length() + << " GNodes " << RetVal->GNodes.length() + << " LNodes " << RetVal->LNodes.length() + << " ELNodes " << RetVal->ELNodes.length() + << " SNodes " << RetVal->SNodes.length() + << " ESNodes " << RetVal->ESNodes.length() ) ; + if ( _DataFlowExecutor ) { + _DataFlowExecutor->EventList() ; + } +#endif endService( "Graph_Impl::Nodes" ); return ( RetVal._retn() ) ; } @@ -719,11 +733,12 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , const char * anInputParam ) { bool begin = true ; SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; + RetVal->length( 0 ) ; int i , j , countlink ; countlink = 0 ; - for ( i = 0 ; i < DataFlowEditor()->GraphNodesSize() ; i++ ) { + for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) { GraphEditor::InNode * aNode = NULL ; - aNode = (GraphEditor::InNode * ) DataFlowEditor()->GraphNodes( i )->GetInNode() ; + aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ; bool ToProcess = false ; if ( theNode == NULL ) { ToProcess = true ; @@ -744,15 +759,15 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , anInPort = aNode->GetChangeNodeInPort( j ) ; if ( anInputParam == NULL || !strcmp( anInPort->PortName() , anInputParam ) ) { - if ( anInPort->GetOutPort() ) { - GraphBase::OutPort * anOutPort = NULL ; - anOutPort = anInPort->GetOutPort() ; + GraphBase::OutPort * anOutPort = NULL ; + anOutPort = anInPort->GetOutPort() ; + if ( anOutPort && !anOutPort->IsDataStream() ) { if ( strcmp( anOutPort->NodeName() , Name() ) ) { // MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "(" // << anOutPort->PortName() << ") --> " << aNode->Name() << "(" // << anInPort->PortName() << ")" ) ; if ( theNode == NULL || - ( theNode != NULL && theNode->IsEndSwitchNode() && + ( theNode != NULL && !theNode->IsEndSwitchNode() && !strcmp( theNode->Name() , aNode->Name() ) ) ) { if ( anInPort->IsLoop() || anOutPort->IsLoop() || ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() , @@ -767,8 +782,9 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , begin = false ; } GraphEditor::InNode * anOutNode = NULL ; - anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ; + anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ; if ( anOutNode ) { + bool Success ; Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , DataFlowEditor() , @@ -776,20 +792,30 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , anInPort->PortName() , anOutNode , anOutPort->PortName() , - false ) ; - PortableServer::ObjectId * id = myLink->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Link_var iobject ; - iobject = SUPERV::Link::_narrow(obj) ; - RetVal->length( countlink + 1 ) ; - RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ; - anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + false , true , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Link_var iobject ; + iobject = SUPERV::Link::_narrow(obj) ; + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } } } else { RetVal->length( countlink + 1 ) ; RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ; } +// MESSAGE( "Link " << anOutPort->NodeName() << "(" +// << anOutPort->PortName() << ") --> " << aNode->Name() << "(" +// << anInPort->PortName() << ")" << " selected" ) ; + } + else { +// MESSAGE( "Link " << anOutPort->NodeName() << "(" +// << anOutPort->PortName() << ") --> " << aNode->Name() << "(" +// << anInPort->PortName() << ")" << " skipped" ) ; } } } @@ -801,44 +827,56 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , int k ; for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) { GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ; - GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; + GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; if ( theNode == NULL || - !strcmp( theNode->Name() , toNode->Name() ) || !strcmp( theNode->Name() , aNode->Name() ) ) { - if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) { - if ( anInputParam == NULL || - !strcmp( anInPort->PortName() , anInputParam ) ) { - if ( anInPort->IsLoop() || anOutPort->IsLoop() || - ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() , - anOutPort->NodeName() ) ) ) { -// MESSAGE( "Link " << anOutPort->NodeName() << "(" -// << anOutPort->PortName() << ") --> " << aNode->Name() << "(" -// << anInPort->PortName() << ")" << " ignored" ) ; - } - else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { - if ( begin ) { - beginService( "Graph_Impl::Links" ); - begin = false ; - } - Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , + if ( !anInPort->IsDataStream() ) { + if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) { + if ( anInputParam == NULL || + !strcmp( anInPort->PortName() , anInputParam ) ) { + if ( anInPort->IsLoop() || anOutPort->IsLoop() || + ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() , + anOutPort->NodeName() ) ) ) { +// MESSAGE( "Link " << anOutPort->NodeName() << "(" +// << anOutPort->PortName() << ") --> " << toNode->Name() << "(" +// << anInPort->PortName() << ")" << " ignored" ) ; + } + else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "Graph_Impl::Links" ); + begin = false ; + } + bool Success ; + Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , DataFlowEditor() , toNode , anInPort->PortName() , aNode , anOutPort->PortName() , - false ) ; - PortableServer::ObjectId * id = myLink->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Link_var iobject ; - iobject = SUPERV::Link::_narrow(obj) ; - RetVal->length( countlink + 1 ) ; - RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ; - anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + false , true , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::Link_var iobject ; + iobject = SUPERV::Link::_narrow(obj) ; + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( iobject ) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } + } + else { + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::Link::_duplicate( SUPERV::Link::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ; + } +// MESSAGE( "Link " << anOutPort->NodeName() << "(" +// << anOutPort->PortName() << ") --> " << toNode->Name() << "(" +// << anInPort->PortName() << ")" << " selected" ) ; } else { - RetVal->length( countlink + 1 ) ; - RetVal[ countlink++ ] = SUPERV::Link::_duplicate( anOutPort->InPortObjRef( anInPort ) ) ; +// MESSAGE( "Link " << anOutPort->NodeName() << "(" +// << anOutPort->PortName() << ") --> " << toNode->Name() << "(" +// << anInPort->PortName() << ")" << " skipped" ) ; } } } @@ -846,25 +884,34 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , } } } +#if 0 + const char * NodeName = "" ; + const char * InputParamName = "" ; + if ( theNode ) { + NodeName = theNode->Name() ; + } + if ( anInputParam ) { + InputParamName = anInputParam ; + } + MESSAGE( RetVal->length() << " Links of Node " << NodeName << " and of InPort " << InputParamName ) ; + for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) { + MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "(" + << RetVal[i]->OutPort()->Name() << ") --> " + << RetVal[i]->InPort()->Node()->Name() << "(" + << RetVal[i]->InPort()->Name() << ")" ) ; + } +#endif if ( !begin ) { endService( "Graph_Impl::Links" ); } return ( RetVal._retn() ) ; } -SUPERV::ListOfGraphs * Graph_Impl::Graphs() { -// beginService( "Graph_Impl::ListOfGraphs" ); - SUPERV::ListOfGraphs_var RetVal = new SUPERV::ListOfGraphs ; - MESSAGE( "Graph_Impl::Graphs not yet implemented" ); -// endService( "Graph_Impl::ListOfGraphs" ); - return ( RetVal._retn() ) ; -} - Engines::Component_ptr Graph_Impl::ComponentRef( const char * aComputerContainer , const char * aComponentName ) { Engines::Container_var myContainer ; Engines::Component_var objComponent ; - DataFlowEditor()->StartComponent( 0 , aComputerContainer , aComponentName , + DataFlowEditor()->Graph()->StartComponent( 0 , aComputerContainer , aComponentName , myContainer , objComponent ) ; return Engines::Component::_duplicate( objComponent ) ; } @@ -881,12 +928,6 @@ bool Graph_Impl::IsExecutable() { // endService( "Graph_Impl::IsExecutable" ); return RetVal ; } -bool Graph_Impl::IsDataFlow() { -// beginService( "Graph_Impl::IsDataFlow" ); - bool RetVal = false ; // = DataFlowEditor()->IsDataFlow() ; -// endService( "Graph_Impl::IsDataFlow" ); - return RetVal ; -} bool Graph_Impl::IsEditing() { // beginService( "Graph_Impl::IsEditing" ); @@ -922,7 +963,7 @@ SUPERV::ListOfNodes * Graph_Impl::LevelNodes(long aLevel ) { // RetVal->length( Nodes->length() ); for ( i = 0 ; i < (int ) Nodes->length() ; i++ ) { // char * aNode = Nodes[ i ] ; - GraphBase::ComputingNode * aNode = DataFlowEditor()->GetChangeGraphNode( Nodes[ i ] ) ; + GraphBase::ComputingNode * aNode = DataFlowEditor()->Graph()->GetChangeGraphNode( Nodes[ i ] ) ; RetVal = SetNode( RetVal , aNode ) ; // cout << "Graph_Impl::LevelNodes( " << aLevel << " ) " << aNode->Name() << endl ; // CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , @@ -944,12 +985,6 @@ long Graph_Impl::ThreadsMax() { // endService( "Graph_Impl::ThreadsMax" ); return RetVal ; } -long Graph_Impl::GraphsNumber() { -// beginService( "Graph_Impl::GraphsNumber" ); - long RetVal = DataFlowEditor()->GraphsNumber() ; -// endService( "Graph_Impl::GraphsNumber" ); - return RetVal ; -} long Graph_Impl::Threads() { // beginService( "Node_Impl::Threads" ); long RetVal = _DataFlowExecutor->Threads() ; @@ -992,10 +1027,11 @@ bool Graph_Impl::Begin() { GraphBase::SGraph * myGraph = DataFlowEditor()->GetDataFlow() ; _DataFlowExecutor = new GraphExecutor::DataFlow( _Orb , _NamingService , myGraph->Info.theName.c_str() , - DebugFileName ) ; + DebugFileName , Kind() ) ; MESSAGE( "Graph_Impl::Begin : DataFlowExecutor created" ); RetVal = _DataFlowExecutor->LoadDataFlow( *myGraph ) ; if ( RetVal ) { + _DataFlowExecutor->Graph()->SetObjImpl( DataFlowEditor()->Graph()->ObjImpl() ) ; DataFlowEditor()->Executor( _DataFlowExecutor ) ; } if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) { @@ -1190,14 +1226,101 @@ long Graph_Impl::LastLevelDone() { return RetVal ; } +long Graph_Impl::SubGraphsNumber() { +// beginService( "Graph_Impl::SubGraphsNumber" ); + long RetVal = 0 ; + if ( DataFlowEditor()->IsExecutable() ) { + RetVal = DataFlowEditor()->SubGraphsNumber() ; + } +// endService( "Graph_Impl::SubGraphsNumber" ); + return RetVal ; +} + +SUPERV::ListOfNodes * Graph_Impl::SubGraphsNodes( const long aSubGraphNumber ) { + beginService( "Graph_Impl::SubGraphsNodes" ); + SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ; + if ( DataFlowEditor()->IsEditing() ) { + SUPERV::ListOfNodes * aGraphNodes = Nodes() ; + int i ; +// ComputingNodes + for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) { + SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// FactoryNodes + for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) { + SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// InLineNodes + for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) { + SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// GOTONodes + for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) { + SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// LoopNodes + for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) { + SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// EndLoopNodes + for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) { + SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// SwitchNodes + for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) { + SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// EndSwitchNodes + for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) { + SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ; + if ( aNode->SubGraph() == aSubGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } + } + endService( "Graph_Impl::SubGraphsNodes" ); + return ( RetVal._retn() ) ; +} + bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { +// beginService( "Graph_Impl::Merge" ); + bool RetVal = true ; + map< string , int > aMapOfNodes ; + RetVal = Merge( aGraph , aMapOfNodes ) ; +// endService( "Graph_Impl::Merge" ); + return RetVal ; +} + +bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) { beginService( "Graph_Impl::Merge" ); bool RetVal = true ; if ( DataFlowEditor()->IsEditing() ) { SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ; - int i ; - map< string , int > aMapOfNodes ; + SUPERV::Port_ptr aPort ; +// SUPERV::StreamPort_ptr aStreamPort ; +// ComputingNodes for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) { SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ; SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ; @@ -1207,7 +1330,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { myNode->SetComment( aNode->Comment() ) ; myNode->Coords( aNode->X() , aNode->Y() ) ; string * aNodetheName = new string( aNode->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ; delete aNodetheName ; RetVal = true ; } @@ -1215,7 +1338,19 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { RetVal = false ; break ; } +// The following informations are now in the service from SALOME_ModuleCatalog +// SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ; +// int j ; +// for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) { +// if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) { +// aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ; +// } +// else if ( myStreamPorts[ j ]->IsDataStream() ) { +// aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ; +// } +// } } +// FactoryNodes if ( RetVal ) { for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) { SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ; @@ -1228,7 +1363,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { myNode->SetComment( aNode->Comment() ) ; myNode->Coords( aNode->X() , aNode->Y() ) ; string * aNodetheName = new string( aNode->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ; delete aNodetheName ; RetVal = true ; } @@ -1236,8 +1371,20 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { RetVal = false ; break ; } +// The following informations are now in the service from SALOME_ModuleCatalog +// SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ; +// int j ; +// for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) { +// if ( myStreamPorts[ j ]->IsInput() && myStreamPorts[ j ]->IsDataStream() ) { +// aStreamPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ; +// } +// else if ( myStreamPorts[ j ]->IsDataStream() ) { +// aStreamPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , myStreamPorts[ j ]->Type() ) ; +// } +// } } } +// InLineNodes if ( RetVal ) { for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) { SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ; @@ -1248,16 +1395,27 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { myNode->SetComment( aNode->Comment() ) ; myNode->Coords( aNode->X() , aNode->Y() ) ; string * aNodetheName = new string( aNode->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ; delete aNodetheName ; SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ; int j ; for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) { if ( myPorts[ j ]->IsInput() ) { - myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; } else { - myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + } + } + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ; + for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) { + if ( myStreamPorts[ j ]->IsInput() ) { + aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } + else { + aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } } } RetVal = true ; @@ -1268,6 +1426,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { } } } +// GOTONodes if ( RetVal ) { for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) { SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ; @@ -1278,16 +1437,27 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { myNode->SetComment( aNode->Comment() ) ; myNode->Coords( aNode->X() , aNode->Y() ) ; string * aNodetheName = new string( aNode->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ; delete aNodetheName ; SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ; int j ; for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) { if ( myPorts[ j ]->IsInput() ) { - myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; } else { - myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + } + } + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ; + for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) { + if ( myStreamPorts[ j ]->IsInput() ) { + aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } + else { + aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } } } RetVal = true ; @@ -1298,6 +1468,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { } } } +// LoopNodes if ( RetVal ) { for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) { SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ; @@ -1315,13 +1486,27 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { myNode->SetComment( aNode->Comment() ) ; myNode->Coords( aNode->X() , aNode->Y() ) ; string * aNodetheName = new string( aNode->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ; delete aNodetheName ; SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ; int j ; for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) { if ( myPorts[ j ]->IsInput() ) { - myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + } + else { + aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + } + } + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ; + for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) { + if ( myStreamPorts[ j ]->IsInput() ) { + aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } + else { + aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } } } SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ; @@ -1331,7 +1516,18 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ; anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ; aNodetheName = new string( myEndOfLoop->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( anEndOfLoop->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfLoop->Name() ) ; + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + SUPERV::ListOfStreamPorts myStreamLoopPorts = *(myEndOfLoop->StreamPorts()) ; + for ( j = 0 ; j < (int ) myStreamLoopPorts.length() ; j++ ) { + if ( myStreamLoopPorts[ j ]->IsInput() ) { + aPort = myNode->InStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ; + } + else { + aPort = myNode->OutStreamPort( myStreamLoopPorts[ j ]->Name() , StringToDataStreamType( myStreamLoopPorts[ j ]->Type() ) , myStreamLoopPorts[ j ]->Dependency() ) ; + } + } + } delete aNodetheName ; RetVal = true ; } @@ -1341,6 +1537,7 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { } } } +// SwitchNodes if ( RetVal ) { for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) { SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ; @@ -1352,16 +1549,27 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { myNode->SetComment( aNode->Comment() ) ; myNode->Coords( aNode->X() , aNode->Y() ) ; string * aNodetheName = new string( aNode->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( myNode->Name() ) ; delete aNodetheName ; SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ; int j ; for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) { if ( myPorts[ j ]->IsInput() ) { - myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; } else { - myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + } + } + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + SUPERV::ListOfStreamPorts myStreamPorts = *(aNode->StreamPorts()) ; + for ( j = 0 ; j < (int ) myStreamPorts.length() ; j++ ) { + if ( myStreamPorts[ j ]->IsInput() ) { + aPort = myNode->InStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } + else { + aPort = myNode->OutStreamPort( myStreamPorts[ j ]->Name() , StringToDataStreamType( myStreamPorts[ j ]->Type() ) , myStreamPorts[ j ]->Dependency() ) ; + } } } SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ; @@ -1371,15 +1579,26 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ; anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ; aNodetheName = new string( myEndOfSwitch->Name() ) ; - aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ; + aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->Graph()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ; delete aNodetheName ; myPorts = *(myEndOfSwitch->Ports()) ; for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) { if ( myPorts[ j ]->IsInput() ) { - anEndOfSwitch->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; } else { - anEndOfSwitch->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + aPort = myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ; + } + } + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + SUPERV::ListOfStreamPorts myStreamSwitchPorts = *(myEndOfSwitch->StreamPorts()) ; + for ( j = 0 ; j < (int ) myStreamSwitchPorts.length() ; j++ ) { + if ( myStreamSwitchPorts[ j ]->IsInput() ) { + aPort = myNode->InStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; + } + else { + aPort = myNode->OutStreamPort( myStreamSwitchPorts[ j ]->Name() , StringToDataStreamType( myStreamSwitchPorts[ j ]->Type() ) , myStreamSwitchPorts[ j ]->Dependency() ) ; + } } } RetVal = true ; @@ -1401,9 +1620,9 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { SUPERV::Port_var InPort = aLink->InPort() ; string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ; string * aLinkToNodeName = new string( InPort->Node()->Name() ) ; - RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , OutPort->Name() , - DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , InPort->Name() ) ; if ( RetVal ) { int j ; @@ -1412,9 +1631,9 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { RetVal = aLink->Coords( j , X , Y ) ; if ( !RetVal ) break ; - RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , OutPort->Name() , - DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , InPort->Name() , j , X , Y ) ; if ( !RetVal ) { @@ -1431,28 +1650,53 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { if ( RetVal ) { for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) { SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ; - char * aPortName = aPort->Name() ; - char * aNodeName = new char[ strlen( aPortName ) + 1 ] ; - strcpy( aNodeName , aPortName ) ; - char * thePortName = strchr( aNodeName , '\\' ) ; - thePortName[ 0 ] = '\0' ; - bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ; -// cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1 -// << " HasInput " << hasinput << endl ; - if ( hasinput ) { - RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() , - thePortName + 1 , - *(aPort->ToAny()) ) ; - } - delete [] aNodeName ; - if ( !RetVal ) { - break ; + if ( !aPort->IsGate() ) { + MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ; + char * aPortName = aPort->Name() ; + char * aNodeName = new char[ strlen( aPortName ) + 1 ] ; + strcpy( aNodeName , aPortName ) ; + char * thePortName = strchr( aNodeName , '\\' ) ; + thePortName[ 0 ] = '\0' ; + bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ; +// cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1 +// << " HasInput " << hasinput << endl ; + if ( hasinput ) { + RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() , + thePortName + 1 , + *(aPort->ToAny()) ) ; + } + delete [] aNodeName ; + if ( !RetVal ) { + break ; + } } } } } } + MESSAGE( "Graph_Impl::Merge returns " << RetVal ) ; endService( "Graph_Impl::Merge" ); return RetVal ; } +SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() { + SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ; + beginService( "Graph_Impl::ToStreamGraph" ); + if ( IsStreamGraph() ) { +// StreamGraph_Impl * myStreamGraph = new StreamGraph_Impl( _Orb , _Poa , _ContId , +// instanceName() , interfaceName() ) ; +// PortableServer::ObjectId * id = myStreamGraph->getId() ; +// CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamGraph::_narrow( ObjRef() ) ; + if ( CORBA::is_nil( iobject ) ) { + MESSAGE( "ToStreamGraph of " << Name() << " (IsStreamGraph) --> nil reference" ) ; + } + } + else { + MESSAGE( "ToStreamGraph of " << Name() << " (IsNOTStreamGraph) --> nil reference" ) ; + } + endService( "Graph_Impl::ToStreamGraph" ); + return SUPERV::StreamGraph::_duplicate( iobject ) ; +} + + diff --git a/src/Supervision/Graph_Impl.hxx b/src/Supervision/Graph_Impl.hxx index d7b8d9a..0a3b874 100644 --- a/src/Supervision/Graph_Impl.hxx +++ b/src/Supervision/Graph_Impl.hxx @@ -37,7 +37,7 @@ #include "SALOME_Component_i.hxx" #include "SALOME_LifeCycleCORBA.hxx" -#include "Link_Impl.hxx" +#include "StreamLink_Impl.hxx" #include "FNode_Impl.hxx" #include "GNode_Impl.hxx" #include "LNode_Impl.hxx" @@ -71,7 +71,8 @@ class Graph_Impl :public INode_Impl , PortableServer::ObjectId * contId , const char *instanceName , const char *interfaceName , - const char *aDataFlowName ) ; + const char *aDataFlowName , + const SUPERV::KindOfNode aKindOfNode ) ; virtual SUPERV::Graph_ptr Copy() ; virtual ~Graph_Impl() ; @@ -94,12 +95,6 @@ class Graph_Impl :public INode_Impl , virtual bool Export(const char * aXmlFile ) ; -#if 0 - virtual GraphBase::ListOfNodes * GetNodes() ; - virtual GraphBase::ListOfLinks * GetLinks() ; - virtual GraphBase::ListOfLinks * GetDatas() ; -#endif - virtual SUPERV::CNode_ptr CNode( const SALOME_ModuleCatalog::Service &NodeService ) ; virtual SUPERV::FNode_ptr FNode( @@ -135,17 +130,16 @@ class Graph_Impl :public INode_Impl , GraphBase::ComputingNode * aNode ) ; virtual SUPERV::ListOfNodes * Nodes() ; virtual void SetNodeObjRef( GraphEditor::InNode * anInNode ) ; + virtual SUPERV::ListOfLinks * GLinks() ; virtual SUPERV::ListOfLinks * Links( GraphBase::ComputingNode * aNode , const char * anInputParam ) ; - virtual SUPERV::ListOfGraphs * Graphs() ; virtual Engines::Component_ptr ComponentRef( const char * aComputerContainer , const char * aComponentName ) ; virtual bool IsValid() ; virtual bool IsExecutable() ; - virtual bool IsDataFlow() ; virtual bool IsEditing() ; virtual bool IsExecuting() ; @@ -155,7 +149,6 @@ class Graph_Impl :public INode_Impl , virtual long LevelMax() ; virtual SUPERV::ListOfNodes * LevelNodes(long aLevel ) ; virtual long ThreadsMax() ; - virtual long GraphsNumber() ; virtual long Threads() ; virtual long SuspendedThreads() ; @@ -175,7 +168,13 @@ class Graph_Impl :public INode_Impl , SUPERV::GraphState & aState ) ; virtual long EventQSize() ; + virtual long SubGraphsNumber() ; + virtual SUPERV::ListOfNodes * SubGraphsNodes( const long aSubGraphNumber ) ; + virtual bool Merge(const SUPERV::Graph_ptr aGraph ) ; + virtual bool Merge(const SUPERV::Graph_ptr aGraph , map< string , int > & aMapOfNodes ) ; + + virtual SUPERV::StreamGraph_ptr ToStreamGraph() ; }; diff --git a/src/Supervision/INode_Impl.cxx b/src/Supervision/INode_Impl.cxx index dce4335..cd5e83e 100644 --- a/src/Supervision/INode_Impl.cxx +++ b/src/Supervision/INode_Impl.cxx @@ -144,7 +144,7 @@ bool INode_Impl::Delete() { if ( DataFlowEditor()->IsEditing() ) { RetVal = DataFlowEditor()->RemoveNode( Name() ) ; if ( RetVal ) - RetVal = DataFlowEditor()->IsValid() ; + RetVal = DataFlowEditor()->UnValid() ; } // endService( "INode_Impl::Delete" ); return RetVal ; @@ -184,11 +184,11 @@ SUPERV::Port_ptr INode_Impl::InPort( const char *aParameterName , SUPERV::Port_ptr InEndobject = SUPERV::Port::_nil() ; Port_Impl * myInPort = NULL ; bool InPortCreated = false ; - MESSAGE( "INode_Impl::InPort " << DataFlowNode()->Name() << "->AddInPort( " << aParameterName << " , " - << aParameterType ) ; + MESSAGE( "CNode_Impl::InPort " << DataFlowNode()->Name() << "->AddInPort( " << aParameterName << " , " + << aParameterType << " )" ) ; GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ; - if ( anInPort == NULL && DataFlowNode()->IsOneOfInLineNodes() ) { - anInPort = DataFlowNode()->AddInPort( aParameterName , aParameterType ) ; + if ( anInPort == NULL ) { + anInPort = DataFlowNode()->AddInPort( aParameterName , aParameterType , SUPERV::InLineParameter ) ; InPortCreated = true ; } if ( anInPort ) { @@ -209,8 +209,8 @@ SUPERV::Port_ptr INode_Impl::InPort( const char *aParameterName , } if ( !CORBA::is_nil( Inobject ) && InPortCreated && - ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() || - DataFlowNode()->IsEndSwitchNode() ) ) { + ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() ) ) { +// || DataFlowNode()->IsEndSwitchNode() ) ) { Outobject = OutPort( aParameterName , aParameterType ) ; if ( DataFlowNode()->IsLoopNode() ) { LNode_Impl * myLoopNode = (LNode_Impl * ) this ; @@ -227,11 +227,11 @@ SUPERV::Port_ptr INode_Impl::OutPort( const char *aParameterName , const char *aParameterType ) { Port_Impl * myOutPort = NULL ; SUPERV::Port_ptr Outobject = SUPERV::Port::_nil() ; - MESSAGE( "INode_Impl::OutPort " << DataFlowNode()->Name() << "->AddOutPort( " << aParameterName << " , " - << aParameterType ) ; + MESSAGE( "CNode_Impl::OutPort " << DataFlowNode()->Name() << "->AddOutPort( " << aParameterName << " , " + << aParameterType << " )" ) ; GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ; - if ( anOutPort == NULL && DataFlowNode()->IsOneOfInLineNodes() ) { - anOutPort = DataFlowNode()->AddOutPort( aParameterName , aParameterType ) ; + if ( anOutPort == NULL ) { + anOutPort = DataFlowNode()->AddOutPort( aParameterName , aParameterType , SUPERV::InLineParameter ) ; } if ( anOutPort ) { Outobject = anOutPort->ObjRef() ; @@ -255,80 +255,100 @@ SUPERV::Port_ptr INode_Impl::OutPort( const char *aParameterName , return SUPERV::Port::_duplicate( Outobject ); } -#if 0 -bool INode_Impl::BusPort( const char * InOutParameterName , - const char * InOutParameterType , - SUPERV::Port_out InputPort , - SUPERV::Port_out OutputPort ) { - return BusPorts( InOutParameterName , InOutParameterType , - InOutParameterName , InOutParameterType , - InputPort , OutputPort ) ; -} +SUPERV::StreamPort_ptr INode_Impl::InStreamPort( const char *aParameterName , + const SALOME_ModuleCatalog::DataStreamType aParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) { + SUPERV::StreamPort_ptr Inobject = SUPERV::StreamPort::_nil() ; + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + StreamPort_Impl * myInStreamPort = NULL ; + bool InPortCreated = false ; + MESSAGE( "INode_Impl::InStreamPort " << DataFlowNode()->Name() << "->AddInPort( " << aParameterName << " , " + << aParameterType << " )" ) ; + GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( aParameterName ) ; + if ( anInPort && !anInPort->IsDataStream() ) { + MESSAGE( "INode_Impl::InStreamPort ERROR !IsDataStream " ) ; + } + else if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + if ( anInPort == NULL ) { + anInPort = DataFlowNode()->ComputingNode()->AddInDataStreamPort( aParameterName , aParameterType , aDependency , SUPERV::DataStreamParameter ) ; + InPortCreated = true ; + } -bool INode_Impl::BusPorts( const char * InputParameterName , - const char * InputParameterType , - const char * OutputParameterName , - const char * OutputParameterType , - SUPERV::Port_out InputPort , - SUPERV::Port_out OutputPort ) { - beginService( "INode_Impl::BusPorts" ); - bool RetVal = false ; - Port_Impl * myInPort = NULL ; - Port_Impl * myOutPort = NULL ; - SUPERV::Port_var Inobject = SUPERV::Port::_nil() ; - SUPERV::Port_var Outobject = SUPERV::Port::_nil() ; -// if ( DataFlowNode()->GetInPort( InputParameterName ) || -// DataFlowNode()->GetOutPort( OutputParameterName ) ) { -// } -// else { - GraphBase::InPort * anInPort = DataFlowNode()->AddInPort( InputParameterName , - InputParameterType ) ; - if ( anInPort ) { - myInPort = new Port_Impl( _Orb , _Poa , _ContId , + if ( anInPort ) { + Inobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ; + if ( CORBA::is_nil( Inobject ) ) { + myInStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , DataFlowEditor() , DataFlowNode() , -// InputParameterName ) ; (GraphBase::Port * ) anInPort , true ) ; - GraphBase::OutPort * anOutPort = DataFlowNode()->AddOutPort( OutputParameterName , - OutputParameterType ) ; - if ( anOutPort ) { - const CORBA::Any * anAny = anOutPort->Value() ; - myOutPort = new Port_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - DataFlowEditor() , - DataFlowNode() , -// OutputParameterName , - (GraphBase::Port * ) anOutPort , - false , - anAny ) ; - DataFlowNode()->InOutPort( anInPort , anOutPort ) ; - RetVal = true ; + if ( myInStreamPort ) { + PortableServer::ObjectId * id = myInStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Inobject = SUPERV::StreamPort::_narrow(obj) ; + anInPort->ObjRef( SUPERV::StreamPort::_duplicate( Inobject ) ) ; + } + } } } -// } - if ( RetVal && myInPort && myOutPort ) { - if ( DataFlowNode()->CoupledNode() ) { - GraphBase::InPort * anInPort ; - anInPort = DataFlowNode()->CoupledNode()->AddInPort( OutputParameterName , - OutputParameterType ) ; - GraphBase::OutPort * anOutPort ; - anOutPort = DataFlowNode()->CoupledNode()->AddOutPort( InputParameterName , - InputParameterType ) ; - DataFlowNode()->CoupledNode()->InOutPort( anInPort , anOutPort ) ; + +// if ( !CORBA::is_nil( Inobject ) && InPortCreated && +// ( DataFlowNode()->IsLoopNode() || DataFlowNode()->IsEndLoopNode() || +// DataFlowNode()->IsEndSwitchNode() ) ) { +// Outobject = OutPort( aParameterName , aParameterType ) ; +// if ( DataFlowNode()->IsLoopNode() ) { +// LNode_Impl * myLoopNode = (LNode_Impl * ) this ; +// InEndobject = myLoopNode->Coupled()->InPort( aParameterName , aParameterType ) ; +// DataFlowEditor()->AddLink( Outobject->Node()->Name() , Outobject->Name() , +// InEndobject->Node()->Name() , InEndobject->Name() ) ; +// } +// } + DataFlowEditor()->UnValid() ; + } + return SUPERV::StreamPort::_duplicate( Inobject ) ; +} + +SUPERV::StreamPort_ptr INode_Impl::OutStreamPort( const char * aParameterName , + const SALOME_ModuleCatalog::DataStreamType aParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) { + StreamPort_Impl * myOutStreamPort = NULL ; + SUPERV::StreamPort_ptr Outobject = SUPERV::StreamPort::_nil() ; + if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + MESSAGE( "INode_Impl::OutStreamPort " << DataFlowNode()->Name() << "->AddOutPort( " << aParameterName << " , " + << aParameterType << " )" ) ; + GraphBase::OutPort * anOutPort = DataFlowNode()->GetChangeOutPort( aParameterName ) ; + if ( anOutPort && !anOutPort->IsDataStream() ) { + MESSAGE( "INode_Impl::OutStreamPort ERROR !IsDataStream " ) ; } - PortableServer::ObjectId * id = myInPort->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id) ; - Inobject = SUPERV::Port::_narrow(obj) ; - InputPort = SUPERV::Port::_duplicate( Inobject ) ; - id = myOutPort->getId() ; - obj = _poa->id_to_reference(*id); - Outobject = SUPERV::Port::_narrow(obj) ; - OutputPort = SUPERV::Port::_duplicate( Outobject ) ; + else if ( DataFlowEditor()->Graph()->IsDataStreamNode() ) { + if ( anOutPort == NULL ) { + anOutPort = DataFlowNode()->ComputingNode()->AddOutDataStreamPort( aParameterName , aParameterType , aDependency , SUPERV::DataStreamParameter ) ; + } + + if ( anOutPort ) { + Outobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ; + if ( CORBA::is_nil( Outobject ) ) { + const CORBA::Any * anAny = anOutPort->Value() ; + myOutStreamPort = new StreamPort_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anOutPort , + false , + anAny ) ; + if ( myOutStreamPort ) { + PortableServer::ObjectId * id = myOutStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id) ; + Outobject = SUPERV::StreamPort::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( Outobject ) ) ; + } + } + } + } + DataFlowEditor()->UnValid() ; } - endService( "INode_Impl::BusPorts" ); - return RetVal ; + return SUPERV::StreamPort::_duplicate( Outobject ); } -#endif + diff --git a/src/Supervision/INode_Impl.hxx b/src/Supervision/INode_Impl.hxx index 166d686..fd7342f 100644 --- a/src/Supervision/INode_Impl.hxx +++ b/src/Supervision/INode_Impl.hxx @@ -22,7 +22,7 @@ #include "CNode_Impl.hxx" -#include "Port_Impl.hxx" +#include "StreamPort_Impl.hxx" #include "DataFlowEditor_DataFlow.hxx" #include "DataFlowExecutor_DataFlow.hxx" @@ -77,13 +77,20 @@ class INode_Impl : public CNode_Impl , virtual SUPERV::ListOfStrings * PyFunction() ; virtual char * PyFuncName() ; + virtual GraphBase::InLineNode * BaseNode() { + return DataFlowNode()->InLineNode() ; } ; + virtual SUPERV::Port_ptr InPort( const char * aParameterName , const char * aParameterType ) ; virtual SUPERV::Port_ptr OutPort( const char * aParameterName , const char * aParameterType ) ; - virtual GraphBase::InLineNode * BaseNode() { - return DataFlowNode()->InLineNode() ; } ; + virtual SUPERV::StreamPort_ptr InStreamPort( const char * aParameterName , + const SALOME_ModuleCatalog::DataStreamType aParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) ; + virtual SUPERV::StreamPort_ptr OutStreamPort( const char * aParameterName , + const SALOME_ModuleCatalog::DataStreamType aParameterType , + const SALOME_ModuleCatalog::DataStreamDependency aDependency ) ; } ; diff --git a/src/Supervision/LNode_Impl.cxx b/src/Supervision/LNode_Impl.cxx index 436a59e..5e20dd8 100644 --- a/src/Supervision/LNode_Impl.cxx +++ b/src/Supervision/LNode_Impl.cxx @@ -91,7 +91,7 @@ void LNode_Impl::destroy() { aCoupled->destroy() ; } } - endService( "LNode_Impl::Destroy" ); +// endService( "LNode_Impl::Destroy" ); } bool LNode_Impl::Delete() { diff --git a/src/Supervision/Link_Impl.cxx b/src/Supervision/Link_Impl.cxx index f20bd13..9f9cb48 100644 --- a/src/Supervision/Link_Impl.cxx +++ b/src/Supervision/Link_Impl.cxx @@ -34,7 +34,7 @@ using namespace std; //#include "utilities.h" -#include "Link_Impl.hxx" +#include "StreamLink_Impl.hxx" Link_Impl::Link_Impl( CORBA::ORB_ptr orb , PortableServer::POA_ptr poa , @@ -46,14 +46,14 @@ Link_Impl::Link_Impl( CORBA::ORB_ptr orb , const char *InputParameterName , GraphEditor::InNode * DataFlowOutNode , const char *OutputParameterName , - const bool Create ) : -// const SUPERV::Value_ptr aValue ) : + const bool Create , + const bool Get , + bool & Success ) : Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, false) { // MESSAGE("Link_Impl::Link_Impl activate object instanceName(" // << instanceName << ") interfaceName(" << interfaceName << ") --> " // << hex << (void *) this << dec ) - bool linksts ; - beginService( "Link_Impl::Link_Impl" ); +// beginService( "Link_Impl::Link_Impl" ); _Orb = CORBA::ORB::_duplicate(orb); _Poa = poa ; _ContId = contId ; @@ -67,22 +67,27 @@ Link_Impl::Link_Impl( CORBA::ORB_ptr orb , _OutputParameterName = new char[ strlen( OutputParameterName ) + 1 ] ; strcpy( _OutputParameterName , OutputParameterName ) ; if ( Create ) { - linksts = _DataFlowEditor->AddLink( _DataFlowOutNode->Name() , + Success = _DataFlowEditor->AddLink( _DataFlowOutNode->Name() , _OutputParameterName , _DataFlowNode->Name() , _InputParameterName ) ; } - else { + else if ( Get ) { char * DataFlowOutNodeName = NULL ; char * OutParamName = NULL ; - linksts = _DataFlowEditor->GetLink( _DataFlowNode->Name() , + Success = _DataFlowEditor->GetLink( _DataFlowNode->Name() , _InputParameterName , &DataFlowOutNodeName , &OutParamName ) ; } - _thisObj = this ; - _id = _poa->activate_object(_thisObj); - endService( "Link_Impl::Link_Impl" ); + else { + Success = false ; + } + if ( Success ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj) ; + } +// endService( "Link_Impl::Link_Impl" ); } Link_Impl::Link_Impl() { @@ -109,42 +114,95 @@ bool Link_Impl::Delete() { _OutputParameterName , _DataFlowNode->Name() , _InputParameterName ) ; + if ( RetVal ) { + DataFlowEditor()->UnValid() ; + } // endService( "Link_Impl::Delete" ); return RetVal ; } SUPERV::Port_ptr Link_Impl::InPort() { // beginService( "Link_Impl::InPort" ); + SUPERV::Port_var iobject = SUPERV::Port::_nil() ; GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _InputParameterName ) ; - Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + if ( anInPort ) { + iobject = anInPort->ObjRef() ; + if ( CORBA::is_nil( iobject ) ) { + if ( !anInPort->IsDataStream() ) { + Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode , + (GraphBase::Port * ) anInPort , + true ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Port::_narrow(obj) ; + anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + StreamPort_Impl * myStreamPort = new StreamPort_Impl( + _Orb , _Poa , _ContId , instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowNode , -// _InputParameterName ) ; + DataFlowEditor() , + DataFlowOutNode() , (GraphBase::Port * ) anInPort , - true ) ; - PortableServer::ObjectId * id = myPort->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Port_var iobject ; - iobject = SUPERV::Port::_narrow(obj) ; + false ) ; + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamPort_var iStreamobject ; + iStreamobject = SUPERV::StreamPort::_narrow(obj) ; + anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iStreamobject ) ) ; + iobject = SUPERV::Port::_narrow( iStreamobject ) ; + } + } + else { + iobject = anInPort->ObjRef() ; + } + } // endService( "Link_Impl::InPort" ); return SUPERV::Port::_duplicate( iobject ) ; } SUPERV::Port_ptr Link_Impl::OutPort() { // beginService( "Link_Impl::OutPort" ); + SUPERV::Port_var iobject = SUPERV::Port::_nil() ; GraphBase::OutPort * anOutPort = _DataFlowOutNode->GetChangeOutPort( _OutputParameterName ) ; - Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + if ( anOutPort ) { + iobject = anOutPort->ObjRef() ; + if ( CORBA::is_nil( iobject ) ) { + if ( !anOutPort->IsDataStream() ) { + Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowOutNode , + (GraphBase::Port * ) anOutPort , + false ) ; + PortableServer::ObjectId * id = myPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Port::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ; + } + else { + StreamPort_Impl * myStreamPort = new StreamPort_Impl( + _Orb , _Poa , _ContId , instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowOutNode , -// _OutputParameterName ) ; + DataFlowEditor() , + DataFlowOutNode() , (GraphBase::Port * ) anOutPort , false ) ; - PortableServer::ObjectId * id = myPort->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::Port_var iobject ; - iobject = SUPERV::Port::_narrow(obj) ; + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamPort_var iStreamobject ; + iStreamobject = SUPERV::StreamPort::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iStreamobject ) ) ; + iobject = SUPERV::Port::_narrow( iStreamobject ) ; + } + } + else { + iobject = anOutPort->ObjRef() ; + } + } // endService( "Link_Impl::OutPort" ); return SUPERV::Port::_duplicate( iobject ) ; } diff --git a/src/Supervision/Link_Impl.hxx b/src/Supervision/Link_Impl.hxx index b51245c..0f0ef19 100644 --- a/src/Supervision/Link_Impl.hxx +++ b/src/Supervision/Link_Impl.hxx @@ -70,12 +70,29 @@ class Link_Impl : public POA_SUPERV::Link , const char *InputParameterName , GraphEditor::InNode * DataFlowOutNode , const char *OutputParameterName , - const bool Create ) ; + const bool Create , + const bool Get , + bool & Success ) ; virtual ~Link_Impl() ; virtual void destroy() ; virtual bool Delete() ; + GraphEditor::DataFlow * DataFlowEditor() { + return _DataFlowEditor ; } ; + GraphEditor::InNode * DataFlowNode() { + return _DataFlowNode ; } ; + char * DataFlowNodeName() { + return _DataFlowNodeName ; } ; + char * InputParameterName() { + return _InputParameterName ; } ; + GraphEditor::InNode * DataFlowOutNode() { + return _DataFlowOutNode ; } ; + char * DataFlowOutNodeName() { + return _DataFlowOutNodeName ; } ; + char * OutputParameterName() { + return _OutputParameterName ; } ; + SUPERV::Port_ptr OutPort() ; SUPERV::Port_ptr InPort() ; diff --git a/src/Supervision/Makefile.in b/src/Supervision/Makefile.in index 341019d..cd9aed0 100755 --- a/src/Supervision/Makefile.in +++ b/src/Supervision/Makefile.in @@ -39,6 +39,7 @@ EXPORT_SHAREDPYSCRIPTS = SUPERV_shared_modules.py EXPORT_HEADERS = \ SuperV_Impl.hxx \ + StreamGraph_Impl.hxx \ Graph_Impl.hxx \ CNode_Impl.hxx \ FNode_Impl.hxx \ @@ -48,16 +49,19 @@ EXPORT_HEADERS = \ ELNode_Impl.hxx \ SNode_Impl.hxx \ ESNode_Impl.hxx \ + StreamLink_Impl.hxx \ Link_Impl.hxx \ - Value_Impl.hxx \ - Port_Impl.hxx -# Input_Impl.hxx \ + StreamPort_Impl.hxx \ + Port_Impl.hxx \ + Value_Impl.hxx # Libraries targets LIB = libSUPERVEngine.la LIB_SRC = Value_Impl.cxx \ Port_Impl.cxx \ + StreamPort_Impl.cxx \ Link_Impl.cxx \ + StreamLink_Impl.cxx \ CNode_Impl.cxx \ FNode_Impl.cxx \ INode_Impl.cxx \ @@ -67,8 +71,8 @@ LIB_SRC = Value_Impl.cxx \ SNode_Impl.cxx \ ESNode_Impl.cxx \ Graph_Impl.cxx \ + StreamGraph_Impl.cxx \ SuperV_Impl.cxx -# Input_Impl.cxx \ LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ @@ -83,14 +87,13 @@ BIN_SERVER_IDL = CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) \ -I${KERNEL_ROOT_DIR}/include/salome -#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wno-deprecated -#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall ### mpv: D_DEBUG key must be set only on DEBUG compilation mode -CXXFLAGS += -g -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ +CXXFLAGS += -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ -I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+= -lSalomeSuperVisionEditor -lSalomeSuperVisionExecutor -lSalomeSuperVisionBase \ -lSalomeContainer -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA \ -lOpUtil -lRegistry -lTOOLSDS -lSALOMELocalTrace \ $(QT_MT_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome +#LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) @CONCLUDE@ diff --git a/src/Supervision/Port_Impl.cxx b/src/Supervision/Port_Impl.cxx index 3e0ee67..cab7239 100644 --- a/src/Supervision/Port_Impl.cxx +++ b/src/Supervision/Port_Impl.cxx @@ -44,33 +44,26 @@ Port_Impl::Port_Impl( CORBA::ORB_ptr orb , const char *interfaceName , GraphEditor::DataFlow * DataFlowEditor , GraphEditor::InNode * DataFlowNode , -// const char *ParameterName , GraphBase::Port * DataFlowPort , bool InputPort , const CORBA::Any * anAny ) : -// const SUPERV::Value_ptr aValue ) : Value_Impl(orb, poa, contId, instanceName, interfaceName, -// DataFlowEditor , DataFlowNode , ParameterName, aValue->ToAny() , DataFlowEditor , DataFlowNode , DataFlowPort->PortName(), anAny , false ) { -// MESSAGE("Value_Impl::Value_Impl activate object instanceName(" -// << instanceName << ") interfaceName(" << interfaceName << ") --> " -// << hex << (void *) this << dec ) +// MESSAGE("Port_Impl::Port_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName +// << ") IsDataStream " << DataFlowPort->IsDataStream() ) _Orb = CORBA::ORB::_duplicate(orb); _Poa = poa ; _ContId = contId ; - _thisObj = this ; - _id = _poa->activate_object(_thisObj); + if ( !DataFlowPort->IsDataStream() ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj) ; + } _DataFlowEditor = DataFlowEditor ; _DataFlowNode = DataFlowNode ; -// _DataFlowPort = _DataFlowNode->GetChangeInPort( ParameterName ) ; _DataFlowPort = DataFlowPort ; -// _InputPort = true ; _InputPort = InputPort ; -// if ( _DataFlowPort == NULL ) { -// _DataFlowPort = _DataFlowNode->GetChangeOutPort( ParameterName ) ; -// _InputPort = false ; -// } InPort( _InputPort ) ; } @@ -81,30 +74,29 @@ Port_Impl::Port_Impl( CORBA::ORB_ptr orb , const char *interfaceName , GraphEditor::DataFlow * DataFlowEditor , GraphEditor::InNode * DataFlowNode , -// const char *ParameterName ) : GraphBase::Port * DataFlowPort , bool InputPort ) : Value_Impl(orb, poa, contId, instanceName, interfaceName, DataFlowEditor , DataFlowNode , DataFlowPort->PortName() , false ) { -// DataFlowEditor , DataFlowNode , ParameterName , false ) { -// MESSAGE("Value_Impl::Value_Impl activate object instanceName(" -// << instanceName << ") interfaceName(" << interfaceName << ") --> " -// << hex << (void *) this << dec ) + char * nodename = DataFlowEditor->Graph()->Name() ; + if ( DataFlowNode ) { + nodename = DataFlowNode->Name() ; + } +// MESSAGE("Port_Impl::Port_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName +// << ") " << nodename << "(" << DataFlowPort->PortName() +// << ") IsDataStream " << DataFlowPort->IsDataStream() ) ; _Orb = CORBA::ORB::_duplicate(orb); _Poa = poa ; _ContId = contId ; - _thisObj = this ; - _id = _poa->activate_object(_thisObj); + if ( !DataFlowPort->IsDataStream() ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj) ; + } _DataFlowEditor = DataFlowEditor ; _DataFlowNode = DataFlowNode ; -// _DataFlowPort = _DataFlowNode->GetChangeInPort( ParameterName ) ; _DataFlowPort = DataFlowPort ; -// _InputPort = true ; _InputPort = InputPort ; -// if ( _DataFlowPort == NULL ) { -// _DataFlowPort = _DataFlowNode->GetChangeOutPort( ParameterName ) ; -// _InputPort = false ; -// } InPort( _InputPort ) ; } @@ -199,24 +191,123 @@ char * Port_Impl::Type() { SUPERV::CNode_ptr Port_Impl::Node() { bool begin = true ; - SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ; - if ( CORBA::is_nil( _DataFlowNode->ObjRef() ) ) { - if ( begin ) { - beginService( "Port_Impl::Node" ) ; - begin = false ; + SUPERV::CNode_var iobject ; + if ( _DataFlowNode ) { +// MESSAGE( "Port_Impl::Node " << _DataFlowNode->Name() ) ; + iobject = SUPERV::CNode::_narrow( _DataFlowNode->ObjRef() ) ; + if ( CORBA::is_nil( iobject ) ) { + if ( begin ) { + beginService( "Port_Impl::Node" ) ; + begin = false ; + } + PortableServer::ObjectId * id ; + CORBA::Object_var obj ; + if ( _DataFlowNode->IsComputingNode() ) { + CNode_Impl * myNode = NULL ; + myNode = new CNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + iobject = SUPERV::CNode::_narrow( obj ) ; + myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ; + } + else if ( _DataFlowNode->IsFactoryNode() ) { + FNode_Impl * myNode = NULL ; + myNode = new FNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::FNode_var Fiobject = SUPERV::FNode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( Fiobject ) ; + myNode->SetObjRef( SUPERV::FNode::_duplicate( Fiobject ) ) ; + } + else if ( _DataFlowNode->IsInLineNode() ) { + INode_Impl * myNode = NULL ; + myNode = new INode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::INode_var Iiobject = SUPERV::INode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( Iiobject ) ; + myNode->SetObjRef( SUPERV::INode::_duplicate( Iiobject ) ) ; + } + else if ( _DataFlowNode->IsGOTONode() ) { + GNode_Impl * myNode = NULL ; + myNode = new GNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::GNode_var Giobject = SUPERV::GNode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( Giobject ) ; + myNode->SetObjRef( SUPERV::GNode::_duplicate( Giobject ) ) ; + } + else if ( _DataFlowNode->IsLoopNode() ) { + LNode_Impl * myNode = NULL ; + myNode = new LNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::LNode_var Liobject = SUPERV::LNode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( Liobject ) ; + myNode->SetObjRef( SUPERV::LNode::_duplicate( Liobject ) ) ; + } + else if ( _DataFlowNode->IsEndLoopNode() ) { + ELNode_Impl * myNode = NULL ; + myNode = new ELNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::ELNode_var ELiobject = SUPERV::ELNode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( ELiobject ) ; + myNode->SetObjRef( SUPERV::ELNode::_duplicate( ELiobject ) ) ; + } + else if ( _DataFlowNode->IsSwitchNode() ) { + SNode_Impl * myNode = NULL ; + myNode = new SNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::SNode_var Siobject = SUPERV::SNode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( Siobject ) ; + myNode->SetObjRef( SUPERV::SNode::_duplicate( Siobject ) ) ; + } + else if ( _DataFlowNode->IsEndSwitchNode() ) { + ESNode_Impl * myNode = NULL ; + myNode = new ESNode_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + _DataFlowEditor , + _DataFlowNode ) ; + id = myNode->getId() ; + obj = _poa->id_to_reference(*id); + SUPERV::ESNode_var ESiobject = SUPERV::ESNode::_narrow( obj ) ; + iobject = SUPERV::CNode::_narrow( ESiobject ) ; + myNode->SetObjRef( SUPERV::ESNode::_duplicate( ESiobject ) ) ; + } + } + else { +// MESSAGE( "Port_Impl::Node known objref " << iobject->Name() ) ; } - CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId , - instanceName() , interfaceName() , - _DataFlowEditor , - _DataFlowNode ) ; - PortableServer::ObjectId * id = myNode->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - SUPERV::CNode_var iobject ; - iobject = SUPERV::CNode::_narrow(obj) ; - myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ; } else { - iobject = _DataFlowNode->ObjRef() ; + MESSAGE( "Port_Impl::GraphNode " << _DataFlowEditor->Graph()->Name() ) ; + iobject = SUPERV::CNode::_narrow( _DataFlowEditor->Graph()->ObjRef() ) ; + if ( CORBA::is_nil( iobject ) ) { + MESSAGE( "Port_Impl::GraphNode NilRef" ) ; + } } if ( !begin ) { endService( "Port_Impl::Node" ) ; @@ -227,8 +318,18 @@ SUPERV::CNode_ptr Port_Impl::Node() { SUPERV::ListOfLinks * Port_Impl::Links() { beginService( "Port_Impl::Links" ) ; SUPERV::ListOfLinks_var RetVal = new SUPERV::ListOfLinks ; - RetVal = _DataFlowEditor->ObjImpl()->Links( _DataFlowNode->ComputingNode() , - _DataFlowPort->PortName() ) ; + RetVal = _DataFlowEditor->Graph()->ObjImpl()->Links( _DataFlowNode->ComputingNode() , + _DataFlowPort->PortName() ) ; + MESSAGE( "Links of Node " << _DataFlowNode->ComputingNode()->Name() + << " and of Port " << _DataFlowPort->PortName() + << " _InputPort " << _InputPort ) ; + int i ; + for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) { + MESSAGE( "Link " << RetVal[i]->OutPort()->Node()->Name() << "(" + << RetVal[i]->OutPort()->Name() << ") --> " + << RetVal[i]->InPort()->Node()->Name() << "(" + << RetVal[i]->InPort()->Name() << ")" ) ; + } endService( "Port_Impl::Links" ) ; return ( RetVal._retn() ) ; } @@ -242,8 +343,8 @@ SUPERV::Link_ptr Port_Impl::Link() { SUPERV::ListOfLinks_var Links = new SUPERV::ListOfLinks ; // cout << "Port_Impl::Link " << _DataFlowNode->Name() << " " // << _DataFlowPort->PortName() << endl ; - Links = _DataFlowEditor->ObjImpl()->Links( _DataFlowNode->ComputingNode() , - _DataFlowPort->PortName() ) ; + Links = _DataFlowEditor->Graph()->ObjImpl()->Links( _DataFlowNode->ComputingNode() , + _DataFlowPort->PortName() ) ; if ( Links->length() ) { iobject = Links[ 0 ] ; } @@ -275,18 +376,21 @@ SUPERV::Link_ptr Port_Impl::Link() { beginService( "Port_Impl::Link" ) ; begin = false ; } + bool Success ; Link_Impl * myLink = new Link_Impl( _Orb , _Poa , _ContId , instanceName() , interfaceName() , _DataFlowEditor , _DataFlowNode , _DataFlowPort->PortName() , - (GraphEditor::InNode * ) _DataFlowEditor->GetChangeGraphNode( FromNodeName )->GetInNode() , + (GraphEditor::InNode * ) _DataFlowEditor->Graph()->GetChangeGraphNode( FromNodeName )->GetInNode() , FromServiceParameterName , - false ) ; - PortableServer::ObjectId * id = myLink->getId() ; - CORBA::Object_var obj = _poa->id_to_reference(*id); - iobject = SUPERV::Link::_narrow(obj) ; - anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + false , true , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::Link::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::Link::_duplicate( iobject ) ) ; + } } else { iobject = anOutPort->InPortObjRef( anInPort ) ; @@ -313,19 +417,21 @@ bool Port_Impl::IsInput() { bool Port_Impl::IsLinked() { // beginService( "Port_Impl::IsLinked" ) ; bool RetVal = false ; - GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _DataFlowPort->PortName() ) ; - GraphBase::OutPort * anOutPort = NULL ; - if ( anInPort) { - anOutPort = anInPort->GetOutPort() ; - } - if ( _DataFlowNode->IsEndLoopNode() && anOutPort && - !strcmp( _DataFlowNode->CoupledNode()->Name() , anOutPort->NodeName() ) ) { -// MESSAGE( "Link " << anOutPort->NodeName() << "(" -// << anOutPort->PortName() << ") --> " << _DataFlowNode->Name() << "(" -// << anInPort->PortName() << ")" << " ignored" ) ; - } - else { - RetVal = _DataFlowNode->IsLinked( _DataFlowPort->PortName() ) ; + if ( _DataFlowNode ) { + GraphBase::InPort * anInPort = _DataFlowNode->GetChangeInPort( _DataFlowPort->PortName() ) ; + GraphBase::OutPort * anOutPort = NULL ; + if ( anInPort) { + anOutPort = anInPort->GetOutPort() ; + } + if ( _DataFlowNode->IsEndLoopNode() && anOutPort && + !strcmp( _DataFlowNode->CoupledNode()->Name() , anOutPort->NodeName() ) ) { +// MESSAGE( "Link " << anOutPort->NodeName() << "(" +// << anOutPort->PortName() << ") --> " << _DataFlowNode->Name() << "(" +// << anInPort->PortName() << ")" << " ignored" ) ; + } + else { + RetVal = _DataFlowNode->IsLinked( _DataFlowPort->PortName() ) ; + } } // endService( "Port_Impl::IsLinked" ) ; return RetVal ; @@ -338,6 +444,12 @@ SUPERV::KindOfPort Port_Impl::Kind() { return RetVal ; } +void Port_Impl::SetKind( SUPERV::KindOfPort aKindOfPort ) { +// beginService( "Port_Impl::SetKind" ) ; + _DataFlowPort->Kind( aKindOfPort ) ; +// endService( "Port_Impl::SetKind" ) ; +} + bool Port_Impl::IsParam() { // beginService( "Port_Impl::IsParam" ) ; bool RetVal = _DataFlowPort->IsParam() ; @@ -381,6 +493,13 @@ bool Port_Impl::IsEndSwitch() { return RetVal ; } +bool Port_Impl::IsDataStream() { +// beginService( "Port_Impl::IsDataStream" ) ; + bool RetVal = _DataFlowPort->IsDataStream() ; +// endService( "Port_Impl::IsDataStream" ) ; + return RetVal ; +} + bool Port_Impl::HasInput() { // beginService( "Port_Impl::" ) ; bool RetVal = false ; @@ -420,3 +539,4 @@ bool Port_Impl::IsDone() { // endService( "Port_Impl::IsDone" ); return RetVal ; } + diff --git a/src/Supervision/Port_Impl.hxx b/src/Supervision/Port_Impl.hxx index 51724b0..eddd426 100644 --- a/src/Supervision/Port_Impl.hxx +++ b/src/Supervision/Port_Impl.hxx @@ -83,31 +83,41 @@ class Port_Impl : public Value_Impl , virtual ~Port_Impl() ; virtual void destroy() ; + GraphEditor::DataFlow * DataFlowEditor() { + return _DataFlowEditor ; } ; + GraphEditor::InNode * DataFlowNode() { + return _DataFlowNode ; } ; + GraphBase::Port * DataFlowPort() { + return _DataFlowPort ; } ; + virtual bool Input( const SUPERV::Value_ptr aValue ) ; virtual bool Input( const CORBA::Any * anAny ) ; - virtual char * Name() ; - virtual char * Type() ; + virtual char * Name() ; + virtual char * Type() ; + + virtual SUPERV::CNode_ptr Node() ; - virtual SUPERV::CNode_ptr Node() ; + virtual SUPERV::Link_ptr Link() ; + virtual SUPERV::ListOfLinks * Links() ; - virtual SUPERV::Link_ptr Link() ; - virtual SUPERV::ListOfLinks * Links() ; + virtual bool IsInput() ; + virtual bool IsLinked() ; + virtual bool HasInput() ; - virtual bool IsInput() ; - virtual bool IsLinked() ; - virtual bool HasInput() ; + virtual SUPERV::KindOfPort Kind() ; + virtual void SetKind( SUPERV::KindOfPort ) ; - virtual SUPERV::KindOfPort Kind() ; - virtual bool IsParam() ; - virtual bool IsGate() ; - virtual bool IsInLine() ; - virtual bool IsLoop() ; - virtual bool IsSwitch() ; - virtual bool IsEndSwitch() ; + virtual bool IsParam() ; + virtual bool IsGate() ; + virtual bool IsInLine() ; + virtual bool IsLoop() ; + virtual bool IsSwitch() ; + virtual bool IsEndSwitch() ; + virtual bool IsDataStream() ; - virtual SUPERV::GraphState State() ; - virtual bool IsDone() ; + virtual SUPERV::GraphState State() ; + virtual bool IsDone() ; } ; diff --git a/src/Supervision/SNode_Impl.cxx b/src/Supervision/SNode_Impl.cxx index 79d244c..1d6b83e 100644 --- a/src/Supervision/SNode_Impl.cxx +++ b/src/Supervision/SNode_Impl.cxx @@ -88,7 +88,7 @@ void SNode_Impl::destroy() { aCoupled->destroy() ; } } - endService( "SNode_Impl::Destroy" ); +// endService( "SNode_Impl::Destroy" ); } bool SNode_Impl::Delete() { diff --git a/src/Supervision/StreamGraph_Impl.cxx b/src/Supervision/StreamGraph_Impl.cxx new file mode 100644 index 0000000..0319e26 --- /dev/null +++ b/src/Supervision/StreamGraph_Impl.cxx @@ -0,0 +1,505 @@ +// SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StreamGraph_Impl.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; + +#include "StreamGraph_Impl.hxx" + +StreamGraph_Impl::StreamGraph_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) : + Graph_Impl(orb, poa, contId, instanceName, interfaceName, aDataFlowName , SUPERV::DataStreamGraph ) { +// MESSAGE("StreamGraph_Impl::StreamGraph_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + beginService( "StreamGraph_Impl::StreamGraph_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + + endService( "StreamGraph_Impl::StreamGraph_Impl" ); +} + +StreamGraph_Impl::StreamGraph_Impl() { +} + +StreamGraph_Impl::~StreamGraph_Impl() { + beginService( "StreamGraph_Impl::~StreamGraph_Impl" ); + endService( "StreamGraph_Impl::~StreamGraph_Impl" ); +} + +void StreamGraph_Impl::destroy() { + beginService( "StreamGraph_Impl::destroy" ); + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + endService( "StreamGraph_Impl::destroy" ); +} + +SUPERV::StreamGraph_ptr StreamGraph_Impl::StreamCopy() { + beginService( "StreamGraph_Impl::StreamCopy" ); + StreamGraph_Impl * myStreamGraph ; + myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId, + instanceName() , interfaceName() , + DataFlowEditor()->Graph()->Name() ) ; + PortableServer::ObjectId * id = myStreamGraph->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamGraph_var iobject ; + iobject = SUPERV::StreamGraph::_narrow(obj) ; + GraphBase::SGraph * aSGraph = GetGraph() ; + myStreamGraph->LoadGraph( aSGraph ) ; + endService( "StreamGraph_Impl::StreamCopy" ); + return SUPERV::StreamGraph::_duplicate(iobject) ; +} + +SUPERV::StreamLink_ptr StreamGraph_Impl::StreamLink( SUPERV::StreamPort_ptr OutStreamPort , + SUPERV::StreamPort_ptr InStreamPort ) { + beginService( "StreamGraph_Impl::StreamLink" ); + SUPERV::StreamLink_var iobject = SUPERV::StreamLink::_nil() ; + if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() && + OutStreamPort->IsDataStream() && InStreamPort->IsDataStream() ) { + GraphBase::InPort * anInPort = DataFlowEditor()->GetNode( InStreamPort->Node()->Name() )->ComputingNode()->GetChangeInPort( InStreamPort->Name() ) ; + GraphBase::OutPort * anOutPort = DataFlowEditor()->GetNode( OutStreamPort->Node()->Name() )->ComputingNode()->GetChangeOutPort( OutStreamPort->Name() ) ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + const char * DataFlowOutNodeName = OutStreamPort->Node()->Name() ; + GraphEditor::InNode * DataFlowOutNode = DataFlowEditor()->GetNode( DataFlowOutNodeName ) ; + const char * DataFlowInNodeName = InStreamPort->Node()->Name() ; + GraphEditor::InNode * DataFlowInNode = DataFlowEditor()->GetNode( DataFlowInNodeName ) ; + if ( DataFlowOutNode && DataFlowInNode ) { + bool Success ; + StreamLink_Impl * myStreamLink = new StreamLink_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowInNode , + InStreamPort->Name() , + DataFlowOutNode , + OutStreamPort->Name() , + true , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myStreamLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamLink::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate(iobject) ) ; + DataFlowEditor()->UnValid() ; + } + } + } + else { + iobject = SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ; + } + } + endService( "StreamGraph_Impl::StreamLink" ); + return SUPERV::StreamLink::_duplicate(iobject) ; +} + +SUPERV::ListOfStreamLinks * StreamGraph_Impl::GStreamLinks() { + return StreamLinks( NULL , NULL ) ; +} + +SUPERV::ListOfStreamLinks * StreamGraph_Impl::StreamLinks( GraphBase::ComputingNode * theNode , + const char * anInputParam ) { + bool begin = true ; + SUPERV::ListOfStreamLinks_var RetVal = new SUPERV::ListOfStreamLinks ; + int i , j , countlink ; + countlink = 0 ; + for ( i = 0 ; i < DataFlowEditor()->Graph()->GraphNodesSize() ; i++ ) { + GraphEditor::InNode * aNode = NULL ; + aNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GraphNodes( i )->GetInNode() ; + bool ToProcess = false ; + if ( theNode == NULL ) { + ToProcess = true ; + } + else { + if ( !strcmp( theNode->Name() , aNode->Name() ) ) { + if ( !theNode->IsEndSwitchNode() ) { + ToProcess = true ; + } + } + else if ( theNode->IsEndSwitchNode() ) { + ToProcess = true ; + } + } + if ( ToProcess ) { + for ( j = 0 ; j < aNode->GetNodeInPortsSize() ; j++ ) { + GraphBase::InPort * anInPort = NULL ; + anInPort = aNode->GetChangeNodeInPort( j ) ; + if ( anInputParam == NULL || + !strcmp( anInPort->PortName() , anInputParam ) ) { + GraphBase::OutPort * anOutPort = NULL ; + anOutPort = anInPort->GetOutPort() ; + if ( anOutPort && anOutPort->IsDataStream() ) { + if ( strcmp( anOutPort->NodeName() , Name() ) ) { + MESSAGE("StreamGraph_Impl::StreamLinks " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> " << aNode->Name() << "(" + << anInPort->PortName() << ")" ) ; + if ( theNode == NULL || + ( theNode != NULL && !theNode->IsEndSwitchNode() && + !strcmp( theNode->Name() , aNode->Name() ) ) ) { + if ( anInPort->IsLoop() || anOutPort->IsLoop() || + ( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() , + anOutPort->NodeName() ) ) ) { + MESSAGE( "StreamLink " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> " << aNode->Name() << "(" + << anInPort->PortName() << ")" << " ignored" ) ; + } + else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "StreamGraph_Impl::StreamLinks" ); + begin = false ; + } + GraphEditor::InNode * anOutNode = NULL ; + anOutNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anOutPort->NodeName() )->GetInNode() ; + if ( anOutNode ) { + bool Success ; + StreamLink_Impl * myStreamLink = new StreamLink_Impl( + _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + aNode , + anInPort->PortName() , + anOutNode , + anOutPort->PortName() , + false , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myStreamLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamLink_var iobject ; + iobject = SUPERV::StreamLink::_narrow(obj) ; + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( iobject ) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ; + MESSAGE( "Link" << countlink-1 << " " + << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> " + << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ; + } + } + } + else { + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ; + MESSAGE( "Link" << countlink-1 << " " + << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> " + << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ; + } + } + } + } + } + } + } + for ( j = 0 ; j < aNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( j ) ; + int k ; + for ( k = 0 ; k < anOutPort->InPortsSize() ; k++ ) { + GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ; + GraphEditor::InNode * toNode = (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; + if ( theNode == NULL || + !strcmp( theNode->Name() , aNode->Name() ) ) { + if ( anInPort->IsDataStream() ) { + if ( theNode || ( toNode->IsEndSwitchNode() && !aNode->IsSwitchNode() ) ) { + if ( anInputParam == NULL || + !strcmp( anInPort->PortName() , anInputParam ) ) { + MESSAGE( "StreamLink " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> " << toNode->Name() << "(" + << anInPort->PortName() << ")" ) ; + MESSAGE( " IOR " << DataFlowEditor()->ObjectToString( anOutPort->InPortObjRef( anInPort ) ) ) ; + if ( anInPort->IsLoop() || anOutPort->IsLoop() || + ( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() , + anOutPort->NodeName() ) ) ) { + MESSAGE( "StreamLink " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> " << toNode->Name() << "(" + << anInPort->PortName() << ")" << " ignored" ) ; + } + else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "Graph_Impl::StreamLinks" ); + begin = false ; + } + bool Success ; + StreamLink_Impl * myStreamLink = new StreamLink_Impl( + _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + toNode , + anInPort->PortName() , + aNode , + anOutPort->PortName() , + false , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myStreamLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + SUPERV::StreamLink_var iobject ; + iobject = SUPERV::StreamLink::_narrow(obj) ; + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( iobject ) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ; + MESSAGE( "Link" << countlink-1 << " " + << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> " + << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ; + } + } + else { + RetVal->length( countlink + 1 ) ; + RetVal[ countlink++ ] = SUPERV::StreamLink::_duplicate( SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ) ; + MESSAGE( "Link" << countlink-1 << " " + << RetVal[countlink-1]->OutStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->OutStreamPort()->Name() << ") --> " + << RetVal[countlink-1]->InStreamPort()->Node()->Name() << "(" + << RetVal[countlink-1]->InStreamPort()->Name() << ")" ) ; + } + } + else { + MESSAGE( "StreamLink " << anOutPort->NodeName() << "(" + << anOutPort->PortName() << ") --> " << toNode->Name() << "(" + << anInPort->PortName() << ")" << " skipped" ) ; + } + } + } + } + } + } + } +//#if 0 + const char * NodeName = "" ; + const char * InputParamName = "" ; + if ( theNode ) { + NodeName = theNode->Name() ; + } + if ( anInputParam ) { + InputParamName = anInputParam ; + } + MESSAGE( RetVal->length() << " StreamLinks of Node " << NodeName << " and of InPort " << InputParamName ) ; + for ( i = 0 ; i < (int ) RetVal->length() ; i++ ) { + MESSAGE( "Link" << i << " " << RetVal[i]->OutStreamPort()->Node()->Name() << "(" + << RetVal[i]->OutStreamPort()->Name() << ") --> " + << RetVal[i]->InStreamPort()->Node()->Name() << "(" + << RetVal[i]->InStreamPort()->Name() << ")" ) ; + } +//#endif + if ( !begin ) { + endService( "StreamGraph_Impl::StreamLinks" ); + } + return ( RetVal._retn() ) ; +} + +bool StreamGraph_Impl::SetStreamParams( const long Timeout , + const SUPERV::KindOfDataStreamTrace DataStreamTrace , + const double DeltaTime ) { + bool sts = DataFlowEditor()->StreamGraph()->SetStreamParams( Timeout , DataStreamTrace , DeltaTime ) ; + if ( sts ) { + DataFlowEditor()->UnValid() ; + } + return sts ; +} + +void StreamGraph_Impl::StreamParams( long & Timeout , + SUPERV::KindOfDataStreamTrace & DataStreamTrace , + double & DeltaTime ) { + DataFlowEditor()->StreamGraph()->StreamParams( Timeout , DataStreamTrace , DeltaTime ) ; +} + +long StreamGraph_Impl::SubStreamGraphsNumber() { +// beginService( "StreamGraph_Impl::StreamGraphsNumber" ); + long RetVal = 0 ; + if ( DataFlowEditor()->IsExecutable() ) { + RetVal = DataFlowEditor()->SubStreamGraphsNumber() ; + } +// endService( "StreamGraph_Impl::SubStreamGraphsNumber" ); + return RetVal ; +} + +SUPERV::ListOfNodes * StreamGraph_Impl::SubStreamGraphsNodes( const long aSubStreamGraphNumber ) { + beginService( "StreamGraph_Impl::SubStreamGraphsNodes" ); + SUPERV::ListOfNodes_var RetVal = new SUPERV::ListOfNodes ; + if ( DataFlowEditor()->IsEditing() ) { + SUPERV::ListOfNodes * aGraphNodes = Nodes() ; + int i ; +// ComputingNodes + for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) { + SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// FactoryNodes + for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) { + SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// InLineNodes + for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) { + SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// GOTONodes + for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) { + SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// LoopNodes + for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) { + SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// EndLoopNodes + for ( i = 0 ; i < (int ) aGraphNodes->ELNodes.length() ; i++ ) { + SUPERV::ELNode_var aNode = (aGraphNodes->ELNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// SwitchNodes + for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) { + SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } +// EndSwitchNodes + for ( i = 0 ; i < (int ) aGraphNodes->ESNodes.length() ; i++ ) { + SUPERV::ESNode_var aNode = (aGraphNodes->ESNodes)[ i ] ; + if ( aNode->SubStreamGraph() == aSubStreamGraphNumber ) { + RetVal = SetNode( RetVal , DataFlowEditor()->Graph()->GetChangeGraphNode( aNode->Name() ) ) ; + } + } + } + endService( "StreamGraph_Impl::SubStreamGraphsNodes" ); + return ( RetVal._retn() ) ; +} + +SUPERV::Graph_ptr StreamGraph_Impl::ToFlowGraph() { + SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; + beginService( "StreamGraph_Impl::ToFlowGraph" ); +// Graph_Impl * myFlowGraph = new Graph_Impl( _Orb , _Poa , _ContId , +// instanceName() , interfaceName() ) ; +// PortableServer::ObjectId * id = myFlowGraph->getId() ; +// CORBA::Object_var obj = _poa->id_to_reference(*id); + if ( !CORBA::is_nil( DataFlowEditor()->StreamGraph()->ObjRef() ) ) { + iobject = SUPERV::Graph::_narrow( DataFlowEditor()->StreamGraph()->ObjRef() ) ; + } + endService( "StreamGraph_Impl::ToFlowGraph" ); + return SUPERV::Graph::_duplicate( iobject ) ; +} + +bool StreamGraph_Impl::StreamMerge(const SUPERV::StreamGraph_ptr aStreamGraph ) { + beginService( "StreamGraph_Impl::StreamMerge" ); + map< string , int > aMapOfNodes ; + bool RetVal = Merge( aStreamGraph , aMapOfNodes ) ; + if ( RetVal ) { + SUPERV::ListOfStreamLinks * aGraphLinks = aStreamGraph->GStreamLinks() ; + SUPERV::ListOfStreamPorts * aGraphPorts = aStreamGraph->StreamPorts() ; + cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts" + << endl ; + int i ; + for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) { + SUPERV::StreamLink_var aLink = (*aGraphLinks)[ i ] ; + SUPERV::StreamPort_var OutPort = aLink->OutStreamPort() ; + SUPERV::StreamPort_var InPort = aLink->InStreamPort() ; + string * aLinkFromNodeName = new string( OutPort->Node()->Name() ) ; + string * aLinkToNodeName = new string( InPort->Node()->Name() ) ; + cout << "Graph_Impl::Merge " << aLinkFromNodeName << "(" << OutPort->Name() << ") ---> " + << aLinkToNodeName << "(" << InPort->Name() << ")" << endl ; + RetVal = DataFlowEditor()->AddLink( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + OutPort->Name() , + DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + InPort->Name() ) ; + cout << "Graph_Impl::Merge " << aLinkFromNodeName << "(" << OutPort->Name() << ") ---> " + << aLinkToNodeName << "(" << InPort->Name() << ") RetVal" << RetVal << endl ; + if ( RetVal ) { + int j ; + for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) { + long X , Y ; + RetVal = aLink->Coords( j , X , Y ) ; + if ( !RetVal ) + break ; + RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() , + OutPort->Name() , + DataFlowEditor()->Graph()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() , + InPort->Name() , + j , X , Y ) ; + if ( !RetVal ) { + break ; + } + } + } + delete aLinkFromNodeName ; + delete aLinkToNodeName ; + if ( !RetVal ) { + break ; + } + } + if ( RetVal ) { + for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) { + SUPERV::StreamPort_var aPort = (*aGraphPorts)[ i ] ; + if ( !aPort->IsGate() ) { + MESSAGE( "Graph_Impl::Merge " << i << ". " << aPort->Node()->Name() << " " << aPort->Name() ) ; + char * aPortName = aPort->Name() ; + char * aNodeName = new char[ strlen( aPortName ) + 1 ] ; + strcpy( aNodeName , aPortName ) ; + char * thePortName = strchr( aNodeName , '\\' ) ; + thePortName[ 0 ] = '\0' ; + bool hasinput = aStreamGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ; +// cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1 +// << " HasInput " << hasinput << endl ; + if ( hasinput ) { + RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->StreamGraph()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() , + thePortName + 1 , + *(aPort->ToAny()) ) ; + } + delete [] aNodeName ; + if ( !RetVal ) { + break ; + } + } + } + } + } + endService( "StreamGraph_Impl::StreamMerge" ); + return RetVal ; +} + diff --git a/src/Supervision/StreamGraph_Impl.hxx b/src/Supervision/StreamGraph_Impl.hxx new file mode 100644 index 0000000..c3ea3bd --- /dev/null +++ b/src/Supervision/StreamGraph_Impl.hxx @@ -0,0 +1,89 @@ +// SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StreamGraph_Impl.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _STREAMGRAPH_IMPL_HXX_ +#define _STREAMGRAPH_IMPL_HXX_ + +//#include + +#include "CORBA.h" + +#include +#include "SALOME_Component_i.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +#include "Graph_Impl.hxx" + +class StreamGraph_Impl : public Graph_Impl , + public POA_SUPERV::StreamGraph { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + StreamGraph_Impl(); + StreamGraph_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const char *aDataFlowName ) ; + + virtual ~StreamGraph_Impl() ; + virtual void destroy() ; + + virtual SUPERV::StreamGraph_ptr StreamCopy() ; + + virtual SUPERV::StreamLink_ptr StreamLink( SUPERV::StreamPort_ptr OutStreamPort , + SUPERV::StreamPort_ptr InStreamPort ) ; + + virtual SUPERV::ListOfStreamLinks * GStreamLinks() ; + + virtual SUPERV::ListOfStreamLinks * StreamLinks( GraphBase::ComputingNode * aNode , + const char * anInputParam ) ; + + virtual bool SetStreamParams( const long Timeout , + const SUPERV::KindOfDataStreamTrace DataStreamTrace , + const double DeltaTime ) ; + virtual void StreamParams( long & Timeout , + SUPERV::KindOfDataStreamTrace & DataStreamTrace , + double & DeltaTime ) ; + + virtual long SubStreamGraphsNumber() ; + virtual SUPERV::ListOfNodes * SubStreamGraphsNodes( const long aSubStreamGraphNumber ) ; + + virtual SUPERV::Graph_ptr ToFlowGraph() ; + + bool StreamMerge( const SUPERV::StreamGraph_ptr aStreamGraph ) ; + +}; + + +#endif diff --git a/src/Supervision/StreamLink_Impl.cxx b/src/Supervision/StreamLink_Impl.cxx new file mode 100644 index 0000000..b68f0e8 --- /dev/null +++ b/src/Supervision/StreamLink_Impl.cxx @@ -0,0 +1,165 @@ +// SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StreamLink_Impl.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; + +#include "StreamLink_Impl.hxx" + +StreamLink_Impl::StreamLink_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *InputParameterName , + GraphEditor::InNode * DataFlowOutNode , + const char *OutputParameterName , + const bool Create , + bool & Success ) : + Link_Impl( orb , poa , contId , instanceName , interfaceName , DataFlowEditor , + DataFlowNode , InputParameterName , DataFlowOutNode , + OutputParameterName , false , false , Success ) { +// MESSAGE("StreamLink_Impl::StreamLink_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) +// bool linksts ; +// beginService( "StreamLink_Impl::Link_Impl" ); + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + if ( Create ) { + Success = DataFlowEditor->AddLink( DataFlowOutNode->Name() , + OutputParameterName , + DataFlowNode->Name() , + InputParameterName ) ; + } + else { + char * DataFlowOutNodeName = NULL ; + char * OutParamName = NULL ; + Success = DataFlowEditor->GetLink( DataFlowNode->Name() , + InputParameterName , + &DataFlowOutNodeName , + &OutParamName ) ; + } + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +// endService( "StreamLink_Impl::Link_Impl" ); +} + +StreamLink_Impl::StreamLink_Impl() { +} + +StreamLink_Impl::~StreamLink_Impl() { + beginService( "Link_Impl::~Link_Impl" ); + endService( "Link_Impl::~Link_Impl" ); +} + +void StreamLink_Impl::destroy() { + beginService( "StreamLink_Impl::destroy" ); + Delete() ; + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + endService( "StreamLink_Impl::destroy" ); +} + +bool StreamLink_Impl::Delete() { +// beginService( "StreamLink_Impl::Delete" ) ; + bool RetVal = DataFlowEditor()->RemoveLink( DataFlowOutNode()->Name() , + OutputParameterName() , + DataFlowNode()->Name() , + InputParameterName() ) ; + if ( RetVal ) { + DataFlowEditor()->UnValid() ; + } +// endService( "StreamLink_Impl::Delete" ); + return RetVal ; +} + +SUPERV::StreamPort_ptr StreamLink_Impl::InStreamPort() { +// beginService( "Link_Impl::InStreamPort" ); + SUPERV::StreamPort_var iobject = SUPERV::StreamPort::_nil() ; + GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( InputParameterName() ) ; + if ( anInPort && anInPort->IsDataStream() ) { + iobject = SUPERV::StreamPort::_narrow( anInPort->ObjRef() ) ; + if ( CORBA::is_nil( iobject ) ) { +// MESSAGE( "StreamLink_Impl::InStreamPort creates myStreamPort " +// << DataFlowNode()->Name() << "( " << anInPort->PortName() << " )" ) ; + StreamPort_Impl * myStreamPort = new StreamPort_Impl( + _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + (GraphBase::Port * ) anInPort , + true ) ; + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamPort::_narrow(obj) ; + anInPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ; + } + else { +// MESSAGE( "StreamLink_Impl::InStreamPort Gets ObjRef " +// << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ; + } + } +// endService( "StreamLink_Impl::InStreamPort" ); + return SUPERV::StreamPort::_duplicate( iobject ) ; +} + +SUPERV::StreamPort_ptr StreamLink_Impl::OutStreamPort() { +// beginService( "StreamLink_Impl::OutStreamPort" ); + SUPERV::StreamPort_var iobject ; + GraphBase::OutPort * anOutPort = DataFlowOutNode()->GetChangeOutPort( OutputParameterName() ) ; + if ( anOutPort && anOutPort->IsDataStream() ) { + iobject = SUPERV::StreamPort::_narrow( anOutPort->ObjRef() ) ; + if ( CORBA::is_nil( iobject ) ) { +// MESSAGE( "StreamLink_Impl::OutStreamPort creates myStreamPort " +// << DataFlowNode()->Name() << "( " << anOutPort->PortName() << " )" ) ; + StreamPort_Impl * myStreamPort = new StreamPort_Impl( + _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowOutNode() , + (GraphBase::Port * ) anOutPort , + false ) ; + PortableServer::ObjectId * id = myStreamPort->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamPort::_narrow(obj) ; + anOutPort->ObjRef( SUPERV::StreamPort::_duplicate( iobject ) ) ; + } + else { +// MESSAGE( "StreamLink_Impl::OutStreamPort Gets ObjRef " +// << iobject->Node()->Name() << "( " << iobject->Name() << " )" ) ; + } + } +// endService( "StreamLink_Impl::OutStreamPort" ); + return SUPERV::StreamPort::_duplicate( iobject ) ; +} + diff --git a/src/Supervision/StreamLink_Impl.hxx b/src/Supervision/StreamLink_Impl.hxx new file mode 100644 index 0000000..af8136c --- /dev/null +++ b/src/Supervision/StreamLink_Impl.hxx @@ -0,0 +1,68 @@ +// SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StreamLink_Impl.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _STREAMLINK_IMPL_HXX_ +#define _STREAMLINK_IMPL_HXX_ + +#include "StreamPort_Impl.hxx" + +#include "Link_Impl.hxx" + +class StreamLink_Impl : public POA_SUPERV::StreamLink , + public Link_Impl { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + StreamLink_Impl(); + StreamLink_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + const char *InputParameterName , + GraphEditor::InNode * DataFlowOutNode , + const char *OutputParameterName , + const bool Create , + bool & Success ) ; + + virtual ~StreamLink_Impl() ; + virtual void destroy() ; + virtual bool Delete() ; + + SUPERV::StreamPort_ptr OutStreamPort() ; + SUPERV::StreamPort_ptr InStreamPort() ; + +} ; + +#endif diff --git a/src/Supervision/StreamPort_Impl.cxx b/src/Supervision/StreamPort_Impl.cxx new file mode 100644 index 0000000..759a0cd --- /dev/null +++ b/src/Supervision/StreamPort_Impl.cxx @@ -0,0 +1,258 @@ +// SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StreamPort_Impl.cxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +using namespace std; + +#include "StreamPort_Impl.hxx" + +StreamPort_Impl::StreamPort_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + GraphBase::Port * DataFlowPort , + bool InputPort , + const CORBA::Any * anAny ) : + Port_Impl( orb , poa , contId , instanceName , interfaceName , + DataFlowEditor , DataFlowNode , DataFlowPort , InputPort , anAny ) { +// MESSAGE("StreamPort_Impl::StreamPort_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +StreamPort_Impl::StreamPort_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + GraphBase::Port * DataFlowPort , + bool InputPort ) : + Port_Impl( orb , poa , contId , instanceName , interfaceName , + DataFlowEditor , DataFlowNode , DataFlowPort , InputPort ) { +// MESSAGE("StreamPort_Impl::StreamPorte_Impl activate object instanceName(" +// << instanceName << ") interfaceName(" << interfaceName << ") --> " +// << hex << (void *) this << dec ) + _Orb = CORBA::ORB::_duplicate(orb); + _Poa = poa ; + _ContId = contId ; + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +StreamPort_Impl::StreamPort_Impl() { +} + +StreamPort_Impl::~StreamPort_Impl() { + beginService( "StreamPort_Impl::~StreamPort_Impl" ); + endService( "StreamPort_Impl::~StreamPort_Impl" ); +} + +void StreamPort_Impl::destroy() { + beginService( "StreamPort_Impl::destroy" ); + bool destroyed = false ; + if ( DataFlowNode()->IsOneOfInLineNodes() ) { + if ( IsInput() ) { + GraphBase::InPort * anInPort = (GraphBase::InPort * ) DataFlowPort() ; + if ( anInPort->GetOutPort() ) { + anInPort->GetOutPort()->RemoveInPort( anInPort ) ; + } + DataFlowNode()->DelInPort( DataFlowPort()->PortName() ) ; + destroyed = true ; + } + else { + DataFlowNode()->DelOutPort( DataFlowPort()->PortName() ) ; + destroyed = true ; + } + if ( destroyed ) { + DataFlowEditor()->UnValid() ; + } + } + if ( destroyed ) { + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + } + endService( "StreamPort_Impl::destroy" ); +} + + +SUPERV::StreamLink_ptr StreamPort_Impl::StreamLink() { + bool begin = true ; + SUPERV::StreamLink_var iobject = SUPERV::StreamLink::_nil() ; + char * FromNodeName = NULL ; + char * FromServiceParameterName = NULL ; + bool status = DataFlowEditor()->GetLink( DataFlowNode()->Name() , + DataFlowPort()->PortName() , + & FromNodeName , + & FromServiceParameterName ) ; + if ( status ) { +// cout << "Port_Impl::Link " << FromNodeName << "(" +// << FromServiceParameterName << ") --> " << _DataFlowNode->Name() +// << "(" << _DataFlowPort->PortName() << ")" << endl ; +// SUPERV::Port_ptr theOutPort = Port( FromServiceParameterName ) ; + + GraphBase::InPort * anInPort = DataFlowNode()->GetChangeInPort( DataFlowPort()->PortName() ) ; + if ( anInPort->GetOutPort() ) { + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) { + if ( begin ) { + beginService( "Port_Impl::Link" ) ; + begin = false ; + } + bool Success ; + StreamLink_Impl * myStreamLink = new StreamLink_Impl( _Orb , _Poa , _ContId , + instanceName() , interfaceName() , + DataFlowEditor() , + DataFlowNode() , + DataFlowPort()->PortName() , + (GraphEditor::InNode * ) DataFlowEditor()->Graph()->GetChangeGraphNode( FromNodeName )->GetInNode() , + FromServiceParameterName , + false , Success ) ; + if ( Success ) { + PortableServer::ObjectId * id = myStreamLink->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamLink::_narrow(obj) ; + anOutPort->AddInPortObjRef( anInPort , SUPERV::StreamLink::_duplicate( iobject ) ) ; + } + } + else { + iobject = SUPERV::StreamLink::_narrow( anOutPort->InPortObjRef( anInPort ) ) ; + } + } + } + if ( !begin ) { + MESSAGE( "Link " << iobject->OutPort()->Node()->Name() << "( " << iobject->OutPort()->Name() << " ) --> " + << iobject->InPort()->Node()->Name() << "( " << iobject->InPort()->Name() << " ) " ) ; + endService( "StreamPort_Impl::StreamLink" ) ; + } + return SUPERV::StreamLink::_duplicate( iobject ) ; +} + +SALOME_ModuleCatalog::DataStreamDependency StreamPort_Impl::Dependency() { +// beginService( "StreamPort_Impl::Dependency" ); + SALOME_ModuleCatalog::DataStreamDependency RetVal = DataFlowPort()->Dependency() ; +// endService( "StreamPort_Impl::Dependency" ); + return RetVal ; +} + +bool StreamPort_Impl::SetDependency( const SALOME_ModuleCatalog::DataStreamDependency aDependency ) { +// beginService( "StreamPort_Impl::SetDependency" ); + DataFlowPort()->Dependency( aDependency ) ; +// endService( "StreamPort_Impl::SetDependency" ); + return true ; +} + +bool StreamPort_Impl::SetParams( const SUPERV::KindOfSchema aKindOfSchema , + const SUPERV::KindOfInterpolation aKindOfInterpolation , + const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) { +// beginService( "StreamPort_Impl::SetParams" ); + bool RetVal = false ; + if ( IsInput() ) { + GraphBase::InDataStreamPort * anInStreamPort = (GraphBase::InDataStreamPort * ) DataFlowPort() ; + RetVal = anInStreamPort->SetParams( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + if ( RetVal ) { + MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation + << " , " << aKindOfExtrapolation << " ) SUCCESS " ) ; + DataFlowEditor()->UnValid() ; + } + else { + MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation + << " , " << aKindOfExtrapolation << " ) FAILED " ) ; + } + } + else { + MESSAGE( "OutStreamPort_Impl::SetParams( " << aKindOfSchema << " , " << aKindOfInterpolation + << " , " << aKindOfExtrapolation << " ) ERROR : OutPort" ) ; + } +// endService( "StreamPort_Impl::SetParams" ); + return RetVal ; +} + +bool StreamPort_Impl::Params( SUPERV::KindOfSchema & aKindOfSchema , + SUPERV::KindOfInterpolation & aKindOfInterpolation , + SUPERV::KindOfExtrapolation & aKindOfExtrapolation ) { +// beginService( "StreamPort_Impl::Params" ); + bool RetVal = false ; + if ( IsInput() ) { + GraphBase::InDataStreamPort * anInStreamPort = (GraphBase::InDataStreamPort * ) DataFlowPort() ; + anInStreamPort->Params( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) ; + MESSAGE( "InStreamPort_Impl::Params( " << aKindOfSchema << " , " << aKindOfInterpolation << " , " << aKindOfExtrapolation << " )" ) ; + RetVal = true ; + } + else { + aKindOfSchema = (SUPERV::KindOfSchema ) -1 ; + aKindOfInterpolation = (SUPERV::KindOfInterpolation ) -1 ; + aKindOfExtrapolation = (SUPERV::KindOfExtrapolation ) -1 ; + MESSAGE( "OutStreamPort_Impl::Params( " << aKindOfSchema << " , " << aKindOfInterpolation + << " , " << aKindOfExtrapolation << " ) ERROR: OutPort" ) ; + } +// endService( "StreamPort_Impl::Params" ); + return RetVal ; +} + +bool StreamPort_Impl::SetNumberOfValues( const long aNumberOfValues ) { +// beginService( "StreamPort_Impl::SetNumberOfValues" ); + bool RetVal = false ; + if ( !IsInput() ) { + GraphBase::OutDataStreamPort * anOutStreamPort = (GraphBase::OutDataStreamPort * ) DataFlowPort() ; + anOutStreamPort->NumberOfValues( aNumberOfValues ) ; + DataFlowEditor()->UnValid() ; + RetVal = true ; + } + else { + MESSAGE( "OutStreamPort_Impl::SetNumberOfValues( " << aNumberOfValues << " ) ERROR : InPort" ) ; + } +// endService( "StreamPort_Impl::SetNumberOfValues" ); + return RetVal ; +} + +long StreamPort_Impl::NumberOfValues() { +// beginService( "StreamPort_Impl::NumberOfValues" ); + long RetVal = -1 ; + if ( !IsInput() ) { + GraphBase::OutDataStreamPort * anOutStreamPort = (GraphBase::OutDataStreamPort * ) DataFlowPort() ; + RetVal = anOutStreamPort->NumberOfValues() ; + MESSAGE( "OutStreamPort_Impl::NumberOfValues() " << RetVal ) ; + } + else { + MESSAGE( "OutStreamPort_Impl::NumberOfValues() ERROR : InPort" ) ; + } +// endService( "StreamPort_Impl::NumberOfValues" ); + return RetVal ; +} + diff --git a/src/Supervision/StreamPort_Impl.hxx b/src/Supervision/StreamPort_Impl.hxx new file mode 100644 index 0000000..f351535 --- /dev/null +++ b/src/Supervision/StreamPort_Impl.hxx @@ -0,0 +1,85 @@ +// SUPERV Supervision : contains the implementation of interfaces of SuperVision described in SUPERV.idl +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StreamPort_Impl.hxx +// Author : Jean Rahuel +// Module : SUPERV +// $Header: + +#ifndef _STREAMPORT_IMPL_HXX_ +#define _STREAMPORT_IMPL_HXX_ + +#include "Port_Impl.hxx" + +#include "StreamLink_Impl.hxx" + +class StreamPort_Impl : public Port_Impl , + public POA_SUPERV::StreamPort { + private: + + CORBA::ORB_ptr _Orb ; + PortableServer::POA_ptr _Poa ; + PortableServer::ObjectId * _ContId ; + + public: + StreamPort_Impl(); + StreamPort_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataStreamNode , + GraphBase::Port * DataStreamPort , + bool InputPort , + const CORBA::Any * anAny ) ; + StreamPort_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + GraphEditor::DataFlow * DataFlowEditor , + GraphEditor::InNode * DataFlowNode , + GraphBase::Port * DataStreamPort , + bool InputPort ) ; + virtual ~StreamPort_Impl() ; + virtual void destroy() ; + + virtual SUPERV::StreamLink_ptr StreamLink() ; + + virtual SALOME_ModuleCatalog::DataStreamDependency Dependency() ; + virtual bool SetDependency( const SALOME_ModuleCatalog::DataStreamDependency aDependency ) ; + + virtual bool SetParams( const SUPERV::KindOfSchema aKindOfSchema , + const SUPERV::KindOfInterpolation aKindOfInterpolation , + const SUPERV::KindOfExtrapolation aKindOfExtrapolation ) ; + virtual bool Params( SUPERV::KindOfSchema & aKindOfSchema , + SUPERV::KindOfInterpolation & aKindOfInterpolation , + SUPERV::KindOfExtrapolation & aKindOfExtrapolation ) ; + + virtual bool SetNumberOfValues( const long aNumberOfValues ) ; + virtual long NumberOfValues() ; + +} ; + +#endif diff --git a/src/Supervision/SuperV.py b/src/Supervision/SuperV.py index 7d23166..76e33d7 100644 --- a/src/Supervision/SuperV.py +++ b/src/Supervision/SuperV.py @@ -16,6 +16,8 @@ try : from salome import CORBA from salome import sg import SALOME_ModuleCatalog + import SUPERV + import SUPERV_idl except : import curses from LifeCycleCORBA import * @@ -46,7 +48,7 @@ from types import * # print 'Supervision Component loaded' SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV") -SuperVision.Swig = 0 +#SuperVision.Swig = 0 modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog") @@ -207,6 +209,11 @@ class CNode: if self.N.IsFactory() : print "ComponentName ",self.N.GetComponentName() print "InterfaceName ",self.N.GetInterfaceName() + if self.N.IsStreamGraph() : + Timeout,DataStreamTrace,DeltaTime = self.G.StreamParams() + print "Timeout",Timeout + print "DataStreamTrace",DataStreamTrace + print "DeltaTime",DeltaTime aService = self.N.Service() print "Service Name ",aService.ServiceName lenin = len( aService.ServiceinParameter ) @@ -244,7 +251,6 @@ class CNode: def Input( self , *args ): types, realargs = getRealArgs(self.N,args) fn = bs_AddInput_valuedict[types] - print types,realargs,fn anInput = apply( fn, realargs) if anInput != None : myInput = Port( anInput , self.N.Verbose ) @@ -253,21 +259,54 @@ class CNode: if self.N.Verbose : print ErrMsg return anInput -# def BusPort( self , InOutParameterName , InOutParameterType ): -# sts,inp,outp = self.N.BusPort( InOutParameterName , -# InOutParameterType ) -# inp = Port( inp , self.N.Verbose ) -# outp = Port( outp , self.N.Verbose ) -# return sts,inp,outp -# def BusPorts( self , InputParameterName , InputParameterType , -# OutputParameterName , OutputParameterType ): -# sts,inp,outp = self.N.BusPorts( InputParameterName , -# InputParameterType , -# OutputParameterName , -# OutputParameterType ) -# inp = Port( inp , self.N.Verbose ) -# outp = Port( outp , self.N.Verbose ) -# return sts,inp,outp + def InStreamPort( self , aParameterName , aParameterType , aDependency ): + aPort = self.N.InStreamPort( aParameterName , aParameterType , aDependency ) + if aPort != None : + myPort = StreamPort( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def OutStreamPort( self , aParameterName , aParameterType , aDependency ): + aPort = self.N.OutStreamPort( aParameterName , aParameterType , aDependency ) + if aPort != None : + myPort = StreamPort( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def GetInPort( self , aParameterName ): + aPort = self.N.GetInPort( aParameterName ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def GetOutPort( self , aParameterName ): + aPort = self.N.GetOutPort( aParameterName ) + if aPort != None : + myPort = Port( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def GetInStreamPort( self , aParameterName ): + aPort = self.N.GetInStreamPort( aParameterName ) + if aPort != None : + myPort = StreamPort( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None + def GetOutStreamPort( self , aParameterName ): + aPort = self.N.GetOutStreamPort( aParameterName ) + if aPort != None : + myPort = StreamPort( aPort , self.N.Verbose ) + return myPort + if self.N.Verbose : + print "Error while creating the Port : ",aParameterName + return None def Ports( self ): ports = self.N.Ports() i = 0 @@ -275,13 +314,34 @@ class CNode: ports[ i ] = Port( ports[i] , self.N.Verbose ) i = i + 1 return ports + def StreamPorts( self ): + ports = self.N.StreamPorts() + i = 0 + while i < len( ports ) : + ports[ i ] = StreamPort( ports[i] , self.N.Verbose ) + i = i + 1 + return ports + def AllPorts( self ): + allports = self.N.Ports() + lenports = len( allports ) + i = 0 + while i < lenports : + allports[ i ] = Port( allports[i] , self.N.Verbose ) + i = i + 1 + ports = self.N.StreamPorts() + i = 0 + while i < len( ports ) : + allports.append( StreamPort( ports[i] , self.N.Verbose ) ) + i = i + 1 + return allports def ListPorts( self , *args ): if len( args ) == 0 : aName = self.N.Name() else : aName = args[ 0 ] - ports = self.N.Ports() + ports = self.AllPorts() listofports = "" + ilst = 0 if len( ports ) : portsname = ports[ 0 ].Name() bs = portsname.find('\\') @@ -289,9 +349,9 @@ class CNode: portsname1,portsname2 = portsname.split('\\') portsname = portsname1 + portsname2 if ports[ 0 ].IsInput(): - listofports = aName + 'In' + portsname + listofports = 'I' + aName + portsname else : - listofports = aName + 'Out' + portsname + listofports = 'O' + aName + portsname i = 1 while i < len( ports ) : portsname = ports[ i ].Name() @@ -300,24 +360,32 @@ class CNode: portsname1,portsname2 = portsname.split('\\') portsname = portsname1 + portsname2 if ports[ i ].IsInput(): - listofports = listofports + ',' + aName + 'In' + portsname + listofports = listofports + ',' + 'I' + aName + portsname else : - listofports = listofports + ',' + aName + 'Out' + portsname + listofports = listofports + ',' + 'O' + aName + portsname i = i + 1 print listofports if len( ports ) == 1 : - listofports = "[" + listofports + "] = " + aName + ".Ports()" + listofports = "[" + listofports + "] = " + aName + ".AllPorts()" else : - listofports = listofports + " = " + aName + ".Ports()" + listofports = listofports + " = " + aName + ".AllPorts()" return listofports def PrintPorts( self ): - ports = self.N.Ports() + ports = self.AllPorts() i = 0 while i < len( ports ) : Direction = "Out" if ports[ i ].IsInput() : Direction = "In" - print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString() + if ( ports[ i ].IsDataStream() ) & ( self.N.IsStreamGraph() == 0 ) : + if ports[ i ].IsInput() : + sts,aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation = ports[ i ].Params() + print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString(),ports[ i ].Dependency(),aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation + else : + numberofvalues = ports[ i ].NumberOfValues() + print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString(),ports[ i ].Dependency(),'NumberOfValues',numberofvalues + else : + print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString() i = i + 1 def Links( self ) : links = self.N.Links() @@ -326,12 +394,58 @@ class CNode: links[ i ] = Link( links[i] , self.N.Verbose ) i = i + 1 return links + def StreamLinks( self ) : + links = self.N.StreamLinks() + i = 0 + while i < len( links ) : + links[ i ] = StreamLink( links[i] , self.N.Verbose ) + i = i + 1 + return links + def AllLinks( self ) : + alllinks = self.N.Links() + lenlinks = len( alllinks ) + i = 0 + while i < lenlinks : + alllinks[ i ] = Link( alllinks[i] , self.N.Verbose ) + i = i + 1 + links = self.N.StreamLinks() + i = 0 + while i < len( links ) : + alllinks.append( StreamLink( links[i] , self.N.Verbose ) ) + i = i + 1 + return alllinks + def ListLinks( self , *args ): + links = self.AllLinks() + if len( links ) : + listoflinks = 'L' + links[ 0 ].OutPort().Node().Name() + listoflinks = listoflinks + links[ 0 ].OutPort().Name() + listoflinks = listoflinks + links[ 0 ].InPort().Node().Name() + listoflinks = listoflinks + links[ 0 ].InPort().Name() + i = 1 + while i < len( links ) : + listoflinks = listoflinks + ',' + 'L' + links[ i ].OutPort().Node().Name() + listoflinks = listoflinks + links[ i ].OutPort().Name() + listoflinks = listoflinks + links[ i ].InPort().Node().Name() + listoflinks = listoflinks + links[ i ].InPort().Name() + i = i + 1 + print listoflinks + if len( args ) == 0 : + aName = self.N.Name() + else : + aName = args[ 0 ] + if len( links ) == 1 : + listoflinks = "[" + listoflinks + "] = " + aName + ".AllLinks()" + else : + listoflinks = listoflinks + " = " + aName + ".AllLinks()" + return listoflinks def PrintLinks( self ): - links = self.Links() + links = self.AllLinks() i = 0 while i < len( links ) : links[i].Print() i = i + 1 + def IsStreamGraph( self ): + return self.N.IsStreamGraph() def IsGraph( self ): return self.N.IsGraph() def IsComputing( self ): @@ -352,6 +466,8 @@ class CNode: return self.N.IsEndSwitch() def SubGraph( self ): return self.N.SubGraph() + def SubStreamGraph( self ): + return self.N.SubStreamGraph() def Thread( self ): return self.N.Thread() def IsWaiting( self ): @@ -476,10 +592,6 @@ class INode(CNode): return self.N.PyFunction() def PyFuncName( self ): return self.N.PyFuncName() - def EPyFunc( self ): - PyFunc = self.N.PyFunction() - PyFunc = self.Edit( self.N.PyFuncName() , PyFunc ) - self.N.SetPyFunction( self.N.PyFuncName() , PyFunc ) def InPort( self , aParameterName , aParameterType ): aPort = self.N.InPort( aParameterName , aParameterType ) @@ -498,6 +610,10 @@ class INode(CNode): if self.N.Verbose : print "Error while creating the Port : ",aParameterName return None + def EPyFunc( self ): + PyFunc = self.N.PyFunction() + PyFunc = self.Edit( self.N.PyFuncName() , PyFunc ) + self.N.SetPyFunction( self.N.PyFuncName() , PyFunc ) ########################################################## class GNode(INode): @@ -603,6 +719,12 @@ class Graph(INode): except: graph = None if graph != None : + if graph.IsStreamGraph() : + aGraph = graph.ToStreamGraph() + if aGraph != None : + graph = StreamGraph( aGraph ) + else : + print "Graph creation failed" self.G = graph self.G.Verbose = 1 self.N = graph @@ -627,14 +749,14 @@ class Graph(INode): print ErrMsg return aNode def Node( self , aComponent , anInterface , aService ): - if SuperVision.Swig : - aService = Service_Swig( aService ) + #if SuperVision.Swig : + #aService = Service_Swig( aService ) return self.FNode( aComponent , anInterface , aService ) def FNode( self , aComponent , anInterface , aService ): NodeComponent = modulecatalog.GetComponent( aComponent ) aService = NodeComponent.GetService( anInterface , aService ) - if SuperVision.Swig : - aService = Service_Swig( aService ) + #if SuperVision.Swig : + #aService = Service_Swig( aService ) aNode = self.G.FNode( aComponent , anInterface , aService ) if aNode != None : myNode = FNode( aNode , self.G.Verbose ) @@ -681,78 +803,6 @@ class Graph(INode): if self.G.Verbose : print ErrMsg return aNode -# def LoopNode( self , aComponent , anInterface , aService , aNodeName ): -# NodeComponent = modulecatalog.GetComponent( aComponent ) -# aService = NodeComponent.GetService( anInterface , aService ) -# aNode,anEndNode = self.G.LoopNode( aComponent , anInterface , aService , aNodeName ) -# myNode = aNode -# myEndNode = anEndNode -# if aNode != None : -# myNode = Node( aNode , self.G.Verbose ) -# if anEndNode != None : -# myEndNode = Node( anEndNode , self.G.Verbose ) -# if ( aNode != None ) & ( anEndNode != None ) : -# return myNode,myEndNode -# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName -# if self.G.Verbose : -# print ErrMsg -# return aNode,anEndNode -# def SwitchNode( self , aComponent , anInterface , aService , aNodeName ): -# NodeComponent = modulecatalog.GetComponent( aComponent ) -# aService = NodeComponent.GetService( anInterface , aService ) -# aNode,anEndNode = self.G.SwitchNode( aComponent , anInterface , aService , aNodeName ) -# myNode = aNode -# myEndNode = anEndNode -# if aNode != None : -# myNode = Node( aNode , self.G.Verbose ) -# if anEndNode != None : -# myEndNode = Node( anEndNode , self.G.Verbose ) -# if ( aNode != None ) & ( anEndNode != None ) : -# return myNode,myEndNode -# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName -# if self.G.Verbose : -# print ErrMsg -# return aNode,anEndNode -# def LNode( self , aNodeName ): -# aNode = self.G.LNode( aNodeName ) -# if aNode != None : -# myNode = Node( aNode , self.G.Verbose ) -# return myNode -# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName -# if self.G.Verbose : -# print ErrMsg -# return aNode -# def LService( self , aComponent , anInterface , aService ): -# NodeComponent = modulecatalog.GetComponent( aComponent ) -# aService = NodeComponent.GetService( anInterface , aService ) -# aNode = self.G.LService( aComponent , anInterface , aService ) -# if aNode != None : -# myNode = Node( aNode , self.G.Verbose ) -# return myNode -# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName -# if self.G.Verbose : -# print ErrMsg -# return aNode -# def CNode( self , aNodeName ): -# aNode = self.G.CNode( aNodeName ) -# if aNode != None : -# myNode = Node( aNode , self.G.Verbose ) -# return myNode -# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName -# if self.G.Verbose : -# print ErrMsg -# return aNode -# def CService( self , aComponent , anInterface , aService ): -# NodeComponent = modulecatalog.GetComponent( aComponent ) -# aService = NodeComponent.GetService( anInterface , aService ) -# aNode = self.G.CService( aComponent , anInterface , aService ) -# if aNode != None : -# myNode = Node( aNode , self.G.Verbose ) -# return myNode -# ErrMsg = "Failed to create a Node with Service " + aService.ServiceName -# if self.G.Verbose : -# print ErrMsg -# return aNode def PrintService( self , aComponent , anInterface , aService ): NodeComponent = modulecatalog.GetComponent( aComponent ) aService = NodeComponent.GetService( anInterface , aService ) @@ -798,8 +848,8 @@ class Graph(INode): return self.G.LevelMax() def ThreadsMax( self ): return self.G.ThreadsMax() - def GraphsNumber( self ): - return self.G.GraphsNumber() + def SubGraphsNumber( self ): + return self.G.SubGraphsNumber() def LevelNodes( self , aLevel ): nodes = self.G.LevelNodes( aLevel ) return self.nodesTuple( nodes ) @@ -944,18 +994,45 @@ class Graph(INode): def GLinks( self ): links = self.G.GLinks() i = 0 - while i < len( links ) : + linkslen = len( links ) + #print 'GLinks ',linkslen,'Links' + while i < linkslen : links[ i ] = Link( links[i] , self.G.Verbose ) i = i + 1 - return links + def GStreamLinks( self ): + streamlinks = self.G.GStreamLinks() + i = 0 + #print 'GStreamLinks ',len( streamlinks ),'StreamLinks' + while i < len( streamlinks ) : + streamlinks[ i ] = StreamLink( streamlinks[i] , self.G.Verbose ) + i = i + 1 + return streamlinks + def GAllLinks( self ) : + alllinks = self.G.GLinks() + lenlinks = len( alllinks ) + i = 0 + while i < lenlinks : + alllinks[ i ] = Link( alllinks[i] , self.N.Verbose ) + i = i + 1 + links = self.G.StreamLinks() + j = 0 + while j < len(links) : + alllinks.append( StreamLink( links[j] , self.N.Verbose ) ) + i = i + 1 + j = j + 1 + return alllinks def ListLinks( self , *args ): - links = self.G.GLinks() + links = self.GAllLinks() if len( links ) : - listoflinks = links[ 0 ].InPort().Node().Name() + listoflinks = 'L' + links[ 0 ].OutPort().Node().Name() + listoflinks = listoflinks + links[ 0 ].OutPort().Name() + listoflinks = listoflinks + links[ 0 ].InPort().Node().Name() listoflinks = listoflinks + links[ 0 ].InPort().Name() i = 1 while i < len( links ) : - listoflinks = listoflinks + ',' + links[ i ].InPort().Node().Name() + listoflinks = listoflinks + ',' + 'L' + links[ i ].OutPort().Node().Name() + listoflinks = listoflinks + links[ i ].OutPort().Name() + listoflinks = listoflinks + links[ i ].InPort().Node().Name() listoflinks = listoflinks + links[ i ].InPort().Name() i = i + 1 print listoflinks @@ -964,15 +1041,15 @@ class Graph(INode): else : aName = args[ 0 ] if len( links ) == 1 : - listoflinks = "[" + listoflinks + "] = " + aName + ".GLinks()" + listoflinks = "[" + listoflinks + "] = " + aName + ".GAllLinks()" else : - listoflinks = listoflinks + " = " + aName + ".GLinks()" + listoflinks = listoflinks + " = " + aName + ".GAllLinks()" return listoflinks def PrintLinks( self ): - links = self.G.GLinks() + links = self.GAllLinks() i = 0 while i < len( links ) : - Link( links[ i ] , self.G.Verbose ).Print() + links[ i ].Print() i = i + 1 def Graphs( self ): graphs = self.G.Graphs() @@ -992,6 +1069,14 @@ class Graph(INode): if self.G.Verbose : print ErrMsg return aCopy + def ToStreamGraph( self ): + aGraph = self.G.ToStreamGraph() + if aGraph != None : + return StreamGraph( aGraph ) + return None + def SubGraphsNodes( self , aSubGraphsNumber ): + nodes = self.G.SubGraphsNodes( aSubGraphsNumber ) + return self.nodesTuple( nodes ) def Merge( self , aGraph ): return self.G.Merge( aGraph.G ) def Destroy( self ): @@ -1006,6 +1091,72 @@ class GraphE(Graph): self.G.Verbose = 1 self.N = graph self.N.Verbose = 1 + def ToStreamGraph( self ): + aGraph = self.G.ToStreamGraph() + if aGraph != None : + return StreamGraphE( aGraph ) + return None + +########################################################## +class StreamGraph(Graph): +########################################################## + def __init__( self , aName ): + try: + graph = SuperVision.StreamGraph( aName ) + except: + try: + graph = aName.G.StreamCopy() + except: + graph = aName + if graph != None : + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 + else : + print "StreamGraph creation failed" + def StreamCopy( self ): + aCopy = self.G.StreamCopy() + if aCopy != None: + myCopy = StreamGraph( aCopy ) + return myCopy + ErrMsg = "Failed to get a Copy of " + self.G.Name() + if self.G.Verbose : + print ErrMsg + return aCopy + def StreamLink( self , anOutStreamPort , anInStreamPort ) : + aStreamLink = self.G.StreamLink( anOutStreamPort.P , anInStreamPort.P ) + if aStreamLink!= None: + myStreamLink = StreamLink( aStreamLink , self.G.Verbose ) + return myStreamLink + ErrMsg = "Failed to make a StreamLink in " + self.G.Name() + if self.G.Verbose : + print ErrMsg + return aStreamLink + def SetStreamParams( self , Timeout , DataStreamTrace , DeltaTime ): + return self.G.SetStreamParams( Timeout , DataStreamTrace , DeltaTime ) + def StreamParams( self ): + Timeout,DataStreamTrace,DeltaTime = self.G.StreamParams() + return Timeout,DataStreamTrace,DeltaTime + def ToFlowGraph( self ): + return self.G.ToFlowGraph() + def SubStreamGraphsNumber( self ): + return self.G.SubStreamGraphsNumber() + def SubStreamGraphsNodes( self , aSubStreamGraphsNumber ): + nodes = self.G.SubStreamGraphsNodes( aSubStreamGraphsNumber ) + return self.nodesTuple( nodes ) + def StreamMerge( self , aStreamGraph ): + return self.G.StreamMerge( aStreamGraph.G ) + +########################################################## +class StreamGraphE(StreamGraph): +########################################################## + def __init__( self , aName ): + graph = SuperVision.StreamGraphE( aName ) + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 ########################################################## class Value: @@ -1100,6 +1251,8 @@ class Port: return self.P.IsSwitch() def IsEndSwitch( self ): return self.P.IsEndSwitch() + def IsDataStream( self ): + return self.P.IsDataStream() # def IsBus( self ): # return self.P.IsBus() def Done( self ): @@ -1121,6 +1274,28 @@ class Port: def Destroy( self ): self.P.destroy() +########################################################## +class StreamPort(Port): +########################################################## + def __init__( self , aPort , Verbose ): + self.P = aPort + self.P.Verbose = Verbose + def StreamLink( self ) : + return self.P.StreamLink() + def Dependency( self ) : + return self.P.Dependency() + def SetDependency( self , aDependency ) : + return self.P.SetDependency( aDependency ) + def Params( self ) : + sts,aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation = self.P.Params() + return sts,aKindOfSchema,aKindOfInterpolation,aKindOfExtrapolation + def SetParams( self , aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) : + return self.P.SetParams( aKindOfSchema , aKindOfInterpolation , aKindOfExtrapolation ) + def NumberOfValues( self ) : + return self.P.NumberOfValues() + def SetNumberOfValues( self , aNumberOfValues ) : + return self.P.SetNumberOfValues( aNumberOfValues ) + ########################################################## class Link: ########################################################## @@ -1145,8 +1320,17 @@ class Link: return None def Print( self ): anOutPort = self.L.OutPort() + anOutPortName = anOutPort.Name() + anOutPortKind = anOutPort.Kind() + anOutPortValue = anOutPort.ToString() + anOutNode = anOutPort.Node() + anOutNodeName = anOutNode.Name() anInPort = self.L.InPort() - print anOutPort.Node().Name(),'(',anOutPort.Name(),' ',anOutPort.Kind(),') =',anOutPort.ToString(),' --> ',anInPort.Node().Name(),'(',anInPort.Name(),')',' ',anInPort.Kind() + anInPortName = anInPort.Name() + anInPortKind = anInPort.Kind() + anInNode = anInPort.Node() + anInNodeName = anInNode.Name() + print anOutNodeName,'(',anOutPortName,' ',anOutPortKind,') =',anOutPortValue,' --> ',anInNodeName,'(',anInPortName,')',' ',anInPortKind def CoordsSize( self ): return self.L.CoordsSize() def AddCoord( self , index , X , Y ): @@ -1161,3 +1345,26 @@ class Link: self.L.destroy() + +########################################################## +class StreamLink(Link): +########################################################## + def __init__( self , aLink , Verbose ): + self.L = aLink + self.L.Verbose = Verbose + def OutStreamPort( self ): + aPort = self.L.OutStreamPort() + if aPort != None : + myPort = StreamPort( aPort , self.L.Verbose ) + return myPort + if self.L.Verbose : + print "Error while getting the Port : " + return None + def InStreamPort( self ): + aPort = self.L.InStreamPort() + if aPort != None : + myPort = StreamPort( aPort , self.L.Verbose ) + return myPort + if self.L.Verbose : + print "Error while getting the Port : " + return None diff --git a/src/Supervision/SuperV_Impl.cxx b/src/Supervision/SuperV_Impl.cxx index 2c42ac0..f64b10f 100644 --- a/src/Supervision/SuperV_Impl.cxx +++ b/src/Supervision/SuperV_Impl.cxx @@ -241,7 +241,7 @@ char* SuperV_Impl::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, string aStr(myStrURL); aStr += myStudyName + string(aLocalPersistentID); - SUPERV::Graph_ptr graph = Graph(aStr.c_str()); + SUPERV::StreamGraph_ptr graph = StreamGraph(aStr.c_str()); if (graph->_is_nil()) THROW_SALOME_CORBA_EXCEPTION("Unable to find graph in the file",SALOME::BAD_PARAM); @@ -612,9 +612,10 @@ SUPERV::Value_ptr SuperV_Impl::Value( CORBA::Any * anAny ) { SUPERV::Graph_ptr SuperV_Impl::Graph(const char * aGraphName ) { beginService( "SuperV_Impl::Graph" ); bool created = true ; + SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; Graph_Impl * myGraph ; - myGraph = new Graph_Impl( _Orb , _Poa, _ContId, - instanceName() , interfaceName() , aGraphName ) ; + myGraph = new Graph_Impl( _Orb , _Poa, _ContId, instanceName() , interfaceName() , + aGraphName , SUPERV::DataFlowGraph ) ; int lenname = strlen( aGraphName ) ; if ( lenname > 4 && !strcmp( &aGraphName[ lenname - 4 ] , ".xml" ) ) { created = myGraph->Import( aGraphName ) ; @@ -622,8 +623,16 @@ SUPERV::Graph_ptr SuperV_Impl::Graph(const char * aGraphName ) { else { myGraph->Import( (char * ) NULL ) ; } - SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; - if ( created ) { + if ( !created && myGraph->IsStreamGraph() ) { + MESSAGE( "SuperV_Impl::Graph " << aGraphName << " IsStreamGraph !" ) ; + myGraph->destroy() ; + SUPERV::StreamGraph_var streamiobject = StreamGraph( aGraphName ) ; + iobject = SUPERV::Graph::_narrow( streamiobject ) ; + if ( CORBA::is_nil( iobject ) ) { + created = false ; + } + } + else if ( created ) { PortableServer::ObjectId * id = myGraph->getId() ; CORBA::Object_var obj = _poa->id_to_reference(*id); iobject = SUPERV::Graph::_narrow(obj) ; @@ -636,9 +645,10 @@ SUPERV::Graph_ptr SuperV_Impl::Graph(const char * aGraphName ) { SUPERV::Graph_ptr SuperV_Impl::GraphE(const char * aGraphName ) { beginService( "SuperV_Impl::GraphE" ); bool created = true ; + SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; Graph_Impl * myGraph ; - myGraph = new Graph_Impl( _Orb , _Poa, _ContId, - instanceName() , interfaceName() , aGraphName ) ; + myGraph = new Graph_Impl( _Orb , _Poa, _ContId, instanceName() , interfaceName() , + aGraphName , SUPERV::DataFlowGraph ) ; int lenname = strlen( aGraphName ) ; if ( lenname > 4 && !strcmp( &aGraphName[ lenname - 4 ] , ".xml" ) ) { created = myGraph->Import( aGraphName ) ; @@ -646,8 +656,15 @@ SUPERV::Graph_ptr SuperV_Impl::GraphE(const char * aGraphName ) { else { myGraph->Import( (char * ) NULL ) ; } - SUPERV::Graph_var iobject = SUPERV::Graph::_nil() ; - if ( created ) { + if ( !created && myGraph->IsStreamGraph() ) { + myGraph->destroy() ; + SUPERV::StreamGraph_var streamiobject = StreamGraphE( aGraphName ) ; + iobject = SUPERV::Graph::_narrow( streamiobject ) ; + if ( CORBA::is_nil( iobject ) ) { + created = false ; + } + } + else if ( created ) { PortableServer::ObjectId * id = myGraph->getId() ; CORBA::Object_var obj = _poa->id_to_reference(*id); iobject = SUPERV::Graph::_narrow(obj) ; @@ -658,6 +675,55 @@ SUPERV::Graph_ptr SuperV_Impl::GraphE(const char * aGraphName ) { return SUPERV::Graph::_duplicate(iobject) ; } +SUPERV::StreamGraph_ptr SuperV_Impl::StreamGraph(const char * aGraphName ) { + beginService( "SuperV_Impl::StreamGraph" ); + bool created = true ; + StreamGraph_Impl * myStreamGraph ; + myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId, instanceName() , + interfaceName() , aGraphName ) ; + int lenname = strlen( aGraphName ) ; + if ( lenname > 4 && !strcmp( &aGraphName[ lenname - 4 ] , ".xml" ) ) { + created = myStreamGraph->Import( aGraphName ) ; + } + else { + myStreamGraph->Import( (char * ) NULL ) ; + } + SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ; + if ( created ) { + PortableServer::ObjectId * id = myStreamGraph->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamGraph::_narrow(obj) ; + myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( iobject ) ) ; + } + endService( "SuperV_Impl::StreamGraph" ); + return SUPERV::StreamGraph::_duplicate(iobject) ; +} + +SUPERV::StreamGraph_ptr SuperV_Impl::StreamGraphE(const char * aGraphName ) { + beginService( "SuperV_Impl::StreamGraphE" ); + bool created = true ; + StreamGraph_Impl * myStreamGraph ; + myStreamGraph = new StreamGraph_Impl( _Orb , _Poa, _ContId, instanceName() , + interfaceName() , aGraphName ) ; + int lenname = strlen( aGraphName ) ; + if ( lenname > 4 && !strcmp( &aGraphName[ lenname - 4 ] , ".xml" ) ) { + created = myStreamGraph->Import( aGraphName ) ; + } + else { + myStreamGraph->Import( (char * ) NULL ) ; + } + SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil() ; + if ( created ) { + PortableServer::ObjectId * id = myStreamGraph->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SUPERV::StreamGraph::_narrow(obj) ; + myStreamGraph->SetObjRef( SUPERV::StreamGraph::_duplicate( iobject ) ) ; + } + myStreamGraph->ReadOnly() ; + endService( "SuperV_Impl::StreamGraphE" ); + return SUPERV::StreamGraph::_duplicate(iobject) ; +} + SUPERV::Graph_ptr SuperV_Impl::getGraph(const char* ior) { SUPERV::Graph_var iobject = SUPERV::Graph::_nil(); try { @@ -670,6 +736,18 @@ SUPERV::Graph_ptr SuperV_Impl::getGraph(const char* ior) { return(SUPERV::Graph::_duplicate(iobject)); } +SUPERV::StreamGraph_ptr SuperV_Impl::getStreamGraph(const char* ior) { + SUPERV::StreamGraph_var iobject = SUPERV::StreamGraph::_nil(); + try { + CORBA::Object_ptr obj = _Orb->string_to_object(ior); + iobject = SUPERV::StreamGraph::_narrow(obj); + } catch ( ... ) { + return SUPERV::StreamGraph::_nil(); + // SUPERV::Graph_var iobject = (SUPERV::Graph_var)NULL; + }; + return(SUPERV::StreamGraph::_duplicate(iobject)); +} + PortableServer::ObjectId * SUPERVEngine_factory ( CORBA::ORB_ptr orb , PortableServer::POA_ptr poa , diff --git a/src/Supervision/SuperV_Impl.hxx b/src/Supervision/SuperV_Impl.hxx index bce58f1..6cfb02f 100644 --- a/src/Supervision/SuperV_Impl.hxx +++ b/src/Supervision/SuperV_Impl.hxx @@ -38,7 +38,7 @@ #include "SALOME_Component_i.hxx" #include "SALOME_LifeCycleCORBA.hxx" -#include "Graph_Impl.hxx" +#include "StreamGraph_Impl.hxx" #include "DataFlowEditor_DataFlow.hxx" @@ -119,6 +119,11 @@ class SuperV_Impl : public POA_SUPERV::SuperG , virtual SUPERV::Graph_ptr GraphE( const char * aDataFlowName ) ; + virtual SUPERV::StreamGraph_ptr StreamGraph( const char * aDataFlowName ) ; + + virtual SUPERV::StreamGraph_ptr StreamGraphE( const char * aDataFlowName ) ; + + virtual SUPERV::StreamGraph_ptr getStreamGraph(const char* ior); virtual SUPERV::Graph_ptr getGraph(const char* ior); }; diff --git a/src/Supervision/Value_Impl.cxx b/src/Supervision/Value_Impl.cxx index 9544348..95a89a1 100644 --- a/src/Supervision/Value_Impl.cxx +++ b/src/Supervision/Value_Impl.cxx @@ -143,7 +143,7 @@ CORBA::Any * Value_Impl::ToAny() { name = _DataFlowNode->Name() ; } else { - name = _DataFlowEditor->Name() ; + name = _DataFlowEditor->Graph()->Name() ; } if ( _InputPort ) { if ( _DataFlowNode ) { @@ -191,7 +191,7 @@ CORBA::Any * Value_Impl::ToAny() { } char * Value_Impl::ToString() { - beginService( "Value_Impl::ToString" ); +// beginService( "Value_Impl::ToString" ); CORBA::Any anAny = *ToAny() ; // cout << "Value_Impl::ToString " << _DataFlowNode->Name() << " " // << _ParameterName << " " ; @@ -201,7 +201,7 @@ char * Value_Impl::ToString() { name = _DataFlowNode->Name() ; } else { - name = _DataFlowEditor->Name() ; + name = _DataFlowEditor->Graph()->Name() ; } if ( _InputPort ) { if ( _DataFlowNode ) { @@ -242,7 +242,7 @@ char * Value_Impl::ToString() { switch (anAny.type()->kind()) { case CORBA::tk_string: { anAny >>= retstr; - MESSAGE( "ToString( string ) '" << retstr << "'" ); +// MESSAGE( "ToString( string ) '" << retstr << "'" ); break ; } case CORBA::tk_long: { @@ -250,7 +250,7 @@ char * Value_Impl::ToString() { anAny >>= l; astr << l << ends ; retstr = astr.str().c_str() ; - MESSAGE( "ToString( long ) '" << l << " " << retstr << "'" ); +// MESSAGE( "ToString( long ) '" << l << " " << retstr << "'" ); break ; } case CORBA::tk_double: { @@ -262,7 +262,7 @@ char * Value_Impl::ToString() { while ( i < (int ) strlen( retstr ) && retstr[ i++ ] == ' ' ) { startstr = i ; } - MESSAGE( "ToString( double ) '" << d << "' '" << retstr << "' '" << &retstr[ startstr ] << "'"); +// MESSAGE( "ToString( double ) '" << d << "' '" << retstr << "' '" << &retstr[ startstr ] << "'"); break ; } case CORBA::tk_objref: { @@ -270,7 +270,7 @@ char * Value_Impl::ToString() { try { anAny >>= obj ; retstr = _Orb->object_to_string( obj ); - MESSAGE( "ToString( object ) '" << retstr << "'" ); +// MESSAGE( "ToString( object ) '" << retstr << "'" ); } catch ( ... ) { retstr = "object_to_string catched " ; @@ -283,7 +283,7 @@ char * Value_Impl::ToString() { break ; } } - endService( "Value_Impl::ToString" ); +// endService( "Value_Impl::ToString" ); return CORBA::string_dup( &retstr[ startstr ] ) ; } @@ -295,7 +295,7 @@ bool Value_Impl::IsIOR() { name = _DataFlowNode->Name() ; } else { - name = _DataFlowEditor->Name() ; + name = _DataFlowEditor->Graph()->Name() ; } if ( _InputPort ) { if ( _DataFlowNode ) { @@ -335,7 +335,7 @@ bool Value_Impl::IsIOR() { char* Value_Impl::ComponentDataType() { GraphExecutor::DataFlow* _DataFlowExecutor = _DataFlowEditor->Executor(); - const GraphBase::ComputingNode* node = _DataFlowExecutor->GetGraphNode(_DataFlowNode->Name()); + const GraphBase::ComputingNode* node = _DataFlowExecutor->Graph()->GetGraphNode(_DataFlowNode->Name()); if ( node->IsFactoryNode() ) { Engines::Component_var compo = ((GraphBase::FactoryNode * ) node )->Component(); if ( CORBA::is_nil( compo ) ) { diff --git a/src/SyrComponent/SyrComponent_Impl.cxx b/src/SyrComponent/SyrComponent_Impl.cxx new file mode 100755 index 0000000..3c93ed7 --- /dev/null +++ b/src/SyrComponent/SyrComponent_Impl.cxx @@ -0,0 +1,398 @@ +// SuperVisionTest SyrComponent : example of component performing some mathinatical operations +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SyrComponent_Impl.cxx +// Author : Jean Rahuel, CEA +// Module : SuperVisionTest + +using namespace std; +#include +#include +#include +#include +#include + +//#include "utilities.h" + +#include "SyrComponent_Impl.hxx" +#include "Adder_Impl.hxx" + +SyrComponent_Impl::SyrComponent_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char *instanceName , + const char *interfaceName , + const bool kactivate ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) { + MESSAGE("SyrComponent_Impl::SyrComponent_Impl this " << hex << this << dec + << "activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ")" ) + if ( kactivate ) { + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + } +} + +SyrComponent_Impl::SyrComponent_Impl() { +} + +SyrComponent_Impl::~SyrComponent_Impl() { +} + +long SyrComponent_Impl::C_ISEVEN( const long anInteger ) { + bool RetVal ; + beginService( " SyrComponent_Impl::C_ISEVEN" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_ISEVEN is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + RetVal = ( anInteger & 1 ) == 0 ; + endService( " SyrComponent_Impl::C_ISEVEN" ); + return RetVal ; +} + +long SyrComponent_Impl::C_ISONE( const long anOddInteger ) { + bool RetVal ; + beginService( " SyrComponent_Impl::C_ISONE" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_ISONE is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + RetVal = ( anOddInteger == 1 ) ; + endService( " SyrComponent_Impl::C_ISONE" ); + return RetVal ; +} + +long SyrComponent_Impl::C_M3( const long anOddInteger ) { + beginService( " SyrComponent_Impl::C_M3" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_M3 is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " SyrComponent_Impl::C_M3" ); + if ( C_ISEVEN( anOddInteger ) ) + return 0 ; + return ( 3*anOddInteger ) ; +} + +long SyrComponent_Impl::C_M3P1( const long anOddInteger ) { + beginService( " SyrComponent_Impl::C_M3P1" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_M3P1 is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " SyrComponent_Impl::C_M3P1" ); + if ( C_ISEVEN( anOddInteger ) ) + return 0 ; + return ( 3*anOddInteger + 1 ) ; +} + +long SyrComponent_Impl::C_DIV2( const long anEvenInteger ) { + beginService( " SyrComponent_Impl::C_DIV2" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_DIV2 is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " SyrComponent_Impl::C_DIV2" ); + if ( !C_ISEVEN( anEvenInteger ) ) + return 0 ; + return ( anEvenInteger >> 1 ) ; +} + +long SyrComponent_Impl::C_INCR( const long aCount ) { + beginService( " SyrComponent_Impl::C_INCR" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_INCR is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " SyrComponent_Impl::C_INCR" ); + return ( aCount + 1 ) ; +} + +long SyrComponent_Impl::C_MIN( const long aMinVal , const long anInteger ) { + beginService( " SyrComponent_Impl::C_MIN" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_MIN is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + int min = aMinVal ; + if ( anInteger < min || aMinVal == 0 ) { + min = anInteger ; + } + string trace = "SyrComponent_Impl::C_MIN : " ; + char cmin[ 30 ] ; + sprintf( cmin , "%d" , min ) ; + trace += cmin ; + sendMessage(NOTIF_TRACE, trace.c_str() ); + endService( " SyrComponent_Impl::C_MIN" ); + return min ; +} + +long SyrComponent_Impl::C_MAX( const long aMaxVal , const long anInteger ) { + beginService( " SyrComponent_Impl::C_MAX" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_MAX is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + int max = aMaxVal ; + if ( anInteger > max ) { + max = anInteger ; + } + string trace = "SyrComponent_Impl::C_MAX : " ; + char cmax[ 30 ] ; + sprintf( cmax , "%d" , max ) ; + trace += cmax ; + sendMessage(NOTIF_TRACE, trace.c_str() ); + endService( " SyrComponent_Impl::C_MAX" ); + return max ; +} + +SuperVisionTest::ListOfSyr_ptr SyrComponent_Impl::C_LISTOFSYR() { + beginService( " SyrComponent_Impl::C_LISTOFSYR" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_LISTOFSYR is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + ListOfSyr_Impl * aNewListOfSyr = new ListOfSyr_Impl( _orb , _poa, _contId, + instanceName() , interfaceName() , + graphName() , nodeName() ) ; + SuperVisionTest::ListOfSyr_var iobject = (SuperVisionTest::ListOfSyr_var ) NULL ; + PortableServer::ObjectId * id = aNewListOfSyr->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SuperVisionTest::ListOfSyr::_narrow(obj) ; + endService( " SyrComponent_Impl::C_LISTOFSYR" ); + return SuperVisionTest::ListOfSyr::_duplicate( iobject ) ; +// return ( aNewListOfSyr._retn() ) ; +} + +SuperVisionTest::ListOfSyr_ptr SyrComponent_Impl::C_AVERAGE( + const SuperVisionTest::ListOfSyr_ptr aListOfSyr , + const long anInteger , + const long aCount , + double & anAverage ) { + beginService( " SyrComponent_Impl::C_AVERAGE" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl::C_AVERAGE is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + SuperVisionTest::SeqOfSyr * aSeqOfSyr = aListOfSyr->GetSeqOfSyr() ; + int len = aSeqOfSyr->length() ; + aSeqOfSyr->length( len + 1 ) ; + (*aSeqOfSyr)[ len ] = anInteger ; + aListOfSyr->SetSeqOfSyr( *aSeqOfSyr ) ; + anAverage = 0 ; + int i ; + for ( i = 0 ; i < len + 1 ; i++ ) { + anAverage += (*aSeqOfSyr)[ i ] ; + } + anAverage = anAverage / ( len + 1 ) ; + string end = " SyrComponent_Impl::C_AVERAGE " ; + char caverage[ 30 ] ; + sprintf( caverage , "%fd" , anAverage ) ; + end += caverage ; + endService( end.c_str() ); + return SuperVisionTest::ListOfSyr::_duplicate( aListOfSyr ) ; +} + +SuperVisionTest::Syr_ptr SyrComponent_Impl::Init( const long anOddInteger ) { + beginService( "SyrComponent_Impl::Init" ); + sendMessage(NOTIF_STEP, "SyrComponent_Impl creates Syr_Impl"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + Syr_Impl * mySyr ; + mySyr = new Syr_Impl( _orb , _poa, _contId, + instanceName() , interfaceName() , + graphName() , nodeName() , anOddInteger ) ; + SuperVisionTest::Syr_var iobject = (SuperVisionTest::Syr_var ) NULL ; + PortableServer::ObjectId * id = mySyr->getId() ; + CORBA::Object_var obj = _poa->id_to_reference(*id); + iobject = SuperVisionTest::Syr::_narrow(obj) ; + endService( "SyrComponent_Impl::Init" ); + return SuperVisionTest::Syr::_duplicate(iobject) ; +} + +ListOfSyr_Impl::ListOfSyr_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char * instanceName , + const char * interfaceName , + const char * graphName , + const char * nodeName ) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName,1,true) { + Names( graphName , nodeName ) ; + MESSAGE("ListOfSyr_Impl::ListOfSyr_Impl activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ") --> " + << hex << (void *) this << dec ) + beginService( "ListOfSyr_Impl::ListOfSyr_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + sendMessage(NOTIF_STEP, "ListOfSyr_Impl is Created"); + endService( "ListOfSyr_Impl::ListOfSyr_Impl" ); +} + +ListOfSyr_Impl::ListOfSyr_Impl() { +} + +ListOfSyr_Impl::~ListOfSyr_Impl() { + beginService( "ListOfSyr_Impl::~ListOfSyr_Impl" ); + endService( "ListOfSyr_Impl::~ListOfSyr_Impl" ); +} + +SuperVisionTest::SeqOfSyr * ListOfSyr_Impl::GetSeqOfSyr() { + SuperVisionTest::SeqOfSyr_var aSeqOfSyr = new SuperVisionTest::SeqOfSyr( _SeqOfSyr ) ; + return ( aSeqOfSyr._retn() ) ; +} + +void ListOfSyr_Impl::SetSeqOfSyr( const SuperVisionTest::SeqOfSyr & aSeqOfSyr ) { + _SeqOfSyr = aSeqOfSyr ; + return ; +} + +extern "C" +{ + PortableServer::ObjectId * SyrComponentEngine_factory + (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("SyrComponentEngine_factory SyrComponentEngine (" + << instanceName << "," << interfaceName << "," << getpid() << ")"); + SyrComponent_Impl * mySyrComponent + = new SyrComponent_Impl(orb, poa, contId, instanceName, interfaceName); + return mySyrComponent->getId() ; + } +} + +Syr_Impl::Syr_Impl( CORBA::ORB_ptr orb , + PortableServer::POA_ptr poa , + PortableServer::ObjectId * contId , + const char * instanceName , + const char * interfaceName , + const char * graphName , + const char * nodeName , + const long anOddInteger ) : + SyrComponent_Impl(orb, poa, contId, instanceName, interfaceName,false) { + Names( graphName , nodeName ) ; + MESSAGE("Syr_Impl::Syr_Impl activate object instanceName(" + << instanceName << ") interfaceName(" << interfaceName << ") --> " + << hex << (void *) this << dec ) + beginService( "Syr_Impl::Syr_Impl" ); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + _InitialInteger = anOddInteger ; + _CurrentInteger = anOddInteger ; + _Count = 0 ; + sendMessage(NOTIF_STEP, "Syr_Impl is Created"); + endService( "Syr_Impl::Syr_Impl" ); +} + +Syr_Impl::Syr_Impl() { +} + +Syr_Impl::~Syr_Impl() { + beginService( "Syr_Impl::~Syr_Impl" ); + endService( "Syr_Impl::~Syr_Impl" ); +} + +long Syr_Impl::Initial() { + beginService( " Syr_Impl::Initial" ); + sendMessage(NOTIF_STEP, "Syr_Impl::Initial is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " Syr_Impl::Initial" ); + return _InitialInteger ; +} + +long Syr_Impl::Current() { + beginService( " Syr_Impl::Current" ); + sendMessage(NOTIF_STEP, "Syr_Impl::Current is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + endService( " Syr_Impl::Current" ); + return _CurrentInteger ; +} + +long Syr_Impl::IsEven() { + bool RetVal ; + beginService( " Syr_Impl::IsEven" ); + sendMessage(NOTIF_STEP, "Syr_Impl::IsEven is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + RetVal = ( _CurrentInteger & 1 ) == 0 ; + MESSAGE( " Syr_Impl::IsEven " << _CurrentInteger << " " << RetVal ); + endService( " Syr_Impl::IsEven" ); + return RetVal ; +} + +long Syr_Impl::IsOne() { + bool RetVal ; + beginService( " Syr_Impl::IsOne" ); + sendMessage(NOTIF_STEP, "Syr_Impl::IsOne is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + RetVal = ( _CurrentInteger == 1 ) ; + MESSAGE( " Syr_Impl::IsOne " << _CurrentInteger << " " << RetVal ); + endService( " Syr_Impl::IsOne" ); + return RetVal ; +} + +long Syr_Impl::Count() { + beginService( " Syr_Impl::Count" ); + sendMessage(NOTIF_STEP, "Syr_Impl::Count is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + MESSAGE( " Syr_Impl::Count " << _Count ); + endService( " Syr_Impl::Count" ); + return _Count ; +} + +void Syr_Impl::M3p1() { + beginService( " Syr_Impl::M3p1" ); + sendMessage(NOTIF_STEP, "Syr_Impl::M3p1 is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + if ( IsEven() ) + _CurrentInteger = 0 ; + else + _CurrentInteger = 3*_CurrentInteger + 1 ; + MESSAGE( " Syr_Impl::M3p1 " << _CurrentInteger ); + endService( " Syr_Impl::M3p1" ); +} + +void Syr_Impl::Div2() { + beginService( " Syr_Impl::Div2" ); + sendMessage(NOTIF_STEP, "Syr_Impl::Div2 is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + if ( !IsEven() ) + _CurrentInteger = 0 ; + else + _CurrentInteger = ( _CurrentInteger >> 1 ) ; + MESSAGE( " Syr_Impl::Div2 " << _CurrentInteger ); + endService( " Syr_Impl::Div2" ); +} + +void Syr_Impl::Incr() { + beginService( " Syr_Impl::Incr" ); + sendMessage(NOTIF_STEP, "Syr_Impl::Incr is Computing"); + int S = 1+(int) (2.0*rand()/(RAND_MAX+1.0)); + sleep(S); + _Count = _Count + 1 ; + MESSAGE( " Syr_Impl::Incr " << _Count ); + endService( " Syr_Impl::Incr" ); +} + + +