From: prascle Date: Wed, 13 Jul 2005 08:03:32 +0000 (+0000) Subject: PR: modifications related to LifeCycle CORBA and SALOME Application concept X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d3b02a337024e6047ac3e8c5ae208f4f972d87f3;p=modules%2Fkernel.git PR: modifications related to LifeCycle CORBA and SALOME Application concept --- diff --git a/Makefile.in b/Makefile.in index 90665ff5d..34857780b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,6 +35,7 @@ killSalomeWithPort.py \ runSalome \ runSalome.csh \ runNS.sh \ +createAppli.sh \ launchConfigureParser.py \ salome.launch \ envSalome.py \ @@ -111,6 +112,10 @@ install-include: $(include_list) done # install script in $(bindir) : +install-appliskel: + $(INSTALL) -d $(bindir) + cp -rp $(top_builddir)/bin/salome/appliskel $(bindir) + install-bin: $(BIN_SCRIPT) $(INSTALL) -d $(bindir) $(INSTALL_PROGRAM) $^ $(bindir) @@ -118,7 +123,7 @@ install-bin: $(BIN_SCRIPT) # install Plugin file install-plugin: $(top_builddir)/share/salome/resources/Plugin ($(INSTALL_DATA) $^ $(datadir)/resources/. || exit 1); \ - + uninstall: uninstall-idl uninstall-idl: @@ -139,5 +144,4 @@ $(top_builddir)/share/salome/resources/Plugin: resources/Plugin resources: $(top_builddir)/share/salome/resources/Plugin -install: install-bin install-include install-make install-plugin install-end - +install: install-bin install-appliskel install-include install-make install-plugin install-end diff --git a/bin/appliskel/CatalogResources.xml b/bin/appliskel/CatalogResources.xml new file mode 100644 index 000000000..8caed2bfb --- /dev/null +++ b/bin/appliskel/CatalogResources.xml @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/bin/appliskel/README b/bin/appliskel/README new file mode 100644 index 000000000..264b879bc --- /dev/null +++ b/bin/appliskel/README @@ -0,0 +1,42 @@ +Set of scripts for a SALOME application +======================================= + +# - A SALOME application distributed on several computers needs APPLI +# directories on the same path ($APPLI) relative to $HOME directory +# of the user, on each computer. + +user scripts: +------------- + +runAppli : SALOME launch (idem runSalome but different name to avoid + confusion with ${KERNEL_ROOT_DIR}/bin/salome/runSalome + +runConsole : a python console in the current SALOME session environment + +runSession : a shell in SALOME environment, either interactive (without args) + or used to run a program (defined by given args) + +internal application scripts: +----------------------------- + +runRemote.sh : called from remote computer, via ssh, rsh... + used for instance to create container + +envd : sets SALOME application environment + sourced by other scripts + +The following files must be adapted to your environment and SALOME Application: +------------------------------------------------------------------------------- + +SalomeApp.xml - list of modules, options on server launch and resources... +CatalogResources.xml - configuration of machines used in SALOME application + (no need of modules list and path here) + +env.d directory must contain the necessary files to source, to define +the SALOME Application environment : + ( envd script source these files in alphanumeric order ) + +For instance, + atFirst.sh - general presets + envProducts.sh - prerequisite SALOME environment + envSalome.sh - list of MODULE_ROOT_DIR diff --git a/bin/appliskel/SalomeApp.xml b/bin/appliskel/SalomeApp.xml new file mode 100644 index 000000000..6897b7136 --- /dev/null +++ b/bin/appliskel/SalomeApp.xml @@ -0,0 +1,100 @@ + +
+ + + + + +
+
+ + + + + + + + + + + + + +
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+ + +
+ + +
+
+ +
+
+ + +
+ +
+ + +
+
diff --git a/bin/appliskel/env.d/atFirst.sh b/bin/appliskel/env.d/atFirst.sh new file mode 100644 index 000000000..0c6715f75 --- /dev/null +++ b/bin/appliskel/env.d/atFirst.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +#------------------------------------------------ +# to be sourced first, used in following scripts +#------------------------------------------------ + +export LD_LIBRARY_PATH="." +export PATH="/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/prascle/bin:." +export PYTHONPATH="" + +export RAC=${HOME} +export PAKSAL=/opt +export PUB=${RAC}/public +export TARP=${RAC}/tarpublic +export PYPACKAGES=${PUB}/site_packages + +# ------------------------------------------------ +# ---- gdb 5.3 + +export PATH=${PAKSAL}/gdb53/bin:${PATH} +export LD_LIBRARY_PATH=${PAKSAL}/gdb53/lib:${LD_LIBRARY_PATH} + +# ------------------------------------------------ +# ---- ddd 3.3.7 + +export PATH=${PAKSAL}/ddd337/bin:${PATH} +export LD_LIBRARY_PATH=${PAKSAL}/ddd337/lib:${LD_LIBRARY_PATH} + +# ------------------------------------------------ +# --- Java 1.4 + +export JDKHOME=${PUB}/j2sdk_nb/j2sdk1.4.2 +export JAVAHOME=${PUB}/j2sdk_nb/j2sdk1.4.2 +export PATH=${JAVAHOME}/bin:${PATH} +export LD_LIBRARY_PATH=${JAVAHOME}/lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${JAVAHOME}/jre/lib/i386:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=${JAVAHOME}/jre/lib/i386/client:${LD_LIBRARY_PATH} + +# ------------------------------------------------ +# --- gsl -1.4 + +export GSLHOME=${PAKSAL}/gsl-1.4 +export PATH=${GSLHOME}/bin:${PATH} +export LD_LIBRARY_PATH=${GSLHOME}/lib:${LD_LIBRARY_PATH} + +# ------------------------------------------------ +# --- fltk 1.1.4 + +export FLTKHOME=${PAKSAL}/fltk114 +export PATH=${FLTKHOME}/bin:${PATH} +export LD_LIBRARY_PATH=${FLTKHOME}/lib:${LD_LIBRARY_PATH} + +# ------------------------------------------------ +# --- gmsh 1.48 + +export GMSHHOME=${PAKSAL}/gmsh148 +export PATH=${GMSHHOME}/bin:${PATH} + +# ------------------------------------------------ +# ---- tkcvs, tkdiffb, cvs + +export PATH=${PAKSAL}/tkcvs7.2/bin:${PAKSAL}/cvs1.11.14/bin:${PATH} diff --git a/bin/appliskel/env.d/envProducts.sh b/bin/appliskel/env.d/envProducts.sh new file mode 100644 index 000000000..aa0570562 --- /dev/null +++ b/bin/appliskel/env.d/envProducts.sh @@ -0,0 +1,120 @@ +#!/bin/sh + +# ------------------------------------------------ +# ---- openpbs + +export OPENPBS=/optroot/openpbs2316 +export PATH=${OPENPBS}/bin:${PATH} +export LD_LIBRARY_PATH=${OPENPBS}/lib:${LD_LIBRARY_PATH} + +#------------------------------------------------------------------------------ + +export INSTALL_ROOT=/home/prascle/PAL_SALOME141 +#------ gcc ------ +export GCC_ROOT=/usr +export CXX=${GCC_ROOT}/bin/g++ +export CC=${GCC_ROOT}/bin/gcc +## +#------ boost ------ +export BOOSTDIR=${INSTALL_ROOT}/boost-1.30.2 +## + +#------ tcltk ------ +export TCLHOME=/usr + +#------ Python ------ +export PYTHONHOME=/usr +export PYTHONPATH=${PYPACKAGES}:${PYTHONPATH} +## +#------ Qt ------ +#export QTDIR=/usr/lib/qt-3.0.5 +export QTDIR=/usr/lib/qt3-gcc3.2 +export PATH=${PATH}:${QTDIR}/bin +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${QTDIR}/lib +## +#------ Sip ------ +export SIPDIR=/usr +export PYQTDIR=/usr +## +#------ PyQt ------ +export PYQT_SIPS=/usr/share/sip/qt +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib/python2.2/site-packages +## +#------ Swig ------ +export SWIG_ROOT=${INSTALL_ROOT}/SWIG-1.3.17 +export PATH=${SWIG_ROOT}/bin:${PATH} +export LD_LIBRARY_PATH=${SWIG_ROOT}/lib:${LD_LIBRARY_PATH} +## +#------ OpenCascade ------ +export CASROOT=/opt/CAS52patch +export LD_LIBRARY_PATH=${CASROOT}/Linux/lib:${LD_LIBRARY_PATH} +export PATH=${CASROOT}/Linux/bin:${PATH} +# Variable for Foundation Classes : +export CSF_UnitsLexicon=${CASROOT}/src/UnitsAPI/Lexi_Expr.dat +export CSF_UnitsDefinition=${CASROOT}/src/UnitsAPI/Units.dat +# Variable for DataExchange : +export CSF_SHMessage=${CASROOT}/src/SHMessage +export CSF_XSMessage=${CASROOT}/src/XSMessage +# Variable for Font : +export CSF_MDTVFontDirectory=${CASROOT}/src/FontMFT +export CSF_MDTVTexturesDirectory=${CASROOT}/src/Textures +## +export CSF_LANGUAGE=us +export MMGT_CLEAR=1 +export CSF_EXCEPTION_PROMPT=1 +export CSF_StandardDefaults=${CASROOT}/src/StdResource +export CSF_PluginDefaults=${CASROOT}/src/StdResource +export CSF_XCAFDefaults=${CASROOT}/src/StdResource +export CSF_GraphicShr=${CASROOT}/Linux/lib/libTKOpenGl.so +export CSF_IGESDefaults=${CASROOT}/src/XSTEPResource +export CSF_STEPDefaults=${CASROOT}/src/XSTEPResource +## +#export TCLLIBPATH=$TCLHOME/lib +## +#------ Qwt ------ +export QWTHOME=${INSTALL_ROOT}/qwt-0.4.1 +export LD_LIBRARY_PATH=${QWTHOME}/lib:${LD_LIBRARY_PATH} +## +#------ Hdf ------ +export HDF5HOME=${INSTALL_ROOT}/hdf5-1.4.4 +export PATH=${HDF5HOME}/bin:$PATH +export LD_LIBRARY_PATH=${HDF5HOME}/lib:${LD_LIBRARY_PATH} +## +#------ Med ------ +export MED2HOME=/opt/med2.2.2 +export PATH=${MED2HOME}/bin:${PATH} +export LD_LIBRARY_PATH=${MED2HOME}/lib:${LD_LIBRARY_PATH} +## +#------ Vtk ------ +export VTKHOME=${INSTALL_ROOT}/VTK-4.2.2 +export PATH=${VTKHOME}/bin:${PATH} +export LD_LIBRARY_PATH=${VTKHOME}/lib/vtk:${LD_LIBRARY_PATH} +export PYTHONPATH=${VTKHOME}/lib/vtk:${VTKHOME}/lib/python2.2/site-packages/vtk_python:${PYTHONPATH} +## +#------ netgen ------ +export NETGENROOT=${INSTALL_ROOT}/netgen4.3 +export NETGEN_HOME=${INSTALL_ROOT}/netgen4.3 +## +#------ OmniORB ------ +export OMNIORBDIR=${INSTALL_ROOT}/omniORB-3.0.5 +export OMNIORB_CONFIG=${OMNIORBDIR}/.omniORB.cfg +export PYTHONPATH=${OMNIORBDIR}/lib/python:${OMNIORBDIR}/lib/i586_linux_2.0_glibc2.1:${PYTHONPATH} +export PATH=$OMNIORBDIR/bin/i586_linux_2.0_glibc2.1:$PATH +export LD_LIBRARY_PATH=$OMNIORBDIR/lib/i586_linux_2.0_glibc2.1:$LD_LIBRARY_PATH +## +#------ Numeric ------ +export PYTHONPATH=${INSTALL_ROOT}/Numeric-22.0/lib/python2.2/site-packages/Numeric:${PYTHONPATH} +## +#------ HappyDoc ------ +export PATH=${INSTALL_ROOT}/HappyDoc-r2_1/bin:${PATH} +export PYTHONPATH=${INSTALL_ROOT}/HappyDoc-r2_1/lib/python2.2/site-packages:${PYTHONPATH} +## +#------ Doxygen ------ +export PATH=${INSTALL_ROOT}/doxygen-1.3-rc2/bin:${PATH} +## +#------ Graphviz ------ +export PATH=${INSTALL_ROOT}/graphviz-1.9/bin:${PATH} +export LD_LIBRARY_PATH=${INSTALL_ROOT}/graphviz-1.9/lib/graphviz:${LD_LIBRARY_PATH} +## + +#------------------------------------------------------------------------------ diff --git a/bin/appliskel/env.d/envSalome.sh b/bin/appliskel/env.d/envSalome.sh new file mode 100644 index 000000000..9d765a072 --- /dev/null +++ b/bin/appliskel/env.d/envSalome.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# --- example to adapt to your own configuration --- +# +# --- envSalome.sh gives a set of MODULE_ROOT_DIR, to source +# --- you must at least define and export KERNEL_ROOT_DIR + +REPINST=/home/prascle/SALOME2/Install + +export KERNEL_ROOT_DIR=${REPINST}/KERNEL_V301 + +export GUI_ROOT_DIR=${REPINST}/GUI_V301 +#export SalomeAppConfig=${GUI_ROOT_DIR}/share/salome/resources +export SalomeAppConfig=${HOME}/${APPLI} +export SUITRoot=${GUI_ROOT_DIR}/share/salome + +export GEOM_ROOT_DIR=${REPINST}/GEOM_V301 +export MED_ROOT_DIR=${REPINST}/MED_V301 +export SMESH_ROOT_DIR=${REPINST}/SMESH_V301 +export SUPERV_ROOT_DIR=${REPINST}/SUPERV_V301 +export VISU_ROOT_DIR=${REPINST}/VISU_V301 +export NETGENPLUGIN_ROOT_DIR=${REPINST}/NETGENPLUGIN_V301 +export COMPONENT_ROOT_DIR=${REPINST}/COMPONENT_V301 +export PYCALCULATOR_ROOT_DIR=${REPINST}/PYCALCULATOR_V301 +export PYHELLO_ROOT_DIR=${REPINST}/PYHELLO_V301 +export PYTIX_ROOT_DIR=${REPINST}/PYTIX_V301 + diff --git a/bin/appliskel/envd b/bin/appliskel/envd new file mode 100644 index 000000000..80261ada2 --- /dev/null +++ b/bin/appliskel/envd @@ -0,0 +1,3 @@ +#!/bin/bash + +for i in $1/env.d/*;do source ${i}; done diff --git a/bin/appliskel/runAppli b/bin/appliskel/runAppli new file mode 100755 index 000000000..3e703bc64 --- /dev/null +++ b/bin/appliskel/runAppli @@ -0,0 +1,63 @@ +#!/bin/bash + +# --- retrieve APPLI path, relative to $HOME +# on sarge, "which" gives not allways the absolute path... + +comName=`which $0` +aa=${comName:0:1} +if test x$aa == x\/; then + mycom=${comName} +elif test x$aa == x\.; then + mycom=${PWD}/${comName:2} +else + mycom=${PWD}/${comName} +fi +APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '` +#echo $APPLI +export APPLI + +# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) + +. ${HOME}/${APPLI}/envd ${HOME}/${APPLI} + +# --- define port for CORBA naming service + +searchFreePort() { + echo -n "Searching for a free port for naming service: " + export NSPORT=2810 + local limit=$NSPORT + let limit=limit+100 + while [ 1 ] + do + aRes=`netstat -ltn | grep -E :${NSPORT}` + if [ -z "$aRes" ]; then + echo ${NSPORT} - Ok + local myhost=`hostname` + export OMNIORB_CONFIG=${HOME}/$APPLI//.omniORB_${myhost}_${NSPORT}.cfg + export NSPORT + local initref="NameService=corbaname::"`hostname`":$NSPORT" + echo "ORBInitRef $initref" > $OMNIORB_CONFIG + break + fi + echo -n "${NSPORT} " + if [[ $NSPORT -eq $limit ]] ; then + echo + echo "Can't find a free port to launch omniNames" + echo "Try to kill the running servers and then launch SALOME again." + exit + fi + let NSPORT=NSPORT+1 + done +} + +# --- run SALOME +# (default arguments defined in local salome.launch could be completed +# by arguments to this command) + +searchFreePort + +if [ $# -ne 0 ] ; then + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $* +else + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py +fi diff --git a/bin/appliskel/runConsole b/bin/appliskel/runConsole new file mode 100755 index 000000000..e45f58611 --- /dev/null +++ b/bin/appliskel/runConsole @@ -0,0 +1,25 @@ +#!/bin/bash + +# --- retrieve APPLI path, relative to $HOME +# on sarge, "which" gives not allways the absolute path... + +comName=`which $0` +aa=${comName:0:1} +if test x$aa == x\/; then + mycom=${comName} +elif test x$aa == x\.; then + mycom=${PWD}/${comName:2} +else + mycom=${PWD}/${comName} +fi +APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '` +#echo $APPLI +export APPLI + +# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) + +. ${HOME}/${APPLI}/envd ${HOME}/${APPLI} + +# --- open a Python interpreter with SALOME environment + +${KERNEL_ROOT_DIR}/bin/salome/envSalome.py python -i ${KERNEL_ROOT_DIR}/bin/salome/salomeConsole.py $* diff --git a/bin/appliskel/runParam b/bin/appliskel/runParam new file mode 100755 index 000000000..17bbd618b --- /dev/null +++ b/bin/appliskel/runParam @@ -0,0 +1,5 @@ +#!/bin/bash + +./runAppli --killall + +#./runSession killSalome.py diff --git a/bin/appliskel/runRemote.sh b/bin/appliskel/runRemote.sh new file mode 100755 index 000000000..84a125765 --- /dev/null +++ b/bin/appliskel/runRemote.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# +# --- run command in SALOME environment from remote call, ssh or rsh +# - SALOME configuration is defined by : +# - list of MODULE_ROOT_DIR +# - prerequisite environment +# - specific configuration for a particular SALOME application +# - These elements of configuration are defined locally on each computer +# in the directory APPLI: +# - A SALOME application distributed on several computers needs APPLI +# directories on the same path ($APPLI) relative to $HOME directory +# of the user, on each computer. +# +# --- call example (from cli76cd to cli76ce): +# ssh cli76ce ${APPLI}/runRemote.sh cli76cd 2810 SALOME_Container myContainerName +# +# --- local arguments +# $0 : ${APPLI}/runRemote.sh: from arg name, rebuild and export $APPLI variable +# $1 : computer name for CORBA name service (where SALOME was launched) +# $2 : port for CORBA name service +# $3 and following : local command to execute, with args +# + +# --- retrieve APPLI path, relative to $HOME +# on sarge, "which" gives not allways the absolute path... + +comName=`which $0` +aa=${comName:0:1} +if test x$aa == x\/; then + mycom=${comName} +elif test x$aa == x\.; then + mycom=${PWD}/${comName:2} +else + mycom=${PWD}/${comName} +fi +APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '` +#echo $APPLI +export APPLI + +# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) + +. ${HOME}/${APPLI}/envd ${HOME}/${APPLI} + +# --- set the OMNIORB_CONFIG file and environment relative to this run of SALOME + +export OMNIORB_CONFIG=${HOME}/${APPLI}/.omniORB_$1_$2.cfg +initref="NameService=corbaname::"$1":$2" +echo "ORBInitRef $initref" > $OMNIORB_CONFIG + +# --- execute the command in the SALOME environment + +shift 2 + +${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile $HOME/$APPLI/.bashrc -c "$*" diff --git a/bin/appliskel/runSession b/bin/appliskel/runSession new file mode 100755 index 000000000..d94bfff6c --- /dev/null +++ b/bin/appliskel/runSession @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Useful shell to run executable progs or shells under Salome env +# Use it with args to run a program : runSession python -i myprog.py +# Use it without args to run an interactive shell under Salome env +# + +# --- retrieve APPLI path, relative to $HOME +# on sarge, "which" gives not allways the absolute path... + +comName=`which $0` +aa=${comName:0:1} +if test x$aa == x\/; then + mycom=${comName} +elif test x$aa == x\.; then + mycom=${PWD}/${comName:2} +else + mycom=${PWD}/${comName} +fi +APPLI=`echo ${HOME} \`dirname $mycom\` | awk ' { print substr($2,length($1)+2) } '` +#echo $APPLI +export APPLI + +# --- set the SALOME environment (prerequisites, MODULES_ROOT_DIR...) + +. ${HOME}/${APPLI}/envd ${HOME}/${APPLI} + +# --- invoque shell with or without args + +if [ $# -ne 0 ] ; then + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc -c "$*" +else + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc +fi diff --git a/bin/createAppli.sh b/bin/createAppli.sh new file mode 100755 index 000000000..c6c4de072 --- /dev/null +++ b/bin/createAppli.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +comName=`which $0` +rep=`dirname $comName` + +cp -r $rep/appliskel $1 +chmod +x $1/*.sh $1/run* $1/envd diff --git a/bin/runSalome b/bin/runSalome index 178359e35..6e7efbc67 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -13,6 +13,7 @@ searchFreePort() { local myhost=`hostname` export OMNIORB_CONFIG=${HOME}/.omniORB_${myhost}_${NSPORT}.cfg local initref="NameService=corbaname::"`hostname`":$NSPORT" + export NSPORT if [[ `python -c "import CORBA; print CORBA.ORB_ID"` == "omniORB4" ]]; then echo "InitRef = $initref" > $OMNIORB_CONFIG else diff --git a/bin/runSalome.py b/bin/runSalome.py index 1a1147a20..810d7bf2b 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -417,17 +417,6 @@ class SessionServer(Server): self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 else: self.CMD=self.SCMD1 + self.SCMD2 - - # arguments SALOME_Session_Server pour ddd - comm_ddd="" - for mot in self.CMD: - if mot == "(": - comm_ddd+='"(" ' - elif mot == ")": - comm_ddd+='")" ' - else: - comm_ddd+=mot+" " - print comm_ddd # --- @@ -632,9 +621,6 @@ def startSalome(args, modules_list, modules_root_dir): clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer") ##---------------- - #macomm2=['ddd'] - #pid = os.spawnvp(os.P_NOWAIT, macomm2[0], macomm2) - # # Attente de la disponibilite du Session Server dans le Naming Service # diff --git a/configure.in.base b/configure.in.base index 9ba416b5a..28e36f21e 100644 --- a/configure.in.base +++ b/configure.in.base @@ -182,7 +182,7 @@ echo testing OpenPBS echo --------------------------------------------- echo -dnl openpbs_ok=no +openpbs_ok=no CHECK_OPENPBS dnl openpbs_ok is set to yes by CHECK_OPENPBS @@ -198,7 +198,7 @@ echo testing LSF echo --------------------------------------------- echo -dnl lsf_ok=no +lsf_ok=no CHECK_LSF dnl lsf_ok is set to yes by CHECK_LSF @@ -368,7 +368,18 @@ echo --------------------------------------------- echo echo Configure -variables="cc_ok boost_ok lex_yacc_ok mpi_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok openpbs_ok lsf_ok" +variables="cc_ok boost_ok lex_yacc_ok mpi_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok" + +for var in $variables +do + eval toto=\$$var + if test x$toto != "x"; then + printf " %10s : " `echo \$var | sed -e "s,_ok,,"` + eval echo \$$var + fi +done +echo "---Optional:" +variables="openpbs_ok lsf_ok" for var in $variables do @@ -436,13 +447,14 @@ dnl directory mkdir -p bin/salome cd bin/salome -for i in $ROOT_SRCDIR/bin/* +for i in `find $ROOT_SRCDIR/bin` do - local_bin=`echo $i | sed -e "s,$ROOT_SRCDIR,.,"` + local_bin=`echo $i | sed -e "s,$ROOT_SRCDIR/bin,.,"` case "$local_bin" in *.in | *~) ;; - ./bin/CVS | ./bin/salome) ;; - *) $INSTALL $i .; echo $local_bin ;; + . | */CVS | */CVS/* | ./salome) ;; + ./appliskel |./appliskel/env.d) $INSTALL -d $local_bin ; echo $local_bin ;; + *) $INSTALL $i $local_bin; echo $local_bin ;; esac done cd $ROOT_BUILDDIR diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index d1f27369a..b54a963cd 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -45,7 +45,7 @@ using namespace std; bool _Sleeping = false ; -// Needed by multi-threaded Python +// // Needed by multi-threaded Python --- Supervision int _ArgC ; char ** _ArgV ; @@ -93,25 +93,14 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, if(activAndRegist) ActSigIntHandler() ; - _ArgC = argc ; - _ArgV = argv ; - _argc = argc ; _argv = argv ; - int i = strlen( _argv[ 0 ] ) - 1 ; - while ( i >= 0 ) - { - if ( _argv[ 0 ][ i ] == '/' ) - { - _argv[ 0 ][ i+1 ] = '\0' ; - break ; - } - i -= 1 ; - } + string hostname = GetHostname(); MESSAGE(hostname << " " << getpid() << " Engines_Container_i starting argc " << _argc << " Thread " << pthread_self() ) ; - i = 0 ; + + int i = 0 ; while ( _argv[ i ] ) { MESSAGE(" argv" << i << " " << _argv[ i ]) ; @@ -127,6 +116,12 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, _isSupervContainer = false; if (strcmp(argv[1],"SuperVisionContainer") == 0) _isSupervContainer = true; + if (_isSupervContainer) + { + _ArgC = argc ; + _ArgV = argv ; + } + _containerName = BuildContainerNameForNS(containerName,hostname.c_str()); _orb = CORBA::ORB::_duplicate(orb) ; @@ -800,21 +795,32 @@ void ActSigIntHandler() perror("SALOME_Container main ") ; exit(0) ; } - INFOS(pthread_self() << "SigIntHandler activated") ; + //PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers) + // use of streams (and so on) should never be used because : + // streams of C++ are naturally thread-safe and use pthread_mutex_lock ===> + // A stream operation may be interrupted by a signal and if the Handler use stream we + // may have a "Dead-Lock" ===HangUp + //==INFOS is commented + // INFOS(pthread_self() << "SigIntHandler activated") ; } void SetCpuUsed() ; void SigIntHandler(int what , siginfo_t * siginfo , - void * toto ) -{ - MESSAGE(pthread_self() << "SigIntHandler what " << what << endl - << " si_signo " << siginfo->si_signo << endl - << " si_code " << siginfo->si_code << endl - << " si_pid " << siginfo->si_pid) ; + void * toto ) { + //PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers) + // use of streams (and so on) should never be used because : + // streams of C++ are naturally thread-safe and use pthread_mutex_lock ===> + // A stream operation may be interrupted by a signal and if the Handler use stream we + // may have a "Dead-Lock" ===HangUp + //==MESSAGE is commented + // MESSAGE(pthread_self() << "SigIntHandler what " << what << endl + // << " si_signo " << siginfo->si_signo << endl + // << " si_code " << siginfo->si_code << endl + // << " si_pid " << siginfo->si_pid) ; if ( _Sleeping ) { _Sleeping = false ; - MESSAGE("SigIntHandler END sleeping.") ; + // MESSAGE("SigIntHandler END sleeping.") ; return ; } else { @@ -824,13 +830,13 @@ void SigIntHandler(int what , siginfo_t * siginfo , } else { _Sleeping = true ; - MESSAGE("SigIntHandler BEGIN sleeping.") ; + // MESSAGE("SigIntHandler BEGIN sleeping.") ; int count = 0 ; while( _Sleeping ) { sleep( 1 ) ; count += 1 ; } - MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; + // MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; } return ; } diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index e5308e8ab..3e13155c3 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -30,10 +30,7 @@ #include #include -//#include "Utils_ORB_INIT.hxx" -//#include "Utils_SINGLETON.hxx" #include -#include "SALOME_NamingService.hxx" #include "SALOME_Container_i.hxx" #include "utilities.h" #include "SALOMETraceCollector.hxx" @@ -58,6 +55,7 @@ int main(int argc, char* argv[]) #ifdef HAVE_MPI2 MPI_Init(&argc,&argv); #endif + // Initialise the ORB. CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ; SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); @@ -80,117 +78,67 @@ int main(int argc, char* argv[]) Py_Initialize() ; PySys_SetArgv( argc , argv ) ; } - - try{ - // Obtain a reference to the root POA. - // obtain the root poa manager - // - long TIMESleep = 500000000; - int NumberOfTries = 40; - int a; - timespec ts_req; - ts_req.tv_nsec=TIMESleep; - ts_req.tv_sec=0; - timespec ts_rem; - ts_rem.tv_nsec=0; - ts_rem.tv_sec=0; - CosNaming::NamingContext_var inc; - PortableServer::POA_var root_poa; - CORBA::Object_var theObj; - CORBA::Object_var obj; - CORBA::Object_var object; - //SALOME_NamingService &naming = *SINGLETON_::Instance() ; - int CONTAINER=0; - const char * Env = getenv("USE_LOGGER"); - int EnvL =0; - if(Env != NULL && strlen(Env)) - EnvL=1; - - CosNaming::Name name; - name.length(1); - name[0].id=CORBA::string_dup("Logger"); - PortableServer::POAManager_var pman; - for(int i = 1; i <= NumberOfTries; i++){ - if(i != 1) - a=nanosleep(&ts_req,&ts_rem); - try{ - obj = orb->resolve_initial_references("RootPOA"); - if(!CORBA::is_nil(obj)) - root_poa = PortableServer::POA::_narrow(obj); - if(!CORBA::is_nil(root_poa)) - pman = root_poa->the_POAManager(); - if(!CORBA::is_nil(orb)) - theObj = orb->resolve_initial_references("NameService"); - if (!CORBA::is_nil(theObj)) - inc = CosNaming::NamingContext::_narrow(theObj); - }catch(CORBA::SystemException&){ - MESSAGE( "Container: CORBA::SystemException: Unable to contact the Naming Service" ); - } - if(!CORBA::is_nil(inc)){ - MESSAGE( "Container: Naming Service was found" ); - if(EnvL == 1){ - for(int j = 1; j <= NumberOfTries; j++){ - if(j != 1) - a=nanosleep(&ts_req, &ts_rem); - try{ - object = inc->resolve(name); - }catch(CosNaming::NamingContext::NotFound){ - MESSAGE( "Container: Logger Server wasn't found" ); - }catch(...){ - MESSAGE( "Container: Unknown exception" ); - } - if(!CORBA::is_nil(object)){ - MESSAGE( "Container: Logger Server was found" ); - CONTAINER = 1; - break; - } - } - } - } - if(CONTAINER == 1 || (EnvL == 0 && !CORBA::is_nil(inc))) - break; - } - char *containerName = ""; - if(argc > 1){ + char *containerName = ""; + if(argc > 1) + { containerName = argv[1] ; } - // add new container to the kill list - char aCommand[40]; - sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid()); - system(aCommand); - - Engines_Container_i * myContainer - = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + try + { + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + ASSERT(!CORBA::is_nil(obj)); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); - pman->activate(); - + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + + // add new container to the kill list + char aCommand[40]; + sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid()); + system(aCommand); + + Engines_Container_i * myContainer + = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + + pman->activate(); + #ifdef CHECKTIME - Utils_Timer timer; - timer.Start(); - timer.Stop(); - MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); - timer.ShowAbsolute(); + Utils_Timer timer; + timer.Start(); + timer.Stop(); + MESSAGE("SALOME_Registry_Server.cxx - orb->run()"); + timer.ShowAbsolute(); #endif - - HandleServerSideSignals(orb); - }catch(CORBA::SystemException&){ - INFOS("Caught CORBA::SystemException."); - }catch(PortableServer::POA::WrongPolicy&){ - INFOS("Caught CORBA::WrongPolicyException."); - }catch(PortableServer::POA::ServantAlreadyActive&){ - INFOS("Caught CORBA::ServantAlreadyActiveException"); - }catch(CORBA::Exception&){ - INFOS("Caught CORBA::Exception."); - }catch(std::exception& exc){ - INFOS("Caught std::exception - "<the_POAManager(); @@ -27,15 +28,18 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb) CORBA::Object_var obj=my_poa->id_to_reference(id); Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj); _NS->Register(refContMan,_ContainerManagerNameInNS); + MESSAGE("constructor end"); } SALOME_ContainerManager::~SALOME_ContainerManager() { + MESSAGE("destructor"); delete _NS; } void SALOME_ContainerManager::Shutdown() { + MESSAGE("Shutdown"); ShutdownContainers(); PortableServer::ObjectId_var oid = _default_POA()->servant_to_id(this); _default_POA()->deactivate_object(oid); @@ -45,6 +49,7 @@ void SALOME_ContainerManager::Shutdown() void SALOME_ContainerManager::ShutdownContainers() { + MESSAGE("ShutdownContainers"); _NS->Change_Directory("/Containers"); vector vec=_NS->list_directory_recurs(); for(vector::iterator iter=vec.begin();iter!=vec.end();iter++) @@ -59,18 +64,20 @@ void SALOME_ContainerManager::ShutdownContainers() Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char *containerName, const Engines::MachineList& possibleComputers) { + MESSAGE("FindOrStartContainer "< vector; string theMachine=_LoadManager.FindBest(possibleComputers); + SCRUTE(theMachine); string command; if(theMachine==GetHostname()) command=_ResManager.BuildCommandToLaunchLocalContainer(containerName); else command=_ResManager.BuildTempFileToLaunchRemoteContainer(theMachine,containerName); - _ResManager.RmTmpFile(); + //_ResManager.RmTmpFile(); int status=system(command.c_str()); if (status == -1) { MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)"); @@ -101,8 +108,10 @@ Engines::Container_ptr SALOME_ContainerManager::FindOrStartContainer(const char Engines::MachineList *SALOME_ContainerManager::GetFittingResources(const Engines::MachineParameters& params, const char *componentName) { + MESSAGE("GetFittingResources"); vector vec=_ResManager.GetFittingResources(params,componentName); Engines::MachineList *ret=new Engines::MachineList; + MESSAGE("Machine list length "<length(vec.size()); for(unsigned int i=0;iResolve(containerNameInNS.c_str()); @@ -130,8 +141,10 @@ Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *contai Engines::Container_ptr SALOME_ContainerManager::FindContainer(const char *containerName,const Engines::MachineList& possibleComputers) { + MESSAGE("FindContainer "<resolve_initial_references("RootPOA"); if(!CORBA::is_nil(obj)) @@ -35,5 +39,7 @@ int main(int argc, char* argv[]) }catch(...){ MESSAGE("Caught unknown exception."); } + END_OF(argv[0]); + delete myThreadTrace; } diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in index 3b825582f..b23e0d50a 100644 --- a/src/LifeCycleCORBA/Makefile.in +++ b/src/LifeCycleCORBA/Makefile.in @@ -36,7 +36,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS = SALOME_LifeCycleCORBA.hxx -EXPORT_PYSCRIPTS = LifeCycleCORBA.py Launchers.py +EXPORT_PYSCRIPTS = Launchers.py # Libraries targets diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 1af1f64e6..aa199fc76 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -52,7 +52,15 @@ using namespace std; SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) { - _NS = ns; + if (!ns) + { + int argc = 0; + char *xargv = ""; + char **argv = &xargv; + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + _NS = new SALOME_NamingService(orb); + } + else _NS = ns; //add try catch _NS->Change_Directory("/"); // mpv 250105: current directory may be not root // (in SALOMEDS for an example) @@ -99,7 +107,7 @@ SALOME_LifeCycleCORBA::FindContainer(const char *containerName) { // Compatibility ... string theComputer ; string theContainer ; - cont = ContainerName( containerName , &theComputer , &theContainer ) ; + cont = _ContainerName( containerName , &theComputer , &theContainer ) ; } else { @@ -142,7 +150,13 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, int studyId, const char *instanceName) { - ASSERT(0); + if (! isKnownComponentClass(componentName)) + return Engines::Component::_nil(); + Engines::MachineList_var listOfMachine = + _ContManager->GetFittingResources(params,componentName); + Engines::Component_var compo = + _FindComponent(params.container_name,componentName,listOfMachine); + return compo._retn(); } //============================================================================= @@ -160,13 +174,29 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, const char *componentName, int studyId) { - ASSERT(0); + if (! isKnownComponentClass(componentName)) + return Engines::Component::_nil(); + + Engines::MachineList_var listOfMachine = + _ContManager->GetFittingResources(params,componentName); + + Engines::Container_var cont = + _ContManager->FindOrStartContainer(params.container_name, + listOfMachine); + if (CORBA::is_nil(cont)) return Engines::Component::_nil(); + + bool isLoadable = cont->load_component_Library(componentName); + if (!isLoadable) return Engines::Component::_nil(); + + Engines::Component_var myInstance = + cont->create_component_instance(componentName, 0); + return myInstance._retn(); } //============================================================================= /*! Public - * Find and aready existing and registered component instance or load a new - * component instance on a container defined by machine parameters + * component instance on a container defined by machine parameters. * \param params machine parameters like type or name... * \param componentName the name of component class * \param studyId default = 0 : multistudy instance @@ -185,12 +215,12 @@ FindOrLoad_Component(const Engines::MachineParameters& params, Engines::MachineList_var listOfMachine = _ContManager->GetFittingResources(params,componentName); - Engines::Component_ptr ret= - FindComponent(params.container_name,componentName,listOfMachine); - if(CORBA::is_nil(ret)) - return LoadComponent(params.container_name,componentName,listOfMachine); + Engines::Component_var compo= + _FindComponent(params.container_name,componentName,listOfMachine); + if(CORBA::is_nil(compo)) + return _LoadComponent(params.container_name,componentName,listOfMachine); else - return ret; + return compo._retn(); } //============================================================================= @@ -201,7 +231,7 @@ FindOrLoad_Component(const Engines::MachineParameters& params, * - 1 localhost/aContainer * - 2 aContainer * - 3 /machine/aContainer - * (not the same rules as FindContainer() method base on protected method + * (not the same rules as FindContainer() method based on protected method * ContainerName() -- MUST BE CORRECTED --) * \param componentName the name of component class * \return a CORBA reference of the component instance, or _nil if problem @@ -222,10 +252,10 @@ SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName, stContainer[rg]='\0'; if(strcmp(stContainer,"localhost")==0) { - Engines::Component_ptr ret=FindOrLoad_Component(stContainer+rg+1, - componentName); + Engines::Component_var compo = FindOrLoad_Component(stContainer+rg+1, + componentName); free(stContainer); - return ret; + return compo._retn(); } else ASSERT(0); // no return in that case... } @@ -236,13 +266,13 @@ SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName, Engines::MachineList_var listOfMachine=new Engines::MachineList; listOfMachine->length(1); listOfMachine[0]=CORBA::string_dup(GetHostname().c_str()); - Engines::Component_ptr ret = FindComponent(containerName, - componentName, - listOfMachine.in()); - if(CORBA::is_nil(ret)) - return LoadComponent(containerName,componentName,listOfMachine); + Engines::Component_var compo = _FindComponent(containerName, + componentName, + listOfMachine.in()); + if(CORBA::is_nil(compo)) + return _LoadComponent(containerName,componentName,listOfMachine); else - return ret; + return compo._retn(); } else { @@ -295,16 +325,25 @@ bool SALOME_LifeCycleCORBA::isKnownComponentClass(const char *componentName) //============================================================================= /*! Protected - - * + * Find and aready existing and registered component instance. + * \param containerName the name of container, or empty string + * (now, default Container Name used = FactoryServer) + * \param componentName the name of component class + * \param listOfMachines list of machine address + * \return a CORBA reference of the component instance, or _nil if not found + * - if containerName given, creates a sublist of the machine list, where + * machine/ContainerName/ComponentName exists. then chooses the best machine. + * - if no containerName given, choose first the best machine, then tries + * machine/ContainerName/ComponentName, where ContainerName = FactoryServer */ //============================================================================= Engines::Component_ptr -SALOME_LifeCycleCORBA::FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines) +SALOME_LifeCycleCORBA::_FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines) { - if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); + if (!isKnownComponentClass(componentName)) return Engines::Component::_nil(); if(containerName[0]!='\0') { Engines::MachineList_var machinesOK=new Engines::MachineList; @@ -358,39 +397,48 @@ SALOME_LifeCycleCORBA::FindComponent(const char *containerName, //============================================================================= /*! Protected - - * + * Load a component instance. + * \param containerName the name of container (no default name) + * \param componentName the name of component class + * \param listOfMachines list of machine address + * \return a CORBA reference of the component instance, or _nil if problem + * - uses the first container (of given name) found in the machines list. + * - if no container found, tries to launch one one the best machine of the + * list. + * Then, find or loads a component instance on the choosen container. */ //============================================================================= Engines::Component_ptr -SALOME_LifeCycleCORBA::LoadComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines) +SALOME_LifeCycleCORBA::_LoadComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines) { - Engines::Container_var cont=_ContManager->FindOrStartContainer(containerName, - listOfMachines); - //string implementation=Engines_Component_i::GetDynLibraryName(componentName); - //return cont->load_impl(componentName, implementation.c_str()); - return cont->load_impl(componentName,""); + Engines::Container_var cont = + _ContManager->FindOrStartContainer(containerName, + listOfMachines); + if (!CORBA::is_nil(cont)) return cont->load_impl(componentName,""); + else return Engines::Component::_nil(); } //============================================================================= /*! Protected - - * + * Alternate Container Launcher, without container manager... */ //============================================================================= Engines::Container_ptr -SALOME_LifeCycleCORBA::FindOrStartContainer(const string aComputerContainer , - const string theComputer , - const string theContainer ) +SALOME_LifeCycleCORBA::_FindOrStartContainer(const string aComputerContainer , + const string theComputer , + const string theContainer ) { SCRUTE( aComputerContainer ) ; SCRUTE( theComputer ) ; SCRUTE( theContainer ) ; - Engines::Container_var aContainer = FindContainer(aComputerContainer.c_str()); + Engines::Container_var aContainer = + FindContainer(aComputerContainer.c_str()); if ( !CORBA::is_nil( aContainer ) ) { @@ -444,9 +492,9 @@ SALOME_LifeCycleCORBA::FindOrStartContainer(const string aComputerContainer , * \param aComputerContainer container name under one of the forms: * - 1 aContainer * - 2 machine/aContainer - * \param theComputer return computer name: + * \param theComputer return computer name (machine): * - 1 machine = GetHostname() - * - 2 machine (localhost replaced by GetHostName()) + * - 2 machine = as given (localhost replaced by GetHostName()) * \param theContainer return container name: * - 1 aContainer * - 2 aContainer @@ -454,9 +502,9 @@ SALOME_LifeCycleCORBA::FindOrStartContainer(const string aComputerContainer , */ //============================================================================= -string SALOME_LifeCycleCORBA::ContainerName(const char *aComputerContainer , - string * theComputer , - string * theContainer ) +string SALOME_LifeCycleCORBA::_ContainerName(const char *aComputerContainer , + string * theComputer , + string * theContainer ) { char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; strcpy( ContainerName , aComputerContainer ) ; @@ -498,7 +546,7 @@ string SALOME_LifeCycleCORBA::ContainerName(const char *aComputerContainer , */ //============================================================================= -string SALOME_LifeCycleCORBA::ComputerPath(const char * theComputer ) +string SALOME_LifeCycleCORBA::_ComputerPath(const char * theComputer ) { CORBA::String_var path; CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index fc4e9d479..859543a1e 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -42,7 +42,7 @@ class SALOME_NamingService; class SALOME_LifeCycleCORBA { public: - SALOME_LifeCycleCORBA(SALOME_NamingService *ns); + SALOME_LifeCycleCORBA(SALOME_NamingService *ns = 0); virtual ~SALOME_LifeCycleCORBA(); Engines::Container_ptr @@ -62,7 +62,7 @@ public: Engines::Component_ptr FindOrLoad_Component(const Engines::MachineParameters& params, const char *componentName, - int studyId=0); + int studyId =0); Engines::Component_ptr FindOrLoad_Component(const char *containerName, @@ -78,29 +78,29 @@ protected: * This method uses Naming Service to find the component. */ Engines::Component_ptr - FindComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines); + _FindComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); Engines::Component_ptr - LoadComponent(const char *containerName, - const char *componentName, - const Engines::MachineList& listOfMachines); + _LoadComponent(const char *containerName, + const char *componentName, + const Engines::MachineList& listOfMachines); SALOME_NamingService *_NS; Engines::ContainerManager_var _ContManager; //private: - std::string ContainerName( const char * aComputerContainer , - std::string * theComputer , - std::string * theContainer ) ; - std::string ComputerPath( const char * theComputer ) ; + std::string _ContainerName( const char * aComputerContainer , + std::string * theComputer , + std::string * theContainer ) ; + std::string _ComputerPath( const char * theComputer ) ; Engines::Container_ptr - FindOrStartContainer(const std::string aComputerContainer , - const std::string theComputer , - const std::string theContainer ) ; + _FindOrStartContainer(const std::string aComputerContainer , + const std::string theComputer , + const std::string theContainer ) ; } ; #endif diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py new file mode 100644 index 000000000..f88ef8722 --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -0,0 +1,41 @@ +# SALOME LifeCycleCORBA : implementation of containers and engines life cycle both in Python and C++ +# +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : LifeCycleCORBA.py +# Author : Paul RASCLE, EDF +# Module : SALOME +# $Header$ + + +import Engines +from libSALOME_LifeCycleCORBA import * + +class LifeCycleCORBA (SALOME_LifeCycleCORBA): + + def __init__(self, orb = None): + SALOME_LifeCycleCORBA.__init__(self) + + def FindOrLoadComponent(self, containerName, componentName): + return SALOME_LifeCycleCORBA.FindOrLoad_Component(self, + containerName, + componentName) diff --git a/src/LifeCycleCORBA_SWIG/Makefile.in b/src/LifeCycleCORBA_SWIG/Makefile.in new file mode 100644 index 000000000..48fa79e78 --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/Makefile.in @@ -0,0 +1,52 @@ +# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE, EDF +# Module : SALOME +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libSALOME_LifeCycleCORBAcmodule.la +LIB_SRC = + +LIB_CLIENT_IDL = SALOME_Component.idl SALOME_ContainerManager.idl + +SWIG_DEF = libSALOME_LifeCycleCORBA.i + +EXPORT_PYSCRIPTS = libSALOME_LifeCycleCORBA.py LifeCycleCORBA.py TestLifeCycleCORBA.py + +CPPFLAGS+= $(PYTHON_INCLUDES) + +LIBS+= $(PYTHON_LIBS) -lSalomeLifeCycleCORBA + +LDFLAGS+= -lSalomeLifeCycleCORBA + +@CONCLUDE@ diff --git a/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py new file mode 100644 index 000000000..479bc930a --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/TestLifeCycleCORBA.py @@ -0,0 +1,18 @@ + +import Engines +import LifeCycleCORBA + +lcc = LifeCycleCORBA.LifeCycleCORBA() + +#obj=lcc.FindOrLoad_Component("FactoryServer","SalomeTestComponent") +#comp=obj._narrow(Engines.TestComponent) +#comp.Coucou(1) + +param={} +param['hostname']='cli76ce' +param['container_name']='myContainer' +smesh=lcc.FindOrLoad_Component(param,'SMESH') + +container=lcc.FindContainer('myContainer') +engine=lcc.FindComponent(param,'SMESH') +geom=lcc.LoadComponent(param,'GEOM') diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i new file mode 100644 index 000000000..b0cedeb17 --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -0,0 +1,104 @@ + + +%module libSALOME_LifeCycleCORBA + +%{ +#include "utilities.h" +#include "SALOME_LifeCycleCORBA.hxx" + + using namespace std; +%} + +%typemap(python,out) Engines::Container_ptr, Engines::Component_ptr +{ + MESSAGE("typemap out on CORBA object ptr"); + SCRUTE($1); + + // --- Get the Python orb + + PyObject* pdict = PyDict_New(); + PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); + PyRun_String("import CORBA", Py_single_input, pdict, pdict); + PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, + pdict, pdict); + PyObject* orb = PyDict_GetItemString(pdict, "o"); + + // --- Get the C++ orb + + int argc = 0; + char *xargv = ""; + char **argv = &xargv; + CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + string s = ORB->object_to_string($1); + SCRUTE(s); + PyObject * tmp = PyString_FromString(s.c_str()); + SCRUTE(tmp); + $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp); + SCRUTE($result); +} + + +%typemap(typecheck) const Engines::MachineParameters & +{ + $1 = ($input != 0); +} + +%typemap(python,in) const Engines::MachineParameters & +{ + printf("typemap in on Engines::MachineParameters\n"); + //MESSAGE("typemap in on Engines::MachineParameters"); + //ASSERT (PyDict_Check($input)) + if (PyDict_Check($input) == 1) + { + Engines::MachineParameters *param = new Engines::MachineParameters ; + PyObject *key, *value; + int pos = 0; + while (PyDict_Next($input, &pos, &key, &value)) + { + char* keystr = PyString_AsString(key); + printf("key: %s\n", keystr); + if (strcmp(keystr,"container_name")==0) + { + param->container_name = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"hostname")==0) + { + param->hostname = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"OS")==0) + { + param->OS = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"mem_mb")==0) + { + param->mem_mb = PyLong_AsLong(value); + } + else if (strcmp(keystr,"cpu_clock")==0) + { + param->cpu_clock = PyLong_AsLong(value); + } + else if (strcmp(keystr,"nb_proc_per_node")==0) + { + param->nb_proc_per_node = PyLong_AsLong(value); + } + else if (strcmp(keystr,"nb_node")==0) + { + param->nb_node = PyLong_AsLong(value); + } + } + $1 = param; + } + else + { + printf("pas un dico\n"); + return NULL; + } +} + +%typemap(python,freearg) const Engines::MachineParameters & +{ + MESSAGE("delete $1"); + delete $1; +} + +%include "SALOME_LifeCycleCORBA.hxx" diff --git a/src/Makefile.in b/src/Makefile.in index 4f4a247e7..76cd1ae3e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -36,7 +36,7 @@ SUBDIRS = SALOMELocalTrace SALOMETraceCollector Logger Utils \ CASCatch GenericObj MEDWrapper NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ ResourcesManager Notification NOTIFICATION_SWIG \ - Container TestContainer LifeCycleCORBA HDFPersist \ + Container TestContainer LifeCycleCORBA LifeCycleCORBA_SWIG HDFPersist \ SALOMEDSClient TOOLSDS SALOMEDSImpl SALOMEDS KERNEL_PY \ ModuleGenerator Communication diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index f39bb93e1..896294107 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -69,7 +69,8 @@ SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb) SALOME_NamingService::~SALOME_NamingService() { - MESSAGE("SALOME_NamingService destruction"); + // Problem MESSAGE with singleton: late destruction, after trace system destruction ? + //MESSAGE("SALOME_NamingService destruction"); } //----------------------------------------------------------------------