From a70632f2ec3c13e767152b77768f386177e91b25 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 9 Aug 2012 14:08:07 +0000 Subject: [PATCH] Merge from V6_main_20120808 08Aug12 --- Examples/ast1/Makefile | 21 + Examples/ast1/README.txt | 9 +- Examples/ast1/components.py | 32 +- Examples/ast1/fcompo/Makefile | 25 +- Examples/ast1/fcompo/compo.f | 19 + Examples/ast1/myaster/Makefile | 45 +- Examples/ast1/myaster/make_cata | 21 +- Examples/ast2/Makefile | 21 + Examples/ast2/README.txt | 20 +- Examples/ast2/components.py | 46 +- Examples/ast2/coupling.xml | 329 +++++----- Examples/ast2/coupling2.xml | 77 +++ Examples/ast2/exeaster | 55 ++ Examples/ast2/f.comm | 2 + Examples/ast2/fcompo/Makefile | 25 +- Examples/ast2/fcompo/compo.f | 19 + Examples/ast2/myaster/Makefile | 25 +- Examples/ast2/myaster/config.txt | 105 ++-- Examples/ast2/myaster/make_exec | 24 +- Examples/ast2/myaster/src/op0189.f | 4 +- Examples/calcium1/Makefile | 30 + Examples/calcium1/code1.f | 270 ++++++++ Examples/calcium1/components.py | 465 ++++++++++++++ Examples/calcium1/coupling.xml | 249 ++++++++ Examples/calcium2/Makefile | 30 + Examples/calcium2/code1.f | 272 ++++++++ Examples/calcium2/components.py | 463 ++++++++++++++ Examples/calcium2/coupling.xml | 249 ++++++++ Examples/context.py | 41 ++ Examples/cpp1/Makefile | 21 + Examples/cpp1/README.txt | 6 +- Examples/cpp1/components.py | 30 +- Examples/cpp1/coupling.xml | 134 ++-- Examples/cpp2/Makefile | 22 +- Examples/cpp2/README.txt | 10 +- Examples/cpp2/components.py | 30 +- Examples/cpp2/prog.cxx | 18 + Examples/cppgui1/Makefile | 21 + Examples/cppgui1/components.py | 127 ++++ Examples/cppgui1/cppcompos.png | Bin 0 -> 831 bytes Examples/cppgui1/cppcomposGUI.cxx | 163 +++++ Examples/cppgui1/cppcomposGUI.h | 58 ++ Examples/cppgui1/demo.ui | 146 +++++ Examples/cppgui1/exec.png | Bin 0 -> 831 bytes Examples/cppgui1/index.rst | 23 + Examples/cppgui1/myinterface.idl | 27 + Examples/cppgui1/using.rst | 17 + Examples/fort1/Makefile | 32 +- Examples/fort1/README.txt | 7 +- Examples/fort1/bidul.f | 19 + Examples/fort1/code1.f | 19 + Examples/fort1/code2.f | 19 + Examples/fort1/components.py | 34 +- Examples/fort1/coupling.xml | 124 ++-- Examples/fort2/Makefile | 28 +- Examples/fort2/README.txt | 11 +- Examples/fort2/code1.f | 19 + Examples/fort2/code2.f | 19 + Examples/fort2/components.py | 33 +- Examples/fort2/prog1.sh | 7 + Examples/fort2/prog2.sh | 7 + Examples/hxx1/Makefile | 21 + Examples/hxx1/README | 23 + Examples/hxx1/component.py | 88 +++ Examples/hxx1/cpp_component.tgz | Bin 0 -> 20078 bytes Examples/hxx1/test_compohxx.py | 129 ++++ Examples/makefile.inc | 26 + Examples/paco1/Makefile | 21 + Examples/paco1/README.txt | 26 + Examples/paco1/components.py | 51 ++ Examples/paco1/coupling.xml | 34 + Examples/paco2/Makefile | 21 + Examples/paco2/README.txt | 25 + Examples/paco2/components.py | 51 ++ Examples/paco2/coupling.xml | 34 + Examples/paco3/Makefile | 21 + Examples/paco3/README.txt | 25 + Examples/paco3/components.py | 96 +++ Examples/paco3/coupling.xml | 52 ++ Examples/pacocontext.py | 40 ++ Examples/pydoc1/Makefile | 21 + Examples/pydoc1/components.py | 55 ++ Examples/pydoc1/exec.png | Bin 0 -> 831 bytes Examples/pydoc1/index.rst | 23 + Examples/pydoc1/using.rst | 20 + Examples/pygui1/Makefile | 21 + Examples/pygui1/README.txt | 19 + Examples/pygui1/components.py | 118 ++++ Examples/pygui1/demo.ui | 146 +++++ Examples/pygui1/exec.png | Bin 0 -> 831 bytes Examples/pygui1/index.rst | 23 + Examples/pygui1/myinterface.idl | 27 + Examples/pygui1/pycompos.png | Bin 0 -> 831 bytes Examples/pygui1/pycomposGUI.py | 144 +++++ Examples/pygui1/using.rst | 20 + Examples/pyth1/Makefile | 21 + Examples/pyth1/README.txt | 6 +- Examples/pyth1/bidul.py | 19 + Examples/pyth1/components.py | 30 +- Examples/pyth1/coupling.xml | 138 ++-- Examples/pyth2/Makefile | 21 + Examples/pyth2/README.txt | 6 +- Examples/pyth2/components.py | 29 +- Examples/types1/Makefile | 21 + Examples/types1/README.txt | 25 + Examples/types1/components.py | 230 +++++++ Examples/types1/coupling.xml | 434 +++++++++++++ Examples/types1/geom_coupling.xml | 93 +++ Examples/types1/geom_coupling_compo2.xml | 93 +++ MANIFEST.in | 53 +- module_generator/__init__.py | 30 +- module_generator/astcompo.py | 293 ++++++--- module_generator/aster_tmpl.py | 128 ++-- module_generator/cata_tmpl.py | 132 +++- module_generator/compat.py | 324 +++++----- module_generator/cpp_tmpl.py | 116 ++-- module_generator/cppcompo.py | 158 ++++- module_generator/doc_tmpl.py | 292 +++++++++ module_generator/fcompo.py | 56 +- module_generator/gener.py | 762 ++++++++++++++++++++--- module_generator/gui_tmpl.py | 97 +++ module_generator/hxx_awk.py | 500 +++++++++++++++ module_generator/hxx_para_tmpl.py | 214 +++++++ module_generator/hxx_tmpl.py | 188 ++++++ module_generator/hxx_tmpl_gui.py | 602 ++++++++++++++++++ module_generator/hxxcompo.py | 479 ++++++++++++++ module_generator/hxxparacompo.py | 439 +++++++++++++ module_generator/mod_tmpl.py | 125 +++- module_generator/paco_tmpl.py | 421 +++++++++++++ module_generator/pacocompo.py | 167 +++++ module_generator/pycompo.py | 146 ++++- module_generator/pyth_tmpl.py | 48 +- module_generator/salomemodules.py | 140 +++++ module_generator/yacstypes.py | 138 ++++ script/hxx2salome.py | 197 ++++++ setup.py | 22 +- 136 files changed, 11980 insertions(+), 1098 deletions(-) create mode 100644 Examples/ast1/Makefile create mode 100644 Examples/ast2/Makefile create mode 100644 Examples/ast2/coupling2.xml create mode 100755 Examples/ast2/exeaster create mode 100644 Examples/calcium1/Makefile create mode 100644 Examples/calcium1/code1.f create mode 100644 Examples/calcium1/components.py create mode 100644 Examples/calcium1/coupling.xml create mode 100644 Examples/calcium2/Makefile create mode 100644 Examples/calcium2/code1.f create mode 100644 Examples/calcium2/components.py create mode 100644 Examples/calcium2/coupling.xml create mode 100644 Examples/context.py create mode 100644 Examples/cpp1/Makefile create mode 100644 Examples/cppgui1/Makefile create mode 100644 Examples/cppgui1/components.py create mode 100644 Examples/cppgui1/cppcompos.png create mode 100644 Examples/cppgui1/cppcomposGUI.cxx create mode 100644 Examples/cppgui1/cppcomposGUI.h create mode 100644 Examples/cppgui1/demo.ui create mode 100644 Examples/cppgui1/exec.png create mode 100644 Examples/cppgui1/index.rst create mode 100644 Examples/cppgui1/myinterface.idl create mode 100644 Examples/cppgui1/using.rst create mode 100755 Examples/fort2/prog1.sh create mode 100755 Examples/fort2/prog2.sh create mode 100644 Examples/hxx1/Makefile create mode 100644 Examples/hxx1/README create mode 100644 Examples/hxx1/component.py create mode 100644 Examples/hxx1/cpp_component.tgz create mode 100644 Examples/hxx1/test_compohxx.py create mode 100644 Examples/makefile.inc create mode 100644 Examples/paco1/Makefile create mode 100644 Examples/paco1/README.txt create mode 100644 Examples/paco1/components.py create mode 100644 Examples/paco1/coupling.xml create mode 100644 Examples/paco2/Makefile create mode 100644 Examples/paco2/README.txt create mode 100644 Examples/paco2/components.py create mode 100644 Examples/paco2/coupling.xml create mode 100644 Examples/paco3/Makefile create mode 100644 Examples/paco3/README.txt create mode 100644 Examples/paco3/components.py create mode 100644 Examples/paco3/coupling.xml create mode 100644 Examples/pacocontext.py create mode 100644 Examples/pydoc1/Makefile create mode 100644 Examples/pydoc1/components.py create mode 100644 Examples/pydoc1/exec.png create mode 100644 Examples/pydoc1/index.rst create mode 100644 Examples/pydoc1/using.rst create mode 100644 Examples/pygui1/Makefile create mode 100644 Examples/pygui1/README.txt create mode 100644 Examples/pygui1/components.py create mode 100644 Examples/pygui1/demo.ui create mode 100644 Examples/pygui1/exec.png create mode 100644 Examples/pygui1/index.rst create mode 100644 Examples/pygui1/myinterface.idl create mode 100644 Examples/pygui1/pycompos.png create mode 100644 Examples/pygui1/pycomposGUI.py create mode 100644 Examples/pygui1/using.rst create mode 100644 Examples/pyth1/Makefile create mode 100644 Examples/pyth2/Makefile create mode 100644 Examples/types1/Makefile create mode 100644 Examples/types1/README.txt create mode 100644 Examples/types1/components.py create mode 100644 Examples/types1/coupling.xml create mode 100644 Examples/types1/geom_coupling.xml create mode 100644 Examples/types1/geom_coupling_compo2.xml create mode 100644 module_generator/doc_tmpl.py create mode 100644 module_generator/gui_tmpl.py create mode 100644 module_generator/hxx_awk.py create mode 100644 module_generator/hxx_para_tmpl.py create mode 100644 module_generator/hxx_tmpl.py create mode 100644 module_generator/hxx_tmpl_gui.py create mode 100644 module_generator/hxxcompo.py create mode 100644 module_generator/hxxparacompo.py create mode 100644 module_generator/paco_tmpl.py create mode 100644 module_generator/pacocompo.py create mode 100644 module_generator/salomemodules.py create mode 100644 module_generator/yacstypes.py create mode 100755 script/hxx2salome.py diff --git a/Examples/ast1/Makefile b/Examples/ast1/Makefile new file mode 100644 index 0000000..02a8472 --- /dev/null +++ b/Examples/ast1/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so *.pyc astmod_SRC astmod_SRC.bak appli appli.bak install install.bak traceExec_proc diff --git a/Examples/ast1/README.txt b/Examples/ast1/README.txt index 6feb349..e694f3e 100644 --- a/Examples/ast1/README.txt +++ b/Examples/ast1/README.txt @@ -1,14 +1,15 @@ A Code_Aster component dynamically loadable =============================================== -To build this example, modify the files components.py, fcompo/Makefile, myaster/Makefile +To build this example, modify the files ../context.py, ../makefile.inc, fcompo/Makefile, myaster/Makefile to take into account your configuration. 1- your prerequisite file 2- your KERNEL_ROOT_DIR 3- your Code_Aster installation +4- your FORTRAN compiler -Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here):: source @@ -26,8 +27,8 @@ process components.py :: python components.py -You should get a SALOME module in source form (pycompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and pycompos. +You should get a SALOME module in source form (astmod_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module astmod. To run a coupling: diff --git a/Examples/ast1/components.py b/Examples/ast1/components.py index 9c7847c..65ff54f 100644 --- a/Examples/ast1/components.py +++ b/Examples/ast1/components.py @@ -1,12 +1,32 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + """ Example with one Code_Aster component and one fortran component """ import os + +#import context from .. +execfile("../context.py") from module_generator import Generator,Module,ASTERComponent,Service,F77Component -context={'update':1,"prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5"} -aster_root="/local/chris/ASTER/instals/NEW9" +aster_root=os.path.join(aster_home,aster_version) libfcompodir=os.path.join(os.getcwd(),"fcompo") myasterdir=os.path.join(os.getcwd(),"myaster","bibpyt") @@ -26,9 +46,9 @@ c1=ASTERComponent("caster",services=[ ], aster_dir=aster_root, python_path=[myasterdir], - argv=["-memjeveux","4",'-rep_outils','/local/chris/ASTER/instals/outils'], + argv=["-memjeveux","4",'-rep_outils',os.path.join(aster_home,'outils')], ) - + c2=F77Component("cfort",services=[ Service("s1",inport=[("a","double"),("b","long"),("c","string")], outport=[("d","double"),("e","long"),("f","string")], @@ -49,4 +69,4 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli(appli_dir,restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/ast1/fcompo/Makefile b/Examples/ast1/fcompo/Makefile index ce601fe..5055ce6 100644 --- a/Examples/ast1/fcompo/Makefile +++ b/Examples/ast1/fcompo/Makefile @@ -1,15 +1,32 @@ -FC=g77 +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# -KERNEL_ROOT_DIR=/local/chris/SALOME2/RELEASES/Install/KERNEL_V5 +include ../../makefile.inc KERNEL_LIBS= -L$(KERNEL_ROOT_DIR)/lib/salome -lCalciumC -lSalomeDSCSuperv -lSalomeDSCContainer -lSalomeDatastream -lSalomeDSCSupervBasic all: libfcompo.so libfcompo.so:compo.o - $(FC) -shared -o libfcompo.so compo.o ${KERNEL_LIBS} -Wl,--rpath -Wl,$(KERNEL_ROOT_DIR)/lib/salome -fexceptions + $(FC) -shared -fPIC -o libfcompo.so compo.o ${KERNEL_LIBS} -Wl,--rpath -Wl,$(KERNEL_ROOT_DIR)/lib/salome -fexceptions compo.o:compo.f - $(FC) -c compo.f -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions + $(FC) -c compo.f -fPIC -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions clean: rm -f *.o *.so diff --git a/Examples/ast1/fcompo/compo.f b/Examples/ast1/fcompo/compo.f index 7abff52..f0fa234 100644 --- a/Examples/ast1/fcompo/compo.f +++ b/Examples/ast1/fcompo/compo.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + SUBROUTINE S1(compo,A,B,C,D,E,F) include 'calcium.hf' integer compo diff --git a/Examples/ast1/myaster/Makefile b/Examples/ast1/myaster/Makefile index 4419fdb..e3dd382 100644 --- a/Examples/ast1/myaster/Makefile +++ b/Examples/ast1/myaster/Makefile @@ -1,25 +1,44 @@ -#ASTER -ASTER_ROOT=/local/chris/ASTER/instals -#SALOME -KERNEL_ROOT_DIR=/local/chris/SALOME2/RELEASES/Install/KERNEL_V5 +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +include ../../makefile.inc -ASTER_INSTALL=$(ASTER_ROOT)/NEW9 +ASTER_INSTALL=$(ASTER_ROOT)/$(ASTER_VERSION) ASTER_PUB=$(ASTER_ROOT)/public ASTER_OUTILS=$(ASTER_ROOT)/outils +MUMPS=-L$(ASTER_PUB)/mumps-4.9.2/lib -ldmumps -lzmumps -lsmumps -lcmumps -lmumps_common -lpord -lmpiseq +METIS=-L$(ASTER_PUB)/metis-4.0/lib -lmetis + + ASTER_LIBS = -L$(ASTER_INSTALL)/lib -laster \ - -L$(ASTER_PUB)/scotch_4.0/bin -lscotch -lscotcherr \ - -L/local/chris/pkg/med23/install/lib -lmed \ + $(MUMPS) $(METIS) \ + -L$(MED2HOME)/lib -lmed \ -lferm -llapack -lhdf5 KERNEL_INCLUDES=-I$(KERNEL_ROOT_DIR)/include/salome KERNEL_LIBS= -L$(KERNEL_ROOT_DIR)/lib/salome -lCalciumC -lSalomeDSCSuperv -lSalomeDSCContainer \ -lSalomeDatastream -lSalomeDSCSupervBasic -Wl,--rpath -Wl,$(KERNEL_ROOT_DIR)/lib/salome -FC=g77 -LD=g77 -FFLAGS= +FC=gfortran +LD=gfortran +FFLAGS=-fopenmp -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 CC=gcc SOURCES= src/op0078.f src/op0189.f src/op0181.f OBJETS=op0078.o op0189.o op0181.o @@ -35,7 +54,7 @@ cata: commande/cata.py cp -rf commande/cata.py* bibpyt/Cata commande/cata.py:$(CATAPY) - ./make_cata $(ASTER_ROOT)/ASTK/ASTK_SERV/bin/as_run + ./make_cata $(ASTER_ROOT)/bin/as_run $(ASTER_VERSION) astermodule:astermodule.so pyth cp -rf astermodule.so bibpyt @@ -47,6 +66,6 @@ op0189.o:src/op0189.f op0181.o:src/op0181.f $(FC) -c -fpic $(FFLAGS) $(KERNEL_INCLUDES) src/op0181.f astermodule.so: $(OBJETS) - $(LD) -shared -o $@ $(OBJETS) $(KERNEL_LIBS) $(ASTER_LIBS) + $(LD) -shared $(FFLAGS) -o $@ $(OBJETS) $(KERNEL_LIBS) $(ASTER_LIBS) clean: - rm -rf *.o *.so bibpyt commande/cata.py* + rm -rf *.o *.so bibpyt commande/cata.py* make-cmd commande diff --git a/Examples/ast1/myaster/make_cata b/Examples/ast1/myaster/make_cata index 37ef2fe..09f2be6 100755 --- a/Examples/ast1/myaster/make_cata +++ b/Examples/ast1/myaster/make_cata @@ -1,8 +1,27 @@ #!/bin/sh +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + cat >make-cmd << END P debug nodebug P mode interactif -P version NEW9 +P version $2 P ncpus 1 A args A memjeveux 16.0 diff --git a/Examples/ast2/Makefile b/Examples/ast2/Makefile new file mode 100644 index 0000000..013cda0 --- /dev/null +++ b/Examples/ast2/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so *.pyc astmod_SRC astmod_SRC.bak appli appli.bak install install.bak traceExec_proc caster_inst_1 cfort_inst_1 monfichier diff --git a/Examples/ast2/README.txt b/Examples/ast2/README.txt index d117e11..08b30cb 100644 --- a/Examples/ast2/README.txt +++ b/Examples/ast2/README.txt @@ -1,14 +1,15 @@ A Code_Aster standalone component (in executable form) =========================================================== -To build this example, modify the files components.py, fcompo/Makefile, myaster/config.txt, myaster/Makefile +To build this example, modify the files ../context.py, ../makefile.inc, fcompo/Makefile, myaster/config.txt, myaster/Makefile to take into account your configuration. 1- your prerequisite file 2- your KERNEL_ROOT_DIR 3- your Code_Aster installation +4- your FORTRAN compiler -Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here):: source @@ -16,24 +17,27 @@ process components.py :: python components.py -You should get a SALOME module in source form (pycompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and pycompos. +You should get a SALOME module in source form (astmod_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module astmod_SRC. -Build the fcompo library :: +Build the fcompo executable, under the SALOME application environment:: cd fcompo - make + ../appli/runSession make -Build the Code_Aster library :: +Build the Code_Aster executable :: cd myaster + modify the config.txt for your SALOME Installation make +Modify the exeaster script that drives the ASTER execution (change the files path) + To run a coupling: 1. start SALOME in background : ./appli/runAppli -t 2. start a SALOME session : ./appli/runSession 3. start YACS coupler with coupling file : driver coupling.xml 4. examine output files in /tmp - 5. shutdown SALOME : shutdowSalome.py + 5. shutdown SALOME : shutdownSalome.py 6. exit session : CTRL-D (or exit) diff --git a/Examples/ast2/components.py b/Examples/ast2/components.py index 5f26dc7..d50a6f0 100644 --- a/Examples/ast2/components.py +++ b/Examples/ast2/components.py @@ -1,25 +1,40 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + """ Example with one Code_Aster component and one fortran component """ import os + +#import context from .. +execfile("../context.py") from module_generator import Generator,Module,ASTERComponent,Service,F77Component -context={'update':1,"prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5"} -aster_home="/local/chris/ASTER/instals" -aster_root=os.path.join(aster_home,"NEW9") -asrun=os.path.join(aster_home,"ASTK/ASTK_SERV/bin/as_run") +aster_root=os.path.join(aster_home,aster_version) fcompodir=os.path.join(os.getcwd(),"fcompo") -myasterdir=os.path.join(os.getcwd(),"myaster","bibpyt") + install_prefix="./install" appli_dir="appli" -export="""F exec %s D 0 -R cmde %s D 0 -""" % (os.path.join(os.getcwd(),"myaster","aster.exe"),os.path.join(os.getcwd(),"myaster","commande")) c1=ASTERComponent("caster",services=[ - Service("s1",inport=[("argv","string"),("a","double"),("b","long"),("c","string")], + Service("s1",inport=[("jdc","file"),("a","double"),("b","long"),("c","string")], outport=[("d","double")], instream=[("aa","CALCIUM_double","T"),("ab","CALCIUM_double","I"), ("ac","CALCIUM_integer","I"),("ad","CALCIUM_real","I"), @@ -28,14 +43,15 @@ c1=ASTERComponent("caster",services=[ ], outstream=[("ba","CALCIUM_double","T"),("bb","CALCIUM_double","I")], ), + Service("s2",inport=[("a","double"),], + outport=[("d","double")], + ), ], aster_dir=aster_root, - exe_path=os.path.join(os.getcwd(),"exeaster"), - asrun=asrun, kind="exe", - export_extras=export, + exe_path=os.path.join(os.getcwd(),"exeaster"), ) - + c2=F77Component("cfort",services=[ Service("s1",inport=[("a","double"),("b","long"),("c","string")], outport=[("d","double"),("e","long"),("f","string")], @@ -58,4 +74,4 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli(appli_dir,restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/ast2/coupling.xml b/Examples/ast2/coupling.xml index 95d944c..0a541cb 100644 --- a/Examples/ast2/coupling.xml +++ b/Examples/ast2/coupling.xml @@ -1,167 +1,164 @@ - - - - - - - - - - - 23 - - - - - caster - s1 - - - - - - - - - - - - - - - - - - - - - cfort - s1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -node1ba -node2a - - -node1bb -node2b - - -node2ba -node1aa - - -node2bb -node1ab - - -node2bc -node1ac - - -node2bd -node1ad - - -node2be -node1ae - - -node2bf -node1af - - -node2bg -node1ag - - - - node1fort:8 - dataout f1 - - - node1d - node98 p1 - - - datainf1 - node2 a - - - ljdcjdc - node1 jdc - - - - node1 a - 23 - - - node1 b - 23 - - - node1 c - hello - - - - node2 b - 23 - - - node2 c - hello - - - - ljdc comm - f.comm - - - - node1 argv - -memjeveux 4 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 23 + + + + caster + + s1 + + + + + + + + + + + + + + + + + + cfort + + s1 + + + + + + + + + + + + + + + + + + + + + + + + datain node2 + node1 node98 + node1 dataout + + datain f1 + node2 a + + + node1 fort:8 + dataout f1 + + + node1 d + node98 p1 + + + node1 ba + node2 a + + + node1 bb + node2 b + + + node2 ba + node1 aa + + + node2 bb + node1 ab + + + node2 bc + node1 ac + + + node2 bd + node1 ad + + + node2 be + node1 ae + + + node2 bf + node1 af + + + node2 bg + node1 ag + + + node1jdc + f.comm + + + node1a + 23 + + + node1b + 23 + + + node1c + hello + + + node2b + 23 + + + node2c + hello + + + + + + + - diff --git a/Examples/ast2/coupling2.xml b/Examples/ast2/coupling2.xml new file mode 100644 index 0000000..bed71be --- /dev/null +++ b/Examples/ast2/coupling2.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + caster + + s2 + + + + + + + + + + + s20 + s2 + + + + + s20 s200 + PyScript1 s20 + PyScript1 s200 + + s20 d + s200 a + + + PyScript1 o2 + s20 jdc + + + PyScript1 o4 + s200 jdc + + + s20a + 5.2 + + + s200a + 5.2 + + + + + + diff --git a/Examples/ast2/exeaster b/Examples/ast2/exeaster new file mode 100755 index 0000000..a2b7d0f --- /dev/null +++ b/Examples/ast2/exeaster @@ -0,0 +1,55 @@ +#!/bin/sh +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +ROOT=/local/cchris/Salome/YACSGEN/V6/YACSGEN/Examples/ast2 + +cat > temp.comm << END +END + +cat > temp.export << END +P actions make_etude +P version STA10.3 +P nomjob salome +P ncpus 1 +A memjeveux 4.000000 +P mem_aster 100 +A tpmax 60 +P memjob 32768 +P mpi_nbcpu 1 +P mpi_nbnoeud 1 +P tpsjob 1 + +P mode batch + +P soumbtc oui +P consbtc oui +F conf $ROOT/install/share/salome/resources/astmod/caster_config.txt D 0 +F comm $PWD/temp.comm D 1 +F exec $ROOT/myaster/aster.exe D 0 +R cmde $ROOT/myaster/commande D 0 +F mess $PWD/messages R 6 +F resu $PWD/resu R 8 +F erre $PWD/erre R 9 +END + +/local/cchris/Aster/V10.3/aster/bin/as_run temp.export + +sleep 5 +echo "Fin du script" diff --git a/Examples/ast2/f.comm b/Examples/ast2/f.comm index 0a8524d..f8a7a55 100644 --- a/Examples/ast2/f.comm +++ b/Examples/ast2/f.comm @@ -1,3 +1,4 @@ +DEBUT(PAR_LOT="NON") print a,b,c YACS_INIT(COMPO=component) @@ -6,3 +7,4 @@ LECTURE_FORCE() d=36.5 +FIN() diff --git a/Examples/ast2/fcompo/Makefile b/Examples/ast2/fcompo/Makefile index fb7aa91..2b8535d 100644 --- a/Examples/ast2/fcompo/Makefile +++ b/Examples/ast2/fcompo/Makefile @@ -1,11 +1,28 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# -FC=g77 - -KERNEL_ROOT_DIR=/local/chris/SALOME2/RELEASES/Install/KERNEL_V5 +include ../../makefile.inc all:prog prog:compo.o - $(FC) -o prog compo.o -L../install/lib/salome -lcfortExelib + $(FC) -o prog compo.o -L../install/lib/salome -lcfortExelib -L$(KERNEL_ROOT_DIR)/lib/salome -lCalciumC + compo.o:compo.f $(FC) -c compo.f -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions diff --git a/Examples/ast2/fcompo/compo.f b/Examples/ast2/fcompo/compo.f index a4423e4..e67a668 100644 --- a/Examples/ast2/fcompo/compo.f +++ b/Examples/ast2/fcompo/compo.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + PROGRAM P CALL YACSINIT() END diff --git a/Examples/ast2/myaster/Makefile b/Examples/ast2/myaster/Makefile index 7a7ea2c..7348553 100644 --- a/Examples/ast2/myaster/Makefile +++ b/Examples/ast2/myaster/Makefile @@ -1,7 +1,26 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# -#ASTER -ASTER_ROOT=/local/chris/ASTER/instals +include ../../makefile.inc aster.exe: - ./make_exec $(ASTER_ROOT)/ASTK/ASTK_SERV/bin/as_run + ./make_exec $(ASTER_ROOT) $(ASTER_VERSION) +clean: + rm -rf commande aster.exe make-exe diff --git a/Examples/ast2/myaster/config.txt b/Examples/ast2/myaster/config.txt index b7cbc4f..8cbf257 100644 --- a/Examples/ast2/myaster/config.txt +++ b/Examples/ast2/myaster/config.txt @@ -1,3 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# # Configuration file # $Id$ # $Name$ @@ -12,6 +30,8 @@ # LINK : linker command # OPTL : linker options # CC : C compiler command +# DEFS : pre-processor #define commands separated by space or comma +# they will be added to all compilation options OPTx_x # OPTC_D : C compiler options using DEBUG mode # OPTC_O : C compiler options using NODEBUG mode # INCL : C include flags @@ -31,51 +51,54 @@ # REPOUT : tools directory # MAKE_SURCH_OFFI/MAKE_CAPY_OFFI : Python modules to compiling elements catalogs # CRP / CRS : tools to check source files and programming rules +# ID_PERF : a label to identify a group of machines (use by TEST_TEMPS command) # -ENV_SH | env | - | /local/chris/ASTER/instals/NEW9/profile.sh +ID_PERF | id | - | claui2c6 +# +ENV_SH | env | - | /local/cchris/Aster/V10.3/aster/STA10.3/profile.sh # LIB | ar | ? | /usr/bin/ar -rv # -#BIBL | python | 2.4 | -L/usr/lib/python2.4/config -lpython2.4 -BIBL | python | 2.4 | -lpython2.4 -BIBL | med | 2.3.5 | -Wl,-R -Wl,/local/chris/pkg/med235/install/lib -L/local/chris/pkg/med235/install/lib -lmed -BIBL | hdf5 | 1.6.5 | -lhdf5 -BIBL | sys | ? | -Wl,--allow-multiple-definition -Wl,--export-dynamic -lieee -ldl -lpthread -lutil -lm /usr/lib/libz.a -BIBL | mpi | 2 | -lmpi -BIBL | zmat | 8.3 | -BIBL | mumps | 4.3.2 | -BIBL | scotch | 4.0 | -L/local/chris/ASTER/instals/public/scotch_4.0/bin -lscotch -lcommon -lscotcherr -lscotcherrcom -BIBL | math | ? | /usr/lib/liblapack.a /usr/lib/libblas.a /usr/lib/libg2c.a -BIBL | salome | ? | -L/local/chris/SALOME2/RELEASES/Install/KERNEL_V5/lib/salome -lCalciumC -lSalomeDSCSuperv -lSalomeDSCContainer -lSalomeDatastream -lSalomeDSCSupervBasic -Wl,--rpath -Wl,/local/chris/SALOME2/RELEASES/Install/KERNEL_V5/lib/salome +BIBL | python | 2.4 | -L/local/cchris/pkg/python2.7/install/lib -L/local/cchris/pkg/python2.7/install/lib/python2.7/config -lpython2.7 +BIBL | med | 2.3.5 | -L/local/cchris/Aster/V10.3/aster/public/med-2.3.6/lib -lmed +BIBL | hdf5 | 1.6.5 | -L/local/cchris/Aster/V10.3/aster/public/hdf5-1.6.9/lib -lhdf5 +BIBL | zmat | 8.4 | +BIBL | mumps | ? | /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libdmumps.a /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libzmumps.a /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libsmumps.a /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libcmumps.a /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libmumps_common.a /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libpord.a /local/cchris/Aster/V10.3/aster/public/mumps-4.9.2/lib/libmpiseq.a -L/local/cchris/Aster/V10.3/aster/public/metis-4.0/lib -lmetis +BIBL | scotch | 4.0 | +BIBL | math | ? | -L/usr/lib -llapack -L/usr/lib -lblas -L/usr/lib/gcc/x86_64-linux-gnu/4.3 -lgfortran +BIBL | mpi | 2 | +BIBL | c++ | ? | -L/usr/lib/gcc/x86_64-linux-gnu/4.3 -lstdc++ -lsupc++ +BIBL | sys | ? | -Wl,--allow-multiple-definition -Wl,--export-dynamic -ldl -lutil -lm -lpthread -lz +BIBL | salome | ? | -L/local/cchris/Salome/Install/KERNEL_V6/lib/salome -lCalciumC -lSalomeDSCSuperv -lSalomeDSCContainer -lSalomeDatastream -lSalomeDSCSupervBasic -Wl,--rpath -Wl,/local/cchris/Salome/Install/KERNEL_V6/lib/salome +# +DEFS | defined | ? | LINUX64 _HAVE_MUMPS _DISABLE_SCOTCH # -NOBUILD | option | ? | bibfor/from_c +NOBUILD | option | ? | # -PYTHON | python | 2.4 | /usr/bin/python +PYTHON | python | 2.4 | /local/cchris/Salome/envSalome6/spython/bin/python # -LINK | link | ? | /usr/bin/g77 -OPTL | link | ? | -v +LINK | link | ? | /usr/bin/gfortran +OPTL | link | ? | -fopenmp # CC | cc | ? | /usr/bin/gcc -#OPTC_D | cc | ? | -c -g -DP_LINUX -D_USE_MPI -OPTC_D | cc | ? | -c -g -DP_LINUX -#OPTC_O | cc | ? | -c -O2 -DP_LINUX -D_USE_MPI -OPTC_O | cc | ? | -c -O2 -DP_LINUX -INCL | include | ? | -I/local/chris/ASTER/instals/NEW9/bibc/include -I/usr/include/python2.4 -I/usr/include -I/usr/include/lam -I/local/chris/ASTER/instals/public/scotch_4.0/bin -# -F77 | f77 | ? | /usr/bin/g77 -OPTF_D | f77 | ? | -c -g -OPTF_O | f77 | ? | -c -O2 -I/usr/include/lam -INCLF | include | ? | -I/local/chris/SALOME2/RELEASES/Install/KERNEL_V5/include/salome -# -F90 | f90 | ? | -OPTF90_D | f90 | ? | -c -g -OPTF90_O | f90 | ? | -c -O2 -INCLF90 | include | ? | +OPTC_D | cc | ? | -c -g -fno-stack-protector -fPIC -fopenmp +OPTC_O | cc | ? | -c -O2 -fno-stack-protector -fPIC -fopenmp +INCL | include | ? | -I/local/cchris/Aster/V10.3/aster/STA10.3/bibc/include -I/local/cchris/pkg/python2.7/install/include/python2.7 -I/local/cchris/Salome/envSalome6/spython/lib/python2.7/site-packages/numpy/core/include -I/local/cchris/Aster/V10.3/aster/public/hdf5-1.6.9/include +# +F77 | f77 | ? | /usr/bin/gfortran +OPTF_D | f77 | ? | -c -g -fPIC -fopenmp -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 +OPTF_O | f77 | ? | -c -O2 -fPIC -fopenmp -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 +INCLF | include | ? | -I/local/cchris/Salome/Install/KERNEL_V6/include/salome +# +F90 | f90 | ? | /usr/bin/gfortran +OPTF90_D | f90 | ? | -c -g -ffixed-line-length-0 -x f77-cpp-input -fPIC -fopenmp -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 +OPTF90_O | f90 | ? | -c -O2 -ffixed-line-length-0 -x f77-cpp-input -fPIC -fopenmp -fdefault-double-8 -fdefault-integer-8 -fdefault-real-8 +INCLF90 | include | ? | -I/local/cchris/Aster/V10.3/aster/STA10.3/bibf90/include_mumps-4.9.2 # G77_AGLA | g77 | ? | unused # SRCFOR | src | 11-04 | bibfor -#SRCF90 | src | 11-04 | bibf90 +SRCF90 | src | 11-04 | bibf90 SRCFERM | src | 11-04 | fermetur SRCC | src | 11-04 | bibc SRCPY | src | 11-04 | bibpyt @@ -107,22 +130,26 @@ ARGEXE | exec | 03-02 | -eficas_path ./Python MAKE_SURCH_OFFI | build | 11-04 | Lecture_Cata_Ele/make_surch_offi.py MAKE_CAPY_OFFI | build | 11-04 | Lecture_Cata_Ele/make_capy_offi.py # -REPOUT | exec | 11-04 | /local/chris/ASTER/instals/outils -REPMAT | exec | 02-05 | /local/chris/ASTER/instals/NEW9/materiau -REPDEX | exec | 02-05 | /local/chris/ASTER/instals/NEW9/datg +REPOUT | exec | 11-04 | /local/cchris/Aster/V10.3/aster/outils +REPMAT | exec | 02-05 | /local/cchris/Aster/V10.3/aster/STA10.3/materiau +REPDEX | exec | 02-05 | /local/cchris/Aster/V10.3/aster/STA10.3/datg # SUPERV | exec | 03-02 | Accas SUPERV | exec | 03-02 | Build +SUPERV | exec | 03-02 | Comportement SUPERV | exec | 03-02 | Execution +SUPERV | exec | 03-02 | Intranet SUPERV | exec | 03-02 | Macro -SUPERV | exec | 03-02 | Messages +SUPERV | exec | 12-06 | Meidee +SUPERV | exec | 09-06 | Messages SUPERV | exec | 03-02 | Noyau -SUPERV | exec | 03-02 | Stanley +SUPERV | exec | 05-04 | Outils +SUPERV | exec | 01-07 | SD +SUPERV | exec | 01-03 | Stanley SUPERV | exec | 03-02 | Utilitai SUPERV | exec | 03-02 | Validation # GZIP | tool | ? | ?GZIP? -CRP | tool | ? | /local/chris/ASTER/instals/outils/CRPCRS/crp_aster.sh -CRS | tool | ? | /local/chris/ASTER/instals/outils/CRPCRS/crs.sh # I18N | i18n | - | + diff --git a/Examples/ast2/myaster/make_exec b/Examples/ast2/myaster/make_exec index 351c97a..676ad84 100755 --- a/Examples/ast2/myaster/make_exec +++ b/Examples/ast2/myaster/make_exec @@ -1,8 +1,27 @@ #!/bin/sh +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + cat >make-exe << END P actions make_exec P actions make_cmde -P version NEW9 +P version $2 P nomjob forma01a P ncpus 1 A memjeveux 4.000000 @@ -23,5 +42,4 @@ R capy ${PWD}/catalo D 0 R cmde ${PWD}/commande DR 0 END - -$1 make-exe +$1/bin/as_run make-exe diff --git a/Examples/ast2/myaster/src/op0189.f b/Examples/ast2/myaster/src/op0189.f index 9c669bd..79bc96f 100644 --- a/Examples/ast2/myaster/src/op0189.f +++ b/Examples/ast2/myaster/src/op0189.f @@ -62,9 +62,9 @@ C COMMON/YACS/IFL include 'calcium.hf' real*8 tt,tp,t0,t1,ss,zz - real yr + real*4 yr CHARACTER*8 tch(2) - real tcp(2) + real*4 tcp(2) integer*4 tlo(3) write(6,*) '--> OP196 ' diff --git a/Examples/calcium1/Makefile b/Examples/calcium1/Makefile new file mode 100644 index 0000000..bf7c92c --- /dev/null +++ b/Examples/calcium1/Makefile @@ -0,0 +1,30 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +include ../makefile.inc + +all:libcode1.so + +libcode1.so:code1.o + $(FC) -shared -fPIC -o libcode1.so code1.o +code1.o:code1.f + $(FC) -c code1.f -fPIC -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions + +clean: + rm -rf *.o *.so install install.bak traceExec_proc appli appli.bak pycompos_SRC pycompos_SRC.bak diff --git a/Examples/calcium1/code1.f b/Examples/calcium1/code1.f new file mode 100644 index 0000000..7d9b813 --- /dev/null +++ b/Examples/calcium1/code1.f @@ -0,0 +1,270 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + + SUBROUTINE SERV1(compo,a,b,c) + include 'calcium.hf' + integer compo(2) + integer i, nval, info, z(10), l + integer*8 lz(10) + integer*4 z4(10),lo(10) + + real*8 dd(10),a,b,c,ti,tf,t + real*4 u(20) + real*4 tti,ttf,tt + character*10 s(3) + character*20 rs(3) + character*64 instance + + write(6,*)a,b + call cpcd(compo,instance,info) + write(6,*)"instance name=",instance + +C write + tt=0. + t=0. + dd(1)=125.45 + dd(2)=8.8 + i=1 + l=10 + CALL cpedb(compo,CP_ITERATION,t,i,'ba',l,dd,info) + CALL cpedb(compo,CP_ITERATION,t,2,'ba',l,dd,info) + CALL cpedb(compo,CP_ITERATION,t,3,'ba',l,dd,info) + write(6,*)'info=',info + call flush(6) + + s(1)="titi" + s(2)="tututu" + s(3)="tatatata" + write(6,*)'s=',s + l=3 + CALL cpech(compo,CP_ITERATION,tt,i,'bb',l,s,info) + write(6,*)'info=',info + call flush(6) + + z(1)=1 + z(2)=8 + z(3)=0 + write(6,*)'z=',z(1) + write(6,*)'z=',z(2) + write(6,*)'z=',z(3) + l=10 + CALL cpeen(compo,CP_ITERATION,tt,i,'bc',l,z,info) + write(6,*)'info=',info + call flush(6) + + u(1)=1 + u(2)=8 + u(3)=4 + u(4)=4 + u(5)=5 + u(6)=5 + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + write(6,*)'u=',u(4) + write(6,*)'u=',u(5) + write(6,*)'u=',u(6) + CALL cpecp(compo,CP_ITERATION,tt,i,'bd',l,u,info) + write(6,*)'info=',info + call flush(6) + + u(1)=1.1 + u(2)=8.8 + u(3)=4.4 + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + CALL cpere(compo,CP_ITERATION,tt,i,'be',l,u,info) + write(6,*)'info=',info + call flush(6) + + lo(1)=1 + lo(2)=0 + lo(3)=1 + write(6,*)'lo=',lo(1) + write(6,*)'lo=',lo(2) + write(6,*)'lo=',lo(3) + CALL cpelo(compo,CP_ITERATION,tt,i,'bf',l,lo,info) + write(6,*)'info=',info + call flush(6) + + lz(1)=11 + lz(2)=22 + lz(3)=33 + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + CALL cpeln(compo,CP_ITERATION,tt,i,'bg',l,lz,info) + write(6,*)'info=',info + call flush(6) + + z4(1)=1 + z4(2)=8 + z4(3)=0 + write(6,*)'z4=',z4(1) + write(6,*)'z4=',z4(2) + write(6,*)'z4=',z4(3) + CALL cpein(compo,CP_ITERATION,tt,i,'bh',l,z4,info) + write(6,*)'info=',info + call flush(6) + + lz(1)=11 + lz(2)=22 + lz(3)=2**30 + lz(3)=2**20*lz(3) + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + CALL cpelg(compo,CP_ITERATION,tt,i,'bi',l,lz,info) + write(6,*)'info=',info + call flush(6) + +C read + ti=0. + tf=1. + i=1 + dd(1)=0. + dd(2)=0. + dd(3)=0. + l=3 + CALL cpldb(compo,CP_ITERATION,ti,tf,i,'aa',l,nval,dd,info) + write(6,*)'info=',info + write(6,*)'dd=',dd(1) + write(6,*)'dd=',dd(2) + write(6,*)'dd=',dd(3) + write(6,*)'nval=',nval + call flush(6) + + tti=0. + ttf=1. + i=1 + CALL cplch(compo,CP_ITERATION,tti,ttf,i,'ab',l,nval,rs,info) + write(6,*)'info=',info + write(6,*)'rs=',rs + write(6,*)'nval=',nval + call flush(6) + + z(1)=0 + z(2)=0 + z(3)=0 + CALL cplen(compo,CP_ITERATION,tti,ttf,i,'ac',l,nval,z,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'z=',z(1) + write(6,*)'z=',z(2) + write(6,*)'z=',z(3) + call flush(6) + + u(1)=0 + u(2)=0 + u(3)=0 + u(4)=0 + u(5)=0 + u(6)=0 + CALL cplcp(compo,CP_ITERATION,tti,ttf,i,'ad',l,nval,u,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + write(6,*)'u=',u(4) + write(6,*)'u=',u(5) + write(6,*)'u=',u(6) + call flush(6) + + u(1)=0 + u(2)=0 + u(3)=0 + CALL cplre(compo,CP_ITERATION,tti,ttf,i,'ae',l,nval,u,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + call flush(6) + + lo(1)=0 + lo(2)=0 + lo(3)=0 + CALL cpllo(compo,CP_ITERATION,tti,ttf,i,'af',l,nval,lo,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'lo=',lo(1) + write(6,*)'lo=',lo(2) + write(6,*)'lo=',lo(3) + call flush(6) + + lz(1)=0 + lz(2)=0 + lz(3)=0 + CALL cplln(compo,CP_ITERATION,tti,ttf,i,'ag',l,nval,lz,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + call flush(6) + + z4(1)=0 + z4(2)=0 + z4(3)=0 + CALL cplin(compo,CP_ITERATION,tti,ttf,i,'ah',l,nval,z4,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'z4=',z4(1) + write(6,*)'z4=',z4(2) + write(6,*)'z4=',z4(3) + call flush(6) + + lz(1)=0 + lz(2)=0 + lz(3)=0 + CALL cpllg(compo,CP_ITERATION,tti,ttf,i,'ai',l,nval,lz,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + call flush(6) + + call cpfini(compo,'aa',1,info) + write(6,*)'info=',info + call flush(6) + + i=1 + l=3 + CALL cpldb(compo,CP_ITERATION,ti,tf,i,'aa',l,nval,dd,info) + write(6,*)'info=',info + call flush(6) + + call cpeffi(compo,'aa',3,info) + write(6,*)'info=',info + call flush(6) + + i=3 + l=3 + CALL cpldb(compo,CP_ITERATION,ti,tf,i,'aa',l,nval,dd,info) + write(6,*)'info=',info + call flush(6) + + CALL cpfin(compo,CP_ARRET,info) + + c=a+b + return + end diff --git a/Examples/calcium1/components.py b/Examples/calcium1/components.py new file mode 100644 index 0000000..dbf9ce0 --- /dev/null +++ b/Examples/calcium1/components.py @@ -0,0 +1,465 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,PYComponent,CPPComponent,F77Component + +# C++ component + +body=""" +std::cerr << "a: " << a << std::endl; +std::cerr << "b: " << b << std::endl; +int info; +double t1,t2; +float tt1,tt2; +int i=1; +int mval; +double val[10],rval[10]; +int ival[10],rival[10]; +long lval[10],rlval[10]; +float cval[20],rcval[20]; +char* sval[]={"coucou","bonjour","salut"}; +char* rsval[3]; +char mystring1[10]; +char mystring2[10]; +char mystring3[10]; +rsval[0]=mystring1; +rsval[1]=mystring2; +rsval[2]=mystring3; + +char instance_name[72]; +info = cp_cd(component,instance_name); +std::cerr << "instance_name: " << instance_name << std::endl; + +val[0]=3.2; +val[1]=5.2; +val[2]=9.8; +std::cerr << "val: " << val[0] << std::endl; +std::cerr << "val: " << val[1] << std::endl; +std::cerr << "val: " << val[2] << std::endl; +cp_edb(component,CP_ITERATION,0.,1,(char*)"ba",10,val); +cp_edb(component,CP_ITERATION,0.,2,(char*)"ba",10,val); +cp_edb(component,CP_ITERATION,0.,3,(char*)"ba",10,val); + +std::cerr << "sval: " << sval[0] << std::endl; +std::cerr << "sval: " << sval[1] << std::endl; +std::cerr << "sval: " << sval[2] << std::endl; +cp_ech(component,CP_ITERATION,0.,1,(char*)"bb",3,sval,6); + +ival[0]=1; +ival[1]=2; +ival[2]=3; +std::cerr << "ival: " << ival[0] << std::endl; +std::cerr << "ival: " << ival[1] << std::endl; +std::cerr << "ival: " << ival[2] << std::endl; +cp_een(component,CP_ITERATION,0.,1,(char*)"bc",10,ival); + +cval[0]=1; +cval[1]=2; +cval[2]=3; +cval[3]=4.5; +cval[4]=5.6; +cval[5]=7.8; +std::cerr << "cval: " << cval[0] << std::endl; +std::cerr << "cval: " << cval[1] << std::endl; +std::cerr << "cval: " << cval[2] << std::endl; +std::cerr << "cval: " << cval[3] << std::endl; +std::cerr << "cval: " << cval[4] << std::endl; +std::cerr << "cval: " << cval[5] << std::endl; +cp_ecp(component,CP_ITERATION,0.,1,(char*)"bd",10,cval); + +cval[0]=1.1; +cval[1]=2.2; +cval[2]=3.3; +std::cerr << "cval: " << cval[0] << std::endl; +std::cerr << "cval: " << cval[1] << std::endl; +std::cerr << "cval: " << cval[2] << std::endl; +cp_ere(component,CP_ITERATION,0.,1,(char*)"be",10,cval); + +ival[0]=1; +ival[1]=0; +ival[2]=1; +std::cerr << "ival: " << ival[0] << std::endl; +std::cerr << "ival: " << ival[1] << std::endl; +std::cerr << "ival: " << ival[2] << std::endl; +cp_elo(component,CP_ITERATION,0.,1,(char*)"bf",10,ival); + +lval[0]=1; +lval[1]=2; +lval[2]=3; +std::cerr << "lval: " << lval[0] << std::endl; +std::cerr << "lval: " << lval[1] << std::endl; +std::cerr << "lval: " << lval[2] << std::endl; +cp_eln(component,CP_ITERATION,0.,1,(char*)"bg",10,lval); + +ival[0]=1; +ival[1]=2; +ival[2]=3; +std::cerr << "ival: " << ival[0] << std::endl; +std::cerr << "ival: " << ival[1] << std::endl; +std::cerr << "ival: " << ival[2] << std::endl; +cp_een(component,CP_ITERATION,0.,1,(char*)"bh",10,ival); + +lval[0]=1; +lval[1]=2; +lval[2]=3; +std::cerr << "lval: " << lval[0] << std::endl; +std::cerr << "lval: " << lval[1] << std::endl; +std::cerr << "lval: " << lval[2] << std::endl; +cp_elg(component,CP_ITERATION,0.,1,(char*)"bi",10,lval); + +/* read */ +info=cp_ldb(component,CP_ITERATION,&t1,&t2,&i,(char*)"aa",3,&mval,rval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rval: " << rval[0] << std::endl; +std::cerr << "rval: " << rval[1] << std::endl; +std::cerr << "rval: " << rval[2] << std::endl; + +info=cp_lch(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ab",3,&mval,rsval,7); +std::cerr << "info: " << info << std::endl; +std::cerr << "rsval: " << rsval[0] << std::endl; +std::cerr << "rsval: " << rsval[1] << std::endl; +std::cerr << "rsval: " << rsval[2] << std::endl; + +info=cp_len(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ac",3,&mval,rival); +std::cerr << "info: " << info << std::endl; +std::cerr << "rival: " << rival[0] << std::endl; +std::cerr << "rival: " << rival[1] << std::endl; +std::cerr << "rival: " << rival[2] << std::endl; + +info=cp_lcp(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ad",3,&mval,rcval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rcval: " << rcval[0] << std::endl; +std::cerr << "rcval: " << rcval[1] << std::endl; +std::cerr << "rcval: " << rcval[2] << std::endl; +std::cerr << "rcval: " << rcval[3] << std::endl; +std::cerr << "rcval: " << rcval[4] << std::endl; +std::cerr << "rcval: " << rcval[5] << std::endl; + +rcval[0]=0.; +rcval[1]=0.; +rcval[2]=0.; +info=cp_lre(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ae",3,&mval,rcval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rcval: " << rcval[0] << std::endl; +std::cerr << "rcval: " << rcval[1] << std::endl; +std::cerr << "rcval: " << rcval[2] << std::endl; + +rival[0]=0; +rival[1]=0; +rival[2]=0; +i=1; +info=cp_llo(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"af",3,&mval,rival); +std::cerr << "info: " << info << std::endl; +std::cerr << "rival: " << rival[0] << std::endl; +std::cerr << "rival: " << rival[1] << std::endl; +std::cerr << "rival: " << rival[2] << std::endl; + +info=cp_lln(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ag",3,&mval,rlval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rlval: " << rlval[0] << std::endl; +std::cerr << "rlval: " << rlval[1] << std::endl; +std::cerr << "rlval: " << rlval[2] << std::endl; + +rival[0]=0; +rival[1]=0; +rival[2]=0; +i=1; +info=cp_len(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ah",3,&mval,rival); +std::cerr << "info: " << info << std::endl; +std::cerr << "rival: " << rival[0] << std::endl; +std::cerr << "rival: " << rival[1] << std::endl; +std::cerr << "rival: " << rival[2] << std::endl; + +info=cp_llg(component,CP_ITERATION,&tt1,&tt2,&i,(char*)"ai",3,&mval,rlval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rlval: " << rlval[0] << std::endl; +std::cerr << "rlval: " << rlval[1] << std::endl; +std::cerr << "rlval: " << rlval[2] << std::endl; + +info=cp_fini(component,(char*)"aa",1); +std::cerr << "info: " << info << std::endl; + +info=cp_effi(component,(char*)"aa",3); +std::cerr << "info: " << info << std::endl; + +cp_fin(component,CP_ARRET); + +c=2*rval[0]; +std::cerr << "c: " << c << std::endl; +""" +c1=CPPComponent("compo1",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double")], + instream=[("aa","CALCIUM_double","I"), + ("ab","CALCIUM_string","I"), + ("ac","CALCIUM_integer","I"), + ("ad","CALCIUM_complex","I"), + ("ae","CALCIUM_real","I"), + ("af","CALCIUM_logical","I"), + ("ag","CALCIUM_long","I"), + ("ah","CALCIUM_integer","I"), + ("ai","CALCIUM_integer","I"), + ], + outstream=[("ba","CALCIUM_double","I"), + ("bb","CALCIUM_string","I"), + ("bc","CALCIUM_integer","I"), + ("bd","CALCIUM_complex","I"), + ("be","CALCIUM_real","I"), + ("bf","CALCIUM_logical","I"), + ("bg","CALCIUM_long","I"), + ("bh","CALCIUM_integer","I"), + ("bi","CALCIUM_integer","I"), + ], + defs="//def1",body=body, + ), + ], + ) + +# python component + +defs=""" +""" + +body=""" +#b1 +info,name= calcium.cp_cd(component) +print "name=",name +print "info=",info + +dep=calcium.CP_ITERATION + +#double +val=numpy.zeros(10,'d') +val[0]=7.7 +val[5]=a*b +nval=10 +print "--------> Appel calcium.cp_edb",val +info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val) +info=calcium.cp_edb(component, dep, 0., 2, "ba", nval,val) +info=calcium.cp_edb(component, dep, 0., 3, "ba", nval,val) + +#string +val=numpy.array(["coucouc ","bonjour ","salut "]) +val=calcium.stringArray(3,8) +val[0]="coucouc" +val[1]="bonjour" +val[2]="salut" +print "--------> Appel calcium.cp_ech",val +info=calcium.cp_ech(component, dep, 0., 1, "bb", 3,val) + +#int +val=numpy.zeros(10,'i') +val[0]=1 +val[1]=3 +print "--------> Appel calcium.cp_een",val +info=calcium.cp_een(component, dep, 0., 1, "bc", 3,val) + +val=numpy.zeros(10,'F') +val[0]=1+2j +val[1]=3+2j +print "--------> Appel calcium.cp_ecp",val +info=calcium.cp_ecp(component, dep, 0., 1, "bd", 3,val) + +val=numpy.zeros(10,'f') +val[0]=1.3 +val[1]=3.2 +print "--------> Appel calcium.cp_ere",val +info=calcium.cp_ere(component, dep, 0., 1, "be", 3,val) + +val=numpy.zeros(10,'i') +val[0]=True +val[1]=False +val[2]=False +print "--------> Appel calcium.cp_elo",val +info=calcium.cp_elo(component, dep, 0., 1, "bf", 3,val) + +val=numpy.zeros(10,'l') +val[0]=1 +val[1]=3 +val[2]=333 +print "--------> Appel calcium.cp_eln",val +info=calcium.cp_eln(component, dep, 0., 1, "bg", 3,val) + +val=numpy.zeros(10,'i') +val[0]=1 +val[1]=3 +val[2]=4 +print "--------> Appel calcium.cp_een",val +info=calcium.cp_een(component, dep, 0., 1, "bh", 3,val) + +val=numpy.zeros(10,'l') +val[0]=1 +val[1]=3 +val[2]=333 +print "--------> Appel calcium.cp_elg",val +info=calcium.cp_elg(component, dep, 0., 1, "bi", 3,val) +print "info=",info + +#read +val=numpy.zeros(10,'d') +print "--------> Appel calcium.cp_ldb" +info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", 3,val) +print mval,val + +val=numpy.array(["","","",], dtype='S13') +print "--------> Appel calcium.cp_lch" +info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val) +print mval,val +print val.dtype + +val=numpy.array([" "," "," ",], dtype='S13') +print "--------> Appel calcium.cp_lch" +info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val) +print mval,val +print val.dtype + +val=calcium.stringArray(3,8) +print "--------> Appel calcium.cp_lch" +info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val) +print mval,val +print val[0] +print val[1] +print val[2] + +val=numpy.zeros(10,'i') +print "--------> Appel calcium.cp_len" +info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ac", 3,val) +print mval,val + +val=numpy.zeros(10,'F') +print "--------> Appel calcium.cp_lcp" +info,tt,ii,mval=calcium.cp_lcp(component, dep, 0.,1., 1, "ad", 3,val) +print mval,val + +val=numpy.zeros(10,'f') +print "--------> Appel calcium.cp_lre" +info,tt,ii,mval=calcium.cp_lre(component, dep, 0.,1., 1, "ae", 3,val) +print mval,val + +val=numpy.zeros(10,'i') +print "--------> Appel calcium.cp_llo" +info,tt,ii,mval=calcium.cp_llo(component, dep, 0.,1., 1, "af", 3,val) +print mval,val + +val=numpy.zeros(10,'l') +print "--------> Appel calcium.cp_lln" +info,tt,ii,mval=calcium.cp_lln(component, dep, 0.,1., 1, "ag", 3,val) +print mval,val + +val=numpy.zeros(10,'i') +print "--------> Appel calcium.cp_len" +info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ah", 3,val) +print mval,val + +val=numpy.zeros(10,'l') +print "--------> Appel calcium.cp_llg" +info,tt,ii,mval=calcium.cp_llg(component, dep, 0.,1., 1, "ai", 3,val) +print "info=",info +print mval,val + +info=calcium.cp_fini(component,"aa",1) +print "info=",info + +info=calcium.cp_effi(component,"aa",3) +print "info=",info + +import time +time.sleep(15) + +c=a+b +d=a-b +err=calcium.cp_fin(component,calcium.CP_ARRET) +print "err=",err +""" +c2=PYComponent("compo2",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double"),("d","double")], + instream=[("aa","CALCIUM_double","I"), + ("ab","CALCIUM_string","I"), + ("ac","CALCIUM_integer","I"), + ("ad","CALCIUM_complex","I"), + ("ae","CALCIUM_real","I"), + ("af","CALCIUM_logical","I"), + ("ag","CALCIUM_long","I"), + ("ah","CALCIUM_integer","I"), + ("ai","CALCIUM_integer","I"), + ], + outstream=[("ba","CALCIUM_double","I"), + ("bb","CALCIUM_string","I"), + ("bc","CALCIUM_integer","I"), + ("bd","CALCIUM_complex","I"), + ("be","CALCIUM_real","I"), + ("bf","CALCIUM_logical","I"), + ("bg","CALCIUM_long","I"), + ("bh","CALCIUM_integer","I"), + ("bi","CALCIUM_integer","I"), + ], + defs=defs,body=body, + ), + ], + ) + +#fortran component + +cwd=os.getcwd() + +c3=F77Component("fcode1", + services=[ + Service("serv1", + inport=[("a","double"),("b","double")], + outport=[("c","double")], + instream=[("aa","CALCIUM_double","I"), + ("ab","CALCIUM_string","I"), + ("ac","CALCIUM_integer","I"), + ("ad","CALCIUM_complex","I"), + ("ae","CALCIUM_real","I"), + ("af","CALCIUM_logical","I"), + ("ag","CALCIUM_long","I"), + ("ah","CALCIUM_integer","I"), + ("ai","CALCIUM_integer","I"), + ], + outstream=[("ba","CALCIUM_double","I"), + ("bb","CALCIUM_string","I"), + ("bc","CALCIUM_integer","I"), + ("bd","CALCIUM_complex","I"), + ("be","CALCIUM_real","I"), + ("bf","CALCIUM_logical","I"), + ("bg","CALCIUM_long","I"), + ("bh","CALCIUM_integer","I"), + ("bi","CALCIUM_integer","I"), + ], + ), + ], + libs="-L%s -lcode1" % cwd, + rlibs="-Wl,--rpath -Wl,%s" % cwd, + ) + +g=Generator(Module("pycompos",components=[c1,c2,c3],prefix="./install",layout="multidir"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + + + diff --git a/Examples/calcium1/coupling.xml b/Examples/calcium1/coupling.xml new file mode 100644 index 0000000..7e3b245 --- /dev/null +++ b/Examples/calcium1/coupling.xml @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + compo1 + + s1 + + + + + + + + + + + + + + + + + + + + + + + + compo2 + + s1 + + + + + + + + + + + + + + + + + + + + + + + + + fcode1 + + serv1 + + + + + + + + + + + + + + + + + + + + + + + + node1 ba + node2 aa + + + node1 bb + node2 ab + + + node1 bc + node2 ac + + + node1 bd + node2 ad + + + node1 be + node2 ae + + + node1 bf + node2 af + + + node1 bg + node2 ag + + + node1 bh + node2 ah + + + node1 bi + node2 ai + + + node2 ba + node3 aa + + + node2 bb + node3 ab + + + node2 bc + node3 ac + + + node2 bd + node3 ad + + + node2 be + node3 ae + + + node2 bf + node3 af + + + node2 bg + node3 ag + + + node2 bh + node3 ah + + + node2 bi + node3 ai + + + node3 ba + node1 aa + + + node3 bb + node1 ab + + + node3 bc + node1 ac + + + node3 bd + node1 ad + + + node3 be + node1 ae + + + node3 bf + node1 af + + + node3 bg + node1 ag + + + node3 bh + node1 ah + + + node3 bi + node1 ai + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + node3a + 63 + + + node3b + 73 + + + + + + diff --git a/Examples/calcium2/Makefile b/Examples/calcium2/Makefile new file mode 100644 index 0000000..bf7c92c --- /dev/null +++ b/Examples/calcium2/Makefile @@ -0,0 +1,30 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +include ../makefile.inc + +all:libcode1.so + +libcode1.so:code1.o + $(FC) -shared -fPIC -o libcode1.so code1.o +code1.o:code1.f + $(FC) -c code1.f -fPIC -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions + +clean: + rm -rf *.o *.so install install.bak traceExec_proc appli appli.bak pycompos_SRC pycompos_SRC.bak diff --git a/Examples/calcium2/code1.f b/Examples/calcium2/code1.f new file mode 100644 index 0000000..3f4afae --- /dev/null +++ b/Examples/calcium2/code1.f @@ -0,0 +1,272 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + + SUBROUTINE SERV1(compo,a,b,c) + include 'calcium.hf' + integer compo(2) + integer i, nval, info, z(10), l + integer*8 lz(10) + integer*4 z4(10),lo(10) + + real*8 dd(10),a,b,c,ti,tf,t + real*4 u(20) + real*4 tti,ttf,tt + character*10 s(3) + character*20 rs(3) + character*64 instance + + write(6,*)a,b + call cpcd(compo,instance,info) + write(6,*)"instance name=",instance + +C write + tt=0. + t=0. + dd(1)=125.45 + dd(2)=8.8 + i=1 + l=10 + CALL cpedb(compo,CP_TEMPS,t,i,'ba',l,dd,info) + t=1. + CALL cpedb(compo,CP_TEMPS,t,i,'ba',l,dd,info) + t=2. + CALL cpedb(compo,CP_TEMPS,t,i,'ba',l,dd,info) + write(6,*)'info=',info + call flush(6) + + s(1)="titi" + s(2)="tututu" + s(3)="tatatata" + write(6,*)'s=',s + l=3 + CALL cpech(compo,CP_TEMPS,tt,i,'bb',l,s,info) + write(6,*)'info=',info + call flush(6) + + z(1)=1 + z(2)=8 + z(3)=0 + write(6,*)'z=',z(1) + write(6,*)'z=',z(2) + write(6,*)'z=',z(3) + l=10 + CALL cpeen(compo,CP_TEMPS,tt,i,'bc',l,z,info) + write(6,*)'info=',info + call flush(6) + + u(1)=1 + u(2)=8 + u(3)=4 + u(4)=4 + u(5)=5 + u(6)=5 + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + write(6,*)'u=',u(4) + write(6,*)'u=',u(5) + write(6,*)'u=',u(6) + CALL cpecp(compo,CP_TEMPS,tt,i,'bd',l,u,info) + write(6,*)'info=',info + call flush(6) + + u(1)=1.1 + u(2)=8.8 + u(3)=4.4 + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + CALL cpere(compo,CP_TEMPS,tt,i,'be',l,u,info) + write(6,*)'info=',info + call flush(6) + + lo(1)=1 + lo(2)=0 + lo(3)=1 + write(6,*)'lo=',lo(1) + write(6,*)'lo=',lo(2) + write(6,*)'lo=',lo(3) + CALL cpelo(compo,CP_TEMPS,tt,i,'bf',l,lo,info) + write(6,*)'info=',info + call flush(6) + + lz(1)=11 + lz(2)=22 + lz(3)=33 + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + CALL cpeln(compo,CP_TEMPS,tt,i,'bg',l,lz,info) + write(6,*)'info=',info + call flush(6) + + z4(1)=1 + z4(2)=8 + z4(3)=0 + write(6,*)'z4=',z4(1) + write(6,*)'z4=',z4(2) + write(6,*)'z4=',z4(3) + CALL cpein(compo,CP_TEMPS,tt,i,'bh',l,z4,info) + write(6,*)'info=',info + call flush(6) + + lz(1)=11 + lz(2)=22 + lz(3)=2**30 + lz(3)=2**20*lz(3) + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + CALL cpelg(compo,CP_TEMPS,tt,i,'bi',l,lz,info) + write(6,*)'info=',info + call flush(6) + +C read + ti=0. + tf=1. + i=1 + dd(1)=0. + dd(2)=0. + dd(3)=0. + l=3 + CALL cpldb(compo,CP_TEMPS,ti,tf,i,'aa',l,nval,dd,info) + write(6,*)'info=',info + write(6,*)'dd=',dd(1) + write(6,*)'dd=',dd(2) + write(6,*)'dd=',dd(3) + write(6,*)'nval=',nval + call flush(6) + + tti=0. + ttf=1. + i=1 + CALL cplch(compo,CP_TEMPS,tti,ttf,i,'ab',l,nval,rs,info) + write(6,*)'info=',info + write(6,*)'rs=',rs + write(6,*)'nval=',nval + call flush(6) + + z(1)=0 + z(2)=0 + z(3)=0 + CALL cplen(compo,CP_TEMPS,tti,ttf,i,'ac',l,nval,z,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'z=',z(1) + write(6,*)'z=',z(2) + write(6,*)'z=',z(3) + call flush(6) + + u(1)=0 + u(2)=0 + u(3)=0 + u(4)=0 + u(5)=0 + u(6)=0 + CALL cplcp(compo,CP_TEMPS,tti,ttf,i,'ad',l,nval,u,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + write(6,*)'u=',u(4) + write(6,*)'u=',u(5) + write(6,*)'u=',u(6) + call flush(6) + + u(1)=0 + u(2)=0 + u(3)=0 + CALL cplre(compo,CP_TEMPS,tti,ttf,i,'ae',l,nval,u,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'u=',u(1) + write(6,*)'u=',u(2) + write(6,*)'u=',u(3) + call flush(6) + + lo(1)=0 + lo(2)=0 + lo(3)=0 + CALL cpllo(compo,CP_TEMPS,tti,ttf,i,'af',l,nval,lo,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'lo=',lo(1) + write(6,*)'lo=',lo(2) + write(6,*)'lo=',lo(3) + call flush(6) + + lz(1)=0 + lz(2)=0 + lz(3)=0 + CALL cplln(compo,CP_TEMPS,tti,ttf,i,'ag',l,nval,lz,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + call flush(6) + + z4(1)=0 + z4(2)=0 + z4(3)=0 + CALL cplin(compo,CP_TEMPS,tti,ttf,i,'ah',l,nval,z4,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'z4=',z4(1) + write(6,*)'z4=',z4(2) + write(6,*)'z4=',z4(3) + call flush(6) + + lz(1)=0 + lz(2)=0 + lz(3)=0 + CALL cpllg(compo,CP_TEMPS,tti,ttf,i,'ai',l,nval,lz,info) + write(6,*)'info=',info + write(6,*)'nval=',nval + write(6,*)'lz=',lz(1) + write(6,*)'lz=',lz(2) + write(6,*)'lz=',lz(3) + call flush(6) + + call cpfint(compo,'aa',0.5,info) + write(6,*)'info=',info + call flush(6) + + ti=0. + tf=0. + l=3 + CALL cpldb(compo,CP_TEMPS,ti,tf,i,'aa',l,nval,dd,info) + write(6,*)'info=',info + call flush(6) + + call cpefft(compo,'aa',1.5,info) + write(6,*)'info=',info + call flush(6) + + ti=2. + tf=2. + l=3 + CALL cpldb(compo,CP_TEMPS,ti,tf,i,'aa',l,nval,dd,info) + write(6,*)'info=',info + call flush(6) + + c=a+b + return + end diff --git a/Examples/calcium2/components.py b/Examples/calcium2/components.py new file mode 100644 index 0000000..6c36cd2 --- /dev/null +++ b/Examples/calcium2/components.py @@ -0,0 +1,463 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,PYComponent,CPPComponent,F77Component + +# C++ component + +body=""" +std::cerr << "a: " << a << std::endl; +std::cerr << "b: " << b << std::endl; +int info; +double t1,t2; +float tt1,tt2; +int i=1; +int mval; +double val[10],rval[10]; +int ival[10],rival[10]; +long lval[10],rlval[10]; +float cval[20],rcval[20]; +char* sval[]={"coucou","bonjour","salut"}; +char* rsval[3]; +char mystring1[10]; +char mystring2[10]; +char mystring3[10]; +rsval[0]=mystring1; +rsval[1]=mystring2; +rsval[2]=mystring3; + +val[0]=3.2; +val[1]=5.2; +val[2]=9.8; +std::cerr << "val: " << val[0] << std::endl; +std::cerr << "val: " << val[1] << std::endl; +std::cerr << "val: " << val[2] << std::endl; +cp_edb(component,CP_TEMPS,0.,1,(char*)"ba",10,val); +cp_edb(component,CP_TEMPS,1.,2,(char*)"ba",10,val); +cp_edb(component,CP_TEMPS,2.,3,(char*)"ba",10,val); + +std::cerr << "sval: " << sval[0] << std::endl; +std::cerr << "sval: " << sval[1] << std::endl; +std::cerr << "sval: " << sval[2] << std::endl; +cp_ech(component,CP_TEMPS,0.,1,(char*)"bb",3,sval,6); + +ival[0]=1; +ival[1]=2; +ival[2]=3; +std::cerr << "ival: " << ival[0] << std::endl; +std::cerr << "ival: " << ival[1] << std::endl; +std::cerr << "ival: " << ival[2] << std::endl; +cp_een(component,CP_TEMPS,0.,1,(char*)"bc",10,ival); + +cval[0]=1; +cval[1]=2; +cval[2]=3; +cval[3]=4.5; +cval[4]=5.6; +cval[5]=7.8; +std::cerr << "cval: " << cval[0] << std::endl; +std::cerr << "cval: " << cval[1] << std::endl; +std::cerr << "cval: " << cval[2] << std::endl; +std::cerr << "cval: " << cval[3] << std::endl; +std::cerr << "cval: " << cval[4] << std::endl; +std::cerr << "cval: " << cval[5] << std::endl; +cp_ecp(component,CP_TEMPS,0.,1,(char*)"bd",10,cval); + +cval[0]=1.1; +cval[1]=2.2; +cval[2]=3.3; +std::cerr << "cval: " << cval[0] << std::endl; +std::cerr << "cval: " << cval[1] << std::endl; +std::cerr << "cval: " << cval[2] << std::endl; +cp_ere(component,CP_TEMPS,0.,1,(char*)"be",10,cval); + +ival[0]=1; +ival[1]=0; +ival[2]=1; +std::cerr << "ival: " << ival[0] << std::endl; +std::cerr << "ival: " << ival[1] << std::endl; +std::cerr << "ival: " << ival[2] << std::endl; +cp_elo(component,CP_TEMPS,0.,1,(char*)"bf",10,ival); + +lval[0]=1; +lval[1]=2; +lval[2]=3; +std::cerr << "lval: " << lval[0] << std::endl; +std::cerr << "lval: " << lval[1] << std::endl; +std::cerr << "lval: " << lval[2] << std::endl; +cp_eln(component,CP_TEMPS,0.,1,(char*)"bg",10,lval); + +ival[0]=1; +ival[1]=2; +ival[2]=3; +std::cerr << "ival: " << ival[0] << std::endl; +std::cerr << "ival: " << ival[1] << std::endl; +std::cerr << "ival: " << ival[2] << std::endl; +cp_een(component,CP_TEMPS,0.,1,(char*)"bh",10,ival); + +lval[0]=1; +lval[1]=2; +lval[2]=3; +std::cerr << "lval: " << lval[0] << std::endl; +std::cerr << "lval: " << lval[1] << std::endl; +std::cerr << "lval: " << lval[2] << std::endl; +cp_elg(component,CP_TEMPS,0.,1,(char*)"bi",10,lval); + +/* read */ +t1=0.; +t2=1.; +info=cp_ldb(component,CP_TEMPS,&t1,&t2,&i,(char*)"aa",3,&mval,rval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rval: " << rval[0] << std::endl; +std::cerr << "rval: " << rval[1] << std::endl; +std::cerr << "rval: " << rval[2] << std::endl; + +tt1=0.; +tt2=1.; +info=cp_lch(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ab",3,&mval,rsval,7); +std::cerr << "info: " << info << std::endl; +std::cerr << "rsval: " << rsval[0] << std::endl; +std::cerr << "rsval: " << rsval[1] << std::endl; +std::cerr << "rsval: " << rsval[2] << std::endl; + +info=cp_len(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ac",3,&mval,rival); +std::cerr << "info: " << info << std::endl; +std::cerr << "rival: " << rival[0] << std::endl; +std::cerr << "rival: " << rival[1] << std::endl; +std::cerr << "rival: " << rival[2] << std::endl; + +info=cp_lcp(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ad",3,&mval,rcval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rcval: " << rcval[0] << std::endl; +std::cerr << "rcval: " << rcval[1] << std::endl; +std::cerr << "rcval: " << rcval[2] << std::endl; +std::cerr << "rcval: " << rcval[3] << std::endl; +std::cerr << "rcval: " << rcval[4] << std::endl; +std::cerr << "rcval: " << rcval[5] << std::endl; + +rcval[0]=0.; +rcval[1]=0.; +rcval[2]=0.; +info=cp_lre(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ae",3,&mval,rcval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rcval: " << rcval[0] << std::endl; +std::cerr << "rcval: " << rcval[1] << std::endl; +std::cerr << "rcval: " << rcval[2] << std::endl; + +rival[0]=0; +rival[1]=0; +rival[2]=0; +i=1; +info=cp_llo(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"af",3,&mval,rival); +std::cerr << "info: " << info << std::endl; +std::cerr << "rival: " << rival[0] << std::endl; +std::cerr << "rival: " << rival[1] << std::endl; +std::cerr << "rival: " << rival[2] << std::endl; + +info=cp_lln(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ag",3,&mval,rlval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rlval: " << rlval[0] << std::endl; +std::cerr << "rlval: " << rlval[1] << std::endl; +std::cerr << "rlval: " << rlval[2] << std::endl; + +rival[0]=0; +rival[1]=0; +rival[2]=0; +i=1; +info=cp_len(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ah",3,&mval,rival); +std::cerr << "info: " << info << std::endl; +std::cerr << "rival: " << rival[0] << std::endl; +std::cerr << "rival: " << rival[1] << std::endl; +std::cerr << "rival: " << rival[2] << std::endl; + +info=cp_llg(component,CP_TEMPS,&tt1,&tt2,&i,(char*)"ai",3,&mval,rlval); +std::cerr << "info: " << info << std::endl; +std::cerr << "rlval: " << rlval[0] << std::endl; +std::cerr << "rlval: " << rlval[1] << std::endl; +std::cerr << "rlval: " << rlval[2] << std::endl; + +info=cp_fint(component,(char*)"aa",0.5); +std::cerr << "info: " << info << std::endl; + +info=cp_efft(component,(char*)"aa",1.5); +std::cerr << "info: " << info << std::endl; + +c=2*rval[0]; +std::cerr << "c: " << c << std::endl; +""" +c1=CPPComponent("compo1",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double")], + instream=[("aa","CALCIUM_double","T"), + ("ab","CALCIUM_string","T"), + ("ac","CALCIUM_integer","T"), + ("ad","CALCIUM_complex","T"), + ("ae","CALCIUM_real","T"), + ("af","CALCIUM_logical","T"), + ("ag","CALCIUM_long","T"), + ("ah","CALCIUM_integer","T"), + ("ai","CALCIUM_integer","T"), + ], + outstream=[("ba","CALCIUM_double","T"), + ("bb","CALCIUM_string","T"), + ("bc","CALCIUM_integer","T"), + ("bd","CALCIUM_complex","T"), + ("be","CALCIUM_real","T"), + ("bf","CALCIUM_logical","T"), + ("bg","CALCIUM_long","T"), + ("bh","CALCIUM_integer","T"), + ("bi","CALCIUM_integer","T"), + ], + defs="//def1",body=body, + ), + ], + ) + +# python component + +defs=""" +""" + +body=""" +#b1 +info,name= calcium.cp_cd(component) +print "name=",name +print "info=",info +dep=calcium.CP_TEMPS + +#double +val=numpy.zeros(10,'d') +val[0]=7.7 +val[5]=a*b +nval=10 +print "--------> Appel calcium.cp_edb",val +info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val) +info=calcium.cp_edb(component, dep, 1., 2, "ba", nval,val) +info=calcium.cp_edb(component, dep, 2., 3, "ba", nval,val) + +#string +val=numpy.array(["coucouc ","bonjour ","salut "]) +val=calcium.stringArray(3,8) +val[0]="coucouc" +val[1]="bonjour" +val[2]="salut" +print "--------> Appel calcium.cp_ech",val +info=calcium.cp_ech(component, dep, 0., 1, "bb", 3,val) + +#int +val=numpy.zeros(10,'i') +val[0]=1 +val[1]=3 +print "--------> Appel calcium.cp_een",val +info=calcium.cp_een(component, dep, 0., 1, "bc", 3,val) + +val=numpy.zeros(10,'F') +val[0]=1+2j +val[1]=3+2j +print "--------> Appel calcium.cp_ecp",val +info=calcium.cp_ecp(component, dep, 0., 1, "bd", 3,val) + +val=numpy.zeros(10,'f') +val[0]=1.3 +val[1]=3.2 +print "--------> Appel calcium.cp_ere",val +info=calcium.cp_ere(component, dep, 0., 1, "be", 3,val) + +val=numpy.zeros(10,'i') +val[0]=True +val[1]=False +val[2]=False +print "--------> Appel calcium.cp_elo",val +info=calcium.cp_elo(component, dep, 0., 1, "bf", 3,val) + +val=numpy.zeros(10,'l') +val[0]=1 +val[1]=3 +val[2]=333 +print "--------> Appel calcium.cp_eln",val +info=calcium.cp_eln(component, dep, 0., 1, "bg", 3,val) + +val=numpy.zeros(10,'i') +val[0]=1 +val[1]=3 +val[2]=4 +print "--------> Appel calcium.cp_een",val +info=calcium.cp_een(component, dep, 0., 1, "bh", 3,val) + +val=numpy.zeros(10,'l') +val[0]=1 +val[1]=3 +val[2]=333 +print "--------> Appel calcium.cp_elg",val +info=calcium.cp_elg(component, dep, 0., 1, "bi", 3,val) +print "info=",info + +#read +val=numpy.zeros(10,'d') +print "--------> Appel calcium.cp_ldb" +info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", 3,val) +print mval,val + +val=numpy.array(["","","",], dtype='S13') +print "--------> Appel calcium.cp_lch" +info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val) +print mval,val +print val.dtype + +val=numpy.array([" "," "," ",], dtype='S13') +print "--------> Appel calcium.cp_lch" +info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val) +print mval,val +print val.dtype + +val=calcium.stringArray(3,8) +print "--------> Appel calcium.cp_lch" +info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val) +print mval,val +print val[0] +print val[1] +print val[2] + +val=numpy.zeros(10,'i') +print "--------> Appel calcium.cp_len" +info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ac", 3,val) +print mval,val + +val=numpy.zeros(10,'F') +print "--------> Appel calcium.cp_lcp" +info,tt,ii,mval=calcium.cp_lcp(component, dep, 0.,1., 1, "ad", 3,val) +print mval,val + +val=numpy.zeros(10,'f') +print "--------> Appel calcium.cp_lre" +info,tt,ii,mval=calcium.cp_lre(component, dep, 0.,1., 1, "ae", 3,val) +print mval,val + +val=numpy.zeros(10,'i') +print "--------> Appel calcium.cp_llo" +info,tt,ii,mval=calcium.cp_llo(component, dep, 0.,1., 1, "af", 3,val) +print mval,val + +val=numpy.zeros(10,'l') +print "--------> Appel calcium.cp_lln" +info,tt,ii,mval=calcium.cp_lln(component, dep, 0.,1., 1, "ag", 3,val) +print mval,val + +val=numpy.zeros(10,'i') +print "--------> Appel calcium.cp_len" +info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ah", 3,val) +print mval,val + +val=numpy.zeros(10,'l') +print "--------> Appel calcium.cp_llg" +info,tt,ii,mval=calcium.cp_llg(component, dep, 0.,1., 1, "ai", 3,val) +print "info=",info +print mval,val + +info=calcium.cp_fint(component,"aa",0.5) +print "info=",info + +info=calcium.cp_efft(component,"aa",1.5) +print "info=",info + +import time +time.sleep(15) + +c=a+b +d=a-b +err=calcium.cp_fin(component,calcium.CP_ARRET) +print "err=",err +""" +c2=PYComponent("compo2",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double"),("d","double")], + instream=[("aa","CALCIUM_double","T"), + ("ab","CALCIUM_string","T"), + ("ac","CALCIUM_integer","T"), + ("ad","CALCIUM_complex","T"), + ("ae","CALCIUM_real","T"), + ("af","CALCIUM_logical","T"), + ("ag","CALCIUM_long","T"), + ("ah","CALCIUM_integer","T"), + ("ai","CALCIUM_integer","T"), + ], + outstream=[("ba","CALCIUM_double","T"), + ("bb","CALCIUM_string","T"), + ("bc","CALCIUM_integer","T"), + ("bd","CALCIUM_complex","T"), + ("be","CALCIUM_real","T"), + ("bf","CALCIUM_logical","T"), + ("bg","CALCIUM_long","T"), + ("bh","CALCIUM_integer","T"), + ("bi","CALCIUM_integer","T"), + ], + defs=defs,body=body, + ), + ], + ) + +#fortran component + +cwd=os.getcwd() + +c3=F77Component("fcode1", + services=[ + Service("serv1", + inport=[("a","double"),("b","double")], + outport=[("c","double")], + instream=[("aa","CALCIUM_double","T"), + ("ab","CALCIUM_string","T"), + ("ac","CALCIUM_integer","T"), + ("ad","CALCIUM_complex","T"), + ("ae","CALCIUM_real","T"), + ("af","CALCIUM_logical","T"), + ("ag","CALCIUM_long","T"), + ("ah","CALCIUM_integer","T"), + ("ai","CALCIUM_integer","T"), + ], + outstream=[("ba","CALCIUM_double","T"), + ("bb","CALCIUM_string","T"), + ("bc","CALCIUM_integer","T"), + ("bd","CALCIUM_complex","T"), + ("be","CALCIUM_real","T"), + ("bf","CALCIUM_logical","T"), + ("bg","CALCIUM_long","T"), + ("bh","CALCIUM_integer","T"), + ("bi","CALCIUM_integer","T"), + ], + ), + ], + libs="-L%s -lcode1" % cwd, + rlibs="-Wl,--rpath -Wl,%s" % cwd, + ) + +g=Generator(Module("pycompos",components=[c1,c2,c3],prefix="./install",layout="multidir"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + + + diff --git a/Examples/calcium2/coupling.xml b/Examples/calcium2/coupling.xml new file mode 100644 index 0000000..7e3b245 --- /dev/null +++ b/Examples/calcium2/coupling.xml @@ -0,0 +1,249 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + compo1 + + s1 + + + + + + + + + + + + + + + + + + + + + + + + compo2 + + s1 + + + + + + + + + + + + + + + + + + + + + + + + + fcode1 + + serv1 + + + + + + + + + + + + + + + + + + + + + + + + node1 ba + node2 aa + + + node1 bb + node2 ab + + + node1 bc + node2 ac + + + node1 bd + node2 ad + + + node1 be + node2 ae + + + node1 bf + node2 af + + + node1 bg + node2 ag + + + node1 bh + node2 ah + + + node1 bi + node2 ai + + + node2 ba + node3 aa + + + node2 bb + node3 ab + + + node2 bc + node3 ac + + + node2 bd + node3 ad + + + node2 be + node3 ae + + + node2 bf + node3 af + + + node2 bg + node3 ag + + + node2 bh + node3 ah + + + node2 bi + node3 ai + + + node3 ba + node1 aa + + + node3 bb + node1 ab + + + node3 bc + node1 ac + + + node3 bd + node1 ad + + + node3 be + node1 ae + + + node3 bf + node1 af + + + node3 bg + node1 ag + + + node3 bh + node1 ah + + + node3 bi + node1 ai + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + node3a + 63 + + + node3b + 73 + + + + + + diff --git a/Examples/context.py b/Examples/context.py new file mode 100644 index 0000000..a264b14 --- /dev/null +++ b/Examples/context.py @@ -0,0 +1,41 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os,sys +sys.path.insert(0,"../..") + +SALOME_ROOT=os.path.expanduser("~/Salome/Install") +SALOME_PREREQ=os.path.expanduser("~/.packages.d/envSalome6main") + +KERNEL_ROOT_DIR=os.getenv("KERNEL_ROOT_DIR",os.path.join(SALOME_ROOT,"KERNEL_V6")) +GUI_ROOT_DIR=os.getenv("GUI_ROOT_DIR",os.path.join(SALOME_ROOT,"GUI_V6")) +YACS_ROOT_DIR=os.getenv("YACS_ROOT_DIR",os.path.join(SALOME_ROOT,"YACS_V6")) +GEOM_ROOT_DIR=os.getenv("GEOM_ROOT_DIR",os.path.join(SALOME_ROOT,"GEOM_V6")) + +context={'update':1, + "makeflags":"", + "prerequisites":SALOME_PREREQ, + "kernel":KERNEL_ROOT_DIR, + "gui":GUI_ROOT_DIR, + "geom":GEOM_ROOT_DIR, + } + + +aster_home=os.path.expanduser("~/Aster/V10.3/aster") +aster_version="STA10.3" diff --git a/Examples/cpp1/Makefile b/Examples/cpp1/Makefile new file mode 100644 index 0000000..8c036b0 --- /dev/null +++ b/Examples/cpp1/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so cppcompos_SRC cppcompos_SRC.bak appli appli.bak install install.bak traceExec_proc diff --git a/Examples/cpp1/README.txt b/Examples/cpp1/README.txt index efa5554..6703a62 100644 --- a/Examples/cpp1/README.txt +++ b/Examples/cpp1/README.txt @@ -1,19 +1,19 @@ A C++ component dynamically loadable ========================================= -To build this example, modify the components.py file +To build this example, modify the ../context.py file to take into account your configuration. 1- your prerequisite file 2- your KERNEL_ROOT_DIR -Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here and execute components.py :: source python components.py You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module cppcompos. To run a coupling: diff --git a/Examples/cpp1/components.py b/Examples/cpp1/components.py index fa1a3bb..58c9da9 100644 --- a/Examples/cpp1/components.py +++ b/Examples/cpp1/components.py @@ -1,10 +1,27 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os -from module_generator import Generator,Module,Service,CPPComponent -context={'update':1, - "prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5", - } +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,CPPComponent cwd=os.getcwd() @@ -32,6 +49,7 @@ c1=CPPComponent("compo1",services=[ ), ], includes="-I/usr/include", + calciumextendedinterface=1, ) @@ -41,5 +59,5 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli("appli",restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/cpp1/coupling.xml b/Examples/cpp1/coupling.xml index 07b3a26..bf6dbfc 100644 --- a/Examples/cpp1/coupling.xml +++ b/Examples/cpp1/coupling.xml @@ -1,63 +1,73 @@ - - - - - - - - - - - - - - compo1 - s1 - - - - - - - - - - compo1 - s1 - - - - - - - - - - - node1ba - node2aa - - - node2ba - node1aa - - - - node1 a - 23 - - - node1 b - 53 - - - node2 a - 63 - - - node2 b - 73 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + compo1 + + s1 + + + + + + + + compo1 + + s1 + + + + + + + + node1 ba + node2 aa + + + node2 ba + node1 aa + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + + - diff --git a/Examples/cpp2/Makefile b/Examples/cpp2/Makefile index 88544a1..4600aef 100644 --- a/Examples/cpp2/Makefile +++ b/Examples/cpp2/Makefile @@ -1,5 +1,25 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# -KERNEL_ROOT_DIR=/local/chris/SALOME2/RELEASES/Install/KERNEL_V5 +include ../makefile.inc prog:prog.cxx g++ -o prog prog.cxx -L./install/lib/salome -lcompo1Exelib +clean: + rm -rf *.o prog install install.bak appli appli.bak cppcompos_SRC cppcompos_SRC.bak compo1_inst_1 traceExec_proc diff --git a/Examples/cpp2/README.txt b/Examples/cpp2/README.txt index 38890cb..d167aa3 100644 --- a/Examples/cpp2/README.txt +++ b/Examples/cpp2/README.txt @@ -1,23 +1,23 @@ A C++ standalone component (executable form) ================================================= -To build this example, modify the components.py and Makefile files +To build this example, modify the ../context.py file to take into account your configuration. 1- your prerequisite file 2- your KERNEL_ROOT_DIR -Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here and execute components.py :: source python components.py You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module cppcompos. -To build the standalone component, run:: +To build the standalone component (executable named prog), execute the Makefile in the SALOME application environment:: - make + ./appli/runSession make To run a coupling: diff --git a/Examples/cpp2/components.py b/Examples/cpp2/components.py index b008576..24828f3 100644 --- a/Examples/cpp2/components.py +++ b/Examples/cpp2/components.py @@ -1,10 +1,27 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os -from module_generator import Generator,Module,Service,CPPComponent -context={'update':1, - "prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5", - } +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,CPPComponent cwd=os.getcwd() @@ -43,5 +60,4 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli("appli",restrict=["KERNEL","GUI","YACS"]) - +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/cpp2/prog.cxx b/Examples/cpp2/prog.cxx index 363c697..6b6fe9f 100644 --- a/Examples/cpp2/prog.cxx +++ b/Examples/cpp2/prog.cxx @@ -1,3 +1,21 @@ +// Copyright (C) 2009-2012 EDF R&D +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// extern "C" void yacsinit(); diff --git a/Examples/cppgui1/Makefile b/Examples/cppgui1/Makefile new file mode 100644 index 0000000..8c036b0 --- /dev/null +++ b/Examples/cppgui1/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so cppcompos_SRC cppcompos_SRC.bak appli appli.bak install install.bak traceExec_proc diff --git a/Examples/cppgui1/components.py b/Examples/cppgui1/components.py new file mode 100644 index 0000000..f31ff14 --- /dev/null +++ b/Examples/cppgui1/components.py @@ -0,0 +1,127 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +#import context from .. +execfile("../context.py") + +import os +from module_generator import * + +idldefs=""" +#include "myinterface.idl" +""" + +compodefs=r""" + + +class A: public virtual POA_Idl_A +{ +public: + void createObject(::SALOMEDS::Study_ptr theStudy, const char* name){}; + + // Driver interface + virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;}; + virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;}; + virtual bool Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;}; + virtual bool LoadASCII(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;}; + virtual void Close(SALOMEDS::SComponent_ptr IORSComponent){}; + virtual char* ComponentDataType(){return "cppcompos";}; + virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, CORBA::Boolean isMultiFile, CORBA::Boolean isASCII){return 0;}; + virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII){return 0;}; + virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR){return 0;}; + virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,SALOMEDS::SObject_ptr theSObject,CORBA::Object_ptr theObject, + const char* theName){return 0;}; + virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject){return 0;}; + virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID){return 0;}; + virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID){return 0;}; + virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject){return 0;}; +}; + +""" + +compomethods=r""" + + Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, + CORBA::Boolean isPublished, + CORBA::Boolean isMultiFile, + CORBA::Boolean& isValidScript) + { + std::cerr << "je suis dans le dump:" << __LINE__ << std::endl; + SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy); + if(CORBA::is_nil(aStudy)) + return new Engines::TMPFile(0); + + SALOMEDS::SObject_var aSO = aStudy->FindComponent("cppcompos"); + if(CORBA::is_nil(aSO)) + return new Engines::TMPFile(0); + + std::string Script = "import cppcompos_ORB\n"; + Script += "import salome\n"; + Script += "compo = salome.lcc.FindOrLoadComponent('FactoryServer','cppcompos')\n"; + Script += "def RebuildData(theStudy):\n"; + Script += " compo.SetCurrentStudy(theStudy)\n"; + const char* aScript=Script.c_str(); + + char* aBuffer = new char[strlen(aScript)+1]; + strcpy(aBuffer, aScript); + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + int aBufferSize = strlen(aBuffer)+1; + Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + isValidScript = true; + return aStreamFile._retn(); + } + + +""" + +body=""" +std::cerr << "a: " << a << std::endl; +std::cerr << "b: " << b << std::endl; +c=a+b; +std::cerr << "c: " << c << std::endl; +""" +c1=CPPComponent("cppcompos",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double")], + defs="//def1",body=body, + ), + ], + includes="-I/usr/include", + idls=["*.idl"], + interfacedefs=idldefs, + inheritedinterface="Idl_A", + compodefs=compodefs, + inheritedclass="A", + addedmethods=compomethods, + ) + +modul=Module("cppcompos",components=[c1],prefix="./install", + doc=["*.rst",], + gui=["cppcomposGUI.cxx","cppcomposGUI.h","demo.ui","*.png"], + ) + +g=Generator(modul,context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + diff --git a/Examples/cppgui1/cppcompos.png b/Examples/cppgui1/cppcompos.png new file mode 100644 index 0000000000000000000000000000000000000000..16a20c116e8243a6b49ed862613d2cc49bdf4caa GIT binary patch literal 831 zcmV-F1Hk-=P)A+3!%gdoE?w?yY*XMamxaAW~()k6;QGVVf3ZPpQcy+38CrH3{Qk zoaxN-vWJ+OcH(Y#5qvHK|CitMf1CdUU;7AQ8zF4-#i736F~#EMso~pq*Ek7JMLa$}POH_T(b)M|f)>8t;^3f3 zKA)#ntMKyW+7Z-s>l6xWsZ53jrMAEC5{41RXe`Snj$`6DMr+Vop|xgsc$hE@Sz20V zb@eG)%b|Y+_m{*NND_%L1}POFH@MUObOdhQq^%&CMdWZvC2q+x@_Pg_JQ$DGG%bJbwIyVzG#2o#E=$@5yGf z#Bm5%IplY1BB@I((}Bdlpj1;;nAaqNZEDBWHP2)F0;K|LMcrchIBe@ z&Ye4p5H>e&{)pCc=qTd1Z_6|q4IIZIpUy{Fg7-dG2KQ=nb2l+s9 +#include +#include +#include +#include +#include + +#include +#include CORBA_CLIENT_HEADER(cppcompos) +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +// QT Includes +#include +#include + +// Export the module +extern "C" { + CAM_Module* createModule() + { + return new cppcomposGUI(); + } +} + +// Constructor +cppcomposGUI::cppcomposGUI() : + SalomeApp_Module( "cppcompos" ), // default name + LightApp_Module( "cppcompos" ) +{ +} + +static cppcompos_ORB::cppcompos_var engine; + +// Module's initialization +void cppcomposGUI::initialize( CAM_Application* app ) +{ + + SalomeApp_Module::initialize( app ); + + Engines::EngineComponent_var comp = dynamic_cast(app)->lcc()->FindOrLoad_Component( "FactoryServer","cppcompos" ); + engine = cppcompos_ORB::cppcompos::_narrow(comp); + + QWidget* aParent = application()->desktop(); + SUIT_ResourceMgr* aResourceMgr = app->resourceMgr(); + + // create actions + QPixmap aPixmap = aResourceMgr->loadPixmap( "cppcompos","exec.png" ); + createAction( 901, "Banner", QIcon( aPixmap ), "Banner", "Banner", 0, aParent, false, this, SLOT( OnGetBanner() ) ); + createAction( 902, "Designer", QIcon( aPixmap ), "Designer", "Designer", 0, aParent, false, this, SLOT( OnDesigner() ) ); + + // create menus + int aMenuId; + aMenuId = createMenu( "cppcompos", -1, -1, 30 ); + createMenu( 901, aMenuId, 10 ); + + // create toolbars + int aToolId = createTool ( "cppcompos" ); + createTool( 901, aToolId ); + createTool( 902, aToolId ); +} + +// Get compatible dockable windows. +void cppcomposGUI::windows( QMap& theMap ) const +{ + theMap.clear(); + theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); + theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); +} + +// Module's engine IOR +QString cppcomposGUI::engineIOR() const +{ + return "bidon"; +} + +// Module's activation +bool cppcomposGUI::activateModule( SUIT_Study* theStudy ) +{ + bool bOk = SalomeApp_Module::activateModule( theStudy ); + + setMenuShown( true ); + setToolShown( true ); + + SALOME_NamingService *aNamingService = SalomeApp_Application::namingService(); + CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject); + SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id()); + + SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent("cppcompos"); + if (aFather->_is_nil()) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder(); + aFather = aStudyBuilder->NewComponent("cppcompos"); + SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue("cppcompos"); + aName->UnRegister(); + aStudyBuilder->DefineComponentInstance(aFather, engine); + } + CORBA::Boolean valid; + engine->DumpPython(aDSStudy,1,0,valid); + + return bOk; +} + +// Module's deactivation +bool cppcomposGUI::deactivateModule( SUIT_Study* theStudy ) +{ + setMenuShown( false ); + setToolShown( false ); + + return SalomeApp_Module::deactivateModule( theStudy ); +} + +// Action slot +void cppcomposGUI::OnGetBanner() +{ + // Dialog to get the Name + bool ok = FALSE; + QString myName = QInputDialog::getText( getApp()->desktop(), "label", "name", QLineEdit::Normal, QString::null, &ok ); + + if ( ok && !myName.isEmpty()) + { + ::CORBA::Double c; + engine->s1(1.,2.,c); + std::cerr << c << std::endl; + QString banner = "Hello " + myName; + SUIT_MessageBox::information( getApp()->desktop(), "info", banner, "OK" ); + } +} + +// Action slot +void cppcomposGUI::OnDesigner() +{ + QWidget* wid= new MyDemo(getApp()->desktop()); + wid->show(); +} + +MyDemo::MyDemo(QWidget *parent) + :QDialog(parent) +{ + ui.setupUi(this); +} diff --git a/Examples/cppgui1/cppcomposGUI.h b/Examples/cppgui1/cppcomposGUI.h new file mode 100644 index 0000000..c096c91 --- /dev/null +++ b/Examples/cppgui1/cppcomposGUI.h @@ -0,0 +1,58 @@ +// Copyright (C) 2009-2012 EDF R&D +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _cppcomposGUI_H_ +#define _cppcomposGUI_H_ + +#include +#include "ui_demo.h" + +class cppcomposGUI: public SalomeApp_Module +{ + Q_OBJECT + +public: + cppcomposGUI(); + void initialize( CAM_Application* ); + QString engineIOR() const; + virtual void windows( QMap& theMap ) const; + +public slots: + bool deactivateModule( SUIT_Study* ); + bool activateModule( SUIT_Study* ); + +protected slots: + void OnGetBanner(); + void OnDesigner(); + +}; + +class MyDemo: public QDialog +{ + Q_OBJECT + +public: + MyDemo(QWidget *parent = 0); + +private: + Ui::DemoDialog ui; + +}; + +#endif diff --git a/Examples/cppgui1/demo.ui b/Examples/cppgui1/demo.ui new file mode 100644 index 0000000..69e4ac0 --- /dev/null +++ b/Examples/cppgui1/demo.ui @@ -0,0 +1,146 @@ + + + + + DemoDialog + + + + 0 + 0 + 400 + 300 + + + + PyUIC4 Demo Dialog + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + + + 6 + + + + + Add items + + + + + + + Clear list + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + + + + + + okButton + clicked() + DemoDialog + accept() + + + 369 + 256 + + + 96 + 254 + + + + + button2 + clicked() + list + clear() + + + 92 + 112 + + + 279 + 123 + + + + + diff --git a/Examples/cppgui1/exec.png b/Examples/cppgui1/exec.png new file mode 100644 index 0000000000000000000000000000000000000000..16a20c116e8243a6b49ed862613d2cc49bdf4caa GIT binary patch literal 831 zcmV-F1Hk-=P)A+3!%gdoE?w?yY*XMamxaAW~()k6;QGVVf3ZPpQcy+38CrH3{Qk zoaxN-vWJ+OcH(Y#5qvHK|CitMf1CdUU;7AQ8zF4-#i736F~#EMso~pq*Ek7JMLa$}POH_T(b)M|f)>8t;^3f3 zKA)#ntMKyW+7Z-s>l6xWsZ53jrMAEC5{41RXe`Snj$`6DMr+Vop|xgsc$hE@Sz20V zb@eG)%b|Y+_m{*NND_%L1}POFH@MUObOdhQq^%&CMdWZvC2q+x@_Pg_JQ$DGG%bJbwIyVzG#2o#E=$@5yGf z#Bm5%IplY1BB@I((}Bdlpj1;;nAaqNZEDBWHP2)F0;K|LMcrchIBe@ z&Ye4p5H>e&{)pCc=qTd1Z_6|q4IIZIpUy{Fg7-dG2KQ=nb2l+s9 @@ -20,7 +21,7 @@ and process components.py :: python components.py You should get a SALOME module in source form (fcompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and fcompos. +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module fcompos. To run a coupling: diff --git a/Examples/fort1/bidul.f b/Examples/fort1/bidul.f index 64011d9..1cb9fc7 100644 --- a/Examples/fort1/bidul.f +++ b/Examples/fort1/bidul.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + subroutine bidul() write(6,*)"coucou" return diff --git a/Examples/fort1/code1.f b/Examples/fort1/code1.f index 37a4fa1..76fb5cb 100644 --- a/Examples/fort1/code1.f +++ b/Examples/fort1/code1.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + SUBROUTINE SERV1(compo,a,b,c) include 'calcium.hf' integer compo(2) diff --git a/Examples/fort1/code2.f b/Examples/fort1/code2.f index d5ab3b1..b34fd38 100644 --- a/Examples/fort1/code2.f +++ b/Examples/fort1/code2.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + SUBROUTINE SERV1(compo,a,b,c) include 'calcium.hf' integer compo(2),nval diff --git a/Examples/fort1/components.py b/Examples/fort1/components.py index 3c44fda..77d49df 100644 --- a/Examples/fort1/components.py +++ b/Examples/fort1/components.py @@ -1,17 +1,37 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os -from module_generator import Generator,Module,Service,F77Component -context={'update':1, - "prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5", - } +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,F77Component cwd=os.getcwd() c1=F77Component("fcode1", services=[Service("serv1",inport=[("a","double"),("b","double")], outport=[("c","double")], outstream=[("PARAM","CALCIUM_double","I")],), ], - libs="-L%s -lcode1" % cwd) + libs="-L%s -lcode1" % cwd, + rlibs="-Wl,--rpath -Wl,%s" % cwd, + ) + c2=F77Component("fcode2", services=[Service("serv1",inport=[("a","double"),("b","double")], outport=[("c","double")], instream=[("PARAM","CALCIUM_double","I")],), ], @@ -23,5 +43,5 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli("appli",restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/fort1/coupling.xml b/Examples/fort1/coupling.xml index c3d4ef8..8c0e551 100644 --- a/Examples/fort1/coupling.xml +++ b/Examples/fort1/coupling.xml @@ -1,59 +1,67 @@ - - - - - - - - - - - - - - fcode1 - serv1 - - - - - - - - - fcode2 - serv1 - - - - - - - - - - - node1PARAM - node2PARAM - - - - node1 a - 23 - - - node1 b - 53 - - - node2 a - 63 - - - node2 b - 73 - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + fcode1 + + serv1 + + + + + + + fcode2 + + serv1 + + + + + + + node1 PARAM + node2 PARAM + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + + - diff --git a/Examples/fort2/Makefile b/Examples/fort2/Makefile index b5b693e..2d3286d 100644 --- a/Examples/fort2/Makefile +++ b/Examples/fort2/Makefile @@ -1,18 +1,34 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# -FC=g77 - -KERNEL_ROOT_DIR=/local/chris/SALOME2/RELEASES/Install/KERNEL_V5 +include ../makefile.inc all:prog1 prog2 prog1:code1.o - $(FC) -o prog1 code1.o -L./install/lib/salome -lfcode1Exelib + $(FC) -o prog1 code1.o -L./install/lib/salome -lfcode1Exelib -L$(KERNEL_ROOT_DIR)/lib/salome -lCalciumC code1.o:code1.f $(FC) -c code1.f -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions prog2:code2.o - $(FC) -o prog2 code2.o -L./install/lib/salome -lfcode2Exelib + $(FC) -o prog2 code2.o -L./install/lib/salome -lfcode2Exelib -L$(KERNEL_ROOT_DIR)/lib/salome -lCalciumC code2.o:code2.f $(FC) -c code2.f -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions clean: - rm -rf *.o prog1 prog2 + rm -rf *.o prog1 prog2 fcode1_inst_1 fcode2_inst_1 fcompos_SRC install traceExec_proc install.bak fcompos_SRC.bak appli appli.bak diff --git a/Examples/fort2/README.txt b/Examples/fort2/README.txt index f2ae712..ded4620 100644 --- a/Examples/fort2/README.txt +++ b/Examples/fort2/README.txt @@ -1,13 +1,14 @@ A Fortran standalone component ================================= -To build this example, modify the components.py and Makefile files +To build this example, modify the ../context.py, ../makefile.inc and Makefile files to take into account your configuration. 1- your prerequisite file 2- your KERNEL_ROOT_DIR +3- your FORTRAN compiler -Then set the environment (including PYTHONPATH for YACGEN, ../.. from here):: +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here):: source @@ -16,11 +17,11 @@ and process components.py :: python components.py You should get a SALOME module in source form (fcompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and fcompos. +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module fcompos. -Build the code1 et code2 executables :: +Build the code1 et code2 executables under the SALOME application environment:: - make + ./appli/runSession make To run a coupling: diff --git a/Examples/fort2/code1.f b/Examples/fort2/code1.f index ac9543a..f4c37ac 100644 --- a/Examples/fort2/code1.f +++ b/Examples/fort2/code1.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + PROGRAM P CALL YACSINIT() END diff --git a/Examples/fort2/code2.f b/Examples/fort2/code2.f index 1a5c654..00886d8 100644 --- a/Examples/fort2/code2.f +++ b/Examples/fort2/code2.f @@ -1,3 +1,22 @@ +C Copyright (C) 2009-2012 EDF R&D +C +C This library is free software; you can redistribute it and/or +C modify it under the terms of the GNU Lesser General Public +C License as published by the Free Software Foundation; either +C version 2.1 of the License. +C +C This library is distributed in the hope that it will be useful, +C but WITHOUT ANY WARRANTY; without even the implied warranty of +C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +C Lesser General Public License for more details. +C +C You should have received a copy of the GNU Lesser General Public +C License along with this library; if not, write to the Free Software +C Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +C +C See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +C + PROGRAM P CALL YACSINIT() END diff --git a/Examples/fort2/components.py b/Examples/fort2/components.py index b92f78d..aed1b22 100644 --- a/Examples/fort2/components.py +++ b/Examples/fort2/components.py @@ -1,10 +1,27 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os -from module_generator import Generator,Module,Service,F77Component -context={'update':1, - "prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5", - } +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,F77Component cwd=os.getcwd() @@ -12,13 +29,13 @@ c1=F77Component("fcode1", services=[Service("serv1",inport=[("a","double"),("b", outport=[("c","double")], outstream=[("PARAM","CALCIUM_double","I")],), ], kind="exe", - exe_path=os.path.join(cwd,"prog1"), + exe_path=os.path.join(cwd,"prog1.sh"), ) c2=F77Component("fcode2", services=[Service("serv1",inport=[("a","double"),("b","double")], outport=[("c","double")], instream=[("PARAM","CALCIUM_double","I")],), ], kind="exe", - exe_path=os.path.join(cwd,"prog2"), + exe_path=os.path.join(cwd,"prog2.sh"), ) g=Generator(Module("fcompos",components=[c1,c2],prefix="./install"),context) @@ -27,5 +44,5 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli("appli",restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/fort2/prog1.sh b/Examples/fort2/prog1.sh new file mode 100755 index 0000000..4f1f3d0 --- /dev/null +++ b/Examples/fort2/prog1.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +script_path=$(dirname $(readlink -f $0)) +$script_path/prog1 + +echo "End of shell" + diff --git a/Examples/fort2/prog2.sh b/Examples/fort2/prog2.sh new file mode 100755 index 0000000..8299c97 --- /dev/null +++ b/Examples/fort2/prog2.sh @@ -0,0 +1,7 @@ +#!/bin/bash +script_path=$(dirname $(readlink -f $0)) +$script_path/prog2 + +echo "End of shell" + + diff --git a/Examples/hxx1/Makefile b/Examples/hxx1/Makefile new file mode 100644 index 0000000..82beac2 --- /dev/null +++ b/Examples/hxx1/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so hxxcompos_SRC hxxcompos_SRC.bak appli appli.bak install install.bak traceExec_proc COMPONENTCPP_INSTALL COMPONENTCPP_SRC COMPONENTCPP_BUILD parse_result parse_type_result diff --git a/Examples/hxx1/README b/Examples/hxx1/README new file mode 100644 index 0000000..2c5154f --- /dev/null +++ b/Examples/hxx1/README @@ -0,0 +1,23 @@ +to run this example, one has first to untar the cpp_component archive, compile it, +and install it in directory COMPONENTCPP_INSTALL + + tar xvfz cpp_component.tgz + mkdir COMPONENTCPP_INSTALL COMPONENTCPP_BUILD + cd COMPONENTCPP_SRC + ./build_configure + cd ../COMPONENTCPP_BUILD + ../COMPONENTCPP_SRC/configure --prefix=... + make + make install + + +Generate the components with : + + python component.py + + +Test them with + + appli/runAppli -u test_compohxx.py + + diff --git a/Examples/hxx1/component.py b/Examples/hxx1/component.py new file mode 100644 index 0000000..34602c3 --- /dev/null +++ b/Examples/hxx1/component.py @@ -0,0 +1,88 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os +from module_generator import Generator,Module,Service +from module_generator import CPPComponent,PYComponent,HXX2SALOMEComponent +class Invalid(Exception): + pass + +kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] +gui_root_dir=os.environ["GUI_ROOT_DIR"] +yacs_root_dir=os.environ["YACS_ROOT_DIR"] +med_root_dir=os.environ["MED_ROOT_DIR"] +geom_root_dir=os.environ["GEOM_ROOT_DIR"] +prereq_file=os.path.join(kernel_root_dir,"..","env_products.sh") +if not os.path.exists(prereq_file): + prereq_file=os.path.join(kernel_root_dir,"..","..","env_products.sh") +if not os.path.exists(prereq_file): + raise Invalid("prerequisite file env_products.sh not found. please replace it manually in component.py") + +#import context from .. +context={'update':1, + "makeflags":"", + "prerequisites":prereq_file, + "kernel":kernel_root_dir, + "gui":gui_root_dir, + "geom":geom_root_dir, + "med":med_root_dir, + "yacs":yacs_root_dir, + } + +cwd=os.getcwd() +cpppath=os.path.join(cwd,"COMPONENTCPP_INSTALL") + + +# PUT HERE DEFINITIONS OF THE COMPONENTS AND THE SERVICES + + +os.environ["CALCULCPP_ROOT_DIR"]=cpppath +os.environ["MEDCALCCPP_ROOT_DIR"]=cpppath +os.environ["TESTMEDCPP_ROOT_DIR"]=cpppath +os.environ["ICOCOCPP_ROOT_DIR"]=cpppath +os.environ["TESTMEMCPP_ROOT_DIR"]=cpppath +c1=HXX2SALOMEComponent("CALCUL.hxx","libCALCULCXX.so" , cpppath ) +c2=HXX2SALOMEComponent("MEDCALC.hxx","libMEDCALCCXX.so" , cpppath ) +c3=HXX2SALOMEComponent("TESTMED.hxx","libTESTMEDCXX.so" , cpppath ) +c4=HXX2SALOMEComponent("ICOCO.hxx","libICOCOCXX.so" , cpppath ) +c5=HXX2SALOMEComponent("TESTMEM.hxx","libTESTMEMCXX.so" , cpppath ) + + +g=Generator(Module("hxxcompos",components=[c4,c1,c2,c3,c5],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", + restrict=["KERNEL","GUI","YACS"], + altmodules={"GUI":gui_root_dir, + "MED":med_root_dir, + "YACS":yacs_root_dir, + "GEOM":geom_root_dir}) +cppenv=""" export CALCULCPP_ROOT_DIR=%(cpppath)s +export MEDCALCCPP_ROOT_DIR=%(cpppath)s +export TESTMEDCPP_ROOT_DIR=%(cpppath)s +export ICOCOCPP_ROOT_DIR=%(cpppath)s +export TESTMEMCPP_ROOT_DIR=%(cpppath)s""" % {"cpppath" : cpppath} + +cppenvfile=open("appli/env.d/cppEnv.sh","w") +cppenvfile.write(cppenv) +cppenvfile.close() + diff --git a/Examples/hxx1/cpp_component.tgz b/Examples/hxx1/cpp_component.tgz new file mode 100644 index 0000000000000000000000000000000000000000..2298007af5f985649a04b0c7211d85b74d596ee4 GIT binary patch literal 20078 zcmV)TK(W6ciwFQjXPr&}1MFM*bKA!C_pilYv00Jg8kFuv(uBo$z}iSYM!a)iQ{zW1=5W^*&6TBKWO_I=zn`>>*?n97T)h} zKYP0KKs@B)T=@s7|zO`T9)rIQ?vF8Sz zaJ#;4M3%2y`C=Z9NsC(pp6m5xy}ueU<2S^Jeq5 z7l$(ytX+MSslXo=JOuG%-B4f7kl6kE=u9%Hwf&FIMj}Wo^TDgtY8)L5iar{bsD!=NU<>WQDku1Kdcas*sR8%PJvSgj!S=eV{vxGO-;*UQ>nq-my zBYXqEEZQ@%k%qI4hi`G(JLeYzSmm4W7kGeZl(VEw6EK`Zud#=pbX?6h|x-_mU1ww1?yqAO4N z0<{07*Ao7lEZ|eFfgt~MdwUK3Z*FdN7x91V+1BP4{Qn%+A*Z`;s^UoCf0E3@@7j5^ z?t(%gp3M_AnWm!AZ;I}B-)*<>bB8{k(&u+Au?fnh&n|s#(&sjP?z9~Ed@2qSDaA!R zPH){rii0?deBz`9tayMQWKi?}hPfHG`<=6Y}3iR=h*2@8$m zAc$|FWO2eckq~=Q7sSLrK;;cYJinS#8m7L3E7 zy|@nP)GmNkXPI?Vv?e0X(pd)13$h$%fxt>Kn3HyVIm#vz99+_JlXVZ`LJmn>FcVf3 z@eCJt1Gc3GhU+%>F+PAMH?lkLOEXDm>Q5v~u^e2`L<>C7en zjV5fUtb(!~w!{olN}!x3a|ed7&{0QX8sApD%|on!#8G;0#O+i9k;JS7UqiM5P-Xxd z9FH|hu;SX}(V#cqPtZ9L9&=;MQ9;un)L`U{B$|(g?I*A&un!s<$-5M!OH6n2Z6nrX z)I%X7Md28uOdTCVmOP79lrC6=wN9O@6G{1TR8PgN89XOJ&=~ri<&8a<`z#8<}8ia=^k$3t|wI>rDG+^_IK}Xh! z5a(GGEntZVDQ`$I2)baz*ftX4FZdU+4~G+W&cJI^&1A@YLNHla3OzjtkSNRrbRUBP zfv(0mAPVvgdb%iB;D%hTZxa7o?F}9dT;ljG}oyi;2=)L}xdeLo5x(Z38(7 zOCEBFXu%9GlHM*eQN(^ASVVYfjZU-Iz$%c&xF!I>Ehb&be~9=_hfI=!2RlcJn1I?I z;wn=R@#t?DjhW;)i9;M}Wn7p*VKLwgi0P<8mIM~R=meKB$AMx+Cc~sjCKcc!Kl4Qc zrr1cgLJt&zh>j}|!XyQ{H&{J`Q{V*1(~@RIIheo|Yyl#o9~dIYp=-urkVEU2Nt=g* z4JH$rV#1X&$6!A&2E)2P&b;{Su2^b<7xZWEE5H}^YSF%A)aQqmUj$+VU1Odz)K`84G7*yaywA+vs z&FUua!2A^?6S243R81x+s0@riMmH*nqp*@GGR|1*$9Pt;I!eo6J4NRE(nF_JJ? zI+fg<=DQIiVwnbPz0#gI0n=J#%us{pd3EDCmVDuiS2L{ zZR7=+Zy}gQiSj7(97f92kY z##kybiQd`y;NbA5dKLWavRWdjrE=BcrUEaExSf~#g)>y1gO}$OI@dZj;5jo_>je(c zj~3WOyDV*~Rk0i@=6RrSjfz-KV^h4ioa|L{qd<)kN@_aJemNcD9ESv4N}Y770xsRS zY@B3)o0w%x;TB;{q_~b&MKni@F%hxw*ub4*X*Mqf9mmGYK!N3f7{G#HLT~@@ylzTT z(oK=llp+$S3xET8au8A}Ik1AJkhwBog8Sm3u8otHJ&;M>Nq}%h0=Y$qsgg#3W5*Bk z(zUD>oy}&HsMvgl!h(x3$rS|?_FFS7@x2?yf`qG!7^Z&?8odD>!&&OuACW>|I`+ zLs@K9oW@SYnmM|dVFLB;anGmJ96=Q?HJ>iA$j;kOt5`sZw$JwZf8P6{V8E_u?qkM* z2@`b~jQvfbtnF$R)E$(-HhujGqDbUJMs`7IUz77?r>Oj?6)8f)1Xdu0AnIgGmaCFH zY#wNB2cdluso!mOc0e|6Bu%5OD=zTUs#XjX;4=)Ue0;_;EGic;Ft^B6j=`MND{Ku> zHX7B_mQ&6f7Q?#T4s7tQZ5Gk&z*u_G?HqQN9Gfj0k(}FrU|{^jrartwDgy6G#;DX! zBw58saw449w+q6-^t#k3s_x#w-D8h}+|Keh2llE{0|h*ZMhr0t999C2URH13M*y3EJ(P9E)xU5ZQ}siNL$Xw< z-8=V}aj|?Cu&Wjq0m_snfW+8L?_It=%RLCK9{x)lNJYV7B&kIUh)3v@*Lz$ZIZRk* zn5=>xbQW!c;}Zr0kvKx3^F(e*Oid&MGNG*j`e#>dJZjrJdELHveQ`NBb{uwO{vWYJ z6(e<^2`e;{(3ZyOh4}N}{A6&{KE0q@7p9|MY5MAHR4*#lSZf9DYXc4trlfnUWZ+XI zcPjG~dWv;2pJPPPV4~Pvy=A@2v0YCp`4-hu>5pQga7cOqjSh>ZbQ;HjDbf;P+q_~$ z{UDrX4oa-^7GZ+Rc%x%$H}S6Ajgo9kV9vmn{tGSqA(f zB-7TYg-vd2oU)m>+L1KN2@z`QQu4jedGm6Zgyg#_4@@X*x4e|VELTU|hX?wS`?i!l z*b^EJh)_KbSvV`e0d*r}JixPSI;Ay>5}iX{zh6gu!JhJvPJg)de9fr?Y`4s05XYuG zyXKr?gLvJjtj{`I5O1PNZ@*%du7P~i%)Nh$AT6wo|!X}kl@{fa~qdF)CE!P1X*fU2KpddVM zyMin-FbbQ{@jVovzNjW)a2pA`2_D+#v9h#4FMm0$culP;!(BTo!jDrEl^V(Et@MT)(4V_^&gT9l2!4&7vC32OLf*VqF zvIWG;De%(K2$&sGX_-Tj#N`^BVpH`T5PbzkTBv84Ja{iquEF{B$IMLPw@k?t=e9MBi0JEYhRl9U4nQesaSCM;QjW)_M#>aH7Df`Jp;Ly>%OO47NnfyfI+7&Un# zI`M4hf#)3AP_X{QPnBA&0%oG~n#zmM02lK1qMo22UCgZ%A)TsI@mY-LNsLe2;>X;( z#o(fR03X4xBebkza0A3y(*RlMga5nVqxw(1mfrsZ3;NW*0sHvhe{Jo+tuMd-`V7}f z{g-|_@+sE1|NT$6cKG*SPoF*8>TW#&{qO8-ZGUt6kvza8)H?w?uX ze*6c`!*|sG&gQdcJ6**8r&~|H{Qm2+TwmK0m6}!d^zN?aRBi+C4-cqgy!zR()YCPO zF8CyI;pq!}Zz-C*bR6!Q(3v0^hEN@%eM}rGak+Cs2YncsY77 z_^CfQyF5HSX*zGIfZ@fkMCGbyUnPwR)G*Oa1KAv&pPpXgFPCf0<}Uxhv^4T@uV&hV z+6|y=*?@=iOmBqJ->C5nd`mX93mrh_gs&5CV&Bl8N0pNV6ry#hQ0xZrB?xu}U3FYNN|mmp+fu8DVLqDfN>+`*0^rmh&vohp8vlyAHd*xUrc>slcE=rjtHhBXH;-nWZ z%#?Q}NBVp2Nyb^!STu~>n$Dk~EC)xi8r?08VBX3@_>LvNEWt-2UzHC7h*z4`;33?= z{UD!Svx4EGw_c4EsTzHPwz^GYR^vEnV53L%p6m+sRj;arEF8(?bo`1M&5h>nuN|kKMa}*}6!(`9U`1`u+!S(QS$M58C`_Ub~NZ;sjeQV4}euxZK%yZBFMu-Sq_6JRq34B z%eh!h&LUBPUb;2O3HiU4#Fc(f=&_o|&*_*_LBTe}8;y8ys1 zmN|Ni_a8rQinq?6s+!;{Ow`O#i~V5PYxW{zNU9&7^a@JZ8V z#*Na>AvZ3@R2Tlfn453jF1HQ<%doewHA*iRqRM%Ei+&FXQgDTe2CjfWZfm`UYImED za>4HMvx>>me;`}EZR`+`kR*RT`IQ~4cF&N<-Cr>*zGu*;p+w#V47@AzY$W+!rV3I2 ze|z8F-!zgedj3Vf`yqM^3pOZDZ0Es{3FnyDfX{?Dn>aIY7&ar@a-zYOd?Yy`cb5IE z_uu^%w;tV6>tQ)fW z$>Bs3`Wu=QzvW0YcnTAnGf0})x4*sP0qD{o!#Q%;`Aj|F5R`3O*puGS={vUTW_g=5 z18xXuWPQ-3X9f}}_Vcxq1zjoGmHQ*MhI5o=rL|7+GQ_L)W)3KAj1OZ)If;$0lVj&b z{@;r)>HpoRZq#b2{4d+JjmpaZyNv6uGjRL%K%B|BK70B4^_g*(WByW4jrDaDPgfQQ z(!SjrTCChnaTY)4l2aVR%?}s~g7Mh&-bi?Rp@5Lq<`54Vq4Bq?{g&&H7OyHn{e%Sv zeSG!r@B&0#AjTjdF^nxR=&tuf3G^E{kGZ|rKejtd8Tbr`7Q>b07vt2)fLw&fX6E>p z=Zu-zjm3FdxET@*3w5HT;Vwqb>>2><5-9LV0z0~Q}PKN{>S|IpUsVo{I6{9tmOYPuFu*3MH^)3bjughHgYLq7HEjfAIm@QnYh{I zi-!;K*QLJaq&8$v>Idyt&9l%4Acd0H+Y^Uil?$+rg1i!Dfr94?=0+?TD2i!xy>AVB zyV4)R>4f_C$-)`c0OG*J!FNT2lj4kRKLP^W z;q0Ju(0X=UKW;Togm&%W`CUn9`>$V@hnA6ea5l8gPTHr(`&ccCPDE*xEe8$M8w~<_ zk34w?4N9<55^KYe-5=Q_eqP0r@DzT%Y&_qRzo-nD=VLr<2tyI}2UNN2zPPZhJ|>5e zCyme4!AQs7yH|{Vl+p#xUN-BErXE#^oYS~-=Z?`j+&?&N@R+!-Fb3IK*+*5Rq`Ij; z;1i&6CBx`C?%C0C`^9nnmDb=Hay&!-5n*#rD7l_|f6!1!TstTOR$?3rgJ)P03aE#- zA`>W2MDo|>wBP2H%l|n9cwxr?J|X^dbF;RJ|6Im3YySDq=X(F<>;F5INdMoiRcoaG zuj2ogb4C6?p6rzSPk*RfZT##;o;FhZ`+eTds+jcKsg~jmz0qWt|8n96&N&`B9$3Aw z82xgSzAen!qg-tWLfuxA#YUJF?FQw7|MlZinO9W}0^i-2#~yXB4#(!4)j$;pX=pBu z?7kRO)J@eC@~&3WHcjhpzeqROL%yl%@7sRf>(BMq%v%2oGXHO2|5q~We`A&ZeJNLL z=*Qgt4{ZL+!%Hjc|EAXsfCxK{S`9&O% zprGDTqma!EDtqoD*}$L*_f>gcgZmn_5@}VcrL?Z4_%o(4vN*lqaA@x-s2*h;k)@qI zm*V9syJBt40e-F3c(~^zMykD{j*vE^I+3der6=J2eK~E3s(Bhxy5>Ls$u+XSN{C{(&w&MTGxW2CcmkBL)|3<%4-rrag$&~treZR3pU5@KlTI=Nb z)$a2gzxwO6-#0?<%I*8-zjFD%%=YjV&;M^%wpae&Wn44oU;h2V@t+$z)f%7wuff}$ zEt3DM_>bjWk^fiDb;<#pc$#y7KYnsaNx+^`kSJ!1`NTlc&x`|Ad1~f)rwNEGtYSO= zmHIs;R_@%E(SW+!*BT5QPCk0$IKf@x#!-9oq60r8Ztq6x|BL4T*r;ySHsbYPqxg@_ zt(E_GDObECHD>?C^M5$r$a0Uxpn(tLMZWQ=EGh>FD4>Jotl|egO^0omI@6-DLF^*Ro0e{+S2LEq-P5=MK*2@3CjBDon%fDaN|5vSUZ_E6@TQ&I2 z{{Px4|L;<+wEo}t1Ni?M%Kz6WmY&e}P0xyjm-cYz6}~Zl;Frkx%ay#otyOg4Cs({h zn&6eQ@spg5y1#2y!eGsBb`$Jn^99dD-)AKaPLHGQB0bG^0?t4VW`8T)Vvv${XAJbF zsf?H8{B7LI`P+z`zm3~Df8&BGyK<(aa-OD&$_boSLB3A7mvLF&7g3L+T&l@{$%k`2 z(@7Xf&vXn#bNbHQ9L>PuuBRd9j7#$+bM)L*i^R^Kmyf3=+OabFxdn7<~C-rjoWO4@s8&33FG|u%@Q0PEHBuNUAcbm`?IB5oZgU`96y6<wBsbv(80hc0y;f4#+O<)Q7K zhp==XRo*3%>W!~yg39Ek0Yaf4z`5WSfF$P)9_S(M`T!4aoerFSXG8KTUh{ORwU!QD>`PAwl)rE>u=`ci8uv1Qh|-JaP(6M4T-Q7bP- zoXR^dO?O_#M^(cK#9Pu}@SDv}AD1A#D3#qfIrqE5tW1vCUVTz}ac))@v0OdciAX9E zQ-?zz=uI{7B+&;k03F!we>WvtWkS1H)HdfT!TBF4!FfKB-7wGjw90sWR=V@qfESSU ze0Bq?1^ogc?>lo$82tNy~x*0k*@mi zF=trG8JOGCFOWA~q^<=dQCFaDoJ)P`_|qxXGlf=})fbpqoqqDkfE*VJdj!~Y?pR%# z*ueR}cEaFG*B)I%QTe5|oB~AxkWsbRA%gFAMZ)och6VsEy>;I01tEUCoXrCT&PlsB zpm2_JgOd5iBT?S>O!w}K5E@gCi**0sT^aiboIKgftXzMazn}mDjD$6hx6naE1OSkxI9y@61^Z6S@|XyX zcr!<)bSGWp&`P@C2+2HW>FWCD=gww+rciI^CvP~(xHlz8%?QYBaj3oX$bZH<5<|PM zE6y`Kk+M*ZgY|YjU=PwX`jiEw2{SjDeQwl#0>-VJK=UU0$nrzS8m8wPNjQA_4p_|Z zHB)SvV&|i7Kn)$B0OY4|R}9VYk;>K$q}w)V6;afbb9qg0uF&wXzs?+*Za zap;(-&1H%DBw!lh`a>*`bSLVAtTkTvPCrh_!itny)I6l5y|`D~#n9+lUz|hDxRf-g z+P-t{xc1v*rFVP3ZeCC4+Y5vp;s!Usp~oYP6R?B%a!9;>^FL>G-?y%d$u0wG^_?-`f64c}6ZX3i z)z?G;i&8|BD?Na&XHWX*;#3c02gRdG0>aykcY6wj&bzn^zkyi`JTuXlWShh_6EHxA zB!90}-ib$un_W6+ON-CYY?s1*yM5f?wc|woUcL2=nXPM}QXN4LBLJFa2jyuB@{ll3 z`5F1~GcyyvLxdIH6cUdr*+*4)^gpU2(_2F)VX8H=&>Law3nGp+752~5v0}k7M|_I- z#c``4ihbL6E@36{GyMKDl`JLkjescX#HP)gUtHzflB%>^(fVd1f-lD8YHA2FweHjY z=h=S!7?ydfepnL3ejlzcG>rB}@qb_T{C{n8V_Tj7-Po>FIsR{z|7R&z>imBr_xyk3 z4|e{)ahvo1jnw)7M*93eZ`P)EF{f;U=Ozc39gH&beC8)andEJRPDx>)f@`$CE_ z-;MvYa0!MWhkd(%gjD16V+}MfiPWZVx1Fz{^5&cKdQynAd7S#jSdO<$Yw~t(sA7sQ;osD5%q7`d*?np3+|r!8 zMJAIeqfJFN&M6gz{bdQiU`F-QMf^7(K0Uv+DzLg&9%=RcQoea`uh zZ}bL`|86ADe>eUp=f4}vKL6d& z&wn@Ood0gjI{)2Ro&WwbU%C9hwcp-vFYNPQpK|`YhTnf$o&Wyw*Npk6e?R~0U-R=n zZpiO{p#0ya{O_OzY^~(~GOoz~OS7Hw{%X(ApE}c}8##cpPGZfedj$2^q9EO0xpf=+ zQv9BxuV6RtjpjGh{Jqq}8+?n5%CXDkU)nvnJRH|SzYOn!88VVL@P?Q2_tc#x4Dxoz z6Lx6^=xPbLMm$P7h?*Fjc$lcxu}9;f6)GnUn@5o!cM2d47X+?72^G8qoPj!191k}0 zHT#=15&KdJMxYNM({bgJz71f_eKZ?)ysu8Do=;AFQ{l;gUPT;2P%1R-%oM@6`k+kgsLEg2q!}_ac8@b@9!4ZT>bxxfB&ifS-xpLQkk^v;tsT>BO-oLU(6wfrHh^DJ#QbN&j$)o|{c%W+A)@T}sF*H?$x-Yj3 zl~S`;(3Cd{Bb#2lip4dJ4T>AGkTe*cBs8+(M#)TQTkrrl+Q+DtvNMRyIfG)NHb+M% z9<4nEyUIVd2drhrH5h!N20u#FP#?pStxNkwHU8ba*7x#tU3(bViO_I$+K!@6g1yuT zpi>-y$+5~ul>W+BTirr#$g2a=IknY+t`5)(T2l|F7txQCEBIudfoyOCuvJGz?j)x$ z2_D4_%O@rk?>cV3>h?J{hrS#Mq-qCIz<$ZBmP=6!*(n24*sceM_Lb_!$0W+9PTyXh zk#J*_D-!rLlxwx8p**L^@=#vOqFkf-9F(iLbV>fYP5+4tFu6Q7K4nd&CwyaeoUH77 zu3KT+!5LN8M{^HLz)g8P2``W7cpJHg-Jd`F@wokfT>P?xcSPhM>RA z!GPij`NW(<&>%@;TGTL+@hwDLYg!Mg(|VwhO zL2$4P)vB3TuljMm&zd`j_j|JnK6w%;L2(UA&xbd0W{_H@h&4plNoeoe!(mXYR5Jw} zH?aNi(Ebo&ks@UWIXdI;18BB={OYXJ>>SrOVPG*T7X;?f=Ar;SUKF5(q3BU%dr^?8 z8w-Q9FoahZhVk0MFkV|2#y1y+@y#s82Vk`X7cGJZE1Z{RX3MEzg%)WWN@R?#nL+Q( zD5Wt9Rb29b;`e4P-sU9zNay;d{^L<~$Be7%)@B|H;&Me*A=P+7SW2}o25@uRBdgTw z0*vLO6kv}lEWpg@zpeO(V9^o%6sZzh+OMc=^j6TnF@P=oXH-0XFjL;;HAy!j)kLC` z*?*GV+)DRzE7j4hOi#CN+|?91@Mog4^gv{Alk7sWzkI8AIP)@5NqZE@cs2bXnh0WO?px>E1UQnBsI$WZ7hJr;ARU&{1%CQd;-OG@c9(% zXbn_A{C{s&t7f%=I!N3IKHV^@HGC)ZhM*u8ha1ot^v3Wh6o;Fw8|V-`_}l0ZagC`u zgkB_9he#Z?{^9YiqtY?yHE+N(Up8OY9|OAMDSY(!p_A#u*WsDK2h&Vb=QO7Nu7sWT-6q%3v^L}A#n3Q& zPqqB8C=ZF2c)@V(1o6mL^9V{Gz$cMZ!livHlKP}5ofS!aagy3uG)aB!ZO_#uuNnLQ z3p)LCgY!SNS~~uxw!O;#u$1fTp8p|2i%a@>a=*sYaoXiEcakKM3n_IQ*>Shg}S8AJ^tMflgxpL>97W3lT zxc&TZZdP|z^S_L1`uz7ici^0#p#~Uy9x>d0{&zOEwpa7NjBEP*Yr_09+nA^SQQjzoW}+5*Ap1b*b0M5my*wR{{}{p3D4k` zwCuCLl>^Tdzo0>JuLx`zKdXV|5Cd^p-QFsdz*0y-c%p%%RszqsGjzpTAb#yyfsOGn z;@&@g1^lfv_&@(OhyN=J|Fhbdcm69+{;$q|FXx&w|Gf*l_x?-I|8{LNGym0<|8FUm zF}@BjJol_O!f!;`?j;JCljgzm=o9ICAeMZ4;Cv|ItK;SoC51hSAFrb~DNrw8)msPY zck3hhv2QAMRPVfm5_kvzh0wj?QGNf%`io}i3Ep;IQadcsXBAaKEb)*>lLI#bN6@(# zevK5!dyNhef{KA3HW+|}7Oz1@^5^M-vy=Vf)=>vkie1t7ur8fgq%(#0?hV9udr*2; zgcr8UFNG+IUOxtaeZh}?slFkmOH{Qa{`pT~e{e!k5deZ}4;;Shd#=3{@taxy$IW`< zRdbN5IDr5fr6VQR7(O0app_y)i_o|2=$!+LH}vQLtuw^T z>HCi!#m8v_&_vz$c3)gM;RWS?mag$KXyDPYA^a>V>X>~2I<++kJ(MwJVHh1xv<^=? z^@9Te%i)O(1QUTZ^zd6+?xo`c0Q_!(K!1cN;!=fHN+zv5!w{qQ&{0t?uj8g~{a_!- z`PpgfpppMdwq}U(I&D0kvA1L5+Xk-QTsX;xxK^S{VDvD<+xx-l2HtQI;)f6b6W%~% zTYU0WPr?H1d{$kD{ukOrHp}N7^KjhA=sk&Ug%xY+Mwxy;|G+EVlt8vi9ggG$v{&E ztprq0_2)aW21;E;sd~npyRtvwzl1O)oTeE_vC6hqH@k9fk~?EiG4OW0|} zNLFr!_QOo!9*9%yL;;E#cOI?-z>OuUeq0Ja_==VAXpS{)Q0@&$y%Tx;7B^95u^# zq7iAXDCbwKY}~o?@Lshfk$$Ium3HwVkK;}>k~IZs^jI+gDJ+o*R$<@ z5EJq6dd4_nQp0iFtHy1A)aejO2VQ>d)t6*TnzjkJbgt)&+4b0_N)4jO)SxZOD2@3h*720q4c6%4)UwA%;K@BP=W^?RT~Dtpj6{IPj_ z);_}8C&vEE=Khb;%a7eaLtg$YR?AiFG8aK#xItS2vSSEe+afSzIS#0iKR`n_w6TDW z-f8XAUGi+0 zv$MTg|I4^^{m-Ack-kKt3;sPvIlgzVeGE$o7(tpm%20yJ)A{^?DEw`0Ya=L-S_B%M zkc!zQz=9`F#XSj8RG;3jBowTB|A`9UMx+X`pnv|8Thy}@| zrYl|&mJsb9g#cI|d9Tw@quTp*eAWLI9xmtt=pCsOp^71+_mo3bpw5difbj$0#-y5{ zY5Ay~fWl!U^iE(tDHtCMnqnLeabN*z`k)=Bo4mAq2S387bXD1s_)g*r)#h}QdKc%l zml)1X8siDTf5f>Ldgv|JsVeltCN|DCiI4|@`3v;QgfixX=)o`R zCj3hGIs=1R5`}lAEO;Iva0XErI^EFoFsDv|A6Px+5^F7y8#RP4vXr~dn#S3TDhbNN z9jP;FC|g{01WX)!toHnf!YVLTzcTWF|H5+5?E~+8ac$h* z|F^lhx!V6*%9Wk}_R*Wx;fqDKF?;@D%Bxjv{x8@!u2I7M1V6uNa2d2cGIX=NF+U?w8=<?0fwy(_z4HZTGUdw+yUoj}jQ zuZea*&y$b>autm{{IZ}LzD3`PmY?Q^9)>8MtSjqUTzeDW7{Ji`-U#0W7gQcPPhEh) zg=Hb0@z$Jg1tD#D@r>E7?SuS1qBQr$fgA{Q7Z3fpeQxS}VgZUnm<()6%xVhX8LH1~ zYfyy5Xn+bCHX04b38*X$6!j@548$Y=0x2UVoWMwSO{lI}V@mXgjT3&P4=zC}MocOX z0u6&MjmC1Xg$H$fbkv>upp{)+cma7xFFZdWpE68Y=*f(sguUVkZX?MMuxk1w$(3}gm~jkM9*?*u-Ae+L#UTM4qyg7uZ&dlGy0OR0I_4+ zdXLy3tg4=v_zHXE+XLID>|B5WIe{k9Bqn(8*)YO3fY0w)kfA+&POT8B!nm+5d4@IW z(AEwwnN0sgQPPfoPNZPadIB=Igr?E>0np;g2`*@xmYYJis*O7Xa*Ma;^z36W{LwA5uI3<*1qBptlx zS02uaj|2#f;6FQO)A!Np=kvpS0CQa;- zL_b(0&H%}mQ1KjH=pU@ncnF1LiCl2Oq<0}Kg>t~vg^kP3ILGgW(1?j=h=C1&s2vc% z;@pw+2h`yJC=4h-z7k`B@QTYwAgz{pl~LUkIYX6eT3}{GY8rXLTSKEffKvyOi24y+ z07*cZks=0=D#(KfDiaLcfoZCy2G_8iMf0QG&8Lf6zJjV>WV zv}qxpw~vLircBXjopg>{&rb0b6@1lhw4S&2>%2XJX^u#9%2SmjITEsA1gytgdH#FJ z8C1}gVIgWz_Kt^^q*o-0nC)D6LliE7buCrf5on-YTVv&YV-m?9#-Y-a^VN$oqrGs% z{VRa>Yy;v{$F<|eB?*UB~Xed!!7`CjS86z9yoUk1lvi1gHAYAAwe&L2f z4G;=1kMPIU;rpKqYBs{Derv1oSMK~utNt_TKU>F)Xa#2-g*Hw z&nB{RxiW~wS^YjJ1++{8Q2^OdfQ3>A_I}9`2paHFU<2MruVQG*y62+0J)j10 zZb=3Z8+AgGh$2I1hHAM8Y|tK~>cv4Sz_GA%T^sasVq7rJoF13T#?P$ah=|Di398!& zE5KHi+=&L+_iUB~l`<$OxpsWJGZdz~=2( z|D~@XjGf-Zn*>8{9e57$a-dy!LSIh<0fRXJEMha%NxhU2uQbVd*HxHL>vG)rvhkn$?^7+|#**MWmxaHeZs%*tHjmRP~NmQXCI zCwgPaVQ|cmdZg)JD0Dw4%UmhVL^;)%a-@Do5P4L7KEWuCDLI?LoDE7$NG^`JyHi=Q zDP<|ssjg@eYfmyl$>2qfC^?aXs~A=n)@=@50%?H4J+f^k5*`Kbm`FMP#31jHRf>&( zo;3;Bf{1iR-cLZ)7;sC7g)!ptmLw+=Zd)O*X=P&)zWXvX2q7pA)JJPe5+0W-b3eM7 zeh_UU0wS;)z5qFLWl7W4;a#;W5YF^gCSi$VvGG~Jq7KKEVu5mEc^4Mzk=pGI&gk7>G39V43LyW8K}lSCch7o)<TDqOy%FH}674XGJ=NDB&n#*@v_wtxW09{q z9;XMQE$Tikr4&OVe}@&MnntJdB#bH;DWVH7HZuYXwTbnRjma#AO%o?b2o)nOR5+Ye zQ#hs2Vi?LOl(iHWGLjfz2XO2TVLOkN0Hq9r4e1~mUrNnD|rX6IN3Dw^6h0rr&q?_tC+C7wtap<<-@|42~{LPK{QK{2-O zeB9B%3{2Qrb_77VT>-OnL54%z6qz@M{lWIx{8f%K_6?y6W0;F<&4BWJQ0Io|%~0l4 zkgE#7m|HHI77lOcjF8h==jVte1yxKPW=H` zy+P>t7!}SuJsuzHzA+c-`ilQ)y<@gXG>ukDu9U0IR@Ku(NcSF1NEW6_{i&8vMtR-e z(5Iq&;Fu<05)!{bjVwq08YgPSRj3bDL0Z%_B?_1Uy3AChGr2SX1F`;8@8Jn9R9Aq0 zquIb`Lz`rs&pu@mgdt}rd;!C)oMG`rcsyUA_|yOXf`Y9r&2J}1hMQ-?L$o&GU_PgJ+m+?hRgg+ zsxflgmfZsbav!>=i6W;2vn}K9P;LYidRRZ|pRQ}oU%WKlNI|tCszb9J@Z!s(k|&d{ zk`7(QKBz9Jxg<8o1~F4%j~Mrbwgq`QMv>&iLbw?xJ+(>84Dd-iqR+`_&^yf@xoGKg z>jt&XO{)EvOuyhcG=dpY$h|AA7O?DwlYlG}D+s)vqa0$e1n>in^o@CkeXVF`$@0vH z>Etw%8b~!IzxeE_70py4MT;DMJR%t7OPKgeL^|qrMliN%#%-m{nwjzF%Z0Z1P-;kj z9PZ}P=3wONiIiHsS`p25b{9&>fTJ#1AO_A;DP9R9>o?K>qBFEbdAb&Q{2s{I9mUTxjhsx#c$4EtO9`+#aY=8XK1WR%QUM?i-|=m?mCP1gAWk3dL$CliRCTbuzwbW`=ErIGfux9LK3P6VX zl)6pIC;@{P6VmeoBTubNa7o;xK>c`fexdPpNA8%jlXEl%qe%-Y(SW4fMH(`2*FcEP zSZClMSabxjyT-(mNJFK+>RL-emoS)8k$UY9V|3(_0VPGfV&|Hwg1edMU;?TbhX(05 zSELPkQ=6aOI`U84S7I8Zy&?{*45ctbDdONnCiXpZx@AP`P$3vqXxbEtm@E6N2pMXd zou(HhgwoJ7pJ25ArXm*{KMuc%Iz~%}rU}g(FU^$6?9_3mkMxs?BL49T{#x%r+W6D#b+NxQBU;CO*4ulUupcr3Wm0%EX{Q zC=Akj9~^sw7O$nOGM_f-E}X6tva5b*T}8Y1(ooEfhv9&5@o;atd(9hTI@wF?+`$dUUPLwAz9pTyi8&5QfyHfV^f;<8quXrkagU?!8!05FOdJ{NuwCYT zl+YR3QbC!e>dzT*s0THq7LX){NdsB4blBSIGc~t|^H!ZgG{3*N7tTHjf+`TPXLdVYyE1pkx{v6_PSccqBqV+9}HT7aSD#3N$~` zNWffH4ac0iq~tV)`oS^@rKTS>ky;}rZ@2MUMsb18Pi!|5jnnIL$c2o5!s@zD-;>&S zfKfX@UV($3>9t&&H;Z@!17yg#)GK4IZ|K`LTC^U0pM}O7SCgVYGl{5rE5e+z_T;vI zHZsXlvl~Uvc#|P3avUQneD4~}gzGg5DbNrohv7j3Y~EfzjaJiKPN zee?^=NYW}`95O)(X$WXo$dFGY2I!SSZx@h+$}>BnbU8=Gy2uQ1N8LxE6}f|Gl4o?E zbvSL)C*zQU+Y5V$nlu~37)j^yqO?iNW6?_>a547iRCv$vdy`Q>T$?#u*BZtw+}6Qs zk*EecCDne4Dx_^oq#{>k0Hw<$Wa!P}4r(jmavM*4;$S&GH<+1;l+W~wSG^W}62xH@ z=;#Mhy_ViHa@VOqJ?X1s$AJ@G%iSP@yxClGH`(}wB`q2poz_FO%O@jgaM0(zgc!;& z%-FzAOff6{X5?Qr93*|@BrM{`9G;=5e@rfUM3@k-XdZ13%Euu&#yQ4yz_MnpBb$j# z@hjZI_h}Cjqx&*lvipXjc4A%9CZT9V$e$>Aqayo6+fQW7#FzVIB< z2|KA(qmwCx#9>FV74+^?fYX&U61#u~`;r$x*Um~Sma0LRVb5elJT9xvwX~mNT}Hj8 zIF=J=;S;!hpn^lmFrq9@(mF+2iK)MP9q(-Eb~^LuSRKj45+PS4(gMOf!RmCC^=w;#J+KNDp@%FFjCo;iPdNrPU-C(ez>sr4B_y470Mue}Il*5T-U*IPhe3-62@@o|gUlWJ z9*iBI!q%0WDZqs*Yw+<1>>+1$p~NpXkl2t|JO><66Hx>uZ*u@4QV1j|*Af^`75Z0Q zN}duRL!7{%kuRzeE`6OSjt^C~F?n+aWUZ&lW()~tm0CcZl(Yq8-WaImD+mQMw&F-+ zs~C;gd9FE7lM1y85>q>bs#Bh?q6QL8sR@q5^pG5k9CFBvJ>Jk@BwXjAAhk($9mTMC zO3znS&^FEQP2QOd4qe(PE9FteplYjwbcIa(3B|%O|J9>V1G#^fSivc!I?5kp(h{?i z^1+ZX^r*hamb6q2BPkH=N9t^D4(3zMOF9ufaLpeUod3++_Q$Xx@qnCmx}CIEdZ7?;c#B4A3Fi)kvid%I5)$Pypb2#?0E8r zV;lOwV5As{s+==F8D7UnoetaL=lbz+{jl?f=D$)F&zk%7)03v?yle{jB^uE>QBkoC z@%*^i6z%6?|7HF7MbpG`$4xAu!@?L@4FHsC)9>c%PV=xMj+)1>TAdC+d-g`ukB$I1 zrsxm{^`8No&DZu|S0To(@;^*U5r*-&(0Ae8SaqGp)j(FKV zpl|fl4;$;yI#m=$_2W*fd1636erh$6gDTWdpxXuUbF1^RecFjSkAtfpz7apR4jZOu zwg^!3_0e(j1jcUw?A9yjaT8v0VsZ)ueg+T@+a16Yj12nOX%lKxSp^-xmehW3ylNf; z{ti3!XRU)4G>MVJ&s&{CXoBL4>)iAG(}Ow;;`I2aebPk#4WbZ$0K$)3CqIh%i6IgD z_tSa=2(Sw*JUwoJ4Js;7YFSVBsOTI zQy0`@`1`DhrH`A3fG=83_5J+`5=GJjTttY~>z#JZ@ z#~B)fmfL_r1WB|OO^710lafg^AX?9%sr{F7_C#XUz7a2BDxNi=SiSL63po$BW58NC zX-S;4B?O5_Vr+B*6~;&9a{~A=_8*J9?U4M3hi{PK9)hwXrCfj%EG1)~ zzlR3GS!zRZ9Hn-?O-AWSVR=sHKZ4Kz8-(3tlOU2mY}!eS8%+juCXi410!<87dN|IV zGmC~sQWmfbj1KHzU{b=lsT~E4Hj9<}P@RZVF4-`&@qM(%M48%nkA*V5sKcUs0)=A+K|#2*ujQTamtaVV0H20GzQ2Rhw|avhK)gCKuEd{TWCF`yyf z0Vr#@L&c!GV0#P%h{9IjQDVM# zqtlIvS!V4wJ{-molwp3jXWmKUI5Im(=#5dd-gHGNK1ji5$yFl<@n#r7DJG+&OIiK7 zoR0u~D^{9e7Z}wON<1s23zij3Cx5;h4H_lfkqIdQzZ;#vkXwc1-W^iJpbF^(MH@k+ zq14dH}Ihrau#fx@UAcu~Qb)Bx`K#D}1$aKImJVM*XjB&Y(_AJo) zEESmQrw{gaXIK5L08vyJg;zURWI_)s8zeiGBov-2|% zvyq5VH5HFkM@uY3rXPj%4xRVRQ4I=#gmT280zOxfh<1f#WXqVU7cQvTm#p6_BH#Yr zOs#2L(n2H`bf$U_3<`OSwEpa*eEeo0PEF*a=bRuOd%FP zBoXW(wu6XG@d$z-k5ff1BxRND>do~Y=p89@^vcEc7;Qb;>WTxuRsX0DQEf@Y>hNvi zfJwrXoO%SUJ)qqcxgip_N4v)XIy$e>$AQ~!v?&ax8aWxX^G~^5lgF9ZSx-!$Ya1gE zK(6(m2k*(ZF|yqWAj}>GYir2P$({}-4sY&8$NuF(5;<6k&%+bRRKy0h;$1_vqB{H@ zMI_7GBik}{A$qHe`9aNORM+Z_K6Svz|kal{u`*Ia}7()bDx@`0t%b& z3@IZCYA*c3#H1a8qmFs~1QaBlyHj{?hVc00|K(y25>%7Rq zeOlkcZE9O(%a8mth6)j9@Szyr)B=-ap?qeVH7B%O35QV0wuhc3(5;KJ>6)CDt zcK1Q6Q-^4B5?&bj2`{q#&99x&W_8`>%H)5lpMoNEywFbo%+3F`wUf#Jw6)6rxs>bB z>3KsCH2XY!nd_^o*NiK({6@FcklGZV$DaV#c=(hnDUja6>nHwt7~ + python components.py + +You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. + +To run a coupling: + + 1. start SALOME in background : ./appli/runAppli -t + 2. start a SALOME session : ./appli/runSession + 3. start YACS coupler with coupling file : driver coupling.xml + 4. examine output files in /tmp + 5. shutdown SALOME : shutdowSalome.py + 6. exit session : CTRL-D (or exit) diff --git a/Examples/paco1/components.py b/Examples/paco1/components.py new file mode 100644 index 0000000..7b98056 --- /dev/null +++ b/Examples/paco1/components.py @@ -0,0 +1,51 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../pacocontext.py") +from module_generator import Generator,Module,Service,PACOComponent + +cwd=os.getcwd() + +body=""" +c = a + b; +""" + +c1=PACOComponent("paco1", + "dummy", + services=[ + Service("run",inport=[("a","double"),("b","double")], + outport=[("c","double")], + body=body, + impl_type="parallel" + ), + ], + ) + + +g=Generator(Module("pacocompos",components=[c1],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + diff --git a/Examples/paco1/coupling.xml b/Examples/paco1/coupling.xml new file mode 100644 index 0000000..06b7840 --- /dev/null +++ b/Examples/paco1/coupling.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + paco1 + + run + + + + + + run0a + 5 + + + run0b + 4 + + + + diff --git a/Examples/paco2/Makefile b/Examples/paco2/Makefile new file mode 100644 index 0000000..f289145 --- /dev/null +++ b/Examples/paco2/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so *.pyc pacocompos_SRC pacocompos_SRC.bak appli appli.bak install install.bak traceExec_proc diff --git a/Examples/paco2/README.txt b/Examples/paco2/README.txt new file mode 100644 index 0000000..efa5554 --- /dev/null +++ b/Examples/paco2/README.txt @@ -0,0 +1,25 @@ +A C++ component dynamically loadable +========================================= + +To build this example, modify the components.py file +to take into account your configuration. + +1- your prerequisite file +2- your KERNEL_ROOT_DIR + +Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: + + source + python components.py + +You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. + +To run a coupling: + + 1. start SALOME in background : ./appli/runAppli -t + 2. start a SALOME session : ./appli/runSession + 3. start YACS coupler with coupling file : driver coupling.xml + 4. examine output files in /tmp + 5. shutdown SALOME : shutdowSalome.py + 6. exit session : CTRL-D (or exit) diff --git a/Examples/paco2/components.py b/Examples/paco2/components.py new file mode 100644 index 0000000..2fe920e --- /dev/null +++ b/Examples/paco2/components.py @@ -0,0 +1,51 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../pacocontext.py") +from module_generator import Generator,Module,Service,PACOComponent + +cwd=os.getcwd() + +body=""" +c = a + b; +""" + +c1=PACOComponent("paco1", + "mpi", + services=[ + Service("run",inport=[("a","double"),("b","double")], + outport=[("c","double")], + body=body, + impl_type="parallel" + ), + ], + ) + + +g=Generator(Module("pacocompos",components=[c1],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + diff --git a/Examples/paco2/coupling.xml b/Examples/paco2/coupling.xml new file mode 100644 index 0000000..704d919 --- /dev/null +++ b/Examples/paco2/coupling.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + paco1 + + run + + + + + + run0a + 5 + + + run0b + 4 + + + + diff --git a/Examples/paco3/Makefile b/Examples/paco3/Makefile new file mode 100644 index 0000000..18fe4f9 --- /dev/null +++ b/Examples/paco3/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so *.pyc DSC_PARALLEL_PARAM_SRC DSC_PARALLEL_PARAM_SRC.bak appli appli.bak install install.bak traceExec_proc diff --git a/Examples/paco3/README.txt b/Examples/paco3/README.txt new file mode 100644 index 0000000..efa5554 --- /dev/null +++ b/Examples/paco3/README.txt @@ -0,0 +1,25 @@ +A C++ component dynamically loadable +========================================= + +To build this example, modify the components.py file +to take into account your configuration. + +1- your prerequisite file +2- your KERNEL_ROOT_DIR + +Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: + + source + python components.py + +You should get a SALOME module in source form (cppcompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and cppcompos. + +To run a coupling: + + 1. start SALOME in background : ./appli/runAppli -t + 2. start a SALOME session : ./appli/runSession + 3. start YACS coupler with coupling file : driver coupling.xml + 4. examine output files in /tmp + 5. shutdown SALOME : shutdowSalome.py + 6. exit session : CTRL-D (or exit) diff --git a/Examples/paco3/components.py b/Examples/paco3/components.py new file mode 100644 index 0000000..de0b1fd --- /dev/null +++ b/Examples/paco3/components.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 *- +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../pacocontext.py") +from module_generator import Generator,Module,Service,PACOComponent + +cwd=os.getcwd() + +master_body=""" + // Init data + Ports::Param_Double_Port::seq_double data; + data.length(10); + for (double i=0; i< 10; i++) + data[i] = i; + _master_port_port->configure_port_method_put(10); + _master_port_port->put(data); + + Ports::Param_Double_Port::seq_double * results; + _master_port_port->get_results(results); + std::cerr << "Master receive a sequence of length = " << results->length() << std::endl; + for (int i = 0; i < results->length(); i++) + std::cerr << "Master receive data : " << (*results)[i] << std::endl; + delete results; +""" + +worker_body=""" + // Réception des données + Ports::Param_Double_Port::seq_double * data = _worker_port_port->get_data(); + std::cerr << "Node " << getMyRank() << " receive a sequence of length = " << data->length() << std::endl; + for (int i = 0; i < data->length(); i++) + std::cerr << "Node " << getMyRank() << " receive data : " << (*data)[i] << std::endl; + delete data; + + // Envoi des données + data = new Ports::Param_Double_Port::seq_double(); + data->length(5); + for (double i=0; i< 5; i++) + { + (*data)[i] = i + i + (getMyRank() * 20); + } + _worker_port_port->configure_set_data(5, 5*getTotalNode(), 5*getMyRank()); + _worker_port_port->set_data(data); + delete data; +""" + +c1=PACOComponent("MASTER", + "dummy", + services=[ + Service("StartMaster", + parallel_outstream=[("master_port", "Param_Double_Port")], + body=master_body, + impl_type="parallel" + ), + ], + ) + +c2=PACOComponent("WORKER", + "mpi", + services=[ + Service("StartWorker", + parallel_instream=[("worker_port", "Param_Double_Port")], + body=worker_body, + impl_type="parallel" + ), + ], + ) + + +g=Generator(Module("DSC_PARALLEL_PARAM",components=[c1, c2],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + diff --git a/Examples/paco3/coupling.xml b/Examples/paco3/coupling.xml new file mode 100644 index 0000000..6c35b5b --- /dev/null +++ b/Examples/paco3/coupling.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + MASTER + + StartMaster + + + + WORKER + + StartWorker + + + + StartMaster2 master_port + StartWorker3 worker_port + + + + + ForLoop0nsteps + 10 + + + + + + + diff --git a/Examples/pacocontext.py b/Examples/pacocontext.py new file mode 100644 index 0000000..5c3ad4e --- /dev/null +++ b/Examples/pacocontext.py @@ -0,0 +1,40 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +KERNEL_ROOT_DIR=os.getenv("KERNEL_ROOT_DIR","/local/cchris/Salome/Install/KERNEL_V5") +GUI_ROOT_DIR=os.getenv("GUI_ROOT_DIR","/local/cchris/Salome/Install/GUI_V5") +YACS_ROOT_DIR=os.getenv("YACS_ROOT_DIR","/local/cchris/Salome/Install/YACS_V5_1_main") + +context={'update':1, + "makeflags":"", + "prerequisites":"/local/cchris/.packages.d/envSalome5", + "kernel":KERNEL_ROOT_DIR, + "paco":"/local/cchris/pkg/paco/install", + "mpi":"/usr/lib/openmpi", + } + + +aster_home="/local/cchris/Aster/V10.1/aster" +aster_version="STA10.1" +#aster_home="/local/cchris/Aster/V10/Install" +#aster_version="STA10.0" + + diff --git a/Examples/pydoc1/Makefile b/Examples/pydoc1/Makefile new file mode 100644 index 0000000..864b877 --- /dev/null +++ b/Examples/pydoc1/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.pyc pycompos_SRC pycompos_SRC.bak appli appli.bak install install.bak traceExec_proc diff --git a/Examples/pydoc1/components.py b/Examples/pydoc1/components.py new file mode 100644 index 0000000..72c35f2 --- /dev/null +++ b/Examples/pydoc1/components.py @@ -0,0 +1,55 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../context.py") + +from module_generator import * + +defs=""" +""" + +body=""" + c=a+b + d=a-b +""" + +c1=PYComponent("pycompos",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double"),("d","double")], + defs=defs,body=body, + ), + ], + ) + +modul=Module("pycompos",components=[c1],prefix="./install", + doc=["*.rst","*.png",], + ) + +g=Generator(modul,context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + + diff --git a/Examples/pydoc1/exec.png b/Examples/pydoc1/exec.png new file mode 100644 index 0000000000000000000000000000000000000000..16a20c116e8243a6b49ed862613d2cc49bdf4caa GIT binary patch literal 831 zcmV-F1Hk-=P)A+3!%gdoE?w?yY*XMamxaAW~()k6;QGVVf3ZPpQcy+38CrH3{Qk zoaxN-vWJ+OcH(Y#5qvHK|CitMf1CdUU;7AQ8zF4-#i736F~#EMso~pq*Ek7JMLa$}POH_T(b)M|f)>8t;^3f3 zKA)#ntMKyW+7Z-s>l6xWsZ53jrMAEC5{41RXe`Snj$`6DMr+Vop|xgsc$hE@Sz20V zb@eG)%b|Y+_m{*NND_%L1}POFH@MUObOdhQq^%&CMdWZvC2q+x@_Pg_JQ$DGG%bJbwIyVzG#2o#E=$@5yGf z#Bm5%IplY1BB@I((}Bdlpj1;;nAaqNZEDBWHP2)F0;K|LMcrchIBe@ z&Ye4p5H>e&{)pCc=qTd1Z_6|q4IIZIpUy{Fg7-dG2KQ=nb2l+s9 + python components.py + +You should get a SALOME module in source form (pycompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module pycompos. + +Launch SALOME : ./appli/runAppli -k +activate the pycompos module, look at the doc, activate commands, ... diff --git a/Examples/pygui1/components.py b/Examples/pygui1/components.py new file mode 100644 index 0000000..d19cea1 --- /dev/null +++ b/Examples/pygui1/components.py @@ -0,0 +1,118 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../context.py") + +from module_generator import * + +defs=""" +""" + +body=""" + c=a+b + d=a-b +""" + +idldefs=""" +#include "myinterface.idl" +""" + +compodefs=r""" +import SALOME_DriverPy +import traceback + +class A(SALOME_DriverPy.SALOME_DriverPy_i): + def __init__(self): + SALOME_DriverPy.SALOME_DriverPy_i.__init__(self,"pycompos") + return + + def createObject( self, study, name ): + "Create object. " + try: + print study,name + builder = study.NewBuilder() + father = study.FindComponent( "pycompos" ) + if father is None: + father = builder.NewComponent( "pycompos" ) + attr = builder.FindOrCreateAttribute( father, "AttributeName" ) + attr.SetValue( "pycompos" ) + + object = builder.NewObject( father ) + attr = builder.FindOrCreateAttribute( object, "AttributeName" ) + attr.SetValue( name ) + except: + traceback.print_exc() + + def DumpPython( self, study, isPublished ): + abuffer = [] + abuffer.append( "def RebuildData( theStudy ):" ) + names = [] + father = study.FindComponent( "pycompos" ) + if father: + iter = study.NewChildIterator( father ) + while iter.More(): + name = iter.Value().GetName() + if name: names.append( name ) + iter.Next() + pass + pass + if names: + abuffer += [ " from salome import lcc" ] + abuffer += [ " import pycompos_ORB" ] + abuffer += [ " " ] + abuffer += [ " compo = lcc.FindOrLoadComponent( 'FactoryServerPy', 'pycompos' )" ] + abuffer += [ " " ] + abuffer += [ " compo.createObject( theStudy, '%s' )" % name for name in names ] + pass + abuffer += [ " " ] + + return ("\n".join( abuffer ), 1) + +""" + +c1=PYComponent("pycompos",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double"),("d","double")], + defs=defs,body=body, + ), + ], + idls=["*.idl"], + interfacedefs=idldefs, + inheritedinterface="Idl_A", + compodefs=compodefs, + inheritedclass="A", + ) + +modul=Module("pycompos",components=[c1],prefix="./install", + doc=["*.rst","*.png"], + gui=["pycomposGUI.py","demo.ui","*.png"], + ) + +g=Generator(modul,context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + + diff --git a/Examples/pygui1/demo.ui b/Examples/pygui1/demo.ui new file mode 100644 index 0000000..69e4ac0 --- /dev/null +++ b/Examples/pygui1/demo.ui @@ -0,0 +1,146 @@ + + + + + DemoDialog + + + + 0 + 0 + 400 + 300 + + + + PyUIC4 Demo Dialog + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + + + 6 + + + + + Add items + + + + + + + Clear list + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + + + + + + okButton + clicked() + DemoDialog + accept() + + + 369 + 256 + + + 96 + 254 + + + + + button2 + clicked() + list + clear() + + + 92 + 112 + + + 279 + 123 + + + + + diff --git a/Examples/pygui1/exec.png b/Examples/pygui1/exec.png new file mode 100644 index 0000000000000000000000000000000000000000..16a20c116e8243a6b49ed862613d2cc49bdf4caa GIT binary patch literal 831 zcmV-F1Hk-=P)A+3!%gdoE?w?yY*XMamxaAW~()k6;QGVVf3ZPpQcy+38CrH3{Qk zoaxN-vWJ+OcH(Y#5qvHK|CitMf1CdUU;7AQ8zF4-#i736F~#EMso~pq*Ek7JMLa$}POH_T(b)M|f)>8t;^3f3 zKA)#ntMKyW+7Z-s>l6xWsZ53jrMAEC5{41RXe`Snj$`6DMr+Vop|xgsc$hE@Sz20V zb@eG)%b|Y+_m{*NND_%L1}POFH@MUObOdhQq^%&CMdWZvC2q+x@_Pg_JQ$DGG%bJbwIyVzG#2o#E=$@5yGf z#Bm5%IplY1BB@I((}Bdlpj1;;nAaqNZEDBWHP2)F0;K|LMcrchIBe@ z&Ye4p5H>e&{)pCc=qTd1Z_6|q4IIZIpUy{Fg7-dG2KQ=nb2l+s9A+3!%gdoE?w?yY*XMamxaAW~()k6;QGVVf3ZPpQcy+38CrH3{Qk zoaxN-vWJ+OcH(Y#5qvHK|CitMf1CdUU;7AQ8zF4-#i736F~#EMso~pq*Ek7JMLa$}POH_T(b)M|f)>8t;^3f3 zKA)#ntMKyW+7Z-s>l6xWsZ53jrMAEC5{41RXe`Snj$`6DMr+Vop|xgsc$hE@Sz20V zb@eG)%b|Y+_m{*NND_%L1}POFH@MUObOdhQq^%&CMdWZvC2q+x@_Pg_JQ$DGG%bJbwIyVzG#2o#E=$@5yGf z#Bm5%IplY1BB@I((}Bdlpj1;;nAaqNZEDBWHP2)F0;K|LMcrchIBe@ z&Ye4p5H>e&{)pCc=qTd1Z_6|q4IIZIpUy{Fg7-dG2KQ=nb2l+s9 python components.py You should get a SALOME module in source form (pycompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and pycompos. +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module pycompos. To run a coupling: diff --git a/Examples/pyth1/bidul.py b/Examples/pyth1/bidul.py index f622882..8085bd2 100644 --- a/Examples/pyth1/bidul.py +++ b/Examples/pyth1/bidul.py @@ -1,2 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + def f(): print "coucou" diff --git a/Examples/pyth1/components.py b/Examples/pyth1/components.py index ae8608f..61c29a8 100644 --- a/Examples/pyth1/components.py +++ b/Examples/pyth1/components.py @@ -1,10 +1,27 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os -from module_generator import Generator,Module,Service,PYComponent -context={'update':1, - "prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5", - } +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,PYComponent cwd=os.getcwd() @@ -46,5 +63,6 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli("appli",restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + diff --git a/Examples/pyth1/coupling.xml b/Examples/pyth1/coupling.xml index cd9b441..7c95f94 100644 --- a/Examples/pyth1/coupling.xml +++ b/Examples/pyth1/coupling.xml @@ -1,65 +1,75 @@ - - - - - - - - - - - - - - compo2 - s1 - - - - - - - - - - - compo2 - s1 - - - - - - - - - - - - node1ba - node2aa - - - node2ba - node1aa - - - - node1 a - 23 - - - node1 b - 53 - - - node2 a - 63 - - - node2 b - 73 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + compo2 + + s1 + + + + + + + + + compo2 + + s1 + + + + + + + + + node1 ba + node2 aa + + + node2 ba + node1 aa + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + + - diff --git a/Examples/pyth2/Makefile b/Examples/pyth2/Makefile new file mode 100644 index 0000000..34110e4 --- /dev/null +++ b/Examples/pyth2/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so *.pyc pycompos_SRC pycompos_SRC.bak appli appli.bak install install.bak traceExec_proc compo2_inst_1 diff --git a/Examples/pyth2/README.txt b/Examples/pyth2/README.txt index 706ee53..88498ae 100644 --- a/Examples/pyth2/README.txt +++ b/Examples/pyth2/README.txt @@ -1,19 +1,19 @@ A Python standalone component (in executable form) ======================================================= -To build this example, modify the components.py file +To build this example, modify the ../context.py file to take into account your configuration. 1- your prerequisite file 2- your KERNEL_ROOT_DIR -Then set the environment (including PYTHONPATH for YACGEN, ../.. from here and execute components.py :: +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here and execute components.py :: source python components.py You should get a SALOME module in source form (pycompos_SRC), its installation (install) and -a SALOME application (appli) composed of modules KERNEL, GUI, YACS and pycompos. +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module pycompos. To run a coupling: diff --git a/Examples/pyth2/components.py b/Examples/pyth2/components.py index 336c58c..65e312f 100644 --- a/Examples/pyth2/components.py +++ b/Examples/pyth2/components.py @@ -1,10 +1,27 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os -from module_generator import Generator,Module,Service,PYComponent -context={'update':1, - "prerequisites":"/local/cchris/.packages.d/envSalome50", - "kernel":"/local/chris/SALOME2/RELEASES/Install/KERNEL_V5", - } +#import context from .. +execfile("../context.py") +from module_generator import Generator,Module,Service,PYComponent cwd=os.getcwd() @@ -42,5 +59,5 @@ g.bootstrap() g.configure() g.make() g.install() -g.make_appli("appli",restrict=["KERNEL","GUI","YACS"]) +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) diff --git a/Examples/types1/Makefile b/Examples/types1/Makefile new file mode 100644 index 0000000..283148d --- /dev/null +++ b/Examples/types1/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +clean: + rm -rf *.o *.so mymodule_SRC mymodule_SRC.bak appli appli.bak install install.bak traceExec_* diff --git a/Examples/types1/README.txt b/Examples/types1/README.txt new file mode 100644 index 0000000..7769282 --- /dev/null +++ b/Examples/types1/README.txt @@ -0,0 +1,25 @@ +A test for several YACS types SALOME_TYPES and others +========================================================= + +To build this example, modify the ../context.py file +to take into account your configuration. + +1- your prerequisite file +2- your KERNEL_ROOT_DIR + +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here and execute components.py :: + + source + python components.py + +You should get a SALOME module in source form (module_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module module. + +To run a coupling: + + 1. start SALOME in background : ./appli/runAppli -t + 2. start a SALOME session : ./appli/runSession + 3. start YACS coupler with coupling file : driver coupling.xml + 4. examine output files in /tmp + 5. shutdown SALOME : shutdowSalome.py + 6. exit session : CTRL-D (or exit) diff --git a/Examples/types1/components.py b/Examples/types1/components.py new file mode 100644 index 0000000..3de0d1f --- /dev/null +++ b/Examples/types1/components.py @@ -0,0 +1,230 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import os + +#import context from .. +execfile("../context.py") + +from module_generator import Generator,Module,Service,CPPComponent,PYComponent,add_type,add_module + +#overload module GEOM definition +idldefs=""" +#include "GEOM_Gen.idl" +""" +makefiledefs=""" +#module GEOM +GEOM_IDL_INCLUDES = -I$(GEOM_ROOT_DIR)/idl/salome +GEOM_INCLUDES= -I$(GEOM_ROOT_DIR)/include/salome +GEOM_IDL_LIBS= -L$(GEOM_ROOT_DIR)/lib/salome -lSalomeIDLGEOM +GEOM_LIBS= -L$(GEOM_ROOT_DIR)/lib/salome +SALOME_LIBS += ${GEOM_LIBS} +SALOME_IDL_LIBS += ${GEOM_IDL_LIBS} +SALOME_INCLUDES += ${GEOM_INCLUDES} +IDL_INCLUDES += ${GEOM_IDL_INCLUDES} +""" +configdefs=""" +if test "x${GEOM_ROOT_DIR}" != "x" && test -d ${GEOM_ROOT_DIR} ; then + AC_MSG_RESULT(Using GEOM installation in ${GEOM_ROOT_DIR}) +else + AC_MSG_ERROR([Cannot find module GEOM. Have you set GEOM_ROOT_DIR ?],1) +fi +""" +add_module("GEOM",idldefs,makefiledefs,configdefs) + +#overload GEOM_Object definition +add_type("GEOM_Object", "GEOM::GEOM_Object_ptr", "GEOM::GEOM_Object_out", "GEOM", "GEOM::GEOM_Object","GEOM::GEOM_Object_ptr") + + +cwd=os.getcwd() + +defs=""" +""" + +body=""" +//inputs +//Parameter +std::cerr << "Parameter:" << std::endl; +std::cerr << "a: " << a.name << "=" << a.value << std::endl; +std::cerr << "" << std::endl; + +//ParameterList +std::cerr << "ParameterList:" << std::endl; +for(CORBA::ULong i = 0;iname << "=" << aa->value << std::endl; +//ParameterList +ab=new SALOME_TYPES::ParameterList; +ac= new SALOME_TYPES::Variable; +ad= new SALOME_TYPES::VariableSequence; +ad2= new SALOME_TYPES::StateSequence; +ad3= new SALOME_TYPES::TimeSequence; +ae= new SALOME_TYPES::VarList; +af= new SALOME_TYPES::ParametricInput; +ag= new SALOME_TYPES::ParametricOutput; +""" + +s2body=""" +std::cerr << "service s2 C++ component" << std::endl; +aa=GEOM::GEOM_Object::_duplicate(a); +a->Register(); +""" + +c1=CPPComponent("compo1",services=[ + Service("s1",inport=[("a","SALOME_TYPES/Parameter"), + ("b","SALOME_TYPES/ParameterList"), + ("c","SALOME_TYPES/Variable"), + ("d","SALOME_TYPES/VariableSequence"), + ("d2","SALOME_TYPES/StateSequence"), + ("d3","SALOME_TYPES/TimeSequence"), + ("e","SALOME_TYPES/VarList"), + ("f","SALOME_TYPES/ParametricInput"), + ("g","SALOME_TYPES/ParametricOutput"), + ], + outport=[("aa","SALOME_TYPES/Parameter"), + ("ab","SALOME_TYPES/ParameterList"), + ("ac","SALOME_TYPES/Variable"), + ("ad","SALOME_TYPES/VariableSequence"), + ("ad2","SALOME_TYPES/StateSequence"), + ("ad3","SALOME_TYPES/TimeSequence"), + ("ae","SALOME_TYPES/VarList"), + ("af","SALOME_TYPES/ParametricInput"), + ("ag","SALOME_TYPES/ParametricOutput"), + ], + defs=defs,body=body, + ), + Service("s2",inport=[("a","GEOM_Object"),],outport=[("aa","GEOM_Object"),],body=s2body,), + ], + ) + +pydefs="""import SALOME_TYPES""" + +pybody=""" +print a,b,c,d,d2,d3,e,f,g +aa=SALOME_TYPES.Parameter(name="a",value="45.") +ab=[] +ac=[1,2,3] +ad=[[1,2,3]] +ad2=[[[1,2,3]]] +ad3=[[[[1,2,3]]]] +ae=["aaa","bbb"] +af=SALOME_TYPES.ParametricInput(inputVarList=ae,outputVarList=ae, inputValues=[[[[1,2,3]]]],specificParameters=[]) +ag=SALOME_TYPES.ParametricOutput(outputValues=[[[[1,2,3]]]], specificOutputInfos=[], returnCode=1, errorMessage="error") +print aa,ab,ac,ad,ad2,ad3,ae,af,ag +""" + +s2pybody=""" +print "service s2 python component" +aa=a +a.Register() +""" + +c2=PYComponent("compo2",services=[ + Service("s1",inport=[("a","SALOME_TYPES/Parameter"), + ("b","SALOME_TYPES/ParameterList"), + ("c","SALOME_TYPES/Variable"), + ("d","SALOME_TYPES/VariableSequence"), + ("d2","SALOME_TYPES/StateSequence"), + ("d3","SALOME_TYPES/TimeSequence"), + ("e","SALOME_TYPES/VarList"), + ("f","SALOME_TYPES/ParametricInput"), + ("g","SALOME_TYPES/ParametricOutput"), + ], + outport=[("aa","SALOME_TYPES/Parameter"), + ("ab","SALOME_TYPES/ParameterList"), + ("ac","SALOME_TYPES/Variable"), + ("ad","SALOME_TYPES/VariableSequence"), + ("ad2","SALOME_TYPES/StateSequence"), + ("ad3","SALOME_TYPES/TimeSequence"), + ("ae","SALOME_TYPES/VarList"), + ("af","SALOME_TYPES/ParametricInput"), + ("ag","SALOME_TYPES/ParametricOutput"), + ], + body=pybody,defs=pydefs, + ), + Service("s2",inport=[("a","GEOM_Object"),],outport=[("aa","GEOM_Object"),],body=s2pybody,), + ], + ) + + +g=Generator(Module("mymodule",components=[c1,c2],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR, "GEOM":GEOM_ROOT_DIR}) + diff --git a/Examples/types1/coupling.xml b/Examples/types1/coupling.xml new file mode 100644 index 0000000..fcf1918 --- /dev/null +++ b/Examples/types1/coupling.xml @@ -0,0 +1,434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + compo1 + + s1 + + + + + + + + + + + + + + + + + + + + + compo2 + + s1 + + + + + + + + + + + + + + + + + + + + + compo1 + + s1 + + + + + + + + + + + + + + + + + + + + + compo2 + + s1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + s12 s11 + s12 PyScript0005 + s13 s10 + s13 PyScript006 + PyScript1154 s12 + PyScript1154 s13 + + s12 aa + s11 a + + + s12 aa + PyScript0005 i1 + + + s12 ab + s11 b + + + s12 ab + PyScript0005 i2 + + + s12 ac + s11 c + + + s12 ac + PyScript0005 i3 + + + s12 ad + s11 d + + + s12 ad + PyScript0005 i4 + + + s12 ad2 + s11 d2 + + + s12 ad2 + PyScript0005 i8 + + + s12 ad3 + s11 d3 + + + s12 ad3 + PyScript0005 i9 + + + s12 ae + PyScript0005 i5 + + + s12 ae + s11 e + + + s12 af + PyScript0005 i6 + + + s12 af + s11 f + + + s12 ag + PyScript0005 i7 + + + s12 ag + s11 g + + + s13 aa + s10 a + + + s13 aa + PyScript006 i1 + + + s13 ab + s10 b + + + s13 ab + PyScript006 i2 + + + s13 ac + s10 c + + + s13 ac + PyScript006 i3 + + + s13 ad + s10 d + + + s13 ad + PyScript006 i4 + + + s13 ad2 + s10 d2 + + + s13 ad2 + PyScript006 i8 + + + s13 ad3 + s10 d3 + + + s13 ad3 + PyScript006 i9 + + + s13 ae + s10 e + + + s13 ae + PyScript006 i5 + + + s13 af + s10 f + + + s13 af + PyScript006 i6 + + + s13 ag + s10 g + + + s13 ag + PyScript006 i7 + + + PyScript1154 o2 + s12 a + + + PyScript1154 o2 + s13 a + + + PyScript1154 o3 + s12 b + + + PyScript1154 o3 + s13 b + + + PyScript1154 o16 + s12 c + + + PyScript1154 o16 + s13 c + + + PyScript1154 o17 + s12 d + + + PyScript1154 o17 + s13 d + + + PyScript1154 o18 + s12 d2 + + + PyScript1154 o18 + s13 d2 + + + PyScript1154 o19 + s12 d3 + + + PyScript1154 o19 + s13 d3 + + + PyScript1154 o5 + s12 e + + + PyScript1154 o5 + s13 e + + + PyScript1154 o7 + s12 f + + + PyScript1154 o7 + s13 f + + + PyScript1154 o8 + s12 g + + + PyScript1154 o8 + s13 g + + + + + + + + + + diff --git a/Examples/types1/geom_coupling.xml b/Examples/types1/geom_coupling.xml new file mode 100644 index 0000000..e57c8dd --- /dev/null +++ b/Examples/types1/geom_coupling.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GEOM_Superv + + MakeBoxDXDYDZ + + + + + + + compo1 + + s2 + + + + + + + MakeBoxDXDYDZ0 s21 + MakeBoxDXDYDZ0 StudyOutNode2 + + MakeBoxDXDYDZ0 return + s21 a + + + MakeBoxDXDYDZ0 return + StudyOutNode2 i3 + + + MakeBoxDXDYDZ0theDX + 10 + + + MakeBoxDXDYDZ0theDY + 10 + + + MakeBoxDXDYDZ0theDZ + 10 + + + + + + diff --git a/Examples/types1/geom_coupling_compo2.xml b/Examples/types1/geom_coupling_compo2.xml new file mode 100644 index 0000000..b0849bc --- /dev/null +++ b/Examples/types1/geom_coupling_compo2.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GEOM_Superv + + MakeBoxDXDYDZ + + + + + + + + + + compo2 + + s2 + + + + MakeBoxDXDYDZ0 s20 + MakeBoxDXDYDZ0 StudyOutNode2 + + MakeBoxDXDYDZ0 return + s20 a + + + MakeBoxDXDYDZ0 return + StudyOutNode2 i3 + + + MakeBoxDXDYDZ0theDX + 10 + + + MakeBoxDXDYDZ0theDY + 10 + + + MakeBoxDXDYDZ0theDZ + 10 + + + + + + diff --git a/MANIFEST.in b/MANIFEST.in index 91bab87..4df6817 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,12 +1,41 @@ -recursive-include Examples/fort1 *.f components.py coupling.xml Makefile README.txt -recursive-include Examples/cpp1 components.py coupling.xml README.txt -recursive-include Examples/pyth1 *.py coupling.xml README.txt -recursive-include Examples/fort2 *.f components.py coupling.xml Makefile README.txt -recursive-include Examples/cpp2 components.py coupling.xml README.txt Makefile prog.cxx -recursive-include Examples/pyth2 components.py coupling.xml README.txt -recursive-include Examples/ast1 components.py coupling.xml f.comm README.txt -recursive-include Examples/ast1/fcompo compo.f Makefile -recursive-include Examples/ast1/myaster Makefile make_cata src/*.f catalo/*.capy -recursive-include Examples/ast2 components.py coupling.xml f.comm README.txt -recursive-include Examples/ast2/fcompo compo.f Makefile -recursive-include Examples/ast2/myaster Makefile make_exec config.txt src/*.f catalo/*.capy +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +include Examples/context.py +include Examples/makefile.inc +include Examples/*/*.f +include Examples/*/*.py +include Examples/*/*.cxx +include Examples/*/*.h +include Examples/*/*.png +include Examples/*/*.ui +include Examples/*/*.rst +include Examples/*/coupling.xml +include Examples/*/Makefile +include Examples/*/README.txt +include Examples/*/f.comm +include Examples/ast*/fcompo/compo.f +include Examples/ast*/fcompo/Makefile +include Examples/ast*/myaster/src/*.f +include Examples/ast*/myaster/catalo/*.capy +include Examples/ast*/myaster/Makefile +include Examples/ast1/myaster/make_cata +include Examples/ast2/myaster/make_exec +include Examples/ast2/myaster/config.txt +include Examples/ast2/exeaster diff --git a/module_generator/__init__.py b/module_generator/__init__.py index 42d4722..e27e3a7 100644 --- a/module_generator/__init__.py +++ b/module_generator/__init__.py @@ -1,10 +1,34 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + """ - Pacakge to generate SALOME modules with components - implemented in C++, Fortran or Python - that can use datastream ports +The python module module_generator defines classes which can be used to define a SALOME module, its components and +generates a SALOME source module, its installation and a SALOME application including this module and +other preexisting SALOME modules like GEOM, SMESH or others. """ from gener import Module, Service, Generator from fcompo import F77Component from cppcompo import CPPComponent +from pacocompo import PACOComponent from pycompo import PYComponent from astcompo import ASTERComponent +from hxxcompo import HXX2SALOMEComponent +from hxxparacompo import HXX2SALOMEParaComponent +from yacstypes import add_type +from salomemodules import add_module diff --git a/module_generator/astcompo.py b/module_generator/astcompo.py index 181f3db..3393b38 100644 --- a/module_generator/astcompo.py +++ b/module_generator/astcompo.py @@ -1,129 +1,229 @@ -import re, os +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +""" + This module defines the ASTERComponent class for ASTER component generation + An ASTER component comes in 3 flavors : + - implemented as a dynamic library (kind='lib') + - implemented as a standalone component (kind='exe') + - implemented as a specific container (kind='cexe') +""" +import re, os, sys from gener import Component, Invalid, makedirs from pyth_tmpl import pyinitEXEService, pyinitCEXEService, pyinitService +import aster_tmpl from aster_tmpl import asterCEXEService, asterEXEService from aster_tmpl import asterService, asterEXECompo, asterCEXECompo, asterCompo -from aster_tmpl import asterexeMakefile, astercexeMakefile, astercompoMakefile from aster_tmpl import comm, make_etude, cexe, exeaster from aster_tmpl import container, component class ASTERComponent(Component): + """ + A :class:`ASTERComponent` instance represents an ASTER SALOME component (special component for Code_Aster that is a mix of + Fortran and Python code) with services given as a list of :class:`Service` instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (executable or shell script). The default is to build the component as a dynamic library. + :param libs: gives all the libraries options to add when linking the generated component (-L...). + :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). + :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. + :param aster_dir: gives the Code_Aster installation directory. + :param python_path: If it is given (as a list of paths), all the paths are added to the python path (sys.path). + :param argv: is a list of strings that gives the command line parameters for Code_Aster. This parameter is only useful when + kind is "lib". + + For example, the following call defines a Code_Aster component named "mycompo" with one service s1 (it must have been defined before). + This standalone component takes some command line arguments:: + + >>> c1 = module_generator.ASTERComponent('mycompo', services=[s1,], kind="exe", + exe_path="launch.sh", + argv=["-memjeveux","4"]) + """ def __init__(self, name, services=None, libs="", rlibs="", aster_dir="", - python_path=None, argv=None, kind="lib", exe_path=None, - asrun=None, export_extras=""): + python_path=None, argv=None, kind="lib", exe_path=None): + """initialise component attributes""" self.aster_dir = aster_dir self.python_path = python_path or [] self.argv = argv or [] self.exe_path = exe_path - self.asrun = asrun - self.export_extras = export_extras Component.__init__(self, name, services, impl="ASTER", libs=libs, rlibs=rlibs, kind=kind) def validate(self): + """validate the component definition""" Component.validate(self) if not self.aster_dir: raise Invalid("aster_dir must be defined for component %s" % self.name) kinds = ("lib", "cexe", "exe") if self.kind not in kinds: - raise Invalid("kind must be one of %s" % kinds) + raise Invalid("kind must be one of %s for component %s" % (kinds,self.name)) if self.kind == "lib" and not self.python_path: raise Invalid("python_path must be defined for component %s" % self.name) if self.kind == "cexe" : if not self.exe_path: raise Invalid("exe_path must be defined for component %s" % self.name) - if not self.asrun: - raise Invalid("asrun must be defined for component %s" % self.name) - if not os.path.exists(self.asrun): - raise Invalid("asrun does not exist for component %s" % self.name) if self.kind == "exe" : if not self.exe_path: raise Invalid("exe_path must be defined for component %s" % self.name) - if not self.asrun: - raise Invalid("asrun must be defined for component %s" % self.name) - if not os.path.exists(self.asrun): - raise Invalid("asrun does not exist for component %s" % self.name) + #Si un port de nom jdc n'est pas defini dans la liste des inports du service, + #on en ajoute un de type string en premiere position for serv in self.services: - #on ajoute un inport string de nom jdc en premier dans la liste des ports de chaque service - serv.inport.insert(0, ("jdc", "string")) + found=False + for port_name,port_type in serv.inport: + if port_name == "jdc": + found=True + break + if not found: + serv.inport.insert(0, ("jdc", "string")) def makeCompo(self, gen): + """drive the generation of SALOME module files and code files + depending on the choosen component kind + """ filename = "%s.py" % self.name #on suppose que les composants ASTER sont homogenes (utilisent meme install) gen.aster = self.aster_dir + + #get ASTER version + f = os.path.join(self.aster_dir, "bibpyt", 'Accas', 'properties.py') + self.version=(0,0,0) + if os.path.isfile(f): + mydict = {} + execfile(f, mydict) + v,r,p = mydict['version'].split('.') + self.version=(int(v),int(r),int(p)) + if self.kind == "lib": - return {"Makefile.am":astercompoMakefile.substitute(module=gen.module.name, - component=self.name), - filename:self.makeaster(gen)} + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + filename:self.makeaster(gen)} elif self.kind == "cexe": - #creation de l'installation aster dans exe_path - self.makecexepath(gen) - return {"Makefile.am":astercexeMakefile.substitute(module=gen.module.name, - component=self.name), - filename:self.makecexeaster(gen)} + fdict=self.makecexepath(gen) + d= {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + self.name+".exe":cexe.substitute(compoexe=self.exe_path), + filename:self.makecexeaster(gen) + } + d.update(fdict) + return d elif self.kind == "exe": - #creation de l'installation aster dans exe_path - self.makeexepath(gen) - return {"Makefile.am":asterexeMakefile.substitute(module=gen.module.name, - component=self.name), - self.name+".exe":exeaster.substitute(export=os.path.join(self.exe_path, "make_etude.export"), asrun=self.asrun), - self.name+"_module.py":self.makeexeaster(gen)} + fdict=self.makeexepath(gen) + d= {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + self.name+".exe":exeaster.substitute(compoexe=self.exe_path), + self.name+"_module.py":self.makeexeaster(gen) + } + d.update(fdict) + return d + + def getMakefileItems(self,gen): + makefileItems={"header":"include $(top_srcdir)/adm_local/make_common_starter.am"} + if self.kind == "lib": + makefileItems["salomepython_PYTHON"]=[self.name+".py"] + elif self.kind == "exe": + makefileItems["salomepython_PYTHON"]=[self.name+"_module.py",self.name+"_component.py"] + if self.version < (10,1,2): + makefileItems["salomepython_PYTHON"].append("E_SUPERV.py") + makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] + makefileItems["salomeres_DATA"]=[self.name+"_config.txt"] + elif self.kind == "cexe": + makefileItems["salomepython_PYTHON"]=[self.name+".py",self.name+"_container.py"] + if self.version < (10,1,2): + makefileItems["salomepython_PYTHON"].append("E_SUPERV.py") + makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] + makefileItems["salomeres_DATA"]=[self.name+"_config.txt"] + return makefileItems + def makeexepath(self, gen): - makedirs(self.exe_path) - #patch to E_SUPERV.py - fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) - esuperv = fil.read() - esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) - fil.close() - #utilisation d'un programme principal python different + """standalone component: generate files for calculation code""" + + fdict={} + + if self.version < (10,1,2): + #patch to E_SUPERV.py + fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) + esuperv = fil.read() + fil.close() + esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) + esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) + esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) + esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) + esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + fdict["E_SUPERV.py"]=esuperv + + #use a specific main program (modification of config.txt file) fil = open(os.path.join(self.aster_dir, "config.txt")) config = fil.read() - config = re.sub("Execution\/E_SUPERV.py", os.path.join(self.exe_path, "aster_component.py"), config) fil.close() + config = re.sub(" profile.sh", os.path.join(self.aster_dir, "profile.sh"), config) - gen.makeFiles({ - "aster_component.py":component.substitute(component=self.name), - "make_etude.export":make_etude.substitute(config=os.path.join(self.exe_path, "config.txt"), - comm=os.path.join(self.exe_path, self.name+".comm"), - extras=self.export_extras), - self.name+".comm":comm, - "config.txt":config, - "profile.sh":os.path.join(self.aster_dir, "profile.sh"), - "E_SUPERV.py":esuperv, - }, self.exe_path) + path=os.path.join(os.path.abspath(gen.module.prefix),'lib', + 'python%s.%s' % (sys.version_info[0], sys.version_info[1]), + 'site-packages','salome','%s_component.py'%self.name) + config = re.sub("Execution\/E_SUPERV.py", path, config) + config += "ENV_SH | env | - | " + self.prerequisites + "\n" + + fdict["%s_config.txt" % self.name] = config + fdict["%s_component.py" % self.name] = component.substitute(component=self.name) + + return fdict def makecexepath(self, gen): - makedirs(self.exe_path) - #patch to E_SUPERV.py - fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) - esuperv = fil.read() - esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) - fil.close() - #utilisation d'un programme principal python different + """specific container: generate files""" + + fdict={} + + if self.version < (10,1,2): + #patch to E_SUPERV.py + fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) + esuperv = fil.read() + fil.close() + esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) + esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) + esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) + esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) + esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + fdict["E_SUPERV.py"]=esuperv + + #use a specific main program fil = open(os.path.join(self.aster_dir, "config.txt")) config = fil.read() - config = re.sub("Execution\/E_SUPERV.py", os.path.join(self.exe_path, "aster_container.py"), config) fil.close() - gen.makeFiles({self.name+".exe":cexe.substitute(export=os.path.join(self.exe_path, "make_etude.export"), - asrun=self.asrun), - "aster_container.py":container, - "make_etude.export":make_etude.substitute(config=os.path.join(self.exe_path, "config.txt"), - comm=os.path.join(self.exe_path, self.name+".comm"), - extras=self.export_extras), - self.name+".comm":comm, - "config.txt":config, - "profile.sh":os.path.join(self.aster_dir, "profile.sh"), - "E_SUPERV.py":esuperv, - }, self.exe_path) - #make exe executable - os.chmod(os.path.join(self.exe_path, self.name+".exe"), 0777) + config = re.sub(" profile.sh", os.path.join(self.aster_dir, "profile.sh"), config) + path=os.path.join(os.path.abspath(gen.module.prefix),'lib', + 'python%s.%s' % (sys.version_info[0], sys.version_info[1]), + 'site-packages','salome','%s_container.py' % self.name) + config = re.sub("Execution\/E_SUPERV.py", path, config) + config += "ENV_SH | env | - | " + self.prerequisites + "\n" + + fdict["%s_container.py" % self.name] = container + fdict["%s_config.txt" % self.name] = config + + return fdict def makeexeaster(self, gen): + """standalone component: generate SALOME component source""" services = [] inits = [] defs = [] @@ -132,6 +232,7 @@ class ASTERComponent(Component): params = [] datas = [] for name, typ in serv.inport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": datas.append('"%s":cPickle.loads(%s)' % (name, name)) @@ -145,6 +246,7 @@ class ASTERComponent(Component): params = [] datas = [] for name, typ in serv.outport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": datas.append('cPickle.dumps(j.g_context["%s"],-1)'%name) @@ -153,11 +255,11 @@ class ASTERComponent(Component): outparams = ",".join(params) rvars = ",".join(datas) - service = asterEXEService.substitute(component=self.name, - service=serv.name, + service = asterEXEService.substitute(component=self.name, + service=serv.name, inparams=inparams, - outparams=outparams, - body=serv.body, + outparams=outparams, + body=serv.body, dvars=dvars, rvars=rvars) streams = [] for name, typ, dep in serv.instream: @@ -172,13 +274,24 @@ class ASTERComponent(Component): instream=instream, outstream=outstream) services.append(service) inits.append(init) + + if self.version < (10,1,2): + importesuperv="from E_SUPERV import SUPERV" + else: + importesuperv="""sys.path=["%s"]+sys.path +from Execution.E_SUPERV import SUPERV +""" % os.path.join(self.aster_dir, "bibpyt") + return asterEXECompo.substitute(component=self.name, module=gen.module.name, - servicesdef="\n".join(defs), - servicesimpl="\n".join(services), + servicesdef="\n".join(defs), + servicesimpl="\n".join(services), initservice='\n'.join(inits), - aster_dir=self.aster_dir) + aster_dir=self.aster_dir, + importesuperv=importesuperv, + ) def makecexeaster(self, gen): + """specific container: generate SALOME component source""" services = [] inits = [] defs = [] @@ -187,6 +300,7 @@ class ASTERComponent(Component): params = [] datas = [] for name, typ in serv.inport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": datas.append('"%s":cPickle.loads(%s)' % (name, name)) @@ -208,11 +322,11 @@ class ASTERComponent(Component): outparams = ",".join(params) rvars = ",".join(datas) - service = asterCEXEService.substitute(component=self.name, - service=serv.name, + service = asterCEXEService.substitute(component=self.name, + service=serv.name, inparams=inparams, - outparams=outparams, - body=serv.body, + outparams=outparams, + body=serv.body, dvars=dvars, rvars=rvars) streams = [] for name, typ, dep in serv.instream: @@ -229,19 +343,31 @@ class ASTERComponent(Component): outstream=outstream) services.append(service) inits.append(init) + + if self.version < (10,1,2): + importesuperv="from E_SUPERV import SUPERV" + else: + importesuperv="""sys.path=["%s"] +sys.path +from Execution.E_SUPERV import SUPERV +""" % os.path.join(self.aster_dir, "bibpyt") + return asterCEXECompo.substitute(component=self.name, module=gen.module.name, servicesdef="\n".join(defs), servicesimpl="\n".join(services), initservice='\n'.join(inits), - aster_dir=self.aster_dir) + aster_dir=self.aster_dir, + importesuperv=importesuperv, + ) + def getImpl(self): if self.kind == "cexe": - return "CEXE", os.path.join(self.exe_path, self.name+".exe") + return "CEXE", self.name+".exe" else: return "SO", "" def makeaster(self, gen): + """library component: generate SALOME component source""" services = [] inits = [] defs = [] @@ -250,6 +376,7 @@ class ASTERComponent(Component): params = [] datas = [] for name, typ in serv.inport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": datas.append('"%s":cPickle.loads(%s)' % (name, name)) diff --git a/module_generator/aster_tmpl.py b/module_generator/aster_tmpl.py index b00658c..7946e86 100644 --- a/module_generator/aster_tmpl.py +++ b/module_generator/aster_tmpl.py @@ -1,26 +1,30 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# try: from string import Template except: from compat import Template,set -astercompoMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am -salomepython_PYTHON = ${component}.py - -""" -astercompoMakefile=Template(astercompoMakefile) -astercexeMakefile=astercompoMakefile - -asterexeMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am -salomepython_PYTHON = ${component}_module.py -# These files are executable scripts -dist_salomescript_SCRIPTS= ${component}.exe -""" -asterexeMakefile=Template(asterexeMakefile) - asterCompo=""" import sys,traceback,os -import ${module}__POA +import ${module}_ORB__POA import calcium import dsccalcium import SALOME @@ -44,15 +48,14 @@ except: ${servicesdef} #ENDDEF -class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV): +class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUPERV): ''' To be identified as a SALOME component this Python class must have the same name as the component, inherit omniorb - class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent + class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent that implements DSC API. ''' def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): - print "${component}.__init__: ", containerName, ';', instanceName,interfaceName dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName) self.argv=[${argv}] #modif pour aster 9.0 @@ -75,12 +78,12 @@ asterCompo=Template(asterCompo) asterCEXECompo=""" import sys,traceback,os import string -import ${module}__POA +import ${module}_ORB__POA import calcium import dsccalcium import SALOME import linecache -from E_SUPERV import SUPERV +${importesuperv} try: import numpy @@ -91,15 +94,17 @@ except: ${servicesdef} #ENDDEF -class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV): +class ExecutionError(Exception): + '''General exception during execution''' + +class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUPERV): ''' To be identified as a SALOME component this Python class must have the same name as the component, inherit omniorb - class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent + class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent that implements DSC API. ''' def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): - print "${component}.__init__: ", containerName, ';', instanceName,interfaceName self.init=0 dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName) @@ -107,12 +112,24 @@ class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV) ${initservice} return False + def interpstring(self,text,args): + try: + self.jdc.g_context.update(args) + CONTEXT.set_current_step(self.jdc) + linecache.cache['']=0,None,string.split(text,'\\n'),'' + exec text in self.jdc.const_context,self.jdc.g_context + CONTEXT.unset_current_step() + except EOFError: + CONTEXT.unset_current_step() + except: + CONTEXT.unset_current_step() + raise + ${servicesimpl} """ asterEXECompo=asterCEXECompo+""" def destroy(self): - dsccalcium.PyDSCComponent.destroy(self) self._orb.shutdown(0) """ @@ -121,7 +138,6 @@ asterEXECompo=Template(asterEXECompo) asterService=""" def ${service}(self,${inparams}): - print "${component}.${service}" self.beginService("${component}.${service}") self.jdc=Cata.cata.JdC(procedure=jdc,cata=Cata.cata,nom="Salome",context_ini=${dvars}) j=self.jdc @@ -180,12 +196,11 @@ asterService=""" print ">> JDC.py : FIN RAPPORT" sys.stdout.flush() raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr), "${component}.py",0)) - + if j.par_lot == 'NON': print "FIN EXECUTION" - err=calcium.cp_fin(self.proxy,calcium.CP_ARRET) + #err=calcium.cp_fin(self.proxy,calcium.CP_ARRET) #retour sans erreur (il faut pousser les variables de sortie) - print "End of ${component}.${service}" sys.stdout.flush() self.endService("${component}.${service}") return ${rvars} @@ -216,8 +231,7 @@ asterService=""" raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0)) else: #retour sans erreur (il faut pousser les variables de sortie) - err=calcium.cp_fin(self.proxy,calcium.CP_ARRET) - print "End of ${component}.${service}" + #err=calcium.cp_fin(self.proxy,calcium.CP_ARRET) sys.stdout.flush() self.endService("${component}.${service}") return ${rvars} @@ -232,29 +246,35 @@ asterService=Template(asterService) asterCEXEService=""" def ${service}(self,${inparams}): - print "${component}.${service}" self.beginService("${component}.${service}") - if not self.init: - self.init=1 - ier=self.main() - j=self.jdc - self.jdc.g_context.update(${dvars}) try: - CONTEXT.set_current_step(self.jdc) - linecache.cache['']=0,0,string.split(jdc,'\\n'),'' - exec jdc in self.jdc.g_context - CONTEXT.unset_current_step() - self.endService("${component}.${service}") - except EOFError: + args=${dvars} + if not args.has_key("jdc"): + fcomm=open("jdc",'r') + jdc=fcomm.read() + fcomm.close() + #args["jdc"]=jdc + if not self.init: + self.init=1 + fcomm=open("fort.1",'w') + fcomm.write(jdc) + fcomm.close() + ier=self.main(args) + if ier != 0: + raise ExecutionError("Error in initial execution") + else: + self.interpstring(jdc,args) + self.endService("${component}.${service}") + j=self.jdc + return ${rvars} except: - sys.stdout.flush() exc_typ,exc_val,exc_fr=sys.exc_info() l=traceback.format_exception(exc_typ,exc_val,exc_fr) self.endService("${component}.${service}") - CONTEXT.unset_current_step() + sys.stdout.flush() + sys.stderr.flush() raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"${component}.py",0)) - return ${rvars} """ asterCEXEService=Template(asterCEXEService) asterEXEService=asterCEXEService @@ -339,14 +359,7 @@ cexe="""#!/bin/sh export SALOME_CONTAINERNAME=$$1 -cp ${export} temp.export -cat >> temp.export << END -F mess $$PWD/messages R 6 -F resu $$PWD/resu R 8 -F erre $$PWD/erre R 9 -END - -${asrun} temp.export +${compoexe} """ cexe=Template(cexe) @@ -356,14 +369,7 @@ export SALOME_CONTAINER=$$1 export SALOME_CONTAINERNAME=$$2 export SALOME_INSTANCE=$$3 -cp ${export} temp.export -cat >> temp.export << END -F mess $$PWD/messages R 6 -F resu $$PWD/resu R 8 -F erre $$PWD/erre R 9 -END - -${asrun} temp.export +${compoexe} """ exeaster=Template(exeaster) diff --git a/module_generator/cata_tmpl.py b/module_generator/cata_tmpl.py index cce5dcf..f3a29ce 100644 --- a/module_generator/cata_tmpl.py +++ b/module_generator/cata_tmpl.py @@ -1,3 +1,22 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + try: from string import Template except: @@ -11,12 +30,19 @@ idl=""" #include "DSC_Engines.idl" #include "SALOME_Exception.idl" +#include "SALOME_PACOExtension.idl" +#include "SALOME_Component.idl" +#include "SALOME_Comm.idl" +#include "SALOME_Parametric.idl" + +${idldefs} -module ${module} +module ${module}_ORB { typedef sequence stringvec; typedef sequence dblevec; typedef sequence intvec; +typedef Engines::dataref dataref; ${interfaces} }; @@ -26,48 +52,96 @@ ${interfaces} idl=Template(idl) interface=""" - interface ${component}:Engines::Superv_Component + interface ${component}:${inheritedinterface} Engines::Superv_Component { ${services} }; """ interface=Template(interface) +parallel_interface=""" +interface ${component} : Engines::Parallel_DSC + { +${services} + }; +""" +parallel_interface=Template(parallel_interface) + +xml="""\ + + + + + + ${module}_ORB +${interfaces} + + +""" +xml = Template(xml) + +xml_interface="""\ + + ${component} +${xml_services} + """ +xml_interface = Template(xml_interface) + +xml_service = """\ + + ${service_name} + distributed + """ +xml_service = Template(xml_service) + idlMakefile=""" include $$(top_srcdir)/adm_local/make_common_starter.am -BUILT_SOURCES = ${module}SK.cc -IDL_FILES=${module}.idl - -lib_LTLIBRARIES = lib${module}.la -salomeidl_DATA = $$(IDL_FILES) -salomepython_DATA = ${module}_idl.py -lib${module}_la_SOURCES = -nodist_lib${module}_la_SOURCES = ${module}SK.cc -nodist_salomeinclude_HEADERS= ${module}.hh -lib${module}_la_CXXFLAGS = -I. $$(KERNEL_INCLUDES) -lib${module}_la_LIBADD = $$(KERNEL_LIBS) +BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES} ${other_sks} +IDL_FILES=${module}.idl ${other_idls} + +lib_LTLIBRARIES = libSalomeIDL${module}.la +salomeidl_DATA = $$(IDL_FILES) ${PACO_salomeidl_DATA} +libSalomeIDL${module}_la_SOURCES = +nodist_libSalomeIDL${module}_la_SOURCES = ${module}SK.cc ${other_sks} +nodist_salomeinclude_HEADERS= ${module}.hh ${PACO_SALOMEINCLUDE_HEADERS} +libSalomeIDL${module}_la_CXXFLAGS = -I. $$(SALOME_INCLUDES) +libSalomeIDL${module}_la_LIBADD = $$(SALOME_IDL_LIBS) ########################################################## %SK.cc %.hh : %.idl -\t$$(OMNIORB_IDL) -bcxx $$(IDLCXXFLAGS) $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$< +\t$$(OMNIORB_IDL) -bcxx $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$< %_idl.py : %.idl -\t$$(OMNIORB_IDL) -bpython $$(IDL_INCLUDES) $$< +\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) ${PACO_INCLUDES} $$< +%PaCO.hxx %PaCO.cxx : %.idl %.xml +\t$$(OMNIORB_IDL) -I@KERNEL_ROOT_DIR@/idl/salome -p@PACOPATH@/lib/python -bpaco -Wb$$(top_srcdir)/idl/$$*.xml,$$(srcdir):@PACOPATH@/idl:@KERNEL_ROOT_DIR@/idl/salome $$(top_srcdir)/idl/$$*.idl -CLEANFILES = *.hh *SK.cc *.py +CLEANFILES = *.hh *SK.cc *.py *.hxx *.cxx -clean-local: -\trm -rf ${module} ${module}__POA +EXTRA_DIST = $$(IDL_FILES) -install-data-local: -\t$${mkinstalldirs} $$(DESTDIR)$$(salomepythondir) -\tcp -R ${module} ${module}__POA $$(DESTDIR)$$(salomepythondir) +install-data-local: $$(IDL_FILES) +\t$$(INSTALL) -d $$(DESTDIR)$$(salomepythondir) +\tls $$^ | while read file; do \\ +\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) -C$$(DESTDIR)$$(salomepythondir) $$$$file ; \\ +\tdone uninstall-local: -\trm -rf $$(DESTDIR)$$(salomepythondir)/${module} -\trm -rf $$(DESTDIR)$$(salomepythondir)/${module}__POA +\trm -rf $$(DESTDIR)$$(salomepythondir)/* + """ idlMakefile=Template(idlMakefile) +# PACO Part +idlMakefilePaCO_BUILT_SOURCES = "${module}PaCO.cxx " +idlMakefilePaCO_nodist_salomeinclude_HEADERS = "${module}PaCO.hxx " +idlMakefilePaCO_BUILT_SOURCES = Template(idlMakefilePaCO_BUILT_SOURCES) +idlMakefilePaCO_nodist_salomeinclude_HEADERS = Template(idlMakefilePaCO_nodist_salomeinclude_HEADERS) +idlMakefilePACO_INCLUDES = "-I@PACOPATH@/idl" +idlMakefilePACO_salomepython_DATA = "${module}PaCO_idl.py" +idlMakefilePACO_salomepython_DATA = Template(idlMakefilePACO_salomepython_DATA) +idlMakefilePACO_salomeidl_DATA = "${module}PaCO.idl" +idlMakefilePACO_salomeidl_DATA = Template(idlMakefilePACO_salomeidl_DATA) + #SALOME catalog catalog=""" @@ -83,6 +157,7 @@ catalog=""" + @@ -161,3 +236,14 @@ cataOutStream=""" """ cataOutStream=Template(cataOutStream) +cataInParallelStream=""" + ${name} + ${type} + """ +cataInParallelStream=Template(cataInParallelStream) + +cataOutParallelStream=""" + ${name} + ${type} + """ +cataOutParallelStream=Template(cataOutParallelStream) diff --git a/module_generator/compat.py b/module_generator/compat.py index f4c5bf9..672b33d 100644 --- a/module_generator/compat.py +++ b/module_generator/compat.py @@ -1,162 +1,162 @@ -#!/usr/bin/env python -#coding: iso-8859-15 -# -# Copyright (C) 2005 Gaëtan Lehmann -# -# this file is part of uptodate -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# - -# this module sets python 2.3 compatibility - - -# python 2.4 now have set in __builtin__ module - -import sets -set = sets.Set -del sets - -# python 2.4 enhance sort method in list object with key and reverse parameters, and introduced sorted function which do the same as sort but on a copied list -# as it's far more difficult to modify sort method, we implement a sorted fuction for python 2.3 - -def sorted(iterable, cmp=None, key=None, reverse=False) : - i = list(iterable) - if key : - d = {} - for v in iterable : - k = key(v) - if not d.has_key(k) : - d[k] = [] - d[k].append(v) - keys = d.keys() - keys.sort(cmp) - i = [] - for k in keys : - i += d[k] - else : - i.sort(cmp) - if reverse : - i.reverse() - return i - -# string.Template allow us to create templated command without problem : -# configparser use standard substitution, so an error in template can make the config file invalid. With the new template, we avoid this problem -# thoses classes are stollen from python 2.4 string module -import re -class _TemplateMetaclass(type): - pattern = r""" - %(delim)s(?: - (?P%(delim)s) | # Escape sequence of two delimiters - (?P%(id)s) | # delimiter and a Python identifier - {(?P%(id)s)} | # delimiter and a braced identifier - (?P) # Other ill-formed delimiter exprs - ) - """ - - def __init__(cls, name, bases, dct): - super(_TemplateMetaclass, cls).__init__(name, bases, dct) - if 'pattern' in dct: - pattern = cls.pattern - else: - pattern = _TemplateMetaclass.pattern % { - 'delim' : re.escape(cls.delimiter), - 'id' : cls.idpattern, - } - cls.pattern = re.compile(pattern, re.IGNORECASE | re.VERBOSE) - - -class Template: - """A string class for supporting $-substitutions.""" - __metaclass__ = _TemplateMetaclass - - delimiter = '$' - idpattern = r'[_a-z][_a-z0-9]*' - - def __init__(self, template): - self.template = template - - # Search for $$, $identifier, ${identifier}, and any bare $'s - - def _invalid(self, mo): - i = mo.start('invalid') - lines = self.template[:i].splitlines(True) - if not lines: - colno = 1 - lineno = 1 - else: - colno = i - len(''.join(lines[:-1])) - lineno = len(lines) - raise ValueError('Invalid placeholder in string: line %d, col %d' % - (lineno, colno)) - - def substitute(self, *args, **kws): - if len(args) > 1: - raise TypeError('Too many positional arguments') - if not args: - mapping = kws - elif kws: - mapping = _multimap(kws, args[0]) - else: - mapping = args[0] - # Helper function for .sub() - def convert(mo): - # Check the most common path first. - named = mo.group('named') or mo.group('braced') - if named is not None: - val = mapping[named] - # We use this idiom instead of str() because the latter will - # fail if val is a Unicode containing non-ASCII characters. - return '%s' % val - if mo.group('escaped') is not None: - return self.delimiter - if mo.group('invalid') is not None: - self._invalid(mo) - raise ValueError('Unrecognized named group in pattern', - self.pattern) - return self.pattern.sub(convert, self.template) - - def safe_substitute(self, *args, **kws): - if len(args) > 1: - raise TypeError('Too many positional arguments') - if not args: - mapping = kws - elif kws: - mapping = _multimap(kws, args[0]) - else: - mapping = args[0] - # Helper function for .sub() - def convert(mo): - named = mo.group('named') - if named is not None: - try: - # We use this idiom instead of str() because the latter - # will fail if val is a Unicode containing non-ASCII - return '%s' % mapping[named] - except KeyError: - return self.delimiter + named - braced = mo.group('braced') - if braced is not None: - try: - return '%s' % mapping[braced] - except KeyError: - return self.delimiter + '{' + braced + '}' - if mo.group('escaped') is not None: - return self.delimiter - if mo.group('invalid') is not None: - return self.delimiter - raise ValueError('Unrecognized named group in pattern', - self.pattern) - return self.pattern.sub(convert, self.template) +#!/usr/bin/env python +#coding: iso-8859-15 +# +# Copyright (C) 2005 Gaëtan Lehmann +# +# this file is part of uptodate +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +# this module sets python 2.3 compatibility + + +# python 2.4 now have set in __builtin__ module + +import sets +set = sets.Set +del sets + +# python 2.4 enhance sort method in list object with key and reverse parameters, and introduced sorted function which do the same as sort but on a copied list +# as it's far more difficult to modify sort method, we implement a sorted fuction for python 2.3 + +def sorted(iterable, cmp=None, key=None, reverse=False) : + i = list(iterable) + if key : + d = {} + for v in iterable : + k = key(v) + if not d.has_key(k) : + d[k] = [] + d[k].append(v) + keys = d.keys() + keys.sort(cmp) + i = [] + for k in keys : + i += d[k] + else : + i.sort(cmp) + if reverse : + i.reverse() + return i + +# string.Template allow us to create templated command without problem : +# configparser use standard substitution, so an error in template can make the config file invalid. With the new template, we avoid this problem +# thoses classes are stollen from python 2.4 string module +import re +class _TemplateMetaclass(type): + pattern = r""" + %(delim)s(?: + (?P%(delim)s) | # Escape sequence of two delimiters + (?P%(id)s) | # delimiter and a Python identifier + {(?P%(id)s)} | # delimiter and a braced identifier + (?P) # Other ill-formed delimiter exprs + ) + """ + + def __init__(cls, name, bases, dct): + super(_TemplateMetaclass, cls).__init__(name, bases, dct) + if 'pattern' in dct: + pattern = cls.pattern + else: + pattern = _TemplateMetaclass.pattern % { + 'delim' : re.escape(cls.delimiter), + 'id' : cls.idpattern, + } + cls.pattern = re.compile(pattern, re.IGNORECASE | re.VERBOSE) + + +class Template: + """A string class for supporting $-substitutions.""" + __metaclass__ = _TemplateMetaclass + + delimiter = '$' + idpattern = r'[_a-z][_a-z0-9]*' + + def __init__(self, template): + self.template = template + + # Search for $$, $identifier, ${identifier}, and any bare $'s + + def _invalid(self, mo): + i = mo.start('invalid') + lines = self.template[:i].splitlines(True) + if not lines: + colno = 1 + lineno = 1 + else: + colno = i - len(''.join(lines[:-1])) + lineno = len(lines) + raise ValueError('Invalid placeholder in string: line %d, col %d' % + (lineno, colno)) + + def substitute(self, *args, **kws): + if len(args) > 1: + raise TypeError('Too many positional arguments') + if not args: + mapping = kws + elif kws: + mapping = _multimap(kws, args[0]) + else: + mapping = args[0] + # Helper function for .sub() + def convert(mo): + # Check the most common path first. + named = mo.group('named') or mo.group('braced') + if named is not None: + val = mapping[named] + # We use this idiom instead of str() because the latter will + # fail if val is a Unicode containing non-ASCII characters. + return '%s' % val + if mo.group('escaped') is not None: + return self.delimiter + if mo.group('invalid') is not None: + self._invalid(mo) + raise ValueError('Unrecognized named group in pattern', + self.pattern) + return self.pattern.sub(convert, self.template) + + def safe_substitute(self, *args, **kws): + if len(args) > 1: + raise TypeError('Too many positional arguments') + if not args: + mapping = kws + elif kws: + mapping = _multimap(kws, args[0]) + else: + mapping = args[0] + # Helper function for .sub() + def convert(mo): + named = mo.group('named') + if named is not None: + try: + # We use this idiom instead of str() because the latter + # will fail if val is a Unicode containing non-ASCII + return '%s' % mapping[named] + except KeyError: + return self.delimiter + named + braced = mo.group('braced') + if braced is not None: + try: + return '%s' % mapping[braced] + except KeyError: + return self.delimiter + '{' + braced + '}' + if mo.group('escaped') is not None: + return self.delimiter + if mo.group('invalid') is not None: + return self.delimiter + raise ValueError('Unrecognized named group in pattern', + self.pattern) + return self.pattern.sub(convert, self.template) diff --git a/module_generator/cpp_tmpl.py b/module_generator/cpp_tmpl.py index bc842fa..3180d60 100644 --- a/module_generator/cpp_tmpl.py +++ b/module_generator/cpp_tmpl.py @@ -1,3 +1,22 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + try: from string import Template except: @@ -9,10 +28,13 @@ cxxCompo=""" #include #include -#include +#include +${CalciumInterface} #include #include #include +#include +#include typedef void (*sighandler_t)(int); sighandler_t setsig(int sig, sighandler_t handler) @@ -28,6 +50,20 @@ sighandler_t setsig(int sig, sighandler_t handler) static void AttachDebugger() { + void *array[20]; + size_t size=20; + char **strings; + size_t i; + std::string _what; + size = backtrace (array, size); + strings = backtrace_symbols (array, size); + for (i = 0; i < size; i++) + _what=_what+strings[i]+ '\\n'; + free (strings); + + std::cerr << pthread_self() << std::endl; + std::cerr << _what << std::endl; + if(getenv ("DEBUGGER")) { std::stringstream exec; @@ -90,14 +126,16 @@ static void unexpectedHandler(void) ${servicesdef} //ENDDEF +#include + extern "C" void cp_exit(int err); -extern "C" void F_FUNC(cpexit,CPEXIT)(int err) +extern "C" void F_FUNC(cpexit,CPEXIT)(int *err) { - if(err==-1) + if(*err==-1) _exit(-1); else - cp_exit(err); + cp_exit(*err); } using namespace std; @@ -113,7 +151,6 @@ ${component}_i::${component}_i(CORBA::ORB_ptr orb, const char *interfaceName) : Superv_Component_i(orb, poa, contId, instanceName, interfaceName) { - std::cerr << "create component" << std::endl; #if ${exe} setsig(SIGSEGV,&THandler); set_terminate(&terminateHandler); @@ -146,10 +183,12 @@ ${component}_i::~${component}_i() void ${component}_i::destroy() { - Engines_Component_i::destroy(); #if ${exe} + _remove_ref(); if(!CORBA::is_nil(_orb)) _orb->shutdown(0); +#else + Engines_Component_i::destroy(); #endif } @@ -199,8 +238,8 @@ extern "C" Engines::Container_var container = Engines::Container::_narrow(obj); ${component}_i * myEngine = new ${component}_i(orb, poa, container, instanceName.c_str(), "${component}"); pman->activate(); - obj=myEngine->_this(); - Engines::Component_var component = Engines::Component::_narrow(obj); + obj=myEngine->POA_${module}_ORB::${component}::_this(); + Engines::EngineComponent_var component = Engines::EngineComponent::_narrow(obj); string component_registerName = containerName + "/" + instanceName; salomens->Register(component,component_registerName.c_str()); orb->run(); @@ -232,12 +271,16 @@ hxxCompo=""" #ifndef _${component}_HXX_ #define _${component}_HXX_ +#include #include "Superv_Component_i.hxx" #include "${module}.hh" -class ${component}_i: - public virtual POA_${module}::${component}, - public virtual Superv_Component_i +//COMPODEFS +${compodefs} +//ENDDEF + +class ${component}_i: public virtual POA_${module}_ORB::${component}, + ${inheritedclass} public virtual Superv_Component_i { public: ${component}_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, @@ -269,22 +312,21 @@ hxxCompo=Template(hxxCompo) cxxService=""" void ${component}_i::${service}(${parameters}) { - std::cerr << "${component}_i::${service}" << std::endl; beginService("${component}_i::${service}"); Superv_Component_i * component = dynamic_cast(this); - char nom_instance[INSTANCE_LEN]; - int info = cp_cd(component,nom_instance); + //char nom_instance[INSTANCE_LEN]; + //int info = cp_cd(component,nom_instance); try { //BODY ${body} //ENDBODY - cp_fin(component,CP_ARRET); + //cp_fin(component,CP_ARRET); } catch ( const CalciumException & ex) { std::cerr << ex.what() << std::endl; - cp_fin(component,CP_ARRET); + //cp_fin(component,CP_ARRET); SALOME::ExceptionStruct es; es.text=CORBA::string_dup(ex.what()); es.type=SALOME::INTERNAL_ERROR; @@ -292,7 +334,7 @@ ${body} } catch ( const SALOME_Exception & ex) { - cp_fin(component,CP_ARRET); + //cp_fin(component,CP_ARRET); SALOME::ExceptionStruct es; es.text=CORBA::string_dup(ex.what()); es.type=SALOME::INTERNAL_ERROR; @@ -300,23 +342,30 @@ ${body} } catch ( const SALOME::SALOME_Exception & ex) { - cp_fin(component,CP_ARRET); + //cp_fin(component,CP_ARRET); throw; } + catch ( const std::exception& ex) + { + //std::cerr << typeid(ex).name() << std::endl; + SALOME::ExceptionStruct es; + es.text=CORBA::string_dup(ex.what()); + es.type=SALOME::INTERNAL_ERROR; + throw SALOME::SALOME_Exception(es); + } catch (...) { std::cerr << "unknown exception" << std::endl; #if ${exe} _exit(-1); #endif - cp_fin(component,CP_ARRET); + //cp_fin(component,CP_ARRET); SALOME::ExceptionStruct es; es.text=CORBA::string_dup(" unknown exception"); es.type=SALOME::INTERNAL_ERROR; throw SALOME::SALOME_Exception(es); } endService("${component}_i::${service}"); - std::cerr << "end of ${component}_i::${service}" << std::endl; } """ @@ -359,36 +408,21 @@ exeCPP=Template(exeCPP) # Makefile compoMakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am - -AM_CFLAGS=$$(KERNEL_INCLUDES) -fexceptions - -lib_LTLIBRARIES = lib${component}Engine.la lib${component}Engine_la_SOURCES = ${component}.cxx ${sources} nodist_lib${component}Engine_la_SOURCES = -lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(KERNEL_INCLUDES) ${includes} -lib${component}Engine_la_FFLAGS = $$(KERNEL_INCLUDES) -fexceptions ${includes} -lib${component}Engine_la_LIBADD = -L$$(top_builddir)/idl -l${module} $$(FLIBS) ${libs} +lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} +lib${component}Engine_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes} +lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) lib${component}Engine_la_LDFLAGS = ${rlibs} -salomeinclude_HEADERS = ${component}.hxx """ compoMakefile=Template(compoMakefile) compoEXEMakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am - -AM_CFLAGS=$$(KERNEL_INCLUDES) -fexceptions - -lib_LTLIBRARIES = lib${component}Exelib.la lib${component}Exelib_la_SOURCES = ${component}.cxx nodist_lib${component}Exelib_la_SOURCES = -lib${component}Exelib_la_CXXFLAGS = -I$$(top_builddir)/idl $$(KERNEL_INCLUDES) ${includes} -lib${component}Exelib_la_FFLAGS = $$(KERNEL_INCLUDES) -fexceptions ${includes} -lib${component}Exelib_la_LIBADD = -L$$(top_builddir)/idl -l${module} $$(FLIBS) ${libs} +lib${component}Exelib_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} +lib${component}Exelib_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes} +lib${component}Exelib_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) lib${component}Exelib_la_LDFLAGS = ${rlibs} -salomeinclude_HEADERS = ${component}.hxx -# These files are executable scripts -dist_salomescript_SCRIPTS= ${component}.exe """ compoEXEMakefile=Template(compoEXEMakefile) - diff --git a/module_generator/cppcompo.py b/module_generator/cppcompo.py index e2d9508..307f72a 100644 --- a/module_generator/cppcompo.py +++ b/module_generator/cppcompo.py @@ -1,25 +1,85 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + """ Module that defines CPPComponent for SALOME components implemented in C++ """ +import os from gener import Component, Invalid from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo -from cpp_tmpl import compoEXEMakefile, compoMakefile, exeCPP +from cpp_tmpl import exeCPP, compoEXEMakefile, compoMakefile +from yacstypes import corba_rtn_type class CPPComponent(Component): - def __init__(self, name, services=None, libs="", rlibs="", includes="", - kind="lib", exe_path=None, sources=None): + """ + A :class:`CPPComponent` instance represents a C++ SALOME component with services given as a list of :class:`Service` + instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (executable or shell script). The default is to build the component as a dynamic library. + :param libs: gives all the libraries options to add when linking the generated component (-L...). + :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). + :param includes: gives all the include options to add when compiling the generated component (-I...). + :param sources: gives all the external source files to add in the compilation step (list of paths). + :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. + :param compodefs: can be used to add extra definition code in the component for example when using a base class + to define the component class by deriving it (see *inheritedclass* parameter) + :param inheritedclass: can be used to define a base class for the component. The base class can be defined in external + source or with the *compodefs* parameter. The value of the *inheritedclass* parameter is the name of the base class. + :param idls: can be used to add extra idl CORBA interfaces to the component. This parameter must gives a list of idl file + names that are added into the generated module (idl directory) and compiled with the generated idl of the module. + :param interfacedefs: can be used to add idl definitions (or includes of idl files) into the generated idl of the module. + :param inheritedinterface: can be used to make the component inherit an extra idl interface that has been included through + the *idls* and *interfacedefs* parameters. See the cppgui1 example for how to use these last parameters. + :param addmethods: is a C++ specific parameter that can be used to redefine a component method (DumpPython for example). This + parameter is a string that must contain the definition and implementation code of the method. See the cppgui1 example + for how to use it. + :param calciumextendedinterface: if you want to use the Calcium extended interface for C++ as defined by the header CalciumInterface.hxx + set this parameter to 1. By default its value is 0 so to not use extended interface. The extended interface requires boost as a dependency. + + For example, the following call defines a standalone component named "mycompo" with one service s1 (it must have been defined before):: + + >>> c1 = module_generator.CPPComponent('mycompo', services=[s1,], kind="exe", + exe_path="./launch.sh") + """ + def __init__(self, name, services=None, libs="", rlibs="", includes="", kind="lib", + exe_path=None, sources=None, inheritedclass="", compodefs="", + idls=None,interfacedefs="",inheritedinterface="",addedmethods="", + calciumextendedinterface=0): self.exe_path = exe_path - Component.__init__(self, name, services, impl="CPP", libs=libs, - rlibs=rlibs, includes=includes, kind=kind, - sources=sources) + self.calciumextendedinterface=calciumextendedinterface + Component.__init__(self, name, services, impl="CPP", libs=libs, rlibs=rlibs, + includes=includes, kind=kind, sources=sources, + inheritedclass=inheritedclass, compodefs=compodefs, idls=idls, + interfacedefs=interfacedefs, inheritedinterface=inheritedinterface, + addedmethods=addedmethods) def validate(self): """ validate component definition parameters""" Component.validate(self) kinds = ("lib", "exe") if self.kind not in kinds: - raise Invalid("kind must be one of %s" % kinds) + raise Invalid("kind must be one of %s for component %s" % (kinds,self.name)) if self.kind == "exe" : if not self.exe_path: @@ -27,40 +87,70 @@ class CPPComponent(Component): def makeCompo(self, gen): """generate files for C++ component - + return a dict where key is the file name and value is the content of the file """ cxxfile = "%s.cxx" % self.name hxxfile = "%s.hxx" % self.name if self.kind == "lib": - sources = " ".join(self.sources) - return {"Makefile.am":compoMakefile.substitute(module=gen.module.name, + sources = " ".join(map(os.path.basename,self.sources)) + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + cxxfile:self.makecxx(gen), + hxxfile:self.makehxx(gen) + } + if self.kind == "exe": + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + self.name+".exe":exeCPP.substitute(compoexe=self.exe_path), + cxxfile:self.makecxx(gen, 1), + hxxfile:self.makehxx(gen) + } + + def getMakefileItems(self,gen): + makefileItems={"header":""" +include $(top_srcdir)/adm_local/make_common_starter.am + +AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions +"""} + if self.kind == "lib": + makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] + makefileItems["salomeinclude_HEADERS"]=[self.name+".hxx"] + makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, component=self.name, - libs=self.libs, + libs=self.libs, rlibs=self.rlibs, - sources=sources, - includes=self.includes), - cxxfile:self.makecxx(gen), hxxfile:self.makehxx(gen)} - if self.kind == "exe": - return {"Makefile.am":compoEXEMakefile.substitute(module=gen.module.name, + sources= " ".join(map(os.path.basename,self.sources)), + includes=self.includes) + elif self.kind == "exe": + makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Exelib.la"] + makefileItems["salomeinclude_HEADERS"]=[self.name+".hxx"] + makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] + makefileItems["body"]=compoEXEMakefile.substitute(module=gen.module.name, component=self.name, - libs=self.libs, + libs=self.libs, rlibs=self.rlibs, - includes=self.includes), - self.name+".exe":exeCPP.substitute(compoexe=self.exe_path), - cxxfile:self.makecxx(gen, 1), hxxfile:self.makehxx(gen)} + includes=self.includes) + return makefileItems def makehxx(self, gen): """return a string that is the content of .hxx file """ services = [] for serv in self.services: - service = " void %s(" % serv.name + service = " %s %s(" % (corba_rtn_type(serv.ret,gen.module.name),serv.name) service = service+gen.makeArgs(serv)+");" services.append(service) + + if self.addedmethods: + services.append(self.addedmethods) servicesdef = "\n".join(services) - return hxxCompo.substitute(component=self.name, module=gen.module.name, - servicesdef=servicesdef) + + inheritedclass=self.inheritedclass + if self.inheritedclass: + inheritedclass= " public virtual " + self.inheritedclass + "," + + return hxxCompo.substitute(component=self.name, module=gen.module.name, + servicesdef=servicesdef, inheritedclass=inheritedclass, + compodefs=self.compodefs) def makecxx(self, gen, exe=0): """return a string that is the content of .cxx file @@ -70,25 +160,31 @@ class CPPComponent(Component): defs = [] for serv in self.services: defs.append(serv.defs) - service = cxxService.substitute(component=self.name, service=serv.name, + service = cxxService.substitute(component=self.name, service=serv.name, parameters=gen.makeArgs(serv), body=serv.body, exe=exe) streams = [] for name, typ, dep in serv.instream: - streams.append(' create_calcium_port(this,"%s","%s","IN","%s");'% (name, typ, dep)) + streams.append(' create_calcium_port(this,(char *)"%s",(char *)"%s",(char *)"IN",(char *)"%s");'% (name, typ, dep)) instream = "\n".join(streams) streams = [] for name, typ, dep in serv.outstream: - streams.append(' create_calcium_port(this,"%s","%s","OUT","%s");'% (name, typ, dep)) + streams.append(' create_calcium_port(this,(char *)"%s",(char *)"%s",(char *)"OUT",(char *)"%s");'% (name, typ, dep)) outstream = "\n".join(streams) init = initService.substitute(component=self.name, service=serv.name, instream=instream, outstream=outstream) services.append(service) inits.append(init) - return cxxCompo.substitute(component=self.name, module=gen.module.name, - exe=exe, exe_path=self.exe_path, - servicesdef="\n".join(defs), - servicesimpl="\n".join(services), - initservice='\n'.join(inits)) + + CalciumInterface="" + if self.calciumextendedinterface: + CalciumInterface="#include " + + return cxxCompo.substitute(component=self.name, module=gen.module.name, + exe=exe, exe_path=self.exe_path, + servicesdef="\n".join(defs), + servicesimpl="\n".join(services), + initservice='\n'.join(inits), + CalciumInterface=CalciumInterface) diff --git a/module_generator/doc_tmpl.py b/module_generator/doc_tmpl.py new file mode 100644 index 0000000..9fccb60 --- /dev/null +++ b/module_generator/doc_tmpl.py @@ -0,0 +1,292 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +try: + from string import Template +except: + from compat import Template,set + +docmakefile=""" +include $$(top_srcdir)/adm_local/make_common_starter.am + +salomedoc_DATA=html/index.html +salomeres_DATA = ${others} + +html/index.html: + make htm + +SPHINXOPTS = +SOURCEDIR = $$(srcdir) +SPHINXBUILD = sphinx-build +PAPEROPT_a4 = -D latex_paper_size=a4 +ALLSPHINXOPTS = -d doctrees $$(PAPEROPT_a4) $$(SPHINXOPTS) $$(SOURCEDIR) + +htm: + mkdir -p html doctrees + $$(SPHINXBUILD) -b html $$(ALLSPHINXOPTS) html + @echo + @echo "Build finished. The HTML pages are in html." + +install-data-local: + $$(INSTALL) -d $$(DESTDIR)$$(salomedocdir) + cp -rf html/* $$(DESTDIR)$$(salomedocdir) ; + +uninstall-local: + chmod -R +w $$(DESTDIR)$$(salomedocdir) + rm -rf $$(DESTDIR)$$(salomedocdir)/* + +clean-local: + -rm -rf html latex doctrees + if test -d "html"; then rm -rf html ; fi + +""" +docmakefile=Template(docmakefile) + +docconf="""# -*- coding: utf-8 -*- +# +# ${module} documentation build configuration file, created by +# sphinx-quickstart on Sun Sep 19 16:20:14 2010. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'${module}' +copyright = u'2010' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1' +# The full version, including alpha/beta/rc tags. +release = '1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = '${module}doc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', '${module}.tex', u'${module} Documentation', + u'cc', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', '${module}', u'${module} Documentation', + [u'cc'], 1) +] +""" + +docconf=Template(docconf) + +docsalomeapp=""" + +
+ +
+
+ +
+
+""" +docsalomeapp=Template(docsalomeapp) + diff --git a/module_generator/fcompo.py b/module_generator/fcompo.py index 02b8d11..03de846 100644 --- a/module_generator/fcompo.py +++ b/module_generator/fcompo.py @@ -1,3 +1,21 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# from gener import Component from cppcompo import CPPComponent @@ -11,6 +29,27 @@ else: f77Types = {"double":"double *", "long":"long *", "string":"const char *"} class F77Component(CPPComponent): + """ + A :class:`F77Component` instance represents a Fortran SALOME component with services given as a list of :class:`Service` + instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (executable or shell script). The default is to build the component as a dynamic library. + :param libs: gives all the libraries options to add when linking the generated component (-L...). + :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). + :param sources: gives all the external source files to add in the compilation step (list of paths). + :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. + + For example, the following call defines a Fortran component named "mycompo" with one service s1 (it must have been defined before). + This component is implemented as a dynamic library linked with a user's library "mylib":: + + >>> c1 = module_generator.F77Component('mycompo', services=[s1,], + libs="-lmylib -Lmydir") + + """ def __init__(self, name, services=None, libs="", rlibs="", kind="lib", exe_path=None, sources=None): CPPComponent.__init__(self, name, services, libs=libs, rlibs=rlibs, @@ -18,17 +57,22 @@ class F77Component(CPPComponent): self.impl = "F77" def makebody(self): + """generate definitions (defs attribute of services) et bodys (body attribute of services)""" for serv in self.services: #defs generation - params = ["void *compo"] + params=[] + if serv.instream or serv.outstream: + params = ["void *compo"] strparams = [] for name, typ in serv.inport: + if typ == "file":continue #files are not passed through service interface if typ == "string": params.append("const STR_PSTR(%s)"%name) strparams.append("STR_PLEN(%s)"%name) else: params.append("%s %s" % (f77Types[typ], name)) for name, typ in serv.outport: + if typ == "file":continue #files are not passed through service interface if typ == "string": params.append("const STR_PSTR(%s)"%name) strparams.append("STR_PLEN(%s)"%name) @@ -38,18 +82,22 @@ class F77Component(CPPComponent): serv.defs = serv.defs+'\nextern "C" void F_FUNC(%s,%s)(%s);' % (serv.name.lower(), serv.name.upper(), args) #body generation - params = ["&component"] + params=[] + if serv.instream or serv.outstream: + params = ["&component"] strparams = [] strallocs = [] #length allocated for out string lstr = 20 for name, typ in serv.inport: + if typ == "file":continue #files are not passed through service interface if typ == "string": params.append("STR_CPTR(%s)" % name) strparams.append("STR_CLEN(%s)"%name) else: params.append("&%s" % name) for name, typ in serv.outport: + if typ == "file":continue #files are not passed through service interface if typ == "string": params.append("STR_CPTR(%s.ptr())" % name) strparams.append("STR_CLEN(%s.ptr())"%name) @@ -61,5 +109,9 @@ class F77Component(CPPComponent): serv.body = serv.body+"\n F_CALL(%s,%s)(%s);" % (serv.name.lower(), serv.name.upper(), args) def makeCompo(self, gen): + """build a dictionary that defines component files + dictionary key = file name + dictionary value = file content or dictionary defining subdirectory content + """ self.makebody() return CPPComponent.makeCompo(self, gen) diff --git a/module_generator/gener.py b/module_generator/gener.py index 18fc93b..d388f1f 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -1,4 +1,25 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + import os, shutil, glob, socket +import traceback +import warnings try: from string import Template @@ -8,73 +29,100 @@ except: class Invalid(Exception): pass -from mod_tmpl import resMakefile, makecommon, configure +debug=0 + +from mod_tmpl import resMakefile, makecommon, configure, paco_configure from mod_tmpl import mainMakefile, autogen, application -from cata_tmpl import catalog, interface, idl, idlMakefile +from mod_tmpl import check_sphinx +from cata_tmpl import catalog, interface, idl, idlMakefile, parallel_interface +from cata_tmpl import xml, xml_interface, xml_service +from cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS +from cata_tmpl import idlMakefilePACO_salomepython_DATA, idlMakefilePACO_salomeidl_DATA +from cata_tmpl import idlMakefilePACO_INCLUDES from cata_tmpl import cataOutStream, cataInStream, cataOutparam, cataInparam +from cata_tmpl import cataOutParallelStream, cataInParallelStream from cata_tmpl import cataService, cataCompo from aster_tmpl import check_aster - -corbaTypes = {"double":"CORBA::Double", "long":"CORBA::Long", - "string":"const char*", "dblevec":"const %s::dblevec&", - "stringvec":"const %s::stringvec&", "intvec":"const %s::intvec&"} -corbaOutTypes = {"double":"CORBA::Double&", "long":"CORBA::Long&", - "string":"CORBA::String_out", "dblevec":"%s::dblevec_out", - "stringvec":"%s::stringvec_out", "intvec":"%s::intvec_out"} - -def corba_in_type(typ, module): - if typ in ("dblevec", "intvec", "stringvec"): - return corbaTypes[typ] % module - else: - return corbaTypes[typ] - -def corba_out_type(typ, module): - if typ in ("dblevec", "intvec", "stringvec"): - return corbaOutTypes[typ] % module - else: - return corbaOutTypes[typ] - -calciumTypes = {"CALCIUM_double":"CALCIUM_double", - "CALCIUM_integer":"CALCIUM_integer", - "CALCIUM_real":"CALCIUM_real", - "CALCIUM_string":"CALCIUM_string", - "CALCIUM_complex":"CALCIUM_complex", - "CALCIUM_logical":"CALCIUM_logical", - } - -ValidImpl = ("CPP", "PY", "F77", "ASTER") -ValidTypes = corbaTypes.keys() -ValidStreamTypes = calciumTypes.keys() -ValidDependencies = ("I", "T") -PyValidTypes = ValidTypes+["pyobj"] +from salomemodules import salome_modules +from yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type +from yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes +from yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies +from gui_tmpl import pyguimakefile, pysalomeapp, cppguimakefile, cppsalomeapp +from doc_tmpl import docmakefile, docconf, docsalomeapp def makedirs(namedir): + """Create a new directory named namedir. If a directory already exists copy it to namedir.bak""" if os.path.exists(namedir): dirbak = namedir+".bak" if os.path.exists(dirbak): shutil.rmtree(dirbak) os.rename(namedir, dirbak) - os.listdir(dirbak) #sert seulement a mettre a jour le systeme de fichier sur certaines machines + os.listdir(dirbak) #needed to update filesystem on special machines (cluster with NFS, for example) os.makedirs(namedir) class Module(object): - def __init__(self, name, components=None, prefix=""): + """ + A :class:`Module` instance represents a SALOME module that contains components given as a list of + component instances (:class:`CPPComponent` or :class:`PYComponent` or :class:`F77Component` or :class:`ASTERComponent`) + with the parameter *components*. + + :param name: gives the name of the module. The SALOME source module + will be located in the directory. + :type name: str + :param components: gives the list of components of the module. + :param prefix: is the path of the installation directory. + :param layout: If given and has the value "monodir", all components + will be generated in a single directory. The default is to generate each component in its + own directory. + :param doc: can be used to add an online documentation to the module. It must be a list of file names (sources, images, ...) that will be + used to build a sphinx documentation (see http://sphinx.pocoo.org, for more information). If not given, the Makefile.am + and the conf.py (sphinx configuration) files are generated. In this case, the file name extension of source files must be .rst. + See small examples in Examples/pygui1 and Examples/cppgui1. + :param gui: can be used to add a GUI to the module. It must be a list of file names (sources, images, qt designer files, ...). + If not given, the Makefile.am and SalomeApp.xml are generated. All image files are put in the resources directory of the module. + The GUI can be implemented in C++ (file name extension '.cxx') or in Python (file name extension '.py'). + See small examples in Examples/pygui1 and Examples/cppgui1. + + For example, the following call defines a module named "mymodule" with 2 components c1 and c2 (they must have been + defined before) that will be installed in the "install" directory:: + + >>> m = module_generator.Module('mymodule', components=[c1,c2], + prefix="./install") + + """ + def __init__(self, name, components=None, prefix="",layout="multidir", doc=None, gui=None): self.name = name self.components = components or [] self.prefix = prefix or "%s_INSTALL" % name - self.validate() + self.layout=layout + self.doc = doc + self.gui = gui + try: + self.validate() + except Invalid,e: + if debug: + traceback.print_exc() + print "Error in module %s: %s" % (name,e) + raise SystemExit def validate(self): + # Test Module name, canot have a "-" in the name + if self.name.find("-") != -1: + raise Invalid("Module name %s is not valid, remove character - in the module name" % self.name) lcompo = set() for compo in self.components: if compo.name in lcompo: raise Invalid("%s is already defined as a component of the module" % compo.name) lcompo.add(compo.name) compo.validate() + if self.gui and self.layout != "multidir": + raise Invalid("A module with GUI can not be generated if layout is not multidir") class Component(object): - def __init__(self, name, services=None, impl="PY", libs="", rlibs="", - includes="", kind="lib", sources=None): + def __init__(self, name, services=None, impl="PY", libs="", rlibs="", + includes="", kind="lib", sources=None, + inheritedclass="",compodefs="", + idls=None,interfacedefs="",inheritedinterface="",addedmethods=""): self.name = name self.impl = impl self.kind = kind @@ -83,6 +131,12 @@ class Component(object): self.rlibs = rlibs self.includes = includes self.sources = sources or [] + self.inheritedclass=inheritedclass + self.compodefs=compodefs + self.idls=idls + self.interfacedefs=interfacedefs + self.inheritedinterface=inheritedinterface + self.addedmethods=addedmethods def validate(self): if self.impl not in ValidImpl: @@ -103,17 +157,59 @@ class Component(object): def getImpl(self): return "SO", "" + def getMakefileItems(self,gen): + return {} + + def setPrerequisites(self, prerequisites_file): + self.prerequisites = prerequisites_file + class Service(object): - def __init__(self, name, inport=None, outport=None, instream=None, - outstream=None, body="", defs=""): + """ + A :class:`Service` instance represents a component service with dataflow and datastream ports. + + :param name: gives the name of the service. + :type name: str + :param inport: gives the list of input dataflow ports. + :param outport: gives the list of output dataflow ports. An input or output dataflow port is defined + by a 2-tuple (port name, data type name). The list of supported basic data types is: "double", "long", "string", + "dblevec", "stringvec", "intvec", "file" and "pyobj" only for Python services. Depending on the implementation + language, it is also possible to use some types from SALOME modules (see :ref:`yacstypes`). + :param ret: gives the type of the return parameter + :param instream: gives the list of input datastream ports. + :param outstream: gives the list of output datastream ports. An input or output datastream port is defined + by a 3-tuple (port name, data type name, mode name). The list of possible data types is: "CALCIUM_double", "CALCIUM_integer", + "CALCIUM_real", "CALCIUM_string", "CALCIUM_complex", "CALCIUM_logical", "CALCIUM_long". The mode can be "I" (iterative mode) + or "T" (temporal mode). + :param defs: gives the source code to insert in the definition section of the component. It can be C++ includes + or Python imports + :type defs: str + :param body: gives the source code to insert in the service call. It can be any C++ + or Python code that fits well in the body of the service method. + :type body: str + + For example, the following call defines a minimal Python service with one input dataflow port (name "a", type double) + and one input datastream port:: + + >>> s1 = module_generator.Service('myservice', inport=[("a","double"),], + instream=[("aa","CALCIUM_double","I")], + body="print a") + + + """ + def __init__(self, name, inport=None, outport=None, ret="void", instream=None, outstream=None, + parallel_instream=None, parallel_outstream=None, defs="", body="", impl_type="sequential"): self.name = name self.inport = inport or [] self.outport = outport or [] + self.ret = ret self.instream = instream or [] self.outstream = outstream or [] + self.parallel_instream = parallel_instream or [] + self.parallel_outstream = parallel_outstream or [] self.defs = defs self.body = body self.impl = "" + self.impl_type = impl_type def validate(self): lports = set() @@ -142,6 +238,20 @@ class Service(object): raise Invalid("%s is already defined as a stream port" % name) lports.add(name) + for port in self.parallel_instream: + name, typ = self.validateParallelStream(port) + if name in lports: + raise Invalid("%s is already defined as a stream port" % name) + lports.add(name) + + for port in self.parallel_outstream: + name, typ = self.validateParallelStream(port) + if name in lports: + raise Invalid("%s is already defined as a stream port" % name) + lports.add(name) + + self.validateImplType() + def validatePort(self, port): try: name, typ = port @@ -157,6 +267,10 @@ class Service(object): raise Invalid("%s is not a valid type. It should be one of %s" % (typ, validtypes)) return name, typ + def validateImplType(self): + if self.impl_type not in ValidImplTypes: + raise Invalid("%s is not a valid impl type. It should be one of %s" % (self.impl_type, ValidImplTypes)) + def validateStream(self, port): try: name, typ, dep = port @@ -168,18 +282,48 @@ class Service(object): raise Invalid("%s is not a valid dependency. It should be one of %s" % (dep, ValidDependencies)) return name, typ, dep + def validateParallelStream(self, port): + try: + name, typ = port + except: + raise Invalid("%s is not a valid definition of a parallel stream port (name,type)" % (port,)) + if typ not in ValidParallelStreamTypes: + raise Invalid("%s is not a valid type. It should be one of %s" % (typ, ValidParallelStreamTypes)) + return name, typ + class Generator(object): + """ + A :class:`Generator` instance take a :class:`Module` instance as its first parameter and can be used to generate the + SALOME source module, builds it, installs it and includes it in a SALOME application. + + :param module: gives the :class:`Module` instance that will be used for the generation. + :param context: If given , its content is used to specify the prerequisites + environment file (key *"prerequisites"*) and the SALOME KERNEL installation directory (key *"kernel"*). + :type context: dict + + For example, the following call creates a generator for the module m:: + + >>> g = module_generator.Generator(m,context) + """ def __init__(self, module, context=None): self.module = module self.context = context or {} self.kernel = self.context["kernel"] + self.gui = self.context.get("gui") + self.makeflags = self.context.get("makeflags") self.aster = "" + if self.module.gui and not self.gui: + raise Invalid("To generate a module with GUI, you need to set the 'gui' parameter in the context dictionnary") + for component in self.module.components: + component.setPrerequisites(self.context.get("prerequisites")) def generate(self): + """Generate a SALOME source module""" module = self.module namedir = module.name+"_SRC" force = self.context.get("force") update = self.context.get("update") + paco = self.context.get("paco") if os.path.exists(namedir): if force: shutil.rmtree(namedir) @@ -192,49 +336,371 @@ class Generator(object): srcs = {} makefile = "SUBDIRS=" - makefiles = [] + makefileItems={"header":""" +include $(top_srcdir)/adm_local/make_common_starter.am +AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions +""", + "salomepython_PYTHON":[], + "dist_salomescript_SCRIPTS":[], + "salomeres_DATA":[], + "lib_LTLIBRARIES":[], + "salomeinclude_HEADERS":[], + "body":"", + } + + #get the list of SALOME modules used and put it in used_modules attribute + def get_dependent_modules(mod,modules): + modules[mod]=1 + if not salome_modules[mod].has_key("depends"):return + for m in salome_modules[mod]["depends"]: + if modules.has_key(m):continue + get_dependent_modules(m,modules) + + modules = {} for compo in module.components: - makefile = makefile+" "+compo.name - srcs[compo.name] = compo.makeCompo(self) - makefiles.append(" src/"+compo.name+"/Makefile") + for serv in compo.services: + for name, typ in serv.inport + serv.outport + [ ("return",serv.ret) ] : + mod = moduleTypes[typ] + if mod: + get_dependent_modules(mod,modules) - srcs["Makefile.am"] = makefile+'\n' - idlfile = "%s.idl" % module.name + self.used_modules = modules.keys() + + for compo in module.components: + #for components files + fdict=compo.makeCompo(self) + if self.module.layout=="multidir": + srcs[compo.name] = fdict + #for src/Makefile.am + makefile = makefile + " " + compo.name + else: + srcs.update(fdict) + #for src/Makefile.am + mdict=compo.getMakefileItems(self) + makefileItems["salomepython_PYTHON"]=makefileItems["salomepython_PYTHON"]+mdict.get("salomepython_PYTHON",[]) + makefileItems["dist_salomescript_SCRIPTS"]=makefileItems["dist_salomescript_SCRIPTS"]+mdict.get("dist_salomescript_SCRIPTS",[]) + makefileItems["salomeres_DATA"]=makefileItems["salomeres_DATA"]+mdict.get("salomeres_DATA",[]) + makefileItems["lib_LTLIBRARIES"]=makefileItems["lib_LTLIBRARIES"]+mdict.get("lib_LTLIBRARIES",[]) + makefileItems["salomeinclude_HEADERS"]=makefileItems["salomeinclude_HEADERS"]+mdict.get("salomeinclude_HEADERS",[]) + makefileItems["body"]=makefileItems["body"]+mdict.get("body","")+'\n' + + if module.gui: + GUIname=module.name+"GUI" + fdict=self.makeGui(namedir) + srcs[GUIname] = fdict + #for src/Makefile.am + makefile = makefile + " " + GUIname + + if self.module.layout == "multidir": + srcs["Makefile.am"] = makefile+'\n' + else: + srcs["Makefile.am"] = self.makeMakefile(makefileItems) + + docsubdir="" + if module.doc: + docsubdir="doc" + + #for catalog files catalogfile = "%sCatalog.xml" % module.name + need_boost=0 + if module.gui: + need_boost=1 + for compo in module.components: + if hasattr(compo,"calciumextendedinterface") and compo.calciumextendedinterface: + need_boost=1 + break + + #add makefile definitions to make_common_starter.am + other_includes="" + common_starter = makecommon.substitute(other_includes=other_includes) + for mod in self.used_modules: + common_starter = common_starter + salome_modules[mod]["makefiledefs"] + '\n' + + adm_local={"make_common_starter.am": common_starter, "check_aster.m4":check_aster} + if module.doc: + adm_local["check_sphinx.m4"]=check_sphinx + self.makeFiles({"autogen.sh":autogen, - "Makefile.am":mainMakefile, + "Makefile.am":mainMakefile.substitute(docsubdir=docsubdir), "README":"", "NEWS":"", "AUTHORS":"", "ChangeLog":"", - "configure.ac":configure.substitute(module=module.name.lower(), makefiles='\n'.join(makefiles)), - "idl":{"Makefile.am":idlMakefile.substitute(module=module.name), idlfile:self.makeidl()}, "src":srcs, "resources":{"Makefile.am":resMakefile.substitute(module=module.name), catalogfile:self.makeCatalog()}, - "adm_local":{"make_common_starter.am":makecommon, "check_aster.m4":check_aster}, + "adm_local":adm_local, }, namedir) + + #add checks for modules in configure.ac + configure_modules="" + for mod in self.used_modules: + configure_modules = configure_modules + salome_modules[mod]["configdefs"] + '\n' + + #for configure.ac + configure_makefiles = [] + if self.module.layout=="multidir": + for compo in module.components: + configure_makefiles.append(" src/"+compo.name+"/Makefile") + + if module.gui: + configure_makefiles.append(" src/%sGUI/Makefile" % module.name) + if module.doc: + configure_makefiles.append(" doc/Makefile") + + other_check="" + other_summary="" + other_require="" + + if need_boost: + other_check=other_check+"""CHECK_BOOST +""" + other_summary=other_summary+"""echo " Boost ................. : $boost_ok" +""" + + if module.gui: + other_check=other_check + """CHECK_SALOME_GUI +CHECK_QT +""" + other_summary=other_summary+'''echo " SALOME GUI ............. : $SalomeGUI_ok" +echo " Qt ..................... : $qt_ok" +''' + other_require=other_require + """ + if test "x$SalomeGUI_ok" = "xno"; then + AC_MSG_ERROR([SALOME GUI is required],1) + fi + if test "x$qt_ok" = "xno"; then + AC_MSG_ERROR([Qt library is required],1) + fi +""" + if module.doc: + other_check=other_check+"CHECK_SPHINX\n" + other_summary=other_summary+'''echo " Sphinx ................. : $sphinx_ok"\n''' + other_require=other_require + """ + if test "x$sphinx_ok" = "xno"; then + AC_MSG_ERROR([Sphinx documentation generator is required],1) + fi +""" + + files={} + #for idl files + idlfile = "%s.idl" % module.name + paco_config="" + PACO_BUILT_SOURCES="" + PACO_SALOMEINCLUDE_HEADERS="" + PACO_INCLUDES="" + PACO_salomepython_DATA="" + PACO_salomeidl_DATA="" + + if paco: + PACO_BUILT_SOURCES = idlMakefilePaCO_BUILT_SOURCES.substitute(module=module.name) + PACO_SALOMEINCLUDE_HEADERS = idlMakefilePaCO_nodist_salomeinclude_HEADERS.substitute(module=module.name) + PACO_salomepython_DATA = idlMakefilePACO_salomepython_DATA.substitute(module=module.name) + PACO_salomeidl_DATA = idlMakefilePACO_salomeidl_DATA.substitute(module=module.name) + PACO_INCLUDES = idlMakefilePACO_INCLUDES + paco_config=paco_configure + + files["configure.ac"]=configure.substitute(module=module.name.lower(), + makefiles='\n'.join(configure_makefiles), + paco_configure=paco_config, + modules=configure_modules, + other_check=other_check, + other_summary=other_summary, + other_require=other_require, + ) + + #if components have other idls + other_idls="" + other_sks="" + for compo in module.components: + if compo.idls: + for idl in compo.idls: + for fidl in glob.glob(idl): + other_idls=other_idls+os.path.basename(fidl) +" " + other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc " + + idlfiles={"Makefile.am": idlMakefile.substitute(module=module.name, + PACO_BUILT_SOURCES=PACO_BUILT_SOURCES, + PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS, + PACO_INCLUDES=PACO_INCLUDES, + PACO_salomepython_DATA=PACO_salomepython_DATA, + PACO_salomeidl_DATA=PACO_salomeidl_DATA, + other_idls=other_idls,other_sks=other_sks, + ), + idlfile : self.makeidl(), + } + if paco: + idlfiles["%s.xml" % module.name]=self.makexml() + + files["idl"]=idlfiles + + self.makeFiles(files,namedir) + os.chmod(os.path.join(namedir, "autogen.sh"), 0777) - #copy source files if any in creates tree + #copy source files if any in created tree for compo in module.components: for src in compo.sources: - shutil.copyfile(src, os.path.join(namedir, "src", compo.name, src)) - - for m4file in ("check_Kernel.m4", "check_omniorb.m4", - "ac_linker_options.m4", "ac_cxx_option.m4", - "python.m4", "enable_pthreads.m4", "check_f77.m4", - "acx_pthread.m4", "check_boost.m4"): - shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file), + if self.module.layout=="multidir": + shutil.copyfile(src, os.path.join(namedir, "src", compo.name, os.path.basename(src))) + else: + shutil.copyfile(src, os.path.join(namedir, "src", os.path.basename(src))) + + if compo.idls: + #copy provided idl files in idl directory + for idl in compo.idls: + for fidl in glob.glob(idl): + shutil.copyfile(fidl, os.path.join(namedir, "idl", os.path.basename(fidl))) + + checks= ("check_Kernel.m4", "check_omniorb.m4", "ac_linker_options.m4", "ac_cxx_option.m4", + "python.m4", "enable_pthreads.m4", "check_f77.m4", "acx_pthread.m4", "check_paco++.m4", + "check_mpi.m4", "check_lam.m4", "check_openmpi.m4", "check_mpich.m4") + if need_boost: + checks=checks+("check_boost.m4",) + for m4file in checks: + shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file), os.path.join(namedir, "adm_local", m4file)) + if self.module.gui: + for m4file in ("check_GUI.m4", "check_qt.m4", "check_opengl.m4"): + shutil.copyfile(os.path.join(self.gui, "adm_local", "unix", "config_files", m4file), + os.path.join(namedir, "adm_local", m4file)) + + self.makeDoc(namedir) return + def makeDoc(self,namedir): + if not self.module.doc: + return + rep=os.path.join(namedir,"doc") + os.makedirs(rep) + for docs in self.module.doc: + for doc in glob.glob(docs): + name = os.path.basename(doc) + shutil.copyfile(doc, os.path.join(rep, name)) + + d={} + + others="" + if not self.module.gui: + #without gui but with doc: create a small SalomeApp.xml in doc directory + if not os.path.exists(os.path.join(namedir, "doc", "SalomeApp.xml")): + #create a minimal SalomeApp.xml + salomeapp=docsalomeapp.substitute(module=self.module.name,lmodule=self.module.name.lower()) + d["SalomeApp.xml"]=salomeapp + others="SalomeApp.xml" + + if not os.path.exists(os.path.join(namedir, "doc", "Makefile.am")): + #create a minimal makefile.am + d["Makefile.am"]=docmakefile.substitute(others=others) + + if not os.path.exists(os.path.join(namedir, "doc", "conf.py")): + #create a minimal conf.py + d["conf.py"]=docconf.substitute(module=self.module.name) + + self.makeFiles(d,os.path.join(namedir,"doc")) + + def makeGui(self,namedir): + if not self.module.gui: + return + ispython=False + iscpp=False + #Force creation of intermediate directories + os.makedirs(os.path.join(namedir, "src", self.module.name+"GUI")) + + for srcs in self.module.gui: + for src in glob.glob(srcs): + shutil.copyfile(src, os.path.join(namedir, "src", self.module.name+"GUI", os.path.basename(src))) + if src[-3:]==".py":ispython=True + if src[-4:]==".cxx":iscpp=True + if ispython and iscpp: + raise Invalid("Module GUI must be pure python or pure C++ but not mixed") + if ispython: + return self.makePyGUI(namedir) + if iscpp: + return self.makeCPPGUI(namedir) + raise Invalid("Module GUI must be in python or C++ but it is none of them") + + def makePyGUI(self,namedir): + d={} + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")): + #create a minimal makefile.am + sources=[] + other=[] + for srcs in self.module.gui: + for src in glob.glob(srcs): + if src[-3:]==".py": + sources.append(os.path.basename(src)) + else: + other.append(os.path.basename(src)) + makefile=pyguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other)) + d["Makefile.am"]=makefile + + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")): + #create a minimal SalomeApp.xml + salomeapp=pysalomeapp.substitute(module=self.module.name,lmodule=self.module.name.lower()) + d["SalomeApp.xml"]=salomeapp + + return d + + def makeCPPGUI(self,namedir): + d={} + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")): + #create a minimal makefile.am + sources=[] + other=[] + ui_files=[] + for srcs in self.module.gui: + for src in glob.glob(srcs): + if src[-4:]==".cxx": + sources.append(os.path.basename(src)) + elif src[-2:]==".h": + sources.append(os.path.basename(src)[:-2]+"_moc.cxx") + elif src[-3:]==".ui": + ui_files.append("ui_"+os.path.basename(src)[:-3]+".h") + elif src[-3:]==".ts": + other.append(os.path.basename(src)[:-3]+".qm") + else: + other.append(os.path.basename(src)) + + makefile=cppguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other), + module=self.module.name, uisources= " ".join(ui_files)) + d["Makefile.am"]=makefile + + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")): + #create a minimal SalomeApp.xml + salomeapp=cppsalomeapp.substitute(module=self.module.name,lmodule=self.module.name.lower()) + d["SalomeApp.xml"]=salomeapp + + return d + + def makeMakefile(self,makefileItems): + makefile="" + if makefileItems.has_key("header"): + makefile=makefile + makefileItems["header"]+'\n' + if makefileItems.has_key("lib_LTLIBRARIES"): + makefile=makefile+"lib_LTLIBRARIES= "+" ".join(makefileItems["lib_LTLIBRARIES"])+'\n' + if makefileItems.has_key("salomepython_PYTHON"): + makefile=makefile+"salomepython_PYTHON= "+" ".join(makefileItems["salomepython_PYTHON"])+'\n' + if makefileItems.has_key("dist_salomescript_SCRIPTS"): + makefile=makefile+"dist_salomescript_SCRIPTS= "+" ".join(makefileItems["dist_salomescript_SCRIPTS"])+'\n' + if makefileItems.has_key("salomeres_DATA"): + makefile=makefile+"salomeres_DATA= "+" ".join(makefileItems["salomeres_DATA"])+'\n' + if makefileItems.has_key("salomeinclude_HEADERS"): + makefile=makefile+"salomeinclude_HEADERS= "+" ".join(makefileItems["salomeinclude_HEADERS"])+'\n' + if makefileItems.has_key("body"): + makefile=makefile+makefileItems["body"]+'\n' + return makefile + def makeArgs(self, service): + """generate source service for arguments""" params = [] for name, typ in service.inport: + if typ=="file":continue #files are not passed through service interface params.append("%s %s" % (corba_in_type(typ, self.module.name), name)) for name, typ in service.outport: + if typ=="file":continue #files are not passed through service interface params.append("%s %s" % (corba_out_type(typ, self.module.name), name)) return ",".join(params) def makeCatalog(self): + """generate SALOME components catalog source""" components = [] for compo in self.module.components: services = [] @@ -246,12 +712,18 @@ class Generator(object): params = [] for name, typ in serv.outport: params.append(cataOutparam.substitute(name=name, type=typ)) + if serv.ret != "void" : + params.append(cataOutparam.substitute(name="return", type=serv.ret)) outparams = "\n".join(params) streams = [] for name, typ, dep in serv.instream: streams.append(cataInStream.substitute(name=name, type=calciumTypes[typ], dep=dep)) for name, typ, dep in serv.outstream: streams.append(cataOutStream.substitute(name=name, type=calciumTypes[typ], dep=dep)) + for name, typ in serv.parallel_instream: + streams.append(cataInParallelStream.substitute(name=name, type=DatastreamParallelTypes[typ])) + for name, typ in serv.parallel_outstream: + streams.append(cataOutParallelStream.substitute(name=name, type=DatastreamParallelTypes[typ])) datastreams = "\n".join(streams) services.append(cataService.substitute(service=serv.name, author="EDF-RD", inparams=inparams, outparams=outparams, datastreams=datastreams)) @@ -261,26 +733,98 @@ class Generator(object): return catalog.substitute(components='\n'.join(components)) def makeidl(self): + """generate module IDL file source (CORBA interface)""" + from pacocompo import PACOComponent interfaces = [] + idldefs="" for compo in self.module.components: - services = [] - for serv in compo.services: - params = [] - for name, typ in serv.inport: - if compo.impl in ("PY", "ASTER") and typ == "pyobj": - typ = "Engines::fileBlock" - params.append("in %s %s" % (typ, name)) - for name, typ in serv.outport: - if compo.impl in ("PY", "ASTER") and typ == "pyobj": - typ = "Engines::fileBlock" - params.append("out %s %s" % (typ, name)) - service = " void %s(" % serv.name - service = service+",".join(params)+") raises (SALOME::SALOME_Exception);" - services.append(service) - interfaces.append(interface.substitute(component=compo.name, services="\n".join(services))) - return idl.substitute(module=self.module.name, interfaces='\n'.join(interfaces)) + if isinstance(compo, PACOComponent): + services = [] + for serv in compo.services: + params = [] + for name, typ in serv.inport: + if typ == "file":continue #files are not passed through IDL interface + params.append("in %s %s" % (idlTypes[typ], name)) + for name, typ in serv.outport: + if typ == "file":continue #files are not passed through IDL interface + params.append("out %s %s" % (idlTypes[typ], name)) + service = " void %s(" % serv.name + service = service+",".join(params)+");" + services.append(service) + + interfaces.append(parallel_interface.substitute(component=compo.name, services="\n".join(services))) + + else: + services = [] + for serv in compo.services: + params = [] + for name, typ in serv.inport: + if typ == "file":continue #files are not passed through IDL interface + if compo.impl in ("PY", "ASTER") and typ == "pyobj": + typ = "Engines::fileBlock" + else: + typ=idlTypes[typ] + params.append("in %s %s" % (typ, name)) + for name, typ in serv.outport: + if typ == "file":continue #files are not passed through IDL interface + if compo.impl in ("PY", "ASTER") and typ == "pyobj": + typ = "Engines::fileBlock" + else: + typ=idlTypes[typ] + params.append("out %s %s" % (typ, name)) + service = " %s %s(" % (idlTypes[serv.ret],serv.name) + service = service+",".join(params)+") raises (SALOME::SALOME_Exception);" + services.append(service) + + from hxxcompo import HXX2SALOMEComponent + from hxxparacompo import HXX2SALOMEParaComponent + if isinstance(compo,HXX2SALOMEComponent) or isinstance(compo,HXX2SALOMEParaComponent): + from hxx_tmpl import interfaceidlhxx + Inherited="" + if isinstance(compo,HXX2SALOMEParaComponent): + Inherited="SALOME_MED::ParaMEDMEMComponent" + idldefs="""#include "ParaMEDMEMComponent.idl"\n""" + else: + if compo.use_medmem==True: + Inherited="Engines::EngineComponent,SALOME::MultiCommClass,SALOME_MED::MED_Gen_Driver" + else: + Inherited="Engines::EngineComponent" + interfaces.append(interfaceidlhxx.substitute(component=compo.name,inherited=Inherited, services="\n".join(services))) + else: + inheritedinterface="" + if compo.inheritedinterface: + inheritedinterface=compo.inheritedinterface+"," + interfaces.append(interface.substitute(component=compo.name, services="\n".join(services),inheritedinterface=inheritedinterface)) + + #build idl includes for SALOME modules + for mod in self.used_modules: + idldefs = idldefs + salome_modules[mod]["idldefs"] + + for compo in self.module.components: + if compo.interfacedefs: + idldefs = idldefs + compo.interfacedefs + + return idl.substitute(module=self.module.name, interfaces='\n'.join(interfaces),idldefs=idldefs) + + # For PaCO++ + def makexml(self): + from pacocompo import PACOComponent + interfaces = [] + for compo in self.module.components: + if isinstance(compo, PACOComponent): + services = [] + for serv in compo.services: + if serv.impl_type == "parallel": + service = xml_service.substitute(service_name=serv.name) + services.append(service) + interfaces.append(xml_interface.substitute(component=compo.name, xml_services="\n".join(services))) + return xml.substitute(module=self.module.name, interfaces='\n'.join(interfaces)) def makeFiles(self, dic, basedir): + """create files and directories defined in dictionary dic in basedir directory + dic key = file name to create + dic value = file content or dictionary defining the content of a sub directory + """ for name, content in dic.items(): filename = os.path.join(basedir, name) if isinstance(content, str): @@ -293,33 +837,75 @@ class Generator(object): self.makeFiles(content, filename) def bootstrap(self): + """Execute the first build step (bootstrap autotools with autogen.sh script) : execution of libtool, autoconf, automake""" ier = os.system("cd %s_SRC;sh autogen.sh" % self.module.name) if ier != 0: raise Invalid("bootstrap has ended in error") def configure(self): + """Execute the second build step (configure) with installation prefix as given by the prefix attribute of module""" prefix = self.module.prefix + paco = self.context.get("paco") + mpi = self.context.get("mpi") + args = (self.module.name, self.kernel, self.aster) + cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s" % args + if self.gui: + cmd = cmd + " --with-gui=%s" % self.gui if prefix: prefix = os.path.abspath(prefix) - cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s --prefix=%s" - ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix)) - else: - cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s" - ier = os.system(cmd % (self.module.name, self.kernel, self.aster)) + cmd = cmd + " --prefix=%s" % prefix + if paco: + cmd += " --with-paco=%s" % paco + if mpi: + cmd += " --with-mpi=%s" % mpi + + ier = os.system(cmd) if ier != 0: raise Invalid("configure has ended in error") def make(self): - ier = os.system("cd %s_SRC;make" % self.module.name) + """Execute the third build step (compile and link) : make""" + make_command = "make " + if self.makeflags: + make_command += self.makeflags + ier = os.system("cd %s_SRC;%s" % (self.module.name, make_command)) if ier != 0: raise Invalid("make has ended in error") def install(self): + """Execute the installation step : make install """ + makedirs(self.module.prefix) ier = os.system("cd %s_SRC;make install" % self.module.name) if ier != 0: raise Invalid("install has ended in error") - def make_appli(self, appliname, restrict=None, altmodules=None): + def make_appli(self, appliname, restrict=None, altmodules=None, resources=""): + """ + Create a SALOME application containing the module and preexisting SALOME modules. + + :param appliname: is a string that gives the name of the application (directory path where the application + will be installed). + :type appliname: str + :param restrict: If given (a list of module names), only those SALOME modules will be included in the + application. The default is to include all modules that are located in the same directory as the KERNEL module and have + the same suffix (for example, if KERNEL directory is KERNEL_V5 and GEOM directory is GEOM_V5, GEOM module is automatically + included, except if restrict is used). + :param altmodules: can be used to add SALOME modules that cannot be managed with the precedent rule. This parameter + is a dict with a module name as the key and the installation path as the value. + :param resources: can be used to define an alternative resources catalog (path of the file). + + For example, the following calls create a SALOME application with external modules and resources catalog in "appli" directory:: + + >>> g=Generator(m,context) + >>> g.generate() + >>> g.bootstrap() + >>> g.configure() + >>> g.make() + >>> g.install() + >>> g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}, + resources="myresources.xml") + + """ makedirs(appliname) rootdir, kerdir = os.path.split(self.kernel) @@ -365,6 +951,7 @@ class Generator(object): #add the generated module modules.append(' ' % (self.module.name, os.path.abspath(self.module.prefix))) + #try to find a prerequisites file prerequisites = self.context.get("prerequisites") if not prerequisites: @@ -373,8 +960,15 @@ class Generator(object): if not os.path.exists(prerequisites): raise Invalid("Can not create an application : prerequisites file not defined or does not exist") + #add resources catalog if it exists + resources_spec="" + if os.path.isfile(resources): + resources_spec='' % os.path.abspath(resources) + #create config_appli.xml file - appli = application.substitute(prerequisites=prerequisites, modules="\n".join(modules)) + appli = application.substitute(prerequisites=prerequisites, + modules="\n".join(modules), + resources=resources_spec) fil = open(os.path.join(appliname, "config_appli.xml"), 'w') fil.write(appli) fil.close() diff --git a/module_generator/gui_tmpl.py b/module_generator/gui_tmpl.py new file mode 100644 index 0000000..4cfc9fa --- /dev/null +++ b/module_generator/gui_tmpl.py @@ -0,0 +1,97 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +try: + from string import Template +except: + from compat import Template,set + +pyguimakefile=""" +include $$(top_srcdir)/adm_local/make_common_starter.am + +# Scripts to be installed +salomepython_PYTHON= ${sources} + +salomeres_DATA =SalomeApp.xml ${other_sources} +""" +pyguimakefile=Template(pyguimakefile) + + +pysalomeapp=""" + +
+ + + + +
+
+ +
+
+ + +
+
+""" +pysalomeapp=Template(pysalomeapp) + +cppguimakefile=""" +include $$(top_srcdir)/adm_local/make_common_starter.am + +BUILT_SOURCES=${uisources} + +lib_LTLIBRARIES= lib${module}.la +lib${module}_la_SOURCES = ${sources} +lib${module}_la_CPPFLAGS = $$(SALOME_INCLUDES) $$(GUI_CXXFLAGS) $$(BOOST_CPPFLAGS) $$(QT_INCLUDES) -I$$(top_builddir)/idl +lib${module}_la_LIBADD = -L$$(top_builddir)/idl -lSalomeIDL${module} + +salomeres_DATA =SalomeApp.xml ${other_sources} + +# meta object implementation files generation (moc) +%_moc.cxx: %.h + $$(MOC) $$< -o $$@ + +# qt forms files generation (uic) +ui_%.h: %.ui + $$(UIC) -o $$@ $$< + +# translation (*.qm) files generation (lrelease) +%.qm: %.ts + $$(LRELEASE) $$< -qm $$@ +""" +cppguimakefile=Template(cppguimakefile) + +cppsalomeapp=""" + +
+ + + +
+
+ +
+
+ + +
+
+""" +cppsalomeapp=Template(cppsalomeapp) diff --git a/module_generator/hxx_awk.py b/module_generator/hxx_awk.py new file mode 100644 index 0000000..e914672 --- /dev/null +++ b/module_generator/hxx_awk.py @@ -0,0 +1,500 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# only the first two characters of the map are actually used to find out in/out caracteristic +cpp2idl_mapping={} +cpp2idl_mapping["int"]="in long" +cpp2idl_mapping["bool"]="in boolean" +cpp2idl_mapping["double"]="in double" +cpp2idl_mapping["float"]="in float" +cpp2idl_mapping["long"]="in long" +cpp2idl_mapping["short"]="in short" +cpp2idl_mapping["unsigned"]="in unsigned long" +cpp2idl_mapping["const char*"]="in string" +cpp2idl_mapping["const std::string&"]="in string" +cpp2idl_mapping["int&"]="out long" +cpp2idl_mapping["bool&"]="out boolean" +cpp2idl_mapping["double&"]="out double" +cpp2idl_mapping["float&"]="out float" +cpp2idl_mapping["long&"]="out long" +cpp2idl_mapping["short&"]="out short" +cpp2idl_mapping["unsigned&"]="out unsigned long" +cpp2idl_mapping["std::string&"]="out string" +cpp2idl_mapping["const MEDMEM::MESH&"]="in SALOME_MED::MESH" +cpp2idl_mapping["const MEDMEM::MESH*"]="in SALOME_MED::MESH" +cpp2idl_mapping["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT" +cpp2idl_mapping["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT" +cpp2idl_mapping["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDDOUBLE" +cpp2idl_mapping["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDDOUBLE" +cpp2idl_mapping["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDDOUBLE" +cpp2idl_mapping["const std::vector&"]="in %(module)s::dblevec" +cpp2idl_mapping["const std::vector >&"]="in SALOME::Matrix" +cpp2idl_mapping["std::vector*&"]="out %(module)s::dblevec" +cpp2idl_mapping["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDINT" +cpp2idl_mapping["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDINT" +cpp2idl_mapping["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDINT" +cpp2idl_mapping["const std::vector&"]="in %(module)s::intvec" +cpp2idl_mapping["std::vector*&"]="out %(module)s::intvec" +cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +cpp2idl_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="out SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" + +# ['stringvec', 'string', 'double', 'long', 'dblevec', 'file', 'intvec', 'dataref', 'GEOM_Object', 'SMESH_Mesh', 'SMESH_Hypothesis', 'SALOME_MED/MED', 'SALOME_MED/MESH', 'SALOME_MED/SUPPORT', 'SALOME_MED/FIELD', 'SALOME_MED/FIELDDOUBLE', 'SALOME_MED/FIELDINT'] +cpp2yacs_mapping={} +cpp2yacs_mapping["int"]="long" +cpp2yacs_mapping["bool"]="boolean" +cpp2yacs_mapping["double"]="double" +#cpp2yacs_mapping["float"]="in float" +cpp2yacs_mapping["long"]="long" +#cpp2yacs_mapping["short"]="in short" +#cpp2yacs_mapping["unsigned"]="in unsigned long" +cpp2yacs_mapping["const char*"]="string" +cpp2yacs_mapping["const std::string&"]="string" +cpp2yacs_mapping["int&"]="long" +cpp2yacs_mapping["bool&"]="boolean" +cpp2yacs_mapping["double&"]="double" +#cpp2yacs_mapping["float&"]="out float" +cpp2yacs_mapping["long&"]="long" +#cpp2yacs_mapping["short&"]="out short" +#cpp2yacs_mapping["unsigned&"]="out unsigned long" +cpp2yacs_mapping["std::string&"]="string" +cpp2yacs_mapping["const MEDMEM::MESH&"]="SALOME_MED/MESH" +cpp2yacs_mapping["const MEDMEM::MESH*"]="SALOME_MED/MESH" +cpp2yacs_mapping["const MEDMEM::SUPPORT&"]="SALOME_MED/SUPPORT" +cpp2yacs_mapping["const MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT" +cpp2yacs_mapping["const MEDMEM::FIELD*"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["const MEDMEM::FIELD&"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["MEDMEM::FIELD*&"]="SALOME_MED/FIELDDOUBLE" + +cpp2yacs_mapping["const std::vector&"]="dblevec" + +cpp2yacs_mapping["const std::vector >&"]="SALOME/Matrix" + +cpp2yacs_mapping["std::vector*&"]="dblevec" + +cpp2yacs_mapping["const MEDMEM::FIELD*"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["const MEDMEM::FIELD&"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["MEDMEM::FIELD*&"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["const std::vector&"]="intvec" +cpp2yacs_mapping["std::vector*&"]="intvec" + +cpp2yacs_mapping["void"]="void" +cpp2yacs_mapping["char*"]="string" +cpp2yacs_mapping["std::string"]="string" +cpp2yacs_mapping["MEDMEM::MESH&"]="SALOME_MED/MESH" +cpp2yacs_mapping["MEDMEM::MESH*"]="SALOME_MED/MESH" +cpp2yacs_mapping["MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT" +cpp2yacs_mapping["MEDMEM::FIELD*"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["MEDMEM::FIELD&"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["MEDMEM::FIELD*"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["MEDMEM::FIELD&"]="SALOME_MED/FIELDINT" + +cpp2yacs_mapping["std::vector*"]="dblevec" +cpp2yacs_mapping["std::vector*"]="intvec" + +cpp2yacs_mapping["std::vector >*"]="SALOME/Matrix" +cpp2yacs_mapping["std::vector"]="stringvec" +cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +cpp2yacs_mapping["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED/MEDCouplingUMeshCorbaInterface" +cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +# table for c++ code generation : argument's processing +cpp_impl_a={} +cpp_impl_a["int"]="\tint _%(arg)s(%(arg)s);\n" +cpp_impl_a["bool"]="\tbool _%(arg)s(%(arg)s);\n" +cpp_impl_a["double"]="\tdouble _%(arg)s(%(arg)s);\n" +cpp_impl_a["float"]="\tfloat _%(arg)s(%(arg)s);\n" +cpp_impl_a["long"]="\tlong _%(arg)s(%(arg)s);\n" +cpp_impl_a["short"]="\tshort _%(arg)s(%(arg)s);\n" +cpp_impl_a["unsigned"]="\tunsigned _%(arg)s(%(arg)s);\n" +cpp_impl_a["const char*"]="\tconst char* _%(arg)s(%(arg)s);\n" +cpp_impl_a["const std::string&"]="\tconst std::string _%(arg)s(%(arg)s);\n" +cpp_impl_a["int&"]="\tint _%(arg)s;\n" +cpp_impl_a["bool&"]="\tbool _%(arg)s;\n" +cpp_impl_a["double&"]="\tdouble _%(arg)s;\n" +cpp_impl_a["float&"]="\tfloat _%(arg)s;\n" +cpp_impl_a["long&"]="\tlong _%(arg)s;\n" +cpp_impl_a["short&"]="\tshort _%(arg)s;\n" +cpp_impl_a["unsigned&"]="\tunsigned _%(arg)s;\n" +cpp_impl_a["std::string&"]="\tstd::string _%(arg)s;\n" +cpp_impl_a["const MEDMEM::MESH&"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n" # MESHClient cannot be created on the stack (private constructor), so we create it on the heap and dereference it later (in treatment 4) +cpp_impl_a["const MEDMEM::MESH*"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n" +cpp_impl_a["const MEDMEM::SUPPORT&"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n" # SUPPORTClient cannot be created on the stack (protected destructor), so we create it on the heap and dereference it later (in treatment 4) +cpp_impl_a["const MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n" +cpp_impl_a["MEDMEM::FIELD*&"]="\tMEDMEM::FIELD* _%(arg)s;\n" +cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%(arg)s ( new MEDMEM::FIELDClient(%(arg)s) );\n" +cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%(arg)s(%(arg)s);\n" +cpp_impl_a["const std::vector&"]="\tlong _%(arg)s_size=%(arg)s.length();\n\tconst double *_%(arg)s_value = &%(arg)s[0];\n"\ + "\tstd::vector _%(arg)s(_%(arg)s_value,_%(arg)s_value+_%(arg)s_size);\n" +cpp_impl_a["std::vector*&"]="\tstd::vector* _%(arg)s;\n" +cpp_impl_a["const std::vector >&"]="\tMatrixClient _%(arg)s_client;\n\tint _%(arg)s_nbRow;\n\tint _%(arg)s_nbCol;\n"\ + "\tdouble* _%(arg)s_tab = _%(arg)s_client.getValue(%(arg)s,_%(arg)s_nbCol,_%(arg)s_nbRow);\n\tstd::vector > _%(arg)s(_%(arg)s_nbRow);\n"\ + "\tfor (int i=0; i!=_%(arg)s_nbRow; ++i)\n\t{\n\t _%(arg)s[i].resize(_%(arg)s_nbCol);\n"\ + "\t std::copy(_%(arg)s_tab+_%(arg)s_nbCol*i,_%(arg)s_tab+_%(arg)s_nbCol*(i+1), _%(arg)s[i].begin());\n\t}\n\tdelete [] _%(arg)s_tab;\n" +cpp_impl_a["MEDMEM::FIELD*&"]="\tMEDMEM::FIELD* _%(arg)s;\n" +cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%(arg)s ( new MEDMEM::FIELDClient(%(arg)s) );\n" +cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%(arg)s(%(arg)s);\n" +cpp_impl_a["const std::vector&"]="\tlong _%(arg)s_size=%(arg)s.length();\n"\ + "\tstd::vector _%(arg)s(_%(arg)s_size);\n"\ + "\tfor (int i=0; i!=_%(arg)s_size; ++i)\n\t _%(arg)s[i]=%(arg)s[i];" +cpp_impl_a["std::vector*&"]="\tstd::vector* _%(arg)s;\n" +cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n" +cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\tParaMEDMEM::MEDCouplingFieldDouble* __%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n"\ + "\tParaMEDMEM::MEDCouplingFieldDouble& _%(arg)s=*__%(arg)s;\n" +cpp_impl_a["ParaMEDMEM::MEDCouplingFieldDouble*&"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s;\n" + + +# table for c++ code generation : returned value processing +cpp_impl_b={} +cpp_impl_b["void"]="" +cpp_impl_b["int"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["bool"]="\tCORBA::Boolean _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["double"]="\tCORBA::Double _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["float"]="\tCORBA::Float _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["long"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["short"]="\tCORBA::Short _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["unsigned"]="\tCORBA::ULong _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["const char*"]="\tchar* _rtn_ior = CORBA::string_dup(_rtn_cpp);\n" +cpp_impl_b["char*"]="\tchar* _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["std::string"]="""\tchar* _rtn_ior=CORBA::string_dup(_rtn_cpp.c_str());\n +\tstd::copy(_rtn_cpp.begin(),_rtn_cpp.end(),_rtn_ior);\n""" +cpp_impl_b["const MEDMEM::MESH&"]="""\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast(&_rtn_cpp));\n +\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n""" +cpp_impl_b["MEDMEM::MESH&"]="\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(&_rtn_cpp);\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" +cpp_impl_b["MEDMEM::MESH*"]= "\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(_rtn_cpp);\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" +cpp_impl_b["const MEDMEM::MESH*"]="\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast(_rtn_cpp));\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" +cpp_impl_b["MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORT_i * _rtn_support_i = new MEDMEM::SUPPORT_i(_rtn_cpp);\n\tSALOME_MED::SUPPORT_ptr _rtn_ior = _rtn_support_i->_this();\n" +cpp_impl_b["const MEDMEM::FIELD*"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(const_cast*>(_rtn_cpp),false);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["MEDMEM::FIELD*"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(_rtn_cpp,true);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["MEDMEM::FIELD&"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(&_rtn_cpp,false);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["const MEDMEM::FIELD&"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(const_cast*>(&_rtn_cpp),false);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["std::vector*"]="""\t%(module)s::dblevec * _rtn_ior = new %(module)s::dblevec;\n +\tint _rtn_cpp_length=(*_rtn_cpp).size();\n +\t_rtn_ior->length(_rtn_cpp_length);\n +\tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n""" +cpp_impl_b["std::vector >*"]="""\tint _rtn_cpp_i=(*_rtn_cpp).size();\n\tint _rtn_cpp_j=(*_rtn_cpp)[0].size();\n +\tdouble* _rtn_tab = new double[_rtn_cpp_i*_rtn_cpp_j];\n +\tfor (int i=0; i!=_rtn_cpp_i; ++i)\n\t std::copy((*_rtn_cpp)[i].begin(),(*_rtn_cpp)[i].end(),_rtn_tab+i*_rtn_cpp_j);\n +\tSALOME_Matrix_i* _rtn_matrix_i = new SALOME_Matrix_i(*this,_rtn_tab,_rtn_cpp_i,_rtn_cpp_j,true);\n +\tSALOME::Matrix_ptr _rtn_ior = _rtn_matrix_i->_this();\n\tdelete _rtn_cpp;\n""" +cpp_impl_b["const MEDMEM::FIELD*"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast*>(_rtn_cpp),false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["MEDMEM::FIELD*"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(_rtn_cpp,true);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["MEDMEM::FIELD&"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(&_rtn_cpp,false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast*>(&_rtn_cpp),false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["std::vector*"]="""\t%(module)s::intvec * _rtn_ior = new %(module)s::intvec; +\tint _rtn_cpp_length=(*_rtn_cpp).size(); +\t_rtn_ior->length(_rtn_cpp_length); +\tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n""" +cpp_impl_b["std::vector"]="""\t%(module)s::stringvec * _rtn_ior = new %(module)s::stringvec; +\tint _rtn_cpp_length=_rtn_cpp.size(); +\t_rtn_ior->length(_rtn_cpp_length); +\tfor (int i=0; i<_rtn_cpp_length; ++i) +\t (*_rtn_ior)[i] = _rtn_cpp[i].c_str();\n""" +cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MEDCouplingFieldDoubleServant(_rtn_cpp); +\t_rtn_cpp->decrRef(); +\tSALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["ParaMEDMEM::MEDCouplingUMesh*"]="""\tParaMEDMEM::MEDCouplingUMeshServant * _rtn_mesh_i = new ParaMEDMEM::MEDCouplingUMeshServant(_rtn_cpp); +\t_rtn_cpp->decrRef(); +\tSALOME_MED::MEDCouplingUMeshCorbaInterface_ptr _rtn_ior = _rtn_mesh_i->_this();\n""" +# +# table for c++ code generation : out parameters processing and removeRef for reference counted objects +# +cpp_impl_c={} +cpp_impl_c["MEDMEM::FIELD*&"]="""\tMEDMEM::FIELDTEMPLATE_I * %(arg)s_ior = new MEDMEM::FIELDTEMPLATE_I(_%(arg)s, true);\n +\t%(arg)s = %(arg)s_ior->_this();\n""" +cpp_impl_c["MEDMEM::FIELD*&"]=""" \tMEDMEM::FIELDINT_i * %(arg)s_ior = new MEDMEM::FIELDINT_i(_%(arg)s, true);\n +\t%(arg)s = %(arg)s_ior->_this();\n""" +cpp_impl_c["std::vector*&"]="""\t%(arg)s = new %(module)s::dblevec;\n +\t%(arg)s->length((*_%(arg)s).size());\n +\tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n""" +cpp_impl_c["std::vector*&"]="""\t%(arg)s = new %(module)s::intvec;\n +\t%(arg)s->length((*_%(arg)s).size());\n +\tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n""" +cpp_impl_c["std::string&"]="\t%(arg)s = CORBA::string_dup(_%(arg)s.c_str());\n" +cpp_impl_c["int&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["bool&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["double&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["float&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["long&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["short&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["unsigned&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["const MEDMEM::MESH&"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const MEDMEM::MESH*"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const MEDMEM::SUPPORT&"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const MEDMEM::SUPPORT*"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n" +cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n" +cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\t__%(arg)s->decrRef();\n" +cpp_impl_c["ParaMEDMEM::MEDCouplingFieldDouble*&"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * %(arg)s_out=new ParaMEDMEM::MEDCouplingFieldDoubleServant(_%(arg)s); +\t_%(arg)s->decrRef(); +\t%(arg)s = %(arg)s_out->_this();\n""" + +# +# the following awk files (extracted from hxx2saloe) are used to parse hxx file +# +# +parse01=""" +# This awk program deletes C like comments '*/ ... /*' +# -- +# Copyright (C) CEA +# Author : Nicolas Crouzet (CEA) +# -- +{ + if (t = index($0, "/*")) { + if (t > 1) + tmp = substr($0, 1, t - 1) + else + tmp = "" + u = index(substr($0, t + 2), "*/") + while (u == 0) { + getline + t = -1 + u = index($0, "*/") + } + if (u <= length($0) - 2) + $0 = tmp substr($0, t + u + 3) + else + $0 = tmp + } + print $0 +} +""" +parse1=""" +# This awk program extract public functions of the class definition present in hxx interface +# -- +# Copyright (C) CEA +# Author : Nicolas Crouzet (CEA) +# -- + +BEGIN { public=0 } + +# we want to extract each function that is public and that does'nt contain +# the patterns : public, protected, private, // (comments), { and } +public == 1 && +$1 !~ /public/ && +$1 !~ /protected/ && +$1 !~ /private/ && +$1 !~ /\/\/*/ && +$1 !~ /{|}/ { + for (i=1; i<=NF; i++) + printf "%s ", $i +# change line if last field contains ";" -> one function per line in output + if ( $NF ~ /;/ ) + printf "\\n" +} + +$1 == "class" && $0 !~ /;/ {public=1} # we test matching against /;/ to get rid of forward declaration +$1 ~ /public/ {public=1} +$1 ~ /protected/ {public=0} +$1 ~ /private/ {public=0} +$1 ~ /}/ {public=0} +""" +parse2=""" +# suppress blanks between type and indirection or reference operators (* and &) +# -- +# Copyright (C) CEA +# Author : Nicolas Crouzet (CEA) +# -- +{ gsub(/[ \\t]+&/,"\\\\& ") + gsub(/[ \\t]+\*/,"* ") + print $0 } +""" +parse3=""" +# This awk program contains the type mapping tables - and the treatments +# -- +# Copyright (C) CEA, EDF +# Author : Nicolas Crouzet (CEA) +# -- +# for code generation +# +BEGIN { +# +# file name generation + class_i=class_name"_i" +# +# +# type mapping from c++ component to idl +# + idl_arg_type["int"]="in long" + idl_arg_type["bool"]="in boolean" + idl_arg_type["double"]="in double" + idl_arg_type["float"]="in float" + idl_arg_type["long"]="in long" + idl_arg_type["short"]="in short" +# idl_arg_type["unsigned"]="in unsigned long" + idl_arg_type["const char*"]="in string" + idl_arg_type["const std::string&"]="in string" + idl_arg_type["int&"]="out long" + idl_arg_type["bool&"]="out boolean" + idl_arg_type["double&"]="out double" + idl_arg_type["float&"]="out float" + idl_arg_type["long&"]="out long" + idl_arg_type["short&"]="out short" + idl_arg_type["unsigned&"]="out unsigned long" + idl_arg_type["std::string&"]="out string" + idl_arg_type["const MEDMEM::MESH&"]="in SALOME_MED::MESH" + idl_arg_type["const MEDMEM::MESH*"]="in SALOME_MED::MESH" + idl_arg_type["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT" + idl_arg_type["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT" + idl_arg_type["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDDOUBLE" + idl_arg_type["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDDOUBLE" + idl_arg_type["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDDOUBLE" + idl_arg_type["const std::vector&"]="in SALOME::vectorOfDouble" + idl_arg_type["const std::vector >&"]="in SALOME::Matrix" + idl_arg_type["std::vector*&"]="out SALOME::vectorOfDouble" + idl_arg_type["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDINT" + idl_arg_type["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDINT" + idl_arg_type["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDINT" + idl_arg_type["const std::vector&"]="in SALOME::vectorOfLong" + idl_arg_type["std::vector*&"]="out SALOME::vectorOfLong" + idl_arg_type["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" + idl_arg_type["const ParaMEDMEM::MEDCouplingFieldDouble&"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" + idl_arg_type["ParaMEDMEM::MEDCouplingFieldDouble*&"]="out SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +# +# +# mapping for returned types +# + idl_rtn_type["void"]="void" + idl_rtn_type["int"]="long" + idl_rtn_type["bool"]="boolean" + idl_rtn_type["double"]="double" + idl_rtn_type["float"]="float" + idl_rtn_type["long"]="long" + idl_rtn_type["short"]="short" + idl_rtn_type["unsigned"]="unsigned long" + idl_rtn_type["const char*"]="string" + idl_rtn_type["char*"]="string" + idl_rtn_type["std::string"]="string" + idl_rtn_type["const MEDMEM::MESH&"]="SALOME_MED::MESH" + idl_rtn_type["MEDMEM::MESH&"]="SALOME_MED::MESH" + idl_rtn_type["MEDMEM::MESH*"]="SALOME_MED::MESH" + idl_rtn_type["const MEDMEM::MESH*"]="SALOME_MED::MESH" + idl_rtn_type["MEDMEM::SUPPORT*"]="SALOME_MED::SUPPORT" + idl_rtn_type["const MEDMEM::FIELD*"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["MEDMEM::FIELD*"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["MEDMEM::FIELD&"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["const MEDMEM::FIELD&"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["std::vector*"]="SALOME::vectorOfDouble" + idl_rtn_type["std::vector >*"]="SALOME::Matrix" + idl_rtn_type["const MEDMEM::FIELD*"]="SALOME_MED::FIELDINT" + idl_rtn_type["MEDMEM::FIELD*"]="SALOME_MED::FIELDINT" + idl_rtn_type["MEDMEM::FIELD&"]="SALOME_MED::FIELDINT" + idl_rtn_type["const MEDMEM::FIELD&"]="SALOME_MED::FIELDINT" + idl_rtn_type["std::vector*"]="SALOME::vectorOfLong" + idl_rtn_type["std::vector"]="StrSeq" + idl_rtn_type["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED::MEDCouplingUMeshCorbaInterface" + idl_rtn_type["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +# +# +# record sep is ");\\n" whith blanks all around, and optional "(" at the beginning + RS="[(]?[ \\t]*[)][ \\t]*(const)?[ \\t]*[;][ \\t]*[\\n]" + FS="[ \\t]*[(,][ \\t]*" # field sep is either "(" or "," surrounded by blanks +} + +# --------------------- treatment 1 ---------------------------------- +# +# extract from fields types, function name, and argument's names +# +{ + print "Function : ",$0 >> "parse_result" # print for debug + for (i=1; i<=NF; i++) { + print "\\t-> ",i," : ",$i >> "parse_result" + } + ok1=0;ok=1 + error_message="\\t The non compatible types are : " + # check if returned type ($1) is one of the accepted types (idl_rtn_type) + for (cpptype in idl_rtn_type) { + if ( substr($1,1,length(cpptype)) == cpptype ) { + # if compatible, store returned type and function name + type[1]=cpptype + name[1]=substr($1,length(cpptype)+1) + sub("^[ \\t]*","",name[1]) # get rid of leading blanks + ok1=1 + break + } + } + ok*=ok1 + if ( ! ok1) { + split($1,tab," ") + error_message=error_message sprintf("\\n\\t\\t-> %s (return type)",tab[1]) + } + # for each argument ($i), check if it is compatible (belongs to idl_arg_type) + for (i=2; i<=NF; i++) { + ok2=0 + split($i,tab,"=") # get rid of default value + item=tab[1] + sub("/[ \\t]*&[ \\t]*/", "&", item) # supress spaces around * and $ + sub("/[ \\t]**[ \\t]*/", "*", item) + for (cpptype in idl_arg_type) { + l = length(cpptype) + s0 = substr(item,1,l) # to discriminate between int and int&, ... + s1 = " " + if (length(item) > l) + s1 = substr(item, l+1, 1) + + if ( (s0 == cpptype) && (s1 == " ") ) { + # if compatible, store argument type and name + type[i]=cpptype + name[i]=substr(item,length(cpptype)+1) + sub("^[ \\t]*","",name[i]) # get rid of leading blanks + if ( length(name[i]) == 0 ) # automatic name if argument's name wasn't precised + name[i]=sprintf("_arg%d",i-1) + ok2=1 + break + } + } + ok*=ok2 # ok=0 if one of the type is not compatible + if ( ! ok2) { + error_message=error_message "\\n\\t\\t-> "item + } + } + + # print compatibility + if ( $0 !~ class_name ) { # constructor are not considered, but we don't print it + if ( ok == 0){ # if one of the c++ type is not compatible + printf " [KO] : %s",$0 + } + else + printf " [OK] : %s",$0 + + if ( $0 !~ /\(/ ) { + printf "(" # if there is no argument, parenthesis was suppressed, so we add it for printing + } + printf ");\\n" + if ( ok == 0){ #print the error message + printf "%s\\n\\n",error_message + } + } + if ( ok == 0) # pass to the next function if one of the c++ type is not compatible + next +} +# +# --------------------- treatment 1 bis ------------------------------ +{ + printf "Function;%s;%s\\n",type[1],name[1] > "parse_type_result" + for (i=2; i<=NF; i++) { + printf "%s;%s\\n",type[i],name[i] >> "parse_type_result" + } +} +""" diff --git a/module_generator/hxx_para_tmpl.py b/module_generator/hxx_para_tmpl.py new file mode 100644 index 0000000..e8f60e2 --- /dev/null +++ b/module_generator/hxx_para_tmpl.py @@ -0,0 +1,214 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +try: + from string import Template +except: + from compat import Template,set + +cxxCompo=""" +// this cxx file was generated by yacsgen +#include "${component}_i.hxx" +#include "${cxx_include_file}" +using namespace std; +#include +#include +#include +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" +#include "ReceiverFactory.hxx" +#include "SALOME_Matrix_i.hxx" +#include "MatrixClient.hxx" +#include "Utils_CorbaException.hxx" +#include "MEDCouplingFieldDouble.hxx" + +typedef struct +{ + bool exception; + string msg; +} except_st; + + +//DEFS +${servicesdef} +//ENDDEF + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +${component}_i::${component}_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + bool regist) : + ParaMEDMEMComponent_i(orb,poa,contId,instanceName,interfaceName,regist),${inheritedconstructor}cppCompo_(new ${component}) +{ + MESSAGE("activate object"); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +${component}_i::~${component}_i() +{ +} + +${servicesimpl} + +${thread_impl} + +extern "C" +{ + PortableServer::ObjectId * ${component}Engine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + + bool regist; + int numproc; + int flag; + + MPI_Initialized(&flag); + if (!flag) { + int argc = 0; + char ** argv = NULL; + MPI_Init(&argc, &argv); + } + + MPI_Comm_rank( MPI_COMM_WORLD, &numproc ); + if( numproc == 0 ) + regist = true; + else + regist = false; + ${component}_i * my${component} = new ${component}_i(orb, poa, contId, instanceName, interfaceName, regist); + return my${component}->getId(); + } +} +""" +cxxCompo=Template(cxxCompo) + +hxxCompo=""" +//this file was generated by yacsgen +#ifndef __${component}_hxx2salome__ +#define __${component}_hxx2salome__ + +#include +#include "Utils_CorbaException.hxx" +#include CORBA_SERVER_HEADER(${module}) +#include "Utils_CorbaException.hxx" +#include // for std::auto_ptr + +${compodefs} + +// thread functions declaration +${thread_func_decl} + +// thread structures declaration +${thread_str_decl} + +class ${component}; // forward declaration + +class ${component}_i: ${inheritedclass} + public POA_${module}_ORB::${component}_Gen, + public ParaMEDMEM::ParaMEDMEMComponent_i +{ + +public: + ${component}_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + bool regist); + virtual ~${component}_i(); + +${servicesdef} + +// (re)defined methods of Driver + +private: + std::auto_ptr<${component}> cppCompo_; + +}; + + +extern "C" + PortableServer::ObjectId * ${component}Engine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + +#endif +""" +hxxCompo=Template(hxxCompo) + +cxxService=""" +${ret} ${component}_i::${service}(${parameters}) throw (SALOME::SALOME_Exception) +{ + beginService("${component}_i::${service}"); + BEGIN_OF("${component}_i::${service}"); + except_st *est; + void *ret_th; + pthread_t *th; + try + { +${body} + endService("${component}_i::${service}"); + END_OF("${component}_i::${service}"); + + } + catch (std::exception& ex) + { + THROW_SALOME_CORBA_EXCEPTION( ex.what(), SALOME::INTERNAL_ERROR ); + } +} +""" +cxxService=Template(cxxService) + + +compoMakefile=""" + +dist_lib${component}Engine_la_SOURCES = \ + ${component}_i.cxx + +lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) $$(MPI_INCLUDES) ${includes} +lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} -lSalomeMPIContainer -lparamedmemcompo $$(FLIBS) + + +""" + +#, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass +interfaceidlhxx=""" + interface ${component}_Gen: ${inherited} + { +${services} + }; +""" +interfaceidlhxx=Template(interfaceidlhxx) + + +compoMakefile=Template(compoMakefile) diff --git a/module_generator/hxx_tmpl.py b/module_generator/hxx_tmpl.py new file mode 100644 index 0000000..b3b3c39 --- /dev/null +++ b/module_generator/hxx_tmpl.py @@ -0,0 +1,188 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +try: + from string import Template +except: + from compat import Template,set + +cxxCompo=""" +// this cxx file was generated by yacsgen +#include "${component}_i.hxx" +#include "${component}.hxx" +using namespace std; +#include +#include +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" +#include "ReceiverFactory.hxx" +#include "SALOME_Matrix_i.hxx" +#include "MatrixClient.hxx" +#include "Utils_CorbaException.hxx" + +//DEFS +${servicesdef} +//ENDDEF + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +${component}_i::${component}_i(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),${inheritedconstructor}cppCompo_(new ${component}) +{ + MESSAGE("activate object"); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +${component}_i::~${component}_i() +{ +} + +${servicesimpl} + +char* ${component}_i::ComponentDataType() +{ + return CORBA::string_dup("${component}"); +} + +Engines::EngineComponent_ptr ${component}_i::GetComponentInstance() +{ + return ${component}_Gen::_this(); +} + +extern "C" +{ + PortableServer::ObjectId * ${component}Engine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("PortableServer::ObjectId * ${component}Engine_factory()"); + SCRUTE(interfaceName); + ${component}_i * my${component} + = new ${component}_i(orb, poa, contId, instanceName, interfaceName); + return my${component}->getId() ; + } +} +""" +cxxCompo=Template(cxxCompo) + +hxxCompo=""" +//this file was generated by yacsgen +#ifndef __${component}_hxx2salome__ +#define __${component}_hxx2salome__ + +#include +#include CORBA_SERVER_HEADER(${module}) +#include "SALOME_Component_i.hxx" +#include "SALOMEMultiComm.hxx" +#include // for std::auto_ptr +//COMPODEFS +${compodefs} +//ENDDEF + +class ${component}; // forward declaration + +class ${component}_i: ${inheritedclass} + public POA_${module}_ORB::${component}_Gen, + public Engines_Component_i +{ + +public: + ${component}_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + virtual ~${component}_i(); + +${servicesdef} + +// (re)defined methods of Driver + virtual Engines::EngineComponent_ptr GetComponentInstance(); + char* ComponentDataType(); + +private: + std::auto_ptr<${component}> cppCompo_; + +}; + + +extern "C" + PortableServer::ObjectId * ${component}Engine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + +#endif +""" +hxxCompo=Template(hxxCompo) + +cxxService=""" +${ret} ${component}_i::${service}(${parameters}) throw (SALOME::SALOME_Exception) +{ + beginService("${component}_i::${service}"); + BEGIN_OF("${component}_i::${service}"); + try + { +${body} + } + catch (std::exception& ex) + { + THROW_SALOME_CORBA_EXCEPTION( ex.what(), SALOME::INTERNAL_ERROR ); + } +} +""" +cxxService=Template(cxxService) + + +compoMakefile=""" + +dist_lib${component}Engine_la_SOURCES = \ + ${component}_i.cxx + +lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} +lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) + + +""" + +#, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass +interfaceidlhxx=""" + interface ${component}_Gen: ${inherited} + { +${services} + }; +""" +interfaceidlhxx=Template(interfaceidlhxx) + + +compoMakefile=Template(compoMakefile) diff --git a/module_generator/hxx_tmpl_gui.py b/module_generator/hxx_tmpl_gui.py new file mode 100644 index 0000000..2950c5d --- /dev/null +++ b/module_generator/hxx_tmpl_gui.py @@ -0,0 +1,602 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +try: + from string import Template +except: + from compat import Template,set + +hxxgui_cxx=""" +#include "${component_name}GUI.h" + +#include +#include +#include +#include +#include +#include + +#include + +#define COMPONENT_NAME "${component_name}" + +using namespace std; + +// Constructor +${component_name}GUI::${component_name}GUI() : + SalomeApp_Module( COMPONENT_NAME ), // Module name + LightApp_Module( COMPONENT_NAME ) +{ + // Initializations + default_bool = false; + default_int = 0; + default_spinInt = 0; + default_spinDbl = 0.; + default_selection = QString(""); + + // List for the selector + selector_strings.clear(); + selector_strings.append( tr( "PREF_LIST_TEXT_0" ) ); + selector_strings.append( tr( "PREF_LIST_TEXT_1" ) ); + selector_strings.append( tr( "PREF_LIST_TEXT_2" ) ); +} + +// Gets a reference to the module's engine +${component_name}_ORB::${component_name}_Gen_ptr ${component_name}GUI::Init${component_name}Gen( SalomeApp_Application* app ) +{ + Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer",COMPONENT_NAME ); + ${component_name}_ORB::${component_name}_Gen_ptr clr = ${component_name}_ORB::${component_name}_Gen::_narrow(comp); + ASSERT(!CORBA::is_nil(clr)); + return clr; +} + +// Module's initialization +void ${component_name}GUI::initialize( CAM_Application* app ) +{ + // Get handle to Application, Desktop and Resource Manager + SalomeApp_Module::initialize( app ); + + Init${component_name}Gen( dynamic_cast( app ) ); + + QWidget* aParent = app->desktop(); + + SUIT_ResourceMgr* aResourceMgr = application()->resourceMgr(); + + // GUI items + // --> Create actions: 190 is linked to item in "File" menu + // and 901 is linked to both specific menu and toolbar + createAction( 190, tr( "TLT_MY_NEW_ITEM" ), QIcon(), tr( "MEN_MY_NEW_ITEM" ), tr( "STS_MY_NEW_ITEM" ), 0, aParent, false, + this, SLOT( OnMyNewItem() ) ); + + QPixmap aPixmap = aResourceMgr->loadPixmap( COMPONENT_NAME,tr( "ICON_${component_name}" ) ); + createAction( 901, tr( "TLT_${component_name}_ACTION" ), QIcon( aPixmap ), tr( "MEN_${component_name}_ACTION" ), tr( "STS_${component_name}_ACTION" ), 0, aParent, false, + this, SLOT( OnCallAction() ) ); + + // --> Create item in "File" menu + int aMenuId; + aMenuId = createMenu( tr( "MEN_FILE" ), -1, -1 ); + createMenu( separator(), aMenuId, -1, 10 ); + aMenuId = createMenu( tr( "MEN_FILE_${component_name}" ), aMenuId, -1, 10 ); + createMenu( 190, aMenuId ); + + // --> Create specific menu + aMenuId = createMenu( tr( "MEN_${component_name}" ), -1, -1, 30 ); + createMenu( 901, aMenuId, 10 ); + + // --> Create toolbar item + int aToolId = createTool ( tr( "TOOL_${component_name}" ) ); + createTool( 901, aToolId ); +} + +// Module's engine IOR +QString ${component_name}GUI::engineIOR() const +{ + CORBA::String_var anIOR = getApp()->orb()->object_to_string( Init${component_name}Gen( getApp() ) ); + return QString( anIOR.in() ); +} + +// Module's activation +bool ${component_name}GUI::activateModule( SUIT_Study* theStudy ) +{ + bool bOk = SalomeApp_Module::activateModule( theStudy ); + + setMenuShown( true ); + setToolShown( true ); + + return bOk; +} + +// Module's deactivation +bool ${component_name}GUI::deactivateModule( SUIT_Study* theStudy ) +{ + setMenuShown( false ); + setToolShown( false ); + + return SalomeApp_Module::deactivateModule( theStudy ); +} + +// Default windows +void ${component_name}GUI::windows( QMap& theMap ) const +{ + theMap.clear(); + theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); + theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); +} + +// Action slot: Launched with action 190 +void ${component_name}GUI::OnMyNewItem() +{ + SUIT_MessageBox::warning( getApp()->desktop(),tr( "INF_${component_name}_TITLE" ), tr( "INF_${component_name}_TEXT" ), tr( "BUT_OK" ) ); +} + +// Action slot: Launched with action 901 +void ${component_name}GUI::OnCallAction() +{ + // Create a ${component_name} component + ${component_name}_ORB::${component_name}_Gen_ptr ${component_name}gen = ${component_name}GUI::Init${component_name}Gen( getApp() ); + + // Do the job... + // + // ${component_name}gen->method( arg1, arg2, ... ); + + // Open a dialog showing Preferences values (just to display something) + + // ****** Direct access to preferences: implementation at 12/12/05 ****** + // Comment out this section when "preferencesChanged" called back + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + + default_bool = mgr->booleanValue(COMPONENT_NAME, "default_bool", false); + + default_int = mgr->integerValue(COMPONENT_NAME, "default_integer", 3); + + default_spinInt = mgr->integerValue(COMPONENT_NAME, "default_spinint", 4); + + default_spinDbl = mgr->doubleValue(COMPONENT_NAME, "default_spindbl", 4.5); + + int selectorIndex = mgr->integerValue(COMPONENT_NAME, "default_selector"); + default_selection = (0<=selectorIndex && selectorIndex<=selector_strings.count() ? selector_strings[selectorIndex]: QString("None")); + // ****** End of section to be commented out ****** + + QString SUC = ( default_bool ? QString( tr ("INF_${component_name}_CHECK") ) : QString( tr("INF_${component_name}_UNCHECK") ) ) ; + + QString textResult = QString( tr( "RES_${component_name}_TEXT" ) ).arg(SUC).arg(default_int).arg(default_spinInt).arg(default_spinDbl).arg(default_selection); + SUIT_MessageBox::information( getApp()->desktop(), tr( "RES_${component_name}_TITLE" ), textResult, tr( "BUT_OK" ) ); +} + +void ${component_name}GUI::createPreferences() +{ + // A sample preference dialog + + // One only tab + int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) ); + + // One only group + int defaultsGroup = addPreference( tr( "PREF_GROUP_DEFAULTS" ), genTab ); + + // A checkbox + addPreference( tr( "PREF_DEFAULT_BOOL" ), defaultsGroup, LightApp_Preferences::Bool, COMPONENT_NAME, "default_bool" ); + + // An entry for integer + addPreference( tr( "PREF_DEFAULT_INTEGER" ), defaultsGroup, LightApp_Preferences::Integer, COMPONENT_NAME, "default_integer" ); + + // An integer changed by spinbox + int spinInt = addPreference( tr( "PREF_DEFAULT_SPININT" ), defaultsGroup, LightApp_Preferences::IntSpin, COMPONENT_NAME, "default_spinint" ); + setPreferenceProperty( spinInt, "min", 0 ); + setPreferenceProperty( spinInt, "max", 20 ); + setPreferenceProperty( spinInt, "step", 2 ); + + // A Double changed by spinbox + int spinDbl = addPreference( tr( "PREF_DEFAULT_SPINDBL" ), defaultsGroup, LightApp_Preferences::DblSpin, COMPONENT_NAME, "default_spindbl" ); + setPreferenceProperty( spinDbl, "min", 1 ); + setPreferenceProperty( spinDbl, "max", 10 ); + setPreferenceProperty( spinDbl, "step", 0.1 ); + + // A choice in a list + int options = addPreference( tr( "PREF_DEFAULT_SELECTOR" ), defaultsGroup, LightApp_Preferences::Selector, COMPONENT_NAME, "default_selector" ); + QList indices; + indices.append( 0 ); + indices.append( 1 ); + indices.append( 2 ); + setPreferenceProperty( options, "strings", selector_strings ); + setPreferenceProperty( options, "indexes", indices ); +} + +void ${component_name}GUI::preferencesChanged( const QString& sect, const QString& name ) +{ +// ****** This is normal way: Not yet called back at 12/12/05 ****** + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if( sect==COMPONENT_NAME ) + { + if( name=="default_bool" ) + default_bool = mgr->booleanValue(COMPONENT_NAME, "default_bool", false); + if( name=="default_integer" ) + default_int = mgr->integerValue(COMPONENT_NAME, "default_integer", 3); + if( name=="default_spinint" ) + default_spinInt = mgr->integerValue(COMPONENT_NAME, "default_spinint", 4); + if( name=="default_spindbl" ) + default_spinDbl = mgr->doubleValue(COMPONENT_NAME, "default_spindbl", 4.5); + if( name=="default_selector" ) + { + int selectorIndex = mgr->integerValue(COMPONENT_NAME, "default_selector"); + default_selection = (0<=selectorIndex && selectorIndex<=selector_strings.count() ? selector_strings[selectorIndex]: QString("None")); + } + } +} + +// Export the module +extern "C" { + CAM_Module* createModule() + { + return new ${component_name}GUI(); + } +} +""" +hxxgui_cxx=Template(hxxgui_cxx) + +hxxgui_h=""" +#ifndef _${component_name}GUI_H_ +#define _${component_name}GUI_H_ + +#include + +#include +#include CORBA_CLIENT_HEADER(${component_name}) + +class SalomeApp_Application; +class ${component_name}GUI: public SalomeApp_Module +{ + Q_OBJECT + +public: + ${component_name}GUI(); + + void initialize( CAM_Application* ); + QString engineIOR() const; + void windows( QMap& ) const; + + static ${component_name}_ORB::${component_name}_Gen_ptr Init${component_name}Gen( SalomeApp_Application* ); + + virtual void createPreferences(); + virtual void preferencesChanged( const QString&, const QString& ); + +public slots: + bool deactivateModule( SUIT_Study* ); + bool activateModule( SUIT_Study* ); + +protected slots: + void OnMyNewItem(); + void OnCallAction(); + +private: + bool default_bool; + int default_int; + int default_spinInt; + double default_spinDbl; + QString default_selection; + + QStringList selector_strings; + +}; + +#endif +""" +hxxgui_h=Template(hxxgui_h) +hxxgui_icon_ts=""" + + + + @default + + ICON_${component_name} + Exec${component_name}.png + + + +""" +hxxgui_icon_ts=Template(hxxgui_icon_ts) +hxxgui_message_en=""" + + + + @default + + TLT_MY_NEW_ITEM + A ${component_name} owned menu item + + + MEN_MY_NEW_ITEM + My menu + + + STS_MY_NEW_ITEM + Display a simple dialog + + + TLT_${component_name}_ACTION + Open ${component_name} dialog + + + MEN_FILE + File + + + MEN_FILE_${component_name} + ${component_name} menu + + + MEN_${component_name} + ${component_name} + + + TOOL_${component_name} + ${component_name} + + + + ${component_name}GUI + + BUT_OK + OK + + + BUT_CANCEL + Cancel + + + INF_${component_name}_TITLE + ${component_name} Information + + + INF_${component_name}_TEXT + This is just a test + + + INF_${component_name}_CHECK + checked + + + INF_${component_name}_UNCHECK + Unchecked + + + RES_${component_name}_TITLE + Sample ${component_name} dialog + + + RES_${component_name}_TEXT + Preferences are: \n\tCheckbox: %1\n\tInteger: %2\n\tInteger2: %3\n\tDouble: %4\n\tText: %5 + + + PREF_TAB_GENERAL + General + + + PREF_GROUP_DEFAULTS + Default Values + + + PREF_DEFAULT_BOOL + Check me + + + PREF_DEFAULT_INTEGER + Enter an integer : + + + PREF_DEFAULT_SPININT + Click arrows (integer) : + + + PREF_DEFAULT_SPINDBL + Click arrows (double) + + + PREF_DEFAULT_SELECTOR + Select an option + + + PREF_LIST_TEXT_0 + first option + + + PREF_LIST_TEXT_1 + second option + + + PREF_LIST_TEXT_2 + third option + + + +""" +hxxgui_message_en=Template(hxxgui_message_en) +hxxgui_message_fr=""" + + + + @default + + TLT_MY_NEW_ITEM + Un article de menu propre a ${component_name} + + + MEN_MY_NEW_ITEM + Mon menu + + + STS_MY_NEW_ITEM + Affiche une boite de dialogue simple + + + TLT_${component_name}_ACTION + Ouvre la boite de dialogue de ${component_name} + + + MEN_FILE + File + + + MEN_FILE_${component_name} + Menu de ${component_name} + + + MEN_${component_name} + ${component_name} + + + TOOL_${component_name} + ${component_name} + + + + ${component_name}GUI + + BUT_OK + OK + + + BUT_CANCEL + Annuler + + + INF_${component_name}_TITLE + Information ${component_name} + + + INF_${component_name}_TEXT + Ceci est un simple test + + + INF_${component_name}_CHECK + coche + + + INF_${component_name}_UNCHECK + decoche + + + RES_${component_name}_TITLE + Dialogue example de ${component_name} + + + RES_${component_name}_TEXT + Les preferences sont : \n\tCase a cocher : %1\n\tEntier : %2\n\tEntier2 : %3\n\tDouble : %4\n\tTexte : %5 + + + PREF_TAB_GENERAL + General + + + PREF_GROUP_DEFAULTS + valeur par defaut + + + PREF_DEFAULT_BOOL + Cochez-moi + + + PREF_DEFAULT_INTEGER + Entrez un entier : + + + PREF_DEFAULT_SPININT + cliquez sur les fleches (entier) + + + PREF_DEFAULT_SPINDBL + cliquez sur les fleches (double) + + + PREF_DEFAULT_SELECTOR + Choisissez une option + + + PREF_LIST_TEXT_0 + premiere option + + + PREF_LIST_TEXT_1 + deuxieme option + + + PREF_LIST_TEXT_2 + troisieme option + + + +""" +hxxgui_message_fr=Template(hxxgui_message_fr) +hxxgui_config=""" +language=en +""" +hxxgui_config=Template(hxxgui_config) +hxxgui_xml_en=""" + + + + + + + + + + + + + + + + + + + + + + + + + +""" +hxxgui_xml_en=Template(hxxgui_xml_en) +hxxgui_xml_fr=""" + + + + + + + + + + + + + + + + + + + + + + +""" +hxxgui_xml_fr=Template(hxxgui_xml_fr) + diff --git a/module_generator/hxxcompo.py b/module_generator/hxxcompo.py new file mode 100644 index 0000000..9b2e32e --- /dev/null +++ b/module_generator/hxxcompo.py @@ -0,0 +1,479 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + Module that generates SALOME c++ Component from a non SALOME c++ component + (its header and its shares library) +""" + +debug=1 +import os +import string +import fnmatch +from tempfile import mkstemp +from gener import Component, Invalid +from hxx_tmpl import cxxService, hxxCompo, cxxCompo, compoMakefile +from module_generator import Service +from yacstypes import corba_rtn_type,moduleTypes +from hxx_awk import parse01,parse1,parse2,parse3 +from hxx_awk import cpp2idl_mapping +# these tables contain the part of code which depends upon c++ types +from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c +from hxx_awk import cpp2yacs_mapping +from tempfile import mkdtemp +from hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts +from hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr +from hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en + +# ------------------------------------------------------------------------------ + +class HXX2SALOMEComponent(Component): + def __init__(self, hxxfile , cpplib , cpp_path ): + # search a file within a directory tree + def search_file(pattern, root): + matches = [] + for path, dirs, files in os.walk(os.path.abspath(root)): + for filename in fnmatch.filter(files, pattern): + matches.append(os.path.join(path, filename)) + return matches + + hxxfileful = search_file(hxxfile,cpp_path) + cpplibful = search_file(cpplib,cpp_path) + format_error = 'Error in HXX2SALOMEComponent : file %s ot found in %s' + assert len(hxxfileful) > 0, format_error % (hxxfile, cpp_path) + assert len(cpplibful) > 0, format_error % (cpplib, cpp_path) + hxxfile = hxxfileful[0] + cpplib = cpplibful[0] + + # grab name of c++ component + cmd1="""awk '$1 == "class" && $0 !~ /;/ {print $2}' """ + hxxfile +\ + """|awk -F: '{printf "%s",$1}' """ + f=os.popen(cmd1) + class_name=f.readlines()[0] + name=class_name + print "classname=",class_name + f.close() + + # create temporary awk files for the parsing + (fd01,p01n)=mkstemp() + f01=os.fdopen(fd01,"w") + f01.write(parse01) + f01.close() + + (fd1,p1n)=mkstemp() + f1=os.fdopen(fd1,"w") + f1.write(parse1) + f1.close() + + (fd2,p2n)=mkstemp() + f2=os.fdopen(fd2,"w") + f2.write(parse2) + f2.close() + + (fd3,p3n)=mkstemp() + f3=os.fdopen(fd3,"w") + f3.write(parse3) + f3.close() + + # awk parsing of hxx files - + # result written in file parse_type_result + cmd2 = [ + "cat %s" % hxxfile, + "awk -f %s" % p01n, + "sed 's/virtual //g'", + "sed 's/MEDMEM_EXPORT//g'", + "sed 's/throw.*;/;/g'", + "awk -f %s" % p1n, + "awk -f %s" % p2n, + "awk -v class_name=%s -f %s" % (class_name, p3n) ] + cmd2 = ' | '.join(cmd2) + + os.system(cmd2) + os.remove(p01n) + os.remove(p1n) + os.remove(p2n) + os.remove(p3n) + + # Retrieve the information which was generated in + # the file parse_type_result. + # The structure of the file is : + # + # Function return_type function_name + # [arg1_type arg1_name] + # [arg2_type arg2_name] + # ... + # The service names are stored in list_of_services + # The information relative to a service (called service_name) is stored in + # the dictionnary service_definition[service_name] + list_of_services=[] + service_definition={} + result_parsing=open("parse_type_result","r") + for line in result_parsing.readlines(): + line=line[0:-1] # get rid of trailing \n + words = string.split(line,';') + + if len(words) >=3 and words[0] == "Function": # detect a new service + function_name=words[2] + # store the name of new service + list_of_services.append(function_name) + # create a dict to store informations relative to this service + service_definition[function_name]={} + service_definition[function_name]["ret"]=words[1] # return type + service_definition[function_name]["inports"]=[] + service_definition[function_name]["outports"]=[] + service_definition[function_name]["ports"]=[] + service_definition[function_name]["impl"]=[] + + # an argument type and argument name of the current service + if len(words) == 2: + current_service=list_of_services[-1] + current_service_dict=service_definition[current_service] + typename=words[0] + argname=words[1] + # store in c++ order the arg names + current_service_dict["ports"].append( (argname,typename) ) + + # separate in from out parameters + inout=cpp2idl_mapping[typename][0:2] + assert inout=="in" or inout=="ou",'Error in table cpp2idl_mapping' + if inout == "in": + current_service_dict["inports"].append((argname, typename) ) + else: + current_service_dict["outports"].append((argname, typename) ) + # + # For each service : + # - generate implementation of c++ servant + # - store it in service_definition[serv]["impl"] + for serv in list_of_services: + if debug: + print "service : ",serv + print " inports -> ",service_definition[serv]["inports"] + print " outports -> ",service_definition[serv]["outports"] + print " return -> ",service_definition[serv]["ret"] + + + # Part 1 : Argument pre-processing + s_argument_processing="//\tArguments processing\n" + for (argname,argtype) in service_definition[serv]["inports"] + \ + service_definition[serv]["outports"]: + format=cpp_impl_a[argtype] + s_argument_processing += format % {"arg" : argname } + + # if there was no args + if s_argument_processing=="//\tArguments processing\n": + s_argument_processing="" + + + # Part 2 : Call to the underlying c++ function + s_call_cpp_function="//\tCall cpp component\n\t" + rtn_type=service_definition[serv]["ret"] + + # if return type is void, the call syntax is different + if rtn_type == "void" : + s_call_cpp_function += "cppCompo_->%s(" % serv + else: + s_call_cpp_function +=\ + "%s _rtn_cpp = cppCompo_->%s(" % (rtn_type ,serv ) + + for (argname,argtype) in service_definition[serv]["ports"]: + # special treatment for some arguments + post="" + pre="" + + if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 : + # for auto_ptr argument, retrieve the raw pointer behind + post=".get()" + if argtype == "const MEDMEM::MESH&" or \ + argtype == "const MEDMEM::SUPPORT&" : + # we cannot create MESHClient on the stack + # (private constructor!), + # so we create it on the heap and dereference it + pre="*" + + post+="," # separator between arguments + s_call_cpp_function += " %s_%s%s" % ( pre,argname,post) + if s_call_cpp_function[-1]==',': + # get rid of trailing comma + s_call_cpp_function=s_call_cpp_function[0:-1] + + s_call_cpp_function=s_call_cpp_function+');\n' + + # Part 3.a : Out Argument Post-processing + s_argument_postprocessing="//\tPost-processing & return\n" + for (argname,argtype) in service_definition[serv]["outports"]: + format=cpp_impl_c[argtype] + # the treatment of %(module) is postponed in makecxx() + # because we don't know here the module name + s_argument_postprocessing += \ + format % {"arg" : argname, "module" : "%(module)s" } + + # Part 3.b : In Argument Post-processing + for (argname,argtype) in service_definition[serv]["inports"]: + # not all in types require a treatment + if cpp_impl_c.has_key(argtype): + format=cpp_impl_c[argtype] + # id : treatment of %(module) is postponed in makecxx + s_argument_postprocessing += \ + format % {"arg" : argname, "module" : "%(module)s" } + + # Part 3.c : return processing + s_rtn_processing=cpp_impl_b[rtn_type] + + format_end_serv = "\tendService(\"%(class_name)s_i::%(serv_name)s\");" + format_end_serv += "\n\tEND_OF(\"%(class_name)s_i::%(serv_name)s\");\n" + s_rtn_processing += format_end_serv %\ + { "serv_name" : serv, "class_name" : class_name } + + if rtn_type != "void": + s_rtn_processing += "\treturn _rtn_ior;" + + service_definition[serv]["impl"] = s_argument_processing + \ + s_call_cpp_function + \ + s_argument_postprocessing + \ + s_rtn_processing + if debug: + print "implementation :\n",service_definition[serv]["impl"] + + # + # Create a list of Service objects (called services), + # and give it to Component constructor + # + services=[] + self.use_medmem=False + self.use_medcoupling=False + for serv in list_of_services: + # for inports and outports, Service class expects a list of tuples, + # each tuple containing the name and the yacs type of the port + # thus we need to convert c++ types to yacs types + # (we use for that the cpp2yacs_mapping table) + inports=[] + for op in service_definition[serv]["inports"]: + inports.append([op[0], cpp2yacs_mapping[op[1]] ] ) + + outports = [] + for op in service_definition[serv]["outports"]: + outports.append([op[0], cpp2yacs_mapping[op[1]] ] ) + + Return="void" + if service_definition[serv]["ret"] != "void": + Return=cpp2yacs_mapping[service_definition[serv]["ret"]] + + # find out if component uses medmem types and/or medcoupling types + for (argname,argtype) in inports + outports + [("return",Return)]: + if moduleTypes[argtype]=="MED": + if argtype.count("Coupling")>0: + self.use_medcoupling=True + else: + self.use_medmem=True + break + + code=service_definition[serv]["impl"] + if debug: + print "service : ",serv + print " inports -> ",service_definition[serv]["inports"] + print " converted inports -> ",inports + print " outports -> ",service_definition[serv]["outports"] + print " converted outports -> ",outports + print " Return -> ",service_definition[serv]["ret"] + print " converted Return -> ",Return + + services.append(Service(serv, + inport=inports, + outport=outports, + ret=Return, + defs="", + body=code, + ) ) + + Includes="-I${"+name+"CPP_ROOT_DIR}/include" + Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+name+"CXX" + Compodefs="" + Inheritedclass="" + self.inheritedconstructor="" + if self.use_medmem: + Compodefs=""" +#include CORBA_CLIENT_HEADER(MED) +#include CORBA_CLIENT_HEADER(MED_Gen) +#include "FIELDClient.hxx" +#include "MESHClient.hxx" +#include "MEDMEM_Support_i.hxx" +#include "MEDMEM_Mesh_i.hxx" +#include "MEDMEM_FieldTemplate_i.hxx" +#include "Med_Gen_Driver_i.hxx" +""" + Inheritedclass="Med_Gen_Driver_i, public SALOMEMultiComm" + self.inheritedconstructor="Med_Gen_Driver_i(orb)," + + if self.use_medcoupling: + Compodefs+=""" +#include CORBA_CLIENT_HEADER(MEDCouplingCorbaServant) +#include CORBA_CLIENT_HEADER(MED_Gen) +#include "MEDCouplingFieldDoubleServant.hxx" +#include "MEDCouplingUMeshServant.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingUMeshClient.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldDoubleClient.hxx" +""" + + Component.__init__(self, name, services, impl="CPP", libs=Libs, + rlibs="", includes=Includes, kind="lib", + sources=None,inheritedclass=Inheritedclass, + compodefs=Compodefs) + +# ------------------------------------------------------------------------------ + def makeCompo(self, gen): + """generate files for C++ component + return a dict where key is the file name and + value is the content of the file + """ + cxxfile = "%s_i.cxx" % self.name + hxxfile = "%s_i.hxx" % self.name + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + cxxfile:self.makecxx(gen), + hxxfile:self.makehxx(gen) + } + +# ------------------------------------------------------------------------------ + def getMakefileItems(self,gen): + makefileItems={"header":""" +include $(top_srcdir)/adm_local/make_common_starter.am + +"""} + makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] + makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] + makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, + component=self.name, + libs=self.libs, + includes=self.includes) + return makefileItems + +# ------------------------------------------------------------------------------ + def makehxx(self, gen): + """return a string that is the content of .hxx file + """ + services = [] + for serv in self.services: + service = " %s %s(" % (corba_rtn_type(serv.ret,gen.module.name), + serv.name) + service = service+gen.makeArgs(serv)+") throw (SALOME::SALOME_Exception);" + services.append(service) + servicesdef = "\n".join(services) + + inheritedclass=self.inheritedclass + if self.inheritedclass: + inheritedclass= " public virtual " + self.inheritedclass + "," + + return hxxCompo.substitute(component=self.name, + module=gen.module.name, + servicesdef=servicesdef, + inheritedclass=inheritedclass, + compodefs=self.compodefs) + +# ------------------------------------------------------------------------------ + def makecxx(self, gen, exe=0): + """return a string that is the content of .cxx file + """ + services = [] + inits = [] + defs = [] + for serv in self.services: + defs.append(serv.defs) + print "CNC bug : ",serv.body + service = cxxService.substitute( + component=self.name, + service=serv.name, + ret=corba_rtn_type(serv.ret,gen.module.name), + parameters=gen.makeArgs(serv), + body=serv.body % {"module":gen.module.name+"_ORB"} ) + services.append(service) + return cxxCompo.substitute(component=self.name, + inheritedconstructor=self.inheritedconstructor, + servicesdef="\n".join(defs), + servicesimpl="\n".join(services)) + +# ------------------------------------------------------------------------------ + def getGUIfilesTemplate(self): + """generate in a temporary directory files for a generic GUI, + and return a list with file names. + it is the responsability of the user to get rid + of the temporary directory when finished + """ + gui_cxx=hxxgui_cxx.substitute(component_name=self.name) + gui_h=hxxgui_h.substitute(component_name=self.name) + gui_icon_ts=hxxgui_icon_ts.substitute(component_name=self.name) + gui_message_en=hxxgui_message_en.substitute(component_name=self.name) + gui_message_fr=hxxgui_message_fr.substitute(component_name=self.name) + gui_config=hxxgui_config.substitute(component_name=self.name) + gui_xml_fr=hxxgui_xml_fr.substitute(component_name=self.name) + gui_xml_en=hxxgui_xml_en.substitute(component_name=self.name) + temp_dir=mkdtemp() + gui_cxx_file_name=os.path.join(temp_dir,self.name+"GUI.cxx") + gui_h_file_name=os.path.join(temp_dir,self.name+"GUI.h") + gui_icon_ts_file_name=os.path.join(temp_dir,self.name+"_icons.ts") + gui_message_en_file_name=os.path.join(temp_dir,self.name+"_msg_en.ts") + gui_message_fr_file_name=os.path.join(temp_dir,self.name+"_msg_fr.ts") + gui_config_file_name=os.path.join(temp_dir,"config") + gui_xml_fr_file_name=os.path.join(temp_dir,self.name+"_en.xml") + gui_xml_en_file_name=os.path.join(temp_dir,self.name+"_fr.xml") + + list_of_gui_names=[] + + gui_cxx_file=open(gui_cxx_file_name,"w") + gui_cxx_file.write(gui_cxx) + gui_cxx_file.close() + list_of_gui_names.append(gui_cxx_file_name) + + gui_h_file=open(gui_h_file_name,"w") + gui_h_file.write(gui_h) + gui_h_file.close() + list_of_gui_names.append(gui_h_file_name) + + gui_icon_ts_file=open(gui_icon_ts_file_name,"w") + gui_icon_ts_file.write(gui_icon_ts) + gui_icon_ts_file.close() + list_of_gui_names.append(gui_icon_ts_file_name) + + gui_message_en_file=open(gui_message_en_file_name,"w") + gui_message_en_file.write(gui_message_en) + gui_message_en_file.close() + list_of_gui_names.append(gui_message_en_file_name) + + gui_message_fr_file=open(gui_message_fr_file_name,"w") + gui_message_fr_file.write(gui_message_fr) + gui_message_fr_file.close() + list_of_gui_names.append(gui_message_fr_file_name) + + gui_config_file=open(gui_config_file_name,"w") + gui_config_file.write(gui_config) + gui_config_file.close() + list_of_gui_names.append(gui_config_file_name) + + gui_xml_fr_file=open(gui_xml_fr_file_name,"w") + gui_xml_fr_file.write(gui_xml_fr) + gui_xml_fr_file.close() + list_of_gui_names.append(gui_xml_fr_file_name) + + gui_xml_en_file=open(gui_xml_en_file_name,"w") + gui_xml_en_file.write(gui_xml_en) + gui_xml_en_file.close() + list_of_gui_names.append(gui_xml_en_file_name) + + + return list_of_gui_names diff --git a/module_generator/hxxparacompo.py b/module_generator/hxxparacompo.py new file mode 100644 index 0000000..2b0478a --- /dev/null +++ b/module_generator/hxxparacompo.py @@ -0,0 +1,439 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" + Module that generates SALOME c++ Component from a non SALOME c++ component (its header and its shares library) +""" + +debug=1 +import os +from gener import Component, Invalid +from hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, compoMakefile +from module_generator import Service +import string +from tempfile import mkstemp +from yacstypes import corba_rtn_type,moduleTypes + +class HXX2SALOMEParaComponent(Component): + def __init__(self, hxxfile , cpplib , cpp_path ): + # search a file within a directory tree + import fnmatch + def search_file(pattern, root): + matches = [] + for path, dirs, files in os.walk(os.path.abspath(root)): + for filename in fnmatch.filter(files, pattern): + matches.append(os.path.join(path, filename)) + return matches + + hxxfileful=search_file(hxxfile,cpp_path) + cpplibful=search_file(cpplib,cpp_path) + assert len(hxxfileful) > 0 ,'Error in HXX2SALOMEComponent : file ' + hxxfile + ' not found in ' + cpp_path + assert len(cpplibful) > 0 ,'Error in HXX2SALOMEComponent : file ' + cpplib + ' not found in ' + cpp_path + + self.hxxfile=hxxfile # to include it in servant implementation + + # grab name of c++ component + from hxx_awk import parse01,parse1,parse2,parse3 + cmd1="""awk '$1 == "class" && $0 !~ /;/ {print $2}' """ + hxxfileful[0] + """|awk -F: '{printf "%s",$1}' """ + f=os.popen(cmd1) + class_name=f.readlines()[0] + name=class_name + print "classname=",class_name + + if cpplib[:3]=="lib" and cpplib[-3:]==".so": + cpplibname=cpplib[3:-3] # get rid of lib and .so, to use within makefile.am + else: + cpplibname=class_name+"CXX" # the default name + + f.close() + + # create temporary awk files + (fd01,p01n)=mkstemp() + f01=os.fdopen(fd01,"w") + f01.write(parse01) + f01.close() + + (fd1,p1n)=mkstemp() + f1=os.fdopen(fd1,"w") + f1.write(parse1) + f1.close() + + (fd2,p2n)=mkstemp() + f2=os.fdopen(fd2,"w") + f2.write(parse2) + f2.close() + + (fd3,p3n)=mkstemp() + f3=os.fdopen(fd3,"w") + f3.write(parse3) + f3.close() + + # awk parsing of hxx files - result written in file parse_type_result + cmd2="cat " + hxxfileful[0] + " | awk -f " + p01n + """ | sed 's/virtual //g' | sed 's/MEDMEM_EXPORT//g' | sed 's/throw.*;/;/g' | awk -f """ + p1n + " | awk -f " + p2n + " | awk -v class_name=" + class_name + " -f " + p3n + os.system(cmd2) + os.remove(p01n) + os.remove(p1n) + os.remove(p2n) + os.remove(p3n) + + # Retrieve the information which was generated in the file parse_type_result. + # The structure of the file is : + # + # Function return_type function_name + # [arg1_type arg1_name] + # [arg2_type arg2_name] + # ... + # The service names are stored in list_of_services + # The information relative to a service (called service_name) is stored in the dictionnary service_definition[service_name] + from hxx_awk import cpp2idl_mapping + from hxx_awk import cpp2yacs_mapping + cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" + cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" + cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" + cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface" + list_of_services=[] + service_definition={} + result_parsing=open("parse_type_result","r") + for line in result_parsing.readlines(): + line=line[0:-1] # get rid of trailing \n + words = string.split(line,';') + + if len(words) >=3 and words[0] == "Function": # detect a new service + function_name=words[2] + if function_name != "getInputFieldTemplate": + list_of_services.append(function_name) + service_definition[function_name]={} + service_definition[function_name]["ret"]=words[1] # return type + service_definition[function_name]["inports"]=[] + service_definition[function_name]["outports"]=[] + service_definition[function_name]["ports"]=[] + service_definition[function_name]["impl"]=[] + service_definition[function_name]["thread_func_decl"]=[] + service_definition[function_name]["thread_str_decl"]=[] + + if len(words) == 2 and function_name != "getInputFieldTemplate": # an argument type and argument name of a previous service + typename=words[0] + argname=words[1] + service_definition[list_of_services[-1]]["ports"].append( (argname,typename) ) # store in c++ order the arg names + + # separate in from out parameters + inout=cpp2idl_mapping[typename][0:2] + assert inout=="in" or inout=="ou",'Error in table cpp2idl_mapping' + if inout == "in": + service_definition[list_of_services[-1]]["inports"].append( (argname,typename) ) + else: + service_definition[list_of_services[-1]]["outports"].append( (argname,typename) ) + + if service_definition.has_key('getInputFieldTemplate'): + del service_definition['getInputFieldTemplate'] + # + # generate implementation of c++ servant + # store it in service_definition[serv]["impl"] + # + from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types + cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MPIMEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MPIMEDCouplingFieldDoubleServant(_orb,_poa,this,_rtn_cpp); +\t_rtn_cpp->decrRef(); +\tSALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n""" + cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=cppCompo_->getInputFieldTemplate();\n\t_setInputField(%(arg)s,_%(arg)s);\n\t_initializeCoupling(%(arg)s);\n" + + from yacstypes import corbaTypes,corbaOutTypes + format_thread_signature="void * th_%s(void * st);" # this thread declaration will be included in servant's header + format_thread_struct="typedef struct {\n int ip;\n Engines::IORTab* tior;\n%(arg_decl)s} thread_%(serv_name)s_str;" # this thread declaration will be included in servant's header + format_thread_create=""" +// create threads to forward to other processes the service invocation + if(_numproc == 0) + { + th = new pthread_t[_nbproc]; + for(int ip=1;ip<_nbproc;ip++) + { + %(init_thread_str)s + pthread_create(&(th[ip]),NULL,th_%(serv_name)s,(void*)st); + } + } +""" + s_thread_join=""" +// waiting for all threads to complete + if(_numproc == 0) + { + for(int ip=1;ip<_nbproc;ip++) + { + pthread_join(th[ip],&ret_th); + est = (except_st*)ret_th; + if(est->exception) + { + ostringstream msg; + msg << "[" << ip << "] " << est->msg; + THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(),SALOME::INTERNAL_ERROR); + } + delete est; + } + delete[] th; + } +""" + format_thread_impl=""" +void *th_%(serv_name)s(void *s) +{ + ostringstream msg; + thread_%(serv_name)s_str *st = (thread_%(serv_name)s_str*)s; + except_st *est = new except_st; + est->exception = false; + + try + { + %(module)s_ORB::%(component_name)s_Gen_var compo = %(module)s_ORB::%(component_name)s_Gen::_narrow((*(st->tior))[st->ip]); + compo->%(serv_name)s(%(arg_thread_invocation)s); + } + catch(const SALOME::SALOME_Exception &ex) + { + est->exception = true; + est->msg = ex.details.text; + } + catch(const CORBA::Exception &ex) + { + est->exception = true; + msg << "CORBA::Exception: " << ex; + est->msg = msg.str(); + } + delete st; + return((void*)est); +} + +""" + + self.thread_impl="" # the implementation of the thread functions used to invoque services on slave processors + for serv in list_of_services: + if debug: + print "service : ",serv + print " inports -> ",service_definition[serv]["inports"] + print " outports -> ",service_definition[serv]["outports"] + print " return -> ",service_definition[serv]["ret"] + + # Part 0 : specific treatments for parallel components (call threads to forward the invocation to the service to all processes) + service_definition[serv]["thread_func_decl"]=format_thread_signature % serv + arg_declaration="" + arg_thread_invocation="" + init_thread_str="thread_%s_str *st = new thread_%s_str;" % (serv,serv) + init_thread_str+="\n st->ip = ip;" + init_thread_str+="\n st->tior = _tior;" + for (argname,argtype) in service_definition[serv]["inports"]: + arg_declaration+=" "+corbaTypes[cpp2yacs_mapping[argtype]]+" "+argname+";\n" + init_thread_str+="\n st->"+argname+" = "+argname+";" + for (argname,argtype) in service_definition[serv]["outports"]: + arg_declaration+=" "+corbaOutTypes[cpp2yacs_mapping[argtype]]+" "+argname+";\n" + init_thread_str+="\n st->"+argname+" = "+argname+";" + for (argname,argtype) in service_definition[serv]["ports"]: + arg_thread_invocation+="st->"+argname+", " + if len(arg_thread_invocation)>0: + arg_thread_invocation=arg_thread_invocation[0:-2] # get rid of trailing comma + service_definition[serv]["thread_str_decl"]=format_thread_struct % { "serv_name" : serv, "arg_decl" : arg_declaration } + s_thread_call=format_thread_create % { "serv_name" : serv , "init_thread_str" : init_thread_str} + # within format_thread_impl the treatment of %(module) is postponed in makecxx() because we don't know here the module name + self.thread_impl+=format_thread_impl % {"serv_name" : serv , "arg_thread_invocation" : arg_thread_invocation , "component_name" : name, "module" : "%(module)s" } + + # Part 1 : Argument pre-processing + s_argument_processing="//\tArguments processing\n" + for (argname,argtype) in service_definition[serv]["inports"] + service_definition[serv]["outports"]: + format=cpp_impl_a[argtype] + s_argument_processing += format % {"arg" : argname } + if s_argument_processing=="//\tArguments processing\n": # if there was no args + s_argument_processing="" + + # if an argument called name is of type const char*, this argument is transmitted to getInputFieldTemplate() + # => we insert "name" between the bracket of getInputFieldTemplate() + indice_getInputFieldTemplate=s_argument_processing.find ("cppCompo_->getInputFieldTemplate();") + if s_argument_processing.find ("const std::string _name") != -1 and indice_getInputFieldTemplate != -1: + ind_insertion=indice_getInputFieldTemplate+33 + s_argument_processing=s_argument_processing[:ind_insertion]+"name"+s_argument_processing[ind_insertion:-1] + + # Part 2 : Call to the underlying c++ function + s_call_cpp_function="//\tCall cpp component\n\t" + rtn_type=service_definition[serv]["ret"] + if rtn_type == "void" : # if return type is void, the call syntax is different + s_call_cpp_function += "cppCompo_->%s(" % serv + else: + s_call_cpp_function += "%s _rtn_cpp = cppCompo_->%s(" % (rtn_type ,serv ) + + for (argname,argtype) in service_definition[serv]["ports"]: + # special treatment for some arguments + post="" + pre="" + if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 : + post=".get()" # for auto_ptr argument, retrieve the raw pointer behind + if argtype == "const MEDMEM::MESH&" or argtype == "const MEDMEM::SUPPORT&" : + pre="*" # we cannot create MESHClient on the stack (private constructor), so we create it on the heap and dereference it + post+="," # separator between arguments + s_call_cpp_function += " %s_%s%s" % ( pre,argname,post) + if s_call_cpp_function[-1]==',': + s_call_cpp_function=s_call_cpp_function[0:-1] # get rid of trailing comma + s_call_cpp_function=s_call_cpp_function+');\n' + + # Part 3.a : Out Argument Post-processing + s_argument_postprocessing="//\tPost-processing & return\n" + for (argname,argtype) in service_definition[serv]["outports"]: + format=cpp_impl_c[argtype] + s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # the treatment of %(module) is postponed in makecxx() + # because we don't know here the module name + # Part 3.b : In Argument Post-processing + for (argname,argtype) in service_definition[serv]["inports"]: + if cpp_impl_c.has_key(argtype): # not all in types require a treatment + format=cpp_impl_c[argtype] + s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # id : treatment of %(module) is postponed in makecxx + + # Part 3.c : return processing + s_rtn_processing=cpp_impl_b[rtn_type] + if rtn_type != "void": + s_rtn_processing += "\treturn _rtn_ior;" + + service_definition[serv]["impl"] = s_thread_call + s_argument_processing + s_call_cpp_function + s_thread_join + s_argument_postprocessing + s_rtn_processing + if debug: + print "implementation :\n",service_definition[serv]["impl"] + + # + # Create a list of Service objects (called services), and give it to Component constructor + # + services=[] + self.use_medmem=False + self.use_medcoupling=False + self.thread_func_decl=[] + self.thread_str_decl=[] + for serv in list_of_services: + # for inports and outports, Service class expects a list of tuples, each tuple containing the name and the yacs type of the port + # thus we need to convert c++ types to yacs types (we use for that the cpp2yacs_mapping table + inports=[] + for i in range( len(service_definition[serv]["inports"]) ): + inports.append( [service_definition[serv]["inports"][i][0], cpp2yacs_mapping[service_definition[serv]["inports"][i][1]] ] ) + outports=[] + for i in range( len(service_definition[serv]["outports"]) ): + outports.append( [service_definition[serv]["outports"][i][0], cpp2yacs_mapping[service_definition[serv]["outports"][i][1]] ] ) + + Return="void" + if service_definition[serv]["ret"] != "void": + Return=cpp2yacs_mapping[service_definition[serv]["ret"]] + + # find out if component uses medmem types and/or medcoupling types + for (argname,argtype) in inports + outports + [("return",Return)]: + if moduleTypes[argtype]=="MED": + if argtype.count("Coupling")>0: + self.use_medcoupling=True + else: + self.use_medmem=True + break + + code=service_definition[serv]["impl"] + if debug: + print "service : ",serv + print " inports -> ",service_definition[serv]["inports"] + print " converted inports -> ",inports + print " outports -> ",service_definition[serv]["outports"] + print " converted outports -> ",outports + print " Return -> ",service_definition[serv]["ret"] + print " converted Return -> ",Return + + services.append(Service(serv, + inport=inports, + outport=outports, + ret=Return, + defs="", + body=code, + ) ) + self.thread_func_decl.append(service_definition[serv]["thread_func_decl"]) + self.thread_str_decl.append(service_definition[serv]["thread_str_decl"]) + Includes="-I${"+name+"CPP_ROOT_DIR}/include" + Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+cpplibname + Compodefs="" + Inheritedclass="" + self.inheritedconstructor="" + Compodefs=""" +#include CORBA_SERVER_HEADER(MEDCouplingCorbaServantTest) +#include "MPIMEDCouplingFieldDoubleServant.hxx" +""" + + Component.__init__(self, name, services, impl="CPP", libs=Libs, + rlibs="", includes=Includes, kind="lib", + sources=None,inheritedclass=Inheritedclass, + compodefs=Compodefs) + + def makeCompo(self, gen): + """generate files for C++ component + + return a dict where key is the file name and value is the content of the file + """ + cxxfile = "%s_i.cxx" % self.name + hxxfile = "%s_i.hxx" % self.name + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + cxxfile:self.makecxx(gen), + hxxfile:self.makehxx(gen) + } + + def getMakefileItems(self,gen): + makefileItems={"header":""" +include $(top_srcdir)/adm_local/make_common_starter.am + +"""} + makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] + makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] + makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, + component=self.name, + libs=self.libs, + includes=self.includes) + return makefileItems + + def makehxx(self, gen): + """return a string that is the content of .hxx file + """ + services = [] + for serv in self.services: + service = " %s %s(" % (corba_rtn_type(serv.ret,gen.module.name),serv.name) + service = service+gen.makeArgs(serv)+") throw (SALOME::SALOME_Exception);" + services.append(service) + servicesdef = "\n".join(services) + + inheritedclass=self.inheritedclass + thread_func_decl="\n".join(self.thread_func_decl) + thread_str_decl="\n".join(self.thread_str_decl) + if debug: + print "thread_func_decl : " + print thread_func_decl + print "thread_str_decl : " + print thread_str_decl + + if self.inheritedclass: + inheritedclass= " public virtual " + self.inheritedclass + "," + + return hxxCompo.substitute(component=self.name, module=gen.module.name, thread_func_decl=thread_func_decl, + thread_str_decl=thread_str_decl, servicesdef=servicesdef, inheritedclass=inheritedclass, + compodefs=self.compodefs) + + def makecxx(self, gen, exe=0): + """return a string that is the content of .cxx file + """ + services = [] + inits = [] + defs = [] + for serv in self.services: + defs.append(serv.defs) + service = cxxService.substitute(component=self.name, service=serv.name,ret=corba_rtn_type(serv.ret,gen.module.name), + parameters=gen.makeArgs(serv), + body=serv.body % {"module":gen.module.name+"_ORB"} ) + services.append(service) + return cxxCompo.substitute(component=self.name, cxx_include_file=self.hxxfile, + inheritedconstructor=self.inheritedconstructor, + servicesdef="\n".join(defs), + servicesimpl="\n".join(services), + thread_impl=self.thread_impl % {"module":gen.module.name} ) + diff --git a/module_generator/mod_tmpl.py b/module_generator/mod_tmpl.py index 1a5746c..9291230 100644 --- a/module_generator/mod_tmpl.py +++ b/module_generator/mod_tmpl.py @@ -1,3 +1,22 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + try: from string import Template except: @@ -6,6 +25,7 @@ except: application=""" +${resources} ${modules} @@ -26,13 +46,14 @@ echo "Running libtoolize..." ; libtoolize --copy --force || exit 1 echo "Running automake..." ; automake --add-missing --copy || exit 1 """ -mainMakefile="""include $(top_srcdir)/adm_local/make_common_starter.am -SUBDIRS = idl resources src +mainMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am +SUBDIRS = idl resources src ${docsubdir} ACLOCAL_AMFLAGS = -I adm_local """ +mainMakefile=Template(mainMakefile) configure=""" -AC_INIT(salome,4.1) +AC_INIT(${module}, 1.0) AC_CONFIG_AUX_DIR(adm_local) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(${module}_config.h) @@ -43,18 +64,24 @@ if test "x$$Kernel_ok" = "xno"; then AC_MSG_ERROR([You must define a correct KERNEL_ROOT_DIR or use the --with-kernel= configure option !]) fi +dnl Check Salome modules Install +${modules} + AC_PROG_LIBTOOL AC_PROG_CC AC_PROG_CXX CHECK_F77 -CHECK_BOOST CHECK_OMNIORB +CHECK_PACO +CHECK_MPI MODULE_NAME=${module} AC_SUBST(MODULE_NAME) AC_CHECK_ASTER +${other_check} + echo echo echo @@ -64,14 +91,15 @@ echo "------------------------------------------------------------------------" echo echo "Configuration Options Summary:" echo -echo "Mandatory products:" echo " Threads ................ : $$threads_ok" echo " OmniOrb (CORBA) ........ : $$omniORB_ok" echo " OmniOrbpy (CORBA) ...... : $$omniORBpy_ok" echo " Python ................. : $$python_ok" -echo " Boost ................. : $$boost_ok" echo " SALOME KERNEL .......... : $$Kernel_ok" +echo " PaCO++ ................. : $$PaCO_ok" +echo " MPI .................... : $$mpi_ok" echo " Code Aster ............. : $$Aster_ok" +${other_summary} echo echo "------------------------------------------------------------------------" echo @@ -89,8 +117,11 @@ if test "x$$omniORBpy_ok" = "xno"; then AC_MSG_ERROR([OmniOrbpy is required],1) fi if test "x$$Kernel_ok" = "xno"; then - AC_MSG_ERROR([Expat is required],1) + AC_MSG_ERROR([SALOME KERNEL is required],1) fi +${other_require} + +${paco_configure} AC_CONFIG_FILES([ Makefile @@ -103,36 +134,47 @@ AC_OUTPUT """ configure=Template(configure) +paco_configure="""\ +if test "x$$PaCO_ok" = "xno"; then + AC_MSG_ERROR([PaCO++ is required],1) +fi +""" + makecommon=""" # Standard directory for installation -salomeincludedir = $(includedir)/salome -libdir = $(prefix)/lib/salome -bindir = $(prefix)/bin/salome -salomescriptdir = $(bindir) -salomepythondir = $(prefix)/lib/python$(PYTHON_VERSION)/site-packages/salome +salomeincludedir = $$(includedir)/salome +libdir = $$(prefix)/lib/salome +bindir = $$(prefix)/bin/salome +salomescriptdir = $$(bindir) +salomepythondir = $$(prefix)/lib/python$$(PYTHON_VERSION)/site-packages/salome # Directory for installing idl files -salomeidldir = $(prefix)/idl/salome +salomeidldir = $$(prefix)/idl/salome # Directory for installing resource files -salomeresdir = $(prefix)/share/salome/resources/${MODULE_NAME} +salomeresdir = $$(prefix)/share/salome/resources/$${MODULE_NAME} # Directories for installing admin files -admlocaldir = $(prefix)/adm_local -admlocalunixdir = $(admlocaldir)/unix -admlocalm4dir = $(admlocaldir)/unix/config_files +admlocaldir = $$(prefix)/adm_local +admlocalunixdir = $$(admlocaldir)/unix +admlocalm4dir = $$(admlocaldir)/unix/config_files # Shared modules installation directory -sharedpkgpythondir =$(pkgpythondir)/shared_modules +sharedpkgpythondir =$$(pkgpythondir)/shared_modules # Documentation directory -docdir = $(datadir)/doc/salome +salomedocdir = $$(prefix)/share/doc/salome/gui/$${MODULE_NAME} + +IDL_INCLUDES = -I$$(KERNEL_ROOT_DIR)/idl/salome +KERNEL_LIBS= -L$$(KERNEL_ROOT_DIR)/lib/salome -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC +KERNEL_INCLUDES= -I$$(KERNEL_ROOT_DIR)/include/salome $$(OMNIORB_INCLUDES) ${other_includes} -IDL_INCLUDES = -I$(KERNEL_ROOT_DIR)/idl/salome -KERNEL_LIBS= -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC -KERNEL_INCLUDES= -I$(KERNEL_ROOT_DIR)/include/salome $(OMNIORB_INCLUDES) $(BOOST_CPPFLAGS) +SALOME_LIBS= $${KERNEL_LIBS} +SALOME_IDL_LIBS= -L$$(KERNEL_ROOT_DIR)/lib/salome -lSalomeIDLKernel +SALOME_INCLUDES= $${KERNEL_INCLUDES} """ +makecommon=Template(makecommon) resMakefile=""" include $$(top_srcdir)/adm_local/make_common_starter.am @@ -141,3 +183,42 @@ salomeres_DATA = $${DATA_INST} EXTRA_DIST = $${DATA_INST} """ resMakefile=Template(resMakefile) + +check_sphinx=""" +AC_DEFUN([CHECK_SPHINX],[ + +AC_CHECKING(for sphinx doc generator) + +sphinx_ok=yes +dnl where is sphinx ? +AC_PATH_PROG(SPHINX,sphinx-build) +if test "x$SPHINX" = "x" +then + AC_MSG_WARN(sphinx not found) + sphinx_ok=no +fi + +dnl Can I load ths sphinx module ? +dnl This code comes from the ax_python_module macro. +if test -z $PYTHON; +then + PYTHON="python" +fi +PYTHON_NAME=`basename $PYTHON` +AC_MSG_CHECKING($PYTHON_NAME module: sphinx) + $PYTHON -c "import sphinx" 2>/dev/null + if test $? -eq 0; + then + AC_MSG_RESULT(yes) + eval AS_TR_CPP(HAVE_PYMOD_sphinx)=yes + else + AC_MSG_RESULT(no) + eval AS_TR_CPP(HAVE_PYMOD_sphinx)=no + sphinx_ok=no + fi + +AM_CONDITIONAL(SPHINX_IS_OK, [test x"$sphinx_ok" = xyes]) + +]) +""" + diff --git a/module_generator/paco_tmpl.py b/module_generator/paco_tmpl.py new file mode 100644 index 0000000..85acbda --- /dev/null +++ b/module_generator/paco_tmpl.py @@ -0,0 +1,421 @@ +#!/usr/bin/env python +# -*- coding: utf-8 *- +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Author : Andre RIBES (EDF R&D) + +try: + from string import Template +except: + from compat import Template,set + +compoMakefile=""" +include $$(top_srcdir)/adm_local/make_common_starter.am + +BUILT_SOURCES = SALOME_Exception.hxx SALOME_GenericObj.hxx SALOMEDS.hxx SALOME_PyNode.hxx SALOME_Comm.hxx SALOME_Parametric.hxx + +%.hxx : @KERNEL_ROOT_DIR@/idl/salome/%.idl +\t$$(OMNIORB_IDL) -bcxx $$(IDLCXXFLAGS) $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) -I@KERNEL_ROOT_DIR@/idl/salome -Wbh=.hxx -Wbs=.cxx $$< + +AM_CFLAGS=$$(KERNEL_INCLUDES) $$(PACO_INCLUDES) -fexceptions + +lib_LTLIBRARIES = lib${component}Engine.la +lib${component}Engine_la_SOURCES = ${component}.cxx ${sources} +nodist_lib${component}Engine_la_SOURCES = +lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) $$(PACO_INCLUDES) $$(MPI_INCLUDES) ${includes} +lib${component}Engine_la_LIBADD = -L$$(top_builddir)/idl -lSalomeIDL${module} @KERNEL_ROOT_DIR@/lib/salome/libSalomeParallelDSCContainer.la @PACOPATH@/lib/libPaCO_direct_comScheduling.la $$(FLIBS) ${libs} $$(PACO_LIBS) $$(SALOME_LIBS) +lib${component}Engine_la_LDFLAGS = ${rlibs} +salomeinclude_HEADERS = ${component}.hxx +""" +compoMakefile=Template(compoMakefile) + +paco_sources = """\ +$$(top_builddir)/idl/${module}PaCO_${module}_ORB_${component}_client.cxx $$(top_builddir)/idl/${module}PaCO_${module}_ORB_${component}_server.cxx $$(top_builddir)/idl/${module}PaCO.cxx $$(top_builddir)/idl/${module}.cxx +""" +paco_sources = Template(paco_sources) + +hxxCompo=""" +#ifndef _${component}_HXX_ +#define _${component}_HXX_ + +#include "${module}PaCO_${module}_ORB_${component}_server.hxx" +#include "ParallelDSC_i.hxx" +#include "Param_Double_Port_uses_i.hxx" +#include "Param_Double_Port_provides_i.hxx" + +#include "PortProperties_i.hxx" +#include +#include +#include +#include + +class ${component}_i: + public virtual ${module}_ORB::${component}_serv, + public virtual Engines_ParallelDSC_i +{ + public: + ${component}_i(CORBA::ORB_ptr orb, + char * ior, + int rank, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + virtual ~${component}_i(); + + void provides_port_changed(const char* provides_port_name, + int connection_nbr, + const Engines::DSC::Message message) {} + + void uses_port_changed(const char* uses_port_name, + Engines::DSC::uses_port * new_uses_port, + const Engines::DSC::Message message) {delete new_uses_port;} + + CORBA::Boolean init_service(const char * service_name); + +${servicesdef} + private: + PortProperties_i * _fake_properties; +${services_init_ok} +${parallelstreamports} +}; + +extern "C" +{ + PortableServer::ObjectId * ${component}Engine_factory(CORBA::ORB_ptr orb, + char * ior, + int rank, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + PortableServer::ObjectId * ${component}EngineProxy_factory(CORBA::ORB_ptr orb, + paco_fabrique_thread * fab_thread, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + RegistryConnexion **, + const char *instanceName, + int node_number); + void ${component}_isAPACO_Component() {}; +} +#endif + +""" +hxxCompo=Template(hxxCompo) + +hxxinit_ok = """\ + bool _${service_name}_init_ok;""" +hxxinit_ok = Template(hxxinit_ok) + +hxxparallel_outstream = """\ + ${type}_uses_i * _${name}_port; + bool _${name}_port_start_ok;""" +hxxparallel_outstream = Template(hxxparallel_outstream) + +hxxparallel_instream = """\ + ${type}_provides_i * _${name}_port;""" +hxxparallel_instream = Template(hxxparallel_instream) + +cxxCompo=""" +#include "${component}.hxx" +#include + +//DEFS +${servicesdef} +//ENDDEF + +//! Constructor for component "${component}" instance +/*! + * + */ +${component}_i::${component}_i(CORBA::ORB_ptr orb, + char * ior, + int rank, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + ${module}_ORB::${component}_serv(orb, ior, rank), + ${module}_ORB::${component}_base_serv(orb, ior, rank), + Engines_ParallelDSC_i(orb, ior, rank, poa, contId, instanceName, interfaceName), + Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName), + Engines::Parallel_DSC_serv(orb, ior, rank), + InterfaceParallel_impl(orb,ior, rank), + Engines::Superv_Component_serv(orb, ior, rank), + Engines::DSC_serv(orb, ior, rank), + Engines::EngineComponent_serv(orb,ior, rank), + Engines::Parallel_Component_serv(orb,ior, rank), + Engines::Parallel_DSC_base_serv(orb, ior, rank), + Engines::Superv_Component_base_serv(orb, ior, rank), + Engines::DSC_base_serv(orb, ior, rank), + Engines::EngineComponent_base_serv(orb,ior, rank), + Engines::Parallel_Component_base_serv(orb,ior, rank) + +{ + std::cerr << "creating paralle component" << std::endl; + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +${cons_services} +} + +//! Destructor for component "${component}" instance +${component}_i::~${component}_i() +{ +${des_services} +} + +//! Register datastream ports for a component service given its name +/*! + * \param service_name : service name + * \\return true if port registering succeeded, false if not + */ +CORBA::Boolean +${component}_i::init_service(const char * service_name) { + CORBA::Boolean rtn = false; + string s_name(service_name); +${initservice} + return rtn; +} + +${servicesimpl} +""" +cxxCompo=Template(cxxCompo) + +cxx_cons_service = """\ + _${service_name}_init_ok = false; +""" +cxx_cons_service = Template(cxx_cons_service) + +cxx_cons_parallel_outstream = """\ + _${name}_port = NULL; + _${name}_port_start_ok = false; +""" +cxx_cons_parallel_outstream = Template(cxx_cons_parallel_outstream) + +cxx_cons_parallel_instream = """\ + _${name}_port = NULL; +""" +cxx_cons_parallel_instream = Template(cxx_cons_parallel_instream) + +cxx_des_parallel_stream = """\ + if (_${name}_port) + delete _${name}_port; +""" +cxx_des_parallel_stream = Template(cxx_des_parallel_stream) + +initService="""\ + if (s_name == "${service_name}") + { + if (!_${service_name}_init_ok) + { +${init_parallel_datastream_ports} + _${service_name}_init_ok = true; + } + rtn = true; + } +""" +initService=Template(initService) + +hxxparallel_outstream_init = """\ + _${name}_port = new ${type}_uses_i(this, \"${name}\", _orb); + _${name}_port->add_port_to_component(); +""" +hxxparallel_outstream_init = Template(hxxparallel_outstream_init) + +hxxparallel_instream_init = """\ + _${name}_port = ${type}_provides_i::init_port(this, \"${name}\", _orb); + ${type}_provides_i::wait_init_port(this, \"${name}\", _orb); +""" +hxxparallel_instream_init = Template(hxxparallel_instream_init) + +cxxService=""" +void ${component}_i::${service}(${parameters}) +{ + std::cerr << "Begin of ${component}_i::${service} of node " << _myRank << std::endl; + if (_myRank == 0) + beginService("${component}_i::${service}"); +${connect_parallel_streamport} + try + { +//BODY +${body} +//ENDBODY + } + catch ( const SALOME_Exception & ex) + { + SALOME::ExceptionStruct es; + es.text=CORBA::string_dup(ex.what()); + es.type=SALOME::INTERNAL_ERROR; + throw SALOME::SALOME_Exception(es); + } + catch ( const SALOME::SALOME_Exception & ex) + { + throw; + } + catch ( const std::exception& ex) + { + SALOME::ExceptionStruct es; + es.text=CORBA::string_dup(ex.what()); + es.type=SALOME::INTERNAL_ERROR; + throw SALOME::SALOME_Exception(es); + } + catch (...) + { + std::cerr << "unknown exception" << std::endl; + SALOME::ExceptionStruct es; + es.text=CORBA::string_dup(" unknown exception"); + es.type=SALOME::INTERNAL_ERROR; + throw SALOME::SALOME_Exception(es); + } + if (_myRank == 0) + endService("${component}_i::${service}"); + std::cerr << "End of ${component}_i::${service} of node " << _myRank << std::endl; +} + +""" +cxxService=Template(cxxService) + +cxxService_connect = """\ + if (!_${name}_port_start_ok) + { + _${name}_port->start_port(); + _${name}_port_start_ok = true; + } +""" +cxxService_connect = Template(cxxService_connect) + +cxxFactoryDummy = """ +extern "C" +{ + PortableServer::ObjectId * ${component}Engine_factory(CORBA::ORB_ptr orb, char * ior, int rank, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + std::cerr << "Begin of ${component}Engine_factory()" << std::endl; + + paco_fabrique_manager * pfm = paco_getFabriqueManager(); + pfm->register_com("${component}_node_dummy", new paco_dummy_fabrique()); + pfm->register_thread("${component}_node_omni", new paco_omni_fabrique()); + ${component}_i * ${component}_node = new ${component}_i(CORBA::ORB::_duplicate(orb), ior, rank, poa, contId, instanceName, interfaceName); + ${component}_node->setLibCom("${component}_node_dummy", ${component}_node); + ${component}_node->setLibThread("${component}_node_omni"); + + std::cerr << "End of ${component}Engine_factory()" << std::endl; + return ${component}_node->getId(); + } + + PortableServer::ObjectId * ${component}EngineProxy_factory(CORBA::ORB_ptr orb, + paco_fabrique_thread * fab_thread, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + RegistryConnexion ** connexion, + const char *instanceName, + int node_number) + { + cerr << "Begin of ${component}EngineProxy_factory()" << endl; + + paco_fabrique_manager* pfm = paco_getFabriqueManager(); + pfm->register_com("proxy_dummy", new paco_dummy_fabrique()); + pfm->register_thread("proxy_thread", new paco_omni_fabrique()); + ${module}_ORB::${component}_proxy_impl * proxy = new ${module}_ORB::${component}_proxy_impl(CORBA::ORB::_duplicate(orb), + fab_thread); + PortableServer::ObjectId * id = poa->activate_object(proxy); + proxy->_remove_ref(); + // Initialisation du proxy + proxy->setLibCom("proxy_dummy", proxy); + proxy->setLibThread("proxy_thread"); + PaCO::PacoTopology_t serveur_topo; + serveur_topo.total = node_number; + proxy->setTopology(serveur_topo); + + // Ajout dans le registry ... + CORBA::Object_var o = poa->id_to_reference(*contId); // container ior... + const CORBA::String_var the_ior = orb->object_to_string(o); + *connexion = new RegistryConnexion(0, 0, the_ior, "theSession", instanceName); + + cerr << "End of ${component}EngineProxy_factory()" << endl; + return id; + } +} +""" +cxxFactoryDummy = Template(cxxFactoryDummy) + +cxxFactoryMpi = """ +extern "C" +{ + PortableServer::ObjectId * ${component}Engine_factory(CORBA::ORB_ptr orb, char * ior, int rank, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + std::cerr << "Begin of ${component}Engine_factory()" << std::endl; + + paco_fabrique_manager * pfm = paco_getFabriqueManager(); + pfm->register_com("${component}_node_mpi", new paco_mpi_fabrique()); + pfm->register_thread("${component}_node_omni", new paco_omni_fabrique()); + ${component}_i * ${component}_node = new ${component}_i(CORBA::ORB::_duplicate(orb), ior, rank, poa, contId, instanceName, interfaceName); + MPI_Comm parallel_object_group = MPI_COMM_WORLD; + ${component}_node->setLibCom("${component}_node_mpi", ¶llel_object_group); + ${component}_node->setLibThread("${component}_node_omni"); + + std::cerr << "End of ${component}Engine_factory()" << std::endl; + return ${component}_node->getId(); + } + + PortableServer::ObjectId * ${component}EngineProxy_factory(CORBA::ORB_ptr orb, + paco_fabrique_thread * fab_thread, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + RegistryConnexion ** connexion, + const char *instanceName, + int node_number) + { + cerr << "Begin of ${component}EngineProxy_factory()" << endl; + + paco_fabrique_manager* pfm = paco_getFabriqueManager(); + pfm->register_com("proxy_dummy", new paco_dummy_fabrique()); + pfm->register_thread("proxy_thread", new paco_omni_fabrique()); + ${module}_ORB::${component}_proxy_impl * proxy = new ${module}_ORB::${component}_proxy_impl(CORBA::ORB::_duplicate(orb), + fab_thread); + PortableServer::ObjectId * id = poa->activate_object(proxy); + proxy->_remove_ref(); + // Initialisation du proxy + proxy->setLibCom("proxy_dummy", proxy); + proxy->setLibThread("proxy_thread"); + PaCO::PacoTopology_t serveur_topo; + serveur_topo.total = node_number; + proxy->setTopology(serveur_topo); + + // Ajout dans le registry ... + CORBA::Object_var o = poa->id_to_reference(*contId); // container ior... + const CORBA::String_var the_ior = orb->object_to_string(o); + *connexion = new RegistryConnexion(0, 0, the_ior, "theSession", instanceName); + + cerr << "End of ${component}EngineProxy_factory()" << endl; + return id; + } +} +""" +cxxFactoryMpi = Template(cxxFactoryMpi) diff --git a/module_generator/pacocompo.py b/module_generator/pacocompo.py new file mode 100644 index 0000000..a767a66 --- /dev/null +++ b/module_generator/pacocompo.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python +# -*- coding: utf-8 *- +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# Author : Andre RIBES (EDF R&D) + +""" + Module that defines PACOComponent for SALOME PaCO++ components implemented in C++ +""" +import os +from gener import Component, Invalid +from paco_tmpl import compoMakefile, hxxCompo, cxxService +from paco_tmpl import initService, cxxCompo, paco_sources +from paco_tmpl import cxxFactoryDummy, cxxFactoryMpi, cxx_des_parallel_stream +from paco_tmpl import hxxparallel_instream, hxxparallel_outstream, hxxinit_ok +from paco_tmpl import hxxparallel_instream_init, hxxparallel_outstream_init, cxxService_connect +from paco_tmpl import cxx_cons_service, cxx_cons_parallel_outstream, cxx_cons_parallel_instream + +class PACOComponent(Component): + + def __init__(self, name, parallel_lib, services=None, libs="", rlibs="", includes="", + kind="lib", exe_path=None, sources=None): + self.exe_path = exe_path + self.parallel_lib = parallel_lib + Component.__init__(self, name, services, impl="PACO", libs=libs, + rlibs=rlibs, includes=includes, kind=kind, + sources=sources) + def validate(self): + """ validate component definition parameters""" + Component.validate(self) + kinds = ("lib") + if self.kind not in kinds: + raise Invalid("kind must be one of %s for component %s" % (kinds,self.name)) + parallel_libs = ("dummy", "mpi") + if self.parallel_lib not in parallel_libs: + raise Invalid("parallel_lib must be one of %s" % parallel_libs) + + def makeCompo(self, gen): + """generate files for PaCO++ component + + return a dict where key is the file name and value is the content of the file + """ + cxxfile = "%s.cxx" % self.name + hxxfile = "%s.hxx" % self.name + if self.kind == "lib": + sources = " ".join(map(os.path.basename, self.sources)) + sources += " " + sources += paco_sources.substitute(module=gen.module.name, + component=self.name) + return {"Makefile.am":compoMakefile.substitute(module=gen.module.name, + component=self.name, + libs=self.libs, + rlibs=self.rlibs, + sources=sources, + includes=self.includes), + cxxfile:self.makecxx(gen), + hxxfile:self.makehxx(gen)} + + def makehxx(self, gen): + """return a string that is the content of .hxx file + """ + services = [] + parallel_instream = "" + parallel_outstream = "" + services_init_ok = "" + parallelstreamports = "" + for serv in self.services: + service = " void %s(" % serv.name + service = service+gen.makeArgs(serv)+");" + services.append(service) + services_init_ok += hxxinit_ok.substitute(service_name=serv.name) + + # Ajout des ports parallel DataStream + for name, type in serv.parallel_instream: + parallel_instream += hxxparallel_instream.substitute(name=name, + type=type) + for name, type in serv.parallel_outstream: + parallel_outstream += hxxparallel_outstream.substitute(name=name, + type=type) + servicesdef = "\n".join(services) + parallelstreamports += parallel_instream + parallelstreamports += parallel_outstream + return hxxCompo.substitute(component=self.name, + module=gen.module.name, + servicesdef=servicesdef, + services_init_ok=services_init_ok, + parallelstreamports=parallelstreamports, + parallel_lib=self.parallel_lib) + + def makecxx(self, gen): + """return a string that is the content of .cxx file + """ + services = [] + inits = [] + defs = [] + cons_services = "" + des_services = "" + for serv in self.services: + defs.append(serv.defs) + + # Constructeur + cons_services += cxx_cons_service.substitute(service_name=serv.name) + for name, type in serv.parallel_instream: + cons_services += cxx_cons_parallel_instream.substitute(name=name) + for name, type in serv.parallel_outstream: + cons_services += cxx_cons_parallel_outstream.substitute(name=name) + + # Destructeur + # On détruit uniquement les ports uses + # Les ports provides sont détruit lors de la destruction du poa + for name, type in serv.parallel_outstream: + des_services += cxx_des_parallel_stream.substitute(name=name) + + # init_service + init_parallel_datastream_ports="" + for name, type in serv.parallel_instream: + init_parallel_datastream_ports += hxxparallel_instream_init.substitute(name=name, + type=type) + for name, type in serv.parallel_outstream: + init_parallel_datastream_ports += hxxparallel_outstream_init.substitute(name=name, + type=type) + init = initService.substitute(service_name=serv.name, + init_parallel_datastream_ports=init_parallel_datastream_ports) + inits.append(init) + + # Code du service + connect_parallel_streamport = "" + for name, type in serv.parallel_outstream: + connect_parallel_streamport += cxxService_connect.substitute(name=name) + + service = cxxService.substitute(component=self.name, service=serv.name, + parameters=gen.makeArgs(serv), + body=serv.body, + connect_parallel_streamport=connect_parallel_streamport) + services.append(service) + + cxxfile = cxxCompo.substitute(component=self.name, module=gen.module.name, + servicesdef="\n".join(defs), + servicesimpl="\n".join(services), + initservice='\n'.join(inits), + cons_services=cons_services, + des_services=des_services) + + if self.parallel_lib == "dummy": + cxxfile += cxxFactoryDummy.substitute(component=self.name, module=gen.module.name) + elif self.parallel_lib == "mpi": + cxxfile += cxxFactoryMpi.substitute(component=self.name, module=gen.module.name) + + return cxxfile + diff --git a/module_generator/pycompo.py b/module_generator/pycompo.py index 69ac03f..b6e6b94 100644 --- a/module_generator/pycompo.py +++ b/module_generator/pycompo.py @@ -1,40 +1,108 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + """ Module that defines PYComponent for SALOME components implemented in Python """ +import os from gener import Component, Invalid from pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo -from pyth_tmpl import pycompoEXEMakefile, pycompoMakefile +import textwrap +from string import split,rstrip,join + +def indent(text, prefix=' '): + """Indent text by prepending a given prefix to each line.""" + if not text: return '' + lines = split(text, '\n') + lines = map(lambda line, prefix=prefix: prefix + line, lines) + if lines: lines[-1] = rstrip(lines[-1]) + return join(lines, '\n') class PYComponent(Component): - def __init__(self, name, services=None, python_path=None, kind="lib", - sources=None): + """ + A :class:`PYComponent` instance represents a Python SALOME component with services given as a list of :class:`Service` + instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (python executable). The default is to build the component as a python module. + :param sources: gives all the external Python source files to add in the component directory (list of paths). + :param python_path: If it is given (as a list of paths), all the paths are added to the python path (sys.path). + :param compodefs: can be used to add extra definition code in the component for example when using a base class + to define the component class by deriving it (see *inheritedclass* parameter) + :param inheritedclass: can be used to define a base class for the component. The base class can be defined in external + source or with the *compodefs* parameter. The value of the *inheritedclass* parameter is the name of the base class. + :param idls: can be used to add extra idl CORBA interfaces. This parameter must gives a list of idl file names that are + added into the generated module (idl directory) and compiled with the generated idl of the module. + :param interfacedefs: can be used to add idl definitions (or includes of idl files) into the generated idl of the module. + :param inheritedinterface: can be used to make the component inherit an extra idl interface that has been included through + the *idls* and *interfacedefs* parameters. See the pygui1 example for how to use these last parameters. + + For example, the following call defines a Python component named "mycompo" with one service s1 (it must have been defined before):: + + >>> c1 = module_generator.PYComponent('mycompo', services=[s1,], + python_path="apath") + + """ + def __init__(self, name, services=None, kind="lib", sources=None, python_path=None, + compodefs="", inheritedclass="", idls=None, interfacedefs="", inheritedinterface=""): + """initialise component attributes""" self.python_path = python_path or [] - Component.__init__(self, name, services, impl="PY", kind=kind, - sources=sources) + Component.__init__(self, name, services, impl="PY", kind=kind, sources=sources, + inheritedclass=inheritedclass, compodefs=compodefs, + idls=idls,interfacedefs=interfacedefs,inheritedinterface=inheritedinterface) def validate(self): + """validate component attributes""" Component.validate(self) kinds = ("lib","exe") if self.kind not in kinds: - raise Invalid("kind must be one of %s" % kinds) + raise Invalid("kind must be one of %s for component %s" % (kinds,self.name)) def makeCompo(self, gen): + """generate component sources as a dictionary containing + file names (key) and file content (values) + """ pyfile = "%s.py" % self.name - sources = " ".join(self.sources) + sources = " ".join(map(os.path.basename,self.sources)) if self.kind == "lib": - return {"Makefile.am":pycompoMakefile.substitute(module=gen.module.name, - component=self.name, - sources=sources), + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), pyfile:self.makepy(gen) } if self.kind == "exe": - return {"Makefile.am":pycompoEXEMakefile.substitute(module=gen.module.name, - component=self.name, - sources=sources), + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), self.name+".exe":self.makepyexe(gen), } + def getMakefileItems(self,gen): + makefileItems={"header":"include $(top_srcdir)/adm_local/make_common_starter.am"} + if self.kind == "lib": + makefileItems["salomepython_PYTHON"]=[self.name+".py"]+self.sources + if self.kind == "exe": + makefileItems["salomepython_PYTHON"]=self.sources + makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] + return makefileItems + def makepy(self, gen): + """generate standard SALOME component source (python module)""" services = [] inits = [] defs = [] @@ -43,6 +111,7 @@ class PYComponent(Component): params = [] pyparams = [] for name, typ in serv.inport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": pyparams.append(" %s=cPickle.loads(%s)" %(name, name)) @@ -52,13 +121,18 @@ class PYComponent(Component): params = [] pyparams = [] for name, typ in serv.outport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": pyparams.append(" %s=cPickle.dumps(%s,-1)" %(name, name)) outparams = ",".join(params) convertoutparams = '\n'.join(pyparams) + #dedent and indent the body + body=textwrap.dedent(serv.body) + body=indent(body,' '*6) + service = pyService.substitute(component=self.name, service=serv.name, inparams=inparams, - outparams=outparams, body=serv.body, + outparams=outparams, body= body, convertinparams=convertinparams, convertoutparams=convertoutparams) streams = [] @@ -76,12 +150,23 @@ class PYComponent(Component): inits.append(init) python_path = ",".join([repr(p) for p in self.python_path]) + + inheritedclass=self.inheritedclass + callconstructor="" + if self.inheritedclass: + inheritedclass= self.inheritedclass + "," + callconstructor=""" + if hasattr(%s,"__init__"): + %s.__init__(self)""" % (self.inheritedclass,self.inheritedclass) + return pyCompo.substitute(component=self.name, module=gen.module.name, - servicesdef="\n".join(defs), servicesimpl="\n".join(services), + servicesdef="\n".join(defs), servicesimpl="\n".join(services), initservice='\n'.join(inits), - python_path=python_path) + python_path=python_path,inheritedclass=inheritedclass, + compodefs=self.compodefs, callconstructor=callconstructor) def makepyexe(self, gen): + """generate standalone component source (python executable)""" services = [] inits = [] defs = [] @@ -90,6 +175,7 @@ class PYComponent(Component): params = [] pyparams = [] for name, typ in serv.inport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": pyparams.append(" %s=cPickle.loads(%s)" %(name, name)) @@ -99,14 +185,18 @@ class PYComponent(Component): params = [] pyparams = [] for name, typ in serv.outport: + if typ=="file":continue #files are not passed through service interface params.append(name) if typ == "pyobj": pyparams.append(" %s=cPickle.dumps(%s,-1)" %(name, name)) outparams = ",".join(params) convertoutparams = '\n'.join(pyparams) - service = pyService.substitute(component=self.name, service=serv.name, - inparams=inparams, outparams=outparams, - body=serv.body, + #dedent and indent the body + body=textwrap.dedent(serv.body) + body=indent(body,' '*6) + service = pyService.substitute(component=self.name, service=serv.name, + inparams=inparams, outparams=outparams, + body=body, convertinparams=convertinparams, convertoutparams=convertoutparams, ) @@ -125,11 +215,19 @@ class PYComponent(Component): inits.append(init) python_path = ",".join([repr(p) for p in self.python_path]) - return pyCompoEXE.substitute(component=self.name, module=gen.module.name, - servicesdef="\n".join(defs), - servicesimpl="\n".join(services), - initservice='\n'.join(inits), - python_path=python_path) + inheritedclass=self.inheritedclass + callconstructor="" + if self.inheritedclass: + inheritedclass= self.inheritedclass + "," + callconstructor=""" + if hasattr(%s,"__init__"): + %s.__init__(self)""" % (self.inheritedclass,self.inheritedclass) + return pyCompoEXE.substitute(component=self.name, module=gen.module.name, + servicesdef="\n".join(defs), + servicesimpl="\n".join(services), + initservice='\n'.join(inits), + python_path=python_path,inheritedclass=inheritedclass, + compodefs=self.compodefs, callconstructor=callconstructor) diff --git a/module_generator/pyth_tmpl.py b/module_generator/pyth_tmpl.py index dd74576..bef9bb9 100644 --- a/module_generator/pyth_tmpl.py +++ b/module_generator/pyth_tmpl.py @@ -1,3 +1,22 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + try: from string import Template except: @@ -6,10 +25,11 @@ except: pyCompo=""" import sys,traceback,os sys.path=sys.path+[${python_path}] -import ${module}__POA +import ${module}_ORB__POA import calcium import dsccalcium import SALOME +import Engines import cPickle try: @@ -17,20 +37,24 @@ try: except: numpy=None +#COMPODEFS +${compodefs} +#ENDDEF + #DEFS ${servicesdef} #ENDDEF -class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent): +class ${component}(${module}_ORB__POA.${component}, ${inheritedclass} dsccalcium.PyDSCComponent): ''' To be identified as a SALOME component this Python class must have the same name as the component, inherit omniorb - class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent + class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent that implements DSC API. ''' def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): - print "${component}.__init__: ", containerName, ';', instanceName,interfaceName dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName) +${callconstructor} def init_service(self,service): ${initservice} @@ -42,7 +66,6 @@ ${servicesimpl} pyCompoEXE="""#!/usr/bin/env python """+pyCompo+""" def destroy(self): - dsccalcium.PyDSCComponent.destroy(self) self._orb.shutdown(0) if __name__ == '__main__': @@ -80,7 +103,6 @@ pyCompoEXE=Template(pyCompoEXE) pyService=""" def ${service}(self,${inparams}): - print "${component}.${service}" self.beginService("${component}.${service}") component=self.proxy returns=None @@ -89,7 +111,6 @@ ${convertinparams} #BODY ${body} #ENDBODY - print "End of ${component}.${service}" sys.stdout.flush() self.endService("${component}.${service}") ${convertoutparams} @@ -111,16 +132,3 @@ pyinitService=Template(pyinitService) pyinitCEXEService=pyinitService pyinitEXEService=pyinitService -#Makefile - -pycompoMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am -salomepython_PYTHON = ${component}.py ${sources} -""" -pycompoMakefile=Template(pycompoMakefile) - -pycompoEXEMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am -salomepython_PYTHON = ${sources} -dist_salomescript_SCRIPTS= ${component}.exe -""" -pycompoEXEMakefile=Template(pycompoEXEMakefile) - diff --git a/module_generator/salomemodules.py b/module_generator/salomemodules.py new file mode 100644 index 0000000..a6d673c --- /dev/null +++ b/module_generator/salomemodules.py @@ -0,0 +1,140 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +####################################################################### +# SALOME modules # +####################################################################### +salome_modules={} + +def add_module(module,idldefs="",makefiledefs="",configdefs=""): + """ add a module configuration for other module than KERNEL + + :param module: module name (GEOM, SMESH, VISU, ...) + :type module: string + :param idldefs: definition instructions to add to idl files when using this module + :type idldefs: string + :param makefiledefs: definition instructions to add to Makefile files when using this module + :type makefiledefs: string + :param configdefs: instructions to add to configure file when using this module + :type configdefs: string + """ + salome_modules[module]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs} + +#module GEOM +idldefs=""" +#include "GEOM_Gen.idl" +""" +makefiledefs=""" +#module GEOM +GEOM_IDL_INCLUDES = -I$(GEOM_ROOT_DIR)/idl/salome +GEOM_INCLUDES= -I$(GEOM_ROOT_DIR)/include/salome +GEOM_IDL_LIBS= -L$(GEOM_ROOT_DIR)/lib/salome -lSalomeIDLGEOM +GEOM_LIBS= -L$(GEOM_ROOT_DIR)/lib/salome +SALOME_LIBS += ${GEOM_LIBS} +SALOME_IDL_LIBS += ${GEOM_IDL_LIBS} +SALOME_INCLUDES += ${GEOM_INCLUDES} +IDL_INCLUDES += ${GEOM_IDL_INCLUDES} +""" +configdefs=""" +if test "x${GEOM_ROOT_DIR}" != "x" && test -d ${GEOM_ROOT_DIR} ; then + AC_MSG_RESULT(Using GEOM installation in ${GEOM_ROOT_DIR}) +else + AC_MSG_ERROR([Cannot find module GEOM. Have you set GEOM_ROOT_DIR ?],1) +fi +""" +add_module("GEOM",idldefs,makefiledefs,configdefs) + +#module MED +idldefs=""" +#include "MED_Gen.idl" +#include "MED.idl" +#include "MEDCouplingCorbaServant.idl" +""" +makefiledefs=""" +#module MED +MED_IDL_INCLUDES = -I$(MED_ROOT_DIR)/idl/salome +MED_INCLUDES= -I${MED2HOME}/include -I${MED_ROOT_DIR}/include/salome -DH5_USE_16_API -I${HDF5HOME}/include +MED_IDL_LIBS= -L$(MED_ROOT_DIR)/lib/salome -lSalomeIDLMED +MED_LIBS= -L${MED2HOME}/lib -lmed -L${HDF5HOME}/lib -lhdf5 -L${MED_ROOT_DIR}/lib/salome -lSalomeIDLMED -lMEDClientcmodule -lmedcouplingcorba -lmedcouplingclient +SALOME_LIBS += ${MED_LIBS} +SALOME_IDL_LIBS += ${MED_IDL_LIBS} +SALOME_INCLUDES += ${MED_INCLUDES} +IDL_INCLUDES += ${MED_IDL_INCLUDES} +""" +configdefs=""" +if test "x${MED_ROOT_DIR}" != "x" && test -d ${MED_ROOT_DIR} ; then + AC_MSG_RESULT(Using MED installation in ${MED_ROOT_DIR}) +else + AC_MSG_ERROR([Cannot find module MED. Have you set MED_ROOT_DIR ?],1) +fi +""" + +salome_modules["MED"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs} + +#module SMESH +idldefs=""" +#include "SMESH_Gen.idl" +#include "SMESH_Mesh.idl" +""" +makefiledefs=""" +#module SMESH +SMESH_IDL_INCLUDES = -I$(SMESH_ROOT_DIR)/idl/salome +SMESH_INCLUDES= -I$(SMESH_ROOT_DIR)/include/salome +SMESH_IDL_LIBS= -L$(SMESH_ROOT_DIR)/lib/salome -lSalomeIDLSMESH +SMESH_LIBS= -L$(SMESH_ROOT_DIR)/lib/salome +SALOME_LIBS += ${SMESH_LIBS} +SALOME_IDL_LIBS += ${SMESH_IDL_LIBS} +SALOME_INCLUDES += ${SMESH_INCLUDES} +IDL_INCLUDES += ${SMESH_IDL_INCLUDES} +""" +configdefs=""" +if test "x${SMESH_ROOT_DIR}" != "x" && test -d ${SMESH_ROOT_DIR} ; then + AC_MSG_RESULT(Using SMESH installation in ${SMESH_ROOT_DIR}) +else + AC_MSG_ERROR([Cannot find module SMESH. Have you set SMESH_ROOT_DIR ?],1) +fi +""" + +salome_modules["SMESH"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs, + "depends":["GEOM","MED"]} + +#module VISU +idldefs=""" +#include "VISU_Gen.idl" +""" +makefiledefs=""" +#module VISU +VISU_IDL_INCLUDES = -I$(VISU_ROOT_DIR)/idl/salome +VISU_INCLUDES= -I$(VISU_ROOT_DIR)/include/salome +VISU_IDL_LIBS= -L$(VISU_ROOT_DIR)/lib/salome -lSalomeIDLVISU +VISU_LIBS= -L$(VISU_ROOT_DIR)/lib/salome +SALOME_LIBS += ${VISU_LIBS} +SALOME_IDL_LIBS += ${VISU_IDL_LIBS} +SALOME_INCLUDES += ${VISU_INCLUDES} +IDL_INCLUDES += ${VISU_IDL_INCLUDES} +""" +configdefs=""" +if test "x${VISU_ROOT_DIR}" != "x" && test -d ${VISU_ROOT_DIR} ; then + AC_MSG_RESULT(Using VISU installation in ${VISU_ROOT_DIR}) +else + AC_MSG_ERROR([Cannot find module VISU. Have you set VISU_ROOT_DIR ?],1) +fi +""" + +salome_modules["VISU"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs} diff --git a/module_generator/yacstypes.py b/module_generator/yacstypes.py new file mode 100644 index 0000000..c267ff5 --- /dev/null +++ b/module_generator/yacstypes.py @@ -0,0 +1,138 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +########################################################### +# Types definitions # +########################################################### +corbaTypes = {"double":"CORBA::Double", "long":"CORBA::Long", + "string":"const char*", "dblevec":"const %s::dblevec&", + "stringvec":"const %s::stringvec&", "intvec":"const %s::intvec&", + "file":None, "boolean":"CORBA::Boolean", "void":"void" + } + +corbaOutTypes = {"double":"CORBA::Double&", "long":"CORBA::Long&", + "string":"CORBA::String_out", "dblevec":"%s::dblevec_out", + "stringvec":"%s::stringvec_out", "intvec":"%s::intvec_out", + "file":None, "boolean":"CORBA::Boolean_out", "void":None + } +moduleTypes = {"double":"", "long":"", "string":"", "dblevec":"", "stringvec":"", "intvec":"", "file":"", "pyobj":"", "boolean":"", "void":"" } + +idlTypes = {"double":"double", "long":"long", "string":"string", "dblevec":"dblevec", "stringvec":"stringvec", "intvec":"intvec", + "file":"", "boolean":"boolean", "void":"void" } + +corbaRtnTypes = {"double":"CORBA::Double", "long":"CORBA::Long", + "string":"char*", "dblevec":"%s::dblevec*", + "stringvec":"%s::stringvec*", "intvec":"%s::intvec*", + "file":None, "boolean":"CORBA::Boolean", "void":"void" + } + + + +def corba_in_type(typ, module): + if corbaTypes[typ].count("%s")>0: + return corbaTypes[typ] % (module+"_ORB") + else: + return corbaTypes[typ] + +def corba_out_type(typ, module): + if corbaOutTypes[typ].count("%s")>0: + return corbaOutTypes[typ] % (module+"_ORB") + else: + return corbaOutTypes[typ] + +def corba_rtn_type(typ, module): + if corbaRtnTypes[typ].count("%s")>0: + return corbaRtnTypes[typ] % (module+"_ORB") + else: + return corbaRtnTypes[typ] + +ValidTypes = corbaTypes.keys() +PyValidTypes = ValidTypes+["pyobj"] + +def add_type(typename, corbaType=None, corbaOutType=None, module="", idltype=None, corbaRtnType=None): + """ add a data type YACS from other module than KERNEL to the list of available types + + :param typename: YACS data type name + :type typename: string + :param corbaType: representation for C++ CORBA in parameter + :type corbaType: string + :param corbaOutType: representation for C++ CORBA out parameter + :type corbaOutType: string + :param module: name of the module that defines the data type (GEOM for GEOM_Object) + :type module: string + :param idltype: representation for CORBA idl + :type idltype: string + :param corbaRtnType: representation for C++ CORBA return parameter + :type corbaRtnType: string + """ + corbaTypes[typename] = corbaType or "const "+typename.replace("/","::")+"&" + corbaOutTypes[typename] = corbaOutType or typename.replace("/","::")+"_out" + corbaRtnTypes[typename] = corbaRtnType or typename.replace("/","::")+"*" + moduleTypes[typename] = module + idlTypes[typename] = idltype or typename.replace("/","::") + ValidTypes.append(typename) + PyValidTypes.append(typename) + +calciumTypes = {"CALCIUM_double":"CALCIUM_double", + "CALCIUM_integer":"CALCIUM_integer", + "CALCIUM_real":"CALCIUM_real", + "CALCIUM_string":"CALCIUM_string", + "CALCIUM_complex":"CALCIUM_complex", + "CALCIUM_logical":"CALCIUM_logical", + "CALCIUM_long":"CALCIUM_long", + } + +DatastreamParallelTypes = {"Param_Double_Port":"Param_Double_Port"} + +ValidImpl = ("CPP", "PY", "F77", "ASTER", "PACO") +ValidImplTypes = ("sequential", "parallel") +ValidStreamTypes = calciumTypes.keys() +ValidParallelStreamTypes = DatastreamParallelTypes.keys() +ValidDependencies = ("I", "T") + +#Add KERNEL YACS types : YACS name, c++ corba arg in, c++ corba arg out,defining module, repr corba idl, c++ corba return +add_type("dataref", "const Engines::dataref&", "Engines::dataref_out", "", "dataref","Engines::dataref*") +add_type("SALOME_TYPES/Parameter") +add_type("SALOME_TYPES/ParameterList", "const SALOME_TYPES::ParameterList&", "SALOME_TYPES::ParameterList_out", "", "SALOME_TYPES::ParameterList","SALOME_TYPES::ParameterList*") +add_type("SALOME_TYPES/VarList", "const SALOME_TYPES::VarList&", "SALOME_TYPES::VarList_out", "", "SALOME_TYPES::VarList","SALOME_TYPES::VarList*") +add_type("SALOME_TYPES/Variable", "const SALOME_TYPES::Variable&", "SALOME_TYPES::Variable_out", "", "SALOME_TYPES::Variable","SALOME_TYPES::Variable*") +add_type("SALOME_TYPES/VariableSequence", "const SALOME_TYPES::VariableSequence&", "SALOME_TYPES::VariableSequence_out", "", "SALOME_TYPES::VariableSequence","SALOME_TYPES::VariableSequence*") +add_type("SALOME_TYPES/StateSequence", "const SALOME_TYPES::StateSequence&", "SALOME_TYPES::StateSequence_out", "", "SALOME_TYPES::StateSequence","SALOME_TYPES::StateSequence*") +add_type("SALOME_TYPES/TimeSequence", "const SALOME_TYPES::TimeSequence&", "SALOME_TYPES::TimeSequence_out", "", "SALOME_TYPES::TimeSequence","SALOME_TYPES::TimeSequence*") +add_type("SALOME_TYPES/ParametricInput", "const SALOME_TYPES::ParametricInput&", "SALOME_TYPES::ParametricInput_out", "", "SALOME_TYPES::ParametricInput","SALOME_TYPES::ParametricInput*") +add_type("SALOME_TYPES/ParametricOutput", "const SALOME_TYPES::ParametricOutput&", "SALOME_TYPES::ParametricOutput_out", "", "SALOME_TYPES::ParametricOutput","SALOME_TYPES::ParametricOutput*") + +#Add GEOM YACS types +add_type("GEOM_Object", "GEOM::GEOM_Object_ptr", "GEOM::GEOM_Object_out", "GEOM", "GEOM::GEOM_Object","GEOM::GEOM_Object_ptr") + +#Add SMESH YACS types +add_type("SMESH_Mesh", "SMESH::SMESH_Mesh_ptr", "SMESH::SMESH_Mesh_out", "SMESH", "SMESH::SMESH_Mesh","SMESH::SMESH_Mesh_ptr") +add_type("SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr", "SMESH::SMESH_Hypothesis_out", "SMESH", "SMESH::SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr") + +#Add MED YACS types +add_type("SALOME_MED/MED", "SALOME_MED::MED_ptr", "SALOME_MED::MED_out", "MED", "SALOME_MED::MED", "SALOME_MED::MED_ptr") +add_type("SALOME_MED/MESH", "SALOME_MED::MESH_ptr", "SALOME_MED::MESH_out", "MED", "SALOME_MED::MESH", "SALOME_MED::MESH_ptr") +add_type("SALOME_MED/SUPPORT", "SALOME_MED::SUPPORT_ptr", "SALOME_MED::SUPPORT_out", "MED", "SALOME_MED::SUPPORT", "SALOME_MED::SUPPORT_ptr") +add_type("SALOME_MED/FIELD", "SALOME_MED::FIELD_ptr", "SALOME_MED::FIELD_out", "MED", "SALOME_MED::FIELD", "SALOME_MED::FIELD_ptr") +add_type("SALOME_MED/FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr", "SALOME_MED::FIELDDOUBLE_out", "MED", "SALOME_MED::FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr") +add_type("SALOME_MED/FIELDINT", "SALOME_MED::FIELDINT_ptr", "SALOME_MED::FIELDINT_out", "MED", "SALOME_MED::FIELDINT", "SALOME_MED::FIELDINT_ptr") +add_type("SALOME/Matrix", "SALOME::Matrix_ptr", "SALOME::Matrix_out", "MED", "SALOME::Matrix", "SALOME::Matrix_ptr") +add_type("SALOME_MED/MEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr") +add_type("SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_out", "MED", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr") +add_type("SALOME_MED/MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr", "SALOME_MED::MEDCouplingUMeshCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr") diff --git a/script/hxx2salome.py b/script/hxx2salome.py new file mode 100755 index 0000000..43a8cca --- /dev/null +++ b/script/hxx2salome.py @@ -0,0 +1,197 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +usage=""" +hxx2salome.py [options] _root_dir lib.hxx .so installDir + +generate a SALOME component that wrapps given the C++ component + +Mandatory arguments: + + - _root_dir : install directory (absolute path) of the c++ component + - .hxx : header of the c++ component" + - lib.so : the shared library containing the c++ component + - installDir : directory where the generated files and the build should be installed + + Note that .hxx and lib.so should be found in _root_dir) + +""" + +import os +import sys +import string +import optparse +from module_generator import Generator,Module,Service,HXX2SALOMEComponent + +# ------------------------------------------------------------------------------ + +def main(): +# Reproduce the main options of original hxx2salome script + parser = optparse.OptionParser(usage=usage) + parser.add_option( + '-e', + dest="environ_file", + default='sh', + help="specify the name of a environment file (bash/sh) that will" +\ + " be updated") + parser.add_option( + '-g', + action="store_true", + dest="do_gui", + default=False, + help="to create a generic gui in your component building tree") + parser.add_option( + '-c', + action="store_true", + dest="do_compile", + default=False, + help="to compile after generation") + parser.add_option( + '-s', + dest="shell_syntax", + help="use this option with csh to update the environment " +\ + "with the CSH syntax") + + options, args = parser.parse_args() + + assert len(args) == 4, \ + 'ERROR, four mandatory arguments are expected!\n\n%s\n' % usage + cppdir = args[0] # install directory of the c++ component + hxxfile = args[1] # header of the c++ component + libfile = args[2] # the shared library containing the c++ component + installpath = args[3] # directory where the generated files are installed + +# Make sure given paths/files are valid + if not os.path.exists(cppdir): + print "ERROR: cppdir %s does not exist. It is mandatory" % cppdir + print usage + sys.exit(1) + + if not os.path.exists(installpath): + print "ERROR: installpath %s does not exist. It is mandatory" \ + % installpath + print usage + sys.exit(1) + + if options.environ_file != None: + if not os.path.exists(options.environ_file): + print "ERROR: environ_file %s does not exist. It is mandatory" \ + % options.environ_file + print usage + sys.exit(1) + + hxx2salome(cppdir=cppdir, + hxxfile=hxxfile, + libfile=libfile, + installpath=installpath, + do_gui=options.do_gui, + do_compile=options.do_compile, + environ_file=options.environ_file, + shell_syntax=options.shell_syntax + ) + pass + +# ------------------------------------------------------------------------------ + +def hxx2salome(cppdir, + hxxfile, + libfile, + installpath, + do_gui, + do_compile, + environ_file, + shell_syntax): + + # setup from environment a minimal context + kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] + gui_root_dir=os.environ["GUI_ROOT_DIR"] + context={'update':1, + "makeflags":"-j2", + "kernel":kernel_root_dir, + "gui":gui_root_dir, + } + # + salome_compo = HXX2SALOMEComponent(hxxfile,libfile,cppdir) + install_root_dir = os.path.join(installpath,salome_compo.name) + module_root_dir = os.path.join(install_root_dir, + salome_compo.name+"_INSTALL") + + # to be able to compile the generated component + os.environ[salome_compo.name+"CPP_ROOT_DIR"]=cppdir + + # if necessary creates the directory in which the component + # will be geberated and compiled. + try: + os.mkdir(install_root_dir) + except OSError: + print "Warning : directory %s already exixts!" % install_root_dir + + # if a graphical user interface is required, + # ask HXX2SALOMEComponent to generate template files + if do_gui: + gui_files=salome_compo.getGUIfilesTemplate() + g=Generator(Module(salome_compo.name,components=[salome_compo], + prefix=module_root_dir, + gui=gui_files), + context) + else: + g=Generator(Module(salome_compo.name,components=[salome_compo], + prefix=module_root_dir), + context) + + # go in install_root_dir, generate the component + os.chdir(install_root_dir) + g.generate() + + # if specified : compile and install the generated component + if do_compile: + g.bootstrap() + g.configure() + g.make() + g.install() + pass + # + # update environment file if furnished + if environ_file != None: + envfile=open(environ_file,"a") + if shell_syntax == "csh": + update_environ=""" +#------ ${compo_name} +setenv ${compo_name}_SRC_DIR ${install_root_dir}/${compo_name}_SRC +setenv ${compo_name}_ROOT_DIR ${install_root_dir}/${compo_name}_INSTALL +""" + else: + update_environ=""" +#------ ${compo_name} +export ${compo_name}_SRC_DIR=${install_root_dir}/${compo_name}_SRC +export ${compo_name}_ROOT_DIR=${install_root_dir}/${compo_name}_INSTALL +""" + update_environ=string.Template(update_environ) + update_environ=update_environ.substitute(compo_name=salome_compo.name, + install_root_dir=install_root_dir) + envfile.write(update_environ) + envfile.close() + pass + +# ------------------------------------------------------------------------------ + +if __name__ == '__main__': + main() + pass diff --git a/setup.py b/setup.py index eea8893..ee6b019 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,26 @@ +# Copyright (C) 2009-2012 EDF R&D +# +# 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + from distutils.core import setup setup(name='YACSGEN', - version='5.1.0', + version='6.5.0', author='C. Caremoli', packages=['module_generator'], + scripts=['script/hxx2salome.py',] ) -- 2.39.2